本文整理汇总了PHP中Varien_Io_File::streamStat方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Io_File::streamStat方法的具体用法?PHP Varien_Io_File::streamStat怎么用?PHP Varien_Io_File::streamStat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Io_File
的用法示例。
在下文中一共展示了Varien_Io_File::streamStat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewfileAction
public function viewfileAction()
{
$file = null;
$plain = false;
if ($this->getRequest()->getParam('file')) {
// download file
$file = Mage::helper('core')->urlDecode($this->getRequest()->getParam('file'));
} else {
if ($this->getRequest()->getParam('image')) {
// show plain image
$file = Mage::helper('core')->urlDecode($this->getRequest()->getParam('image'));
$plain = true;
} else {
return $this->norouteAction();
}
}
if (strpos($file, 'medma_avatar') !== false) {
$path = Mage::getBaseDir('media') . DS . 'medma_avatar' . DS;
} else {
$path = Mage::getBaseDir('media') . DS . 'customer';
}
$ioFile = new Varien_Io_File();
$ioFile->open(array('path' => $path));
$fileName = $ioFile->getCleanPath($path . $file);
$path = $ioFile->getCleanPath($path);
if ((!$ioFile->fileExists($fileName) || strpos($fileName, $path) !== 0) && !Mage::helper('core/file_storage')->processStorageFile(str_replace('/', DS, $fileName))) {
return $this->norouteAction();
}
if ($plain) {
$extension = pathinfo($fileName, PATHINFO_EXTENSION);
switch (strtolower($extension)) {
case 'gif':
$contentType = 'image/gif';
break;
case 'jpg':
$contentType = 'image/jpeg';
break;
case 'png':
$contentType = 'image/png';
break;
default:
$contentType = 'application/octet-stream';
break;
}
$ioFile->streamOpen($fileName, 'r');
$contentLength = $ioFile->streamStat('size');
$contentModify = $ioFile->streamStat('mtime');
$this->getResponse()->setHttpResponseCode(200)->setHeader('Pragma', 'public', true)->setHeader('Content-type', $contentType, true)->setHeader('Content-Length', $contentLength)->setHeader('Last-Modified', date('r', $contentModify))->clearBody();
$this->getResponse()->sendHeaders();
while (false !== ($buffer = $ioFile->streamRead())) {
echo $buffer;
}
} else {
$name = pathinfo($fileName, PATHINFO_BASENAME);
$this->_prepareDownloadResponse($name, array('type' => 'filename', 'value' => $fileName));
}
exit;
}
示例2: generateXml
public function generateXml()
{
$x147 = "str_replace";
$x148 = "utf8_encode";
$x149 = "preg_match_all";
$x14a = "preg_match";
$x14b = "is_null";
$x14c = "number_format";
$x14d = "is_numeric";
$x14e = "preg_split";
$x14f = "utf8_decode";
$x150 = "is_string";
$x151 = "json_decode";
$x152 = "is_array";
$x153 = "array_push";
$x154 = "print_r";
$x155 = "version_compare";
$x156 = "in_array";
$x157 = "array_pop";
$x158 = "str_pad";
$x159 = "array_shift";
$x15a = "array_reverse";
$x15b = "array_values";
$x15c = "preg_replace";
$x15d = "strip_tags";
$x15e = "html_entity_decode";
$x15f = "mb_strtolower";
$x160 = "mb_strtoupper";
Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> --------------- START PROCESS FOR " . strtoupper($this->x165(false)) . "-----------------", null, $this->x165('.log'));
ini_set('memory_limit', Mage::getStoreConfig("simplegoogleshopping/system/memory_limit") . 'M');
$this->_debug = isset($_GET['debug']) ? true : false;
include Mage::getBaseDir() . "/lib/Wyomind/Google/Requirements.php";
$x3a = new Varien_Io_File();
$x4f = new Varien_Io_File();
$x52 = Mage::getBaseDir() . DS . 'var' . DS . 'tmp' . DS;
$x53 = $x52 . "sgs_" . $this->getSimplegoogleshoppingId() . ".flag";
$x3a->setAllowCreateFolders(true);
if (!$this->_display) {
$x3a->open(array('path' => $this->getPath()));
if ($x3a->fileExists($this->x165()) && !$x3a->isWriteable($this->x165())) {
Mage::throwException(Mage::helper('simplegoogleshopping')->__('File "\\x25\\x73" cannot be saved. Please, make sure the directory "\\x25\\x73" is writeable by web server.', $this->x165(), $this->getPath()));
}
$x3a->streamOpen($this->x165());
$x4f->open(array('path' => $x52));
if ($x4f->fileExists($x53, false)) {
$x4f->streamOpen($x53, 'r');
$x4d = $x4f->streamReadCsv(";");
$x54 = $x4f->streamStat();
if ($x4d[0] == "PROCESSING") {
$x55 = $x54["mtime"];
$x56 = $x4d[3];
if (!(Mage::getSingleton('core/date')->gmtTimestamp() > $x55 + $x56 * 10 || Mage::getSingleton('core/date')->gmtTimestamp() > $x55 + $x56 * 2)) {
Mage::throwException(Mage::helper('simplegoogleshopping')->__('File "\\x25\\x73" is already processing. Please wait the end of the process.', $this->x165(), $this->getPath()));
}
}
} else {
$x4f->streamOpen($x53);
}
}
$x57 = array("ac" => "activation_code", "ak" => "activation_key", "bu" => "base_url", "md" => "md5", "th" => "this", "dm" => "_demo", "ext" => "sgs", "ver" => "9.0.1");
$x150(Mage::app()->getRequest()->getParam("store_id")) ? $x58 = Mage::app()->getRequest()->getParam("store_id") : ($x58 = $this->getStoreId());
$x59 = Mage::getSingleton('core/date')->gmtDate('Y-m-d');
$x5a = Mage::getDesign()->getSkinUrl();
$x5b = Mage::getStoreConfig("catalog/placeholder/image_placeholder", $x58);
$x5c = Mage::getStoreConfig("currency/options/base", $x58);
$x5d = Mage::getStoreConfig("cataloginventory/item_options/manage_stock", $x58);
$x5e = Mage::getStoreConfig("cataloginventory/item_options/backorders", $x58);
$x5f = Mage::app()->getStore($x58)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, false);
$x60 = Mage::getModel('core/store')->load($x58)->getBaseUrl();
$x61 = Mage::app()->getStore($x58)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA, false);
$x62 = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $x58);
$x63 = Mage::app()->getStore($x58)->getRootCategoryId();
$x64 = Mage::app()->getStore()->getStoreId();
$x65 = array("activation_key" => Mage::getStoreConfig("simplegoogleshopping/license/activation_key"), "activation_code" => Mage::getStoreConfig("simplegoogleshopping/license/activation_code"), "base_url" => Mage::getStoreConfig("web/secure/base_url"));
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_xmlitempattern")) ? $x66 = Mage::app()->getRequest()->getParam("simplegoogleshopping_xmlitempattern") : ($x66 = $this->getSimplegoogleshoppingXmlitempattern());
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_title")) ? $x67 = Mage::app()->getRequest()->getParam("simplegoogleshopping_title") : ($x67 = $this->getSimplegoogleshoppingTitle());
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_description")) ? $x68 = Mage::app()->getRequest()->getParam("simplegoogleshopping_description") : ($x68 = $this->getSimplegoogleshoppingDescription());
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_categories")) ? $x69 = $x151(Mage::app()->getRequest()->getParam("simplegoogleshopping_categories")) : ($x69 = $x151($this->getSimplegoogleshoppingCategories()));
$x150(Mage::app()->getRequest()->getParam("category_filter")) ? $x6a = Mage::app()->getRequest()->getParam("category_filter") : ($x6a = $this->getSimplegoogleshoppingCategoryFilter());
$x150(Mage::app()->getRequest()->getParam("category_type")) ? $x6b = Mage::app()->getRequest()->getParam("category_type") : ($x6b = $this->getSimplegoogleshoppingCategoryType());
$x6c = array();
$x6d = array();
if ($x152($x69)) {
foreach ($x69 as $x6e) {
if ($x6e->checked) {
$x6c[] = $x6e->line;
}
}
foreach ($x69 as $x6e) {
if ($x6e->mapping != "") {
$x6d[$x6e->line] = $x6e->mapping;
}
}
}
if (count($x6c) < 1) {
$x6c[] = '*';
}
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_type_ids")) ? $x6f = explode(',', Mage::app()->getRequest()->getParam("simplegoogleshopping_type_ids")) : ($x6f = explode(',', $this->getSimplegoogleshoppingTypeIds()));
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_visibility")) ? $x70 = explode(',', Mage::app()->getRequest()->getParam("simplegoogleshopping_visibility")) : ($x70 = explode(',', $this->getSimplegoogleshoppingVisibility()));
$x150(Mage::app()->getRequest()->getParam("simplegoogleshopping_attributes")) ? $x71 = $x151(Mage::app()->getRequest()->getParam("simplegoogleshopping_attributes")) : ($x71 = $x151($this->getSimplegoogleshoppingAttributes()));
//.........这里部分代码省略.........
示例3: render
public function render(Varien_Object $row)
{
$dir = Mage::getBaseDir() . DS . 'var' . DS . 'tmp' . DS;
$file = $dir . "sgs_" . $row->getId() . ".flag";
$flag = new Varien_Io_File();
$flag->open(array('path' => $dir));
if ($flag->fileExists($file, false)) {
$flag->streamOpen($file, 'r');
$line = $flag->streamReadCsv(";");
$stats = $flag->streamStat();
if ($line[0] == $this::_PROCESSING) {
$updated_at = $stats["mtime"];
$task_time = $line[3];
if (Mage::getSingleton('core/date')->gmtTimestamp() > $updated_at + $task_time * 10) {
$line[0] = 'FAILED';
} elseif (Mage::getSingleton('core/date')->gmtTimestamp() > $updated_at + $task_time * 2) {
$line[0] = 'HOLD';
}
} elseif ($line[0] == $this::_SUCCEED) {
$cron = array();
$cron['curent']['localTime'] = Mage::getSingleton('core/date')->timestamp();
$cron['file']['localTime'] = Mage::getSingleton('core/date')->timestamp($stats["mtime"]);
$cronExpr = json_decode($row->getCronExpr());
$i = 0;
foreach ($cronExpr->days as $d) {
foreach ($cronExpr->hours as $h) {
$time = explode(':', $h);
if (date('l', $cron['curent']['localTime']) == $d) {
$cron['tasks'][$i]['localTime'] = strtotime(Mage::getSingleton('core/date')->date('Y-m-d')) + $time[0] * 60 * 60 + $time[1] * 60;
} else {
$cron['tasks'][$i]['localTime'] = strtotime("last " . $d, $cron['curent']['localTime']) + $time[0] * 60 * 60 + $time[1] * 60;
}
if ($cron['tasks'][$i]['localTime'] >= $cron['file']['localTime'] && $cron['tasks'][$i]['localTime'] <= $cron['curent']['localTime']) {
$line[0] = $this::_PENDING;
continue 2;
}
$i++;
}
}
}
switch ($line[0]) {
case $this::_SUCCEED:
$severity = 'notice';
$status = Mage::helper("simplegoogleshopping")->__($line[0]);
break;
case $this::_PENDING:
$severity = 'minor';
$status = Mage::helper("simplegoogleshopping")->__($line[0]);
break;
case $this::_PROCESSING:
$percent = round($line[1] * 100 / $line[2]);
$severity = 'minor';
$status = Mage::helper("simplegoogleshopping")->__($line[0]) . " [" . $percent . "%]";
break;
case $this::_HOLD:
$severity = 'major';
$status = Mage::helper("simplegoogleshopping")->__($line[0]);
break;
case $this::_FAILED:
$severity = 'critical';
$status = Mage::helper("simplegoogleshopping")->__($line[0]);
break;
default:
$severity = 'critical';
$status = Mage::helper("simplegoogleshopping")->__("ERROR");
break;
}
} else {
$severity = 'minor';
$status = Mage::helper("simplegoogleshopping")->__($this::_PENDING);
}
$script = "<script language='javascript' type='text/javascript'>var updater_url='" . $this->getUrl('/simplegoogleshopping/updater') . "'</script>";
return $script . "<span class='grid-severity-{$severity} updater' cron='" . $row->getCronExpr() . "' id='feed_" . $row->getId() . "'><span>" . $status . "</span></span>";
}