Esempio n. 1
0
 function forgot_mail($username, $email)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('login_forgotMail', array(&$username, &$email))) {
         return vivvo_hooks_manager::get_status();
     }
     if (isset($_SESSION['vivvo']['register_time']) && $_SESSION['vivvo']['register_time'] + 60 > VIVVO_START_TIME) {
         $this->set_error_code(2755);
         return false;
     }
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Users.class.php';
     $lang = vivvo_lang::get_instance();
     $user_list = new Users_list();
     if (!$username && !$email) {
         $this->set_error_code(2712);
         return false;
     } else {
         if ($username) {
             $user_list->search(array('search_username' => $username));
             $user = current($user_list->list);
         } elseif ($email) {
             $user_list->search(array('search_email_address' => $email));
             $user = current($user_list->list);
         }
         if ($user) {
             $search = array('(', ')', '<', '>', '@', ';', ':', '\\', '"', '.', '[', ']');
             $replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
             $vivvo_website_title = str_replace($search, $replace, VIVVO_WEBSITE_TITLE);
             $vivvo_website_title = "=?UTF-8?B?" . base64_encode($vivvo_website_title) . "?=";
             $headers['From'] = $vivvo_website_title . '<' . VIVVO_EMAIL_SEND_FROM . '>';
             $recipients = array();
             $recipients[] = $user->email_address;
             $headers['Subject'] = "=?UTF-8?B?" . base64_encode(VIVVO_EMAIL_FORGOT_SUBJECT) . "?=";
             $headers['Content-Type'] = "text/plain; charset=UTF-8;";
             $body_template = new template();
             $template_sting = xml_template_node::xmlentities_decode(VIVVO_EMAIL_FORGOT_BODY);
             $body_template->set_string_template($template_sting);
             $confirm_url = make_absolute_url('login.html?activation_key=' . md5($user->username . $user->email_address . $user->password));
             $body_template->assign('activation_url', $confirm_url);
             $body_template->assign('user', $user);
             $body = $body_template->get_output() . "\n\n";
             if (VIVVO_EMAIL_SMTP_PHP == 1) {
                 $mail_object = new Mail();
                 $mail_object->send($recipients, $headers, $body);
             } else {
                 $mail_options['driver'] = 'smtp';
                 $mail_options['host'] = VIVVO_EMAIL_SMTP_HOST;
                 $mail_options['port'] = VIVVO_EMAIL_SMTP_PORT;
                 $mail_options['localhost'] = 'localhost';
                 if (VIVVO_EMAIL_SMTP_PASSWORD != '' && VIVVO_EMAIL_SMTP_USERNAME != '') {
                     $mail_options['auth'] = true;
                     $mail_options['username'] = VIVVO_EMAIL_SMTP_PASSWORD;
                     $mail_options['password'] = VIVVO_EMAIL_SMTP_USERNAME;
                 } else {
                     $mail_options['auth'] = false;
                     $mail_options['username'] = '';
                     $mail_options['password'] = '';
                 }
                 $mail_object = Mail::factory('smtp', $mail_options);
                 $mail_object->send($recipients, $headers, $body);
             }
         }
         $_SESSION['vivvo']['register_time'] = time();
         return true;
     }
 }
Esempio n. 2
0
 /**
  * Set mass fields in user table with some value
  *
  * @param string $user_ids
  * @param string $field_name
  * @param string $value
  * @return mixed array on succes, or false on fail
  */
 function set_field($user_ids, $field_name, $value, $all_matching = 0)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('user_setField', array(&$user_ids, &$field_name, &$value, &$all_matching))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     if ($sm->user) {
         if ($sm->user->is_admin()) {
             $user_list = new Users_list();
             if ($all_matching == 1) {
                 $user_params = $user_list->get_search_params_from_url($sm);
                 $user_list->search($user_params['search_options'], '', 'ascending', 0, 0, false);
                 if ($user_list->sql_update_list($this->_post_master, array($field_name => $value), NULL, true)) {
                     admin_log($sm->user->get_username(), 'Edited users #' . trim(implode(',', $user_ids)));
                     return true;
                 } else {
                     $this->set_error_code(2329);
                     return false;
                 }
             } else {
                 if ($user_list->get_users_by_ids($user_ids)) {
                     if ($user_list->sql_update_list($this->_post_master, array($field_name => $value))) {
                         admin_log($sm->user->get_username(), 'Edited users #' . trim(implode(',', $user_ids)));
                         return true;
                     } else {
                         $this->set_error_code(2330);
                         return false;
                     }
                 } else {
                     return false;
                 }
             }
         } else {
             $this->set_error_code(2331);
             return false;
         }
     } else {
         $this->set_error_code(2332);
         return false;
     }
 }