Beispiel #1
0
 public function createLog($user_id)
 {
     $model = new SysLog();
     $time = time();
     $model->user_id = $user_id;
     $model->user_name = User::getNameById($user_id);
     $model->log_time = $time;
     $model->message = "登陆成功!";
     $model->log_ip = Yii::app()->request->userHostAddress;
     if (SysLog::model()->count("user_id=:user_id and log_time=:log_time", array(":user_id" => $user_id, ":lig_time" => $time)) == 0) {
         $model->save();
     }
 }
Beispiel #2
0
 public function onRequest($request, $response)
 {
     //SysLog::debug(__METHOD__ . print_r($request,true), __CLASS__);
     //统一进行路由和数据的预处理
     $req = HttpHelper::httpReqHandle($request);
     // SysLog::info(__METHOD__.print_r($req,true),__CLASS__);
     if ($req['r'] === HttpHelper::HTTP_ERROR_URI) {
         $response->status(404);
         //todo:log
         $response->end("not found");
         return;
     }
     //SysLog::info(__METHOD__.'  '.__LINE__ . " REQUEST IS ".print_r($req,true),__CLASS__);
     $class = $req['route']['controller'] . 'Controller';
     $fun = 'action' . $req['route']['action'];
     //判断类是否存在
     if (!class_exists($class) || !method_exists($class, $fun)) {
         $response->status(404);
         SysLog::error(__METHOD__ . " class or fun not found class == {$class} fun == {$fun}", __CLASS__);
         $response->end("uri not found");
         return;
     }
     $obj = new $class($this->server, array('request' => $req['request'], 'response' => $response), $request->fd);
     //代入参数
     $request->scheduler->newTask($obj->{$fun}());
     $request->scheduler->run();
 }
Beispiel #3
0
 public function onReceive($server, $clientId, $fromId, $data)
 {
     $data = Yaaf::unpackAll($data);
     SysLog::notice(__METHOD__ . " fd = {$clientId}  fromId = {$fromId} data = " . print_r($data, true), __CLASS__);
     $info = $server->connection_info($clientId, $fromId);
     //yaaf 协议 路由
     $req = YaafHelper::yaafReqHandle($data);
     SysLog::info(__METHOD__ . print_r($req, true), __CLASS__);
     //路由失败 直接返回错误
     if ($req['r'] === YaafHelper::YAAF_ERROR_CMD) {
         //todo 协议搞成yaaf
         $yaaf_data = Yaaf::packHeader() . Yaaf::packBody(array('errCode' => -1, 'errMsg' => 'not found class'));
         $server->sendto($info['remote_ip'], $info['remote_port'], $yaaf_data);
         return;
     }
     $class = $req['route']['controller'] . 'Controller';
     $fun = 'action' . $req['route']['action'];
     //判断类是否存在
     if (!class_exists($class) || !method_exists($class, $fun)) {
         SysLog::error(__METHOD__ . print_r($req, true), __CLASS__);
         $yaaf_data = Yaaf::packHeader() . Yaaf::packBody(array('errCode' => -1, 'errMsg' => 'not found class'));
         $server->sendto($info['remote_ip'], $info['remote_port'], $yaaf_data);
         return;
     }
     $obj = new $class($this->server, array('request' => $data, 'info' => $info), $clientId);
     //代入参数
     $server->scheduler->newTask($obj->doFun($fun));
     $server->scheduler->run();
 }
Beispiel #4
0
 public function send(callable $callback)
 {
     $client = new \swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);
     $client->on("connect", function ($cli) {
         $cli->send($this->data);
     });
     $client->on('close', function ($cli) {
     });
     $client->on('error', function ($cli) use($callback) {
         $cli->close();
         call_user_func_array($callback, array('r' => 1, 'key' => $this->key, 'calltime' => $this->calltime, 'error_msg' => 'conncet error'));
     });
     $client->on("receive", function ($cli, $data) use($callback) {
         $this->calltime = microtime(true) - $this->calltime;
         $cli->close();
         call_user_func_array($callback, array('r' => 0, 'key' => $this->key, 'calltime' => $this->calltime, 'data' => $data));
     });
     if ($client->connect($this->ip, $this->port, $this->timeout, 1)) {
         $this->calltime = microtime(true);
         if (floatval($this->timeout) > 0) {
             $this->timer = swoole_timer_after(floatval($this->timeout) * 1000, function () use($client, $callback) {
                 $client->close();
                 \SysLog::error(__METHOD__ . " TIMEOUT ", __CLASS__);
                 $this->calltime = microtime(true) - $this->calltime;
                 call_user_func_array($callback, array('r' => 2, 'key' => '', 'calltime' => $this->calltime, 'error_msg' => 'timeout'));
             });
         }
     }
 }
 function DoLogin()
 {
     SysLog::Instance()->log('Login(sso)::DoLogin', "login");
     $ssoclient = SsoClient::Instance();
     SysLog::Instance()->log('Login(sso)::DoLogin poke me!!', "login");
     //       echo "Is sso alive? ";
     //       var_dump($ssoclient->isSsoAlive());
     //       die();
     $SsoAuth = $ssoclient->authenticateSsoUser($this->mUsername, $this->mPassword, $this->mSsoSystemId);
     //       echo "<pre>";
     //       var_dump($SsoAuth);
     //       echo "</pre>";
     //       die();
     SysLog::Instance()->log("DoLogin got SsoAuth: " . print_r($SsoAuth, true), "login");
     if ($SsoAuth['status'] === true) {
         // save SSID
         $ssoclient->saveSsIdToLocal($SsoAuth['ssid'], Configuration::Instance()->GetValue('application', 'sso_group'));
         // request details on SSID
         $SsoAttr = $ssoclient->requestSsIdAttributes($SsoAuth['ssid'], $this->mSsoSystemId);
         SysLog::Instance()->log("DoLogin got SsoAttr: " . print_r($SsoAttr, true), "login");
         $local_username = $SsoAttr['mSsoLocalUsername'];
         $this->mUser->mUserName = $local_username;
         $this->mUser->GetUser();
     }
     //       echo "<pre>";
     //       var_dump($SsoAttr);
     //       echo "</pre>";
     //       die($local_username);
     return $SsoAuth['status'];
 }
 function DoLogin()
 {
     $this->mUser->mUserName = $this->mUserName;
     $this->FetchUserInfo();
     SysLog::Instance()->log('User (' . $this->mUserName . ') active: ' . $this->GetCurrentUser()->GetActive(), 'login');
     if ($this->GetCurrentUser()->GetActive() != 'Yes') {
         return FALSE;
     }
     $hashed = $this->IsPasswordHashed();
     $salt = $this->GetSalt();
     if ($hashed) {
         $hash = md5(md5($salt . $this->GetCurrentUser()->GetPassword()));
     } else {
         $hash = $this->mUser->mPassword;
     }
     SysLog::Instance()->log('comparing: ' . $this->mPassword . ' == ' . $hash . ' hashed=' . $hashed . ' salt=' . $salt, 'login');
     if (md5($this->mPassword) == $hash) {
         SysLog::Instance()->log('Logged in!', 'login');
         $this->mIsLoggedIn = true;
         $_SESSION['is_logged_in'] = true;
         $_SESSION['username'] = (string) $this->mUserName;
         Session::Instance()->Restart();
         // regenerate session_id, prevent session fixation
     } else {
         $this->mIsLoggedIn = false;
         $_SESSION['is_logged_in'] = false;
         $_SESSION['username'] = Configuration::Instance()->GetValue('application', 'default_user');
     }
     return $this->mIsLoggedIn;
 }
Beispiel #7
0
 public static function createUdpApplication($config)
 {
     AutoLoad::addRoot(dirname(dirname($config)));
     SysLog::init(UserConfig::getConfig('log'));
     return new YaafUdpServ();
     // return $class;
     //进行路由解析等
 }
Beispiel #8
0
 /**
  * [init 启动定时器]
  * @return [type] [description]
  */
 public static function init()
 {
     if (!isset(self::$tickKey)) {
         self::$tickKey = swoole_timer_tick(1000 * self::LOOPTIME, function () {
             //循环数组,踢出超时情况
             self::loop();
         });
         \SysLog::info(__METHOD__ . " init timer tick key == " . self::$tickKey, __CLASS__);
     }
 }
 function SessionGc($maxExpireTime)
 {
     SysLog::Log('Garbage collecting...', 'Session');
     $result = $this->Execute($this->mSqlQueries['gc_data'], array(time(), $maxExpireTime));
     if (!$result) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
 function test($test_value)
 {
     if (trim($test_value) == '') {
         SysLog::Log('RuleRequired: Field ' . $this->mElementName . ' harus diisi', 'formhelper');
         $this->setError('Field ' . $this->mElementName . ' harus diisi');
         return false;
     } else {
         SysLog::Log('RuleRequired: Field ' . $this->mElementName . ' is not empty', 'formhelper');
         return true;
     }
 }
Beispiel #11
0
 /**
  * [packRsp 回调函数,收包,合包,回调]
  * @param  [type] $r          [description]
  * @param  [type] $client_key [description]
  * @param  [type] $data       [description]
  * @return [type]             [description]
  */
 public function recv($r, $client_key, $calltime, $data)
 {
     \SysLog::info(__METHOD__ . " r = {$r} client_key = {$client_key} callList = " . count($this->callRsp), __CLASS__);
     $this->callRsp[$client_key] = array('r' => $r, 'calltime' => $calltime, 'data' => $data);
     //收包完成
     if (count($this->callRsp) == count($this->callList)) {
         \SysLog::info(__METHOD__ . " get all the rsp ==== " . print_r($this->callRsp, true), __CLASS__);
         $this->calltime = microtime(true) - $this->calltime;
         call_user_func_array($this->callback, array('r' => $r, 'key' => '', 'calltime' => $calltime, 'data' => $this->callRsp));
     }
 }
 function DoLogout()
 {
     SysLog::Instance()->log('DoLogout sso', 'login');
     $ssoclient = SsoClient::Instance();
     $ssid = $ssoclient->getLocalSsId(Configuration::Instance()->GetValue('application', 'sso_group'));
     $result = $ssoclient->invalidateSsId($ssid);
     SysLog::Instance()->log('DoLogout sso invalidate result' . print_r($result, true), 'login');
     $result2 = $ssoclient->removeLocalSsId(Configuration::Instance()->GetValue('application', 'sso_group'));
     SysLog::Instance()->log('DoLogout sso removeLocalSsId result' . print_r($result2, true), 'login');
     return $result;
 }
    function GetFormHelperManagerJs($standalone = true)
    {
        $js1 = "";
        if (!empty($this->mFormHelpers)) {
            $js_formhelper .= <<<_FORM_HELPER_
   <script type="text/javascript">
      /* must preceed behaviour Library to get the desired effect: add validation selector and then let the rest handled by the simple_validator */
      function GtfwFormHelper() {
_FORM_HELPER_;
            //
            foreach ($this->mFormHelpers as $item) {
                $js_formhelper .= "\n" . $item->getJsCode() . "\n";
            }
            $js_formhelper .= <<<_FORM_HELPER_
      }
_FORM_HELPER_;
            if ($standalone) {
                $js_formhelper .= "\nFormHelperManager.addLoadEvent(GtfwFormHelper); /* apply */";
                // use loadevent
                SysLog::Log('Preparing formHelper for fullpage request', 'formhelpermanager');
            } else {
                $js_formhelper .= "\nGtfwFormHelper(); /* run immediately */";
                // run immediately
                SysLog::Log('Preparing formHelper for component requiremnt', 'formhelpermanager');
            }
            $js_formhelper .= '</script>';
        } else {
            SysLog::Log('No FormHelper set', 'formhelpermanager');
            $js_formhelper = '';
        }
        if ($standalone) {
            $js = <<<_RAW_HEAD_
   <script type="text/javascript" src="js/FormHelper.js"></script>
_RAW_HEAD_;
            $js1 .= <<<_RAW_HEAD_
   <script type="text/javascript" src="js/behaviour.js"></script>
   <script type="text/javascript" src="js/balloon.js"></script>
   <script type="text/javascript" src="js/simple_validator.js"></script>
_RAW_HEAD_;
            // load available js rules
            foreach (FormHelper::$JsRuleFiles as $item) {
                SysLog::Log('Loading JsRulesFiles: ' . $item . '.js', 'formhelpermanager');
                $js1 .= <<<_RAW_HEAD_
   <script type="text/javascript" src="js/formhelper_rules/{$item}.js"></script>
_RAW_HEAD_;
            }
        }
        if ($standalone) {
            return $js . $js_formhelper . $js1;
        } else {
            return $js_formhelper;
        }
    }
Beispiel #14
0
 /**
  * 处理request对象
  * @param req swoole yaaf server 获得的request对象
  */
 public static function yaafReqHandle($req)
 {
     $cmd = $req['reqHead']['cmd'];
     //路由
     $appRoute = YaafRoute::getRoute($cmd);
     SysLog::info(__METHOD__ . print_r($appRoute, true), __CLASS__);
     if (!$appRoute) {
         return array('r' => self::YAAF_ERROR_CMD);
     }
     //这里考虑以后根据appName路由到后端svr yaafUdpServ作为代理 分发流量
     return array('r' => self::YAAF_OK, 'route' => $appRoute, 'request' => array('reqHead' => $req['reqHead'], 'reqBody' => $req['reqBody']));
 }
 function test($test_value)
 {
     SysLog::Log('TypeEmail: testing TestValue: "' . $test_value . '"', 'formhelper');
     if (filter_var($test_value, FILTER_VALIDATE_EMAIL) === FALSE) {
         SysLog::Log('TypeEmail: Field ' . $this->mElementName . ' harus berupa alamat email', 'formhelper');
         $this->setError('Field ' . $this->mElementName . ' harus berupa alamat email');
         return false;
     } else {
         SysLog::Log('TypeEmail: Field ' . $this->mElementName . ' adalah alamat email', 'formhelper');
         return true;
     }
 }
Beispiel #16
0
 /**
  * 处理request对象
  * @param req swoole http server 获得的request对象
  */
 public static function httpReqHandle($req)
 {
     $method = $req->server['request_method'];
     $uri = $req->server['request_uri'];
     //路由
     $appRoute = HttpRoute::urlrouter_rewrite($uri, $method);
     SysLog::info(__METHOD__ . print_r($appRoute, true), __CLASS__);
     if (!$appRoute) {
         return array('r' => self::HTTP_ERROR_URI);
     }
     return array('r' => self::HTTP_OK, 'route' => $appRoute, 'request' => array('uri' => $uri, 'header' => $req->header, 'get' => array_merge((array) (isset($req->get) ? $req->get : array()), (array) $appRoute['get']), 'post' => isset($req->post) ? $req->post : '', 'files' => isset($req->files) ? $req->files : '', 'cookie' => isset($req->cookie) ? $req->cookie : '', 'rawcontent' => $req->rawContent(), 'method' => $method));
 }
 function __construct($dbConfig = NULL)
 {
     parent::__construct($dbConfig);
     SysLog::Instance()->log("creating AdodbLiteDatabaseEngine", "database");
     require_once Configuration::Instance()->GetValue('application', 'gtfw_base') . 'main/lib/adodb_lite/adodb.inc.php';
     $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_ASSOC;
     // this should be in config, but how?
     SysLog::Instance()->log("AdodbLiteDatabaseEngine::Preparing dbtype:" . $this->mDbConfig['db_type']);
     $this->mrDbConnection = ADONewConnection($this->mDbConfig['db_type']);
     // set debug mode via configuration
     $this->mrDbConnection->debug = (bool) $this->mDbConfig['db_debug_enabled'];
     SysLog::Instance()->log("AdodbLiteDatabaseEngine::Done preparing dbtype:" . $this->mDbConfig['db_type']);
 }
 final function Send()
 {
     $result = $this->ProcessRequest();
     $dbMsg = SysLog::Instance()->getAllError();
     if (isset($result["exec"]) && !empty($dbMsg)) {
         $result["exec"] = "message=" . json_encode($dbMsg) . ";for(var msg in message){console.log(message[msg]);};" . $result["exec"];
     } elseif (isset($result["exec"]) && empty($dbMsg)) {
         $result["exec"] = "if(console.clear != undefined)console.clear(); if(window.clear != undefined) window.clear();" . $result["exec"];
     } elseif (!isset($result["exec"]) && !empty($dbMsg)) {
         $result["exec"] = "message=" . json_encode($dbMsg) . ";for(var msg in message){console.log(message[msg]);};" . $result;
     }
     $result = $this->returnJSON($result);
     echo "{$result}";
 }
 final function validate()
 {
     $test_value = $this->mTestValue;
     SysLog::Log($this->getRuleName() . ': testing TestValue: "' . print_r($test_value, true) . '"', 'formhelper');
     if (is_array($test_value)) {
         foreach ($test_value as $key => $value) {
             if (!$this->test($value)) {
                 return false;
             }
         }
         return true;
     } else {
         return $this->test($test_value);
     }
 }
Beispiel #20
0
 private function test()
 {
     $test = new TestModel();
     $res = (yield $test->MysqlMuticallTest());
     SysLog::info(__METHOD__ . " res == " . print_r($res, true), __CLASS__);
     if ($res['r'] == 0) {
         //yield success
         SysLog::info(__METHOD__ . " yield success data == " . print_r($res['data'], true), __CLASS__);
         (yield $res);
     } else {
         //yield failed
         SysLog::error(__METHOD__ . " yield failed res == " . print_r($res, true), __CLASS__);
         (yield array('r' => 1, 'error_msg' => 'yield failed'));
     }
 }
Beispiel #21
0
 /**
  * [createClient description]
  * @return [type] [description]
  */
 public function createClient($ip, $port, $data, $timeout, $protocolType)
 {
     switch ($protocolType) {
         case 'udp':
             $client = new UDP($ip, $port, $data, $timeout);
             break;
         case 'tcp':
             $client = new TCP($ip, $port, $data, $timeout);
             break;
         default:
             \SysLog::error(__METHOD__ . " protocolType valid ==> {$protocolType}", __CLASS__);
             return false;
             break;
     }
     return $client;
 }
 function test($test_value)
 {
     $regexp = '/\\d+/';
     if ($test_value != '') {
         SysLog::Log('TypeNumber(' . $this->mElementName . '): Field is not empty: ' . $test_value, 'formhelper');
         if (!preg_match($regexp, $test_value, $matches)) {
             $this->setError('Field ' . $this->mElementName . ' harus berupa angka');
             return false;
         } else {
             return true;
         }
     } else {
         SysLog::Log('TypeNumber(' . $this->mElementName . '): Field is empty', 'formhelper');
         return true;
     }
 }
 /**
  * this method offers a default result caching technique,
  * but you can override this method as needed when the default isn't satisfying
  * @param string sql, within the form for sprintf
  * @param array params
  */
 public function OpenCache($sql, $params, $varMarker = NULL)
 {
     $sql_parsed = $this->GetCacheIdentifier($sql, $params);
     if (($result = $this->GetCache($sql_parsed)) === FALSE) {
         SysLog::Log('cache MISS for ' . $sql, 'cache');
         // cache miss
         $result = $this->Open($sql, $params, $varMarker);
         if ($result !== FALSE) {
             $this->CacheResult($sql_parsed, $result);
         }
         // cache valid only result
     } else {
         SysLog::Log('cache HIT for ' . $sql, 'cache');
     }
     SysLog::Log("OpenCache returns:\n" . print_r($result, true), 'cache');
     return $result;
 }
Beispiel #24
0
 public static function loop()
 {
     \SysLog::info(__METHOD__, __CLASS__);
     /*
     			遍历自己的数组,发现时间超过预定时间段,且该IO的状态依然是未回包状态,则走超时逻辑
     */
     foreach (self::$event as $socket => $e) {
         $now = microtime(true);
         \SysLog::debug(__METHOD__ . " key == {$socket}  now == {$now} timeout == " . $e['timeout'], __CLASS__);
         if ($now > $e['timeout']) {
             self::del($socket);
             $cli = $e['cli'];
             $cli->close();
             call_user_func_array($e['callback'], $e['params']);
         }
     }
 }
Beispiel #25
0
 /**
  * 处理request对象
  * @param req swoole http server 获得的request对象
  */
 public static function httpReqHandle($req)
 {
     $method = $req->server['request_method'];
     $uri = $req->server['request_uri'];
     //正则匹配的路由 支持restful 提供给深度用户使用
     // $appRoute = HttpRoute::urlrouter_rewrite($uri,$method);
     // explode 解析类似于  controller/action类型的url
     //默认会解析到default/index
     $mvcArr = explode('/', $uri);
     $appRoute['controller'] = isset($mvcArr[1]) ? $mvcArr[1] : 'default';
     $appRoute['action'] = isset($mvcArr[2]) ? $mvcArr[2] : 'index';
     SysLog::info(__METHOD__ . print_r($appRoute, true), __CLASS__);
     if (!$appRoute) {
         return array('r' => self::HTTP_ERROR_URI);
     }
     return array('r' => self::HTTP_OK, 'route' => $appRoute, 'request' => array('uri' => $uri, 'header' => $req->header, 'get' => array_merge((array) (isset($req->get) ? $req->get : array()), (array) $appRoute['get']), 'post' => isset($req->post) ? $req->post : '', 'files' => isset($req->files) ? $req->files : '', 'cookie' => isset($req->cookie) ? $req->cookie : '', 'rawcontent' => $req->rawContent(), 'method' => $method));
 }
 function __construct($dbConfig = NULL)
 {
     parent::__construct($dbConfig);
     // preparing wsdl cache configuration
     if (!isset($this->mDbConfig['db_wsdl_cache_enabled'])) {
         $this->mDbConfig['db_wsdl_cache_enabled'] = TRUE;
     }
     ini_set('soap.wsdl_cache_enabled', (string) intval($this->mDbConfig['db_wsdl_cache_enabled']));
     $this->mDbConfig['db_wsdl_cache_lifetime'] = $this->mDbConfig['db_wsdl_cache_lifetime'] != '' ? (int) $this->mDbConfig['db_wsdl_cache_lifetime'] : 60 * 60 * 24;
     // defaults to 1 day
     ini_set('soap.wsdl_cache_ttl', $this->mDbConfig['db_wsdl_cache_lifetime']);
     $this->mDbConfig['db_wsdl_cache_path'] = file_exists($this->mDbConfig['db_wsdl_cache_path']) ? $this->mDbConfig['db_wsdl_cache_path'] : Configuration::Instance()->GetTempDir();
     ini_set('soap.wsdl_cache_dir', $this->mDbConfig['db_wsdl_cache_path']);
     $this->mDbConfig['db_connection_timeout'] = $this->mDbConfig['db_connection_timeout'] != '' ? (int) $this->mDbConfig['db_connection_timeout'] : 30;
     // default to 30
     SysLog::Instance()->Log('PhpSoapDatabaseEngine::__construct', 'DatabaseEngine');
 }
 /**
  * Request SSID atribute (eg: username, etc) which will then be used to log into local system and run the system as usual (without SSO)
  * @param string $Ssid
  * @param string $domain system id
  * @return array Refer to SsidAttributes class (ssolib.php)
  * @todo make return value an object
  * @see SsidAttributes
  */
 function requestSsidAttributes($Ssid, $domain)
 {
     // TODO: makesure it's ecrypted before trasmited over the net
     //$this->mSoapClient->debug = true;
     $result = $this->mSoapClient->call('RequestSsidAttributes', array('sso_ssid' => $Ssid, 'sso_systemid' => $domain));
     SysLog::Instance()->log("requestSsidAttributes soaprequest: " . print_r($this->mSoapClient->request, true), "SsoClient");
     SysLog::Instance()->log("requestSsidAttributes soapresponse: " . print_r($this->mSoapClient->response, true), "SsoClient");
     //SysLog::Instance()->log("requestSsidAttributes response data: ".print_r($this->mSoapClient->responseData, true), "SsoClient");
     SysLog::Instance()->log("requestSsidAttributes got SsidAttributes: " . print_r($result, true), "SsoClient");
     //SysLog::Instance()->log("requestSsidAttributes debug: ".$this->mSoapClient->getDebug(), "SsoClient");
     //echo htmlentities($this->mSoapClient->getDebugAsXMLComment());
     //$this->mSoapClient->debug = false;
     //       echo "<pre>".htmlentities($this->mSoapClient->Response);
     //       var_dump($this->mSoapClient);
     //       echo "</pre>";
     //       die();
     return $result;
 }
 public function AllowedToAccess($module, $submodule, $action, $type)
 {
     if (Authentication::instance()->checkValidationAppClint() && Authorization::instance()->IsAllowedToAccess($module, $submodule, $action, $type, Authentication::instance()->getApplicationId())) {
         return true;
     } elseif (!Authentication::instance()->checkValidationAppClint() && Authorization::instance()->IsAllowedToAccess($module, $submodule, $action, $type, Authentication::instance()->getApplicationId())) {
         return true;
     } else {
         $dbMsg = SysLog::Instance()->getAllError();
         if (!empty($dbMsg)) {
             echo "<pre>";
             for ($i = 0; $i < count($dbMsg); $i++) {
                 echo $dbMsg[$i];
             }
             echo "</pre>";
         }
         Log::Instance()->SendLog('Gagal akses, request denied');
         die('You don\'t have permission to access this service');
     }
 }
 function GetUserGroup()
 {
     // fecth user groups
     $this->mUserGroup = array();
     $result = $this->Open($this->mSqlQueries['get_user_group'], array($this->mUserId, $this->mApplicationId));
     if ($result) {
         foreach ($result as $row => $val) {
             $this->mUserGroup[$val['GroupId']] = $val['GroupName'];
         }
     }
     // determine default user group & unit id
     $result = $this->Open($this->mSqlQueries['get_default_user_group'], array($this->mUserId, $this->mApplicationId));
     $this->mDefaultUserGroupId = $result[0]['GroupId'];
     $this->mDefaultUnitId = $result[0]['UnitId'];
     SysLog::Log('Got default GUID: ' . $this->mDefaultUserGroupId, get_class());
     if (!isset($_SESSION['active_user_group_id'])) {
         SysLog::Log('SetActiveUserGroupId to DefaultGUID: ' . $this->mDefaultUserGroupId, get_class());
         $_SESSION['active_user_group_id'] = $this->mDefaultUserGroupId;
     }
 }
 function DoLogin()
 {
     $this->mUser->mUserName = $this->mUserName;
     $this->FetchUserInfo();
     SysLog::Instance()->log('User (' . $this->mUserName . ') active: ' . $this->GetCurrentUser()->GetActive(), 'login');
     if ($this->GetCurrentUser()->GetActive() != 'Yes') {
         return FALSE;
     }
     SysLog::Instance()->log('Comparing: (supplied) ' . md5($this->mPassword) . ' == (original) ' . $this->GetCurrentUser()->GetPassword(), 'login');
     if ($this->GetCurrentUser()->GetPassword() == md5($this->mPassword)) {
         SysLog::Instance()->log('Logged in!', 'login');
         $this->mIsLoggedIn = true;
         $_SESSION['is_logged_in'] = true;
         $_SESSION['username'] = $this->mUserName;
         Session::Instance()->Restart();
         // regenerate session_id, prevent session fixation
     } else {
         $this->mIsLoggedIn = false;
     }
     return $this->mIsLoggedIn;
 }