<?php
/*
copyright: copyright 2004 Php Image Host. All Rights Reserved. You may modify this file for use on your
					site running a licenced copy of the Php Image Host scripts.
					You must not distribute this file or derivations of it.
Nullified By CrAcKlOvE
*/

require_once(dirname(__FILE__).'/includes/config.inc.php');
require_once(dirname(__FILE__).'/../classes/pagecontent.class.php');
require_once(dirname(__FILE__).'/includes/header.inc.php');

$pc =& new pagecontent($ace);
$name = $ace->getstr('name', $_POST);
$description = $ace->getstr('description',$_POST);
$cid = $ace->getint('content_id', $_REQUEST);

if( $ace->getstr('create', $_POST) ){
	if( $name != '' ){
		$cid = $pc->addcontent($name, $description);
	}
}

$cont = $pc->getcontentbyid($cid);
if( !$cont ) $cid = 0;

if( $cid ){
	if( $ace->getstr('update', $_POST) ){
		$content = $ace->getstr('content', $_POST);
		if( $pc->updatecontent($cid, $content) ){
			$statusmessage = 'Content for page "'.$cont->name.'" updated.';
			$cont->content = $content;
		}
	}elseif( $ace->getstr('delete', $_GET) ){
		$pc->deletecontent($cid);
		$cid = $cont = 0;
	}
}

$all = $pc->getallcontent();

?>
<div style="text-align: center;">
<b>Edit Page Content</b><br /><br />
On this page you can edit the content displayed on many of the pages of your site.

To edit the content for a particular page, select its name from the drop down list. If you are adding
additional pages to this site, you can create a new page content to use on that page. See the terms.php
script for a simple example of adding your own page.
<br /><br />
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="get">
<b>Edit Content:</b>
		<select name="content_id" onChange="this.form.submit();">
			<option value="0">Create New Page Content</option>
<?php
foreach( $all as $c ){
?>
			<option value="<?php echo $c->content_id;?>"<?php if( $c->content_id == $cid ) echo ' SELECTED ';?>>
<?php echo htmlspecialchars($c->name.' - '.$c->description);?>
			</option>
<?php
}
?>
		</select>
		<input type="submit" value="Edit" />
		<input type="submit" name="delete" value="Delete" onClick="return confirm('Are you sure you want to delete the selected page content?');" />
</form>
<br />
<?php if( $cid != 0 ){ ?>
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="POST">
<input type="hidden" name="content_id" value="<?php echo $cid;?>" />
<textarea name="content" style="width: 600px; height: 400px;"><?php echo htmlspecialchars($cont->content);?></textarea>
<br /><br />
<input type="submit" name="update" value="Update Content" />
<br /><br />
The following tags will be replaced by the relevant values:
<br />
<table style="width: 90%; background-color: #aaaaaa;" align="center" cellspacing="1" cellpadding="0" border="0">
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">Tag</td>
	<td style="font-weight: bold; text-align: left;">Value</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{paid_account_name}</td>
	<td style="font-weight: bold; text-align: left;">Your name for a paid account</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{free_account_name}</td>
	<td style="font-weight: bold; text-align: left;">Your name for a free acount</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{paid_account_cost}</td>
	<td style="font-weight: bold; text-align: left;">The price of a paid account</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{sitename}</td>
	<td style="font-weight: bold; text-align: left;">The name of this site.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{siteurl}</td>
	<td style="font-weight: bold; text-align: left;">The URL of this site.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{thumbnail_width} / {thumbnail_height}</td>
	<td style="font-weight: bold; text-align: left;">The width and height for thumbnail images.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td colspan="2" style="text-align: left; padding: 5px; background-color: #aaaaff;font-weight: bold;">The following show plan specifications for free or paid account. Replace the word "prefix" with either "free" or "paid", eg. {prefix_max_images} should be either {free_max_images} or {paid_max_images}.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{prefix_type_name}</td>
	<td style="font-weight: bold; text-align: left;">The name for this type of account (free or paid)</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{prefix_max_images}</td>
	<td style="font-weight: bold; text-align: left;">Maximum images this plan allows.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{prefix_bandwidth}</td>
	<td style="font-weight: bold; text-align: left;">Monthly bandwidth allowance.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{prefix_storage}</td>
	<td style="font-weight: bold; text-align: left;">Storage space for this plan.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{prefix_max_upload_size}</td>
	<td style="font-weight: bold; text-align: left;">The maximum uploaded filesize this plan allows.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{prefix_max_image_width} / {prefix_max_image_height}</td>
	<td style="font-weight: bold; text-align: left;">The maximum allowed width and height for uploaded images with this plan.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{prefix_simultaneous_uploads}</td>
	<td style="font-weight: bold; text-align: left;">The number of images a user on this plan can upload at once.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td colspan="2" style="text-align: left; padding: 5px; background-color: #aaaaff;font-weight: bold;">The following are only valid on pages shown only to logged in members:</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{username}</td>
	<td style="font-weight: bold; text-align: left;">Member's username</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{email}</td>
	<td style="font-weight: bold; text-align: left;">The member's email address.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{user_type_name}</td>
	<td style="font-weight: bold; text-align: left;">The name for the user's account (free or paid)</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{user_max_images}</td>
	<td style="font-weight: bold; text-align: left;">Maximum images the user can upload.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{user_bandwidth}</td>
	<td style="font-weight: bold; text-align: left;">Monthly bandwidth allowance (mb).</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{user_storage}</td>
	<td style="font-weight: bold; text-align: left;">Storage space allowance (mb).</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{user_bandwidth_used}</td>
	<td style="font-weight: bold; text-align: left;">Bandwidth used this month (mb).</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{user_storage_used}</td>
	<td style="font-weight: bold; text-align: left;">Storage space used (mb).</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{user_max_upload_size}</td>
	<td style="font-weight: bold; text-align: left;">The maximum filesize the user can upload.</td>
</tr>
<tr style="background-color: #ffffff;">
	<td style="font-weight: bold; text-align: left;">{user_max_image_width} / {user_max_image_height}</td>
	<td style="font-weight: bold; text-align: left;">The maximum allowed width and height for uploaded images.</td>
</tr>

</table>
</form>
<?php }else{ ?>
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
<table class="formtable" align="center" cellspacing="1" cellpadding="0">
<tr>
<td class="formheading" colspan="2">Add A New Page Content Item</td>
</tr>
<tr>
	<td class="formfield" colspan="2">You can use this form to add a new page content template to the database if you
		are adding one or more custom pages to your site and want to use this editor to edit the content.<br />
		See the "terms.php" file for a basic example of a page using one of these page content templates.
	</td>
</tr>
<tr>
<td class="formlabel">Page Content Name:</td>
<td class="formfield"><input type="text" name="name" value="<?php echo htmlspecialchars($name);?>" />
<br />This is the name you will use to display the content.
</td>
</tr>
<tr>
<td class="formlabel">Description:</td>
<td class="formfield">
<textarea name="description" style="width: 400px; height: 50px;"><?php echo htmlspecialchars($description);?></textarea>
<br />A short description of what this page content is used for.
</td>
</tr>
<tr>
<td class="formlabel">&nbsp;</td>
<td class="formfield"><input type="submit" name="create" value="Create Page Content" /></td>
</tr>
</table>
</form>
</div>
<?php
}
require_once(dirname(__FILE__).'/includes/footer.inc.php');

?>
