Example #1
0
 public function __construct($Debug = false)
 {
     $this->Debug = (bool) $Debug;
     Std::Out();
     Std::Out('[Info] [WhatsBot] Loading... Debug = ' . var_export($this->Debug, true));
     Config::Load();
     LoadLibs();
     $Config = Config::Get('WhatsBot');
     if (!empty($Config['WhatsApp']['Username']) && !empty($Config['WhatsApp']['Nickname']) && !empty($Config['WhatsApp']['Password'])) {
         $this->Password = $Config['WhatsApp']['Password'];
         # WhatsApp
         Std::Out();
         Std::Out("[Info] [WhatsBot] I'm {$Config['WhatsApp']['Nickname']} ({$Config['WhatsApp']['Username']})");
         $this->WhatsProt = new WhatsProt($Config['WhatsApp']['Username'], $Config['WhatsApp']['Nickname'], $this->Debug);
         $this->WhatsApp = new WhatsApp($this->WhatsProt);
         # WhatsBot
         $this->ModuleManager = new ModuleManager($this, $this->WhatsApp);
         $this->ThreadManager = new ThreadManager($this, $this->WhatsProt, $this->ModuleManager);
         $this->Parser = new WhatsBotParser($this->WhatsApp, $this->ModuleManager);
         # Load
         $this->ModuleManager->LoadModules();
         $this->ThreadManager->LoadThreads();
         # Binding
         $this->WhatsApp->EventManager()->LoadListeners($this, $this->WhatsApp, $this->Parser, $this->ModuleManager, $this->ThreadManager, array('Connection', 'WhatsBot'));
     } else {
         throw new Exception('You have to setup the config file config/WhatsBot.json');
     }
 }
Example #2
0
 function Run()
 {
     //Load config
     $config = new Config();
     $config->Load();
     $displayManager = new DisplayManager();
     //Create Login Manager
     $loginManager = new LoginManager();
     $loginManager->Load();
     $loginFail = false;
     if ($loginManager->WantLogin()) {
         $loginFail = !$loginManager->TryLogin();
         if (!$loginFail) {
             header('location: index.php');
         }
     }
     if ($loginManager->WantLogout()) {
         $loginManager->Logout();
     }
     if (isset($_GET['want']) and $_GET['want'] == 'logo') {
         $logo = new Logo();
         $logo->Generate();
         return;
     } elseif (isset($_GET['want']) and $_GET['want'] == 'source') {
         $displayManager->DisplaySource();
     } else {
         if ($loginManager->IsLogged()) {
             $imageManager = new ImageManager();
             $images = $imageManager->GetImages();
             $displayManager->DisplayImagesPage($images);
         } else {
             $displayManager->DisplayLoginPage($loginFail);
         }
     }
 }
 public function testIssetWithOverloading()
 {
     include_once "php/mt.php";
     include_once "php/lib/MTUtil.php";
     $cfg_file = realpath("t/mysql-test.cfg");
     $mt = MT::get_instance(1, $cfg_file);
     $ctx =& $mt->context();
     // Test some objects inheriting ObjectBase class.
     require_once "php/lib/class.mt_config.php";
     $config = new Config();
     $config->Load();
     $this->assertTrue(isset($config->id));
     require_once "php/lib/class.mt_author.php";
     $author = new Author();
     $author->Load();
     $this->assertTrue(isset($author->id));
     // protected variable call (bugid:113105)
     require_once "php/lib/class.mt_entry.php";
     $entry = new Entry();
     $entry->id = 1;
     $this->assertTrue(isset($entry->id));
     $this->assertNull($entry->_prefix);
     $this->assertFalse(isset($entry->_prefix));
     // fixed Dynamic publishing error occurred with memcached environment. bugid: 113546
     $mt->config('MemcachedServers', '127.0.0.1:11211');
     $obj_names = array('asset' => 'Asset', 'author' => 'Author', 'blog' => 'Blog', 'category' => 'Category', 'comment' => 'Comment', 'entry' => 'Entry', 'folder' => 'Folder', 'page' => 'Page', 'tbping' => 'TBPing', 'template' => 'Template', 'website' => 'Website');
     foreach ($obj_names as $table => $name) {
         require_once "php/lib/class.mt_{$table}.php";
         $obj = new $name();
         $obj->Load();
         $this->cache("{$table}:" . $obj->id, $obj);
         $obj_cache = $this->load_cache("{$table}:" . $obj->id);
         $this->assertInstanceOf("{$name}", $obj_cache);
     }
 }
Example #4
0
 public function SessionInitAfter()
 {
     if (!Config::Get('_db_')) {
         $aConfig = Config::ReReadStorageConfig();
         if ($aConfig) {
             Config::Load($aConfig, false, null, null, 'storage');
         }
     }
 }
Example #5
0
 public function testIssetWithOverloading()
 {
     include_once "php/mt.php";
     include_once "php/lib/MTUtil.php";
     $cfg_file = realpath("t/mysql-test.cfg");
     $mt = MT::get_instance(1, $cfg_file);
     $ctx =& $mt->context();
     // Test some objects inheriting ObjectBase class.
     require_once "php/lib/class.mt_config.php";
     $config = new Config();
     $config->Load();
     $this->assertTrue(isset($config->id));
     require_once "php/lib/class.mt_author.php";
     $author = new Author();
     $author->Load();
     $this->assertTrue(isset($author->id));
     // protected variable call (bugid:113105)
     require_once "php/lib/class.mt_entry.php";
     $entry = new Entry();
     $entry->Load();
     $this->assertTrue(isset($entry->id));
     $this->assertNull($entry->_prefix);
     $this->assertFalse(isset($entry->_prefix));
 }
Example #6
0
 /**
  * Initialization of skin
  *
  */
 protected function _initSkin()
 {
     $this->sViewSkin = $this->GetConfigSkin();
     // Load skin's config
     $aConfig = array();
     Config::ResetLevel(Config::LEVEL_SKIN);
     $aSkinConfigPaths['sSkinConfigCommonPath'] = Config::Get('path.smarty.template') . '/settings/config/';
     $aSkinConfigPaths['sSkinConfigAppPath'] = Config::Get('path.dir.app') . F::File_LocalPath($aSkinConfigPaths['sSkinConfigCommonPath'], Config::Get('path.dir.common'));
     // Может загружаться основной конфиг скина, так и внешние секции конфига,
     // которые задаются ключом 'config_load'
     // (обычно это 'classes', 'assets', 'jevix', 'widgets', 'menu')
     $aConfigNames = array('config') + F::Str2Array(Config::Get('config_load'));
     // Config section that are loaded for the current skin
     $aSkinConfigNames = array();
     // ** Old skin version compatibility
     $oSkin = E::ModuleSkin()->GetSkin($this->sViewSkin);
     if (!$oSkin || !$oSkin->GetCompatible() || $oSkin->SkinCompatible('1.1', '<')) {
         // 'head.default' may be used in skin config
         C::Set('head.default', C::Get('assets.default'));
     }
     // Load configs from paths
     foreach ($aConfigNames as $sConfigName) {
         foreach ($aSkinConfigPaths as $sPath) {
             $sFile = $sPath . $sConfigName . '.php';
             if (F::File_Exists($sFile)) {
                 $aSubConfig = F::IncludeFile($sFile, false, true);
                 if ($sConfigName != 'config' && !isset($aSubConfig[$sConfigName])) {
                     $aSubConfig = array($sConfigName => $aSubConfig);
                 } elseif ($sConfigName == 'config' && isset($aSubConfig['head'])) {
                     // ** Old skin version compatibility
                     $aSubConfig['assets'] = $aSubConfig['head'];
                     unset($aSubConfig['head']);
                 }
                 // загружаем конфиг, что позволяет сразу использовать значения
                 // в остальных конфигах скина (assets и кастомном config.php) через Config::Get()
                 Config::Load($aSubConfig, false, null, null, $sFile);
                 if ($sConfigName != 'config' && !isset($aSkinConfigNames[$sConfigName])) {
                     $aSkinConfigNames[$sConfigName] = $sFile;
                 }
             }
         }
     }
     if (!$oSkin || !$oSkin->GetCompatible() || $oSkin->SkinCompatible('1.1', '<')) {
         // 'head.default' may be used in skin config
         C::Set('head.default', false);
     }
     Config::ResetLevel(Config::LEVEL_SKIN_CUSTOM);
     $aStorageConfig = Config::ReadStorageConfig(null, true);
     // Reload sections changed by user
     if ($aSkinConfigNames) {
         foreach (array_keys($aSkinConfigNames) as $sConfigName) {
             if (isset($aStorageConfig[$sConfigName])) {
                 if (empty($aConfig)) {
                     $aConfig[$sConfigName] = $aStorageConfig[$sConfigName];
                 } else {
                     $aConfig = F::Array_MergeCombo($aConfig, array($sConfigName => $aStorageConfig[$sConfigName]));
                 }
             }
         }
     }
     // Checks skin's config from users settings
     $sUserConfigKey = 'skin.' . $this->sViewSkin . '.config';
     $aUserConfig = Config::Get($sUserConfigKey);
     if ($aUserConfig) {
         if (!$aConfig) {
             $aConfig = $aUserConfig;
         } else {
             $aConfig = F::Array_MergeCombo($aConfig, $aUserConfig);
         }
     }
     if ($aConfig) {
         Config::Load($aConfig, false, null, null, $sUserConfigKey);
     }
     // Check skin theme and set one in config if it was changed
     if ($this->GetConfigTheme() != Config::Get('view.theme')) {
         Config::Set('view.theme', $this->GetConfigTheme());
     }
     // Load lang files for skin
     E::ModuleLang()->LoadLangFileTemplate(E::ModuleLang()->GetLang());
     // Load template variables from config
     if (($aVars = Config::Get('view.assign')) && is_array($aVars)) {
         $this->Assign($aVars);
     }
 }
Example #7
0
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
/*
 * Before we do anything else, lets check to see if we have a settings.php file
 * Without that file we can deduce that
 *  a) This is a first time install
 *  b) This is a corrupt or failed install
 */
if (!file_exists("settings.php")) {
    Kit::Redirect("install.php");
    die;
}
// parse and init the settings.php
Config::Load();
// Test our DB connection through PDO
try {
    PDOConnect::init();
} catch (PDOException $e) {
    die('Database connection problem.');
}
// create a database class instance (legacy)
$db = new database();
if (!$db->connect_db($dbhost, $dbuser, $dbpass)) {
    die('Database connection problem.');
}
if (!$db->select_db($dbname)) {
    die('Database connection problem.');
}
date_default_timezone_set(Config::GetSetting("defaultTimezone"));
Example #8
0
 /**
  * Инициализация хуков шаблонизатора
  */
 public function InitHooks()
 {
     $aActivePlugins = $this->Plugin_GetActivePlugins();
     foreach ($aActivePlugins as $sPlugin) {
         $aConfig = ACE::FileIncludeIfExists(Plugin::GetTemplatePath($sPlugin) . '/settings/config/config.php');
         Config::Load($aConfig, false);
     }
     $aHooks = Config::Get('view.hooks');
     if (is_array($aHooks)) {
         foreach ($aHooks as $aHook) {
             $this->TplHookCreate($aHook['template'], $aHook['selector'], $aHook['content'], $aHook['action']);
         }
     }
 }
Example #9
0
 /**
  * Initialization of skin
  *
  */
 protected function _initSkin()
 {
     $this->sViewSkin = $this->GetConfigSkin();
     // Load skin's config
     $aConfig = array();
     if (F::File_Exists($sFile = Config::Get('path.smarty.template') . '/settings/config/config.php')) {
         $aConfig = F::IncludeFile($sFile, FALSE, TRUE);
     }
     if (F::File_Exists($sFile = Config::Get('path.smarty.template') . '/settings/config/menu.php')) {
         $aConfig = F::Array_MergeCombo($aConfig, F::IncludeFile($sFile, false, true));
     }
     //        $aConfigLoad = F::Str2Array(Config::Get('config_load'));
     //        if ($aConfigLoad) {
     //            foreach ($aConfigLoad as $sConfigName) {
     //                if (F::File_Exists($sFile = Config::Get('path.smarty.template') . "/settings/config/$sConfigName.php")) {
     //                    $aConfig = array_merge($aConfig, F::IncludeFile($sFile, false, true));
     //                }
     //            }
     //        }
     // Checks skin's config in app dir
     $sFile = Config::Get('path.dir.app') . F::File_LocalPath($sFile, Config::Get('path.dir.common'));
     if (F::File_Exists($sFile)) {
         $aConfig = F::Array_MergeCombo($aConfig, F::IncludeFile($sFile, false, true));
     }
     // Checks skin's config from users settings
     $aUserConfig = Config::Get('skin.' . $this->sViewSkin . '.config');
     if ($aUserConfig) {
         if (!$aConfig) {
             $aConfig = $aUserConfig;
         } else {
             $aConfig = F::Array_MergeCombo($aConfig, $aUserConfig);
         }
     }
     Config::ResetLevel(Config::LEVEL_SKIN);
     if ($aConfig) {
         Config::Load($aConfig, false, null, null, 'skin');
     }
     // Check skin theme and set one in config if it was changed
     if ($this->GetConfigTheme() != Config::Get('view.theme')) {
         Config::Set('view.theme', $this->GetConfigTheme());
     }
     // Load lang files for skin
     E::ModuleLang()->LoadLangFileTemplate(E::ModuleLang()->GetLang());
     // Skip skin widgets for local viewer
     if (!$this->bLocal) {
         // * Load skin widgets
         if (F::File_Exists($sFile = Config::Get('path.smarty.template') . '/settings/config/widgets.php')) {
             $aSkinWidgets = F::IncludeFile($sFile, false, true);
             if (isset($aSkinWidgets['widgets']) && is_array($aSkinWidgets['widgets']) && count($aSkinWidgets['widgets'])) {
                 $aWidgets = array_merge(Config::Get('widgets'), $aSkinWidgets['widgets']);
                 Config::Set('widgets', $aWidgets);
             }
         }
     }
     // Load template variables from config
     if (($aVars = Config::Get('view.assign')) && is_array($aVars)) {
         $this->Assign($aVars);
     }
 }
Example #10
0
 public function fetch_config()
 {
     require_once 'class.mt_config.php';
     $config = new Config();
     $config->Load();
     return $config;
 }
Example #11
0
 /**
  * Конструктор
  *
  * @param Engine $oEngine Объект ядра
  * @param string $sAction Название экшена
  */
 public function __construct($oEngine, $sAction = null)
 {
     if (func_num_args() == 1 && is_string($oEngine)) {
         // Передан только экшен
         $this->oEngine = E::getInstance();
         $sAction = $oEngine;
     } else {
         // LS-compatible
         $this->oEngine = $oEngine;
     }
     $this->_prepareRequestData();
     //Engine::getInstance();
     $this->sCurrentAction = $sAction;
     $this->aParams = R::GetParams();
     $this->RegisterEvent();
     //Config::ResetLevel(Config::LEVEL_ACTION);
     // Get current config level
     $iConfigLevel = C::GetLevel();
     // load action's config if exists
     if ($sFile = F::File_Exists('/config/actions/' . $sAction . '.php', Config::Get('path.root.seek'))) {
         // Дополняем текущий конфиг конфигом экшена
         if ($aConfig = F::File_IncludeFile($sFile, true, true)) {
             // Текущий уровень конфига может быть как меньше LEVEL_ACTION,
             // так и больше. Нужно обновить все уровни
             if ($iConfigLevel <= Config::LEVEL_ACTION) {
                 $iMinLevel = $iConfigLevel;
                 $iMaxLevel = Config::LEVEL_ACTION;
             } else {
                 $iMinLevel = Config::LEVEL_ACTION;
                 $iMaxLevel = $iConfigLevel;
             }
             for ($iLevel = $iMinLevel; $iLevel <= $iMaxLevel; $iLevel++) {
                 if ($iLevel > $iConfigLevel) {
                     Config::ResetLevel(Config::LEVEL_ACTION);
                 }
                 Config::Load($aConfig, false, null, $iLevel, $sFile);
             }
         }
     } elseif ($iConfigLevel < Config::LEVEL_ACTION) {
         Config::ResetLevel(Config::LEVEL_ACTION);
     }
 }
Example #12
0
 /**
  * Load subconfig file
  *
  * @param string $sFile
  * @param string $sName
  * @param int    $nConfigLevel
  */
 protected static function _loadSectionFile($sFile, $sName, $nConfigLevel = 0)
 {
     if (F::File_Exists($sFile)) {
         $aCfg = F::File_IncludeFile($sFile, true, true);
         if ($aCfg) {
             if (isset($aCfg[$sName])) {
                 $aConfig = $aCfg[$sName];
             } else {
                 $aConfig = $aCfg;
             }
             Config::Load(array($sName => $aConfig), false, null, $nConfigLevel, $sFile);
         }
     }
 }
Example #13
0
 public function configure()
 {
     Config::Load();
 }