예제 #1
1
 function index()
 {
     $usersListQuery = $this->usersModel->getLastXUsers(6);
     $footerWidebarData['usersListArr'] = $usersListQuery;
     $contactStatus['contactStatus'] = false;
     if ($this->input->post('submit')) {
         $name = (string) $this->input->post('name', TRUE);
         $email = (string) $this->input->post('email', TRUE);
         $subject = (string) $this->input->post('subject', TRUE);
         $message = (string) $this->input->post('message', TRUE);
         if (empty($name) or empty($email) or empty($subject) or empty($message)) {
             show_error("Toate campurile sunt obligatorii. Te rog sa completezi toate campurile si sa incerci din nou.");
         }
         if (!valid_email($email)) {
             show_error("Adresa de mail nu este valida.");
         }
         $config['protocol'] = 'sendmail';
         $this->email->initialize($config);
         $this->email->from($email, $name);
         $this->email->to('*****@*****.**');
         $this->email->subject('NoiseStats Contact - ' . $subject);
         $this->email->message($message);
         $this->email->send();
         $contactStatus['contactStatus'] = true;
         $this->load->view('header');
         $this->load->view('contact', $contactStatus);
         $this->load->view('footer_widebar', $footerWidebarData);
         $this->load->view('footer');
     } else {
         $this->load->view('header');
         $this->load->view('contact', $contactStatus);
         $this->load->view('footer_widebar', $footerWidebarData);
         $this->load->view('footer');
     }
 }
예제 #2
0
 private function validateForm()
 {
     $this->data['field_name'] = $this->input->post('name');
     if (utf8_strlen($this->input->post('name')) < 3 || utf8_strlen($this->input->post('name')) > 20) {
         $this->error['name'] = lang('error_name');
     }
     $this->load->helper('email');
     $this->data['field_email'] = $this->input->post('email');
     if (!valid_email($this->input->post('email'))) {
         $this->error['email'] = lang('error_email');
     }
     $this->data['field_title'] = $this->input->post('title');
     if (utf8_strlen($this->input->post('title')) <= 0) {
         $this->error['title'] = lang('error_title');
     }
     $this->data['field_enquiry'] = $this->input->post('enquiry');
     if (utf8_strlen($this->input->post('enquiry')) <= 0) {
         $this->error['content'] = lang('error_content');
     }
     if (!checkCaptcha($this->input->post('captcha'), 'captcha_contact')) {
         $this->error['captcha'] = lang('error_captcha');
     }
     if (!$this->error) {
         return true;
     } else {
         return false;
     }
 }
예제 #3
0
 function api_verify_input($list_id, $timestamp_param = NULL)
 {
     $recipient_id = $this->CI->input->post('recipient_id');
     if (empty($recipient_id)) {
         $this->error = ['status' => 401, 'message' => 'missing parameter recipient_id'];
         return NULL;
     }
     $to_name = $this->CI->input->post('to_name');
     if (is_null($to_email = valid_email($this->CI->input->post('to_email')))) {
         $this->error = ['status' => 401, 'message' => 'invalid email address in to_email'];
         return NULL;
     }
     $timestamp = $this->CI->input->post($timestamp_param);
     $timestamp = strtotime($timestamp);
     if ($timestamp == FALSE) {
         $this->error = ['status' => 401, 'message: timestamp parameter missing or ill formated'];
         return NULL;
     }
     $timestamp = date('Y-m-d H:i:s', $timestamp);
     $result = ['recipient_id' => $recipient_id, 'to_name' => $to_name, 'to_email' => $to_email, $timestamp_param => $timestamp];
     if ($timestamp_param = 'metadata_updated') {
         $metadata = $this->CI->input->post('metadata');
         $metadata_json = (is_array($metadata) and !empty($metadata)) ? json_encode($metadata) : NULL;
         $result['metadata_json'] = $metadata_json;
     }
     $recipient = $this->get($list_id, $recipient_id, $to_name, $to_email);
     $result['recipient'] = $recipient;
     return $result;
 }
예제 #4
0
 public function profile_oke($profile)
 {
     $result = true;
     if (trim($profile["fullname"]) == "") {
         $this->output->add_message("Fill in your name.");
         $result = false;
     }
     if (valid_email($profile["email"]) == false) {
         $this->output->add_message("Invalid e-mail address.");
         $result = false;
     } else {
         if (($check = $this->db->entry("users", $profile["email"], "email")) != false) {
             if ($check["id"] != $this->user->id) {
                 $this->output->add_message("E-mail address already exists.");
                 $result = false;
             }
         }
     }
     if (hash_password($profile["current"], $this->user->username) != $this->user->password) {
         $this->output->add_message("Current password is incorrect.");
         $result = false;
     }
     if ($profile["password"] != "") {
         if ($profile["password"] != $profile["repeat"]) {
             $this->output->add_message("New passwords do not match.");
             $result = false;
         } else {
             if ($this->user->password == $profile["hashed"]) {
                 $this->output->add_message("New password must be different from current password.");
                 $result = false;
             }
         }
     }
     return $result;
 }
예제 #5
0
 public function forget_pass()
 {
     $this->load->helper('email');
     $this->load->helper('string');
     $this->load->model('Users_Model');
     $email = $this->input->post('email');
     if (!valid_email($email)) {
         $this->session->set_flashdata('log_error', 'Please Enter a Valid Email id.');
     } else {
         if ($this->Users_Model->mailexist($email)) {
             $userdetails = $this->Users_Model->getDetailByMailId($email);
             $username = $userdetails->fld_username;
             $fld_id = $userdetails->fld_id;
             $random_Pass = strtolower(random_string());
             $md_pass = md5($random_Pass);
             $data = array('fld_password' => $md_pass);
             $chang_pass = $this->Users_Model->updateUser($fld_id, $data);
             if ($chang_pass) {
                 $url = site_url('administrator');
                 $msg = "<b>New login details</b> <br /> Username : "******" <br /> Password : "******" <br /> Url : <a href='" . $url . "' title='Click Here'>" . $url . "</a>";
                 $sendmail = send_email($email, $subject = 'Password Change', $message = $msg);
                 if ($sendmail) {
                     $this->session->set_flashdata('log_succ', 'Please check your email id, We have sent your login details on your mail Id.');
                 } else {
                     $this->session->set_flashdata('log_error', 'There is some error accoured, Please try again');
                 }
             }
         } else {
             $this->session->set_flashdata('log_error', 'Your email Id is not registered.');
         }
     }
     redirect('administrator/?forget=true');
 }
예제 #6
0
 public function signup()
 {
     // get the post
     $post = $this->get_input_vals();
     $email = $post['newsletter_email'];
     if (valid_email($email) && 0 == strlen($post['phone_number'])) {
         $this->newsletter_model->save_email($email);
         $this->_log_action($post['url'], 'newsletter signup', 'success');
         // send email
         $this->send_email($email, "Sign up service from <" . $this->config->item('from_email') . ">", "Thank you for signing up", "Thank you for signing up to our newsletter");
         // log, reload
         $this->_log_action($post['url'], "you successfully signed up to the email newsletter: " . $email . "", "success");
         $this->_reload($post['url'], "you successfully signed up to the email newsletter: " . $email . "", "success");
     } else {
         $this->_store_post($post);
         if ($email == '') {
             $this->_log_action($post['url'], 'newsletter signup', 'fail - empty');
         } else {
             $this->_log_action($post['url'], 'newsletter signup', 'fail - bad email');
         }
         // log, reload
         $this->_log_action($post['url'], "the email address was invalid", "fail");
         $this->_reload($post['url'], "the email address was invalid", "fail");
     }
 }
예제 #7
0
 public function send_mail($to, $subject, $message, $from = '*****@*****.**', $name = 'reSeed', $cc = null, $bcc = null)
 {
     $from = '*****@*****.**';
     $name = 'reSeed';
     if (!valid_email($from)) {
         return "Campo 'from' non valido";
     }
     if (!valid_email($to)) {
         return "Campo 'to' non valido";
     }
     $this->CI->email->from($from, $name);
     $this->CI->email->to($to);
     $this->CI->email->subject($subject);
     $this->CI->email->message($message);
     if ($cc) {
         $this->CI->email->cc($cc);
     }
     if ($bcc) {
         $this->CI->email->bcc($bcc);
     }
     if ($this->CI->email->send()) {
         return "OK";
     } else {
         return $this->CI->email->print_debugger();
     }
 }
예제 #8
0
파일: contacts.php 프로젝트: KosBeg/paybay
 public function submit()
 {
     $result = array();
     $this->input->is_ajax_request() ? $this->template->set_layout(FALSE) : '';
     /*
     $captcha = $this->input->post('captcha');
     $correctCaptcha 	= $this->session->userdata('captcha_content');
     $expTime			= $this->session->userdata('captcha_exprise_time');
     */
     $name = $this->input->post('name');
     $email = $this->input->post('email');
     $message = $this->input->post('message');
     $this->load->helper('email');
     $errorMessage = '';
     /*
     if( $correctCaptcha != $captcha){
     	$errorMessage = lang('funnyfox_request_qoute_code_invalid_captcha');
     }else if( time() > $expTime ){
     	$errorMessage = lang('funnyfox_request_qoute_code_captcha_expired');
     }else 
     */
     if ($name == "") {
         $errorMessage = lang('funnyfox_contact_name_required');
     } else {
         if ($email == "") {
             $errorMessage = lang('funnyfox_contact_name_required');
         } else {
             if (!valid_email($email)) {
                 $errorMessage = lang('funnyfox_contact_email_invalid');
             } else {
                 if ($message == "") {
                     $errorMessage = lang('funnyfox_contact_message_invalid');
                 }
             }
         }
     }
     if (!$errorMessage) {
         $this->funnyfox_contacts_m->insert(array('name' => $name, 'email' => $email, 'message' => $message, 'created_time' => time()));
         /*			
         $this->load->library('settings');
         $this->load->library('email');
         $this->email->from($sendEmail = $this->settings->get('server_email'), lang('stoepje_winner_frontend_email_name_label'));
         $this->email->to($email);
         
         $this->email->subject(lang('stoepje_winner_frontend_email_subject_label'));
         $prize->email = str_replace('###SALUTATION###', lang('stoepje_winner_salutation_'.$salutation), $prize->email);
         $prize->email = str_replace('###FIRSTNAME###', $firstName, $prize->email);
         $prize->email = str_replace('###LASTNAME###', $lastName, $prize->email);
         $prize->email = str_replace('###VOUCHERCODE###', $voucher->code, $prize->email);
         $this->email->message($prize->email);
         $this->email->send();
         */
         $result['result'] = true;
         $result['message'] = lang('funnyfox_contact_success_message');
     } else {
         $result['result'] = false;
         $result['message'] = $errorMessage;
     }
     echo json_encode($result);
 }
예제 #9
0
 /**
  * get_user function.
  * 
  * @access public
  * @param mixed $user (default: null)
  * @return void
  */
 public function get_user($user = null)
 {
     $this->benchmark->mark('user_model_get_user_start');
     $data = array();
     if (is_int($user)) {
         $data = array('id' => intval($user));
     } else {
         if (is_string($user)) {
             if (valid_email($user)) {
                 $data = array('email' => $user);
             } else {
                 $data = array('username' => $user);
             }
         } else {
             return null;
         }
     }
     $query = $this->db->get_where('users', $data);
     if ($query->num_rows() > 0) {
         $this->benchmark->mark('user_model_get_user_end');
         return $query->row_array();
     }
     $this->benchmark->mark('user_model_get_user_end');
     return null;
 }
예제 #10
0
 function addFeedback()
 {
     if (!$this->safety->allowByControllerName(__METHOD__)) {
         return errorForbidden();
     }
     $this->load->helper('email');
     $this->load->model('Users_Model');
     $userId = (int) $this->session->userdata('userId');
     $data = array();
     if ($userId != USER_ANONYMOUS) {
         $data = $this->Users_Model->get($userId);
     }
     $feedbackUserEmail = element('userEmail', $data);
     if (valid_email($feedbackUserEmail) == false) {
         $feedbackUserEmail = '';
     }
     $form = array('frmName' => 'frmFeedbackEdit', 'callback' => 'function(response) { $.Feedback.onSaveFeedback(response); };', 'fields' => array('feedbackId' => array('type' => 'hidden', 'value' => element('feedbackId', $data, 0)), 'feedbackUserName' => array('type' => 'text', 'label' => lang('Name'), 'value' => trim(element('userFirstName', $data) . ' ' . element('userLastName', $data))), 'feedbackUserEmail' => array('type' => 'text', 'label' => lang('Email'), 'value' => $feedbackUserEmail), 'feedbackDesc' => array('type' => 'textarea', 'label' => lang('Comment'), 'value' => '')), 'buttons' => array('<button type="submit" class="btn btn-primary"><i class="fa fa-comment"></i> ' . lang('Send') . '</button> '));
     $form['rules'] = array(array('field' => 'feedbackUserName', 'label' => $form['fields']['feedbackUserName']['label'], 'rules' => 'trim|required'), array('field' => 'feedbackUserEmail', 'label' => $form['fields']['feedbackUserEmail']['label'], 'rules' => 'trim|required|valid_email'), array('field' => 'feedbackDesc', 'label' => $form['fields']['feedbackDesc']['label'], 'rules' => 'trim|required'));
     $this->form_validation->set_rules($form['rules']);
     if ($this->input->post() != false) {
         $code = $this->form_validation->run();
         if ($code == true) {
             $this->Feedbacks_Model->saveFeedback($this->input->post());
         }
         if ($this->input->is_ajax_request()) {
             return loadViewAjax($code);
         }
     }
     $this->load->view('pageHtml', array('view' => 'includes/crForm', 'meta' => array('title' => lang('Feedback')), 'form' => $form, 'langs' => array('Thanks for contacting us')));
 }
예제 #11
0
 public function doRegister()
 {
     $email = $this->input->post('email');
     $password = $this->input->post('password');
     if (empty($email) || empty($password)) {
         show_error('邮箱或密码不能为空', 100, $heading = 'An Error Was Encountered');
     }
     if (valid_email($email)) {
         $data['email'] = $email;
         //     $passwd = substr($email, 0, strpos($email, '@')).rand(1, 999);
         $data['password'] = md5($password);
         $data['create_time'] = date('Y-m-d H:i:s');
         $valid_user = $this->db->get_where('wufu', array('email' => $email))->row_array();
         if (!empty($valid_user)) {
             show_error('邮箱已经存在', 100, $heading = 'An Error Was Encountered');
         }
         $this->db->insert('wufu', $data);
         $config['mailtype'] = 'html';
         $this->load->library('email');
         $this->email->initialize($config);
         $this->email->from('*****@*****.**', '松鼠先生');
         $this->email->to($email);
         $this->email->subject('五福共享平台密码');
         $this->email->message('您的五福共享平台密码是: ' . $password);
         //$this->email->send();
         redirect('login');
     }
 }
예제 #12
0
 public function insert($data)
 {
     $this->load->helper('email');
     if (array_valid($data)) {
         // Ensure no bogus whitespace on any of the information
         array_trim($data);
         // Perform data validation
         if (!isset($data['name']) or $data['name'] === '') {
             $errors[] = 'Please enter a full name';
         }
         if (!valid_email($data['email'])) {
             $errors[] = 'The email provided is not valid';
         }
         if (!isset($data['identity']) or $data['identity'] === '') {
             $errors[] = 'Please enter a login';
         }
         if (!isset($data['magickey']) or $data['magickey'] === '') {
             $errors[] = 'Please enter a password';
         }
         // Encode the password using sha1()
         $data['magickey'] = sha1($data['magickey']);
         // We have no errors so let's insert the new User
         if (!array_valid($errors)) {
             $this->db->insert('user', $data);
             return TRUE;
         }
     } else {
         $errors[] = 'No user information was provided';
     }
     if (array_valid($errors)) {
         return $errors;
     }
 }
예제 #13
0
 function join_member($member)
 {
     $this->load->helper('email');
     if ($member['email2'] != $member['email']) {
         return ["error", "parameter err"];
     }
     if ($member['password2'] != $member['password']) {
         return ["error", "parameter err"];
     }
     if (valid_email($member['email']) === false) {
         return ["error", "email is not valid"];
     }
     if (strlen(htmlspecialchars($member['name'])) > 64) {
         return ["error", "name is too long"];
     }
     if ($this->name_chk($member['name']) === false) {
         return ["error", "name is duplicated"];
     }
     if ($this->email_chk($member['email']) === false) {
         return ["error", "email is duplicated"];
     }
     if (!isset($member['lang'])) {
         return ["error", "language parameter error"];
     }
     $m = ['email' => $member['email'], 'name' => htmlspecialchars($member['name']), 'password' => md5($member['password']), 'reg_date' => date('Y-m-d H:i:s', time()), 'reg_ip' => $this->input->ip_address(), 'lang' => $member['lang']];
     if ($this->db->insert('users', $m) === false) {
         return ["error", "unknown error"];
     }
     $this->load->model('achievement_model', 'achievement');
     $this->achievement->take('default', $m['name']);
     return true;
 }
 function email_available($str = NULL)
 {
     $is_ajax = FALSE;
     if ($_POST && $this->CI->input->post('is_ajax') == 1 && trim($this->CI->input->post('str')) != NULL) {
         $str = trim($this->input->post('str'));
         $is_ajax = TRUE;
     }
     if (!$this->CI->simpleloginsecure->is_email_available($str)) {
         if (!$is_ajax) {
             $this->set_message('email_available', "The email address {$str} has already been registered, please try a different email address.");
             return FALSE;
         } else {
             if ($this->CI->session->userdata('user_email') == $str) {
                 $email_available_message = 'No change made...';
             } else {
                 $email_available_message = '<span class="error">The email address ' . $str . ' is taken please try a different email address.</span>';
             }
             $result = array('result' => $email_available_message);
             echo json_encode($result);
         }
     } else {
         if (!$is_ajax) {
             return TRUE;
         } else {
             if (!valid_email($str)) {
                 $email_available_message = '<span class="error">Please enter a valid email address.';
             } else {
                 $email_available_message = "The email address {$str} is available.";
             }
             $result = array('result' => $email_available_message);
             echo json_encode($result);
         }
     }
 }
예제 #15
0
 public function test_valid_email()
 {
     $this->assertEquals(FALSE, valid_email('test'));
     $this->assertEquals(FALSE, valid_email('test@test@test.com'));
     $this->assertEquals(TRUE, valid_email('*****@*****.**'));
     $this->assertEquals(TRUE, valid_email('*****@*****.**'));
 }
예제 #16
0
파일: register.php 프로젝트: enamakel/vugo
 public function sendSuccessEmail($data)
 {
     $this->load->helper('email');
     if (valid_email($data['email'])) {
         send_email($data['email'], "Registration Suuccess", "Your Username <b>" . $data['username'] . "</b>, Password <b>" . $data['password'] . "</b>");
     }
 }
예제 #17
0
 function submitforgot()
 {
     $suc = '<button type="button" class="close" data-dismiss="alert" aria-label="Close" style="color:red"><span aria-hidden="true">&times;</span></button>';
     $alerts = '<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert" aria-label="Close" style="color:red"><span aria-hidden="true">&times;</span></button>';
     $alerta = '<div class="alert alert-info"><button type="button" class="close" data-dismiss="alert" aria-label="Close" style="color:red"><span aria-hidden="true">&times;</span></button>';
     $this->load->library('email');
     $this->load->helper('email');
     $email = $this->input->post('email');
     if (valid_email($email)) {
         $config['protocol'] = "smtp";
         $config['smtp_host'] = 'ssl://box997.bluehost.com';
         $config['smtp_port'] = '465';
         $config['smtp_user'] = '******';
         $config['smtp_pass'] = '******';
         $config['mailtype'] = 'html';
         $config['mailpath'] = '/usr/sbin/sendmail';
         $config['charset'] = 'utf-8';
         $config['newline'] = "\r\n";
         $config['wordwrap'] = TRUE;
         $this->email->initialize($config);
         $this->email->from('*****@*****.**', 'Leyte Tourism Portal', '*****@*****.**');
         $this->email->to($email);
         $this->email->subject('Email Test');
         $this->email->message('Please click the link for the password recovery');
         $this->email->send();
         $this->session->set_flashdata('message', $alerta . ' Password Recovery Has been Sent to ' . $email . '</div>');
     } else {
         $this->session->set_flashdata('message', $alerts . 'Invalid Email.</div>');
     }
     redirect('/forgot');
 }
예제 #18
0
 public function logar()
 {
     // Recebe os dados
     $email = $this->input->post('email');
     $senha = $this->input->post('senha');
     // Valida e-mail, se invalido retorna com erro
     if (!valid_email($email)) {
         $this->session->set_flashdata('erro', 'E-mail inválido');
         redirect('/admin');
     }
     // Faz a consulta
     $dados = $this->Model_admin_login->buscar_login($email, $senha);
     // Se não encontra, retorna ao login com erro
     if (!$dados) {
         $this->session->set_flashdata('erro', 'Usuário ou senha inválidos');
         redirect('/admin');
     }
     // verifica se o usuário está realmente ativo
     $usuario_ativo = $this->Model_admin_login->usuario_ativo($email);
     if (!$usuario_ativo) {
         $this->session->set_flashdata('erro', 'Usuário bloqueado!');
         redirect('/admin');
     }
     // Se encontra, carrega as sessoes e retorna a pagina principal
     $dados['logado_admin'] = TRUE;
     // Define a sessão que permite acesso ao sistema
     $this->session->set_userdata($dados);
     redirect('admin_agenda/');
 }
예제 #19
0
 function changeEmail()
 {
     if (!$this->safety->allowByControllerName('profile/edit')) {
         return errorForbidden();
     }
     $userId = $this->session->userdata('userId');
     $data = $this->Users_Model->get($userId);
     $this->load->helper('email');
     $form = array('frmName' => 'frmChangeEmail', 'title' => lang('Change email'), 'buttons' => array('<button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> ' . lang('Save') . ' </button>'), 'fields' => array('userEmail' => array('type' => 'text', 'label' => lang('Email'), 'value' => valid_email(element('userEmail', $data)) == true ? element('userEmail', $data) : '')));
     $form['rules'] = array(array('field' => 'userEmail', 'label' => $form['fields']['userEmail']['label'], 'rules' => 'trim|required|valid_email|callback__validate_exitsEmail'));
     $this->form_validation->set_rules($form['rules']);
     if ($this->input->post() != false) {
         if ($this->form_validation->run() == FALSE) {
             return loadViewAjax(false);
         }
         $this->load->model(array('Tasks_Model'));
         $userId = $this->session->userdata('userId');
         $userEmail = $this->input->post('userEmail');
         $confirmEmailKey = random_string('alnum', 20);
         $this->Users_Model->updateConfirmEmailKey($userId, $userEmail, $confirmEmailKey);
         $this->Tasks_Model->addTask('sendEmailToChangeEmail', array('userId' => $userId));
         return loadViewAjax(true, array('notification' => lang('We have sent you an email with instructions to change your email')));
     }
     return $this->load->view('includes/crJsonForm', array('form' => $form));
 }
예제 #20
0
    function get_email_addr() {

        if (array_key_exists('text', $_REQUEST) and
            array_key_exists('domain', $_REQUEST)) {
            $is_text = true;

            $text   = valid_phone($_REQUEST['text']);
            $domain = $_REQUEST['domain']; 

            $email = valid_email(sprintf("%s@%s", $text, $domain));

            # Save for next time
            $_SESSION['text'] = $text;
            $_SESSION['domain'] = $domain;

        } else if (array_key_exists('email', $_REQUEST)) {
            $is_text = false;
            
            $email = valid_email($_REQUEST['email']);
            
            # Save for next time
            $_SESSION['email'] = $email;

        } else {
            throw new Exception("No destination information provided.");
        }

        return array($email, $is_text);
    }
예제 #21
0
파일: register.php 프로젝트: sjlu/sns
 function index()
 {
     if ($this->input->post("submit")) {
         $email = $this->input->post("email");
         $password = $this->input->post("password");
         $confirm_password = $this->input->post("confirm_password");
         if (empty($email) || empty($password) || empty($confirm_password)) {
             return $this->view(array('error' => 'Please provide all fields.'));
         }
         if (strlen($password) < 6) {
             return $this->view(array('error' => 'Password length is too short.'));
         }
         if ($password !== $confirm_password) {
             return $this->view(array('error' => 'Passwords do not match.'));
         }
         $this->load->helper('email');
         if (!valid_email($email)) {
             return $this->view(array('error' => 'Not a valid email address.'));
         }
         $this->load->model('users_model');
         if ($this->users_model->email_exists($email)) {
             return $this->view(array('error' => 'User account already exists.'));
         }
         $this->users_model->create($email, $password);
         return redirect('login');
     }
     return $this->view();
 }
예제 #22
0
    public function register($email_address,$password,$password_confirmation){
    	$this->load->helper('email');
    	if($password != $password_confirmation){
    		$this->errors[] = "Passwords did not match.";
    		return false;
    	}
    	if(strlen($password) < 6){
    		$this->errors[] = "Password is too short (must be 6 characters or more)";
    		return false;
    	}
    	if(!valid_email($email_address)){
    		$this->errors[] = "Email address is invalid.";
    		return false;
    	}
    	if($this->_email_taken($email_address)){
    		$this->errors[] = "An account already exists with that email. Did you <a href='/auth/forgot_password/>'forget your password</a>?";
    		return false;
    	}

    	$insert = array('email_address'=>$email_address,
    					'password'=>$this->_hash_password($password),
    					'active'=>1);
    	$this->db->insert('users',$insert);
    	return true;

    }
예제 #23
0
 public function login($redirect = NULL)
 {
     if ($redirect === NULL) {
         $redirect = $this->ag_auth->config['auth_login'];
     }
     $this->form_validation->set_rules('username', 'Username', 'required|min_length[6]');
     $this->form_validation->set_rules('password', 'Password', 'required|min_length[6]');
     if ($this->form_validation->run() == FALSE) {
         $this->ag_auth->view('login');
     } else {
         $username = set_value('username');
         $password = $this->ag_auth->salt(set_value('password'));
         $field_type = valid_email($username) ? 'email' : 'username';
         $user_data = $this->ag_auth->get_user($username, $field_type);
         if (array_key_exists('password', $user_data) and $user_data['password'] === $password) {
             unset($user_data['password']);
             unset($user_data['id']);
             $this->ag_auth->login_user($user_data);
             redirect($redirect);
         } else {
             $data['message'] = "The username and password did not match.";
             $this->ag_auth->view('message', $data);
         }
     }
     // if($this->form_validation->run() == FALSE)
 }
 public function forgotpassword()
 {
     $data = '';
     $post = $this->input->post();
     if ($post) {
         $error = array();
         $e_flag = 0;
         if (!valid_email(trim($post['email'])) && trim($post['email']) == '') {
             $error['email'] = 'Please enter email.';
             $e_flag = 1;
         }
         if ($e_flag == 0) {
             $where = array('email' => trim($post['email']), 'role' => 'admin');
             $user = $this->common_model->selectData(ADMIN, '*', $where);
             if (count($user) > 0) {
                 $newpassword = random_string('alnum', 8);
                 $data = array('password' => md5($newpassword));
                 $upid = $this->common_model->updateData(ADMIN, $data, $where);
                 $emailTpl = $this->load->view('email_templates/admin_forgot_password', array('username' => $user[0]->name, 'password' => $newpassword), true);
                 $ret = sendEmail($user[0]->email, SUBJECT_LOGIN_INFO, $emailTpl, FROM_EMAIL, FROM_NAME);
                 if ($ret) {
                     $flash_arr = array('flash_type' => 'success', 'flash_msg' => 'Login details sent successfully.');
                 } else {
                     $flash_arr = array('flash_type' => 'error', 'flash_msg' => 'An error occurred while processing.');
                 }
                 $data['flash_msg'] = $flash_arr;
             } else {
                 $error['email'] = "Invalid email address.";
             }
         }
         $data['error_msg'] = $error;
     }
     $this->load->view('index/forgotpassword', $data);
 }
예제 #25
0
 public function kontakt_mail()
 {
     $this->load->helper('email');
     $this->load->library('email');
     if (valid_email($this->input->post('mail'))) {
         $config['mailtype'] = 'html';
         $config['wordwrap'] = TRUE;
         $this->email->initialize($config);
         //izmeniti mejl from!!! Obavezno serverovu mejl adresu, zbog spama.
         $this->email->from('*****@*****.**', 'Apoteka Biljana i Luka');
         $mail = "<html><head></head><body>" . $this->input->post('textarea') . "<br>" . $this->input->post('mail') . "<br>" . $this->input->post('name') . "</body></html>";
         $this->email->to('*****@*****.**');
         $this->email->subject('Kontakt forma, sajt apoteke');
         $this->email->message($mail);
         $this->email->send();
         $greska = 1;
         //send_email('*****@*****.**', 'Apoteka 9 kontakt forma', $mail);
         //redirect(base_url("index.php/index/kontakt"), 'refresh');
         //echo $this->email->print_debugger();
     } else {
         $greska = 2;
     }
     redirect('index/kontakt/' . $greska, 'refresh');
     //redirect(base_url("index.php/index/kontakt"), 'refresh');
 }
예제 #26
0
파일: account.php 프로젝트: bashrc/hubzilla
function check_account_email($email)
{
    $result = array('error' => false, 'message' => '');
    // Caution: empty email isn't counted as an error in this function.
    // Check for empty value separately.
    if (!strlen($email)) {
        return $result;
    }
    if (!valid_email($email) || !validate_email($email)) {
        $result['message'] .= t('Not a valid email address') . EOL;
    } elseif (!allowed_email($email)) {
        $result['message'] = t('Your email domain is not among those allowed on this site');
    } else {
        $r = q("select account_email from account where account_email = '%s' limit 1", dbesc($email));
        if ($r) {
            $result['message'] .= t('Your email address is already registered at this site.');
        }
    }
    if ($result['message']) {
        $result['error'] = true;
    }
    $arr = array('email' => $email, 'result' => $result);
    call_hooks('check_account_email', $arr);
    return $arr['result'];
}
예제 #27
0
파일: cpanel.php 프로젝트: juslee/e27
 public function index()
 {
     // Define variables
     $email = "";
     $error_message = "";
     // Logout user if already logged in
     if ($this->session->userdata('user_id') != '') {
         $this->session->unset_userdata(array('user_id' => ''));
     }
     // Process authentication if login form is posted
     if ($_POST) {
         $this->load->helper('email');
         $email = $this->input->post('email');
         $password = $this->input->post('password');
         if (valid_email($email)) {
             if ($user_id = $this->administrators->authenticate($email, $password)) {
                 $this->session->set_userdata(array('user_id' => $user_id));
                 redirect('cpanel/giveaways');
             } else {
                 $error_message = "Invalid email and/or password. Please try again.";
             }
         } else {
             $error_message = "Please enter a valid email address.";
         }
     }
     // Set view variables
     $this->data['email'] = $email;
     $this->data['error_message'] = $error_message;
     // Load view
     $this->load->view('cpanel/login', $this->data);
 }
예제 #28
0
 /**
  * Send email to user
  *
  * Send an email to a site user. Using the given view file and data
  *
  * @access public
  * @param mixed $user User email or ID
  * @param string $subject Email subject
  * @param string $view View file to use
  * @param array $data Variable replacement array
  * @return boolean Whether the email was sent
  */
 function send($user = NULL, $subject = 'No Subject', $view = NULL, $data = array())
 {
     if (valid_email($user)) {
         // Email given
         $email = $user;
     } elseif (is_integer($user)) {
         // Get users email
         $query = $this->CI->user_model->fetch('Users', 'email', NULL, array('id' => $user));
         $user = $query->row();
         $email = $user->email;
     } else {
         // Error
         return FALSE;
     }
     // Build email
     $subject = "[" . $this->CI->preference->item('site_name') . "] " . $subject;
     $message = $this->CI->parser->parse($view, $data, TRUE);
     // Setup Email settings
     $this->_initialize_email();
     // Send email
     $this->CI->email->from($this->CI->preference->item('automated_from_email'), $this->CI->preference->item('automated_from_name'));
     $this->CI->email->to($email);
     $this->CI->email->subject($subject);
     $this->CI->email->message($message);
     if (!$this->CI->email->send()) {
         return FALSE;
     }
     return TRUE;
 }
예제 #29
0
 /**
  * process
  * This method is responsible of registering and updating customers
  * it will insert and updates users in your system with new
  * information or retrieving the stripe data.
  *
  * @return [type] [description]
  */
 public function process()
 {
     if ($_POST) {
         //simple validation
         if (!isset($_POST['email']) || !isset($_POST['plan']) || !isset($_POST['stripeToken'])) {
             flash_message('fail_message', '01)' . $this->lang->line('services_process_email_error') . $this->lang->line('services_if_still_problem'));
             redirect(base_url());
         }
         $email = $this->current_user ? $this->current_user['email'] : $_POST['email'];
         $description = 'WSIMPLE CUSTOMER ' . $_POST['plan'];
         $amount = $this->Service->getPrice($_POST['plan']);
         $plan = $_POST['plan'];
         $source = $_POST['stripeToken'];
         $client = $this->User->getByEmail($email);
         //plan & email validation
         if (!$amount || !valid_email($email)) {
             flash_message('fail_message', '02)' . $this->lang->line('services_process_plan_error') . $this->lang->line('services_if_still_problem'));
             redirect(base_url());
         }
         //facebook user without email
         if (!$client && $this->current_user && $email != '') {
             $userUpdate['email'] = $email;
             $client = $this->current_user;
         }
         //new customer
         if (!$client) {
             $options_customer = ['description' => $description, 'email' => $email, 'source' => $source];
             $customer = $this->stripe->addCustomer($options_customer);
             $this->User->insert(['id_status' => '1', 'id_profile' => '2', 'email' => $email, 'stripe_id' => $customer->id]);
         } else {
             //g-ocanto-com customers
             //If our customers are not in stripe, we registered them in there and retrieve the stripe object
             if (!$this->User->getStripeId($client->id)) {
                 $options_customer = ['description' => $description, 'email' => $email, 'source' => $source];
                 $customer = $this->stripe->addCustomer($options_customer);
             } else {
                 //retrieving the stripe object
                 $customer = $this->stripe->getCustomer($this->User->getStripeId($client->id));
             }
             $userUpdate['stripe_id'] = $customer->id;
             $this->User->update($userUpdate, $client->id);
         }
         //selecting service plan
         $options_subscription = ['plan' => $plan];
         //, 'trial_end' => 'now'
         //creating stripe suscription
         $subscription = $customer->subscriptions->create($options_subscription);
         //successfully registration
         if ($subscription->status == 'trialing' || $subscription->status == 'active') {
             $insert_subscription = ['id_user' => $client->id, 'id_service' => $plan, 'stripe_id' => $subscription->id, 'status' => 'active'];
             $this->Subscription->insert($insert_subscription);
             $this->emailsSuccessfullyActivated($email);
             flash_message('successful_message', $this->lang->line('services_successfully_activated'));
         } else {
             flash_message('fail_message', '03)' . $this->lang->line('services_process_email_error') . $this->lang->line('services_if_still_problem'));
         }
     }
     redirect(base_url());
 }
예제 #30
0
 public function getScore()
 {
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $this->load->helper('email');
         $id = $this->input->post('id', TRUE);
         $json = $this->input->post('json', TRUE);
         $first_name = $this->input->post('first_name', TRUE);
         $last_name = $this->input->post('last_name', TRUE);
         $password = $this->input->post('password', TRUE);
         $email = $this->input->post('email', TRUE);
         // Make sure the client doesn't enter an already used email
         $this->db->from('client');
         $this->db->where('email', $email);
         $l = $this->db->get()->result();
         if (count($l) != 0) {
             echo 'email is not valid, choose another one!';
             return;
         } else {
             if (!valid_email($email)) {
                 echo 'email is not valid';
                 return;
             } else {
                 if (!empty($email) && !empty($id) && !empty($json)) {
                     $array = json_decode($json);
                     $score = Score::calculerScore($array);
                     for ($i = 1; $i <= count($array); $i++) {
                         $status = $array[$i - 1];
                         $this->db->where('idClient', $id);
                         $this->db->where('position', $i);
                         $this->db->update('resultat', array('status' => $status));
                     }
                     $d = array('email' => $email, 'password' => sha1($password), 'firstName' => $first_name, 'lastName' => $last_name);
                     $this->db->where('id', $id);
                     $b = $this->db->update('client', $d);
                     // insert score into table score
                     $data = array('score' => $score, 'date' => date('Y-m-d'), 'client_id' => $id);
                     $this->db->insert('score', $data);
                     if ($b) {
                         /*
                          ini_set('SMTP','smtp.menara.ma');
                          $message = "Votre score est: $score\r\nMerci de votre visite";
                         
                          // In case any of our lines are larger than 70 characters, we should use wordwrap()
                          $message = wordwrap($message, 70, "\r\n");
                         
                          // Send
                          mail($email, 'Reputation', $message);
                         */
                         echo "true";
                     } else {
                         echo "false";
                     }
                 } else {
                     echo 'please fill all the mandatory fields';
                 }
             }
         }
     }
 }