$field_name = ucwords(str_replace('_', ' ', str_replace(' ', '_', $key)));
         if ($setting_item->delete()) {
             //if the item was changed successfully, add to array
             $changes[] = "<strong>" . $field_name . "</strong> was deleted successfully.";
         } else {
             //if the item was changed successfully, add to array
             $changes[] = "<strong>" . $field_name . "</strong> was not deleted successfully. " . $database->last_error;
         }
     }
     //else, it does not exist in the database, do nothing
 } else {
     //scenario #2
     //quick check
     //if populating the phone field, strip out all numeric characters
     if ($key == 'phone_number') {
         $value = return_numeric($value);
     }
     //so we need to check if this setting is currently set
     if (isset($website_settings[$key])) {
         //it does currently exist in the database
         //now we need to confirm IF the values are different
         $setting_item = Setting::find_by_name($key, "variable_name");
         if ($setting_item->variable_value != $value) {
             //if we're in here then the values are certainly different
             //update the database
             $setting_item->variable_value = $value;
             $field_name = ucwords(str_replace('_', ' ', str_replace(' ', '_', $key)));
             if ($setting_item->save()) {
                 //if the item was changed successfully, add to array
                 $changes[] = "<strong>" . $field_name . "</strong> was updated successfully.";
             } else {
Example #2
0
//require the framework
require_once "../requires/initialize.php";
// create the page
$page = new Page();
$page->name = "Update Account";
$page->is_user_only = true;
//only process the form if it's submitted
if (isset($_POST["submit"])) {
    //assign variables to all form-submitted values
    $email_address = $_POST['email_address'];
    $hashed_password = sha1($database->escape_value($_POST['password']));
    $confirmed_password = sha1($database->escape_value($_POST['confirmed_password']));
    $first_name = $_POST['first_name'];
    $last_name = $_POST['last_name'];
    $phone_number = return_numeric($_POST['phone_number']);
    $is_notifications_enabled = $_POST['email_notifications'];
    // validations
    //make sure passwords (first and confirmed) are the same
    if ($hashed_password != $confirmed_password) {
        $session->message($session->message . "The passwords you entered do not match. ");
    }
    //make sure the email address is not already taken
    if ($user->email_address != $email_address) {
        if (User::find_by_name($database->escape_value($email_address), "email_address")) {
            $session->message($session->message . "That email address is already taken, please enter a new email address. ");
            $email_address = $user->email_address;
        }
    }
    //only actually create the user if there are no errors
    if (empty($session->message)) {
$page->name = "Create New User";
// check to see if a user is already logged in
if ($session->is_logged_in) {
    $session->message("You are already logged in! To create a new account, please logout first.");
    redirect_head(ROOT_URL);
}
// if the form is submitted, attempt to create their new user account
if (isset($_POST["submit"])) {
    $new_user = new User();
    $new_user->username = $_POST['username'];
    $new_user->email_address = $_POST['email_address'];
    $new_user->hashed_password = sha1($database->escape_value($_POST['password']));
    $confirmed_password = sha1($database->escape_value($_POST['confirmed_password']));
    $new_user->first_name = $_POST['first_name'];
    $new_user->last_name = $_POST['last_name'];
    $new_user->phone_number = return_numeric($_POST['phone_number']);
    $new_user->is_notifications_enabled = $_POST['email_notifications'];
    //make sure the username does not already exist
    if (User::find_by_name($database->escape_value($new_user->username), "username")) {
        $session->message("That username is already taken, please enter a new username. ");
        $new_user->username = "";
    }
    //make sure the email address is not already taken
    if (User::find_by_name($database->escape_value($new_user->email_address), "email_address")) {
        $session->message($session->message . "That email address is already taken, please enter a new email address. ");
        $new_user->email_address = "";
    }
    //make sure passwords are the same
    if ($new_user->hashed_password != $confirmed_password) {
        $session->message($session->message . "The passwords you entered do not match.");
    }