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/category/";
$path1 = ROOT."/image_upload/category/thumb/";
$path2 = ROOT."/image_upload/category/long/";
$path12 = ROOT."/image_upload/category/long/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']=="addCategory")
{
/////////////////////////////////
// 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
$name2 = $_FILES['file2']['name'];
$tmp2 = $_FILES['file2']['tmp_name'];
$image2=explode('.',$name2);
$actual_image_name2 = time().'.'.$image2[1]; // rename the file name
if(move_uploaded_file($tmp, $path.$actual_image_name) && move_uploaded_file($tmp, $path2.$actual_image_name2))
{
///////////////////////////////////////////////////////////
// move the image in the folder
///////////////////////////////////////////////////////////
$resizeObj1 = new resize($path.$actual_image_name);
$resizeObj1 -> resizeImage(200, 200, 'auto');
$resizeObj1 -> saveImage($path1.$actual_image_name, 100);
$resizeObj1 = new resize($path2.$actual_image_name2);
$resizeObj1 -> resizeImage(200, 200, 'auto');
$resizeObj1 -> saveImage($path12.$actual_image_name2, 100);
$tblfield=array('Category_Name','Category_Image', 'Long_Image','Position');
$tblvalues=array($_POST['cate_name'], $actual_image_name, $actual_image_name2, $_POST['position']);
$res=$db->valInsert("category",$tblfield,$tblvalues);
if(empty($res))
{
echo 0;
}
else
{
echo 1;
}
}
}
///*******************************************************
/// Edit Plant
///*******************************************************
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 Category_Image FROM category WHERE Category_Id=".$_REQUEST['id']);
if(count($select)>0)
{
unlink($path.$select[1]['Category_Image']);
unlink($path1.$select[1]['Category_Image']);
}
}
else
{
$gallary_image=$_POST['imageupload'];
}
if($_REQUEST['imageupload2']=='')
{
//Image Name
$gallary2 = $_FILES['fileupload2']['name'];
//Temp Image Image
$tmp22 = $_FILES['fileupload2']['tmp_name'];
$image2=explode('.',$gallary2);
$gallary_image2 = time().'.'.$image2[1]; // rename the file name
if(move_uploaded_file($tmp22, $path2.$gallary_image2))
{
// move the image in the thumb folder
$resizeObj1 = new resize($path2.$gallary_image2);
$resizeObj1 ->resizeImage(200,200,'auto');
$resizeObj1 -> saveImage($path12.$gallary_image2, 100);
}
//Unlink Old Image from folders
$select=$db->ExecuteQuery("SELECT Long_Image FROM category WHERE Category_Id=".$_REQUEST['id']);
if(count($select)>0)
{
unlink($path.$select[1]['Long_Image']);
unlink($path1.$select[1]['Long_Image']);
}
}
else
{
$gallary_image2=$_POST['imageupload2'];
}
$tblfield=array('Category_Name','Category_Image','Long_Image','Position');
$tblvalues=array($_POST['cate_name'],$gallary_image,$gallary_image2,$_POST['position']);
$condition="Category_Id=".$_POST['id'];
$res=$db->updateValue('category',$tblfield,$tblvalues,$condition);
if (empty($res))
{
echo 0;
}
else
{
echo 1;
}
}
///*******************************************************
/// Delete row from Plant table
///*******************************************************
if($_POST['type']=="delete")
{
$select=$db->ExecuteQuery("SELECT Category_Image, Long_Image FROM category WHERE Category_Id=".$_REQUEST['id']);
$res=$db->ExecuteQuery("SELECT Sub_Id FROM sub_category WHERE Category_Id=".$_REQUEST['id']);
//Check HEre If Category is used than you can not delete the row
if(count($res)==0)
{
$tblname="category";
$condition="Category_Id=".$_REQUEST['id'];
$deleteRecord=$db->deleteRecords($tblname,$condition);
if(!$deleteRecord)
{
echo 0;
}else{
if(count($select)>0)
{
unlink($path.$select[1]['Category_Image']);
unlink($path1.$select[1]['Category_Image']);
unlink($path2.$select[1]['Long_Image']);
unlink($path12.$select[1]['Long_Image']);
}
echo 1;
}
}
else
{
echo 0;
}
}
EliteHackz.ORG
Revonzy Mini Shell
root@revonzy.com