本文整理汇总了PHP中Varien_Io_File::rm方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Io_File::rm方法的具体用法?PHP Varien_Io_File::rm怎么用?PHP Varien_Io_File::rm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Io_File
的用法示例。
在下文中一共展示了Varien_Io_File::rm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rotateLogs
/**
* Rotate all files in var/log which ends with .log
*/
public function rotateLogs()
{
$var = Mage::getBaseDir('log');
$logDir = new Varien_Io_File();
$logDir->cd($var);
$logFiles = $logDir->ls(Varien_Io_File::GREP_FILES);
foreach ($logFiles as $logFile) {
if ($logFile['filetype'] == 'log') {
$filename = $logFile['text'];
if (extension_loaded('zlib')) {
$zipname = $var . DS . $this->getArchiveName($filename);
$zip = gzopen($zipname, 'wb9');
gzwrite($zip, $logDir->read($filename));
gzclose($zip);
} else {
$logDir->cp($filename, $this->getArchiveName($filename));
}
foreach ($this->getFilesOlderThan(self::MAX_FILE_DAYS, $var, $filename) as $oldFile) {
$logDir->rm($oldFile['text']);
}
$logDir->rm($filename);
}
}
$logDir->close();
}
示例2: export
/**
* Export function:
* - Returns false, if an error occured or if there are no orders to export
* - Returns array, containing the filename and the file contents
*
* @return bool|array
*/
public function export()
{
$collection = $this->_hasOrdersToExport();
if (!$collection) {
return false;
}
$fileName = $this->getFileName();
// Open file
$file = new Varien_Io_File();
$file->open(array('path' => Mage::getBaseDir('var')));
$file->streamOpen($fileName);
// Add headline
$row = array('Kundenname', 'BLZ', 'Kontonummer', 'BIC/Swift-Code', 'IBAN', 'Betrag', 'Verwendungszweck');
$file->streamWriteCsv($row);
// Add rows
foreach ($collection as $order) {
/* @var $orderModel Mage_Sales_Model_Order */
$orderModel = Mage::getModel('sales/order')->load($order->getData('entity_id'));
/* @var $paymentMethod Itabs_Debit_Model_Debit */
$paymentMethod = $orderModel->getPayment()->getMethodInstance();
// Format order amount
$amount = number_format($order->getData('grand_total'), 2, ',', '.');
$row = array('name' => $paymentMethod->getAccountName(), 'bank_code' => $paymentMethod->getAccountBLZ(), 'account_number' => $paymentMethod->getAccountNumber(), 'account_swift' => $paymentMethod->getAccountSwift(), 'account_iban' => $paymentMethod->getAccountIban(), 'amount' => $amount . ' ' . $order->getData('order_currency_code'), 'purpose' => 'Bestellung Nr. ' . $order->getData('increment_id'));
$file->streamWriteCsv($row);
$this->_getDebitHelper()->setStatusAsExported($order->getId());
}
// Close file, get file contents and delete temporary file
$file->close();
$filePath = Mage::getBaseDir('var') . DS . $fileName;
$fileContents = file_get_contents($filePath);
$file->rm($fileName);
$response = array('file_name' => $fileName, 'file_content' => $fileContents);
return $response;
}
示例3: uploadFile
/**
* Upload file to CDN async
*/
public function uploadFile()
{
$adapter = Mage::getModel('mycdn/adapter');
if (!$adapter) {
return;
}
$ioObject = new Varien_Io_File();
$ioObject->setAllowCreateFolders(true);
$ioObject->open(array('path' => $ioObject->dirname($this->getData('filename'))));
if (!$ioObject->fileExists($this->getData('filename'), true)) {
Mage::helper('mycdn')->addLog('[CRON] No file ' . $this->getData('filename'));
$this->delete();
return;
}
//Mage::helper('mycdn')->addLog('[CRON] processing id = ' . $this->getId());
//Mage::helper('mycdn')->addLog($this->getData());
$result = $adapter->uploadFile($this->getData('filename'), $this->getData('uploadname'), $this->getData('content_type'));
if ($result && $this->getData('delete')) {
$ioObject->rm($this->getData('filename'));
Mage::helper('mycdn')->addLog('[DELETE] CRON delete for ' . $this->getData('filename'));
}
if ($result) {
Mage::helper('mycdn')->addLog('[JOB] CRON delete job for ' . $this->getData('filename') . "\n");
$this->delete();
}
}
示例4: uninstall
final function uninstall(Varien_Event_Observer $observer)
{
$module = $observer->getEvent()->getModule();
if (0 !== strpos(get_class($this), $module)) {
return false;
}
$this->run();
$manifestPath = str_replace('_', '/', $module) . '/etc/manifest.xml';
foreach (explode(PS, get_include_path()) as $includePath) {
if (file_exists($includePath . DS . $manifestPath)) {
$manifestPath = $includePath . DS . $manifestPath;
break;
}
}
if (!file_exists($manifestPath)) {
throw new Exception('Manifest path "' . $manifestPath . '" does not exist');
}
$manifestXml = new SimpleXMLElement($manifestPath, null, true);
$paths = $manifestXml->xpath('/manifest/' . $module . '/paths/path');
$file = new Varien_Io_File();
foreach ($paths as $path) {
$path = BP . DS . $path;
if (file_exists($path)) {
if (is_dir($path)) {
$file->rmdir($path, true);
} else {
$file->rm($path);
}
}
}
$this->_removeResources($module);
}
示例5: removeImage
/**
* Remove item image by image filename
*
* @param string $imageFile
* @return bool
*/
public function removeImage($imageFile)
{
$io = new Varien_Io_File();
$io->open(array('path' => $this->getBaseDir()));
if ($io->fileExists($imageFile)) {
return $io->rm($imageFile);
}
return false;
}
示例6: saveAction
public function saveAction()
{
$post_data = $this->getRequest()->getPost();
if ($post_data) {
try {
$post_data['category'] = implode(',', $post_data['category']);
//save image
try {
if ((bool) $post_data['image']['delete'] == 1) {
$post_data['image'] = '';
} else {
unset($post_data['image']);
if (isset($_FILES)) {
if ($_FILES['image']['name']) {
if ($this->getRequest()->getParam("id")) {
$model = Mage::getModel("gallery/image")->load($this->getRequest()->getParam("id"));
if ($model->getData('image')) {
$io = new Varien_Io_File();
$io->rm(Mage::getBaseDir('media') . DS . implode(DS, explode('/', $model->getData('image'))));
}
}
$path = Mage::getBaseDir('media') . DS . 'gallery' . DS . 'image' . DS;
$uploader = new Varien_File_Uploader('image');
$uploader->setAllowedExtensions(array('jpg', 'png', 'gif'));
$uploader->setAllowRenameFiles(false);
$uploader->setFilesDispersion(false);
$destFile = $path . $_FILES['image']['name'];
$filename = $uploader->getNewFileName($destFile);
$uploader->save($path, $filename);
$post_data['image'] = 'gallery/image/' . $filename;
}
}
}
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
return;
}
//save image
$model = Mage::getModel("gallery/image")->addData($post_data)->setId($this->getRequest()->getParam("id"))->save();
Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Image was successfully saved"));
Mage::getSingleton("adminhtml/session")->setImageData(false);
if ($this->getRequest()->getParam("back")) {
$this->_redirect("*/*/edit", array("id" => $model->getId()));
return;
}
$this->_redirect("*/*/");
return;
} catch (Exception $e) {
Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
Mage::getSingleton("adminhtml/session")->setImageData($this->getRequest()->getPost());
$this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
return;
}
}
$this->_redirect("*/*/");
}
示例7: _beforeSave
/**
* Save uploaded file before saving config value
*
* Save changes and delete file if "delete" option passed
*
* @return Codewix_Logo_Model_System_Config_Backend_Logo
*/
protected function _beforeSave()
{
$value = $this->getValue();
$deleteFlag = is_array($value) && !empty($value['delete']);
$fileTmpName = $_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'];
if ($this->getOldValue() && ($fileTmpName || $deleteFlag)) {
$io = new Varien_Io_File();
$io->rm($this->_getUploadRoot(self::UPLOAD_ROOT_TOKEN) . DS . self::UPLOAD_DIR . DS . $this->getOldValue());
}
return parent::_beforeSave();
}
示例8: refreshStatus
public function refreshStatus($observer)
{
ob_start();
$product = split("_", $observer['event']['name']);
$product = $product[count($product) - 1];
// remove old local key
$dir = Mage::getBaseDir("var") . DS . "smartosc" . DS . strtolower(substr('X-MultiVendor Basic', 0, 5)) . DS;
$filepath = $dir . "license.dat";
$file = new Varien_Io_File();
$file->rm($filepath);
if (Mage::helper('smcore')->checkLicense('X-MultiVendor Basic', Mage::getStoreConfig($product . '/general/key'), true)) {
Mage::getModel('core/config')->saveConfig($product . '/general/enable', "1");
} else {
Mage::getModel('core/config')->saveConfig($product . '/general/enable', "0");
}
Mage::getConfig()->cleanCache();
}
示例9: refreshStatus
public function refreshStatus($observer)
{
ob_start();
$product = split("_", $observer['event']['name']);
$product = $product[count($product) - 1];
if ($product == "barcode") {
$product2 = SM_Barcode_Helper_Abstract::PRODUCT;
} else {
$product2 = $product;
}
// remove old local key
$dir = Mage::getBaseDir("var") . DS . "smartosc" . DS . strtolower(substr($product2, 0, 5)) . DS;
$filepath = $dir . "license.dat";
$file = new Varien_Io_File();
$file->rm($filepath);
Mage::helper('smcore')->checkLicense($product2, Mage::getStoreConfig($product . '/general/key'), true);
Mage::getConfig()->cleanCache();
}
示例10: deleteExtensionFolderFiles
/**
* Deletes all extension folders and the app/etc/modules config file.
*/
public function deleteExtensionFolderFiles()
{
$namespacePath = $this->_getNamespacePath();
$extensionPath = $this->_getExtensionPath();
try {
$this->_filesystem->rmdir($extensionPath, true);
if (is_dir($namespacePath)) {
$this->_filesystem->cd($namespacePath);
if (count($this->_filesystem->ls()) == 0) {
$this->_filesystem->rmdir($namespacePath, true);
}
}
$modulesConfigFile = $this->_namespace . '_' . $this->_extensionName . '.xml';
$modulesConfigFilePath = $this->_helper->getModulesConfigDir() . DS . $modulesConfigFile;
if (file_exists($modulesConfigFilePath)) {
$this->_filesystem->rm($modulesConfigFilePath);
}
} catch (Exception $e) {
Mage::log($e->getMessage(), null, $this->_helper->getLogFilename());
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
}
示例11: _copyImage
protected function _copyImage($file)
{
try {
$ioObject = new Varien_Io_File();
$destDirectory = dirname($this->_getConfig()->getMediaPath($file));
$ioObject->open(array('path' => $destDirectory));
$destFile = $this->_getUniqueFileName($file, $ioObject->dirsep());
if (!$ioObject->fileExists($this->_getConfig()->getMediaPath($file), true)) {
throw new Exception('File not exists');
}
if ($this->_checkDb()) {
Mage::helper('core/file_storage_database')->copyFile($this->_getConfig()->getMediaShortUrl($file), $this->_getConfig()->getMediaShortUrl($destFile));
$ioObject->rm($this->_getConfig()->getMediaPath($destFile));
} else {
$ioObject->cp($this->_getConfig()->getMediaPath($file), $this->_getConfig()->getMediaPath($destFile));
}
} catch (Exception $e) {
$file = $this->_getConfig()->getMediaPath($file);
Mage::throwException(Mage::helper('ampaction')->__('Failed to copy file %s. Please, delete media with non-existing images and try again.', $file));
$e = $e;
// for zend debugger
}
return str_replace($ioObject->dirsep(), '/', $destFile);
}
示例12: generateFile
public function generateFile()
{
$x114 = "preg_split";
$x115 = "implode";
$x116 = "str_replace";
$x117 = "utf8_encode";
$x118 = "preg_match_all";
$x119 = "preg_match";
$x11a = "rtrim";
$x11b = "is_null";
$x11c = "count";
$x11d = "is_numeric";
$x11e = "explode";
$x11f = "substr";
$x120 = "trim";
$x121 = "strlen";
$x122 = "htmlentities";
$x123 = "html_entity_decode";
$x124 = "preg_replace";
$x125 = "json_decode";
$x126 = "is_array";
$x127 = "stristr";
$x128 = "print_r";
$x129 = "is_string";
$x12a = "ucwords";
$x12b = "array_push";
$x12c = "version_compare";
$x12d = "in_array";
$x12e = "sprintf";
$x12f = "array_pop";
$x130 = "ceil";
$x131 = "ini_get";
$x132 = "set_time_limit";
$x133 = "number_format";
$x134 = "strip_tags";
$x135 = "htmlspecialchars";
$x136 = "strrpos";
$x137 = "is_bool";
$x138 = "mb_strtolower";
$x139 = "mb_strtoupper";
$x13a = "ftp_connect";
$x13b = "ftp_login";
$x13c = "ftp_pasv";
$x13d = "ftp_put";
$x13e = "ftp_close";
ini_set('memory_limit', Mage::getStoreConfig("datafeedmanager/system/memory_limit") . 'M');
error_reporting(Mage::getStoreConfig("datafeedmanager/system/error_reporting"));
$this->_debug = isset($_GET['debug']) ? true : false;
$this->_log = Mage::getStoreConfig("datafeedmanager/system/log_enabled");
if ($this->_debug) {
echo "----------------------------------------------<br>------------ DEBUG MODE ----------------<br>----------------------------------------------<br><br>";
$x128($x66);
}
$x67 = $this->_indexPhp;
$x68 = array("ac" => "activation_code", "ak" => "activation_key", "bu" => "base_url", "md" => "md5", "th" => "this", "dm" => "_demo", "ext" => "dfm", "ver" => "6.5.0");
$x129(Mage::app()->getRequest()->getParam("store_id")) ? $x69 = Mage::app()->getRequest()->getParam("store_id") : ($x69 = $this->getStoreId());
$x6a = Mage::getSingleton('core/date')->gmtDate('Y-m-d');
$x6b = Mage::getDesign()->getSkinUrl();
$x6c = Mage::getStoreConfig("catalog/placeholder/image_placeholder", $x69);
$x6d = Mage::getStoreConfig("currency/options/base", $x69);
$x6e = Mage::getStoreConfig("cataloginventory/item_options/manage_stock", $x69);
$x6f = Mage::getStoreConfig("cataloginventory/item_options/backorders", $x69);
$x70 = Mage::app()->getStore($x69)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, false);
$x71 = Mage::getModel('core/store')->load($x69)->getBaseUrl();
$x72 = Mage::app()->getStore($x69)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA, false);
$x73 = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $x69);
$x74 = Mage::app()->getStore($x69)->getRootCategoryId();
$x75 = array("activation_key" => Mage::getStoreConfig("datafeedmanager/license/activation_key"), "activation_code" => Mage::getStoreConfig("datafeedmanager/license/activation_code"), "base_url" => Mage::getStoreConfig("web/secure/base_url"));
$x129(Mage::app()->getRequest()->getParam("feed_product")) ? $x76 = Mage::app()->getRequest()->getParam("feed_product") : ($x76 = $this->getFeed_product());
$x129(Mage::app()->getRequest()->getParam("feed_header")) ? $x63 = Mage::app()->getRequest()->getParam("feed_header") : ($x63 = $this->getFeed_header());
$x129(Mage::app()->getRequest()->getParam("feed_footer")) ? $x77 = Mage::app()->getRequest()->getParam("feed_footer") : ($x77 = $this->getFeed_footer());
$x129(Mage::app()->getRequest()->getParam("feed_type")) ? $x78 = Mage::app()->getRequest()->getParam("feed_type") : ($x78 = $this->getFeed_type());
$x129(Mage::app()->getRequest()->getParam("feed_extraheader")) ? $x79 = Mage::app()->getRequest()->getParam("feed_extraheader") : ($x79 = $this->getFeed_extraheader());
$x129(Mage::app()->getRequest()->getParam("feed_include_header")) ? $x7a = Mage::app()->getRequest()->getParam("feed_include_header") : ($x7a = $this->getFeed_include_header());
$x129(Mage::app()->getRequest()->getParam("feed_separator")) ? $x5e = Mage::app()->getRequest()->getParam("feed_separator") : ($x5e = $this->getFeed_separator());
$x129(Mage::app()->getRequest()->getParam("feed_protector")) ? $x5f = Mage::app()->getRequest()->getParam("feed_protector") : ($x5f = $this->getFeed_protector());
$x129(Mage::app()->getRequest()->getParam("feed_escape")) ? $x60 = Mage::app()->getRequest()->getParam("feed_escape") : ($x60 = $this->getFeed_escape());
$x129(Mage::app()->getRequest()->getParam("feed_satus")) ? $x7b = Mage::app()->getRequest()->getParam("feed_satus") : ($x7b = $this->getFeed_status());
$x129(Mage::app()->getRequest()->getParam("feed_enclose_data")) ? $x7c = Mage::app()->getRequest()->getParam("feed_enclose_data") : ($x7c = $this->getFeed_enclose_data());
$x129(Mage::app()->getRequest()->getParam("feed_clean_data")) ? $x7d = Mage::app()->getRequest()->getParam("feed_clean_data") : ($x7d = $this->getFeed_clean_data());
$x129(Mage::app()->getRequest()->getParam("datafeedmanager_categories")) ? $x7e = $x125(Mage::app()->getRequest()->getParam("datafeedmanager_categories")) : ($x7e = $x125($this->getDatafeedmanagerCategories()));
$x129(Mage::app()->getRequest()->getParam("datafeedmanager_category_filter")) ? $x7f = Mage::app()->getRequest()->getParam("datafeedmanager_category_filter") : ($x7f = $this->getDatafeedmanagerCategoryFilter());
$x129(Mage::app()->getRequest()->getParam("datafeedmanager_categories")) ? $x66 = Mage::app()->getRequest()->getParam("datafeedmanager_categories") : ($x66 = $this->getDatafeedmanagerCategories());
$x129(Mage::app()->getRequest()->getParam("feed_encoding")) ? $this->_feed_encoding = Mage::app()->getRequest()->getParam("feed_encoding") : ($this->_feed_encoding = $this->getFeed_encoding());
$x80 = $this->getFtpEnabled();
$x81 = $this->getFtpHost();
$x82 = $this->getFtpLogin();
$x83 = $this->getFtpPassword();
$x84 = $this->getFtpDir();
$x85 = $this->getFtpActive();
$x86 = array();
$x87 = array();
if ($x66 != '*' && $x126($x7e)) {
foreach ($x7e as $x88) {
if ($x88->checked) {
$x86[] = $x88->line;
}
}
foreach ($x7e as $x88) {
if ($x88->mapping != "") {
//.........这里部分代码省略.........
示例13: _deleteImageFiles
/**
* Remove all image files
*
* @param string $imageFile
* @param bool $deleteOriginal
* @return Mage_XmlConnect_Model_Images
*/
protected function _deleteImageFiles($imageFile, $deleteOriginal = true)
{
$convertedImageFile = $this->_convertFileExtensionToPng($imageFile);
$ioAdapter = new Varien_Io_File();
$baseImageDir = Mage::helper('xmlconnect/image')->getMediaPath('custom');
if (is_dir($baseImageDir)) {
$dirArray = array_diff(scandir($baseImageDir), array('.', '..'));
foreach ($dirArray as $item) {
if (!is_dir($baseImageDir . DS . $item)) {
continue;
}
$ioAdapter->rm($baseImageDir . DS . $item . DS . basename($convertedImageFile));
}
}
if ($deleteOriginal) {
$ioAdapter->rm(self::getBasePath() . DS . basename($imageFile));
}
return $this;
}
示例14: deleteFile
/**
* Delete file
*
* @param string $targetPath File path to be deleted
* @return boolean
*/
public function deleteFile($targetPath)
{
$result = false;
$io = new Varien_Io_File();
if ($io->fileExists($targetPath)) {
$result = $io->rm($targetPath);
}
return $result;
}
示例15: deleteFile
/**
* Delete file (and its thumbnail if exists) from storage
*
* @param string $target File path to be deleted
* @return Mage_Cms_Model_Wysiwyg_Images_Storage
*/
public function deleteFile($target)
{
$io = new Varien_Io_File();
$io->rm($target);
Mage::helper('core/file_storage_database')->deleteFile($target);
$thumb = $this->getThumbnailPath($target, true);
if ($thumb) {
$io->rm($thumb);
Mage::helper('core/file_storage_database')->deleteFile($thumb);
}
return $this;
}