-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed66292
commit de32b18
Showing
28 changed files
with
675 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
class admin extends controller{ | ||
function index(){ | ||
if(common::isLoggedIn()){ | ||
url::redir("/admin/home"); | ||
}else{ | ||
if(url::post("username") && url::post("password")){ | ||
$admins = new admins(); | ||
if($user = $admins->auth(url::post("username"), url::post("password"))){ | ||
session::set("id", $user["id"]); | ||
session::set("username", $user["username"]); | ||
session::set("fname", $user["fname"]); | ||
session::set("lname", $user["lname"]); | ||
url::redir("/admin/home"); | ||
}else{ | ||
$data = array("error" => "<div class='alert alert-danger' role='alert'>Username or Password Incorrect.</div>"); | ||
load::view("admin/login", $data); | ||
} | ||
}else{ | ||
load::view("admin/login"); | ||
} | ||
} | ||
} | ||
|
||
function home(){ | ||
if(!common::isLoggedIn()){ | ||
url::redir("/"); | ||
}else{ | ||
load::view("admin/home"); | ||
} | ||
} | ||
|
||
function doLogout(){ | ||
session::endSession(); | ||
url::redir("/"); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
class main extends controller implements controllerInterface{ | ||
|
||
function index(){ | ||
load::view("main::index"); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
class admins extends model{ | ||
|
||
function auth($username, $password){ | ||
/*Make in your Database a table with" | ||
'id','int','11'[a.i] | ||
'username','varchar','255' | ||
'password','varchar','255' | ||
'fname','varchar','255' | ||
'lname','varchar','255' | ||
'dflag','tinyint','1','as defined[0]' | ||
place yourlogin in there | ||
*/ | ||
$this->model->query("SELECT * FROM `admins` WHERE `username`=? AND `password`=? AND `dFlag`=?", | ||
array($username, $password, 0)); | ||
if($row = $this->model->fetch_assoc()){ | ||
return $row; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE html> | ||
<?php load::view("admin::template::head") ?> | ||
<div class="starter-template"> | ||
<h1>Administration Page</h1> | ||
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | ||
</div> | ||
<?php load::view("admin::template::foot") ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<?php load::view("admin::template::head") ?> | ||
<?=(isset($error)) ? $error : ""?> | ||
<form method="POST"> | ||
<div class="form-group"> | ||
<label for="username">Username</label> | ||
<input type="text" class="form-control" name="username" placeholder="Username"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="password">Password</label> | ||
<input type="password" class="form-control" name="password" placeholder="Password"> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Login</button> | ||
</form> | ||
<?php load::view("admin::template::foot") ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!DOCTYPE html> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!DOCTYPE html> | ||
<?php load::view("pageSetup::pageSetup") ?> | ||
|
||
<?php load::view("template::head") ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php load::view("template::head") ?> | ||
<!DOCTYPE html> | ||
<div class="starter-template"> | ||
<div class="jumbotron"> | ||
<h1 class="display-4">404 page not found</h1> | ||
</div> | ||
</div> | ||
<?php load::view("template::foot") ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php load::view("template::head") ?> | ||
<!DOCTYPE html> | ||
<div class="starter-template"> | ||
<h1>Index Page</h1> | ||
<p class="lead"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
</p> | ||
</div> | ||
<?php load::view("template::foot") ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title><?=$GLOBALS["config"]["appName"]?></title> | ||
<link rel="shortcut icon" type="image/png" href="/assets/img/favicon.ico"> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"> | ||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script> | ||
<style> | ||
.navbar-brand > img{height:40px} | ||
</style> | ||
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!DOCTYPE html> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<?php load::view("pageSetup::pageSetup") ?> | ||
<body> | ||
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top"> | ||
<a class="navbar-brand" href="/"><img src="/assets/img/logo.png" alt="TimonPHP"></a> | ||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
|
||
<div class="collapse navbar-collapse" id="navbarsExampleDefault"> | ||
<ul class="navbar-nav mr-auto"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="/">Home</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="/#">Lorem</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="/#">Lorem</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="/#">Lorem</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</nav> | ||
<br><br><br><br> | ||
<main role="main" class="container"> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "nbeij/phpcat", | ||
"description": "A small basic framework", | ||
"type": "project", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Noah Beij", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
spl_autoload_register(function($class){ | ||
$corePath = $GLOBALS["config"]["path"]["core"]; | ||
$appPath = $GLOBALS["config"]["path"]["app"]; | ||
if(file_exists("{$corePath}abstracts/{$class}.php")){ | ||
$instantiable = false; | ||
require_once "{$corePath}abstracts/{$class}.php"; | ||
}else if(file_exists("{$corePath}classes/{$class}.php")){ | ||
$instantiable = true; | ||
require_once "{$corePath}classes/{$class}.php"; | ||
}else if(file_exists("{$corePath}interfaces/{$class}.php")){ | ||
$instantiable = false; | ||
require_once "{$corePath}interfaces/{$class}.php"; | ||
}else if(file_exists("{$appPath}controllers/{$class}.php")){ | ||
$instantiable = true; | ||
require_once "{$appPath}controllers/{$class}.php"; | ||
}else if(file_exists("{$appPath}libs/{$class}.php")){ | ||
$instantiable = true; | ||
require_once "{$appPath}libs/{$class}.php"; | ||
}else if(file_exists("{$appPath}models/{$class}.php")){ | ||
require_once "{$appPath}models/{$class}.php"; | ||
}else if(file_exists("{$appPath}interfaces/{$class}.php")){ | ||
$instantiable = false; | ||
require_once "{$appPath}interfaces/{$class}.php"; | ||
}else if(file_exists("{$appPath}abstracts/{$class}.php")){ | ||
$instantiable = false; | ||
require_once "{$appPath}abstracts/{$class}.php"; | ||
} | ||
|
||
if($instantiable = true){ | ||
foreach($GLOBALS["instances"] as $instance){ | ||
$instance->$class = new $class(); | ||
} | ||
} | ||
}); | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
class common{ | ||
|
||
static function isLoggedIn(){ | ||
$check = array("id","username","fname","lname"); | ||
return (session::check($check)) ? true : false; | ||
} | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
class controller{ | ||
|
||
function __construct(){ | ||
$GLOBALS["instances"][] = &$this; | ||
} | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?php | ||
class database{ | ||
|
||
private $obj; | ||
private $result = null; | ||
public $current_field = ""; | ||
public $lengths = ""; | ||
public $num_rows = ""; | ||
|
||
function connect($host, $username, $password, $database = null){ | ||
if(is_null($database)){ | ||
$this->obj = new mysqli($host, $username, $password); | ||
}else{ | ||
$this->obj = new mysqli($host, $username, $password, $database); | ||
} | ||
} | ||
|
||
function changeDB($database){ | ||
$this->obj->select_db($database); | ||
} | ||
|
||
function refValues($arr){ | ||
if(strnatcmp(phpversion(), "5.3") >= 0){ | ||
$refs = array(); | ||
foreach($arr as $key => $value){ | ||
$refs[$key] = &$arr[$key]; | ||
} | ||
return $refs; | ||
} | ||
return $arr; | ||
} | ||
|
||
function query($query, $args = null){ | ||
if(is_null($args)){ | ||
$this->result = $this->obj->query($query); | ||
$this->current_field = $this->result->current_field; | ||
$this->lengths = $this->result->lengths; | ||
$this->num_rows = $this->result->num_rows; | ||
return $this->result; | ||
}else{ | ||
if(!is_array($args)){ | ||
$argsBkp = $args; | ||
$args = array($argsBkp); | ||
} | ||
if($stmt = $this->obj->prepare($query)){ | ||
$datatypes = ""; | ||
foreach($args as $value){ | ||
if(is_int($value)){ | ||
$datatypes .= "i"; | ||
}else if(is_double($value)){ | ||
$datatypes .= "d"; | ||
}else if(is_string($value)){ | ||
$datatypes .= "s"; | ||
}else{ | ||
$datatypes .= "b"; | ||
} | ||
} | ||
array_unshift($args, $datatypes); | ||
if(call_user_func_array(array($stmt, "bind_param"), $this->refValues($args))){ | ||
$stmt->execute(); | ||
|
||
$this->result = $stmt->get_result(); | ||
if($this->result){ | ||
$this->current_field = $this->result->current_field; | ||
$this->lengths = $this->result->lengths; | ||
$this->num_rows = $this->result->num_rows; | ||
}else{ | ||
$this->current_field = ""; | ||
$this->lengths = 0; | ||
$this->num_rows = 0; | ||
} | ||
$this->error = $stmt->error; | ||
return $this->result; | ||
}else{ | ||
$this->current_field = ""; | ||
$this->lengths = 0; | ||
$this->num_rows = 0; | ||
return false; | ||
} | ||
}else{ | ||
$this->current_field = ""; | ||
$this->lengths = 0; | ||
$this->num_rows = 0; | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
|
||
function data_seek($offset = 0){ | ||
return $this->result->data_seek($offset); | ||
} | ||
|
||
function fetch_all(){ | ||
return $this->result->fetch_all(); | ||
} | ||
|
||
function fetch_array(){ | ||
return $this->result->fetch_array(); | ||
} | ||
|
||
function fetch_assoc(){ | ||
return $this->result->fetch_assoc(); | ||
} | ||
|
||
function fetch_field_direct($field){ | ||
return $this->result->fetch_field_direct($field); | ||
} | ||
|
||
function fetch_field(){ | ||
return $this->result->fetch_field(); | ||
} | ||
|
||
function fetch_fields(){ | ||
return $this->result->fetch_fields(); | ||
} | ||
|
||
function fetch_object($class_name = "stdClass", $params = null){ | ||
if(is_null($params)){ | ||
return $this->result->fetch_object($class_name); | ||
}else{ | ||
return $this->result->fetch_object($class_name, $params); | ||
} | ||
} | ||
|
||
function fetch_row(){ | ||
return $this->result->fetch_row(); | ||
} | ||
|
||
function field_seek($field){ | ||
return $this->result->field_seek($field); | ||
} | ||
|
||
function insert_id(){ | ||
return $this->result->insert_id; | ||
} | ||
|
||
function fetch_all_kv(){ | ||
$out = array(); | ||
while($row = $this->result->fetch_assoc()){ | ||
$out[] = $row; | ||
} | ||
return $out; | ||
} | ||
} | ||
?> |
Oops, something went wrong.