...

View Full Version : Problems with admin.php and config.php file modifications



mariahneu
05-03-2009, 11:41 PM
I'm having problems with the BellaBiblio script (http://www.jemjabella.co.uk/scripts/bellabiblio).

Although, it is a book review script, I'm trying to modify it to turn it into a website review script, however, I modified the code in Dreamweaver and modified the current code, yet I keep receiving a "Parse error: syntax error, unexpected T_CASE in /home/bt4t/public_html/aaaatestingcodes/BellaBiblio/admin.php on line 569" error here: http://www.velociteen.com/aaaatestingcodes/BellaBiblio/admin.php

The login is "admin" and the password is "password" (without the " ", of course)

config.php Code:


<?php
/*
BellaBiblio v2 Copyright Jem Turner 2006, 2007 unless otherwise noted
http://www.jemjabella.co.uk/

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License. See README.txt
or LICENSE.txt for more information.
*/


// ADMIN SETTINGS
$admin_name = "admin"; // admin username
$admin_pass = "password"; // admin password
$secret = "please-change-me123"; // this is like a second password. you won't have to remember it, so make it random

// GENERAL SETTINGS
$perpage = 15; // amount of books to show per page
$amazonA = ""; // if you have an amazon affiliates account, fill in the username between the quotation marks

// AMAZON SEARCH FEATURE
$amazonKey = ''; // API KEY - sign up at http://aws.amazon.com/
$searchresults = 3; // amount of results to return on search




// DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW WHAT YOU'RE DOING

define("BOOKS", "books.txt");
define("RECBOOKS", "rec-books.txt");

function cleanUp($text) {
$text = strip_tags($text);
$text = repCommas(trim(htmlentities($text)));

if (!get_magic_quotes_gpc())
$text = addslashes($text);

return $text;
}
function repCommas($input) {
return str_replace(",", "|", $input);
}
function fixCommas($input) {
return str_replace("|", ",", $input);
}
function blanklinefix($inputfile) {
ignore_user_abort(true);
$content = file($inputfile);

if (count($content) > 0) {
$content = array_diff(array_diff($content, array("")), array("\n"));

$newContent = array();
foreach ($content as $line) {
$newContent[] = trim($line);
}
$newContent = implode("\n", $newContent);

$fl = fopen($inputfile, "w+");
if (flock($fl, LOCK_EX)) {
fwrite($fl, $newContent);
flock($fl, LOCK_UN);
} else {
echo 'The file: '.$inputfile.' could not be locked for writing; the blanklinefix function could not be applied at this time.';
}
fclose($fl);
}
ignore_user_abort(false);
}
function get_data($var) {
global $c;
if (isset($c[$var])) {
echo $c[$var];
}
}
function sort_array($array, $sortkey, $sorttype) {
if ($sortkey == "review") exit("<p>I told ya not to sort by review, are you trying to be smart?!</p>");
$newBooks = array($status,$reviewer,$date,$screenshot,$title,$link,$owner,$contact,$positive,$negative,$original ity,$design,$content,$navigation,$bonus,$total,$grade);
var_dump($book);


foreach ($array as $key => $book) {
$key = str_pad($key, 3, "0", STR_PAD_LEFT);
list($status,$reviewer,$date,$screenshot,$title,$link,$owner,$contact,$positive,$negative,$originali ty,$design,$content,$navigation,$bonus,$total,$grade) = preg_split("/,(?! )/", $book);
$newBooks[$$sortkey.$key] = $book;
}
if ($sorttype == "ksort") ksort($newBooks); elseif ($sorttype == "krsort") krsort($newBooks);
return array_values($newBooks);
}
function breakEmail($email) {
$email = str_replace('.', 'DOTTY', $email);
$email = str_replace('@', 'ATTIE', $email);
$email = str_replace('-', 'DASHY', $email);
$email = str_replace('_', 'SCORE', $email);

return $email;
}
function fixEmail($email) {
$email = str_replace('DOTTY', '.', $email);
$email = str_replace('ATTIE', '@', $email);
$email = str_replace('DASHY', '-', $email);
$email = str_replace('SCORE', '_', $email);

return $email;
}

blanklinefix(BOOKS);
blanklinefix(RECBOOKS);
error_reporting(E_ALL);
?>

I'm just starting to use .PHP, so any help would be much appreciated. Thanks! =]

mariahneu
05-03-2009, 11:41 PM
admin.php Code:


<?php
/*
BellaBiblio v2 Copyright &#169; Jem Turner 2006, 2007 unless otherwise noted
http://www.jemjabella.co.uk/

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License. See README.txt
or LICENSE.txt for more information.
*/
require_once('config.php');
if (isset($_COOKIE['bellabiblio'])) {
if ($_COOKIE['bellabiblio'] == md5($admin_name.$admin_pass.$secret)) {
if (isset($_GET['ap'])) $page = $_GET['ap']; else $page = "";

include('header.php');
switch ($page) {
case "add_book":
foreach ($_POST as $key => $val) {
$c[$key] = cleanUp($val);
}
$show_form = true;
$error_msg = NULL;

if (isset($c['submit'])) {
if ($c['status'] != "reviewed" && $c['status'] != "pending") {
$error_msg .= "Invalid status - reviewed or pending only.";
} elseif (!ereg("^[A-Za-z0-9\(\)_ -]", $c['publisher'])) {
$error_msg .= "Invalid characters in Publisher field.";
} elseif (!ereg("^[A-Za-z0-9\(\)_\. -]", $c['author'])) {
$error_msg .= "Invalid characters in Author field.";
}

if ($error_msg == NULL) {
$show_form = false;

$c['review'] = str_replace("<br /><br /><br /><br />", "<br /><br />", preg_replace("/,(?! )/", ", ", preg_replace("([\r\n])", "<br />", $c['review'])));
$bookFormat = $c['status'].",".$c['reviewer'].",".$c['date'].",".$c['screenshot'].",".$c['title'].",".$c['link'].",".$c['owner'].",".$c['contact'].",".$c['positive'].',"'.$c['negative'].',"'.$c['originality'].',"'.$c['design'].',"'.$c['content'].',"'.$c['navigation'].',"'.$c['bonus'].',"'.$c['total'].',"'.$c['grade']."\n";


ignore_user_abort(true);
$oldBooks = file_get_contents(BOOKS);
$fp = fopen(BOOKS, "w") or die ("Couldn't open ".BOOKS." - your review could not be added.");
if (flock($fp, LOCK_EX)) {
fwrite($fp, $bookFormat);
flock($fp, LOCK_UN);
}
$fp = fopen(BOOKS, "a") or die ("Couldn't open ".BOOKS);
if (flock($fp, LOCK_EX)) {
fwrite($fp, $oldBooks);
flock($fp, LOCK_UN);
}
fclose($fp);

echo '<p>Review added. <a href="admin.php?ap=add_book">Add another review?</a></p>';
ignore_user_abort(false);
}
}
if (!isset($c['submit']) || $show_form == true) {
if ($error_msg != NULL) {
echo "<p><strong style='color: red;'>ERROR:</strong><br />";
echo nl2br($error_msg) . "</p>";
}

if (isset($amazonKey) && $amazonKey != "") {
?>
<div id="amazonLoader" style="width: 780px; height: 90px;">
<h1>Find a Book</h1>
<p>Enter your keyword to search Amazon:<br />
<input type="text" name="searchText" id="searchText" value="" /> <label for="search">Search Amazon</label><br />
<input type="button" class="button" name="search" id="search" value="Search" onclick="getAmazon();" />
</p>
</div>

<div id="amazonResult" style="background-color: #ECECEC;">

</div>
<?php
}
?>

<h1 id="addbook">Enter Website Review Info</h1>
<form action="admin.php?ap=add_book" method="post" enctype="multipart/form-data"><p>
<label for="status2"><strong>Status of Review:</strong></label>
<select name="status" id="status">
<option value="reviewed"<?php if ($status == "reviewed") echo ' selected="selected"'; ?>>Reviewed</option>
<option value="pending"<?php if ($status == "pending") echo ' selected="selected"'; ?>>Pending Review</option></select>
</p>
<p><br />
<label for="reviewer"><strong>Reviewer:</strong></label>
<input name="reviewer" type="text" id="reviewer" size="25" value="<?php echo $reviewer; ?>" />
</p>
<p>
<br />


<label for="date"><strong>Date Reviewed:</strong></label>
<input name="publisher" type="text" id="publisher" size="15" value="<?php echo $date; ?>" />
</p>
<p><br />
<label for="screenshot"><strong>Link to Screenshot:</strong></label>
<input name="published" type="text" id="published" size="50" value="<?php echo $screenshot; ?>" />
</p>
<p> <br />
<label for="title2"><strong>Title of Site:</strong></label>
<input name="title" type="text" id="title" size="40" value="<?php echo $title; ?>" />
</p>
<p><br />
<label for="link2"><strong>Link to Site:</strong></label>
<input name="author" type="text" id="author" size="50" value="<?php echo $link; ?>" /> <label for="link"><br>
</label>
<br />
<label for="author2"><strong>Owner of Site:</strong></label>
<input name="genre" type="text" id="genre" size="25" value="<?php echo $owner; ?>" />
</p>
<p> <br />
<label for="e-mail2"><strong>Contact E-Mail:</strong></label>
<input name="pages" type="text" id="pages" size="40" value="<?php echo $contact; ?>" />
</p>
<p>
<strong>
<label><br />
Positive Aspects:
<br />
<textarea name="positive_aspects" id="positive_aspects" cols="45" rows="5"><?php echo $positive; ?></textarea>
</label>
</strong></p>
<p>
<strong>
<label>Negative Aspects:<br />
<textarea name="negative_aspects" id="negative_aspects" cols="45" rows="5"><?php echo $negative; ?></textarea>
</label>
</strong> </p>
<table width="200" border="1">
<caption>
<strong>Grading Scale: </strong>
</caption>
<tr>
<th scope="col">Total Score:</th>
<th scope="col">Letter Grade:</th>
</tr>
<tr>
<td>100+</td>
<td>A+</td>
</tr>
<tr>
<td>95-99</td>
<td>A</td>
</tr>
<tr>
<td>90-94</td>
<td>A-</td>
</tr>
<tr>
<td>87-89</td>
<td>B+</td>
</tr>
<tr>
<td>84-86</td>
<td>B</td>
</tr>
<tr>
<td>80-83</td>
<td>B-</td>
</tr>
<tr>
<td>77-79</td>
<td>C+</td>
</tr>
<tr>
<td>74-76</td>
<td>C</td>
</tr>
<tr>
<td>70-83</td>
<td>C-</td>
</tr>
<tr>
<td>67-69</td>
<td>D+</td>
</tr>
<tr>
<td>64-66</td>
<td>D</td>
</tr>
<tr>
<td>60-63</td>
<td>D-</td>
</tr>
<tr>
<td>0-59</td>
<td>F</td>
</tr>
</table>
<p>
<label><strong>Originality (out of 25):</strong>
<input name="originality" type="text" id="originality" size="7" maxlength="2" value="<?php echo $originality; ?>" />
</label>
</p>
<p>
<strong>
<label>Design &amp; Visual </label>
(out of 25)
<label>:
<input name="DesignVisual" type="text" id="DesignVisual" size="7" maxlength="2" value="<?php echo $design; ?>" />
</label>
</strong> </p>
<p>
<strong>
<label>Content </label>
(out of 25)
<label>:
<input name="content" type="text" id="content" size="7" maxlength="2" value="<?php echo $content; ?>" />
</label>
</strong> </p>
<p>
<strong>
<label>Navigation </label>
(out of 25):
<label>
<input name="navigation" type="text" id="navigation" size="7" maxlength="2" value="<?php echo $navigation; ?>" />
</label>
</strong> </p>
<p>
<strong>
<label>Bonus Points (up to 25):
<input name="bonuspoints" type="text" id="bonuspoints" size="7" maxlength="2" value="<?php echo $bonus; ?>" />
</label>
</strong> </p>
<p>
<strong>
<label>Total Score (out of 100):
<input name="total" type="text" id="total" size="7" maxlength="3" value="<?php echo $total; ?>" />
</label>
</strong> </p>
<p>
<label><strong>Grade:</strong>
<select name="grade" id="grade">
<option>"F"<?php if ($grade == 'F') echo ' selected="selected"'; ?>F</option>
<option>"D-"<?php if ($grade == 'D-') echo ' selected="selected"'; ?>D-</option>
<option>"D"<?php if ($grade == 'D') echo ' selected="selected"'; ?>D</option>
<option>"D+"<?php if ($grade == 'D+') echo ' selected="selected"'; ?>D+</option>
<option>"C-"<?php if ($grade == 'C-') echo ' selected="selected"'; ?>C-</option>
<option>"C"<?php if ($grade == 'C') echo ' selected="selected"'; ?>C</option>
<option>"C+"<?php if ($grade == 'C+') echo ' selected="selected"'; ?>C+</option>
<option>"B-"<?php if ($grade == 'B-') echo ' selected="selected"'; ?>B-</option>
<option>"B"<?php if ($grade == 'B') echo ' selected="selected"'; ?>B</option>
<option>"B+"<?php if ($grade == 'B+') echo ' selected="selected"'; ?>B+</option>
<option>"A-"<?php if ($grade == 'A-') echo ' selected="selected"'; ?>A-</option>
<option>"A"<?php if ($grade == 'A') echo ' selected="selected"'; ?>A</option>
<option>"A+"<?php if ($grade == 'A+') echo ' selected="selected"'; ?>A+</option>
</select>
</label>
</p>
<p><input type="submit" class="button" name="submit" id="submit" value="Add" /></p>
</form>

mariahneu
05-03-2009, 11:42 PM
(admin.php continued)


<?php
}
break;
case "manage_books":
$bookfile = file(BOOKS);
$bookcount = count($bookfile);
$numpages = ceil($bookcount/$perpage);

echo '<p class="pagination">';

if (!isset($_GET['page']) || !is_numeric($_GET['page'])) $page = 1;
else $page = $_GET['page'];

if ($perpage < $bookcount) {
if ($page > 1 && $page <= $numpages) {
$prev = $page - 1;
echo '<a href="admin.php?ap=manage_books&amp;page='.$prev.'"><img src="images/previous.gif" alt="Previous" /></a> &middot; ';
} else {
echo '<img src="images/previous.gif" alt="Previous" /> &middot; ';
}
for ($x=1; $x<=$numpages; $x++) {
if ($page == $x) {
echo '<span class="bold">'.$x.'</span> ';
} else {
echo '<a href="admin.php?ap=manage_books&amp;page='.$x.'">'.$x.'</a> ';
}
}
if ($page < $numpages) {
$next = $page + 1;
echo ' &middot; <a href="admin.php?ap=manage_books&amp;page='.$next.'"><img src="images/next.gif" alt="Next" /></a>';
} else {
echo ' &middot; <img src="images/next.gif" alt="Next" />';
}
}
echo '<br /><span class="bold">'; if ($bookcount == 1) echo ' Book'; else echo ' Websites'; echo ' Reviewed: '.$bookcount.'</span></p>'
?>

<table id="books">
<tr><th>Status</th> <th>Reviewer</th> <th>Review Date</th> <th>Screenshot</th> <th>Title</th> <th>Site Link</th> <th>+</th> <th>-</th> <th class="center">Originality</th> <th class="center">Design & Visual</th> <th class="center">Content</th> <th class="center">Navigation</th> <th class="center">Bonus Points</th> <th class="center">Grade</th> <th class="center">Admin</th></tr>
<?php
$i = $perpage * ($page - 1);
$end = $i + $perpage;
if ($end > $bookcount) $end = $bookcount;

while ($i < $end){
list($status,$reviewer,$date,$screenshot,$title,$link,$owner,$contact,$positive,$negative,$originali ty,$design,$content,$navigation,$bonus,$total,$grade) = preg_split("/,(?! )/", $bookfile[$i]);
$review = trim(stripslashes($review), "\"\x00..\x1F");



echo "<tr>";
echo '<td>'.$status.'</td>';
echo '<td>'.$reviewer.'</td>';
echo '<td>'.$date.'</td>';
echo '<td>'.$screenshot.'</td>';
echo '<td>'.$title.'</td>';
echo '<td>'.$link.'</td>';
echo '<td>'.$owner.'</td>';
echo '<td>'.$contact.'</td>';
echo '<td>'.$positive.'</td>';
echo '<td>'.$negative.'</td>';
echo '<td>'.$originality.'</td>';
echo '<td>'.$design.'</td>';
echo '<td>'.$content.'</td>';
echo '<td>'.$navigation.'</td>';
echo '<td>'.$bonus.'</td>';
echo '<td>'.$total.'</td>';
echo '<td>'.$grade.'</td>';
echo '<td class="center"><a href="admin.php?ap=edit_book&amp;b='.$i.'"><img src="images/edit.png" alt="edit" /></a> <a href="admin.php?ap=delete_book&amp;b='.$i.'" onclick="javascript:return confirm(\'Are you sure?\')"><img src="images/delete.png" alt="delete" /></a></td>';
echo "</tr>\n";

$i++;
}
?>
</table>
<?php
break;
case "edit_book":
if (!isset($_GET['b']) || !is_numeric($_GET['b'])) exit("<p>Invalid book id.</p>");
else $bookid = $_GET['b'];

foreach ($_POST as $key => $val) {
$c[$key] = cleanUp($val);
}
$show_form = true;
$error_msg = NULL;

if (isset($c['submit'])) {
if ($c['status'] != "reviewed" && $c['status'] != "pending") {
$error_msg .= "Invalid status - reviewed or pending only.";
} elseif (!ereg("^[A-Za-z0-9_-]", $c['publisher'])) {
$error_msg .= "Invalid characters in Publisher field.";

if ($error_msg == NULL) {
$show_form = false;

ignore_user_abort(true);
$bfl = fopen(BOOKS, "r");
while(!feof($bfl)) {
$bookarray[] = fgets($bfl, 4096);
}}
break;
case "delete_book":
}
fclose($bfl);

$c['review'] = str_replace("<br /><br /><br /><br />", "<br /><br />", preg_replace("/,(?! )/", ", ", preg_replace("([\r\n])", "<br />", $c['review'])));
$bookarray[$bookid] = $c['status'].",".$c['reviewer'].",".$c['date'].",".$c['screenshot'].",".$c['title'].",".$c['owner'].",".$c['contact'].",".$c['positive'].",".$c['negative'].',"'.$c['originality'].',"'.$c['design'].',"'.$c['content'].',"'.$c['navigation'].',"'.$c['bonus'].',"'.$c['total'].',"'.$c['grade'].'"'."\n";
$newBooks = trim(implode($bookarray));


$fp = fopen(BOOKS, "w") or die ("Couldn't open ".BOOKS);
if (flock($fp, LOCK_EX)) {
fwrite($fp, $newBooks);
flock($fp, LOCK_UN);
}
fclose($fp);

echo '<p>Review edited. <a href="admin.php?ap=manage_books">Manage more books?</a></p>';
ignore_user_abort(false);
}
}
if (!isset($c['submit']) || $show_form == true) {
if ($error_msg != NULL) {
echo "<p><strong style='color: red;'>ERROR:</strong><br />";
echo nl2br($error_msg) . "</p>";
}

$books = file(BOOKS);
if (empty($books[$bookid])) {
echo "<p>That review does not exist.</p>";
exit(include('footer.php'));
}

?>

<h1 id="addbook">Enter Website Review Info</h1>
<form action="admin.php?ap=add_book" method="post" enctype="multipart/form-data"><p>
<label for="status2"><strong>Status of Review:</strong></label>
<select name="status" id="status">
<option value="reviewed"<?php if ($status == "reviewed") echo ' selected="selected"'; ?>>Reviewed</option>
<option value="pending"<?php if ($status == "pending") echo ' selected="selected"'; ?>>Pending Review</option></select>
</p>
<p><br />
<label for="reviewer2"><strong>Reviewer:</strong></label>
<input name="isbn" type="text" id="isbn" size="25" value="<?php echo $reviewer; ?>" />
</p>
<p>
<br />

<label for="date2"><strong>Date Reviewed:</strong></label>
<input name="publisher" type="text" id="publisher" size="15" value="<?php echo $date; ?>" />
</p>
<p><br />
<label for="screenshot2"><strong>Link to Screenshot:</strong></label>
<input name="published" type="text" id="published" size="50" value="<?php echo $screenshot; ?>" />
</p>
<p> <br />
<label for="title2"><strong>Title of Site:</strong></label>
<input name="title" type="text" id="title" size="40" value="<?php echo $title; ?>" />
</p>
<p><br />
<label for="link2"><strong>Link to Site:</strong></label>
<input name="author" type="text" id="author" size="50" value="<?php echo $link; ?>" /> <label for="link"><br>
</label>
<br />
<label for="author2"><strong>Owner of Site:</strong></label>
<input name="genre" type="text" id="genre" size="25" value="<?php echo $owner; ?>" />
</p>
<p> <br />
<label for="e-mail2"><strong>Contact E-Mail:</strong></label>
<input name="pages" type="text" id="pages" size="40" value="<?php echo $contact; ?>" />
</p>
<p>
<strong>
<label><br />
Positive Aspects:
<br />
<textarea name="positive_aspects" id="positive_aspects" cols="45" rows="5"><?php echo $positive; ?></textarea>
</label>
</strong></p>
<p>
<strong>
<label>Negative Aspects:<br />
<textarea name="negative_aspects" id="negative_aspects" cols="45" rows="5"><?php echo $negative; ?></textarea>
</label>
</strong> </p>
<table width="200" border="1">
<caption>
<strong>Grading Scale: </strong>
</caption>
<tr>
<th scope="col">Total Score:</th>
<th scope="col">Letter Grade:</th>
</tr>
<tr>
<td>100+</td>
<td>A+</td>
</tr>
<tr>
<td>95-99</td>
<td>A</td>
</tr>
<tr>
<td>90-94</td>
<td>A-</td>
</tr>
<tr>
<td>87-89</td>
<td>B+</td>
</tr>
<tr>
<td>84-86</td>
<td>B</td>
</tr>
<tr>
<td>80-83</td>
<td>B-</td>
</tr>
<tr>
<td>77-79</td>
<td>C+</td>
</tr>
<tr>
<td>74-76</td>
<td>C</td>
</tr>
<tr>
<td>70-83</td>
<td>C-</td>
</tr>
<tr>
<td>67-69</td>
<td>D+</td>
</tr>
<tr>
<td>64-66</td>
<td>D</td>
</tr>
<tr>
<td>60-63</td>
<td>D-</td>
</tr>
<tr>
<td>0-59</td>
<td>F</td>
</tr>
</table>
<p>
<label><strong>Originality (out of 25):</strong>
<input name="originality" type="text" id="originality" size="7" maxlength="2" value="<?php echo $originality; ?>" />
</label>
</p>
<p>
<strong>
<label>Design &amp; Visual </label>
(out of 25)
<label>:
<input name="DesignVisual" type="text" id="DesignVisual" size="7" maxlength="2" value="<?php echo $design; ?>" />
</label>
</strong> </p>
<p>
<strong>
<label>Content </label>
(out of 25)
<label>:
<input name="content" type="text" id="content" size="7" maxlength="2" value="<?php echo $content; ?>" />
</label>
</strong> </p>
<p>
<strong>
<label>Navigation </label>
(out of 25):
<label>
<input name="navigation" type="text" id="navigation" size="7" maxlength="2" value="<?php echo $navigation; ?>" />
</label>
</strong> </p>
<p>
<strong>
<label>Bonus Points (up to 25):
<input name="bonuspoints" type="text" id="bonuspoints" size="7" maxlength="2" value="<?php echo $bonus; ?>" />
</label>
</strong> </p>
<p>
<strong>
<label>Total Score (out of 100):
<input name="total" type="text" id="total" size="7" maxlength="3" value="<?php echo $total; ?>" />
</label>
</strong> </p>
<p>
<label><strong>Grade:</strong>
<select name="grade" id="grade">
<option>&quot;F&quot;<?php if ($grade == F) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)F</option>
<option>&quot;D-&quot;<?php if ($grade == AD) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)D-</option>
<option>&quot;D&quot;<?php if ($grade == D) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)D</option>
<option>&quot;D&quot;<?php if ($grade == AB) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)D+</option>
<option>&quot;C-&quot;<?php if ($grade == DCD) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)C-</option>
<option>&quot;C&quot;<?php if ($grade == C) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)C</option>
<option>&quot;C+&quot;<?php if ($grade == FDF) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)C+</option>
<option>&quot;B-&quot;<?php if ($grade == DFD) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)B-</option>
<option>&quot;B&quot;<?php if ($grade == B) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)B</option>
<option>&quot;B+&quot;<?php if ($grade == DDS) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)B+</option>
<option>&quot;A-&quot;<?php if ($grade == DSD) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)A-</option>
<option>&quot;A&quot;<?php if ($grade == A) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)A</option>
<option>&quot;A+&quot;<?php if ($grade == SDF) echo ' selected="selected"'; ?>(&amp = '&', &lt = '<', &gt = '>', &quot = quotation mark)A+</option>
</select>
</label>
</p>
<p><input type="submit" class="button" name="submit" id="submit" value="Add" /></p>
</form>


<?php
}
break;
case "delete_book":
if (!isset($_GET['b']) || !is_numeric($_GET['b'])) exit("<p>Invalid review ID.</p>");
else $bookid = $_GET['b'];

$books = file(BOOKS);
if (empty($books[$bookid])) {
echo "<p>That review does not exist.</p>";
exit(include('footer.php'));
}
unset($books[$bookid]);
echo '<p>Book deleted. <a href="admin.php?ap=manage_books">Manage more reviews?</a></p>';

$newBooks = trim(implode($books));
ignore_user_abort(true);
$fp = fopen(BOOKS, "w") or die ("Couldn't open ".BOOKS);
if (flock($fp, LOCK_EX)) {
fwrite($fp, $newBooks);
flock($fp, LOCK_UN);

break;
}
fclose($fp);
ignore_user_abort(false);
case "recommended":
$key = md5(date("Y-m-d H"));

if (isset($_GET['key']) && $_GET['key'] == $key) {
ignore_user_abort(true);
$fp = fopen(RECBOOKS, "w") or die ("Couldn't open ".RECBOOKS);
if (flock($fp, LOCK_EX)) {
fwrite($fp, "");
flock($fp, LOCK_UN);
}
fclose($fp);
ignore_user_abort(false);
}
$recbooks = file(RECBOOKS);
$recbookcount = count($recbooks);
$i = 0;
?>
<h1>View Pending Reviews</h1>
<?php
if ($recbookcount == 0) {
echo '<p>No pending website reviews.</p>';
} else {
echo '<p>';
while ($i < $recbookcount){
list($yourtitle,$yourlink,$yourname,$yourcontact,$ourlink) = preg_split("/,(?! )/", $recbooks[$i]);

if (!empty($yourtitle)) echo '<a href="mailto:'.fixEmail($yourcontact).'">'.$yourname.'</a> recommended: <strong>';
else echo $yourname.' recommended: <strong>';

echo stripslashes($yourlink).'</strong> by <em>'.stripslashes($ourlink).'</em>';


$i++;
}
echo '</p>';
echo '<p><a href="admin.php?ap=recommended&amp;key='.$key.'">Empty pending reviews file</a></p>';
}
break;
default:
echo "<h1>Review Admin Panel</h1>";
?>
<ul>
<li><a href="admin.php?ap=add_book">Add Review</a></li>
<li><a href="admin.php?ap=manage_books">Manage Reviews</a></li>
</ul>
<ul>
<li><a href="admin.php?ap=recommended">Pending Reviews</a></li>
</ul>
<ul>
<li><a href="logout.php">Logout</a></li>
<li><a href="index.php">View Review Website</a></li>
</ul>
<?php
break;
}
echo '<p><a href="admin.php">Control Panel Home</a></p>';
include('footer.php');
exit;
} else {
echo "<p>Bad cookie. Clear 'em out and start again.</p>";
include('footer.php');
exit;
}
}
if (isset($_GET['p']) && $_GET['p'] == "login") {
if ($_POST['name'] != $admin_name || $_POST['pass'] != $admin_pass) {
include('header.php');
echo "<p>Sorry, that username and password combination does not match. Please try again.</p>";
?>
<form action="admin.php?p=login" method="post"><fieldset>
<label><input type="text" name="name" id="name" /> Name</label><br />
<label><input type="password" name="pass" id="pass" /> Password</label><br />
<input type="submit" id="submit" class="button" value="Login" />
</fieldset></form>
<?php
include('footer.php');
exit;
} elseif ($_POST['name'] == $admin_name && $_POST['pass'] == $admin_pass) {
setcookie('bellabiblio', md5($_POST['name'].$_POST['pass'].$secret), time()+(31*86400));
header("Location: admin.php");
} else {
include('header.php');
echo "<p>Sorry, you could not be logged in at this time. Please try again.</p>";
?>
<form action="admin.php?p=login" method="post"><fieldset>
<label><input type="text" name="name" id="name" /> Name</label><br />
<label><input type="password" name="pass" id="pass" /> Password</label><br />
<input type="submit" id="submit" class="button" value="Login" />
</fieldset></form>
<?php
include('footer.php');
exit;
}
exit;
}
include('header.php');
?>

<form action="admin.php?p=login" method="post"><p>
<label><input type="text" name="name" id="name" /> Name</label><br />
<label><input type="password" name="pass" id="pass" /> Password</label><br />
<input type="submit" id="submit" class="button" value="Login" />
</p></form>

<?php
include('footer.php');
?>

venegal
05-04-2009, 12:35 AM
PLEASE use php tags instead of quote tags and make sure you don't lose the indentation of the original code. That's really ugly to look at.

That said, there are several things off here:

First of all there is three times $originali ty instead of $originality, two times in config.php, one time in admin.php.

Secondly you are missing a brace in admin.php:


}}
break;
case "delete_book":

mariahneu
05-04-2009, 01:33 AM
PLEASE use php tags instead of quote tags and make sure you don't lose the indentation of the original code. That's really ugly to look at.

That said, there are several things off here:

First of all there is three times $originali ty instead of $originality, two times in config.php, one time in admin.php.

Secondly you are missing a brace in admin.php:


}}
break;
case "delete_book":


My apologies, I did not notice the PHP tag; just fixed it.

However, where do you place

}}
break;
case "delete_book": ?

Oh, and the coding just copied strangely; no error with $originality values.

venegal
05-04-2009, 02:07 AM
Sorry, I didn't see that case "delete_book": appears several times in admin.php. I meant the second time. But you can disregard that, because now indentation suggests, that the brace is actually missing somewhere else:


if (isset($c['submit'])) {
if ($c['status'] != "reviewed" && $c['status'] != "pending") {
$error_msg .= "Invalid status - reviewed or pending only.";
} elseif (!ereg("^[A-Za-z0-9_-]", $c['publisher'])) {
$error_msg .= "Invalid characters in Publisher field.";

You don't close the elseif there.

mariahneu
05-04-2009, 02:17 AM
I closed the elseif, but now it says there's an error in line 260


}}
break;
case "manage_books":

venegal
05-04-2009, 02:39 AM
Oh, you changed the code there, that's why before I didn't see that case "delete_book": appears twice -- because it didn't, and it shouldn't. For some reason, you put


}}
break;
case "delete_book":

at some random place in your script. Remove that.

Edit: And why is there suddenly a second right brace in the snippet in your last post? That wasn't there before, and shouldn't be. Are you sure, you know what you are doing? It looks a bit as if you were just trying random stuff that breaks the code more probably than it fixes it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum