Location: PHPKode > projects > SiteX > files.php
<?PHP
ob_start();
session_start();
include("./includes/globals.php.inc");
include("./includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");

protectComponentPage(9);

if ($sxSetup['MemberFiles']) {
  if(!loggedIn())
  loginError($sxLang['LoginRequired']);
}

if(!isset($folderid))
	$folderid = 0;

$sxTitleAddendum = getComponentName("9") .' - '. $sxSetup['METATitleExt'] ;
include("./themes/$THEME_FOLDER/header.php");
?>
     
<div class="bodyWrapper">
<h1 class="sxAdminHeading">Files</h1>
<div align="left">
<table border="0" cellspacing="2" cellpadding="5" align="center" width="100%">
<tr> 
  <td class="tableColumn"><?PHP echo $sxLang['GeneralItemName']; ?></td>
  <td class="tableColumn" width="60"><?PHP echo $sxLang['GeneralItemSize']; ?></td>
  <td class="tableColumn" width="50"><?PHP echo $sxLang['GeneralItemHits']; ?></td>
 </tr>
 <?PHP
 	$query = "SELECT * FROM $DB_Files_Folders WHERE hide='0' ORDER BY name ASC";
	$result = mysql_query($query, $Link) or queryError("24", mysql_error());
		
	// Log if folders exist
	if(mysql_num_rows($result) > 0)
		$sxNoFolders = false;
	else
		$sxNoFolders = true;

	while($ROW = mysql_fetch_object($result))
	{
		echo '  <tr bgcolor="' . $sxTheme['ColorTableRow'] . '">';
		{
			if($sxViewFolder == $ROW->id)
			{
				$sxFolderImage = "folder_open.gif";
				$sxFolderLinkVar = "sxCloseFolder";
				$sxFolderOpened = true;
			}
			else
			{
				$sxFolderImage = "folder_closed.gif";
				$sxFolderLinkVar = "sxViewFolder";
				$sxFolderOpened = false;
			}
			
			$query2 = "SELECT * FROM $DB_Files WHERE folderid='$ROW->id'";
			$result2 = mysql_query($query2, $Link) or queryError("2901", mysql_error());

			echo '     <td colspan="4">';
			echo '       <table border="0" cellpadding="0" cellspacing="0">';
			echo '         <tr>';
			echo '           <td><a name="folder' . $ROW->id . '" href="' . $_SERVER['PHP_SELF'] . '?' . $sxFolderLinkVar . '=' . $ROW->id . '#folder' . $ROW->id . '"><img src="./images/' . $sxFolderImage . '" border="0"></a></td>';
			echo '           <td>&nbsp;&nbsp;<a name="folder' . $ROW->id . '" href="' . $_SERVER['PHP_SELF'] . '?' . $sxFolderLinkVar . '=' . $ROW->id . '#folder' . $ROW->id . '">' . $ROW->name . ' (' . mysql_num_rows($result2) . ')</a></td>';
			echo '         </tr>';
			echo '       </table>';
			echo '     </td>';
		}
		echo '  </tr>';
		
		// Show contents of folder
		if($sxViewFolder == $ROW->id)
		{
			$query2 = "SELECT * FROM $DB_Files WHERE folderid='$ROW->id' ORDER BY filename ASC";
			$result2 = mysql_query($query2, $Link) or queryError("24", mysql_error());
			while($ROW2 = mysql_fetch_object($result2))
			{
				echo '  <tr bgcolor="' . incrementHexNumber($sxTheme['ColorTableRow']) . '">'."\n";
				echo '     <td>&nbsp;&nbsp;&nbsp;-&nbsp;<a name="file' . $ROW2->id . '" href="redirect.php?fileid=' . $ROW2->id . '">' . limitStringForce( htmlspecialchars($ROW2->name), 100) . '</a></td>';
				echo '     <td>' . number_format($ROW2->size/1000) . ' kb</td>'; 
				echo '     <td align="center">' . number_format($ROW2->hits) . '</td>';
				echo '  </tr>';
			}
			if(mysql_num_rows($result2) == 0)
				echo '<tr bgcolor="' . incrementHexNumber($sxTheme['ColorTableRow']) . '"><td colspan="5" width="500">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <em>' . $sxLang['NoFiles'] . '</em></td></tr>';
		} // End show contents of folder
	} // End folder loop

	$query = "SELECT * FROM $DB_Files WHERE folderid='$folderid' ORDER BY filename ASC";
	$result = mysql_query($query, $Link) or queryError("24", mysql_error());
	while($ROW = mysql_fetch_object($result)){
		echo '  <tr bgcolor="' . $sxTheme['ColorTableRow'] . '">'."\n";
		echo '     <td><a name="' . $ROW->id . '" href="redirect.php?fileid=' . $ROW->id . '">' . limitStringForce( htmlspecialchars($ROW->name), 100) . '</a></td>';
		echo '     <td>' . number_format($ROW->size/1000) . ' kb</td>';
		echo '     <td>' . number_format($ROW->hits) . '</td>';
		echo '  </tr>';
	}
	if((mysql_num_rows($result) == 0)AND($sxNoFolders == true))
		echo '<tr bgcolor="' . $sxTheme['ColorTableRow'] . '"><td colspan="5" align="center"><em>' . $sxLang['NoFiles'] . '</em></td></tr>';
  ?>
</table>
</div>
</div>
<?PHP
include("./themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX