Revonzy Mini Shell
<?php
include('../../../config.php');
require_once(PATH_LIBRARIES.'/classes/DBConn.php');
require_once(PATH_LIBRARIES.'/functions/fun1.php');
$db = new DBConn();
$pathmulti = ROOT."/image_upload/materials/";
$pathmulti1 = ROOT."/image_upload/materials/thumb/";
$file_path = ROOT."/image_upload/materials/file/";
///*******************************************************
/// Validate that the data already exist or not
///*******************************************************
if($_POST['type']=="validate")
{
$sql="SELECT Sub_Name FROM catelog_category CC INNER JOIN catelog_sub_category CSC ON CSC.Category_Id=CC.Category_Id WHERE Sub_Name='".$_POST['sub_name']."' and CSC.Category_Id='".$_POST['cate_name']."' AND Sub_Id<>'".$_REQUEST['id']."'";
$res=$db->ExecuteQuery($sql);
if(empty($res))
{
echo 0;
}
else
{
echo 1;
}
}
///*******************************************************
/// To Insert New category /////////////////////////////////
///*******************************************************
if($_POST['type']=="addSubcategory")
{
/*print_r($_FILES);
exit;*/
//File Uplaod here
$file_upload='';
if($_REQUEST['varifyimage']==1)
{
$file=$_FILES['fileupload']['name'];
$tmp2 = $_FILES['fileupload']['tmp_name'];
//print_r($tmp2);
$image=explode('.',$file);
$file_upload = time().'.'.$image[1]; // rename the file name
move_uploaded_file($tmp2, $file_path.$file_upload);
}
$tblfield=array('Category_Id','Sub_Name','Position','Sub_Desc','HSub_Name','HSub_Desc','Url_Path','File_Uplaod');
$tblvalues=array($_POST['category'],$_POST['subcategory'],$_POST['position'],$_POST['desc'],$_POST['hsubcategory'],$_POST['hdesc'],$_POST['url_path'],$file_upload);
$res=$db->valInsert("catelog_sub_category",$tblfield,$tblvalues);
if(empty($res))
{
echo 0;
}
else
{
echo 1;
}
}
///*******************************************************
/// Edit Sub category
///*******************************************************
if($_POST['type']=="editCategory")
{
/*print_r($_POST);
exit;*/
$file_upload='';
if($_REQUEST['varifyimage']==1)
{
$file=$_FILES['fileupload']['name'];
$tmp2 = $_FILES['fileupload']['tmp_name'];
//print_r($tmp2);
$image=explode('.',$file);
$file_upload = time().'.'.$image[1]; // rename the file name
move_uploaded_file($tmp2, $file_path.$file_upload);
//delete Here Old File
$sql="SELECT File_Uplaod FROM catelog_sub_category WHERE Sub_Id ='".$_POST['id']."'";
$imagename=$db->ExecuteQuery($sql);
if(count($imagename)>0)
{
if($imagename[1]['File_Uplaod']!="" && file_exists($file_path.$imagename[1]['File_Uplaod']))
{
unlink($file_path.$imagename[1]['File_Uplaod']);
}
}
}else{
$file_upload=$_POST['oldfile'];
}
$tblfield=array('Category_Id','Sub_Name','Position','Sub_Desc','HSub_Name','HSub_Desc','Url_Path','File_Uplaod');
$tblvalues=array($_POST['category'],$_POST['subcategory'],$_POST['position'],$_POST['desc'],$_POST['hsubcategory'],$_POST['hdesc'],$_POST['url_path'],$file_upload);
$condition="Sub_Id=".$_POST['id'];
$res=$db->updateValue('catelog_sub_category',$tblfield,$tblvalues,$condition);
if (empty($res))
{
//echo mysql_error();
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 catelog_material WHERE Sub_Id ='".$_POST['id']."'";
$imagename=$db->ExecuteQuery($sql);
if(count($imagename)>0)
{
$tblname="catelog_material";
$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 catelog_sub_category where Sub_Id='".$_POST['id']."'");
//Check HEre If Category is used than you can not delete the row
if(count($res)>0)
{
//delete Here Old File
$sql="SELECT File_Uplaod FROM catelog_sub_category WHERE Sub_Id ='".$_POST['id']."'";
$imagename=$db->ExecuteQuery($sql);
if(count($imagename)>0)
{
if($imagename[1]['File_Uplaod']!="" && file_exists($file_path.$imagename[1]['File_Uplaod']))
{
unlink($file_path.$imagename[1]['File_Uplaod']);
}
}
$tblname="catelog_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