Example #1
0
 /**
  * Submit dello step2D, � stata scelta la tabella
  *
  * @param string $oldState
  * @return void
  */
 function executeLater_step2Csv($oldState)
 {
     // controlla se � stato ftto submit
     if (strtolower(__Request::get('action', '')) == 'next') {
         // sposta il file caricato nella cache
         if (isset($_FILES['mbCsvFile']) && !empty($_FILES['mbCsvFile']) && !empty($_FILES['mbCsvFile']['name'])) {
             $file = $_FILES['mbCsvFile'];
             $file_path = $file['tmp_name'];
             $file_name = $file['name'];
             $file_destname = __Paths::getRealPath('CACHE') . md5(time() . $file_name) . '.csv';
             if (move_uploaded_file($file_path, $file_destname)) {
                 $moduleName = explode('.', $file_name);
                 $options = array('filePath' => $file_destname, 'enclosure' => __Request::get('mbCsvEnclose', ';'), 'delimiter' => __Request::get('mbCsvSeparate', ';'));
                 $this->_parent->refreshToState('step3', array('mbTable' => $this->getModuleName($moduleName[0]), 'mbTableDB' => __Request::get('table'), 'mbName' => $moduleName[0], 'mbModuleType' => 'csv', 'mbCsvOptions' => $options));
             } else {
                 // errore
                 $this->_parent->validateAddError(__T('Errore nel caricamento del file'));
             }
             @unlink($file_destname);
         } else {
             // errore
             $this->_parent->validateAddError(__T('Errore nel caricamento del file'));
         }
     }
 }
Example #2
0
 /**
  * @param int $n
  *
  * @return mixed
  * @throws Exception
  */
 static function &getConnection($n = 0)
 {
     static $instance = array();
     if (!isset($instance['__' . $n])) {
         $options = array();
         $sufix = $n == 0 ? '' : '#' . $n;
         switch (__Config::get('DB_TYPE' . $sufix)) {
             case 'sqlite':
                 $dsn = 'sqlite:' . __Paths::getRealPath('APPLICATION', 'data/' . __Config::get('DB_NAME' . $sufix));
                 $dbUser = '';
                 $dbPassword = '';
                 break;
             default:
                 $socket = __Config::get('DB_SOCKET' . $sufix);
                 $socket = empty($socket) ? '' : ';unix_socket=' . $socket;
                 $dsn = 'mysql:dbname=' . __Config::get('DB_NAME' . $sufix) . ';host=' . __Config::get('DB_HOST' . $sufix) . $socket;
                 $dbUser = __Config::get('DB_USER' . $sufix);
                 $dbPassword = __Config::get('DB_PSW' . $sufix);
                 if (__Config::get('CHARSET') == 'utf-8') {
                     $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8");
                 }
                 if (__Config::get('DB_MYSQL_BUFFERED_QUERY')) {
                     $options[PDO::MYSQL_ATTR_USE_BUFFERED_QUERY] = true;
                 }
                 break;
         }
         $i = 0;
         $lastException = null;
         while (!isset($instance['__' . $n])) {
             try {
                 if ($i < 3) {
                     $instance['__' . $n] = new Connection($dsn, $dbUser, $dbPassword, $options);
                 } else {
                     break;
                 }
             } catch (Exception $e) {
                 $i++;
                 $lastException = $e;
                 $eventInfo = array('type' => GLZ_LOG_EVENT, 'data' => array('level' => GLZ_LOG_ERROR, 'group' => 'glizy.sql', 'message' => array('errorMessage' => $e->getMessage(), 'errorCode' => $e->getCode(), 'attempt' => $i)));
                 $evt = org_glizy_ObjectFactory::createObject('org.glizy.events.Event', org_glizy_ObjectValues::get('org.glizy', 'application'), $eventInfo);
                 org_glizy_events_EventDispatcher::dispatchEvent($evt);
             }
         }
         if (!isset($instance['__' . $n])) {
             throw new Exception($lastException->getMessage(), $lastException->getCode(), $lastException);
         }
     }
     return $instance['__' . $n];
 }
Example #3
0
 public static function getLocalePath($languageId)
 {
     return __Paths::getRealPath('APPLICATION_TO_ADMIN') . self::BASE_PATH . 'locale/' . $languageId . '.php';
 }
Example #4
0
 public function getTemplateCache()
 {
     $cache = org_glizy_ObjectFactory::createObject('org.glizy.cache.CacheFunction', $this, -1, false, __Paths::getRealPath('APPLICATION_TO_ADMIN_CACHE'));
     return $cache;
 }
Example #5
0
 function __construct()
 {
     parent::__construct();
     $this->cache = org_glizy_ObjectFactory::createObject('org.glizy.cache.CacheFunction', $this, __Config::get('glizycms.sitemap.cacheLife'), false, __Paths::getRealPath('APPLICATION_TO_ADMIN_CACHE'));
 }
Example #6
0
<?php

require_once "core/core.inc.php";
$application = org_glizy_ObjectFactory::createObject('org.glizycms.core.application.Application', 'application');
org_glizy_Paths::addClassSearchPath('admin/application/classes/');
$application->runSoft();
$timestamp = __Request::get('timestamp');
$lastUpdate = org_glizy_Registry::get('movio/modules/publishApp/lastUpdate');
$result = array('updated' => $lastUpdate > $timestamp, 'lastUpdate' => $lastUpdate, 'fileSize' => @filesize(__Paths::getRealPath('BASE') . 'export/mobileContents.zip'), 'url' => GLZ_HOST . '/export/' . 'mobileContents.zip', 'checkUpdateUrl' => GLZ_HOST . '/checkUpdate.php');
header("Content-Type: application/json");
echo json_encode($result);
Example #7
0
 private function insertWatermark(&$img, $width, $height, $mode)
 {
     $minWidth = __Config::get('IMG_WATERMARK_MIN_WIDTH');
     $minHeight = __Config::get('IMG_WATERMARK_MIN_HEIGHT');
     $watermarkFile = __Config::get('IMG_WATERMARK');
     $pos = __Config::get('IMG_WATERMARK_POS') ?: 'RB';
     $watermarkFile = $watermarkFile ? __Paths::getRealPath('BASE', $watermarkFile) : false;
     if (!$watermarkFile || $minWidth >= $width && $minHeight >= $height) {
         return;
     }
     $perc = __Config::get('IMG_WATERMARK_SIZE_PERC');
     if ($mode == 'Imagick') {
         $watermark = new Imagick();
         $watermark->readImage($watermarkFile);
         $w_height = $watermark->getImageHeight();
         $w_width = $watermark->getImageWidth();
     } else {
         $watermark = imagecreatefrompng($watermarkFile);
         imagealphablending($watermark, true);
         $w_width = imagesx($watermark);
         $w_height = imagesy($watermark);
     }
     if ($width > $height) {
         $sy = $height * $perc / 100;
         $sx = $w_width / $w_height * $sy;
     } else {
         $sx = $width * $perc / 100;
         $sy = $sx * $w_height / $w_width;
     }
     $marg_left = $width / 100;
     //$margin_right = $margin_left;
     $marg_top = $height / 100;
     //$marg_bottom = $margin_top;
     switch ($pos) {
         case "LT":
             $posx = $marg_left;
             $posy = $marg_top;
             break;
         case "LC":
             $posx = $marg_left;
             $posy = $height / 2 - $w_height / 2;
             break;
         case "LB":
             $posx = $marg_left;
             $posy = $height - $sy - $marg_top;
             break;
         case "CT":
             $posx = $width / 2 - $w_width / 2;
             $posy = $marg_top;
             break;
         case "CC":
             $posx = $width / 2 - $w_width / 2;
             $posy = $height / 2 - $w_height / 2;
             break;
         case "CB":
             $posx = $width / 2 - $w_width / 2;
             $posy = $height - $sy - $marg_top;
             break;
         case "RT":
             $posx = $width - $sx - $marg_left;
             $posy = $marg_top;
             break;
         case "RC":
             $posx = $width - $sx - $marg_left;
             $posy = $height / 2 - $w_height / 2;
             break;
         case "RB":
         default:
             $posx = $width - $sx - $marg_left;
             $posy = $height - $sy - $marg_top;
     }
     if ($mode == 'Imagick') {
         $watermark->scaleImage($sx, $sy);
         $img->compositeImage($watermark, imagick::COMPOSITE_OVER, $posx, $posy);
         $watermark->clear();
         $watermark->destroy();
     } else {
         imagecopyresampled($img, $watermark, $posx, $posy, 0, 0, $sx, $sy, imagesx($watermark), imagesy($watermark));
         imagedestroy($watermark);
     }
 }
Example #8
0
 public function onInvalidateSitemap()
 {
     $siteMap = org_glizy_ObjectFactory::createObject('org.glizycms.core.application.SiteMapDB');
     $siteMap->invalidate();
     $siteMap = org_glizy_ObjectFactory::createObject('org.glizy.compilers.Routing', __Paths::getRealPath('APPLICATION_TO_ADMIN_CACHE'));
     $siteMap->invalidate();
 }