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); } }
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']); } }