Location: PHPKode > projects > chillyCMS > chillyCMS/modules/download/backend.php
<?php
defined('DOIT') or die('Restricted access');

include_once(PATH."/core/file.class.php");
global $page;
$id=intval($_REQUEST["id"]);

//settings are passed to this file in the variable $modsettings formatted as a string
$settingsarray=explode(',', $modsettings);
//remove files from download list?
if (isset($_GET["action"]) && $_GET["action"]=="remove") {
	$filetoremove=no_semicola($_GET["file"]);
	$sql = "delete from mod_download where `modid`=$id and `filename`='$filetoremove'";
	$page->query($sql);
	//$result = $page->db->getdata_array();
	//db_query("delete from mod_download where `modid`=$id and `filename`='$filetoremove'");
}
//get all files in download list
$sql = "select * from mod_download where `modid`=$id order by `filename`";
$page->query($sql);
$result = $page->db->getdata_array();
//$downloadfiles=db_query_array("select * from mod_download where `modid`=$id order by `filename`");
//Options to show in frontend
$editform .= "<p>$mod_dl[lbl_moddl]</p><br />";

if($writeright) {
	$editform .= "<h3>$mod_dl[lbl_displayopt]</h3><br />".
	//--filetype
	"<span>$mod_dl[lbl_showfiletype]</span>";
	if ($settingsarray[0]=="on") {
		$editform .= "<input type='checkbox' class='middle' name='showfiletype' checked='checked' />";
	} else {
		$editform .= "<input type='checkbox' class='middle' name='showfiletype' />";
	}
	//--filesize
	$editform .= "<span style='margin: 0 0 0 20px;'>$mod_dl[lbl_showfilesize]</span>";
	if ($settingsarray[1]=="on") {
		$editform .= "<input type='checkbox' class='middle' name='showfilesize' checked='checked' />";
	} else {
		$editform .= "<input type='checkbox' class='middle' name='showfilesize' />";
	}
	$editform .= "<br /><br /><h3 class='floatleft'>$mod_dl[lbl_files]</h3>";
	//add files link
	$editform .= "<a class='new floatright' target='popup' onclick=\"window.open('','popup','width=400,height=500,".
	"scrollbars=yes,toolbar=no,status=no,resizable=no,menubar=no,location=no,directories=no,top=200,".
	"left=150')\" href=\"".URL."/modules/download/addfiles.php?modid=$id\" ".
	">$mod_dl[lbl_addfiles]</a><br /><br />".
	//table
	"<table cellspacing='0' width='100%'>".
		"<tr>".
		"<th>Filename</th>".
		"<th class='center'>$mod_dl[lbl_ftype]</th>".
		"<th class='right'>$mod_dl[lbl_fsize]</th>".
		"<th class='center'>$mod_dl[lbl_downloads]</th>".
		"<th class='center'>$l_gen[lbl_delete]</th>".
		"</tr>";
	$style="odd";
	if (!empty($result)) {
		foreach ($result as $df) {
			$filefull=PATH."/".$df["location"]."/".$df["filename"];
			if (file_exists($filefull)) {
				$myfile=new File($filefull);
				$filesize=filesize_text(filesize($filefull));
				$editform .= "<tr class='$style'>".
				"<td class='left'>$myfile->name</td>".
				"<td>".strtolower($myfile->ext)."</td>".
				"<td class='right'>$filesize</td>".
				"<td>$df[downloads]</td>".	
				"<td><a class='delete' href='".URL."/admin/edit.site.php?id=$id&amp;".
				"action=remove&amp;file=".$myfile->name.".".$myfile->ext."' ".
				"title='$l_gen[lbl_delete]'></a></td>".
				"</tr>";
				if ($style=="odd") { $style="even"; } else { $style="odd"; }
			} else {
				$page->debug('File missing! Removing missing file from download database...');
				$sql = 'delete from mod_download where `modid`='.$id.' and `filename`=\''.
				$df["filename"].'\' and `location`=\''.$df["location"].'\'';
				if ($page->query($sql)) { $page->debug('Success'); } else { $page->debug('Error'); }
			}
		}
	}
	$editform .= "</table>";
} else {
	$editform .= "<br /><br />".$l_edit["msg_nowrite"];
}
//since the data is to be saved in an array, the order is important!
$specialsettings="showfiletype,showfilesize";
?>
Return current item: chillyCMS