dev folder

This commit is contained in:
flash 2015-03-29 18:25:18 +02:00
parent 10376658b2
commit 360ae2148d
9 changed files with 61 additions and 17 deletions

View file

@ -45,7 +45,7 @@ class Configuration {
else else
return self::$_LCNF[$key]; return self::$_LCNF[$key];
} else } 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)) if(array_key_exists($key, self::$_DCNF))
return self::$_DCNF[$key]; return self::$_DCNF[$key];
else else
return null; trigger_error('Unable to get configuration value!', E_USER_ERROR);
} }

View file

@ -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 // Initialise Twig
private static function initTwig() { private static function initTwig() {
@ -73,7 +66,7 @@ class Main {
public static function verifyCaptcha($response) { public static function verifyCaptcha($response) {
// Attempt to get the 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 // In the highly unlikely case that it failed to get anything forge a false
if(!$resp) 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;
}
} }

View file

@ -1,6 +1,6 @@
<?php <?php
/* /*
* Flashii Sakura Backend * Sakura C/PMS
* (c)Flashwave/Flashii Media 2013-2015 <http://flash.moe> * (c)Flashwave/Flashii Media 2013-2015 <http://flash.moe>
*/ */
@ -31,7 +31,7 @@ require_once ROOT_DIRECTORY .'_sakura/components/Sessions.php';
require_once ROOT_DIRECTORY .'_sakura/components/Users.php'; require_once ROOT_DIRECTORY .'_sakura/components/Users.php';
// Generate path to database driver // 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 // Include database driver
if(file_exists($_DBNGNPATH)) if(file_exists($_DBNGNPATH))
@ -39,7 +39,6 @@ if(file_exists($_DBNGNPATH))
else else
die('<h1>Failed to load database driver.</h1>'); die('<h1>Failed to load database driver.</h1>');
// Set Error handler // Set Error handler
set_error_handler(array('Sakura\Main', 'ErrorHandler')); set_error_handler(array('Sakura\Main', 'ErrorHandler'));
@ -50,6 +49,7 @@ Main::init($fiiConf);
$renderData = array( $renderData = array(
'sakura' => [ 'sakura' => [
'version' => SAKURA_VERSION, 'version' => SAKURA_VERSION,
'urls' => Configuration::getLocalConfig('urls') 'urls' => Configuration::getLocalConfig('urls'),
'charset' => Configuration::getConfig('charset')
] ]
); );

View file

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<!-- META --> <!-- META -->
<meta charset="UTF-8" /> <meta charset="{{ sakura.charset }}" />
<title>{{ page.title }}</title> <title>{{ page.title }}</title>
<meta name="description" content="Any community that gets its laughs by pretending to be idiots will eventually be flooded by actual idiots who mistakenly believe that they're in good company. Welcome to Flashii." /> <meta name="description" content="Any community that gets its laughs by pretending to be idiots will eventually be flooded by actual idiots who mistakenly believe that they're in good company. Welcome to Flashii." />
<meta name="keywords" content="Flashii, Media, Flashwave, Murasaki, Misaka, Circle, Zeniea, MalwareUp, Cybernetics, Saibateku, Community" /> <meta name="keywords" content="Flashii, Media, Flashwave, Murasaki, Misaka, Circle, Zeniea, MalwareUp, Cybernetics, Saibateku, Community" />

View file

@ -7,7 +7,7 @@
namespace Sakura; namespace Sakura;
// Include components // Include components
require_once('/var/www/flashii.net/_sakura/sakura.php'); require_once '/var/www/flashii.net/_sakura/sakura.php';
// Print page contents // Print page contents
print Main::$_TPL->render('errors/http404.tpl', $renderData); print Main::$_TPL->render('errors/http404.tpl', $renderData);

5
main/dev/index.php Normal file
View file

@ -0,0 +1,5 @@
<h1>Development Tools</h1>
<ul>
<li><a href="sql.php">SQL</a>
<li><a href="registerData.php">Registration Data</a>
</ul>

33
main/dev/registerData.php Normal file
View file

@ -0,0 +1,33 @@
<?php
require_once '/var/www/flashii.net/_sakura/sakura.php';
if(isset($_POST['submit'])) {
$pass = Sakura\Hashing::create_hash($_POST['password']);
$regData = [
'username' => $_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;
}
?>
<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">
username: <input type="text" name="username" /><br />
password: <input type="password" name="password" /><br />
email: <input type="text" name="email" /><br />
<input type="submit" name="submit" value="Submit" />
</form>

View file

@ -7,7 +7,7 @@
namespace Sakura; namespace Sakura;
// Include components // Include components
require_once('/var/www/flashii.net/_sakura/sakura.php'); require_once '/var/www/flashii.net/_sakura/sakura.php';
// Add page specific things // Add page specific things
$renderData['page'] = [ $renderData['page'] = [