$first_page = true; foreach ($file_list as $this_file) { $serial = $bimport->makeSerial(); $permissions = fileperms($import_path . '/' . $folder); if ($permissions == '16895') { $new_path = '../' . DIR_COMICS_IMG . '/' . $serial; mkdir($new_path); $success = rename($import_path . '/' . $folder . '/' . $this_file, $new_path . '/' . $this_file); } else { $success = false; $total_success = false; $alert_output = $message->alert_dialog('I couldn’t import all of the new images. Looks like a permissions error. Please temporarily set the folders in /import to 777.'); } if ($success) { // Create the image DB record. $new_image_id = $comic_image->createImageRecord('/' . DIR_COMICS_IMG . $serial . '/' . $this_file); // Create the page DB record. $title = explode('.', $this_file); $title = $title[0]; if ($first_page === true) { $new_page_id = $comic_image->createPageRecord($title, $last_page + $i, $book_id, $new_marker_id); $first_page = false; } else { $new_page_id = $comic_image->createPageRecord($title, $last_page + $i, $book_id); } // Assign the image to the page. if ($new_image_id && $new_page_id) { $new_assignment_id = $comic_image->assignImageToPage($new_image_id, $new_page_id); } $i += 0.0001; } elseif ($success !== false) {
$success = $fileops->up_process('file_change'); if ($success && $new_page_id) { foreach ($success as $filename) { // Figure the real file name to make an alt attribute. $alt = explode('/', $filename); // Break into parts $alt = end($alt); // Get the last part (should be the file name) $alt = explode('.', $alt); // Break into parts array_pop($alt); // Remove the last part (should be the extension) $alt = implode('.', $alt); // Put it back together // Create the image DB record. $new_image_id = $comic_image->createImageRecord('/' . DIR_COMICS_IMG . $filename, $alt); // Assign the image to the page. if ($new_image_id && $new_page_id) { $new_assignment_id = $comic_image->assignImageToPage($new_image_id, $new_page_id); } } header('location:book.page-edit.php?page_id=' . $new_page_id); die; } } // ! Display logic // Build calendar options (month list, day list, year list) for ($i = 1; $i < 32; $i++) { $i < 10 ? $i = '0' . $i : null; $day_list[$i] = array('title' => $i, 'id' => $i); }
$fileops->up_set_destination_folder('../' . DIR_COMICS_IMG); $files_uploaded = $fileops->up_process($which); $new_order = $_POST['new_order']; $new_order ? $new_order : ($new_order = 1); if ($files_uploaded) { $i = -1; $qty = count($_FILES['file']['name']); foreach ($files_uploaded as $key => $val) { $title = explode('.', $val); $title = $title[0]; if (strpos($title, '/')) { $title = explode('/', $title); $title = $title[1]; } // Create the image DB record. $new_image_id = $comic_image->createImageRecord(DIR_COMICS_IMG . '/' . $val); // Create the page DB record. $new_page_id = $comic_image->createPageRecord($title, $new_order + $i, $book_id); $first_page_id ? null : ($first_page_id = $new_page_id); // Assign the image to the page. if ($new_image_id && $new_page_id) { $new_assignment_id = $comic_image->assignImageToPage($new_image_id, $new_page_id); } $i += 0.0001; } reset_page_order($book_id, $db); header('location:book.view.php'); } } else { $alert_output .= $message->alert_dialog('Yeah, look, I can’t put files in the ' . DIR_COMICS_IMG . ' folder on your web host.'); }