Thorsten G. hat geschrieben:
$str_file_modified = date("d.m.Y H:i", filemtime($str_file_url));
$str_file_created = date("d.m.Y H:i", filectime($str_file_url));[/code]
filemtime() ist natürlich eine File-Funktion die auf DB-Daten nicht funktioniert.
Liste funktioniert bei mir unter 4.6.23
1. Habe mal dem Input einen kleinen Design-Flash gegeben
2. Liste mit Login-Schutz mit rechte übergabe durch Gruppen
3. modified & created-date aus der Datenbank um DBFS zunutzen
4. Verlinkung über dbfs.php (Download File nicht getestet)
BeschreibungCode: Alles auswählen
Download List
Generate a List of all downloadable files in a custom "upload"-dir based directory
Autor: Stefan Seifarth <info@polycoder.de>
Version: 1.2
Modified: 2008-01-09, Oliver Lohkemper (Login-Check)
Features:
- set download directory with simple drop down
- count downloads (see module "Download File")
- you can define file extensions which are be visible,
all other files in this directory won't be shown.
- you can use windows wildcard filter for different selection of files
- get specific download information such metaname and description
- set Display-Typ: display, hidden and after login
Important:
Modul use the database entries from the contenido file-management
and don't search physical webspace!
EingabeCode: Alles auswählen
?>
<?php
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname : Download List
* Author(s) : Stefan Seifarth <info@polycoder.de>
* Copyright : www.polycoder.de / www.htcm.de
* Created : 2006-01-07
* Modified : 2008-01-09, Oliver Lohkemper (Login-Check)
************************************************/
# CMS VAR 1 = Display-Typ
# CMS VAR 2 = fegroup
cInclude("classes", "class.frontend.groups.php");
cInclude ("classes", "class.upload.php");
$fegroups = new FrontendGroupCollection;
$fegroups->select("idclient = '$client'","", "groupname ASC");
// get all directories from database
$dllist_collection = new UploadCollection ();
$dllist_collection->select("idclient='".$client."'","dirname","dirname ASC");
$arr_found_dirs = array();
$arr_dirs = array();
while ( $dllist_item = $dllist_collection->next() ) {
$arr_found_dirs[] = $dllist_item->get("dirname");
}
$i = 0;
foreach ($arr_found_dirs as $str_dir) {
$arr_current_dir = explode("/",$str_dir );
array_pop($arr_current_dir);
$depth = count($arr_current_dir);
if ( $depth == 0 ) {
$arr_dirs[$i]["name"] = str_replace("/", "", $cfgClient[$client]["upload"]);
} else {
$arr_dirs[$i]["name"] = $arr_current_dir[$depth-1];
}
$arr_dirs[$i]["depth"] = $depth;
$arr_dirs[$i]["path"] = $str_dir;
$arr_dirs[$i]["indent"] = "";
for ($z = 1; $z <= $depth; $z ++) {
# 3 blanks for every level
$arr_dirs[$i]["indent"] .= " ";
}
$i++;
}
?>
<table cellspacing="0" cellpadding="2" border="0" width="100%">
<!-- directory selectbox -->
<tr>
<td style="padding-top: 2px; width: 50px;" class="text_medium"><b><?php echo mi18n("Verzeichnis:"); ?></b></td>
<td style="padding-top: 2px;">
<?php
// print out directory selectbox
$str_predefined = trim("CMS_VALUE[110]");
print '<select name="CMS_VAR[110]" class="text_medium" style="width: 100%;">' . "\n";
// output of all found directories
foreach ( $arr_dirs as $arr_dir ) {
$str_selected = "";
if ( $str_predefined == $arr_dir["path"] ) $str_selected = ' selected="selected"';
print '<option value="' . $arr_dir["path"] . '"' . $str_selected . '>' . $arr_dir["indent"] . $arr_dir["name"] . '</option>' . "\n";
}
print '</select>' . "\n";
?>
</td>
</tr>
<tr>
<td style="padding-top: 2px;" colspan="2" class="text_medium">
<?php echo mi18n("Verzeichnis für Downloads auswählen."); ?>
</td>
</tr>
<tr>
<td style="padding-top: 2px;" colspan="2" class="text_medium"> </td>
</tr>
<!-- fileextensions -->
<tr>
<td style="padding-top: 2px;" class="text_medium"><b><?php echo mi18n("Dateiendungen:"); ?></b></td>
<td style="padding-top: 2px;"><input type="text" name="CMS_VAR[111]" value="CMS_VALUE[111]" style="width: 100%;" class="text_medium"></td>
</tr>
<tr>
<td style="padding-top: 2px;" colspan="2" class="text_medium">
<?php echo mi18n("leergelassen = alle Dateien"); ?><br>
<?php echo mi18n("mehrere Dateitypen durch Komma abtrennen"); ?><br>
<?php echo mi18n("z.B.:"); ?> pdf,jpg,txt
</td>
</tr>
<tr>
<td style="padding-top: 2px;" colspan="2" class="text_medium"> </td>
</tr>
<!-- Filter -->
<tr>
<td style="padding-top: 2px;" class="text_medium"><b><?php echo mi18n("Dateifilter:"); ?></b></td>
<td style="padding-top: 2px;"><input type="text" name="CMS_VAR[113]" value="CMS_VALUE[113]" style="width: 100%;" class="text_medium"></td>
</tr>
<tr>
<td style="padding-top: 2px;" colspan="2" class="text_medium">
<?php echo mi18n("leergelassen = alle Dateien"); ?><br>
<?php echo mi18n("Filter wie unter Windows nutzen."); ?><br>
* = <?php echo mi18n("mehrere Zeichen"); ?><br>
? = <?php echo mi18n("ein Zeichen"); ?><br>
; = <?php echo mi18n("Trennzeichen für mehrere Filter"); ?><br>
<?php echo mi18n("z.B.:"); ?> ?datei*.*;datei_00?.*
</td>
</tr>
<tr>
<td style="padding-top: 2px;" colspan="2" class="text_medium"> </td>
</tr>
<!-- download article -->
<tr>
<td style="padding-top: 2px;" class="text_medium"><b><?php echo mi18n("Downloadzähler:"); ?></b></td>
<td style="padding-top: 2px;"><input type="text" name="CMS_VAR[112]" value="CMS_VALUE[112]" style="width: 30px;" class="text_medium"></td>
</tr>
<tr>
<td style="padding-top: 2px;" colspan="2">
<?php echo mi18n("idart = idart des Downloadzähler-Artikel (inkl. Download-File-Modul)"); ?><br>
<?php echo mi18n("leergelassen = Download ohne Zähler"); ?>
</td>
</tr>
<tr>
<td style="padding-top: 2px;" colspan="2" class="text_medium"> </td>
</tr>
<!-- login check or not -->
<tr>
<td style="padding-top: 2px;"><b><?php echo mi18n("Display:"); ?></b></td>
<td>
<select name="CMS_VAR[1]" class="text_medium" style="width: 100%;">
<option onClick="document.getElementById('komentar_feu_group').style.display = 'none';" value="1"<?php echo ("CMS_VALUE[1]"=='1' ? ' selected' : ''); ?>><?php echo mi18n("Hidden"); ?></option>
<option onClick="document.getElementById('komentar_feu_group').style.display = 'none';" value="2"<?php echo ("CMS_VALUE[1]"=='2' ? ' selected' : ''); ?>><?php echo mi18n("Display"); ?></option>
<option onClick="document.getElementById('komentar_feu_group').style.display = 'block';" value="3"<?php echo ("CMS_VALUE[1]"=='3' ? ' selected' : ''); ?>><?php echo mi18n("FEU"); ?></option>
</select>
<div id="komentar_feu_group" style="display: <?php echo ("CMS_VALUE[1]"== "3" ? 'block' : 'none'); ?>;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?php echo mi18n("Frontendgroup"); ?>:</td>
</tr>
<tr>
<td>
<select size="5" onchange="var myValue = ''; for( i = 0; i < this.options.length; i++ ) { if( this.options[i].selected ) myValue += ','+this.options[i].value; } document.getElementById('cmsVar2').value = myValue.substr(1);" class="text_medium" style="width: 100%;" multiple="multiple">
<?php
$mySelectedGroups = explode(',', "CMS_VALUE[2]");
while ($fegroup = $fegroups->next()) {
$groupname = $fegroup->get("groupname");
$idfegroup = $fegroup->get("idfrontendgroup");
echo '<option value="'.$idfegroup.'"'.( in_array($idfegroup, $mySelectedGroups) ? ' selected' : '' ).'>'.$groupname.'</option>';
}
?>
</select>
<input id="cmsVar2" name="CMS_VAR[2]" type="hidden" value="CMS_VALUE[2]">
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<?php
AusgabeCode: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : Download List
* Author(s) : Stefan Seifarth <info@polycoder.de>
* Copyright : www.polycoder.de / www.htcm.de
* Created : 2006-01-07
* Modified : 2008-01-09, Oliver Lohkemper (Login-Check)
************************************************/
cInclude ("classes", "class.upload.php");
cInclude ("classes", "class.properties.php");
cInclude ("classes", "class.htmlelements.php");
cInclude ("includes", "functions.upl.php");
cInclude("classes", "class.frontend.groups.php");
cInclude('classes', 'class.template.php');
$tpl = new Template;
$feuser = new FrontendUser;
$feuser->loadByPrimaryKey($auth->auth['uid']);
$Settings = array();
$Settings['viewtyp'] = "CMS_VALUE[1]";
$Settings['access_groups'] = explode(',', "CMS_VALUE[2]");
$Settings['feuser_groups'] = $feuser->getGroupsForUser();
$Settings['access'] = "0";
$Settings['feuser']['name'] = $feuser->getField('username');
if( !$Settings['viewtyp'] ) {
// Default für alle Artikel die keine Settings haben
$Settings['viewtyp'] = 2;
}
elseif( $Settings['viewtyp'] == 3 ) {
// Prüfen ob der User in einer er ausgewählten Gruppen ist
$Settings['access'] = (count( array_intersect( $Settings['feuser_groups'], $Settings['access_groups'] ) ) ? 1 : 0);
}
if( $Settings['viewtyp'] == 2
OR ( $Settings['viewtyp'] == 3 AND $Settings['access'] == 1 ) ) {
// template defined vars
$dllist_path = "CMS_VALUE[110]";
$dllist_extensions = trim("CMS_VALUE[111]");
$dllist_idart = trim("CMS_VALUE[112]");
$dllist_filenamefilter = trim("CMS_VALUE[113]");
// add filetype condition
$str_where_filetype = "";
if ( strlen ($dllist_extensions) > 0) {
$arr_extensions = explode (",",$dllist_extensions);
$arr_where = array();
foreach ($arr_extensions as $str_extension) {
$arr_where[] = "filetype ='" . trim($str_extension) . "'";
}
$str_where_filetype = ' ( ' . implode( " OR ", $arr_where ) . ' ) AND ';
}
// add filename filter condition
$str_where_filenamefilter = "";
if ( strlen ($dllist_filenamefilter) > 0) {
$arr_filenamefilter = explode(";", $dllist_filenamefilter);
$arr_where = array();
foreach ($arr_filenamefilter as $str_filenamefilter) {
$str_filenamefilter = trim($str_filenamefilter);
// replace special chars for wildcards
$str_filenamefilter = str_replace("%","\%", $str_filenamefilter);
$str_filenamefilter = str_replace("_","\_", $str_filenamefilter);
$str_filenamefilter = str_replace("*","%", $str_filenamefilter);
$str_filenamefilter = str_replace("?","_", $str_filenamefilter);
$arr_where[] = ' filename LIKE "' . mysql_escape_string($str_filenamefilter) . '"';
}
$str_where_filenamefilter = ' ( ' . implode( " OR ", $arr_where ) . ' ) AND ';
}
// get list of all files
$dllist_collection = new UploadCollection ();
$dllist_collection->select($str_where_filenamefilter . $str_where_filetype . " dirname = '" . $dllist_path . "'","","filename ASC");
// initialize needed objects
$obj_file_properties = new PropertyCollection();
$obj_icon = new cHTMLImage();
$obj_description = new cHTMLDIV();
// reset template
$tpl = new Template();
$tpl->reset();
// add head description
$tpl->set("s","HEAD_NAME", mi18n("Dateiname") );
$tpl->set("s","HEAD_FILETYPE", mi18n("Dateityp") );
$tpl->set("s","HEAD_FILESIZE", mi18n("Größe") );
$tpl->set("s","HEAD_COUNTER", mi18n("Downloads") );
$tpl->set("s","HEAD_FILECREATED", mi18n("Erstellt am") );
$tpl->set("s","HEAD_FILEMODIFIED", mi18n("Bearbeitet am") );
// run file list
$image_id = 0;
while ($dllist_item = $dllist_collection->next() ) {
$image_id++;
// icon for file
$obj_icon->setSrc( uplGetFileIcon($dllist_item->get("filename")) );
$obj_icon->setID("dlIco".$image_id);
// file description
$str_file_description = "";
if (strlen($dllist_item->get("description"))> 0) {
$obj_description->setContent($dllist_item->get("description"));
$obj_description->setClass("fileDescription");
$str_file_description = $obj_description->toHTML();
}
// filename
$str_file_name = $dllist_item->get("filename");
$str_file_name_property = $obj_file_properties->getValue("upload", $dllist_item->get("dirname").$dllist_item->get("filename"), "file", "medianame");
if (strlen($str_file_name_property) > 0) {
$str_file_name = $str_file_name_property;
}
// filecounter
$str_file_counter = "0";
$str_file_counter_property = $obj_file_properties->getValue("upload", $dllist_item->get("dirname").$dllist_item->get("filename"), "file", "counter");
if ( strlen ($str_file_counter_property) > 0 ) {
$str_file_counter = $str_file_counter_property;
}
// file url
if(substr($dllist_item->get("dirname"), 0,5) != "dbfs:") {
$str_file_url = $cfgClient[$client]["upl"]["htmlpath"] . $dllist_item->get("dirname") . $dllist_item->get("filename");
if ( isset($dllist_idart) && !empty($dllist_idart) && (int)$dllist_idart > 0 ) {
$str_file_url = $sess->url("front_content.php?idart=" . $dllist_idart . "&changelang=" . $lang . "&client=" . $client . "&sse_idupl=" . $dllist_item->get("idupl") );
}
}
else {
$str_file_url = $cfgClient[$client]["path"]["htmlpath"] . "dbfs.php?file=" . substr($dllist_item->get("dirname"),6) . $dllist_item->get("filename");
if ( isset($dllist_idart) && !empty($dllist_idart) && (int)$dllist_idart > 0 ) {
$str_file_url = $sess->url("dbfs.php?idart=" . $dllist_idart . "&changelang=" . $lang . "&client=" . $client . "&sse_idupl=" . $dllist_item->get("idupl") );
}
}
// file time
$str_file_modified = "";
$str_file_created = "";
$str_file_modified = split( "[- :]", $dllist_item->get("created") );
$str_file_created = split( "[- :]", $dllist_item->get("lastmodified") );
$str_file_modified = mktime($str_file_modified[3], $str_file_modified[4], $str_file_modified[5], $str_file_modified[2], $str_file_modified[1], $str_file_modified[0] );
$str_file_created = mktime($str_file_created[3], $str_file_created[4], $str_file_created[5], $str_file_created[2], $str_file_created[1], $str_file_created[0] );
$str_file_modified = date("d.m.Y H:i", $str_file_created);
$str_file_created = date("d.m.Y H:i", $str_file_modified);
// fill template
$tpl->set("d", "FILE_ICON", $obj_icon->toHTML() . ' ');
$tpl->set("d", "FILE_NAME", $str_file_name );
$tpl->set("d", "FILE_TYPE", $dllist_item->get("filetype") );
$tpl->set("d", "FILE_SIZE", human_readable_size($dllist_item->get("size")) );
$tpl->set("d", "FILE_COUNTER", $str_file_counter );
$tpl->set("d", "FILE_DESCRIPTION", $str_file_description );
$tpl->set("d", "FILE_URL", $str_file_url );
$tpl->set("d", "FILE_CREATED", $str_file_created);
$tpl->set("d", "FILE_MODIFIED", $str_file_modified );
$tpl->next();
}
// set template
$str_template_name = "download_list.html";
if ( isset($dllist_idart) && !empty($dllist_idart) && (int)$dllist_idart > 0 ) {
$str_template_name = "download_list_counter.html";
}
// print template
print $tpl->generate($cfgClient[$client]["tpl"]["path"] . $str_template_name, 1, 0);
}
elseif( $Settings['viewtyp'] == 3 ) {
echo mi18n("Bitte einloggen.");
}
?>
download_list.htmlCode: Alles auswählen
<!-- download module for contenido 4.6.x - for download visit www.polycoder.de -->
<table border="1">
<thead>
<tr>
<th align="left">{HEAD_NAME}</th>
<th>{HEAD_FILETYPE}</th>
<th>{HEAD_FILESIZE}</th>
<th>{HEAD_FILECREATED}</th>
<th>{HEAD_FILEMODIFIED}</th>
</tr>
</thead>
<tbody>
<!-- BEGIN:BLOCK -->
<tr>
<td>{FILE_ICON}<a href="{FILE_URL}">{FILE_NAME}</a>{FILE_DESCRIPTION}</td>
<td>{FILE_TYPE}</td>
<td>{FILE_SIZE}</td>
<td>{FILE_CREATED}</td>
<td>{FILE_MODIFIED}</td>
</tr>
<!-- END:BLOCK -->
</tbody>
<tfoot></tfoot>
</table>
wenn stese die Änderunge an nimmt (publiziertz)
entferne ich den Code um diesen wichtigen Beitrag nicht zuzumüllen
mfg oli