Location: PHPKode > projects > TinyShell PHP/Ajax > core/plugin_functions.php
<?
	
	// Authorizes user also. If require_login is set to false
	// workdir is not updated to match the shell!
	function is_ajax($require_login = true) {
		if (isset($_GET['ajax'])) {
			$logic_err = $_GET['ajax'] != "2";
			if ($require_login) {
				$login = require_login($_GET["ajax_cwd"]);
				if ($login != "0") {
					if ($logic_err) echo $login;
					else echo "An error has occured!";
					exit; // quit execution!
				} else {
					if ($logic_err) echo $login;
					return true;
				}
			} else { // no error
				if ($logic_err) echo "0";
				return true;
			}
		}
		return false;
	}
	
	function require_login($dir) {
		if (!is_logged_in() || $_SESSION['login']['IP'] != $_SERVER['REMOTE_ADDR'] || $_SESSION['login']['UA'] != $_SERVER['HTTP_USER_AGENT']) {
			$_SESSION = array();
			return "1";
		} else if (!@chdir($dir)) { // this chdir was successfull ;-)
			@chdir($_SERVER['DOCUMENT_ROOT']);
			return "2".getcwd();
		}
		return "0"; // no error
	}
	
	function ticket_request() {
		$_SESSION['ticket'] = uniqid();
		return $_SESSION['ticket'];
	}
	function ticket_validate($hash, $msg) {
		$b = $hash == sha1($_SESSION['ticket'].sha1($_SESSION['ticket'].$msg));
		$_SESSION['ticket'] = "";
		return $b;
	}
	function is_utf8($s) {
		return preg_match("/^[\\x00-\\x7F]*$/u", $s) || preg_match("/^[\\x00-\\xFF]*$/u", $s);
	}
	
?>
Return current item: TinyShell PHP/Ajax