/**
  * Check file system path
  *
  * @param   string $path
  * @param   bool $recursive
  * @param   bool $existence
  * @param   string $mode
  * @return  bool
  */
 protected function _checkPath($path, $recursive, $existence, $mode)
 {
     $res = true;
     $fullPath = dirname(Mage::getRoot()) . $path;
     if ($mode == self::MODE_WRITE) {
         $setError = false;
         if ($existence) {
             if (is_dir($fullPath) && !is_dir_writeable($fullPath) || !is_writable($fullPath)) {
                 $setError = true;
             }
         } else {
             if (file_exists($fullPath) && !is_writable($fullPath)) {
                 $setError = true;
             }
         }
         if ($setError) {
             $this->_getInstaller()->getDataModel()->addError(Mage::helper('install')->__('Path "%s" must be writable.', $fullPath));
             $res = false;
         }
     }
     if ($recursive && is_dir($fullPath)) {
         foreach (new DirectoryIterator($fullPath) as $file) {
             if (!$file->isDot() && $file->getFilename() != '.svn' && $file->getFilename() != '.htaccess') {
                 $res = $res && $this->_checkPath($path . DS . $file->getFilename(), $recursive, $existence, $mode);
             }
         }
     }
     return $res;
 }
Example #2
0
 public function getImportPath()
 {
     $path = Mage::getBaseDir('var') . DS . 'import' . DS . 'enhancedcms' . DS;
     if (is_dir_writeable($path) != true) {
         mkdir($path, '0744', $recursive = true);
     }
     // end
     return $path;
 }
 protected function _initAction()
 {
     $testDirs = array(Mage::getConfig()->getVarDir(), Mage::getBaseDir());
     foreach ($testDirs as $dir) {
         if (!is_dir_writeable($dir)) {
             $this->_getSession()->addError($this->__('%s is not writeable by web server, please fix it.', $dir));
         }
     }
 }
Example #4
0
 /**
  * Get directory to store files; create if necessary and test if it is writable.
  *
  * @return string
  * @throws Mage_Core_Exception
  */
 protected function _getStorageDirectory()
 {
     $directoryPath = Mage::getStoreConfig(self::DIRECTORY_CONFIG_PATH);
     if (!is_dir($directoryPath)) {
         if (!mkdir($directoryPath, 0777, true)) {
             Mage::throwException(Mage::helper('contentsync')->__('Directory "%s" could not be created.', $directoryPath));
         }
     }
     if (!is_dir_writeable($directoryPath)) {
         Mage::throwException(Mage::helper('contentsync')->__('Directory "%s" is not writable.', $directoryPath));
     }
     if (!in_array(substr($directoryPath, -1, 1), array('/', '\\'))) {
         $directoryPath .= DS;
     }
     return $directoryPath;
 }
Example #5
0
 public function getImportPath($theme = "")
 {
     $path = Mage::getBaseDir('var') . DS . 'cache' . DS;
     if (is_dir_writeable($path) != true) {
         mkdir($path, '0744', $recursive = true);
     }
     // end
     return $path;
 }
Example #6
0
 /**
  * Check file system full path
  *
  * @param  string $fullPath
  * @param  bool $recursive
  * @param  bool $existence
  * @return bool
  */
 protected function _checkFullPath($fullPath, $recursive, $existence)
 {
     $res = true;
     $setError = $existence && (is_dir($fullPath) && !is_dir_writeable($fullPath) || !is_writable($fullPath)) || !$existence && file_exists($fullPath) && !is_writable($fullPath);
     if ($setError) {
         $this->_getInstaller()->getDataModel()->addError(Mage::helper('install')->__('Path "%s" must be writable.', $fullPath));
         $res = false;
     }
     if ($recursive && is_dir($fullPath)) {
         $skipFileNames = array('.svn', '.htaccess');
         foreach (new DirectoryIterator($fullPath) as $file) {
             $fileName = $file->getFilename();
             if (!$file->isDot() && !in_array($fileName, $skipFileNames)) {
                 $res = $this->_checkFullPath($fullPath . DS . $fileName, $recursive, $existence) && $res;
             }
         }
     }
     return $res;
 }
Example #7
0
 public function getUpdatedCustomerFromFile($lastUpdatedTime)
 {
     $customerIds = array();
     $dir = Mage::getBaseDir('media') . DS . 'webpos';
     $customer_updatedfile = $dir . DS . 'customer_updated.txt';
     if (!is_dir_writeable($dir)) {
         $file = new Varien_Io_File();
         $file->checkAndCreateFolder($dir);
     }
     $fileContent = file_get_contents($customer_updatedfile);
     $fileContent = Zend_Json::decode($fileContent);
     if (count($fileContent) > 0) {
         foreach ($fileContent as $customerId => $updated_time) {
             if ($lastUpdatedTime < $updated_time) {
                 $customerIds[] = $customerId;
             }
         }
     }
     return $customerIds;
 }
 /**
  * Class destructor
  */
 public function __destruct()
 {
     if (self::$_numberOfFilesAddedToCache > 0) {
         if (self::isApcUsed()) {
             if (PHP_SAPI != 'cli') {
                 apc_store(self::getCacheKey(), self::$_cache, 0);
             }
         } elseif (is_dir_writeable(dirname(self::getCacheFilePath()))) {
             $fileContent = serialize(self::$_cache);
             $tmpFile = tempnam(sys_get_temp_dir(), 'aoe_classpathcache');
             if (file_put_contents($tmpFile, $fileContent)) {
                 if (@rename($tmpFile, self::getCacheFilePath())) {
                     @chmod(self::getCacheFilePath(), 0664);
                 } else {
                     @unlink($tmpFile);
                 }
             }
         }
     }
 }
 protected function _verifyMinification()
 {
     $stepOk = true;
     try {
         $varPath = Mage::getConfig()->getVarDir('minifycache');
         $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'skin/frontend/default' . '/default/css/print.css';
         $client = new Zend_Http_Client($url);
         /* HHVM fix for "Invalid chunk size" */
         if ($this->_is_hhvm()) {
             $client->setConfig(array('httpversion' => Zend_Http_Client::HTTP_0));
         }
         /* eof fix */
         $response = $client->request();
         $originalLength = strlen($response->getRawBody());
         $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'lib/minify/m.php?f=/skin/frontend/default' . '/default/css/print.css';
         $client->setUri($url);
         $response = $client->request();
         $minifiedLength = strlen($response->getRawBody());
         if ($minifiedLength >= $originalLength) {
             $this->messages[] = 'Verify Minification ERROR: minification does not work (Step 3)';
             $this->errorOccurred = true;
             $stepOk = false;
         }
         if (!is_dir($varPath)) {
             $this->messages[] = 'Verify Minification ERROR: "' . $varPath . '" does not exist (Step 3)';
             $this->errorOccurred = true;
             $stepOk = false;
         }
         if (!is_dir_writeable($varPath)) {
             $this->messages[] = 'Verify Minification ERROR: "' . $varPath . '" is not writeable (Step 3)';
             $this->errorOccurred = true;
             $stepOk = false;
         }
         clearstatcache();
         if ($handle = opendir($varPath)) {
             $filesOK = false;
             while (false !== ($entry = readdir($handle))) {
                 if (strpos($entry, 'minify_') !== false) {
                     $filesOK = true;
                     break;
                 }
             }
             closedir($handle);
             if (!$filesOK) {
                 $this->messages[] = 'Verify Minification ERROR: there are no files starting with "minify_" in "' . $varPath . '" (Step 3)';
                 $this->errorOccurred = true;
                 $stepOk = false;
             }
         } else {
             $this->messages[] = 'Verify Minification ERROR: can\'t open "' . $varPath . '" for reading (Step 3)';
             $this->errorOccurred = true;
             $stepOk = false;
         }
     } catch (Exception $e) {
         $this->errorOccurred = true;
         $stepOk = false;
         $this->messages[] = $e->getMessage();
     }
     if ($stepOk) {
         $this->messages[] = 'Step 3 - OK';
     }
 }
Example #10
0
 public function checkLicense($product, $key, $update = false)
 {
     return true;
     //        if ($update)
     //            $this->checkUpdate();
     # Get Variables from storage (retrieve from wherever it's stored - DB, file, etc...)
     $session = Mage::getSingleton('adminhtml/session');
     $msgs = $session->getMessages(true);
     $msgs->deleteMessageByIdentifier($product);
     $licensekey = $key;
     $dir = Mage::getBaseDir("var") . DS . "smartosc" . DS . strtolower(substr($product, 0, 5)) . DS;
     $filepath = $dir . "license.dat";
     $file = new Varien_Io_File();
     if (!($localkey = $file->read($filepath))) {
         $localkey = "";
     }
     # The call below actually performs the license check. You need to pass in the license key and the local key data
     if (!$update) {
         $results = $this->_checkLicense($licensekey, $localkey);
     } else {
         $results = $this->_checkLicense($licensekey);
     }
     # For Debugging, Echo Results
     //        ob_start();
     //        echo "<textarea cols=100 rows=20>";
     //        print_r($results);
     //        echo "</textarea>";
     //die;
     if (strtoupper($results["status"]) == "ACTIVE") {
         # Allow Script to Run
         if (strtoupper($results['productname']) == strtoupper($product)) {
             if ($results["localkey"]) {
                 # Save Updated Local Key to DB or File
                 $localkeydata = $results["localkey"];
                 if (!is_dir_writeable($dir)) {
                     $file->checkAndCreateFolder($dir);
                 }
                 if (!$file->write($filepath, $localkeydata)) {
                     die('Cannot update licensing data to ' . $filepath);
                 }
             }
             Mage::getModel('core/config')->saveConfig($product . '/general/license_status', $results["status"] . " until " . $results['nextduedate']);
             Mage::getConfig()->cleanCache();
             if ($update) {
                 $session->addSuccess("The license key is valid!");
                 if ($msgs->getLastAddedMessage()) {
                     $msgs->getLastAddedMessage()->setIdentifier($product);
                 }
             }
             return true;
         }
     } elseif ($results["status"] == "Invalid") {
         $message = $results["status"];
     } elseif ($results["status"] == "Expired") {
         $message = $results["status"];
     } elseif ($results["status"] == "Suspended") {
         $message = $results["status"];
     }
     $session->addError('The "' . $product . '" extension has been disabled or your license key is invalid!');
     if ($msgs->getLastAddedMessage()) {
         $msgs->getLastAddedMessage()->setIdentifier($product);
     }
     Mage::getModel('core/config')->saveConfig($product . '/general/license_status', $message);
     Mage::getConfig()->cleanCache();
     return false;
 }
 public function customerSaveAfter($observer)
 {
     $customer = $observer->getCustomer();
     $customerId = $customer->getId();
     $dir = Mage::getBaseDir('media') . DS . 'webpos';
     $customer_updatedfile = $dir . DS . 'customer_updated.txt';
     if (!is_dir_writeable($dir)) {
         $file = new Varien_Io_File();
         $file->checkAndCreateFolder($dir);
     }
     $date = getdate();
     $updated_time = $date[0];
     $fileContent = file_get_contents($customer_updatedfile);
     $fileContent = Zend_Json::decode($fileContent);
     $fileContent[$customerId] = $updated_time;
     $fileContent = Zend_Json::encode($fileContent);
     file_put_contents($customer_updatedfile, $fileContent);
 }
Example #12
0
 public function getUnWritableDirectories()
 {
     $itemsToCheck = $this->getFoldersAndFiles();
     $unWritableDirs = array();
     foreach ($itemsToCheck as $item) {
         $item = Mage::getBaseDir() . '/' . $item;
         $items = glob($item);
         if (preg_match('/\\*$/', $item)) {
             $item = preg_replace('/\\*$/', '', $item);
             $items = array_merge($items, $this->getDirectories($item));
         }
         foreach ($items as $path) {
             if (is_file($path)) {
                 $path = explode('/', $path);
                 array_pop($path);
                 $path = implode('/', $path);
             }
             $path = rtrim($path, '/');
             !is_dir_writeable($path) && ($unWritableDirs[] = $path);
         }
     }
     return array_values(array_unique($unWritableDirs));
 }
Example #13
0
<a href="#" class="floatright close-message"> <i class="fa fa-close"></i></a>
</div>
<?php 
    $config_file = 'log/log.log';
    touch($config_file);
    chmod($config_file, 0644);
    $config_file_handle = fopen($config_file, 'a') or die('Cannot open file:  ' . $config_file);
    $config_data = '' . date(now) . ' | Base URL Path is not set' . PHP_EOL . '';
    fwrite($config_file_handle, $config_data);
}
?>
<!-- Check if config set permissions -->
<?php 
clearstatcache();
$configPath = '' . $BaseUrl . 'config/app/config.php';
$setError = is_dir($configPath) && !is_dir_writeable($configPath) || !is_writable($configPath) || file_exists($configPath) && !is_writable($configPath) && !is_readable($configPath);
if ($setError) {
} else {
    ?>
<div class="alert alert-danger message-item animated bounce m-t-10 " role="alert">
<strong><i class="fa fa-exclamation-triangle"></i> </strong> <?php 
    echo $configPath;
    ?>
 is writable. Please CHMOD to 644 for security.
<a href="#" class="floatright close-message"> <i class="fa fa-close"></i></a>
</div>
<?php 
}
?>

Example #14
0
 public function createOrderBarcode($order_id)
 {
     $dir = Mage::getBaseDir("media") . DS . "barcode" . DS . "order" . DS;
     if (!is_dir_writeable($dir)) {
         $file = new Varien_Io_File();
         $file->checkAndCreateFolder($dir);
     }
     // Creating some Color (arguments are R, G, B)
     $color_black = new FColor(0, 0, 0);
     $color_white = new FColor(255, 255, 255);
     $number_of_char = strlen($order_id);
     // to process with editted order, with order_id like 100000005-1
     if ($number_of_char > 9) {
         $order_id = str_replace("-", "", $order_id);
     }
     $field = str_pad($order_id, 12, "0", STR_PAD_LEFT);
     $width = 172;
     $height = 62;
     switch (intval(Mage::getStoreConfig("barcode/general/symbology"))) {
         case 1:
             $code_generated = new code128(30, $color_black, $color_white, 1, $field, 3, "A");
             break;
         case 2:
             $code_generated = new code128(30, $color_black, $color_white, 1, $field, 3, "B");
             break;
         case 3:
             $code_generated = new code128(30, $color_black, $color_white, 1, $field, 3, "C");
             break;
         case 4:
             $code_generated = new code39(30, $color_black, $color_white, 1, $field, 3);
             break;
         case 5:
             $code_generated = new i25(30, $color_black, $color_white, 1, $field, 3);
             break;
         default:
             $code_generated = new ean13(30, $color_black, $color_white, 1, $field, 3);
             $width = 110;
             break;
     }
     /* Here is the list of the arguments
        1 - Width
        2 - Height
        3 - Filename (empty : display on screen)
        4 - Background color */
     $path = $dir . $order_id . ".png";
     $imageUrl = Mage::getBaseUrl("media") . DS . "barcode" . DS . "order" . DS . $order_id . ".png";
     $drawing = new FDrawing($width, $height, $path, $color_white);
     $drawing->init();
     // You must call this method to initialize the image
     $drawing->add_barcode($code_generated);
     $drawing->draw_all();
     $im = $drawing->get_im();
     // Next line create the little picture, the barcode is being copied inside
     //		$im2 = imagecreate(330,120);
     //
     //		imagecopyresized($im2, $im, 189, 10, 0, 0, $code_generated->lastX, $code_generated->lastY, $code_generated->lastX, $code_generated->lastY);
     // Draw (or save) the image into PNG format.
     $drawing->finish(IMG_FORMAT_PNG);
     return $path;
 }
Example #15
0
 protected function _verifyMinification()
 {
     $stepOk = true;
     try {
         $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'skin/frontend/default' . '/default/css/print.css';
         $client = new Zend_Http_Client($url);
         $response = $client->request();
         $originalLength = $response->getHeader('Content-Length');
         $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'lib/minify/m.php?f=/skin/frontend/default' . '/default/css/print.css';
         $client->setUri($url);
         $response = $client->request();
         $minifiedLength = $response->getHeader('Content-Length');
         if ($minifiedLength >= $originalLength) {
             $this->messages[] = 'Verify Minification ERROR: minification does not work (Step 3)';
             $this->errorOccurred = true;
             $stepOk = false;
         }
         $varPath = Mage::getBaseDir() . DS . 'var' . DS . 'minifycache';
         if (!is_dir($varPath)) {
             $this->messages[] = 'Verify Minification ERROR: "' . $varPath . '" does not exist (Step 3)';
             $this->errorOccurred = true;
             $stepOk = false;
         }
         if (!is_dir_writeable($varPath)) {
             $this->messages[] = 'Verify Minification ERROR: "' . $varPath . '" is not writeable (Step 3)';
             $this->errorOccurred = true;
             $stepOk = false;
         }
         if ($handle = opendir($varPath)) {
             $filesOK = false;
             while (false !== ($entry = readdir($handle))) {
                 if (strpos($entry, 'minify_') !== false) {
                     $filesOK = true;
                     break;
                 }
             }
             closedir($handle);
             if (!$filesOK) {
                 $this->messages[] = 'Verify Minification ERROR: there are no files starting with "minify_" in "' . $varPath . '" (Step 3)';
                 $this->errorOccurred = true;
                 $stepOk = false;
             }
         } else {
             $this->messages[] = 'Verify Minification ERROR: can\'t open "' . $varPath . '" for reading (Step 3)';
             $this->errorOccurred = true;
             $stepOk = false;
         }
     } catch (Exception $e) {
         $this->errorOccurred = true;
         $stepOk = false;
         $this->messages[] = $e->getMessage();
     }
     if ($stepOk) {
         $this->messages[] = 'Step 3 - OK';
     }
 }
Example #16
0
 public function createDirIfNotExists($dir)
 {
     if (!empty($this->_dirExists[$dir])) {
         return true;
     }
     if (file_exists($dir)) {
         if (!is_dir($dir)) {
             return false;
         }
         if (!is_dir_writeable($dir)) {
             return false;
         }
     } else {
         $oldUmask = umask(0);
         if (!@mkdir($dir, 0777, true)) {
             return false;
         }
         umask($oldUmask);
     }
     $this->_dirExists[$dir] = true;
     return true;
 }
 public function getUnWritableDirectories()
 {
     $directoriesForCheck = array();
     foreach ($this->getFoldersAndFiles() as $item) {
         $fullDirPath = Mage::getBaseDir() . DS . $item;
         if (preg_match('/\\*$/', $item)) {
             $fullDirPath = preg_replace('/\\*$/', '', $fullDirPath);
             $directoriesForCheck = array_merge($directoriesForCheck, $this->getDirectories($fullDirPath));
         }
         $directoriesForCheck[] = dirname($fullDirPath);
         is_dir($fullDirPath) && ($directoriesForCheck[] = rtrim($fullDirPath, '/\\'));
     }
     $directoriesForCheck = array_unique($directoriesForCheck);
     $unWritableDirs = array();
     foreach ($directoriesForCheck as $directory) {
         !is_dir_writeable($directory) && ($unWritableDirs[] = $directory);
     }
     return $unWritableDirs;
 }
 */
$applicationBaseDir = (require_once __DIR__ . '/framework/bootstrap.php');
$totalStartTime = microtime(true);
$shell = new Zend_Console_Getopt(array('profile=s' => 'Profile configuration file', 'tmp_dir-s' => 'Directory for temporary files'));
\Magento\ToolkitFramework\Helper\Cli::setOpt($shell);
$args = $shell->getOptions();
if (empty($args)) {
    echo $shell->getUsageMessage();
    exit(0);
}
$tmpDir = \Magento\ToolkitFramework\Helper\Cli::getOption('tmp_dir', null);
if (is_null($tmpDir) && !is_dir(DEFAULT_TEMP_DIR)) {
    $tmpDir = DEFAULT_TEMP_DIR;
    mkdir($tmpDir);
}
if (!is_dir($tmpDir) || !is_dir_writeable($tmpDir)) {
    echo 'Temporary directory is not writable. ' . $tmpDir, 'Please specify a writable directory for temporary files in "tmp_dir" param:', PHP_EOL;
    exit(1);
}
$config = \Magento\ToolkitFramework\Config::getInstance();
$config->loadConfig(\Magento\ToolkitFramework\Helper\Cli::getOption('profile'));
$config->loadLabels(__DIR__ . '/framework/labels.xml');
$labels = $config->getLabels();
echo 'Generating profile with following params:' . PHP_EOL;
foreach ($labels as $configKey => $label) {
    echo ' |- ' . $label . ': ' . $config->getValue($configKey) . PHP_EOL;
}
$files = \Magento\ToolkitFramework\FixtureSet::getInstance()->getFixtures();
$logWriter = new \Zend_Log_Writer_Stream('php://output');
$logWriter->setFormatter(new \Zend_Log_Formatter_Simple('%message%' . PHP_EOL));
$logger = new \Zend_Log($logWriter);