<?php
/**
* Edit Main Page
* original author Adam Morton <am26882@appstate.edu>
* modified by endonesia dot com
*/
function main_page_data()
{
include("header.php");
$result = mysql_query("select main_title, main_text, main_image, main_image_active, alt, active from main_page_content");
list($main_title, $main_text, $main_image, $main_image_active, $main_alt, $active) = mysql_fetch_row($result);
$main_title = htmlspecialchars(stripslashes($main_title));
$main_text = htmlspecialchars(stripslashes($main_text));
$main_alt = htmlspecialchars(stripslashes($main_alt));
$box_title = "
<table width=100%>
<tr>
<td><b>Edit Main Page</b></td>
<td align="right"><a href="admin.php"><b>Back to Admin Menu</b></a></td>
</tr>
</table>";
$box_stuff = "
<form action="admin.php" method="post" enctype="multipart/form-data">
<table align="center" cellspacing="10">
<tr><td>";
if($active){
$box_stuff .= "<input type="checkbox" name="active" value="1" checked="checked" />";
}
else{
$box_stuff .= "<input type="checkbox" name="active" value="1" />";
}
$box_stuff .= "Make this content active?
</td></tr>
<tr><td class="type5" valign="top" align="left" width="50%">
Main Title: <br />
<input type="text" name="main_title" value="$main_title" maxlength="200" size="50" /><br/><br />
Main Text: <br />
<textarea name="main_text" cols="60" rows="20" wrap="virtual">$main_text</textarea><br /><br />
Main Image: <br />";
if($main_image != "none"){
$box_stuff .= "
<img src="$main_images_webdir$main_image" alt="$main_alt" /><br />
<input type="hidden" name="old_main_image" value="$main_image" />
<input type="file" name="main_image" maxlength="60" size="25" />
<br /><br />
Image Short Description:<br />
<input type="text" name="main_alt" maxlength="60" size="33" value="$main_alt" />";
} else {
$box_stuff .= "<input type="file" name="main_image" maxlength="60" size="25" />
<br />
<input type="hidden" name="old_main_image" value="0" />
Image Short Description:<br />
<input type="text" name="main_alt" maxlength="60" size="33" value="$main_alt" />";
}
if($main_image_active)
{
$box_stuff .= "<br /><br /><input type="checkbox" name="main_image_active" value="1" checked="checked" />";
}
else
{
$box_stuff .= "<br /><br /><input type="checkbox" name="main_image_active" value="1" />";
}
$box_stuff .= " Make this image active?</td></tr>
<tr><td class=tengahtop></td></tr>
<tr><td>
<select name="op">
<option value="update_main_data">Update Text Only</option>
<option value="update_main_image">Update Text and Image</option>
</select>
<input type="submit" value="Update" />
</td></tr>
</table>
</form>";
themesidebox($box_title, $box_stuff);
include ('footer.php');
}
function update_main_data($main_title, $main_text, $main_alt, $main_image_active, $active)
{
include("config.php");
if(substr_count($main_title, "<?")) $main_title = str_replace("<?", "<NOPHP", $main_title);
if(substr_count($main_text, "<?")) $main_text = str_replace("<?", "<NOPHP", $main_text);
if(substr_count($main_alt, "<?")) $main_alt = str_replace("<?", "<NOPHP", $main_alt);
$main_title = addslashes($main_title);
$main_text = addslashes($main_text);
if(!$active) $active='0';
if(!$main_image_active) $main_image_active='0';
mysql_query("update main_page_content set main_title='$main_title', main_text='$main_text', alt='$main_alt', main_image_active='$main_image_active', active='$active'");
}
function update_main_image($main_title, $main_text, $main_image, $main_alt, $main_image_name, $main_image_active, $main_image_type, $main_image_size, $active)
{
include("config.php");
if(substr_count($main_title, "<?")) $main_title = str_replace("<?", "<NOPHP", $main_title);
if(substr_count($main_text, "<?")) $main_text = str_replace("<?", "<NOPHP", $main_text);
if(substr_count($main_alt, "<?")) $main_alt = str_replace("<?", "<NOPHP", $main_alt);
$main_title = addslashes($main_title);
$main_text = addslashes($main_text);
if($main_image_size > $max_user_file_size)
page_error("$main_image_name : The image in the section is too large. <br />
The largest allowable size is: $max_user_file_size bytes.<br />
Your file is: $main_image_size bytes.");
$this_image_type = explode(";", $main_image_type);
if(substr_count($allowed_types, $this_image_type[0]) > 0)
{
if(copy($main_image, $main_page_images.$main_image_name))
mysql_query("update main_page_content set main_title='$main_title', main_text='$main_text', main_image='$main_image_name', main_image_active='$main_image_active', alt='$main_alt', active='$active'");
else
page_error("$main_image_name : The image did not load sucessfully. Please try again.<br />");
}
else
page_error("$main_image_name : The image in the section has a wrong file type.<br />
The allowed types are:$allowed_types<br />
You file is of type: $this_image_type[0]");
}
function page_error($type)
{
include ("header.php");
echo "
<table border="0" width="100%" cellpadding="5" cellspacing="1">
<tr><td class="type4"><font color="red">Data Error!!</font></td></tr>
<tr><td class="type5" align="center">
<b>The following error has occurred:</b><br /><br />
$type
<br /><br />
Please hit the back button on your browser and re-submit your data.
</td></tr>
</table>";
include("footer.php");
exit();
}
function save_new_page()
{
include ("header.php");
$box_title = "
<table width=100%>
<tr>
<td><a href="admin.php?op=main_page_data"><b>Edit Main Page</b></a></td>
<td align="right"><a href="admin.php"><b>Back to Admin Menu</b></a></td>
</tr>
</table>";
$box_stuff = "<br />Your page has been saved!";
themesidebox($box_title, $box_stuff);
include("footer.php");
}
?>