コード例 #1
0
 function writeRewriteFile()
 {
     $adapter = Mage::getModel('freelunchlabs_cloudfront/refreshadapters_apache');
     $base_dir = Mage::getBaseDir() . DS;
     $file = new Varien_Io_File();
     try {
         if ($file->cd($base_dir) && $file->checkAndCreateFolder($this->cdn_rewrite_directory, 0755)) {
             if ($file->cd($base_dir . $this->cdn_rewrite_directory)) {
                 if (!$file->write($adapter->filename, $adapter->buildFileContents(), 0644)) {
                     throw new Exception("Could not write .htaccess to: " . $file->pwd());
                 }
             }
         }
     } catch (Exception $e) {
         Mage::getSingleton('core/session')->addWarning('Configuration saved but there was an error creating the .htaccess file: ' . $e->getMessage());
     }
 }