From 3b807424bd87ff9a86a671112add3473f52fa943 2017-06-21 21:28:24 From: DarkMorford Date: 2017-06-21 21:28:24 Subject: [PATCH] Update more admin pages to use DBAL functions. --- diff --git a/character-twitter.php b/character-twitter.php index 9aee60b..9ee383c 100644 --- a/character-twitter.php +++ b/character-twitter.php @@ -10,7 +10,8 @@ if('post_twitter' == $_REQUEST['action']) check_nonce('new-character-twitter'); #Fetch the password from the DB. - $acct = $mtdb->getRow(sprintf("SELECT username, password FROM twitter_user WHERE id = '%d'", $_REQUEST['twitter-account'])); + $stmt = $dbConnection->executeQuery('SELECT username, password FROM twitter_user WHERE id = ?', array($_REQUEST['twitter-account'])); + $acct = $stmt->fetch(); $post_at = strtotime($_REQUEST['date18']); @@ -35,13 +36,8 @@ if('post_twitter' == $_REQUEST['action']) else { #No luck, gotta schedule. - $mtdb->query( - sprintf("INSERT INTO twitter_post (status, user, time, text)VALUES ('scheduled', '%d', FROM_UNIXTIME('%d'), '%s')", - mysqli_real_escape_string($mtdb->link, $_REQUEST['twitter-account']), - $post_at, - mysqli_real_escape_string($mtdb->link, $_REQUEST['message']) - ) - ); + $dbConnection->executeUpdate('INSERT INTO twitter_post (status, user, time, text) VALUES (\'scheduled\', ?, FROM_UNIXTIME(?), ?)', + array($_REQUEST['twitter-account'], $post_at, $_REQUEST['message'])); $info .= "Your tweet for user " . htmlentities($acct->username) . " has been scheduled."; adminlog('Tweet for account ' . $acct->username . ' has been scheduled.', MTS_TWITTER, MTA_ADD); } @@ -52,12 +48,11 @@ if('post_twitter' == $_REQUEST['action']) } } -$characters = $mtdb->getAll("SELECT id, username FROM twitter_user ORDER BY username"); +$characters = $dbConnection->fetchAll('SELECT id, username FROM twitter_user ORDER BY username'); -$scheduled = $mtdb->getAll("SELECT username, text, status, twitter_post.id AS id, time - FROM twitter_post JOIN twitter_user - ON twitter_post.user = twitter_user.id - WHERE twitter_post.status = 'scheduled' ORDER BY time"); +$scheduled = $dbConnection->fetchAll('SELECT username, text, status, twitter_post.id AS id, time ' . + 'FROM twitter_post JOIN twitter_user ON twitter_post.user = twitter_user.id ' . + 'WHERE twitter_post.status = \'scheduled\' ORDER BY time'); adminhead('Manage Character Twitters'); adminmenu(); diff --git a/delete-tweet.php b/delete-tweet.php index e70002e..4a35719 100644 --- a/delete-tweet.php +++ b/delete-tweet.php @@ -12,7 +12,7 @@ $victim = (int)$_REQUEST['tweet_id']; if($victim) { - $r = $mtdb->query("DELETE FROM twitter_post WHERE id = '$victim'"); + $r = $dbConnection->executeUpdate('DELETE FROM twitter_post WHERE id = ?', array($victim)); if(!$r) { adminlog('Error deleting scheduled tweet ' . $victim, MTS_TWITTER, MTA_DELETE, E_ERROR); diff --git a/delete-twitter-user.php b/delete-twitter-user.php index c8069b1..0a50ed8 100644 --- a/delete-twitter-user.php +++ b/delete-twitter-user.php @@ -12,7 +12,7 @@ $victim = (int)$_REQUEST['id']; if($victim) { - $r = $mtdb->query("DELETE FROM twitter_user WHERE id = '$victim'"); + $r = $dbConnection->executeUpdate('DELETE FROM twitter_user WHERE id = ?', array($victim)); if(!$r) { adminlog('Error deleting specified twitter user ' . $victim, MTS_TWITTER, MTA_DELETE, E_ERROR); diff --git a/edit-comic.php b/edit-comic.php index 478b5ac..28d170b 100644 --- a/edit-comic.php +++ b/edit-comic.php @@ -35,13 +35,13 @@ if( $_POST ) { 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.'); + 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 = $mtdb->getOne( 'SELECT extension FROM media_t WHERE id = ' . (int)$strip->media ); + $fileext = $dbConnection->fetchColumn('SELECT extension FROM media_t WHERE id = ?', array($strip->media), array(PDO::PARAM_INT)); if(strlen($fileext) < 3) { @@ -86,7 +86,7 @@ if( $_POST ) { $imagedata = getimagesize($_FILES['comicFile']['tmp_name']); $strip->media = $imagedata[2]; } - $fileext = $mtdb->getOne( 'SELECT extension FROM media_t WHERE id=' . (int)$strip->media ); + $fileext = $dbConnection->fetchColumn('SELECT extension FROM media_t WHERE id = ?', array($strip->media), array(PDO::PARAM_INT)); if(strlen($fileext) < 3) { @@ -178,7 +178,7 @@ adminmenu('manage-comics.php');

Comic Type

getAll( 'SELECT id, description FROM strip_t ORDER BY id' ); +$types = $dbConnection->fetchAll('SELECT id, description FROM strip_t ORDER BY id'); foreach( $types as $k=>$v ) printf('', htmlentities($v->id), ($last_type == $v->id ? 'selected="selected"' : '' ), $v->description); ?>