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


PHP rar_close函数代码示例

本文整理汇总了PHP中rar_close函数的典型用法代码示例。如果您正苦于以下问题:PHP rar_close函数的具体用法?PHP rar_close怎么用?PHP rar_close使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: Analyze

 public function Analyze()
 {
     $info =& $this->getid3->info;
     $info['fileformat'] = 'rar';
     if ($this->option_use_rar_extension === true) {
         if (function_exists('rar_open')) {
             if ($rp = rar_open($info['filenamepath'])) {
                 $info['rar']['files'] = array();
                 $entries = rar_list($rp);
                 foreach ($entries as $entry) {
                     $info['rar']['files'] = getid3_lib::array_merge_clobber($info['rar']['files'], getid3_lib::CreateDeepArray($entry->getName(), '/', $entry->getUnpackedSize()));
                 }
                 rar_close($rp);
                 return true;
             } else {
                 $info['error'][] = 'failed to rar_open(' . $info['filename'] . ')';
             }
         } else {
             $info['error'][] = 'RAR support does not appear to be available in this PHP installation';
         }
     } else {
         $info['error'][] = 'PHP-RAR processing has been disabled (set $getid3_rar->option_use_rar_extension=true to enable)';
     }
     return false;
 }
开发者ID:anandsrijan,项目名称:mahariya-001,代码行数:25,代码来源:module.archive.rar.php

示例2: uncompress_rar

 public function uncompress_rar($path, $cachedir)
 {
     $rar_file = rar_open($path);
     $entries = rar_list($rar_file);
     $allowed = array('.jpg', '.gif', '.png', 'jpeg');
     foreach ($entries as $entry) {
         if (in_array(substr($entry->getName(), -4), $allowed)) {
             $entry->extract($cachedir);
         }
     }
     rar_close($rar_file);
 }
开发者ID:bonsoirval,项目名称:FoOlSlide,代码行数:12,代码来源:files_model.php

示例3: unrar

function unrar($rarfile)
{
    $rar_file = rar_open($rarfile) or die("Can't open Rar archive");
    $entries = rar_list($rar_file);
    foreach ($entries as $entry) {
        echo 'Filename: ' . $entry->getName() . "\n";
        echo 'Packed size: ' . $entry->getPackedSize() . "\n";
        echo 'Unpacked size: ' . $entry->getUnpackedSize() . "\n";
        $entry->extract('D:/usr/lioncube/');
    }
    rar_close($rar_file);
}
开发者ID:pankajsinghjarial,项目名称:SYLC-AMERICAN,代码行数:12,代码来源:zip_funct.php

示例4: extract

 public function extract($source, $target, $password)
 {
     $rarFile = rar_open(suffix($source, '.rar'), $password);
     $list = rar_list($rarFile);
     if (!empty($list)) {
         foreach ($list as $file) {
             $entry = rar_entry_get($rarFile, $file);
             $entry->extract($target);
         }
     } else {
         throw new InvalidArgumentException('Error', 'emptyVariable', '$list');
     }
     rar_close($rarFile);
 }
开发者ID:znframework,项目名称:znframework,代码行数:14,代码来源:RAR.php

示例5: unrarFile

function unrarFile()
{
    $rar_file = rar_open(RAR_FILE);
    try {
        $list = rar_list($rar_file);
        foreach ($list as $file) {
            $file->extract(TARGET_DIR);
        }
    } catch (Exception $e) {
        try {
            rar_close($rar_file);
        } catch (Exception $e) {
        }
        echo "An exception occured while extracting archive: " . $e . "\n";
    }
}
开发者ID:sasfeld,项目名称:Scripts,代码行数:16,代码来源:index_extractor.php

示例6: extract

 public function extract($source = '', $target = '.', $password = NULL)
 {
     if (!is_file($source)) {
         return Error::set('Error', 'fileParameter', '1.(source)');
     }
     $rarFile = rar_open($source, $password);
     $list = rar_list($rarFile);
     if (!empty($list)) {
         foreach ($list as $file) {
             $entry = rar_entry_get($rarFile, $file);
             $entry->extract($target);
         }
     } else {
         return Error::set('Error', 'emptyVariable', '$list');
     }
     rar_close($rarFile);
 }
开发者ID:bytemtek,项目名称:znframework,代码行数:17,代码来源:RAR.php

示例7: func_rar

function func_rar($path1, $file2, $unrar = '')
{
    if (!function_exists("rar_open")) {
        if ($unrar['key'] == false) {
            echo 'You have not selected the variable $unrar=$arc[type_archive] in setup.php';
            echo "\n";
            $error6 = 1;
        }
        if ($unrar['path'] == false) {
            echo 'You have not selected the variable $unrar[path] in setup.php';
            echo "\n";
            $error6 = 1;
        }
        //echo $unrar['path'].' '.$unrar['key'].' '.$path1.'/'.$file2.' '.$unrar['out_dir'].$path1.'/'; echo "\n\n";
        exec($unrar['path'] . ' ' . $unrar['key'] . ' ' . $path1 . '/' . $file2 . ' ' . $unrar['out_dir'] . $path1 . '/', $out, $val);
        //print_r($out);
        if (!isset($out[1])) {
            echo "There no installed php functions php-rar or bash function unrar. Install one of this functions\n";
        }
        if ($out[$unrar['id_ok']] == $unrar['value_ok'] && $error6 == false) {
            return 0;
        } else {
            return 1;
        }
    } else {
        //echo "rar_php\n";
        $rar_file = @rar_open($path1 . '/' . $file2);
        if ($rar_file == false) {
            return false;
        } else {
            $entries = rar_list($rar_file);
            foreach ($entries as $entry) {
                $entry->extract($path1);
            }
            rar_close($rar_file);
            return 0;
        }
    }
}
开发者ID:RoSk0,项目名称:nod_upd_php,代码行数:39,代码来源:functions.php

示例8: process_file_in_rar

function process_file_in_rar($file_path, $type)
{
    global $is_debug;
    debug("process_file_in_rar: " . $file_path);
    $rar_file_path = "";
    if (strpos(strtolower($file_path), ".rar") != FALSE) {
        $rar_file_path = parse_real_path($file_path, ".rar");
    }
    if (strpos(strtolower($file_path), ".cbr") != FALSE) {
        $rar_file_path = parse_real_path($file_path, ".cbr");
    }
    $image_path = str_replace($rar_file_path . "/", "", $file_path);
    debug("rar_file_path: " . $rar_file_path);
    debug("image_path: " . $image_path);
    $rar_handle = rar_open($rar_file_path);
    if ($rar_handle != FALSE) {
        foreach ($rar_handle->getEntries() as $entry) {
            $entry_name = $entry->getName();
            $entry_name = change_encoding($entry_name);
            if (end_with($entry_name, $image_path)) {
                debug("found file in rar: " . $entry_name);
                $entry_size = $entry->getUnpackedSize();
                $fp = $entry->getStream();
                rar_close($rar_handle);
                if (!$is_debug) {
                    header("Content-Type: " . $type);
                    header("Content-Length: " . $entry_size);
                    while (!feof($fp)) {
                        $buff = fread($fp, 8192);
                        if ($buff !== false) {
                            echo $buff;
                        } else {
                            break;
                        }
                    }
                }
                fclose($fp);
            }
        }
    } else {
        debug("handle error");
    }
}
开发者ID:comicfans,项目名称:comix-server,代码行数:43,代码来源:handler.php

示例9: _unpack

 /**
  * Unpack archive
  *
  * @param  string  $path  archive path
  * @param  array   $arc   archiver command and arguments (same as in $this->archivers)
  * @return void
  * @author Dmitry (dio) Levashov
  * @author Alexey Sukhotin
  **/
 protected function _unpack($path, $arc)
 {
     $cwd = getcwd();
     $dir = $this->_dirname($path);
     chdir($dir);
     //$cmd = $arc['cmd'].' '.$arc['argc'].' '.escapeshellarg($this->_basename($path));
     $change = array(".zip", ".rar");
     $with = array("", "");
     $newFolderName = str_replace($change, $with, $this->_basename($path));
     $newFolderName2 = $newFolderName;
     for ($fld = 1; $fld < 100; $fld++) {
         if (file_exists($newFolderName)) {
             $newFolderName = $newFolderName2 . '-' . $fld;
         } else {
             continue;
         }
     }
     /* FIX 2012.12.11 */
     if (preg_match('/\\.zip$/i', $this->_basename($path))) {
         $zip = new ZipArchive();
         if ($zip->open($this->_basename($path)) === TRUE) {
             /* $this->_basename($path) - failo vardas */
             $zip->extractTo('./' . $newFolderName);
             //'.'.$this->_basename($path).'/'
             $zip->close();
         } else {
         }
         //$this->procExec($cmd, $o, $c);
     } elseif (preg_match('/\\.rar$/i', $this->_basename($path))) {
         $rar_file = rar_open($this->_basename($path)) or die;
         $entries = rar_list($rar_file);
         foreach ($entries as $entry) {
             $entry->extract('./' . $newFolderName);
         }
         rar_close($rar_file);
     }
     chdir($cwd);
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:47,代码来源:elFinderVolumeLocalFileSystem.class.php

示例10: index_url


//.........这里部分代码省略.........
                    }
                    foreach ($entries as $entry) {
                        $name = $entry->getName();
                        if ($debug == '2') {
                            $report = "<strong>&nbsp;&nbsp;" . $name . "</strong>";
                            printThis($report, $cl);
                            $size = (int) ($entry->getPackedSize() / 1024);
                            if ($size == 0) {
                                $size = '1';
                            }
                            $report = "&nbsp;&nbsp;&nbsp;-&nbsp;Packed size:&nbsp;&nbsp;" . $size . " kByte";
                            printThis($report, $cl);
                            $size = (int) ($entry->getUnpackedSize() / 1024);
                            if ($size == 0) {
                                $size = '1';
                            }
                            $report = "&nbsp;&nbsp;&nbsp;-&nbsp;Unpacked size:&nbsp;" . $size . " kByte<br />";
                            printThis($report, $cl);
                        }
                        $entry->extract('', "./" . $tmp_dir . "/" . $name . "");
                        //  extract single file of archiv into temporary folder
                        $buf = file_get_contents("./" . $tmp_dir . "/" . $name . "");
                        //  read content of this intermediate file
                        unlink("./" . $tmp_dir . "/" . $name . "");
                        //  destroy this file
                        if ($buf) {
                            $buf = get_arch_content($buf, $name, $url, $chrSet);
                            //  if necessary, convert PDF, extract feed etc. for the recent file
                            $file .= "" . $buf . "<br /><br />";
                            //  add all uncompressed and converted files together
                        }
                    }
                }
                rar_close($rar);
            }
            unlink("" . $tmp_dir . "/archiv.temp");
        }
        $file0 = $file;
        //  rememberr the original (e.g. for doc2txt converter)
        //  remove useless part of the content
        $file = purify_content($file);
        $valid_utf8 = '1';
        $raw_file = $file;
        //  kill eventually duplicate coding info in dynamic links
        if (stristr(substr($file, '0', '4000'), "encoding") && strstr(substr($file, '0', '4000'), "charset")) {
            $file = substr($file, strrpos($file, "<!DOCTYPE"));
            //  subsstring starting at last found <!DOCTYPE
        }
        //  we need to do it again for eventually new charset in archive
        $chrSet = '';
        if ($use_prefcharset == '1') {
            //  use preferred charset as defined in Admin settings
            $chrSet = $home_charset;
        } else {
            if ($server_char && $url_status['charset']) {
                $chrSet = $url_status['charset'];
                //  use charset as supplied by the remote server
            } else {
                //  try to extract the charset of this file
                if (preg_match("'encoding=[\\'\"](.*?)[\\'\"]'si", substr($file, 0, 3000), $regs)) {
                    $chrSet = trim(strtoupper($regs[1]));
                    //      get encoding of current XML or XHTML file     and use it furtheron
                }
                if (!$chrSet) {
                    if (preg_match("'charset=(.*?)[ \\/\\;\\'\"]'si", substr($file, 0, 3000), $regs)) {
                        $chrSet = trim(strtoupper($regs[1]));
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:67,代码来源:spiderfuncs.php

示例11: decompress

 /**
  * Decompresses the given content
  *
  * @param  string $content
  * @return bool
  * @throws Exception\RuntimeException if archive not found, cannot be opened,
  *                                    or error during decompression
  */
 public function decompress($content)
 {
     if (!file_exists($content)) {
         throw new Exception\RuntimeException('RAR Archive not found');
     }
     $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content));
     $password = $this->getPassword();
     if ($password !== null) {
         $archive = rar_open($archive, $password);
     } else {
         $archive = rar_open($archive);
     }
     if (!$archive) {
         throw new Exception\RuntimeException("Error opening the RAR Archive");
     }
     $target = $this->getTarget();
     if (!is_dir($target)) {
         $target = dirname($target);
     }
     $filelist = rar_list($archive);
     if (!$filelist) {
         throw new Exception\RuntimeException("Error reading the RAR Archive");
     }
     foreach ($filelist as $file) {
         $file->extract($target);
     }
     rar_close($archive);
     return true;
 }
开发者ID:Flesh192,项目名称:magento,代码行数:37,代码来源:Rar.php

示例12: close

 /**
  * @see File_Archive_Reader::close()
  */
 function close()
 {
     rar_close($this->rarEntry);
     if ($this->fileReader !== null) {
         $this->fileReader->close();
     }
     if ($this->rarTmpName !== null) {
         unlink($this->rarTmpName);
     }
     if ($this->entryTmpName !== null) {
         unlink($this->entryTmpName);
     }
     $this->rarFile = null;
     $this->rarEntry = null;
     reset($this->rarList);
     return parent::close();
 }
开发者ID:orcoliver,项目名称:oneye,代码行数:20,代码来源:Rar.php

示例13: basename

    } else {
        echo 'Hello,压缩包 ' . basename(_decode($_GET['path'])) . ' 解压成功!';
    }
} elseif ($_POST['ftype'] == 'rar') {
    if (function_exists('rar_open')) {
        if (($rar = rar_open(_decode($_GET['path']))) == false) {
            echo 'Hello,函数Rar_open无法启用!';
        } else {
            $entries = rar_list($rar);
            foreach ($entries as $entry) {
                echo '文件名称: ' . $entry->getName() . ".<br />";
                echo '压档大小: ' . number_format($entry->getPackedSize() / 1024 / 1024, 3) . " MB<br />";
                echo '原始大小: ' . number_format($entry->getUnpackedSize() / 1024 / 1024, 3) . " MB<br />";
                $entry->extract($_POST['dirpath']);
            }
            rar_close($rar);
        }
    } else {
        chmod(dirname(__FILE__) . '/unpack.rar', 0755);
        if (function_exists('shell_exec') == false) {
            echo 'Hello,主机禁用了核心函数哦!';
        } elseif (shell_exec('./unpack.rar x ' . _decode($_GET['path']) . ' ' . $_POST['dirpath']) == false) {
            echo 'Hello,相关系统命令执行失败!';
        } else {
            echo 'Hello,相关系统命令执行成功!';
        }
    }
} elseif ($_POST['ftype'] == 'other') {
    chmod(dirname(__FILE__) . '/unpack.7za', 0755);
    if (function_exists('shell_exec') == false) {
        echo 'Hello,主机禁用了核心函数哦!';
开发者ID:sembrono,项目名称:1,代码行数:31,代码来源:unpk.php

示例14: __construct


//.........这里部分代码省略.........
             case "read":
                 // read txt file contents
                 $sExt = strtolower(array_pop(explode('.', $this->sSFile)));
                 //
                 // install extensions and add to php.ini
                 // - extension=php_zip.dll
                 if ($sExt == "zip") {
                     $sDta = "";
                     if (!function_exists("zip_open")) {
                         $sErr .= "php_zip not installed or enabled";
                     } else {
                         if ($zip = @zip_open(getcwd() . "/" . $this->sSFile)) {
                             //
                             while ($zip_entry = @zip_read($zip)) {
                                 $sDta .= @zip_entry_name($zip_entry) . "\\r\\n";
                             }
                             // zip_entry_filesize | zip_entry_compressedsize | zip_entry_compressionmethod
                             @zip_close($zip);
                             $this->aReturn['data'] = array('type' => 'archive', 'text' => $sDta);
                         }
                     }
                 } else {
                     if ($sExt == "rar") {
                         // - extension=php_rar.dll
                         if (!function_exists("rar_open")) {
                             $sMsg .= "php_rar not installed or enabled";
                         } else {
                             if ($rar_file = @rar_open(getcwd() . "/" . $this->sSFile)) {
                                 $entries = @rar_list($rar_file);
                                 foreach ($entries as $entry) {
                                     $sDta .= $entry->getName() . "\\r\\n";
                                 }
                                 // getName | getPackedSize | getUnpackedSize
                                 @rar_close($rar_file);
                                 $this->aReturn['data'] = array('type' => 'archive', 'text' => $sDta);
                             }
                         }
                     } else {
                         if ($sExt == "pdf") {
                             include 'class.pdf2text.php';
                             $oPdf = new PDF2Text();
                             $oPdf->setFilename($this->sSFile);
                             $oPdf->decodePDF();
                             $sCnt = str_replace(array("\n", "\r", "\t"), array("\\n", "\\n", ""), substr($oPdf->output(), 0, PREVIEW_BYTES));
                             $this->aReturn['data'] = array('type' => 'ascii', 'text' => $sCnt);
                         } else {
                             if ($sExt == "doc") {
                                 //////////////////////////////
                                 // does not seem to be possible
                                 //////////////////////////////
                             } else {
                                 $oHnd = fopen($this->sSFile, "r");
                                 $sCnt = preg_replace(array("/\n/", "/\r/", "/\t/"), array("\\n", "\\r", "\\t"), addslashes(fread($oHnd, 600)));
                                 fclose($oHnd);
                                 $this->aReturn['data'] = array('type' => 'ascii', 'text' => $sCnt);
                             }
                         }
                     }
                 }
                 $this->aReturn['msg'] .= count($this->aReturn['data']) ? 'contentsSucces' : 'contentsFail';
                 break;
             case "rename":
                 // rename file
                 if (isset($_POST["file"]) && isset($_POST["nfile"])) {
                     $sFile = $_POST["file"];
                     $sNFile = $_POST["nfile"];
开发者ID:holtzermann17,项目名称:drupal_planetary,代码行数:67,代码来源:sfbrowser.php

示例15: get_index

 public function get_index()
 {
     $dir = App::$param['path'] . "app/tmp/" . Connection::$param["postgisdb"] . "/__vectors";
     $safeName = \app\inc\Model::toAscii($_REQUEST['name'], array(), "_");
     $skipFailures = $_REQUEST["ignoreerrors"] == "true" ? true : false;
     $append = $_REQUEST["append"] == "true" ? true : false;
     $overwrite = $_REQUEST["overwrite"] == "true" ? true : false;
     if (is_numeric($safeName[0])) {
         $safeName = "_" . $safeName;
     }
     //Check if file is .zip
     $zipCheck1 = explode(".", $_REQUEST['file']);
     $zipCheck2 = array_reverse($zipCheck1);
     if (strtolower($zipCheck2[0]) == "zip" || strtolower($zipCheck2[0]) == "rar") {
         $ext = array("shp", "tab", "geojson", "gml", "kml", "mif", "gdb");
         $folderArr = array();
         $safeNameArr = array();
         for ($i = 0; $i < sizeof($zipCheck1) - 1; $i++) {
             $folderArr[] = $zipCheck1[$i];
         }
         $folder = implode(".", $folderArr);
         if (strtolower($zipCheck2[0]) == "zip") {
             // ZIP start
             $zip = new \ZipArchive();
             $res = $zip->open($dir . "/" . $_REQUEST['file']);
             if ($res === false) {
                 $response['success'] = false;
                 $response['message'] = "Could not unzip file";
                 return Response::json($response);
             }
             $zip->extractTo($dir . "/" . $folder);
             $zip->close();
             // ZIP end
         }
         if (strtolower($zipCheck2[0]) == "rar") {
             // RAR start
             $rar_file = rar_open($dir . "/" . $_REQUEST['file']);
             if (!$rar_file) {
                 $response['success'] = false;
                 $response['message'] = "Could not unrar file";
                 return Response::json($response);
             }
             $list = rar_list($rar_file);
             foreach ($list as $file) {
                 $entry = rar_entry_get($rar_file, $file);
                 $file->extract($dir . "/" . $folder);
                 // extract to the current dir
             }
             rar_close($rar_file);
             // RAR end
         }
         if ($handle = opendir($dir . "/" . $folder)) {
             while (false !== ($entry = readdir($handle))) {
                 if ($entry !== "." && $entry !== "..") {
                     $zipCheck1 = explode(".", $entry);
                     $zipCheck2 = array_reverse($zipCheck1);
                     if (in_array(strtolower($zipCheck2[0]), $ext)) {
                         $_REQUEST['file'] = $folder . "/" . $entry;
                         for ($i = 0; $i < sizeof($zipCheck1) - 1; $i++) {
                             $safeNameArr[] = $zipCheck1[$i];
                         }
                         $safeName = \app\inc\Model::toAscii(implode(".", $safeNameArr), array(), "_");
                         break;
                     }
                     $_REQUEST['file'] = $folder;
                 }
             }
         }
     }
     $srid = $_REQUEST['srid'] ?: "4326";
     $encoding = $_REQUEST['encoding'] ?: "LATIN1";
     switch ($_REQUEST['type']) {
         case "Point":
             $type = "point";
             break;
         case "Polygon":
             $type = "multipolygon";
             break;
         case "Line":
             $type = "multilinestring";
             break;
         case "Geometry":
             $type = "geometry";
             break;
         default:
             $type = "PROMOTE_TO_MULTI";
             break;
     }
     $model = new \app\inc\Model();
     $tableExist = $model->isTableOrView(Connection::$param["postgisschema"] . "." . $safeName);
     $tableExist = $tableExist["success"];
     if ($tableExist == true && $overwrite == false && $append == false) {
         $response['success'] = false;
         $response['message'] = "'{$safeName}' exists already, use 'Overwrite'";
         $response['code'] = 406;
         return $response;
     }
     if ($_REQUEST["append"] == "true") {
         $sql = "DELETE FROM " . Connection::$param["postgisschema"] . "." . $safeName;
         $res = $model->prepare($sql);
//.........这里部分代码省略.........
开发者ID:ronaldoof,项目名称:geocloud2,代码行数:101,代码来源:Processvector.php


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