id = (int)$_REQUEST['strip_id']; $strip = getstrip($strip->id); if( $_POST ) { // Form Elements $strip->new_id = (int)$_POST['strip_new_id'] ? (int)$_POST['strip_new_id'] : $strip->id; $strip->published = empty($_POST['strip_date']) ? time() : strtotime( $_POST['strip_date'] ); $strip->type = (int)$_POST['strip_type']; $strip->title = trim($_POST['strip_title']); $strip->transcript_posted = $_POST['content']; $strip->book = trim($_POST['book']); $strip->page = trim($_POST['page']); if( '' == $strip->title ) mtdie('Strips must be supplied with titles.'); $YESTERDAY = mktime(0,0,0, date('m'), date('d')-1, date('Y')); switch($_POST['action']) { case 'new_comic': check_nonce('new-strip'); // Ensure that dates are not in the past if( $strip->published < $YESTERDAY ) mtdie('Strips may not be backdated. Enter a date today or in the future.'); if( !is_valid_upload('comicFile') ) { adminlog("Image upload failed.", MTS_STRIP, MTA_ADD, E_WARNING); mtdie('If you want to upload a new comic, you must provide said comic.', 'Strip upload failed.'); } // get image type and target extension $imagedata = getimagesize($_FILES['comicFile']['tmp_name']); $strip->media = $imagedata[2]; $fileext = $dbConnection->fetchColumn('SELECT extension FROM media_t WHERE id = ?', array($strip->media), 0, array(PDO::PARAM_INT)); var_dump($fileext); if(strlen($fileext) < 3) { //bad image upload type adminlog("Bad image type upload on new strip. Invalid media type.", MTS_STRIP, MTA_ADD, E_ERROR); mtdie('Bad image type upload on new strip. Invalid media type.'); } // Insert new strip into the database, get a real $strip->id if(!insertstrip( $strip )) { adminlog("Error on insertion of new strip: ".$dbConnection->errorCode(), MTS_STRIP, MTA_ADD, E_ERROR); mtdie('Error on insertion of new strip: '.$dbConnection->errorCode(), 'SQL Error'); } // Store the uploaded file to xxxx-0.ext $basefile = $strip->published <= time() ? sprintf(SITE_PATH_ABS.'/'.SITE_STRIP.'/'.'%04d.%s', $strip->id, $fileext) : sprintf(SITE_PATH_ABS.'/'.SITE_STRIP.'/restricted/'.'%04d.%s', $strip->id, $fileext); if(!move_uploaded_file($_FILES['comicFile']['tmp_name'], $basefile)) { adminlog("Filesystem error in storing image.", MTS_STRIP, MTA_ADD, E_ERROR); mtdie('There was a problem storing the uploaded strip image. Please harass contact support.','Filesystem Error'); } // Alert Twitter if the strip is for immediate publication if( $strip->published <= time() ) twitterpost("Comic ".$strip->id." posted: ".SITE_HOST.SITE_PATH."/strip/".$strip->id); $info.="

Comic posted!

"; break; case 'edit_comic': if( 0 >= $strip->new_id ) mtdie('Strip numbers must be numeric, greater than 0.'); if( 0 >= $strip->id ) mtdie('Existing strip number, in the form, was zero. This should never happen.'); // When updating, $strip->id is the old strip number. Update in place first. Possibly adjust strip number later. check_nonce('save-strip-'.$strip->id); // If uploading, get filetype. If not uploading, filetype got loaded from database earlier. if( is_valid_upload('comicFile') ) { $imagedata = getimagesize($_FILES['comicFile']['tmp_name']); $strip->media = $imagedata[2]; } $fileext = $dbConnection->fetchColumn('SELECT extension FROM media_t WHERE id = ?', array($strip->media), 0, array(PDO::PARAM_INT)); if(strlen($fileext) < 3) { //bad image upload type adminlog("Bad image type upload on strip ".$strip->id.". Invalid media type.", MTS_STRIP, MTA_UPDATE, E_ERROR); mtdie('Bad image type upload on strip '.$strip->id.'. Invalid media type.'); } // Update existing strip if(!updatestrip( $strip ) ) { adminlog("Failed to update strip ".$strip->id.".", MTS_STRIP, MTA_UPDATE); mtdie('Error updating strip: ' . $dbConnection->errorCode(), 'SQL Error'); } if( is_valid_upload('comicFile') ) { // If uploading, store the uploaded file to xxxx-n.ext $basefile = $strip->published <= time() ? sprintf(SITE_PATH_ABS.'/'.SITE_STRIP.'/'.'%04d.%s', $strip->id, $fileext) : sprintf(SITE_PATH_ABS.'/'.SITE_STRIP.'/restricted/'.'%04d.%s', $strip->id, $fileext); if(!move_uploaded_file($_FILES['comicFile']['tmp_name'], $basefile)) { adminlog("Filesystem error in saving image.", MTS_STRIP, MTA_UPDATE, E_ERROR); mtdie("There was a problem storing the uploaded strip image. Please harass contact support.", 'Filesystem Error'); } adminlog("Image replaced for comic ".$strip->id.".", MTS_STRIP, MTA_UPDATE); } // No new file uploaded. Do nuffink. // Conditionally broadcast success if( $_POST['broadcast'] ) { #Limit broadcast message to 60 characters. Compose it now. $b_msg = 'Comic ' . $strip->id . ' updated: ' . substr(trim($_REQUEST['broadcast_message']), 0, 60) . ', ' . SITE_HOST . SITE_PATH . "/strip/" . $strip->id; rsspost($b_msg, SITE_HOST.SITE_PATH.'/strip/'.$strip->id); twitterpost($b_msg); $info.="

Update broadcasted with message '$b_msg'.

"; } $info.="

Changes saved. id."\">View on site."; break; default: adminlog("User did something strange.", MTS_STRIP, MTA_MODIFY); mtdie('You know, it would be really nice if you avoided nonsensical actions.'); } $info = savetranscript($strip) . $info; # If the strip number changed, swap strips sequentially to shuffle it into place if( $strip->id != $strip->new_id ) { $f = fopen(SITE_PATH_ABS.'/'.SITE_STRIP.'/'.SITE_STRIP_LOCK, 'w'); flock($f, LOCK_EX); while( $strip->new_id < $strip->id ) { // Move this strip backward swap_strips( $strip->id - 1, $strip->id ); $strip->id--; } while( $strip->id < $strip->new_id ) { // Move this strip forward swap_strips( $strip->id + 1, $strip->id ); $strip->id++; } $strip->id = $strip->new_id; close($f); } } ////////////////////// Display Edit Form //////////////////////// $strip = getstrip($strip->id); gettranscript($strip); adminhead('Edit Comic'); adminmenu('manage-comics.php'); ?>

Edit Comic

id); ?>

Comic Type

Post Date

Strip Number

Replace Comic

Broadcast Update

Strip

Book Page Number

-
Title
Transcript