Junior Spellweaver
- Joined
- May 5, 2012
- Messages
- 110
- Reaction score
- 10
Hi Ragezone,
First I'd like to apologise for stopping the other SnowCMS development but now I'd like to finish it. I'm opening a new development because it's quite different now...
This time i'm going to use PDO with prepared statements, plus there will be no globals. This time I think I really have enough experience to really finish it and have progress.
I will create my own style and there is a template system so you guys can create one yourself easily too.
Well enough of this, let's show off.
Screens:
And some snippets:
Template:
User class:
Bootstrap:
If you feel like posting any tips or criticisms, please do.
I hope you guys like this development and will follow it.
First I'd like to apologise for stopping the other SnowCMS development but now I'd like to finish it. I'm opening a new development because it's quite different now...
This time i'm going to use PDO with prepared statements, plus there will be no globals. This time I think I really have enough experience to really finish it and have progress.
I will create my own style and there is a template system so you guys can create one yourself easily too.
Well enough of this, let's show off.
Screens:
You must be registered to see links
You must be registered to see links
You must be registered to see links
And some snippets:
Template:
PHP:
<?php
class TPL {
private static $file, $dir, $variable, $content;
public static function SetDirectory($dir) {
self::$dir = $dir;
}
public static function SetFile($file) {
self::$file = $file;
if(trim($file) == '') {
$file = 'index';
}
$file1 = 'data/TPL/' . self::$dir . '/' . $file . '.php';
$error = 'data/TPL/' . self::$dir . '/error.php';
if(is_file($file1)) {
self::$content = file_get_contents($file1);
}
else {
self::$content = file_get_contents($error);
}
}
public static function GetHandler() {
if(self::$file == '') {
self::$file = 'index';
}
$handler = 'data/handlers/'.self::$file.'.php';
if(is_file($handler)) {
include $handler;
}
include('data/handlers/main.php');
}
public static function SetVariable($key, $value) {
self::$variable['{'.$key.'}'] = $value;
}
public static function InitializeVariables() {
return str_ireplace(array_keys(self::$variable), array_values(self::$variable), self::$content);
}
public static function Start() {
return self::InitializeVariables(self::$content);
}
}
?>
User class:
PHP:
<?php
class users {
public static function CheckAccount($name, $pass) {
$Check = DB::$connect->prepare("SELECT count(*) FROM users WHERE username = :name AND password = :pass");
$Check->Execute(array(
':name' => $name,
':pass' => Core::Hash($pass)
));
$Row = $Check->Fetch();
return $Row['Count(*)'];
}
public static function AddUser($name, $pass, $mail) {
$add = DB::$connect->prepare("INSERT INTO users(username, password, mail, motto) VALUES(:name, :pass, :mail, :motto)");
return $add->execute(array(
':name' => $name,
':pass' => Core::Hash($pass),
':mail' => $mail,
':motto' => Config::$motto
));
}
public static function ValidMail($mail) {
return (preg_match("/^[a-zA-Z0-9_\.-]+@([a-zA-Z0-9]+([\-]+[a-zA-Z0-9]+)*\.)+[a-z]{2,7}$/i", $mail) && strlen($mail) >= 3 && strlen($mail) <= 64);
}
public static function CheckPass($pass) {
return (strlen($pass) > 3 && strlen($pass) < 10);
}
public static function GetUser($user) {
$getuser = DB::$connect->prepare("SELECT count(*) FROM users WHERE username = ?");
$getuser->execute(array($user));
$row = $getuser->fetch();
return $row['count(*)'];
}
}
?>
Bootstrap:
PHP:
<?php
session_start();
require('core.php');
Core::loadclasses();
DB::connect();
$file = trim($_SERVER['REQUEST_URI'], '/');
TPL::SetDirectory(Config::$style);
TPL::SetFile($file);
TPL::GetHandler();
echo TPL::Start();
?>
If you feel like posting any tips or criticisms, please do.
I hope you guys like this development and will follow it.
Last edited: