function Fath_ctrl($cont) { try { $ret = array(); if (0 === strcmp($cont, DATH_CONT_LGI)) { if (true === Fath_login()) { $ret["ret"] = true; } else { $ret["ret"] = false; $ret["ret_msg"] = "authorization failed"; } } else { if (0 === strcmp($cont, DATH_CONT_LGO)) { Frot_resetSession(); $ret["ret"] = true; } else { if (0 === strcmp($cont, DATH_CONT_USR)) { $user = Frot_getSession("user"); $ret["ret"] = true; $ret["ret_msg"] = $user; } } } return $ret; } catch (Exception $e) { throw new Exception('ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . '):' . __FUNCTION__ . '()' . PHP_EOL . $e->getMessage()); } }
function Flgn_iniSrc($url) { try { global $Grot_path; # Fcom_setLogInfo( "debug" , "Flgn_iniSrc:".$Grot_path ); $cont = Frot_getConts($url["type"], $url["cont"], $tgt); if (null === $cont) { Frot_jumpFirst(); return; } Frot_setSession($tgt, true, false); $conts_lst = Frot_getContsList(array(DROT_STT_LGN, DROT_SUBSTT_INI)); $chk_flg = true; foreach ($conts_lst as $key => $val) { $chk_flg = Frot_getSession($val); if (null === $chk_flg) { # Fcom_setLogInfo( "debug" , "null session:".$val ); break; } } if (true === $chk_flg) { Frot_resetSession(); Frot_setSession(DROT_SESROT_STT, DROT_STT_LGN); Frot_setSession(DROT_SESROT_SUBSTT, DROT_SUBSTT_RDY); Fcom_setLogInfo("debug", "ready"); } echo $cont; } catch (Exception $e) { throw new Exception('ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . '):' . __FUNCTION__ . '()' . PHP_EOL . $e->getMessage()); } }
function Flgn_ctrl() { try { global $Grot_path; global $Grot_state; # Frot_logSession(); $sub_sts = Frot_getSession(DROT_SESROT_SUBSTT); if (null === $sub_sts) { Frot_setSession(DROT_SESROT_SUBSTT, DROT_SUBSTT_FST, false); $sub_sts = DROT_SUBSTT_FST; } if (0 === strcmp($sub_sts, DROT_SUBSTT_FST)) { # Fcom_setLogInfo( "debug" , "first:".$Grot_path ); Flgn_first(); return; } else { if (0 === strcmp($sub_sts, DROT_SUBSTT_INI)) { # Fcom_setLogInfo( "debug" , "init:".$Grot_path ); Flgn_init(); return; } else { if (0 === strcmp($sub_sts, DROT_SUBSTT_RDY)) { # Fcom_setLogInfo( "debug" , "ready:".$Grot_path ); Flgn_ready(); return; } else { Frot_jumpFirst(); return; } } } } catch (Exception $e) { throw new Exception('ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . '):' . __FUNCTION__ . '()' . PHP_EOL . $e->getMessage()); } }
/** * @brief get front contents * @param url : url object (/:app/:func/:type/:cont) */ function Frot_getConts($type, $cont, &$tgt) { try { global $Grot_uriList; global $Grot_path; # Fcom_setLogInfo( "debug" , "Frot_getConts:".$Grot_path ); $list = null; $sts = Frot_getSession(DROT_SESROT_STT); $sub_sts = Frot_getSession(DROT_SESROT_SUBSTT); if (!isset($Grot_uriList[$sts])) { # Fcom_setLogInfo ( "debug" , 'ERR(File:'.basename(__FILE__).',Line:'.__line__.')' ); return null; } $list = $Grot_uriList[$sts]; if (!isset($list[$sub_sts])) { Fcom_setLogInfo("debug", 'ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . ')'); return null; } $list2 = $list[$sub_sts]; if (isset($list2[$type][$cont])) { Frot_setContsType($list2[$type][$cont]); $tgt = $list2[$type][$cont]; return file_get_contents(dirname(__FILE__) . '/../../../..' . $list2[$type][$cont]); } #Fcom_setLogInfo ( "debug" , 'ERR(File:'.basename(__FILE__).',Line:'.__line__.')' ); return null; } catch (Exception $e) { throw new Exception('ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . '):' . __FUNCTION__ . '() path:' . $path . PHP_EOL . $e->getMessage()); } }
function Fapp_jumpFirst() { try { global $Grot_path; Fcom_setLogInfo(DCOM_LOGLV_DBG, "app jump first:" . $Grot_path); $user = Frot_getSession("user"); # Frot_logSession(); Frot_resetSession(); if (null === $user) { header('Location: http://' . DROT_HOST . '/' . DROT_APP_NAME); exit; } Frot_setSession(DROT_SESROT_STT, DROT_STT_APP, false); Frot_setSession(DROT_SESROT_SUBSTT, DROT_SUBSTT_FST, false); Frot_setSession(DROT_LGDIN_USER, $user, false); header('Location: http://' . DROT_HOST . '/' . DROT_APP_NAME . '/'); exit; } catch (Exception $e) { throw new Exception('ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . '):' . __FUNCTION__ . '()' . PHP_EOL . $e->getMessage()); } }
function Fapp_iniSrc($url) { try { global $Grot_path; $cont = Frot_getConts($url["type"], $url["cont"], $tgt); if (null === $cont) { Fcom_setLogInfo("debug", "app null conts:" . $Grot_path); #Fapp_jumpFirst(); return; } Frot_setSession($tgt, true, false); # Frot_logSession(); $conts_lst = Frot_getContsList(array(DROT_STT_APP, DROT_SUBSTT_INI)); # Fcom_logObj( "conts_lst" , $conts_lst ); $chk_flg = true; # Fcom_setLogInfo( "debug" , "check ready start" ); foreach ($conts_lst as $key => $val) { $chk_flg = Frot_getSession($val); # Fcom_setLogInfo( "debug" , $key.":".$chk_flg ); if (null === $chk_flg) { # Fcom_setLogInfo( "debug" , "null session:".$val ); break; } } # Fcom_setLogInfo( "debug" , "end check ready" ); if (true === $chk_flg) { $user = Frot_getSession("user"); Frot_resetSession(); Frot_setSession(DROT_SESROT_STT, DROT_STT_APP); Frot_setSession(DROT_SESROT_SUBSTT, DROT_SUBSTT_RDY); Frot_setSession("user", $user, false); Fcom_setLogInfo("debug", "app ready:" . $user); } echo $cont; return; } catch (Exception $e) { throw new Exception('ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . '):' . __FUNCTION__ . '()' . PHP_EOL . $e->getMessage()); } }
require_once dirname(__FILE__) . "/../app/Sapp_ctrl.php"; require_once dirname(__FILE__) . "/../rst/Srst_ctrl.php"; /*** global ***/ $Grot_path = null; $Grot_state = null; try { session_start(); $Grot_path = $_SERVER['REQUEST_URI']; // check REST if (true === Frst_isRestRequest($Grot_path, $_POST)) { $ret = Frst_callTarget($Grot_path, $_POST); echo json_encode($ret); return; } /* routing state */ $Grot_state = Frot_getSession(DROT_SESROT_STT); /* degub start */ # Frot_resetSession(); # return; # Frot_logSession(); Fcom_setLogInfo("debug", "url:" . $Grot_path); /* debug end */ /* check login */ if (null === $Grot_state) { Frot_setSession(DROT_SESROT_STT, DROT_STT_LGN, false); $Grot_state = DROT_STT_LGN; } if (0 === strcmp($Grot_state, DROT_STT_LGN)) { Flgn_ctrl(); return; } else {