Example #1
0
 public function index()
 {
     $this->view->filetree = filetree::php_file_tree(Kohana::config('freeswitch.cfg_root'), "javascript:FileManager.load('[link]');", array('xml', 'conf', 'tpl'));
     javascript::add('php_file_tree_jquery.js');
     stylesheet::add('php_file_tree.css');
     javascript::add('editarea/edit_area_full.js');
 }
Example #2
0
 public static function php_file_tree_dir($directory, $uaction, $extensions = array(), $first_call = true)
 {
     if (function_exists('scandir')) {
         $file = scandir($directory);
     } else {
         $file = php4_scandir($directory);
     }
     natcasesort($file);
     // Make directories first
     $files = $dirs = array();
     foreach ($file as $this_file) {
         if (is_dir($directory . '/' . $this_file)) {
             $dirs[] = $this_file;
         } else {
             $files[] = $this_file;
         }
     }
     $file = array_merge($dirs, $files);
     // Filter unwanted extensions
     if (!empty($extensions)) {
         foreach (array_keys($file) as $key) {
             if (!is_dir($directory . '/' . $file[$key])) {
                 $ext = substr($file[$key], strrpos($file[$key], '.') + 1);
                 if (!in_array($ext, $extensions)) {
                     unset($file[$key]);
                 }
             }
         }
     }
     if (count($file) > 2) {
         // Use 2 instead of 0 to account for . and .. directories
         $php_file_tree = '<ul';
         if ($first_call) {
             $php_file_tree .= ' class="php-file-tree"';
             $first_call = false;
         }
         $php_file_tree .= '>';
         foreach ($file as $this_file) {
             if ($this_file != '.' && $this_file != '..') {
                 if (is_dir($directory . '/' . $this_file)) {
                     // Directory
                     $php_file_tree .= '<li class="pft-directory"><span>' . htmlspecialchars($this_file) . '</span>';
                     $php_file_tree .= \filetree::php_file_tree_dir($directory . '/' . $this_file, $uaction, $extensions, false);
                     $php_file_tree .= '</li>';
                 } else {
                     // File
                     // Get extension (prepend 'ext-' to prevent invalid classes from extensions that begin with numbers)
                     $ext = 'ext-' . substr($this_file, strrpos($this_file, '.') + 1);
                     //						$link = '/adm/index.php?i=-forumhulp-upload-acp-upload_module&sid=90b2a79945e6a0c1f0b33626e9ffcffc&mode=main&file=' . $directory . '/' . urlencode($this_file);
                     $link = $uaction . '&file=' . $directory . '/' . urlencode($this_file);
                     $php_file_tree .= '<li class="pft-file ' . strtolower($ext) . (!in_array(strtolower($ext), array('ext-png', 'ext-jpg', 'ext-gif')) ? '" onclick="loadXMLDoc(\'' . $link . '\')"' : '') . ' title="' . $this_file . '"><span>' . htmlspecialchars($this_file) . '</span></li>';
                 }
             }
         }
         $php_file_tree .= '</ul>';
     }
     return $php_file_tree;
 }
Example #3
0
 public function index()
 {
     $this->template->content = new View('globalmedia/index');
     javascript::add('php_file_tree_jquery.js');
     stylesheet::add('php_file_tree.css');
     // Collect a list of paths in the system, to be displayed as a list
     $this->view->filetree = filetree::php_file_tree(Media::getMediaPath(), "javascript:filterPath('[link]');", FALSE, '/^8000$|^16000$|^32000$|^48000$/');
     // Build a grid with a hidden device_id, device_type, and add an option for the user to select the display columns
     $this->grid = jgrid::grid($this->baseModel, array('caption' => '&nbsp;', 'gridName' => 'MediaGrid'))->add('mediafile_id', 'ID', array('width' => '80', 'hidden' => true, 'key' => true))->add('file', 'Filename', array('width' => '40', 'search' => true, 'callback' => array('MediaFile', 'getBaseName')))->add('path', 'Path', array('width' => '80', 'hidden' => true, 'key' => true, 'search' => true))->add('description', 'Description', array('width' => '80', 'search' => true))->add('size', 'File Size', array('width' => '40', 'align' => 'right', 'callback' => array('function' => array('MediaFile', 'getSize'), 'arguments' => 'registry')))->add('length', 'Length', array('width' => '40', 'align' => 'right', 'callback' => array('function' => array('MediaFile', 'getLength'), 'arguments' => 'registry')))->navButtonAdd('Columns', array('onClickButton' => 'function () {  $(\'#{table_id}\').setColumns(); }', 'buttonimg' => url::base() . 'assets/css/jqGrid/table_insert_column.png', 'title' => 'Show/Hide Columns', 'noCaption' => true, 'position' => 'first'))->addAction('globalmedia/details', 'Details', array('arguments' => 'mediafile_id', 'attributes' => array('class' => 'qtipAjaxForm')))->addAction('globalmedia/download', 'Download', array('arguments' => 'mediafile_id'))->addAction('globalmedia/delete', 'Delete', array('width' => '60', 'arguments' => 'mediafile_id'));
     // dont foget to let the plugins add to the grid!
     plugins::views($this);
     // Produces the grid markup or JSON
     $this->view->grid = $this->grid->produce();
 }
 /**
  *
  * @package automod
  * @copyright (c) 2008 phpBB Group
  * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
  *
  */
 function upload_ext($action)
 {
     $this->listzip();
     $this->user->add_lang('posting');
     // For error messages
     include $this->phpbb_root_path . 'includes/functions_upload.' . $this->php_ext;
     $upload = new \fileupload();
     $upload->set_allowed_extensions(array('zip'));
     // Only allow ZIP files
     if (!is_writable($this->ext_dir)) {
         $this->trigger_error($this->user->lang['EXT_NOT_WRITABLE'] . $this->back_link, E_USER_WARNING);
         return false;
     }
     $upload_dir = $this->ext_dir;
     // Make sure the ext/ directory exists and if it doesn't, create it
     if (!is_dir($this->ext_dir)) {
         $this->recursive_mkdir($this->ext_dir);
     }
     // Proceed with the upload
     if ($action == 'upload') {
         $file = $upload->form_upload('extupload');
     } else {
         if ($action == 'upload_remote') {
             $file = $this->remote_upload($upload, $this->request->variable('remote_upload', ''));
         }
     }
     if ($action != 'upload_local') {
         if (empty($file->filename)) {
             $this->trigger_error((sizeof($file->error) ? implode('<br />', $file->error) : $this->user->lang['NO_UPLOAD_FILE']) . $this->back_link, E_USER_WARNING);
             return false;
         } else {
             if ($file->init_error || sizeof($file->error)) {
                 $file->remove();
                 $this->trigger_error((sizeof($file->error) ? implode('<br />', $file->error) : $this->user->lang['EXT_UPLOAD_INIT_FAIL']) . $this->back_link, E_USER_WARNING);
                 return false;
             }
         }
         $file->clean_filename('real');
         $file->move_file(str_replace($this->phpbb_root_path, '', $upload_dir), true, true);
         if (sizeof($file->error)) {
             $file->remove();
             $this->trigger_error(implode('<br />', $file->error) . $this->back_link, E_USER_WARNING);
             return false;
         }
         $dest_file = $file->destination_file;
     } else {
         $dest_file = $this->phpbb_root_path . 'ext/' . $this->request->variable('local_upload', '');
     }
     include $this->phpbb_root_path . 'includes/functions_compress.' . $this->php_ext;
     $zip = new \ZipArchive();
     $res = $zip->open($dest_file);
     if ($res !== true) {
         $this->trigger_error($this->user->lang['ziperror'][$res] . $this->back_link, E_USER_WARNING);
         return false;
     }
     $zip->extractTo($this->phpbb_root_path . 'ext/tmp');
     $zip->close();
     $style_path = $this->get_style_path($this->phpbb_root_path . 'ext/tmp');
     if (!$style_path) {
         $this->trigger_error($this->user->lang['ACP_UPLOAD_STYLE_ERROR_COMP'] . $this->back_link, E_USER_WARNING);
         return false;
     }
     $style_cfg = $this->read_style_cfg($style_path);
     $destination = str_replace(' ', '_', $style_cfg['name']);
     if ($style_cfg['phpbb_version'] != $this->config['version']) {
         $this->trigger_error($this->user->lang['ACP_UPLOAD_STYLE_ERROR_DEST'] . $this->back_link, E_USER_WARNING);
         return false;
     }
     $display_name = $style_cfg['name'];
     if (!isset($style_cfg['name'])) {
         $this->rrmdir($this->phpbb_root_path . 'ext/tmp');
         if ($action != 'upload_local') {
             $file->remove();
         }
         $this->trigger_error($this->user->lang['NOT_AN_STYLE'] . $this->back_link, E_USER_WARNING);
         return false;
     }
     $source = substr($style_path, 0, -10);
     /* Delete the previous version of style files - we're able to update them. */
     if (is_dir($this->phpbb_root_path . 'styles/' . $destination)) {
         $this->rrmdir($this->phpbb_root_path . 'styles/' . $destination);
     }
     $this->rcopy($source, $this->phpbb_root_path . 'styles/' . $destination);
     $this->rrmdir($this->phpbb_root_path . 'ext/tmp');
     $this->template->assign_block_vars('authors', array('AUTHOR' => $style_cfg['copyright']));
     $string = @file_get_contents($this->phpbb_root_path . 'styles/' . $destination . '/style.cfg');
     if ($string !== false) {
         $readme = highlight_string($string, true);
     } else {
         $readme = false;
     }
     $this->template->assign_vars(array('S_UPLOADED' => $display_name, 'FILETREE' => \filetree::php_file_tree($this->phpbb_root_path . 'styles/' . $destination, $display_name, $this->main_link), 'S_ACTION' => $this->phpbb_root_path . '/adm/index.php?i=acp_styles&sid=' . $this->user->session_id . '&mode=install&action=install&hash=' . generate_link_hash('install') . '&dir=' . urlencode($destination), 'S_ACTION_BACK' => $this->main_link, 'U_ACTION' => $this->u_action, 'README_MARKDOWN' => $readme, 'FILENAME' => $string !== false ? 'style.cfg' : '', 'CONTENT' => $string !== false ? highlight_string($string, true) : ''));
     // Remove the uploaded archive file
     if ($this->request->variable('keepext', false) == false) {
         $file->remove();
     }
     return true;
 }
Example #5
0
<div>
    <?php 
echo form::open();
?>

    <?php 
echo form::open_section('Create Folder');
?>

    <div class="field">
        <?php 
echo form::label('path', 'Upload Path:');
echo form::dropdown('path', array_merge(array('' => '(root)'), filetree::file_tree_dir($soundPath, TRUE, '/8000$|16000$|32000$|48000$/')), $reqPath);
?>
    </div>

    <div class="field">
        <?php 
echo form::label('newfolder', 'Folder Name:');
echo form::input('newfolder');
?>
    </div>

    <?php 
if (isset($views)) {
    echo subview::renderAsSections($views);
}
?>

    <div class="buttons form_bottom">
Example #6
0
File: add.php Project: swk/bluebox
<div>
    <?php 
echo form::open(NULL, array('enctype' => "multipart/form-data"));
?>

    <?php 
echo form::open_section('Upload File');
?>

    <div class="field">
        <?php 
echo form::label('upload[path]', 'Upload Path:');
echo form::dropdown('upload[path]', filetree::file_tree_dir($soundPath, TRUE, '/8000$|16000$|32000$|48000$/'));
?>
    </div>

    <div class="field">
        <?php 
echo form::label('upload', 'Audio File (MP3 or WAV):');
echo form::upload('upload');
?>
    </div>

    <div class="field">
        <?php 
echo form::label('upload[description]', 'Description:');
echo form::input('upload[description]');
?>
    </div>

    <!-- Ignored