<?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__).'/includes/header.inc.php');

$sql = "SELECT * FROM account_types  ";
$res = $ace->query($sql, 'Get Account Types');

if( mysql_num_rows($res)<2 ) die("Error retrieving account details from database.");

$plans = array();
while( $p = mysql_fetch_object($res) ) $plans[$p->type_type] = $p;

if( $ace->getstr('update', $_POST) != '' ){
	$ints = array('max_images', 'max_upload_size', 'max_image_width','max_image_height','bandwidth', 'storage',
								'email_friends','auto_jpeg', 'auto_resize', 'jpeg_quality','add_branding',
								'simultaneous_uploads', 'images_per_page', 'max_galleries', 'rename_images', 'resize_images');
	foreach( $ints as $i ){
		$n1 = $i.'1';
		$n2 = $i.'2';
		$plans['free']->$i = $ace->getint($n1, $_POST);
		$plans['paid']->$i = $ace->getint($n2, $_POST);
	}
	$plans['free']->type_name = $ace->getstr('type_name1', $_POST, 'Free');
	$plans['paid']->type_name = $ace->getstr('type_name2', $_POST, 'Paid');
	$plans['paid']->cost_1 = $ace->getdouble('cost_1', $_POST, 4.95);
	$plans['paid']->cost_3 = $ace->getdouble('cost_3', $_POST, 4.95);
	$plans['paid']->cost_6 = $ace->getdouble('cost_6', $_POST, 4.95);
	$plans['paid']->cost_12 = $ace->getdouble('cost_12', $_POST, 4.95);
	if( $plans['free']->type_name == '' || $plans['paid']->type_name == '' ){
		echo '<div class="errors">You must enter a name for each plan.</div>';
	}else{
		$sql = "UPDATE account_types SET type_name='".addslashes($plans['free']->type_name)."' ";
		foreach( $ints as $i ){
			$sql .= ','.$i.'='.$plans['free']->$i.' ';
		}
		$sql.= "WHERE type_type='free' ";
		$res = $ace->query($sql, 'Update Free Plan');

		$sql = "UPDATE account_types SET type_name='".addslashes($plans['paid']->type_name)."', ";
		$sql .="cost_1='".$plans['paid']->cost_1."', ";
		$sql .="cost_3='".$plans['paid']->cost_3."', ";
		$sql .="cost_6='".$plans['paid']->cost_6."', ";
		$sql .="cost_12='".$plans['paid']->cost_12."' ";
		foreach( $ints as $i ){
			$sql .= ','.$i.'='.$plans['paid']->$i.' ';
		}
		$sql.= "WHERE type_type='paid' ";
		$res = $ace->query($sql, 'Update Paid Plan');
		echo '<div class="errors">Plan Specifications Updated</div>';

		if( !isset($users) ){
			require_once(dirname(__FILE__).'/../classes/users.class.php');
			$users =& new users($ace);
		}
		$users->canceluseroverbandwidth();
	}
}

?>
<div style="text-align: center;">
<b>Account Features</b><br /><br />
This page allows you to change the settings for what features the free and paid accounts have.
</div>
<br /><br /> 
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
<table class="formtable" cellspacing="1" border="0" cellpadding="0" align="center">
<tr>
	<td class="formheading">&nbsp;</td>
	<td class="formheading">Free Membership</td>
	<td class="formheading">Paid Membership</td>
</tr>
<tr>
	<td class="formlabel">Plan Name:</td>
	<td class="formfield"><input type="text" name="type_name1" value="<?php echo htmlspecialchars($plans['free']->type_name);?>" /></td>
	<td class="formfield"><input type="text" name="type_name2" value="<?php echo htmlspecialchars($plans['paid']->type_name);?>" /></td>
</tr>
<tr>
	<td class="formlabel" rowspan="4">Price:</td>
	<td class="formfield" style="text-align: right;">1 Month:</td>
	<td class="formfield"><input type="text" name="cost_1" value="<?php echo $plans['paid']->cost_1;?>" /></td>
</tr>
<tr>
	<td class="formfield" style="text-align: right;">3 Months:</td>
	<td class="formfield"><input type="text" name="cost_3" value="<?php echo $plans['paid']->cost_3;?>" /></td>
</tr>
<tr>
	<td class="formfield" style="text-align: right;">6 Months:</td>
	<td class="formfield"><input type="text" name="cost_6" value="<?php echo $plans['paid']->cost_6;?>" /></td>
</tr>
<tr>
	<td class="formfield" style="text-align: right;">12 Months:</td>
	<td class="formfield"><input type="text" name="cost_12" value="<?php echo $plans['paid']->cost_12;?>" /></td>
</tr>
<tr>
	<td class="formlabel">Total Allowed Images:</td>
	<td class="formfield"><input type="text" name="max_images1" value="<?php echo $plans['free']->max_images;?>" /></td>
	<td class="formfield"><input type="text" name="max_images2" value="<?php echo $plans['paid']->max_images;?>" /></td>
</tr>
<tr>
	<td class="formlabel">Max Upload Size:</td>
	<td class="formfield"><input type="text" name="max_upload_size1" value="<?php echo $plans['free']->max_upload_size;?>" /> kb</td>
	<td class="formfield"><input type="text" name="max_upload_size2" value="<?php echo $plans['paid']->max_upload_size;?>" /> kb</td>
</tr>
<tr>
	<td class="formlabel">Max Image Width:</td>
	<td class="formfield"><input type="text" name="max_image_width1" value="<?php echo $plans['free']->max_image_width;?>" /></td>
	<td class="formfield"><input type="text" name="max_image_width2" value="<?php echo $plans['paid']->max_image_width;?>" /></td>
</tr>
<tr>
	<td class="formlabel">Max Image Height:</td>
	<td class="formfield"><input type="text" name="max_image_height1" value="<?php echo $plans['free']->max_image_height;?>" /></td>
	<td class="formfield"><input type="text" name="max_image_height2" value="<?php echo $plans['paid']->max_image_height;?>" /></td>
</tr>
<tr>
	<td class="formlabel">Monthly Bandwidth:</td>
	<td class="formfield"><input type="text" name="bandwidth1" value="<?php echo $plans['free']->bandwidth;?>" />mb</td>
	<td class="formfield"><input type="text" name="bandwidth2" value="<?php echo $plans['paid']->bandwidth;?>" />mb</td>
</tr>
<tr>
	<td class="formlabel">Total Storage:</td>
	<td class="formfield"><input type="text" name="storage1" value="<?php echo $plans['free']->storage;?>" />mb</td>
	<td class="formfield"><input type="text" name="storage2" value="<?php echo $plans['paid']->storage;?>" />mb</td>
</tr>
<tr>
	<td class="formlabel">Auto Resize:</td>
	<td class="formfield"><input type="checkbox" name="auto_resize1" value="1" <?php if( $plans['free']->auto_resize ) echo ' CHECKED ';?> /></td>
	<td class="formfield"><input type="checkbox" name="auto_resize2" value="1" <?php if( $plans['paid']->auto_resize ) echo ' CHECKED ';?> /></td>
</tr>
<tr>
	<td class="formlabel">Auto Convert To Jpeg:</td>
	<td class="formfield"><input type="checkbox" name="auto_jpeg1" value="1" <?php if( $plans['free']->auto_jpeg ) echo ' CHECKED ';?> /></td>
	<td class="formfield"><input type="checkbox" name="auto_jpeg2" value="1" <?php if( $plans['paid']->auto_jpeg ) echo ' CHECKED ';?> /></td>
</tr>
<tr>
	<td class="formlabel">Jpeg Quality:</td>
	<td class="formfield"><input type="text" name="jpeg_quality1" value="<?php echo $plans['free']->jpeg_quality;?>" /></td>
	<td class="formfield"><input type="text" name="jpeg_quality2" value="<?php echo $plans['paid']->jpeg_quality;?>" /></td>
</tr>
<tr>
	<td class="formlabel">Allow Renaming?</td>
	<td class="formfield"><input type="checkbox" name="rename_images1" value="1" <?php if( $plans['free']->rename_images ) echo ' CHECKED ';?> /></td>
	<td class="formfield"><input type="checkbox" name="rename_images2" value="1" <?php if( $plans['paid']->rename_images ) echo ' CHECKED ';?> /></td>
</tr>
<tr>
	<td class="formlabel">Allow Image Resizing?</td>
	<td class="formfield"><input type="checkbox" name="resize_images1" value="1" <?php if( $plans['free']->resize_images ) echo ' CHECKED ';?> /></td>
	<td class="formfield"><input type="checkbox" name="resize_images2" value="1" <?php if( $plans['paid']->resize_images ) echo ' CHECKED ';?> /></td>
</tr>
<tr>
	<td class="formlabel">Simultaneous Uploads:</td>
	<td class="formfield"><input type="text" name="simultaneous_uploads1" value="<?php echo $plans['free']->simultaneous_uploads;?>" /></td>
	<td class="formfield"><input type="text" name="simultaneous_uploads2" value="<?php echo $plans['paid']->simultaneous_uploads;?>" /></td>
</tr>
<tr>
	<td class="formlabel">Thumbnails Per Page:</td>
	<td class="formfield"><input type="text" name="images_per_page1" value="<?php echo $plans['free']->images_per_page;?>" /></td>
	<td class="formfield"><input type="text" name="images_per_page2" value="<?php echo $plans['paid']->images_per_page;?>" /></td>
</tr>
<tr>
	<td class="formlabel">Image Galleries:</td>
	<td class="formfield"><input type="text" name="max_galleries1" value="<?php echo $plans['free']->max_galleries;?>" /></td>
	<td class="formfield"><input type="text" name="max_galleries2" value="<?php echo $plans['paid']->max_galleries;?>" /></td>
</tr>
<tr>
	<td class="formlabel">Email Images To Friends:</td>
	<td class="formfield"><input type="text" name="email_friends1" value="<?php echo $plans['free']->email_friends;?>" /></td>
	<td class="formfield"><input type="text" name="email_friends2" value="<?php echo $plans['paid']->email_friends;?>" /></td>
</tr>
<tr>
	<td class="formlabel">Add Branding:</td>
	<td class="formfield"><input type="checkbox" name="add_branding1" value="1" <?php if( $plans['free']->add_branding ) echo ' CHECKED ';?> /></td>
	<td class="formfield"><input type="checkbox" name="add_branding2" value="1" <?php if( $plans['paid']->add_branding ) echo ' CHECKED ';?> /></td>
</tr>
<tr>
	<td class="formlabel">&nbsp;</td>
	<td class="formfield" style="text-align: center;"><input type="submit" name="update" value="Update Plans" /></td>
	<td class="formfield">&nbsp;</td>
</tr>
</table>
</form>
<?php

require_once(dirname(__FILE__).'/includes/footer.inc.php');

?>
