Revonzy Mini Shell
<?php
include('../../../config.php');
require_once(PATH_LIBRARIES.'/classes/DBConn.php');
require_once(PATH_LIBRARIES.'/classes/resize.php');
/*require_once(PATH_LIBRARIES.'/functions/fun1.php');*/
$db = new DBConn();
$pathmulti = ROOT."/image_upload/projects/";
$pathmulti1 = ROOT."/image_upload/projects/thumb/";
///*******************************************************
/// Validate that the data already exist or not
///*******************************************************
if($_POST['type']=="validate")
{
$sql="SELECT Section_Name FROM image_section WHERE Section_Name='".$_POST['image_name']."' and Section_Id<>'".$_REQUEST['id']."'";
$res=$db->ExecuteQuery($sql);
if(empty($res))
{
echo 0;
}
else
{
echo 1;
}
}
///*******************************************************
/// To Insert New category /////////////////////////////////
///*******************************************************
if($_POST['type']=="addImageupload")
{
$con= mysql_connect(SERVER,DBUSER,DBPASSWORD);
mysql_query('SET AUTOCOMMIT=0',$con);
mysql_query('START TRANSACTION',$con);
try
{
/*//Section Details Upload First
$tblfield=array('Section_Name','Image_Desc','Category_Id','Sub_Id','Langauge','Status');
$tblvalues=array($_POST['imagename'],$_POST['desc'],$_POST['category'],$_POST['subcategory'],$_POST['langauge'],1);
$res=$db->valInsert("image_section",$tblfield,$tblvalues);
if(!$res)
{
throw new Exception('0');
}
$lastid=mysql_insert_id();
*/
$gallary = $_FILES['imageupload']['name'];
//print_r($gallary);
$i=0;
foreach($gallary as $gallaryval)
{
$tmp2 = $_FILES['imageupload']['tmp_name'];
//print_r($tmp2);
$image=explode('.',$gallaryval);
$gallary_image = time().$i.'.'.$image[1]; // rename the file name
if(move_uploaded_file($tmp2[$i], $pathmulti.$gallary_image))
{
// move the image in the thumb folder
$resizeObj1 = new resize($pathmulti.$gallary_image);
$resizeObj1 ->resizeImage(200,200,'auto');
$resizeObj1 -> saveImage($pathmulti1.$gallary_image, 100);
$CheckQuery=$db->ExecuteQuery("SELECT Image_Id FROM image_upload WHERE MainImage=1 AND Sub_Id=".$_POST['subcategory']." AND Client_Id=".$_POST['clientId']);
if(count($CheckQuery)==0)
{
$sql1="INSERT INTO image_upload(Image_Path,MainImage,Category_Id,Sub_Id,Client_Id,Project) values('".$gallary_image."', 1, ".$_POST['category'].", ".$_POST['subcategory'].",".$_POST['clientId'].",'".$_POST['project']."')";
}else{
$sql1="INSERT INTO image_upload(Image_Path, MainImage, Category_Id, Sub_Id, Client_Id, Project) values('".$gallary_image."', 0, ".$_POST['category'].", ".$_POST['subcategory'].", ".$_POST['clientId'].",'".$_POST['project']."')";
}
//echo $sql1;
$res1=mysql_query($sql1);
if(!$res1)
{
//echo mysql_error();
throw new Exception('0');
}
$i++;
}
}//end of foreach
echo 1;
mysql_query("COMMIT",$con);
}
catch(Exception $e)
{
echo $e->getMessage();
mysql_query('ROLLBACK',$con);
mysql_query('SET AUTOCOMMIT=1',$con);
}
}
///*******************************************************
/// Edit Sub category
///*******************************************************
if($_POST['type']=="editCategory")
{
/*print_r($_POST);
exit;*/
$tblfield=array('Category_Id','Sub_Name','Position','Sub_Desc','Langauge');
$tblvalues=array($_POST['category'],$_POST['subcategory'],$_POST['position'],$_POST['desc'],$_POST['langauge']);
$condition="Sub_Id=".$_POST['id'];
$res=$db->updateValue('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")
{
$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 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>';
}
}
///*******************************************************
/// Onchange Category
///*******************************************************
if($_POST['type']=="getSubcategory")
{
$sql="SELECT Sub_Id, Sub_Name FROM sub_category WHERE Category_Id=".$_REQUEST['id']." ORDER BY Sub_Id DESC";
$res=$db->ExecuteQuery($sql);
echo '<option value="">Select Subcategory</option>';
foreach($res as $val)
{
echo '<option value="'.$val['Sub_Id'].'">'.$val['Sub_Name'].'</option>';
}
}
///*******************************************************
/// Onchange Sub Category
///*******************************************************
/*if($_POST['type']=="getClients")
{
$sql="SELECT DISTINCT iu.Client_Id, c.Client_Name FROM image_upload iu
INNER JOIN clients c ON iu.Client_Id = c.Client_Id
WHERE Category_Id=".$_REQUEST['catId']." AND Sub_Id=".$_REQUEST['id'];
$res=$db->ExecuteQuery($sql);
echo '<option value="">Select Client</option>';
foreach($res as $val)
{
echo '<option value="'.$val['Client_Id'].'">'.$val['Client_Name'].'</option>';
}
}*/
///*******************************************************
/// Delete gallery Images
///*******************************************************
if($_POST['type']=="deletegallerymultiimg")
{
foreach($_POST['id'] as $deleteVal)
{
$sql="SELECT Image_Path FROM image_upload WHERE Image_Id =".$deleteVal;
$imagename=$db->ExecuteQuery($sql);
$tblname="image_upload";
$condition="Image_Id =".$deleteVal;
$res=$db->deleteRecords($tblname,$condition);
foreach($imagename as $image)
{
if($image['Image_Path']!="")
{
unlink($pathmulti.$image['Image_Path']);
unlink($pathmulti1.$image['Image_Path']);
}
}
}
}
///*******************************************************
/// make main image
///*******************************************************
if($_POST['type']=="makemainimage")
{
$res1=mysql_query("UPDATE image_upload SET MainImage=0 WHERE Sub_Id=".$_POST['book_id']." AND Client_Id=".$_POST['client_Id']);
$res=mysql_query("UPDATE image_upload SET MainImage=1 WHERE Sub_Id=".$_POST['book_id']." AND Client_Id=".$_POST['client_Id']." AND Image_Id=".$_POST['id']);
if(empty($res))
{
echo 0;
}
else
{
echo 1;
}
}
//*****************************************************
// Image Showing
//*****************************************************
if($_POST['type']=='imageShow')
{
////////Get Gallery Image
$gallery_list=$db->ExecuteQuery("SELECT * FROM image_upload WHERE Sub_Id=".$_POST['subcategory']." AND Client_Id=".$_POST['clientId']);
if($gallery_list)
{
?>
<div class="form-group">
<div class="col-sm-12">
<input title="Select All" type="checkbox" id="selecctallgallery"/>
<button title="Delete" type="button" class="btn btn-danger btn-sm " id="deletegalleryimage" name="deletegalleryimage"> <span class="glyphicon glyphicon-trash"></span> Delete All</button>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<?php
$i=1;
foreach($gallery_list as $value){
?>
<div class="col-sm-3 bg-success imgBlck">
<div>
<input title="Set As Base Image" type="radio" class="select mainimage" name="mainimage" value="<?php echo $value['Image_Id'];?>" <?php if($value['MainImage']==1){ echo "checked ";}?> />
Base Image </div>
<div class="galleryImg"><img width="80px" src="<?php echo PATH_UPLOAD_IMAGE."/projects/thumb/".$value['Image_Path'];?>" alt="" /></div>
<div>
</div>
<div>
<?php if($value['MainImage']!=1){?>
<input type="checkbox" class="deletegallery" id="<?php echo $value['Image_Id'];?>"/>
<?php } ?>
<!--<button type="button" class="btn btn-danger btn-sm delete" id="<?php //echo $value['Id']; ?>" name="delete"> <span class="glyphicon glyphicon-trash"></span></button>-->
</div>
</div>
<?php $i++;}
?>
</div>
<?php } }?>
EliteHackz.ORG
Revonzy Mini Shell
root@revonzy.com