Exemple #1
0
 function on_submit()
 {
     $user_update = array();
     $full_name = Url::get('full_name');
     $user_name = Url::get('register_user_name');
     $mobile_phone = AZLib::trimSpace(Url::get('mobile_phone'));
     $home_phone = AZLib::trimSpace(Url::get('home_phone'));
     $gender = (int) Url::get('gender');
     $yahoo_id = AZLib::trimSpace(Url::get('yahoo_id'));
     $skype_id = AZLib::trimSpace(Url::get('skype_id'));
     $address = AZLib::trimSpace(Url::get('address'));
     $website = AZLib::trimSpace(Url::get('website'));
     $this->checkFormInput('Tên đầy đủ', 'full_name', $full_name, 'str', false, '', 0, 50);
     $this->checkFormInput('Điện thoại di động', 'mobile_phone', $mobile_phone, 'str', false, '', 0, 50);
     $this->checkFormInput('Điện thoại bàn', 'home_phone', $home_phone, 'str', false, '', 0, 50);
     $change_pass = 0;
     $change_mail = 0;
     if (User::is_root() && (User::id() == 1 || $this->user['id'] != 1)) {
         $email = Url::get('email');
         $password = AZLib::trimSpace(Url::get('register_password'));
         $confirm_password = AZLib::trimSpace(Url::get('confirm_password'));
         if ($password && User::encode_password($password) != $this->user['password']) {
             //Có nhập pass mới khác pass cũ
             $this->checkFormInput('Mật khẩu truy cập', 'register_password', $password, 'str', true, '', 6, 50);
             $change_pass = 1;
             if ($password != $confirm_password) {
                 $this->setFormError('confirm_password', "Nhập lại Mật khẩu truy cập không khớp!");
             }
         }
         if ($email && $email != $this->user['email']) {
             //Có nhập email mới khác email cũ
             $this->checkFormInput('Email', 'email', $email, 'email', true, '', 6, 50);
             $change_mail = 1;
         }
     }
     if ($mobile_phone && !AZLib::is_mobile($mobile_phone)) {
         $mobile_phone = "";
     }
     if (!$this->errNum) {
         if ($change_mail && DB::exists('SELECT id FROM `user` WHERE `email`="' . $email . '" AND id!=' . $this->user['id'])) {
             $this->setFormError('email', "<b>Email</b> bạn chọn đã tồn tại, hãy chọn lại một <b>Email</b> khác!");
         } else {
             $user_info = array('full_name' => $full_name, 'mobile_phone' => $mobile_phone, 'home_phone' => $home_phone, 'gender' => $gender == 1 ? 0 : 1, 'yahoo_id' => $yahoo_id, 'skype_id' => $skype_id, 'address' => $address, 'website' => $website);
             if ($change_pass) {
                 $user_info['password'] = User::encode_password($password);
             }
             if ($change_mail) {
                 $user_info['email'] = $email;
             }
             DB::update('user', $user_info, "id=" . $this->user['id']);
             User::getUser($this->user['id'], 0, 1);
             Url::redirect_current();
         }
     }
 }
Exemple #2
0
 function edit_user_info()
 {
     $user_id = (int) Url::get('user_id', 0);
     $info = AZLib::getParam('id');
     $value = AZLib::getParam('value');
     $input = array();
     $output = '';
     if ($user_id && (User::have_permit(ADMIN_USER) || User::id() == $user_id && !User::is_block())) {
         if ($info == 'up_item') {
             if (User::is_admin()) {
                 $user = DB::select('user', "id={$user_id}");
                 if (User::is_root()) {
                     $value = (int) $value;
                     $input = array('up_item' => $value > 0 ? $value : 0);
                     $output = '<b>' . $value . '</b>';
                     echo $output;
                     $admin = User::$current->data;
                     if ($user) {
                         $up_count = $value - $user['up_item'];
                         if ($up_count != 0) {
                             //type: 0:Tiền mặt; 1:thu tại nhà; 2:chuyển khoản; 3:Free, KM; 8:Online
                             $up_log_sql = "INSERT INTO up_log (`user_id`,\t`user_name`,\t\t\t`admin_id`,\t\t`admin_name`,\t\t\t`time`,\t `up_count`,`up_before`,\t\t`up_after`,\t`price`,\t`type`,\t\t`note`)\r\n\t                                                VALUES ({$user['id']},\t'{$user['user_name']}',{$admin['id']},\t'{$admin['user_name']}'," . TIME_NOW . ",{$up_count},'{$user['up_item']}',{$value},\t\t0,\t\t\t3,\t\t\t'')";
                             DB::query($up_log_sql);
                             if ($up_count > 0) {
                                 $update = DB::query('UPDATE user SET up_item=up_item + ' . $up_count . ' WHERE id=' . $user_id);
                             } else {
                                 $update = DB::query('UPDATE user SET up_item=up_item - ' . abs($up_count) . ' WHERE id=' . $user_id);
                             }
                             //DB::Update('user',$input,"id=$user_id");
                             User::getUser($user_id, 0, 1);
                         }
                     }
                 } else {
                     $output = "<b>" . (int) $user['up_item'] . "</b>";
                     echo $output;
                 }
                 exit;
             } else {
                 $output = '<b>' . $value . '</b>';
                 echo $output;
                 exit;
             }
         } elseif (!AZLib::checkBadWord($value) || User::have_permit(ADMIN_USER)) {
             $output = 'Ch&#7913;c n&#259;ng n&#224;y &#273;ang &#273;&#432;&#7907;c b&#7893; sung. &#7844;n F5 &#273;&#7875; t&#7843;i l&#7841;i trang.';
             if ($info == 'blast') {
                 $input = array('blast' => $value);
                 $userblast = ' ' . AZLib::BBCode(AZLib::cleanHtml($value));
                 if (strpos($userblast, 'http://')) {
                     $user_blast = $userblast;
                     while (strpos($user_blast, 'http://')) {
                         $tmp = substr($user_blast, strpos($user_blast, 'http://'));
                         if (strpos($tmp, ' ') || strpos($tmp, '<')) {
                             if (strpos($tmp, ' ') && strpos($tmp, '<') && strpos($tmp, ' ') > strpos($tmp, '<')) {
                                 $blast_url = substr($tmp, 0, strpos($tmp, '<'));
                             } else {
                                 $blast_url = substr($tmp, 0, strpos($tmp, ' '));
                             }
                         } else {
                             $blast_url = $tmp;
                         }
                         $user_blast = str_replace($blast_url, '', $user_blast);
                     }
                     $new_blast_url = ' <a href="' . $blast_url . '" target="_blank">Click here</a>';
                     $userblast = substr($user_blast . $new_blast_url, 1);
                 }
                 $user = User::getUser($user_id);
                 if ($value) {
                     //blast không trống
                     if ($value != $user['blast']) {
                         //Thay đổi blast
                         DB::delete("feed", "user_id={$user_id} AND type = 8");
                         //thêm vào feed cho các thành viên theo đuôi
                         DB::query("INSERT INTO \tfeed \t(type, \tuser_id,  act_user_id,  time)\r\n                                                    VALUES\t(8,\t\t{$user_id}, {$user_id}, " . TIME_NOW . ")");
                     }
                 } else {
                     //Xoá blast
                     DB::delete("feed", "user_id={$user_id} AND type = 8");
                 }
                 $output = $userblast . ' <img src="style/images/icon/icon_edit.gif" title="Click để sửa..." alt="Click để sửa..." class="hand_point" rel="blast" align="absmiddle">';
             } elseif ($info == 'address') {
                 $input = array('address' => trim($value));
                 $output = AZLib::word_limit($value, 12, '');
             } elseif ($info == 'mobile_phone') {
                 $value = preg_replace("/[^0-9]/", "", $value);
                 if (!AZLib::is_mobile($value)) {
                     $value = '';
                 }
                 $input = array('mobile_phone' => trim($value));
                 $output = AZLib::word_limit($value, 10, '');
             } elseif ($info == 'home_phone') {
                 if (User::have_permit(ADMIN_USER) || User::$current->data['phone_verify'] == 0) {
                     $value = preg_replace("/[^0-9]/", "", $value);
                     if (AZLib::is_mobile($value) || substr($value, 0, 1) != "0") {
                         $value = '';
                     }
                     $input = array('home_phone' => trim($value));
                     $output = AZLib::word_limit($value, 10, '');
                 }
             } elseif ($info == 'yahoo_id') {
                 $input = array('yahoo_id' => trim($value));
                 $output = AZLib::word_limit($value, 12, '');
             } elseif ($info == 'skype_id') {
                 $input = array('skype_id' => trim($value));
                 $output = AZLib::word_limit($value, 12, '');
             } elseif ($info == 'website') {
                 $input = array('website' => trim($value));
                 $website = $value;
                 if ($website != '') {
                     if (strrpos($website, 'ttp://') != 1) {
                         $website = 'http://' . $website;
                     }
                     if (strlen($website) > 8) {
                         if (strpos($website, '/', 8) > 0) {
                             $website = substr($website, 0, strpos($website, '/', 8));
                         }
                     }
                 }
                 $website = '<a href="' . $value . '" target="_blank" class="lineHeight18"><strong>' . AZLib::strippedLink($website, 26) . '</strong></a>';
                 $output = $website;
             } elseif ($info == 'email' && User::is_admin()) {
                 $input = array('email' => trim($value));
                 $output = $value;
             } elseif ($info == 'signature') {
                 $input = array('signature' => trim($value));
                 $output = AZLib::parseBBCode(AZLib::cleanHtml($value));
             } else {
                 $output = '';
             }
             echo $output;
         } else {
             echo 'N&#7897;i dung c&#243; t&#7915; x&#7845;u! Click &#273;&#7875; s&#7917;a nhanh.';
             exit;
         }
     } else {
         echo 'B&#7841;n kh&#244;ng c&#243; quy&#7873;n s&#7917;a th&#244;ng tin th&#224;nh vi&#234;n';
         exit;
     }
     if ($input) {
         DB::Update('user', $input, "id={$user_id}");
         User::getUser($user_id, 0, 1);
     }
     exit;
 }
Exemple #3
0
 function on_submit()
 {
     $full_name = Url::get('full_name');
     $email = Url::get('email');
     $user_name = Url::get('register_user_name');
     $mobile_phone = AZLib::trimSpace(Url::get('mobile_phone'));
     $home_phone = AZLib::trimSpace(Url::get('home_phone'));
     $password = AZLib::trimSpace(Url::get('register_password'));
     $confirm_password = AZLib::trimSpace(Url::get('confirm_password'));
     $gender = (int) Url::get('gender');
     $yahoo_id = AZLib::trimSpace(Url::get('yahoo_id'));
     $skype_id = AZLib::trimSpace(Url::get('skype_id'));
     $address = AZLib::trimSpace(Url::get('address'));
     $website = AZLib::trimSpace(Url::get('website'));
     $this->checkFormInput('Tên đầy đủ', 'full_name', $full_name, 'str', false, '', 0, 50);
     $this->checkFormInput('Email', 'email', $email, 'email', true, '', 6, 50);
     $this->checkFormInput('Tên truy cập', 'user_name', $user_name, 'uname', true, '', 4, 50);
     $this->checkFormInput('Điện thoại di động', 'mobile_phone', $mobile_phone, 'str', false, '', 0, 50);
     $this->checkFormInput('Điện thoại bàn', 'home_phone', $home_phone, 'str', false, '', 0, 50);
     $this->checkFormInput('Mật khẩu truy cập', 'register_password', $password, 'str', true, '', 6, 50);
     $this->checkFormInput('Nhập lại mật khẩu', 'confirm_password', $confirm_password, 'str', true, '', 6, 50);
     if ($password != $confirm_password) {
         $this->setFormError('confirm_password', "Nhập lại Mật khẩu truy cập không khớp!");
         return;
     }
     if ($mobile_phone && !AZLib::is_mobile($mobile_phone)) {
         $mobile_phone = "";
     }
     if (!$this->errNum) {
         if (DB::exists('SELECT id FROM `user` WHERE `email`="' . $email . '"')) {
             $this->setFormError('email', "<b>Email</b> bạn chọn đã tồn tại, hãy chọn lại một <b>Email</b> khác!");
         } elseif (DB::exists('SELECT id FROM `user` WHERE `user_name`="' . $user_name . '"')) {
             $this->setFormError('email', "<b>Tên truy cập</b> bạn chọn đã tồn tại, hãy chọn lại một <b>Tên truy cập</b> khác!");
         } else {
             $user_info = array('user_name' => $user_name, 'email' => $email, 'password' => User::encode_password($password), 'full_name' => $full_name, 'mobile_phone' => $mobile_phone, 'home_phone' => $home_phone, 'create_time' => TIME_NOW, 'gender' => $gender == 1 ? 0 : 1, 'yahoo_id' => $yahoo_id, 'skype_id' => $skype_id, 'address' => $address, 'website' => $website, 'is_active' => (int) (bool) USER_ACTIVE_ON, 'reg_ip' => AZLib::ip());
             $id = DB::insert('user', $user_info);
             if ($id) {
                 if (USER_ACTIVE_ON && $user_info['is_active'] == 1) {
                     global $display;
                     $active = DB::select('user_active', 'user_id=' . $id);
                     $active_code = md5(TIME_NOW . $user_info['password']);
                     if ($active) {
                         $active = array('id' => $active['id'], 'user_id' => $id, 'active_code' => $active_code, 'time' => TIME_NOW);
                     } else {
                         $active = array('user_id' => $id, 'active_code' => $active_code, 'time' => TIME_NOW);
                     }
                     DB::insert('user_active', $active, true);
                     $display->add('eb_url', WEB_ROOT);
                     $display->add('user_id', $id);
                     $display->add('user_name', $user_info['user_name']);
                     $display->add('active_code', $active_code);
                     $content_email = $display->output('send_active_mail', 1, 'RegisterSuccess');
                     //Send email here;
                     if (System::sendEBEmail($user_info['email'], 'Kích hoạt tài khoản!', $content_email)) {
                         Url::redirect_current();
                     } else {
                         $this->setFormError('', '<b>Tạo mới tài khoản thành công!</b><br /><br />Tuy nhiên hệ thống chưa gửi được Mã kích hoạt tới E-mail: "' . $user_info['email'] . '"!');
                     }
                     $this->show_form = false;
                 } else {
                     Url::redirect_current();
                 }
             } else {
                 $this->setFormError('', "Chưa đăng ký được, mời bạn thử lại!");
             }
         }
     }
 }
Exemple #4
0
 function on_submit()
 {
     if (User::checkLock4Ever(1)) {
         Url::redirect_current();
     }
     //check bảo mật
     $just_registed_s = 0;
     $just_registed_c = 0;
     if (isset($_SESSION['just_registed'])) {
         $just_registed_s = $_SESSION['just_registed'];
     }
     if (isset($_COOKIE['just_registed'])) {
         $just_registed_c = $_COOKIE['just_registed'];
     }
     if ($just_registed_s > TIME_NOW - 120 || $just_registed_c > TIME_NOW - 120 || !REG_ON) {
         Url::redirect_current();
     }
     //END check bảo mật
     // check de ban IP
     $ip = AZLib::ip();
     $arr_badwords = AZLib::checkBadWord($ip, true);
     if ($arr_badwords["bad"] != "" && $arr_badwords["bad_key"] != "") {
         $this->setFormError('ban_ip', "Có lỗi xẩy ra");
     }
     // end check de ban IP
     $full_name = Url::get('full_name');
     $email = Url::get('email');
     $user_name = Url::get('register_user_name');
     $mobile_phone = AZLib::trimSpace(Url::get('mobile_phone'));
     $password = AZLib::trimSpace(Url::get('register_password'));
     $confirm_password = AZLib::trimSpace(Url::get('confirm_password'));
     $this->checkFormInput('Tên đầy đủ', 'full_name', $full_name, 'str', false, '', 0, 50);
     $this->checkFormInput('Email', 'email', $email, 'email', true, '', 6, 50);
     $this->checkFormInput('Tên truy cập', 'user_name', $user_name, 'uname', true, '', 4, 50);
     $this->checkFormInput('Điện thoại di động', 'mobile_phone', $mobile_phone, 'str', false, '', 0, 50);
     $this->checkFormInput('Mật khẩu truy cập', 'register_password', $password, 'str', true, '', 6, 50);
     $this->checkFormInput('Nhập lại mật khẩu', 'confirm_password', $confirm_password, 'str', true, '', 6, 50);
     if (!$this->errNum) {
         if ($password != $confirm_password) {
             $this->setFormError('captcha_register', "Nhập lại Mật khẩu truy cập không khớp!");
             return;
         }
     }
     $captcha_register = Url::get('captcha_register');
     if ($mobile_phone && !AZLib::is_mobile($mobile_phone)) {
         $mobile_phone = "";
     }
     if ($captcha_register == '') {
         $this->setFormError('captcha_register', "Bạn chưa nhập <b>Mã bảo mật</b>!");
     } else {
         if (!isset($_SESSION["enbac_validate"]) || $captcha_register != $_SESSION["enbac_validate"]) {
             $this->setFormError('captcha_register', "<b>Mã bảo mật</b> không chính xác!");
         }
     }
     if ((int) Url::get('confirm_register') != 1) {
         $this->setFormError('confirm_register', "Bạn phải đọc và đồng ý với những <a target=\"_blank\" href=\"http://help.enbac.com/content/4/5/en/Quy-che-thanh-vien.html\" >điều khoản của Enbac.com</a>!");
     }
     if (!$this->errNum) {
         if (DB::exists('SELECT id FROM `user` WHERE `email`="' . $email . '"')) {
             $this->setFormError('email', "<b>Email</b> bạn chọn đã tồn tại, hãy chọn lại một <b>Email</b> khác!");
         } elseif (DB::exists('SELECT id FROM `user` WHERE `user_name`="' . $user_name . '"')) {
             $this->setFormError('email', "<b>Tên truy cập</b> bạn chọn đã tồn tại, hãy chọn lại một <b>Tên truy cập</b> khác!");
         } else {
             $user_info = array('user_name' => $user_name, 'email' => $email, 'password' => User::encode_password($password), 'full_name' => $full_name, 'mobile_phone' => $mobile_phone, 'create_time' => TIME_NOW, 'is_active' => (int) (bool) USER_ACTIVE_ON, 'reg_ip' => AZLib::ip());
             $id = DB::insert('user', $user_info);
             if ($id) {
                 $_SESSION['just_registed'] = TIME_NOW;
                 AZLib::my_setcookie('just_registed', TIME_NOW);
                 if (USER_ACTIVE_ON && $user_info['is_active'] == 1) {
                     global $display;
                     $active = DB::select('user_active', 'user_id=' . $id);
                     $active_code = md5(TIME_NOW . $user_info['password']);
                     if ($active) {
                         $active = array('id' => $active['id'], 'user_id' => $id, 'active_code' => $active_code, 'time' => TIME_NOW);
                     } else {
                         $active = array('user_id' => $id, 'active_code' => $active_code, 'time' => TIME_NOW);
                     }
                     DB::insert('user_active', $active, true);
                     $display->add('eb_url', WEB_ROOT);
                     $display->add('user_id', $id);
                     $display->add('user_name', $user_info['user_name']);
                     $display->add('active_code', $active_code);
                     $display->add('WEB_NAME', WEB_NAME);
                     $display->add('MAIL_FOOTER', MAIL_FOOTER);
                     $content_email = $display->output('send_active_mail', 1, 'RegisterSuccess');
                     //Send email here;
                     if (System::sendEBEmail($user_info['email'], 'Kích hoạt tài khoản!', $content_email)) {
                         //$this->setFormSucces('','<b>Chúc mừng bạn đã đăng ký tài khoản thành công!</b><br /><br />Mã kích hoạt đã được gửi đi tới E-mail: "'.$user_info['email'].'"<br />Bạn hãy check lại Email để kích hoạt tài khoản của mình!');
                         Url::redirect('reg_success', array('cmd' => 'notify'));
                     } else {
                         $this->setFormError('', '<b>Chúc mừng bạn đã đăng ký tài khoản thành công!</b><br /><br />Tuy nhiên hệ thống chưa gửi được Mã kích hoạt tới E-mail: "' . $user_info['email'] . '"!<br />Bạn có thể <a href="' . Url::build('reg_success', array('cmd' => 'active')) . '">click vào đây</a> để hệ thống gửi lại mã kích hoạt vào Email của mình!');
                     }
                     $this->show_form = false;
                 } else {
                     User::Login($id);
                     Url::redirect('reg_success');
                 }
             } else {
                 $this->setFormError('', "Chưa đăng ký được, mời bạn thử lại!");
             }
         }
     }
 }
Exemple #5
0
 function update_user($new_path, $phone_verify, $img_server)
 {
     if (!isset($_POST['show_email'])) {
         $show_email = 0;
     } else {
         $show_email = 1;
     }
     if (!isset($_POST['show_home_phone'])) {
         $show_home_phone = 0;
     } else {
         $show_home_phone = 1;
     }
     if (!isset($_POST['email_alert'])) {
         $email_alert = 0;
     } else {
         $email_alert = 1;
     }
     $id_card = Url::get('id_card');
     if (AZLib::checkBadWord($id_card)) {
         $id_card = '';
     }
     $new_blast = Url::get('blast');
     if (AZLib::checkBadWord($new_blast)) {
         $new_blast = '';
     }
     $new_sign = Url::get('sign');
     if (AZLib::checkBadWord($new_sign)) {
         $new_sign = '';
     }
     $full_name = Url::get('full_name');
     if (AZLib::checkBadWord($full_name)) {
         $full_name = '';
     }
     $address = Url::get('address');
     if (AZLib::checkBadWord($address)) {
         $address = '';
     }
     $home_phone = Url::get('home_phone');
     $home_phone = preg_replace("/[^0-9]/", "", $home_phone);
     if (AZLib::is_mobile($home_phone) || substr($home_phone, 0, 1) != "0") {
         $home_phone = '';
     }
     $fax = Url::get('fax');
     $fax = preg_replace("/[^0-9]/", "", $fax);
     $mobile_phone = Url::get('mobile_phone');
     $mobile_phone = preg_replace("/[^0-9]/", "", $mobile_phone);
     if (!AZLib::is_mobile($mobile_phone)) {
         $mobile_phone = '';
     }
     $website = Url::get('website');
     if (AZLib::checkBadWord($website)) {
         $website = '';
     }
     $yahoo_id = Url::get('yahoo_id');
     if (AZLib::checkBadWord($yahoo_id)) {
         $yahoo_id = '';
     }
     $skype_id = Url::get('skype_id');
     if (AZLib::checkBadWord($skype_id)) {
         $skype_id = '';
     }
     $arr = explode('-', Url::get('birth_day'));
     if (is_numeric($arr['0']) && is_numeric($arr['1']) && is_numeric($arr['2'])) {
         $strBirthDay = $arr['2'] . '-' . $arr['1'] . '-' . $arr['0'];
     } else {
         $strBirthDay = "";
     }
     if ($new_path) {
         $new_row = array('full_name' => trim($full_name), 'address' => trim($address), 'id_card' => $id_card, 'birth_day' => $strBirthDay, 'gender' => intval(Url::get('gender')), 'home_phone' => trim($home_phone), 'fax' => trim($fax), 'mobile_phone' => trim($mobile_phone), 'show_home_phone' => $show_home_phone, 'show_email' => $show_email, 'email_alert' => $email_alert, 'website' => trim($website), 'yahoo_id' => trim($yahoo_id), 'skype_id' => $skype_id, 'blast' => trim($new_blast), 'signature' => trim($new_sign), 'img_server' => $img_server, 'avatar_url' => trim($new_path));
     } else {
         $new_row = array('full_name' => trim($full_name), 'address' => trim($address), 'id_card' => $id_card, 'birth_day' => $strBirthDay, 'gender' => intval(Url::get('gender')), 'home_phone' => trim($home_phone), 'show_home_phone' => $show_home_phone, 'fax' => trim($fax), 'mobile_phone' => trim($mobile_phone), 'show_email' => $show_email, 'email_alert' => $email_alert, 'website' => trim($website), 'yahoo_id' => trim($yahoo_id), 'skype_id' => trim($skype_id), 'blast' => $new_blast, 'signature' => trim($new_sign));
     }
     PersonalDB::update_user_information($new_row);
     if ($new_blast) {
         //blast không trống
         DB::delete("feed", "user_id=" . User::id() . " AND type = 8");
         DB::query("INSERT INTO feed (type, user_id, act_user_id, time)\r\n\t\t\t\t\t\t\t\t\t\tVALUES (8, " . User::id() . ", " . User::id() . ", " . TIME_NOW . ")");
     } else {
         //Xoá blast
         DB::delete("feed", "user_id=" . User::id() . " AND type = 8");
     }
 }