本文整理汇总了PHP中rar_open函数的典型用法代码示例。如果您正苦于以下问题:PHP rar_open函数的具体用法?PHP rar_open怎么用?PHP rar_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rar_open函数的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: next
/**
* @see File_Archive_Reader::next()
*/
function next()
{
$error = parent::next();
if (PEAR::isError($error)) {
return $error;
}
if ($this->rarFile === null) {
$dataFilename = $this->source->getDataFilename();
if ($dataFilename !== null) {
$this->rarTmpName = null;
$this->rarFile = rar_open($dataFilename);
} else {
$this->rarTmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far');
//Generate the tmp data
$dest = new File_Archive_Writer_Files();
$dest->newFile($this->tmpName);
$this->source->sendData($dest);
$dest->close();
$this->rarFile = rar_open($this->tmpName);
}
if (!$this->rarFile) {
return PEAR::raiseError("Unable to open rar file {$dataFilename}");
}
if ($this->rarList === null) {
$this->rarList = rar_list($this->rarFile);
reset($this->rarList);
}
}
if ($fileReader !== null) {
$this->fileReader->close();
$this->fileReader = null;
}
$entryName = next($this->rarList);
$this->source = null;
if ($entryName === false) {
return false;
}
$this->rarEntry = rar_entry_get($this->rarFile, $entryName);
if (!$this->rarEntry) {
return PEAR::raiseError("Error reading entry {$entryName}");
}
return true;
}
示例8: extract
/**
* Extract a ZIP compressed file to a given path
*
* @access public
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
* @param array $options Extraction options [unused]
* @return boolean True if successful
* @since 1.5
*/
function extract($archive, $destination, $options = array())
{
if (!is_file($archive)) {
return PEAR::raiseError('Archive does not exist');
}
if (!$this->isSupported()) {
return PEAR::raiseError('RAR Extraction not supported by your PHP installation.');
}
$arch = rar_open($archive);
if ($arch === FALSE) {
return PEAR::raiseError("Cannot open the rar archive");
}
$entries = rar_list($arch);
if ($entries === FALSE) {
return PEAR::raiseError("Cannot retrieve entries");
}
foreach ($entries as $file) {
$file->extract($destination);
}
return true;
}
示例9: 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;
}
}
}
示例10: open
public function open($filename = '', $password = NULL, $volumeCallback = NULL)
{
if (!is_string($filename)) {
return Error::set(lang('Error', 'stringParameter', '1.(filename)'));
}
return rar_open($filename, $password, $volumeCallback);
}
示例11: 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");
}
}
示例12: index_url
//.........这里部分代码省略.........
}
while ($zip_entry = zip_read($zip)) {
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
//uncompress the content of recent archiv file
$name = zip_entry_name($zip_entry);
// get filename of recent archive file
if ($debug == '2') {
//
$report = "<strong> " . $name . "</strong>";
printThis($report, $cl);
$size = (int) (zip_entry_filesize($zip_entry) / 1024);
if ($size == 0) {
$size = '1';
}
$report = " - Unpacked size: " . $size . " kByte<br />";
printThis($report, $cl);
}
$buf = get_arch_content($buf, $name, $url, $chrSet);
// if necessary, convert PDF, extract feed etc. for the recent file
zip_entry_close($zip_entry);
// done for this file in archiv
$file .= "" . $buf . "<br /><br />";
// add all uncompressed and converted files together
}
}
zip_close($zip);
}
unlink("" . $tmp_dir . "/archiv.temp");
}
// if required, uncompress RAR archives and make content of each file => text
if ($url_status['content'] == 'rar' && $index_rar == '1') {
file_put_contents("" . $tmp_dir . "/archiv.temp", $file);
$rar = rar_open("" . $tmp_dir . "/archiv.temp");
if ($rar) {
$url_status['content'] = "text";
// preventiv, all individual archiv files willl be converted to 'text'
$file = '';
// starting with a blank file for all archive files
$topic = 'rar';
$entries = rar_list($rar);
if ($rar) {
if ($debug == '2') {
printStandardReport('archivFiles', $command_line, $no_log);
}
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 . "");
示例13: 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;
}
示例14: scandisk
function scandisk($dir, $sendermail = false)
{
//mysql_query("INSERT INTO temir (text) VALUES('asdf')");
$files = scandir($dir, 1);
if (is_file($file = $dir . '/' . $files[0])) {
//parsexcelsimple($file);
$info = pathinfo($file);
if (!$sendermail) {
$sender = explode('--', $info['filename']);
if (isset($sender[1])) {
$sendermail = $sender[1];
} else {
$sendermail = '';
}
/*if($sendermail=='alla-ultra@mail.ru')
{
$newname=$dir.'/the--alla-ultra@mail.ru--file.xml';
rename($file, $newname); //because alla sends xml file with xls extension
$file=$newname;
}*/
}
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
if ($info["extension"] == "xls" || $info["extension"] == "xlsx" || $info["extension"] == "xml") {
//file from alla-ultra is saved as xls and it's corrupt. to fix it we use convert() in dmail() and skip the corrupted one here
//file from elenaultra is saved as skip and it's kinda also corrupt
if (strpos($info["basename"], 'alla-ultra@mail.ru--file.xls') === false || strpos($info["basename"], 'skip') === false) {
parsexcel($file, $sendermail);
//parsexcelsimple($file,$sendermail);
$sendermail = '';
} else {
$sendermail = false;
}
} elseif ($info["extension"] == "zip") {
$zip = new ZipArchive();
if ($zip->open($file) === TRUE) {
$zip->extractTo($path);
$zip->close();
} else {
die("Can't open zip archive");
}
} elseif ($info["extension"] == "rar") {
//install rar from here:http://php.net/manual/en/rar.installation.php
$rar_file = rar_open($file) or die("Can't open Rar archive");
$entries = rar_list($rar_file);
foreach ($entries as $entry) {
$entry->extract($path);
}
rar_close($rar_file);
}
unlink($file);
scandisk($dir, $sendermail);
}
}
示例15: basename
echo 'Hello,压缩包 ' . basename(_decode($_GET['path'])) . ' 解压失败!';
} else {
echo 'Hello,压缩包 ' . basename(_decode($_GET['path'])) . ' 解压成功!';
echo '<div class="big_board"><div class="board_title"></div></div>->>Hello,共解出档案 ' . count($count) . ' 个哦!';
}
} elseif ($_POST['ftype'] == 'tar') {
require 'tar.php';
$tar = new Archive_Tar(_decode($_GET['path']));
if (($count = $tar->extract($_POST['dirpath'])) == false) {
echo 'Hello,压缩包 ' . basename(_decode($_GET['path'])) . ' 解压失败!';
} 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,主机禁用了核心函数哦!';