Ejemplo n.º 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');
 }
Ejemplo n.º 2
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' => ' ', '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();
 }
Ejemplo n.º 3
0
 /**
  *
  * @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;
 }