function ParseTemplate($data = NULL)
 {
     $cur_mod = $dispt->mModule;
     $cur_sub_mod = $dispt->mSubmodule;
     if (empty($data)) {
         $this->mrTemplate->addVar('menulist', 'MENU_DESC', 'No demo is available!');
         $this->mrTemplate->addVar('menulist', 'MENU_URL', '#');
     } else {
         foreach ($data as $key => $value) {
             if (Security::Instance()->mSecurityEnabled) {
                 $allow = Security::Instance()->AllowedToAccess($value['Module'], $value['SubModule'], 'view', $value['Type']);
             } else {
                 $allow = true;
             }
             if ($value['Module'] == $cur_mod && $value['SubModule'] == $cur_sub_mod) {
                 $this->mrTemplate->addVar('menulist', 'STRONG_OPEN', '<strong>');
                 $this->mrTemplate->addVar('menulist', 'STRONG_CLOSE', '</strong>');
             } else {
                 $this->mrTemplate->addVar('menulist', 'STRONG_OPEN', '');
                 $this->mrTemplate->addVar('menulist', 'STRONG_CLOSE', '');
             }
             if ($allow) {
                 $this->mrTemplate->addVar('menulist', 'MENU_NAME', $value['MenuName']);
                 $this->mrTemplate->addVar('menulist', 'MENU_DESC', $value['Description']);
                 $this->mrTemplate->addVar('menulist', 'MENU_URL', Configuration::Instance()->GetValue('application', 'baseaddress') . Dispatcher::Instance()->GetUrl($value['Module'], $value['SubModule'], 'view', $value['Type']));
                 $this->mrTemplate->parseTemplate('menulist', 'a');
             }
         }
     }
 }
 function NusoapResponse()
 {
     // force to set global variable $debug
     // before calling parent constructor
     $GLOBALS['debug'] = $this->mDebugMode;
     parent::soap_server();
     $this->configureWsdl(__CLASS__ . 'Service', FALSE, $this->mEndpoint);
     $this->mrDispatcher = Dispatcher::Instance();
     $this->mrSecurity = Security::Instance();
     $this->mrSession = Session::Instance();
     if (!empty($this->mRegisteredFunctions)) {
         foreach ($this->mRegisteredFunctions as $func_name => $params) {
             if (is_array($params) && $params != NULL) {
                 $this->register($func_name, $params['in'], $params['out'], $params['namespace'], $params['soapaction'], $params['style'], $params['use'], $params['documentation'], $params['encodingStyle']);
             } else {
                 $this->register($func_name);
             }
         }
     }
     if (!empty($this->mRegisteredTypes)) {
         foreach ($this->mRegisteredTypes as $type_name => $params) {
             if (is_array($params) && count($params) > 0) {
                 if ($params['type'] == 'complexType' && $params['phptype'] != 'scalar') {
                     $this->wsdl->addComplexType($type_name, $params['type'], $params['phptype'], $params['compositor'], $params['restrictionBase'], $params['elements'], $params['attrs'], $params['arraytype']);
                 } else {
                     $this->wsdl->addSimpleType($type_name, $params['type'], $params['phptype'], $params['compositor'], $params['restrictionBase'], $params['elements'], $params['attrs'], $params['arraytype']);
                 }
             } else {
                 $this->register($func_name);
             }
         }
     }
     $this->wsdl->addComplexType('ListType', 'complexType', 'array');
     $this->wsdl->addComplexType('AgmListType', 'complexType', 'array', '', 'SOAP-ENC:Array', array(), array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'xsd:integer[]')), 'xsd:integer');
 }
예제 #3
0
 function __construct()
 {
     SysLog::Instance()->log('Login(sso)::__construct', "login");
     // make a copy of a user instance
     $this->mUser = Security::Instance()->mrUser;
     $this->mSsoSystemId = Configuration::Instance()->GetValue('application', 'system_id');
     /* TODO: make this configurable" */
 }
예제 #4
0
 public function GetUnloadNotify()
 {
     #gtfwDebugSet
     #$this->SetDebugOn();
     $userId = Security::Instance()->mAuthentication->GetCurrentUser()->GetUserId();
     $result = $this->Open($this->mSqlQueries['get_unload_notify'], array($userId));
     $this->SetLoadAll();
     return $result;
 }
 function ProcessRequest()
 {
     Security::Instance()->Logout(TRUE);
     //$this->RedirectTo($this->mrDispatcher->GetUrl('login_default', 'session', 'destroy', 'html'));
     $module = Configuration::Instance()->GetValue('application', 'default_module');
     $submodule = Configuration::Instance()->GetValue('application', 'default_submodule');
     $action = Configuration::Instance()->GetValue('application', 'default_action');
     $type = Configuration::Instance()->GetValue('application', 'default_type');
     $this->RedirectTo(Dispatcher::Instance()->GetUrl($module, $submodule, $action, $type));
 }
 function ProcessRequest()
 {
     Security::Instance()->Logout(TRUE);
     //$this->RedirectTo($this->mrDispatcher->GetUrl('login_default', 'session', 'destroy', 'html'));
     $module = Configuration::Instance()->GetValue('application', 'default_module');
     $submodule = Configuration::Instance()->GetValue('application', 'default_submodule');
     $action = Configuration::Instance()->GetValue('application', 'default_action');
     $type = Configuration::Instance()->GetValue('application', 'default_type');
     $urlRedirect = Dispatcher::Instance()->GetUrl($module, $submodule, $action, $type);
     return array('exec' => 'GtfwAjax.replaceContentWithUrl("body-application","' . $urlRedirect . '&ascomponent=1")');
 }
예제 #7
0
 public function SendLog($log)
 {
     if (class_exists('Security')) {
         $user = Security::Instance()->mAuthentication->GetCurrentUser()->GetUserName();
     }
     if (empty($user)) {
         $user = GTFWConfiguration::GetValue('application', 'default_user');
     }
     $ip = $_SERVER['REMOTE_ADDR'];
     $result = $this->SendLogDb($user, $ip, $log);
     return $result;
 }
 function ProcessRequest()
 {
     if (Security::Instance()->IsLoggedIn()) {
         // redirect to proper place
         $module = 'home';
         $submodule = 'home';
         $action = 'view';
         $type = 'html';
         $this->RedirectTo(Dispatcher::Instance()->GetUrl($module, $submodule, $action, $type));
         return NULL;
     }
     echo '<pre>';
     print_r(Security::Instance()->IsLoggedIn());
     echo '</pre>';
     return Security::Instance()->RequestSalt();
 }
 function ProcessRequest()
 {
     if (Security::Instance()->Login($_REQUEST['username'] . '', $_REQUEST['password'] . '', $_REQUEST['hashed'] . '' == 1)) {
         // redirect to proper place
         $module = 'home';
         $submodule = 'home';
         $action = 'view';
         $type = 'html';
         Log::Instance()->SendLog('Proses Login Sukses');
         $this->RedirectTo(Dispatcher::Instance()->GetUrl($module, $submodule, $action, $type));
         return;
     } else {
         Log::Instance()->SendLog('Proses Login Gagal');
         $this->RedirectTo(Dispatcher::Instance()->GetUrl('login_default', 'login', 'view', 'html') . '&fail=1');
         return;
     }
     return NULL;
 }
 function IsLoggedIn()
 {
     return Security::Instance()->IsLoggedIn();
 }
예제 #11
0
 function Logout()
 {
     // make a copy of a user instance
     $this->mrUser = Security::Instance()->mrUser;
 }
 function ModuleDenied($module)
 {
     #gtfwDbOpen
     $groupId = Security::Instance()->mAuthentication->GetCurrentUser()->GetDefaultUserGroupId();
     #gtfwDbOpen
     if ($this->labelAksi == "notset") {
         if (!isset($_SESSION['describe_gtfw_module'])) {
             $result = $this->open($this->mSqlQueries['describe_gtfw_module'], array());
             $_SESSION['describe_gtfw_module'] = json_encode($result);
         } else {
             $result = json_decode($_SESSION['describe_gtfw_module'], true);
         }
         for ($i = 0; $i < count($result); $i++) {
             if (strtoupper($result[$i]['Field']) == 'LABELAKSI') {
                 $this->labelAksi = true;
                 break;
             } else {
                 $this->labelAksi = false;
             }
         }
     }
     if (isset($module->mrVariable)) {
         if (empty($this->moduleDelete)) {
             if (!isset($this->moduleDelete[$module->mrVariable])) {
                 if ($this->labelAksi === true) {
                     $result = $this->open($this->mSqlQueries['module_denied'], array($groupId, $module));
                 } else {
                     $result = $this->open($this->mSqlQueries['module_denied_2'], array($groupId, $module));
                 }
                 $this->moduleDelete[$module->mrVariable] = $result;
             } else {
                 $result = $this->moduleDelete[$module->mrVariable];
             }
             return $result;
         } else {
             return $this->moduleDelete[$module->mrVariable];
         }
     } else {
         return false;
     }
 }
 function call($params, $content)
 {
     //print_r($params);
     $name = 'name';
     // koreksi code tanpa mengubah code aslinya
     $content_repo =& $GLOBALS['content_repo'];
     $component_name =& $GLOBALS['component_name'];
     if (!isset($content_repo)) {
         $content_repo = array();
     }
     if (!isset($component_name)) {
         $component_name = array();
     }
     if (!isset($params['type'])) {
         $params['type'] = null;
     }
     // checking component's name
     if ($params[$name] != '' && isset($component_name[$params[$name]]) && $component_name[$params[$name]] != "{$params['module']} {$params['submodule']} {$params['action']} {$params['type']}") {
         return 'Redeclared component name: ' . $params['name'] . " for module {$params['module']}, submodule {$params['submodule']}, action {$params['action']}, and type {$params['type']}";
     }
     if (!isset($params['type'])) {
         $params['type'] = '';
     }
     $component_name[$params[$name]] = "{$params['module']} {$params['submodule']} {$params['action']} {$params['type']}";
     // this caching mechanism isn't suitable for module that needs to be rendered
     // everytime, such as paging navigation
     if (isset($content_repo[$params['name']][$params['module']][$params['submodule']][$params['action']][$params['type']])) {
         $this_content = $content_repo[$params['name']][$params['module']][$params['submodule']][$params['action']][$params['type']];
     } else {
         // catching component's paramaters
         $parameters = array();
         // pattemplate content style
         // warning: value is always trimmed!!
         if (trim($content) != '') {
             $temp = explode("\n", $content);
             foreach ($temp as $k => $v) {
                 if (trim($v) != '') {
                     list($var, $val) = explode(':=', $v);
                     $parameters[$var] = trim($val);
                 }
             }
         }
         // http get style (via 'params' attribute)
         if (isset($params['params'])) {
             if (trim($params['params']) != '') {
                 parse_str($params['params'], $temp);
                 foreach ($temp as $k => $v) {
                     $parameters[$k] = $v;
                 }
             }
         }
         // html tag attribute style
         // ie. not name, module, submodule, action, params
         foreach ($params as $k => $v) {
             if ($k != 'name' && $k != 'module' && $k != 'submodule' && $k != 'action' && $k != 'params') {
                 $parameters[$k] = $v;
             }
         }
         // WARNING: this soon will be obsolete
         // modified by Ageng (is it correct??)
         // catch the parameters that was setted for component
         if (isset($GLOBALS['parameters_set'])) {
             foreach ($GLOBALS['parameters_set'] as $key => $value) {
                 foreach ($parameters as $keyparameters => $valueparameters) {
                     if ($keyparameters == $key) {
                         $parameters[$keyparameters] = $value;
                     }
                 }
             }
         }
         ob_start();
         if (Security::Instance()->AllowedToAccess($params['module'], $params['submodule'], $params['action'], 'html')) {
             list($file_path, $class_name) = Dispatcher::Instance()->GetModule($params['module'], $params['submodule'], $params['action'], 'html');
             if (FALSE === $file_path) {
                 Dispatcher::Instance()->ModuleNotFound();
             } else {
                 require_once Configuration::Instance()->GetValue('application', 'gtfw_base') . 'main/lib/pat_template/pat_template.php';
                 require_once Configuration::Instance()->GetValue('application', 'gtfw_base') . 'main/lib/gtfw/response/html/HtmlResponse.class.php';
                 require_once $file_path;
                 if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
                     eval('$module = new ' . $class_name . '();');
                 } else {
                     eval('$module = new ' . $class_name . '();');
                 }
                 // give component a name
                 $module->mComponentName = $params['name'];
                 // display as module
                 // modified by Ageng
                 // assign component parameters to their property
                 $module->mComponentParameters = $parameters;
                 $module->Display(TRUE);
             }
         } else {
             Security::Instance()->ModuleAccessDenied();
         }
         $this_content = ob_get_contents();
         // ===== added by roby =====
         // this code created to make "prepared variable" to prevent patTemplate parsing it in included module that call with gtfwrendermodule function
         // because prepared variable will be parsed in main modul as a normal variable
         // to apply, you can put a param in gtfwrendermodule function like example below:
         // <!-- patTemplate:gtfwrendermodule module="module_name" submodule="sub_module" action="view" name="template_name" prepared_var="var1, var2"  / -->
         // multiple variables can be splited by comma as show above
         // and you must change character { and } with [ and ] in included module
         // e.g.: if you want variable {NAME} not to be parsed, you must change it with [NAME] and code below will change it back to {NAME} after prosessing included module
         if (!empty($params['prepared_var'])) {
             $arr_prepared_var = array();
             $arr_search = array();
             $arr_replace = array();
             $arr_prepared_var = explode(',', $params['prepared_var']);
             foreach ($arr_prepared_var as $v) {
                 $v = trim($v);
                 $arr_search[] = "[{$v}]";
                 $arr_replace[] = '{' . $v . '}';
             }
             $this_content = str_replace($arr_search, $arr_replace, $this_content);
         }
         // ===== end =====
         $content_repo[$params['name']][$params['module']][$params['submodule']][$params['action']][$params['type']] = $this_content;
         ob_end_clean();
     }
     return $this_content;
 }
예제 #14
0
 public function GetDhtmlxMenu()
 {
     $username = Security::Instance()->mAuthentication->GetCurrentUser()->GetUserName();
     $result = $this->Open($this->mSqlQueries['dhtmlx_menu'], array($username));
     return $result;
 }
예제 #15
0
 function Dispatch()
 {
     // send header first
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     if (isset($_SERVER['HTTP_X_GTFWMODULETYPE'])) {
         $type = $_SERVER['HTTP_X_GTFWMODULETYPE'];
     } else {
         $type = null;
     }
     //SysLog::Log("HEADER: " .$_SERVER['X-GtfwModuleType'], 'dispatcher');
     SysLog::Log("HEADER: " . $type, 'dispatcher');
     $module = '';
     $submodule = '';
     $action = '';
     $type = '';
     if (Configuration::Instance()->GetValue('application', 'url_type') == 'Long') {
         if (isset($_REQUEST['mod']) && isset($_REQUEST['sub']) && isset($_REQUEST['act']) && isset($_REQUEST['typ']) || $_REQUEST['typ'] == "rest") {
             // hack for requests/responses that don't need obfuscation
             if (in_array($_REQUEST['typ'], Configuration::Instance()->GetValue('application', 'url_obfuscator_exception'))) {
                 Configuration::Instance()->RegisterHook($this);
             }
             //
             $module = $this->Decrypt($_REQUEST['mod']);
             $submodule = $this->Decrypt($_REQUEST['sub']);
             $action = $this->Decrypt($_REQUEST['act']);
             $type = $this->Decrypt($_REQUEST['typ']);
             SysLog::Log("Long URL \$_REQUEST", 'dispatcher');
         } else {
             SysLog::Log("No \$_REQUEST set for Long URL {$_REQUEST['mod']}", 'dispatcher');
         }
     } elseif (Configuration::Instance()->GetValue('application', 'url_type') == 'Short') {
         if (isset($_REQUEST['mid'])) {
             $module_id = $this->Decrypt($_REQUEST['mid']);
             $request_translated = $this->TranslateRequestToLong($module_id);
             if (is_array($request_translated)) {
                 $module = $request_translated[0];
                 $submodule = $request_translated[1];
                 $action = $request_translated[2];
                 $type = $request_translated[3];
             }
         }
     } elseif (Configuration::Instance()->GetValue('application', 'url_type') == 'Path') {
         list(, , $module, , $submodule, , $action, , $type, ) = explode('/', $_SERVER['PATH_INFO']);
         $module = $this->Decrypt($module);
         $submodule = $this->Decrypt($submodule);
         $action = $this->Decrypt($action);
         $type = $this->Decrypt($type);
     }
     SysLog::Log("Translated request: {$module}/{$submodule}/{$action}/{$type} from " . print_r($_REQUEST, true), 'dispatcher');
     // default
     if ($module == '' && $submodule == '' && $action == '' && $type == '') {
         $module = Configuration::Instance()->GetValue('application', 'default_module');
         $submodule = Configuration::Instance()->GetValue('application', 'default_submodule');
         $action = Configuration::Instance()->GetValue('application', 'default_action');
         $type = Configuration::Instance()->GetValue('application', 'default_type');
     }
     // hack to overide any typ specified before.
     if (isset($_COOKIE['GtfwModuleType'])) {
         $type = $_COOKIE['GtfwModuleType']->Raw();
         // delete the cookie
         setcookie('GtfwModuleType', '', mktime(5, 0, 0, 7, 26, 1997));
     }
     if (isset($_SERVER['HTTP_X_GTFWMODULETYPE'])) {
         $type = $_SERVER['HTTP_X_GTFWMODULETYPE'];
     }
     SysLog::Log("Final request: {$module}/{$submodule}/{$action}/{$type}", 'dispatcher');
     $this->mModule = $module;
     $this->mSubModule = $submodule;
     $this->mAction = $action;
     $this->mType = $type;
     if (class_exists('ServiceSecurity')) {
         if (ServiceSecurity::Instance()->AllowedToAccess($module, $submodule, $action, $type)) {
             list($file_path, $class_name) = $this->GetModule($module, $submodule, $action, $type);
             if (FALSE === $file_path) {
                 $dbMsg = SysLog::Instance()->getAllError();
                 if (!empty($dbMsg)) {
                     echo "<pre>";
                     for ($i = 0; $i < count($dbMsg); $i++) {
                         echo $dbMsg[$i];
                     }
                     echo "</pre>";
                 }
                 die('Service Not Found');
             } else {
                 $this->DispacherSend($type, $file_path, $class_name);
             }
         }
     } else {
         SysLog::Instance()->log("Security::Instance()->AllowedToAccess({$module}, {$submodule}, {$action}, {$type})", 'sanitizer');
         if (Security::Instance()->AllowedToAccess($module, $submodule, $action, $type)) {
             list($file_path, $class_name) = $this->GetModule($module, $submodule, $action, $type);
             if (FALSE === $file_path) {
                 $this->ModuleNotFound();
             } else {
                 if (!Security::Instance()->IsProtocolCheckPassed($module, $submodule, $action, $type)) {
                     // redirect to https or http
                     $url = Configuration::Instance()->GetValue('application', 'baseaddress');
                     if (!isset($_SERVER['HTTPS'])) {
                         $url = preg_replace('/^http:/', 'https:', $url);
                     }
                     $url .= $this->GetUrl($module, $submodule, $action, $type);
                     Redirector::RedirectToUrl($url);
                 } else {
                     $this->DispacherSend($type, $file_path, $class_name);
                 }
             }
         } else {
             Security::Instance()->RequestDenied();
         }
     }
 }
 function Display($asModule = FALSE)
 {
     $urlAsModule = $_REQUEST['ascomponent']->Integer()->Raw() == 1;
     $this->mAsModule = $asModule || $urlAsModule;
     // dirty hack, for parent-child module communication
     $this->mrMainHtml = Dispatcher::Instance()->mrMainResponse;
     SysLog::Log('Finally, $this->mAsModule: ' . $this->mAsModule, 'htmlresponse');
     $data = $this->ProcessRequest();
     if ($this->mRedirected) {
         return;
     }
     // instantiate here, for efficiency reason
     //      $vartemp = & new patTemplate();
     $this->mrTemplate = new patTemplate();
     $this->mrTemplate->useTemplateCache('File', array('cacheFolder' => './tmplCache', 'lifetime' => 10, 'filemode' => 0644));
     // if this response is originated from dispatcher
     // ie. it will return the whole document
     // on the other side, it will return part of document (a.k.a module)
     // when $asModule is set to TRUE
     if (!$this->mAsModule) {
         $this->TemplateBase();
     } else {
         // use form helper
         SysLog::Log('Preparing FormHelper template', 'formhelper');
         $this->PrepareFormHelperTemplateBase();
     }
     $this->TemplateModule();
     $this->ParseTemplate($data);
     // prepare FormHelperJs
     $fhm = new FormHelperManager($this->mFormHelpers);
     if ($this->mAsModule) {
         $this->mrTemplate->addVar('form-helper-common', 'FORM_HELPER', $fhm->GetFormHelperManagerJs(false));
     }
     // set body extra, i.e. onload, onclick, etc
     if (!$this->mAsModule) {
         if ($this->mrTemplate->exists('document')) {
             if (!empty($this->mBodyAttribute)) {
                 $body_extra = '';
                 foreach ($this->mBodyAttribute as $attribute => $value) {
                     $body_extra .= ' ' . $value[0] . '=' . $value[1];
                 }
                 $this->mrTemplate->addVar('document', 'BODY_ATTRIBUTE', $body_extra);
                 ///TODO: onload attribute will clash with formHelper, so it's better to have special treatment for onload here
             }
             if (!empty($this->mRawHead)) {
                 $raw_head = '';
                 foreach ($this->mRawHead as $content) {
                     $raw_head .= $content;
                 }
                 $this->mrTemplate->addVar('document', 'RAW_HEAD', $raw_head);
             }
             $this->mrTemplate->addVar('document', 'RAW_HEAD', $fhm->GetFormHelperManagerJs());
         }
     }
     if (Configuration::Instance()->GetValue('application', 'url_friendly')) {
         $this->mrTemplate->addVar('document', 'RAW_BASEURL', Configuration::Instance()->GetValue('application', 'basedir'));
         $this->mrTemplate->addVar('content', 'RAW_BASEURL', Configuration::Instance()->GetValue('application', 'basedir'));
     }
     $delButton = Security::Instance()->ModuleDenied(Dispatcher::Instance()->mModule);
     $script = "<script>if(window.ButtonAccess){ var ba = new ButtonAccess(" . json_encode($delButton) . "); ba.removeButton();}</script>";
     $dbMsg = SysLog::Instance()->getAllError();
     $logMessage = "\r\n\t\t<script>\r\n\t\t\tmessage=" . json_encode($dbMsg) . ";\r\n\t\t\t\r\n\t\t\tfor(var msg in message){\r\n\t\t\t\tconsole.log(message[msg]);\r\n\t\t\t}\r\n\t\t</script>";
     $cleanLog = "";
     if (empty($dbMsg)) {
         $cleanLog = "\r\n\t\t\t<script>\r\n\t\t\t\t//if(console.clear != undefined)\r\n\t\t\t\t//\tconsole.clear();\r\n\t\t\t\t\r\n\t\t\t\t//if(window.clear != undefined)\r\n\t\t\t\t//\t\twindow.clear();\r\n\t\t\t</script>";
     }
     ob_start();
     $this->mrTemplate->displayParsedTemplate();
     $content = ob_get_contents();
     ob_end_clean();
     #		$doc = new DOMDocument;
     #
     #		$doc->loadHTML($content);
     #
     #		$items = $doc->getElementsByTagName("a");
     #		print_r($items->item(0)->getAttribute("href"));
     #		exit;
     echo $content . $script . $logMessage . $cleanLog;
 }