Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
First commit
  • Loading branch information
barreeeiroo committed May 23, 2017
1 parent e91cefd commit 29226cd
Show file tree
Hide file tree
Showing 114 changed files with 49,125 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# DISABLE INDEXING

Options -Indexes


# BROWSER REDIRECT

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/alerts
RewriteCond %{REQUEST_URI} !^/api
RewriteCond %{REQUEST_URI} !^/core
RewriteCond %{REQUEST_URI} !^/media
RewriteCond %{REQUEST_URI} !^/utils
RewriteCond %{REQUEST_URI} !^/versions
RewriteCond %{REQUEST_URI} !^/visual
RewriteRule ^(.*)$ /home [R]


# BEGIN GZIP

<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript image/jpg image/png
</ifmodule>

# END GZIP
41 changes: 41 additions & 0 deletions alerts/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

require_once '../core/dbconfig.php';

class ALERTS
{

private $conn;

public function __construct()
{
$database = new Database();
$db = $database->dbConnection();
$this->conn = $db;
}

public function runQuery($sql)
{
$stmt = $this->conn->prepare($sql);
return $stmt;
}

public function get_alerts($request,$id)
{
try {
if ($request == "last") {
$stmt = $this->conn->prepare("SELECT MAX(id) FROM `alerts`;");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return $result;
} else {
$stmt = $this->conn->prepare("SELECT $request FROM `alerts` WHERE id=$id");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return $result;
}
} catch(PDOException $ex) {
echo $ex->getMessage();
}
}
}
41 changes: 41 additions & 0 deletions alerts/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

// For DEBUG: Display all errors
error_reporting(E_ALL);
ini_set('display_errors', 'On');

//Start API
session_start();
require_once('functions.php');
$ALERTS = new ALERTS();

// Security Methods
$key = "ChatAble";
if (!isset($_GET['key'])) {
http_response_code(403);
exit("No Key");
} else {
if ($_GET['key'] != $key) {
http_response_code(403);
exit("Incorrect Key");
}
}


// Function
if (isset($_GET['alerts'])) {
if (!isset($_GET['id'])) {
$request = "last";
$id = 0;
$result = $ALERTS->get_alerts($request,$id);
print($result['MAX(id)']);
} else {
if (!isset($_GET['request'])) {
exit("Request a row");
}
$id = $_GET['id'];
$request = $_GET['request'];
$result = $ALERTS->get_alerts($request,$id);
print($result[$request]);
}
}
Loading

0 comments on commit 29226cd

Please sign in to comment.