本文整理汇总了PHP中set_alert函数的典型用法代码示例。如果您正苦于以下问题:PHP set_alert函数的具体用法?PHP set_alert怎么用?PHP set_alert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_alert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LoginParticulier
public function LoginParticulier()
{
$this->mLayout = "empty";
$this->mTheme = 'login-page';
$this->mViewFile = 'loginparticulier';
if (validate_form()) {
$username = $this->input->post('username');
$password = $this->input->post('password');
$this->load->model('User_model', 'user_model');
$user = $this->user_model->get_by('email', $username);
// only admin and staff can login
/*if ( verify_role(['admin', 'staff'], $user) )
{*/
// password correct
if (verify_pw($password, $user['password'])) {
// limited fields to store in session
$fields = array('id', 'role', 'email', 'first_name', 'last_name', 'created_at');
$user_data = elements($fields, $user);
login_user($user);
// success
set_alert('success', 'Connexion réussie');
redirect('home');
exit;
}
//}
// failed
set_alert('danger', 'Nom d\'utilisateur ou Mot de passe incorrect');
redirect('/login/Loginparticulier');
}
}
示例2: update_product_table
function update_product_table()
{
$action = $this->action;
if ($action == 'visibility') {
$this->update_product_table_visibility();
$type = 'success';
$msg = 'Changes successfully saved.';
} else {
if ($action == 'delete') {
$this->update_product_table_delete();
$type = 'success';
$msg = 'Item(s) successfully deleted.';
} else {
if ($action == 'new') {
$this->update_product_table_new();
} else {
if ($action == 'status') {
$this->update_product_active();
$type = 'success';
$msg = 'Changes successfully saved.';
}
}
}
}
$page = 'self';
set_alert($type, $msg);
safe_redirect($page);
}
示例3: form_basic
public function form_basic()
{
$form = $this->form_builder->create_form('example/form_basic');
$form->add_text('name', 'Name', TRUE);
$form->add_text('email', 'Email', TRUE);
$form->add_text('subject', 'Subject');
$form->add_textarea('message', 'Message', TRUE);
$form->add_recaptcha();
$form->add_submit();
if (!empty($this->input->post()) && $form->validate()) {
// passed validation
$email = $this->input->post('email');
$password = $this->input->post('password');
if (empty($user_id)) {
// failed
$form->add_custom_error('Failed to create user');
} else {
// success
set_alert('success', 'Thanks for registration. We have sent you a email and please follow the instruction to activate your account.');
redirect('account/login');
}
}
// display form when no POST data, or validation failed
$this->mViewData['form'] = $form;
$this->_render('example/form_basic');
}
示例4: index
/**
* Login page and submission
*/
public function index()
{
// Login form
$this->load->library('form_builder');
$form = $this->form_builder->create_form('admin/login');
$form->add_text('username', '', 'Username', 'admin');
$form->add_password('password', '', 'Password', 'admin');
$form->add_submit('Sign In', 'primary', TRUE);
if (!empty($this->input->post()) && $form->validate()) {
// passed validation
$username = $this->input->post('username');
$password = $this->input->post('password');
$this->load->model('admin_user_model', 'users');
$user = $this->users->login($username, $password);
if (empty($user)) {
// login failed
set_alert('danger', 'Invalid Login');
refresh();
} else {
// login success
$this->session->set_userdata('admin_user', $user);
redirect('admin');
}
}
// display form when no POST data, or validation failed
$this->mViewData['form'] = $form;
$this->mBodyClass = 'login-page';
$this->render('login', 'empty');
}
示例5: index
public function index()
{
$this->mLayout = "empty";
$this->mTheme = 'login-page';
$this->mViewFile = 'login';
if (validate_form()) {
$username = $this->input->post('username');
$password = $this->input->post('password');
$this->load->model('Backend_user_model', 'backend_users');
$user = $this->backend_users->get_by('username', $username);
// only admin and staff can login
if (verify_role(['admin', 'staff-1', 'staff-2', 'staff-3'], $user)) {
// password correct
if (verify_pw($password, $user['password'])) {
// limited fields to store in session
$fields = array('id', 'role', 'username', 'full_name', 'created_at');
$user_data = elements($fields, $user);
login_user($user);
// success
set_alert('success', 'Login success');
redirect('home');
exit;
}
}
// failed
set_alert('danger', 'Invalid Login');
redirect('login');
}
}
示例6: change_password
/**
* Submission of Change Password form
*/
public function change_password()
{
$this->load->model('admin_user_model', 'admin_users');
$updated = $this->admin_users->change_password($this->mUser->id, $this->input->post('new_password'));
if ($updated) {
set_alert('success', 'Successfully changed password.');
} else {
set_alert('danger', 'Failed to changed password.');
}
redirect('admin/account');
}
示例7: change_password
/**
* Submission of Change Password form
*/
public function change_password()
{
$form_url = 'account';
if (validate_form($form_url)) {
// update db
$password = $this->input->post('password');
$update_data = ['password' => hash_pw($password)];
$result = $this->backend_users->update($this->mUser['id'], $update_data);
// success
set_alert('success', 'Mot de passe changé.');
}
// back to form
redirect($form_url);
}
示例8: reset_password
/**
* Reset password for backend users
*/
public function reset_password($user_id)
{
$this->mTitle = "Backend Users";
$this->mViewFile = 'admin/reset_password';
$this->mViewData['target'] = $this->backend_users->get($user_id);
if (validate_form('', 'admin/reset_password')) {
// update db
$password = $this->input->post('password');
$result = $this->backend_users->update($user_id, ['password' => hash_pw($password)]);
// success or failed
if ($result) {
set_alert('success', 'Successfully updated.');
} else {
set_alert('danger', 'Database error.');
}
// refresh page to show alert msg
redirect(current_url());
}
}
示例9: register
public function register()
{
if (post('register')) {
$pengguna = ['username' => post('username'), 'email' => post('email'), 'level' => 0, 'aktif' => 1];
$pelanggan = ['nama_lengkap' => post('nama'), 'alamat' => post('alamat'), 'kota' => post('kota'), 'telp' => post('telp')];
if (post('password') == post('passconf')) {
$pengguna['password'] = md5(post('password'));
}
if ($userId = User::add($pengguna)) {
$pelanggan['id_pengguna'] = $userId;
if (Customer::add($pelanggan)) {
set_alert('success', 'Registrasi berhasil, silahkan login ke akun yang baru saja anda buat');
redirect('login');
} else {
set_alert('error', 'Maaf registrasi gagal');
redirect('register');
}
}
}
return $this->render('form-register', ['heading' => 'Silahkan register']);
}
示例10: validate_form
function validate_form($form_url = '', $rule_set = '')
{
$CI =& get_instance();
$CI->load->library('form_validation');
if ($CI->form_validation->run($rule_set) == FALSE) {
if (validation_errors()) {
// save error messages to flashdata
set_alert('danger', validation_errors());
// save all fields to flashdata for repopulating
// note: set_value() will not work upon redirection
$CI->session->set_flashdata('form_fields', $CI->input->post());
// refresh or jump page to show error messagees
$url = empty($form_url) ? current_url() : $form_url;
redirect($url);
exit;
}
// display form
return FALSE;
} else {
// success
return TRUE;
}
}
示例11: insert_product
function insert_product()
{
//include("static/thumbnail.php");
/* --- DEFINED VARIABLE --- */
$date = date('Y-m-d H:i:s');
$date_only = date('d-m-y-H-i-s');
$product_category = filter_var($this->product_category, FILTER_SANITIZE_NUMBER_INT);
$product_name = filter_var($this->product_name, FILTER_SANITIZE_STRING);
$product_size_type_id = filter_var($this->size_type, FILTER_SANITIZE_NUMBER_INT);
$product_id = filter_var($this->product_id, FILTER_SANITIZE_NUMBER_INT);
$type_id = $this->type_id;
//array
$color_id = $this->color_id;
//array
$type_name = $this->type_name;
//array
$type_code = $this->type_code;
//array
$type_price = $this->type_price;
//array
$type_description = $this->type_description;
//array
$type_sizefit = $this->type_sizefit;
//array
$type_image = $this->color_image;
//double_array
$type_delete = $this->type_delete;
//array
$order = $this->order;
//double_array
$image_id = $this->image_id;
$image_delete = $this->image_delete;
$stock_quantity = $this->stock_quantity;
//double_array
$stock_name = $this->stock_name;
//double_array
$type_weight = $this->type_weight;
$page_title = filter_var($this->page_title, FILTER_SANITIZE_STRING);
$page_description = filter_var($this->page_description, FILTER_SANITIZE_STRING);
$page_keywords = filter_var($this->page_keywords, FILTER_SANITIZE_STRING);
$product_alias = cleanurl($this->product_name, FILTER_SANITIZE_STRING);
/* --- EDIT PRODUCT --- */
$this->update_product($product_category, $product_name, $product_size_type_id, $product_alias, $page_title, $page_description, $page_keywords, $product_id);
/* --- TYPE PRODUCT --- */
$i = 0;
$max_order = $this->get_max_type_order();
foreach ($type_name as $key => $type_name) {
$i = $key;
$i = $i + $max_order->maximum_order;
$temp_type_order = $this->get_type_data($this->type_id[$key]);
/* --- DELETE PRODUCTS --- */
if ($this->type_delete[$key] == '1') {
if ($this->type_id[$key] != '') {
$type_id_ = $this->type_id[$key];
$this->update_delete_product('1', $type_id_);
$this->delete_stocks($type_id);
}
} else {
$type_code = filter_var($this->type_code[$key], FILTER_SANITIZE_STRING);
$type_name = filter_var($type_name, FILTER_SANITIZE_STRING);
$type_alias = cleanurl($type_name);
$type_price = filter_var($this->type_price[$key], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
$type_description = $this->type_description[$key];
$type_sizefit = $this->type_sizefit[$key];
$type_information = $this->type_information[$key];
$color_id = filter_var($this->color_id[$key], FILTER_SANITIZE_NUMBER_INT);
$type_weight = filter_var($this->type_weight[$key], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
$product_id = filter_var($this->product_id, FILTER_SANITIZE_NUMBER_INT);
$type_id = filter_var($this->type_id[$key], FILTER_SANITIZE_NUMBER_INT);
/* --- ADD --- */
if ($type_id == '') {
$this->insert_type_id($type_code, $type_name, $type_price, $type_description, $type_sizefit, $type_information, $color_id, $type_weight, $product_id, $i, $page_title, $page_description, $type_alias);
} else {
$this->update_type_id($type_code, $type_name, $type_price, $type_description, $type_sizefit, $type_information, $color_id, $type_weight, $temp_type_order->type_order, $type_alias, $page_title, $page_description, $type_id);
}
if ($type_id == '') {
$temp = $this->get_max_type_id();
$type_id = $temp->max_type_id;
} else {
$type_id = $type_id;
}
/* --- END: ADD --- */
/* --- TYPE COLOR IMAGE--- */
$i = $key;
if ($this->color_image["tmp_name"][$i] != null) {
$file_type = substr($this->color_image["name"][$i], -4);
$file_name = substr($this->color_image["name"][$i], 0, -4);
$tmp_name = $this->color_image["tmp_name"][$i];
$name = cleanurl($type_name) . "_" . $date_only . "_" . substr(cleanurl($file_name), 0, 20) . '-' . $k . $file_type;
$error = $this->color_image["error"][$i];
if ($error == 0) {
move_uploaded_file($tmp_name, "../files/uploads/type_color_image/{$name}");
$img_src = "files/uploads/type_color_image/{$name}";
} else {
$type = 'error';
$msg = 'Error: ' . $error;
set_alert($type, $msg);
safe_redirect('self');
}
$this->insert_type_color($img_src, $type_id);
//.........这里部分代码省略.........
示例12: users
public function users($do = '', $id = '')
{
$data = ['heading' => 'Administrasi: Pengguna'];
switch ($do) {
case 'form':
if (post('submit')) {
$data = ['username' => post('username'), 'email' => post('email')];
if (User::is('admin')) {
$data['level'] = post('level');
}
if ($password = post('password') and $password == post('passconf')) {
$data['password'] = $password;
}
if (User::save($data, $id)) {
if ($id) {
set_alert('success', 'Berhasil memperbarui data pengguna <b>' . $data['username'] . '</b>');
} else {
set_alert('success', 'Berhasil menambahkan <b>' . $data['username'] . '</b> sebagai pengguna');
}
return redirect('admin/users');
}
set_alert('error', 'Terjadi kesalahan dalam penyimpanan pengguna <b>' . $data['username'] . '</b>');
return redirect($this->uri->path());
}
if ($id) {
$data['data'] = User::show([User::primary() => $id])->fetchOne();
}
return $this->render('user-form', $data);
break;
case 'delete':
if (User::del([User::primary() => $id])) {
set_alert('success', 'Pengguna berhasil terhapus');
} else {
set_alert('error', 'Terjadi kesalahan dalam penghapusan pengguna');
}
return redirect('admin/users');
break;
default:
$data['data'] = User::show();
return $this->render('user-table', $data);
break;
}
}
示例13: upload_file
function upload_file($global_url, $type, $file, $prefix, $upload_dir, $ini_max_upload)
{
/* ----------------------------------------------------------------------
* TYPE:
* string: images / files
* ----------------------------------------------------------------------
*/
$files_name = substr($file['name'], 0, -4);
$file_type = $file['type'];
if ($type === 'images') {
if ($file_type === 'image/jpeg') {
$file_type = '.jpg';
} else {
if ($file_type === 'image/png') {
$file_type = '.png';
} else {
if ($file_type === 'image/gif') {
$file_type = '.gif';
}
}
}
} else {
if ($type === 'files') {
if ($file_type === 'application/zip') {
$file_type = '.zip';
} else {
if ($file_type === 'application/x-rar-compressed') {
$file_type = '.rar';
} else {
if ($file_type === 'application/pdf') {
$file_type = '.pdf';
}
}
}
}
}
$uploads_dir = __DIR__ . '/../../../' . $upload_dir;
$userfile_name = cleanurl(str_replace(array('(', ')', ' '), '_', substr($files_name, 0, 20))) . $file_type;
$userfile_tmp = $file['tmp_name'];
$file_error = $file['error'];
$file_type = $file['type'];
$slideshow_size = $file['size'];
$prefix = $prefix . '-' . date('d-m-y-H-i-s') . '-';
$prod_img = $uploads_dir . $prefix . $userfile_name;
$filename = $upload_dir . $prefix . $userfile_name;
if ($type === 'images') {
$allowed_type = array('image/jpeg', 'image/png', 'image/gif');
} else {
if ($type === 'files') {
$allowed_type = array('application/zip', 'application/x-rar-compressed', 'application/pdf');
}
}
/* --- TOTAL SIZE SLIDESHOW --- */
if ($slideshow_size > $ini_max_upload) {
$type = 'danger';
$msg = 'Maximum file size: ' . price(1, $ini_max_upload) . 'Byte(s)';
set_alert($type, $msg);
safe_redirect('self');
/* --- FILE TYPE (IMAGE: JPG, PNG, GIF & FILES: PDF, ZIP) --- */
} else {
if (!in_array($file_type, $allowed_type)) {
$type = 'danger';
$msg = 'Only allowed images format: .jpg, .png, .gif & files format: .pdf, .zip, .rar';
set_alert($type, $msg);
safe_redirect('self');
} else {
if (!move_uploaded_file($userfile_tmp, $prod_img)) {
$type = 'danger';
$msg = 'Error: Permission denied, check folder: ' . $uploads_dir . ' permission';
set_alert($type, $msg);
safe_redirect('self');
} else {
if (move_uploaded_file($userfile_tmp, $prod_img) && $file_error == 0) {
}
}
}
}
return $filename;
}
示例14: delete
/**
* Menghapus data pada $table
*
* @param string $table Nama Tabel
* @param array $where Kondisi
* @return bool
*/
public function delete($table, $where = [])
{
$wheres = $this->_parseWhere($where);
try {
return $this->query("DELETE FROM `%s` %s", $table, $wheres);
} catch (Exception $e) {
set_alert('error', $e->getMessage());
return false;
}
}
示例15: delete_category
function delete_category($category_id)
{
$sql = "SELECT IFNULL(total_product_main,0)+IFNULL(total_product_child,0) AS total_product\n\t\t\t \n\t\t\t FROM tbl_category AS cat \n\t\t\t LEFT JOIN (SELECT product_category, COUNT(tbl_product.id) AS total_product_main FROM tbl_product\n\t\t\t WHERE product_delete!='1'\n\t\t\t GROUP BY product_category) AS prod\n\t\t\t ON cat.category_id = prod.product_category\n\t\t\t \n\t\t\t LEFT JOIN (SELECT COUNT(x.id) AS total_product_child, category_parent FROM tbl_product AS x LEFT JOIN tbl_category_relation AS y\n\t\t\t ON x.product_category = y.category_child\n\t\t\t \t WHERE product_delete!='1'\n\t\t\t \t GROUP BY category_parent) AS prod2\n\t\t\t \t ON cat.category_id = prod2.category_parent\n\t\t\t \n\t\t\t \t LEFT JOIN (SELECT * from tbl_category_relation WHERE relation_level = '1') AS relation\n\t\t\t \t ON cat.category_id = relation.category_child\n\t\t\t \t WHERE (category_id = '{$category_id}')";
$query = $this->conn->query($sql);
$row = array();
while ($result = $query->fetch_object()) {
array_push($row, $result);
}
$total_product = $row[0]->total_product;
if ($total_product != 0) {
$type = 'danger';
$msg = "Can't delete item(s) because it contains one or more item under it.";
} else {
$sql = "SELECT * from tbl_category WHERE category_id = '{$category_id}'";
$query = $this->conn->query($sql);
$result = $query->fetch_object();
if ($query->num_rows != null) {
$get_order_array = $query->fetch_object();
$category_order = $get_order_array->category_order;
}
$sql = "UPDATE tbl_category SET category_order = '(category_order - 1)' WHERE category_order > ?";
$stmt = $this->conn->prepare($sql);
if ($stmt === false) {
trigger_error('Database error: ' . $sql . ' Error: ' . $this->conn->errno . ' ' . $this->conn->error, E_USER_ERROR);
} else {
$stmt->bind_param("s", $category_order);
$stmt->execute();
}
$stmt->close();
$sql = "DELETE FROM tbl_category WHERE category_id = ?";
$stmt = $this->conn->prepare($sql);
if ($stmt === false) {
trigger_error('Database error: ' . $sql . ' Error: ' . $this->conn->errno . ' ' . $this->conn->error, E_USER_ERROR);
} else {
$stmt->bind_param("s", $category_id);
$stmt->execute();
}
$stmt->close();
$sql = "SELECT * from tbl_category_relation WHERE category_parent = '{$category_id}'";
$query = $this->conn->query($sql);
if ($query->num_rows != null) {
for ($counter = 1; $counter <= $query->num_rows; $counter++) {
$category_relation_array = $query->fetch_object();
$category_child = $category_relation_array->category_child;
$sql = "DELETE FROM tbl_category_relation WHERE category_parent = ? OR category_child = ?";
$stmt = $this->conn->prepare($sql);
if ($stmt === false) {
trigger_error('Database error: ' . $sql . ' Error: ' . $this->conn->errno . ' ' . $this->conn->error, E_USER_ERROR);
} else {
$stmt->bind_param("ss", $category_child, $category_child);
$stmt->execute();
}
$stmt->close();
$sql = "DELETE FROM tbl_category WHERE category_id = ?";
$stmt = $this->conn->prepare($sql);
if ($stmt === false) {
trigger_error('Database error: ' . $sql . ' Error: ' . $this->conn->errno . ' ' . $this->conn->error, E_USER_ERROR);
} else {
$stmt->bind_param("s", $category_child);
$stmt->execute();
}
$stmt->close();
}
}
$sql = "DELETE FROM tbl_category_relation WHERE category_child = ? OR category_parent = ?";
$stmt = $this->conn->prepare($sql);
if ($stmt === false) {
trigger_error('Database error: ' . $sql . ' Error: ' . $this->conn->errno . ' ' . $this->conn->error, E_USER_ERROR);
} else {
$stmt->bind_param("ss", $category_id, $category_id);
$stmt->execute();
}
$stmt->close();
$type = 'success';
$msg = "Successfully deleted category";
}
set_alert($type, $msg);
}