本文整理匯總了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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";
}
}
示例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);
}
示例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;
}
}
}
示例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");
}
}
示例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);
}
示例10: index_url
//.........這裏部分代碼省略.........
}
foreach ($entries as $entry) {
$name = $entry->getName();
if ($debug == '2') {
$report = "<strong> " . $name . "</strong>";
printThis($report, $cl);
$size = (int) ($entry->getPackedSize() / 1024);
if ($size == 0) {
$size = '1';
}
$report = " - Packed size: " . $size . " kByte";
printThis($report, $cl);
$size = (int) ($entry->getUnpackedSize() / 1024);
if ($size == 0) {
$size = '1';
}
$report = " - Unpacked size: " . $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]));
示例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;
}
示例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();
}
示例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,主機禁用了核心函數哦!';
示例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"];
示例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);
//.........這裏部分代碼省略.........