sWMLanguage); $oWMUserInterface = &Singleton::instance('WMUserInterface'); $oWMUserInterface->setSkin($sSkin); try{ $oWMRequest = &Singleton::instance('WMRequest'); }catch(Exc $e){ } //If reload helper provided, data are first processed and then, user //is redirected to the same page, where his sid(use REALM ?) //request id and view to be shown are sent as GET vars to be able //to properly load the request from session backwards //This workaround solves the problem with showing up resending the form data //dialog each time user tries to refresh a page that does something with data //and the problems connected to this issue //This helps to store request ,when user is not authorized ( no session ) if($_REQUEST['usid']){ session_id($_REQUEST['usid']); session_start(); }else{ session_start(); $sid = session_id(); } if($_REQUEST['__sent']){ try{ //Store the requested data to session if(!$_REQUEST['rid']){ $sRequestID = $oWMRequest->store(); //Load request, if the action was called by link }else{ $sRequestID = urldecode($_REQUEST['rid']); $oWMRequest->appendGetData($sRequestID); } //Checks & executes actions sent by client - this will be my job try{ $oWMAction->checkInput(); $aResult = $oWMAction->execInput(); }catch(Exc $e){ //Get view to be moved on after error $sErrorView = $e->sView?$e->sView:$oWMRequest->get('error_view'); //FIXME : Serialize exc object to session ? $oWMRequest->set('error_id',$e->wmcode,$sRequestID); $oWMRequest->set('error_msg',$e->message,$sRequestID); $oWMRequest->set('error_view',$sErrorView,$sRequestID); if(!$_REQUEST['sid']){ $sStr = "&usid=".session_id(); }else{ $sStr = "&sid=".$_REQUEST['sid']; } header("Location: ".$sScriptUrl."?view=".$oWMUserInterface->getView(). "&rid=".$sRequestID. $sStr ); die(); } //After doing requested actions , redirect user to the results page header("Location: ".$sScriptUrl."?view=".$oWMUserInterface->getView(). ($oWMData->get('general','sid')?("&sid=".$oWMData->get('general','sid')):''). "&rid=".$sRequestID ); die(); } catch(Exc $e) { //Catch exception to be able to show it $oWMRequest->setException($e->sView); $oWMUserInterface->setError($e->XHTMLMessage()); } }else{ } try{ //Is there a request that has been processed before refresh refresh? $sRequestID = $_GET['rid']; if($sRequestID){ //If so retrieve it from session $oWMRequest->retrieve($sRequestID); }else{ //Prepare request object(load REQUEST data) $oWMRequest->prepare(); } //Set view $sView = $oWMRequest->get('view'); $oWMUserInterface->setView($sView?$sView:'login'); //Error if($oWMRequest->get('error_id')){ if($_GET['error_id']){ $oWMRequest->set('error_id','ERROR: XSS Injection of error ID'); } if($_GET['error_msg']){ $oWMRequest->set('error_id','ERROR: XSS Injection of error message'); } $sErrorView = $oWMRequest->get('error_view')?$oWMRequest->get('error_view'):'login'; $oExc = new Exc($oWMRequest->get('error_id'),$oWMRequest->get('error_msg'),false,false,$sErrorView); $oWMRequest->setException($oExc); $oWMUserInterface->setError($oExc->XHTMLMessage($oWMLanguage,$oWMUserInterface->getSkin())); } $i = time(); $o = microtime(); //Prepares data for the current view - you can //insert a portions of code to retrieve data from Merak/Webmail $oWMData->prepare(); //echo 'WMData->prepare() time: '.(time()+microtime()-$i-$o); //UserInterface tool - you will write your own widgets or use //existing ones to draw the interface just like you want(how it //is specified in the xml descriptor of the view echo $oWMUserInterface->draw(); //Critical exception }catch(Exc $e){ print_r($e); $sError = $e->XHTMLMessage($oWMLanguage,$oWMUserInterface->getSkin()); $aErrorData['error']['num'][]['error'] = $sError; $aErrorData['title'] = 'ERROR'; echo template('interface/skin/'.$oWMUserInterface->getSkin().'/template/html.tpl',$aErrorData); } //Time $time2 = explode(' ', microtime()); $begintime = $time1[1] + $time1[0]; $endtime = $time2[1] + $time2[0]; $totaltime = $endtime - $begintime; //echo "\n-- Executed in $totaltime sec --\n"; ?>