Execute();
//End Restrict Access To Page
if (isset($_POST['submit_ftp'])) {
$_POST['file_ftp'] = basename($_POST['file_ftp']);
}
//start Trigger_Custom trigger
function Trigger_Custom(&$tNG) {
$filename_ftp = 'files_ftp/'.$_POST['file_ftp'];
if (file_exists($filename_ftp)) {
//rename($filename_ftp, "files/".$tNG->GetColumnValue('ID_file')."_".$_SESSION['kt_key']);
copy($filename_ftp, "files/".$_POST['ID_order']."_".$tNG->GetColumnValue('ID_file')."_".$_SESSION['kt_key']);
unlink($filename_ftp);
} else {
$myErrorObjectName = new tNG_error("Il nome del file indicato non è presente nello spazio FTP.", array(), array());
return $myErrorObjectName;
}
}
//end Trigger_Custom trigger
// Start trigger
$formValidation = new tNG_FormValidation();
$formValidation->addField("filename", true, "text", "", "", "", "");
$tNGs->prepareValidation($formValidation);
// End trigger
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Rs_orders = 5;
$pageNum_Rs_orders = 0;
if (isset($_GET['pageNum_Rs_orders'])) {
$pageNum_Rs_orders = $_GET['pageNum_Rs_orders'];
}
$startRow_Rs_orders = $pageNum_Rs_orders * $maxRows_Rs_orders;
$KTColParam1_Rs_orders = "0";
if (isset($_SESSION["kt_login_id"])) {
$KTColParam1_Rs_orders = $_SESSION["kt_login_id"];
}
mysql_select_db($database_azzurra, $azzurra);
$query_Rs_orders = sprintf("SELECT orders.ID_order, orders.descr, orders.data, states.state_desc FROM (orders LEFT JOIN states ON states.ID_state=orders.ID_state) WHERE orders.ID_user=%s ORDER BY orders.ID_order DESC ", GetSQLValueString($KTColParam1_Rs_orders, "int"));
$query_limit_Rs_orders = sprintf("%s LIMIT %d, %d", $query_Rs_orders, $startRow_Rs_orders, $maxRows_Rs_orders);
$Rs_orders = mysql_query($query_limit_Rs_orders, $azzurra) or die(mysql_error());
$row_Rs_orders = mysql_fetch_assoc($Rs_orders);
if (isset($_GET['totalRows_Rs_orders'])) {
$totalRows_Rs_orders = $_GET['totalRows_Rs_orders'];
} else {
$all_Rs_orders = mysql_query($query_Rs_orders);
$totalRows_Rs_orders = mysql_num_rows($all_Rs_orders);
}
$totalPages_Rs_orders = ceil($totalRows_Rs_orders/$maxRows_Rs_orders)-1;
$queryString_Rs_orders = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Rs_orders") == false &&
stristr($param, "totalRows_Rs_orders") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Rs_orders = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Rs_orders = sprintf("&totalRows_Rs_orders=%d%s", $totalRows_Rs_orders, $queryString_Rs_orders);
// Make an insert transaction instance
$ins_files1 = new tNG_insert($conn_azzurra);
$tNGs->addTransaction($ins_files1);
// Register triggers
$ins_files1->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "submit_ftp");
$ins_files1->registerTrigger("END", "Trigger_Default_Redirect", 99, "area_files.php?ID_order={POST.ID_order}&ID_user={GET.ID_user}");
$ins_files1->registerTrigger("AFTER", "Trigger_Custom", 50);
$ins_files1->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
// Add columns
$ins_files1->setTable("files");
$ins_files1->addColumn("ID_order", "NUMERIC_TYPE", "POST", "ID_order");
$ins_files1->addColumn("filename", "STRING_TYPE", "POST", "file_ftp", "");
$ins_files1->addColumn("descr", "STRING_TYPE", "POST", "desc_ftp", "");
$ins_files1->addColumn("ID_user", "NUMERIC_TYPE", "SESSION", "kt_login_id", "");
$ins_files1->setPrimaryKey("ID_file", "NUMERIC_TYPE");
// Execute all the registered transactions
$tNGs->executeTransactions();
// Get the transaction recordset
$rsfiles = $tNGs->getRecordset("files");
$row_rsfiles = mysql_fetch_assoc($rsfiles);
$totalRows_rsfiles = mysql_num_rows($rsfiles);
?>
Azzurra Print | Tipografia - Litografia - Digital Print - Serigrafia
displayValidationRules();?>
getErrorMsg();
?>