function on_submit() { $class_ids = Url::get('class_ids'); $class_ids = implode(',', $class_ids); $list_class = Classes::get_collection(null, ' id IN (' . $class_ids . ') '); $total = 0; foreach ($list_class as $c) { $total = $total + $c['price']; } $user = PersonalDB::get_account_information(); if ($user['coin'] >= $total) { foreach ($list_class as $class) { if ($class['price'] > 0) { $paid = DB::select('student_paid', ' uid =' . User::id() . ' AND cid=' . $class['id']); if (!$paid) { if (intval(date('d')) < 5) { $month = date('n'); } else { $month = date('n', strtotime('+1 month')); } $data = array('uid' => User::id(), 'price' => $class['price'], 'cid' => $class['id'], 'time' => time(), 'month' => $month); DB::insert('student_paid', $data); } else { if (intval(date('d')) < 5) { $month = date('n'); } else { $month = date('n', strtotime('+1 month')); } $data = array('price' => $class['price'], 'time' => time(), 'month' => $month); DB::update_id('student_paid', $data, $paid['id']); } } } $coin = $user['coin'] - $total; $new_coin = array('coin' => $coin); PersonalDB::update_account_information($new_coin); $this->setSuccessMessage('personal/extra_time', 'Gia hạn thành công, chúc bạn học tập tốt!'); //Url::redirect_url('personal.html?cmd=extra_time'); } else { $this->setErrorMessage('personal/extra_time', "Số tiền trong tài khoản của bạn không đủ để gia hạn, xin vui lòng nạp thêm!"); Url::redirect_url('personal.html?cmd=extra_time'); exit; } Url::redirect_url('personal.html?cmd=extra_time'); }
function on_submit() { if (!User::is_block()) { $email = trim(strip_tags(Url::get('email'))); $user_name = trim(strip_tags(Url::get('user_name'))); $full_name = trim(strip_tags(Url::get('name'))); $this->checkFormInput('Email', 'email', $email, 'email', true, '', 6, 50); if (DB::exists('SELECT id FROM `account` WHERE `email`="' . $email . '" AND id != ' . User::$current->data['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!"); } if (!$this->errNum) { $new_row = array('full_name' => trim($full_name), 'user_name' => $user_name, 'email' => $email); PersonalDB::update_account_information($new_row); User::getUser(User::id(), true); $this->setFormSucces('', "Thông tin của bạn đã được cập nhật!"); } } else { $this->setFormError('', "Tài khoản của bạn hiện đang bị khóa, bạn không thể thực hiện chức năng này!"); } }
function on_submit() { if (User::id() != 0) { $uid = User::id(); // Validate User if (empty($uid)) { if ($_COOKIE['lang'] == 1) { $this->setErrorMessage('personal/change_password', 'Your account is locked, you can not perform this function!'); } else { $this->setErrorMessage('personal/change_password', 'Tài khoản của bạn hiện đang bị khóa, bạn không thể thực hiện chức năng này!'); } Url::redirect_url('personal.html?cmd=manage_order'); exit; } // Get Parameters $email = trim(strip_tags(Url::get('email'))); $full_name = trim(strip_tags(Url::get('full_name'))); $user_name = trim(strip_tags(Url::get('user_name'))); // Get Default Address $default_address = trim(strip_tags(Url::get('default_address'))); $default_city = trim(strip_tags(Url::get('default_city'))); $default_district = trim(strip_tags(Url::get('default_district'))); $this->setSuccessMessage('personal/form_data', array('email' => $email, 'full_name' => $full_name, 'user_name' => $user_name)); // Check Parameters if (empty($email)) { if ($_COOKIE['lang'] == 1) { $this->setErrorMessage('personal/change_password', 'Email address can not be empty'); } else { $this->setErrorMessage('personal/change_password', 'Địa chỉ email không được để trống'); } Url::redirect_url('personal.html?cmd=manage_order'); exit; } if (empty($full_name)) { if ($_COOKIE['lang'] == 1) { $this->setErrorMessage('personal/change_password', 'Full name can not be empty'); } else { $this->setErrorMessage('personal/change_password', 'Tên đầy đủ không được để trống'); } Url::redirect_url('personal.html?cmd=manage_order'); exit; } if (empty($default_address)) { if ($_COOKIE['lang'] == 1) { $this->setErrorMessage('personal/change_password', 'Address can not be empty'); } else { $this->setErrorMessage('personal/change_password', 'Địa chỉ không được để trống'); } Url::redirect_url('personal.html?cmd=manage_order'); exit; } $this->checkFormInput('Email', 'email', $email, 'email', true, '', 6, 50); if (DB::exists('SELECT id FROM `account` WHERE `email` LIKE "' . $email . '" AND id != ' . $uid)) { if ($_COOKIE['lang'] == 1) { $this->setErrorMessage('personal/change_password', "Email you choose already exists, please choose a different email!"); } else { $this->setErrorMessage('personal/change_password', "Email bạn chọn đã tồn tại, hãy chọn lại một email khác!"); } Url::redirect_url('personal.html?cmd=manage_order'); exit; } if (DB::exists('SELECT id FROM `account` WHERE `user_name` LIKE "' . $user_name . '" AND id != ' . $uid)) { if ($_COOKIE['lang'] == 1) { $this->setErrorMessage('personal/change_password', "Already have an account to use this phone number, please leave a phone number to use!"); } else { $this->setErrorMessage('personal/change_password', "Đã có tài khoản sử dụng số điện thoại này, hãy chọn lại một số điện thoại khác để sử dụng!"); } Url::redirect_url('personal.html?cmd=manage_order'); exit; } $new_row = array('full_name' => trim($full_name), 'user_name' => trim($user_name), 'email' => $email); $confirm_phone = trim(strip_tags(Url::get('confirm_phone'))); $confirm_mail = trim(strip_tags(Url::get('confirm_mail'))); if ($confirm_phone == '0000' || isset($_SESSION['uname_pin']) && $confirm_phone == $_SESSION['uname_pin']) { $check1 = true; } else { $check1 = false; } if ($confirm_mail == '0000' || isset($_SESSION['mail_pin']) && $confirm_mail == $_SESSION['mail_pin']) { $check2 = true; } else { $check2 = false; } $u = DB::select('account', 'id=' . $uid); if ($check1 && $check2) { if (isset($_SESSION['uname_pin']) && $confirm_phone == $_SESSION['uname_pin'] && (isset($_SESSION['mail_pin']) && $confirm_mail == $_SESSION['mail_pin'])) { $row = array('uid' => $uid, 'old_user_name' => $u['user_name'], 'new_user_name' => $user_name, 'old_email' => $u['email'], 'new_email' => $email); Log::insertLog($row, 'account'); } elseif (isset($_SESSION['uname_pin']) && $confirm_phone == $_SESSION['uname_pin']) { $row = array('uid' => $uid, 'old_user_name' => $u['user_name'], 'new_user_name' => $user_name); Log::insertLog($row, 'account'); } elseif (isset($_SESSION['mail_pin']) && $confirm_mail == $_SESSION['mail_pin']) { $row = array('uid' => $uid, 'old_email' => $u['email'], 'new_email' => $email); Log::insertLog($row, 'account'); } PersonalDB::update_account_information($new_row); unset($_SESSION['uname_pin']); unset($_SESSION['mail_pin']); // Add Address $exists_address_id = PersonalDB::exists_address($uid, $default_address, $default_district); if (!$exists_address_id) { $new_address = array('uid' => $uid, 'full_name' => $full_name, 'tel' => $user_name, 'address' => $default_address, 'did' => $default_district); $exists_address_id = PersonalDB::add_address($new_address); } // Set Default Address PersonalDB::set_default_address($uid, $exists_address_id); } else { unset($new_row); if ($_COOKIE['lang'] == 1) { $this->setErrorMessage('personal/change_password', 'You enter the confirmation code, please re-operation'); } else { $this->setErrorMessage('personal/change_password', 'Bạn nhập sai mã xác nhận, vui lòng thực hiện lại thao tác'); } Url::redirect_url('personal.html?cmd=manage_order'); } // Update Password $new_password = trim(strip_tags(EClassApi::getParam('new_password'))); $confirm_password = trim(strip_tags(EClassApi::getParam('confirm_password'))); if (!empty($new_password) && strlen($new_password) > 0 && !empty($confirm_password) && strlen($confirm_password) > 0) { if ($new_password == $confirm_password) { $new_password = User::eat_encode_password($new_password, SALTAUTH); if ($new_password) { $new_row = array('password' => trim($new_password)); PersonalDB::update_account_information($new_row); } } else { if ($_COOKIE['lang'] == 1) { $this->setErrorMessage('personal/change_password', 'Confirm password wrong'); } else { $this->setErrorMessage('personal/change_password', 'Xác nhận mật khẩu sai'); } Url::redirect_url('personal.html?cmd=manage_order'); exit; } } if ($_COOKIE['lang'] == 1) { $this->setSuccessMessage('personal/change_password', 'Your information has been changed'); } else { $this->setSuccessMessage('personal/change_password', 'Thông tin của bạn đã được thay đổi'); } Url::redirect_url('personal.html?cmd=manage_order'); } else { if ($_COOKIE['lang'] == 1) { $this->setErrorMessage('user/login', 'You must login to access this area'); } else { $this->setErrorMessage('user/login', 'Bạn phải đăng nhập trước khi truy cập khu vực này'); } Url::redirect_url('home'); } }
function remove_avatar() { header('Content-Type: text/html; charset=utf-8'); global $display; $id = intval(Url::get('id', 0)); $uid = $_SESSION['user_id']; $image = PersonalDB::get_image_upload_byId($id); if ($image) { unlink($image['path']); } PersonalDB::delete_avatar($id); $user = PersonalDB::get_account_byId($uid); if ($image['path'] == $user['avatar_url']) { $avatar_url = array('avatar_url' => ''); PersonalDB::update_account_information($avatar_url); } if ($image['path'] == $user['banner_url']) { $banner_url = array('banner_url' => ''); PersonalDB::update_account_information($banner_url); } $list_image = PersonalDB::get_image_upload($user['id']); $display->add('list_image', $list_image); exit; }
function on_submit() { if (User::id() != 0) { $uid = User::id(); if (empty($uid)) { $this->setErrorMessage('personal/change_password', 'Tài khoản của bạn hiện đang bị khóa, bạn không thể thực hiện chức năng này!'); Url::redirect_url('personal.html?cmd=change_password'); exit; } $email = trim(strip_tags(Url::get('email'))); $full_name = trim(strip_tags(Url::get('full_name'))); $user_name = trim(strip_tags(Url::get('user_name'))); $facebook = trim(strip_tags(Url::get('facebook'))); $this->setSuccessMessage('personal/form_data', array('email' => $email, 'full_name' => $full_name, 'user_name' => $user_name)); if (empty($email)) { $this->setErrorMessage('personal/change_password', 'Địa chỉ email không được để trống'); Url::redirect_url('personal.html?cmd=change_password'); exit; } if (empty($full_name)) { $this->setErrorMessage('personal/change_password', 'Tên đầy đủ không được để trống'); Url::redirect_url('personal.html?cmd=change_password'); exit; } $this->checkFormInput('Email', 'email', $email, 'email', true, '', 6, 50); if (DB::exists('SELECT id FROM `account` WHERE `email` LIKE "' . $email . '" AND id != ' . $uid)) { $this->setErrorMessage('personal/change_password', "Email bạn chọn đã tồn tại, hãy chọn lại một email khác, xin cám ơn!"); Url::redirect_url('personal.html?cmd=change_password'); exit; } if (DB::exists('SELECT id FROM `account` WHERE `user_name` LIKE "' . $user_name . '" AND id != ' . $uid)) { $this->setErrorMessage('personal/change_password', "Đã có tài khoản sử dụng số điện thoại này, hãy chọn lại một số điện thoại khác để sử dụng, xin cám ơn!"); Url::redirect_url('personal.html?cmd=change_password'); exit; } $new_row = array('full_name' => trim($full_name), 'user_name' => trim($user_name), 'email' => $email, 'facebook' => $facebook); $confirm_phone = trim(strip_tags(Url::get('confirm_phone'))); $confirm_mail = trim(strip_tags(Url::get('confirm_mail'))); if ($confirm_phone == '0000' || isset($_SESSION['uname_pin']) && $confirm_phone == $_SESSION['uname_pin']) { $check1 = true; } else { $check1 = false; } if ($confirm_mail == '0000' || isset($_SESSION['mail_pin']) && $confirm_mail == $_SESSION['mail_pin']) { $check2 = true; } else { $check2 = false; } $u = DB::select('account', 'id=' . $uid); if ($check1 && $check2) { PersonalDB::update_account_information($new_row); unset($_SESSION['uname_pin']); unset($_SESSION['mail_pin']); } else { unset($new_row); $this->setErrorMessage('personal/change_password', 'Bạn nhập sai mã xác nhận, vui lòng thực hiện lại thao tác'); Url::redirect_url('personal.html?cmd=change_password'); } // Update Password $new_password = trim(strip_tags(EClassApi::getParam('new_password'))); $confirm_password = trim(strip_tags(EClassApi::getParam('confirm_password'))); if (!empty($new_password) && strlen($new_password) > 0 && !empty($confirm_password) && strlen($confirm_password) > 0) { if ($new_password == $confirm_password) { $new_password = User::eat_encode_password($new_password, SALTAUTH); if ($new_password) { $new_row = array('password' => trim($new_password)); PersonalDB::update_account_information($new_row); } } else { $this->setErrorMessage('personal/change_password', 'Xác nhận mật khẩu sai'); Url::redirect_url('personal.html?cmd=change_password'); exit; } } $this->setSuccessMessage('personal/change_password', 'Thông tin của bạn đã được thay đổi'); Url::redirect_url('personal.html?cmd=change_password'); } else { $this->setErrorMessage('user/login', 'Bạn phải đăng nhập trước khi truy cập khu vực này'); Url::redirect_url('home'); } }