Example #1
0
 public function tearDown()
 {
     parent::tearDown();
     @unlink(ClassLoader::getRealPath('cache.') . 'currencies.php');
     $this->setUpCurrency();
     ActiveRecordModel::rollback();
 }
Example #2
0
 private function getFilterUrlTemplate()
 {
     include_once ClassLoader::getRealPath('application.helper.smarty') . '/function.categoryUrl.php';
     $params = array('filters' => array(new ManufacturerFilter(999, '___')), 'data' => Category::getRootNode()->toArray());
     $templateUrl = createCategoryUrl($params, $this->application);
     return strtr($templateUrl, array(999 => '#', '___' => '|'));
 }
Example #3
0
 public function testSimpleImport()
 {
     $lv = ActiveRecordModel::getNewInstance('Language');
     $lv->setID('xx');
     $lv->save();
     $profile = new CsvImportProfile('Product');
     $profile->setField(0, 'Product.sku');
     $profile->setField(1, 'Product.name', array('language' => 'en'));
     $profile->setField(2, 'Product.name', array('language' => 'xx'));
     $profile->setField(3, 'Product.shippingWeight');
     $profile->setParam('delimiter', ';');
     $csvFile = ClassLoader::getRealPath('cache.') . 'testDataImport.csv';
     file_put_contents($csvFile, 'test; "Test Product"; "Parbaudes Produkts"; 15' . "\n" . 'another; "Another Test"; "Vel Viens"; 12.44');
     $import = new ProductImport($this->getApplication());
     $csv = $profile->getCsvFile($csvFile);
     $cnt = $import->importFile($csv, $profile);
     $this->assertEquals($cnt, 2);
     $test = Product::getInstanceBySKU('test');
     $this->assertTrue($test instanceof Product);
     $this->assertEquals($test->shippingWeight->get(), '15');
     $this->assertEquals($test->getValueByLang('name', 'en'), 'Test Product');
     $another = Product::getInstanceBySKU('another');
     $this->assertEquals($another->getValueByLang('name', 'xx'), 'Vel Viens');
     unlink($csvFile);
 }
Example #4
0
 public function notify($requestArray)
 {
     $requestArray['version'] = '1.2open';
     $keys = array('TPE', 'date', 'montant', 'reference', 'texte-libre', 'version', 'code-retour');
     $values = array();
     foreach (array('TPE', 'date', 'montant', 'reference', 'texte-libre', 'version', 'code-retour') as $key) {
         $values[$key] = $requestArray[$key];
     }
     $macParams = array_combine($keys, $values);
     $mac = $requestArray['retourPLUS'] . implode('+', $macParams) . '+';
     $hash = strtoupper($this->CMCIC_hmac($mac));
     ob_end_clean();
     file_put_contents(ClassLoader::getRealPath('cache.') . get_class($this) . '.php', var_export($requestArray, true));
     if ('annulation' == strtolower($requestArray['code-retour'])) {
         printf("Pragma: no-cache \nContent-type: text/plain \nVersion: 1 %s", 'Annulation');
     } else {
         if ($hash == $requestArray['MAC']) {
             $result = new TransactionResult();
             $result->gatewayTransactionID->set($requestArray['reference']);
             $result->amount->set(substr($requestArray['montant'], 0, -3));
             $result->currency->set(substr($requestArray['montant'], -3));
             $result->rawResponse->set($requestArray);
             $result->setTransactionType(TransactionResult::TYPE_SALE);
             printf("Pragma: no-cache \nContent-type: text/plain \nVersion: 1 %s", 'OK');
             return $result;
         } else {
             printf("Pragma: no-cache \nContent-type: text/plain \nVersion: 1 %s", 'Document falsifie');
             exit;
         }
     }
 }
Example #5
0
/**
 * ...
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 *
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_function_includeCss($params, LiveCartSmarty $smarty)
{
    $fileName = $params['file'];
    $filePath = substr($fileName, 0, 1) != '/' ? ClassLoader::getRealPath('public.stylesheet.') . $fileName : ClassLoader::getRealPath('public') . $fileName;
    // fix slashes
    $filePath = str_replace('\\', DIRECTORY_SEPARATOR, $filePath);
    $filePath = str_replace('/', DIRECTORY_SEPARATOR, $filePath);
    if (!is_file($filePath) && !isset($params['external']) || substr($filePath, -4) != '.css') {
        return;
    }
    $css = CssFile::getInstanceFromPath($filePath, $smarty->getApplication()->getTheme());
    $origFileName = $fileName;
    if ($css->isPatched()) {
        $filePath = $css->getPatchedFilePath();
        $fileName = $css->getPatchedFileRelativePath();
    }
    if (isset($params['inline']) && $params['inline'] == 'true') {
        $path = 'stylesheet/' . str_replace(DIRECTORY_SEPARATOR, '/', $fileName) . '?' . filemtime($filePath);
        return '<link href="' . $path . '" media="screen" rel="Stylesheet" type="text/css" />' . "\n";
    } else {
        if (isset($params['external'])) {
            $smarty->_smarty_vars['INCLUDED_STYLESHEET_FILES_EXTERNAL'][] = $fileName;
        } else {
            $includedStylesheetTimestamp = $smarty->_smarty_vars['INCLUDED_STYLESHEET_TIMESTAMP'];
            if (!($includedStylesheetFiles = $smarty->_smarty_vars['INCLUDED_STYLESHEET_FILES'])) {
                $includedStylesheetFiles = array();
            }
            if (in_array($filePath, $includedStylesheetFiles)) {
                if (isset($params['front'])) {
                    unset($includedStylesheetFiles[array_search($filePath, $includedStylesheetFiles)]);
                } else {
                    return;
                }
            }
            $fileMTime = filemtime($filePath);
            if ($fileMTime > (int) $includedStylesheetTimestamp) {
                $smarty->_smarty_vars['INCLUDED_STYLESHEET_TIMESTAMP'] = $fileMTime;
            }
            if (isset($params['front'])) {
                array_unshift($includedStylesheetFiles, $filePath);
            } else {
                if (isset($params['last'])) {
                    $includedStylesheetFiles['x' . (count($includedStylesheetFiles) + 200) * (int) $params['last']] = $filePath;
                } else {
                    array_push($includedStylesheetFiles, $filePath);
                }
            }
            $smarty->_smarty_vars['INCLUDED_STYLESHEET_FILES'] = $includedStylesheetFiles;
        }
    }
    foreach ($smarty->getApplication()->getConfigContainer()->getFilesByRelativePath('public/stylesheet/' . $origFileName, true) as $file) {
        if (realpath($file) == realpath($filePath)) {
            continue;
        }
        $file = substr($file, strlen(ClassLoader::getRealPath('public')));
        $params['file'] = $file;
        smarty_function_includeCss($params, $smarty);
    }
}
 public function tearDown()
 {
     parent::tearDown();
     $dir = ClassLoader::getRealPath('storage.customize.view.theme.sometheme');
     if (file_exists($dir)) {
         rmdir($dir);
     }
 }
Example #7
0
 public function getFilePath()
 {
     if (is_array($this->params)) {
         $hash = md5(implode('-', array_values($this->params)));
     } else {
         $hash = md5($this->params);
     }
     return ClassLoader::getRealPath('cache.output.' . $this->type . '.') . $hash;
 }
Example #8
0
 /**
  * Gets a smarty instance
  *
  * @return Smarty
  */
 public function getSmartyInstance()
 {
     if (!$this->tpl) {
         $this->tpl = new Smarty();
         $this->tpl->compile_dir = self::$compileDir;
         $this->tpl->template_dir = ClassLoader::getRealPath("application.view");
     }
     return $this->tpl;
 }
Example #9
0
 public function testGerRoleNames()
 {
     $dumpControllerRoles = new RolesParser(ClassLoader::getRealPath("test.framework.roles.controllers.DumpController") . ".php", ClassLoader::getRealPath("test.framework.roles.cache.DumpControllerRoles") . ".php");
     $roleNames = $dumpControllerRoles->getRolesNames();
     $this->assertEqual(count($roleNames), 4);
     $this->assertTrue(in_array('test', $roleNames));
     $this->assertTrue(in_array('test.subtest', $roleNames));
     $this->assertTrue(in_array('another', $roleNames));
     $this->assertTrue(in_array('another.another', $roleNames));
 }
Example #10
0
/**
 * ...
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 *
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_function_includeJs($params, Smarty_Internal_Template $smarty)
{
    static $jsPath;
    if (!$jsPath) {
        $jsPath = ClassLoader::getRealPath('public.javascript.');
    }
    $fileName = $params['file'];
    $filePath = substr($fileName, 0, 1) != '/' ? $jsPath . $fileName : ClassLoader::getRealPath('public') . $fileName;
    $fileName = substr($fileName, 0, 1) != '/' ? 'javascript/' . $fileName : substr($fileName, 1);
    //  fix slashes
    $filePath = str_replace('\\', DIRECTORY_SEPARATOR, $filePath);
    $filePath = str_replace('/', DIRECTORY_SEPARATOR, $filePath);
    if (isset($params['path'])) {
        $filePath = $params['path'];
    }
    if (!is_file($filePath) || substr($filePath, -3) != '.js') {
        return;
    }
    if (isset($params['inline']) && $params['inline'] == 'true') {
        return '<script src="' . str_replace(DIRECTORY_SEPARATOR, '/', $fileName) . '?' . filemtime($filePath) . '" type="text/javascript"></script>' . "\n";
    } else {
        $includedJavascriptTimestamp = $smarty->getGlobal("INCLUDED_JAVASCRIPT_TIMESTAMP");
        if (!($includedJavascriptFiles = $smarty->getGlobal('INCLUDED_JAVASCRIPT_FILES'))) {
            $includedJavascriptFiles = array();
        }
        if (isset($includedJavascriptFiles[$filePath])) {
            if (!isset($params['front'])) {
                return false;
            } else {
                unset($includedJavascriptFiles[$filePath]);
            }
        }
        $fileMTime = filemtime($filePath);
        if ($fileMTime > (int) $includedJavascriptTimestamp) {
            $smarty->setGlobal('INCLUDED_JAVASCRIPT_TIMESTAMP', $fileMTime);
        }
        if (isset($params['front'])) {
            $includedJavascriptFiles = array_merge(array($filePath => $fileName), $includedJavascriptFiles);
        } else {
            $includedJavascriptFiles[$filePath] = $fileName;
        }
        $smarty->setGlobal('INCLUDED_JAVASCRIPT_FILES', $includedJavascriptFiles);
    }
    foreach ($smarty->getApplication()->getConfigContainer()->getFilesByRelativePath('public/' . $fileName, true) as $file) {
        if (realpath($file) == realpath($filePath)) {
            continue;
        }
        $file = substr($file, strlen(ClassLoader::getRealPath('public')));
        $params['file'] = $file;
        smarty_function_includeJs($params, $smarty);
    }
}
Example #11
0
 private function getDrivers()
 {
     $drivers = array();
     foreach (new DirectoryIterator(ClassLoader::getRealPath('library.import.driver')) as $file) {
         if (!$file->isDot()) {
             include_once $file->getPathname();
             $className = basename($file->getFileName(), '.php');
             $drivers[$className] = call_user_func(array($className, 'getName'));
         }
     }
     natcasesort($drivers);
     return $drivers;
 }
Example #12
0
 function testPatching()
 {
     $file = 'stylesheet/backend/stat.css';
     $path = ClassLoader::getRealPath('public.') . $file;
     $css = new CssFile($file);
     $css->clearPatchRules();
     $css->deleteSelector('#stat table');
     $css->save();
     $this->assertTrue(strpos(file_get_contents($css->getPatchedFilePath()), '#stat table') == 0);
     $css->deleteProperty('#stat .label', 'font-weight');
     $css->save();
     $this->assertTrue(strpos(file_get_contents($css->getPatchedFilePath()), 'font-weight') == 0);
     $css->clearPatchRules();
 }
 public function ztestModelPlugins()
 {
     $this->getApplication()->registerPluginDirectory(ClassLoader::getRealPath('test.fixture.plugin'));
     $currency = Currency::getNewInstance('ZZZ');
     $currency->save();
     $this->assertEquals($currency->rate->get(), 0.5);
     $this->assertFalse((bool) $currency->isEnabled->get());
     $currency->rate->set(0.6);
     $currency->save();
     $this->assertTrue((bool) $currency->isEnabled->get());
     $array = $currency->toArray();
     $this->assertTrue($array['testValue']);
     $this->getApplication()->unregisterPluginDirectory(ClassLoader::getRealPath('test.fixture.plugin'));
 }
Example #14
0
/**
 * ...
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 *
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_function_compiledJs($params, Smarty_Internal_Template $smarty)
{
    $includedJavascriptTimestamp = $smarty->getGlobal("INCLUDED_JAVASCRIPT_TIMESTAMP");
    $includedJavascriptFiles = $smarty->getGlobal("INCLUDED_JAVASCRIPT_FILES");
    $app = $smarty->getApplication();
    if ($includedJavascriptFiles && isset($params['glue']) && $params['glue'] == 'true' && !$smarty->getApplication()->isDevMode() && !$smarty->getApplication()->isTemplateCustomizationMode()) {
        $request = $app->getRequest();
        if (isset($params['nameMethod']) && 'hash' == $params['nameMethod']) {
            $names = array_keys($includedJavascriptFiles);
            sort($names);
            $compiledFileName = md5(implode("\n", $names)) . '.js';
        } else {
            $compiledFileName = $request->getControllerName() . '-' . $request->getActionName() . '.js';
        }
        $compiledFilePath = ClassLoader::getRealPath('public.cache.javascript.') . $compiledFileName;
        $baseDir = ClassLoader::getRealPath('public.javascript.');
        $compiledFileTimestamp = 0;
        if (!is_file($compiledFilePath) || filemtime($compiledFilePath) < $includedJavascriptTimestamp) {
            if (!is_dir(ClassLoader::getRealPath('public.cache.javascript'))) {
                mkdir(ClassLoader::getRealPath('public.cache.javascript'), 0777, true);
            }
            // compile
            $compiledFileContent = "";
            $compiledFilesList = array();
            foreach ($includedJavascriptFiles as $jsFile => $fileName) {
                $compiledFileContent .= "\n\n\n/***************************************************\n";
                $compiledFileContent .= " * " . str_replace($baseDir, '', $jsFile) . "\n";
                $compiledFileContent .= " ***************************************************/\n\n";
                $compiledFileContent .= file_get_contents($jsFile);
                $compiledFilesList[] = basename($jsFile);
            }
            file_put_contents($compiledFilePath, $compiledFileContent);
            if (function_exists('gzencode')) {
                file_put_contents($compiledFilePath . '.gz', gzencode($compiledFileContent, 9));
            }
        }
        $compiledFileTimestamp = filemtime($compiledFilePath);
        return '<script src="' . $app->getPublicUrl('gzip.php') . '?file=' . $compiledFileName . '&amp;time=' . $compiledFileTimestamp . '" type="text/javascript"></script>';
    } else {
        if ($includedJavascriptFiles) {
            $includeString = "";
            $publicPath = ClassLoader::getRealPath('public.');
            foreach ($includedJavascriptFiles as $path => $jsFile) {
                $urlPath = str_replace('\\', '/', str_replace($publicPath, '', $jsFile));
                $includeString .= '<script src="' . $app->getPublicUrl($urlPath) . '?' . filemtime($path) . '" type="text/javascript"></script>' . "\n";
            }
            return $includeString;
        }
    }
}
Example #15
0
/**
 * ...
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 * 
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_function_img($params, LiveCartSmarty $smarty)
{
    if (isset($params['src']) && (substr($params['src'], 0, 6) == 'image/' || substr($params['src'], 0, 7) == 'upload/')) {
        if (is_file($params['src'])) {
            $imageTimestamp = @filemtime(ClassLoader::getRealPath('public.') . str_replace('/', DIRECTORY_SEPARATOR, $params['src']));
            $params['src'] .= '?' . $imageTimestamp;
        }
    }
    $content = "<img ";
    foreach ($params as $name => $value) {
        $content .= $name . '="' . $value . '" ';
    }
    $content .= "/>";
    return $content;
}
Example #16
0
 public function __construct($theme)
 {
     if (!$theme || is_string($theme) == false || strpos($theme, '..') !== false || strpos($theme, '\\') !== false || strpos($theme, '/') !== false || strpos($theme, '.') !== false && strlen($theme) == 1) {
         throw new Exception('Illegal theme name');
     }
     $this->theme = $theme;
     $this->path = ClassLoader::getRealPath('public.upload.theme.' . $this->theme . '.');
     $this->thumbnailPath = ClassLoader::getRealPath('public.upload.theme.' . $this->theme . '.thumbs.');
     if (file_exists($this->path) == false) {
         mkdir($this->path, 0777, true);
     }
     if (file_exists($this->thumbnailPath) == false) {
         mkdir($this->thumbnailPath, 0777, true);
     }
 }
Example #17
0
 public function export()
 {
     // preload current locale
     $this->locale;
     $tempDir = ClassLoader::getRealPath('cache.tmp.' . rand(1, 10000000));
     $locale = Locale::getInstance($this->request->get('id'));
     $fileDir = ClassLoader::getRealPath('application.configuration.language.en');
     $files = $locale->translationManager()->getDefinitionFiles($fileDir);
     // prepare language files
     $translated = array();
     foreach ($files as $file) {
         $relPath = substr($file, strlen($fileDir) + 1);
         // get language default definitions
         $default = $locale->translationManager()->getFileDefs($relPath, true);
         if (!is_array($default)) {
             $default = array();
         }
         // get translated definitions
         $transl = $locale->translationManager()->getCacheDefs($relPath, true);
         $transl = array_merge($default, $transl);
         $values = array();
         foreach ($transl as $key => $value) {
             $values[] = $key . '=' . $value;
         }
         $path = $tempDir . '/' . $locale->getLocaleCode() . '/' . $relPath;
         if ($values) {
             if (!is_dir(dirname($path))) {
                 mkdir(dirname($path), 0777, true);
             }
             file_put_contents($path, implode("\n", $values));
         }
     }
     // put the files in zip archive
     require_once ClassLoader::getRealPath('library.pclzip') . '/pclzip.lib.php';
     if (!is_dir($tempDir)) {
         return new ActionRedirectResponse('backend.language', 'edit', array('id' => $locale->getLocaleCode()));
     }
     chdir($tempDir);
     $zip = dirname($tempDir) . '/temp_' . rand(1, 10000) . '.zip';
     $archive = new PclZip($zip);
     $archive->add($locale->getLocaleCode());
     // remove the temp directory
     $this->application->rmdir_recurse($tempDir);
     $response = new ObjectFileResponse(ObjectFile::getNewInstance('ObjectFile', $zip, 'LiveCart-' . $locale->getLocaleCode() . '.zip'));
     $response->deleteFileOnComplete();
     return $response;
 }
Example #18
0
 public function copyDirectory($source, $target)
 {
     $settings = $this->application->getConfig();
     switch ($settings->get('UPDATE_COPY_METHOD')) {
         case 'UPDATE_COPY':
             return $this->recurse_copy($source, $target);
             break;
         case 'UPDATE_FTP':
             if ($conn = $this->getFTPConnection()) {
                 $root = ClassLoader::getRealPath('.');
                 $ftpRoot = '/' . $settings->get('UPDATE_FTP_DIRECTORY') . '/' . substr($target, strlen($root) - 1);
                 return $this->ftp_uploaddirectory($conn, $source, $ftpRoot);
             } else {
                 return false;
             }
             break;
     }
 }
Example #19
0
 public static function getCurrencyRateSourceList()
 {
     $list = array();
     foreach (new DirectoryIterator(ClassLoader::getRealPath('application.model.currencyrate')) as $item) {
         if ($item->isDot()) {
             continue;
         }
         $fn = $item->getFileName();
         $cn = substr($fn, 0, -4);
         ClassLoader::import('application.model.currencyrate.' . $cn);
         if (!is_subclass_of($cn, __CLASS__)) {
             continue;
         }
         $list[$cn] = $cn;
     }
     ksort($list);
     return $list;
 }
Example #20
0
 public function testDeleteFileGroupWithFiles()
 {
     $group = ProductFileGroup::getNewInstance($this->product);
     $group->setNextPosition();
     $group->setValueByLang('name', 'en', 'TEST_GROUP');
     $group->save();
     $file = ClassLoader::getRealPath('cache.') . 'blabla';
     file_put_contents($file, 'asdsad');
     $productFile = ProductFile::getNewInstance($this->product, $file, 'movedFile.txt');
     $productFile->productFileGroup->set($group);
     $productFile->save();
     $productFilePath = $productFile->getPath();
     $group->delete();
     try {
         $productFile->reload();
         $this->fail();
     } catch (Exception $e) {
         $this->pass();
     }
     $this->assertFalse(is_file($productFilePath));
     unlink($file);
 }
Example #21
0
 public function getPatchFile($patchedName = null)
 {
     return ClassLoader::getRealPath('public.upload.css.delete.') . ($patchedName ? $patchedName : $this->theme . '-' . md5($this->relPath)) . '.php';
 }
Example #22
0
 public function export()
 {
     require_once ClassLoader::getRealPath('library.pclzip') . '/pclzip.lib.php';
     $id = $this->getRequest()->get('id');
     $files = $this->getThemeFiles($id);
     if ($files === null) {
         return new ActionRedirectResponse('backend.theme', 'index');
     }
     do {
         $path = ClassLoader::getRealPath('cache.tmp.theme_export_' . rand(1, 10000000));
     } while (file_exists($path));
     $zipFilePath = $path . '_archive.zip';
     $confFilePath = $path . DIRECTORY_SEPARATOR . 'theme.conf';
     foreach (array($zipFilePath, $confFilePath) as $fp) {
         if (!is_dir(dirname($fp))) {
             mkdir(dirname($fp), 0777, true);
         }
     }
     file_put_contents($confFilePath, sprintf('[Theme]' . "\n" . 'name = %s', $id));
     $archive = new PclZip($zipFilePath);
     chdir(ClassLoader::getBaseDir());
     $files[] = $confFilePath;
     $archive->add($files, PCLZIP_OPT_REMOVE_PATH, $path);
     $this->application->rmdir_recurse($path);
     $response = new ObjectFileResponse(ObjectFile::getNewInstance('ObjectFile', $zipFilePath, $id . '.zip'));
     $response->deleteFileOnComplete();
     return $response;
 }
Example #23
0
 public function uploadOptionFile()
 {
     ClassLoader::import('application.model.order.OrderedItemOption');
     $field = 'upload_' . $this->request->get('field');
     $option = ActiveRecordModel::getInstanceById('ProductOption', $this->request->get('id'), true);
     $validator = $this->getValidator('optionFile');
     $this->addOptionValidation($validator, $option->toArray(), $field);
     if (!$validator->isValid()) {
         return new JSONResponse(array('error' => $validator->getErrorList()));
     }
     // create tmp file
     $file = $_FILES[$field];
     $tmp = 'tmp_' . $field . md5($file['tmp_name']) . '__' . $file['name'];
     $dir = ClassLoader::getRealPath('public.upload.optionImage.');
     $path = $dir . $tmp;
     if (!file_exists($dir)) {
         mkdir($dir);
         chmod($dir, 0777);
     }
     move_uploaded_file($file['tmp_name'], $path);
     // create thumbnail
     $thumb = null;
     if (@getimagesize($path)) {
         $thumb = 'tmp_thumb_' . $tmp;
         $thumbPath = $dir . $thumb;
         OrderedItemOption::resizeImage($path, $thumbPath, 1);
     }
     return new JSONResponse(array('name' => $file['name'], 'file' => $tmp, 'thumb' => $thumb));
 }
Example #24
0
 public function setFileList($files)
 {
     // get file list from store
     $url = 'http://' . $this->domain->get() . '/storeSync/fileList';
     $params = array('password' => $this->apiKey->get());
     //$u = $url . '?password='******'<span style="font-size: 2px">.</span>';
     $res = $this->httpPost($url, $params);
     if (is_null($res)) {
         return;
     }
     echo '<span style="font-size: 2px">.</span>';
     $res = json_decode($res, true);
     if (is_null($res)) {
         return;
     }
     echo '<span style="font-size: 2px">.</span>';
     // get ID's of images actually used
     $ids = array();
     foreach (ActiveRecord::getDataBySQL('SELECT ID FROM galssess_snapshot_import.ProductImage') as $id) {
         $ids[$id['ID']] = true;
     }
     echo '<span style="font-size: 2px">.</span>';
     // filter out files that are not needed to update
     foreach ($files as $file => $time) {
         if (!empty($res[$file]) && $res[$file] >= $time) {
             unset($files[$file]);
         } else {
             if (strpos($file, 'roductimage')) {
                 list($productId, $id, $foo) = explode('-', $file, 3);
                 if (!isset($ids[$id])) {
                     unset($files[$file]);
                 }
             }
         }
     }
     echo '<span style="font-size: 2px">.</span>';
     $cd = getcwd();
     chdir(ClassLoader::getRealPath('public.upload'));
     echo '<span style="font-size: 2px">.</span>';
     $tar = $this->getQueryFile('.tar');
     exec('tar cvf "' . $tar . '" --files-from /dev/null');
     echo '<span style="font-size: 2px">.</span>';
     foreach ($files as $file => $time) {
         exec('tar rvf "' . $tar . '" ' . $file);
         echo '<span style="font-size: 2px">.</span>';
     }
     echo '<span style="font-size: 2px">.</span>';
     chdir($cd);
     echo '<span style="font-size: 2px">.</span>';
 }
Example #25
0
 public function getThemeDirectories()
 {
     return array(ClassLoader::getRealPath('storage.customize.view.theme.' . $this->name), ClassLoader::getRealPath('public.upload.theme.' . $this->name));
 }
Example #26
0
 public function updateSalesRank()
 {
     $cacheFile = ClassLoader::getRealPath('cache.salesrank');
     if (!file_exists($cacheFile) || filemtime($cacheFile) < time() - 3600) {
         touch($cacheFile);
         ActiveRecord::executeUpdate('UPDATE Product SET salesRank=(SELECT SUM(count) FROM OrderedItem LEFT JOIN CustomerOrder ON OrderedItem.customerOrderID=CustomerOrder.ID WHERE productID=Product.ID AND CustomerOrder.isPaid=1 AND CustomerOrder.dateCompleted > "' . ARSerializableDateTime::createFromTimeStamp(strtotime('-' . $this->config->get('BESTSELLING_ITEMS_DAYS') . ' days')) . '")');
     }
 }
Example #27
0
        $start = microtime(true);
        ClassLoader::load($className);
        $elapsed = microtime(true) - $start;
        if (empty($GLOBALS['ClassLoaderTime'])) {
            $GLOBALS['ClassLoaderTime'] = $GLOBALS['ClassLoaderCount'] = 0;
        }
        $GLOBALS['ClassLoaderTime'] += $elapsed;
        $GLOBALS['ClassLoaderCount']++;
    }
}
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR . 'ClassLoader.php';
ClassLoader::mountPath('.', dirname(dirname($_SERVER["SCRIPT_FILENAME"])) . DIRECTORY_SEPARATOR);
if (defined('CACHE_DIR')) {
    ClassLoader::mountPath('cache', CACHE_DIR);
}
$classLoaderCacheFile = ClassLoader::getRealPath('cache.') . 'classloader.php';
if (file_exists($classLoaderCacheFile)) {
    $classLoaderCache = (include $classLoaderCacheFile);
    ClassLoader::setRealPathCache($classLoaderCache['realPath']);
    ClassLoader::setMountPointCache($classLoaderCache['mountPoint']);
}
if (isset($_REQUEST['stat'])) {
    ClassLoader::import('library.stat.Stat');
    $stat = new Stat(true);
    $GLOBALS['stat'] = $stat;
}
ClassLoader::import('framework.request.Request');
ClassLoader::import('framework.request.Router');
ClassLoader::import('framework.controller.*');
ClassLoader::import('framework.response.*');
ClassLoader::import('application.controller.*');
Example #28
0
<?php

$ret = array();
foreach (new DirectoryIterator(ClassLoader::getRealPath('library.tracking.method')) as $method) {
    if ($method->isFile() && substr($method->getFileName(), 0, 1) != '.') {
        $ret[] = basename($method->getFileName(), '.php');
    }
}
return implode(', ', $ret);
Example #29
0
File: index.php Project: saiber/www
    exit;
}
ini_set('date.timezone', 'America/New_York');
ob_start();
// session cookie expires in 180 days
session_set_cookie_params(180 * 60 * 60 * 24);
include_once (include 'appdir.php') . '/application/Initialize.php';
ClassLoader::import('application.LiveCart');
ini_set('display_errors', 0);
$app = new LiveCart();
if (isset($stat)) {
    $app->setStatHandler($stat);
    $stat->logStep('Initialization');
}
// Custom initialization tasks
$custom = ClassLoader::getRealPath('storage.configuration.CustomInitialize') . '.php';
if (file_exists($custom)) {
    include $custom;
}
if (version_compare('5.2', PHP_VERSION, '>')) {
    ClassLoader::import('library.json.json');
}
function runApp(LiveCart $app)
{
    static $attempts = 0;
    // check if we're not getting into an endless loop
    if (++$attempts > 5) {
        try {
            $app->run();
        } catch (Exception $e) {
            dump_livecart_trace($e);
Example #30
0
 protected function insert()
 {
     // check currency symbol
     if (!$this->pricePrefix->get() && !$this->priceSuffix->get()) {
         $prefixes = (include ClassLoader::getRealPath('installdata.currency.signs') . '.php');
         if (isset($prefixes[$this->getID()])) {
             $signs = $prefixes[$this->getID()];
             $this->pricePrefix->set($signs[0]);
             if (isset($signs[1])) {
                 $this->priceSuffix->set($signs[1]);
             }
         }
     }
     // check if default currency exists
     if (!ActiveRecord::getRecordSet('Currency', select(eq('Currency.isDefault', 1)))->getTotalRecordCount()) {
         $this->isDefault->set(true);
         $this->isEnabled->set(true);
     }
     $this->setLastPosition();
     return parent::insert();
 }