Location: PHPKode > projects > Bohemian CMS file manager > A_DOWNLOADS/downloads_unsplit_no_public.php
<?php 
require('utilities.inc'); 
include('public.inc'); 
 #find out who's logged in
session_start();

if ($_GET['orderby']) {
$order_by = $_GET['orderby'];
$_SESSION['orderby']=$order_by;
}
else {
$order_by = 'id DESC';
//die('died');
}

function my_page_URL() {

$page_URL = 'http';
if ($_SERVER["HTTPS"] == "on") {$page_URL .= "s";}
$page_URL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$page_URL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$page_URL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $page_URL;
}

$url=my_page_URL();
$domain = strstr($url, 'bohemianism'); 
$cms_page_url= str_replace('bohemianism.ca/', '', $domain);

$php_ext=".php";
$cms_page_url= $cms_page_url;
public_db_connect();

$timer_start = microtime(true);
$get_user_agent = $_SERVER['HTTP_USER_AGENT'];
if (strpos($get_user_agent,'MSIE') != false && strpos($get_user_agent,'Opera') === false){
if (strpos($get_user_agent,'Windows NT 5.2') != false){
if(strpos($get_user_agent,'.NET CLR') === false) return;
}
}

  $myid = $_SESSION['id'];
?> 
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />		
		<meta name="description" content="<?php echo $description; ?>" />
		<meta name="keywords" content="<?php echo $keywords; ?>" /> 
		
		<link rel="stylesheet" type="text/css" href="style.css" />
		<!--[if IE 6]>
	<link rel="stylesheet" type="text/css" href="ie6.css" />
<![endif]-->
<SCRIPT type= "text/javascript">
 // function redireccionar() {
 //   setTimeout("location.href='http://www.bohemiawebsite.com/home/index.php/fixedwidth'", 5000);
//  }
 </SCRIPT>

<script type= "text/javascript">
if (screen.width >= 800 && screen.width <=1035 ) {
document.location = "http://bohemianism.ca/index_fixed.php"
}
else if (screen.width <=500 ) {
document.location = "http://bohemianism.ca/mobile"
}
</script> 

<script type= "text/javascript">
<!-- Original:  Ronnie T. Moore, Editor -->
<!-- Web Site:  http://javascriptsource.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var refarray = new Array();
refarray['http://vancouver.en.craigslist.ca/'] = "clist.php";
//refarray['yahoo.com'] = "page.html?from=yahoo";
//refarray['lycos.com'] = "page.html?from=lycos";
//refarray['infoseek.com'] = "page.html?from=infoseek";
for (var i in refarray) {
if (document.referrer.indexOf(i) != -1) window.location.replace(refarray[i]);
}
//  End -->
</script>
  <script type="text/javascript">
function showstuff(){
   document.getElementById("submenu").style.visibility="visible";
}
function hidestuff(){
   document.getElementById("submenu").style.visibility="hidden";
}
</script>
  <script type="text/javascript">
function showstuff2(){
   document.getElementById("submenu2").style.visibility="visible";
}
function hidestuff2(){
   document.getElementById("submenu2").style.visibility="hidden";
}
</script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
	<script src="ckeditor/_samples/sample.js" type="text/javascript"></script>

	
		<title><?php echo $page_title; ?></title>
	
	</head>

<body id="body" style="/*background:white; background-color:white;*/" onLoad="redireccionar()">
	<div id="container" style="" >
                    
<div id="main" style="width:100%; margin-left:0px; margin-right:0px;">
    <div id="nav_bg">
			<span style="font-size:20px; margin-top:13px; /*position:absolute;*/float:left; "><i></i></span>			
			<ul id="navigation2" style="z-index:2;">
			<li style="z-index:1;"><a href="login.php">Home</a></li>			
		</ul>
			
		</div>		
        <!-- Header end --> 

				
	<?php  if (is_numeric($myid) || $myid==1) {	?>
      <!-- Main begin-->
        <div id="main" style="width:100%; margin-left:0px; margin-right:0px;">	
		
		<?php
	  ##START DLOADS
 $counter = 1; //This number sets the amount of upload and description boxes

if (isset($_POST['mysubmit']) && !empty($_POST['myhid']) && $_POST['submit']) { 
$db=public_db_connect();

	for ($i = 0; $i < $counter; $i++) { 
	
		$filename = 'upload'.$i;
		$description = 'description'.$i;
		$category = 'category'.$i;
	
		if (isset($_FILES[$filename]) && ($_FILES[$filename]['error'] != 4)) {
		
	// file needs to be pdf or word doc and 1 MB max
	if (($_FILES[$filename]['type'] == "application/pdf" || $_FILES[$filename]['type'] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document" || $_FILES[$filename]['type'] == "application/zip" || $_FILES[$filename]['type'] == "application/x-zip" || $_FILES[$filename]['type'] == "application/x-zip-compressed" || $_FILES[$filename]['type'] == "application/multipart/x-zip" || $_FILES[$filename]['type'] == "application/application/x-compress" || $_FILES[$filename]['type'] == "application/application/x-compressed" || $_FILES[$filename]['type'] == "application/application/octet-stream" || $_FILES[$filename]['type'] == "text/xml" || $_FILES[$filename]['type'] == "text/plain" || $_FILES[$filename]['type'] == "text/html" || $_FILES[$filename]['type'] == "text/css" || $_FILES[$filename]['type'] == "application/x-javascript" || $_FILES[$filename]['type'] == "image/jpeg" || $_FILES[$filename]['type'] == "image/pjpeg" || $_FILES[$filename]['type'] == "image/jpg" || $_FILES[$filename]['type'] == "image/pjpg" || $_FILES[$filename]['type'] == "image/gif" || $_FILES[$filename]['type'] == "image/x-png" ) && ($_FILES["image_upload_box"]["size"] < 1000000)){ 	

			if (!empty($_POST[$description])) {
			$desc = mysql_real_escape_string($_POST[$description]);
			} else {
				$desc = 'None';
			}
	
			$name = $_FILES[$filename]['name'];
			$size =$_FILES[$filename]['size']; 
			$type = $_FILES[$filename]['type'];
			$cat = mysql_real_escape_string($_POST[$category]);
			
			$command = "INSERT INTO uploads (id, name, size, type, description, category, published, date) VALUES ('', '$name', '$size', '$type', '$desc', '$cat', 0, now())";
			$result = mysql_query($command);
				
			if ($result==true) {
			$to = 'hide@address.com';
			$subject = 'New Upload';
			$message = 'A new upload was made from the community news and events page.';
			$headers = 'From: hide@address.com' . "\r\n" .
			'Reply-To: hide@address.com' . "\r\n" .
			'X-Mailer: PHP/' . phpversion();
			// mail($to, $subject, $message, $headers);
			$upload_id = mysql_insert_id();
				
				if (move_uploaded_file($_FILES[$filename]['tmp_name'], "uploads/$name")) {
						
					echo '<p><span style="color:#36624C;">File name '.$name.' has been uploaded!</span></p>';
					echo '<p><span style="color:#36624C;"><a href="'.$_SERVER[PHP_SELF].'">Upload another file </a></span></p>';
					
					echo '<p><span style="color:#36624C;"><a href="'.$_SERVER[PHP_SELF].'">Back to downloads.</a></span></p>';
					
				} else { 
				
					echo '<p><font color="red">File number ' . ($i + 1) . ' could not be moved.</font></p>';
		
					$query = "DELETE FROM uploads WHERE upload_id = $upload_id";
					$result = mysql_query ($query);
					}				
			}

			else {
				echo '<p><font color="red">Your submission could not be processed due to a system error. We apologize for any inconvenience.</font></p>'; 				
			}			
		}	else {
		echo '<p><span style="color:#36624C;">We only accept the following documents:<br/>Word, PDF, txt, jpeg, gif, png, html, javascript and css that are less than 1 mb!</span></p>';
					echo '<p><span style="color:#36624C;"><a href="'.$_SERVER[PHP_SELF].'">Try again</a></span></p>';
					}
}		
	} 	
	mysql_close();	
 exit();
} 

else {
//echo "Please add a description";
}
?>
<form enctype="multipart/form-data" action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">

	<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
	<input type="hidden" name="myhid" value ="hi">
	<style type="text/css">
	textarea#ta {
	width:450px;
	display:block;
   	border-radius: 10px;
	border: 1px solid #36624C;
	padding:15px;
	font-family:arial;
	height:50px;
	}
	</style>
	<?php 
	for ($i = 0; $i < $counter; $i++){
		echo '<div style="display:inline-block; width:100%;"> 
		<div style="float:left; width:50%;"><p style="font-family:arial; font-size:14px;"><b>Upload File:</b> <input type="file" name="upload' . $i . '" /></p>
		<p style="display:none;"><b>Category:</b> <select  style=" " name="category' . $i . '" ><option>PDF</option><option>HTML</option></select></p>
	<p><strong>Description:</strong></p><p><b></b> <textarea id="ta" style="width:90%; min-height:75px; height:100%;" name="description' . $i . '" ></textarea></p></div>
	<div style="float:left;width:50%; padding-top:10px; margin-bottom:0px;"><img style="width:100%;display:none;" src="images/dloads.png" /></div></div>
	';
	//echo "The for loop is done twice";
	}
	?>	
	<input type="hidden" name="mysubmit" value="TRUE" />
	<div align="left"><input type="submit" style="width:10%;margin-left:15px;" name="submit" value="Submit" /></div>
</form></div>
<?php/* } 

else {

}*/
?>
<div style="clear:both;"></div>
<?php } ?>











		
 <?php
###################### SEPARATING ADMIN FROM USERS
###################### NON ADMIN
 if (!(is_numeric($myid)) || $myid!=1) {
 //if ($page_title) {

	?>
<div>
<?php 
$db=public_db_connect();
###################BEGIN ADMIN
if ($_SESSION['customer_id']=='1') { 
//echo "Booyah!";
}
#############END ADMIN
###########################BEGIN NON-ADMIN
else { 
if ($_POST['submit_type']) {
$type = $_POST['file_type'];
$file_category = $_POST['file_category'];
//echo $cat;
}?>
<div style="height:auto;padding-top:5px; padding-bottom:10px; color:white; background-color:#440110; margin: auto; width:100%;">
<div><strong><span style="color:#FF7214; font-size:20px;margin-left:20px;">DOWNLOAD FILES</span></strong></div>
<div style="display:block; width:100%;"><div style="float:left;width:65px;display:none;"><strong>File Type:</strong></div> 
<div style="float:left;"></p></div></div>

<!-- below not used -->
<div style="display:none; width:100%;"><div style="float:left;width:65px;"><strong>Category:</strong></div> 
<div style="float:left;display:none;"><form action="<?php echo $_SERVER[PHP_SELF]."?".$_SERVER[QUERY_STRING].'?'; ?>" method="POST">
<select name="category">
<option>text/plain</option>
<option>application/zip</option>
<option>application/pdf</option></select>
<input type="submit" name="submit_category" value="Search"/></form></div></div>
<!-- end not used -->

<?php 
if (!$_POST['submit_type']) { ?>
<table style="margin-top:0px; width:100%;" cellpadding="10" cellspacing="0"><tr style="color:#dc4000;"><td><strong>FILE NAME</strong><?php echo '&nbsp<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=name asc"><img style="border:none;" src="images/arrow-up.png" /></a>'.''.'<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=name desc"><img style="border:none;" src="images/arrow.png" /></a>';?></td><td><strong>SIZE</strong></td><td><strong>TYPE</strong><?php echo '&nbsp<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=type asc"><img style="border:none;" src="images/arrow-up.png" /></a>'.''.'<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=type desc"><img style="border:none;" src="images/arrow.png" /></a>';?></td><td><strong>DESCRIPTION</strong><?php echo '&nbsp<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=description asc"><img style="border:none;" src="images/arrow-up.png" /></a>'.''.'<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=description desc"><img style="border:none;" src="images/arrow.png" /></a>';?></td><td><strong>DATE</strong><?php echo '&nbsp<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=date asc"><img style="border:none;" src="images/arrow-up.png" /></a>'.''.'<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=date desc"><img style="border:none;" src="images/arrow.png" /></a>';?></td></tr>

<?php }
else{ ?>
<table style="margin-top:0px; width:100%;" cellpadding="10" cellspacing="0"><tr style="color:#dc4000;"><td><strong>FILE NAME</strong></td><td><strong>SIZE</strong></td><td><strong>TYPE</strong></td><td><strong>DESCRIPTION</strong></td><td><strong>DATE</strong></td></tr>
<?php
}
#######################################PAGINATION STARTS HERE	
if (!(isset($page_number))) { 
 $page_number = 1; 
 } 

//Need to get the page number by counting rows, entries and getting entries per page
$page_number=$_GET['pagenumber']; 
if($_POST['submit_type']){
if($type == 'All' && $file_category=='All') {
//echo $type.$file_category;
$command2 = "SELECT * FROM uploads where published ='1' ORDER BY $order_by ";
}
else if($type=='All' && $file_category != 'All') {
$command2 = "SELECT * FROM uploads where published ='1' AND category='$file_category' ORDER BY $order_by ";
}
else if($type!='All' && $file_category == 'All') {
$command2 = "SELECT * FROM uploads where published ='1' AND type='$type' ORDER BY $order_by ";
}
else if($type!='All' && $file_category != 'All') {
$command2 = "SELECT * FROM uploads where published ='1' AND type='$type' AND category='$file_category' ORDER BY $order_by ";
}
else {
$command2 = "SELECT * FROM uploads where published ='1' AND type='$type' ORDER BY $order_by ";
}
}
## end post submitted
else{
$command2 = "select * from uploads where published ='1' "; 
}
$result2 = mysql_query($command2, $db); 
$rows = mysql_num_rows($result2);
//command below tells us how many entries there actually are
//echo $rows;
//how many entries we want
$number_entries = 5; 
//echo $number_entries;
 //This tells us the page number of our last page 
$last_page = ceil($rows/$number_entries); 
//this makes sure the page number isn't below one, or more than our maximum pages 
 if ($page_number < 1) { 
$page_number = 1; 
} 
elseif ($page_number > $last_page) { 
$page_number = $last_page; 
} 

if($_POST['submit_type']){
if($type == 'All' && $file_category=='All') {
$command = "SELECT * FROM uploads where published ='1' ORDER BY $order_by ";
}
else if($type=='All' && $file_category != 'All') {
$command = "SELECT * FROM uploads where published ='1' AND category='$file_category' ORDER BY $order_by ";
}
else if($type!='All' && $file_category == 'All') {
$command = "SELECT * FROM uploads where published ='1' AND type='$type' ORDER BY $order_by ";
}
else if($type!='All' && $file_category != 'All') {
$command = "SELECT * FROM uploads where published ='1' AND type='$type' AND category='$file_category' ORDER BY $order_by ";
}
else {
$command = "SELECT * FROM uploads where published ='1' AND type='$type' ORDER BY $order_by ";
}
/*if($type == 'All') {
$command = "SELECT * FROM uploads where published ='1' ORDER BY $order_by ";
}
else{
$command = "SELECT * FROM uploads where published ='1' AND type='$type' ORDER BY $order_by ";
}*/
}
else{
$command = "SELECT * FROM uploads where published ='1' ORDER BY $order_by ";
}
$command .= 'limit ' .($page_number - 1) * $number_entries .',' .$number_entries; 
$result= mysql_query($command, $db);

while($row = mysql_fetch_assoc($result)){
$bg =($bg=='#BDE4D1' ? '#252525' : '#BDE4D1');
		
$file_id = $row['id'];
$file_name = $row['name'];
$myfilesize = $row['size'];
$myfilesize= number_format($myfilesize/1000,0);
$mytype = $row['type'];
$mydescription = $row['description'];
$mypublished = $row['published'];
$mydate = $row['date'];

echo '<span style="color:white;"><tr bgcolor="' . $bg . '"><td><a class="dload" href="downloads/downloads.php?filename='.$file_name.'"><b>'.$file_name.'</b></a>
<td><b></b>'.$myfilesize.' kb</td>
<td><strong></strong> '.$mytype.'</a></td><td><strong></strong> '.$mydescription.'</td><td><strong></strong> '.date('Y-m-j', strtotime($row[date])).'</td>';
if ($_SESSION['customer_id']=='1'){
echo '<td><strong></strong> '.$mypublished.'</td>'; 
}
echo '<tr></span>';
}
?>
</table>
<?php
//starting with the first page, make a loop for all pages and links to those pages
 for($i = 0; $i<$last_page; $i++) {
		$page_link = $i + 1;
		//create an array of links
		$links_pages[] = " <a style=\"font-size:12px; color:#DFD849;\" href='{$_SERVER['PHP_SELF']}?orderby=".$_SESSION[orderby]."&pagenumber=".$page_link."' >".$page_link."</a>";
	}
	
 // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.
 ?>
<div style="display:none; text-align:center; background-color:#252525; padding:5px;">
<?php
 if ($page_number == 1) {
 } 
 else if ($page_number > 1)
 {
 echo " <a style=\"font-size:12px; color:#DFD849;\" href='{$_SERVER['PHP_SELF']}?orderby=".$_SESSION[orderby]."&pagenumber=1'> <<-First</a> ";
 echo " ";

$previous_page = $page_number-1;

 echo " <a style=\"font-size:12px; color:#DFD849; \" href='{$_SERVER['PHP_SELF']}?orderby=".$_SESSION[orderby]."&pagenumber=$previous_page'> <-Previous</a> "; ?>

<?php 
} 
?>


<?php
if ($page_number == $last_page) {
} 
 else { 
 $next_page = $page_number+1;
 echo "<a style=\"font-size:12px; color:#DFD849;\" href='{$_SERVER['PHP_SELF']}?orderby=".$_SESSION[orderby]."&pagenumber=$next_page'>Next -></a> ";
 echo " ";
 echo " <a style=\"font-size:12px; color:#DFD849;\" href='{$_SERVER['PHP_SELF']}?orderby=".$_SESSION[orderby]."&pagenumber=$last_page'>Last ->></a>";
 } 

// This shows the user what page they are on, and the total number of pages
echo "<span style=\"font-size:12px;\"> Page $page_number of $last_page</span>"; 	
?></div>
  <div style="display:none; text-align:center; background-color:#252525; padding:5px;">
  Page: 
  <?php 
  if (count($links_pages))  {
  foreach($links_pages as $links){
	echo $links;
  }
  }
  else {
  echo "1";
  }
  ?>

</div></div></div></div><div style="clear:both;"></div>
<div style="clear:both;"></div>
<hr style="display:none;">

   <?php 
include("footer.php");
  exit();
}
?>

<?php
#############END NON-ADMIN
		  ##END DLOADS		
}



 ########################################### END NON ADMIN 
 ########################################### ADMIN BEGIN
  else {

  echo "<b><a style=\"margin-left:10px;\" href=\"logout.php\">Logout!</a></b>"." <br/>";
   
$db = member_db_connect();
    $top = $_POST['top'];
    

    #first, make sure all fields were submitted
    if (!($top /*&& $mid && $footer*/)) {
       $error_message = "<div style=\"display:none;\">Please make sure you've filled in all the form fields.</div>";
    }
  
    else {
       $success = true;  //flag to determine success of transaction

       //start transaction
       $command = "SET AUTOCOMMIT=0";
       $result = mysql_query($command);
       $command = "BEGIN";
       $result = mysql_query($command);

        
          if (is_numeric($cms_id)) {
          $command = "SELECT top FROM cms WHERE cms_id='".addslashes($cms_id)."';";
          $result = mysql_query($command);

          if ($data = mysql_fetch_object($result)) {
              $command = "UPDATE cms SET top='".addslashes($top)
                         ."' WHERE cms_id='".addslashes($cms_id)."';";
		      $result = mysql_query($command);
			  
			  if ($result == false) {
                   $success = false;
              }
          }
          else {
                          
			 if (($result == false) ||
                 (mysql_affected_rows() == 0)) {
                 $success = false;
             }
          }
       }
	 
       if (!$success) {
              $command = "ROLLBACK";
              $result = mysql_query($command);
              $error_message = "We're sorry, there has been an error on our end.  
                                Please contact us to report this bug.  ";
       }
       else {
              $command = "COMMIT";
              $result = mysql_query($command);
       }
       $command = "SET AUTOCOMMIT=1";  //return to autocommit
       $result = mysql_query($command);

       #If successful, redirect
       if ($success) {
       echo "Changes Successful!";
       }
       
    } 
?>
<h4 style="display:none;">Edit Your Homepage:</h4>
<?
###################BEGIN ADMIN
if ($_SESSION['customer_id']=='1') { 
#####UPDATE PUBLISHING
if ($_POST['pub']=='0') {
$myfile_id = $_POST['update'];
//echo "hi".$myfile_id;
$command = "UPDATE uploads set published='1' where id=$myfile_id ";
$result = mysql_query($command, $db); 

} else if ($_POST['pub']=='1') {
$myfile_id = $_POST['update'];
//echo "hi".$myfile_id;
$command = "UPDATE uploads set published='0' where id=$myfile_id ";
$result = mysql_query($command, $db); 
}
##############END UPDATE PUBLISHING
##############BEGIN DELETE UPLOAD FILE
if ($_POST['delete_upload']) {
$myfile_id = $_POST['delete_upload'];
//echo "hi".$myfile_id;
$command = "DELETE FROM uploads where id=$myfile_id ";
$result = mysql_query($command, $db); 
}
##############END DELETE UPLOAD FILE
##############BEGIN EDIT DESCRIPTION
if ($_POST['update_desc']) {
$myfile_id = $_POST['update_description'];
$text_desc= $_POST['update_text_desc'];
$command = "UPDATE uploads set description='$text_desc' where id=$myfile_id ";
$result = mysql_query($command, $db); 
}
##############END EDIT DESCRIPTION
?>
<div style="height:100%;"><strong><span style="color:#FF7214; display:none;">DOWNLOAD FILES</span></strong><br/><br/>
<table style="width:100%;" cellpadding="10"><tr><td><strong>Name</strong><?php echo '&nbsp<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=name asc"><img src="images/arrow-up-black.png" /></a>'.''.'<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=name desc"><img src="images/arrow-black.png" /></a>';?></td><td><strong>Size</strong><?php echo '&nbsp<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=size asc"><img src="images/arrow-up-black.png" /></a>'.''.'<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=size desc"><img src="images/arrow-black.png" /></a>';?></td><td><strong>Type</strong><?php echo '&nbsp<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=type asc"><img src="images/arrow-up-black.png" /></a>'.''.'<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=type desc"><img src="images/arrow-black.png" /></a>';?></td><td><strong>Date</strong><?php echo '&nbsp<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=date asc"><img src="images/arrow-up-black.png" /></a>'.''.'<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=date desc"><img src="images/arrow-black.png" /></a>';?></td><td><strong>Description</strong></td><td><strong>Published</strong><?php echo '&nbsp<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=published asc"><img src="images/arrow-up-black.png" /></a>'.''.'<a style="color:#dc4000;" href="'.$_SERVER['PHP_SELF'].'?orderby=published desc"><img src="images/arrow-black.png" /></a>';?></td><td><strong>Delete</strong></td></tr>
<?php 
//count them and make pagination like I've done many times before
#######################################PAGINATION STARTS HERE	
if (!(isset($page_number))) { 
 $page_number = 1; 
 } 

//Need to get the page number 
$page_number=$_GET['pagenumber']; 
$command2 = "select * from uploads "; 
$result2 = mysql_query($command2, $db); 
$rows = mysql_num_rows($result2);
//command below tells us how many entries there actually are
//echo $rows;
//how many entries we want
$number_entries = 5; 
//echo $number_entries;
 //This tells us the page number of our last page 
$last_page = ceil($rows/$number_entries); 
//this makes sure the page number isn't below one, or more than our maximum pages 
 if ($page_number < 1) { 
$page_number = 1; 
} 
elseif ($page_number > $last_page) { 
$page_number = $last_page; 
} 

$command = "SELECT * FROM uploads ORDER BY $order_by ";
$command .= 'limit ' .($page_number - 1) * $number_entries .',' .$number_entries; 
$result= mysql_query($command, $db);

while($row = mysql_fetch_assoc($result)){
$file_id = $row['id'];
$file_name = $row['name'];
$myfilesize = $row['size'];
$myfilesize= number_format($myfilesize/1000,0);
$mytype = $row['type'];
$mydescription = $row['description'];
$mypublished = $row['published'];
$mydate = $row['date'];

//if ($_SESSION['customer_id']=='1'){
echo '<tr><td><a href="/downloads/downloads.php?filename='.$file_name.'"><b>'.$file_name.'</b></a>
<td><b></b>'.$myfilesize.' kb</td>
<td><strong></strong> '.$mytype.'</a></td>';

echo '<td><strong></strong> '.date('Y-m-j', strtotime($row[date])).'</td>';

echo '<td style="text-align:center;"><strong></strong> ';

echo '<strong></strong> <form method="post" action="'.$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'].'">
<input type="hidden" name="update_description" value="'.$file_id.'" />
<textarea name="update_text_desc">'.$mydescription.'</textarea>
<input type="submit" name="update_desc" value="Update" /></form></td>';


//echo '<td style="text-align:center;"><strong></strong> <a href="publish.php?">'.$mypublished.'</a></td>'; 
echo '<td style="text-align:center;"><strong></strong> <form method="post" action="'.$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'].'">
<input type="hidden" name="update" value="'.$file_id.'" />
<input type="hidden" name="pub" value="'.$mypublished.'" />
<input type="submit" name="submit" value="';
if ($mypublished=='1') {
echo "Unpublish";
}
else if ($mypublished=='0'){
echo "Publish";
} 
 echo '" /></form></td>'; 
//echo '<td style="text-align:center;"><strong></strong><a href="delete_upload_file.php">Delete</a></td>'; 
echo '<td style="text-align:center;"><strong></strong> <form method="post" action="'.$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'].'">
<input type="hidden" name="delete_upload" value="'.$file_id.'" />
<input type="submit" name="submit" value="Delete" /></form></td>';
//}
echo '<tr>';
}
}
#############END ADMIN
?>
<span style="color:red;font-size:12px;">
<?
if ($error_message) {
   echo $error_message;
}
?>
</span>
<?php //include('upload.php'); ?>
<div style="display:none;">
<form style="padding:10px; /*width:98%*/" method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
		<p>
			<label for="editor1">
				Editor 1:</label>
			<textarea cols="80" id="editor1" name="top" rows="10">
<?php 
//include('newn3_header.php');
$command = "SELECT top FROM cms where 
cms_id='$cms_id';";
       $result = mysql_query($command);
       while ($data = mysql_fetch_object($result)) {
          echo stripslashes($data->top);
		  		  	  
		  }?></body>
</textarea>
			<script type="text/javascript">
			//<![CDATA[

				CKEDITOR.replace( 'editor1',
					{
						/*
						 * Style sheet for the contents
						 */
						contentsCss : 'body {color:#000; background-color#:FFF;}',

						/*
						 * Simple HTML5 doctype
						 */
						docType : '<!DOCTYPE HTML>',

						/*
						 * Core styles.
						 */
						coreStyles_bold	: { element : 'b' },
						coreStyles_italic	: { element : 'i' },
						coreStyles_underline	: { element : 'u'},
						coreStyles_strike	: { element : 'strike' },

						/*
						 * Font face
						 */
						// Define the way font elements will be applied to the document. The "font"
						// element will be used.
						font_style :
						{
								element		: 'font',
								attributes		: { 'face' : '#(family)' }
						},

						/*
						 * Font sizes.
						 */
						fontSize_sizes : 'xx-small/1;x-small/2;small/3;medium/4;large/5;x-large/6;xx-large/7',
						fontSize_style :
							{
								element		: 'font',
								attributes	: { 'size' : '#(size)' }
							} ,

						/*
						 * Font colors.
						 */
						colorButton_enableMore : true,

						colorButton_foreStyle :
							{
								element : 'font',
								attributes : { 'color' : '#(color)' }
							},

						colorButton_backStyle :
							{
								element : 'font',
								styles	: { 'background-color' : '#(color)' }
							},

						/*
						 * Styles combo.
						 */
						stylesSet :
								[
									{ name : 'Computer Code', element : 'code' },
									{ name : 'Keyboard Phrase', element : 'kbd' },
									{ name : 'Sample Text', element : 'samp' },
									{ name : 'Variable', element : 'var' },

									{ name : 'Deleted Text', element : 'del' },
									{ name : 'Inserted Text', element : 'ins' },

									{ name : 'Cited Work', element : 'cite' },
									{ name : 'Inline Quotation', element : 'q' }
								],

						on : { 'instanceReady' : configureHtmlOutput }
					});

/*
 * Adjust the behavior of the dataProcessor to avoid styles
 * and make it look like FCKeditor HTML output.
 */
function configureHtmlOutput( ev )
{
	var editor = ev.editor,
		dataProcessor = editor.dataProcessor,
		htmlFilter = dataProcessor && dataProcessor.htmlFilter;

	// Out self closing tags the HTML4 way, like <br>.
	dataProcessor.writer.selfClosingEnd = '>';

	// Make output formatting behave similar to FCKeditor
	var dtd = CKEDITOR.dtd;
	for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) )
	{
		dataProcessor.writer.setRules( e,
			{
				indent : true,
				breakBeforeOpen : true,
				breakAfterOpen : false,
				breakBeforeClose : !dtd[ e ][ '#' ],
				breakAfterClose : true
			});
	}

	// Output properties as attributes, not styles.
	htmlFilter.addRules(
		{
			elements :
			{
				$ : function( element )
				{
					// Output dimensions of images as width and height
					if ( element.name == 'img' )
					{
						var style = element.attributes.style;

						if ( style )
						{
							// Get the width from the style.
							var match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec( style ),
								width = match && match[1];

							// Get the height from the style.
							match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec( style );
							var height = match && match[1];

							if ( width )
							{
								element.attributes.style = element.attributes.style.replace( /(?:^|\s)width\s*:\s*(\d+)px;?/i , '' );
								element.attributes.width = width;
							}

							if ( height )
							{
								element.attributes.style = element.attributes.style.replace( /(?:^|\s)height\s*:\s*(\d+)px;?/i , '' );
								element.attributes.height = height;
							}
						}
					}

					// Output alignment of paragraphs using align
					if ( element.name == 'p' )
					{
						style = element.attributes.style;

						if ( style )
						{
							// Get the align from the style.
							match = /(?:^|\s)text-align\s*:\s*(\w*);/i.exec( style );
							var align = match && match[1];

							if ( align )
							{
								element.attributes.style = element.attributes.style.replace( /(?:^|\s)text-align\s*:\s*(\w*);?/i , '' );
								element.attributes.align = align;
							}
						}
					}

					if ( !element.attributes.style )
						delete element.attributes.style;

					return element;
				}
			},

			attributes :
				{
					style : function( value, element )
					{
						// Return #RGB for background and border colors
						return convertRGBToHex( value );
					}
				}
		} );
}


/**
* Convert a CSS rgb(R, G, B) color back to #RRGGBB format.
* @param Css style string (can include more than one color
* @return Converted css style.
*/
function convertRGBToHex( cssStyle )
{
	return cssStyle.replace( /(?:rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\))/gi, function( match, red, green, blue )
		{
			red = parseInt( red, 10 ).toString( 16 );
			green = parseInt( green, 10 ).toString( 16 );
			blue = parseInt( blue, 10 ).toString( 16 );
			var color = [red, green, blue] ;

			// Add padding zeros if the hex value is less than 0x10.
			for ( var i = 0 ; i < color.length ; i++ )
				color[i] = String( '0' + color[i] ).slice( -2 ) ;

			return '#' + color.join( '' ) ;
		 });
}
			//]]>
			</script>
		</p>
		<p>
		<input type="hidden" name="cms_id" value="<? echo htmlentities($cms_id); ?>">
<input type=submit value="SUBMIT">
		</p>
	</form></div>

<!--Beginning of style-->
<?php
//include("footer.php");

?>
</table>

<?php
//starting with the first page, make a loop for all pages and links to those pages
 for($i = 0; $i<$last_page; $i++) {
		$page_link = $i + 1;
		//create an array of links
		$links_pages[] = " <a style=\"font-size:13px;\" href='{$_SERVER['PHP_SELF']}?orderby=".$_SESSION[orderby]."&pagenumber=".$page_link."' >".$page_link."</a>";
	}
	
 // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.
 ?>
<div style="text-align:center; display:none;">
<?php
 if ($page_number == 1) {
 } 
 else if ($page_number > 1)
 {
 echo " <a style=\"font-size:13px;\" href='{$_SERVER['PHP_SELF']}?orderby=".$_SESSION[orderby]."&pagenumber=1'> <<-First</a> ";
 echo " ";

$previous_page = $page_number-1;

 echo " <a style=\"font-size:13px; \" href='{$_SERVER['PHP_SELF']}?orderby=".$_SESSION[orderby]."&pagenumber=$previous_page'> <-Previous</a> "; ?>

<?php 
} 
?>


<?php
if ($page_number == $last_page) {
} 
 else { 
 $next_page = $page_number+1;
 echo "<a style=\"font-size:13px;\" href='{$_SERVER['PHP_SELF']}?orderby=".$_SESSION[orderby]."&pagenumber=$next_page'>Next -></a> ";
 echo " ";
 echo " <a style=\"font-size:13px;\" href='{$_SERVER['PHP_SELF']}?orderby=".$_SESSION[orderby]."&pagenumber=$last_page'>Last ->></a>";
 } 

// This shows the user what page they are on, and the total number of pages
echo "<span style=\"font-size:13px;\"> Page $page_number of $last_page</span>"; 	
?></div>
  <div style="text-align:center;display:none;">
  Page: 
  <?php 
  if (count($links_pages))  {
  foreach($links_pages as $links){
	echo $links;
  }
  }
  else {
  echo "1";
  }
?>


</div><div style="clear:both;"></div>
<?php   
include("footer.php");?>
   
		<?php
exit();   }
############################### END ADMIN  
?> 
Return current item: Bohemian CMS file manager