$query_check = "SELECT COUNT(*) FROM FattureAcquisti WHERE Fornitori_idFornitori = '" . $idForn . "' AND NumFattVendor='" . $invoice . "'"; $result_check = mysqli_query($mysqli, $query_check) or die("Error" . mysql_error()); $row_check = $result_check->fetch_assoc(); if ($row_check['COUNT(*)'] != 0) { $status = 'no_duplicate'; } else { if (isset($_FILES['pdfinv']) and $userfile_in_size != "" and TRIM($userfile_in_tmp) != "" and $_FILES['pdfinv']['error'] == UPLOAD_ERR_OK and is_uploaded_file($userfile_in_tmp)) { // Extension of invoice file $estensione = strtolower(substr($userfile_in_name, strrpos($userfile_in_name, "."), strlen($userfile_in_name) - strrpos($userfile_in_name, "."))); $annocorrente = date("Y"); if ($estensione == '.pdf') { if (is_dir("../invoices/{$annocorrente}") == TRUE) { // Nothing } else { // Create the folder Mkdir("../invoices/{$annocorrente}", 0777); } // Select the Vendor Name from DB $query1 = "SELECT NomeFornitore FROM Fornitori WHERE idFornitori = '" . $idForn . "'"; $rq1 = mysqli_query($mysqli, $query1) or die("Errore nella query. Query non eseguita 1 " . mysql_error()); $row1 = $result->fetch_assoc(); // Filter the Name of Manufacturer $find = array('/[^A-Za-z0-9- ]/', '!\\s+!', '/[ ]/', '/-{2,}/'); $replace = array('', ' ', '-', '-'); $nomeForn = strtolower(preg_replace($find, $replace, stripcslashes(trim($row1['NomeFornitore'])))); // Create the name of invoice: VendorName_daymonthyear.pdf $invoiceName = $nomeForn . "_" . date('d-m-Y', strtotime($date)) . $estensione; move_uploaded_file($userfile_in_tmp, "../invoices/{$annocorrente}/" . $invoiceName); $urlinvoice = "invoices/{$annocorrente}/{$invoiceName}"; if (isset($_POST['reg_invoice_date']) and !empty($_POST['reg_invoice_date']) and isset($_POST['reg_invoice_number']) and !empty($_POST['reg_invoice_number'])) { $reg_invoice_date = $_POST['reg_invoice_date'];
$val .= "'" . str_db($_POST['admin_email']) . "',"; $val .= "'" . replaceSpecial($_POST['result_message']) . "',"; $val .= "'" . date('Y-m-d') . "',"; $val .= "'" . replaceSpecial($_POST['quiz_content']) . "',"; $val .= "'" . replaceSpecial($_POST['cont_error']) . "',"; $val .= "'" . $visible . "',"; $val .= "'" . str_db($_POST['min_answer']) . "',"; $val .= "'" . $status . "'"; $sql = " insert into quizzes ("; $sql .= $record; $sql .= ") VALUES ("; $sql .= $val; $sql .= ")"; execute($sql); $last_id = mysql_insert_id(); Mkdir(path_stored_quizzes . '/' . $last_id, 0755, true); copy(path_rel_sfw . '/get_code.php', path_stored_quizzes . '/' . $last_id . '/' . $rand_cod . '.php'); replace_line_in_file(path_stored_quizzes . '/' . $last_id . '/' . $rand_cod . '.php', "{include}", "require_once('" . path_rel_sfw . "/include/inc_db.php');"); replace_line_in_file(path_stored_quizzes . '/' . $last_id . '/' . $rand_cod . '.php', "{sql_replace}", "\$" . "sqli = 'select * from quizzes where code = \"" . $rand_cod . "\"';"); /*******************************************************************/ foreach ($_POST as $key => $val) { if (substr($key, 0, 9) == 'question_') { $record = 'id_quiz,questions'; $valu = "'" . str_db($last_id) . "',"; $valu .= "'" . str_db($val) . "'"; $sql = " insert into questions ("; $sql .= $record; $sql .= ") VALUES ("; $sql .= $valu; $sql .= ")"; execute($sql);
/** * crea le cartelle necessarie per lo storage delle foto * @param owner: nickname del proprietario * @param fname: nome dell'imamgine * @return: percorso per il savataggio delle immagini per l'utente richiedente */ function createUserDirectory($owner, $fname) { if (file_exists(UP_DIR . "uploads/{$owner}")) { if (file_exists(UP_DIR . "uploads/{$owner}/" . date("dmy"))) { $path = self::generatePath($owner, $fname); } else { Mkdir(UP_DIR . "uploads/{$owner}/" . date("dmy"), 0777); $path = self::generatePath($owner, $fname); } } else { Mkdir(UP_DIR . "uploads/{$owner}", 0777); Mkdir(UP_DIR . "uploads/{$owner}/" . date("dmy"), 0777); $path = self::generatePath($owner, $fname); } return $path; }
/** * crea le cartelle necessarie per lo storage delle foto * @owner: nickname del proprietario * @fname: nome dell'imamgine * @return: percorso per il savataggio delle immagini per l'utente richiedente */ function createUserDirectory($owner, $fname) { $UP_DIR = $_SERVER["DOCUMENT_ROOT"] . "/IoEsisto/v02"; if (file_exists("{$UP_DIR}/uploads/{$owner}")) { /*DEBUG*/ echo "</br>la cartella {$owner} esiste</br>"; if (file_exists("{$UP_DIR}/uploads/{$owner}/" . date("dmy"))) { /*DEBUG*/ echo "</br>la cartella" . date("dmy") . " esiste</br>"; $path = self::generatePath($owner, $fname); } else { /*DEBUG*/ echo "</br>la cartella" . date("dmy") . " NON esiste</br>"; Mkdir("{$UP_DIR}/uploads/{$owner}/" . date("dmy"), 0777); $path = self::generatePath($owner, $fname); } } else { /*DEBUG*/ echo "</br>la cartella {$owner} NON esiste</br>"; Mkdir("{$UP_DIR}/uploads/{$owner}", 0777); Mkdir("{$UP_DIR}/uploads/{$owner}/" . date("dmy"), 0777); $path = self::generatePath($owner, $fname); } return $path; }
// 2 - Create the folder and insert the image // Filter Category and Subcategory name to make folder $find = array('/[^A-Za-z0-9- ]/', '!\\s+!', '/[ ]/', '/-{2,}/'); $replace = array('', ' ', '-', '-'); $category_photo = strtolower(preg_replace($find, $replace, stripcslashes($category))); $subCategory_photo = strtolower(preg_replace($find, $replace, stripcslashes($subCategory))); // Check extension if ($estensione_photo == '.jpg' or $estensione_photo == '.png' or $estensione_photo == '.gif') { if (is_dir("photos/{$category_photo}/{$subCategory_photo}") == TRUE) { // Nothing } else { if (is_dir("photos/{$category_photo}") == TRUE) { Mkdir("photos/{$category_photo}/{$subCategory_photo}", 0777); } else { Mkdir("photos/{$category_photo}", 0777); Mkdir("photos/{$category}/{$subCategory_photo}", 0777); } } // Create the image name Filtered $photoName = preg_replace($find, $replace, stripcslashes($ManuPartNo)); // Catch the image with cURL // cURL doesn't love SPACE in URL. Replace it with '%20' $ImagePath = str_replace(' ', '%20', $ImagePath); $ch = curl_init($ImagePath); $photoDest = "photos/{$category_photo}/{$subCategory_photo}/" . $photoName . $estensione_photo; $fp = fopen($photoDest, 'wb'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp);
static function Mkdir($utf8_path, $mode) { return Mkdir($utf8_path, $mode); }
$row3 = $rquery3->fetch_assoc(); // Filter Category and Subcategory name to make folder $find = array('/[^A-Za-z0-9- ]/', '!\\s+!', '/[ ]/', '/-{2,}/'); $replace = array('', ' ', '-', '-'); $category_doc = strtolower(preg_replace($find, $replace, stripcslashes(trim($row3['NomeCategoria'])))); $subCategory_doc = strtolower(preg_replace($find, $replace, stripcslashes(trim($row3['NomeSottoCategoria'])))); $estensione_file = strtolower(substr($userfile_ds_name, strrpos($userfile_ds_name, "."), strlen($userfile_ds_name) - strrpos($userfile_ds_name, "."))); if ($estensione_file == '.zip' or $estensione_file == '.pdf' or $estensione_file == '.stp' or $estensione_file == '.bxl' or $estensione_file == '.doc' or $estensione_file == '.odt') { if (is_dir("documents/{$category_doc}/{$subCategory_doc}") == TRUE) { // Nothing } else { if (is_dir("documents/{$category_doc}") == TRUE) { Mkdir("documents/{$category_doc}/{$subCategory_doc}", 0777); } else { Mkdir("documents/{$category_doc}", 0777); Mkdir("documents/{$category_doc}/{$subCategory_doc}", 0777); } } $DocNameFile = preg_replace($find, $replace, stripcslashes($nomeDocu)); $urlfile = "documents/{$category_doc}/{$subCategory_doc}/" . $DocNameFile . $estensione_file; $query9 = "SELECT URLLink FROM Documenti WHERE URLLink = '" . $urlfile . "'"; $rquery9 = mysqli_query($mysqli, $query9) or die("500 Internal Error"); $numrow = $rquery9->num_rows; if ($numrow > 0) { $urlfile = "documents/{$category_doc}/{$subCategory_doc}/" . $DocNameFile . "_" . $numrow . $estensione_file; } move_uploaded_file($userfile_ds_tmp, $urlfile); // Insert the document in DB $query6 = "INSERT INTO Documenti (Titolo, URLLink, DataInserimento, Descrizione, SizeKB, Type) VALUES ('" . $nomeDocu . "', '" . $urlfile . "', CURRENT_TIMESTAMP, '" . $descDocu . "', '" . $userfile_ds_size / 1024 . "', '" . strtoupper(substr($estensione_file, 1)) . "')"; mysqli_query($mysqli, $query6) or die("500 Internal Error"); // ID of new documents
<?php /*------------------------------------------------------------------------ # mod_jcode - JCode # ------------------------------------------------------------------------ # Iacopo Guarneri # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.the-html-tool.com -------------------------------------------------------------------------*/ // no direct access defined('_JEXEC') or die('Restricted access'); if (!file_exists("components/com_jcode/source")) { Mkdir("components/com_jcode/source", 0775); $handle = fopen("components/com_jcode/source/index.html", 'w'); fwrite($handle, ""); fclose($handle); } $txt = stripslashes($_POST['txt']); $txt = str_replace("[e_commerciale]", "&", $txt); $txt = str_replace("[piu]", "+", $txt); $file = "components/com_jcode/source/" . $_POST['title']; $handle = fopen($file, 'w'); fwrite($handle, $txt); fclose($handle);
// Filter Category and Subcategory name to make folder $find = array('/[^A-Za-z0-9- ]/', '!\\s+!', '/[ ]/', '/-{2,}/'); $replace = array('', ' ', '-', '-'); $nomeCategoria_docu = strtolower(preg_replace($find, $replace, stripcslashes(trim($row_docu_cat['NomeCategoria'])))); $nomeSottoCategoria_docu = strtolower(preg_replace($find, $replace, stripcslashes(trim($row_docu_cat['NomeSottoCategoria'])))); // File extension $estensione_file = strtolower(substr($userfile_ds_name, strrpos($userfile_ds_name, "."), strlen($userfile_ds_name) - strrpos($userfile_ds_name, "."))); if ($estensione_file == '.zip' or $estensione_file == '.pdf' or $estensione_file == '.stp' or $estensione_file == '.bxl' or $estensione_file == '.doc' or $estensione_file == '.odt') { if (is_dir("documents/{$nomeCategoria_docu}/{$nomeSottoCategoria_docu}") == TRUE) { // Nothing } else { if (is_dir("documents/{$nomeCategoria_docu}") == TRUE) { Mkdir("documents/{$nomeCategoria_docu}/{$nomeSottoCategoria_docu}", 0777); } else { Mkdir("documents/{$nomeCategoria_docu}", 0777); Mkdir("documents/{$nomeCategoria_docu}/{$nomeSottoCategoria_docu}", 0777); } } // Clean document filename $DocNameFile = preg_replace($find, $replace, stripcslashes($DocName)); //Inserisco la foto rinominata nella cartella $urlfile = "documents/{$nomeCategoria_docu}/{$nomeSottoCategoria_docu}/" . $DocNameFile . $estensione_file; // Check in DB for documents with same URL $query_docu_check_url = "SELECT URLLink FROM Documenti WHERE URLLink = '" . $urlfile . "'"; $result_docu_check_url = mysqli_query($mysqli, $query_docu_check_url) or die("500 Internal Error"); $numrow_docu = $result_docu_check_url->num_rows; if ($numrow_docu > 0) { $urlfile = "documents/{$nomeCategoria_docu}/{$nomeSottoCategoria_docu}/" . $DocNameFile . "_" . $numrow_docu . $estensione_file; } move_uploaded_file($userfile_ds_tmp, $urlfile); // Id of Product just Inserted