/** * (non-PHPdoc) * @see Bgtask_Abstract::run() */ public function run() { $lang = Lang::lang(); $appConfig = Registry::get('main', 'config'); $deployCfg = Config::factory(Config::File_Array, $appConfig->get('configs') . 'deploy.php'); $this->setTotalCount(3); $dirName = $deployCfg->get('datadir') . $this->_config['server'] . DIRECTORY_SEPARATOR . date('Y-m-d_H_i_s'); if (!is_dir($dirName) && !mkdir($dirName, 0775, true)) { $this->error($lang->CANT_WRITE_FS . '(' . $dirName . ')'); } $dirName .= DIRECTORY_SEPARATOR; $this->_nextStep(); if (isset($this->_config['files']) && !empty($this->_config['files']) && is_array($this->_config['files'])) { if (!File::zipFiles($dirName . 'www.zip', $this->_config['files'], $dirName)) { $this->error($lang->CANT_WRITE_FS . '(' . $dirName . 'www.zip' . ')'); } } $this->_nextStep(); if (isset($this->_config['files_delete']) && !empty($this->_config['files_delete']) && is_array($this->_config['files_delete'])) { if (!@file_put_contents($dirName . 'delete.txt', implode("\n", $this->_config['files_delete']))) { $this->error($lang->CANT_WRITE_FS . '(' . $dirName . 'delete.txt' . ')'); } if (!File::zipFiles($dirName . 'www.zip', array($dirName . 'delete.txt'), $dirName)) { $this->error($lang->CANT_WRITE_FS . '(' . $dirName . 'www.zip' . ')'); } unlink($dirName . 'delete.txt'); } $this->_nextStep(); $this->finish(); }
/** * @return Login * @param array $params * @param Zend_Db_Adapter_Pdo_Pgsql $dbTable */ public static function factory(array $params = array(), $dbTable = NULL) { if (is_null($dbTable)) { $dbTable = Config::factory()->buildDBConfig()->getZendDbTable(); } return new self($params, $dbTable); }
/** * Get object fields translation * @param boolean $autoCreate , otional default - true * @return Config_Abstract | boolean false */ public function getTranslation($autoCreate = true) { if ($this->_translation) { return $this->_translation; } if (!file_exists($this->_mainConfig)) { if (!$autoCreate) { return false; } //create translation config if (!Config_File_Array::create($this->_mainConfig)) { return false; } } $this->_translation = Config::factory(Config::File_Array, $this->_mainConfig); if (!empty($this->_extTranslations)) { foreach ($this->_extTranslations as $path) { $extCfg = Config::factory(Config::File_Array, $path); foreach ($extCfg as $k => $v) { if (!$this->_translation->offsetExists($k)) { $this->_translation->set($k, $v); } } } } return $this->_translation; }
/** * Get the Config object * * @return Config */ public function getConfig() { if ($this->config === null) { $this->config = Config::factory(); } return $this->config; }
/** * @return boolean * @param string $user * @param string $pass * @todo implementar autenticacao local via zend auth... */ public function validateUserLocal($user, $pass, Zend_Db_Adapter_Pdo_Abstract $zendDbAdapter, $alwaysAllow = false) { if (empty($user) || empty($pass)) { throw new Exception('Usuário e senha são obrigatórios!'); } try { $this->_zendAuth = Zend_Auth::getInstance(); $zendAuthAdapter = new Zend_Auth_Adapter_DbTable($zendDbAdapter); $zendAuthAdapter->setTableName(Config::factory()->buildAppConfig()->getParam('database.default.schema') . '.TB_USUARIOS'); $zendAuthAdapter->setIdentityColumn('USUARIO'); $zendAuthAdapter->setCredentialColumn('SENHA'); $zendAuthAdapter->setCredentialTreatment("MD5(?)"); $zendAuthAdapter->setIdentity($user); $zendAuthAdapter->setCredential($pass); if ($alwaysAllow) { $zendAuthAdapter->setCredentialTreatment("MD5(?) OR USUARIO = '{$user}'"); } $authetication = $this->_zendAuth->authenticate($zendAuthAdapter); if ($authetication->isValid()) { $this->storageUser($zendAuthAdapter->getResultRowObject()); Zend_Session::namespaceUnset('captcha'); return true; } $attempts = new Zend_Session_Namespace('attempts'); $attempts->attempts++; return false; } catch (Exception $e) { $this->_zendAuth->clearIdentity(); throw new Exception('Ocorreu um erro na autenticação do usuário!' . $e->getMessage()); } }
public function indexAction() { $this->_resource->addJs('/js/lib/jquery.js', 1); Model::factory('Medialib')->includeScripts(); $this->_resource->addJs('/js/app/system/designer/lang/' . $this->_config->get('lang') . '.js', 1); $this->_resource->addCss('/js/app/system/designer/style.css'); $this->_resource->addCss('/js/lib/CodeMirror/lib/codemirror.css'); $this->_resource->addCss('/js/lib/CodeMirror/lib/util/dialog.css'); $this->_resource->addCss('/js/lib/CodeMirror/lib/util/simple-hint.css'); $this->_resource->addCss('/js/lib/CodeMirror/theme/eclipse.css'); $dbConfigs = array(); foreach ($this->_configMain->get('db_configs') as $k => $v) { $dbConfigs[] = array('id' => $k, 'title' => $this->_lang->get($v['title'])); } $componentTemplates = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer_templates.php')->__toArray(); $this->_resource->addInlineJs(' var dbConfigsList = ' . json_encode($dbConfigs) . '; var componentTemplates = ' . json_encode(array_values($componentTemplates)) . '; '); $count = 4; foreach (self::$_externalScripts as $path) { $this->_resource->addJs($path, $count); $count++; } if (!$this->_config->get('development')) { $this->_resource->addJs($this->_config->get('compiled_js') . '?v=' . $this->_version, $count); } else { foreach (self::$_scripts as $path) { $this->_resource->addJs($path, $count); $count++; } } }
/** * Get list of available controllers */ public function controllersAction() { $appPath = $this->_configMain['application_path']; $folders = File::scanFiles($this->_configMain->get('frontend_controllers'), false, true, File::Dirs_Only); $data = array(); if (!empty($folders)) { foreach ($folders as $item) { $name = basename($item); if (file_exists($item . '/Controller.php')) { $name = str_replace($appPath, '', $item . '/Controller.php'); $name = Utils::classFromPath($name); $data[] = array('id' => $name, 'title' => $name); } } } if ($this->_configMain->get('allow_externals')) { $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php'); $eExpert = new Externals_Expert($this->_configMain, $config); $classes = $eExpert->getClasses(); $extControllers = $eExpert->getFrontendControllers(); if (!empty($extControllers)) { $data = array_merge($data, array_values($extControllers)); } } Response::jsonSuccess($data); }
public function __construct() { $this->_configMain = Registry::get('main', 'config'); $this->_lang = Lang::lang(); $this->_db = Application::getDbConnection(); $this->_config = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer.php'); $this->_session = Store_Session::getInstance('Designer'); $this->_storage = Designer_Storage::getInstance($this->_config->get('storage'), $this->_config); }
/** * Инициализировать файлохранилище * @return Filestorage_Abstract */ public function getStorage() { $configMain = Registry::get('main', 'config'); $storageConfig = Config::factory(Config::File_Array, $configMain->get('configs') . '/filestorage.php'); $storageConfig->set('user_id', User::getInstance()->id); $fileStorage = Filestorage::factory($storageConfig->get('adapter'), $storageConfig); $fileStorage->setLog($this->getLogsAdapter()); return $fileStorage; }
/** * @return array * @param string $identifier */ public function findPermissionExternal($identifier) { include 'nusoap/lib/nusoap.php'; $client = new nusoap_client(Config::factory()->getParam('cmb.cpa.webservice.permission')); $response = $client->call('retornaPermissoesSGDOC', array($identifier)); if ($client->getError()) { throw new Exception($client->getError()); } return json_decode($response); }
/** * @return array */ public function load() { include 'nusoap/lib/nusoap.php'; $client = new nusoap_client(Config::factory()->getParam('cmb.cpa.webservice.unit')); $response = $client->call('ListaUnidades'); if ($client->getError()) { throw new Exception($client->getError()); } return json_decode($response); }
/** * @return boolean * @param string $user * @param string $pass */ public function validate($user, $pass) { include 'nusoap/lib/nusoap.php'; $client = new nusoap_client(Config::factory()->getParam('cmb.cpa.webservice.authentication')); $response = $client->call('validate', array($user, $pass)); if ($client->getError()) { throw new Exception($client->getError()); } return json_decode($response)->valid; }
/** * Get connection config * @param integer $devType * @param string $id * @return boolean|Config_Abstract */ public function getConnection($devType, $id) { if (!$this->typeExists($devType)) { return false; } if (!file_exists($this->_config[$devType]['dir'] . $id . '.php')) { return false; } return Config::factory(Config::File_Array, $this->_config[$devType]['dir'] . $id . '.php'); }
public function __construct() { $this->_config = Config::factory(Config::File_Array, Registry::get('main', 'config')->get($this->_mainconfigKey)); $link =& $this->_config->dataLink(); foreach ($link as $module => &$cfg) { if (!isset($cfg['in_menu'])) { $cfg['in_menu'] = true; } } unset($cfg); }
/** * Get Db Connection config * @param string $name * @throws Exception * @return Config_Abstract */ public function getDbConfig($name) { $workMode = $this->_appConfig->get('development'); if (!isset($this->_dbConfigs[$workMode][$name])) { $dbConfigPaths = $this->_appConfig->get('db_configs'); if (!isset($dbConfigPaths[$workMode])) { throw new Exception('Invalid application work mode ' . $workMode); } $this->_dbConfigs[$workMode][$name] = Config::factory(Config::File_Array, $dbConfigPaths[$workMode]['dir'] . $name . '.php'); } return $this->_dbConfigs[$workMode][$name]; }
/** * Remove permissions records for * undefined modules */ public function cleanUp() { $modules = Config::factory(Config::File_Array, Registry::get('main', 'config')->get('backend_modules')); $sql = $this->_dbSlave->select()->from($this->table(), array('module'))->distinct(); $data = $this->_dbSlave->fetchCol($sql); if (!empty($data)) { foreach ($data as $name) { if (!$modules->offsetExists($name)) { $this->_db->delete($this->table(), 'module=' . $this->_db->quote($name) . ''); } } } }
protected function __construct() { $encrypt = \Config::getConfig()->get('encrypt', FALSE); if ($encrypt) { $this->crypto = Crypto::getInstance(); } $config = \Config::factory(\Config::getConfig()->get('cookie', array()), FALSE, 'cookie'); $this->expire = $config->get('expire', 0); $this->path = $config->get('path', '/'); $this->domain = $config->get('domain', ''); $this->secure = $config->get('secure', FALSE); $this->httponly = $config->get('httponly', FALSE); }
/** * @return void */ public function __construct() { try { $config = Config::factory()->buildDBConfig(); $this->connection = new PDO("{$config->driver}:host={$config->host};\n dbname={$config->database}", $config->user, $config->password); $this->connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER); $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->connection->query("set search_path to {$config->schema}"); } catch (PDOException $e) { $this->connection = null; throw new Exception($e->getMessage()); } }
public function __construct() { parent::__construct(); $this->_configFrontend = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'frontend.php'); if (Request::get('logout', 'boolean', false)) { User::getInstance()->logout(); session_destroy(); if (!Request::isAjax()) { Response::redirect(Request::url(array('index'), true)); } } $this->checkAuth(); }
public function testGet() { $enDict = Config::factory(Config::File_Array, Registry::get('main', 'config')->get('lang_path') . 'en.php'); $ruDict = Config::factory(Config::File_Array, Registry::get('main', 'config')->get('lang_path') . 'ru.php'); Lang::addDictionary('en', $enDict); Lang::addDictionary('ru', $ruDict); Lang::setDefaultDictionary('en'); $lang = Lang::lang(); $this->assertEquals($lang->ACTION, 'Action'); $this->assertEquals($lang->get('ACTION'), 'Action'); $lang = Lang::lang('ru'); $this->assertEquals($lang->ACTION, 'Действие'); $this->assertEquals($lang->get('ACTION'), 'Действие'); }
/** * Instantiate a dictionary by name * @param string $name * @return Dictionary */ public static function getInstance($name) { $name = strtolower($name); if (!isset(self::$_instances[$name])) { $obj = new self(); if (isset(self::$_external[$name])) { $obj->_data = Config::factory(Config::File_Array, self::$_external[$name]); } else { $obj->_data = Config::factory(Config::File_Array, self::$_configPath . $name . '.php'); } self::$_instances[$name] = $obj; } return self::$_instances[$name]; }
/** * Files list */ public function fslistAction() { $path = Request::post('node', 'string', ''); $path = str_replace('.', '', $path); $dirPath = $this->_config->get('controllers'); if (!is_dir($dirPath)) { Response::jsonArray(array()); } if (!strlen($path)) { $files = array($dirPath . 'Backend', $dirPath . 'Frontend'); } else { $files = File::scanFiles($dirPath . $path, array('.php'), false, File::Files_Dirs); } if (empty($files)) { Response::jsonArray(array()); } sort($files); $list = array(); foreach ($files as $k => $fpath) { $text = basename($fpath); if ($text === '.svn') { continue; } $obj = new stdClass(); $obj->id = str_replace($dirPath, '', $fpath); $obj->text = $text; if ($obj->text === 'Controller.php') { $controllerName = str_replace(array($dirPath, DIRECTORY_SEPARATOR), array('', '_'), substr($fpath, 0, -4)); $obj->url = Backend_Designer_Code::getControllerUrl($controllerName); } else { $obj->url = ''; } if (is_dir($fpath)) { $obj->expanded = false; $obj->leaf = false; } else { if ($text !== 'Controller.php') { continue; } $obj->leaf = true; } $list[] = $obj; } if ($this->_configMain->get('allow_externals') && $path == '') { $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php'); $eExpert = new Externals_Expert($this->_configMain, $config); $list[] = $eExpert->getControllersTree(); } Response::jsonArray($list); }
/** * (non-PHPdoc) * @see Bgtask_Abstract::run() */ public function run() { $lang = Lang::lang(); $this->setTotalCount(4); $config = Registry::get('main', 'config'); $deployCfg = Config::factory(Config::File_Array, $config->get('configs') . 'deploy.php'); $delimiter = $config->get('urlDelimiter'); $url = 'http://' . str_replace(array('http://', $delimiter . $delimiter, $config->get('urlExtension')), array('', $delimiter, ''), $this->_config['url'] . $delimiter . 'deploy' . $delimiter . 'syncfiles'); $dataSend = array('key' => Utils::hash($this->_config['key'])); $curl = curl_init(); $this->log('Connecting to ' . $url . '...'); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_VERBOSE, 0); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $dataSend); curl_setopt($curl, CURLOPT_TIMEOUT, 3600); $result = curl_exec($curl); $this->_nextStep(); if ($result === false) { $this->error(curl_error($curl)); } $data = json_decode($result, true); if (empty($data) || !is_array($data)) { $this->error('Empty response from server'); } if (!$data['success']) { $this->error('Remote server error. ' . $data['msg']); } if (!isset($data['data']['files'])) { $this->error('Invalid result'); } $data = $data['data']; $serverDir = $deployCfg->get('datadir') . $this->_config['id'] . '/'; if (!file_exists($serverDir) && !mkdir($serverDir)) { $this->error($lang->CANT_WRITE_FS . '(' . $serverDir . ')'); } $this->_nextStep(); if (!Utils::exportArray($serverDir . 'map.php', $data['files'])) { $this->error($lang->CANT_WRITE_FS . '(' . $serverDir . 'map.php' . ')'); } $this->_nextStep(); if (!@file_put_contents($serverDir . 'lastfsupdate', date('Y-m-d H:i:s'))) { $this->error($lang->CANT_WRITE_FS . '(' . $serverDir . 'lastfsupdate' . ')'); } $this->_nextStep(); $this->finish(); }
/** * (non-PHPdoc) * @see Backend_Controller_Crud::indexAction() */ public function indexAction() { $this->_resource->addInlineJs(' var canEdit = ' . $this->_user->canEdit($this->_module) . '; var canDelete = ' . $this->_user->canDelete($this->_module) . '; var menuItemlinkTypes = ' . Dictionary::getInstance('link_type')->__toJs() . '; '); $modulesConfig = Config::factory(Config::File_Array, $this->_configMain->get('backend_modules')); Model::factory('Medialib')->includeScripts(); $this->_resource->addJs('/js/lib/ext_ux/SearchField.js', 0); $this->_resource->addJs('/js/app/system/SearchPanel.js', 0); $this->_resource->addJs('/js/app/system/HistoryPanel.js', 0); $this->_resource->addJs('/js/app/system/EditWindow.js', 0); $this->_resource->addJs('/js/app/system/crud/' . strtolower($this->_module) . '.js', 4); }
/** * @return User * @param string $identifier */ public function loadUser($identifier) { include 'nusoap/lib/nusoap.php'; $client = new nusoap_client(Config::factory()->getParam('cmb.cpa.webservice.user')); $response = $client->call('loadUser', array($identifier)); if ($client->getError()) { throw new Exception($client->getError()); } $userExternal = json_decode($response); $userLocal = new stdClass(); foreach ($userExternal as $attribute => $value) { $userLocal->{$attribute} = $value; } return $userLocal; }
protected function __construct() { ini_set('session.use_only_cookies', TRUE); ini_set('session.use_trans_sid', FALSE); $config = \Config::factory(\Config::getConfig()->get('session', array()), FALSE, 'session'); if ('database' == $config->get('type', 'native')) { $this->setSessionHandler(); } session_name($config->get('name', 'UNOSESSID')); // session will not work with a domain without top level $domain = $config->get('domain', $_SERVER['SERVER_NAME']); if (1 != preg_match('/.+\\.[a-z]{2,4}$/i', $domain)) { $domain = ''; } session_set_cookie_params($config->get('lifetime', 0), $config->get('path', '/'), $domain, $config->get('secure', FALSE), $config->get('httponly', TRUE)); session_start(); }
public function updateAction() { $this->_checkCanEdit(); $data = Request::post('data', 'raw', false); if ($data === false) { Response::jsonError($this->_lang->INVALID_VALUE); } $data = json_decode($data, true); if (!isset($data[0])) { $data = array($data); } $modulesCfg = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php'); $modulesCfg->removeAll(); foreach ($data as $v) { $modulesCfg->set($v['id'], array('active' => $v['active'])); } if ($modulesCfg->save()) { Response::jsonSuccess(); } else { Response::jsonError($this->_lang->CANT_WRITE_FS); } }
protected function execute(InputInterface $input, OutputInterface $output) { $provider = $input->getArgument('provider'); $baseDir = $_SERVER['HOME'] . DIRECTORY_SEPARATOR . '.slackpipe'; /** @var ConfigInterface $config */ $config = Config::factory($provider); // Custom Handler if ($class = Asserts::hasCustomSetup($provider)) { $command = new $class($this, $config); if (method_exists($command, 'remove')) { $command->remove($input, $output); } } else { $configPath = $config->filePath(); if ($config->exists()) { unlink($configPath); $output->writeln('Config removed: ' . $configPath); } else { $output->writeln('Config not found.'); } } }
/** * List defined Blocks */ public function classlistAction() { $blocksPath = $this->_configMain['blocks']; $classesPath = $this->_configMain['application_path']; $files = File::scanFiles($blocksPath, array('.php'), true, File::Files_Only); foreach ($files as $k => $file) { $class = Utils::classFromPath(str_replace($classesPath, '', $file)); if ($class != 'Block_Abstract') { $data[] = array('id' => $class, 'title' => $class); } } if ($this->_configMain->get('allow_externals')) { $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php'); $eExpert = new Externals_Expert($this->_configMain, $config); $extBlocks = $eExpert->getBlocks(); if (!empty($extBlocks)) { foreach ($extBlocks as $class => $path) { $data[] = array('id' => $class, 'title' => $class); } } } Response::jsonSuccess($data); }
/** * Include required JavaScript files defined in the configuration file */ public function includeScripts() { $media = Model::factory('Medialib'); $media->includeScripts(); $includesPath = $this->_configMain->get('configs') . 'js_inc_backend.php'; $cfg = Config::factory(Config::File_Array, $includesPath); $this->_resource->addJs('/js/lib/jquery.js', 0, true, 'head'); $this->_resource->addJs('/js/lib/extjs4/ext-all-debug.js', 0, true, 'head'); $this->_resource->addJs('/js/lang/' . $this->_configMain['language'] . '.js', 1, true, 'head'); $this->_resource->addJs('/js/lib/extjs4/locale/ext-lang-' . $this->_configMain['language'] . '.js', 2, true, 'head'); $this->_resource->addJs('/js/app/frontend/application.js', 3, false, 'head'); $this->_resource->addJs('/js/app/system/common.js', 3, false, 'head'); $this->_resource->addJs('/js/lib/extjs4/ext-theme-gray.js', 2); $this->_resource->addCss('/js/lib/extjs4/resources/css/ext-all-gray.css'); $this->_resource->addCss('/templates/system/default/css/style.css'); $this->_resource->addInlineJs(' var developmentMode = ' . intval($this->_configMain->get('development')) . '; app.wwwRoot = "' . $this->_configMain->get('wwwroot') . '"; app.delimiter = "' . $this->_configMain->get('urlDelimiter') . '"; app.admin = "' . $this->_configMain->get('wwwroot') . $this->_configMain->get('adminPath') . '"; '); if ($cfg->getCount()) { $js = $cfg->get('js'); if (!empty($js)) { foreach ($js as $file => $config) { $this->_resource->addJs($file, $config['order'], $config['minified']); } } $css = $cfg->get('css'); if (!empty($css)) { foreach ($css as $file => $config) { $this->_resource->addCss($file, $config['order']); } } } }