-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
1,209 changed files
with
139,978 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,17 @@ | ||
<?php | ||
defined('ALTUMCODE') || die(); | ||
|
||
require 'init.php'; | ||
|
||
/* Controller */ | ||
require CONTROLLERS_ROUTE . $route . $controller . '.php'; | ||
|
||
/* Establish the title of the page */ | ||
require_once 'includes/titles.php'; | ||
|
||
/* View */ | ||
if($controller_has_view) { | ||
require VIEWS_ROUTE . $route . 'wrapper.php'; | ||
} | ||
|
||
require 'deinit.php'; |
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,94 @@ | ||
<?php | ||
|
||
class Captcha { | ||
|
||
/* Configuration Variables */ | ||
public $image_width = 120; | ||
public $image_height = 30; | ||
public $text_length = 6; | ||
public $lines = 6; | ||
public $background_color = [255, 255, 255]; | ||
public $text_color = [0, 0, 0]; | ||
public $lines_color = [63, 63, 63]; | ||
|
||
private $recaptcha = false; | ||
private $recaptcha_public_key = false; | ||
private $recaptcha_private_key = false; | ||
private $captcha_location = 'get-captcha'; | ||
|
||
public function __construct($recaptcha = false, $public_key = false, $private_key = false) { | ||
|
||
/* Determine if its needed to show the recaptcha or not */ | ||
if($recaptcha && $public_key && $private_key) { | ||
|
||
$this->recaptcha = true; | ||
$this->recaptcha_public_key = $public_key; | ||
$this->recaptcha_private_key = $private_key; | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
/* Custom valid function for both the normal captcha and the recaptcha */ | ||
public function is_valid() { | ||
|
||
if($this->recaptcha) { | ||
|
||
$recaptcha = new \ReCaptcha\ReCaptcha($this->recaptcha_private_key); | ||
$response = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); | ||
|
||
return ($response->isSuccess()); | ||
|
||
} else { | ||
|
||
return ($_POST['captcha'] == $_SESSION['captcha']); | ||
|
||
} | ||
} | ||
|
||
/* Display function based on the captcha settings ( normal captcha or recaptcha ) */ | ||
public function display() { | ||
global $language; | ||
|
||
if($this->recaptcha) { | ||
echo '<div class="g-recaptcha" data-sitekey="' . $this->recaptcha_public_key . '"></div>'; | ||
} else { | ||
echo '<img src="' . $this->captcha_location . '" id="captcha" alt="' . $language->global->accessibility->captcha_image_alt . '" /><input type="text" name="captcha" class="form-control form-control-border" aria-label="' . $language->global->accessibility->captcha_input . '" required="required" />'; | ||
} | ||
|
||
} | ||
|
||
/* Generating the captcha image */ | ||
public function process() { | ||
|
||
/* Initialize the image */ | ||
header('Content-type: image/png'); | ||
|
||
/* Generate the text */ | ||
$text = null; | ||
|
||
for($i = 1; $i <= $this->text_length; $i++) $text .= mt_rand(1, 9) . ' '; | ||
|
||
/* Store the generated text in Sessions */ | ||
$_SESSION['captcha'] = str_replace(' ', '', $text); | ||
|
||
/* Create the image */ | ||
$image = imagecreate($this->image_width, $this->image_height); | ||
|
||
/* Define the background color */ | ||
imagecolorallocate($image, $this->background_color[0], $this->background_color[1], $this->background_color[2]); | ||
|
||
/* Start writing the text */ | ||
imagestring($image, 5, 7, 7, $text, imagecolorallocate($image, $this->text_color[0], $this->text_color[1], $this->text_color[2])); | ||
|
||
/* Generate lines */ | ||
for($i = 1; $i <= $this->lines; $i++) imageline($image, mt_rand(1, $this->image_width), mt_rand(1, $this->image_height), mt_rand(1, $this->image_width), mt_rand(1, $this->image_height), imagecolorallocate($image, $this->lines_color[0], $this->lines_color[1], $this->lines_color[2])); | ||
|
||
/* Output the image */ | ||
imagepng($image, null, 9); | ||
|
||
} | ||
|
||
|
||
} |
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,29 @@ | ||
<?php | ||
|
||
class CsrfProtection { | ||
private $previous_hash; | ||
public $hash; | ||
|
||
public function __construct() { | ||
/* Generate a new token */ | ||
$token = md5(time() + time()); | ||
|
||
/* Save the previous hash, if there is none then add the new token */ | ||
$this->previous_hash = (isset($_SESSION['token'])) ? $_SESSION['token'] : $token; | ||
|
||
/* Save the new session / variable */ | ||
if(basename($_SERVER['SCRIPT_NAME']) == 'index.php') $_SESSION['token'] = $token; | ||
@$this->hash = $_SESSION['token']; | ||
|
||
} | ||
|
||
public function is_valid($key = 'token', $hash = false) { | ||
|
||
return (isset($_POST[$key]) && ($_POST[$key] === $this->previous_hash)) || | ||
(isset($_GET[$key]) && ($_GET[$key] === $this->previous_hash)) || | ||
($hash && $hash === $this->previous_hash); | ||
} | ||
|
||
} | ||
|
||
?> |
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,83 @@ | ||
<?php | ||
|
||
/* Helper class for generating and answering to DataTables */ | ||
class DataTable { | ||
public $accepted_columns = []; | ||
public $accepted_order_directions = ['asc', 'desc']; | ||
public $response; | ||
|
||
public function set_accepted_columns(Array $columns) { | ||
$this->accepted_columns = $columns; | ||
} | ||
|
||
public function get_columns() { | ||
return $this->response->columns; | ||
} | ||
|
||
public function get_order() { | ||
return $this->response->order; | ||
} | ||
|
||
public function get_search() { | ||
return $this->response->search; | ||
} | ||
|
||
public function get_draw() { | ||
return $this->response->draw; | ||
} | ||
|
||
public function get_start() { | ||
return $this->response->start; | ||
} | ||
|
||
public function get_length() { | ||
return $this->response->length; | ||
} | ||
|
||
public function process($data) { | ||
|
||
$this->response = new StdClass(); | ||
|
||
$this->response->columns = $this->columns_query($data['columns']); | ||
$this->response->order = $this->order_query($data['order'], $data['columns']); | ||
|
||
$this->response->search = Database::clean_string($_POST['search']['value']); | ||
$this->response->draw = (int) filter_var($_POST['draw'], FILTER_SANITIZE_NUMBER_INT); | ||
$this->response->start = (int) filter_var($_POST['start'], FILTER_SANITIZE_NUMBER_INT); | ||
$this->response->length = (int) filter_var($_POST['length'], FILTER_SANITIZE_NUMBER_INT); | ||
} | ||
|
||
public function columns_query($columns) { | ||
$columns_array = []; | ||
|
||
foreach($columns as $column) { | ||
$column_name = Database::clean_string($column['data']); | ||
|
||
if(in_array($column_name, $this->accepted_columns)) { | ||
$columns_array[] = $column_name; | ||
} | ||
} | ||
|
||
$string = implode(', ', $columns_array); | ||
|
||
return $string; | ||
} | ||
|
||
public function order_query($order, $columns) { | ||
$order_array = []; | ||
|
||
foreach($order as $entry) { | ||
|
||
$column_name = Database::clean_string($columns[$entry['column']]['data']); | ||
$direction = Database::clean_string($entry['dir']); | ||
|
||
if(in_array($column_name, $this->accepted_columns) && in_array($direction, $this->accepted_order_directions)) { | ||
$order_array[] = $column_name . ' ' . $direction; | ||
} | ||
} | ||
|
||
$string = implode(', ', $order_array); | ||
|
||
return $string; | ||
} | ||
} |
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,110 @@ | ||
<?php | ||
|
||
class Database { | ||
public static $database; | ||
|
||
|
||
public static function get($what = [], $from, $conditions = [], $order = false, $clean = true) { | ||
|
||
$what = ($what == '*') ? '*' : '`' . implode('`, `', $what) . '`'; | ||
$from = '`' . $from . '`'; | ||
$where = []; | ||
|
||
foreach($conditions as $key => $value) { | ||
$value = ($clean) ? self::clean_string($value) : $value; | ||
$where[] = '`' . $key . '` = \'' . $value . '\''; | ||
} | ||
$where = implode(' AND ', $where); | ||
|
||
$order_by = ($order) ? 'ORDER BY ' . $order : null; | ||
|
||
$result = self::$database->query("SELECT {$what} FROM {$from} WHERE {$where} {$order_by}"); | ||
|
||
return ($result->num_rows) ? $result->fetch_object() : false; | ||
|
||
} | ||
|
||
public static function simple_get($raw_what, $from, $conditions = [], $clean = true) { | ||
|
||
$what = '`' . $raw_what . '`'; | ||
|
||
$from = '`' . $from . '`'; | ||
|
||
$where = []; | ||
foreach($conditions as $key => $value) { | ||
$value = ($clean) ? self::clean_string($value) : $value; | ||
$where[] = '`' . $key . '` = \'' . $value . '\''; | ||
} | ||
$where = implode(' AND ', $where); | ||
|
||
$result = self::$database->query("SELECT {$what} FROM {$from} WHERE {$where}"); | ||
$data = $result->fetch_object(); | ||
|
||
return ($result->num_rows) ? $data->{$raw_what} : false; | ||
|
||
} | ||
|
||
public static function exists($what = [], $from, $conditions = []) { | ||
|
||
$what = (!is_array($what)) ? '`' . $what . '`' : '`' . implode('`, `', $what) . '`'; | ||
$from = '`' . $from . '`'; | ||
$where = []; | ||
|
||
foreach($conditions as $key => $value) $where[] = '`' . $key . '` = \'' . $value . '\''; | ||
$where = implode(' AND ', $where); | ||
|
||
|
||
$result = self::$database->query("SELECT {$what} FROM {$from} WHERE {$where}"); | ||
|
||
return ($result->num_rows) ? $result->num_rows : false; | ||
|
||
} | ||
|
||
public static function clean_string($data) { | ||
return self::$database->escape_string(filter_var($data, FILTER_SANITIZE_STRING)); | ||
} | ||
|
||
public static function clean_array(Array $data) { | ||
foreach($data as $key => $value) { | ||
$data[$key] = self::clean_string($value); | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
|
||
public static function update($what, $fields = [], $conditions = []) { | ||
|
||
$what = '`' . $what . '`'; | ||
$parameters = []; | ||
$where = []; | ||
|
||
foreach($fields as $key => $value) $parameters[] = '`' . $key . '` = \'' . $value . '\''; | ||
$parameters = implode(', ', $parameters); | ||
|
||
foreach($conditions as $key => $value) $where[] = '`' . $key . '` = \'' . $value . '\''; | ||
$where = implode(' AND ', $where); | ||
|
||
|
||
return self::$database->query("UPDATE {$what} SET {$parameters} WHERE {$where}"); | ||
|
||
} | ||
|
||
public static function insert($table, $data = [], $clean = true) { | ||
|
||
$parameters = []; | ||
$values = []; | ||
|
||
foreach($data as $key => $value) { | ||
$parameters[] = $key; | ||
$values[] = ($clean) ? self::clean_string($value) : $value; | ||
} | ||
|
||
$parameters_string = '`' . implode('`, `', $parameters) . '`'; | ||
$values_string = '\'' . implode('\', \'', $values) . '\''; | ||
|
||
return self::$database->query("INSERT INTO `{$table}` ({$parameters_string}) VALUES ({$values_string})"); | ||
} | ||
|
||
|
||
} |
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,52 @@ | ||
<?php | ||
|
||
class InstagramHelper { | ||
|
||
public static function get_hashtags($string) { | ||
|
||
preg_match_all('/#([\w\d]+)/', $string, $array); | ||
|
||
|
||
return $array[1]; | ||
|
||
} | ||
|
||
public static function get_mentions($string) { | ||
|
||
preg_match_all('/@([\w\d][\w\d\.\_]+[\w\d])/', $string, $array); | ||
|
||
|
||
return $array[1]; | ||
|
||
} | ||
|
||
|
||
public static function get_embed_html($shortcode) { | ||
|
||
$url = 'https://api.instagram.com/oembed/?url=http://instagr.am/p/' . $shortcode . '/&hidecaption=true&maxwidth=450'; | ||
|
||
/* Initiate curl */ | ||
$ch = curl_init(); | ||
|
||
/* Disable SSL verification */ | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
|
||
/* Will return the response */ | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
|
||
/* Set the Url */ | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
|
||
/* Execute */ | ||
$data = curl_exec($ch); | ||
|
||
/* Close */ | ||
curl_close($ch); | ||
|
||
$response = json_decode($data); | ||
|
||
return $response ? $response->html : false; | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.