Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Description:
- * This is the ACP class
- *
- * @author Asus
- * @date 1/15/2015
- * @file Class.ACP.php
- * @package Class/
- */
- /*****************************/
- /*/ Created By DarkSkiesDO /*/
- /*/ Script By DarkSkiesDO /*/
- /**************************/
- class ACP {
- /* ACP - Variables */
- static $Access;
- /* Add - Variables */
- static $AddResponse;
- /* Edit - Variables */
- static $EditResponse;
- static $Title;
- static $Author;
- static $Story;
- static $Status;
- public function __construct($user) {
- // Globalize Our Database Variable //
- global $PDO;
- // Access: Prepare Query //
- $getAccess = $PDO->prepare("SELECT * FROM users WHERE username = ?");
- // Access: Execute Query //
- $getAccess->execute(array($user));
- // Access: Fetch Statement //
- while ($Users = $getAccess->fetch(PDO::FETCH_ASSOC)) {
- // Access: Row - Rank //
- $Rank = $Users["rank"];
- // Access: Check //
- if ($Rank >= 10) {
- // Access: Set //
- ACP::$Access = true;
- return true;
- } else {
- // Access: Set //
- ACP::$Access = false;
- return false;
- }
- }
- }
- /* Add - Functions */
- static function createStory($Title, $Author, $Story, $Status) {
- // Globalize Our Database Variable //
- global $PDO;
- // Add: Sanitize Variables //
- $Title = strip_tags(stripslashes($Title));
- $Author = strip_tags(stripslashes($Author));
- $Story = strip_tags(stripslashes($Story));
- $Status = strip_tags(stripslashes($Status));
- // Add: Prepare Query //
- $addStory = $PDO->prepare("INSERT INTO stories VALUES ('', ?, ?, ?, '', utc_timestamp(), ?)");
- // Add: Execute Query //
- $addStory->execute(array($Title, $Author, $Story, $Status));
- // Add: Check Query //
- if ($addStory) {
- ACP::$AddResponse = "<font color='green'>Story Created/Added Successfully!</font>";
- } else {
- ACP::$AddResponse = "<font color='red'>Story Couldn't Be Created/Added!</font>";
- }
- }
- /* Edit - Functions */
- static function checkStory($Id) {
- // Globalize Our Database Variable //
- global $PDO;
- // Story: Prepare Query //
- $getStory = $PDO->prepare("SELECT * FROM stories WHERE id = ?");
- // Story: Execute Query //
- $getStory->execute(array($Id));
- // Story: Row Count //
- $storyCount = $getStory->rowCount();
- // Story: Row Check //
- if ($storyCount == 1) {
- ACP::buildStory($Id);
- } else {
- if ($Id == 1) {
- header('Location: ./index?page=admin&action=home');
- } else {
- header('Location: ./index?page=admin&action=edit&storyId=1');
- }
- }
- }
- static function buildStory($Id) {
- // Globalize Our Database Variable //
- global $PDO;
- // Story: Prepare Query //
- $getStory = $PDO->prepare("SELECT * FROM stories WHERE id = ?");
- // Story: Execute Query //
- $getStory->execute(array($Id));
- // Story: Fetch Statement //
- while ($Data = $getStory->fetch(PDO::FETCH_ASSOC)) {
- // Story: Row - Title //
- $Title = $Data["title"];
- // Story: Row - Author //
- $Author = $Data["author"];
- // Story: Row - Story //
- $Story = $Data["story"];
- // Story: Row - Status //
- $Status = $Data["status"];
- }
- // Story - Set Variables //
- ACP::$Title = $Title;
- ACP::$Author = $Author;
- ACP::$Story = $Story;
- ACP::$Status = $Status;
- }
- static function updateStory($Id, $Title, $Author, $Story, $Status) {
- // Globalize Our Database Variable //
- global $PDO;
- // Update: Sanitize Variables //
- $Title = strip_tags(stripslashes($Title));
- $Author = strip_tags(stripslashes($Author));
- $Story = strip_tags(stripslashes($Story));
- $Status = strip_tags(stripslashes($Status));
- // Update: Prepare Query //
- $updateStory = $PDO->prepare("UPDATE stories SET title = ?, author = ?, story = ?, status = ? WHERE id = ?");
- // Update: Execute Query //
- $updateStory->execute(array($Title, $Author, $Story, $Status, $Id));
- // Update: Check Query //
- if ($updateStory) {
- ACP::$EditResponse = "<font color='green'>Story Updated Successfully!</font>";
- } else {
- ACP::$EditResponse = "<font color='red'>Story Couldn't Be Updated!</font>";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement