logo

Member
Member
Offline Offline
Posts: 46
SVN 663: Couple of errors in Pages administration w/FIXES

A couple of typos in the Pages administration...

Open
Code:
/Layouts/Admin/Pages.php


First, its looking for a _POST item that isn't set by the forms: rating vs ratings.

Find:
Code:

      $check = call('addpage', $_POST['pagename'], htmlentities($_POST['content']), $_POST['comment'], $_POST['rating']);


Replace With:
Code:

      $check = call('addpage', $_POST['pagename'], htmlentities($_POST['content']), $_POST['comment'], $_POST['ratings']);


Next, a copy and paste error. Note usage of comment on the ratings box.

Find
Code:

<td>Ratings: <input type="checkbox" name="ratings" '; if($check == false && isset($_POST['comment'])) { $body.= 'checked="checked"'; } $body.= ' /></td>


Replace With:
Code:

<td>Ratings: <input type="checkbox" name="ratings" '; if($check == false && isset($_POST['ratings'])) { $body.= 'checked="checked"'; } $body.= ' /></td>


Next up, a bit of error checking was added to editing a page, but isn't present on new pages.

For Reference:
Code:
      $check = call('editpage', stripslashes($_POST['pagename']), htmlentities($_POST['content']), $_GET['id'], $_POST['comment'], $_POST['ratings']);


Find:
Code:
$check = call('addpage', $_POST['pagename'], htmlentities($_POST['content']), $_POST['comment'], $_POST['rating']);


Replace With:
Code:
$check = call('addpage', stripslashes($_POST['pagename']), htmlentities($_POST['content']), $_POST['comment'], $_POST['rating']);


Now, a fix (at least band-aid) for a couple other errors...

If either checkbox isn't checked, the post isn't being given the contents as unchecked. It's plain not getting them.

This is what I'm getting if they both aren't checked...
Code:

Notice: Undefined index: comment in C:!WebServerhtdocsLayoutsAdminPages.php on line 26
Notice: Undefined index: ratings in C:!WebServerhtdocsLayoutsAdminPages.php on line 26


I stuck this handy little bit of code near the top of the file, and made it output where I could see it. You're welcome to use it for testing.
Code:

$body .= "nExtracted POST:<br>n"; foreach($_POST as $k=>$v) { $body .= 'Key: "' . $k . "" Value: "" . $v . ""<br>n"; }


Don't leave it in anything production grade, its definitely a testing item.

That's how I found out rather than sending '0' or 'off', it's just not sending values for comment or ratings. Thus, the keys aren't present in _POST.

So here's how to recitfy that.

Find:
Code:

if(!isset($_GET['type']) || $_GET['type'] == null) {
   if($_POST)
      $check = call('addpage', $_POST['pagename'], htmlentities($_POST['content']), $_POST['comment'], $_POST['rating']);
   else
      $check = false;


Replace With:
Code:

if(!isset($_GET['type']) || $_GET['type'] == null) {
   if($_POST) {
      if (!(isset($_POST['comment']))) {$_POST['comment'] = 0;}
      if (!(isset($_POST['ratings']))) {$_POST['ratings'] = 0;}
      $check = call('addpage', stripslashes($_POST['pagename']), htmlentities($_POST['content']), $_POST['comment'], $_POST['ratings']);
   } else {
      $check = false;
   }


Odd thing is, no errors are produced from updating an existing page, only new page creation.

Anyway, these lines of sanity checking correct the errors.

Fun fun, another 4 more bugs squashed.

Time to head to phpmyadmin and quickly drop the 47 new pages. =)
Last Edit: 25th September, 2009, 05:46:32 AM by FWishbringer
eoCMS Developer
eoCMS Developer
Offline Offline
avatar
Posts: 1528
Re: SVN 663: Couple of errors in Pages administration w/FIXES

Fixed

Please do not PM me requesting support or anything, use the forums, thats what they are here for
eoCMS Designer
eoCMS Designer
Offline Offline
avatar
Posts: 1290
tbarkass_willamson@hotmail.com
Re: SVN 663: Couple of errors in Pages administration w/FIXES

This bug has been deemed [Fixed] by an eoCMS developer. If you dispute the Fix, please PM a developer, giving details of why. This topic can then be unlocked allowing for further discussion.

Seen a bug? Report it!

Jump to:


0.06 seconds Queries: 13