Exemplo n.º 1
0
	/**
	 * pageFinish() - to output contents of the SMARTY template to the screen
	 * 
	 * @return (echo)
	 */
	function pageFinish($action,$errorReporting=TRUE,$popup=FALSE){
		global $smarty,$myNav,$myError,$_SESSION;
		$smarty->assign("tot_time",stopTiming());
		$smarty->assign("nav_bar",$myNav->out());
		$smarty->assign("action",$action);
		
		//error reporting?
		if(($myError->getLength()>0) and ($errorReporting)){
			$smarty->assign("error_out",TRUE);
			$smarty->assign("error_list",$myError->getList());
		}
		
		//user logged in?
		if(is_object($_SESSION['USER'])){
			if($_SESSION['USER']->get("name")){
				$smarty->assign('logged_in',TRUE);
				$smarty->assign('user_name',ucfirst($_SESSION['USER']->get("name")));
			}
			
			//mark permissions
			$smarty->assign('edit_presentbox',$_SESSION['USER']->get("edit_presentbox"));
		}
		
		//output!
		if(!$popup){
			$smarty->display('index.htm');
		}else{
			$smarty->display('indexpopup.htm');
		}
	}
Exemplo n.º 2
0
    $allowedIPs = gethostbynamel($parsed['host']);
    $ip = getenv("REMOTE_ADDR");
    if (!in_array($ip, $allowedIPs)) {
        logError(getenv('REMOTE_HOST') . " XML-RPC access denied");
        return "this IP is not from neighbour " . $neighbour->get('node_id');
    }
}
function syncResp($params)
{
    debug("incoming SYNC request");
    $lastSync = xmlrpc_decode($params->getParam(0));
    $nodeData = xmlrpc_decode($params->getParam(1));
    $objects = xmlrpc_decode($params->getParam(2));
    $neighbour = sotf_Neighbour::getById($nodeData['node_id']);
    if (!$neighbour) {
        logError("No access: you are not an allowed neighbour node!");
        return new xmlrpcresp(0, XMLRPC_ERR_NO_ACCESS, "No access: you are not an allowed neighbour node!");
    }
    $msg = checkAccess($neighbour);
    if ($msg) {
        logError($msg);
        return new xmlrpcresp(0, XMLRPC_ERR_NO_ACCESS, "No access: {$msg}!");
    }
    $retval = $neighbour->syncResponse($lastSync, $nodeData, $objects);
    // send response
    $retval = xmlrpc_encode($retval);
    return new xmlrpcresp($retval);
}
stopTiming();
$page->logRequest();
debug("--------------- XML-RPC SERVER FINISHED -----------------------------------");
Exemplo n.º 3
0
 function send($template = 'main.htm')
 {
     global $smarty, $totalTime;
     if ($this->popup) {
         if ($template == 'main.htm') {
             $template = 'main_popup.htm';
         }
         $smarty->assign('POPUP', 1);
     }
     if (!$this->popup && !$this->halted) {
         if ($_SESSION['stream']) {
             $smarty->assign('STREAM_DATA', $_SESSION['stream']);
             // collect streaming info
             $playlist = new sotf_Playlist();
             $smarty->assign("STREAM_INFO", $playlist->getStreamInfo($_SESSION['stream']));
         }
     }
     unset($_SESSION['halted']);
     session_unregister('halted');
     // handle status messages
     $smarty->assign('STATUS_MESSAGES', $_SESSION['statusMsgs']);
     unset($_SESSION['statusMsgs']);
     session_unregister('statusMsgs');
     $smarty->assign('ERROR_MESSAGES', $_SESSION['errorMsgs']);
     unset($_SESSION['errorMsgs']);
     session_unregister('errorMsgs');
     stopTiming();
     $smarty->assign("totalTime", $totalTime);
     $smarty->display($template);
     $this->logRequest();
     //exit; //??
 }
Exemplo n.º 4
0
 function send($template = 'main.htm')
 {
     global $smarty, $totalTime;
     if ($this->popup) {
         if ($template == 'main.htm') {
             $template = 'main_popup.htm';
         }
         $smarty->assign('POPUP', 1);
     }
     unset($_SESSION['halted']);
     // handle status messages
     $smarty->assign('STATUS_MESSAGES', $_SESSION['statusMsgs']);
     unset($_SESSION['statusMsgs']);
     $smarty->assign('ERROR_MESSAGES', $_SESSION['errorMsgs']);
     unset($_SESSION['errorMsgs']);
     stopTiming();
     $smarty->assign("totalTime", $totalTime);
     $smarty->display($template);
     $this->logRequest();
     //exit; //??
 }
Exemplo n.º 5
0
	function stopTiming(){
  	global $startTime;

   	$microtime = microtime();
   	$microsecs = substr($microtime, 2, 8);
   	$secs = substr($microtime, 11);
   	$endTime = "$secs.$microsecs";
    $tottime = round(($endTime - $startTime),4);
		return $tottime;
  }
	
	//Запустим секундомер
  startTiming();
	
	$total = _readAll() - 166;
	switch ($total){
		case ($total < 2500):{$status = 'Baby'; break;}
		case ($total < 5000):{$status = 'Kid'; break;}
		case ($total < 7500):{$status = 'PreTeen'; break;}
		case ($total < 10000):{$status = 'Teenager'; break;}
		case ($total < 20000):{$status = 'PostTeen'; break;}
		case ($total < 30000):{$status = 'Adult'; break;}
		case ($total < 40000):{$status = 'GrandPa'; break;}
		default:{$status = 'Death'; break;}
	}
	
	echo "Overall you (and maybe not you) have written <b>" . $total . "</b> lines of code! <br>
	This code needs " . round($size / 1024,2) . " Kb of space!<br><br>";
	echo "Objectively, <b>your project is a - " . $status . "</b><br><br>";
	echo "This calculation has taken: " . stopTiming() . " seconds!";
?>
Exemplo n.º 6
0
 function send($template = 'main.htm')
 {
     global $smarty, $totalTime;
     stopTiming();
     $smarty->assign("totalTime", $totalTime);
     $smarty->display($template);
     $this->logRequest();
     //exit; //??
 }