Esempio n. 1
0
 /**
  * get the application's config
  *
  * @param unknown_type $app_name
  * @param unknown_type $env
  */
 public static function getAppConfig($app_name, $env)
 {
     $app_conf = new AppConfig();
     $app_conf->setup();
     // init frameowk's dirs
     // TODO Make these dirs configable
     rtConfig::set('rt_apps_dir', rtConfig::get('rt_project_dir') . DS . 'apps');
     rtConfig::set('rt_app_dir', rtConfig::get('rt_apps_dir') . DS . $app_name);
     rtConfig::set('rt_app_config_dir', rtConfig::get('rt_app_dir') . DIRECTORY_SEPARATOR . 'config');
     rtConfig::set('rt_app_controllers_dir', rtConfig::get('rt_app_dir') . DS . 'controllers');
     rtConfig::set('rt_app_components_dir', rtConfig::get('rt_app_controllers_dir') . DS . 'components');
     rtConfig::set('rt_app_views_dir', rtConfig::get('rt_app_dir') . DS . 'views');
     rtConfig::set('rt_app_views_layout_dir', rtConfig::get('rt_app_views_dir') . DS . 'layout');
     rtConfig::set('rt_models_dir', rtConfig::get('rt_project_dir') . DS . 'lib' . DS . 'models');
     rtConfig::set('rt_app_helpers_dir', rtConfig::get('rt_app_dir') . DS . 'helper');
     rtConfig::set('rt_config_dir', rtConfig::get('rt_project_dir') . DS . 'config');
     rtConfig::set('rt_web_dir', rtConfig::get('rt_project_dir') . DS . 'web');
     rtConfig::set('rt_data_dir', rtConfig::get('rt_project_dir') . DS . 'data');
     rtAutoloader::addPath(rtConfig::get('rt_project_dir') . DS . 'lib');
     rtAutoloader::addPath(rtConfig::get('rt_models_dir'), rtConfig::get('rt_models_dir') . DS . 'generated', rtConfig::get('rt_app_controllers_dir'), rtConfig::get('rt_app_components_dir'));
     // setup app config
     require rtConfig::get('rt_app_config_dir') . DS . $app_name . 'AppConfig.class.php';
     $app_class_name = $app_name . 'AppConfig';
     $class = new $app_class_name();
     $class->setup();
     return $class;
 }
Esempio n. 2
0
function app_controller()
{
    global $session, $route, $mysqli;
    $result = false;
    include "Modules/app/AppConfig_model.php";
    $appconfig = new AppConfig($mysqli);
    if ($route->format == 'html') {
        if ($route->action == "" && $session['write']) {
            $result = view("Modules/app/client.php", array());
        }
    }
    if ($route->format == 'json') {
        if ($route->action == "setconfig" && $session['write']) {
            $result = $appconfig->set($session['userid'], get('data'));
        }
        if ($route->action == "getconfig" && $session['read']) {
            $result = $appconfig->get($session['userid']);
        }
        if ($route->action == "dataremote") {
            $id = (int) get("id");
            $start = (double) get("start");
            $end = (double) get("end");
            $interval = (int) get("interval");
            $result = json_decode(file_get_contents("http://emoncms.org/feed/data.json?id={$id}&start={$start}&end={$end}&interval={$interval}&skipmissing=0&limitinterval=0"));
        }
        if ($route->action == "valueremote") {
            $id = (int) get("id");
            $result = (double) json_decode(file_get_contents("http://emoncms.org/feed/value.json?id={$id}"));
        }
    }
    return array('content' => $result, 'fullwidth' => true);
}
 /**
  * 构造函数
  * @param AppConfig $app_config 应用程序的配置文件
  * @param string $action 要锁定的动作
  * @param string $unique_id 识别的唯一id
  * @return ActionLocker
  */
 public function __construct(AppConfig $app_config, $action, $unique_id = null)
 {
     $this->uid = $unique_id;
     $cache = $app_config->getLockCacheInstance();
     $this->locker = new MemLocker($cache);
     $this->action = $action;
 }
Esempio n. 4
0
 /**
  * 
  * @param Request $request
  * @param \AppConfig $appConfig
  * @throws \Exception
  * @return string
  */
 public function getActionMethodName(Request $request, \AppConfig $appConfig)
 {
     if (!$appConfig->getApplicationConfig() instanceof ArrayObject) {
         throw new \Exception("Method getApplicationConfig should return Zend\\Stdlib\\ArrayObject instance");
     }
     $it = $appConfig->getApplicationConfig()->getIterator();
     while ($it->valid()) {
         if ($request->getActionName() == $it->key()) {
             return $it->current();
         }
     }
 }
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 6
0
 public function __construct()
 {
     $this->redis = new Redis();
     if (!$this->redis->connect(AppConfig::getValue('redis_socket'))) {
         AppController::fatalError('unable to connect to Redis server');
     }
 }
Esempio n. 7
0
 /**
  * @return AppConfig
  */
 public static function getInstance()
 {
     if (!self::$_instance) {
         self::$_instance = new AppConfig();
     }
     return self::$_instance;
 }
Esempio n. 8
0
 public static function getDB()
 {
     if (is_null(self::$db)) {
         self::$db = self::getMongo()->{AppConfig::get("db.mongodb.name")};
     }
     return self::$db;
 }
Esempio n. 9
0
 function get_table($paged = 0)
 {
     /* Execute a prepared statement by passing an array of values */
     $dbh = new PDO('mysql:dbname=' . AppConfig::gacv("AC_db") . ';host=' . AppConfig::gacv("AC_server"), AppConfig::gacv("AC_user"), AppConfig::gacv("AC_pass"));
     $sql = sprintf("select * from %s WHERE " . $this->lookup_tbl_id_col . " = :lookup_tbl_id_col OR 1 = :lookup_not_set order by %s", $this->tbl_name, $this->lookup_value_col);
     if ($paged) {
         $sql .= MyEDB_Pager::get_sql_limit_clause();
     }
     $sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY));
     //
     //$sth->execute(array(':lookup_tbl_id_col' => ($_REQUEST[$this->lookup_tbl_id_col])? $_REQUEST[$this->lookup_tbl_id_col] : $this->lookup_tbl_id_col));
     $sth->bindParam(':lookup_tbl_id_col', $lookup_tbl_id_col);
     $sth->bindParam(':lookup_not_set', $lookup_not_set);
     $lookup_tbl_id_col = $_REQUEST[$this->lookup_tbl_id_col];
     $lookup_not_set = $_REQUEST[$this->lookup_tbl_id_col] ? 0 : 1;
     $sth->execute();
     $res = $sth->fetchAll(PDO::FETCH_BOTH);
     //echo $sql.$this->lookup_tbl_id_col;//
     $table_hash = array();
     //print_r($res);
     foreach ($res as $ar) {
         //echo $sql."-".$lookup_tbl_id_col." ".$lookup_not_set;
         $table_hash[$ar[0]] = array($ar[1], "lookup_table_id" => $ar[$this->lookup_tbl_id_col], "disabled" => $ar['disabled']);
     }
     return $table_hash;
 }
Esempio n. 10
0
 public static function getInstance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new Config();
     }
     return self::$_instance;
 }
 /**
  * @return TableServer
  */
 public function getTableServer()
 {
     if ($this->table_server === null) {
         $this->table_server = $this->app_config->getTableServer($this->table, $this->key_value);
     }
     return $this->table_server;
 }
 public static function get_config_data()
 {
     if (!($config = AppConfig::get()->first())) {
         return [];
     }
     return $config->forAPI();
 }
Esempio n. 13
0
 public static function initConfig()
 {
     if (null == self::$connection) {
         self::$connection = parse_ini_file(__DIR__ . "/config.ini", 1);
         /*converts ini file into a array*/
     }
 }
Esempio n. 14
0
 private static function getInstance()
 {
     if (is_null(self::$instance)) {
         $config = (require app_path('config/app.php'));
         self::$instance = new self($config);
     }
     return self::$instance;
 }
Esempio n. 15
0
 public function process(Vtiger_Request $request)
 {
     $shortURL = str_replace('index.php', '', AppConfig::main('site_URL'));
     $viewer = $this->getViewer($request);
     $viewer->assign('URLCSS', $shortURL . Yeti_Layout::getLayoutFile('modules/AJAXChat/Chat.css'));
     $viewer->assign('URL', $shortURL . "libraries/AJAXChat/index.php");
     $viewer->view('Index.tpl', 'AJAXChat');
 }
Esempio n. 16
0
 static function getDefaultViewComments()
 {
     if (AppConfig::module('ModComments', 'DEFAULT_VIEW') == 'Timeline') {
         return 'Timeline';
     } else {
         return 'List';
     }
 }
Esempio n. 17
0
 public static function getDatabase()
 {
     if (!self::$database) {
         $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);
         self::$database = new PDO('mysql:host=localhost;dbname=db_here;port=3306;charset=utf8', 'user_here', 'password_here', $options);
     }
     return self::$database;
 }
 public function __construct()
 {
     $this->config = AppConfig::getInstance()->get();
     $this->api = new DigitalOcean($this->config->config->token);
     while (true) {
         $this->checkDroplets();
         sleep(self::UPDATE_TIME * 60);
     }
 }
Esempio n. 19
0
 public function __construct()
 {
     if (AppConfig::read('Smtp.enabled')) {
         $config = array('transport' => 'Smtp', 'from' => array(AppConfig::read('Smtp.email') => AppConfig::read('Smtp.name')), 'host' => AppConfig::read('Smtp.host'), 'port' => AppConfig::read('Smtp.port'), 'timeout' => 30, 'username' => AppConfig::read('Smtp.login'), 'password' => AppConfig::read('Smtp.password'), 'client' => null, 'log' => false, 'charset' => 'utf-8', 'headerCharset' => 'utf-8');
     } else {
         $config = array('transport' => 'Mail', 'from' => array(AppConfig::read('Smtp.email') => AppConfig::read('Smtp.name')), 'charset' => 'utf-8', 'headerCharset' => 'utf-8');
     }
     $this->default = $config;
 }
Esempio n. 20
0
 public function __construct()
 {
     if (!is_file(CONFIG_FILE)) {
         throw new \Exception("Config file not found: '" . CONFIG_FILE . "'");
     }
     if (self::$config === false) {
         self::$config = (require CONFIG_FILE);
     }
 }
Esempio n. 21
0
 /**
  * @return \Doctrine\ORM\EntityManager
  */
 public static function getMySql()
 {
     if (is_null(self::$mysql)) {
         $paths = array('src/Main/Entity');
         $config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration($paths, true);
         self::$mysql = \Doctrine\ORM\EntityManager::create(array('driver' => 'pdo_mysql', 'user' => AppConfig::get("db.mysql.host"), 'password' => AppConfig::get("db.mysql.password"), 'dbname' => AppConfig::get("db.mysql.name"), 'charset' => 'utf8', 'driverOptions' => array(1002 => 'SET NAMES utf8')), $config);
     }
     return self::$mysql;
 }
Esempio n. 22
0
 public function saveData($data)
 {
     foreach ($data as $parent => $values) {
         foreach ($values as $key => $value) {
             AppConfig::write($parent . '.' . $key, $value);
         }
     }
     return true;
 }
Esempio n. 23
0
 public static function getLayoutFile($name)
 {
     $basePath = 'layouts' . '/' . AppConfig::main('defaultLayout') . '/';
     $filePath = Vtiger_Loader::resolveNameToPath('~' . $basePath . $name);
     if (is_file($filePath)) {
         return $basePath . $name;
     }
     $basePath = 'layouts' . '/' . Vtiger_Viewer::getDefaultLayoutName() . '/';
     return $basePath . $name;
 }
Esempio n. 24
0
 /**
  * Apply special host settings,
  * Taken from "hosts" part of site config file
  *
  * @return void
  */
 public static function applyHostSettings($file)
 {
     self::$hosts = (require DOCUMENT_ROOT . "/{$file}");
     $server = preg_replace('|^www.|', '', $_SERVER['HTTP_HOST']);
     if (isset(self::$hosts[$server])) {
         $host = self::$hosts[$server];
         self::$settings = array_merge(self::$settings, $host);
     } else {
         throw new \Exception('wrong server config');
     }
 }
Esempio n. 25
0
 public function process(Vtiger_Request $request)
 {
     $mode = $request->getMode();
     $viewer = $this->getViewer($request);
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $viewer->assign('CURRENT_USER', $currentUserModel);
     $viewer->assign('EVENT_LIMIT', AppConfig::module('Calendar', 'EVENT_LIMIT'));
     $viewer->assign('WEEK_VIEW', AppConfig::module('Calendar', 'SHOW_TIMELINE_WEEK') ? 'agendaWeek' : 'basicWeek');
     $viewer->assign('DAY_VIEW', AppConfig::module('Calendar', 'SHOW_TIMELINE_DAY') ? 'agendaDay' : 'basicDay');
     $viewer->view('CalendarView.tpl', $request->getModule());
 }
Esempio n. 26
0
 public static function unauthorised($message = null)
 {
     if ($message) {
         (new Log(SECURITY_LOG))->setFatal(true)->logMessage($message);
     }
     // Show a Friendly Error Page
     $view = new HTMLView(true);
     $view->includeTemplate('error.unauthorised', ['app_name' => AppConfig::getValue('app_name')]);
     $view->render(true);
     exit;
     // terminate script (regardless of location)
 }
Esempio n. 27
0
 public function checkPermission(Vtiger_Request $request)
 {
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $record = $request->get('record');
     if (!AppConfig::security('SHOW_MY_PREFERENCES')) {
         throw new NoPermittedToRecordException('LBL_PERMISSION_DENIED');
     }
     if ($currentUserModel->isAdminUser() == true || $currentUserModel->get('id') == $record) {
         return true;
     } else {
         throw new NoPermittedToRecordException('LBL_PERMISSION_DENIED');
     }
 }
Esempio n. 28
0
function ShowLoginDialog($facebook)
{
    $facebook->setAccessToken(null);
    $cookieName = 'fbsr_' . AppConfig::GetAppId();
    setcookie($cookieName, "", 1);
    $loginUrl = $facebook->getLoginUrl(array('canvas' => 1, 'fbconnect' => 0, 'req_perms' => 'email'));
    $redirectScript = "<script type=\"text/javascript\">\n";
    $redirectScript .= "if (parent != self) \n";
    $redirectScript .= "top.location.href = \"" . $loginUrl . "\";\n";
    $redirectScript .= "else self.location.href = \"" . $loginUrl . "\";\n";
    $redirectScript .= "</script>";
    echo $redirectScript;
}
Esempio n. 29
0
 public function getModalScripts(Vtiger_Request $request)
 {
     $parentScriptInstances = parent::getModalScripts($request);
     $scripts = ['~libraries/jquery/jstree/jstree.js'];
     if (AppConfig::relation('SELECTABLE_CATEGORY')) {
         $scripts[] = '~libraries/jquery/jstree/jstree.category.js';
     }
     if ($this->relationType == 1) {
         $scripts[] = '~libraries/jquery/jstree/jstree.edit.js';
     }
     $scripts[] = 'modules.Vtiger.resources.TreeCategoryModal';
     $modalInstances = $this->checkAndConvertJsScripts($scripts);
     $scriptInstances = array_merge($modalInstances, $parentScriptInstances);
     return $scriptInstances;
 }
Esempio n. 30
0
 function including($file_name)
 {
     try {
         $path = FileHandler::GetUsingPath($file_name);
         if ($path) {
             require_once $path;
             return true;
         } else {
             return require_file(AppConfig::GetInstance()->USING_DIRS, $file_name);
         }
     } catch (Exception $ex) {
         debug('Uncaught exception: ' . $ex->getMessage() . "\n" . $ex->getTraceAsString());
         return false;
     }
 }