Revonzy Mini Shell
<?php
include('../../../config.php');
require_once(PATH_LIBRARIES.'/classes/DBConn.php');
require_once(PATH_LIBRARIES.'/classes/resize.php');
$db = new DBConn();
$path = ROOT."/image_upload/subcategory/";
$path1 = ROOT."/image_upload/subcategory/thumb/";
///*******************************************************
/// Validate that the data already exist or not
///*******************************************************
if($_POST['type']=="validate")
{
$sql="SELECT Category_Name FROM category WHERE Category_Name='".$_POST['cate_name']."' and Category_Id<>'".$_REQUEST['id']."'";
$res=$db->ExecuteQuery($sql);
if(empty($res))
{
echo 0;
}
else
{
echo 1;
}
}
///*******************************************************
/// To Insert New category /////////////////////////////////
///*******************************************************
if($_POST['type']=="addSubcategory")
{
/////////////////////////////////
// Code for team member photo
/////////////////////////////////
$name = $_FILES['file']['name'];
$tmp = $_FILES['file']['tmp_name'];
$image=explode('.',$name);
$actual_image_name = time().'.'.$image[1]; // rename the file name
if(move_uploaded_file($tmp, $path.$actual_image_name))
{
///////////////////////////////////////////////////////////
// move the image in the images/team folder
///////////////////////////////////////////////////////////
$resizeObj1 = new resize($path.$actual_image_name);
$resizeObj1 -> resizeImage(200, 200, 'auto');
$resizeObj1 -> saveImage($path1.$actual_image_name, 100);
$tblfield=array('Category_Id','Sub_Name','Position','Sub_Desc','Subcategory_Image');
$tblvalues=array($_POST['category'],$_POST['subcategory'],$_POST['position'],$_POST['desc'],$actual_image_name);
$res=$db->valInsert("sub_category",$tblfield,$tblvalues);
if(empty($res))
{
echo 0;
}
else
{
echo 1;
}
}
}
///*******************************************************
/// Edit Sub category
///*******************************************************
if($_POST['type']=="editCategory")
{
if($_REQUEST['imageupload']=='')
{
//Image Name
$gallary = $_FILES['fileupload']['name'];
//Temp Image Image
$tmp2 = $_FILES['fileupload']['tmp_name'];
$image=explode('.',$gallary);
$gallary_image = time().'.'.$image[1]; // rename the file name
if(move_uploaded_file($tmp2, $path.$gallary_image))
{
// move the image in the thumb folder
$resizeObj1 = new resize($path.$gallary_image);
$resizeObj1 ->resizeImage(200,200,'auto');
$resizeObj1 -> saveImage($path1.$gallary_image, 100);
}
//Unlink Old Image from folders
$select=$db->ExecuteQuery("SELECT Subcategory_Image FROM sub_category WHERE Sub_Id=".$_REQUEST['id']);
if(count($select)>0)
{
unlink($path.$select[1]['Subcategory_Image']);
unlink($path1.$select[1]['Subcategory_Image']);
}
}
else
{
$gallary_image=$_POST['imageupload'];
}
$tblfield=array('Category_Id','Sub_Name','Position','Sub_Desc','Subcategory_Image');
$tblvalues=array($_POST['category'],$_POST['subcategory'],$_POST['position'],$_POST['desc'],$gallary_image);
$condition="Sub_Id=".$_POST['id'];
$res=$db->updateValue('sub_category',$tblfield,$tblvalues,$condition);
if (empty($res))
{
echo 0;
}
else
{
echo 1;
}
}
///*******************************************************
/// Delete row from Plant table
///*******************************************************
if($_POST['type']=="delete")
{
//GEt HEre All Image Which Uploaded based on sub category
$sql="SELECT Image_Path FROM image_upload WHERE Sub_Id ='".$_POST['id']."'";
$imagename=$db->ExecuteQuery($sql);
if(count($imagename)>0)
{
$tblname="image_upload";
$condition="Sub_Id =".$_POST['id'];
$res=$db->deleteRecords($tblname,$condition);
foreach($imagename as $image)
{
if($image['Image_Path']!="")
{
unlink($pathmulti.$image['Image_Path']);
unlink($pathmulti1.$image['Image_Path']);
}
}
}
$res=$db->ExecuteQuery("Select Sub_Id FROM sub_category where Sub_Id='".$_POST['id']."'");
//Check HEre If Category is used than you can not delete the row
if(count($res)>0)
{
$tblname="sub_category";
$condition="Sub_Id=".$_POST['id'];
$res=$db->deleteRecords($tblname,$condition);
if($res)
{
echo 1;
}
else
{
//echo mysql_error();
echo 0;
}
}
else
{
echo 0;
}
}
///*******************************************************
/// Onchange Langauge
///*******************************************************
if($_POST['type']=="getCategory")
{
$sql="SELECT Category_Name, Category_Id FROM category WHERE Langauge='".$_REQUEST['id']."'";
$res=$db->ExecuteQuery($sql);
echo '<option value="">Select Category</option>';
foreach($res as $val)
{
echo '<option value="'.$val['Category_Id'].'">'.$val['Category_Name'].'</option>';
}
}
EliteHackz.ORG
Revonzy Mini Shell
root@revonzy.com