コード例 #1
0
 /**
  * Removes image with ids specified in post request.
  * On success returns 'OK'
  */
 public function actionSet()
 {
     $id = $_POST['id'];
     $photo = GalleryPhoto::model()->findByPk($id);
     $p = $photo->file_name;
     $path = mb_pathinfo($p);
     $ext = $path['extension'];
     if (Yii::app()->params['LIGHTSPEED_MT'] == '1') {
         $prefix = "//lightspeedwebstore.s3.amazonaws.com/" . Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'] . '/gallery';
     } else {
         $prefix = '/images/gallery';
     }
     $file = $prefix . '/' . $photo->gallery_id . '/' . $photo->id . "." . $photo->thumb_ext;
     _xls_set_conf('HEADER_IMAGE', $file);
     echo 'OK';
 }
コード例 #2
0
ファイル: Twig.php プロジェクト: fdcore/yacms
 public function render($template, $data = null, $return = false)
 {
     $app = \Slim\Slim::getInstance();
     if (defined('IS_ADMIN')) {
         $loader = new Twig_Loader_Filesystem(BASE_PATH . '/_app/templates/admin');
     } else {
         $loader = new Twig_Loader_Filesystem(BASE_PATH . '/_app/templates');
     }
     $twig = new Twig_Environment($loader);
     $bundles = directory_map(BASE_PATH . '/_app/bundles');
     foreach ($bundles as $f) {
         $pi = mb_pathinfo($f);
         $type_name = explode('.', $pi['filename']);
         include_once BASE_PATH . '/_app/bundles/' . $f;
         if ($type_name[0] == 'filter') {
             $twig->addFilter(new Twig_SimpleFilter($type_name[1], $type_name[1]));
         }
         if ($type_name[0] == 'func') {
             $twig->addFunction(new Twig_SimpleFunction($type_name[1], $type_name[1]));
         }
         if ($type_name[0] == 'test') {
             $twig->addTest(new Twig_SimpleTest($type_name[1], $type_name[1]));
         }
     }
     $req = $app->request;
     $data['request'] = $req;
     if (isset($_SESSION['phone'])) {
         $data['phone'] = $app->model->get_user($_SESSION['phone']);
     }
     $data['config'] = $app->config;
     $data['user'] = $app->model->get_user();
     if (isset($_SESSION['slim.flash'])) {
         $data['flash'] = $_SESSION['slim.flash'];
     }
     $data = array_merge($this->data->all(), (array) $data);
     if ($return) {
         return $twig->render($template, $data);
     } else {
         echo $twig->render($template, $data);
     }
 }
コード例 #3
0
ファイル: Images.php プロジェクト: uiDeveloper116/webstore
 public function SaveImageData($strName, $blbImage)
 {
     $this->DeleteImage();
     $strPath = Images::GetImagePath($strName);
     $arrPath = mb_pathinfo($strPath);
     $strFolder = $arrPath['dirname'];
     $strSaveFunc = 'imagepng';
     if ($arrPath['extension'] == 'jpg') {
         $strSaveFunc = 'imagejpeg';
     }
     if ($arrPath['extension'] == 'gif') {
         $strSaveFunc = 'imagegif';
     }
     if ($strSaveFunc == "imagepng") {
         //Set transparency
         $retVal = $this->check_transparent($blbImage);
         if ($retVal) {
             imagealphablending($blbImage, false);
             imagesavealpha($blbImage, true);
         }
     }
     if ($this->SaveImageFolder($strFolder) && $strSaveFunc($blbImage, $strPath)) {
         $this->image_path = $strName;
         return true;
     }
     Yii::log("Failed to save file {$strName}", 'image', __FUNCTION__);
     return false;
 }
コード例 #4
0
 /**
  * Look for all modules (class files) in extensions folder.
  *
  * @param string $moduletype Type of module which determines what folder to scan.
  *
  * @return void
  */
 public function scanModules($moduletype = "payment")
 {
     if ($moduletype == "theme") {
         $files = glob(YiiBase::getPathOfAlias('webroot.themes') . '/*', GLOB_ONLYDIR);
         foreach ($files as $key => $file) {
             if (stripos($file, '/themes/trash') > 0 || stripos($file, '/themes/_customcss') > 0) {
                 unset($files[$key]);
             }
         }
     } else {
         $arrCustom = array();
         if (file_exists(YiiBase::getPathOfAlias("custom.extensions." . $moduletype))) {
             $arrCustom = glob(realpath(YiiBase::getPathOfAlias("custom.extensions." . $moduletype)) . '/*', GLOB_ONLYDIR);
         }
         if (!is_array($arrCustom)) {
             $arrCustom = array();
         }
         $files = array_merge(glob(realpath(YiiBase::getPathOfAlias('ext.ws' . $moduletype)) . '/*', GLOB_ONLYDIR), $arrCustom);
     }
     foreach ($files as $file) {
         $moduleName = mb_pathinfo($file, PATHINFO_BASENAME);
         $version = 0;
         $name = $moduleName;
         if ($moduletype === 'theme') {
             $model = Yii::app()->getComponent('wstheme')->getAdminModel($moduleName);
             $configuration = '';
             if ($model) {
                 $version = $model->version;
                 $name = $model->name;
                 $configuration = $model->getDefaultConfiguration();
             }
         } else {
             try {
                 $version = Yii::app()->getComponent($moduleName)->Version;
                 $name = Yii::app()->getComponent($moduleName)->AdminNameNormal;
                 $configuration = Yii::app()->getComponent($moduleName)->getDefaultConfiguration();
             } catch (Exception $e) {
                 Yii::log("{$moduleName} component can't be read " . $e, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
             }
         }
         //Check if module is already in database
         $objModule = Modules::LoadByName($moduleName);
         if (!$objModule instanceof Modules) {
             //The module doesn't exist, attempt to install it
             try {
                 $objModule = new Modules();
                 $objModule->active = 0;
                 $objModule->module = $moduleName;
                 $objModule->category = $moduletype;
                 $objModule->version = $version;
                 $objModule->name = $name;
                 $objModule->configuration = $configuration;
                 if (!$objModule->save()) {
                     Yii::log("Found widget {$moduleName} could not install " . print_r($objModule->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
                 }
             } catch (Exception $e) {
                 Yii::log("Found {$moduletype} widget {$moduleName} could not install " . $e, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
             }
         }
         $objModule->version = $version;
         $objModule->name = $name;
         $objModule->save();
     }
 }
コード例 #5
0
 protected function getGalleryThemes()
 {
     $postVar = "";
     $objCurrentSettings = Modules::model()->findAllByAttributes(array('category' => 'theme'));
     foreach ($objCurrentSettings as $item) {
         $postVar[] = array($item->module, $item->version);
     }
     $arr = array();
     $strXml = $this->getFile("http://" . _xls_get_conf('LIGHTSPEED_UPDATER', 'updater.lightspeedretail.com') . "/webstore/themes", array('version' => XLSWS_VERSIONBUILD, 'themes' => $postVar));
     if (stripos($strXml, "404 Not Found") > 0 || stripos($strXml, "An internal error") > 0 || empty($strXml)) {
         Yii::log("Connect failed to updater", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         return $arr;
     }
     $oXML = new SimpleXMLElement($strXml);
     foreach ($oXML->themes->theme as $item) {
         $filename = mb_pathinfo($item->installfile, PATHINFO_BASENAME);
         $filename = str_replace(".zip", "", $filename);
         $arr[$filename]['img'] = CHtml::image($item->thumbnail, $item->name);
         $arr[$filename]['title'] = strtolower($item->name);
         $arr[$filename]['name'] = $item->name;
         $arr[$filename]['version'] = $item->version;
         $arr[$filename]['installfile'] = $item->installfile;
         $arr[$filename]['releasedate'] = strtotime($item->releasedate);
         $arr[$filename]['description'] = $item->description;
         $arr[$filename]['credit'] = $item->credit;
         $arr[$filename]['md5'] = $item->md5;
         $arr[$filename]['options'] = "";
         $arr[$filename]['newver'] = $item->newver;
         $arr[$filename]['installed'] = $this->checkThemeInstalled($item->name);
     }
     return $arr;
 }
コード例 #6
0
ファイル: install_db.php プロジェクト: xctcc/congtu
 flushNow();
 // var counters
 $r = 0;
 // number removed files
 $u = 0;
 // number of updated files
 foreach ($bw_files as $bw_file) {
     $bw_array = load_old_db($bw_file);
     //	preprint($bw_array);
     // check if db
     if (!isset($bw_array[0]['id']) && !isset($bw_array['id'])) {
         unlink($bw_file);
         $r++;
     } elseif (isset($bw_array[0]['id'])) {
         $u++;
         $file_info = mb_pathinfo($bw_file);
         $icl = array('id' => $bw_array[0]['id'], 'date' => time(), 'image' => 0, 'thumb_mid' => 0, 'thumb' => 0, 'gallery' => 0, 'bandwidth' => 0, 'lr_date' => 0, 'lr_image' => 0, 'lr_thumb_mid' => 0, 'lr_thumb' => 0, 'lr_gallery' => 0, 'lr_bandwidth' => 0);
         // workout the last reset date for home page and image list (use month for now)
         //	if ($settings['SET_BANDWIDTH_RESET'] == 'm'){
         $resetdate = strtotime('01 ' . date('M Y'));
         $n_resetdate = strtotime('next month');
         //	}else{
         //		 $resetdate = strtotime('last monday', strtotime('tomorrow'));
         //		 $n_resetdate = strtotime("next Monday");
         //	}
         foreach ($bw_array as $bw_item) {
             if ($bw_item['date'] > $resetdate) {
                 if ($bw_item['date'] > $icl['lr_date']) {
                     $icl['lr_date'] = $bw_item['date'];
                 }
                 if ($bw_item['image']) {
コード例 #7
0
    /**
     * Triggers to perform upgrade tasks using a special key from the db upgrade routine
     * If we have to move files or remove something specifically during an upgrade
     * @param $id
     */
    public function runTask($id)
    {
        Yii::log("Running upgrade task {$id}.", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
        switch ($id) {
            case 416:
                //Place any header images in our new gallery library
                Gallery::LoadGallery(1);
                $d = dir(YiiBase::getPathOfAlias('webroot') . "/images/header");
                while (false !== ($filename = $d->read())) {
                    if ($filename[0] != ".") {
                        $model = new GalleryPhoto();
                        $model->gallery_id = 1;
                        $model->file_name = $filename;
                        $model->name = '';
                        $model->description = '';
                        $model->save();
                        $arrImages["/images/header/" . $filename] = CHtml::image(Yii::app()->request->baseUrl . "/images/header/" . $filename);
                        $src = YiiBase::getPathOfAlias('webroot') . "/images/header/" . $filename;
                        $fileinfo = mb_pathinfo($filename);
                        $model->thumb_ext = $fileinfo['extension'];
                        $model->save();
                        $imageFile = new CUploadedFile($filename, $src, "image/" . $fileinfo['extension'], getimagesize($src), null);
                        if (Yii::app()->params['LIGHTSPEED_MT'] == '1') {
                            $model->setS3Image($imageFile);
                        } else {
                            $model->setImage($imageFile);
                        }
                    }
                }
                break;
            case 417:
                //Remove wsconfig.php reference from /config/main.php
                if (Yii::app()->params['LIGHTSPEED_MT'] == 1) {
                    return;
                }
                //only applies to single tenant
                $main_config = file_get_contents(YiiBase::getPathOfAlias('webroot') . "/config/main.php");
                // @codingStandardsIgnoreStart
                $main_config = str_replace('if (file_exists(dirname(__FILE__).\'/wsconfig.php\'))
	$wsconfig = require(dirname(__FILE__).\'/wsconfig.php\');
else $wsconfig = array();', '//For customization, let\'s look in custom/config for a main.php which will be merged
//Use this instead of modifying this main.php directly
if(file_exists(realpath(dirname(__FILE__)."/../custom").\'/config/main.php\'))
	$arrCustomConfig = require(realpath(dirname(__FILE__)."/../custom").\'/config/main.php\');
else
	$arrCustomConfig = array();', $main_config);
                $main_config = str_replace('),$wsconfig);', '),
	$arrCustomConfig
);', $main_config);
                // @codingStandardsIgnoreEnd
                file_put_contents(YiiBase::getPathOfAlias('webroot') . "/config/main.php", $main_config);
                break;
            case 423:
                // add cart/cancel url rule for sim payment methods (ex. moneris) that require hardcoded cancel urls
                $main_config = file_get_contents(YiiBase::getPathOfAlias('webroot') . "/config/main.php");
                // check to see if the entry is already there and write it if it isn't
                $position = strpos($main_config, 'cart/cancel');
                if (!$position) {
                    $comments = "\r\r\t\t\t\t\t\t// moneris simple integration requires a hardcoded cancel URL\r\t\t\t\t\t\t// any other methods that require something similar we can add a cart/cancel rule like this one\r\t\t\t\t\t\t";
                    $pos = strpos($main_config, "sro/view',") + strlen("sro/view',");
                    $main_config = substr_replace($main_config, $comments . "'cart/cancel/<order_id:\\WO-[0-9]+>&<cancelTXN:(.*)>'=>'cart/cancel',\t\t\t\t\t\t", $pos, 0);
                    file_put_contents(YiiBase::getPathOfAlias('webroot') . "/config/main.php", $main_config);
                }
                break;
            case 427:
                // Add URL mapping for custom pages
                // If the store's on multi-tenant server, do nothing
                if (Yii::app()->params['LIGHTSPEED_MT'] > 0) {
                    return;
                }
                $main_config = file_get_contents(YiiBase::getPathOfAlias('webroot') . "/config/main.php");
                $search_string = "'<id:(.*)>/pg'";
                // Check if the entry already exists. If not, add the mapping.
                if (strpos($main_config, $search_string) === false) {
                    $position = strpos($main_config, "'<feed:[\\w\\d\\-_\\.()]+>.xml' => 'xml/<feed>', //xml feeds");
                    $custompage_mapping = "'<id:(.*)>/pg'=>array('custompage/index', 'caseSensitive'=>false,'parsingOnly'=>true), //Custom Page\r\t\t\t\t\t\t";
                    $main_config = substr_replace($main_config, $custompage_mapping, $position, 0);
                    file_put_contents(YiiBase::getPathOfAlias('webroot') . "/config/main.php", $main_config);
                }
                break;
            case 447:
                // Remove bootstrap, add in separate main.php
                // If the store's on multi-tenant server, do nothing
                if (Yii::app()->params['LIGHTSPEED_MT'] > 0) {
                    return;
                }
                $main_config = file_get_contents(YiiBase::getPathOfAlias('webroot') . "/config/main.php");
                // @codingStandardsIgnoreStart
                //Remove preloading bootstrap, loaded now in Controller.php on demand if needed
                $main_config = str_replace("\t\t\t'bootstrap',\n", "", $main_config);
                //Bootstrap is loaded on demand now
                $main_config = str_replace("//Twitter bootstrap\n\t\t\t\t'bootstrap'=>array(\n\t\t\t\t\t'class'=>'ext.bootstrap.components.Bootstrap',\n\t\t\t\t\t'responsiveCss'=>true,\n\t\t\t\t),", "", $main_config);
                //Remove old email strings and facebook strings, they're loaded elsewhere now
                $main_config = str_replace("//Email handling\n\t\t\t\t'email'=>require(dirname(__FILE__).'/wsemail.php'),\n", "", $main_config);
                //Remove old email strings and facebook strings, they're loaded elsewhere now
                $main_config = str_replace("//Facebook integration\n\t\t\t\t'facebook'=>require(dirname(__FILE__).'/wsfacebook.php'),\n", "", $main_config);
                //for any main.php that was missing all of this before
                $main_config = str_replace('),array());', '),
	$arrCustomConfig
);', $main_config);
                $main_config = str_replace('	\'params\'=>array(
		// this is used in contact page
		\'mainfile\'=>\'yes\',
	),

);', '	\'params\'=>array(
		// this is used in contact page
		\'mainfile\'=>\'yes\',
	)),
	$arrCustomConfig
);', $main_config);
                $main_config = str_replace('// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(', '// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return CMap::mergeArray(
	array(', $main_config);
                $search_string = "//For customization,";
                // Check if the entry already exists. If not, add the mapping.
                if (strpos($main_config, $search_string) === false) {
                    $main_config = str_replace('Yii::setPathOfAlias(\'extensions\', dirname(__FILE__).DIRECTORY_SEPARATOR.\'../core/protected/extensions\');

', 'Yii::setPathOfAlias(\'extensions\', dirname(__FILE__).DIRECTORY_SEPARATOR.\'../core/protected/extensions\');

//For customization, let\'s look in custom/config for a main.php which will be merged
//Use this instead of modifying this main.php directly
if(file_exists(realpath(dirname(__FILE__)."/../custom").\'/config/main.php\'))
	$arrCustomConfig = require(realpath(dirname(__FILE__)."/../custom").\'/config/main.php\');
else
	$arrCustomConfig = array();

', $main_config);
                }
                // @codingStandardsIgnoreEnd
                file_put_contents(YiiBase::getPathOfAlias('webroot') . "/config/main.php", $main_config);
                @unlink(YiiBase::getPathOfAlias('webroot') . "/config/wsemail.php");
                @unlink(YiiBase::getPathOfAlias('webroot') . "/config/wsfacebook.php");
                if (Yii::app()->theme) {
                    $arrActiveCss = Yii::app()->theme->info->cssfiles;
                    $arrActiveCss[] = Yii::app()->theme->config->CHILD_THEME;
                    Yii::app()->theme->config->activecss = $arrActiveCss;
                }
                break;
        }
    }
コード例 #8
0
 public function delete()
 {
     if (Yii::app()->params['LIGHTSPEED_MT'] == '1') {
         $this->_galleryDir = "gallery";
     }
     $p = $this->file_name;
     $path = mb_pathinfo($p);
     $ext = $path['extension'];
     $ext = $this->thumb_ext;
     $this->removeFile($this->galleryDir . '/' . $this->getFileName('') . '.' . $ext);
     $this->removeFile($this->galleryDir . '/_' . $this->getFileName('') . '.' . $this->galleryExt);
     foreach ($this->gallery->versions as $version => $actions) {
         $this->removeFile($this->galleryDir . '/' . $this->getFileName($version) . '.' . $this->galleryExt);
     }
     return parent::delete();
 }
コード例 #9
0
ファイル: Image.php プロジェクト: uiDeveloper116/webstore
 /** 
  * Output the image to the browser. 
  * 
  * @param   boolean  keep or discard image process actions
  * @return	object 
  */
 public function render($keep_actions = FALSE)
 {
     $new_image = $this->image['file'];
     // Separate the directory and filename
     $dir = mb_pathinfo($new_image, PATHINFO_DIRNAME);
     $file = mb_pathinfo($new_image, PATHINFO_BASENAME);
     // Normalize the path
     $dir = str_replace('\\', '/', realpath($dir)) . '/';
     // Process the image with the driver
     $status = $this->driver->process($this->image, $this->actions, $dir, $file, $render = TRUE);
     // Reset actions. Subsequent save() or render() will not apply previous actions.
     if ($keep_actions === FALSE) {
         $this->actions = array();
     }
     return $status;
 }
コード例 #10
0
 function __construct($params)
 {
     $this->start_time = microtime(true);
     if (!isset($params)) {
         $this->printError("no params defined.");
         return false;
     }
     if (!isset($params["system"])) {
         $this->printError("no system params defined.");
         return false;
     }
     if (isset($params["system"]["show_errors"])) {
         $this->show_errors = $params["system"]["show_errors"];
     }
     if ($this->show_errors == true) {
         error_reporting(E_ERROR | E_WARNING | E_PARSE);
     } else {
         error_reporting(0);
     }
     if (isset($params["system"]["root"])) {
         $this->root = $params["system"]["root"];
     }
     if (isset($params["system"]["clean_urls"])) {
         $this->clean_urls = $params["system"]["clean_urls"];
     }
     if (isset($params["system"]["main_page"])) {
         $this->main_page = $params["system"]["main_page"];
     }
     if (isset($params["system"]["404_page"])) {
         $this->notfound_page = $params["system"]["404_page"];
     }
     if (isset($params["system"]["auto_pages"])) {
         $this->auto_pages = $params["system"]["auto_pages"];
     }
     if (isset($params["menus"])) {
         $this->menus = $params["menus"];
     }
     if (!isset($params["templates"])) {
         $this->printError("no templates defined.");
         return false;
     }
     if (!isset($params["pages"]) && !strlen($this->auto_pages)) {
         $this->printError("no pages defined.");
         return false;
     }
     if (isset($params["aliases"])) {
         $this->aliases = $params["aliases"];
     }
     $this->pages = $params["pages"];
     foreach ($this->pages as &$page) {
         if (!isset($page["name"])) {
             $page["name"] = mb_pathinfo($page["path"], PATHINFO_FILENAME);
         }
     }
     if (strlen($this->auto_pages)) {
         foreach (glob($this->auto_pages . "/*.{html,htm,txt}", GLOB_BRACE) as $file) {
             $add = true;
             foreach ($this->pages as $addedpage) {
                 if ($addedpage["path"] == $file) {
                     $add = false;
                     break;
                 }
             }
             if ($add) {
                 $this->pages[] = array("path" => $file, "title" => mb_pathinfo($file, PATHINFO_FILENAME), "name" => mb_pathinfo($file, PATHINFO_FILENAME));
             }
         }
     }
     $this->templates = $params["templates"];
 }
コード例 #11
0
ファイル: helpers.php プロジェクト: uiDeveloper116/webstore
function _upload_default_header_to_s3()
{
    Gallery::LoadGallery(1);
    $d = dir(YiiBase::getPathOfAlias('webroot') . "/images/header");
    while (false !== ($filename = $d->read())) {
        if ($filename == "defaultheader.png") {
            $model = new GalleryPhoto();
            $model->gallery_id = 1;
            $model->file_name = $filename;
            $model->name = '';
            $model->description = '';
            $model->thumb_ext = 'png';
            $model->save();
            $arrImages["/images/header/" . $filename] = CHtml::image(Yii::app()->request->baseUrl . "/images/header/" . $filename);
            $src = YiiBase::getPathOfAlias('webroot') . "/images/header/" . $filename;
            $fileinfo = mb_pathinfo($filename);
            $imageFile = new CUploadedFile($filename, $src, "image/" . $fileinfo['extension'], getimagesize($src), null);
            if (Yii::app()->params['LIGHTSPEED_MT'] == '1') {
                $model->setS3Image($imageFile);
            }
            _xls_set_conf('HEADER_IMAGE', "//lightspeedwebstore.s3.amazonaws.com/" . _xls_get_conf('LIGHTSPEED_HOSTING_LIGHTSPEED_URL') . "/gallery/1/" . $model->id . ".png");
        }
    }
}
コード例 #12
0
ファイル: routes.php プロジェクト: fdcore/yacms
<?php

$controllers = directory_map(BASE_PATH . '_app/controllers');
if (count($controllers > 0)) {
    foreach ($controllers as $file) {
        if (is_array($file)) {
            continue;
        }
        $file = mb_pathinfo($file);
        $file = $file['filename'];
        if ($file == 'index') {
            continue;
        }
        $app->group('/' . $file, function () use($app, $file) {
            include_once BASE_PATH . '_app/controllers/' . $file . '.php';
        });
    }
}
if (file_exists(BASE_PATH . '_app/controllers/index.php')) {
    include BASE_PATH . '_app/controllers/index.php';
}