
PK 
<?php
session_start();
include_once('../include/common.php');
include_once('../include/connection.php');
include_once('../include/session.php');
function thumb_jpeg($sourceImage,$destinationImageName,$destinationPath,$newWidth,$newHeight) {
if($sourceImage) {
preg_match('/\.([A-Za-z]+?)$/', $destinationImageName, $matches);
if($matches[1] == 'png' && function_exists('imagecreatefrompng') || $matches[1] == 'jpg' && function_exists('imagecreatefromjpeg') || $matches[1] == 'jpeg' && function_exists('imagecreatefromjpeg') || $matches[1] == 'gif' && function_exists('imagecreatefromgif') || $matches[1] == 'bmp' && function_exists('imagecreatefromwbmp')) {
list($owidth, $oheight) = getimagesize($sourceImage);
if($_POST['resizeby'] == 'height') {
$nheight = ($newWidth>1)?$newWidth:600;
$nwidth = $nheight / $oheight * $owidth;
$resized = @imagecreatetruecolor($nwidth, $nheight);
}
else {
$nwidth = ($newWidth>1)?$newWidth:800;
$nheight = $nwidth / $owidth * $oheight;
$resized = @imagecreatetruecolor($nwidth, $nheight);
}
if($matches[1] == 'png')
$original = @imagecreatefrompng($sourceImage);
if($matches[1] == 'jpg' || $matches[1] == 'jpeg')
$original = @imagecreatefromjpeg($sourceImage);
if($matches[1] == 'gif')
$original = @imagecreatefromgif($sourceImage);
if($matches[1] == 'bmp')
$original = @imagecreatefromwbmp($sourceImage);
@imagecopyresampled($resized, $original, 0, 0, 0, 0, $nwidth, $nheight, $owidth, $oheight);
// header('Content-Disposition: attachment; filename="'.$_FILES['image']['name'].'"');
// header('Content-type: image/'.(($matches[1] == 'jpg')?'jpeg':$matches[1]));
if($matches[1] == 'png')
@imagepng($resized);
if($matches[1] == 'jpg' || $matches[1] == 'jpeg')
@ImageJPEG($resized,"$destinationPath/$destinationImageName",100);
//imagejpeg($resized);
if($matches[1] == 'gif')
@imagegif($resized);
if($matches[1] == 'bmpg')
@imagewbmp($resized);
}else{
$error = 'File type not supported!';
}
} else{
$error = 'No image uploaded!';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<title>Gallery</title>
<!-- CSS -->
</head>
<body>
<table border="0px" width="100%" align="center" cellpadding="0" cellspacing="0">
<!--header-->
<tr>
<td align="center" colspan="3"><?php include"../include/adminheader.php"; ?></td>
</tr>
<!--/header-->
<!--Content-->
<tr>
<td width="20%"> </td>
<td width="60%">
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bordercolor="#111111" class="main_table" style="border-collapse: collapse">
<tr>
<td align="center"> </td>
</tr>
<!-- //////////////////////////////// manage gallery images starts ////////////////////////////// -->
<tr>
<td align="center"><br><hr><br></td>
</tr>
<tr>
<td height="21" class="page_title"> .: Manage Images <a name="addimage"></a></td>
</tr>
<tr>
<td height="21" class="form_heading"> </td>
</tr>
<tr>
<td align="center">
<script>
function __validate(){
check=document.img;
//~!@#$%^&*()_+|\=-.\'checkNumberaftahan
if(! checkMixedaftahan(check.title, 2, 255, '_', '-', ' ', '','Image Name'))
return false;
if(! checkMixedaftahans(check.desc, 2, 100000, '_', '~!@#$%^&*()_+|\=-.\'', ' ', '','Image Detail'))
return false;
if(! checkMixedaftahans(check.image, 2, 255, '_', '~!@#$%^&*()_+|\=-.\'', ' ', '','Image'))
return false;
}
function del(p){
cn=confirm("Are you sure to delete this record");
if(cn){
window.location.href=p;
}
}
function validateSendInvite(){
for(var i=1; i<=3; i++){
checkName=eval("document.img.image_name"+i+"");
checkdesc=eval("document.img.image_details"+i+"");
checkimage=eval("document.img.image_file"+i+"");
if(i==1 && checkName.value=="" && checkdesc.value=="" && checkimage.value==""){
alert("Please fill in Name & Description and upload Image .");
if(checkName.value=="")
checkName.focus();
else if(checkdesc.value=="")
checkdesc.focus();
else
checkimage.focus();
return false;
}else if(checkName.value=="" && checkdesc.value=="" && checkimage.value=="")
continue;
else if(checkName.value=="" || checkdesc.value=="" || checkimage.value=="") {
if(! checkMixedaftahan(checkName, 2, 255, '_', '-', ' ', '','Image Name'))
return false;
if(! checkMixedaftahans(checkdesc, 2, 100000, '_', '~!@#$%^&*()_+|\=-.\'', ' ', '','Image Detail'))
return false;
if(! checkMixedaftahans(checkimage, 2, 255, '_', '~!@#$%^&*()_+|\=-.\'', ' ', '','Image'))
return false;
}
}
} // end function
</script>
<!-- <form style="margin:0" name='admin' method="POST" action="" enctype="multipart/form-data" onsubmit="return validateSendInvite();"> -->
<form style="margin:0" name='img' method="POST" action="" enctype="multipart/form-data" onsubmit="return validateSendInvite();">
<table class="inner_table" cellspacing="1" cellpadding="2" width="90%" border="0">
<tr>
<td colspan='2' class="field_heading11" align="center">
<?
/////////////////////////// add gallery images starts //////////////////////
if($_POST[sbmt_btn] =="Add New Image"){
$_POST[gallery_id]=1;
for($i=1;$i<=10;$i++){
$ext = substr($_FILES['image_file'.$i]['name'], -4);
if($ext == ".jpg" || $ext == ".JPG"){
$uploaddir = '../site_data/gallery/'.$_POST[gallery_id].'/';
$q = "select * from gallery_images order by gallery_image_id desc";
$q = mysql_query($q) or die(mysql_error());
if($r=mysql_fetch_array($q)){
$id=$r[gallery_image_id]+1;
}
$file_name= $id."_".$_POST[gallery_id]."_photograph".$ext;
$uploadfile = $uploaddir . $file_name ;
//$uploadfile = $uploaddir. $_FILES['image_file'.$i]['name'];
if (move_uploaded_file($_FILES['image_file'.$i]['tmp_name'], $uploadfile)) {
thumb_jpeg($uploadfile,$file_name,$uploaddir."/bigimage",700,700);
thumb_jpeg($uploadfile,$file_name,$uploaddir,150,150);
//thumb_jpeg($_FILES['image_file'.$i]['tmp_name'],$id."_photograph".$ext,$uploaddir,300,300);
//$image_file=$_FILES['image_file'.$i]['name'];
}
//echo $image_details=$file_name;
$gallery_id=$_POST["gallery_id"];
$image_name=$_POST["image_name".$i];
//$image_details = $_POST["image_details".$i];
//if($image_name != ""){
if($_FILES['image_file'.$i]['name']!= ""){
$query = "insert into gallery_images set
gallery_id='$gallery_id',
image_name='$image_name',
image_details='$image_details',
image_date = '".mktime(date("h:i:s"))."',
image_file = '$file_name'";
mysql_query($query) or die(mysql_error());
echo "Images Added Successfully in Gallery<br>";
}
}else{
if($_FILES['image_file'.$i]['name'] !="")
echo "Only .jpg file required.<br>";
}
} //end for
}
/////////////////////////// add gallery images ends //////////////////////
/////////////////////////// update gallery starts //////////////////////
if($_POST[sbmt_btn] =="Update Image"){
$_POST[gallery_id]=1;
for($i=1;$i<=1;$i++){
$query="select * from gallery_images where image_name = '".$_POST["image_name".$i]."' and gallery_id = '$_POST[gallery_id]' and gallery_image_id!='$_GET[img_id]'";
$query=mysql_query($query) or die(mysql_error());
if($row=mysql_fetch_array($query)){
echo "Error:<br>Image Name: '". $_POST[image_name] . "' already exists in this gallery.<br>";
}else{
$gallery_id=$_POST["gallery_id"];
$image_name=$_POST["image_name".$i];
$image_details = $_POST["image_details".$i];
$query = "update gallery_images set
gallery_id='$gallery_id',
image_name='$image_name',
image_details='$image_details' where gallery_image_id='$_GET[img_id]'";
mysql_query($query) or die(mysql_error());
echo "Record Successfully Updated <br>";
}
} //end for
}
/////////////////////////// update gallery ends //////////////////////
/////////////////////////// feth gallery for edit starts //////////////////////
$query="select * from gallery_images where gallery_image_id = '$_GET[img_id]'";
$query=mysql_query($query) or die(mysql_error());
if($gal_img=mysql_fetch_array($query)){}
/////////////////////////// feth gallery for edit ends //////////////////////
?>
</td>
</tr>
<tr>
<td width="98%" align="right" class="edit_field_data" colspan="2"><b>* Denoted Required Fields</b></td>
</tr>
<?
if($_GET[img_id]!="")
$j=1;
else
$j=10;
for($i=1;$i<=$j;$i++){
?>
<!-- <tr>
<td width="29%" class="td_data1">Image Name <? echo $i;?>*</td>
<td width="69%" class="td_data1"><input type="text" name="image_name<? echo $i;?>" size="60" class="field" value="<?=$gal_img[image_name]?>"></td>
</tr> -->
<? if($_GET[img_id]==""){?>
<tr>
<td width="29%" class="td_data2">Gallery Image <? echo $i;?></td>
<td width="69%" class="td_data2"><input type="file" name="image_file<? echo $i;?>" size="20" class="field"></td>
</tr>
<?}?>
<tr>
<?}?>
<td height="19" align="right" class="edit_field_data" colspan="2"><hr color="red" size="1"></td>
</tr>
<tr>
<td width="29%" class="edit_field_data1"> </td>
<td width="69%" class="edit_field_data1"><input type="submit" value="<? if($_GET[saction]=='editgalleryimg'){echo "Update Image";}else{echo "Add New Image";}?>" name="sbmt_btn" class="field">
<input type="reset" value="Reset Form" name="B2" class="field"></td>
</tr>
</table>
</form>
<!-- ///////////////////// show gallery images starts ////////////////////////////// -->
<?
if($_GET[saction] == "deletegalleryimage"){
$query="delete from gallery_images where gallery_image_id = '$_GET[gallery_image_id]'";
$query=mysql_query($query) or die(mysql_error());
@unlink("../site_data/gallery/$_GET[gallery_id]/$_GET[image_file]");
@unlink("../site_data/gallery/$_GET[gallery_id]/bigimage/$_GET[image_file]");
echo "<br><u><b>Record deleted</b></u><br> ";
}
?>
<table class="inner_table" cellspacing="1" cellpadding="2" width="90%" border="0">
<tr class="list1">
<td class="edit_field_head" width="40">Sr. No</td>
<td class="edit_field_head" width="50">Delete</td>
<td class="edit_field_head">Image</td>
</tr>
<?php
$query="select * from gallery_images order by gallery_image_id desc";
$query=mysql_query($query) or die(mysql_error());
$cnt=0;
$style = "edit_field_data1";
while($row=mysql_fetch_array($query)){
$cnt++;
if($style == "edit_field_data")
$style = "edit_field_data1";
elseif($style == "edit_field_data1")
$style = "edit_field_data";
?>
<tr style="background:#ebfed6;">
<td class="<?php echo $style;?>"><?php echo $cnt;?></td>
<td class="<?php echo $style;?>" align="center">
<!-- <a href="?action=gallery&saction=editgalleryimg&img_id=<?=$row[gallery_image_id];?>#addimage"><img src="edit.png" width="16" height="16" border="0" alt="Edit"></a> / -->
<a href="javascript:del('?action=gallery&saction=deletegalleryimage&gallery_image_id=<? echo $row[gallery_image_id];?>&image_file=<? echo $row[image_file];?>&gallery_id=<? echo $row[gallery_id];?>#addimage');"><img src="delete.png" width="16" height="16" border="0" alt="Delete"></a>
<?php //echo $row[gallery_details];?></td>
<td class="<?php echo $style;?>">
<img src="../site_data/gallery/1/<?=$row[image_file];?>" width="60" border="0" alt="">
</td>
</tr>
<?
$gallery_name1 = $row[gallery_name];
}?>
</table>
<!-- //////////////////////////////// show gallery ends ////////////////////////////// -->
</td>
</tr>
<!-- //////////////////////////////// manage gallery images ends ////////////////////////////// -->
<tr>
<td align="center">
</td>
</tr>
</table>
</td>
<td width="20%" align="left"> </td>
</tr>
<!--End Content-->
<!--footer-->
<tr>
<td align="center" colspan="3"><?php include"../include/adminfooter.php"; ?></td>
</tr>
<!--footer-->
</table>
</body>
</html>


PK 99