Location: PHPKode > projects > Somery > somery/upload/admin/additionals.php
<?php
// Somery, a weblogging script by Robin de Graaf, copyright 2001-2006
// Somery is distributed under the Artistic License (see LICENSE.txt)
//
// ADMIN/ADDITIONALS.PHP > 08-03-2006

$start = TRUE; 
include("system/include.php"); 
if ($checkauth) {

if (!$action) { 
	echo "<strong>Additionals</strong><br />
	Additionals are simply pages that you can call by linking index.php?call=calltitle. So if you want an about page, create an additional that has a calltitle of about, and you can just do index.php?call=about and it'll show up. Additionals may contain BB code.<br /><br /><table width=\"100%\"><tr><td><a href=\"additionals.php?action=new\">Create new additional</a><br /><br />"; 
	$result = mysql_query("SELECT * FROM ".$prefix."additionals ORDER BY title");
	$total = mysql_num_rows($result);
	if ($total == 0) { 
		echo "No additionals.";
	} else {
		while($row=mysql_fetch_object($result)) { 
			echo "<tr><td>- $row->calltitle ($row->title)</td><td width=\"40\">"; 
			echo "<a href='additionals.php?action=edit&adid=$row->adid'>edit</a>"; 
			echo "</td></tr>"; 
		}
	}
	echo "</table><br>"; 
} elseif ($action == "new") {
	echo "<table><tr><td><form method='post' action='additionals.php'><input type='hidden' name='action' value='create'><input type='hidden' name='adid' value='$adid'></td></tr></table>"; 
	echo "<b>New Additional</b><br><table>"; 
	echo "<tr><td width=100>Additional title</td><td><input size=50 name='addtitle' type='text' value='$row->title'></td></tr>"; 
	echo "<tr><td width=100>Call title (NO spaces/other)</td><td><input size=50 name='addcall' type='text' value='$row->calltitle'></td></tr>"; 
	echo "<tr><td width=100 valign=\"top\">Additional body</td><td><textarea name='addbody' rows=20 cols=58>$row->body</textarea></td></tr>
	<tr><td width=175>&nbsp</td><td><input type='submit' value='create'></td></tr> 
	</table>"; 
} elseif ($action == "create") { 
	if (!$addtitle && !$err) { echo $error[11]; $err = 1; } 
	if (!$addcall && !$err) { echo $error[18]; $err = 1; } 
	if (!$err) { 
	$addtitle = debbcode($addtitle);
	$addtitle = cleanstring($addtitle);
	$addbody = cleanstring($addbody);
	$addbody = addslashes($addbody);

	$result = mysql_query("INSERT INTO ".$prefix."additionals (title,calltitle,body,created,modified) VALUES ('$addtitle', '$addcall', '$addbody', '".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."')");
      echo "Additional created, redirecting...<meta http-equiv=Refresh content=1;URL='additionals.php'>"; 
	} 
} elseif ($action == "edit") { 
	echo "<table><tr><td><form method='post' action='additionals.php'><input type='hidden' name='action' value='update'><input type='hidden' name='adid' value='$adid'></td></tr></table>"; 
	echo "<b>Edit Additional</b><br><table>"; 
	$result = mysql_query("SELECT * FROM ".$prefix."additionals WHERE adid='$adid'"); 
	while($row=mysql_fetch_object($result)) { 
		echo "<tr><td width=100>Additional title</td><td><input size=50 name='addtitle' type='text' value='$row->title'></td></tr>"; 
		echo "<tr><td width=100>Call title (NO spaces/other)</td><td><input size=50 name='addcall' type='text' value='$row->calltitle'></td></tr>"; 
		echo "<tr><td width=100 valign=\"top\">Additional text</td><td><textarea name='addbody' rows=20 cols=58>$row->body</textarea></td></tr>"; 
	} 
	echo " 
	<tr><td width=175><br>Delete this additional</td><td><br><input type='checkbox' name='delete'></td></tr> 
	<tr><td width=175>&nbsp</td><td><input type='submit' value='edit'></td></tr> 
	</table>"; 
} elseif ($action == "update") { 
	if ($delete) { 
		$result = mysql_query("DELETE FROM ".$prefix."additionals WHERE adid = '$adid'"); 
		echo "Additional deleted, redirecting...<meta http-equiv=Refresh content=1;URL='additionals.php'>"; 
	} else { 
	if (!$addtitle && !$err) { echo $error[11]; $err = 1; } 
	if (!$err) { 
		$addtitle = debbcode($addtitle);
		$addtitle = cleanstring($addtitle);
		$addbody = cleanstring($addbody);
		$addbody = addslashes($addbody);
		$result = mysql_query("UPDATE ".$prefix."additionals SET  
			title='$addtitle', 
			calltitle='$addcall', 
			body='$addbody',
			modified='".date("Y-m-d H:i:s")."'
		WHERE adid = '$adid'"); 
	      echo "Additional updated, redirecting...<meta http-equiv=Refresh content=1;URL='additionals.php'>"; 
	} 
	} 
} 
?> 
 
<?php }; $start = FALSE; include("system/include.php"); ?>
Return current item: Somery