当前位置: 首页>>代码示例>>PHP>>正文


PHP validate_email_address函数代码示例

本文整理汇总了PHP中validate_email_address函数的典型用法代码示例。如果您正苦于以下问题:PHP validate_email_address函数的具体用法?PHP validate_email_address怎么用?PHP validate_email_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了validate_email_address函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 /**
  * Process password forgotten
  * 
  * @access public
  * @return void
  */
 public function process()
 {
     $email_address = $this->input->post('email_address');
     if (validate_email_address($email_address)) {
         //load model
         $this->load->model('account_model');
         $data = $this->account_model->get_data($email_address);
         if ($data !== NULL) {
             $password = create_random_string(config('ACCOUNT_PASSWORD'));
             if ($this->account_model->save_password($data['customers_id'], $password)) {
                 $this->load->library('email_template');
                 $email = $this->email_template->get_email_template('password_forgotten');
                 $email->set_data($data['customers_firstname'], $data['customers_lastname'], getenv('REMOTE_ADDR'), $password, $data['customers_gender'], $data['customers_email_address']);
                 $email->build_message();
                 $email->send_email();
                 $this->message_stack->add_session('login', lang('success_password_forgotten_sent'), 'success');
                 redirect('account/login');
             }
         } else {
             $this->message_stack->add('password_forgotten', lang('error_password_forgotten_no_email_address_found'));
         }
     } else {
         $this->message_stack->add('password_forgotten', lang('error_password_forgotten_no_email_address_found'));
     }
     $this->template->build('account/password_forgotten');
 }
开发者ID:colonia,项目名称:tomatocart-v2,代码行数:32,代码来源:password_forgotten.php

示例2: content

function content()
{
    if (!user_logged_in()) {
        return must_log_in();
    }
    $user = fetch_one_or_none('users', 'id', user_logged_in());
    $errors = array();
    if (array_key_exists('change', $_POST)) {
        if (!isset($_POST['email']) || !$_POST['email']) {
            $errors[] = "Please enter an email address";
        } else {
            $email = $_POST['email'];
            if ($email && !validate_email_address($email)) {
                $errors[] = "Invalid email address";
            }
            if (count($errors) == 0 && count(fetch_all('users', 'email_address', $email))) {
                $errors[] = "A user with this email address already exists";
            }
            if (count($errors) == 0) {
                update_all('users', array('new_email_address' => $email), 'id', user_logged_in());
                send_email_change_email($email, $user->name);
                ?>
        <p>We have sent an email to your new address requesting that you
          confirm that change of address.</p>
        <?php 
                return;
            }
        }
    }
    $fields = array();
    page_header('Change email address');
    show_error_list($errors);
    ?>
 
    <form method="post" action="" accept-charset="UTF-8">
      <div class="fieldrow">
        <div class="field">
          <label>Current address:</label>
          <div><tt><?php 
    esc($user->email_address);
    ?>
</tt></div>
        </div>
      </div>

      <div class="fieldrow">
        <?php 
    text_field($fields, 'email', 'New address');
    ?>
      </div>

      <div class="fieldrow">
        <input type="submit" name="change" value="Change"/>
      </div>
    </form>
  <?php 
}
开发者ID:ras52,项目名称:geneopedia,代码行数:57,代码来源:change-email.php

示例3: set_data

 /**
  * Set Data
  *
  * @access public
  * @return void
  */
 function set_data($from_name, $from_email_address, $to_email_address, $message, $wishlist_url)
 {
     $this->from_name = $from_name;
     $this->from_email_address = $from_email_address;
     $this->to_email_address = $to_email_address;
     $this->message = $message;
     $this->wishlist_url = $wishlist_url;
     $emails = explode(',', $this->to_email_address);
     foreach ($emails as $email) {
         if (validate_email_address($email)) {
             $this->add_recipient('', $email);
         }
     }
 }
开发者ID:colonia,项目名称:tomatocart-v2,代码行数:20,代码来源:email_template_share_wishlist.php

示例4: register

 /**
  * Registers a user, returning false if the username already exists
  *
  * @param string $username              The username of the new user
  * @param string $password              The password
  * @param string $name                  The user's display name
  * @param string $email                 The user's email address
  * @param bool   $allow_multiple_emails Allow the same email address to be
  *                                      registered multiple times?
  *
  * @return int|false The new user's GUID; false on failure
  * @throws \RegistrationException
  */
 function register($username, $password, $name, $email, $allow_multiple_emails = false)
 {
     // no need to trim password.
     $username = trim($username);
     $name = trim(strip_tags($name));
     $email = trim($email);
     // A little sanity checking
     if (empty($username) || empty($password) || empty($name) || empty($email)) {
         return false;
     }
     // Make sure a user with conflicting details hasn't registered and been disabled
     $access_status = access_get_show_hidden_status();
     access_show_hidden_entities(true);
     if (!validate_email_address($email)) {
         throw new \RegistrationException(_elgg_services()->translator->translate('registration:emailnotvalid'));
     }
     if (!validate_password($password)) {
         throw new \RegistrationException(_elgg_services()->translator->translate('registration:passwordnotvalid'));
     }
     if (!validate_username($username)) {
         throw new \RegistrationException(_elgg_services()->translator->translate('registration:usernamenotvalid'));
     }
     if ($user = get_user_by_username($username)) {
         throw new \RegistrationException(_elgg_services()->translator->translate('registration:userexists'));
     }
     if (!$allow_multiple_emails && get_user_by_email($email)) {
         throw new \RegistrationException(_elgg_services()->translator->translate('registration:dupeemail'));
     }
     access_show_hidden_entities($access_status);
     // Create user
     $user = new \ElggUser();
     $user->username = $username;
     $user->email = $email;
     $user->name = $name;
     $user->access_id = ACCESS_PUBLIC;
     $user->setPassword($password);
     $user->owner_guid = 0;
     // Users aren't owned by anyone, even if they are admin created.
     $user->container_guid = 0;
     // Users aren't contained by anyone, even if they are admin created.
     $user->language = _elgg_services()->translator->getCurrentLanguage();
     if ($user->save() === false) {
         return false;
     }
     // Turn on email notifications by default
     set_user_notification_setting($user->getGUID(), 'email', true);
     return $user->getGUID();
 }
开发者ID:gzachos,项目名称:elgg_ellak,代码行数:61,代码来源:UsersTable.php

示例5: foreach

 foreach ($_POST as $key => $value) {
     $_POST[$key] = remove_email_injection(trim($value));
 }
 // Loop into required fields and make sure they match our needs
 foreach ($required_fields as $field) {
     // the field has been submitted?
     if (!array_key_exists($field, $_POST)) {
         array_push($validation, $field);
     }
     // check there is information in the field?
     if ($_POST[$field] == '') {
         array_push($validation, $field);
     }
     // validate the email address supplied
     if ($field == 'email') {
         if (!validate_email_address($_POST[$field])) {
             array_push($validation, $field);
         }
     }
 }
 // basic validation result
 if (count($validation) == 0) {
     // Prepare our content string
     $email_content = 'New Website Comment: ' . "\n\n";
     // simple email content
     foreach ($_POST as $key => $value) {
         if ($key != 'submit') {
             $email_content .= $key . ': ' . $value . "\n";
         }
     }
     // if validation passed ok then send the email
开发者ID:yordan-kovachev,项目名称:BoxGifts,代码行数:31,代码来源:contact.php

示例6: content

function content()
{
    $errors = array();
    if (array_key_exists('register', $_POST)) {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $password = $_POST['password'];
        $password2 = $_POST['password2'];
        if (!$name || !$email || !$password || !$password2) {
            $errors[] = "Please fill in all the fields";
        }
        if ($password && $password2 && $password != $password2) {
            $errors[] = "Passwords do not match";
            $_POST['password'] = '';
            $_POST['password2'] = '';
        }
        if ($email && !validate_email_address($email)) {
            error_log("Invalid email address <{$email}> while registering");
            $errors[] = "Invalid email address";
        }
        if (count($errors) == 0 && count(fetch_all('users', 'email_address', $email))) {
            $errors[] = "A user with this email address already exists";
        }
        if (count($errors) == 0) {
            $token = make_random_token();
            $data = array('name' => $name, 'email_address' => $email, 'password_crypt' => crypt($password), 'date_registered' => date('Y-m-d H:i:s'), 'activation_token' => $token);
            insert_array_contents('users', $data);
            send_activation_email($email, $name, $token);
            ?>

      <h2>Account registered</h2>

      <p>An email has just been sent to the email address you supplied.  This
        contains a link which you should follow to activate your account.</p>
      
      <?php 
            return;
        }
    }
    page_header('Register for an account');
    show_error_list($errors);
    ?>

    <form method="post" action="" accept-charset="UTF-8">
      <div class="fieldrow">
        <?php 
    text_field($_POST, 'name', 'Name', 'publicly visible');
    ?>
      </div>

      <div class="fieldrow">
        <?php 
    text_field($_POST, 'email', 'Email address');
    ?>
      </div>

      <div class="fieldrow">
        <div>
          <label for="password">Password</label>
          <input type="password" id="password" name="password" 
            value="<?php 
    esc($_POST['password']);
    ?>
" />
        </div>
        <div>
          <label for="password2">Confirm password</label>
          <input type="password" id="password2" name="password2" 
            value="<?php 
    esc($_POST['password2']);
    ?>
" />
        </div>
      </div>

      <div class="fieldrow">
        <input type="submit" name="register" value="Register" />
      </div>
    </form>
  <?php 
}
开发者ID:ras52,项目名称:geneopedia,代码行数:81,代码来源:register.php

示例7: save_billing_form

 /**
  * Save billing form
  */
 public function save_billing_form()
 {
     $data = array();
     $errors = array();
     $this->load->model('account_model');
     //checkout method: 'register' or 'guest'
     $checkout_method = $this->input->post('checkout_method');
     //if the customer is not logged on
     //check email
     if (!$this->customer->is_logged_on()) {
         $billing_email_address = $this->input->post('billing_email_address');
         if ($billing_email_address === NULL || strlen(trim($billing_email_address)) < config('ACCOUNT_EMAIL_ADDRESS')) {
             $errors[] = sprintf(lang('field_customer_email_address_error'), config('ACCOUNT_EMAIL_ADDRESS'));
         } else {
             //validate email address
             if (!validate_email_address($billing_email_address)) {
                 $errors[] = lang('field_customer_email_address_check_error');
             } else {
                 //check whether email exists
                 $data = $this->account_model->get_data($billing_email_address);
                 if ($data !== NULL) {
                     $errors[] = lang('field_customer_email_address_exists_error');
                 } else {
                     $data['email_address'] = $billing_email_address;
                 }
             }
         }
         //if checkout method is 'register' then check the password
         $data['password'] = NULL;
         if ($checkout_method == 'register') {
             $billing_password = $this->input->post('billing_password');
             $confirmation = $this->input->post('confirmation');
             if ($billing_password === NULL || $billing_password !== NULL && strlen(trim($billing_password)) < config('ACCOUNT_PASSWORD')) {
                 $errors[] = sprintf(lang('field_customer_password_error'), config('ACCOUNT_PASSWORD'));
             } elseif ($confirmation === NULL || $confirmation !== NULL && trim($billing_password) != trim($confirmation)) {
                 $errors[] = lang('field_customer_password_mismatch_with_confirmation');
             } else {
                 $data['password'] = $billing_password;
             }
         }
     }
     //if the create_billing_address equals 1 then get the data
     $data['create_billing_address'] = $this->input->post('create_billing_address');
     if ($data['create_billing_address'] == 'on') {
         //gender
         $billing_gender = $this->input->post('billing_gender');
         if (config('ACCOUNT_GENDER') == '1') {
             if ($billing_gender == 'm' || $billing_gender == 'f') {
                 $data['gender'] = $billing_gender;
             } else {
                 $errors[] = lang('field_customer_gender_error');
             }
         } else {
             $data['gender'] = $billing_gender !== NULL ? $billing_gender : 'm';
         }
         //firstname
         $billing_firstname = $this->input->post('billing_firstname');
         if ($billing_firstname !== NULL && strlen(trim($billing_firstname)) >= config('ACCOUNT_FIRST_NAME')) {
             $data['firstname'] = $billing_firstname;
         } else {
             $errors[] = sprintf(lang('field_customer_first_name_error'), config('ACCOUNT_FIRST_NAME'));
         }
         //lastname
         $billing_lastname = $this->input->post('billing_lastname');
         if ($billing_lastname !== NULL && strlen(trim($billing_lastname)) >= config('ACCOUNT_LAST_NAME')) {
             $data['lastname'] = $billing_lastname;
         } else {
             $errors[] = sprintf(lang('field_customer_last_name_error'), config('ACCOUNT_LAST_NAME'));
         }
         //company
         if (config('ACCOUNT_COMPANY') > -1) {
             $billing_company = $this->input->post('billing_company');
             if ($billing_company !== NULL && strlen(trim($billing_company)) >= config('ACCOUNT_COMPANY')) {
                 $data['company'] = $billing_company;
             } else {
                 $errors[] = sprintf(lang('field_customer_company_error'), config('ACCOUNT_COMPANY'));
             }
         }
         //street address
         $billing_street_address = $this->input->post('billing_street_address');
         if ($billing_street_address !== NULL && strlen(trim($billing_street_address)) >= config('ACCOUNT_STREET_ADDRESS')) {
             $data['street_address'] = $billing_street_address;
         } else {
             $errors[] = sprintf(lang('field_customer_street_address_error'), config('ACCOUNT_STREET_ADDRESS'));
         }
         //suburb
         if (config('ACCOUNT_SUBURB') >= 0) {
             $billing_suburb = $this->input->post('billing_suburb');
             if ($billing_suburb !== NULL && strlen(trim($billing_suburb)) >= config('ACCOUNT_SUBURB')) {
                 $data['suburb'] = $billing_suburb;
             } else {
                 $errors[] = sprintf(lang('field_customer_suburb_error'), config('ACCOUNT_SUBURB'));
             }
         }
         //postcode
         if (config('ACCOUNT_POST_CODE') > -1) {
             $billing_postcode = $this->input->post('billing_postcode');
//.........这里部分代码省略.........
开发者ID:colonia,项目名称:tomatocart-v2,代码行数:101,代码来源:checkout.php

示例8: register_user

/**
 * Registers a user, returning false if the username already exists
 *
 * @param string $username The username of the new user
 * @param string $password The password
 * @param string $name The user's display name
 * @param string $email Their email address
 * @param bool $allow_multiple_emails Allow the same email address to be registered multiple times?
 * @param int $friend_guid Optionally, GUID of a user this user will friend once fully registered 
 * @return int|false The new user's GUID; false on failure
 */
function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $friend_guid = 0, $invitecode = '')
{
    // Load the configuration
    global $CONFIG;
    $username = trim($username);
    $password = trim($password);
    $name = trim($name);
    $email = trim($email);
    // A little sanity checking
    if (empty($username) || empty($password) || empty($name) || empty($email)) {
        return false;
    }
    // See if it exists and is disabled
    $access_status = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // Validate email address
    if (!validate_email_address($email)) {
        throw new RegistrationException(elgg_echo('registration:emailnotvalid'));
    }
    // Validate password
    if (!validate_password($password)) {
        throw new RegistrationException(elgg_echo('registration:passwordnotvalid'));
    }
    // Validate the username
    if (!validate_username($username)) {
        throw new RegistrationException(elgg_echo('registration:usernamenotvalid'));
    }
    // Check to see if $username exists already
    if ($user = get_user_by_username($username)) {
        //return false;
        throw new RegistrationException(elgg_echo('registration:userexists'));
    }
    // If we're not allowed multiple emails then see if this address has been used before
    if (!$allow_multiple_emails && get_user_by_email($email)) {
        throw new RegistrationException(elgg_echo('registration:dupeemail'));
    }
    access_show_hidden_entities($access_status);
    // Check to see if we've registered the first admin yet.
    // If not, this is the first admin user!
    $admin = datalist_get('admin_registered');
    // Otherwise ...
    $user = new ElggUser();
    $user->username = $username;
    $user->email = $email;
    $user->name = $name;
    $user->access_id = ACCESS_PUBLIC;
    $user->salt = generate_random_cleartext_password();
    // Note salt generated before password!
    $user->password = generate_user_password($user, $password);
    $user->owner_guid = 0;
    // Users aren't owned by anyone, even if they are admin created.
    $user->container_guid = 0;
    // Users aren't contained by anyone, even if they are admin created.
    $user->save();
    // If $friend_guid has been set, make mutual friends
    if ($friend_guid) {
        if ($friend_user = get_user($friend_guid)) {
            if ($invitecode == generate_invite_code($friend_user->username)) {
                $user->addFriend($friend_guid);
                $friend_user->addFriend($user->guid);
            }
        }
    }
    global $registering_admin;
    if (!$admin) {
        $user->admin = true;
        datalist_set('admin_registered', 1);
        $registering_admin = true;
    } else {
        $registering_admin = false;
    }
    // Turn on email notifications by default
    set_user_notification_setting($user->getGUID(), 'email', true);
    return $user->getGUID();
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:86,代码来源:users.php

示例9: elgg_echo

             } else {
                 $result['status'] = false;
                 $result['text'] = elgg_echo('registration:usernamenotvalid');
             }
         } catch (Exception $e) {
             $result['status'] = false;
             $result['text'] = $e->getMessage();
         }
     }
     break;
 case 'email':
     $email = get_input('email');
     if ($email) {
         $result['status'] = true;
         try {
             if (validate_email_address($email)) {
                 $hidden = access_show_hidden_entities(true);
                 if (get_user_by_email($email)) {
                     $result['status'] = false;
                     $result['text'] = elgg_echo('registration:dupeemail');
                 }
                 access_show_hidden_entities($hidden);
             } else {
                 $result['status'] = false;
                 $result['text'] = elgg_echo('registration:notemail');
             }
         } catch (Exception $e) {
             $result['status'] = false;
             $result['text'] = $e->getMessage();
         }
     }
开发者ID:coldtrick,项目名称:profile_manager,代码行数:31,代码来源:validate.php

示例10: register_user

/**
 * Registers a user, returning false if the username already exists
 *
 * @param string $username              The username of the new user
 * @param string $password              The password
 * @param string $name                  The user's display name
 * @param string $email                 Their email address
 * @param bool   $allow_multiple_emails Allow the same email address to be
 *                                      registered multiple times?
 * @param int    $friend_guid           GUID of a user to friend once fully registered
 * @param string $invitecode            An invite code from a friend
 *
 * @return int|false The new user's GUID; false on failure
 */
function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $friend_guid = 0, $invitecode = '')
{
    // Load the configuration
    global $CONFIG;
    // no need to trim password.
    $username = trim($username);
    $name = trim(strip_tags($name));
    $email = trim($email);
    // A little sanity checking
    if (empty($username) || empty($password) || empty($name) || empty($email)) {
        return false;
    }
    // Make sure a user with conflicting details hasn't registered and been disabled
    $access_status = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    if (!validate_email_address($email)) {
        throw new RegistrationException(elgg_echo('registration:emailnotvalid'));
    }
    if (!validate_password($password)) {
        throw new RegistrationException(elgg_echo('registration:passwordnotvalid'));
    }
    if (!validate_username($username)) {
        throw new RegistrationException(elgg_echo('registration:usernamenotvalid'));
    }
    if ($user = get_user_by_username($username)) {
        throw new RegistrationException(elgg_echo('registration:userexists'));
    }
    if (!$allow_multiple_emails && get_user_by_email($email)) {
        throw new RegistrationException(elgg_echo('registration:dupeemail'));
    }
    access_show_hidden_entities($access_status);
    // Create user
    $user = new ElggUser();
    $user->username = $username;
    $user->email = $email;
    $user->name = $name;
    $user->access_id = ACCESS_PUBLIC;
    $user->salt = generate_random_cleartext_password();
    // Note salt generated before password!
    $user->password = generate_user_password($user, $password);
    $user->owner_guid = 0;
    // Users aren't owned by anyone, even if they are admin created.
    $user->container_guid = 0;
    // Users aren't contained by anyone, even if they are admin created.
    $user->language = get_current_language();
    $user->save();
    // If $friend_guid has been set, make mutual friends
    if ($friend_guid) {
        if ($friend_user = get_user($friend_guid)) {
            if ($invitecode == generate_invite_code($friend_user->username)) {
                $user->addFriend($friend_guid);
                $friend_user->addFriend($user->guid);
                // @todo Should this be in addFriend?
                add_to_river('river/relationship/friend/create', 'friend', $user->getGUID(), $friend_guid);
                add_to_river('river/relationship/friend/create', 'friend', $friend_guid, $user->getGUID());
            }
        }
    }
    // Turn on email notifications by default
    set_user_notification_setting($user->getGUID(), 'email', true);
    return $user->getGUID();
}
开发者ID:riggo,项目名称:Elgg,代码行数:76,代码来源:users.php

示例11: user_get_user_by_email

/**
 * Web service to get all users registered with an email ID
 *
 * @param string $email Email ID to check for
 * @return string $foundusers Array of usernames registered with this email ID
 * @throws InvalidParameterException
 * @throws RegistrationException
 */
function user_get_user_by_email($email)
{
    if (!validate_email_address($email)) {
        throw new RegistrationException(elgg_echo('registration:notemail'));
    }
    $user = get_user_by_email($email);
    if (!$user) {
        throw new InvalidParameterException('registration:emailnotvalid');
    }
    foreach ($user as $key => $singleuser) {
        $foundusers[$key] = $singleuser->username;
    }
    return $foundusers;
}
开发者ID:manlui,项目名称:elgg_with_rest_api,代码行数:22,代码来源:user.php

示例12: save

 /**
  * Save the edited account
  *
  * @access public
  */
 public function save()
 {
     $data = array();
     //validate gender
     if (config('ACCOUNT_GENDER') == '1') {
         $gender = $this->input->post('gender');
         if ($gender == 'm' || $gender == 'f') {
             $data['customers_gender'] = $gender;
         } else {
             $this->message_stack->add('account_edit', lang('field_customer_gender_error'));
         }
     } else {
         $data['customers_gender'] = !empty($gender) ? $gender : '';
     }
     //validate firstname
     $firstname = $this->input->post('firstname');
     if (!empty($firstname) || strlen(trim($firstname)) >= config('ACCOUNT_FIRST_NAME')) {
         $data['customers_firstname'] = $this->security->xss_clean($firstname);
     } else {
         $this->message_stack->add('account_edit', sprintf(lang('field_customer_first_name_error'), config('ACCOUNT_FIRST_NAME')));
     }
     //validate lastname
     $lastname = $this->input->post('lastname');
     if (!empty($lastname) || strlen(trim($lastname)) >= config('ACCOUNT_LAST_NAME')) {
         $data['customers_lastname'] = $this->security->xss_clean($lastname);
     } else {
         $this->message_stack->add('account_edit', sprintf(lang('field_customer_last_name_error'), config('ACCOUNT_LAST_NAME')));
     }
     //validate dob days
     if (config('ACCOUNT_DATE_OF_BIRTH') == '1') {
         $dob_days = $this->input->post('dob_days');
         if (!empty($dob_days)) {
             $data['customers_dob'] = $dob_days;
         } else {
             $this->message_stack->add('account_edit', lang('field_customer_date_of_birth_error'));
         }
     }
     //email address
     $email_address = $this->input->post('email_address');
     if (!empty($email_address) && strlen(trim($email_address)) >= config('ACCOUNT_EMAIL_ADDRESS')) {
         if (validate_email_address($email_address)) {
             if ($this->account_model->check_duplicate_entry($email_address, $this->customer->get_id()) === FALSE) {
                 $data['customers_email_address'] = $email_address;
             } else {
                 $this->message_stack->add('account_edit', lang('field_customer_email_address_exists_error'));
             }
         } else {
             $this->message_stack->add('account_edit', lang('field_customer_email_address_check_error'));
         }
     } else {
         $this->message_stack->add('account_edit', sprintf(lang('field_customer_email_address_error'), config('ACCOUNT_EMAIL_ADDRESS')));
     }
     //newsletter
     if (config('ACCOUNT_NEWSLETTER') == '1') {
         $data['customers_newsletter'] = $this->input->post('newsletter') == 1 ? '1' : '0';
     }
     if ($this->message_stack->size('account_edit') === 0) {
         if ($this->account_model->save($data, $this->customer->get_id())) {
             $this->customer->set_data($data['customers_email_address']);
             $this->message_stack->add_session('account', lang('success_account_updated'), 'success');
             redirect(site_url('account'));
         } else {
             $this->message_stack->add('account_edit', lang('error_database'));
         }
     }
     //setup view
     $this->template->build('account/account_edit');
 }
开发者ID:colonia,项目名称:tomatocart-v2,代码行数:73,代码来源:edit.php

示例13: queueRecords

 /**
  * Validate records and create update and create queues
  *
  * @param mixed $data
  */
 function queueRecords($data = null)
 {
     if (!$this->records->mapped) {
         $this->mapRecords($data);
     }
     $this->records->queue = array();
     foreach ($this->records->mapped as $record) {
         $create = true;
         $update = false;
         $messages = array();
         // First check if the user already exists
         if ($record['guid']) {
             $create = false;
             $record_entity = get_entity($record['guid']);
             if (elgg_instanceof($record_entity, 'user')) {
                 $messages[] = elgg_echo('upload_users:error:userexists');
                 if ($this->update_existing_users) {
                     $update = true;
                 }
             } else {
                 if ($this->update_existing_users) {
                     $messages[] = elgg_echo('upload_users:error:invalid_guid');
                 }
             }
         } else {
             try {
                 validate_email_address($record['email']);
                 $record_by_username = get_user_by_username($record['username']);
                 $record_by_email = get_user_by_email($record['email']);
                 if (elgg_instanceof($record_by_username, 'user') || elgg_instanceof($record_by_email[0], 'user')) {
                     $create = false;
                     if ($record_by_username->guid != $record_by_email[0]->guid) {
                         if ($this->fix_usernames && !$this->update_existing_users) {
                             $create = true;
                             while (get_user_by_username($record['username'])) {
                                 $record['username'] = $record['username'] . rand(1000, 9999);
                             }
                         } else {
                             $messages[] = elgg_echo('upload_users:error:update_email_username_mismatch');
                             // username does not match with the email we have in the database
                         }
                     } else {
                         $messages[] = elgg_echo('upload_users:error:userexists');
                         if ($this->update_existing_users) {
                             $record['guid'] = $record_by_username->guid;
                             $update = true;
                         }
                     }
                 }
             } catch (RegistrationException $r) {
                 $create = false;
                 $messages[] = $r->getMessage();
             }
         }
         // No existing accounts found; validate details for registration
         if ($create) {
             if (!$record['name']) {
                 $create = false;
                 $messages[] = elgg_echo('upload_users:error:empty_name');
             }
             try {
                 validate_username($record['username']);
             } catch (RegistrationException $r) {
                 $create = false;
                 $messages[] = $r->getMessage();
             }
             if ($record['password']) {
                 try {
                     validate_password($record['password']);
                 } catch (RegistrationException $r) {
                     $create = false;
                     $messages[] = $r->getMessage();
                 }
             }
         }
         $record['__upload_users_messages'] = $messages;
         $record['__upload_users_status'] = false;
         if ($create || $update) {
             $record['__upload_users_status'] = true;
         }
         $this->records->queue[] = $record;
     }
 }
开发者ID:arckinteractive,项目名称:upload_users,代码行数:88,代码来源:UploadUsers.php

示例14: save

 /**
  * Save the guest book
  *
  * @access public
  * @return void
  */
 public function save()
 {
     //validate title
     $title = $this->input->post('title');
     if (!empty($title)) {
         $data['title'] = $this->security->xss_clean($title);
     } else {
         $this->message_stack->add('guestbook', lang('field_guestbook_title_error'));
     }
     //validate email
     $email = $this->input->post('email');
     if (!empty($email) && validate_email_address($email)) {
         $data['email'] = $this->security->xss_clean($email);
     } else {
         $this->message_stack->add('guestbook', lang('field_guestbook_email_error'));
     }
     //validate content
     $content = $this->input->post('content');
     if (!empty($content)) {
         $data['content'] = $this->security->xss_clean($content);
     } else {
         $this->message_stack->add('guestbook', lang('field_guestbook_content_error'));
     }
     //url
     $url = $this->input->post('url');
     $data['url'] = $this->security->xss_clean($url);
     if ($this->message_stack->size('guestbook') === 0) {
         if ($this->guestbooks_model->save($data)) {
             $this->message_stack->add_session('guestbook', lang('success_guestbook_saved'), 'success');
             redirect(site_url('info/guestbooks'));
         }
     } else {
         $this->template->build('info/guestbook_add');
     }
 }
开发者ID:colonia,项目名称:tomatocart-v2,代码行数:41,代码来源:guestbooks.php

示例15: apiController

/**
 * the main apiController function that outputs json_encoded results
 * @param $path
 * @param $request
 * @param $files
 */
function apiController($path, $request, $files = null)
{
    global $dao, $smarty;
    list($reqPath, $queryString) = explode('?', $path);
    $pathParts = explode('/', substr($reqPath, 1));
    list($action) = $pathParts;
    Log::getInstance()->log("Reached server");
    Log::getInstance()->log("{$path} , {$request}");
    if ($action != "addExpeditionPoint" && $action != "getDeviceByAuthKey") {
        $log = Log::getInstance();
        $log->log("{$action}");
        $log->log("{$path}, {$request}");
    }
    $authKey = $request["authKey"];
    if ($action != "isreachable" && $action != "login" && $action != "registerUser" && $action != "registerDevice" && $action != "getPendingDeviceStatus" && !$authKey) {
        $response = array("errorCode" => ERR_AUTHKEY_MISSING, "errorMessage" => "You must provide an authentication key with each request.");
        echo json_encode($response);
        die;
    }
    if ($action != isreachable && $action != "login" && $action != "registerUser") {
        $device = $dao->getDeviceByAuthKey($authKey);
        if ($action != "registerDevice" && $action != "getPendingDeviceStatus" && !$device) {
            $response = errorResponseCode(ERR_AUTHKEY_INVALID, "Invalid authentication key.");
            echo json_encode($response);
            die;
        }
        $deviceUserId = $device["user_id"];
        $deviceIdentifier = $device["imei"];
    }
    switch ($action) {
        case 'isreachable':
            jsonMessage(AUTHN_OK, "The server is reachable");
            break;
        case 'login':
            extract($request);
            Log::getInstance()->log("Login = {$request} email={$email} imei={$imei}");
            if (!$email) {
                jsonError(ERR_EMAIL_MISSING, "Email Address is required");
            } else {
                if (!validate_email_address($email)) {
                    jsonError(ERR_EMAIL_INVALID, "Email Address is invalid");
                }
            }
            if (!$password) {
                jsonError(ERR_PASSWORD_MISSING, "Password is required");
            }
            // NOTE: Tablets don't have imei.  So this will only work for phones.
            //			if (!$imei){
            //				jsonError(ERR_IMEI_MISSING, "IMEI Code is required");
            //			}
            if ($login = $dao->checkLogin($email, $password)) {
                $authKey = genAuthKey();
                $userId = $login["id"];
                if ($dao->registerDevicePending($userId, $authKey)) {
                    jsonMessage(AUTHN_OK, $authKey);
                } else {
                    jsonError(ERR_SERVER, "Authentication Key cannot be generated");
                }
            } else {
                jsonError(AUTHN_FAILED, "Authentication failed. Please Check email address or password.");
            }
            break;
        case 'registerUser':
            extract($request);
            if (!$email) {
                jsonError(ERR_EMAIL_MISSING, "Email Address is required");
            } else {
                if (!validate_email_address($email)) {
                    jsonError(ERR_EMAIL_INVALID, "Email Address is invalid");
                }
            }
            if (!$firstname) {
                jsonError(ERR_FIRSTNAME_MISSING, "Firstname is required");
            }
            if (!$lastname) {
                jsonError(ERR_LASTNAME_MISSING, "LastName is required");
            }
            if (strlen($password1) < 6) {
                jsonError(ERR_PASSWORD1_INVALID, "Password must be 6 characters or longer");
            }
            if ($password1 != $password2) {
                jsonError(ERR_PASSWORD_UNMATCHED, "Passwords must match");
            }
            $newUser = array($email, $firstname, $lastname, $password1);
            $result = $dao->registerUser($newUser);
            if ($result === REGISTRATION_EMAILEXISTS) {
                jsonError(ERR_EMAIL_INVALID, "Email already exists");
            }
            $smarty->assign('link', SERVER_BASE_URI . "/web/verifyEmail?email={$email}");
            sendEmail($email, "email verification", $smarty->fetch("emails/new_user.tpl"));
            jsonMessage(AUTHN_OK, "Registration Successful");
            break;
        case 'getDeltaFindsIds':
            echo $dao->getDeltaFindsIds($authKey, $request["projectId"]);
//.........这里部分代码省略.........
开发者ID:Raconeisteron,项目名称:posit-mobile.web,代码行数:101,代码来源:api.php


注:本文中的validate_email_address函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。