Exemplo n.º 1
0
function FatalError($st) {
	global $OUTJSON;
	global $APPL;
	global $CMD;
	global $WEBGUI;
	global $ini;
		
	$WEBGUI=array();
	unset($OUJSON['win']);
	
	if (@$ini['error']['debug'] or @$ini['error']['showid']) {
		$errorID = $APPL['app']."\n".parse_url($APPL['url'],PHP_URL_PATH)."\n$st";
		$errorID = base_convert(abs(crc32($errorID)),10,36).'-'.base_convert(abs(crc32(strtoupper($errorID))),10,36);
		}
		
	if (@$ini['error']['debug'] or @$ini['error']['log']) {
		@ob_get_clean();
		ob_start();
		if (@$ini['error']['args']) debug_print_backtrace(); else debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
		$dbg=@ob_get_clean();
		}
	
	if (@$ini['error']['log']) {
		$f = $_SERVER['DOCUMENT_ROOT'].'/var/log';
		if (!file_exists($f)) @mkdir($f);
		$f.= '/.error';
		if (!file_exists($f)) @mkdir($f);
		$f.='/'.$errorID.'.log';
		
		if (!file_exists($f)) {
			$t0=str_replace(array('<br>','<br />'),"\n",$dbg);
			$t0=str_replace("\n\n","\n",$t0);
			$t0=strip_tags($t0);
			$t0=html_entity_decode($t0,ENT_QUOTES);
			@file_put_contents($f,date('r')." Error: $st\n".$t0);
			$t0=null;
			}
		}
		
	if (@$ini['error']['showid']) $st="Error $errorID:\n".$st;
	if (@$ini['error']['debug']) $st=$st."\nDebug:\n".$dbg."\n\n\n";
	
	if ($APPL['isRAW']) die(json_encode(array('err'=>$st)));
		
	$OUTJSON['cmd'] = array(
			array(
				'api'	=>	'err',
				'data'	=>	$st	)
				)
			;
			
	if ($APPL['hdc']) $OUTJSON['cmd'][] = array(
		'api'	=>	'close',
		'data'	=>	$APPL['hdc'] )
		;
		
	$CMD=array();
	retGUI();
	}
Exemplo n.º 2
0
			if ($f['extension']=='php') {
				WGRequirePHP($f['f']);
				} else if ($f['extension']=='json') {
					$js=@file_get_contents($f);
					$js=json_decode($f,true);
					if (!is_array($js)) FatalError("Invalid executor json `".$APPL['executor']."`");
					Window($f['filename']);
					$WEBGUI['win']=array_merge($WEBGUI['win'],$js);
					$js=null;
					unset($js['hdc']);
					endWin(); 
					} else FatalError("Unknown executor type `".$APPL['executor']."`");
			} else if ($f['D']) execApp($f['w'],$JSON['t']);
		}
	if (is_array($ini['db']) && !$DBH) dbclose($DBH);			
	retGUI();
	}

/// GET

$startFile=false;

if (@$_SERVER['REQUEST_URI']=='/logout.php' or @$_SERVER['REDIRECT_URL']=='/logout.php') {
			header("HTTP/1.1 200 Ok",true,200);
			header("Content-Type: text/plain; charset=UTF-8",true,200);
			@session_destroy();
			exit("Logout");
			}

if (
	(isset($_SERVER['REDIRECT_STATUS']) and ( $_SERVER['REDIRECT_STATUS'] == 403 or $_SERVER['REDIRECT_STATUS'] == 404 )) and