コード例 #1
0
ファイル: file.php プロジェクト: asphix/icms2
 public function parse($value)
 {
     $file = is_array($value) ? $value : cmsModel::yamlToArray($value);
     if (!$file) {
         return;
     }
     $name = $this->getOption('show_name') ? $file['name'] : LANG_PARSER_FILE_LABEL_GET;
     $size_info = $this->getOption('show_size') ? '<span class="size">' . files_format_bytes($file['size']) . '</span>' : '';
     return '<a href="' . $this->getDownloadURL($file) . '">' . $name . '</a> ' . $size_info;
 }
コード例 #2
0
ファイル: index.php プロジェクト: Val-Git/icms2
 public function run()
 {
     //
     // формируем виджеты главной админки
     //
     // Виджет статистики
     $chart_nav = cmsEventsManager::hookAll('admin_dashboard_chart');
     $cookie = cmsUser::getCookie('dashboard_chart');
     $defaults = array('controller' => 'users', 'section' => 'reg', 'period' => 7);
     if ($cookie) {
         $cookie = json_decode($cookie, true);
         if (is_array($cookie)) {
             $defaults = array('controller' => $cookie['c'], 'section' => $cookie['s'], 'period' => $cookie['p']);
         }
     }
     $dashboard_blocks[] = array('title' => LANG_CP_DASHBOARD_STATS, 'class' => 'col3', 'html' => $this->cms_template->getRenderedChild('index_chart', array('chart_nav' => $chart_nav, 'defaults' => $defaults)));
     $uploader = new cmsUploader();
     $extensions = get_loaded_extensions();
     $sysinfo = array(LANG_CP_DASHBOARD_SI_PHP => phpversion(), LANG_CP_DASHBOARD_SI_ML => files_format_bytes(files_convert_bytes(@ini_get('memory_limit'))), LANG_CP_DASHBOARD_SI_MAX => $uploader->getMaxUploadSize(), LANG_CP_DASHBOARD_SI_IP => filter_input(INPUT_SERVER, 'SERVER_ADDR'), LANG_CP_DASHBOARD_SI_ROOT => ROOT, LANG_CP_DASHBOARD_SI_SESSION => session_save_path(), LANG_CP_DASHBOARD_SI_ION => in_array('ionCube Loader', $extensions), LANG_CP_DASHBOARD_SI_ZEND => in_array('Zend Optimizer', $extensions), LANG_CP_DASHBOARD_SI_ZENDG => in_array('Zend Guard Loader', $extensions));
     $dashboard_blocks[] = array('title' => LANG_CP_DASHBOARD_SYSINFO, 'html' => $this->cms_template->getRenderedChild('index_sysinfo', array('sysinfo' => $sysinfo)));
     $dashboard_blocks[] = array('title' => LANG_CP_DASHBOARD_RESOURCES, 'html' => $this->cms_template->getRenderedChild('index_resources', array()));
     $dashboard_blocks = array_merge($dashboard_blocks, cmsEventsManager::hookAll('admin_dashboard_block', false, array()));
     $_block_id = 0;
     foreach ($dashboard_blocks as $dashboard_block) {
         // в одном хуке можно создавать несколько виджетов админки
         // для этого хук должен вернуть массив виджетов
         if (!isset($dashboard_block['title'])) {
             foreach ($dashboard_block as $sub_dashboard_block) {
                 $sub_dashboard_block['id'] = $_block_id;
                 $result_dashboard_blocks[$_block_id] = $sub_dashboard_block;
                 $_block_id++;
             }
         } else {
             $dashboard_block['id'] = $_block_id;
             $result_dashboard_blocks[$_block_id] = $dashboard_block;
         }
         $_block_id++;
     }
     // формируем с учетом порядка
     if (!empty($this->options['dashboard_order'])) {
         $order_id = 1000;
         foreach ($result_dashboard_blocks as $block_id => $block) {
             if (isset($this->options['dashboard_order'][$block_id])) {
                 $order_id = $this->options['dashboard_order'][$block_id];
             } else {
                 $order_id += 1;
             }
             $_result_dashboard_blocks[$order_id] = $block;
         }
         ksort($_result_dashboard_blocks);
     } else {
         $_result_dashboard_blocks = $result_dashboard_blocks;
     }
     return $this->cms_template->render('index', array('dashboard_blocks' => $_result_dashboard_blocks));
 }
コード例 #3
0
ファイル: index.php プロジェクト: mafru/icms2
 public function run()
 {
     $chart_nav = cmsEventsManager::hookAll('admin_dashboard_chart');
     $uploader = new cmsUploader();
     $extensions = get_loaded_extensions();
     $sysinfo = array(LANG_CP_DASHBOARD_SI_PHP => phpversion(), LANG_CP_DASHBOARD_SI_ML => files_format_bytes(files_convert_bytes(@ini_get('memory_limit'))), LANG_CP_DASHBOARD_SI_MAX => $uploader->getMaxUploadSize(), LANG_CP_DASHBOARD_SI_IP => filter_input(INPUT_SERVER, 'SERVER_ADDR'), LANG_CP_DASHBOARD_SI_ROOT => ROOT, LANG_CP_DASHBOARD_SI_ION => in_array('ionCube Loader', $extensions), LANG_CP_DASHBOARD_SI_ZEND => in_array('Zend Optimizer', $extensions), LANG_CP_DASHBOARD_SI_ZENDG => in_array('Zend Guard Loader', $extensions));
     $cookie = cmsUser::getCookie('dashboard_chart');
     $defaults = array('controller' => 'users', 'section' => 'reg', 'period' => 7);
     if ($cookie) {
         $cookie = json_decode($cookie, true);
         if (is_array($cookie)) {
             $defaults = array('controller' => $cookie['c'], 'section' => $cookie['s'], 'period' => $cookie['p']);
         }
     }
     return cmsTemplate::getInstance()->render('index', array('dashboard_blocks' => cmsEventsManager::hookAll('admin_dashboard_block'), 'chart_nav' => $chart_nav, 'sysinfo' => $sysinfo, 'defaults' => $defaults));
 }
コード例 #4
0
ファイル: uploader.php プロジェクト: rookees/icms2
 /**
  * Загружает файл на сервер переданный через input типа file
  * @param string $post_filename Название поля с файлом в массиве $_FILES
  * @param string $allowed_ext Список допустимых расширений (через запятую)
  * @param string $allowed_size Максимальный размер файла (в байтах)
  * @param string $destination Папка назначения (внутри пути upload)
  * @return array
  */
 public function uploadForm($post_filename, $allowed_ext = false, $allowed_size = 0, $destination = false)
 {
     $config = cmsConfig::getInstance();
     $user = cmsUser::getInstance();
     $source = $_FILES[$post_filename]['tmp_name'];
     $error_code = $_FILES[$post_filename]['error'];
     $dest_size = $_FILES[$post_filename]['size'];
     $dest_name = basename(files_sanitize_name($_FILES[$post_filename]['name']));
     $dest_ext = mb_strtolower(pathinfo($dest_name, PATHINFO_EXTENSION));
     if ($allowed_ext !== false) {
         $allowed_ext = explode(",", $allowed_ext);
         foreach ($allowed_ext as $idx => $ext) {
             $allowed_ext[$idx] = mb_strtolower(trim(trim($ext, '., ')));
         }
         if (!in_array($dest_ext, $allowed_ext)) {
             return array('error' => LANG_UPLOAD_ERR_MIME, 'success' => false, 'name' => $dest_name);
         }
     }
     if ($allowed_size) {
         if ($dest_size > $allowed_size) {
             return array('error' => sprintf(LANG_UPLOAD_ERR_INI_SIZE, files_format_bytes($allowed_size)), 'success' => false, 'name' => $dest_name);
         }
     }
     if (!$destination) {
         $user->increaseFilesCount();
         $dest_dir = $this->getUploadDestinationDirectory();
         $dest_file = substr(md5($user->id . $user->files_count . microtime(true)), 0, 8) . '.' . $dest_ext;
         $destination = $dest_dir . '/' . $dest_file;
     } else {
         $destination = $config->upload_path . $destination . '/' . $dest_name;
     }
     return $this->moveUploadedFile($source, $destination, $error_code, $dest_name, $dest_size);
 }
コード例 #5
0
ファイル: uploader.php プロジェクト: dgolovanev/icms2
 /**
  * Загружает файл на сервер переданный через XHR
  * @param string $post_filename Название поля с файлом в массиве $_GET
  * @param string $allowed_ext Список допустимых расширений (через запятую)
  * @param string $allowed_size Максимальный размер файла (в байтах)
  * @param string $destination Папка назначения (внутри пути upload)
  * @return array
  */
 public function uploadXHR($post_filename, $allowed_ext = false, $allowed_size = 0, $destination = false)
 {
     $user = cmsUser::getInstance();
     $dest_name = files_sanitize_name($_GET['qqfile']);
     $dest_ext = pathinfo($dest_name, PATHINFO_EXTENSION);
     if (!$this->checkExt($dest_ext, $allowed_ext)) {
         return array('error' => LANG_UPLOAD_ERR_MIME, 'success' => false, 'name' => $dest_name);
     }
     if ($allowed_size) {
         if ($this->getXHRFileSize() > $allowed_size) {
             return array('error' => sprintf(LANG_UPLOAD_ERR_INI_SIZE, files_format_bytes($allowed_size)), 'success' => false, 'name' => $dest_name);
         }
     }
     $dest_file = substr(md5(uniqid() . microtime(true)), 0, 8) . '.' . $dest_ext;
     if (!$destination) {
         $user->increaseFilesCount();
         $destination = $this->getUploadDestinationDirectory() . '/' . $dest_file;
     } else {
         $destination = cmsConfig::get('upload_path') . $destination . '/' . $dest_file;
     }
     return $this->saveXHRFile($destination, $dest_name);
 }
コード例 #6
0
ファイル: file.tpl.php プロジェクト: asphix/icms2
    <?php 
echo html_file_input($field->element_name);
?>
    <?php 
echo html_input('hidden', $field->element_name, '');
?>
    <?php 
if ($field->data['allowed_extensions']) {
    ?>
        <div class="hint"><?php 
    printf(LANG_PARSER_FILE_EXTS_FIELD_HINT, implode(', ', array_map(function ($val) {
        return trim($val);
    }, explode(',', mb_strtoupper($field->data['allowed_extensions'])))));
    ?>
</div>
    <?php 
}
?>
    <?php 
if ($field->data['max_size_mb']) {
    ?>
        <div class="hint"><?php 
    printf(LANG_PARSER_FILE_SIZE_FIELD_HINT, files_format_bytes($field->data['max_size_mb']));
    ?>
</div>
    <?php 
}
?>
</div>

コード例 #7
0
ファイル: upload.tpl.php プロジェクト: asphix/icms2
if ($allowed_extensions) {
    ?>
			<div class="hint"><?php 
    printf(LANG_PARSER_FILE_EXTS_FIELD_HINT, implode(', ', array_map(function ($val) {
        return trim($val);
    }, explode(',', mb_strtoupper($allowed_extensions)))));
    ?>
</div>
		<?php 
}
?>
		<?php 
if ($max_size_mb) {
    ?>
			<div class="hint"><?php 
    printf(LANG_PARSER_FILE_SIZE_FIELD_HINT, files_format_bytes($max_size_mb));
    ?>
</div>
		<?php 
}
?>
		
		<div class="button">
			<?php 
echo html_submit(LANG_UPLOAD);
?>
		</div>
	</div>
	
</form>