Example #1
0
 /**
  * start($path = '', $name = '')
  *
  * セッションを開始する
  * もし、すでにセッションが存在している場合は
  * そのセッションIDを用いてセッションをスタートする
  * セッションが存在しない場合は新規にセッションを生成し、スタートする
  *
  * @access    public
  *
  * @param     string  $path    セッションファイル保存ディレクトリ
  * @param     string  $name    セッション名
  *
  * @return    boolean    セッション開始結果(true:正常終了/false:異常終了)
  */
 public function start($path = '', $name = '')
 {
     // セッション保存ディレクトリが指定されていたらその値を採用
     if (!empty($path)) {
         $this->sesspath = $path;
     }
     // セッション名が指定されていたらその値を採用
     if (!empty($name)) {
         $this->sessname = $name;
     }
     // セッション保存ディレクトリをセット
     if (!empty($this->sesspath) and is_writable($this->sesspath)) {
         session_save_path($this->sesspath);
         // 指定されていないか書き込めないならfalseを返す
     } else {
         return false;
     }
     // セッション名の指定
     session_name($this->sessname);
     // セッションが存在しない場合の処理
     if (empty($_COOKIE[$this->sessname])) {
         // 生成したセッションIDを付与する
         $base = $this->genRand();
         session_id($base);
     }
     // end of if
     // セッションタイムアウトの秒数をコンフィグから取得しセット
     $conf = new Conf();
     $conf->parse(RISOLUTO_CONF . 'risoluto.ini');
     session_set_cookie_params($conf->getIni('SESSION', 'timeout'));
     // セッションの開始
     return session_start();
 }
 /**
  * test_GetParseStatus_AfterParsed()
  *
  * パース後のGetParseStatus()の挙動をテストする
  */
 public function test_GetParseStatus_AfterParsed()
 {
     $instance = new Conf();
     $instance->parse(RISOLUTO_CONF . 'risoluto.ini');
     $this->assertTrue($instance->getParseStatus());
     unset($instance);
 }
Example #3
0
 static function init()
 {
     $fh = fopen("./log.txt", "w");
     try {
         fputs($fh, "start\n");
         $conf = new Conf(dirname(__FILE__) . "/../public/conf01.xml");
         print "user: "******"\n";
         print "host: " . $conf->get('host') . "\n";
         $conf->set("pass", "newpass");
         $conf->write();
     } catch (FileException $e) {
         // permissions issue or non-existent file
         fputs($fh, "file exception\n");
         throw $e;
     } catch (XmlException $e) {
         fputs($fh, "xml exception\n");
         // broken xml
     } catch (ConfException $e) {
         fputs($fh, "conf exception\n");
         // wrong kind of XML file
     } catch (Exception $e) {
         fputs($fh, "general exception\n");
         // backstop: should not be called
     } finally {
         fputs($fh, "end\n");
         fclose($fh);
     }
 }
Example #4
0
 static function site_classes(Conf $conf)
 {
     $sites = $conf->opt("repositorySites", ["harvardseas"]);
     return array_map(function ($abbr) {
         return RepositorySite::$sitemap[$abbr];
     }, $sites);
 }
Example #5
0
 public function testSet()
 {
     $this->conf->set('batch.num.messages', 666);
     $dumpedConfig = $this->conf->dump();
     $batchNumMessages = $dumpedConfig['batch.num.messages'];
     $this->assertEquals(666, $batchNumMessages);
 }
 /**
  * test_getIni_WithTwoArgs()
  *
  * パース後のgetIni()の挙動をテストする(セクションのみ指定)
  */
 public function test_getIni_WithTwoArgs()
 {
     $want = "RisolutoApps\\Pages\\View";
     $instance = new Conf();
     $instance->parse(RISOLUTO_CONF . 'risoluto.ini');
     $this->assertEquals($instance->getIni('SEQ', 'default'), $want);
     unset($instance);
 }
 /**
  * risolutoErrorLog($loglevel, $msg)
  *
  * エラーログを出力する
  *
  * @access    private
  *
  * @param     string $loglevel 出力するメッセージのログレベル
  * @param     string $msg 出力するメッセージ
  *
  * @return    boolean 常にTrue
  */
 private function risolutoErrorLog($loglevel, $msg)
 {
     // ログ出力しエラーメッセージを返却
     $conf = new Conf();
     $conf->parse(RISOLUTO_CONF . 'risoluto.ini');
     $log = new Log();
     $log->setCurrentLogLevel($conf->getIni('LOGGING', 'loglevel'));
     $log->log($loglevel, $msg);
 }
 private function _getProperModule()
 {
     $key = $this->_conf->get('module_url_variable_name');
     $moduleUrlName = $this->_get->{$key};
     $moduleName = $this->_appMap->getModuleNameFromUrlName($moduleUrlName);
     if (!is_null($moduleName)) {
         return new $moduleName($this->_get, $this->_post, $this->_conf, $this->_view, $this->_appMap);
     }
     throw new ControllerException('No module has been choosen for execution');
 }
Example #9
0
 /**
  * getProvider()
  *
  * 認証プロバイダの情報を取得する
  *
  * @access    private
  *
  * @param     void
  *
  * @return    object    認証プロバイダのインスタンス
  */
 private static function getProvider()
 {
     // コンフィグファイルの読み込み
     $conf = new Conf();
     $conf->parse(RISOLUTO_CONF . 'risoluto.ini');
     // プロバイダ情報を取得
     $tmp_provider = $conf->getIni('AUTH', 'provider');
     $provider = !empty($tmp_provider) ? $tmp_provider : 'Risoluto\\AuthDb';
     // 取得したプロバイダのインスタンスを生成し返却する
     return $provider;
 }
 public function __construct(Map $map, Conf $conf)
 {
     $this->setImageHandler($map->getImageHandler());
     $this->_logoLayout = LogoLayout::factory($conf->get('logo_layout'));
     $this->_logoFiles = $conf->get('logo_files');
     $this->setWorldMap($map->getWorldMap());
     $leftUpCorner = $map->getLeftUpCorner();
     $this->setLeftUpCorner($leftUpCorner['lon'], $leftUpCorner['lat']);
     $rightDownCorner = $map->getRightDownCorner();
     $this->setRightDownCorner($rightDownCorner['lon'], $rightDownCorner['lat']);
     parent::__construct($map->getImage());
 }
Example #11
0
function _update_schema_regrade_flags(Conf $conf)
{
    $result = $conf->ql("select rgr.*, u.cid from RepositoryGradeRequest rgr\n        left join (select link, pset, min(cid) cid\n                   from ContactLink where type=" . LINK_REPO . " group by link, pset) u on (u.link=rgr.repoid)");
    while ($row = edb_orow($result)) {
        if ($row->cid && ($u = $conf->user_by_id($row->cid)) && ($pset = $conf->pset_by_id($row->pset))) {
            $info = new PsetView($pset, $u, $u);
            $info->force_set_commit($row->hash);
            $update = ["flags" => ["t" . $row->requested_at => ["uid" => $u->contactId]]];
            $info->update_current_info($update);
        }
    }
    Dbl::free($result);
    return true;
}
Example #12
0
 /**
  * This implements the 'singleton' design pattern
  *
  * @return Conf The one and only instance
  */
 static function get_instance()
 {
     if (!self::$instance) {
         self::$instance = new Conf();
     }
     return self::$instance;
 }
 function index()
 {
     /* 取得列表数据 */
     $conditions = $this->_get_query_conditions(array(array('field' => 'state', 'name' => 'state', 'handler' => 'groupbuy_state_translator'), array('field' => 'group_name', 'name' => 'group_name', 'equal' => 'LIKE')));
     // 标识有没有过滤条件
     if ($conditions) {
         $this->assign('filtered', 1);
     }
     $page = $this->_get_page(10);
     //获取分页信息
     $groupbuy_list = $this->_groupbuy_mod->find(array('join' => 'be_join', 'order' => 'gb.group_id DESC', 'limit' => $page['limit'], 'count' => true, 'conditions' => 'user_id=' . $this->visitor->info['user_id'] . $conditions));
     $page['item_count'] = $this->_groupbuy_mod->getCount();
     //获取统计的数据
     foreach ($groupbuy_list as $key => $groupbuy) {
         $groupbuy['ican'] = $this->_ican($groupbuy['group_id']);
         $groupbuy_list[$key] = $groupbuy;
         $groupbuy_list[$key]['spec_quantity'] = unserialize($groupbuy['spec_quantity']);
         $groupbuy['default_image'] || ($groupbuy_list[$key]['default_image'] = Conf::get('default_goods_image'));
     }
     //dump($groupbuy_list);
     /* 当前位置 */
     $this->_curlocal(LANG::get('member_center'), 'index.php?app=member', LANG::get('my_groupbuy'), 'index.php?app=buyer_groupbuy', LANG::get('groupbuy_list'));
     /* 当前用户中心菜单 */
     $this->_curitem('my_groupbuy');
     /* 当前所处子菜单 */
     $this->_curmenu('groupbuy_list');
     $this->_format_page($page);
     $this->assign('page_info', $page);
     //将分页信息传递给视图,用于形成分页条
     $this->assign('groupbuy_list', $groupbuy_list);
     $this->assign('state', array('all' => Lang::get('group_all'), 'on' => Lang::get('group_on'), 'end' => Lang::get('group_end'), 'finished' => Lang::get('group_finished'), 'canceled' => Lang::get('group_canceled')));
     $this->_config_seo('title', Lang::get('member_center') . ' - ' . Lang::get('my_groupbuy'));
     $this->display('buyer_groupbuy.index.html');
 }
Example #14
0
 public function __construct()
 {
     $dispatcher = Conf::get('global.dispatcher_path', PI_CORE . 'RouteDispatcher.php');
     if (!is_readable($dispatcher) || !Pi::inc($dispatcher)) {
         throw new Exception('can not find the dispatcher config : global.dispatcher_path', 1032);
     }
 }
Example #15
0
 /**
  * [getIns 获取单例]
  * @return [type] [description]
  */
 public static function getConfIns()
 {
     if (self::$ins instanceof self) {
         return self::$ins;
     }
     return self::$ins = new self();
 }
Example #16
0
 /**
  * Get config data
  *
  * @param  $valueName
  * @return PDO
  */
 public static function get($valueName)
 {
     if (empty(self::$_cache)) {
         self::$_cache = self::_loadConfig();
     }
     return !empty(self::$_cache[$valueName]) ? self::$_cache[$valueName] : null;
 }
Example #17
0
 public function configureData()
 {
     if (!Tool::isOk($_POST['id']) || !($user = Model_User::getLoggedUser()) || $user->getId() != $_POST['id'] || !Tool::isOk($_POST['zip']) || !isset($_POST['gender']) || !Tool::isOk($_POST['login'])) {
         header('Location: ' . Conf::get('ROOT_PATH'));
         exit;
     }
     DB::update('UPDATE `user` SET
         `zip`="' . $_POST['zip'] . '",
         `male`="' . $_POST['gender'] . '"
         WHERE `id`="' . $_POST['id'] . '"');
     if (isset($_FILES) && isset($_FILES['avatar']) && $_FILES['avatar']['error'] != 4) {
         $size = filesize($_FILES['avatar']['tmp_name']);
         $stat = stat($_FILES['avatar']['tmp_name']);
         if ($size[0] <= 1680 && $size[1] <= 1680 && $stat['size'] <= 450 * 1024) {
             $extention = strtolower(preg_replace('#.+\\.([a-zA-Z]+)$#isU', '$1', $_FILES['avatar']['name']));
             $original = Conf::get('MEDIA_DIR') . 'avatar/original/' . $_POST['id'] . '.' . $extention;
             move_uploaded_file($_FILES['avatar']['tmp_name'], $original);
             $sizeSmall = explode('x', Conf::get('AVATAR_SMALL_SIZE'));
             $sizeMedium = explode('x', Conf::get('AVATAR_MEDIUM_SIZE'));
             $sizeLarge = explode('x', Conf::get('AVATAR_LARGE_SIZE'));
             Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_LARGE_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeLarge[0], isset($sizeLarge[1]) ? $sizeLarge[1] : false, true);
             Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_MEDIUM_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeMedium[0], isset($sizeMedium[1]) ? $sizeMedium[1] : false, true);
             Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_SMALL_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeSmall[0], isset($sizeSmall[1]) ? $sizeSmall[1] : false, true);
         }
     }
     $_SESSION['feedback'] = 'Your informations has been updated';
     header('Location: ' . Conf::get('ROOT_PATH') . $_POST['login']);
 }
 public static function getInstance()
 {
     if (!self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 public function excluirImagensDoAnuncio()
 {
     $sql = "delete from anuncioimagem where idAnuncio = :idAnuncio";
     $delete = new ComandoPreparado(Conf::pegCnxPadrao(), $sql);
     $delete->liga("idAnuncio", $this->idAnuncio);
     $delete->executa();
 }
Example #20
0
 protected final function __construct()
 {
     $this->conf = Conf::getConfIns();
     $this->connect($this->conf->host, $this->conf->user, $this->conf->pwd);
     $this->query('SET NAMES UTF8');
     $this->query('USE ' . $this->conf->db);
 }
 public static function _init()
 {
     date_default_timezone_set(Conf::param('timezone'));
     //设置默认时区
     //地址重写
     Rewrite::init();
 }
 public function excluirCaracteristicasDoImovel()
 {
     $sql = 'delete from imovelcaracteristica where idImovel=:idImovel';
     $delete = new ComandoPreparado(Conf::pegCnxPadrao(), $sql);
     $delete->liga("idImovel", $this->idImovel);
     $delete->executa();
 }
Example #23
0
 public function configure()
 {
     // Init category
     $category = new Model_Category(Conf::get('MAIN_CATEGORY'));
     if ($category->getQuestionsTotal(true, true) == 0) {
         return;
     }
     // Get questions
     $questions = $category->getQuestions('latest', $this->page, true, true);
     if ($category->getQuestionsTotal(true, true) <= ($this->page + 1) * Conf::get('QUESTION_PER_PAGE')) {
         header('X-JSON: (Question.setEndReached())');
     }
     $colors = Conf::get('GRAPH_COLORS');
     // Loop through all questions
     foreach ($questions as $key => $question) {
         // Get question's answers
         $answers = $question->getAnswers();
         $data = array();
         foreach (array_reverse($answers) as $key => $answer) {
             $data[] = array('value' => $answer->getPercentResultsMatching() / 100, 'color' => $colors[$key]);
         }
         // Assign question infos
         Globals::$tpl->assignLoopVar('question_archive', array('id' => $question->getId(), 'label' => $question->getLabel(), 'guid' => Tool::makeGuid($question->getLabel()), 'data' => json_encode($data), 'time' => Tool::timeWarp($question->getEndDate())));
         // Assign answers infos
         foreach ($answers as $key => $answer) {
             Globals::$tpl->assignLoopVar('question_archive.answer', array('percentFormated' => round($answer->getPercentResultsMatching()), 'label' => $answer->getLabel(), 'key' => $key));
         }
     }
 }
 public function excluirProximidadesDoImovel()
 {
     $sql = 'delete from imovelproximidade where idImovel=:idImovel';
     $delete = new ComandoPreparado(Conf::pegCnxPadrao(), $sql);
     $delete->liga("idImovel", $this->idImovel);
     $delete->executa();
 }
Example #25
0
 /**
  * 部分功能初始化
  */
 public static function init()
 {
     //引入公共方法
     require __BT__ . '/common/common.php';
     if (defined("__APP__")) {
         $file = __APP__ . '/common/common.php';
         if (is_file($file)) {
             require $file;
         }
         $config = __APP__ . '/library/Config.php';
         if (is_file($config)) {
             $conf = (include $config);
             //初始化conf
             Conf::init($conf);
         }
     }
     //定义常量.
     define('PHP_CLI', php_sapi_name());
     define('NOW_TIME', $_SERVER['REQUEST_TIME']);
     if (PHP_CLI != 'cli') {
         define('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
         define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
         define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
         define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
         define('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
         define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ? true : false);
     }
 }
Example #26
0
 public function configure()
 {
     // Get answers
     $answers = $this->question->getAnswers();
     $colors = Conf::get('GRAPH_COLORS');
     $dataWomen = array();
     $dataMen = array();
     // Percent MALE
     foreach (array_reverse($answers) as $key => $answer) {
         $dataMen[] = array('value' => $answer->getPercentResultsMatchingMale() / 100 * 0.95 + 0.05, 'color' => $colors[$key]);
     }
     foreach ($answers as $key => $answer) {
         Globals::$tpl->assignLoopVar('question_men', array('key' => $key, 'label' => $answer->getLabel(), 'percent' => number_format($answer->getPercentResultsMatchingMale(), 1, ',', ' ')));
     }
     // Percent FEMALE
     foreach (array_reverse($answers) as $key => $answer) {
         $dataWomen[] = array('value' => $answer->getPercentResultsMatchingFemale() / 100 * 0.95 + 0.05, 'color' => $colors[$key]);
     }
     foreach ($answers as $key => $answer) {
         Globals::$tpl->assignLoopVar('question_women', array('key' => $key, 'label' => $answer->getLabel(), 'percent' => number_format($answer->getPercentResultsMatchingFemale(), 1, ',', ' ')));
     }
     Globals::$tpl->assignVar('question_men_data', json_encode($dataMen));
     Globals::$tpl->assignVar('question_women_data', json_encode($dataWomen));
     Globals::$tpl->assignVar('question_label', $this->question->getLabel());
 }
 /**
  * 系统解密方法
  * @param  string $data 要解密的字符串 (必须是think_encrypt方法加密的字符串)
  * @param  string $key  加密密钥
  * @return string
  */
 static function think_decrypt($data, $key = '')
 {
     $key = md5(empty($key) ? Conf::param('data_auth_key') : $key);
     $data = str_replace(array('-', '_'), array('+', '/'), $data);
     $mod4 = strlen($data) % 4;
     if ($mod4) {
         $data .= substr('====', $mod4);
     }
     $data = base64_decode($data);
     $expire = substr($data, 0, 10);
     $data = substr($data, 10);
     if ($expire > 0 && $expire < time()) {
         return '';
     }
     $x = 0;
     $len = strlen($data);
     $l = strlen($key);
     $char = $str = '';
     for ($i = 0; $i < $len; $i++) {
         if ($x == $l) {
             $x = 0;
         }
         $char .= substr($key, $x, 1);
         $x++;
     }
     for ($i = 0; $i < $len; $i++) {
         if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) {
             $str .= chr(ord(substr($data, $i, 1)) + 256 - ord(substr($char, $i, 1)));
         } else {
             $str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1)));
         }
     }
     return base64_decode($str);
 }
 /**
  * Este metodo consulta os clientes de um determinado dono do dacadastro
  * @param idPessoaProprietario
  */
 public function consultar()
 {
     $criterio = '';
     /*$criterio  = (empty ($this->descricao)) ? '' : " or contabanco.descricao = :descricao" ;
       $criterio .= (empty ($this->idBanco)) ? '' : " or banco.descricao like :idBanco" ;        
       $criterio .= (empty ($this->agencia)) ? '' : " or contabanco.agencia = :agencia" ;        
       $criterio .= (empty ($this->conta)) ? '' : " or contabanco.conta = :conta" ;     */
     $sql = "select idContaReceber, documento, descricao, concat(parcela, '/', coalesce(parcelas,1)) as parcela, valorNominal, DATE_FORMAT(dataVencimento,'%d/%m/%Y') as dataVencimento, situacao, dataVencimento as ordem from contareceber where idPessoaProprietario=:idPessoaProprietario ";
     if (empty($criterio)) {
         $sql .= '  order by ordem asc limit ' . Conf::$PAGINACAO;
     } else {
         $sql .= " and (idContaReceber is null " . $criterio . ") order by descricao";
     }
     $consulta = new ConsultaPreparada(Conf::pegCnxPadrao(), $sql);
     $consulta->liga("idPessoaProprietario", $this->idPessoaProprietario);
     /*if (!empty ($criterio)) {
           if (!empty ($this->descricao)) {
               $consulta->liga("descricao", $this->descricao.'%');
           }
           
           if (!empty ($this->idBanco)) {
               $consulta->liga("idBanco", $this->idBanco.'%');
           }
           
           if (!empty ($this->agencia)) {
               $consulta->liga("agencia", $this->agencia);
           }
           
           if (!empty ($this->conta)) {
               $consulta->liga("conta", $this->descricao);
           }           
       } */
     return $this->transformaEmArray($consulta->getResultados());
 }
 function login()
 {
     if ($this->visitor->has_login) {
         $this->show_warning('has_login');
         return;
     }
     if (!IS_POST) {
         if (Conf::get('captcha_status.backend')) {
             $this->assign('captcha', 1);
         }
         $this->display('login.html');
     } else {
         if (Conf::get('captcha_status.backend') && base64_decode($_SESSION['captcha']) != strtolower($_POST['captcha'])) {
             $this->show_warning('captcha_faild');
             return;
         }
         $user_name = trim($_POST['user_name']);
         $password = $_POST['password'];
         $ms =& ms();
         $user_id = $ms->user->auth($user_name, $password);
         if (!$user_id) {
             /* 未通过验证,提示错误信息 */
             $this->show_warning($ms->user->get_error());
             return;
         }
         /* 通过验证,执行登陆操作 */
         if (!$this->_do_login($user_id)) {
             return;
         }
         $this->show_message('login_successed', 'go_to_admin', 'index.php');
     }
 }
Example #30
0
 /**
  * Get PDO instance
  *
  * @return PDO
  */
 public static function getPDO()
 {
     if (empty(self::$_pdo)) {
         self::$_pdo = new PDO(Conf::get(self::DSN), Conf::get(self::USER), Conf::get(self::PASSWORD));
     }
     return self::$_pdo;
 }