function __construct()
 {
     adminGateKeeper();
     $title = "Create a Custom Page";
     $body = drawForm(array("name" => "create_custom_page", "method" => "post", "action" => "CreateCustomPage"));
     $this->html = drawpage($title, $body);
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $product = getEntity($guid);
     \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey());
     if ($product->interval != "one_time") {
         try {
             $plan = \Stripe\Plan::retrieve($guid);
             $plan->delete();
         } catch (Exception $e) {
             forward();
         }
     } else {
         if ($product->stripe_sku) {
             $sku = \Stripe\SKU::retrieve($product->stripe_sku);
             $sku->delete();
         }
         if ($product->stripe_product_id) {
             $stripe_product = \Stripe\Product::retrieve($product->stripe_product_id);
             $stripe_product->delete();
         }
     }
     $product->delete();
     new SystemMessage("Your product has been deleted.");
     forward("store");
 }
 /**
  * Clears cache
  */
 public function view()
 {
     adminGateKeeper();
     Cache::clear();
     new SystemMessage("All caches have been cleared.");
     forward();
 }
 public function __construct()
 {
     if (!pageArray(2)) {
         forward("admin/plugins");
     }
     $guid = pageArray(2);
     adminGateKeeper();
     $plugin = getEntity($guid);
     classGateKeeper($plugin, "Plugin");
     $plugin->status = "disabled";
     $plugin->save();
     Cache::clear();
     Cache::clear();
     Admintab::deleteAll();
     Setting::updateSettingsTable();
     clearCache();
     Cache::clear();
     Systemvariable::set("setup_complete", false);
     $translations = getEntities(array("type" => "Translationentity"));
     if ($translations) {
         foreach ($translations as $translation) {
             $translation->delete();
         }
     }
     new SystemMessage("Your plugin has been disabled.");
     forward("admin/plugins");
 }
 function __construct()
 {
     adminGateKeeper();
     $ip = pageArray(2);
     if ($ip) {
         new BlacklistIp($ip);
         $params = array("type" => "User", "metadata_name_value_pairs" => array(array("name" => "ip1", "value" => $ip), array("name" => "ip2", "value" => $ip)), "metadata_name_value_pairs_operand" => "OR");
         $users = getEntities($params);
         $tables = Dbase::getAllTables(false);
         foreach ($users as $user) {
             new BlacklistEmail($user->email);
             $guid = $user->guid;
             foreach ($tables as $table) {
                 $entities = getEntities(array("type" => $table, "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => $guid), array("name" => "container_guid", "value" => $guid)), "metadata_name_value_pairs_operand" => "OR"));
                 if ($entities) {
                     foreach ($entities as $entity) {
                         $entity->delete();
                     }
                 }
             }
             $user->delete();
         }
         new SystemMessage("Ip {$ip} has been banned, and all users using it have been deleted.");
         forward("home");
     }
 }
 public function __construct()
 {
     $guid = pageArray(2);
     adminGateKeeper();
     $plugin = getEntity($guid);
     Setting::updateSettingsTable();
     clearCache();
     Cache::clear();
     Cache::clear();
     if ($plugin->enable()) {
         new SystemMessage("Plugin Enabled");
         new Cache("enabled_plugins_", false, "site");
         new Cache("enabled_plugins_reversed", false, "site");
         Systemvariable::set("setup_complete", false);
         forward("admin/plugins");
     }
     Setting::updateSettingsTable();
     clearCache();
     Cache::clear();
     Cache::clear();
     Admintab::deleteAll();
     $translations = getEntities(array("type" => "Translationentity"));
     if ($translations) {
         foreach ($translations as $translation) {
             $translation->delete();
         }
     }
     new SystemMessage("Your plugin can't be enabled.  Check requirements");
     forward("admin/plugins");
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = getInput("guid");
     $title = getInput("title");
     $description = getInput('description');
     $price = getInput("price");
     $hidden = getInput("hidden") == 0 ? false : true;
     $product = getEntity($guid);
     $product->title = $title;
     $product->description = $description;
     $product->price = $price;
     $product->hidden = $hidden;
     $product->save();
     $product->createAvatar();
     if (isset($_FILES["download"]) && $_FILES["download"]["name"]) {
         $file = new File();
         $file->access_id = "product";
         $file->container_guid = $product->guid;
         $guid = $file->save();
         uploadFile("download", $guid, array("zip"));
         $product->download = $guid;
     }
     new SystemMessage("Your product has been updated.");
     forward("store");
 }
 public function __construct()
 {
     adminGateKeeper();
     Admintab::deleteAll();
     Cache::clear();
     Cache::clear();
     $plugins = Plugin::getAll();
     if ($plugins) {
         foreach ($plugins as $plugin) {
             $plugin->enable();
         }
         Cache::clear();
         Cache::clear();
         Cache::clear();
         new SystemMessage("All possible plugins have been enabled.");
     }
     Systemvariable::set("setup_complete", false);
     $translations = getEntities(array("type" => "Translationentity"));
     if ($translations) {
         foreach ($translations as $translation) {
             $translation->delete();
         }
     }
     forward("admin/plugins");
 }
 function __construct()
 {
     adminGateKeeper();
     $home_page = getInput("home_page");
     Setting::set("home_page", $home_page);
     new SystemMessage("Your home page has been updated.");
     forward();
 }
 public function __construct()
 {
     adminGateKeeper();
     $google_analytics = getInput("google_analytics");
     Setting::set("google_analytics", $google_analytics);
     new SystemMessage("Your code has been updated.");
     forward();
 }
 public function __construct()
 {
     adminGateKeeper();
     $add_this = getInput("add_this");
     Setting::set("add_this", $add_this);
     new SystemMessage("Your Addthis Code has been updated");
     forward();
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $page = getEntity($guid);
     $page->delete();
     new SystemMessage("Your page has been deleted.");
     forward("admin/custom_pages");
 }
 public function __construct()
 {
     adminGateKeeper();
     Cache::clear();
     Cache::clear();
     Cache::clear();
     new SystemMessage(translate("system:cache:cleaned:success:system:message"));
     forward();
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $report = getEntity($guid);
     $report->closed = true;
     $report->save();
     forward("admin/reported_content");
 }
 public function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $activity = getEntity($guid);
     $activity->delete();
     new SystemMessage("Your activity has been deleted.");
     forward();
 }
 public function __construct()
 {
     $title = $body = $buttons = $breadcrumbs = NULL;
     switch (pageArray(1)) {
         default:
             $body = display("pages/forum");
             $title = "Forum Categories";
             if (adminLoggedIn()) {
                 $add_category_url = getSiteURL() . "forum/add_category";
                 $buttons = "<a href='{$add_category_url}' class='btn btn-danger'>Add a Category</a>";
             }
             $breadcrumbs = array(array("link" => getSiteURL() . "forum", "label" => "Categories"));
             break;
         case 'add_category':
             adminGateKeeper();
             $body = drawForm(array("name" => "add_category", "method" => "post", "action" => "addCategory"));
             $title = "Add a Forum Category";
             break;
         case 'category':
             $guid = pageArray(2);
             if ($guid) {
                 $category = getEntity($guid);
                 $body = display("forum/category");
                 if (loggedIn()) {
                     $add_topic_url = getSiteURL() . "forum/add_topic/{$guid}";
                     $buttons = "<a href='{$add_topic_url}' class='btn btn-success'>Add Topic</a>";
                 }
             }
             $breadcrumbs = array(array("link" => getSiteURL() . "forum", "label" => "Categories"), array("link" => getSiteURL() . "forum/category/" . $category->guid, "label" => $category->title));
             break;
         case "add_topic":
             gateKeeper();
             $category_guid = pageArray(2);
             $category = getEntity($category_guid);
             $body = drawForm(array("name" => "add_topic", "method" => "post", "action" => "addTopic"));
             $title = "Add a topic to {$category->title}";
             break;
         case "topic":
             $topic = getEntity(pageArray(2));
             $category = getEntity($topic->container_guid);
             $breadcrumbs = array(array("link" => getSiteURL() . "forum", "label" => "Categories"), array("link" => getSiteURL() . "forum/category/" . $category->guid, "label" => $category->title), array("link" => getSiteURL() . "forum/topic/" . $topic->guid, "label" => $topic->title));
             $body = display("forum/topic");
             break;
         case "editCategory":
             adminGateKeeper();
             $title = "Edit Forum Category";
             $body = drawForm(array("name" => "edit_category", "method" => "post", "action" => "editCategory'"));
             break;
         case "editTopic":
             adminGateKeeper();
             $title = "Edit Forum Topic";
             $body = drawForm(array("name" => "edit_topic", "method" => "post", "action" => "editTopic"));
             break;
     }
     $this->html = drawPage(array("header" => $title, "body" => $body, "button" => $buttons, "breadcrumbs" => $breadcrumbs));
 }
 public function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $user = getEntity($guid);
     $user->logOut();
     $user->logIn();
     new SystemMessage("You are now logged in as " . $user->full_name);
     forward("home");
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $user = getEntity($guid);
     $user->banned = "true";
     $user->save();
     new SystemMessage(translate("ban:user:success:system:message"));
     forward("home");
 }
 function __construct()
 {
     adminGateKeeper();
     $logo = getEntity(array("type" => "Logo"));
     if ($logo) {
         $logo->delete();
     }
     new SystemMessage("Your logo has been removed.");
     forward();
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $user = getEntity($guid);
     $user->banned = "false";
     $user->save();
     new SystemMessage("You have successfully unbanned a user.");
     forward("home");
 }
 /**
  * Creates html for admin page
  */
 public function __construct()
 {
     adminGateKeeper();
     $tab = pageArray(1);
     if (!$tab) {
         $tab = "general";
     }
     $body = display("pages/admin", array("tab" => $tab));
     $this->html = drawPage(array("header" => translate("title:admin_panel"), "body" => $body));
 }
 public function __construct()
 {
     adminGateKeeper();
     $metatags = getEntities(array("type" => "Metatag"));
     foreach ($metatags as $metatag) {
         $metatag->delete();
     }
     Systemvariable::set("setup_complete", "false");
     new SystemMessage("Default values have been loaded.");
     forward();
 }
 public function __construct()
 {
     adminGateKeeper();
     $settings = getEntities(array("type" => "Setting"));
     foreach ($settings as $setting) {
         $setting->delete();
     }
     Systemvariable::set("setup_complete", "false");
     clearCache();
     Cache::clear();
     forward();
 }
 public function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     if ($guid) {
         $user = getEntity($guid);
         // Prevent admin from deleting self
         if ($user->guid != getLoggedInUserGuid()) {
             $guid = $user->guid;
             $user->delete();
             runHook("delete_user", array("user_guid" => $guid));
         }
     }
     forward("admin/users");
 }
 public function __construct()
 {
     adminGateKeeper();
     $guid = getInput("guid");
     $title = getInput("title");
     $description = getInput("description");
     $order = getInput("order");
     $category = getEntity($guid);
     $category->title = $title;
     $category->description = $description;
     $category->order = $order;
     $category->save();
     new SystemMessage("Your category has been updated.");
     forward("forum/category/{$guid}");
 }
 function __construct()
 {
     adminGateKeeper();
     $logos = getEntities(array("type" => "Logo"));
     if ($logos) {
         foreach ($logos as $logo) {
             $logo->delete();
         }
     }
     $logo = new Logo();
     $logo->save();
     $logo->createAvatar();
     new SystemMessage("Your avatar has been uploaded.");
     forward("admin/logo");
 }
 public function __construct()
 {
     adminGateKeeper();
     $guid = getInput("guid");
     $entity = getEntity($guid);
     $title = getInput("title");
     $description = getInput("description");
     if ($title) {
         $entity->metatag_value = $title;
     }
     if ($description) {
         $entity->metatag_value = $description;
     }
     $entity->save();
     forward();
 }
 public function __construct()
 {
     adminGateKeeper();
     $title = getInput("title");
     if (!$title) {
         new SystemMessage("Title cannot be left blank");
         forward();
     }
     $category = new Forumcategory();
     $category->title = $title;
     $category->description = getInput("description");
     $category->access_id = getInput("access_id");
     $category->owner_guid = getLoggedInUserGuid();
     $category->save();
     new SystemMessage("Your forum category has been created.");
     forward("forum");
 }
 function __construct()
 {
     adminGateKeeper();
     $users = getEntities(array("type" => "User"));
     foreach ($users as $user1) {
         foreach ($users as $user2) {
             $test = getEntity(array("type" => "friend", "metadata_name_value_pairs" => array(array("name" => "guid_one", "value" => $user1->guid), array("name" => "guid_two", "value" => $user2->guid))));
             if (!$test) {
                 // No friendship, let's create one.
                 FriendsPlugin::addFriend($user1->guid, $user2->guid);
             }
         }
     }
     $plugin = getEntity(array("type" => "Plugin", "metadata_name" => "name", "metadata_value" => "everyoneFriends"));
     $plugin->status = "disabled";
     $plugin->save();
     forward("admin");
 }
 public function __construct()
 {
     adminGateKeeper();
     $name = pageArray(2);
     if ($name != "user") {
         $query = "DELETE FROM `entities` WHERE `type` = '{$name}'";
         Dbase::query($query);
         $query = "DROP TABLE `{$name}`";
         Dbase::query($query);
         Systemvariable::set("setup_complete", "false");
         clearCache();
         Cache::clear();
         Cache::clear();
         Cache::clear();
         new SystemMessage("Your table has been deleted.");
     }
     forward();
 }