示例#1
0
 function get_new_key()
 {
     $this->load->helper('random_password');
     $aes_key = get_random_password(10, 15, TRUE, TRUE, TRUE);
     $id = $this->save($aes_key);
     $data = array('aes_key' => $aes_key, 'id' => $id);
     return $data;
 }
示例#2
0
 function resetPassword()
 {
     $this->load->library('myencryption');
     $this->load->library('form_validation');
     $this->form_validation->set_rules('resetmail', 'Reset email', 'valid_email');
     $this->form_validation->set_error_delimiters('<div class="alert alert-warning">', '</div>');
     if ($this->form_validation->run() == false) {
         $this->load->view('login_view');
     } else {
         $mail = $this->input->post('resetmail');
         $this->db->where('email_address', trim(strtolower($mail)));
         $result = $this->db->get('user');
         if ($result->num_rows() == 1) {
             function get_random_password($chars_min = 8, $chars_max = 10, $use_upper_case = true, $include_numbers = true, $include_special_chars = false)
             {
                 $length = rand($chars_min, $chars_max);
                 $selection = 'aeuoyibcdfghjklmnpqrstvwxz';
                 if ($include_numbers) {
                     $selection .= "1234567890";
                 }
                 if ($include_special_chars) {
                     $selection .= "!@\"#\$%&[]{}?|";
                 }
                 $password = "";
                 for ($i = 0; $i < $length; $i++) {
                     $current_letter = $use_upper_case ? rand(0, 1) ? strtoupper($selection[rand() % strlen($selection)]) : $selection[rand() % strlen($selection)] : $selection[rand() % strlen($selection)];
                     $password .= $current_letter;
                 }
                 return $password;
             }
             $newpass = get_random_password();
             $this->db->where('email_address', trim(strtolower($mail)));
             $newpass1 = $this->myencryption->encode($newpass);
             $this->db->update('user', array('password' => $newpass1));
             if ($this->db->affected_rows() == 1) {
                 $config = array('protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.gmail.com', 'smtp_port' => 465, 'smtp_user' => '*****@*****.**', 'smtp_pass' => 'Broskomsot123', 'mailtype' => 'html', 'charset' => 'iso-8859-1');
                 $this->load->library('email', $config);
                 $this->email->set_newline("\r\n");
                 // Set to, from, message, etc.
                 $this->email->from('*****@*****.**', 'Rest password MSC');
                 $this->email->to($mail);
                 $this->email->subject('New Password');
                 $this->email->message('Your New Password is : ' . $newpass);
                 if (!$this->email->send()) {
                     $arr['message'] = '<div class="alert alert-warning" style="text-align:left">Reset password failed. please try again later.</div>';
                     $this->load->view('login_view', $arr);
                 } else {
                     $arr['message'] = '<div class="alert alert-success" style="text-align:left">Reset password successful. Please check your email for the new password</div>';
                     $this->load->view('login_view', $arr);
                 }
             }
         } else {
             $arr['message'] = '<div class="alert alert-warning">Given reset email dose not exist!</div>';
             $this->load->view('login_view', $arr);
         }
     }
 }
示例#3
0
 /**
  * @Decorated
  */
 public function index()
 {
     $this->page_decorator->setPageMetaTag("description", "Home page");
     $this->page_decorator->setPageMetaTag("keywords", "Home page");
     $this->page_decorator->setPageMetaTag("author", "Trieu Nguyen");
     $this->page_decorator->setPageTitle("Job Management System at DRD");
     $this->load->helper('random_password');
     $ran_pass = get_random_password(10, 12, TRUE, TRUE, FALSE);
     ApplicationHook::logInfo($ran_pass);
     $data = array();
     $this->load->view("decorator/body", $data);
 }
示例#4
0
 /**
  * @Decorated
  */
 public function index()
 {
     $this->page_decorator->setPageMetaTag("description", "Home page");
     $this->page_decorator->setPageMetaTag("keywords", "Home page");
     $this->page_decorator->setPageMetaTag("author", "Trieu Nguyen");
     $this->page_decorator->setPageTitle("Job Management System at DRD");
     $this->load->helper('random_password');
     $ran_pass = get_random_password(10, 12, TRUE, TRUE, FALSE);
     //ApplicationHook::logInfo($ran_pass);
     $this->load->database();
     $this->db->cache_on();
     $query = $this->db->query("SELECT COUNT(id) as number FROM users");
     $this->db->cache_off();
     foreach ($query->result() as $row) {
         ApplicationHook::logInfo($row->number);
     }
     $data = array();
     $this->load->view("decorator/body", $data);
 }
示例#5
0
    function cek_email($resemail)
    {
        $uname = $this->input->post("uname");
        $cekemail = $this->m_user->cek_email($uname, $resemail);
        if ($cekemail) {
            $len = strlen($uname);
            $str = get_random_password(6, 8, true, $len);
            $hash = sha1($str);
            $query = $this->db->where('username', $uname)->update('user', array('password' => $hash));
            if ($query) {
                $this->load->library('email');
                $this->email->from('*****@*****.**', 'jvm system');
                $this->email->to($resemail);
                $this->email->subject('RESET PASSWORD');
                $this->email->message('silahkan login dengan username = '******' dan password ='******'Y-m-d h:i:s') . "\n";
                $log .= $this->email->print_debugger();
                $log .= "\n";
                $file = 'logemail.txt';
                $pathfile = APPPATH . 'views/' . $file;
                if (file_exists($pathfile)) {
                    $current = file_get_contents($pathfile);
                    $current .= $log;
                    $current .= "\r\n";
                    file_put_contents($pathfile, $current);
                } else {
                    $handle = fopen($pathfile, 'w') or die('Cannot open file:  ' . $pathfile);
                    //implicitly creates file
                    fwrite($handle, $log);
                }
                return true;
            } else {
                ?>
					<script type="text/javascript">alert('maaf terjadi kesalahan pada system :(');</script>
			<?php 
            }
        } else {
            return false;
        }
    }
示例#6
0
}
$username = $_REQUEST['username'];
$user_exists = check_user_exists($username);
if ($user_exists == false) {
    $msg = "User <b>{$username}</b> not found. Please check the username entered.";
} else {
    $user_profile = get_user_by_name($username);
    $email = $user_profile->email;
    # Remove the following line once get_user_profile works
    if (trim($email) == "") {
        $msg = "Email address not present for <b>{$username}</b>. Please contact sysadmin to reset your password.";
    } else {
        if (check_valid_email($email) === false) {
            $msg = "Email address <b>{$email}</b> not valid. Please contact sysadmin to reset your password.";
        } else {
            $new_password = get_random_password();
            $password_changed = change_user_password($username, $new_password);
            if ($password_changed === false) {
                $msg = "Error while resetting password. Please try again.";
            } else {
                $subject = "[BLIS] New password for " . $username;
                $to_addr = $email;
                $body = "Your password has been reset.\nPlease note that passwords are case-sensitive.\n\n" . "Username: "******"\n" . "New Password: "******"\n\n" . "Please login to update your password.\n" . "http://lis.cc.gatech.edu";
                if (mail($email, $subject, $body)) {
                    $msg = "New password emailed to <u>" . $email . "</u>";
                } else {
                    $msg = "Error sending email to <u>" . $email . "</u>. Please contact sysadmin to reset your password.";
                }
            }
        }
    }
示例#7
0
function reset_password($email)
{
    global $data;
    $ci =& get_instance();
    $user = $ci->SystemModel->get_user_by_email($email);
    if ($user) {
        $uid = $user->id;
        $username = $user->username;
        $password = get_random_password();
        $dbdata = array('password' => prep_password($password));
        $ci->SystemModel->update_user($uid, $dbdata);
        //Email User
        $message = array();
        $message[] = "Your password to your Nakid CMS installation has been reset. You can now log in with:";
        $message[] = "<strong>Username:</strong> " . $username;
        $message[] = "<strong>Password:</strong> " . $password;
        $message[] = "This password can be changed once you log in";
        $message = implode("<br/>\n", $message);
        systememail($email, "Nakid CMS login", $message);
    } else {
        $data['notes'][] = array("Account not found", "error");
    }
}
      $exam_functions_id = $_POST["exam_functions_id"];
   }*/
$exam_type = OFFICIAL_EXAM;
$exam_answer_type = GIVE_ANSWER_AFTER_SUBMIT;
$exam_location = OLINE_TEST;
/*
   if(($user_id = check_number($_POST["user_id"])) == SYMBOL_ERROR)
   {
      sleep(DELAY_SEC);
      echo SYMBOL_ERROR;
      return;
   }*/
$exam_duration = 30;
$exam_password = "";
if ($exam_location == ONSITE_TEST) {
    $exam_password = get_random_password();
}
$exam_status = EXAM_INACTIVE;
$qualify_percent = 80;
$fail_times = 1;
$exam_id = 1;
$type_scores = array(SINGLE_CHOICE_PROB => $exam_single_score, MULTI_CHOICE_PROB => $exam_multi_score, TRUE_FALSE_PROB => $exam_true_false_score);
// begin, end
/*
$sql_begin_datetime = timestamp_to_datetime($from_timestamp);
$sql_end_datetime = timestamp_to_datetime($to_timestamp);
// get all function name
$functions_name = array();
*/
//link
$link = @mysqli_connect(DB_HOST, ADMIN_ACCOUNT, ADMIN_PASSWORD, CONNECT_DB);
示例#9
0
function _xForgotPasswordConfirmed()
{
    global $t, $C;
    require_once 'textdb.php';
    $db = new PasswordConfirmsDB();
    $db->DeleteExpired();
    $confirm = $db->Retrieve($_REQUEST['id']);
    require_once 'validator.php';
    $v =& Validator::Get();
    $v->Register(empty($confirm), VT_IS_FALSE, 'Invalid or expired confirmation code');
    if (!$v->Validate()) {
        $t->Assign('g_invalid_confirm', true);
    } else {
        $db->Delete($_REQUEST['id']);
        $password = get_random_password();
        require_once 'dirdb.php';
        $db = new TradeDB();
        $trade = $db->Update($confirm['domain'], array('password' => sha1($password)));
        $trade['password'] = $password;
        $t->AssignByRef('g_trade', $trade);
    }
    $t->Display('trade-stats-forgot-confirmed.tpl');
}
示例#10
0
function _xConfirmShow()
{
    global $t, $C;
    require_once 'textdb.php';
    $db = new RegisterConfirmsDB();
    $db->DeleteExpired();
    $confirm = $db->Retrieve($_REQUEST['id']);
    require_once 'validator.php';
    $v =& Validator::Get();
    $v->Register(empty($confirm), VT_IS_FALSE, 'Invalid or expired confirmation code');
    if (!$v->Validate()) {
        $t->Assign('g_invalid_confirm', true);
    } else {
        $db->Delete($_REQUEST['id']);
        $defaults = unserialize(file_get_contents(FILE_NEW_TRADE_DEFAULTS));
        require_once 'dirdb.php';
        $password = get_random_password();
        $db = new TradeDB();
        $trade = $db->Update($confirm['domain'], array('status' => $defaults['status'], 'timestamp_autostop' => time(), 'password' => sha1($password)));
        $trade['password'] = $password;
        $t->AssignByRef('g_trade', $trade);
        require_once 'mailer.php';
        if ($C['flag_register_email_user'] && !string_is_empty($trade['email'])) {
            $m = new Mailer();
            $m->Mail('email-register-complete.tpl', $t, $trade['email'], $trade['email']);
        }
        if ($C['flag_register_email_admin']) {
            $m = new Mailer();
            $m->Mail('email-register-admin.tpl', $t, $C['email_address'], $C['email_name']);
        }
    }
    $t->Display('register-confirm.tpl');
}