Example #1
0
 /**
  * @param        $msg
  * @param int    $level
  * @param string $group
  *
  * @return bool|mixed
  * @throws Exception
  */
 function log($msg, $level = GLZ_LOG_DEBUG, $group = '')
 {
     if (!$this->_check($level, $group)) {
         return false;
     }
     $t = explode(" ", microtime());
     $params = array('@timestamp' => date("Y-m-d\\TH:i:s", $t[1]) . substr((string) $t[0], 1, 4) . date("P"), 'host' => !isset($_SERVER["SERVER_ADDR"]) ? 'console' : $_SERVER["SERVER_ADDR"], 'group' => $group, 'level' => $level, 'caller' => $this->getCallingName(), 'pid' => getmypid(), 'appName' => __Config::get('APP_NAME'));
     $message = array_merge($this->_message, $params);
     if (is_array($msg)) {
         $message = array_merge($message, $msg);
     } else {
         $message = array_merge($message, array('message' => $msg));
     }
     // set_time_limit(0);
     $data = json_encode($message);
     $restUrl = $this->_host . $this->_index . '-' . date("Y.m.d") . '/' . $this->_type;
     $ch = curl_init($restUrl);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data)));
     if (!($result = curl_exec($ch))) {
         if (class_exists('org_glizy_Config') && org_glizy_Config::get('DEBUG') === true) {
             throw new Exception(curl_error($ch), curl_errno($ch));
         }
     }
     curl_close($ch);
     return $result;
 }
Example #2
0
/**
 * This file is part of the GLIZY framework.
 * Copyright (c) 2005-2012 Daniele Ugoletti <*****@*****.**>
 *
 * For the full copyright and license information, please view the COPYRIGHT.txt
 * file that was distributed with this source code.
 */
function getImage($applicationPath, $corePath = '')
{
    require_once $corePath . 'core/core.inc.php';
    org_glizy_Paths::init($applicationPath, $corePath);
    org_glizy_Config::init();
    $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : NULL;
    $w = isset($_REQUEST['w']) ? intval($_REQUEST['w']) : NULL;
    $h = isset($_REQUEST['h']) ? intval($_REQUEST['h']) : NULL;
    $force = isset($_REQUEST['f']) ? $_REQUEST['f'] == 'true' || $_REQUEST['f'] == '1' : false;
    $crop = isset($_REQUEST['c']) ? $_REQUEST['c'] == 'true' || $_REQUEST['c'] == '1' : false;
    if (is_null($id)) {
        exit;
    }
    glz_import('org.glizycms.mediaArchive.MediaManager');
    $media = org_glizycms_mediaArchive_MediaManager::getMediaById($id);
    if ($media->type != 'IMAGE') {
        exit;
    }
    if (!is_null($w) && !is_null($h)) {
        //resize the image
        $mediaInfo = $media->getResizeImage($w, $h, $crop, 0, $force);
    } else {
        // get the full image
        $mediaInfo = $media->getImageInfo();
    }
    $ext = array(IMG_GIF => '.gif', IMG_JPG => '.jpeg', IMG_PNG => '.png', IMG_WBMP => '.wbmp');
    header("location: " . GLZ_HOST . '/' . $mediaInfo['fileName']);
}
Example #3
0
 private function includeFolder($folder)
 {
     // controlla se il file in cache è valido
     $options = array('cacheDir' => org_glizy_Paths::get('CACHE_CODE'), 'lifeTime' => org_glizy_Config::get('CACHE_CODE'), 'readControlType' => '', 'fileExtension' => '.css');
     $cacheSignature = get_class($this) . $folder;
     $cacheObj = org_glizy_ObjectFactory::createObject('org.glizy.cache.CacheFile', $options);
     $cssFileName = $cacheObj->verify($cacheSignature);
     if ($cssFileName === false) {
         $cssFile = '';
         if ($dir_handle = @opendir($folder)) {
             while ($file_name = readdir($dir_handle)) {
                 if ($file_name != "." && $file_name != ".." && !is_dir("{$dir}/{$file_name}")) {
                     $f[] = $file_name;
                 }
             }
             sort($f);
             closedir($dir_handle);
             foreach ($f as $element) {
                 $cssCode = file_get_contents($folder . '/' . $element);
                 $cssFile .= $cssCode . "\n";
             }
         }
         if (__Config::get('DEBUG') !== false) {
             $cacheObj->save($cssFile, NULL, get_class($this));
         } else {
             $cacheObj->save($cssFile, NULL, $cacheSignature);
         }
         $cssFileName = $cacheObj->getFileName();
     }
     return $cssFileName;
 }
Example #4
0
 function __construct($model, $lifeTime = null, $cacheFolder = null)
 {
     $cacheFolder = $cacheFolder ? $cacheFolder : org_glizy_Paths::getRealPath('CACHE_CODE');
     $this->model = $model;
     $this->group = $cacheFolder . $model;
     $options = array('cacheDir' => $cacheFolder, 'lifeTime' => !$lifeTime ? org_glizy_Config::get('CACHE_CODE') : $lifeTime, 'readControlType' => '', 'fileExtension' => '.php');
     $this->_cacheObj =& org_glizy_ObjectFactory::createObject('org.glizy.cache.CacheFile', $options);
 }
Example #5
0
 function init()
 {
     $this->_siteMapArray = array();
     $this->_pageTypeMap = array();
     $application =& org_glizy_ObjectValues::get('org.glizy', 'application');
     $this->_user =& $application->getCurrentUser();
     $this->isAdmin = $application->isAdmin();
     $this->hidePrivatePage = org_glizy_Config::get('HIDE_PRIVATE_PAGE', true);
 }
Example #6
0
 function log($msg, $level = GLZ_LOG_DEBUG, $group = '')
 {
     if (!$this->_check($level, $group)) {
         return false;
     }
     if (is_array($msg) || is_object($msg)) {
         $msg = json_encode($msg);
     }
     org_glizy_helpers_Mail::sendEmail(array('email' => $this->destEmail, 'name' => $this->destEmail), array('email' => org_glizy_Config::get('SMTP_EMAIL'), 'name' => org_glizy_Config::get('SMTP_SENDER')), $this->mailTitle, str_replace("\t", "<br />", $this->_format($msg, $level, $group)));
     return true;
 }
Example #7
0
 function __construct($parent, $lifeTime = null, $memoryCache = false, $cacheFolder = null, $group = null)
 {
     $cacheFolder = $cacheFolder ? $cacheFolder : org_glizy_Paths::getRealPath('CACHE_CODE');
     $this->parent = $parent;
     $this->memoryCache = $memoryCache;
     $this->group = $group ? $group : $cacheFolder . get_class($this->parent);
     $options = array('cacheDir' => $cacheFolder, 'lifeTime' => !$lifeTime ? org_glizy_Config::get('CACHE_CODE') : $lifeTime, 'readControlType' => '', 'fileExtension' => '.php');
     if ($options['lifeTime'] == '-1') {
         $options['lifeTime'] = null;
     }
     $this->_cacheObj =& org_glizy_ObjectFactory::createObject('org.glizy.cache.CacheFile', $options);
 }
Example #8
0
 function getItems()
 {
     $menuProxy = org_glizy_ObjectFactory::createObject('org.glizycms.contents.models.proxy.MenuProxy');
     $siteMap = $menuProxy->getSiteMap();
     $siteMapIterator =& org_glizy_ObjectFactory::createObject('org.glizy.application.SiteMapIterator', $siteMap);
     $menus = array();
     // $menus[] = array('-', '', 0);
     $maxDepth = org_glizy_Config::get('ADM_SITE_MAX_DEPTH');
     $maxDepth = !is_null($maxDepth) && $this->getAttribute('maxDepth') ? $maxDepth : NULL;
     $pageTypeFilter = $this->getAttribute('pageType');
     $startFrom = $this->getAttribute('startFrom');
     if (is_null($startFrom)) {
         while (!$siteMapIterator->EOF) {
             $n = $siteMapIterator->getNodeArray();
             $siteMapIterator->moveNext();
             if (!is_null($maxDepth) && $n['depth'] > $maxDepth || $n['depth'] == 1 && !$this->_user->acl(__Config::get('SITEMAP_ID'), 'new') && $this->_content != 1) {
                 continue;
             }
             $pad = str_repeat('.  ', $n['depth'] - 1);
             if (!empty($pageTypeFilter)) {
                 if ($pageTypeFilter != $n['pageType']) {
                     continue;
                 }
                 $pad = '';
             }
             $this->_items[] = array('key' => $n['id'], 'value' => $pad . trim(strip_tags($n['title'])), 'selected' => $n['id'] == $this->_content ? 1 : 0, 'options' => $n['pageType']);
         }
     } else {
         $found = false;
         $menuDepth = 0;
         while (!$siteMapIterator->EOF) {
             $n = $siteMapIterator->getNodeArray();
             $siteMapIterator->moveNext();
             if ($n['id'] == $startFrom) {
                 $found = true;
                 $menuDepth = $n['depth'];
                 continue;
             }
             if ($found) {
                 if ($menuDepth == $n['depth']) {
                     break;
                 }
                 if (!empty($pageTypeFilter)) {
                     if ($pageTypeFilter != $n['pageType']) {
                         continue;
                     }
                 }
                 $this->_items[] = array('key' => $n['id'], 'value' => trim(strip_tags($n['title'])), 'selected' => $n['id'] == $this->_content ? 1 : 0, 'options' => $n['pageType']);
             }
         }
     }
 }
Example #9
0
 public function logout()
 {
     org_glizy_Session::start();
     $evt = array('type' => GLZ_EVT_USERLOGOUT, 'data' => '');
     $this->dispatchEvent($evt);
     if (org_glizy_Config::get('USER_LOG')) {
         $user = org_glizy_Session::get('glizy.user');
         $arLog =& org_glizy_ObjectFactory::createModel('org.glizy.models.UserLog');
         $arLog->load($user['logId']);
         $arLog->delete();
     }
     org_glizy_Session::removeAll();
     setcookie("glizy_username", "", time() - 3600);
     setcookie("glizy_password", "", time() - 3600);
 }
Example #10
0
 function fixLanguages($templateSource)
 {
     $templateSource = str_replace('<head>', '<head><base href="' . GLZ_HOST . '/" />', $templateSource);
     $templateSource = preg_replace('/(\\<html.*xml:lang=)"([^"]*)"/', '$1"' . $this->language . '"', $templateSource);
     $templateSource = preg_replace('/(\\<html.*lang=)"([^"]*)"/', '$1"' . $this->language . '"', $templateSource);
     if (org_glizy_Config::get('SEF_URL') === 'full') {
         // non è il massimo ma la regexp su testi lunghi crasha
         $templateSource = str_replace(array('href="#', 'href=\'#', 'href="noTranslate:'), array('href="' . __Routing::scriptUrl() . '#', 'href=\'' . __Routing::scriptUrl() . '#', 'href="'), $templateSource);
         //$newtemplateSource = preg_replace("/<(.*?)(href)\s*=\s*(\'|\")(\#.*)(\'|\")(.*?)>/si", "<$1$2=$3".__Routing::scriptUrl()."$4$5$6>", $templateSource);
         // if ( !empty( $newtemplateSource ) )
         // 			{
         // 				$templateSource = &$newtemplateSource;
         // 			}
     }
     return $templateSource;
 }
Example #11
0
 function process()
 {
     $allowGroups = $this->getAttribute('allowGroups') != '' ? explode(',', $this->getAttribute('allowGroups')) : array();
     if ((!org_glizy_Session::get('glizy.userLogged') || !(count($allowGroups) ? in_array($this->_user->groupId, $allowGroups) : true)) && $this->getAttribute('enabled')) {
         if (org_glizy_helpers_Link::scriptUrl() != org_glizy_helpers_Link::makeUrl('link', array('pageId' => org_glizy_Config::get('START_PAGE')))) {
             if ($this->getAttribute('showErrorMessage')) {
                 org_glizy_Session::set('glizy.loginError', org_glizy_locale_Locale::get('GLZ_LOGIN_NOACCESS'));
             }
             org_glizy_Session::set('glizy.loginUrl', __Request::get('__url__'));
         }
         org_glizy_helpers_Navigation::gotoUrl(org_glizy_helpers_Link::makeUrl('link', array('pageId' => $this->getAttribute('accessPageId'))));
         exit;
     }
     if ($this->getAttribute('checkAcl') && !$this->_user->acl($this->_application->getPageId(), 'visible')) {
         header('HTTP/1.0 403 Forbidden');
         exit;
     }
 }
Example #12
0
 /**
  * @param int    $errno
  * @param string $errstr
  * @param string $errfile
  * @param int    $errline
  * @param string $message
  * @param int    $headerCode
  */
 public static function show($errno, $errstr, $errfile, $errline, $message = '', $headerCode = 500)
 {
     $eventInfo = array('type' => 'dumpException', 'data' => array('message' => $message, 'errono' => $errono, 'file' => $errfile, 'errline' => $errline));
     $evt =& org_glizy_ObjectFactory::createObject('org.glizy.events.Event', $this, $eventInfo);
     org_glizy_events_EventDispatcher::dispatchEvent($evt);
     @header('HTTP/1.0 500 Internal Server Error');
     $errors = array(1 => 'E_ERROR', 2 => 'E_WARNING', 4 => 'E_PARSE', 8 => 'E_NOTICE', 16 => 'E_CORE_ERROR', 32 => 'E_CORE_WARNING', 64 => 'E_COMPILE_ERROR', 128 => 'E_COMPILE_WARNING', 256 => 'E_USER_ERROR', 512 => 'E_USER_WARNING', 2047 => 'E_ALL', 2048 => 'E_STRICT', 4096 => 'E_RECOVERABLE_ERROR');
     $e = array();
     $e['code'] = isset($errors[$errno]) ? $errors[$errno] : $errors[1];
     $e['description'] = $errstr;
     $e['message'] = $message;
     if (class_exists('org_glizy_Config') && org_glizy_Config::get('DEBUG') === true) {
         $e['file'] = $errfile;
         $e['line'] = $errline;
         $e['stacktrace'] = array_slice(debug_backtrace(), 2);
         include_once dirname(__FILE__) . '/../../../pages/errors/debug.php';
     } else {
         include_once dirname(__FILE__) . '/../../../pages/errors/general.php';
     }
     exit;
 }
Example #13
0
 public function executeLater($email)
 {
     if ($this->submit && $this->controller->validate()) {
         $ar = org_glizy_ObjectFactory::createModel('org.glizy.models.User');
         if (!$ar->find(array('user_email' => $email))) {
             // utente non trovato
             $this->view->validateAddError(__T('MW_LOSTPASSWORD_ERROR'));
             return false;
         }
         // utente trovato
         // genera una nuova password e la invia per email
         glz_import('org.glizy.helpers.Mail');
         // invia la notifica all'utente
         $subject = org_glizy_locale_Locale::get('MW_LOSTPASSWORD_EMAIL_SUBJECT');
         $body = org_glizy_locale_Locale::get('MW_LOSTPASSWORD_EMAIL_BODY');
         $body = str_replace('##USER##', $email, $body);
         $body = str_replace('##HOST##', org_glizy_helpers_Link::makeSimpleLink(GLZ_HOST, GLZ_HOST), $body);
         $body = str_replace('##PASSWORD##', $ar->user_password, $body);
         org_glizy_helpers_Mail::sendEmail(array('email' => org_glizy_Request::get('email', ''), 'name' => $ar->user_firstName . ' ' . $ar->user_lastName), array('email' => org_glizy_Config::get('SMTP_EMAIL'), 'name' => org_glizy_Config::get('SMTP_SENDER')), $subject, $body);
         $this->changeAction('lostPasswordConfirm');
     }
 }
Example #14
0
 function _init()
 {
     parent::_init();
     // inizialize the editing language
     $language = org_glizy_Session::get('glizy.editingLanguageId');
     if (is_null($language)) {
         $ar = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Language');
         $ar->language_isDefault = 1;
         $ar->language_FK_site_id = org_glizy_Config::get('SITE_ID');
         $ar->find();
         org_glizy_Session::set('glizy.editingLanguage', $ar->language_code);
         org_glizy_Session::set('glizy.editingLanguageId', $ar->language_id);
         org_glizy_Session::set('glizy.editingLanguageIsDefault', $ar->language_isDefault);
         $language = $ar->language_id;
     }
     org_glizy_ObjectValues::set('org.glizy', 'editingLanguageId', $language);
     $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Language');
     //$it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Language');
     $languagesId = array();
     foreach ($it as $ar) {
         $languagesId[] = $ar->language_id;
     }
     org_glizy_ObjectValues::set('org.glizy', 'languagesId', $languagesId);
 }
Example #15
0
 /**
  * @param string $fileName
  * @param array $info
  * @param string $htmlTemplateHeader
  * @param string $htmlTemplateFooter
  * @param string $templatePath
  * @return array
  */
 static function sendEmailFromTemplate($fileName, $info, $htmlTemplateHeader = '', $htmlTemplateFooter = '', $templatePath = '')
 {
     /** @var org_glizy_application_Application $application */
     $application = org_glizy_ObjectValues::get('org.glizy', 'application');
     $templatePath = $templatePath ? $templatePath : __Paths::get('APPLICATION_STATIC') . '/templatesEmail/' . $application->getLanguage() . '/';
     $emailText = file_get_contents($templatePath . $fileName . '.txt');
     $emailText = explode("\n", $emailText);
     $emailTitle = array_shift($emailText);
     $emailBody = implode("\n<br />", $emailText);
     foreach ($info as $k => $v) {
         $emailBody = str_replace('##' . $k . '##', $v, $emailBody);
         $emailTitle = str_replace('##' . $k . '##', $v, $emailTitle);
     }
     if ($htmlTemplateHeader && $htmlTemplateFooter) {
         $emailBody = file_get_contents($templatePath . $htmlTemplateHeader) . $emailBody . file_get_contents($templatePath . $htmlTemplateFooter);
     }
     return org_glizy_helpers_Mail::sendEmail(array('email' => $info['EMAIL'], 'name' => $info['FIRST_NAME'] . ' ' . $info['LAST_NAME']), array('email' => org_glizy_Config::get('SMTP_EMAIL'), 'name' => org_glizy_Config::get('SMTP_SENDER')), $emailTitle, $emailBody, $info['ATTACHS'], $info['CC'], $info['BCC']);
 }
Example #16
0
<?php

$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : NULL;
$w = isset($_REQUEST['w']) ? intval($_REQUEST['w']) : 0;
if (is_null($id)) {
    exit;
}
if (!defined('GLZ_LOADED')) {
    require_once 'core/core.inc.php';
    org_glizy_Paths::init('application', '');
    org_glizy_Config::init();
    if (file_exists(org_glizy_Paths::get('APPLICATION_STARTUP'))) {
        // if the startup folder is defined all files are included
        glz_require_once_dir(org_glizy_Paths::get('APPLICATION_STARTUP'));
    }
    org_glizy_ObjectValues::set('org.glizy', 'languageId', 1);
}
$zoomFile = __Paths::get('CACHE') . '/zoom_' . $id . '_' . $w . '.xml';
if (!file_exists($zoomFile)) {
    glz_import('org.glizycms.mediaArchive.MediaManager');
    set_time_limit(0);
    $media = org_glizycms_mediaArchive_MediaManager::getMediaById($id);
    if (preg_match('/\\.tif$/', $media->fileName)) {
        $mediaInfo = $media->getResizeImage(2000, 2000);
        $media->fileName = $mediaInfo['fileName'];
    }
    set_include_path(implode(PATH_SEPARATOR, array(realpath('application/libs/openzoom/'), get_include_path())));
    require 'Oz/Deepzoom/ImageCreator.php';
    $converter = new Oz_Deepzoom_ImageCreator(254, 1, "jpg", 0.8);
    $converter->create(realpath($media->getFileName()), $zoomFile);
}
Example #17
0
 /**
  * Get the table prefix for a connection, the table prefix is defined in config file
  * @param  integer $n connection number
  * @return string     table prefix
  */
 public static function getTablePrefix($n = 0)
 {
     return org_glizy_Config::get($n == 0 ? 'DB_PREFIX' : 'DB_PREFIX#' . $n);
 }
Example #18
0
 /**
  * Render
  *
  * @return	void
  * @access	public
  */
 function render_html()
 {
     if ($this->getAttribute('action') == 'get') {
         $this->addOutputCode(org_glizy_Config::get($this->getAttribute('key')));
     }
 }
Example #19
0
 function _verifyCache($width, $height, $crop, $cropOffset, $forceSize)
 {
     $cacheOptions = array('cacheDir' => org_glizy_Paths::get('CACHE_IMAGES'), 'lifeTime' => org_glizy_Config::get('CACHE_IMAGES'), 'readControlType' => '', 'fileExtension' => '.jpg');
     $this->_cacheObj =& org_glizy_ObjectFactory::createObject('org.glizy.cache.CacheFile', $cacheOptions);
     $fileName = $this->getFileName() . $width . '_' . $height . '_' . ($crop ? '1' : '0') . '_' . $cropOffset . '_' . ($forceSize ? '1' : '0') . '_' . ($this->watermark ? '1' : '0');
     return $this->_cacheObj->verify($fileName, get_class($this), false, $this->getFileName());
 }
Example #20
0
 function getCompressedUrl($url, $compress = NULL)
 {
     $compress = is_null($compress) ? org_glizy_Config::get('JS_COMPRESS') : $compress;
     $url = $compress ? org_glizy_Paths::get('STATIC_DIR') . 'js.php?v=' . org_glizy_Config::get('APP_VERSION') . '&r=' . org_glizy_Paths::get('ROOT') . '&s=' . $url : $url;
     return str_replace('&', '&amp;', $url);
 }
Example #21
0
 static function init()
 {
     self::$method = strtolower(@$_SERVER['REQUEST_METHOD']);
     $url = '';
     $params =& org_glizy_Request::_getValuesArray(true);
     $charset = strtolower(org_glizy_Config::get('CHARSET'));
     $requestCharset = @$_SERVER['CONTENT_TYPE'];
     if ($charset != "utf-8" && stripos($requestCharset, 'utf-8') !== false) {
         self::$decodeUtf8 = true;
     }
     if (self::$skipDecode) {
         self::$decodeUtf8 = false;
     }
     foreach ($_GET as $k => $v) {
         if (!is_array($v) && get_magic_quotes_gpc()) {
             $v = stripslashes($v);
         }
         if (self::$decodeUtf8) {
             $v = org_glizy_Request::utf8_decode($v);
         }
         $url .= '&' . $k . '=' . $v;
         $params[$k] = array($v, GLZ_REQUEST_GET);
     }
     foreach ($_POST as $k => $v) {
         if (!is_array($v) && get_magic_quotes_gpc()) {
             $v = stripslashes($v);
         }
         if (self::$decodeUtf8) {
             $v = org_glizy_Request::utf8_decode($v);
         }
         $url .= '&' . $k . '=' . $v;
         $params[$k] = array($v, GLZ_REQUEST_POST);
     }
     $contentType = @$_SERVER['CONTENT_TYPE'];
     $body = @file_get_contents('php://input');
     if ($body && $contentType && $contentType != 'application/x-www-form-urlencoded') {
         $params['__postBody__'] = array($body, GLZ_REQUEST_POST);
         parse_str($body, $output);
         foreach ($output as $k => $v) {
             if (!isset($params[$k])) {
                 $url .= '&' . $k . '=' . $v;
                 $params[$k] = array($v, GLZ_REQUEST_POST);
             }
         }
     }
     $params['__url__'] = array(__Routing::$requestUrl, GLZ_REQUEST_GET);
     $params['__back__url__'] = array($url, GLZ_REQUEST_GET);
     if (self::$translateInfo && isset($params['pageId'])) {
         $pageId = strtolower($params['pageId'][GLZ_REQUEST_VALUE]);
         $translateInfo = __Session::get('__translateInfo_' . $pageId, array());
         foreach ($translateInfo as $v) {
             if (isset($params[$v['target_name']]) && $params[$v['target_name']][GLZ_REQUEST_VALUE] == $v['label']) {
                 $params[$v['target']][GLZ_REQUEST_VALUE] = $v['value'];
             }
         }
         __Session::remove('__translateInfo_' . $pageId);
     }
     $values = __Session::get('__valuesForNextRefresh');
     if (isset($values) && is_array($values)) {
         foreach ($values as $k => $v) {
             $params[$k][GLZ_REQUEST_VALUE] = $v;
         }
         __Session::remove('__valuesForNextRefresh');
     }
 }
Example #22
0
 /**
  * @param $values array
  */
 function setFromArray($values)
 {
     org_glizy_Session::start();
     foreach ($values as $k => $v) {
         $_SESSION[org_glizy_Config::get('SESSION_PREFIX') . $k] = $v;
     }
 }
Example #23
0
 private function includeFolder($folder)
 {
     // controlla se il file in cache è valido
     $options = array('cacheDir' => org_glizy_Paths::get('CACHE_JS'), 'lifeTime' => org_glizy_Config::get('CACHE_CODE'), 'readControlType' => '', 'fileExtension' => '.js');
     $cacheSignature = get_class($this) . $folder;
     $cacheObj = org_glizy_ObjectFactory::createObject('org.glizy.cache.CacheFile', $options);
     $jsFileName = $cacheObj->verify($cacheSignature);
     if ($jsFileName === false) {
         $jsFile = '';
         $folder = glz_findClassPath($folder);
         $extension = $this->getAttribute('extension');
         foreach (glob($folder . '/*' . $extension) as $file) {
             // $file = pathinfo($file);
             // $file = str_replace('_', '.', $file['filename']);
             // $availableModules[] = $file;
             // $f[] = $file;
             $jsCode = file_get_contents($file);
             $jsCode = $this->replaceLocale($jsCode);
             $jsFile .= $jsCode . "\n";
         }
         if (__Config::get('DEBUG') || $this->getAttribute('inline')) {
             $cacheObj->save($jsFile, NULL, get_class($this));
         } else {
             require_once org_glizy_Paths::get('CORE_LIBS') . '/jsmin/jsmin.php';
             $cacheObj->save(JSMin::minify($jsFile), NULL, $cacheSignature);
         }
         $jsFileName = $cacheObj->getFileName();
     }
     return $jsFileName;
 }
Example #24
0
 function _replaceSqlTag($sql)
 {
     $application =& org_glizy_ObjectValues::get('org.glizy', 'application');
     if (strpos($sql, '##TABLE_NAME##') !== false) {
         $sql = str_replace('##TABLE_NAME##', $this->getTableName(), $sql);
     }
     $sql = str_replace('##SELECT_ALL##', $this->_getQuerySqlString('all', false), $sql);
     $sql = str_replace('##TABLE_PREFIX##', $this->_tablePrefix, $sql);
     $sql = str_replace('##SITE_ID##', org_glizy_Config::get('SITE_ID'), $sql);
     if (!is_null($application)) {
         $user =& $application->getCurrentUser();
         $sql = str_replace('##USER_ID##', $user->id, $sql);
         $sql = str_replace('##USER_GROUP_ID##', $user->groupId, $sql);
         $sql = str_replace('##LANGUAGE_ID##', $application->getLanguageId(), $sql);
         if (method_exists($application, 'getEditingLanguageId')) {
             $sql = str_replace('##EDITING_LANGUAGE_ID##', $application->getEditingLanguageId(), $sql);
         }
     }
     if (strpos($sql, "??") !== false) {
         preg_match_all("/\\?\\?([^\\?]*)\\?\\?/U", $sql, $resmatch);
         foreach ($resmatch[1] as $varname) {
             if (strpos($varname, '.') !== false) {
                 list($filterName, $name) = explode('.', $varname);
                 $value = call_user_func($filterName, __Request::get($name));
             } else {
                 $value = __Request::get($varname);
             }
             $sql = str_replace("??{$varname}??", org_glizy_dataAccess_DataAccess::qstr($value), $sql);
         }
     }
     return $sql;
 }
Example #25
0
 /**
  * @param $modeName
  */
 function setMode($modeName)
 {
     $configArray =& org_glizy_Config::_getConfigArray();
     if (isset($configArray['__modes__'][$modeName])) {
         foreach ($configArray['__modes__'][$modeName] as $k => $v) {
             $configArray[$k] = $v;
         }
     } else {
         // TODO: in modalit� debug visualzzare un warning
     }
 }
Example #26
0
 public function onShutdownFunction()
 {
     if (!self::$isRegistred) {
         return;
     }
     $error = error_get_last();
     if ($error['type'] == 1) {
         if (org_glizy_Config::get('ERROR_DUMP') !== '') {
             org_glizy_Exception::error_dump($error['type'], $error['message'], $error['file'], $error['line']);
         }
         org_glizy_Exception::show($error['type'], $error['message'], $error['file'], $error['line']);
     }
 }
Example #27
0
 /**
  * Process
  *
  * @return	boolean	false if the process is aborted
  * @access	public
  */
 function process()
 {
     if (is_null($this->getAttribute('type')) || $this->getAttribute('type') == org_glizy_Config::get('DATASOURCE_MODE')) {
         $siteMap =& $this->_application->getSiteMap();
         $this->_currentMenu =& $this->_application->getCurrentMenu();
     } else {
         switch ($this->getAttribute('type')) {
             case 'db':
                 $siteMap =& org_glizy_ObjectFactory::createObject('org.glizy.application.SiteMapDB');
                 break;
             case 'xml':
                 $siteMap =& org_glizy_ObjectFactory::createObject('org.glizy.application.SiteMapXML');
                 break;
             case 'pageType':
                 $siteMap =& org_glizy_ObjectFactory::createObject('org.glizy.application.SiteMap');
                 break;
         }
         $this->_currentMenu =& $siteMap->getHomeNode();
     }
     $this->_currentMenuId = $this->_currentMenu->id;
     $this->_startMenu =& $this->_currentMenu;
     // cerca il menu da dove iniziare a disegnare
     $startFrom = explode('-', $this->getAttribute('startFrom'));
     switch ($startFrom[0]) {
         case '*':
             break;
         case '*parent':
             if (count($startFrom) == 1) {
                 $this->_startMenu =& $this->_currentMenu->parentNode();
                 if (is_null($this->_startMenu)) {
                     $this->_startMenu =& $this->_currentMenu;
                 }
             } else {
                 if ($this->_startMenu->depth >= $startFrom[1]) {
                     while (true) {
                         if ($this->_startMenu->depth == $startFrom[1] || $this->_startMenu->depth < $startFrom[1]) {
                             //$startMenu = &$this->_currentMenu;
                             break;
                         }
                         $tempNode =& $this->_startMenu->parentNode();
                         if (is_null($tempNode) || $tempNode->depth == 0) {
                             // siamo arrivati alla home
                             $this->_startMenu = NULL;
                         }
                         $this->_startMenu =& $tempNode;
                     }
                 } else {
                     $this->setAttribute('visible', false);
                     return;
                 }
             }
             break;
         default:
             // TODO
             // controllare che il menù indicato sia corretto
             $this->_startMenu =& $siteMap->getNodeById($startFrom[0]);
             break;
     }
     // calcola i menù da aprire
     $this->_menuToOpen = array();
     if ($this->getAttribute('showPath') === true) {
         $tempNode2 = $this->_application->getCurrentMenu();
         //do 16/04/2010
         if ($this->getAttribute('openFirstLevel')) {
             $menuHome =& $siteMap->getNodeById(1);
             foreach ($menuHome->attributes['childNodes'] as $childPageId) {
                 $this->_menuToOpen[] = $childPageId;
             }
         }
         while (true) {
             if (!is_null($this->getAttribute('maxPathDepth'))) {
                 if ($tempNode2->depth <= $this->getAttribute('maxPathDepth')) {
                     $this->_menuToOpen[] = $tempNode2->id;
                 }
             } else {
                 $this->_menuToOpen[] = $tempNode2->id;
             }
             $tempNode =& $tempNode2->parentNode();
             if (is_null($tempNode) || $tempNode->depth == 0) {
                 break;
             }
             $tempNode2 =& $tempNode;
         }
     }
     $this->_startDepth = is_null($this->getAttribute('startFromDepth')) ? $this->_startMenu->depth : $this->getAttribute('startFromDepth');
     $endDepth = $this->getAttribute('depth');
     if ($endDepth[0] == '+') {
         $this->_endDepth = $this->_startMenu->depth + intval(substr($endDepth, 1));
     } else {
         $this->_endDepth = intval($endDepth);
     }
     $this->_content = array();
 }
Example #28
0
 function __construct($cacheDir = null)
 {
     $options = array('cacheDir' => $cacheDir ? $cacheDir : org_glizy_Paths::get('CACHE_CODE'), 'lifeTime' => org_glizy_Config::get('CACHE_CODE'), 'readControlType' => '', 'fileExtension' => '.php');
     $this->_cacheObj =& org_glizy_ObjectFactory::createObject('org.glizy.cache.CacheFile', $options);
 }
Example #29
0
 /**
  * @param string $route
  * @param array  $queryVars
  * @param array  $addParam
  *
  * @return mixed|string
  */
 public static function makeURL($route = '', $queryVars = array(), $addParam = array())
 {
     if (is_object($queryVars)) {
         $queryVars = method_exists($queryVars, 'getValuesAsArray') ? $queryVars->getValuesAsArray() : (array) $queryVars;
     }
     if (org_glizy_Config::get('SEF_URL') == false) {
         return org_glizy_Routing::_makeURL_NOSEF($route, $queryVars, $addParam);
     } else {
         return org_glizy_Routing::_makeURL_SEF($route, $queryVars, $addParam);
     }
 }
Example #30
0
 function login()
 {
     $this->log("login", GLZ_LOG_SYSTEM);
     if (org_glizy_Session::get('glizy.userLogged')) {
         $this->log("user is logged", GLZ_LOG_SYSTEM);
         $user = org_glizy_Session::get('glizy.user');
         // crea l'utente
         $this->_user =& org_glizy_ObjectFactory::createObject('org.glizy.application.User', $user);
         org_glizy_ObjectValues::setByReference('org.glizy', 'user', $this->_user);
         org_glizy_ObjectValues::set('org.glizy', 'userId', $this->_user->id);
         if (org_glizy_Config::get('USER_LOG')) {
             $this->log("log user access", GLZ_LOG_SYSTEM);
             $arLog =& org_glizy_ObjectFactory::createModel('org.glizy.models.UserLog');
             $arLog->load($user['logId']);
             $arLog->userlog_FK_user_id = $user['id'];
             $arLog->save();
         }
     } else {
         $this->log("user not logged", GLZ_LOG_SYSTEM);
         // utente finto
         $user = 0;
         // crea l'utente
         $this->_user =& org_glizy_ObjectFactory::createObject('org.glizy.application.User', $user);
         org_glizy_ObjectValues::setByReference('org.glizy', 'user', $this->_user);
         org_glizy_ObjectValues::set('org.glizy', 'userId', 0);
     }
 }