Remove a stray debug function that snuck in.
Remove a stray debug function that snuck in.

File last commit:

e18a8b6ee362
7fe186c7689f
Show More
strip.php
144 lines | 4.7 KiB | text/x-php | PhpLexer
Add most necessary files for admin interface.
r1 <?php
// Book: The offset from 0 at the beginning of time
// Page: The offset from 0 at the beginning of the volume
More database updates.
r34 class Strip
{
public $id;
public $old_id;
public $published;
public $media;
public $type;
public $title;
public $book;
public $page;
Add most necessary files for admin interface.
r1 }
// old_id is used to detect alterations to the strip id in forms. Not saved in database.
// media is imagetype
// Strip id is automatically incremented
function insertstrip(&$strip) {
More database updates.
r34 global $dbConnection;
Update include/*.php to use mysqli_* functions.
r4
Fix a couple of bugs related to posting comics.
r46 $strip->book = ($strip->book == '') ? NULL : (int)$strip->book;
$strip->page = ($strip->page == '') ? NULL : (int)$strip->page;
Update include/*.php to use mysqli_* functions.
r4
More database updates.
r34 $dbConnection->beginTransaction();
$newid = $dbConnection->fetchColumn('SELECT MAX(id) FROM strip') + 1;
$sql = 'INSERT INTO strip (id, published, media, type, title, book, page) VALUES(?, FROM_UNIXTIME(?), ?, ?, ?, ?, ?)';
$stmt = $dbConnection->prepare($sql);
$stmt->bindValue(1, $newid);
$stmt->bindValue(2, $strip->published, PDO::PARAM_INT);
$stmt->bindValue(3, $strip->media, PDO::PARAM_INT);
$stmt->bindValue(4, $strip->type, PDO::PARAM_INT);
$stmt->bindValue(5, trim($strip->title));
$stmt->bindValue(6, $strip->book);
$stmt->bindValue(7, $strip->page);
$r = $stmt->execute();
Add most necessary files for admin interface.
r1 if( !$r ) {
More database updates.
r34 $dbConnection->rollback();
Add most necessary files for admin interface.
r1 return false;
}
More database updates.
r34 $dbConnection->commit();
Add most necessary files for admin interface.
r1 adminlog("Comic ".$newid." posted.", MTS_STRIP, MTA_ADD);
Update include/*.php to use mysqli_* functions.
r4
Add most necessary files for admin interface.
r1 $strip->id = $newid;
if( $strip->id == 0 ) return false;
return true;
Update include/*.php to use mysqli_* functions.
r4 }
Add most necessary files for admin interface.
r1
function updatestrip(&$strip) {
More database updates.
r34 global $dbConnection;
Update include/*.php to use mysqli_* functions.
r4
Kill one more NULL bug.
r49 $strip->book = ($strip->book === '') ? NULL : (int)$strip->book;
$strip->page = ($strip->page === '') ? NULL : (int)$strip->page;
Update include/*.php to use mysqli_* functions.
r4
More database updates.
r34 $dbConnection->beginTransaction();
$sql = 'UPDATE strip SET published = FROM_UNIXTIME(?), media = ?, type = ?, title = ?, book = ?, page = ? WHERE id = ?';
$stmt = $dbConnection->prepare($sql);
$stmt->bindValue(1, $strip->published, PDO::PARAM_INT);
$stmt->bindValue(2, $strip->media, PDO::PARAM_INT);
$stmt->bindValue(3, $strip->type, PDO::PARAM_INT);
$stmt->bindValue(4, trim($strip->title));
$stmt->bindValue(5, $strip->book, PDO::PARAM_INT);
$stmt->bindValue(6, $strip->page, PDO::PARAM_INT);
$stmt->bindValue(7, $strip->id, PDO::PARAM_INT);
$stmt->execute();
$dbConnection->commit();
Add most necessary files for admin interface.
r1 adminlog("Comic ".$strip->id." modified.", MTS_STRIP, MTA_MODIFY);
return true;
Update include/*.php to use mysqli_* functions.
r4 }
Add most necessary files for admin interface.
r1
// Delete destination strip from DB and FS, and Update/Rename the source strip into place. Destructive Move!
function move_strip($from_id, $to_id)
{
More database updates.
r34 global $dbConnection;
Add most necessary files for admin interface.
r1 $from_id = (int) $from_id;
$to_id = (int) $to_id;
Update include/*.php to use mysqli_* functions.
r4
Add most necessary files for admin interface.
r1 // Ensure our source exists
More database updates.
r34 $num_strips = $dbConnection->fetchColumn('SELECT COUNT(*) FROM strip WHERE id = ?', array($from_id));
Add most necessary files for admin interface.
r1 if($num_strips < 1)
mtdie("Cannot move strip number $from_id, because it cannot be found in database.");
// Ready the destination
deletestrip( $to_id );
Update include/*.php to use mysqli_* functions.
r4
Add most necessary files for admin interface.
r1 // Update database
More database updates.
r34 $dbConnection->executeUpdate('UPDATE strip SET id = ? WHERE id = ?', array($to_id, $from_id));
$strip = $dbConnection->executeQuery('SELECT strip.id, extension FROM strip, media_t WHERE media_t.id = strip.media AND strip.id = ?', array($to_id))->fetch();
Add most necessary files for admin interface.
r1
// Update filesystem
foreach(glob(sprintf(SITE_PATH_ABS.'/'.SITE_STRIP.'/%04d.*', $from_id)) as $item) {
preg_match('/\.(\w{3})$/', $item, $match) or die("Invalid filename: $item");
rename($item, sprintf(SITE_PATH_ABS.'/'.SITE_STRIP.'/%04d.%s', $to_id, $match[1]));
}
}
// Classic swap function, using strip 0 as temporary storage. Can cause concurrency issues. FLOCK!
function swap_strips( $from_id, $to_id ) {
move_strip($from_id, 0);
move_strip($to_id, $from_id);
move_strip(0, $from_id );
adminlog("Comics ".$from_id." and ".$to_id." swapped.", MTS_STRIP, MTA_MODIFY);
}
function deletestrip($id) {
$id = (int)$id;
if ( !$id ) return false;
Update include/*.php to use mysqli_* functions.
r4
More database updates.
r34 global $dbConnection;
$r = $dbConnection->executeUpdate('DELETE FROM strip WHERE id = ?', array($id));
Add most necessary files for admin interface.
r1 foreach(glob(sprintf(SITE_PATH_ABS.'/'.SITE_STRIP.'/%04d*.*', $id)) as $item)
unlink($item);
foreach(glob(sprintf(SITE_PATH_ABS.'/'.SITE_STRIP.'/restricted/%04d*.*', $id)) as $item)
unlink($item);
adminlog("Comic ".$id." deleted.", MTS_STRIP, MTA_DELETE);
return $r;
}
function getstrip($id) {
More database updates.
r34 global $dbConnection;
return $dbConnection->executeQuery('SELECT id, UNIX_TIMESTAMP(published) as published, type, media, title, book, page FROM strip WHERE id = ?', array($id))->fetch();
Add most necessary files for admin interface.
r1 }
function get_stripimage_filename( $strip ) {
More database updates.
r34 global $dbConnection;
$ext = $dbConnection->fetchColumn('SELECT extension FROM media_t WHERE id = ?', array($strip->media)); // filename extension
Add most necessary files for admin interface.
r1 return sprintf( '%s/%04d.%s', SITE_STRIP, $strip->id, $ext );
}
function get_stripid_by_rantid($rantid) {
More database updates.
r34 global $dbConnection;
return $dbConnection->fetchColumn('SELECT MAX(strip.id) FROM strip, rant WHERE strip.published <= rant.published AND rant.id = ?', array($rantid));
Add most necessary files for admin interface.
r1 }
?>