From 3bbe234fe5bb1c00115dfd1aeb962bb170a4dd09 2017-06-21 20:48:36 From: DarkMorford Date: 2017-06-21 20:48:36 Subject: [PATCH] More updates to rants and pages. --- diff --git a/edit-page.php b/edit-page.php index d1c9bf9..0653133 100644 --- a/edit-page.php +++ b/edit-page.php @@ -59,8 +59,6 @@ if( $_POST ) { adminhead('Edit Page'); adminmenu('manage-pages.php'); - - ?> @@ -80,7 +78,7 @@ tinyMCE.init({ theme_advanced_blockformats : "p,h3,h4,h5,h6", theme_advanced_resizing : true, theme_advanced_styles : "Spoiler=spoiler" - + }); diff --git a/edit-rant.php b/edit-rant.php index 68289a7..f262891 100644 --- a/edit-rant.php +++ b/edit-rant.php @@ -118,7 +118,7 @@ if( $_POST ) { foreach($_POST['delete_attachment'] as $attachment) deleteattachment($attachment); - $existing_attachments = $mtdb->getAll('SELECT ra.id AS id, extension FROM rant_attachment ra JOIN media_t ON ra.media = media_t.id WHERE ra.rant = '.$rant->id.' ORDER BY id'); + $existing_attachments = $dbConnection->fetchAll('SELECT ra.id AS id, extension FROM rant_attachment ra JOIN media_t ON ra.media = media_t.id WHERE ra.rant = ? ORDER BY id', array($rant->id)); for($i = 0; $i < count($existing_attachments); $i++) { $rant->body = preg_replace('/(href|src)=\"([^\"]*?)\\{'.($i+1).'\\}(.*?)\"/', '\1="'.get_rantattachment_filename($existing_attachments[$i]->id).'"', $rant->body); } @@ -218,7 +218,7 @@ tinyMCE.init({

Author

%s', $v->id, SITE_HOST, SITE_PATH, get_rantattachment_filename($v->id), get_rantattachment_filename($v->id)); ?> diff --git a/manage-pages.php b/manage-pages.php index d3ecebf..3376f33 100644 --- a/manage-pages.php +++ b/manage-pages.php @@ -17,10 +17,10 @@ $page = 1; if( isset($_GET['page'] )) $page = (int) $_GET['page']; $perpage = 15; -$start = ($page-1) * $perpage; +$start = ($page - 1) * $perpage; -$total = ceil( $mtdb->getOne("SELECT count(DISTINCT url_name) FROM static_page") / $perpage ); -$pages = $mtdb->getAll("SELECT url_name, pubdate, status, title, body FROM static_page ORDER BY url_name ASC LIMIT $start,$perpage"); +$total = ceil( $dbConnection->fetchColumn('SELECT COUNT(url_name) FROM static_page') / $perpage ); +$pages = $dbConnection->fetchAll('SELECT url_name, pubdate, status, title, body FROM static_page ORDER BY url_name ASC LIMIT ?, ?', array($start, $perpage)); pagination( $page, $total ); diff --git a/manage-rants.php b/manage-rants.php index 80edd37..31b74f7 100644 --- a/manage-rants.php +++ b/manage-rants.php @@ -17,10 +17,10 @@ $page = 1; if( isset($_GET['page'] )) $page = (int) $_GET['page']; $perpage = 15; -$start = ($page-1) * $perpage; +$start = ($page - 1) * $perpage; -$total = ceil( $mtdb->getOne("SELECT count(DISTINCT id) FROM rant") / $perpage ); -$rants = $mtdb->getAll("SELECT r.id,UNIX_TIMESTAMP(r.published) AS published,c.name,r.title,r.body, r.status FROM rant r,contributor c WHERE c.id=r.author GROUP BY id ORDER BY id DESC LIMIT $start,$perpage"); +$total = ceil( $dbConnection->fetchColumn('SELECT COUNT(id) FROM rant') / $perpage ); +$rants = $dbConnection->fetchAll('SELECT r.id, UNIX_TIMESTAMP(r.published) AS published, c.name, r.title, t.body, r.status FROM rant r JOIN contributor c ON r.author = c.id ORDER BY r.id DESC LIMIT ?, ?', array($start, $perpage)); pagination( $page, $total ); diff --git a/post-rant.php b/post-rant.php index 8521116..35d4609 100644 --- a/post-rant.php +++ b/post-rant.php @@ -11,7 +11,7 @@ auth_redirect(); // Require logged in user to access this page. adminhead('Write Rant'); adminmenu('post-rant.php'); -$rant_image_ext = $mtdb->getOne( 'SELECT extension FROM media_t WHERE id=' . (int)$currentuser->imagetype ); +$rant_image_ext = $dbConnection->fetchColumn('SELECT extension FROM media_t WHERE id = ?', array((int)$currentuser->imagetype)); ?> @@ -58,10 +58,10 @@ tinyMCE.init({
getAll('select id,name from contributor'); - foreach( $contrib as $k=>$v ) { + $contrib = $dbConnection->fetchAll('SELECT id, name FROM contributor'); + foreach( $contrib as $k => $v ) + { printf('', htmlentities($v->id), ( $currentuser->id == $v->id ? 'selected="selected"' : '' ), $v->name ); } ?>