public function cekpasswordlama() { $id_akun = $this->session->userdata("id_akun_user"); $where = array("ID_USER" => $id_akun); $cek = $this->profilmodel->tampilData("mp_user", "*", $where, TRUE); if ($cek->PASSWORD == acakPass($this->input->post("passlama"))) { return TRUE; } else { $this->form_validation->set_message('cekpasswordlama', 'Password lama anda salah'); return FALSE; } }
function registerSubmit() { $this->form_validation->set_rules('username', 'Username', 'required|is_unique[mp_user.USERNAME]|max_length[50]'); $this->form_validation->set_rules('pass1', 'Password', 'required'); $this->form_validation->set_rules('pass2', 'Password Confirmation', 'required|matches[pass1]'); $this->form_validation->set_rules('nama', 'Nama', 'required|max_length[50]'); $this->form_validation->set_rules('provinsi', 'Provinsi', 'callback_cekProvinsi|required'); $this->form_validation->set_rules('kota', 'Kota', 'callback_cekKota|required'); $this->form_validation->set_rules('kecamatan', 'Kecamatan', 'callback_cekKecamatan|required'); $this->form_validation->set_rules('email', 'Email', 'required|is_unique[mp_akun.EMAIL]|max_length[50]|valid_email'); $this->form_validation->set_rules('g-recaptcha-response', 'Captcha', 'callback_cekRecaptcha'); if ($this->form_validation->run() == FALSE) { $this->session->set_flashdata('notif', validation_errors()); $this->session->set_flashdata('clr', 'danger'); redirect('user_register/'); //echo validation_errors(); } else { $akundata = array("NAMA" => $this->input->post("nama"), "ALAMAT" => $this->input->post("alamat"), "ID_PROVINSI" => $this->input->post("provinsi"), "ID_KABUPATEN" => $this->input->post("kota"), "ID_KECAMATAN" => $this->input->post("kecamatan"), "KELUHARAN" => $this->input->post("kelurahan"), "NO_HP" => $this->input->post("hp"), "EMAIL" => $this->input->post("email"), "STATUS_VALID" => 0, "USERNAME" => $this->input->post("username"), "FT_PROFIL" => ""); $this->registermodel->tambahData($akundata, "mp_akun"); $userdata = array("ID_LEVEL" => 3, "USERNAME" => $this->input->post("username"), "PASSWORD" => acakPass($this->input->post("pass1"))); $this->registermodel->tambahData($userdata, "mp_user"); $where = array("USERNAME" => $this->input->post("username")); $id_akun2 = $this->registermodel->tampilData("mp_akun", "*", $where, TRUE); $id_akun = $id_akun2->ID_AKUN; $where2 = array("USERNAME" => $this->input->post("username")); $data2 = array("ID_AUTH" => $id_akun); $this->registermodel->editData($data2, "mp_user", $where2); $email = verifikasiEmail($id_akun2->EMAIL); $baseurl = base_url(); $config = array("mailtype" => "html"); $this->email->initialize($config); $this->email->from('*****@*****.**', 'UKM INDOBABA'); $this->email->to($id_akun2->EMAIL); $this->email->cc('*****@*****.**'); $this->email->bcc('*****@*****.**'); $this->email->subject('Kode Verivikasi'); $this->email->message("Register sukses, silahkan klik link berikut<br/><br/><a href='" . base_url("user_register/verifikasi/" . $id_akun . "/" . $email) . "'>Link verifikasi</a>"); $this->email->send(); $this->session->set_flashdata('notif', "Link verifikasi berhasil terkirim ke email anda"); $this->session->set_flashdata('clr', 'success'); redirect('user_register/'); } }
function resetPasswordSubmit() { if ($this->session->userdata('id_pass_ses')) { $id = $this->session->userdata('id_pass_ses'); $email = base64_encode_fix($this->session->userdata('id_email_ses')); $h_email = $this->session->userdata('id_email_ses'); $sesi_random = base64_encode_fix($this->session->userdata('sesi_random')); $pass_baru = $this->input->post('pass_bar'); $pass_bar_con = $this->input->post('pass_bar_con'); if ($pass_baru != $pass_bar_con) { $this->session->set_flashdata('notif', 'Password yang Anda masukkan tidak sama'); $this->session->set_flashdata('clr', 'info'); redirect('login/resetPassword/' . $email . '/' . $sesi_random); exit; } $pas_acak = acakPass($pass_baru); $data = array("PASSWORD" => $pas_acak); $where = array("ID_USER" => $id); // Login otomatis $id_akun_auth = $this->db->query("SELECT * FROM mp_akun WHERE EMAIL='{$h_email}'")->row(); $data_login = array("id_akun_user" => $id, "user" => TRUE, "id_akun_auth" => $id_akun_auth->ID_AKUN); $this->session->set_userdata($data_login); $sql = $this->loginmodel->editData($data, 'mp_user', $where); if ($sql) { $this->session->unset_userdata(array('id_email_ses', 'sesi_random', 'id_pass_ses')); $this->session->set_flashdata('notif', 'Password Anda berhasil diganti'); $this->session->set_flashdata('clr', 'info'); redirect('user_profil'); } } else { echo "false"; } }
function tambahUkmSubmit() { $this->form_validation->set_rules('nm_toko', 'Nama Toko', 'required'); $this->form_validation->set_rules('des_toko', 'Deskripsi Toko', 'required'); $this->form_validation->set_rules('alamat', 'Alamat', 'required'); $this->form_validation->set_rules('id_penanggung_jwb', 'Penanggung Jawab', 'required|numeric'); $this->form_validation->set_rules('email', 'Email', 'valid_email'); $this->form_validation->set_rules('id_provinsi', 'Provinsi', 'required'); $this->form_validation->set_rules('id_kota', 'Kota', 'required'); $this->form_validation->set_rules('username', 'Username', 'required'); $this->form_validation->set_rules('password', 'Password', 'required'); $this->form_validation->set_rules('kelurahan', 'kelurahan', 'required'); if ($this->form_validation->run() == FALSE) { // Set flashdata $this->session->set_flashdata('nm_toko', set_value('nm_toko')); $this->session->set_flashdata('des_toko', set_value('des_toko')); $this->session->set_flashdata('alamat', set_value('alamat')); $this->session->set_flashdata('email', set_value('email')); $this->session->set_flashdata('username', set_value('username')); $this->session->set_flashdata('password', set_value('password')); $this->session->set_flashdata('notif', validation_errors()); $this->session->set_flashdata('clr', 'danger'); redirect('admin_ukm/tambahUkm'); } else { $this->session->set_flashdata('nm_toko', set_value('nm_toko')); $this->session->set_flashdata('des_toko', set_value('des_toko')); $this->session->set_flashdata('alamat', set_value('alamat')); $this->session->set_flashdata('email', set_value('email')); $this->session->set_flashdata('username', set_value('username')); } $nm_toko = $this->input->post('nm_toko'); $id_penanggung_jwb = $this->input->post('id_penanggung_jwb'); $des_toko = $this->input->post('des_toko'); $alamat = $this->input->post('alamat'); $no_hp = $this->input->post('no_hp'); $no_telp = $this->input->post('no_telp'); $email = $this->input->post('email'); $id_provinsi = $this->input->post('id_provinsi'); $id_kota = $this->input->post('id_kota'); $kecamatan = $this->input->post('kecamatan'); $kelurahan = $this->input->post('kelurahan'); $key_meta = $this->input->post('key_meta'); $des_meta = $this->input->post('des_meta'); $username = $this->input->post('username'); $get_username = getUsername($username, 'ukm'); $password = $this->input->post('password'); $pass_acak = acakPass($password); $s_bbm = $this->input->post('s_bbm'); $s_whatsapp = $this->input->post('s_whatsapp'); $level_user = 2; // Jangan hilangkan value pada form $this->session->set_flashdata('nm_toko', set_value('nm_toko')); $this->session->set_flashdata('des_toko', set_value('des_toko')); $this->session->set_flashdata('alamat', set_value('alamat')); $this->session->set_flashdata('email', set_value('email')); $this->session->set_flashdata('username', set_value('username')); $this->session->set_flashdata('password', set_value('password')); // Set kurir if ($this->input->post('jne')) { $jne = 1; } else { $jne = 0; } if ($this->input->post('tiki')) { $tiki = 1; } else { $tiki = 0; } if ($this->input->post('pos')) { $pos = 1; } else { $pos = 0; } //echo $_FILES['userImage']['name'];exit(); $ter = $this->adminukm->tampilData('mp_toko', 'MAX(ID_TOKO) AS TERAKHIR', $where = array(), TRUE); $namafilee = $ter->TERAKHIR + 1; //echo $namafilee;exit(); if ($_FILES['userImage']['name']) { if ($_FILES['profil']['name']) { $fnamePRO = $_FILES['profil']['name']; $sourcePathPRO = $_FILES['profil']['tmp_name']; $targetPathPRO = "./upload/profil/" . $namafilee . ".jpg"; if (move_uploaded_file($sourcePathPRO, $targetPathPRO)) { $resizePRO = './upload/profil/'; $namePRO = $namafilee . ".jpg"; $imgPRO = imagecreatefromjpeg($targetPathPRO); $widthPRO = imagesx($imgPRO); $heightPRO = imagesy($imgPRO); $new_widthPRO = 100; $new_heightPRO = 300; $tmp_imgPRO = imagecreatetruecolor($new_widthPRO, $new_heightPRO); imagecopyresized($tmp_imgPRO, $imgPRO, 0, 0, 0, 0, $new_widthPRO, $new_heightPRO, $widthPRO, $heightPRO); imagejpeg($tmp_imgPRO, "{$resize}{$name}"); $fname = $_FILES['userImage']['name']; $sourcePath = $_FILES['userImage']['tmp_name']; $targetPath = "./upload/sampul/" . $namafilee . ".jpg"; if (move_uploaded_file($sourcePath, $targetPath)) { $resize = './upload/sampul/'; $name = $namafilee . ".jpg"; $img = imagecreatefromjpeg($targetPath); $width = imagesx($img); $height = imagesy($img); $new_width = 500; $new_height = 300; $tmp_img = imagecreatetruecolor($new_width, $new_height); imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($tmp_img, "{$resize}{$name}"); $data_insert = array('ID_PROVINSI' => $id_provinsi, 'ID_KOTA' => $id_kota, 'NM_TOKO' => $nm_toko, 'DES_TOKO' => $des_toko, 'NO_HP' => $no_hp, 'NO_TELP' => $no_telp, 'EMAIL' => $email, 'ID_PENANGGUNG_JWB' => $id_penanggung_jwb, 'ALAMAT' => $alamat, 'S_BBM' => $s_bbm, 'S_WHATSAPP' => $s_whatsapp, 'DES_META' => $des_meta, 'KEY_META' => $key_meta, 'KELURAHAN' => $kelurahan, 'KECAMATAN' => $kecamatan, 'USERNAME' => $get_username, 'FT_PROFIL' => $namafilee . ".jpg", 'FT_SAMPUL' => $namafilee . ".jpg", 'STATUS_DELETE' => 0); } } } else { $fname = $_FILES['userImage']['name']; $sourcePath = $_FILES['userImage']['tmp_name']; $targetPath = "./upload/sampul/" . ${$namafilee} . ".jpg"; if (move_uploaded_file($sourcePath, $targetPath)) { $resize = './upload/sampul/'; $name = $namafilee . ".jpg"; $img = imagecreatefromjpeg($targetPath); $width = imagesx($img); $height = imagesy($img); $new_width = 500; $new_height = 300; $tmp_img = imagecreatetruecolor($new_width, $new_height); imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($tmp_img, "{$resize}{$name}"); $data_insert = array('ID_PROVINSI' => $id_provinsi, 'ID_KOTA' => $id_kota, 'NM_TOKO' => $nm_toko, 'DES_TOKO' => $des_toko, 'NO_HP' => $no_hp, 'NO_TELP' => $no_telp, 'EMAIL' => $email, 'ID_PENANGGUNG_JWB' => $id_penanggung_jwb, 'ALAMAT' => $alamat, 'S_BBM' => $s_bbm, 'S_WHATSAPP' => $s_whatsapp, 'DES_META' => $des_meta, 'KEY_META' => $key_meta, 'KELURAHAN' => $kelurahan, 'KECAMATAN' => $kecamatan, 'USERNAME' => $get_username, 'FT_SAMPUL' => $namafilee . ".jpg"); } } } elseif ($_FILES['profil']['name']) { $fname = $_FILES['profil']['name']; $sourcePath = $_FILES['profil']['tmp_name']; $targetPath = "./upload/profil/" . $namafilee . ".jpg"; if (move_uploaded_file($sourcePath, $targetPath)) { $resize = './upload/profil/'; $name = $namafilee . ".jpg"; $img = imagecreatefromjpeg($targetPath); $width = imagesx($img); $height = imagesy($img); $new_width = 500; $new_height = 300; $tmp_img = imagecreatetruecolor($new_width, $new_height); imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($tmp_img, "{$resize}{$name}"); $data_insert = array('ID_PROVINSI' => $id_provinsi, 'ID_KOTA' => $id_kota, 'NM_TOKO' => $nm_toko, 'DES_TOKO' => $des_toko, 'NO_HP' => $no_hp, 'NO_TELP' => $no_telp, 'EMAIL' => $email, 'ID_PENANGGUNG_JWB' => $id_penanggung_jwb, 'ALAMAT' => $alamat, 'S_BBM' => $s_bbm, 'S_WHATSAPP' => $s_whatsapp, 'DES_META' => $des_meta, 'KEY_META' => $key_meta, 'KELURAHAN' => $kelurahan, 'KECAMATAN' => $kecamatan, 'USERNAME' => $get_username, 'FT_PROFIL' => $namafilee . ".jpg", 'STATUS_DELETE' => 0); } } else { $data_insert = array('ID_PROVINSI' => $id_provinsi, 'ID_KOTA' => $id_kota, 'NM_TOKO' => $nm_toko, 'DES_TOKO' => $des_toko, 'NO_HP' => $no_hp, 'NO_TELP' => $no_telp, 'EMAIL' => $email, 'ID_PENANGGUNG_JWB' => $id_penanggung_jwb, 'ALAMAT' => $alamat, 'S_BBM' => $s_bbm, 'S_WHATSAPP' => $s_whatsapp, 'DES_META' => $des_meta, 'KEY_META' => $key_meta, 'KELURAHAN' => $kelurahan, 'KECAMATAN' => $kecamatan, 'USERNAME' => $get_username, 'STATUS_DELETE' => 0); } $data_user = array('USERNAME' => $get_username, 'PASSWORD' => $pass_acak, 'ID_LEVEL' => $level_user); $where = array('USERNAME' => $get_username); // Masukkan data $this->adminukm->tambahData($data_insert, 'mp_toko'); $idtokochat = $this->db->insert_id(); $datapesannotif = array("ID_TOKO" => $idtokochat, "NOTIF_BINTANG_UKM" => 1, "NOTIF_BINTANG_ADMIN" => 0, "NOTIF_SUARA_UKM" => 1); $this->adminukm->tambahData($datapesannotif, 'mp_pesan_notif'); $datapesan = array("ISI_PESAN" => "Selamat Bergabung Dengan Indobaba", "ID_TOKO" => $idtokochat, "TGL_PESAN" => date("Y-m-d H:i:s"), "LEVEL" => 1); $this->adminukm->tambahData($datapesan, 'mp_pesan'); $this->adminukm->tambahData($data_user, 'mp_user'); $id_auth = $this->adminukm->tampilData('mp_toko', 'ID_TOKO,USERNAME', $where, TRUE); // Edit dan tambahkan ID AUTH $where_auth = array('ID_AUTH' => $id_auth->ID_TOKO); $this->adminukm->editData('mp_user', $where_auth, $where); $data_kurir = array('JNE' => $jne, 'TIKI' => $tiki, 'POS' => $pos, 'ID_TOKO' => $id_auth->ID_TOKO); $this->adminukm->tambahData($data_kurir, 'mp_kurir'); $this->session->set_flashdata('notif', 'Tambah UKM sukses'); $this->session->set_flashdata('clr', 'success'); redirect('admin_ukm/tambahUkm'); }
public function ubahpasswordAdminsubmit() { $this->form_validation->set_rules('PASSWORD', 'PASSWORD', 'required'); $this->form_validation->set_rules('PASSWORDLM', 'password lama', 'required'); $this->form_validation->set_rules('PASSWORD2', 'Confrim password', 'required|matches[PASSWORD]'); if ($this->form_validation->run() == FALSE) { $this->session->set_flashdata('notif', validation_errors()); $this->session->set_flashdata('clr', 'danger'); redirect('admin_user/ubahpasswordAdmin'); } $cekpass = $this->user->tampilData('mp_user'); foreach ($cekpass as $row) { if ($row->PASSWORD == acakPass($this->input->post('PASSWORD'))) { $this->session->set_flashdata('notif', 'Ulangi Password sudah terpakai'); $this->session->set_flashdata('clr', 'warning'); redirect('admin_user/ubahpasswordAdmin'); } } $where = array('ID_USER' => $this->session->userdata('id_akun_admin'), 'PASSWORD' => acakPass($this->input->post('PASSWORDLM'))); $data = array('PASSWORD' => acakPass($this->input->post('PASSWORD'))); $update = $this->user->editData($data, 'mp_user', $where); if ($update) { $this->session->set_flashdata('notif', 'admin berhasil di tambah'); $this->session->set_flashdata('clr', 'success'); redirect('admin_user'); } else { $this->session->set_flashdata('notif', 'maaf data tidak bisa masuk ulangi lagi'); $this->session->set_flashdata('clr', 'warning'); redirect('admin_user'); } }