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

Current Path : home/irplbiz/www/lnselgallery/control/
Upload File :
Current File : /home/irplbiz/www/lnselgallery/control/gallery-add.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

$msg = "";



function getExtension($str) {

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

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

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

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

	return $ext;

	}

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

{



	$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;

	}

	}

	

	

	$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;

	}

	}



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

	

 $insgallery = "INSERT INTO `ln_tbl_gallery` SET 

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

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

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

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

`cid` = '".$cid."'";



mysql_query($insgallery);



$msg = "Successfully Added.";







}

?>

<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">Add gallery

            <div style="position:absolute; right:0px; top:5px;"><a href="gallery-add.php" class="btn">Add Gallery</a></div>

            </div></td></tr>



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

            </tr>

    <tr>

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

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

	  </tr>

      

  

 

    <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">

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

      

    <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]" />

			</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]" />

			</td>

            </tr>

				 

			<tr>

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

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

			</td>

            </tr>	

			<tr>

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

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

			</td>

            </tr>	

			

			

			<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"]; ?>">&nbsp;<?php echo $resCategory["name"]; ?></span>

			<?php

			}

			?>

			

			</td>

            </tr>

			

			

            <tr>

            <td colspan="2" style="border:1px dotted #ccc;"  align="center"><input name="submit" type="submit" class="submit1" value="Add 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>