Пример #1
0
function read($fname)
{
    $xls = PHPExcel_IOFactory::load($fname);
    $xls->setActiveSheetIndex(0);
    $sheet = $xls->getActiveSheet();
    $nRow = $sheet->getHighestRow();
    $nColumn = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn());
    $arr = [];
    for ($i = 1; $i <= $nRow; $i++) {
        for ($j = 0; $j <= $nColumn; $j++) {
            $row[$j] = trim($sheet->getCellByColumnAndRow($j, $i)->getValue());
        }
        if ($row[0] != '') {
            $pass = generate_password(6);
            $var = explode(' ', trim($row[0]));
            $fio = array();
            foreach ($var as $word) {
                if ($word != '') {
                    $fio[] = trim($word);
                }
            }
            $fam = $fio[0];
            $name = $fio[1];
            $otch = $fio[2];
            $email = trim($row[1]);
            $ou = trim($row[2]);
            $arr[] = ['fam' => $fam, 'name' => $name, 'otch' => $otch, 'email' => $email, 'phone' => '', 'login' => getLogin($fam, $name, $otch), 'password' => $pass, 'password_md5' => md5($pass), 'mr' => '', 'ou' => $ou];
        } else {
        }
    }
    return $arr;
}
Пример #2
0
 function perform($edit = array())
 {
     $fields = array();
     if (validate_nonblank($edit['username'])) {
         $fields['username'] = $edit['username'];
     }
     if (validate_nonblank($edit['email'])) {
         $fields['email'] = $edit['email'];
     }
     if (count($fields) < 1) {
         error_exit("You must supply at least one of username or email address");
     }
     /* Now, try and find the user */
     $user = Person::load($fields);
     /* Now, we either have one or zero users.  Regardless, we'll present
      * the user with the same output; that prevents them from using this
      * to guess valid usernames.
      */
     if ($user) {
         /* Generate a password */
         $pass = generate_password();
         $user->set_password($pass);
         if (!$user->save()) {
             error_exit("Error setting password");
         }
         /* And fire off an email */
         $rc = send_mail($user, false, false, _person_mail_text('password_reset_subject', array('%site' => variable_get('app_name', 'Leaguerunner'))), _person_mail_text('password_reset_body', array('%fullname' => "{$user->firstname} {$user->lastname}", '%username' => $user->username, '%password' => $pass, '%site' => variable_get('app_name', 'Leaguerunner'))));
         if ($rc == false) {
             error_exit("System was unable to send email to that user.  Please contact system administrator.");
         }
     }
 }
 function generate_password($min_length = 8, $initials_required = 1, $caps_required = 1, $nums_required = 1)
 {
     $length = $min_length;
     $req_length = $initials_required + $caps_required + $nums_required;
     if ($req_length > $length) {
         //If the combined number of required chars exceed the length of the password, increase the password length.
         $length = $req_length;
     }
     $passwd = '';
     //Define the characters table
     $chars[0] = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
     $chars[1] = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
     $chars[2] = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
     $counter = array(0 => 0, 1 => 0, 2 => 0);
     //Keeps track of how many times each class has been used
     for ($i = 0; $i < $length; $i++) {
         $r = rand(0, 2);
         //Find a random chartype (initial,capital,numeric)
         $counter[$r]++;
         //Increase the given counter
         $char = $chars[$r][rand(0, count($chars[$r]))];
         //Find a char from the array
         $passwd .= $char;
         //assign the char to the password string
     }
     if ($counter[0] >= $initials_required && $counter[1] >= $caps_required && $counter[2] >= $nums_required) {
         //Test if the password string contains the number of charactes defined.
         return $passwd;
     } else {
         //Try again
         return generate_password($length, $initials_required, $caps_required, $nums_required);
     }
 }
Пример #4
0
 protected function generate_password($length = 9, $strength = 4)
 {
     if (defined('STRICT_TYPES') && CAMEL_CASE == '1') {
         return (string) self::parameters(['length' => DT::UINT8, 'strength' => DT::UINT8])->call(__FUNCTION__)->with($length, $strength)->returning(DT::STRING);
     } else {
         return (string) generate_password($length, $strength);
     }
 }
Пример #5
0
 /**
  * *
  * * @return mixed
  * */
 function create_member()
 {
     $this->form_validation->set_rules('username', 'User name', 'trim|required|min_length[4]|is_unique[user.username]');
     $this->form_validation->set_rules('password', 'Password', 'required');
     $this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email|is_unique[user.primary_email]');
     $this->form_validation->set_message('is_unique', 'The %s is already taken! Please choose another.');
     $this->form_validation->set_error_delimiters('<div style="margin:1%" class="alert alert-error"><strong>', '</strong></div>');
     $this->form_validation->set_rules('membership', 'Membership', 'required');
     $this->form_validation->set_rules('term_condition', 'Terms & Condition', 'required');
     if ($this->form_validation->run() == TRUE) {
         $username = $this->input->post('username');
         $pass = generate_password();
         $email = $this->input->post('email');
         $color2 = $this->input->post('color2');
         $membership_amt = $this->input->post('membership');
         $data_to_store = array('date_of_registration' => date("Y-m-d H:i:s"), 'username' => $username, 'password' => md5($pass), 'firstname' => $this->input->post('username'), 'primary_email' => $email, 'color' => $this->input->post('color'), 'color2' => isset($color2) ? $color2 : "", 'term_condition' => $this->input->post('term_condition'), 'membership' => $membership_amt, 'status' => 'Inactive');
         $uid = $this->user_model->store_user($data_to_store);
         $this->load->helper('email');
         $this->load->library('email');
         if (valid_email($email)) {
             // compose email
             $this->email->clear(TRUE);
             $get_admin_detail = get_admin_detail();
             //common helper function for admin detail
             $this->email->from($get_admin_detail['email'], $get_admin_detail['name']);
             $this->email->to($email);
             $this->email->set_mailtype("html");
             $this->email->subject('Register Confirmation for StacksGuide Account!');
             $mail_data['url'] = site_url() . 'payment/payment_send/' . $uid . '/' . encrypt($membership_amt);
             $message = $this->load->view('mail_templates/stacks_signup_mail', $mail_data, true);
             $this->email->message($message);
             // try send mail ant if not able print debug
             if (!$this->email->send()) {
                 $msgadd = "<strong>E-mail not sent </strong>";
                 //.$this->email->print_debugger();
                 $data['flash_message'] = TRUE;
                 $this->session->set_flashdata('flash_class', 'alert-error');
                 $this->session->set_flashdata('flash_message', $msgadd);
                 redirect('home');
             } else {
                 $msgadd = "<strong>Please check your Email</strong>";
                 //.$this->email->print_debugger();
                 $data['flash_message'] = TRUE;
                 $this->session->set_flashdata('flash_class', 'alert-error');
                 $this->session->set_flashdata('flash_message', $msgadd);
                 redirect('home');
             }
         }
         //redirect("payment/payment_send/$uid/$membership_amt");
     }
     //        else {
     //
     //            $this->session->set_flashdata('validation_error_messages', validation_errors());
     //            redirect('signup');
     //        }
     $data['main_content'] = 'signup_view';
     $this->load->view('includes/template', $data);
 }
Пример #6
0
 public static function turn_on($message = null, $key = null)
 {
     if (!$key) {
         $key = generate_password(16);
     }
     self::turn_off();
     self::generate_file($key, $message);
     return $key;
 }
Пример #7
0
 public function generate_update_login_id($user_name, $length, $user_id)
 {
     $user_name_subStr = substr($user_name, 0, $length);
     $randomNuber = rand(10, 5000);
     $user_data['login_id'] = $user_login_type . $user_name_subStr . $user_id . $randomNuber;
     $user_data['password'] = generate_password(8);
     $condition['student_Id'] = $student_Id;
     $condition['user_login_type'] = 'S';
     $data['user'] = $user_data;
     $data['condition'] = $condition;
     $this->update_id_pass($data);
 }
Пример #8
0
 public function signup()
 {
     // TODO validate
     $password = generate_password();
     $user = Sentry::register(array('email' => Input::get('email'), 'password' => $password, 'username' => Input::get('name') . '.' . Input::get('last_name') . '.' . Input::get('second_last_name') . '.' . rand(1, 10)));
     $student_data = Input::all();
     $student_data['user_id'] = $user->id;
     $this->repository->store($student_data);
     Mail::queue('emails.courses.verification', ['student' => Input::except('photo'), 'password' => $password, 'activation_code' => $user->getActivationCode()], function ($message) {
         $message->to(Input::get('email'), Input::get('name'))->subject('Filmoteca UNAM: Verificación de email');
     });
 }
 /**
  * Returns success or failure
  *
  * @return bool success or failure
  */
 public static function process_magento_request($order_number, $customer, $moodle_courses)
 {
     global $USER, $DB;
     if (get_config('magentoconnector', 'magentoconnectorenabled') == 0) {
         return false;
     }
     $params = self::validate_parameters(self::process_magento_request_parameters(), array('order_number' => $order_number, 'customer' => $customer, 'moodle_courses' => $moodle_courses));
     $context = context_user::instance($USER->id);
     self::validate_context($context);
     if (!($user = $DB->get_record('user', array('email' => $customer['email'])))) {
         $user = new stdClass();
         $user->firstname = $customer['firstname'];
         $user->lastname = $customer['lastname'];
         $user->email = $customer['email'];
         $user->city = $customer['city'];
         $user->country = $customer['country'];
         $user->confirmed = 1;
         $user->policyagreed = 1;
         $user->mnethostid = 1;
         $user->username = local_magentoconnector_generate_username($customer['firstname'], $customer['lastname']);
         $user->timecreated = time();
         $password = generate_password();
         $user->password = hash_internal_user_password($password);
         $userid = $DB->insert_record('user', $user);
     } else {
         $userid = $user->id;
     }
     $roleid = $DB->get_field('role', 'id', array('shortname' => LOCAL_MAGENTOCONNECTOR_STUDENT_SHORTNAME));
     $enrol = enrol_get_plugin('magento');
     foreach ($moodle_courses as $moodle_course) {
         if ($course = $DB->get_record('course', array('idnumber' => $moodle_course['course_id']))) {
             $enrolinstance = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => 'magento'), '*', MUST_EXIST);
             $enrol->enrol_user($enrolinstance, $userid, $roleid);
             $record = new stdClass();
             $record->userid = $userid;
             $record->ordernum = $order_number;
             $record->courseid = $course->id;
             $record->timestamp = time();
             $DB->insert_record('local_magentoconnector_trans', $record);
         } else {
             // no such course ... ?
         }
     }
     if (isset($password)) {
         $enrolinstance->newusername = $user->username;
         $enrolinstance->newaccountpassword = $password;
     }
     $customer = $DB->get_record('user', array('id' => $userid));
     $enrol->email_welcome_message($enrolinstance, $customer);
     return true;
 }
Пример #10
0
function author_save_new()
{
    extract(doSlash(psa(array('privs', 'name', 'email', 'RealName'))));
    $pw = generate_password(6);
    $nonce = md5(uniqid(rand(), true));
    if ($name) {
        $rs = safe_insert("txp_users", "privs    = '{$privs}',\n\t\t\t\t name     = '{$name}',\n\t\t\t\t email    = '{$email}',\n\t\t\t\t RealName = '{$RealName}',\n\t\t\t\t pass     =  password(lower('{$pw}')),\n\t\t\t\t nonce    = '{$nonce}'");
    }
    if ($rs) {
        send_password($pw, $email);
        admin(gTxt('password_sent_to') . sp . $email);
    } else {
        admin(gTxt('error_adding_new_author'));
    }
}
Пример #11
0
function reset_author_pass($name)
{
    $email = safe_field('email', 'txp_users', "name = '" . doSlash($name) . "'");
    $new_pass = doSlash(generate_password(6));
    $rs = safe_update('txp_users', "pass = password(lower('{$new_pass}'))", "name = '" . doSlash($name) . "'");
    if ($rs) {
        if (send_new_password($new_pass, $email, $name)) {
            return gTxt('password_sent_to') . ' ' . $email;
        } else {
            return gTxt('could_not_mail') . ' ' . $email;
        }
    } else {
        return gTxt('could_not_update_author') . ' ' . htmlspecialchars($name);
    }
}
Пример #12
0
function reset_author_pass($name)
{
    $email = safe_field('email', 'txp_users', "name = '" . doSlash($name) . "'");
    $new_pass = generate_password(PASSWORD_LENGTH);
    $hash = doSlash(txp_hash_password($new_pass));
    $rs = safe_update('txp_users', "pass = '******'", "name = '" . doSlash($name) . "'");
    if ($rs) {
        if (send_new_password($new_pass, $email, $name)) {
            return gTxt('password_sent_to') . ' ' . $email;
        } else {
            return gTxt('could_not_mail') . ' ' . $email;
        }
    } else {
        return gTxt('could_not_update_author') . ' ' . txpspecialchars($name);
    }
}
Пример #13
0
function reset_user_password($username)
{
    /* resets the password for the user with the username $username, and sends it
     * to him/her via email */
    global $CFG;
    /* load up the user record */
    $user = sql_getUserdataFromUsername($username);
    /* reset the password */
    $newpassword = generate_password();
    sql_setUserpasswd($username, $newpassword);
    /* email the user with the new account information */
    $var = new Object();
    $var->username = $username;
    $var->fullname = $user->Firstname . " " . $user->Lastname;
    $var->newpassword = $newpassword;
    $var->support = $CFG->support;
    $emailbody = read_template("{$CFG->templatedir}/email/reset_password.php", $var);
    mail("{$var->fullname} <{$user->Email}>", "OTMP Account Information", $emailbody, "From: {$var->support}");
}
function get_meeting_pin($length, $meeting_uuid)
{
    global $db;
    $pin = generate_password($length, 1);
    $sql = "select count(*) as num_rows from v_meetings ";
    $sql .= "where domain_uuid = '" . $_SESSION['domain_uuid'] . "' ";
    //$sql .= "and meeting_uuid <> '".$meeting_uuid."' ";
    $sql .= "and (moderator_pin = '" . $pin . "' or participant_pin = '" . $pin . "') ";
    $prep_statement = $db->prepare(check_sql($sql));
    if ($prep_statement) {
        $prep_statement->execute();
        $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
        if ($row['num_rows'] == 0) {
            return $pin;
        } else {
            get_meeting_pin($length, $uuid);
        }
    }
}
Пример #15
0
function send_newpassword($email, $current_ip)
{
    /* get the Client and set the new password */
    $client = User::get_from_email($email);
    if ($client && $client->email == $email) {
        $newpassword = generate_password(6);
        $client->update_password($newpassword);
        $mailer = new Mailer();
        $mailer->set_default_sender();
        $mailer->subject = T_("Lost Password");
        $mailer->recipient_name = $client->fullname;
        $mailer->recipient = $client->email;
        $message = sprintf(T_("A user from %s has requested a password reset for '%s'."), $current_ip, $client->username);
        $message .= "\n";
        $message .= sprintf(T_("The password has been set to: %s"), $newpassword);
        $mailer->message = $message;
        return $mailer->send();
    }
    return false;
}
    private function __app_reset_password_and_mail($user)
    {
        global $CFG;
        $site = get_site();
        $supportuser = generate_email_supportuser();
        $userauth = get_auth_plugin($user->auth);
        if (!$userauth->can_reset_password() or !is_enabled_auth($user->auth)) {
            trigger_error("Attempt to reset user password for user {$user->username} with Auth {$user->auth}.");
            return false;
        }
        $newpassword = generate_password();
        if (!$userauth->user_update_password($user, $newpassword)) {
            $error->error = true;
            $error->msg = 'fp_passwordgen_failure';
            echo json_encode($error);
            die;
        }
        $a = new stdClass();
        $a->firstname = $user->firstname;
        $a->lastname = $user->lastname;
        $a->sitename = format_string($site->fullname);
        $a->username = $user->username;
        $a->newpassword = $newpassword;
        //$a->signoff = generate_email_signoff();
        $message = 'Hi ' . $a->firstname . ',

Your account password at \'' . $a->sitename . '\' has been reset
and you have been issued with a new temporary password.

Your current login information is now:
   username: '******'
   password: '******'

Cheers from the \'' . $a->sitename . '\' administrator.';
        //$message = get_string('newpasswordtext', '', $a);
        $subject = format_string($site->fullname) . ': ' . get_string('changedpassword');
        unset_user_preference('create_password', $user);
        // prevent cron from generating the password
        //directly email rather than using the messaging system to ensure its not routed to a popup or jabber
        return email_to_user($user, $supportuser, $subject, $message);
    }
Пример #17
0
 public function _EM_change_password()
 {
     $old_password = I('post.old_password');
     $new_password = I('post.new_password');
     $user_id = I('get.id');
     if (!$user_id || $user_id != get_current_user_id()) {
         return $this->error(__('account.Params Error'));
     }
     if (!$old_password || !$new_password) {
         return $this->error(__('account.Every item is required'));
     }
     $user_service = D('Account/User');
     $user = $user_service->where(['id' => $user_id])->find();
     list($old_hashed_password) = generate_password($old_password, $user['rand_hash']);
     if ($old_hashed_password !== $user['password']) {
         return $this->error(__('account.Old password not equal to saved'));
     }
     list($new_password_hashed, $new_hash) = generate_password($new_password);
     $user_service->where(['id' => $user_id])->save(['password' => $new_password_hashed, 'rand_hash' => $new_hash]);
     $this->logout();
 }
Пример #18
0
function update_profile($email, $password = NULL, $home = NULL)
{
    $query_profile = "SELECT * FROM users";
    $profile = mysql_query($query_profile) or die(mysql_error());
    $row_profile = mysql_fetch_assoc($profile);
    if ($home == NULL) {
        $home = $row_profile['user_home'];
    }
    if ($password) {
        $password_salt = time();
        $password = generate_password($password, $password_salt);
    } else {
        $password = $row_profile['user_password'];
        $password_salt = $row_profile['user_salt'];
    }
    mysql_query("UPDATE users SET \n    user_email = '" . mysql_real_escape_string(trim($email)) . "', \n    user_password = '******', \n    user_salt = '" . mysql_real_escape_string(trim($password_salt)) . "', \n    user_home = '" . mysql_real_escape_string(trim($home)) . "' \n    WHERE user_email = '" . mysql_real_escape_string(trim($email)) . "'");
    if (mysql_error()) {
        die(mysql_error());
    }
    return mysql_affected_rows();
}
Пример #19
0
 /**
  * Interactive
  *
  * @access private
  */
 function __handle($address, $password = NULL, $random = false)
 {
     if ($random == true) {
         $password = generate_password();
     }
     if ($password != NULL) {
         $handler = new MailboxHandler();
         if (!$handler->init($address)) {
             $this->error("Change Password", join("\n", $handler->errormsg));
         }
         if (!$handler->change_pw($password, NULL, false)) {
             $this->error("Change Password", join("\n", $handler->errormsg));
         }
     }
     $this->out("");
     $this->out("Password updated.");
     $this->hr();
     $this->out(sprintf('The Mail address is  %20s', $address));
     $this->out(sprintf('The new password is %20s', $password));
     $this->hr();
     return;
 }
Пример #20
0
 /**
  * - compare password / password2 field (error message will be displayed at password2 field)
  * - autogenerate password if enabled in config and $new
  * - display password on $new if enabled in config or autogenerated
  */
 protected function _validate_password($field, $val)
 {
     if (!$this->_validate_password2($field, $val)) {
         return false;
     }
     if ($this->new && Config::read('generate_password') == 'YES' && $val == '') {
         # auto-generate new password
         unset($this->errormsg[$field]);
         # remove "password too short" error message
         $val = generate_password();
         $this->values[$field] = $val;
         # we are doing this "behind the back" of set()
         $this->infomsg[] = Config::Lang('password') . ": {$val}";
         return false;
         # to avoid that set() overwrites $this->values[$field]
     } elseif ($this->new && Config::read('show_password') == 'YES') {
         $this->infomsg[] = Config::Lang('password') . ": {$val}";
     }
     return true;
     # still here? good.
 }
Пример #21
0
 $regmessage = "Добро пожаловать, " . $logs . " \nТеперь вы зарегистрированный пользователь сайта " . $config['home'] . " , сохраните ваш пароль и логин в надежном месте, они вам еще пригодятся. \nВаши данные для входа на сайт \nЛогин: " . $logs . " \nПароль: " . $pars . " \n\nСсылка для автоматического входа на сайт: \n" . $config['home'] . "/input.php?login="******"&pass="******" \nНадеемся вам понравится на нашем портале! \nС уважением администрация сайта \nЕсли это письмо попало к вам по ошибке, то просто проигнорируйте его \n\n";
 if ($config['regkeys'] == 1) {
     $registration_key = generate_password();
     echo '<b><span style="color:#ff0000">Внимание! После входа на сайт, вам будет необходимо ввести мастер-ключ для подтверждения регистрации<br />';
     echo 'Мастер-ключ был выслан вам на почтовый ящик: ' . $meil . '</span></b><br /><br />';
     $regmessage .= "Внимание! \nДля подтверждения регистрации необходимо в течении 24 часов ввести мастер-ключ! \nВаш мастер-ключ: " . $registration_key . " \nВведите его после авторизации на сайте \nИли перейдите по прямой ссылке: \n\n" . $config['home'] . "/pages/key.php?act=inkey&key=" . $registration_key . " \n\nЕсли в течении 24 часов вы не подтвердите регистрацию, ваш профиль будет автоматически удален";
 }
 if ($config['regkeys'] == 2) {
     echo '<b><span style="color:#ff0000">Внимание! Ваш аккаунт будет активирован только после проверки администрацией!</span></b><br /><br />';
     $regmessage .= "Внимание! \nВаш аккаунт будет активирован только после проверки администрацией! \nПроверить статус активации вы сможете после авторизации на сайте";
 }
 // Активация пригласительного ключа
 if (!empty($config['invite'])) {
     DB::run()->query("UPDATE `invite` SET `used`=?, `invited`=? WHERE `key`=? LIMIT 1;", array(1, $logs, $invite));
 }
 $registration = DBM::run()->insert('users', array('users_login' => $logs, 'users_pass' => md5(md5($pars)), 'users_email' => $meil, 'users_joined' => SITETIME, 'users_level' => 107, 'users_gender' => $gender, 'users_themes' => 0, 'users_postguest' => $config['bookpost'], 'users_postnews' => $config['postnews'], 'users_postprivat' => $config['privatpost'], 'users_postforum' => $config['forumpost'], 'users_themesforum' => $config['forumtem'], 'users_postboard' => $config['boardspost'], 'users_point' => 0, 'users_money' => $config['registermoney'], 'users_timelastlogin' => SITETIME, 'users_confirmreg' => $config['regkeys'], 'users_confirmregkey' => $registration_key, 'users_navigation' => $config['navigation'], 'users_subscribe' => generate_password(32)));
 // ------------------------------ Уведомление в приват ----------------------------------//
 $textpriv = text_private(1, array('%USERNAME%' => $logs, '%SITENAME%' => $config['home']));
 send_private($logs, $config['nickname'], $textpriv);
 if (!empty($config['regmail'])) {
     sendMail($meil, 'Регистрация на сайте ' . $config['title'], nl2br($regmessage));
 }
 // ----------------------------------------------------------------------------------------//
 $_SESSION['reguser'] = 1;
 echo 'Вы удачно зарегистрированы!<br /><br />';
 echo 'Логин: <b>' . $logs . '</b><br />';
 echo 'Пароль: <b>' . $pars . '</b><br /><br />';
 echo 'Теперь вы можете войти<br />';
 echo '<br /><img src="/images/img/open.gif" alt="image" /> ';
 echo '<b><a href="/input.php?login='******'&amp;pass='******'">Вход на сайт</a></b><br /><br />';
 echo 'Вы можете сделать закладку для быстрого входа:<br />';
Пример #22
0
 /**
  * The ProcessNewOrderNotification function is a shell function for 
  * handling a <new-order-notification>. You will need to modify this 
  * function to transfer the information contained in a 
  * <new-order-notification> to your internal systems that process that data.
  *
  * @param    $xml_response    asynchronous notification XML DOM
  */
 function ProcessNewOrderNotification($dom_data_root, $sn)
 {
     /*
      * +++ CHANGE ME +++
      * New order notifications inform you of new orders that have
      * been submitted through Google Checkout. A <new-order-notification>
      * message contains a list of the items in an order, the tax
      * assessed on the order, the shipping method selected for the
      * order and the shipping address for the order.
      *
      * If you are implementing the Notification API, you need to
      * modify this function to relay the information in the
      * <new-order-notification> to your internal systems that
      * process this order data.
      */
     global $db;
     $this->LogMessage("Google Checkout: New Order Notification #" . $dom_data_root['google-order-number'], $debug_only_msg = false);
     //$this->LogMessage ("DEBUG: [".serialize($dom_data_root)."]");
     $cart = $dom_data_root['shopping-cart'];
     $payment_id = $cart['merchant-private-data']['payment-id'];
     $memeber_id = $cart['merchant-private-data']['memeber-id'];
     $payments = array();
     if ($payment_id) {
         $payments[] = $payment_id;
     }
     $buyer = $dom_data_root['buyer-billing-address'];
     $email = trim($buyer['email']);
     $users = $db->users_find_by_string($email, 'email', $exact = 1);
     if (!$memeber_id && !$payment_id && $this->_allow_create) {
         // create new member/subscription
         if (!$users && check_email($email)) {
             // No member exists. Create new account.
             $name_f = trim($buyer['structured-name']['first-name']);
             $name_l = trim($buyer['structured-name']['last-name']);
             if (!$name_f && !$name_l) {
                 list($name_f, $name_l) = @explode(" ", $buyer['contact-name']);
             }
             $address = $buyer['address1'];
             $city = $buyer['city'];
             $zip = $buyer['postal-code'];
             $state = $buyer['region'];
             $country = $buyer['country-code'];
             $phone = $buyer['phone'];
             $v = array('email' => $email, 'name_f' => $name_f, 'name_l' => $name_l, 'address' => $address, 'city' => $city, 'zip' => $zip, 'state' => $state, 'country' => $country);
             $v['login'] = generate_login($v);
             $v['pass'] = generate_password($v);
             $member_id = $db->add_pending_user($v);
             // and add payment(s)
             foreach ((array) $dom_data_root['shopping-cart']['items'] as $item) {
                 $products = $db->get_products_list();
                 foreach ($products as $pr) {
                     if ($pr['google_merchant_item_id'] != '' && $pr['google_merchant_item_id'] == $item['merchant-item-id']) {
                         $product_id = $pr['product_id'];
                         $product = $db->get_product($product_id);
                         $price = $product['price'];
                         $begin_date = date("Y-m-d");
                         $duration = $this->get_days($product['expire_days']) * 3600 * 24;
                         $expire_date = date('Y-m-d', time() + $duration);
                         $payment_id = $db->add_waiting_payment($member_id, $product_id, $paysys_id = 'google_checkout', $price, $begin_date, $expire_date, $vars, $additional_values = false);
                         if ($payment_id) {
                             $payments[] = $payment_id;
                         }
                     }
                 }
             }
         }
     }
     //$member  = $db->get_user($memeber_id);
     foreach ($payments as $payment_id) {
         $q = $db->query($s = "UPDATE {$db->config['prefix']}payments\n                    SET receipt_id = '" . $db->escape($dom_data_root['google-order-number']) . "'\n                    WHERE payment_id='{$payment_id}'\n                    ");
         $payment = $db->get_payment($payment_id);
         $payment['receipt_id'] = $dom_data_root['google-order-number'];
         $payment['data']['google-order-number'] = $dom_data_root['google-order-number'];
         $payment['data']['fulfillment-order-state'] = $dom_data_root['fulfillment-order-state'];
         $payment['data']['financial-order-state'] = $dom_data_root['financial-order-state'];
         $err = $db->update_payment($payment_id, $payment);
         if ($err) {
             $this->LogMessage($err, $debug_only_msg = false);
         }
     }
     $this->SendNotificationAcknowledgment($sn);
 }
Пример #23
0
'y','z','A','B','C','D',
'E','F','G','H','I','J',
'K','L','M','N','O','P',
'Q','R','S','T','U','V',
'W','X','Y','Z','1','2',
'3','4','5','6','7','8',
'9','0');
// Генерируем пароль
$pass = "";
for($i = 0; $i < $number; $i++){// Вычисляем случайный индекс массива
$index = rand(0, count($arr) - 1);
$pass .= $arr[$index];
}
return $pass;
}
$pass=generate_password($num);
$password = md5($pass);
 if ($_POST['vindex'] == 'on') {$vindex = 1; } else {$vindex = 0;};
$send = mysql_query("INSERT INTO users VALUES(NULL,'"._filter($name)."','"._filter($password)."','"._filter($vindex)."')");

if ($send == 'true')
{
?>
Пользователь добавлен! Его логин - <?=$name?>, пароль - <?=$pass?>
<?
exit;
}

else 

{
require_once 'connect.php';
$result = "";
$items = '';
$mail_info_sent = false;
$password = '';
//if a program director is being sent information
if (isset($_REQUEST['pd'])) {
    $qry = "SELECT * FROM  `tblapproveduserlist` WHERE  `EmailAddress` LIKE  (SELECT EmailAddress FROM `tblprogramdirectors` WHERE `tblprogramdirectors`.CustomerID='0' AND `tblprogramdirectors`.ShipToID='0' AND `tblprogramdirectors`.EEStatus!='A' AND `tblprogramdirectors`.`ProgramDirectorsID`='" . $mysqli->real_escape_string($_REQUEST['pd']) . "')";
    $result_data = $mysqli->query($qry) or die($mysqli->error . ' ' . $qry);
    if ($result_data->num_rows > 0) {
        $result_data_array = $result_data->fetch_assoc();
        $to = $result_data_array['EmailAddress'];
        $subject = "Parts Ordering:: Your profile has been Updated";
        //Program Director
        //CustomerServiceNow@TekkiesU.com
        $password = generate_password();
        $message = "\n                <html>\n                <head><title>SECHRIST INDUSTRIES,INC.</title></head>\n                <body>\n                <p>An administrative from the Customer Service have updated your profile details. <br><br>Your newly generated password is <u style='border:1px solid gray;background-color:gray;color:#FFF'>" . $password . "</u><br><br> If you have additional questions or concerns regarding account please call or email Customer Service at (714) 555-1212 and CustomerServiceNow@TekkiesU.com</p>\n                <table style='border-collapse: collapse;'><tr style='background-color: #DEE0EC;'></tr></table>\n                <p><a href='" . SITE_PATH . "'>Click here</a> to visit your dashboard.</p>\n                </body>\n                </html>\n                ";
        //Program Director
        // Always set content-type when sending HTML email
        $headers = "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
        // More headers
        $headers .= 'From: <*****@*****.**>' . "\r\n";
        $headers .= 'Bcc: WebSiteOrders@Sechristusa.com' . "\r\n";
        if (mail($to, $subject, $message, $headers)) {
            $mail_info_sent = true;
            //update query- activate program director and save added details in the database
            $updateQuery = "UPDATE `tblprogramdirectors` SET \n                    `Password`='" . $mysqli->real_escape_string($password) . "'\n                     WHERE `ProgramDirectorsID`=" . $_REQUEST['pd'] . ";";
            $mysqli->query($updateQuery);
            //run created query to feed data into mysql database
        }
Пример #25
0
function handle_user_insert(&$HTTP_VARS, &$errors)
{
    if (!is_user_valid($HTTP_VARS['user_id'])) {
        $HTTP_VARS['user_id'] = strtolower(filter_input_field("filtered(20,20,a-zA-Z0-9_.)", $HTTP_VARS['user_id']));
        if (!validate_input_field(get_opendb_lang_var('userid'), "filtered(20,20,a-zA-Z0-9_.)", "Y", $HTTP_VARS['user_id'], $errors)) {
            return FALSE;
        }
        if (validate_user_info(NULL, $HTTP_VARS, $address_provided_r, $errors)) {
            if ($HTTP_VARS['op'] == 'signup') {
                // no password saved when signing up, as user still must be activated
                $active_ind = 'X';
                // Will be reset when user activated
                $HTTP_VARS['pwd'] = NULL;
            } else {
                $active_ind = 'Y';
                if (strlen($HTTP_VARS['pwd']) == 0) {
                    if (is_valid_opendb_mailer()) {
                        $HTTP_VARS['pwd'] = generate_password(8);
                    } else {
                        $errors[] = array('error' => get_opendb_lang_var('passwd_not_specified'));
                        return FALSE;
                    }
                } else {
                    if ($HTTP_VARS['pwd'] != $HTTP_VARS['confirmpwd']) {
                        $errors[] = array('error' => get_opendb_lang_var('passwds_do_not_match'));
                        return FALSE;
                    }
                }
            }
            // We want to validate and perform inserts even in signup mode
            if (insert_user($HTTP_VARS['user_id'], $HTTP_VARS['fullname'], $HTTP_VARS['pwd'], $HTTP_VARS['user_role'], $HTTP_VARS['uid_language'], $HTTP_VARS['uid_theme'], $HTTP_VARS['email_addr'], $active_ind)) {
                $user_r = fetch_user_r($HTTP_VARS['user_id']);
                return update_user_addresses($user_r, $address_provided_r, $HTTP_VARS, $errors);
            } else {
                $db_error = db_error();
                $errors[] = array('error' => get_opendb_lang_var('user_not_added', 'user_id', $HTTP_VARS['user_id']), 'detail' => $db_error);
                return FALSE;
            }
        } else {
            return FALSE;
        }
    } else {
        $errors[] = array('error' => get_opendb_lang_var('user_exists', 'user_id', $HTTP_VARS['user_id']), 'detail' => '');
        return FALSE;
    }
}
Пример #26
0
     $reponse = "password and login should be at least 6 characters";
 } else {
     //encrypt password
     $password = md5($npassword);
     //check if username already taken
     $check = mysql_query("SELECT * FROM member WHERE username='******'");
     if (mysql_num_rows($check) >= 1) {
         $reponse = "Username already taken";
     } else {
         $checkemail = mysql_query("SELECT * FROM member WHERE email='{$email}'");
         if (mysql_num_rows($checkemail) >= 1) {
             $reponse = "email already taken";
         } else {
             //generate random code
             $code = generate_password(15);
             $initcode = generate_password(15);
             //send activation email
             $to = $email;
             $subject = "Activate your account";
             $headers = "From: " . WEBSIT_LINK;
             $body = "Hello {$username},\nYou registered and need to activate your account.Click the link below or paste it into the URL bar of your browser\n" . WEBSIT_LINK . "/activate.php?code={$code}\nThanks!.\n\r\n\t\t\t\t\t\t\t\t\t\tlogin   :{$username}\n\r\n\t\t\t\t\t\t\t\t\t\tpassword:{$npassword}\n";
             if (!mail($to, $subject, $body, $headers)) {
                 $reponse == "We couldn't sign you up at this time. Please try again later.";
             } else {
                 $img = "./img/user/0.jpg";
                 //register into database
                 $register = mysql_query("INSERT INTO member (username,password,img,email,code,initcode,etat,total) VALUES ('{$username}','{$password}','{$img}','{$email}','{$code}','{$initcode}','OK','0')");
                 if (!$register) {
                     $reponse = "erreur !!";
                 } else {
                     $reponse = "You have been registered successfully! Please check your email ({$email}) to activate your account";
Пример #27
0
function author_save_new()
{
    require_privs('admin.edit');
    extract(doSlash(psa(array('privs', 'name', 'email', 'RealName'))));
    $privs = assert_int($privs);
    if ($name && is_valid_email($email)) {
        $password = doSlash(generate_password(6));
        $nonce = doSlash(md5(uniqid(mt_rand(), TRUE)));
        $rs = safe_insert('txp_users', "\n\t\t\t\tprivs    = {$privs},\n\t\t\t\tname     = '{$name}',\n\t\t\t\temail    = '{$email}',\n\t\t\t\tRealName = '{$RealName}',\n\t\t\t\tnonce    = '{$nonce}',\n\t\t\t\tpass     = password(lower('{$password}'))\n\t\t\t");
        if ($rs) {
            send_password($RealName, $name, $email, $password);
            admin(gTxt('password_sent_to') . sp . $email);
            return;
        }
    }
    admin(gTxt('error_adding_new_author'));
}
Пример #28
0
 /**
  * Add new instance of enrol plugin with default settings.
  * @param stdClass $course
  * @return int id of new instance
  */
 public function add_default_instance($course)
 {
     $fields = $this->get_instance_defaults();
     if ($this->get_config('requirepassword')) {
         $fields['password'] = generate_password(20);
     }
     return $this->add_instance($course, $fields);
 }
function customer_update($event, $step)
{
    global $txp_user, $vars, $txpcfg, $prefs;
    extract($prefs);
    extract(doSlash($_REQUEST));
    $RealName = $billing_firstname . " " . $billing_lastname;
    $user_id = assert_int($user_id);
    if (!isset($shipping_same_as_billing)) {
        $shipping_same_as_billing = 0;
    } else {
        $shipping_same_as_billing = 1;
    }
    if (!function_exists("generate_password")) {
        require_once txpath . '/include/txp_admin.php';
    }
    if (!function_exists("is_valid_email")) {
        require_once txpath . '/lib/txplib_misc.php';
    }
    if ($name && is_valid_email($email)) {
        $password = doSlash(generate_password(6));
        $nonce = doSlash(md5(uniqid(rand(), true)));
        $rs = safe_update('txp_users', "\r\n\t\t\t\tprivs\t\t = 0,\r\n\t\t\t\tname\t\t = '{$name}',\r\n\t\t\t\temail\t\t = '{$email}',\r\n\t\t\t\tRealName = '{$RealName}',\r\n\t\t\t\tbilling_company = '{$billing_company}',\r\n\t\t\t\tbilling_address1 = '{$billing_address1}',\r\n\t\t\t\tbilling_address2 = '{$billing_address2}',\r\n\t\t\t\tbilling_city = '{$billing_city}',\r\n\t\t\t\tbilling_state = '{$billing_state}',\r\n\t\t\t\tbilling_zip = '{$billing_zip}',\r\n\t\t\t\tbilling_country = '{$billing_country}',\r\n\t\t\t\tbilling_fax = '{$billing_fax}',\r\n\t\t\t\tbilling_phone = '{$billing_phone}',\r\n\t\t\t\tshipping_same_as_billing = {$shipping_same_as_billing},\r\n\t\t\t\tshipping_company = '{$shipping_company}',\r\n\t\t\t\tshipping_address1 = '{$shipping_address1}',\r\n\t\t\t\tshipping_address2 = '{$shipping_address2}',\r\n\t\t\t\tshipping_city = '{$shipping_city}',\r\n\t\t\t\tshipping_state = '{$shipping_state}',\r\n\t\t\t\tshipping_zip = '{$shipping_zip}',\r\n\t\t\t\tshipping_country = '{$shipping_country}',\r\n\t\t\t\tshipping_fax = '{$shipping_fax}',\r\n\t\t\t\tshipping_phone = '{$shipping_phone}',\r\n\t\t\t\tshipping_firstname = '{$shipping_firstname}',\r\n\t\t\t\tshipping_lastname = '{$shipping_lastname}',\r\n\t\t\t\tbilling_firstname = '{$billing_firstname}',\r\n\t\t\t\tbilling_lastname = '{$billing_lastname}'", "user_id = {$user_id}");
        if ($rs) {
            customers_list('', '', "customer updated");
        } else {
            customers_list("There was an error trying to update customer");
        }
    }
}
Пример #30
0
 function user_add($username, $password, $user_email = '')
 {
     global $db, $domain_uuid, $v_salt;
     $user_uuid = uuid();
     if (strlen($username) == 0) {
         return false;
     }
     if (strlen($password) == 0) {
         return false;
     }
     if (!username_exists($username)) {
         //salt used with the password to create a one way hash
         $salt = generate_password('20', '4');
         //add the user account
         $user_type = 'Individual';
         $user_category = 'user';
         $sql = "insert into v_users ";
         $sql .= "(";
         $sql .= "domain_uuid, ";
         $sql .= "user_uuid, ";
         $sql .= "username, ";
         $sql .= "password, ";
         $sql .= "salt, ";
         if (strlen($user_email) > 0) {
             $sql .= "user_email, ";
         }
         $sql .= "add_date, ";
         $sql .= "add_user ";
         $sql .= ")";
         $sql .= "values ";
         $sql .= "(";
         $sql .= "'{$domain_uuid}', ";
         $sql .= "'{$user_uuid}', ";
         $sql .= "'{$username}', ";
         $sql .= "'" . md5($salt . $password) . "', ";
         $sql .= "'{$salt}', ";
         if (strlen($user_email) > 0) {
             $sql .= "'{$user_email}', ";
         }
         $sql .= "now(), ";
         $sql .= "'" . $_SESSION["username"] . "' ";
         $sql .= ")";
         $db->exec(check_sql($sql));
         unset($sql);
         //add the user to the member group
         $group_name = 'user';
         $sql = "insert into v_group_users ";
         $sql .= "(";
         $sql .= "group_user_uuid, ";
         $sql .= "domain_uuid, ";
         $sql .= "group_name, ";
         $sql .= "user_uuid ";
         $sql .= ")";
         $sql .= "values ";
         $sql .= "(";
         $sql .= "'" . uuid() . "', ";
         $sql .= "'{$domain_uuid}', ";
         $sql .= "'{$group_name}', ";
         $sql .= "'{$user_uuid}' ";
         $sql .= ")";
         $db->exec(check_sql($sql));
         unset($sql);
     }
     //end if !username_exists
 }