5tarl0rd

Current Path : /home/tiporg/public_html/manage/
Upload File :
Current File : /home/tiporg/public_html/manage/banners.php

<?php

ini_set("display_errors",0); 

include("classes/access_user_class.php");

//include("slideshow_xml_generator.php");

//include("photoflow_xml_generator.php");

include_once('thumbnail/thumbnail.class.php');



$page_protect = new Access_user;

 //$page_protect->login_page = "login.php"; 

$page_protect->access_page(); 

if (isset($_GET['action']) && $_GET['action'] == "log_out") {

	$page_protect->log_out(); // the method to log off

}



/*Uploading instructions

1:use the gd for making thumbs while uploading.

2: Also insert the sort order by getting max9mum sort order

3: remove extra fields of table from db and also form code  

*/



if(isset($_REQUEST['upload']))

{

	$sort_order = $rw['sum']+1;

	$album = $_REQUEST['album'];

	$status = '1';	

	$caption = $_REQUEST['caption'];

	

	$target_path = "../banners/";

	$target_path = $target_path.time()."_".$_FILES['userfiles']['name']; 

	$img =  time()."_".$_FILES['userfiles']['name']; 

	move_uploaded_file($_FILES['userfiles']['tmp_name'], $target_path);

	

	$query = "INSERT INTO tbl_banners (caption,image,status) VALUES ('".$caption."','".$img."','".$status."')"; 

	mysql_query($query)or die('query error');

	$message = "Banner Uploaded successfully"; 

}





if( isset($_POST['image_id']) )

{

	// Set the Caption of the Image

	$imagesLength = count($_POST['image_id']);

	for($i=0; $i<$imagesLength; $i++)

	{

		$query = "UPDATE tbl_banners SET album='".$_REQUEST['album'][$i]."',caption = '".$_POST['caption'][$i]."',status='".$_REQUEST['stat'][$i]."' WHERE id = ".$_POST['image_id'][$i];

		mysql_query($query);

	}





	// Delete Image(s)

	if(isset($_POST['delete']))

	{

		$deleteImages = count($_POST['delete']);

		for($i=0; $i<$deleteImages; $i++)

		{

			$query = "DELETE FROM tbl_banners WHERE id = ".$_POST['delete'][$i];

			mysql_query($query);

		}

	}



	header("Location:banners.php");

}

 

function draw_select( $name, $sqlResult, $thisAlbum)

{

	$text= '';

	mysql_data_seek($sqlResult,0);

	

	$text = '<select name="'.$name.'" >';

	$text .= '<option value="-1">&nbsp;</option>';

	while( $thisRow = mysql_fetch_array($sqlResult) )

	{

		if($thisRow['id'] != $thisAlbum)

		$text .= '<option value="'.$thisRow['id'].'">'.ucwords($thisRow['name']).'</option>';	

	}

	$text .= '</select>';

	

	return $text;

}



/////////// PAGEING CODE //////////////////////



// how many rows to show per page

$rowsPerPage = 5;

// by default we show first page

$pageNum = 1;

// if $_GET['page'] defined, use it as page number

if(isset($_GET['page']))

{

	$pageNum = $_GET['page'];

}



// counting the offset

$offset = ($pageNum - 1) * $rowsPerPage;

$query   = "SELECT COUNT(id) AS numrows FROM tbl_banners";

$result  = mysql_query($query) or die('Error, query failed');

$row     = mysql_fetch_array($result, MYSQL_ASSOC);

$numrows = $row['numrows'];

?>

<html>

<head>



<title>Photo Gallery</title>

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

<link href="css/main.css" rel="stylesheet" type="text/css">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<script language="javascript" type="text/javascript">

	function submitForm()

	{

		frm = document.getElementById("albumPictures");

		if(!frm.submit()){

		//alert("Changes have been saved.");

		}

	}

</script>

</head>

<body  topmargin="0">

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

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

  <tr>

    <td rowspan="2" align="left" background="images/white_left_bar.gif"></td>

    <td align="center"></td>

    <td width="1%" rowspan="2" align="right" background="images/white_right_bar.gif">&nbsp;</td>

  </tr>

  <tr>

  

    <td width="99%" ><table width="98%" border="0" align="center" cellpadding="2" cellspacing="2">

        <tr>

          <td width="20%" valign="top"><?php include("includes/left_column.php");?></td>

          <td width="80%" valign="top" class="bodyTableBorderGray"><table width="100%" border="0" cellspacing="0" cellpadding="0">

              <tr>

                <td height="22" align="center" bgcolor="#EFEFEF" class="boldText">Slide Show Pictures</td>

              </tr>

              <tr>

                <td style="padding-top:10px;"><table border="0" cellpadding="2" cellspacing="2" align="center" width="90%">

					<tr>

					  <td align="right" valign="top"><a href="gallery.php">Go Back</a></td>

				    </tr>				

					<?php

					if(isset($message))

					{

					?>

					<tr>

					  <td align="center" valign="top"><?php echo $message; ?></td>

				    </tr>

					<?php

					}

					?>

					

					<tr>

					<td align="center" valign="top">

					 

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

                      <tr>

                        <td><form action="banners.php" method="post" name="upload" id="upload" enctype="multipart/form-data">

                    <table brder="0" cellpadding="2" cellspacing="3" width="100%" class="bodyTableBorderGray" align="center">

					

                      <tr>

                        <td colspan="2" align="center" valign="top" class="boldBodyText">Upload New Picture </td>

                        </tr>

                      

                      <tr>

                        <td align="right" class="boldBodyText">Picture : </td>

                        <td><input name="userfiles" type="file" id="userfiles"> 

                          (Width: 1660px &amp; Height: 500px) </td>

                      </tr>

                      <tr>

                        <td height="5" colspan="2" align="right" class="boldBodyText"></td>

                        </tr>

                      <tr>

                        <td width="18%" align="right" class="boldBodyText">  Caption : </td>

                        <td width="82%"><input name="caption" type="text" id="caption" value="" size="35"></td>

                      </tr>

                      

                      

                      <tr>

                        <td align="right" class="boldBodyText"></td>

                        <td style="padding:10px 0px 5px 20px;"><input type="submit" name="upload" value="Upload"></td>

                      </tr>

                    </table>

					</form></td>

                      </tr>

                    </table>					</td>

					</tr>

					

			 

					<tr>

					  <td style="text-transform:capitalize;" align="right"><table width="100%" border="0">

                      <tr>

                        <td width="5%" align="left" class="boldBodyText"  style="text-transform:capitalize; padding:10px 0px 0px 0px;"><img src="images/icons/clean.gif" width="16" height="16"></td>

                        <td width="71%" align="left" class="boldBodyText"  style="text-transform:capitalize; padding:10px 0px 0px 0px;">

                            <a href="javascript:void(0)" onClick="submitForm();">Save Changes</a>                             </td>  

                     

                        <td width="5%" align="right" class="boldBodyText"  style="text-transform:capitalize; padding:10px 0px 0px 0px;">&nbsp;</td>

                        <td width="19%" align="right" class="boldBodyText"  style="text-transform:capitalize; padding:10px 0px 0px 0px;">&nbsp;</td>

                      </tr>

                    </table></td>

				    </tr>

	 

					

				   <tr><td>

				<form name="albumPictures" id="albumPictures" action="banners.php"  method="post" >

				<table border="0" cellpadding="1" cellspacing="1" align="center" width="100%">

					<?php 

					$next = '';

					$last = '';

					$prev  = '';    

					$first = '';



					$maxPage = ceil($numrows/$rowsPerPage);

					$self = $_SERVER['PHP_SELF'];

					

					if ($pageNum > 1)

					{

						$page = $pageNum - 1;

						$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";

						$first = " <a href=\"$self?page=1\">[First Page]</a> ";

					} 

					else

					{

						$prev  = ' [Prev] ';        

						$first = ' [First Page] ';  

					}

					

					if ($pageNum < $maxPage)

					{

						$page = $pageNum + 1;

						$next = " <a href=\"$self?page=$page\">[Next]</a> ";

						$nexttop = " &nbsp;<a href=\"$self?page=$page\">next</a> ";

						$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";

					} 

					else

					{

						$next = ' [Next] ';      

						$last = ' [Last Page] '; 

						$nexttop = " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

					}

					

					 

					$pagesListing = '';

					$totalPages = $numrows/$rowsPerPage;

					$b=ceil($totalPages);

					

					$currentPage = (isset( $_REQUEST['page'])) ? $_REQUEST['page'] : '1';

					

					for ( $i=1; $i<=$b; $i++ )

					{

						$pagesListing .= " <a href=\"$self?page=$i\">$i</a> ";

					}

?>

				<tr>

				<td>

				 <table border="0" cellpadding="0" cellspacing="0" width="100%">

				  <tr>

				  	<td align="left" width="30%" class="boldBodyText" style="padding:10px 0px 0px 0px;">

					

					<?php 

					if ($numrows > 0){

						echo 'Showing <strong>'.$pageNum.'</strong> of <strong>'.$maxPage.'</strong>';

					}

					?>					</td>

					<td align="right" width="70%" class="boldBodyText" style="padding:10px 0px 0px 0px; font-weight:bold;"><?php echo $pagesListing. $nexttop ;?></td>

				  </tr>

				 </table>				</td>

				</tr>

				<tr>

                	<td align="center" class="boldBodyText">

<?php					

					////// Paging Code END

					

					$query = "SELECT * FROM tbl_banners ORDER BY id DESC  LIMIT $offset, $rowsPerPage";

					$result = mysql_query($query);

					

					

					if( mysql_num_rows($result) > 0 )

					{

						$columnCount = 0;

						while( $row = mysql_fetch_array($result) )

						{

						?>

						<tr>

						<td align="center">

						

						

						<table border="0" cellpadding="1" cellspacing="1" align="center" width="100%" class="bodyTableBorderGray">

						<tr>



						<td align="left" width="70%" valign="top">

						<table border="0" cellpadding="0" cellspacing="0" align="left" width="100%">

						

						<tr>

						  <td align="left" valign="top" class="boldBodyText" style="padding-left:5px;">&nbsp;</td>

						  <td>&nbsp;</td>

						  </tr>

						<tr><td width="91" align="left" valign="top" class="boldBodyText" style="padding-left:5px;">Caption :&nbsp;</td>

						<td width="248"><textarea name="caption[]" id="caption" rows="3" cols="25"><?php echo $row['caption']; ?></textarea></td></tr><tr><td>&nbsp;</td></tr> 

						</table>						</td>



						

						<td align="center" valign="top">

						<table border="0" cellpadding="0" cellspacing="3" align="center" width="100%" bgcolor="#EFEFEF">

						

						<?php 

						if($row['status'] == '1')

						{

							$chk = "checked = 'checked'";

						}

						else

						{

							$chk = "";

						}

						?>

						<tr bgcolor="#FFFFFF"><td valign="middle" align="center" height="100" colspan="1">

						<div style="height:100px; width:200px;">

						<img src="../banners/<?php echo $row['image']; ?>" height="100" width="200" border="0" />	

						</div>

						</td></tr>

						<tr>

						  <td align="left" valign="middle"><input type="checkbox" name="stat[]" value="<?php echo $row['id']; ?>" <?php echo $chk;?>> &nbsp;Display</td>

						</tr>

						<tr><td width="70%" align="left" valign="middle" class="boldBodyText"><input type="checkbox" name="delete[]" value="<?php echo $row['id']; ?>"> &nbsp;Delete this Image</td>

						<td align="left" valign="middle"><a href="banners.php?action=up&Id=<?php echo $row['site_id']; ?>&id=<?php echo $row['id']; ?>"></a>

						 <a href="banners.php?action=down&cat_id=<?php echo $row['category_id']; ?>&Id=<?php echo $row['site_id']; ?>&id=<?php echo $row['id']; ?>"></a> </td>

						</tr>

						

						

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

						</table>						</td>

						 </tr> 

					 </table>						 </td> 

						 </tr>

						 <?php 						

						 }

					}

					else

					{

					?>

						<tr><td align="center">No Records found.</td></tr>

					<?php 

					}

					?>

					</table>

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

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

					</form>

					



						  </td>

                    </tr>

					<?php 					// print the page navigation link

					if ($numrows > 0){

					?>

						<tr><td align="center" class="boldBodyText" style="padding:5px 0px 5px 0px;"><?php echo $first; ?>&nbsp;<?php echo $prev; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $next; ?>&nbsp;<?php echo $last; ?></td></tr>

					<?php }

					?>

                  </table></td>

              </tr>

            </table></td>

        

		

		

		</tr>

      </table></td>

  </tr>

  <tr>

    <td><img src="images/white_left_bottom_corner.gif" width="9" height="9" /></td>

    <td width="99%" background="images/white_bottom_bar.gif"><img src="images/white_bottom_bar.gif" width="4" height="9"/></td>

    <td width="1%"><img src="images/white_right_bottom_corner.gif" width="9" height="9" /></td>

  </tr>

</table>

</body>

</html>

5tarL0rd By 5tarl0rd Being Anonymous