コード例 #1
0
ファイル: waLog.class.php プロジェクト: Lazary/webasyst
 /**
  * Write message into log file.
  *
  * @return bool
  */
 public static function log($message, $file = 'error.log')
 {
     if (!self::$path) {
         self::$path = waConfig::get('wa_path_log');
         if (!self::$path) {
             self::$path = wa()->getConfig()->getRootPath() . DIRECTORY_SEPARATOR . 'wa-log';
         }
         self::$path .= DIRECTORY_SEPARATOR;
     }
     $file = self::$path . $file;
     if (!file_exists($file)) {
         waFiles::create($file);
         touch($file);
         chmod($file, 0666);
     } elseif (!is_writable($file)) {
         return false;
     }
     $fd = fopen($file, 'a');
     if (flock($fd, LOCK_EX)) {
         fwrite($fd, PHP_EOL . date('Y-m-d H:i:s:') . PHP_EOL . $message);
         fflush($fd);
         flock($fd, LOCK_UN);
     }
     fclose($fd);
     return true;
 }
コード例 #2
0
ファイル: waGroup.model.php プロジェクト: Lazary/webasyst
 public static function getIcons()
 {
     if (self::$icons === null) {
         $path = waConfig::get('wa_path_root') . '/wa-content/img/users/';
         if (!file_exists($path) || !is_dir($path)) {
             $list = array();
         }
         if (!($dh = opendir($path))) {
             $list = array();
         }
         $list = array();
         while (false !== ($file = readdir($dh))) {
             if ($file == '.' || $file == '..') {
                 continue;
             }
             if (is_dir($path . '/' . $file)) {
                 continue;
             } else {
                 $list[] = $file;
             }
         }
         closedir($dh);
         foreach ($list as &$l) {
             $p = strpos($l, '.png');
             if ($p !== false) {
                 $l = substr($l, 0, $p);
             }
         }
         unset($l);
         natsort($list);
         self::$icons = array_values($list);
     }
     return self::$icons;
 }
コード例 #3
0
 public static function log($message, $file = 'error.log')
 {
     $path = waConfig::get('wa_path_log');
     if (!$path) {
         $path = dirname(dirname(dirname(__FILE__)));
     }
     $path .= '/' . $file;
     if (!file_exists($path)) {
         waFiles::create(dirname($path));
         touch($path);
         chmod($path, 0666);
     } elseif (!is_writable($path)) {
         return false;
     }
     $fd = fopen($path, 'a');
     if (!flock($fd, LOCK_EX)) {
         throw new waException('Unable to lock ' . $path);
     }
     fwrite($fd, "\n");
     fwrite($fd, date('Y-m-d H:i:s: '));
     fwrite($fd, $message);
     fflush($fd);
     flock($fd, LOCK_UN);
     fclose($fd);
     return true;
 }
コード例 #4
0
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_modifier_wa_format_amount($string, $currency_id = null, $format = '%', $locale = null)
{
    if ($locale === null || $currency_id === null) {
        /**
         * @var waSmarty3View
         */
        $smarty = waConfig::get('current_smarty');
    }
    if ($locale === null) {
        $locale = $smarty->getVars('locale');
    }
    if ($locale === null) {
        $locale = wa()->getUser()->getLocale();
    }
    if ($currency_id === null) {
        $currency_id = $smarty->getVars('currency_id');
    }
    if ($currency_id && $locale) {
        if ($format == 'words') {
            $format = '%.W{n0} %.2{f0}';
        }
        $string = waCurrency::format($format, $string, $currency_id, $locale);
    }
    return $string;
}
コード例 #5
0
 protected static function loadPath()
 {
     if (!self::$path) {
         self::$path = waConfig::get('wa_path_log');
         if (!self::$path) {
             self::$path = wa()->getConfig()->getRootPath() . DIRECTORY_SEPARATOR . 'wa-log';
         }
         self::$path .= DIRECTORY_SEPARATOR;
     }
 }
コード例 #6
0
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_modifier_wa_format_number($n, $decimals = 0, $locale = null)
{
    if ($locale === null) {
        /**
         * @var waSmarty3View
         */
        $smarty = waConfig::get('current_smarty');
    }
    if ($locale === null) {
        $locale = $smarty->getVars('locale');
    }
    if ($locale === null) {
        $locale = waSystem::getInstance()->getUser()->getLocale();
    }
    return waLocale::format($n, $decimals, $locale);
}
コード例 #7
0
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_modifier_wa_datetime($string, $format = 'datetime', $timezone = null, $locale = null)
{
    if ($locale === null) {
        /**
         * @var waSmarty3View
         */
        $smarty = waConfig::get('current_smarty');
        $locale = $smarty->getVars('locale');
    }
    if ($locale === null) {
        $locale = waSystem::getInstance()->getUser()->getLocale();
    }
    if (!$string) {
        return '';
    }
    return wa_date($format, $string, $timezone, $locale);
}
コード例 #8
0
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_modifier_wa_format_country($code, $locale = null)
{
    if ($locale === null) {
        /**
         * @var waSmarty3View
         */
        $smarty = waConfig::get('current_smarty');
    }
    if ($locale === null) {
        $locale = $smarty->getVars('locale');
    }
    if ($locale === null) {
        $locale = waSystem::getInstance()->getUser()->getLocale();
    }
    $country_model = new waCountryModel();
    $country = $country_model->get($code, $locale);
    return isset($country['name']) ? $country['name'] : $code;
}
コード例 #9
0
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_modifier_wa_date_add($string, $format, $timezone = null, $locale = null)
{
    if ($locale === null) {
        /**
         * @var waSmarty3View
         */
        $smarty = waConfig::get('current_smarty');
        $locale = $smarty->getVars('locale');
    }
    if ($locale === null) {
        $locale = waSystem::getInstance()->getUser()->getLocale();
    }
    $string = wa_date('date', $string, $timezone, $locale);
    if (preg_match('/(\\d+)([d])/i', $format, $match)) {
        $string = wa_date('date', date('Y-m-d', strtotime($string) + $match[1] * 60 * 60 * 24), $timezone, $locale);
    }
    return $string;
}
コード例 #10
0
 public function execute()
 {
     try {
         $path_cache = waConfig::get('wa_path_cache');
         waFiles::delete($path_cache, true);
         waFiles::protect($path_cache);
         $app_path = waConfig::get('wa_path_apps');
         $apps = new waInstallerApps();
         $app_list = $apps->getApplicationsList(true);
         foreach ($app_list as $app) {
             if (isset($app['enabled']) && $app['enabled']) {
                 $path_cache = $app_path . '/' . $app['slug'] . '/js/compiled';
                 waFiles::delete($path_cache, true);
             }
         }
         $this->response['message'] = _w('Cache cleared');
     } catch (Exception $ex) {
         $this->setError($ex->getMessage());
     }
 }
コード例 #11
0
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_modifier_wa_format_amount($string, $currency_id = null, $locale = null)
{
    if ($locale === null || $currency_id === null) {
        /**
         * @var waSmarty3View
         */
        $smarty = waConfig::get('current_smarty');
    }
    if ($locale === null) {
        $locale = $smarty->getVars('locale');
    }
    if ($locale === null) {
        $locale = waSystem::getInstance()->getUser()->getLocale();
    }
    if ($currency_id === null) {
        $currency_id = $smarty->getVars('currency_id');
    }
    if ($currency_id && $locale) {
        $string = waCurrency::format('%', $string, $currency_id, $locale);
    }
    return $string;
}
コード例 #12
0
 public static function flushCache($apps = array())
 {
     $path_cache = waConfig::get('wa_path_cache');
     waFiles::protect($path_cache);
     $caches = array();
     $paths = waFiles::listdir($path_cache);
     foreach ($paths as $path) {
         #skip long action & data path
         if ($path != 'temp') {
             $path = $path_cache . '/' . $path;
             if (is_dir($path)) {
                 $caches[] = $path;
             }
         }
     }
     if ($apps) {
         $app_path = waConfig::get('wa_path_apps');
         foreach ($apps as $app) {
             if (!empty($app['installed'])) {
                 $caches[] = $app_path . '/' . $app['slug'] . '/js/compiled';
             }
         }
     }
     $caches[] = $path_cache . '/temp';
     $root_path = wa()->getConfig()->getRootPath();
     $errors = array();
     foreach ($caches as $path) {
         try {
             waFiles::delete($path);
         } catch (Exception $ex) {
             $errors[] = str_replace($root_path . DIRECTORY_SEPARATOR, '', $ex->getMessage());
             waFiles::delete($path, true);
         }
     }
     return $errors;
 }
コード例 #13
0
ファイル: waConfig.class.php プロジェクト: Lazary/webasyst
 /**
  * Clears all current configuration parameters.
  */
 public static function clear()
 {
     self::$config = array();
 }
コード例 #14
0
ファイル: 1348146055.php プロジェクト: Lazary/webasyst
<?php

// old files
$files = array('blogPages.action.php', 'blogPagesDelete.controller.php', 'blogPagesSave.controller.php', 'blogPagesSort.controller.php', 'blogPagesUploadimage.controller.php');
// path to wa-apps/blog/lib/actions/pages/
$path = $this->getAppPath('lib/actions/pages/');
// remove old files
foreach ($files as $file) {
    if (file_exists($path . $file)) {
        unlink($path . $file);
    }
}
// try remove cache (for correct autoload)
try {
    $path_cache = waConfig::get('wa_path_cache') . '/apps/blog/';
    waFiles::delete($path_cache, true);
} catch (Exception $e) {
}
// add new fields to table pages
$model = new waModel();
try {
    $sql = "ALTER TABLE blog_page\n        ADD full_url VARCHAR(255) NULL DEFAULT NULL AFTER url,\n        ADD domain VARCHAR(255) NULL DEFAULT NULL,\n        ADD route VARCHAR(255) NULL DEFAULT NULL,\n        ADD parent_id INT(11) NULL DEFAULT NULL";
    $model->exec($sql);
} catch (waDbException $e) {
    // nothing if fields already exists
}
$model->exec("UPDATE blog_page SET full_url = url WHERE parent_id IS NULL");
// set domain and route for pages
$routing_path = $this->getPath('config', 'routing');
if (file_exists($routing_path)) {
    $routing = (include $routing_path);
コード例 #15
0
 /**
  * Returns instance of AppConfig
  *
  * @param string $application
  * @param string $environment
  * @param string $root_path
  * @param string $locale
  * @throws waException
  * @return waAppConfig
  */
 public static function getAppConfig($application, $environment = null, $root_path = null, $locale = null)
 {
     $class_name = $application . 'Config';
     if ($root_path === null) {
         $root_path = waConfig::get('wa_path_root');
     }
     if ($environment === null) {
         $environment = waSystem::getInstance()->getEnv();
     }
     if ($application === 'webasyst') {
         require_once $root_path . '/wa-system/webasyst/lib/config/webasystConfig.class.php';
         return new webasystConfig($environment, $root_path);
     }
     if (file_exists($file = $root_path . '/wa-apps/' . $application . '/lib/config/' . $class_name . '.class.php')) {
         require_once $file;
         return new $class_name($environment, $root_path, $application, $locale);
     } elseif (file_exists($file = $root_path . '/wa-apps/' . $application . '/lib/config/app.php')) {
         return new waAppConfig($environment, $root_path, $application, $locale);
     } else {
         throw new waException(sprintf('Application "%s" does not exist.', $application));
     }
 }
コード例 #16
0
ファイル: 1348148962.php プロジェクト: Lazary/webasyst
<?php

// old files
$files = array('photosPages.action.php', 'photosPagesDelete.controller.php', 'photosPagesSave.controller.php', 'photosPagesSort.controller.php', 'photosPagesUploadimage.controller.php');
// path to wa-apps/photos/lib/actions/pages/
$path = $this->getAppPath('lib/actions/pages/');
// remove old files
foreach ($files as $file) {
    if (file_exists($path . $file)) {
        unlink($path . $file);
    }
}
// try remove cache (for correct autoload)
try {
    $path_cache = waConfig::get('wa_path_cache') . '/apps/photos/';
    waFiles::delete($path_cache, true);
} catch (Exception $e) {
}
// add new fields to table pages
$model = new waModel();
try {
    $sql = "ALTER TABLE photos_page\n        ADD full_url VARCHAR(255) NULL DEFAULT NULL AFTER url,\n        ADD domain VARCHAR(255) NULL DEFAULT NULL,\n        ADD route VARCHAR(255) NULL DEFAULT NULL,\n        ADD parent_id INT(11) NULL DEFAULT NULL";
    $model->exec($sql);
} catch (waDbException $e) {
    // nothing if fields already exists
}
$model->exec("UPDATE photos_page SET full_url = url WHERE parent_id IS NULL");
// set domain and route for pages
$routing_path = $this->getPath('config', 'routing');
if (file_exists($routing_path)) {
    $routing = (include $routing_path);
コード例 #17
0
ファイル: 1319617589.php プロジェクト: Lazary/webasyst
<?php

$path = waConfig::get('wa_path_config') . '/routing.php';
if (file_exists($path)) {
    $routes = (include $path);
    foreach ($routes as $domain => $rules) {
        $result = array();
        foreach ($rules as $rule_id => $r) {
            if (strpos($r['url'], '[') !== false) {
                $r['url'] = preg_replace('/\\[i:([a-z_]+)\\]/ui', '<$1:\\d+>', $r['url']);
                $r['url'] = preg_replace('/\\[s?:([a-z_]+)\\]/ui', '<$1>', $r['url']);
            }
            $result[] = $r;
        }
        $routes[$domain] = $result;
    }
    waUtils::varExportToFile($routes, $path);
}
コード例 #18
0
 /**
  * Relative path from app root to plugin root this controller belongs to
  * (no leading slash, with trailing slash). For application controllers return ''.
  * @return string relative path or ''
  */
 public function getPluginRoot()
 {
     $path = waAutoload::getInstance()->get(get_class($this));
     if (!$path) {
         return '';
     }
     // Remove path to application from path to a controller to get relative path
     $appsPath = str_replace('\\', '/', waConfig::get('wa_path_apps'));
     $path = dirname($path);
     $path = str_replace('\\', '/', $path);
     if (false === strpos($path, $appsPath)) {
         // webasyst app
         $appsPath = str_replace('\\', '/', waConfig::get('wa_path_system'));
         if (false === strpos($path, $appsPath)) {
             return '';
         }
     }
     $path = str_replace($appsPath, '', $path);
     $path = trim($path, '\\/');
     $path = preg_replace('~^[^/]+/~', '', $path);
     // remove app dir from the begining of the path
     // /lib dir indicates that we've found either a plugin root or an application root
     $prevBase = '';
     while ($prevBase != 'lib') {
         $prevBase = basename($path);
         $path = dirname($path);
         if (!$path || $path == '.') {
             return '';
         }
     }
     return $path . '/';
 }
コード例 #19
0
 public function getPlugins()
 {
     if ($this->plugins === null) {
         $locale = wa()->getLocale();
         $file = waConfig::get('wa_path_cache') . "/apps/" . $this->application . '/config/plugins.' . $locale . '.php';
         if (!file_exists($file) || SystemConfig::isDebug()) {
             waFiles::create(waConfig::get('wa_path_cache') . "/apps/" . $this->application . '/config');
             // read plugins from file wa-config/[APP_ID]/plugins.php
             $path = $this->getConfigPath('plugins.php', true);
             if (!file_exists($path)) {
                 $this->plugins = array();
                 return $this->plugins;
             }
             $all_plugins = (include $path);
             $this->plugins = array();
             foreach ($all_plugins as $plugin_id => $enabled) {
                 if ($enabled) {
                     $plugin_config = $this->getPluginPath($plugin_id) . "/lib/config/plugin.php";
                     if (!file_exists($plugin_config)) {
                         continue;
                     }
                     $plugin_info = (include $plugin_config);
                     waSystem::pushActivePlugin($plugin_id, $this->application);
                     // Load plugin locale if it exists
                     $locale_path = wa()->getAppPath('plugins/' . $plugin_id . '/locale', $this->application);
                     if (is_dir($locale_path)) {
                         waLocale::load($locale, $locale_path, wa()->getActiveLocaleDomain(), false);
                     }
                     $plugin_info['name'] = _wp($plugin_info['name']);
                     if (isset($plugin_info['title'])) {
                         $plugin_info['title'] = _wp($plugin_info['title']);
                     }
                     if (isset($plugin_info['description'])) {
                         $plugin_info['description'] = _wp($plugin_info['description']);
                     }
                     waSystem::popActivePlugin();
                     $plugin_info['id'] = $plugin_id;
                     if (isset($plugin_info['img'])) {
                         $plugin_info['img'] = 'wa-apps/' . $this->application . '/plugins/' . $plugin_id . '/' . $plugin_info['img'];
                     }
                     if (isset($plugin_info['rights']) && $plugin_info['rights']) {
                         $plugin_info['handlers']['rights.config'] = 'rightsConfig';
                     }
                     if (isset($plugin_info['frontend']) && $plugin_info['frontend']) {
                         $plugin_info['handlers']['routing'] = 'routing';
                     }
                     $this->plugins[$plugin_id] = $plugin_info;
                 }
             }
             waUtils::varExportToFile($this->plugins, $file);
         } else {
             $this->plugins = (include $file);
         }
     }
     return $this->plugins;
 }
コード例 #20
0
 public function display($template, $cache_id = null)
 {
     waConfig::set('current_smarty', $this);
     $this->prepare();
     $this->smarty->display($template, $cache_id);
 }
コード例 #21
0
ファイル: preferences.php プロジェクト: navi8602/wa-shop-ppg
<?php

/****************************************************************************/
/*                                                                          */
/* YOU MAY WISH TO MODIFY OR REMOVE THE FOLLOWING LINES WHICH SET DEFAULTS  */
/*                                                                          */
/****************************************************************************/
// Sets the default charset so that setCharset() is not needed elsewhere
Swift_Preferences::getInstance()->setCharset('utf-8');
// Without these lines the default caching mechanism is "array" but this uses a lot of memory.
// If possible, use a disk cache to enable attaching large attachments etc.
// You can override the default temporary directory by setting the TMPDIR environment variable.
$temp_path = waConfig::get('wa_path_cache') . '/temp/swift';
if (!file_exists($temp_path)) {
    waFiles::create($temp_path);
}
if (is_writable($temp_path)) {
    Swift_Preferences::getInstance()->setTempDir($temp_path)->setCacheType('disk');
}
Swift_Preferences::getInstance()->setQPDotEscape(false);
コード例 #22
0
 public function execute()
 {
     $model = new waAppSettingsModel();
     $settings = array('name' => 'Webasyst', 'url' => wa()->getRootUrl(true), 'auth_form_background' => null, 'auth_form_background_stretch' => 1, 'locale' => 'ru_RU', 'email' => '', 'rememberme' => 1);
     $config_settings = array('debug' => 'boolean');
     $flush_settings = array('debug');
     $config_path = waSystem::getInstance()->getConfigPath() . '/config.php';
     $config = file_exists($config_path) ? include $config_path : array();
     if (!is_array($config)) {
         $config = array();
     }
     $changed = false;
     $flush = false;
     $message = array();
     try {
         $messages = installerMessage::getInstance()->handle(waRequest::get('msg'));
         foreach ($settings as $setting => &$value) {
             if (waRequest::post() && !in_array($setting, array('auth_form_background'))) {
                 $post_value = waRequest::post($setting, '', 'string_trim');
                 if (!is_null($post_value)) {
                     $model->set('webasyst', $setting, $post_value);
                     $changed = true;
                 } elseif (!is_null($value)) {
                     $model->set('webasyst', $setting, '');
                 }
                 $value = $model->get('webasyst', $setting, $value);
             } else {
                 $value = $model->get('webasyst', $setting, $value);
             }
             unset($value);
         }
         $config_changed = false;
         if (waRequest::post()) {
             $config_values = waRequest::post('config');
             if (!is_array($config_values)) {
                 $config_values = array();
             }
             foreach ($config_settings as $setting => $type) {
                 $value = isset($config_values[$setting]) ? $config_values[$setting] : false;
                 switch ($type) {
                     case 'boolean':
                         $value = $value ? true : false;
                         break;
                 }
                 if (!isset($config[$setting]) || $config[$setting] !== $value) {
                     $config[$setting] = $value;
                     $config_changed = true;
                     if (in_array($setting, $flush_settings)) {
                         $flush = true;
                     }
                 }
             }
             if ($config_changed) {
                 waUtils::varExportToFile($config, $config_path);
             }
             if ($flush) {
                 $path_cache = waConfig::get('wa_path_cache');
                 waFiles::delete($path_cache, true);
                 waFiles::protect($path_cache);
             }
             $model->ping();
         }
         if ($changed || $config_changed) {
             $message[] = '[`Settings saved`]';
         }
         $name = preg_replace('/\\?.*$/', '', $settings['auth_form_background']);
         $path = wa()->getDataPath($name, true, 'webasyst');
         $file = waRequest::file('auth_form_background');
         if ($file->uploaded()) {
             if ($name) {
                 waFiles::delete(wa()->getDataPath($name, true, 'webasyst'));
                 $model->set('webasyst', 'auth_form_background', false);
                 $settings['auth_form_background'] = false;
             }
             $ext = 'png';
             if (preg_match('/\\.(png|gif|jpg|jpeg|bmp|tif)$/i', $file->name, $matches)) {
                 $ext = $matches[1];
             }
             $name = 'auth_form_background.' . $ext;
             $path = wa()->getDataPath($name, true, 'webasyst');
             try {
                 $image = $file->waImage();
             } catch (waException $ex) {
                 $message = $ex->getMessage();
                 $tmp_name = $file->tmp_name;
                 if (!preg_match('//u', $tmp_name)) {
                     $tmp_name = iconv('windows-1251', 'utf-8', $tmp_name);
                 }
                 if (strpos($message, $tmp_name) !== false) {
                     throw new waException(preg_replace('/:\\s*$/', '', str_replace($tmp_name, '', $message)));
                 }
                 throw $ex;
             }
             $file->copyTo($path);
             //$image->save($path);
             $name .= '?' . time();
             $model->set('webasyst', 'auth_form_background', $name);
             $settings['auth_form_background'] = $name;
             $message[] = '[`Image uploaded`]';
             $image_info = get_object_vars($image);
             $image_info['file_size'] = filesize($path);
             $image_info['file_name'] = basename($path);
             $this->view->assign('image', $image_info);
         }
         if ($settings['auth_form_background'] && file_exists($path)) {
             $image = new waImage($path);
             $image_info = get_object_vars($image);
             $image_info['file_size'] = filesize($path);
             $image_info['file_name'] = basename($path);
             $this->view->assign('image', $image_info);
             unset($image);
         }
         if ($message) {
             $params = array();
             $params['module'] = 'settings';
             $params['msg'] = installerMessage::getInstance()->raiseMessage(implode(', ', $message));
             $this->redirect($params);
         }
     } catch (waException $ex) {
         $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL);
         $params = array('module' => 'settings', 'msg' => $msg);
         if ($message) {
             //$params['success'] = base64_encode(implode(', ', $message));
         }
         $this->redirect($params);
     }
     $this->view->assign('update_counter', $model->get($this->getApp(), 'update_counter'));
     //$this->view->assign('install_counter', $model->get($this->getApp(), 'install_counter'));
     $apps = wa()->getApps();
     $version = $apps['installer']['version'];
     if (abs(time() - $apps['installer']['build']) > 2) {
         $version .= '.' . $apps['installer']['build'];
     }
     $this->view->assign('version', $version);
     $this->view->assign('settings', $settings);
     $this->view->assign('config', $config);
     $this->view->assign('action', 'settings');
     $this->view->assign('messages', $messages);
     $locales = waSystem::getInstance()->getConfig()->getLocales('name');
     $this->view->assign('locales', $locales);
     $this->view->assign('title', _w('Settings'));
 }
コード例 #23
0
ファイル: smarty_security.php プロジェクト: Lazary/webasyst
 /**
  * Check if directory of file resource is trusted.
  *
  * @param string $filepath
  * @return boolean true if directory is trusted
  * @throws SmartyException if directory is not trusted
  */
 public function isTrustedResourceDir($filepath)
 {
     if (substr($filepath, -4) == '.php') {
         throw new SmartyException("file '" . basename($filepath) . "' not allowed by security setting");
     }
     $config_path = waConfig::get('wa_path_config');
     $_filepath = realpath($filepath);
     $directory = dirname($_filepath);
     while (true) {
         if ($directory == $config_path) {
             throw new SmartyException("directory '{$_filepath}' not allowed by security setting");
             return false;
         }
         // abort if we've reached root
         if (($pos = strrpos($directory, DS)) === false || !isset($directory[1])) {
             break;
         }
         // bubble up one level
         $directory = substr($directory, 0, $pos);
     }
 }
コード例 #24
0
 protected function install()
 {
     $file_db = $this->path . '/lib/config/db.php';
     if (file_exists($file_db)) {
         $schema = (include $file_db);
         $model = new waModel();
         $model->createSchema($schema);
     } else {
         // check plugin.sql
         $file_sql = $this->path . '/lib/config/plugin.sql';
         if (file_exists($file_sql)) {
             waAppConfig::executeSQL($file_sql, 1);
         }
     }
     // check install.php
     $file = $this->path . '/lib/config/install.php';
     if (file_exists($file)) {
         $app_id = $this->app_id;
         include $file;
         // clear db scheme cache, see waModel::getMetadata
         try {
             // remove files
             $path = waConfig::get('wa_path_cache') . '/db/';
             waFiles::delete($path, true);
         } catch (waException $e) {
             waLog::log($e->__toString());
         }
         // clear runtime cache
         waRuntimeCache::clearAll();
     }
 }
コード例 #25
0
ファイル: load.php プロジェクト: Lazary/webasyst
<?php

$dir = waConfig::get('wa_path_system') . '/helper';
include $dir . "/misc.php";
include $dir . "/view.php";
include $dir . "/datetime.php";
include $dir . "/currency.php";
コード例 #26
0
ファイル: 1348215142.php プロジェクト: Lazary/webasyst
<?php

// old files
$files = array('pages/sitePages.action.php', 'pages/sitePages.controller.php', 'pages/sitePagesDelete.controller.php', 'pages/sitePagesSave.controller.php', 'pages/sitePagesSort.controller.php', 'pages/sitePagesUploadimage.controller.php', 'design/siteDesign.action.php', 'design/siteDesignDelete.controller.php', 'design/siteDesignSave.controller.php');
// path to wa-apps/site/lib/actions/pages/
$path = $this->getAppPath('lib/actions/');
// remove old files
foreach ($files as $file) {
    if (file_exists($path . $file)) {
        unlink($path . $file);
    }
}
// try remove cache (for correct autoload)
try {
    $path_cache = waConfig::get('wa_path_cache') . '/apps/site/';
    waFiles::delete($path_cache, true);
} catch (Exception $e) {
}
// add new fields to table pages
$model = new waModel();
try {
    $sql = "ALTER TABLE site_page\n        ADD full_url VARCHAR(255) NULL DEFAULT NULL AFTER url,\n        ADD route VARCHAR(255) NULL DEFAULT NULL,\n        ADD parent_id INT(11) NULL DEFAULT NULL";
    $model->exec($sql);
} catch (waDbException $e) {
    // nothing if fields already exists
}
$model->exec("UPDATE site_page SET full_url = url WHERE parent_id IS NULL");
$domains = $model->query("SELECT id,name FROM site_domain")->fetchAll('name', true);
// set domain and route for pages
$routing_path = $this->getPath('config', 'routing');
if (file_exists($routing_path)) {
コード例 #27
0
 /**
  *
  * Update general plugin sort
  * @param string $plugin plugin id
  * @param int $sort 0 is first
  */
 public function setPluginSort($plugin, $sort)
 {
     $path = $this->getConfigPath('plugins.php', true);
     if (file_exists($path) && ($plugins = (include $path)) && !empty($plugins[$plugin])) {
         $sort = max(0, min(intval($sort), count($plugins) - 1));
         $order = array_flip(array_keys($plugins));
         if ($order[$plugin] != $sort) {
             $b = array($plugin => $plugins[$plugin]);
             unset($plugins[$plugin]);
             $a = array_slice($plugins, 0, $sort, true);
             $c = array_slice($plugins, $sort, null, true);
             $plugins = array_merge($a, $b, $c);
             if (waUtils::varExportToFile($plugins, $path)) {
                 waFiles::delete(waConfig::get('wa_path_cache') . "/apps/" . $this->application . '/config', true);
             } else {
                 throw new waException("Fail while update plugins sort order");
             }
         }
     }
 }
コード例 #28
0
 protected function getFilePath()
 {
     $path = waConfig::get('wa_path_cache') . '/' . $this->key . '.php';
     waFiles::create($path);
     return $path;
 }
コード例 #29
0
 /**
  * Returns path to directory used for storing app's temporary files.
  *
  * @param  string|null  $path    Optional path to a subdirectory in main temporary files directory.
  * @param  string|null  $app_id  Optional app id. If not specified, then current app's id is used by default.
  * @return  string
  */
 public function getTempPath($path = null, $app_id = null)
 {
     if ($app_id === null) {
         $app_id = $this->getConfig()->getApplication();
     }
     if ($path) {
         $path = preg_replace('!\\.\\.[/\\\\]!', '', $path);
     }
     $dir = waConfig::get('wa_path_cache') . '/temp/' . $app_id . ($path ? '/' . $path : '');
     waFiles::create($dir);
     return $dir;
 }
コード例 #30
0
    public function __toString()
    {
        try {
            $wa = wa();
            $additional_info = '';
        } catch (Exception $e) {
            $wa = null;
            $additional_info = $e->getMessage();
        }
        $message = nl2br($this->getMessage());
        if ($wa && waSystem::getApp()) {
            try {
                $app = $wa->getAppInfo();
            } catch (Exception $e) {
                $app = array();
            }
            $backend_url = $wa->getConfig()->getBackendUrl(true);
        } else {
            $app = array();
        }
        if (!waSystemConfig::isDebug() && $wa && $wa->getEnv() !== 'cli') {
            $env = $wa->getEnv();
            $file = $code = $this->getCode();
            if (!$code || !file_exists(dirname(__FILE__) . '/data/' . $code . '.php')) {
                $file = 'error';
            }
            if (file_exists(waConfig::get('wa_path_config') . DIRECTORY_SEPARATOR . 'exception' . DIRECTORY_SEPARATOR . $file . '.php')) {
                include waConfig::get('wa_path_config') . DIRECTORY_SEPARATOR . 'exception' . DIRECTORY_SEPARATOR . $file . '.php';
            } else {
                include dirname(__FILE__) . '/data/' . $file . '.php';
            }
            exit;
        }
        if ($wa && $wa->getEnv() == 'cli' || !$wa && php_sapi_name() == 'cli') {
            return date("Y-m-d H:i:s") . " php " . implode(" ", waRequest::server('argv')) . "\n" . "Error: {$this->getMessage()}\nwith code {$this->getCode()} in '{$this->getFile()}' around line {$this->getLine()}:{$this->getFileContext()}\n" . "\nCall stack:\n" . $this->getTraceAsString() . "\n" . ($additional_info ? "Error while initializing waSystem during error generation: " . $additional_info . "\n" : '');
        } elseif ($this->code == 404) {
            $response = new waResponse();
            $response->setStatus(404);
            $response->sendHeaders();
        }
        $request = htmlentities(var_export($_REQUEST, true), ENT_NOQUOTES, 'utf-8');
        $params = htmlentities(var_export(waRequest::param(), true), ENT_NOQUOTES, 'utf-8');
        $context = htmlentities($this->getFileContext(), ENT_NOQUOTES, 'utf-8');
        $trace = htmlentities($this->getTraceAsString(), ENT_NOQUOTES, 'utf-8');
        $result = <<<HTML
<div style="width:99%; position:relative; text-align: left;">
    <h2 id='Title'>{$message}</h2>
    <div id="Context" style="display: block;">
        <h3>Error with code {$this->getCode()} in '{$this->getFile()}' around line {$this->getLine()}:</h3>
        <pre>{$context}</pre>
    </div>
    <div id="Trace">
        <h2>Call stack</h2>
        <pre>{$trace}</pre>
    </div>
    <div id="Request">
        <h2>Request</h2>
        <pre>{$request}</pre>
    </div>
</div>
    <div style="text-align: left;">
        <h2>Params</h2>
        <pre>{$params}</pre>
    </div>
HTML;
        if ($additional_info) {
            $additional_info = htmlentities($additional_info, ENT_NOQUOTES, 'utf-8');
            $result .= <<<HTML

    <div style="text-align: left;">
        <h2>Error while initializing waSystem during error generation</h2>
        <pre>{$additional_info}</pre>
    </div>
HTML;
        }
        return $result;
    }