system: Linux mars.sprixweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
<?php
class Model_MPhotos
{
function showPhotoCate22($errval)
{
$plans="SELECT * FROM categorey_table where categorey_status='Enable'";
$obj=new Bin_Query();
$obj->executeQuery($plans);
return Display_DPhotos::showPhotoCate($obj->records,$planscount,$errval);
}
function showPhotoCate($errval)
{
$id=(int)$_GET['id'];
if($id=='')
{
$plans="SELECT * FROM categorey_table where categorey_status='Enable'";
$obj=new Bin_Query();
$obj->executeQuery($plans);
}
else
{
$obj=new Bin_Query();
$obj1=new Bin_Query();
$select="select * from photos_table where photos_id=$id";
$obj1->executeQuery($select);
$planscount=$obj1->records[0]['photos_cat_id'];
$plans="SELECT * FROM categorey_table where categorey_status='Enable'";
$obj=new Bin_Query();
$obj->executeQuery($plans);
}
return Display_DPhotos::showPhotoCate($obj->records,$planscount,$errval);
}
function showPhotos()
{
$select1="select * from photos_table";
$obj2=new Bin_Query();
$obj2->executeQuery($select1);
return Display_DPhotos::showPhotos($obj2->records);
}
function upload()
{
define ("MAX_SIZE","9000");
$valid_formats = array("jpg", "png", "gif", "bmp","jpeg");
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
{
$uploaddir = "../uploads/photoG/"; //a directory inside
$uploaddir1 = "../uploads/photoG_thumb/"; //a directory inside
foreach ($_FILES['photos']['name'] as $name => $value)
{
$filename = stripslashes($_FILES['photos']['name'][$name]);
$size=filesize($_FILES['photos']['tmp_name'][$name]);
if ($size < (MAX_SIZE*1024))
{
$image_name=$filename;
echo "<img src='".$uploaddir.$image_name."' class='imgList'>";
$time=time();
$jpg='.jpg';
$newname=$uploaddir.$time.$jpg;
$newname1=$uploaddir1.$time.$jpg;
if (move_uploaded_file($_FILES['photos']['tmp_name'][$name], $newname))
{
new Lib_ThumbImage('thumb',$newname,$uploaddir1,100);
$cate=$_POST['txtcate'];
$year=$_POST['txtyear'];
$message=$_POST['txtmessage'];
mysql_query("INSERT INTO photos_table(photos_cat,photos_year,photos_message,photos_image,photos_thumb) VALUES('$cate','$year','$message','$newname','$newname1')");
}
else
{
echo '<span class="imgList">You have exceeded the size limit! so moving unsuccessful! </span>';
}
}
else
{
echo '<span class="imgList">You have exceeded the size limit!</span>';
}
}
}
}
function insertPhotos()
{
$cate=$_POST['txtcate'];
$year=$_POST['txtyear'];
$message=$_POST['txtmessage'];
$uploaded_path = '../uploads/photoG';
$uploaded_path1 = '../uploads/photoG_thumb';
$saved_path = 'uploads/photoG';
$saved_path1 = 'uploads/photoG_thumb';
if($_FILES['image']['size']>0)
{
$headerimage = $uploaded_path."/".$_FILES['image']['name'];
$savedpath = $saved_path."/".$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'],$headerimage);
//list($img_w,$img_h, $type, $attr) = getimagesize($uploaded_path);
new Lib_ThumbImage('thumb',$headerimage,$uploaded_path1,100);
$savedpath1 = $saved_path1."/".$_FILES['image']['name'];
}
$insert="insert into photos_table (photos_cat,photos_year,photos_message,photos_image,photos_thumb) values('$cate','$year','$message','$savedpath','$savedpath1')";
$obj=new Bin_Query();
if($obj->updateQuery($insert))
{
$_SESSION['message'] = 'Photos has been added Successfully';
}
else
{
$_SESSION['error_message'] = 'Oops unable to insert';
}
}
function showEdit()
{
$testid=$_GET['id'];
$select="select * from photos_table where photos_id='$testid' ";
$obj=new Bin_Query();
$obj->executeQuery($select);
if($obj->records[0]['photos_image']=='')
$obj->records[0]['photos_image']='uploads/photoG/no_image1.gif';
return $obj->records[0];
}
function updatePhotos()
{
if(isset($_POST['update']))
{
$testid=$_GET['id'];
$year=$_POST['txtyear'];
$message=$_POST['txtmessage'];
$uploaded_path = '../uploads/photoG';
$saved_path = 'uploads/photoG';
if($_FILES['image']['size']>0)
{
$headerimage = $uploaded_path."/".$_FILES['image']['name'];
$savedpath = $saved_path."/".$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'],$headerimage);
//list($img_w,$img_h, $type, $attr) = getimagesize($uploaded_path);
new Lib_ThumbImage('thumb',$headerimage,$uploaded_path1,40);
$savedpath1 = $saved_path1."/".$_FILES['image']['name'];
}
else
{
$select="select * from photos_table where photos_id='$testid'";
$obj1= new Bin_Query();
$obj1->executeQuery($select);
$savedpath=$obj1->records[0]['photos_image'];
$savedpath1=$obj1->records[0]['photos_thumb'];
//$userphoto=''
}
$update="update photos_table set photos_year='$year',photos_message='$message', photos_image='$savedpath',photos_thumb='$savedpath1' where photos_id='$testid'";
$obj=new Bin_Query();
if($obj->updateQuery($update))
{
$_SESSION['message']="Photos updated Sucessfully";
}
else
{
$_SESSION['error_message']="Oops unable to update";
}
}
if(isset($_POST['del']))
{
$testid=$_GET['id'];
$sql1="delete from photos_table WHERE photos_id='".$testid."' ";
$obj=new Bin_Query();
////////////New Modification////////////
$select="select * from photos_table where photos_id='".$testid."'";
$obj1= new Bin_Query();
$obj1->executeQuery($select);
$mphotoM=$obj1->records[0]['photos_image'];
$mphotoTumb=$obj1->records[0]['photos_thumb'];
$mphoto='../'.$mphotoM.'';
$mphoto1='../'.$mphotoTumb.'';
unlink($mphoto);
unlink($mphoto1);
////////////New Modification////////////
if($obj->updateQuery($sql1))
{
$_SESSION['message']=" User Deleted Sucessfully";
}
}
}
function deletePhotos()
{
if(isset($_POST['delete']))
{
//$esc=$_POST['check'];
foreach($_POST as $key=>$item)
{
if($key==$item)
{
$sql1="delete from photos_table WHERE photos_id='".$key."' ";
////////////New Modification////////////
$select="select * from photos_table where photos_id='".$key."'";
$obj1= new Bin_Query();
$obj1->executeQuery($select);
$mphotoM=$obj1->records[0]['photos_image'];
$mphotoTumb=$obj1->records[0]['photos_thumb'];
$mphoto='../'.$mphotoM.'';
$mphoto1='../'.$mphotoTumb.'';
unlink($mphoto);
unlink($mphoto1);
////////////New Modification////////////
}
$obj=new Bin_Query();
if($obj->updateQuery($sql1))
{
$_SESSION['message']=" User Deleted Sucessfully";
}
/* else
{
$_SESSION['error_message']=" Process failed";
}
*/
}
}
}
}
?>