function resolveBuletine() { define("FOLDER_BULETINE_VECHI", "uploads/buletine-vechi/"); define("FOLDER_BULETINE", "uploads/buletine/"); define("FOLDER_IMAGINI_BULETINE", "uploads/imagini-buletine/"); echo "\\Buletine\n"; if ($handle = opendir(FOLDER_BULETINE_VECHI)) { $dirFiles = array(); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $dirFiles[] = $file; } } sort($dirFiles); // Start date = '2006-08-27'; $i = 0; foreach ($dirFiles as $file) { echo "{$file}\n"; $buletinNumar = intval(substr($file, -7, -4)); $fileSize = filesize(FOLDER_BULETINE_VECHI . $file) / 1024 / 1024; $calculatedTime = mktime(0, 0, 0, 8, 27 + $i * 7, 2006); $fileDate = date("Y-m-d", $calculatedTime); $idRes = insertResursa("Buletin " . $buletinNumar, 1, 0, null, 6, "", $fileDate, "CURRENT_TIMESTAMP()", 0); $caleThumbPdf = salveazaImaginePdf($file); insertAttachment(FOLDER_BULETINE . $file, "", 'pdf', $idRes, $caleThumbPdf, null, $fileSize); copy(FOLDER_BULETINE_VECHI . $file, FOLDER_BULETINE . $file); $i++; // if ($i == 10) // break; } closedir($handle); } }
/** * Copy one uploaded file to his destination and insert an entry in the database * @access private * @return boolean TRUE if OK */ function uploadFile($IdPost, $IdTopic, $name, $size, $type, $src_file, $inline = DEFAULT_INLINE) { global $MAX_FILE_SIZE; global $mimetypes, $mimetype_default; global $insert_base; settype($size, 'integer'); $this->errno = 0; # Check temporary file # -------------------- if (empty($src_file) || strcasecmp($src_file, 'none') == 0) { $this->errno = NO_FILE; return false; } # Check size # ---------- if ($size == 0) { $this->errno = FILE_EMPTY; return false; } else { $fsize = filesize($src_file); } if ($size != $fsize) { $this->errno = ERR_FILE; return FALSE; } if ($size > $MAX_FILE_SIZE) { $this->errno = FILE_TOO_BIG; return FALSE; } # Check name # ---------- if (empty($name)) { $this->errno = NO_FILE; return false; } $name = preg_replace('#[/\\\\:\\*\\?"<>|]#i', '_', rawurldecode($name)); # Check type and extension # ------------------------ load_mimetypes(); $suffix = strtoLower(substr(strrchr($name, '.'), 1)); if (isset($mimetypes[$suffix])) { $type = $mimetypes[$suffix]; } elseif (empty($type) || $type == 'application/octet-stream') { $type = $mimetype_default; } if (!$this->isAllowedFile($name, $type)) { $this->errno = INVALID_FILE_TYPE; return FALSE; } # Find the path to upload directory # ------------------------------------------- global $DOCUMENTROOT; $rep = $DOCUMENTROOT; settype($log_filename, "string"); if ($insert_base == true) { # insert attachment reference in database # --------------------------------------- $id = insertAttachment($this->apli, $IdPost, $IdTopic, $this->IdForum, $name, $this->upload_dir, $inline, $size, $type); if ($id <= 0) { $this->errno = DB_ERROR; return FALSE; } # copy temporary file to the upload directory # ------------------------------------------- $dest_file = $rep . $this->upload_dir . "{$id}." . $this->apli . ".{$name}"; $copyfunc = function_exists('move_uploaded_file') ? 'move_uploaded_file' : 'copy'; if (!$copyfunc($src_file, $dest_file)) { deleteAttachment($this->apli, $IdPost, $rep . $this->upload_dir, $id, $name); $this->errno = COPY_ERROR; return FALSE; } @chmod($dest_file, 0766); $log_filename = $dest_file; } else { if ($this->apli == "minisite") { # copy temporary file to the upload directory # ------------------------------------------- global $rep_upload_minisite; $copyfunc = function_exists('move_uploaded_file') ? 'move_uploaded_file' : 'copy'; if (!$copyfunc($src_file, $rep . $rep_upload_minisite . $name)) { $this->errno = COPY_ERROR; return FALSE; } @chmod($rep . $rep_upload_minisite . $name, 0766); $log_filename = $rep . $rep_upload_minisite . $name; } elseif ($this->apli == "editeur") { # copy temporary file to the upload directory # ------------------------------------------- global $rep_upload_editeur; $copyfunc = function_exists('move_uploaded_file') ? 'move_uploaded_file' : 'copy'; if (!$copyfunc($src_file, $rep . $rep_upload_editeur . $name)) { $this->errno = COPY_ERROR; return FALSE; } @chmod($rep . $rep_upload_editeur . $name, 0766); $log_filename = $rep . $rep_upload_editeur . $name; } else { return FALSE; } } Ecr_Log("security", "Upload File(s) : " . getip(), $log_filename); return TRUE; }
function resolveAudio() { echo "\nAudio\n"; // Select evenimente $q = "SELECT l.*, c.title as cat2_titlu FROM pec_audio_list l left join pec_audio_categories2 c on l.id_cat2 = c.id order by id"; $r = mysql_query($q); while ($row = mysql_fetch_assoc($r)) { $tipuri_resurse = array("3" => "5", "4" => "3", "5" => "4", "6" => "9", "7" => "11"); $data = null; $data_adaugare = $row['datainsert']; $rawTitle = str_replace("&", "si", $row['title']); $title_parts = explode("-", $rawTitle); $autor = trim($title_parts[0]); var_dump($autor); // TODO: nu insereaza caracterul ' $pos = strpos($rawTitle, "-"); $titlu = trim(substr($rawTitle, $pos + 1, strlen($rawTitle) - $pos)); var_dump($titlu); $tip_id = $tipuri_resurse[$row["id_cat1"]]; $autor_id = checkExistingAuthor($autor); if ($autor_id == -1) { $autor_id = insertAutor($autor); } $id_meniu = 0; if ($row['cat2_titlu']) { $id_meniu = checkExistingMeniu($tip_id, $row['cat2_titlu']); if ($id_meniu == -1) { $id_meniu = insertMeniu($tip_id, $row['cat2_titlu']); } } $resurse_id = insertResursa($titlu, $autor_id, null, $id_meniu, $tip_id, null, $data, $data_adaugare, $row['views']); insertAttachment($row['source'], null, 'mp3', $resurse_id, null, transformInSeconds($row['durata']), $row['marimea']); } }