public function __construct() { runHook("action:login:before"); $email = getInput("email"); $access = getIgnoreAccess(); $referer = getInput("referer"); $user = getEntity(array("type" => "User", "metadata_name" => "email", "metadata_value" => $email), true, true); if ($user) { $password = getInput("password"); $password1 = md5($password); $password2 = $user->password; if ($password1 == $password2) { $user->logIn(); new SystemMessage(translate("system_message:logged_in")); runHook("action:login:after", array("user" => $user)); if ($referer) { forward($referer); } } else { new SystemMessage(translate("system_message:could_not_log_in")); } } else { new SystemMessage(translate("system_message:could_not_log_in")); } forward("home"); }
public function __construct() { if (!pageArray(2) || !pageArray(3)) { return false; } $email = pageArray(2); $code = pageArray(3); runHook("action:verify_email:before"); $access = getIgnoreAccess(); setIgnoreAccess(); $user = getEntities(array("type" => "User", "metadata_name_value_pairs" => array(array("name" => "email", "value" => $email), array("name" => "email_verification_code", "value" => $code)))); setIgnoreAccess($access); if (!$user) { new SystemMessage(translate("system_message:email_could_not_be_verified")); forward("home"); } $user = $user[0]; $user->email_verification_code = NULL; $user->verified = "true"; $user->save(); runHook("action:verify_email:after"); new SystemMessage(translate("system_message:email_verified")); new Activity($user->guid, "activity:joined", array($user->getURL(), $user->full_name)); forward("login"); }
public function __construct() { $password = getInput("password"); $password2 = getInput("password2"); if ($password != $password2) { new SystemMessage("Passwords must match."); } $guid = getInput("guid"); $code = getInput("code"); $access = getIgnoreAccess(); setIgnoreAccess(); $user = getEntity($guid); if ($user) { if ($user->password_reset_code == $code) { $user->password = password_hash($password, PASSWORD_BCRYPT); $user->password_reset_code = NULL; $user->save(); new SystemMessage("Your password has been reset."); forward("home"); } } else { new SystemMessage("No user found with that email."); forward("home"); } setIgnoreAccess($access); }
static function getNotificationCount($guid) { $access = getIgnoreAccess(); setIgnoreAccess(); $count = getEntities(array("type" => "Notification", "count" => true, "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid())))); setIgnoreAccess($access); return $count; }
/** * Creates notification page html */ public function __construct() { $user_guid = getLoggedInUserGuid(); $access = getIgnoreAccess(); setIgnoreAccess(); $notifications = listEntities(array("type" => "Notification", "metadata_name" => "owner_guid", "metadata_value" => $user_guid)); setIgnoreAccess($access); $buttons = getSiteURL() . "action/deleteAllNotifications/{$user_guid}"; $buttons = addTokenToURL($buttons); $buttons = "<a href='{$buttons}' class='btn btn-danger'>Dismiss All</a>"; $page = drawPage(array("header" => "Notifications", "body" => $notifications, "button" => $buttons)); $this->html = $page; }
function __construct() { $access = getIgnoreAccess(); setIgnoreAccess(); $system_settings = getEntities(array("type" => "Setting", "metadata_name" => "tab", "metadata_value" => "adsense")); setIgnoreAccess($access); if ($system_settings) { foreach ($system_settings as $setting) { $setting->value = getInput($setting->name); $setting->save(); } } clearCache(); forward("admin/adsense"); }
public function __construct() { $email = getInput("email"); $access = getIgnoreAccess(); setIgnoreAccess(); $user = getEntities(array("type" => "User", "metadata_name" => "email", "metadata_value" => $email, "limit" => 1)); setIgnoreAccess($access); if (!empty($user)) { $user = $user[0]; $user->sendPasswordResetLink(); forward("passwordResetEmailSent"); } else { new SystemMessage("No account with that email found."); forward(); } }
public function __construct() { $access = getIgnoreAccess(); setIgnoreAccess(); $system_settings = getEntities(array("type" => "Setting")); setIgnoreAccess($access); if ($system_settings) { foreach ($system_settings as $setting) { $name = $setting->name; $value = getInput($name); $setting->value = $value; $setting->save(); } } clearCache(); forward("admin/general"); }
function login($data) { $returnuser = "******"; $email = $data['email']; $password = $data['password']; $ignore_access = getIgnoreAccess(); setIgnoreAccess(true); $user = getEntity(array("type" => "User", "metadata_name_value_pairs" => array(array("name" => "email", "value" => $email), array("name" => "verified", "value" => "true"))), true, true); setIgnoreAccess($ignore_access); if ($user) { $password1 = md5($password); $password2 = $user->password; if ($password1 == $password2) { $returnuser = $user; unset($returnuser->password); return json_encode($returnuser); } } return "false"; }
/** * Creates html for forgot password page */ public function __construct() { $code = pageArray(1); $email = pageArray(2); if ($code && $email) { $access = getIgnoreAccess(); setIgnoreAccess(); $user = getEntities(array("type" => "User", "metadata_name_value_pairs" => array(array("name" => "email", "value" => $email), array("name" => "password_reset_code", "value" => $code)))); setIgnoreAccess($access); if ($user) { $user = $user[0]; new Vars("guid", $user->guid); new Vars("code", $code); $form = drawForm(array("name" => "new_password", "method" => "post", "action" => "newPassword")); $header = "Enter your new password."; $this->html = drawPage($header, $form); $this->html = drawPage(array("header" => $header, "body" => $form)); } } else { $form = drawForm(array("name" => "forgot_password", "method" => "post", "action" => "ForgotPassword")); $this->html = drawPage(array("header" => "Reset Your Password", "body" => $form)); } }
* SocialApparatus CONFIDENTIAL * __________________ * * [2002] - [2017] SocialApparatus (http://SocialApparatus.co) * All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of SocialApparatus * and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; denyDirect(); $access = getIgnoreAccess(); setIgnoreAccess(); $system_settings = Setting::getAll("video_settings"); setIgnoreAccess($access); if ($system_settings) { foreach ($system_settings as $name => $setting) { echo display("input/" . $setting->field_type, array("name" => $setting->name, "value" => $setting->value, "class" => "form-control", "label" => isset($setting->label) ? $setting->label : translate("admin:video_settings:" . $setting->name), "options_values" => $setting->options)); } echo display("input/submit", array("class" => "btn btn-success", "label" => "Save")); } else { echo "<blockquote>These settings are created by plugins.</blockquote>"; }
static function loggedInUserCanViewEntity($entity = false, $ignore_access = false, $logged_in_user_guid = false) { // run blocked content handlers $handlers = Cache::get("blocked_content_handlers", "session"); if ($handlers) { foreach ($handlers as $handler) { $handlerEntity = "SocialApparatus\\" . $handler; $r = new $handlerEntity(); $return = $r->validate($entity); if (!$return) { return false; } } } if ($entity->access_id == "system") { return true; } if (!is_a($entity, "SocialApparatus\\User")) { if (loggedIn()) { $logged_in_user_guid = getLoggedInUserGuid(); } } if (!is_object($entity)) { return true; } if (!$entity) { return true; } if (!$entity->access_id) { $entity->access_id = "system"; $entity->save(); } if ($ignore_access) { return true; } if (!is_object($entity)) { return true; } if (getIgnoreAccess()) { return true; } // Logged in user trying to view him/herself if (getLoggedInUserGuid() == $entity->guid || $logged_in_user_guid == $entity->guid) { return true; } // Logged in user owns entity if (getLoggedInUserGuid() == $entity->owner_guid || $logged_in_user_guid == $entity->owner_guid) { return true; } // Admins can view everything if (adminLoggedIn()) { return true; } if (is_numeric($entity->access_id)) { $access_entity = getEntity($entity->access_id); if (is_a($access_entity, "SocialApparatus\\Group")) { if (isEnabledPlugin("Groups")) { if ($access_entity->loggedInUserIsMember($logged_in_user_guid)) { return true; } } } return false; } $access_handler = Accesshandler::get($entity->access_id); $access_handler = ucfirst($entity->access_id) . "AccessHandler"; $access_handler = "SocialApparatus\\" . $access_handler; if (class_exists($access_handler)) { $return = (new $access_handler())->init($entity, $logged_in_user_guid); return $return; } return false; }
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"); } } }
static function getEntity($params, $ignore_access = false, $return_password = false, $logged_in_user_guid = false) { if (!is_array($params)) { $entity = Cache::get("entity_" . $params); if (!$entity) { $type = self::getTypeFromGuid($params); if ($type) { $type = ucfirst($type); $classname = "SocialApparatus\\" . ucfirst($type); $entity = new $classname(); $entity->type = $type; $entity->guid = $params; $entity->populateMetadata($params); } else { return false; } } if (isset($entity->password)) { if (!$return_password) { unset($entity->password); } } if (loggedInUserCanViewEntity($entity, $ignore_access, $logged_in_user_guid)) { return $entity; } else { return false; } } else { $entities = getEntities($params, true, false, $return_password, $logged_in_user_guid); if (is_array($entities)) { if (!$return_password) { foreach ($entities as $entity) { unset($entity->password); } } if (isset($entities[0])) { if (loggedInUserCanViewEntity($entities[0], $ignore_access, $logged_in_user_guid) || getIgnoreAccess()) { return $entities[0]; } else { return false; } } else { return false; } } else { return false; } } }
static function getAll() { $access = getIgnoreAccess(); setIgnoreAccess(); $plugins = getEntities(array("type" => "Plugin")); setIgnoreAccess($access); return $plugins; }