// Copyright (c) 2009 Samvel Khalatian (http://kshost.net) // // KSLog is freely distributable under the terms of an MIT-style license. // session_start(); define("TLDIR_INDEX", $_SERVER['DOCUMENT_ROOT']); @(include_once TLDIR_INDEX . '/config/config.php.inc'); @(include_once TLDIR_INDEX . '/php/KSAuth.php'); @(include_once TLDIR_INDEX . '/php/KSJson.php'); @(include_once TLDIR_INDEX . '/php/KSServiceJson.php'); // User and Pass in _POST will be checked by KSAuth class $_POST['user'] = trim(strip_tags(urldecode(stripslashes($_POST['user'])))); $_POST['pass'] = trim(strip_tags(urldecode(stripslashes($_POST['pass'])))); try { $_auth = new KSAuth(); if ($_POST['user'] && $_POST['pass']) { $_auth->authenticate($_POST['user'], $_POST['pass']); } else { if ($_SESSION['KS_SID']) { $_auth->authenticate(); } else { throw new RuntimeException('You are not authorized for this page.'); } } $files = glob("{$_SERVER['DOCUMENT_ROOT']}{$_SERVER['PHP_SELF']}.inc") or array(); if (1 != count($files)) { // INSUFFICIENT PRIVILEDGES throw new RuntimeException('Requested Page does not exit.'); } // INCLUDE FILE
<?php // Copyright (c) 2009 Samvel Khalatian (http://kshost.net) // // KSLog is freely distributable under the terms of an MIT-style license. // session_start(); define("TLDIR_INDEX", $_SERVER['DOCUMENT_ROOT']); @(include_once TLDIR_INDEX . '/config/config.inc.php'); @(include_once TLDIR_INDEX . '/php/KSAuth.php'); @(include_once TLDIR_INDEX . '/php/KSPage.php'); @(include_once TLDIR_INDEX . '/php/KSJson.php'); @(include_once TLDIR_INDEX . '/php/KSMySQL.php'); @(include_once TLDIR_INDEX . '/php/KSServiceJson.php'); $_auth = new KSAuth(); try { $_auth->authenticate(); } catch (Exception $exception) { KSServiceJson::instance()->chain(new KSJsonError($exception->getMessage())); } class KSIndexPage extends KSPage { public function head() { parent::head(); ?> <title>KSLog (alpha)</title> <link href='./css/ksgrowl.css' rel='stylesheet' type='text/css'>
// Copyright (c) 2009 Samvel Khalatian (http://kshost.net) // // KSLog is freely distributable under the terms of an MIT-style license. // session_start(); define("TLDIR_INDEX", $_SERVER['DOCUMENT_ROOT']); @(include_once TLDIR_INDEX . '/config/config.php.inc'); @(include_once TLDIR_INDEX . '/php/KSAuth.php'); @(include_once TLDIR_INDEX . '/php/KSJson.php'); @(include_once TLDIR_INDEX . '/php/KSServiceJson.php'); // User and Pass in _POST will be checked by KSAuth class $_POST['user'] = trim(strip_tags(urldecode(stripslashes($_POST['user'])))); $_POST['pass'] = trim(strip_tags(urldecode(stripslashes($_POST['pass'])))); class KSJsonLogin extends KSJsonMessage { public function __toString() { return json_encode(array('uid' => $GLOBALS['KS_USER']->id(), 'name' => $GLOBALS['KS_USER']->name(), 'message' => $this->message())); } } try { $_auth = new KSAuth(); if (!$_auth->authenticate($_POST['user'], $_POST['pass'])) { throw new RuntimeException('Authentication failed.'); } KSServiceJson::instance()->chain(new KSJsonLogin("You are logged in.")); } catch (Exception $exception) { KSServiceJson::instance()->chain(new KSJsonError($exception->getMessage())); } echo KSServiceJson::instance();
<?php // Copyright (c) 2009 Samvel Khalatian (http://kshost.net) // // KSLog is freely distributable under the terms of an MIT-style license. // session_start(); define("TLDIR_INDEX", $_SERVER['DOCUMENT_ROOT']); @(include_once TLDIR_INDEX . '/config/config.php.inc'); @(include_once TLDIR_INDEX . '/php/KSAuth.php'); @(include_once TLDIR_INDEX . '/php/KSJson.php'); @(include_once TLDIR_INDEX . '/php/KSServiceJson.php'); try { $_auth = new KSAuth(); $_auth->unauthenticate(); KSServiceJson::instance()->chain(new KSJsonMessage("You are logged out.")); } catch (Exception $exception) { KSServiceJson::instance()->chain(new KSJsonError($exception->getMessage())); } echo KSServiceJson::instance();