-
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.
Clean CSS, Added helpers, Added 404 tpl
- Loading branch information
Showing
36 changed files
with
538 additions
and
10,498 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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
$routes['default'] = 'main'; | ||
$routes['home'] = 'main'; | ||
$routes['login'] = 'login'; | ||
$routes['auth'] = 'auth'; | ||
$routes['404'] = 'main'; |
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,51 @@ | ||
<?php | ||
|
||
use Hybridauth\Exception\Exception; | ||
use Hybridauth\Hybridauth; | ||
use Hybridauth\HttpClient; | ||
use Hybridauth\Storage\Session; | ||
|
||
$vue = $page ?? 'login'; | ||
if (!empty($page)) { | ||
if ($page == 'social') { | ||
try { | ||
$hybridauth = new Hybridauth($config); | ||
|
||
$storage = new Session(); | ||
|
||
if (isset($_GET['provider'])) { | ||
$storage->set('provider', $_GET['provider']); | ||
} | ||
|
||
if ($provider = $storage->get('provider')) { | ||
$hybridauth->disconnectAllAdapters(); | ||
$adapter = $hybridauth->authenticate($provider); | ||
$storage->set('provider', null); | ||
if ($adapter->isConnected()) { | ||
$profile = $adapter->getUserProfile(); | ||
} | ||
} | ||
|
||
if (isset($_GET['logout'])) { | ||
$adapter = $hybridauth->getAdapter($_GET['logout']); | ||
$adapter->disconnect(); | ||
$hybridauth->disconnectAllAdapters(); | ||
} | ||
//HttpClient\Util::redirect('http://supfile.tk'); | ||
} catch (Exception $e) { | ||
echo $e->getMessage(); | ||
} | ||
|
||
} | ||
elseif ($page == 'login') { | ||
|
||
} elseif ($page == 'register') { | ||
|
||
} | ||
} else { | ||
header('Location: /auth/login'); | ||
} | ||
|
||
$smarty->display(VIEWS . 'account/' . 'login' . '.tpl'); | ||
|
||
// password_hash($pass, PASSWORD_ARGON2I); |
This file was deleted.
Oops, something went wrong.
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
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
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,139 @@ | ||
<?php | ||
|
||
class DB extends PDO | ||
{ | ||
|
||
private static $instance; | ||
private $hostname; | ||
private $database; | ||
private $username; | ||
private $password; | ||
private $db; | ||
private $query; | ||
|
||
public function __construct() { | ||
try { | ||
$this->hostname = DB_HOST; | ||
$this->database = DB_NAME; | ||
$this->username = DB_USER; | ||
$this->password = DB_PASSWORD; | ||
$this->db = parent::__construct('mysql:host=' . $this->hostname . ';dbname=' . $this->database, $this->username, $this->password, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); | ||
parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
parent::setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); | ||
} catch (PDOException $e) { | ||
throw new Exception('Unable to connect to database.' . $e->getMessage()); | ||
} | ||
} | ||
|
||
// Returns instance of object or creates it if it doesn't exist yet (singleton style) | ||
public static function getInstance() { | ||
if (!self::$instance) { | ||
self::$instance = new DB(); | ||
} | ||
return self::$instance; | ||
} | ||
|
||
// Destroying database link at the end of execution | ||
public function __destruct() { | ||
$this->db = null; | ||
} | ||
|
||
// No cloning allowed | ||
private function __clone() { | ||
} | ||
|
||
public function result($query = false, $attr = false, $nofetch = false, $fetchtype = NULL) { | ||
$return = false; | ||
if ($query) { | ||
try { | ||
$stmt = parent::prepare($query); | ||
|
||
if ($attr) | ||
$return = $stmt->execute($attr); | ||
else | ||
$return = $stmt->execute(); | ||
} catch (PDOException $e) { | ||
$error_message = $e->getMessage(); | ||
$file_error = $e->getFile(); | ||
$trace = $e->getTraceAsString(); | ||
err("Error: " . $error_message . " On File: " . $file_error . " Traceback: " . $trace); | ||
} | ||
|
||
if ($nofetch) | ||
return $return; | ||
else | ||
return $stmt->fetch($fetchtype); | ||
} | ||
return false; | ||
} | ||
|
||
public function results($query = false, $attr = false, $nofetch = false, $fetchtype = NULL) { | ||
if ($query) { | ||
try { | ||
$stmt = parent::prepare($query); | ||
|
||
if ($attr) { | ||
$return = $stmt->execute($attr); | ||
} else { | ||
$return = $stmt->execute(); | ||
} | ||
} catch (PDOException $e) { | ||
err("Error: " . $e->getMessage()); | ||
} | ||
|
||
if ($nofetch) | ||
return $return; | ||
else | ||
return $stmt->fetchAll($fetchtype); | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* @param bool $table | ||
* @param bool $attr | ||
* @return bool|null|string | ||
*/ | ||
public function insert($table = false, $attr = false) { | ||
if ($table && $attr) { | ||
$names = join(array_keys($attr), ","); | ||
$values = join(array_fill(0, count($attr), "?"), ","); | ||
$attr = array_values($attr); | ||
$result = null; | ||
try { | ||
$stmt = parent::prepare("INSERT INTO `" . $table . "` ($names) VALUES ($values)"); | ||
$result = $stmt->execute($attr); | ||
|
||
if ($result) | ||
$result = parent::lastInsertId(); | ||
} catch (PDOException $e) { | ||
error_log("Error: " . $e->getMessage()); | ||
} | ||
|
||
return $result; | ||
} | ||
return false; | ||
} | ||
|
||
public function update($table = false, $attr = false, $where = 'id') { | ||
if ($table && $attr) { | ||
$whereval = $attr[$where]; | ||
unset($attr[$where]); | ||
$names = join(array_keys($attr), " = ?, ") . " = ?"; | ||
|
||
$attr = array_values($attr); | ||
$attr[] = $whereval; | ||
$result = null; | ||
try { | ||
$stmt = parent::prepare("UPDATE `" . $table . "` SET $names WHERE $where = ?"); | ||
// error_log("UPDATE `".$table."` SET $names WHERE $where = ?"); | ||
$result = $stmt->execute($attr); | ||
} catch (PDOException $e) { | ||
error_log("Error: " . $e->getMessage()); | ||
} | ||
|
||
return $result; | ||
} | ||
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,32 @@ | ||
<?php | ||
/** | ||
* @param $value | ||
* @param null $title | ||
*/ | ||
function err($value, $title = null) { | ||
error_log('===================================================='); | ||
if (!is_null($title)) { | ||
error_log('****************' . $title); | ||
} | ||
if (is_array($value) || is_object($value)) { | ||
error_log(print_r($value, true)); | ||
} elseif (is_bool($value)) { | ||
error_log($value ? 'true' : 'false'); | ||
} else { | ||
error_log($value); | ||
} | ||
} | ||
|
||
/** | ||
* @param $value | ||
* @param null $title | ||
*/ | ||
function pr($value, $title = null) { | ||
if (!is_null($title)) { | ||
echo '<h1>' . $title . '</h1>'; | ||
} | ||
echo '<pre>'; | ||
print_r($value); | ||
echo '</pre>'; | ||
echo '<hr />'; | ||
} |
File renamed without changes.
Oops, something went wrong.