Psyduck - 可達鴨 之 鴨力山大 v0.1

Current Path : home/irplbiz/www/lnselgallery/control/
Upload File :
Current File : /home/irplbiz/www/lnselgallery/control/gallery-edit.php

<?php

session_start();

include('includes/db_connect.php');

?>

<!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 href="style.css" rel="stylesheet" type="text/css" />

<link href="css/form-style.css" rel="stylesheet" type="text/css" />

<title>Welcome to Our  Website::Admin Panel</title>

</head>

<?php



function getExtension($str) {

	$i = strrpos($str,".");

	if (!$i) { return ""; }

	$l = strlen($str) - $i;

	$ext = substr($str,$i+1,$l);

	return $ext;

	}

$msg = "";

if($_POST["mode"] == "edit")

{



$file=$_FILES['file']['name'];

	

	

	$file1=$_FILES['file1']['name'];

	if ($file1)

	{

	$filename = stripslashes($_FILES['file1']['name']);

	$extension = getExtension($filename);

	$extension = strtolower($extension);

	$timestamp = time().rand(1,9999);

	

	

	$galleryImageBefore1 = $timestamp . "." . $extension ; 

	$consname="document/" . $galleryImageBefore1 ; 

	$copied = copy($_FILES['file1']['tmp_name'], $consname);

	

	if (!$copied) {

	echo 'Copy unsuccessfull!';

	$errors=1;

	}else{

	$thumb_name=$consname;

	}

	}

	else

	{

		$galleryImageBefore1 = $_POST["documents1"];

	}

	

	

	$file2=$_FILES['file2']['name'];

	if ($file2)

	{

	$filename = stripslashes($_FILES['file2']['name']);

	$extension = getExtension($filename);

	$extension = strtolower($extension);

	$sizekb=filesize($_FILES['file2']['tmp_name']);

	$timestamp = time().rand(1,9999);

	$galleryImageBefore2 = $timestamp . "." . $extension ; 

	$consname="document/" . $galleryImageBefore2 ; 

	$copied = copy($_FILES['file2']['tmp_name'], $consname);

	

	if (!$copied) {

	echo 'Copy unsuccessfull!';

	$errors=1;

	}else{

	$thumb_name=$consname;

	}

	}

	else

	{

		$galleryImageBefore2 = $_POST["documents2"];

	}







$cid = implode(",", $_POST["cid"]);

	

 $insgallery = "UPDATE `ln_tbl_gallery` SET 

`title` = '".$_POST["title"]."',

`link` = '".$_POST["link"]."',

`image` = '".$galleryImageBefore1."',

`thumb` = '".$galleryImageBefore2."',

`cid` = '".$cid."' WHERE id = ".$_POST["id"];



mysql_query($insgallery);





$msg = "Update Successfully.";





}

?>

<body>

<div class="main">

<div class="inner-panel">

<table width="978" border="0" cellspacing="0" cellpadding="0" align="center" >

    <?php include('includes/header.php'); ?>



  <tr>

    <td width="200">&nbsp;</td>

    <td align="right" width="10">&nbsp;</td>

    <td align="right" width="768">&nbsp;</td>

  </tr>

  <tr>

    <td width="200" valign="top"><?php include('includes/sidebar.php'); ?></td>

    <td width="10" style="background-color:none;">&nbsp;</td>

    <td width="768" bgcolor="#FFFFFF" valign="top" align="right">

    	<div class="right-bar-style">

		<table width="97%" border="0" align="left" cellpadding="0" cellspacing="0"  bgcolor="#fff"  style="padding:0px; margin:2px 10px;">

		

            <tr>

            <td colspan="3"><div class="heading fs-32">Edit Gallery</div></td></tr>

			<tr>

            <td colspan="3">&nbsp;</td>

            </tr>

    <tr>

	  	<td align="center" style="color: green; font-weight: bold;" colspan="3">

			<?php echo $msg; ?>		</td>

	  </tr>

      

  <?php

 $sqlGallery = "SELECT * FROM `ln_tbl_gallery` WHERE id = ".$_REQUEST["id"];

$rsGallery = mysql_query($sqlGallery);

$numGallery = mysql_num_rows($rsGallery);

$resGallery = mysql_fetch_array($rsGallery);





$strCat = $resGallery["cid"];

$strCatArry = (explode(",",$strCat));



 

 ?>

 <table width="100%">

      <tr>

        <td>

			<table width="97%" border="0" align="left" cellpadding="0" cellspacing="0"  bgcolor="#fff"  style="padding:0px; margin:2px 10px;">

				

				<tr><td><form action="" method="post" name="form" enctype="multipart/form-data" id="frmValidation" onsubmit="return confirm('Are you sure you want to save this form?');">

				<input type="hidden" name="mode" value="edit">

				<input type="hidden" name="id" value="<?php echo $_REQUEST["id"]; ?>"  />

				<input type="hidden" name="documents1" id="documents1" value="<?php echo $resGallery["image"]; ?>"  />

				<input type="hidden" name="documents2" id="documents2" value="<?php echo $resGallery["thumb"]; ?>"  />

				

      

    <table width="100%">

      <tr>

        <td>

		<table width="100%">

            

            <tr>

            <td style="border:1px dotted #ccc;">Gallery Title <span style="color:#F00;">*</span></td>

            <td style="border:1px dotted #ccc;"><input type="text" name="title" id="title" class="validate[required]" value="<?php echo $resGallery["title"]; ?>"/>

			</td>

            </tr>

			 <tr>

            <td style="border:1px dotted #ccc;">Gallery Link <span style="color:#F00;">*</span></td>

            <td style="border:1px dotted #ccc;"><input type="text" name="link" id="link" class="validate[required]" value="<?php echo $resGallery["link"]; ?>"/>

			</td>

            </tr>

		 	<tr>

            <td style="border:1px dotted #ccc;">Update Big Image <span style="color:#F00;">*</span></td>

            <td style="border:1px dotted #ccc;"><input type="file" name="file1" />

			</td>

            </tr>

			<?php

			if( $resGallery["image"] != "")

			{

			?>

					<tr id="doc2">

					<td style="border:1px dotted #ccc;">Big Image:  <span style="color:#F00;"></span></td>

					<td style="border:1px dotted #ccc;"><img src="document/<?php echo $resGallery["image"]; ?>" height="100"  />

					</td>

					</tr>	

				

			<?php

			}

			?>

			

           	<tr>

            <td style="border:1px dotted #ccc;">Update Thumb Image <span style="color:#F00;">*</span></td>

            <td style="border:1px dotted #ccc;"><input type="file" name="file2" />

			</td>

            </tr>

			<?php

			if( $resGallery["thumb"] != "")

			{

			?>

					<tr id="doc2">

					<td style="border:1px dotted #ccc;">Thumb Image:  <span style="color:#F00;"></span></td>

					<td style="border:1px dotted #ccc;"><img src="document/<?php echo $resGallery["thumb"]; ?>" height="100"  />

					</td>

					</tr>	

				

			<?php

			}

			?>

			

          

			<tr>

            <td style="border:1px dotted #ccc;">Gallery Category <span style="color:#F00;">*</span></td>

            <td style="border:1px dotted #ccc;">

			

			<?php

			$sqlCategory = "SELECT * FROM `ln_tbl_category` WHERE 1 order by name ";

			$rsCategory = mysql_query($sqlCategory);

			$numCategory = mysql_num_rows($rsCategory);

			while($resCategory = mysql_fetch_array($rsCategory))

			{

			?>

				<span style=" margin-right:20px;float:left;"><input type="checkbox" name="cid[]" value="<?php echo $resCategory["id"]; ?>" <?php if (in_array($resCategory['id'], $strCatArry)){ echo "checked=checked";} ?>>&nbsp;<?php echo $resCategory["name"]; ?></span>

			<?php

			}

			?>

			

			</td>

            </tr>

			

            <tr>

            <td style="border:1px dotted #ccc;" colspan="2" align="center"><input name="submit" type="submit" class="submit1" value="Update Gallery" style="width:185px;"/></td>

            </tr>

            </table></td>

      </tr>

    </table>



 </form> 

 

  

 

          

	 </td>

      

      

      

      </tr>

      

	  </table>

		</td>

      </tr>

    </table>

 

      

	 </td>

      

      

      

      </tr>

      

	  </table>

	  </div>

	

   </td>

  </tr>

</table>

</div>

</div>

</body>

</html>