function cpm_action_multiple_upload_file() { global $cpm_config; if (strtotime($_POST['time']) === false) { $cpm_config->warnings[] = sprintf(__('<strong>There was an error in the post time (%1$s)</strong>. The time is not parseable by strtotime().', 'comicpress-manager'), $_POST['time']); } else { $files_to_handle = array(); foreach ($_FILES as $name => $info) { if (strpos($name, "upload-") !== false) { if (is_uploaded_file($_FILES[$name]['tmp_name'])) { $files_to_handle[] = $name; } else { switch ($_FILES[$name]['error']) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $cpm_config->warnings[] = sprintf(__("<strong>The file %s was too large.</strong> The max allowed filesize for uploads to your server is %s.", 'comicpress-manager'), $_FILES[$name]['name'], ini_get('upload_max_filesize')); break; case UPLOAD_ERR_NO_FILE: break; default: $cpm_config->warnings[] = sprintf(__("<strong>There was an error in uploading %s.</strong> The <a href='http://php.net/manual/en/features.file-upload.errors.php'>PHP upload error code</a> was %s.", 'comicpress-manager'), $_FILES[$name]['name'], $_FILES[$name]['error']); break; } } } } if (count($files_to_handle) > 0) { cpm_handle_file_uploads($files_to_handle); $cpm_config->comic_files = cpm_read_comics_folder(); } else { $cpm_config->warnings[] = __("<strong>You didn't upload any files!</strong>", 'comicpress-manager'); } } }
function cpm_action_write_comic_post() { global $cpm_config; $files_to_handle = array(); if (isset($_FILES['upload'])) { if (is_uploaded_file($_FILES['upload']['tmp_name'])) { $files_to_handle[] = 'upload'; } } if (count($files_to_handle) > 0) { list($posts_created, $duplicated_posts) = cpm_handle_file_uploads($files_to_handle); if (count($posts_created) > 0) { if (count($posts_created) == 1) { ?> <script type="text/javascript">document.location.href = "post.php?action=edit&post=<?php echo $posts_created[0]['ID']; ?> ";</script><?php } else { $cpm_config->warnings[] = __("<strong>More than one new post was generated!</strong> Please report this error.", 'comicpress-manager'); } } if (count($duplicated_posts) > 0) { if (count($duplicated_posts) == 1) { ?> <script type="text/javascript">document.location.href = "post.php?action=edit&post=<?php echo $duplicated_posts[0][0]['ID']; ?> ";</script><?php } else { $cpm_config->warnings[] = __("<strong>More than one duplicate post was found!</strong> Please report this error.", 'comicpress-manager'); } } $cpm_config->warnings[] = __("<strong>No posts were created, and no duplicate posts could be found!</strong>", 'comicpress-manager'); } else { $cpm_config->warnings[] = __("<strong>You didn't upload any files!</strong>", 'comicpress-manager'); } }
/** * Handle editing a post. */ function cpm_handle_edit_post($post_id) { global $cpm_config; if (!$cpm_config->is_cpm_managing_posts) { $ok = false; extract(cpm_get_all_comic_categories()); $post_categories = wp_get_post_categories($post_id); foreach ($category_tree as $node) { $parts = explode("/", $node); if (in_array(end($parts), $post_categories)) { $ok = true; break; } } if (is_uploaded_file($_FILES['comicpress-replace-image']['tmp_name']) && !$ok) { $post_categories = wp_get_post_categories($post_id); $post_categories[] = end(explode("/", reset($category_tree))); wp_set_post_categories($post_id, $post_categories); $ok = true; } if ($ok) { $new_date = date(CPM_DATE_FORMAT, strtotime(implode("-", array($_POST['aa'], $_POST['mm'], $_POST['jj'])))); foreach (array('hovertext' => 'comicpress-img-title', 'transcript' => 'comicpress-transcript') as $meta_name => $post_name) { if (isset($_POST[$post_name])) { update_post_meta($post_id, $meta_name, $_POST[$post_name]); } } if (is_uploaded_file($_FILES['comicpress-replace-image']['tmp_name'])) { $_POST['override-date'] = $new_date; cpm_handle_file_uploads(array('comicpress-replace-image')); } } } }