home *** CD-ROM | disk | FTP | other *** search
- <?php
- /*
- Copyright Intermesh 2003
- Author: Merijn Schering <mschering@intermesh.nl>
- Version: 1.0 Release date: 08 July 2003
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
- */
-
- $site_id = isset($_REQUEST['site_id']) ? $_REQUEST['site_id'] : 0;
-
- $filter[] = 'html';
- $filter[] = 'htm';
- $filter[] = 'jpg';
- $filter[] = 'gif';
- $filter[] = 'png';
-
- function get_path($folder_id)
- {
- global $cms;
- $path = '';
-
- while($folder = $cms->get_folder($folder_id))
- {
- $path = '/<a href="'.$_SERVER['PHP_SELF'].'?folder_id='.$folder['id'].'">'.$folder['name'].'</a>'.$path;
- $folder_id = $folder['parent_id'];
- }
- return $path;
- }
-
- require("../../Group-Office.php");
- require($GO_CONFIG->class_path.'cms.class.inc');
- $cms = new cms();
-
- //authenticate the user
- $GO_SECURITY->authenticate();
-
- //see if the user has access to this module
- //for this to work there must be a module named 'example'
- $GO_MODULES->authenticate('cms');
-
- //get the language file
- require($GO_LANGUAGE->get_language_file('cms'));
-
- //remember sorting in cookie
- if (isset($_REQUEST['newsort']))
- {
- SetCookie("cms_sort",$_REQUEST['newsort'],time()+3600*24*365,"/","",0);
- $_COOKIE['cms_sort'] = $_REQUEST['newsort'];
- }
- if (isset($_REQUEST['newdirection']))
- {
- SetCookie("cms_direction",$_REQUEST['newdirection'],time()+3600*24*365,"/","",0);
- $_COOKIE['cms_direction'] = $_REQUEST['newdirection'];
- }
-
-
- $site = $cms->get_site($site_id);
-
- if (!$GO_SECURITY->has_permission($GO_SECURITY->user_id, $site['acl_write']))
- {
- require($GO_THEME->theme_path."header.inc");
- require($GO_CONFIG->root_path.'error_docs/403.inc');
- require($GO_THEME->theme_path."footer.inc");
- exit();
-
- }
-
- //set the folder id we are in
- $folder_id = isset($_REQUEST['folder_id']) ? $_REQUEST['folder_id'] : $site['root_folder_id'];
-
- require($GO_THEME->theme_path."header.inc");
-
- //determine sorting
- if (!isset($_COOKIE['cms_sort']))
- $_COOKIE['cms_sort'] = "cms_files.name";
-
- if (!isset($_COOKIE['cms_direction']))
- $_COOKIE['cms_direction'] = "ASC";
-
- if ($_COOKIE['cms_direction'] == "DESC")
- {
- $image_string = ' <img src="'.$GO_THEME->image_url.'buttons/arrow_down.gif" border="0" />';
- $newdirection = "ASC";
- }else
- {
- $image_string = ' <img src="'.$GO_THEME->image_url.'buttons/arrow_up.gif" border="0" />';
- $newdirection = "DESC";
- }
-
- $folder = $cms->get_folder($folder_id);
-
- echo '<table border="0" cellpadding="10"><tr><td>';
- echo '<h2>'.get_path($folder['parent_id']).'/<a href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&folder_id='.$folder['id'].'">'.$folder['name'].'</a></h2>';
- echo '<table border="0">';
- if($folder['parent_id']!=0)
- {
- echo '<td align="center" width="60" nowrap>';
- echo '<a class="small" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&folder_id='.$folder['parent_id'].'"><img src="'.$GO_THEME->images['uplvl_big'].'" border="0" height="32" width="32" /><br />omhoog</a></td>';
- }
- echo '<td align="center" width="60" nowrap>';
- echo '<a class="small" href="javascript:window.close();"><img src="'.$GO_THEME->images['close'].'" border="0" height="32" width="32" /><br />close</a></td>';
-
- echo '</table>';
-
- echo '<table border="0" cellpadding="0" cellspacing="0"><tr>';
- echo '<td class="TableHead2" width="16"><input type="checkbox" onclick="javascript:invert_selection()" name="dummy" /></td>';
- echo '<td class="TableHead2" width="16"> </td>';
- echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&newsort=cms_files.name&newdirection='.$newdirection.'">'.$strName;
- if ($_COOKIE['cms_sort'] == "cms_files.name")
- echo $image_string;
- echo '</a></td>';
-
- echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&newsort=filetypes.friendly&newdirection='.$newdirection.'">'.$strType;
- if ($_COOKIE['cms_sort'] == "filetypes.friendly")
- echo $image_string;
- /*
- echo '</a></td>';
-
- echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&newsort=cms_files.size&newdirection='.$newdirection.'">'.$strSize;
- if ($_COOKIE['cms_sort'] == "cms_files.size")
- echo $image_string;
- echo '</a></td>';
-
- echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&newsort=cms_files.mtime&newdirection='.$newdirection.'">'.$strModified;
- if ($_COOKIE['cms_sort'] == "cms_files.mtime")
- echo $image_string;
- */
- echo '<td class="TableHead2" width="100" nowrap><a class="TableHead2" href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&newsort=cms_files.priority&newdirection='.$newdirection.'&folder_id='.$folder_id.'">'.$cms_priority;
- if ($_COOKIE['cms_sort'] == "cms_files.priority")
- echo $image_string;
- echo '</a></td></tr>';
-
- //list the folders
-
- //adjust sorting because folders because they lack some columns
- if ($_COOKIE['cms_sort'] == "cms_files.time")
- {
- $folders_sort = "time";
- }else
- {
- $folders_sort = "name";
- }
-
- //list the folders first
- $total_size = 0;
- $count_folders = $cms->get_folders($folder_id, $folders_sort, $_COOKIE['cms_direction']);
- while ($cms->next_record())
- {
- $short_name = cut_string($cms->f('name'), 30);
- echo '<tr id="folder_'.$cms->f('id').'" class="Table1">';
- echo '<td><input onclick="javascript:folder_click(this)" type="checkbox" name="folders[]" value="'.$cms->f('id').'" id="'.$cms->f('name').'" /></td>';
- if ($cms->f('disabled') == '1')
- {
- echo '<td><img width="16" height="16" border="0" src="'.$GO_THEME->images['invisible_folder'].'" /></td>';
- }else
- {
- echo '<td><img width="16" height="16" border="0" src="'.$GO_THEME->images['folder'].'" /></td>';
- }
-
- if (isset($cut_folders) && in_array($cms->f('id'), $cut_folders))
- {
- echo '<td nowrap> <a href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&folder_id='.$cms->f('id').'"><font color="#7d7d7d">'.$cms->f('name').'</font></a> </td>';
- }else
- {
- echo '<td nowrap> <a href="'.$_SERVER['PHP_SELF'].'?site_id='.$site_id.'&folder_id='.$cms->f('id').'" title="'.$cms->f('name').'">'.$short_name.'</a> </td>';
- }
- echo '<td nowrap>'.$fbFolder.' </td>';
- /*
- echo '<td align="right">- </td>';
- echo '<td nowrap>'.date($_SESSION['GO_SESSION']['date_format'], $cms->f('mtime')).' </td>';
- */
- echo '<td nowrap align="center">'.$cms->f('priority').'</td>';
- echo '</tr>';
- echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
-
- }
-
- //list the files
- $count_files = $cms->get_files($folder_id, $_COOKIE['cms_sort'], $_COOKIE['cms_direction']);
- while ($cms->next_record())
- {
- if (in_array($cms->f('extension'), $filter))
- {
- $total_size += $cms->f('size');
- $short_name = strip_extension(cut_string($cms->f('name'), 30));
-
- echo '<tr id="file_'.$cms->f('id').'" class="Table1">';
- echo '<td><input onclick="javascript:file_click(this)" type="checkbox" name="files[]" value="'.$cms->f('id').'" id="'.$cms->f('name').'" /></td>';
- echo '<td><img width="16" height="16" border="0" src="'.$GO_CONFIG->control_url.'icon.php?extension='.$cms->f('extension').'" /></td>';
-
- if (eregi('htm',$cms->f('extension')))
- {
- if ($cms->f('title') != '')
- {
- $link_name = $cms->f('title');
- }else
- {
- $link_name = strip_extension($cms->f('name'));
- }
- echo '<td nowrap> <a href=\'javascript:_insertHyperlink("view.php?site_id='.$site_id.'&file_id='.$cms->f('id').'", "'.$link_name.'");\' title="'.$cms->f('name').'">';
- }else
- {
- echo '<td nowrap> <a href=\'javascript:_insertImage("download.php?site_id='.$site_id.'&file_id='.$cms->f('id').'");\' title="'.$cms->f('name').'">';
- }
-
- if (isset($cut_files) && in_array($cms->f('id'), $cut_files))
- {
- echo '<font color="#7d7d7d">'.$short_name.'</font></a> </td>';
- }else
- {
- echo $short_name.'</a> </td>';
- }
- echo '<td nowrap>'.$cms->f('friendly').' </td>';
- /*
- echo '<td nowrap align="right">'.format_size($cms->f('size')).' </td>';
- echo '<td nowrap>'.date($_SESSION['GO_SESSION']['date_format'], $cms->f('mtime')).' </td>';
- */
- echo '<td nowrap align="center">'.$cms->f('priority').'</td>';
- echo '</tr>';
- echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
- }
- }
-
- $count_items = $count_folders+$count_files;
- echo '<tr><td colspan="99" class="small" height="18"> '.$count_items.' item(s) '.$fbFolderSize.': '.format_size($total_size).'</td></tr>';
- echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
- echo "</table>";
-
- echo '</td></tr></table>';
- ?>
- <script type="text/javascript" language="javascript">
-
- function _insertImage(url)
- {
- opener.editor_insertHTML('<img src="'+url+'" border="0" align="absmiddle" />');
- //opener.editor_insertImage(url);
- window.close();
- }
-
- function _insertHyperlink(url, name)
- {
- opener.editor_insertHTML('<a href="'+url+'" target="_self">'+name+'</a>');
- window.close();
- }
-
- window.onblur = function() {
- setTimeout('self.focus()',100);
- }
-
- </script>
- <?php
- require($GO_THEME->theme_path."footer.inc");
- ?>