static function draw()
 {
     $page = self::urlArray(0);
     if ($page != "setupcomplete" && $page != "action" && file_exists(getSitePath() . "install/")) {
         forward("setupcomplete");
     }
     $body = $header = $nav = $footer = NULL;
     if ($page) {
         $page_handler_class = "SocialApparatus\\" . ucfirst($page) . "PageHandler";
     } else {
         $page_handler_class = "SocialApparatus\\HomePageHandler";
     }
     Vars::clear();
     if (class_exists($page_handler_class)) {
         $body = (new $page_handler_class())->view();
     } else {
         new SystemMessage("Page not found.");
         forward("home");
     }
     Vars::clear();
     $header = display("page_elements/header");
     Vars::clear();
     $nav = display("page_elements/navigation");
     Vars::clear();
     $footer = display("page_elements/footer");
     Vars::clear();
     echo $header;
     echo $nav;
     echo $body;
     echo $footer;
     Debug::clear();
     Dbase::con()->close();
     die;
 }
 public function __construct()
 {
     new StorageType("Comment", "body", "text");
     new CSS("comments", getSitePath() . "core_plugins/comments/assets/css/comments.css");
     new FooterJS("comments", getSiteURL() . "core_plugins/comments/assets/js/comments.js", 5000, true);
     new ViewExtension('pages/home_stats', "pages/comment_stats");
     new Usersetting(array("name" => "notify_when_comment", "field_type" => "dropdown", "options" => array("email" => "Email", "site" => "Site", "both" => "Both", "none" => "None"), "tab" => "notifications", "default_value" => "both"));
 }
 public function __construct()
 {
     new ViewExtension("profile/right", "profile_status", "before");
     new ViewExtension("profile_owner_block_body", "profile/status");
     new ViewExtension("tinymce/buttons", "profileStatus/button");
     new FooterJS("profile_status", getSiteURL() . "core_plugins/profileStatus/assets/js/profile_status.php", 20000, true);
     new StorageType("Profilestatus", "description", "text");
     new StorageType("User", "profile_status", "text");
     new CSS("profile_status", getSitePath() . "core_plugins/profileStatus/assets/css/style.css", 10000);
     new StorageType("Profilestatus", "profile_status", "text");
 }
 public function __construct()
 {
     new CSS("files", getSitePath() . "core_plugins/files/assets/css/files.css", 600);
     new FooterJS("files", getSiteURL() . "core_plugins/files/assets/js/files.js", 600, true);
     if (loggedIn()) {
         new StorageType("File", "path", "text");
         new StorageType("File", "description", "text");
         new StorageType("File", "filename", "text");
         new StorageType("File", "file_location", "text");
     }
 }
 function __construct()
 {
     if (loggedIn()) {
         $count = self::countUnread();
         new MenuItem(array("name" => "messages", "page" => "messages", "label" => "Messages <span class='badge'>{$count}</span> ", "menu" => "my_account", "weight" => 100));
     }
     new CSS("messages", getSitePath() . "core_plugins/messages/assets/css/style.css", 400000);
     new FooterJS("messages", getSiteURL() . "core_plugins/messages/assets/js/messages.js", 5000, true);
     new StorageType("MessageElement", "subject", "text");
     new StorageType("MessageElement", "message", "text");
     new StorageType("Message", "subject", "text");
     new Usersetting(array("name" => "notify_when_message", "field_type" => "dropdown", "options" => array("email" => "Email", "site" => "Site", "both" => "Both", "none" => "None"), "tab" => "notifications", "default_value" => "both"));
 }
 public function __construct()
 {
     if (loggedIn()) {
         new MenuItem(array("name" => "profile", "label" => "My Profile", "page" => "profile/" . getLoggedInUserGuid(), "menu" => "my_account", "weight" => 0));
         if (currentPage() == "profile" && pageArray(1) == getLoggedInUserGuid()) {
             new MenuItem(array("name" => "edit_profile", "label" => "Edit Profile", "menu" => "profile", "page" => "editProfile", "list_class" => "active", "link_class" => "list-group-item list-group-item-danger"));
         } elseif (currentPage() == "home" && loggedIn()) {
             new MenuItem(array("name" => "view_my_profile", "label" => "View My Profile", "menu" => "profile", "page" => "profile/" . getLoggedInUserGuid(), "weight" => 10));
             new MenuItem(array("name" => "edit_profile", "label" => "Edit My Profile", "menu" => "profile", "page" => "editProfile", "link_class" => "list-group-item", "weight" => 20));
             if (isEnabledPlugin("members")) {
                 new MenuItem(array("name" => "members", "label" => "Browse Members", "menu" => "profile", "page" => "members", "weight" => 30));
             }
             if (isEnabledPlugin("inviteFriends")) {
                 new MenuItem(array("name" => "invite_friends", "label" => translate("invite_your_friends"), "menu" => "profile", "page" => "members", "weight" => 40));
             }
         }
         if (currentPage() == "profile" && adminLoggedIn()) {
             if (adminLoggedIn()) {
                 $guid = pageArray(1);
                 $user = getEntity($guid);
                 if (is_a($user, "SocialApparatus\\User")) {
                     if (!isAdmin($user)) {
                         new MenuItem(array("name" => "delete", "label" => "Delete User", "page" => "action/deleteUser/{$guid}", "menu" => "profile", "weight" => 100000, "list_class" => "active", "link_class" => "list-group-item list-group-item-danger confirm"));
                         new MenuItem(array("name" => "login_as", "label" => "Login As", "page" => "action/loginas/{$guid}", "menu" => "profile", "weight" => 90000, "list_class" => "active", "link_class" => "list-group-item list-group-item-danger confirm"));
                         if ($user->banned == "true") {
                             new MenuItem(array("name" => "unban", "label" => "Unban", "page" => "action/unbanUser/{$guid}", "menu" => "profile", "weight" => 80000, "list_class" => "active", "link_class" => "list-group-item list-group-item-danger confirm"));
                         } else {
                             new MenuItem(array("name" => "ban", "label" => "Ban", "page" => "action/banUser/{$guid}", "menu" => "profile", "weight" => 80000, "list_class" => "active", "link_class" => "list-group-item list-group-item-danger confirm"));
                         }
                     }
                 }
             }
         }
     }
     if (currentPage() == "profile") {
         new CSS("profile", getSitePath() . "core_plugins/profile/assets/css/profile.css");
         new FooterJS('profile', getSiteURL() . 'core_plugins/profile/assets/js/profile.js', 900, true);
     }
     if (currentPage() == "admin") {
         new ViewExtension("admin/tabs", "admin_tabs/profile_fields");
     }
     new ProfileField("first_name", "First Name", "text", false, false, "form-control", "default", 10);
     new ProfileField("last_name", "Last Name", "text", false, false, "form-control", "default", 20);
     new ProfileField("gender", "Gender", "dropdown", array("Male" => "Male", "Female" => "Female"));
     new ProfileField("birthday", "Birthday", "date");
     new ProfileField("about", "About Me", "textarea");
     new ProfileField("hobbies", "Hobbies", "tags");
     new StorageType("User", "about", "text");
     new ViewExtension("profile/right", "profile/activity");
 }
 function __construct()
 {
     if (loggedIn()) {
         if (currentPage() == "profile") {
             if (isEnabledPlugin("Friends")) {
                 $user_one = pageArray(1);
                 $user_two = getLoggedInUserGuid();
                 if (FriendsPlugin::friends($user_one, $user_two)) {
                     new MenuItem(array("name" => "chat", "menu" => "profile", "label" => "Chat", "page" => "action/CreateChat/" . $user_one, "link_class" => "list-group-item list-group-item-success"));
                 }
             }
         }
     }
     new ViewExtension("page_elements/foot", "chat/chat_boxes");
     new CSS("chat", getSitePath() . "core_plugins/chat/assets/css/chat.css", 400);
     new FooterJS("chat", getSiteURL() . "core_plugins/chat/assets/js/chat.js", 400, true);
     new Usersetting(array("name" => "notify_offline_chat", "field_type" => "dropdown", "options" => array("yes" => "Yes", "no" => "No"), "default_value" => "yes", "tab" => "notifications"));
 }
 public function __construct()
 {
     new CSS("photo", getSitePath() . "core_plugins/photos/assets/css/photos.css");
     new StorageType("Photo", "description", "text");
     new StorageType("Photoalbum", "description", "text");
     new StorageType("Photoalbum", "icon_filename", "text");
     new FooterJS("photo", getSiteURL() . "core_plugins/photos/assets/js/photo.js", 5000, true);
     new ViewExtension("header:after", "page_elements/photo_selector");
     new ViewExtension("profile/middle", "photos/profile");
     new ViewExtension('pages/home_stats', "pages/photo_stats");
     new ViewExtension("page_elements/site_js", "photos/photo_footer");
     new ViewExtension("tinymce/buttons", "photos/tinymce_button");
     if (isEnabledPlugin("groups")) {
         new ViewExtension("groups/right", "photos/group_photos");
     } else {
         removeViewExtension("groups/right", "photos/group_photos");
     }
     new Metatag("Photo", "title", getSiteName() . " | Photos");
     new MenuItem(array("name" => "photos", "href" => "photos", "label" => "Photos", "menu" => "header_left", "list_class" => "visible-xs hidden-sm visible-md visible-lg"));
     new MenuItem(array("name" => "photos2", "href" => "photos", "label" => "Photos", "menu" => "tools", "page" => "photos"));
 }
 function __construct()
 {
     if (!file_exists(getSitePath() . "install/")) {
         echo "true";
         die;
     }
     $files = glob(getSitePath() . "install/*");
     if ($files) {
         foreach ($files as $file) {
             @unlink($file);
         }
     }
     rmdir(getSitePath() . "install");
     if (file_exists(getSitePath() . "install/")) {
         echo "false";
         die;
     } else {
         echo "true";
         die;
     }
 }
 public function __construct()
 {
     new CSS("videos", getSitePath() . "core_plugins/videos/vendor/mediaelement/build/mediaelementplayer.css");
     new FooterJS("video", getSiteURL() . "core_plugins/videos/assets/js/video.js", 5001, true);
     new FooterJS("video_player", getSiteURL() . "core_plugins/videos/vendor/mediaelement/build/mediaelement-and-player.min.js", 5000);
     new StorageType("Video", "description", "text");
     new StorageType("Video", "url", "text");
     new StorageType("Videoalbum", "description", "text");
     new StorageType("Videoalbum", "icon_filename", "text");
     new ViewExtension("header:after", "page_elements/video_selector");
     new ViewExtension("page_elements/site_js", "videos/video_footer");
     new ViewExtension("profile/right", "videos/profile");
     new ViewExtension("tinymce/buttons", "videos/tinymce_button");
     new Hook("cron:minute", "VideoConvertHook");
     new Admintab("video_settings", 1000, array());
     new Setting("allow_video_uploads", "dropdown", array("no" => "No", "yes" => "Yes"), "video_settings");
     new Setting("ffmpeg_ffmprobe_executable_path", "text", array(), "video_settings", shell_exec("which ffmpeg"));
     new Metatag("Video", "title", getSiteName() . " | Videos");
     new MenuItem(array("name" => "videos", "href" => "videos", "label" => "Videos", "menu" => "header_left", "list_class" => "visible-xs hidden-sm visible-md visible-lg"));
     new MenuItem(array("name" => "videos2", "href" => "videos", "label" => "Videos", "menu" => "tools", "page" => "videos"));
 }
 function __construct()
 {
     require_once getSitePath() . "core_plugins/ecommerce/vendor/autoload.php";
     new FooterJS("strip", "https://js.stripe.com/v2/");
     new CSS("ecommerce", getSitePath() . "plugins/ecommerce/assets/css/ecommerce.css", 100);
     new Admintab("ecommerce", "200");
     new Setting("store_name", "text", NULL, "ecommerce", "Store");
     new Setting("show_ecommerce_menu_item", "dropdown", array("yes" => "Yes", "no" => "No"), "ecommerce", "yes");
     new Setting("ecommerce_menu_item_label", "textarea", array("yes" => "Yes", "no" => "No"), "ecommerce", "Store");
     new Setting("ecommerce_menu_weight", "text", NULL, "ecommerce", 500);
     $show_ecommerce_menu_item = Setting::get("show_ecommerce_menu_item");
     if ($show_ecommerce_menu_item == "yes") {
         $label = Setting::get("ecommerce_menu_item_label");
         $weight = Setting::get("ecommerce_menu_weight");
         new MenuItem(array("name" => "store", "label" => $label, "weight" => $weight));
     }
     new Setting("show_ecommerce_cart_item", "dropdown", array("yes" => "Yes", "no" => "No"), "ecommerce", "yes");
     new Setting("ecommerce_cart_menu_item_label", "textarea", NULL, "ecommerce", "Cart");
     new Setting("ecommerce_cart_menu_item_weight", "text", NULL, "ecommerce", 8000);
     new Setting("stripe_testing", "dropdown", array("true" => "True", "false" => "False"), "ecommerce", "true");
     new Setting("stripe_test_secret", "text", NULL, "ecommerce", "");
     new Setting("stripe_test_publishable", "text", NULL, "ecommerce", "");
     new Setting("stripe_live_secret", "text", NULL, "ecommerce", "");
     new Setting("stripe_live_publishable", "text", NULL, "ecommerce", "");
     $show_ecommerce_cart_item = Setting::get("show_ecommerce_cart_item");
     $cart = Cache::get("cart", "session");
     if ($show_ecommerce_cart_item == "yes") {
         $label = Setting::get("ecommerce_cart_menu_item_label");
         $weight = Setting::get("ecommerce_cart_menu_item_weight");
         new MenuItem(array("name" => "cart", "label" => $label, "weight" => $weight));
     }
     if (loggedIn()) {
         new MenuItem(array("name" => "billing", "label" => "Billing", "menu" => "my_account", "page" => "billing"));
     }
     new StorageType("Product", "description", "text");
     new StorageType("Productcategory", "description", "text");
     new StorageType("Product", "title", "text");
     new StorageType("Productcategory", "title", "text");
 }
 public function __construct()
 {
     new MenuItem(array("name" => "members", "label" => "Members", "page" => "members", "menu" => "directory", "weight" => 70));
     new CSS("members", getSitePath() . "core_plugins/members/assets/css/style.css", 500);
     new FooterJS("members", getSiteURL() . "core_plugins/members/assets/js/members.js", 500, true);
 }
 function __construct()
 {
     new CSS("freshTheme", getSitePath() . "core_plugins/freshTheme/assets/freshTheme.css", 10000, true);
 }
 public function __construct()
 {
     new CSS("likes", getSitePath() . "core_plugins/likes/assets/css/style.css", 500);
     new FooterJS("likes", getSiteURL() . "core_plugins/likes/assets/js/likes.js", 5000);
 }
 public function __construct()
 {
     new FooterJS("rating", getSiteURL() . "core_plugins/rating/assets/js/rating.js", 540, true);
     new CSS("rating", getSitePath() . "core_plugins/rating/assets/css/rating.css");
 }
 static function loadPluginClasses()
 {
     $plugins = Plugin::getEnabledPlugins(false);
     if ($plugins) {
         foreach ($plugins as $plugin) {
             if (is_a($plugin, "SocialApparatus\\Plugin")) {
                 $plugin_class_name = "SocialApparatus\\" . ucfirst($plugin->name) . "Plugin";
                 $translation_class_name = "SocialApparatus\\" . ucfirst($plugin->name) . "Translation";
                 if (class_exists($translation_class_name)) {
                     new $translation_class_name();
                 }
                 foreach (glob(getSitePath() . "core_plugins/" . $plugin->name . "/lib/*.php") as $filename) {
                     include_once $filename;
                 }
                 foreach (glob(getSitePath() . "plugins/" . $plugin->name . "/lib/*.php") as $filename) {
                     include_once $filename;
                 }
                 if (class_exists($plugin_class_name)) {
                     new $plugin_class_name();
                 } else {
                     $plugin->disable();
                 }
             }
         }
     }
     return;
 }
    function __construct()
    {
        //        if (!file_exists(getSitePath() . "install/")) {
        //            forward("home");
        //        }
        $path = getSitePath();
        $url = getSiteURL();
        $this->html = <<<HTML
<style>
    body {
        background:#EFEFEF;
    }
    .navbar {
        display:none;
    }
    .jumbotron {
        background:#ffffff;
    }
    ol {
        font-size:17px; 
        font-weight:bold;
    }
    ol span {
        font-weight:normal;
    }
    ol table {
        font-weight:normal;
    }
</style>
<div class='container' style="margin-top:30px;">
            <div class='jumbotron'>
    <p>
        <a href='http://socia.us'><img src='https://socia.us/plugins/theme/assets/img/logo.png'/></a>
    </p>
    <div class='alert alert-success'>
        <p class='lead text-center'>SocialApparatus is now installed!</p>
    </div>
    <p class='lead'>
        Next steps:
        <ol>
            <li>
                Delete the install folder.<br/><span>You should now delete the /install/ directory from your web server.<br/><p><a class='btn btn-info btn-sm delete_install_folder' onclick='sitejs.delete_install_folder()'>Attempt Automatically</a></p></span>
            </li>
            <li style='margin-bottom:10px;'>
                Secure the /engine/ folder.<br/><span>Your engine folder permissions should be set to 755, and the files inside should be 644.</span>
            </li>
            <li>
                Setup system cron jobs.<span>You should setup a cron job in your control panel to run using the following commands:</span>
                <table class='table table-striped table-bordered table-condensed' style='margin-top:10px;'>
                    <tr>
                        <th style='width:300px;'>Frequency</th>
                        <th>Command</th>
                    </tr>
                    <tr>
                        <td>Every week</td>
                        <td>
                            <pre>php -q {$path}cron/week.php</pre>    
                        </td>
                    </tr>
                    <tr>
                        <td>Every day</td>
                        <td>
                            <pre>php -q {$path}cron/day.php</pre>    
                        </td>
                    </tr>
                    <tr>
                        <td>Every fifteen minutes</td>
                        <td>
                            <pre>php -q {$path}cron/fifteen.php</pre>    
                        </td>
                    </tr>
                    <tr>
                        <td>Every five minutes</td>
                        <td>
                            <pre>php -q {$path}cron/five.php</pre>    
                        </td>
                    </tr>
                    <tr>
                        <td>Every minute</td>
                        <td>
                            <pre>php -q {$path}cron/minute.php</pre>    
                        </td>
                    </tr>
                </table>
            </li>
        </ol>
    </p>
<p class='lead'>
    That's it!  Once you've deleted your /install/ folder, reload this page or <a href='{$url}' class='btn btn-success'>View your site.</a>
</p>
            </div>
</div>
HTML;
    }
 public function __construct($first_name = NULL, $last_name = NULL, $email = NULL, $password = NULL, $password2 = NULL)
 {
     $registration_fields = getAllRegistrationFields();
     runHook("action:register:before");
     if (!$first_name) {
         foreach ($registration_fields as $field) {
             $name = $field['name'];
             ${$name} = getInput($name);
         }
     }
     $banned = getEntity(array("type" => "BlacklistEmail", "metadata_name" => "email", "metadata_value" => $email));
     if ($banned) {
         new SystemMessage("Your email address has been banned.");
         forward("home");
     }
     $ip = NULL != getenv('REMOTE_ADDR') ? getenv('REMOTE_ADDR') : "";
     if ($ip) {
         $banned = getEntity(array("type" => "BlacklistIp", "metadata_name" => "ip", "metadata_value" => $ip));
         if ($banned) {
             new SystemMessage("Your ip has been banned.");
             forward("home");
         }
     }
     $ip2 = NULL != getenv('HTTP_X_FORWARDED_FOR') ? getenv('HTTP_X_FORWARDED_FOR') : "";
     if ($ip2) {
         $banned = getEntity(array("type" => "BannedIp", "metadata_name" => "ip", "metadata_value" => $ip2));
         if ($banned) {
             new SystemMessage("Your ip has been banned.");
             forward("home");
         }
     }
     $banned_emails = json_decode(file_get_contents(getSitePath() . "data/banned_email_providers.json"));
     foreach ($banned_emails as $banned_email) {
         if (strpos($email, $banned_email) !== false) {
             new SystemMessage("Sorry, temporary email addresses aren't allowed.");
             forward("register?first_name=" . $first_name . "&last_name=" . $last_name . "&email=" . $email . "&message_type=danger");
         }
     }
     if (isset($password) && isset($password2) && isset($email)) {
         if ($password != $password2) {
             new SystemMessage(translate("system_message:passwords_must_match"));
             forward("register?first_name=" . $first_name . "&last_name=" . $last_name . "&email=" . $email . "&message_type=danger");
         }
         $access = getIgnoreAccess();
         setIgnoreAccess();
         $test = getEntities(array("type" => "User", "metadata_name" => "email", "metadata_value" => $email, "limit" => 1));
         setIgnoreAccess($access);
         if ($test) {
             new SystemMessage(translate("system_message:email_taken"));
             forward("register?first_name=" . $first_name . "&last_name=" . $last_name . "&email=" . $email . "&message_type=danger");
         }
         $user = new User();
         foreach ($registration_fields as $field) {
             if (isset($field['name'])) {
                 $name = $field['name'];
                 $user->{$name} = ${$name};
             }
         }
         $user->password = md5($password);
         $user->verified = "false";
         unset($user->password2);
         $user_exists = getEntities(array("type" => "User", "limit" => 1));
         if (!$user_exists) {
             $user->level = "admin";
             $user->verified = "true";
             new SystemMessage("Since you are the first registered user, your account has been setup as the site administrator, and your email verified.");
         }
         $ip1 = NULL != getenv('REMOTE_ADDR') ? getenv('REMOTE_ADDR') : "";
         $ip2 = NULL != getenv('HTTP_X_FORWARDED_FOR') ? getenv('HTTP_X_FORWARDED_FOR') : "";
         $user->ip1 = $ip1;
         $user->ip2 = $ip2;
         $user->save();
         runHook("send_verification_email:before");
         $email_sent = Email::sendVerificationEmail($user);
         runHook("send_verification_email:after");
         runHook("action:register:after", array('user' => $user));
         if ($email_sent) {
             forward("VerificationEmailSent/" . $user->guid);
         } else {
             forward("home");
         }
     }
 }
 public function __construct()
 {
     new CSS("userpicker", getSitePath() . "core_plugins/userpicker/assets/css/userpicker.css", 901);
     new FooterJS("userpicker", getSiteURL() . "core_plugins/userpicker/assets/js/userpicker.js", 901);
 }