Example #1
1
 /**
  * Creates or updates a key-value pair in the config table.
  *
  * @param string $name the key
  * @param string $value the value
  * @return void
  */
 public static function setValue($name, $value)
 {
     $model = new Config();
     $model->name = $name;
     $model->value = $value;
     $model->replace();
 }
 /**
  * Try to retrieve a default setting from a config fallback.
  *
  * @param string $key
  * @param mixed  $default
  *
  * @return mixed config setting or default when not found
  */
 protected function getDefault($key, $default)
 {
     if (!$this->fallback) {
         return $default;
     }
     return $this->fallback->get($key, $default);
 }
Example #3
1
 public function getErrors(Config $cfg)
 {
     $i18n = Localization::getTranslator();
     $walletSettings = [];
     $emailSettings = [];
     $providerClass = '';
     try {
         $provider = $cfg->getWalletProvider();
         $providerClass = get_class($provider);
         $provider->verifyOwnership();
     } catch (Exception $e) {
         if (strpos($providerClass, 'CoinbaseWallet') !== false) {
             $walletSettings[] = ['id' => '#wallet-coinbaseApiKey-error', 'error' => $e->getMessage()];
         } else {
             $walletSettings[] = ['id' => '#wallet-id-error', 'error' => $e->getMessage()];
         }
     }
     try {
         $t = new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl');
         $t->setUsername($cfg->getEmailUsername())->setPassword($cfg->getEmailPassword())->start();
     } catch (Exception $e) {
         $emailSettings[] = ['id' => '#email-username-error', 'error' => $e->getMessage()];
     }
     $errors = [];
     if (!empty($pricingSettings)) {
         $errors['#pricing-settings'] = self::getPricingErrorsFromConfig($cfg);
     }
     if (!empty($walletSettings)) {
         $errors['#wallet-settings'] = $walletSettings;
     }
     if (!empty($emailSettings)) {
         $errors['#email-settings'] = $emailSettings;
     }
     return $errors;
 }
Example #4
1
 /**
  * Read menu file. Parse xml and initializate menu.
  *
  * @param	menu		string 		Configuration file
  * @param	cacheFile	string		Name of file where parsed config will be stored for faster loading
  * @return	void
  */
 public function parseFile(RM_Account_iUser $obUser)
 {
     PROFILER_IN('Menu');
     $cacheFile = $this->_filepath . '.' . L(NULL) . '.cached';
     if ($this->_cache_enabled and file_exists($cacheFile) and filemtime($cacheFile) > filemtime($this->_filepath)) {
         $this->_rootArray = unserialize(file_get_contents($cacheFile));
     } else {
         #
         # Initializing PEAR config engine...
         #
         $old = error_reporting();
         error_reporting($old & ~E_STRICT);
         require_once 'Config.php';
         $conf = new Config();
         $this->_root = $conf->parseConfig($this->_filepath, 'XML');
         if (PEAR::isError($this->_root)) {
             error_reporting($old);
             throw new Exception(__METHOD__ . '(): Error while reading menu configuration: ' . $this->_root->getMessage());
         }
         $this->_rootArray = $this->_root->toArray();
         if ($this->_cache_enabled) {
             file_put_contents($cacheFile, serialize($this->_rootArray));
         }
     }
     $arr = array_shift($this->_rootArray);
     $arr = $arr['menu'];
     $this->_menuData['index'] = array();
     // index for branches
     $this->_menuData['default'] = array();
     // default selected block of menu
     $this->_menuData['tree'] = $this->formMenuArray($obUser, $arr['node']);
     $this->_menuData['branches'] = array();
     // tmp array, dont cached
     PROFILER_OUT('Menu');
 }
Example #5
1
 public function preload()
 {
     $this->mdata['objlang'] = $this->language;
     $this->mdata['objurl'] = $this->url;
     $this->load->model('tool/image');
     $this->load->language('module/pavblog');
     $this->load->model("pavblog/blog");
     $this->load->model("pavblog/comment");
     $mparams = $this->config->get('pavblog');
     $default = $this->model_pavblog_blog->getDefaultConfig();
     $mparams = !empty($mparams) ? $mparams : array();
     if ($mparams) {
         $mparams = array_merge($default, $mparams);
     } else {
         $mparams = $default;
     }
     $config = new Config();
     if ($mparams) {
         foreach ($mparams as $key => $value) {
             $config->set($key, $value);
         }
     }
     $this->mparams = $config;
     if (!defined("_PAVBLOG_MEDIA_")) {
         if (file_exists('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/pavblog.css')) {
             $this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/pavblog.css');
         } else {
             $this->document->addStyle('catalog/view/theme/default/stylesheet/pavblog.css');
         }
         define("_PAVBLOG_MEDIA_", true);
     }
 }
Example #6
1
 public function __construct(PricingProvider $p)
 {
     $cfg = new Config();
     $this->currencyMeta = $cfg->getCurrencyMeta();
     $this->pricingProvider = $p;
     $this->loadCache();
 }
Example #7
1
 /**
  * Attempt to create a user, given a user email and a password
  */
 function create($email, $password, $idSession)
 {
     $user = new User();
     $userRow = $user->findByEmail($email);
     $config = new Config();
     $configRow = $config->fetchAll()->current();
     // Does this user exist?
     if ($userRow) {
         // Check the password
         if ($userRow->password == md5($password)) {
             // Delete a possibly existing session. Safer.
             $db = Zend_Db_Table::getDefaultAdapter();
             $db->query("DELETE FROM Session WHERE idSession = '{$idSession}'");
             // Insert in Session, for 2 hours
             $sessionRow = $this->createRow();
             $sessionRow->idSession = $idSession;
             $sessionRow->id_user = $userRow->id;
             $this->tempsLimite = date("U") + 7200;
             $sessionRow->roles = $userRow->roles;
             $sessionRow->save();
             return true;
         }
         return false;
     } else {
         return false;
     }
 }
 public function view($term, $pageID)
 {
     //require_once  'JsonClientUtil.php';
     require_once 'ServiceUtil.php';
     require_once 'Config.php';
     $myConfig = new Config();
     $myConfig->loadJsonConfig($data);
     $util = new ServiceUtil();
     $data['test'] = NULL;
     $term = str_replace("_", "%20", $term);
     //$term = str_replace("/", "%2F", $term);
     $startPoint = ($pageID - 1) * 20;
     $result = $util->expandTerm($term);
     $terms = $util->parseExpandedTerm($result, $term);
     //$litResult = searchLiteratureByYearUsingSolr($terms,$startPoint,20,"*",$year);
     $litResult = $util->searchLatestLiterature($terms, $startPoint, 20, "*", "*");
     $data['publications'] = $litResult;
     $data['term'] = $term;
     $data['pageID'] = $pageID;
     $data['page_title'] = "Literature:" . str_replace("%20", " ", $term);
     $data['enable_config'] = true;
     $this->load->view('templates/header2', $data);
     $this->load->view('pages/latestPublicationDisplay', $data);
     $this->load->view('templates/footer2', $data);
 }
Example #9
0
 public static function table($name)
 {
     $file = new Config();
     $file->name = $name;
     $file->setType('config');
     return $file;
 }
Example #10
0
 /**
  * Class constructor
  *
  * @param string $readOnly If readOnly is true, don't refresh the user's expire time.
  */
 public function __construct($readOnly = false)
 {
     session_start();
     $config = new Config();
     $this->_config = $config;
     // Users are always authorized if the configuration tells us to skip authentication.
     if ($config->getSkipAuth()) {
         return;
     }
     self::$_userId = $config->getUserId();
     self::$_password = $config->getUserPassword();
     if ($this->isAuthorized($readOnly)) {
         if (isset($_POST['auth_username']) && isset($_POST['auth_password']) && !$readOnly) {
             // User is logging in.
             $authTicket = bin2hex(openssl_random_pseudo_bytes(32));
             $atc = new AuthTicketController();
             $atm = new AuthTicketModel();
             $atm->setAuthTicket($authTicket);
             $atc->add($atm);
             $userId = self::$_userId;
             $now = date("Y-m-d H:i:s");
             $out = "{$now}: Login detected for {$userId} with {$authTicket}." . PHP_EOL;
             file_put_contents("login.log", $out, FILE_APPEND);
             self::$_authTicket = $authTicket;
             $_SESSION['auth_ticket'] = self::$_authTicket;
         }
     }
 }
Example #11
0
 public function __construct($site_config = null)
 {
     if ($site_config == null) {
         $siteConfigObj = new Config("site_config");
         $site_config = $siteConfigObj->getInfo();
         $this->config = $site_config;
     } else {
         $this->config = $site_config;
     }
     if ($this->checkEmailConf($site_config)) {
         $phpMailerDir = IWEB_PATH . 'core/util/phpmailer/PHPMailerAutoload.php';
         include_once $phpMailerDir;
         //创建实例
         $this->smtp = new PHPMailer();
         $this->smtp->Timeout = 60;
         $this->smtp->SMTPSecure = $site_config['email_safe'];
         $this->smtp->isHTML();
         //使用系统mail函数发送
         if (isset($site_config['email_type']) && $site_config['email_type'] == '2') {
             $this->smtp->isMail();
         } else {
             $this->smtp->isSMTP();
             $this->smtp->SMTPAuth = true;
             $this->smtp->Host = $site_config['smtp'];
             $this->smtp->Port = $site_config['smtp_port'];
             $this->smtp->Username = $site_config['smtp_user'];
             $this->smtp->Password = $site_config['smtp_pwd'];
         }
     } else {
         $this->error = '配置参数填写不完整';
     }
 }
Example #12
0
 public function common($uid)
 {
     $result = array();
     $menuModel = new Menu();
     //顶部菜单/底部菜单
     for ($i = 1; $i < 7; $i++) {
         $sql = "select * from {{menu}} where sort = {$i} and position = 1 and userid = {$uid} and pid = 0 ";
         $data["upmenu_{$i}"] = $menuModel->findBySql($sql);
         $sql = "select * from {{menu}} where sort = {$i} and position = 2 and userid = {$uid} and pid = 0";
         $data["downmenu_{$i}"] = $menuModel->findBySql($sql);
     }
     //下拉菜单
     $sql = "select * from {{menu}} where pid = (select id from {{menu}} where position = 1 and userid = {$uid} and sort = 3 and pid = 0) and position = 1 and userid = {$uid} order by sort asc ";
     $data["uplistmenu_3"] = $menuModel->findAllBySql($sql);
     //视频列表
     $mvModel = new Mv();
     $sql = "select * from {{mv}} where userid = {$uid} order by sort asc ";
     $data['mvlist'] = $mvModel->findAllBySql($sql);
     //音乐列表
     //			$songModel = new Song();
     //			$sql = "select * from {{song}} where userid = $uid order by sort asc ";
     //			$data['musiclist'] = $songModel->findAllBySql($sql);
     //网站个性配置
     $webModel = new Config();
     $sql = "select * from {{webconfig}} where userid = {$uid} ";
     $data['webconfig'] = $webModel->findBySql($sql);
     $data['url'] = "http://" . Yii::app()->params['bucket'] . "." . Yii::app()->params['domain'] . "/";
     $data['uid'] = $uid;
     return $data;
 }
Example #13
0
 /**
  * Will call events as close as it gets to one hour. Event handlers
  * which use this MUST be as quick as possible, maybe only adding a
  * queue item to be handled later or something. Otherwise execution
  * will timeout for PHP - or at least cause unnecessary delays for
  * the unlucky user who visits the site exactly at one of these events.
  */
 public function callTimedEvents()
 {
     $timers = array('minutely' => 60, 'hourly' => 3600, 'daily' => 86400, 'weekly' => 604800);
     foreach ($timers as $name => $interval) {
         $run = false;
         $lastrun = new Config();
         $lastrun->section = 'cron';
         $lastrun->setting = 'last_' . $name;
         $found = $lastrun->find(true);
         if (!$found) {
             $lastrun->value = time();
             if ($lastrun->insert() === false) {
                 common_log(LOG_WARNING, "Could not save 'cron' setting '{$name}'");
                 continue;
             }
             $run = true;
         } elseif ($lastrun->value < time() - $interval) {
             $orig = clone $lastrun;
             $lastrun->value = time();
             $lastrun->update($orig);
             $run = true;
         }
         if ($run === true) {
             // such as CronHourly, CronDaily, CronWeekly
             Event::handle('Cron' . ucfirst($name));
         }
     }
 }
Example #14
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);
         }
     }
 }
Example #15
0
 /**
  *
  */
 public function preload()
 {
     $this->load->model('pavblog/blog');
     $this->load->model('pavblog/comment');
     $this->load->model('tool/image');
     $mparams = $this->config->get('pavblog');
     $config = new Config();
     if ($mparams) {
         foreach ($mparams as $key => $value) {
             $config->set($key, $value);
         }
     }
     $this->mparams = $config;
     if ($this->mparams->get('comment_engine') == '' || $this->mparams->get('comment_engine') == 'local') {
     } else {
         $this->mparams->set('blog_show_comment_counter', 0);
         $this->mparams->set('cat_show_comment_counter', 0);
     }
     $this->language->load('module/pavblog');
     $this->load->model("pavblog/category");
     if (!defined("_PAVBLOG_MEDIA_")) {
         if (file_exists('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/pavblog.css')) {
             $this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/pavblog.css');
         } else {
             $this->document->addStyle('catalog/view/theme/default/stylesheet/pavblog.css');
         }
         define("_PAVBLOG_MEDIA_", true);
     }
 }
Example #16
0
 function indexAction()
 {
     $config_table = new Config();
     $modules_table = new Modules("core");
     $request = new Bolts_Request($this->getRequest());
     if ($request->has('modid')) {
         $modid = $request->modid;
     } else {
         $modid = 'bolts';
     }
     if ($this->_request->isPost()) {
         //we are posting
         $config_params = $this->_request->getParams();
         foreach ($config_params as $ckey => $value) {
             $data = array('value' => $value);
             $config_table->update($data, "ckey = '" . $ckey . "' and module='" . $modid . "'");
         }
         $this->view->success = $this->_T('Configuration Updated.');
         $config_table->cache();
         $params = array();
         $this->_Bolts_plugin->doAction($this->_mca . '_post_save', $params);
         // ACTION HOOK
     }
     $config = $config_table->fetchAll($config_table->select()->where('module = ?', $modid));
     if (count($config) > 0) {
         $config = $config->toArray();
         sort($config);
         $this->view->config = $config;
     }
     $modules = $modules_table->getEnabledModules();
     sort($modules);
     $this->view->modules = $modules;
     $this->view->current = $modid;
     $this->view->modid = $modid;
 }
Example #17
0
 /**
  * Initialize the internal static variables using the global variables
  *
  * @param Config $config Configuration object to load data from
  */
 public function init(Config $config)
 {
     foreach ($config->get('PasswordConfig') as $type => $options) {
         $this->register($type, $options);
     }
     $this->setDefaultType($config->get('PasswordDefault'));
 }
 public function run()
 {
     $cfg = new Config();
     $pNum = (int) $cfg->get('OLD_VERSION_JOB_PAGE_NUM');
     $pNum = $pNum < 0 ? 1 : $pNum + 1;
     $pl = new PageList();
     $pl->setItemsPerPage(3);
     /* probably want to keep a record of pages that have been gone through 
      * so you don't start from the beginning each time..
      */
     $pages = $pl->getPage($pNum);
     if (!count($pages)) {
         $cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
         return t("All pages have been processed, starting from beginning on next run.");
     }
     $versionCount = 0;
     $pagesAffected = array();
     foreach ($pages as $page) {
         if ($page instanceof Page) {
             $pvl = new VersionList($page);
             $pagesAffected[] = $page->getCollectionID();
             foreach (array_slice(array_reverse($pvl->getVersionListArray()), 10) as $v) {
                 if ($v instanceof CollectionVersion && !$v->isApproved() && !$v->isMostRecent()) {
                     @$v->delete();
                     $versionCount++;
                 }
             }
         }
     }
     $pageCount = count($pagesAffected);
     $cfg->save('OLD_VERSION_JOB_PAGE_NUM', $pNum);
     //i18n: %1$d is the number of versions deleted, %2$d is the number of affected pages, %3$d is the number of times that the Remove Old Page Versions job has been executed.
     return t2('%1$d versions deleted from %2$d page (%3$d)', '%1$d versions deleted from %2$d pages (%3$s)', $pageCount, $versionCount, $pageCount, implode(',', $pagesAffected));
 }
Example #19
0
 public function testDisplayTimeOptions()
 {
     $expected = "<option value=\"1 Month\" selected=\"selected\">1 Month</option>\n<option value=\"3 Month\">3 Month</option>\n<option value=\"6 Month\">6 Month</option>\n<option value=\"12 Month\">12 Month</option>\n";
     $this->assertEquals($expected, $this->object->displayTimeOptions());
     $expected = "<option value=\"1 Month\">1 Month</option>\n<option value=\"3 Month\">3 Month</option>\n<option value=\"6 Month\">6 Month</option>\n<option value=\"12 Month\" selected=\"selected\">12 Month</option>\n";
     $this->assertEquals($expected, $this->object->displayTimeOptions('12 Month'));
 }
Example #20
0
 public function update($id, $request)
 {
     $config = new Config(CONFIG . 'app.json');
     $config->parseFile();
     $data = $request->getParameters();
     if (isset($data['userSubmit'])) {
         $deny_fields = ['id', 'rank'];
         if (User::exists($id)) {
             $user = User::find($id);
             foreach ($data as $k => $value) {
                 if (isset($user->{$k}) && !in_array($k, $deny_fields)) {
                     switch ($k) {
                         case 'username':
                             $u_c = $user->getMainChannel();
                             $u_c->name = $value;
                             $u_c->save();
                             break;
                         case 'pass':
                             $value = !empty($value) ? password_hash($value, PASSWORD_BCRYPT) : $user->pass;
                             break;
                     }
                     $user->{$k} = $value;
                 }
                 $user->save();
             }
             $r = new ViewResponse("admin/user/edit", ['user' => $user]);
         }
         return $r;
     }
 }
 /**
  * @param Service $service
  *
  * @return AuthAdapterInterface
  */
 private function getAuthenticationAdapter()
 {
     //TODO add check for adapter interface
     //TODO ...plus I don't like this method code
     $adapter = $this->service->getAdapter() ?: $this->config->getDefaultAdapter();
     $adapterOptions = $this->service->getAdapterOptions();
     if (empty($adapterOptions)) {
         $adapterOptions = $this->config->getDefaultOptionsForAdapter();
     }
     if ($adapter === null) {
         throw new \RuntimeException('No suitable authentication adapter found');
     }
     if (class_exists($adapter)) {
         //Try FQCN
         $adapterInstance = new $adapter();
         $adapterInstance->setOptions($adapterOptions);
     } elseif (class_exists('noFlash\\PkiAuthenticator\\Adapters\\' . $adapter . 'Adapter')) {
         //Try default adapter
         $class = 'noFlash\\PkiAuthenticator\\Adapters\\' . $adapter . 'Adapter';
         $adapterInstance = new $class();
         $adapterInstance->setOptions($adapterOptions);
         return $adapterInstance;
     }
     throw new \RuntimeException('Adapter specified for service cannot be initialized');
 }
Example #22
0
 /**
  * @param array $params
  * @param Config $mainConfig
  * @return array
  */
 public static function applyDefaultParameters(array $params, Config $mainConfig)
 {
     $logger = LoggerFactory::getInstance('Mime');
     $params += ['typeFile' => $mainConfig->get('MimeTypeFile'), 'infoFile' => $mainConfig->get('MimeInfoFile'), 'xmlTypes' => $mainConfig->get('XMLMimeTypes'), 'guessCallback' => function ($mimeAnalyzer, &$head, &$tail, $file, &$mime) use($logger) {
         // Also test DjVu
         $deja = new DjVuImage($file);
         if ($deja->isValid()) {
             $logger->info(__METHOD__ . ": detected {$file} as image/vnd.djvu\n");
             $mime = 'image/vnd.djvu';
             return;
         }
         // Some strings by reference for performance - assuming well-behaved hooks
         Hooks::run('MimeMagicGuessFromContent', [$mimeAnalyzer, &$head, &$tail, $file, &$mime]);
     }, 'extCallback' => function ($mimeAnalyzer, $ext, &$mime) {
         // Media handling extensions can improve the MIME detected
         Hooks::run('MimeMagicImproveFromExtension', [$mimeAnalyzer, $ext, &$mime]);
     }, 'initCallback' => function ($mimeAnalyzer) {
         // Allow media handling extensions adding MIME-types and MIME-info
         Hooks::run('MimeMagicInit', [$mimeAnalyzer]);
     }, 'logger' => $logger];
     if ($params['infoFile'] === 'includes/mime.info') {
         $params['infoFile'] = __DIR__ . "/libs/mime/mime.info";
     }
     if ($params['typeFile'] === 'includes/mime.types') {
         $params['typeFile'] = __DIR__ . "/libs/mime/mime.types";
     }
     $detectorCmd = $mainConfig->get('MimeDetectorCommand');
     if ($detectorCmd) {
         $params['detectCallback'] = function ($file) use($detectorCmd) {
             return wfShellExec("{$detectorCmd} " . wfEscapeShellArg($file));
         };
     }
     return $params;
 }
Example #23
0
 public function __construct($site_config = null)
 {
     if ($site_config == null) {
         $siteConfigObj = new Config("site_config");
         $site_config = $siteConfigObj->getInfo();
         $this->config = $site_config;
     } else {
         $this->config = $site_config;
     }
     if ($this->checkEmailConf($site_config)) {
         //使用系统mail函数发送
         if (isset($site_config['email_type']) && $site_config['email_type'] == '2') {
             $this->smtp = new ISmtp();
         } else {
             //使用外部SMTP服务器发送
             $server = $site_config['smtp'];
             $port = $site_config['smtp_port'];
             $account = $site_config['smtp_user'];
             $password = $site_config['smtp_pwd'];
             $this->smtp = new ISmtp($server, $port, $account, $password);
         }
         if (!$this->smtp) {
             $this->error = '无法创建smtp类';
         }
     } else {
         $this->error = '配置参数填写不完整';
     }
 }
Example #24
0
 /**
  * Save config data
  * 
  * @param string $name   Config name
  * @param Config $config Config data
  * 
  * @return boolean
  */
 public function save($name, Config $config)
 {
     $path = $this->_getPath($name);
     $data = $config->valueOf();
     file_put_contents($path, serialize($data));
     return true;
 }
Example #25
0
 /**
  * The progress bar's UI extended model class constructor
  *
  * @param      string    $file          file name of model properties
  * @param      string    $type          type of external ressource (phpArray, iniFile, XML ...)
  *
  * @since      1.0
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function HTML_Progress_Model($file, $type)
 {
     $this->_package = 'HTML_Progress';
     if (!file_exists($file)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$file', 'was' => $file, 'expected' => 'file exists', 'paramnum' => 1));
     }
     $conf = new Config();
     if (!$conf->isConfigTypeRegistered($type)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$type', 'was' => $type, 'expected' => implode(" | ", array_keys($GLOBALS['CONFIG_TYPES'])), 'paramnum' => 2));
     }
     $data = $conf->parseConfig($file, $type);
     $structure = $data->toArray(false);
     $this->_progress =& $structure['root'];
     if (is_array($this->_progress['cell']['font-family'])) {
         $this->_progress['cell']['font-family'] = implode(",", $this->_progress['cell']['font-family']);
     }
     if (is_array($this->_progress['string']['font-family'])) {
         $this->_progress['string']['font-family'] = implode(",", $this->_progress['string']['font-family']);
     }
     $this->_orientation = $this->_progress['orientation']['shape'];
     $this->_fillWay = $this->_progress['orientation']['fillway'];
     if (isset($this->_progress['script']['file'])) {
         $this->_script = $this->_progress['script']['file'];
     } else {
         $this->_script = null;
     }
     if (isset($this->_progress['cell']['count'])) {
         $this->_cellCount = $this->_progress['cell']['count'];
     } else {
         $this->_cellCount = 10;
     }
     $this->_updateProgressSize();
 }
/**
 * Função que valida um usuário e senha
 *
 * @param string $usuario - O usuário a ser validado
 * @param string $senha - A senha a ser validada
 *
 * @return bool - Se o usuário foi validado ou não (true/false)
 */
function validaUsuario($user, $password)
{
    //Instância do banco de dados.
    $database = new Config();
    $db = $database->getConnection();
    global $_SG;
    //$cS = ($_SG['caseSensitive']) ? 'BINARY' : '';
    // Usa a função addslashes para escapar as aspas
    //    $nusuario = addslashes($user);
    //    $nsenha = addslashes($password);
    $usuario = new Usuario($db);
    $usuario->readName($user);
    if (empty($usuario->cd_usuario)) {
        // Nenhum registro foi encontrado => o usuário é inválido
        return false;
    } else {
        if (password_verify($password, $usuario->nm_senha_usuario)) {
            $_SESSION['usuarioID'] = $usuario->cd_usuario;
            // Pega o valor da coluna 'id do registro encontrado no MySQL
            $_SESSION['usuarioNome'] = $usuario->nm_usuario;
            // Pega o valor da coluna 'nome' do registro encontrado no MySQL
            // Verifica a opção se sempre validar o login
            if ($_SG['validaSempre'] == true) {
                // Definimos dois valores na sessão com os dados do login
                $_SESSION['usuarioLogin'] = $user;
                $_SESSION['usuarioSenha'] = $password;
            }
            return true;
        } else {
            return false;
        }
    }
}
Example #27
0
 private function template()
 {
     $config = new Config($this->registry);
     $twigPath = $config->getTWIGPath();
     $this->themeUrl = $this->registry->siteUrl . 'themes/' . $this->registry->template . '/';
     $this->isAjaxRequest = $this->registry->dispatcher->isAjaxRequest();
     require $twigPath;
     \Twig_Autoloader::register();
     $loader = new \Twig_Loader_Filesystem($this->getTemplate());
     $twig = new \Twig_Environment($loader);
     $urlFunction = new \Twig_SimpleFunction('url', function ($ctrl_action, $paramsArray = NULL) {
         $ctrl_action = explode('/', $ctrl_action);
         $controller = $ctrl_action[0] . '/';
         $action = $ctrl_action[1] . '/';
         $params = '';
         if (isset($paramsArray)) {
             $params .= '?';
             foreach ($paramsArray as $key => $value) {
                 $params .= $key . '=' . $value;
                 if (end($paramsArray) != $value) {
                     $params .= '&';
                 }
             }
         }
         $url = $this->registry->siteUrl . $controller . $action . $params;
         return $url;
     });
     $twig->addFunction($urlFunction);
     $template = $twig->loadTemplate($this->getView());
     return $template;
 }
Example #28
0
 public function addConfig(Config $config)
 {
     $this->configs[] = $config;
     $config->addConfig($this);
     $this->addVars($config->getVars());
     $this->addSectionVars($config->getSectionVars());
 }
Example #29
0
 public function testIsDevAllowed()
 {
     $store = 'some store';
     $result = 'result';
     $this->helperMock->expects($this->once())->method('isDevAllowed')->with($store)->will($this->returnValue($result));
     $this->assertEquals($result, $this->model->isDevAllowed($store));
 }
Example #30
0
 /**
  * @param string $key
  * @return mixed
  */
 public static function get($scope)
 {
     if (!isset(self::$settings[$scope])) {
         self::$instance->load($scope);
     }
     return self::$settings[$scope];
 }