Offline
- Thread Author
- #1
PHP:
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
class zipci
{
CONST ARCHIVECOMMENT = 'shared by forum.warezm.com';
CONST DIR = 'i-scripts/';
public function message($code)
{
switch( (int) $code )
{
case ZipArchive::ER_OK : return 'N No error';
case ZipArchive::ER_MULTIDISK : return 'N Multi-disk zip archives not supported';
case ZipArchive::ER_RENAME : return 'S Renaming temporary file failed';
case ZipArchive::ER_CLOSE : return 'S Closing zip archive failed';
case ZipArchive::ER_SEEK : return 'S Seek error';
case ZipArchive::ER_READ : return 'S Read error';
case ZipArchive::ER_WRITE : return 'S Write error';
case ZipArchive::ER_CRC : return 'N CRC error';
case ZipArchive::ER_ZIPCLOSED : return 'N Containing zip archive was closed';
case ZipArchive::ER_NOENT : return 'N No such file';
case ZipArchive::ER_EXISTS : return 'N File already exists';
case ZipArchive::ER_OPEN : return 'S Can\'t open file';
case ZipArchive::ER_TMPOPEN : return 'S Failure to create temporary file';
case ZipArchive::ER_ZLIB : return 'Z Zlib error';
case ZipArchive::ER_MEMORY : return 'N Malloc failure';
case ZipArchive::ER_CHANGED : return 'N Entry has been changed';
case ZipArchive::ER_COMPNOTSUPP : return 'N Compression method not supported';
case ZipArchive::ER_EOF : return 'N Premature EOF';
case ZipArchive::ER_INVAL : return 'N Invalid argument';
case ZipArchive::ER_NOZIP : return 'N Not a zip archive';
case ZipArchive::ER_INTERNAL : return 'N Internal error';
case ZipArchive::ER_INCONS : return 'N Zip archive inconsistent';
case ZipArchive::ER_REMOVE : return 'S Can\'t remove file';
case ZipArchive::ER_DELETED : return 'N Entry has been deleted';
default : return sprintf('Unknown status %s', $code );
}
}
public function filelist($dir)
{
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != ".zip" && $entry != ".." && $entry != ".") {
$files[] .= $entry;
}
}
return(array($files));
closedir($handle);
}
}
public function setAllArchiveComment()
{
foreach ($this->filelist(zipci::DIR)[0] as $key => $value) {
$zip = new ZipArchive;
$sekk = $zip->open(zipci::DIR.$value);
if ($sekk === TRUE) {
//Read contents into memory
$oldContents = $zip->getFromName($fileToModify);
//Modify contents:
$newContents = str_replace('key', $_GET['param'], $oldContents);
//Delete the old...
$zip->deleteName($fileToModify);
//Write the new...
$zip->setArchiveComment(zipci::ARCHIVECOMMENT);
//And write back to the filesystem.
$ans["$value"] = 'ok';
} else {
$ans["$value"] = $this->message($sekk);
continue;
}
$zip->close();
}
return($ans);
}
public function setAllRename($dir,$exps=null,$pos=null)
{
foreach ($this->filelist($dir)[0] as $key => $value) {
$exp = explode($exps, $value);
$newname = str_replace($exp[$pos].'-', '', $value);
$bak = rename($_SERVER['DOCUMENT_ROOT'].'/'.$dir.$value, $_SERVER['DOCUMENT_ROOT'].'/'.$dir.$newname);
$last_error = error_get_last();
}
}
}
?>
Bu yazılım zip olarak çektiğiniz çoklu yazılımların zip halinin açıklamasını düzeltmeye ve isimlerini değiştirmeye yarıyor.
Tüm ziplerin adını değiştir ( Rename ALl zip files ) :
PHP:
$class = new zipci;
$class->setAllRename('DIRECTORY',0,0);
Tüm ziplerin AÇIKLAMASINI DEĞİŞTİRMEYE YARAR ( Set description ALl zip files ) :
$class = new zipci;
$class->setAllArchiveComment();
Configs / konfigürasyon :
CONST ARCHIVECOMMENT = 'YOUR TEXT DESCRİPTİON ';
CONST DIR = 'DIRECTORY';