Location: PHPKode > projects > Coxiar Media Platform > coxiar_productions/cpanel/edit_categories.php
<?php
set_time_limit(0);
session_start();
include("../db.php");
require_once '../widget/widget_categories.php';
$Categories = new Widget_Categories();
if(isset($_SESSION['logged_in']) != true) 	exit; 

$emode = (isset($_GET['emode'])) ? $_GET['emode'] : 'V';

if(isset($_POST['TheFunction'])){
	$emode = $_POST['emode'];

	$tid = (isset($_POST['ttid'])) ? $_POST['ttid'] : '';
	$sqlx = '';
	if($_FILES['tcategory_image'.$tid]['name'] != ""){

		$uploaddir = '../category_images/';
		$uploadfile_temp = date('HiSu').rand(1, 10).basename($_FILES['tcategory_image'.$tid]['name']);
		$uploadfile_date = date('Y-m-d');
		$uploadfile = $uploaddir.$uploadfile_date.'/'.$uploadfile_temp;
		if(file_exists($uploaddir.$uploadfile_date.'/') != true){
			mkdir($uploaddir.$uploadfile_date.'/');
		}

		move_uploaded_file($_FILES['tcategory_image'.$tid]['tmp_name'], $uploadfile);
		exec($config['mogrify'].' -format gif -thumbnail 125x100 "'.realpath($uploadfile).'"');

	}
	if($_POST['Mode'] == "1"){
		if($tid == ''){
			$sql1 = "INSERT INTO ";
		}
		else{
			$sql1 = "UPDATE ";
			$sqlx = " Where `category_id` = '".$tid."'";
		}
		$sql = $sql1."`categories` Set `category_name` = '".$_POST['tcategory_name'.$tid]."' ".
						", `category_image` = '".(($_FILES['tcategory_image'.$tid]['name'] != "") ? str_replace('category_images/', '', str_replace('../','',$uploadfile)) : $_POST['tcategory_image_old'.$tid])."' ".
						", `category_sub` = '".$_POST['tcategory_sub'.$tid]."' ".
						", `category_type` = '".$emode."'".$sqlx;
	}
	else{

			$sql = "Delete from `categories` Where `category_id` = '".$tid."'";

			

	}

	//echo $sql;
	//exit;
	mysql_query($sql);

}

$query = "Select * From `categories` Where `category_type` = '".$emode."'";
$result = mysql_query($query);
?>
<html>
<head>
<title>Edit Categories</title>
<style type="text/css">
<!--
body {
	background-color: black;
}
h1{
font-size:20px;
font-family:Arial, Helvetica, sans-serif;
}
div, td, tr, table, p{
font-size:10px;
font-family:Arial, Helvetica, sans-serif;
color:white;
}
a:link {
	color:white;
	text-decoration: underline;
}
a:visited {
	color:white;
	text-decoration: underline;
}
a:hover {
	text-decoration: underline;
	color:white;
}
a:active {
	text-decoration: underline;
	color:white;
}
input{

font-size:10px;
font-family:Tahoma;

-->
</style>
<script language="Javascript">
function selectedItem(tid, mode){
	if(mode == 3){
	alert('Feature not available yet =X');
	return false;
	}

	document.DataEntry.ttid.value = tid;
	document.DataEntry.Mode.value = mode;
	document.DataEntry.submit();
	return true;
}
</script>
</head>
<body>
<br>
<div align="center">
<img src="../images/easy_tms.php?text=<?=urlencode('Edit Categories - '.(($emode == 'V') ? 'Videos' : 'Stills'))?>&font_size=13"><br>
<br>
<form action="<?=$_SERVER['PHP_SELF']?>" onsubmit="return false;"  enctype="multipart/form-data" name="DataEntry" method="POST">
<input type="hidden" name="Mode">
<input type="hidden" name="ttid" value=" ">
<input type="hidden" name="TheFunction" value="1">
<input type="hidden" name="emode" value="<?=$emode?>">
<?php
while($row = mysql_fetch_assoc($result)){
$tid = $row['category_id'];
?>
	<div style="border: 1px white solid; height:150px; width:500px;">
	<div style="position:relative; left:25; top:25px; bottom:25px;">
	<table width="500" border="0" cellspacing="0" cellpadding="0" >
	<tr>
	<td rowspan="4" border="0">
	<img src="../category_images/thumbnail.php?category_id=<?=$row['category_id']?>" width="125px" height="75px"><br><br>

	</td>
	</tr>

	<tr>
	<td>
	Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<input type="text" name="tcategory_name<?=$tid?>" value="<?=htmlentities($row['category_name'])?>">
	</td>
	</tr>

	<tr>
	<td>

	Thumbnail &nbsp; <input type="file" name="tcategory_image<?=$tid?>" size="35"/>
			 <input type="hidden" name="tcategory_image_old<?=$tid?>" value="<?=$row['category_image']?>"/>
	</td>
	</tr>

	<tr>
	<td>
	Category of &nbsp;
	<? 
	if($emode == 'V')	echo $Categories->Videos_Combobox('tcategory_sub'.$tid,$row['category_sub']);
	else			echo $Categories->Stills_Combobox('tcategory_sub'.$tid,$row['category_sub']);
	?>
	</td>
	</tr>

	<tr>
	<td>
		&nbsp;
	</td>
	<td>
	<img src="../images/easy_tms.php?text=Save&font_size=13" onclick="selectedItem(<?=$tid?>, 1);">
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<img src="../images/easy_tms.php?text=Delete&font_size=13" onclick="selectedItem(<?=$tid?>, 2);">
	</td>
	</tr>
	</table>
	</div>
	</div>
	<br><br>
<?php
}
?>

</form>

</div>
</body>
</html>
Return current item: Coxiar Media Platform