/** * Configuration constants * @author Robert Harris <*****@*****.**> * * The following constants you are going to want to make changes to match your server's configuration * TEMP_DIRECTORY, MOD, DOMAIN_PATH */ /** * @const string - System version */ define('LHP_VERSION', '2.0'); /** * @const bool - Are we using command line? */ defined('CMD_LINE') or define('CMD_LINE', false); /** * @const int - File permission to be used when user uploads file */ define('MOD', 0775); /** * @const string - Current domain without www. (ie domain.com) */ defined('DOMAIN') or define('DOMAIN', LhpBrowser::getDomain()); /** * @const string - Directory path of domain files without trailing / */ define('DOMAIN_PATH', dirname(dirname(__FILE__)) . '/domains/' . DOMAIN); /** * @const string - Full path to temp directory (used for uploading files, plugin installations and more) */ define('TEMP_DIRECTORY', dirname(dirname(__FILE__)) . '/domains/' . DOMAIN . '/temp/');
/** * setSessionHash - set session hash */ public function setSessionHash() { $random = str_random(64); $this->cookie->set('ls', $random); $login_hash = $this->generate_password_hash(AUTH_KEY . $random . LhpBrowser::getUserAgent()); $this->set("session_id", $login_hash); return $login_hash; }
/** * error - prints exception error */ public static function ExceptionError($e) { if (DEBUG) { print "\n\nError: " . $e->getMessage() . "\n\n"; exit; } else { if (!CMD_LINE) { LhpBrowser::redirectToUrl('http://www.' . DOMAIN); } } }
/** * check_tokens - Check md5 hash token for form validation */ public function check_tokens(&$cookie, &$user) { if ($this->get('action') == 'save' && !$user->getBypass()) { return LhpBrowser::getRequestMethod() == 'post' && ($cookie->get('SESSIONID') !== null && $this->get('token') == md5(LhpBrowser::getUserAgent() . FORM_KEY . $cookie->get('SESSIONID') . $this->get('token_hash')) || $user->getBypass()); } else { return true; } }