Current File : /home/inlingua/public_html/decay_sym/root/var/softaculous/apps/cxs/index.php
<?php

// If you are root we need to step down
if(posix_getuid() == 0){
	
	$webuzo = posix_getpwnam('webuzo');
	
	include_once('/usr/local/webuzo/sdk/sessions.php');
	
	$SESS = new Webuzo_Sessions();
	$logged_in = $SESS->isLogin();
	//echo '<pre>';print_r($SESS);
	
	// Send to login URL
	if(empty($logged_in)){
		echo 'The Webuzo Session token is invalid !';
		die();
	}
	
	$user = !empty($SESS->orig_user) ? $SESS->orig_user : $SESS->user['user'];
	
	if($user != 'root'){
		echo 'Only root user allowed !';
		die();
	}
	
}

$globals['current_url'] = $_SERVER['HTTP_HOST'].'/'.parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$globals['current_url'] = 'http'.(!empty($_SERVER['HTTPS']) ? 's' : '').'://'.str_replace('//', '/', $globals['current_url']);

// current_url = http(s)://HOSTNAME:PORT/sessIONxxxxxxxxxx/FILENAME.php? (NO vars)
$globals['current_url'] .= preg_match('/\?/is', $globals['current_url']) ? '' : '?';

// panel_url = http(s)://HOSTNAME:PORT/sessIONxxxxxxxxxx/ (No vars and no filename)
if(preg_match('/sess([\w]*)\//is', $_SERVER['REQUEST_URI'])){
	$globals['panel_url'] = preg_replace('/(.*)(sess([\w]*)\/)(.*)/is', '$1$2', $globals['current_url']);
}else{
	$globals['panel_url'] = preg_replace('/(.*)\/([^\?]*)\?(.*)/is', '$1/', $globals['current_url']);
}

// We need to pass certain variables
foreach($_SERVER as $k => $v){
	putenv($k.'='.$v);
}

putenv('webuzo_panel_url='.$globals['panel_url']);

$env = http_build_query($_POST);

if ($env == "") {
	$env = http_build_query($_GET);
}

putenv('QUERY_STRING='.$env);

/* echo '<pre>';
print_r($globals);
print_r($_SERVER);
die(); */

exec('perl /var/softaculous/apps/cxs/index.cgi', $result, $ret);//r_print($tmp);

$header = 1;
foreach ($result as $line) {
	if ($header) {
		$line = str_replace('Security error', '', $line);
		header ("$line\n");
	} else {
		print "$line\n";
	}
	if ($header && $line == "") {
		$header = 0;
	}
}