/**
  * @return HybridSessionStore_Cookie
  */
 protected function getStore()
 {
     $store = Injector::inst()->get('HybridSessionStore');
     $store->setKey(uniqid());
     $store->open(getTempFolder() . '/' . __CLASS__, 'SESSIONCOOKIE');
     return $store;
 }
 /**
  * Gets the path to the queuedjob cache directory
  */
 protected function getJobDir()
 {
     // make sure our temp dir is in place. This is what will be inotify watched
     $jobDir = Config::inst()->get('QueuedJobService', 'cache_dir');
     if ($jobDir[0] != '/') {
         $jobDir = getTempFolder() . '/' . $jobDir;
     }
     if (!is_dir($jobDir)) {
         Filesystem::makeFolder($jobDir);
     }
     return $jobDir;
 }
 /**
  * On any restart, make sure to check that our temporary file is being created still.
  */
 public function prepareForRestart()
 {
     parent::prepareForRestart();
     // if the file we've been building is missing, lets fix it up
     if (!$this->tempFile || !file_exists($this->tempFile)) {
         $tmpfile = tempnam(getTempFolder(), 'sitemap');
         if (file_exists($tmpfile)) {
             $this->tempFile = $tmpfile;
         }
         $this->currentStep = 0;
         $this->pagesToProcess = DB::query('SELECT ID FROM SiteTree_Live WHERE ShowInSearch=1')->column();
     }
 }
 /**
  * On any restart, make sure to check that our temporary file is being created still. 
  */
 public function prepareForRestart()
 {
     parent::prepareForRestart();
     // if the file we've been building is missing, lets fix it up
     if (!$this->tempFile || !file_exists($this->tempFile)) {
         $tmpfile = tempnam(getTempFolder(), 'postsitemap');
         if (file_exists($tmpfile)) {
             $this->tempFile = $tmpfile;
         }
         $this->currentStep = 0;
         $this->toProcess = $this->getProcessIds();
     }
 }
Esempio n. 5
0
 public function testGetTempPathInProject()
 {
     if (file_exists($this->tempPath)) {
         $this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath);
     } else {
         // A typical Windows location for where sites are stored on IIS
         $this->assertEquals(getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
         // A typical Mac OS X location for where sites are stored
         $this->assertEquals(getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project');
         // A typical Linux location for where sites are stored
         $this->assertEquals(getTempFolder('/var/www/silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cache-var-www-silverstripe-test-project');
     }
 }
 public function testGetTempPathInProject()
 {
     $user = getTempFolderUsername();
     if (file_exists($this->tempPath)) {
         $this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath . DIRECTORY_SEPARATOR . $user);
     } else {
         $user = getTempFolderUsername();
         $base = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'silverstripe-cache-php' . preg_replace('/[^\\w-\\.+]+/', '-', PHP_VERSION);
         // A typical Windows location for where sites are stored on IIS
         $this->assertEquals($base . 'C--inetpub-wwwroot-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user, getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'));
         // A typical Mac OS X location for where sites are stored
         $this->assertEquals($base . '-Users-joebloggs-Sites-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user, getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'));
         // A typical Linux location for where sites are stored
         $this->assertEquals($base . '-var-www-silverstripe-test-project' . DIRECTORY_SEPARATOR . $user, getTempFolder('/var/www/silverstripe-test-project'));
     }
 }
Esempio n. 7
0
 public function requireTempFolder($testDetails)
 {
     $this->testing($testDetails);
     try {
         $tempFolder = getTempFolder();
     } catch (Exception $e) {
         $tempFolder = false;
     }
     if (!$tempFolder) {
         $testDetails[2] = "Permission problem gaining access to a temp directory. " . "Please create a folder named silverstripe-cache in the base directory " . "of the installation and ensure it has the adequate permissions.";
         $this->error($testDetails);
     }
 }
 /**
  *
  */
 public function importAttachmentsAsFiles($directory = null)
 {
     // todo(Jake): make $directory use relative to the SS/basedir rather than full filepath
     $this->logFunctionStart(__FUNCTION__);
     if ($directory === null) {
         throw new Exception('Must provide a $directory parameter');
     }
     $directorIsCLI = Director::is_cli();
     $folderMap = array();
     $existingWpIDs = singleton('File')->WordpressIDsMap();
     $fileResolver = new WordpressAttachmentFileResolver($directory, getTempFolder());
     if (!$fileResolver->getFilesRecursive()) {
         $this->log('No files found recursively in ' . $fileResolver->directory);
         $this->logFunctionEnd(__FUNCTION__);
         return;
     }
     $basePath = Director::baseFolder() . DIRECTORY_SEPARATOR;
     $baseAssetPath = $basePath . ASSETS_DIR . DIRECTORY_SEPARATOR;
     $this->setupDefaultDatabaseIfNull();
     $attachments = $this->_db->getAttachments();
     foreach ($attachments as $wpData) {
         $wpID = $wpData['ID'];
         if (isset($existingWpIDs[$wpID])) {
             //$this->log('File (Wordpress ID: '.$wpID.') already imported.');
             continue;
         }
         $wpMeta = $this->_db->attachAndGetAttachmentMeta($wpData);
         if (isset($wpMeta['_wp_attached_file'])) {
             $filepaths = $fileResolver->getFilepathsFromRecord($wpData);
             if (!$filepaths) {
                 $this->log('Unable to find matching file for "' . $wpMeta['_wp_attached_file'] . '"" database entry (Wordpress ID: ' . $wpData['ID'] . ')', 'error');
                 continue;
             }
             // Check each filepath and see what year/month pattern matches the current Wordpress attachment
             $yearMonthFile = $fileResolver->extractYearAndMonth($wpMeta['_wp_attached_file']);
             if (!$yearMonthFile) {
                 throw new Exception('Doubled up basename and unable to determine year/month from _wp_attached_file postmeta.');
             }
             $chosenFilepath = null;
             foreach ($filepaths as $filepath) {
                 $checkYearMonthAgainst = $fileResolver->extractYearAndMonth($filepath);
                 if ($yearMonthFile === $checkYearMonthAgainst) {
                     $chosenFilepath = $filepath;
                 }
             }
             if ($chosenFilepath === null) {
                 $errorString = "\n    - " . implode("\n    - ", $filepaths);
                 $errorString = 'Unable to find EXACT matching file for "' . $wpMeta['_wp_attached_file'] . '"" database entry (Wordpress ID: ' . $wpData['ID'] . ') -- Possible paths were: ' . $errorString;
                 if (!$directorIsCLI) {
                     $errorString = nl2br($errorString);
                 }
                 $this->log($errorString, 'notice');
                 continue;
             }
             // $chosenFilepath = Full filename (ie. C:/wamp/www/MySSSite)
             $relativeFilepath = str_replace($basePath, '', $chosenFilepath);
             if ($relativeFilepath === $chosenFilepath) {
                 throw new Exception('Wordpress assets must be moved underneath your Silverstripe assets folder.');
             }
             // Convert from Windows backslash to *nix forwardslash
             $relativeFilepath = str_replace("\\", '/', $relativeFilepath);
             // Add S3 CDN path to the record
             $cdnFile = '';
             if (isset($wpMeta['amazonS3_info']) && isset($wpMeta['amazonS3_info']['key'])) {
                 $cdnFile = 'Cdn:||' . $wpMeta['amazonS3_info']['key'];
             }
             // Feed record data into the object directly
             $recordData = array('Title' => $wpData['post_title'], 'Created' => $wpData['post_date'], 'LastEdited' => $wpData['post_modified'], 'Content' => $wpData['post_content'], 'Description' => $wpData['post_content'], 'CDNFile' => $cdnFile);
             if ($fileResolver->isFileExtensionImage($relativeFilepath)) {
                 $record = Image::create($recordData);
             } else {
                 $record = File::create($recordData);
             }
             $record->Filename = $relativeFilepath;
             // Determine folder to save to
             $relativeDirectoryInsideAssets = str_replace(array($baseAssetPath, '\\'), array('', '/'), $chosenFilepath);
             $relativeDirectoryInsideAssets = dirname($relativeDirectoryInsideAssets);
             if (!isset($folderMap[$relativeDirectoryInsideAssets])) {
                 // Using this to speed-up the lookup on already found or made directories
                 $folderMap[$relativeDirectoryInsideAssets] = Folder::find_or_make($relativeDirectoryInsideAssets);
             }
             $folder = $folderMap[$relativeDirectoryInsideAssets];
             if (!$folder || !$folder->ID) {
                 throw new Exception('Unable to determine or create Folder at: ' . $relativeDirectoryInsideAssets);
             }
             $record->ParentID = $folder->ID;
             try {
                 $record->WordpressData = $wpData;
                 $record->write();
                 $this->log('Added "' . $record->Title . '" (' . $record->class . ') to #' . $record->ID, 'created');
             } catch (Exception $e) {
                 //Debug::dump($relativeFilepath);
                 //Debug::dump($e->getMessage()); exit;
                 $this->log('Failed to write #' . $record->ID . ' (' . $record->class . ', Wordpress ID: ' . $wpData['ID'] . ') -- ' . $e->getMessage(), 'error');
             }
         }
     }
     $this->logFunctionEnd(__FUNCTION__);
 }
    $frameworkDirSlashSuffix = FRAMEWORK_DIR ? FRAMEWORK_DIR . '/' : '';
} else {
    throw new Exception("Path error: FRAMEWORK_PATH " . FRAMEWORK_PATH . " not within BASE_PATH " . BASE_PATH);
}
define('FRAMEWORK_ADMIN_DIR', $frameworkDirSlashSuffix . 'admin');
define('FRAMEWORK_ADMIN_PATH', FRAMEWORK_PATH . '/admin');
define('THIRDPARTY_DIR', $frameworkDirSlashSuffix . 'thirdparty');
define('THIRDPARTY_PATH', FRAMEWORK_PATH . '/thirdparty');
define('ADMIN_THIRDPARTY_DIR', FRAMEWORK_ADMIN_DIR . '/thirdparty');
define('ADMIN_THIRDPARTY_PATH', BASE_PATH . '/' . ADMIN_THIRDPARTY_DIR);
if (!defined('ASSETS_DIR')) {
    define('ASSETS_DIR', 'assets');
}
if (!defined('ASSETS_PATH')) {
    define('ASSETS_PATH', BASE_PATH . '/' . ASSETS_DIR);
}
///////////////////////////////////////////////////////////////////////////////
// INCLUDES
if (defined('CUSTOM_INCLUDE_PATH')) {
    $includePath = '.' . PATH_SEPARATOR . CUSTOM_INCLUDE_PATH . PATH_SEPARATOR . FRAMEWORK_PATH . PATH_SEPARATOR . FRAMEWORK_PATH . '/parsers' . PATH_SEPARATOR . THIRDPARTY_PATH . PATH_SEPARATOR . get_include_path();
} else {
    $includePath = '.' . PATH_SEPARATOR . FRAMEWORK_PATH . PATH_SEPARATOR . FRAMEWORK_PATH . '/parsers' . PATH_SEPARATOR . THIRDPARTY_PATH . PATH_SEPARATOR . get_include_path();
}
set_include_path($includePath);
/**
 * Define the temporary folder if it wasn't defined yet
 */
require_once 'Core/TempPath.php';
if (!defined('TEMP_FOLDER')) {
    define('TEMP_FOLDER', getTempFolder(BASE_PATH));
}
Esempio n. 10
0
 * CustomHtmlForms is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with CustomHtmlForms.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package CustomHtmlForm
 * @subpackage Config
 * @ignore
 */
ContentController::add_extension('CustomHtmlFormPage_Controller');
Security::add_extension('CustomHtmlFormPage_Controller');
SiteConfig::add_extension('CustomHtmlFormConfiguration');
$cacheBaseDir = getTempFolder() . DIRECTORY_SEPARATOR . 'cache';
$cacheDir = $cacheBaseDir . DIRECTORY_SEPARATOR . 'CustomHtmlForm';
if (Director::isDev()) {
    $cachelifetime = 1;
} else {
    $cachelifetime = 86400;
}
if (!is_dir($cacheDir)) {
    if (!is_dir($cacheBaseDir)) {
        mkdir($cacheBaseDir);
    }
    mkdir($cacheDir);
}
if (class_exists('SilvercartCleanCacheTask')) {
    SilvercartCleanCacheTask::register_cache_directory($cacheDir);
}
 /**
  * Renders passed in content to a PDF.
  *
  * If $outputTo == '', then the temporary filename is returned, with the expectation
  * that the caller will correctly handle the streaming of the content.
  *
  * @param String $content
  * 			Raw content to render into a pdf
  * @param String $outputTo
  * 				'file' or 'browser'
  * @param String $outname
  * 				A filename if the pdf is sent direct to the browser
  * @return String
  * 				The filename of the output file
  */
 protected function render($content, $outputTo = null, $outname = '')
 {
     // Setup a temp folder for the pdfs
     $tempFolder = getTempFolder();
     if (!is_dir($tempFolder)) {
         throw new Exception("Temp directory could not be found " . var_export(getTempFolder(), true));
     }
     $pdfFolder = $tempFolder . '/' . self::$temp_folder_name;
     if (!file_exists($pdfFolder)) {
         @mkdir($pdfFolder, 0750);
     }
     if (!is_dir($pdfFolder)) {
         throw new Exception("PDF temp directory could not be found " . $pdfFolder);
     }
     // Change all the links and urls in the content to use absolute paths
     $content = $this->fixLinks($content);
     // Translate all the breaking spaces that tinymce litters everywhere
     $content = $this->fixEntities($content);
     // Create a temp pdf file ready for the pdf convertor output
     $pdfFile = tempnam($pdfFolder, "pdf_");
     // Start up the pdf generator and tell it where to write its output
     $pdfGenerator = new PDFGenerator($pdfFile);
     // Convert the content into pdf
     if (!$pdfGenerator->generatePDF($content)) {
         throw new Exception("PDF could not be created");
     }
     if (!file_exists($pdfFile)) {
         throw new Exception("Could not generate pdf " . $pdfFile);
     }
     // Return the pdf contents if the output type is anything but 'browser'
     if ($outputTo != 'browser') {
         return $pdfFile;
     }
     // Return the pdf to the browser as a file download
     if (file_exists($pdfFile)) {
         $filedata = array('path' => $pdfFile, 'name' => urlencode(htmlentities($outname)), 'mime' => "application/pdf");
         // TODO: use this instead
         //$this->send_file($filedata);
         $size = filesize($pdfFile);
         $type = "application/pdf";
         $name = urlencode(htmlentities($outname));
         if (!headers_sent()) {
             // set cache-control headers explicitly for https traffic, otherwise no-cache will be used,
             // which will break file attachments in IE
             // Thanks to Niklas Forsdahl <*****@*****.**>
             if (isset($_SERVER['HTTPS'])) {
                 header('Cache-Control: private');
                 header('Pragma: ');
             }
             header('Content-disposition: attachment; filename=' . $name);
             header('Content-type: application/pdf');
             //octet-stream');
             header('Content-Length: ' . $size);
             readfile($pdfFile);
         } else {
             echo "Invalid file";
         }
         // Delete the pdf temp file
         unlink($pdfFile);
     }
     return true;
 }
 /**
  * Creates and returns the CSV content to download.
  * $exportContext can be:
  * 0 = all customers with a valid email address
  * 1 = all newsletter recipients
  * 2 = all newsletter recipients with customer account
  * 3 = all newsletter recipients without customer account
  * 4 = all non-newletter recipients with customer account
  * 
  * @param string $exportContext 0|1|2|3|4; Identifies the context to get recipients for
  * 
  * @return string
  */
 protected function getCSVContent($exportContext)
 {
     $membersSql = 'SELECT "M"."Email", "M"."Salutation", "M"."FirstName", "M"."Surname" FROM "Member" AS "M" WHERE "M"."Email" IS NOT NULL';
     $anonymousSql = 'SELECT "ANR"."Email", "ANR"."Salutation", "ANR"."FirstName", "ANR"."Surname" FROM "SilvercartAnonymousNewsletterRecipient" AS "ANR" WHERE "ANR"."Email" IS NOT NULL AND "ANR"."NewsletterOptInStatus" = 1';
     $membersSqlAddition = '';
     switch ($exportContext) {
         case '1':
             // All newletter recipients
             $useMembersSql = true;
             $useAnonymousSql = true;
             $membersSqlAddition = ' AND "M"."NewsletterOptInStatus" = 1';
             break;
         case '2':
             // All newletter recipients with customer account
             $useMembersSql = true;
             $useAnonymousSql = false;
             $membersSqlAddition = ' AND "M"."NewsletterOptInStatus" = 1';
             break;
         case '3':
             // All newletter recipients without customer account
             $useMembersSql = false;
             $useAnonymousSql = true;
             break;
         case '4':
             // All non-newletter recipients
             $useMembersSql = true;
             $useAnonymousSql = false;
             $membersSqlAddition = ' AND "M"."NewsletterOptInStatus" = 0';
             break;
         case '0':
         default:
             // All customers with a valid email address
             $useMembersSql = true;
             $useAnonymousSql = true;
             break;
     }
     $tempFolder = getTempFolder();
     $tempCsvFile = $tempFolder . '/do_newsletter_recipients_export.csv';
     $csvFile = fopen($tempCsvFile, 'w');
     fputcsv($csvFile, array('email', 'salutation', 'firstname', 'surname'));
     if ($useMembersSql) {
         $records = DB::query($membersSql . $membersSqlAddition);
         if ($records->numRecords() > 0) {
             foreach ($records as $record) {
                 $record['Salutation'] = SilvercartTools::getSalutationText($record['Salutation']);
                 fputcsv($csvFile, $record);
             }
         }
     }
     if ($useAnonymousSql) {
         $records = DB::query($anonymousSql);
         if ($records->numRecords() > 0) {
             foreach ($records as $record) {
                 $record['Salutation'] = SilvercartTools::getSalutationText($record['Salutation']);
                 fputcsv($csvFile, $record);
             }
         }
     }
     fclose($csvFile);
     $csvFileContent = file_get_contents($tempCsvFile);
     unlink($tempCsvFile);
     return $csvFileContent;
 }
Esempio n. 13
0
     $_SERVER['REQUEST_METHOD'] = "";
 }
 define('BASE_PATH', getcwd());
 global $databaseConfig;
 $_SESSION = null;
 state("Including SilverStripe core...");
 if (file_exists("sapphire/core/Core.php")) {
     $framework_dir = "sapphire";
 } elseif (file_exists("framework/core/Core.php")) {
     $framework_dir = "framework";
 } else {
     fail("Could not find framework directory!");
 }
 require_once $framework_dir . "/core/TempPath.php";
 if (isset($PARAMS['flush'])) {
     exec("rm -rf " . getTempFolder(BASE_PATH));
 }
 require_once $framework_dir . "/core/Core.php";
 require_once $framework_dir . "/model/DB.php";
 say("done.");
 state("Connecting to database...");
 if ($databaseConfig['type'] == "MySQLDatabase") {
     $conn = @new MySQLi($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
     if ($conn->connect_error) {
         $err = $conn->connect_error;
         say("\nCould not connect to MySQL Database.", "on_red", "white");
         say("This is often due to an issue with MAMP.");
         say("You can run 'silversmith fix-mamp' resolve this issue.");
         $answer = ask("Press any key to show the error output...");
         say("Connection error: {$conn->connect_error}");
     }
 /**
  * Get the absolute path to the pidfile
  *
  * @return string
  */
 protected function getPidFilePath()
 {
     return getTempFolder() . DIRECTORY_SEPARATOR . 'pid.' . strtolower(__CLASS__) . '.txt';
 }
Esempio n. 15
0
 /**
  * @return HTMLPurifier (or anything with a "purify()" method)
  */
 public function getHtmlPurifierService()
 {
     $config = HTMLPurifier_Config::createDefault();
     $allowedElements = $this->getOption('html_allowed_elements');
     $config->set('HTML.AllowedElements', $allowedElements);
     // This injector cannot be set unless the 'p' element is allowed
     if (in_array('p', $allowedElements)) {
         $config->set('AutoFormat.AutoParagraph', true);
     }
     $config->set('AutoFormat.Linkify', true);
     $config->set('URI.DisableExternalResources', true);
     $config->set('Cache.SerializerPath', getTempFolder());
     return new HTMLPurifier($config);
 }
 /**
  * Renders passed in content to a PDF.
  *
  * If $outputTo == '', then the temporary filename is returned, with the expectation
  * that the caller will correctly handle the streaming of the content.
  *
  * @param string $content
  * 			Raw content to render into a pdf
  * @param string $outputTo
  * 				'file' or 'browser'
  * @param string $outname
  * 				A filename if the pdf is sent direct to the browser
  * @return string
  * 				The filename of the output file
  */
 public function render($content, $outputTo = null, $outname = '')
 {
     $tempFolder = getTempFolder();
     if (!is_dir($tempFolder)) {
         throw new Exception("Could not find TMP directory");
     }
     $pdfFolder = $tempFolder . '/pdfrenditions';
     if (!file_exists($pdfFolder)) {
         @mkdir($pdfFolder);
     }
     if (!is_dir($pdfFolder)) {
         throw new Exception("PDF temp directory could not be found");
     }
     $in = tempnam($pdfFolder, "html_");
     chmod($in, 0664);
     $content = $this->fixLinks($content);
     $content = str_replace('&nbsp;', '&#160;', $content);
     $content = http::absoluteURLs($content);
     file_put_contents($in, $content);
     $mid = tempnam($pdfFolder, "xhtml_");
     chmod($mid, 0664);
     $out = tempnam($pdfFolder, "pdf_") . '.pdf';
     if (class_exists('Tidy')) {
         $this->tidyHtml($in, $mid);
     } else {
         $this->tidyHtmlExternal($in, $mid);
     }
     // then run it through our pdfing thing
     $jarPath = dirname(dirname(dirname(__FILE__))) . '/thirdparty/xhtmlrenderer';
     $classpath = $jarPath . '/flying-saucer-core-9.0.7.jar' . PATH_SEPARATOR . $jarPath . '/flying-saucer-pdf-9.0.7.jar' . PATH_SEPARATOR . $jarPath . '/itext-4.2.1.jar';
     $cmd = self::$java_bin;
     if (!is_executable($cmd)) {
         $cmd = "java";
     }
     $escapefn = 'escapeshellarg';
     $cmd = "{$cmd} -classpath " . $escapefn($classpath) . " org.xhtmlrenderer.simple.PDFRenderer " . $escapefn($mid) . ' ' . $escapefn($out);
     $retVal = exec($cmd, $output, $return);
     if (!file_exists($out)) {
         throw new Exception("Could not generate pdf using command {$cmd}: " . var_export($output, true));
     }
     unlink($in);
     unlink($mid);
     if (!($outputTo == 'browser')) {
         return $out;
     }
     if (file_exists($out)) {
         $size = filesize($out);
         $type = "application/pdf";
         $name = urlencode(htmlentities($outname));
         if (!headers_sent()) {
             // set cache-control headers explicitly for https traffic, otherwise no-cache will be used,
             // which will break file attachments in IE
             // Thanks to Niklas Forsdahl <*****@*****.**>
             if (isset($_SERVER['HTTPS'])) {
                 header('Cache-Control: private');
                 header('Pragma: ');
             }
             header('Content-disposition: attachment; filename=' . $name);
             header('Content-type: application/pdf');
             //octet-stream');
             header('Content-Length: ' . $size);
             readfile($out);
         } else {
             echo "Invalid file";
         }
     }
     unlink($out);
 }
Esempio n. 17
0
Config::inst()->update('CMSFileAddController', 'menuCode', 'files');
Config::inst()->update('CMSSettingsController', 'menuCode', 'config');
Config::inst()->update('SecurityAdmin', 'menuCode', 'customer');
Config::inst()->update('CMSPagesController', 'menuSortIndex', 10);
Config::inst()->update('WidgetSetAdmin', 'menuSortIndex', 20);
Config::inst()->update('ReportAdmin', 'menuSortIndex', 30);
Config::inst()->update('AssetAdmin', 'menuSortIndex', 1);
Config::inst()->update('SecurityAdmin', 'menuSortIndex', 30);
Config::inst()->update('CMSSettingsController', 'menuSortIndex', 1);
// ----------------------------------------------------------------------------
// Dirty bugfixes ....
// ----------------------------------------------------------------------------
if (array_key_exists('Email', $_POST)) {
    $_POST['Email'] = SilvercartTools::prepareEmailAddress($_POST['Email']);
}
$cacheDirectories = array('cacheblock' => getTempFolder() . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'cacheblock', 'silvercart' => getTempFolder() . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'silvercart');
if (Director::isDev()) {
    $cachelifetime = 1;
} else {
    $cachelifetime = 86400;
}
foreach ($cacheDirectories as $cacheName => $cacheDirectory) {
    SilvercartCleanCacheTask::register_cache_directory($cacheDirectory);
    if (!is_dir($cacheDirectory)) {
        mkdir($cacheDirectory);
    }
    SS_Cache::add_backend($cacheName, 'File', array('cache_dir' => $cacheDirectory, 'hashed_directory_level' => 1));
    SS_Cache::set_cache_lifetime($cacheName, $cachelifetime);
    SS_Cache::pick_backend($cacheName, $cacheName);
}
SS_Cache::set_cache_lifetime('aggregate', $cachelifetime);
Esempio n. 18
0
 /**
  * Generate an image on the specified format. It will save the image
  * at the location specified by cacheFilename(). The image will be generated
  * using the specific 'generate' method for the specified format.
  * @param string $format Name of the format to generate.
  * @param string $arg1 Argument to pass to the generate method.
  * @param string $arg2 A second argument to pass to the generate method.
  */
 function generateFormattedImage($format, $arg1 = null, $arg2 = null)
 {
     $cacheFile = $this->cacheFilename($format, $arg1, $arg2);
     $gd = new GD($this->URL);
     if ($gd->hasGD()) {
         $generateFunc = "generate{$format}";
         if ($this->hasMethod($generateFunc)) {
             $gd = $this->{$generateFunc}($gd, $arg1, $arg2);
             if ($gd) {
                 $bucket = $this->getUploadBucket();
                 // TODO create bucket if it does not exist
                 // $this->S3->putBucket($bucket, S3::ACL_PUBLIC_READ);
                 $tempFile = tempnam(getTempFolder(), 's3images') . File::get_file_extension($cacheFile);
                 $gd->writeTo($tempFile);
                 $this->S3->putObjectFile($tempFile, $bucket, '_resampled/' . basename($cacheFile), S3::ACL_PUBLIC_READ);
                 unlink($tempFile);
             }
         } else {
             USER_ERROR("Image::generateFormattedImage - Image {$format} function not found.", E_USER_WARNING);
         }
     }
 }
/**
 * tiny_mce_gzip.php
 *
 * Copyright 2010, Moxiecode Systems AB
 * Released under LGPL License.
 *
 * License: http://tinymce.moxiecode.com/license
 * Contributing: http://tinymce.moxiecode.com/contributing
 */
$frameworkPath = rtrim(dirname(dirname(dirname(dirname(__FILE__)))), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'framework';
$basePath = rtrim(dirname($frameworkPath), DIRECTORY_SEPARATOR);
require_once $frameworkPath . '/core/TempPath.php';
// Handle incoming request if it's a script call
if (TinyMCE4_Compressor::getParam("js")) {
    // Default settings
    $tinyMCECompressor = new TinyMCE4_Compressor(array('cache_dir' => getTempFolder($basePath)));
    // Handle request, compress and stream to client
    $tinyMCECompressor->handleRequest();
}
/**
 * This class combines and compresses the TinyMCE core, plugins, themes and
 * language packs into one disk cached gzipped request. It improves the loading speed of TinyMCE dramatically but
 * still provides dynamic initialization.
 *
 * Example of direct usage:
 * require_once("../jscripts/tiny_mce/tiny_mce_gzip.php");
 *
 * // Renders script tag with compressed scripts
 * TinyMCE_Compressor::renderTag(array(
 *    "url" => "../jscripts/tiny_mce/tiny_mce_gzip.php",
 *    "plugins" => "pagebreak,style",
Esempio n. 20
0
define('MODULES_PATH', BASE_PATH . '/' . MODULES_DIR);
define('THIRDPARTY_DIR', 'jsparty');
define('THIRDPARTY_PATH', BASE_PATH . '/' . THIRDPARTY_DIR);
define('THEMES_DIR', 'themes');
define('THEMES_PATH', BASE_PATH . '/' . THEMES_DIR);
define('SAPPHIRE_DIR', 'sapphire');
define('SAPPHIRE_PATH', BASE_PATH . '/' . SAPPHIRE_DIR);
define('CMS_DIR', 'cms');
define('CMS_PATH', BASE_PATH . '/' . CMS_DIR);
define('ASSETS_DIR', 'assets');
define('ASSETS_PATH', BASE_PATH . '/' . ASSETS_DIR);
/**
 * Define the temporary folder if it wasn't defined yet
 */
if (!defined('TEMP_FOLDER')) {
    define('TEMP_FOLDER', getTempFolder());
}
/**
 * Priorities definition. These constants are used in calls to _t() as an optional argument
 */
define('PR_HIGH', 100);
define('PR_MEDIUM', 50);
define('PR_LOW', 10);
/**
 * Ensure we have enough memory
 */
increase_memory_limit_to('64M');
///////////////////////////////////////////////////////////////////////////////
// INCLUDES
require_once "core/ManifestBuilder.php";
require_once "core/ClassInfo.php";
 /**
  * @return HTMLPurifier (or anything with a "purify()" method)
  */
 public function getHtmlPurifierService()
 {
     $config = HTMLPurifier_Config::createDefault();
     $config->set('HTML.AllowedElements', $this->getOption('html_allowed_elements'));
     $config->set('AutoFormat.AutoParagraph', true);
     $config->set('AutoFormat.Linkify', true);
     $config->set('URI.DisableExternalResources', true);
     $config->set('Cache.SerializerPath', getTempFolder());
     return new HTMLPurifier($config);
 }