From 360ae2148d28f5383a84c25b33f51e7ce9eaea42 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 29 Mar 2015 18:25:18 +0200 Subject: [PATCH] dev folder --- _sakura/components/Configuration.php | 4 +-- _sakura/components/Main.php | 22 +++++++++------ _sakura/sakura.php | 8 +++--- _sakura/templates/yuuno/global/header.tpl | 2 +- main/404.php | 2 +- main/dev/index.php | 5 ++++ main/dev/registerData.php | 33 +++++++++++++++++++++++ main/{sqladmin_.php => dev/sql.php} | 0 main/index.php | 2 +- 9 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 main/dev/index.php create mode 100644 main/dev/registerData.php rename main/{sqladmin_.php => dev/sql.php} (100%) diff --git a/_sakura/components/Configuration.php b/_sakura/components/Configuration.php index 41cfe7f..b414c42 100644 --- a/_sakura/components/Configuration.php +++ b/_sakura/components/Configuration.php @@ -45,7 +45,7 @@ class Configuration { else return self::$_LCNF[$key]; } else - return null; + trigger_error('Unable to get local configuration value!', E_USER_ERROR); } @@ -68,7 +68,7 @@ class Configuration { if(array_key_exists($key, self::$_DCNF)) return self::$_DCNF[$key]; else - return null; + trigger_error('Unable to get configuration value!', E_USER_ERROR); } diff --git a/_sakura/components/Main.php b/_sakura/components/Main.php index b621cf0..81f9fab 100644 --- a/_sakura/components/Main.php +++ b/_sakura/components/Main.php @@ -37,13 +37,6 @@ class Main { } - // Alias for Configuration::getConfig(), only exists because I'm lazy - public static function getConfig($key) { - - return Configuration::getConfig($key); - - } - // Initialise Twig private static function initTwig() { @@ -73,7 +66,7 @@ class Main { public static function verifyCaptcha($response) { // Attempt to get the response - $resp = @file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='. self::getConfig('recaptcha_private') .'&response='. $response); + $resp = @file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='. Configuration::getConfig('recaptcha_private') .'&response='. $response); // In the highly unlikely case that it failed to get anything forge a false if(!$resp) @@ -138,4 +131,17 @@ class Main { } + // Cleaning strings + public static function cleanString($string, $lower = false) { + + $string = htmlentities($string, ENT_QUOTES | ENT_IGNORE, Configuration::getConfig('charset')); + $string = stripslashes($string); + $string = strip_tags($string); + if($lower) + $string = strtolower($string); + + return $string; + + } + } diff --git a/_sakura/sakura.php b/_sakura/sakura.php index fa189dc..a8ad692 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -1,6 +1,6 @@ */ @@ -31,7 +31,7 @@ require_once ROOT_DIRECTORY .'_sakura/components/Sessions.php'; require_once ROOT_DIRECTORY .'_sakura/components/Users.php'; // Generate path to database driver -$_DBNGNPATH = ROOT_DIRECTORY .'_sakura/components/database/' . $fiiConf['db']['driver'] . '.php'; +$_DBNGNPATH = ROOT_DIRECTORY .'_sakura/components/database/'. Configuration::getLocalConfig('db', 'driver') .'.php'; // Include database driver if(file_exists($_DBNGNPATH)) @@ -39,7 +39,6 @@ if(file_exists($_DBNGNPATH)) else die('

Failed to load database driver.

'); - // Set Error handler set_error_handler(array('Sakura\Main', 'ErrorHandler')); @@ -50,6 +49,7 @@ Main::init($fiiConf); $renderData = array( 'sakura' => [ 'version' => SAKURA_VERSION, - 'urls' => Configuration::getLocalConfig('urls') + 'urls' => Configuration::getLocalConfig('urls'), + 'charset' => Configuration::getConfig('charset') ] ); diff --git a/_sakura/templates/yuuno/global/header.tpl b/_sakura/templates/yuuno/global/header.tpl index 6c0e3c2..c5b94f7 100644 --- a/_sakura/templates/yuuno/global/header.tpl +++ b/_sakura/templates/yuuno/global/header.tpl @@ -2,7 +2,7 @@ - + {{ page.title }} diff --git a/main/404.php b/main/404.php index 054d619..88288bd 100644 --- a/main/404.php +++ b/main/404.php @@ -7,7 +7,7 @@ namespace Sakura; // Include components -require_once('/var/www/flashii.net/_sakura/sakura.php'); +require_once '/var/www/flashii.net/_sakura/sakura.php'; // Print page contents print Main::$_TPL->render('errors/http404.tpl', $renderData); diff --git a/main/dev/index.php b/main/dev/index.php new file mode 100644 index 0000000..d381905 --- /dev/null +++ b/main/dev/index.php @@ -0,0 +1,5 @@ +

Development Tools

+ \ No newline at end of file diff --git a/main/dev/registerData.php b/main/dev/registerData.php new file mode 100644 index 0000000..8265789 --- /dev/null +++ b/main/dev/registerData.php @@ -0,0 +1,33 @@ + $_POST['username'], + 'username_clean' => Sakura\Main::cleanString($_POST['username'], true), + 'password_hash' => $pass[3], + 'password_salt' => $pass[2], + 'password_algo' => $pass[0], + 'password_iter' => $pass[1], + 'password_chan' => time(), + 'email' => Sakura\Main::cleanString($_POST['email'], true), + 'regdate' => time(), + 'lastdate' => time(), + 'lastunamechange' => time(), + 'profile_data' => json_encode([]) + ]; + + print_r($regData); + exit; + +} +?> +
+ username:
+ password:
+ email:
+ +
diff --git a/main/sqladmin_.php b/main/dev/sql.php similarity index 100% rename from main/sqladmin_.php rename to main/dev/sql.php diff --git a/main/index.php b/main/index.php index eeb6ebe..5f5500a 100644 --- a/main/index.php +++ b/main/index.php @@ -7,7 +7,7 @@ namespace Sakura; // Include components -require_once('/var/www/flashii.net/_sakura/sakura.php'); +require_once '/var/www/flashii.net/_sakura/sakura.php'; // Add page specific things $renderData['page'] = [