当前位置: 首页>>代码示例>>PHP>>正文


PHP File_Archive::predExtension方法代码示例

本文整理汇总了PHP中File_Archive::predExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP File_Archive::predExtension方法的具体用法?PHP File_Archive::predExtension怎么用?PHP File_Archive::predExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File_Archive的用法示例。


在下文中一共展示了File_Archive::predExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveChanges

 function saveChanges()
 {
     global $CONFIG;
     $_REQUEST->setType('uncompress', 'any');
     if (isset($_FILES['uFiles']) && $this->may($USER, EDIT)) {
         $u = false;
         $ue = false;
         $extensions = $CONFIG->Files->filter;
         foreach ($_FILES['uFiles']['error'] as $i => $e) {
             $parts = explode('.', $_FILES['uFiles']['name'][$i]);
             $extension = array_pop($parts);
             if ($e == UPLOAD_ERR_NO_FILE) {
                 continue;
             }
             $newPath = $this->that->path . '/' . $_FILES['uFiles']['name'][$i];
             if ($e == UPLOAD_ERR_OK) {
                 if ($_REQUEST['uncompress'] && in_array(strtolower(strrchr($_FILES['uFiles']['name'][$i], '.')), array('.tar', '.gz', '.tgz', '.bz2', '.tbz', '.zip', '.ar', '.deb'))) {
                     $tmpfile = $_FILES['uFiles']['tmp_name'][$i] . $_FILES['uFiles']['name'][$i];
                     rename($_FILES['uFiles']['tmp_name'][$i], $tmpfile);
                     $u = true;
                     require_once "File/Archive.php";
                     error_reporting(E_ALL);
                     $curdir = getcwd();
                     chdir($this->path);
                     //FIXME: FIXME!
                     if (@File_Archive::extract(File_Archive::filter(File_Archive::predExtension($extensions), File_Archive::read($tmpfile . '/*')), File_Archive::toFiles()) == null) {
                         $ue = true;
                     } else {
                         Flash::queue(__('Extraction failed'));
                     }
                     chdir($curdir);
                 } elseif (!in_array(strtolower($extension), $extensions)) {
                     Flash::queue(__('Invalid format:') . ' ' . $_FILES['uFiles']['name'][$i], 'warning');
                     continue;
                 } else {
                     $u = (bool) @move_uploaded_file($_FILES['uFiles']['tmp_name'][$i], $newPath);
                 }
             }
             if (!$u) {
                 Flash::queue(__('Upload of file') . ' "' . $_FILES['uFiles']['name'][$i] . '" ' . __('failed') . ' (' . ($e ? $e : __('Check permissions')) . ')', 'warning');
             }
         }
         if ($u) {
             $this->loadStructure(true);
             Flash::queue(__('Your file(s) were uploaded'));
             return true;
         }
         if ($ue) {
             $this->loadStructure(true);
             Flash::queue(__('Your file(s) were uploaded and extracted'));
             return true;
         }
         return false;
     }
 }
开发者ID:jonatanolofsson,项目名称:solidba.se,代码行数:55,代码来源:Upload.php

示例2: testExtension

 function testExtension()
 {
     $source = File_Archive::read('test.php');
     $source->next();
     $predicate = File_Archive::predExtension(array('php', 'txt'));
     $this->assertTrue($predicate->isTrue($source));
     $predicate = File_Archive::predExtension('txt');
     $this->assertFalse($predicate->isTrue($source));
 }
开发者ID:andychang88,项目名称:jianzhanseo.com,代码行数:9,代码来源:test.php


注:本文中的File_Archive::predExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。