本文整理汇总了PHP中ZipArchive::renameName方法的典型用法代码示例。如果您正苦于以下问题:PHP ZipArchive::renameName方法的具体用法?PHP ZipArchive::renameName怎么用?PHP ZipArchive::renameName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZipArchive
的用法示例。
在下文中一共展示了ZipArchive::renameName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($r)
{
if (pts_openbenchmarking_client::user_name() == false) {
echo PHP_EOL . 'You must first be logged into an OpenBenchmarking.org account.' . PHP_EOL;
echo PHP_EOL . 'Create An Account: http://openbenchmarking.org/';
echo PHP_EOL . 'Log-In Command: phoronix-test-suite openbenchmarking-setup' . PHP_EOL . PHP_EOL;
return false;
}
if (($test_suite = pts_types::identifier_to_object($r[0])) != false) {
pts_client::$display->generic_heading($r[0]);
if (pts_validation::validate_test_suite($test_suite)) {
$zip_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . $test_suite->get_identifier(false) . '-' . $test_suite->get_version() . '.zip';
$zip_created = pts_compression::zip_archive_create($zip_file, $test_suite->xml_parser->getFileLocation());
if ($zip_created == false) {
echo PHP_EOL . 'Failed to create zip file.' . PHP_EOL;
return false;
}
$zip = new ZipArchive();
$zip->open($zip_file);
$zip->renameName(basename($test_suite->xml_parser->getFileLocation()), 'suite-definition.xml');
$zip->close();
$commit_description = pts_user_io::prompt_user_input('Enter a test commit description', false);
echo PHP_EOL;
$server_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_suite', array('ts_identifier' => $test_suite->get_identifier_base_name(), 'ts_sha1' => sha1_file($zip_file), 'ts_zip' => base64_encode(file_get_contents($zip_file)), 'ts_zip_name' => basename($zip_file), 'commit_description' => $commit_description));
echo PHP_EOL;
$json = json_decode($server_response, true);
if (isset($json['openbenchmarking']['upload']['error']) && !empty($json['openbenchmarking']['upload']['error'])) {
echo 'ERROR: ' . $json['openbenchmarking']['upload']['error'] . PHP_EOL;
}
if (isset($json['openbenchmarking']['upload']['id']) && !empty($json['openbenchmarking']['upload']['id'])) {
echo 'Command: phoronix-test-suite benchmark ' . $json['openbenchmarking']['upload']['id'] . PHP_EOL;
}
if (isset($json['openbenchmarking']['upload']['url']) && !empty($json['openbenchmarking']['upload']['url'])) {
pts_openbenchmarking::refresh_repository_lists(null, true);
echo 'URL: ' . $json['openbenchmarking']['upload']['url'] . PHP_EOL;
}
echo PHP_EOL;
unlink($zip_file);
}
}
}
示例2: dlSpecBackup
public function dlSpecBackup($collId, $characterSet, $zipFile = 1)
{
global $charset, $paramsArr;
$tempPath = $this->getTempPath();
$buFileName = $paramsArr['un'] . '_' . time();
$zipArchive;
if ($zipFile && class_exists('ZipArchive')) {
$zipArchive = new ZipArchive();
$zipArchive->open($tempPath . $buFileName . '.zip', ZipArchive::CREATE);
}
$cSet = str_replace('-', '', strtolower($charset));
$fileUrl = '';
//If zip archive can be created, the occurrences, determinations, and image records will be added to single archive file
//If not, then a CSV file containing just occurrence records will be returned
echo '<li style="font-weight:bold;">Zip Archive created</li>';
echo '<li style="font-weight:bold;">Adding occurrence records to archive...';
ob_flush();
flush();
//Adding occurrence records
$fileName = $tempPath . $buFileName;
$specFH = fopen($fileName . '_spec.csv', "w");
//Output header
$headerStr = 'occid,dbpk,basisOfRecord,otherCatalogNumbers,ownerInstitutionCode, ' . 'family,scientificName,sciname,tidinterpreted,genus,specificEpithet,taxonRank,infraspecificEpithet,scientificNameAuthorship, ' . 'taxonRemarks,identifiedBy,dateIdentified,identificationReferences,identificationRemarks,identificationQualifier, ' . 'typeStatus,recordedBy,recordNumber,associatedCollectors,eventDate,year,month,day,startDayOfYear,endDayOfYear, ' . 'verbatimEventDate,habitat,substrate,occurrenceRemarks,informationWithheld,associatedOccurrences, ' . 'dataGeneralizations,associatedTaxa,dynamicProperties,verbatimAttributes,reproductiveCondition, ' . 'cultivationStatus,establishmentMeans,lifeStage,sex,individualCount,country,stateProvince,county,municipality, ' . 'locality,localitySecurity,localitySecurityReason,decimalLatitude,decimalLongitude,geodeticDatum, ' . 'coordinateUncertaintyInMeters,verbatimCoordinates,georeferencedBy,georeferenceProtocol,georeferenceSources, ' . 'georeferenceVerificationStatus,georeferenceRemarks,minimumElevationInMeters,maximumElevationInMeters,verbatimElevation, ' . 'previousIdentifications,disposition,modified,language,processingstatus,recordEnteredBy,duplicateQuantity,dateLastModified ';
fputcsv($specFH, explode(',', $headerStr));
//Query and output values
$sql = 'SELECT ' . $headerStr . ' FROM omoccurrences ' . 'WHERE collid = ' . $collId . ' AND observeruid = ' . $this->uid;
if ($rs = $this->conn->query($sql)) {
while ($r = $rs->fetch_row()) {
if ($characterSet && $characterSet != $cSet) {
$this->encodeArr($r, $characterSet);
}
fputcsv($specFH, $r);
}
$rs->close();
}
fclose($specFH);
if ($zipFile && $zipArchive) {
//Add occurrence file and then rename to
$zipArchive->addFile($fileName . '_spec.csv');
$zipArchive->renameName($fileName . '_spec.csv', 'occurrences.csv');
//Add determinations
/*
echo 'Done!</li> ';
echo '<li style="font-weight:bold;">Adding determinations records to archive...';
ob_flush();
flush();
$detFH = fopen($fileName.'_det.csv', "w");
fputcsv($detFH, Array('detid','occid','sciname','scientificNameAuthorship','identifiedBy','d.dateIdentified','identificationQualifier','identificationReferences','identificationRemarks','sortsequence'));
//Add determination values
$sql = 'SELECT d.detid,d.occid,d.sciname,d.scientificNameAuthorship,d.identifiedBy,d.dateIdentified, '.
'd.identificationQualifier,d.identificationReferences,d.identificationRemarks,d.sortsequence '.
'FROM omdeterminations d INNER JOIN omoccurrences o ON d.occid = o.occid '.
'WHERE o.collid = '.$this->collId.' AND o.observeruid = '.$this->uid;
if($rs = $this->conn->query($sql)){
while($r = $rs->fetch_row()){
fputcsv($detFH, $r);
}
$rs->close();
}
fclose($detFH);
$zipArchive->addFile($fileName.'_det.csv');
$zipArchive->renameName($fileName.'_det.csv','determinations.csv');
*/
echo 'Done!</li> ';
ob_flush();
flush();
$fileUrl = str_replace($GLOBALS['serverRoot'], $GLOBALS['clientRoot'], $tempPath . $buFileName . '.zip');
$zipArchive->close();
unlink($fileName . '_spec.csv');
//unlink($fileName.'_det.csv');
} else {
$fileUrl = str_replace($GLOBALS['serverRoot'], $GLOBALS['clientRoot'], $tempPath . $buFileName . '_spec.csv');
}
return $fileUrl;
}
示例3: array
$string = str_replace(array('é', 'è', 'ê', 'ë', 'à', 'â', 'î', 'ï', 'ô', 'ù', 'û', 'ç'), array('E', 'E', 'E', 'E', 'A', 'A', 'I', 'I', 'O', 'U', 'U', 'C'), $string);
return $string;
}
if (isset($_SESSION['RANKtrombi'])) {
$RANK = $_SESSION['RANKtrombi'];
} else {
$RANK = 0;
echo "pwet";
}
if ($RANK < RANG_PRIVILEGED_USER) {
die("Vous n'êtes pas autorisé à obtenir un zip");
} else {
include "./conx/connexion.php";
$selectPersonnes = $connexion->prepare('SELECT NOM, PRENOM, VILLE, HOBBY, PHOTO FROM ' . $prefixeDB . 'personnes WHERE PHOTO!="" AND SUG=0 ORDER BY NOM, PRENOM ASC;');
try {
$selectPersonnes->execute();
} catch (Exception $e) {
die('Erreur mySQL : ' . $e->getMessage() . '"})');
}
if (file_exists("../tmp/archive.zip")) {
unlink("../tmp/archive.zip");
}
$zip = new ZipArchive();
$zip->open('../tmp/archive.zip', ZipArchive::CREATE);
while ($personne = $selectPersonnes->fetch(PDO::FETCH_ASSOC)) {
$zip->addFile("../img/" . $personne['PHOTO'] . ".jpg");
$zip->renameName("../img/" . $personne['PHOTO'] . ".jpg", strtoupperFr($personne['NOM'] . "_" . $personne['PRENOM']) . ".jpg");
}
$zip->close();
echo "<a href='../tmp/archive.zip'>Cliquez pour obtenir le zip</a>";
}
示例4: createDwcArchive
public function createDwcArchive($fileNameSeed = '')
{
$status = false;
if (!$fileNameSeed) {
if (count($this->collArr) == 1) {
$firstColl = current($this->collArr);
if ($firstColl) {
$fileNameSeed = $firstColl['instcode'];
if ($firstColl['collcode']) {
$fileNameSeed .= '-' . $firstColl['collcode'];
}
}
if ($this->schemaType == 'backup') {
$fileNameSeed .= '_backup_' . $this->ts;
}
} else {
$fileNameSeed = 'SymbiotaOutput_' . $this->ts;
}
}
$fileName = str_replace(array(' ', '"', "'"), '', $fileNameSeed) . '_DwC-A.zip';
if (!$this->targetPath) {
$this->setTargetPath();
}
$archiveFile = '';
$this->logOrEcho('Creating DwC-A file: ' . $fileName . "\n");
if (!class_exists('ZipArchive')) {
$this->logOrEcho("FATAL ERROR: PHP ZipArchive class is not installed, please contact your server admin\n");
exit('FATAL ERROR: PHP ZipArchive class is not installed, please contact your server admin');
}
$status = $this->writeOccurrenceFile();
if ($status) {
$archiveFile = $this->targetPath . $fileName;
if (file_exists($archiveFile)) {
unlink($archiveFile);
}
$zipArchive = new ZipArchive();
$status = $zipArchive->open($archiveFile, ZipArchive::CREATE);
if ($status !== true) {
exit('FATAL ERROR: unable to create archive file: ' . $status);
}
//$this->logOrEcho("DWCA created: ".$archiveFile."\n");
//Occurrences
$zipArchive->addFile($this->targetPath . $this->ts . '-occur' . $this->fileExt);
$zipArchive->renameName($this->targetPath . $this->ts . '-occur' . $this->fileExt, 'occurrences' . $this->fileExt);
//Determination history
if ($this->includeDets) {
$this->writeDeterminationFile();
$zipArchive->addFile($this->targetPath . $this->ts . '-det' . $this->fileExt);
$zipArchive->renameName($this->targetPath . $this->ts . '-det' . $this->fileExt, 'identifications' . $this->fileExt);
}
//Images
if ($this->includeImgs) {
$this->writeImageFile();
$zipArchive->addFile($this->targetPath . $this->ts . '-images' . $this->fileExt);
$zipArchive->renameName($this->targetPath . $this->ts . '-images' . $this->fileExt, 'images' . $this->fileExt);
}
//Meta file
$this->writeMetaFile();
$zipArchive->addFile($this->targetPath . $this->ts . '-meta.xml');
$zipArchive->renameName($this->targetPath . $this->ts . '-meta.xml', 'meta.xml');
//EML file
$this->writeEmlFile();
$zipArchive->addFile($this->targetPath . $this->ts . '-eml.xml');
$zipArchive->renameName($this->targetPath . $this->ts . '-eml.xml', 'eml.xml');
$zipArchive->close();
unlink($this->targetPath . $this->ts . '-occur' . $this->fileExt);
if ($this->includeDets) {
unlink($this->targetPath . $this->ts . '-det' . $this->fileExt);
}
if ($this->includeImgs) {
unlink($this->targetPath . $this->ts . '-images' . $this->fileExt);
}
unlink($this->targetPath . $this->ts . '-meta.xml');
if ($this->schemaType == 'dwc') {
rename($this->targetPath . $this->ts . '-eml.xml', $this->targetPath . str_replace('.zip', '.eml', $fileName));
} else {
unlink($this->targetPath . $this->ts . '-eml.xml');
}
} else {
$errStr = "FAILED to create archive file. No records were located in this collection. If records exist, it may be that they don't have Symbiota GUID assignments. Have the portal manager run the GUID mapper (available in sitemap)";
$this->logOrEcho($errStr);
}
$this->logOrEcho("\n-----------------------------------------------------\n");
return $archiveFile;
}
示例5: upload_file
function upload_file($bookId, $name)
{
global $base;
global $st;
$uploadfile = $base . "docs/" . $bookId;
if (!mkdir($uploadfile) and !file_exists($uploadfile)) {
echo "<pre>" . translate('Problem creating directory', $st, 'sys') . " " . $uploadfile . "</pre>";
} else {
if (!chmod($uploadfile, 0777)) {
echo "<pre>" . translate('Problem setting permissions', $st, 'sys') . " " . $uploadfile . "</pre>";
} else {
$ext = substr($_FILES[$name]['name'], strrpos($_FILES[$name]['name'], '.'));
if ($ext == '.oxes' or $ext == '.OXES') {
$_FILES[$name]['name'] = 'upload.oxes';
}
if (!move_uploaded_file($_FILES[$name]['tmp_name'], $uploadfile . "/" . $_FILES[$name]['name'])) {
echo "<pre>" . translate('Problem uploading file', $st, 'sys') . " source: " . $_FILES[$name]['tmp_name'] . " dest: " . $uploadfile . "/" . $_FILES[$name]['name'] . "</pre>";
} else {
if (strtolower(substr($_FILES[$name]['name'], -4)) == '.zip') {
$znames = array();
$zip = new ZipArchive();
$res = $zip->open($uploadfile . "/" . $_FILES[$name]['name']);
if ($res === TRUE) {
for ($i = 0; $i < $zip->numFiles; $i++) {
$zname = $zip->getNameIndex($i);
if (strtolower(substr($zname, -4)) == '.jpg' or strtolower(substr($zname, -5)) == '.oxes') {
$zzname = $zname;
$pos = strrpos($zzname, "/");
if ($pos !== FALSE) {
$zzname = substr($zzname, $pos + 1);
}
correctExistingFiles($bookId, $zzname);
$zip->renameName($zname, $zzname);
$znames[] = $zzname;
}
}
$zip->extractTo($uploadfile . "/", $znames);
$zip->close();
unlink($uploadfile . "/" . $_FILES[$name]['name']);
} else {
echo "<pre>" . translate('file unzip failed', $st, 'sys');
}
} else {
correctExistingFiles($bookId, $_FILES[$name]['name']);
}
}
}
}
}
示例6: ssfa_file_manager
//.........这里部分代码省略.........
}
}
$response = $success == 0 ? 'There was a problem moving the files. Please consult your local ouija specialist.' : ($success == 1 ? "One lonesome file was forced to leave all it knew and move to {$destination}." : ($success > 1 ? "{$success} of {$total} files were magically transported to {$destination}. Or was it Delaware?" : null));
// bulk download action
} elseif ($action === 'bulkdownload') {
$files = stripslashes($_POST["files"]);
$files = explode('/*//*/', rtrim("{$files}", '/*//*/'));
$zipfiles = array();
$values = array();
foreach ($files as $file) {
$file = $remove_install ? ssfa_replace_first($install, '', $abspath . $file) : $abspath . $file;
if (file_exists($file)) {
$zipfiles[] = $file;
$values[] = basename($file);
}
}
$numvals = array_count_values($values);
$sitename = get_bloginfo('name');
$time = uniqid();
$destination = SSFA_PLUGIN . '/ssfatemp';
if (!is_dir($destination)) {
mkdir($destination);
}
$filename = $sitename . ' ' . $time . '.zip';
$link = SSFA_PLUGIN_URL . '/ssfatemp/' . $filename;
$filename = $destination . '/' . $filename;
if (count($zipfiles)) {
$zip = new ZipArchive();
$zip->open($filename, ZipArchive::CREATE);
foreach ($zipfiles as $k => $zipfile) {
$zip->addFile($zipfile, basename($zipfile));
if ($numvals[basename($zipfile)] > 1) {
$parts = pathinfo($zipfile);
$zip->renameName(basename($zipfile), $parts['filename'] . '_' . $k . '.' . $parts['extension']);
}
}
$zip->close();
}
$response = is_file($filename) ? $link : "Error";
// bulk delete action
} elseif ($action === 'bulkdelete') {
$files = $_POST['files'];
$files = explode('/*//*/', rtrim($files, '/*//*/'));
$success = 0;
$total = 0;
foreach ($files as $k => $file) {
$file = SSFA_ROOT === 'siteurl' ? $file : ($GLOBALS['ssfa_install'] ? ssfa_replace_first($GLOBALS['ssfa_install'], '', $file) : $file);
$total++;
if (is_file($abspath . $file)) {
unlink($abspath . $file);
}
if (!is_file($abspath . $file)) {
$success++;
}
}
$response = $success == 0 ? 'There was a problem deleting the files. Please try pressing your delete button emphatically and repeatedly.' : ($success == 1 ? "A million fewer files in the world is a victory. One less file, a tragedy. Farewell, file. Au revoir. Auf Wiedersehen. Adieu." : ($success > 1 ? "{$success} of {$total} files were sent plummeting to the nether regions of cyberspace. Or was it Delaware?" : null));
// delete action
} elseif ($action === 'delete') {
$pp = SSFA_ROOT === 'siteurl' ? $_POST['pp'] : ($GLOBALS['ssfa_install'] ? ssfa_replace_first($GLOBALS['ssfa_install'], '', $_POST['pp']) : $_POST['pp']);
$oldname = $_POST['oldname'];
$ext = $_POST['ext'];
$oldfile = $abspath . "{$pp}/{$oldname}.{$ext}";
if (is_file("{$oldfile}")) {
unlink("{$oldfile}");
}
if (!is_file("{$oldfile}")) {
示例7: createDwcArchive
public function createDwcArchive($fileNameSeed = '')
{
$status = false;
if (!$fileNameSeed) {
if (count($this->collArr) == 1) {
$firstColl = current($this->collArr);
if ($firstColl) {
$fileNameSeed = $firstColl['instcode'];
if ($firstColl['collcode']) {
$fileNameSeed .= '-' . $firstColl['collcode'];
}
}
if ($this->schemaType == 'backup') {
$fileNameSeed .= '_backup_' . $this->ts;
}
} else {
$fileNameSeed = 'SymbiotaOutput_' . $this->ts;
}
}
$fileName = str_replace(array(' ', '"', "'"), '', $fileNameSeed) . '_DwC-A.zip';
if (!$this->targetPath) {
$this->setTargetPath();
}
$archiveFile = '';
$this->logOrEcho('Creating DwC-A file: ' . $fileName . "\n");
if (!class_exists('ZipArchive')) {
$this->logOrEcho("FATAL ERROR: PHP ZipArchive class is not installed, please contact your server admin\n");
exit('FATAL ERROR: PHP ZipArchive class is not installed, please contact your server admin');
}
$status = $this->writeOccurrenceFile();
if ($status) {
$archiveFile = $this->targetPath . $fileName;
if (file_exists($archiveFile)) {
unlink($archiveFile);
}
$zipArchive = new ZipArchive();
$status = $zipArchive->open($archiveFile, ZipArchive::CREATE);
if ($status !== true) {
exit('FATAL ERROR: unable to create archive file: ' . $status);
}
//$this->logOrEcho("DWCA created: ".$archiveFile."\n");
//Occurrences
$zipArchive->addFile($this->targetPath . $this->ts . '-occur' . $this->fileExt);
$zipArchive->renameName($this->targetPath . $this->ts . '-occur' . $this->fileExt, 'occurrences' . $this->fileExt);
//Determination history
if ($this->includeDets) {
$this->writeDeterminationFile();
$zipArchive->addFile($this->targetPath . $this->ts . '-det' . $this->fileExt);
$zipArchive->renameName($this->targetPath . $this->ts . '-det' . $this->fileExt, 'identifications' . $this->fileExt);
}
//Images
if ($this->includeImgs) {
$this->writeImageFile();
$zipArchive->addFile($this->targetPath . $this->ts . '-images' . $this->fileExt);
$zipArchive->renameName($this->targetPath . $this->ts . '-images' . $this->fileExt, 'images' . $this->fileExt);
}
//Meta file
$this->writeMetaFile();
$zipArchive->addFile($this->targetPath . $this->ts . '-meta.xml');
$zipArchive->renameName($this->targetPath . $this->ts . '-meta.xml', 'meta.xml');
//EML file
$this->writeEmlFile();
$zipArchive->addFile($this->targetPath . $this->ts . '-eml.xml');
$zipArchive->renameName($this->targetPath . $this->ts . '-eml.xml', 'eml.xml');
$zipArchive->close();
unlink($this->targetPath . $this->ts . '-occur' . $this->fileExt);
if ($this->includeDets) {
unlink($this->targetPath . $this->ts . '-det' . $this->fileExt);
}
if ($this->includeImgs) {
unlink($this->targetPath . $this->ts . '-images' . $this->fileExt);
}
unlink($this->targetPath . $this->ts . '-meta.xml');
if ($this->schemaType == 'dwc') {
rename($this->targetPath . $this->ts . '-eml.xml', $this->targetPath . str_replace('.zip', '.eml', $fileName));
} else {
unlink($this->targetPath . $this->ts . '-eml.xml');
}
} else {
$errStr = "<span style='color:red;'>FAILED to create archive file due to failure to return occurrence records. " . "Note that OccurrenceID GUID assignments are required for Darwin Core Archive publishing. " . "Symbiota GUID (recordID) assignments are also required, which can be verified by the portal manager through running the GUID mapping utilitiy available in sitemap</span>";
$this->logOrEcho($errStr);
$collid = key($this->collArr);
if ($collid) {
$this->deleteArchive($collid);
}
unset($this->collArr[$collid]);
}
$this->logOrEcho("\n-----------------------------------------------------\n");
return $archiveFile;
}
示例8: manager
//.........这里部分代码省略.........
continue;
}
if (strpos($file, 'wp-admin') !== false) {
continue;
}
if (strpos($file, 'wp-includes') !== false) {
continue;
}
$file = $rootpath . stripslashes($file);
if (file_exists($file)) {
$zipfiles[] = $file;
$values[] = fileaway_utility::basename($file);
}
}
}
$numvals = array_count_values($values);
$prefix = isset($this->settings['download_prefix']) ? $this->settings['download_prefix'] : false;
$prefix = $prefix && $prefix !== '' ? $prefix : date('Y-m-d', current_time('timestamp'));
$time = uniqid();
$destination = fileaway_dir . '/temp';
if (!is_dir($destination)) {
mkdir($destination);
}
$filename = stripslashes($prefix) . ' ' . $time . '.zip';
$link = fileaway_url . '/temp/' . $filename;
$filename = $destination . '/' . $filename;
if (count($zipfiles)) {
$zip = new ZipArchive();
$zip->open($filename, ZipArchive::CREATE);
foreach ($zipfiles as $k => $zipfile) {
$zip->addFile($zipfile, fileaway_utility::basename($zipfile));
if ($numvals[fileaway_utility::basename($zipfile)] > 1) {
$parts = fileaway_utility::pathinfo($zipfile);
$zip->renameName(fileaway_utility::basename($zipfile), $parts['filename'] . '_' . $k . '.' . $parts['extension']);
}
}
$zip->close();
}
if ($stats == 'true' && count($zipfiles) > 0) {
$stat = new fileaway_stats();
$ifiles = array();
foreach ($zipfiles as $zfile) {
$zfile = fileaway_utility::replacefirst($zfile, $rootpath, '');
$ifiles[] = $zfile;
$stat->insert($zfile, false);
}
$current = wp_get_current_user();
if ($this->settings['instant_stats'] == 'true') {
$data = array('timestamp' => date('Y-m-d H:i:s', current_time('timestamp')), 'file' => count($ifiles) . ' ' . strtolower(_x('files', 'plural', 'file-away')), 'files' => "\r\n" . implode("\r\n", $ifiles), 'uid' => $current->ID, 'email' => $current->user_email, 'ip' => $_SERVER['REMOTE_ADDR'], 'agent' => $_SERVER['HTTP_USER_AGENT']);
$stat->imail($data);
}
}
$response = is_file($filename) ? $link : "Error";
} elseif ($action == 'bulkcopy') {
if (!$li) {
die($dm);
}
if (!wp_verify_nonce($_POST['manager_nonce'], 'fileaway-manager-nonce')) {
die($dm);
}
$from = $_POST['from'];
$to = $_POST['to'];
$ext = $_POST['exts'];
$destination = $problemchild ? fileaway_utility::replacefirst(stripslashes($_POST['destination']), $install, '') : stripslashes($_POST['destination']);
$success = 0;
$total = 0;
示例9: exec
$k++;
}
}
//echo $icon_name. '</br>';
}
}
if (isset($icon_atlas1)) {
for ($l = 1; $l <= $k; $l++) {
$icon_name = 'icon_atlas' . $l;
$dest256 = $iconsFolder . $_SESSION['UserPath'] . $_SESSION['Username'] . $timestamp . "_" . $icon_name . "_256.dds";
if (isset(${$icon_name})) {
$icon_uri_target = $dest256;
$command_str = $imageMagickConvert . " " . ${$icon_name} . " -define dds:compression=none -define dds:mipmaps=false " . $icon_uri_target;
exec($command_str);
$zip->addFile($dest256);
$zip->renameName($dest256, $timestamp . "_" . $icon_name . "_256.dds");
$dest128 = $iconsFolder . $_SESSION['UserPath'] . $_SESSION['Username'] . $timestamp . "_" . $icon_name . "_128.dds";
$icon_uri_target = $dest128;
$command_str = $imageMagickConvert . " " . ${$icon_name} . " -resize 1024x1024 -define dds:compression=none -define dds:mipmaps=false " . $icon_uri_target;
exec($command_str);
$zip->addFile($dest128);
$zip->renameName($dest128, $timestamp . "_" . $icon_name . "_128.dds");
$dest80 = $iconsFolder . $_SESSION['UserPath'] . $_SESSION['Username'] . $timestamp . "_" . $icon_name . "_80.dds";
$icon_uri_target = $dest80;
$command_str = $imageMagickConvert . " " . ${$icon_name} . " -resize 640x640 -define dds:compression=none -define dds:mipmaps=false " . $icon_uri_target;
exec($command_str);
$zip->addFile($dest80);
$zip->renameName($dest80, $timestamp . "_" . $icon_name . "_80.dds");
$dest64 = $iconsFolder . $_SESSION['UserPath'] . $_SESSION['Username'] . $timestamp . "_" . $icon_name . "_64.dds";
$icon_uri_target = $dest64;
$command_str = $imageMagickConvert . " " . ${$icon_name} . " -resize 512x512 -define dds:compression=none -define dds:mipmaps=false " . $icon_uri_target;
示例10: foreach
continue;
}
$ob->out($item->getPathname() . ' => ' . $dest . "\n");
$zip->addFile($item->getPathname(), Backup::encode($dest));
}
foreach ($installIterator as $item) {
if ($item->isDir()) {
continue;
}
$dest = str_replace($installFolder . DIRECTORY_SEPARATOR, '', 'installation' . DIRECTORY_SEPARATOR . $item->getPathname());
$ob->out($item->getPathname() . ' => ' . $dest . "\n");
$zip->addFile($item->getPathname(), str_replace('\\', '/', $dest));
}
$zip->addFile($backupSQLFile->getPathname(), $backupSQLFile->getBasename());
$zip->deleteName('configuration.dist.php');
$zip->renameName('configuration.php', 'configuration.dist.php');
$zip->close();
echo 'ZIP ok';
} else {
echo 'failed';
}
?>
</pre>
<script>
toBottom();
stop = true;
</script>
<?php
$ob->endClean();
示例11: renameFiles
/**
* ====================================================================
* RENAME FILE(S) INSIDE A ZIP FILE
* ====================================================================
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* --------- | ----- | -----------------------------------------------
* $old | array | Array of old file name and new file name
* --------- | ----- | -----------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function renameFiles($old, $new = "")
{
$zip = new ZipArchive();
if (File::exist(self::$open) && $zip->open(self::$open)) {
if (is_array($old)) {
foreach ($old as $k => $v) {
$k = File::path($k);
$v = File::path($v);
$root = trim(File::D($k), DS . '.') !== "" ? File::D($k) . DS : "";
$zip->renameName($k, $root . File::B($v));
}
} else {
$old = File::path($old);
$root = trim(File::D($old), DS . '.') !== "" ? File::D($old) . DS : "";
$zip->renameName($old, $root . File::B($new));
}
$zip->close();
}
return new static();
}
示例12: _extractWithZipArchiveClass
/**
* ZipArchiveクラスを利用した解凍
*
* @param string $path Zipファイルパス
* @return bool
*/
protected function _extractWithZipArchiveClass($path)
{
$encodeCharset = "UTF-8";
// server os のファイルシステム文字コード
mb_language('Japanese');
setlocale(LC_ALL, 'ja_JP.UTF-8');
// スレッドセーフじゃないので直前で
$zip = new ZipArchive();
$result = $zip->open($this->_zipPath);
if ($result !== true) {
return false;
}
if ($this->_password) {
$zip->setPassword($this->_password);
}
$index = 0;
while ($zipEntry = $zip->statIndex($index)) {
$zipEntryName = $zipEntry['name'];
$destName = mb_convert_encoding($zipEntry['name'], $encodeCharset, 'auto');
if ($zip->renameName($zipEntryName, $destName) === false) {
return false;
}
if ($zip->extractTo($path, $destName) === false) {
return false;
}
if ($zip->renameName($destName, $zipEntryName) === false) {
return false;
}
$index++;
}
$zip->close();
return true;
}
示例13: get_zipball
/**
* GitHub decides on the root directory in the zipball, but we might disagree.
*
* @since 1.0
*/
public function get_zipball()
{
add_filter('http_request_args', array($this, 'add_http_args'), 10, 2);
$zipball = download_url($this->get_api_url('/repos/:owner/:repo/:archive_format'));
remove_filter('http_request_args', array($this, 'add_http_args'));
if (is_wp_error($zipball)) {
$this->return_404();
}
$z = new ZipArchive();
if (true === $z->open($zipball)) {
$length = strlen($z->getNameIndex(0));
$status = true;
for ($i = 0; $i < $z->numFiles; $i++) {
$name = $z->getNameIndex($i);
if (!$name) {
$status = false;
}
$newname = substr_replace($name, $this->config->repo, 0, $length - 1);
if (!$z->renameName($name, $newname)) {
$status = false;
}
}
$z->close();
if ($status) {
header('Content-Disposition: attachment; filename=' . $this->config->repo . '.zip');
header('Content-Type: application/zip');
header('Content-Length: ' . filesize($zipball));
ob_clean();
flush();
readfile($zipball);
unlink($zipball);
exit;
}
}
unlink($zipball);
$this->return_404();
}
示例14: RawInputFile
public function RawInputFile($FileName, $FileType, $Fields, $SkipLines, $FileCategory, $MergeFieldNumber, $UPCFieldName, $OuterJoin, $TrimData = FALSE, $FileToExtract = NULL, $KeepOldFile = FALSE)
{
// Error Checking of parameters
if (!is_readable($FileName)) {
trigger_error("Filename {$FileName} does not exist or cannot be read", E_USER_ERROR);
}
if (in_array($FileType, $this->ValidFileTypes) === FALSE) {
trigger_error("Invalid file type passed, {$FileType}", E_USER_ERROR);
}
if (!is_array($Fields)) {
trigger_error("The fields parameter must be an array, {$Fields} passed", E_USER_ERROR);
}
if (!is_numeric($SkipLines)) {
trigger_error("SkipLines must be numeric, {$SkipFirst} passed", E_USER_ERROR);
}
if (strlen($FileCategory) == 0) {
trigger_error("FileType parameter is required", E_USER_ERROR);
}
// Erase the supplier errors table
$sqlStmt = "delete from Supplier_Errors where Supplier_Party_ID = '{$this->PartyID}'";
$this->FeedsDbObj->DeleteRow($sqlStmt);
echo "Input file for {$FileCategory} is {$FileName}\n";
// Store the file specifications
if (is_null($this->UPCFieldName)) {
$this->UPCFieldName = $UPCFieldName;
}
if (isset($this->FileCategories[$FileCategory])) {
$this->FileCategories[$FileCategory]++;
} else {
$this->FileCategories[$FileCategory] = 1;
}
$newFile = tempnam(Config::getTmpDir(), "{$this->PartyID}-");
if (asort($Fields) === FALSE) {
trigger_error("Unable to sort fields array", E_USER_ERROR);
}
if ($this->IsMiniMSRP === FALSE && $this->GenericFeed === FALSE && $this->MiniFeed === FALSE && $KeepOldFile === FALSE) {
$this->FilesToPurge[$FileName] = NULL;
}
$this->FilesToPurge[$newFile] = NULL;
if (substr($FileType, 0, 3) == "ZIP") {
$zip = new ZipArchive();
if ($zip->open($FileName, ZipArchive::CREATE) !== TRUE) {
trigger_error("Could not open the Zip File Archive {$FileName}", E_USER_ERROR);
}
// Get filename only, ignore rest of path
$newFileName = pathinfo($newFile, PATHINFO_BASENAME);
if (is_numeric($FileToExtract)) {
$zip->renameIndex($FileToExtract, $newFileName);
} else {
$zip->renameName($FileToExtract, $newFileName);
}
$UnZipDir = Config::getTmpDir() . "/";
if ($zip->extractTo($UnZipDir, $newFileName) === FALSE) {
trigger_error("Could not unzip the Zip File Archive {$FileName} file {$newFileName}", E_USER_ERROR);
}
$zip->close();
$FileName = $newFile;
$newFile = tempnam(Config::getTmpDir(), "{$this->PartyID}-");
$this->FilesToPurge[$newFile] = NULL;
}
// Based on the file type, we will convert to CSV and remove headers.
switch ($FileType) {
case "XLS":
$newFile = $this->HandleXLSFile($FileName, $newFile, $Fields, $SkipLines, $TrimData);
break;
case "ZIPCSV":
case "CSV":
$newFile = $this->HandleCSVFile($FileName, $newFile, $Fields, $SkipLines, $TrimData);
break;
case "DBF":
case "ZIPDBF":
$newFile = $this->HandleDBFFile($FileName, $newFile, $Fields, $SkipLines, $TrimData);
break;
case "TAB":
case "ZIPTAB":
$newFile = $this->HandleTabFile($FileName, $newFile, $Fields, $SkipLines, $TrimData, FALSE);
break;
case "TABQ":
case "ZIPTABQ":
$newFile = $this->HandleTabFile($FileName, $newFile, $Fields, $SkipLines, $TrimData, TRUE);
break;
case "BAR":
case "ZIPBAR":
$newFile = $this->HandleDelimitedFile($FileName, $newFile, $Fields, $SkipLines, "|", $TrimData);
break;
case "TIL":
case "ZIPTIL":
$newFile = $this->HandleDelimitedFile($FileName, $newFile, $Fields, $SkipLines, "~", $TrimData);
break;
case "FIXED":
case "ZIPFIXED":
$newFile = $this->HandleFixedFile($FileName, $newFile, $Fields, $SkipLines, $TrimData);
}
// Re-sequence the columns
// For fixed file format, we have to redo the fields array since it is not a list of fields. It's a list of starting positions:length
$i = 1;
foreach ($Fields as $Key => $Value) {
if ($FileType == "FIXED" || $FileType == "ZIPFIXED") {
if ($i == $MergeFieldNumber) {
$MergeFieldNumber = $i;
//.........这里部分代码省略.........
示例15: loadImportExportTemplates
/**
* Private: Import/Export Templates
* Import/Export templates by XML
*
* @return void
*/
private function loadImportExportTemplates()
{
if ($_GET['process']) {
switch ($_GET['process']) {
case "import":
if (empty($_FILES['FileUpload']['name']) && empty($_POST['FilePath'])) {
$GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['SelectFile'];
$GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
} else {
$break = FALSE;
$uploaded = FALSE;
$is_zip = FALSE;
if (!empty($_FILES['FileUpload']['name'])) {
$type = $_FILES['FileUpload']['type'];
$is_zip = $type == "application/x-gzip" || $type == "application/gzip" ? "gzip" : ($type == "application/zip" ? "zip" : "none");
if ($type != "text/xml" && $type != "application/x-gzip" && $type != "application/gzip" && $type != "application/zip") {
$GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['InvalidFile'];
$GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
$break = TRUE;
} else {
$filepath = CTM_CACHE_PATH . "temp_cache/" . md5(time() . "&ew_template_temp_file&" . mt_rand()) . ".tmp";
if (!copy($_FILES['FileUpload']['tmp_name'], $filepath)) {
$GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UploadError'];
$GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
$break = TRUE;
} else {
$uploaded = TRUE;
}
}
} else {
$filepath = CTM_ROOT_PATH . $_POST['FilePath'];
$find_end = strrpos($filepath, ".");
$file_end = substr($filepath, $find_end + 1);
if (!file_exists($filepath)) {
$GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['FileNoExists'];
$GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
$break = TRUE;
} elseif ($file_end != "xml" && $file_end != "gz" && $file_end != "zip") {
$GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['InvalidFile'];
$GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
$break = TRUE;
} else {
$is_zip = $file_end == "gz" ? "gzip" : ($file_end == "zip" ? "zip" : NULL);
}
}
if ($is_zip == "gzip" && $break == false) {
if (!function_exists("gzopen") || !function_exists("gzread") || !function_exists("gzclose")) {
$GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError'];
$GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
$break = TRUE;
} else {
if ($gzip = gzopen($filepath, "r")) {
$tmp_path = CTM_CACHE_PATH . "temp_cache/" . md5(time() . "&" . EffectWebFiles::TEMPLATE_XML_FILENAME . "&" . mt_rand()) . ".tmp";
$gz_content = gzread($gzip, filesize($filepath) * 2);
gzclose($gzip);
if ($uploaded == true) {
unlink($filepath);
}
$fp = fopen($tmp_path, "w");
fwrite($fp, $gz_content);
fclose($fp);
} else {
$GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError'];
$GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
$break = TRUE;
}
}
} elseif ($is_zip == "zip" && $break == false) {
if (!class_exists("ZipArchive")) {
$GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError'];
$GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
$break = TRUE;
} else {
$zip = new ZipArchive();
if ($zip->open($filepath)) {
$filename = md5(time() . "&" . EffectWebFiles::TEMPLATE_XML_FILENAME . "&" . mt_rand()) . ".tmp";
$tmp_path = CTM_CACHE_PATH . "temp_cache/" . $filename;
$zip->renameName(EffectWebFiles::TEMPLATE_XML_FILENAME, $filename);
$zip->extractTo(CTM_CACHE_PATH . "temp_cache/", array($filename));
$zip->renameName($filename, EffectWebFiles::TEMPLATE_XML_FILENAME);
$zip->close();
if ($uploaded == true) {
unlink($filepath);
}
} else {
$GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError'];
$GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
$break = TRUE;
}
}
} else {
$tmp_path = $filepath;
}
if ($break == false) {
//.........这里部分代码省略.........