コード例 #1
0
ファイル: login.php プロジェクト: akivaron/toko
  public function reg()
  {
      $this->form_validation->set_rules('email', 'email', 'trim|required|xss_clean');
      $this->form_validation->set_rules('uname', 'username', 'trim|required|xss_clean');
      $this->form_validation->set_rules('pass', 'password', 'trim|required|xss_clean');
      if ($this->form_validation->run() == false) {
          $this->form_validation->set_message('cek_database', 'isikan semua field');
          redirect('login?reg');
      } else {
          $email = rtrim($this->input->post('email'));
          $uname = rtrim($this->input->post('uname'));
          $pass = rtrim($this->input->post('pass'));
          $ubaru = array('email' => $email, 'username' => $uname, 'password' => sha1($pass));
          $idbaru = $this->mweb->settable('user', $ubaru);
          if ($idbaru) {
              $notif = array('from' => getid_own(), 'iduser' => getid_min(), 'aksi' => 'register user', 'msg' => 'ada member baru dengan nama user <strong>' . getuname($idbaru) . '</strong><br/>
 					<a href="' . site_url('gudang/slug/4/4/5?id=' . $idbaru . '&tbl=5') . '">details</a>', 'time' => date('d-m-Y h:i:s'));
              $this->mweb->settable('notif', $notif);
              redirect('login?u=' . $idbaru, 'refresh');
          }
      }
  }
コード例 #2
0
ファイル: gudang.php プロジェクト: panahbiru/toko
    function insert()
    {
        if ($this->session->userdata('logged_in')) {
            $session_data = $this->session->userdata('logged_in');
            $idu = $session_data['id'];
            $idtbl = $this->input->post('tabel');
            $tabel = $this->mweb->getmanage_by_id($idtbl);
            switch ($idtbl) {
                case '1':
                    $exclude = array('user', 'log');
                    break;
                case '6':
                    $exclude = array('acc');
                    break;
                case '7':
                    $exclude = array('acc');
                    break;
                case '15':
                    $exclude = array('idreq', 'idimg', 'desc');
                    break;
                case '17':
                    $exclude = array('id');
                    break;
                default:
                    $exclude = array('');
                    break;
            }
            $stmt_list = create_statement($tabel, $exclude);
            $query = explode(',', $stmt_list);
            $data = array();
            $kolom = array();
            $ttempb = array();
            $liskol = $this->db->list_fields($tabel);
            $fkolm = array_shift(array_slice($liskol, 0, 1));
            $lid = $this->mweb->get_akhir($fkolm, $tabel);
            $gettempb = $this->mweb->get_tempbrg($lid, $idtbl);
            foreach ($query as $row) {
                $kolom[] = $row;
                switch ($row) {
                    case 'id':
                        $idnee = $this->input->post($row);
                        $idnee = $lid;
                        $data[] = $idnee;
                        break;
                    case 'time':
                        $data[] = date('d-m-Y h:i:s');
                        break;
                    case 'iduser':
                        $data[] = $session_data['id'];
                        break;
                    case 'Kenaikan_Harga':
                        $hbru = $this->input->post('Harga_Baru');
                        $hlma = $this->input->post('Harga_Lama');
                        if (!empty($hbru) && !empty($hlma) && $hbru > $hlma) {
                            $data[] = intval($hbru - $hlma);
                        } else {
                            $data[] = 0;
                        }
                        break;
                    case 'Description':
                        $set = $this->input->post('set');
                        $nmprod = $this->input->post('namaprod');
                        if (!empty($set) && !empty($nmprod)) {
                            $kdbl = $this->mweb->get_akhir('kdbarang', 'barang');
                            $this->db->set('a.status', 'success');
                            $this->db->set('b.kdbarang', $kdbl);
                            $this->db->where('a.idreq', $set);
                            $this->db->where('a.idreq = b.idreq');
                            $this->db->update('antrian as a, request as b');
                            $imm = $nmprod . '+';
                            $imm .= $this->input->post($row);
                            $data[] = $imm;
                        } else {
                            $data[] = $this->input->post($row);
                        }
                        break;
                    case 'kdbarang':
                        if ($tabel === 'postprod') {
                            $data[] = $this->input->post($row);
                        } else {
                            $data[] = implode('|', $gettempb);
                        }
                        break;
                    default:
                        $data[] = $this->input->post($row);
                        break;
                }
            }
            $setdata = array_combine($kolom, $data);
            $idlastt = $this->mweb->settable($tabel, $setdata);
            $isi = implode(',', $data);
            //-----------------------------------------
            $file = 'log.txt';
            $pathfile = APPPATH . 'views/' . $file;
            $tulislog = $session_data['id'] . ',' . date('Y-m-d h:i:s') . ',' . $tabel . ',' . $isi . "\n";
            if (file_exists($pathfile)) {
                $current = file_get_contents($pathfile);
                // Append a new person to the file
                $current .= $tulislog;
                $current .= "\r\n";
                // Write the contents back to the file
                file_put_contents($pathfile, $current);
            } else {
                $handle = fopen($pathfile, 'w') or die('Cannot open file:  ' . $pathfile);
                //implicitly creates file
                fwrite($handle, $tulislog);
            }
            if ($idlastt) {
                switch ($idtbl) {
                    case '1':
                        $this->db->where('idcus', $idlastt);
                        $this->db->update('cus', array('iduser' => $session_data['id']));
                        break;
                    case '3':
                        $sett = $this->input->post('set');
                        $kdbl = $this->mweb->get_akhir('kdbarang', 'barang');
                        if (getusereq($sett)) {
                            $idpeng = getusereq($sett);
                            $notifh = array('from' => $idu, 'iduser' => $idpeng, 'msg' => 'request barang dengan kode <strong>' . $sett . '</strong> success dengan harga jual Rp.<strong>' . gethrgbrg($idlastt) . '</strong>', 'time' => date('d-m-Y h:i:s'));
                            $settnotif = $this->mweb->settable('notif', $notifh);
                            if (!$settnotif) {
                                ?>
							<script type="text/javascript">alert('maaf terjadi kesalahan pada system :(');</script>
						<?php 
                                redirect('login', 'refresh');
                            }
                        }
                        break;
                    case '5':
                        $qqlast = $this->mweb->get_last_id($idlastt, $tabel);
                        foreach ($qqlast as $record) {
                            $pass = $record['password'];
                        }
                        $passbaru = sha1($pass);
                        $this->mweb->updatepass($idlastt, $passbaru);
                        break;
                    case '15':
                        $config['upload_path'] = FCPATH . 'uploads/';
                        $config['allowed_types'] = 'gif|jpg|png';
                        //load the upload library
                        $this->upload->initialize($config);
                        $this->upload->set_allowed_types('*');
                        $data['upload_data'] = '';
                        //if not successful, set the error message
                        if (!$this->upload->do_upload('userfile')) {
                            redirect(site_url('gudang/profile?tab=3&e=1'), 'refresh');
                        } else {
                            //else, set the success message
                            //$idlastt=$this->mweb->last_id_ins('idreq','request');
                            $data = array('msg' => "Upload success!");
                            $dataimg = $this->upload->data();
                            $postkdb = $this->input->post('kdbarang');
                            $desck = $this->input->post('namaprod');
                            if (empty($postkdb)) {
                                $descc = $desck;
                            } else {
                                $descc = $this->input->post('kdbarang');
                            }
                            $dtimg = array('idimg' => '', 'src' => $dataimg['full_path'], 'desc' => $descc);
                            $set = $this->mweb->setimage($dtimg);
                            $setupd = array('idimg' => $set, 'desc' => $desck);
                            $this->db->where('idreq', $idlastt);
                            $this->db->update('request', $setupd);
                            $setantri = array('idreq' => $idlastt, 'time' => date('d-m-Y h:i:s'));
                            $idant = $this->mweb->settable('antrian', $setantri);
                            if ($idant) {
                                if (!is_mimin()) {
                                    $notifmin = array('from' => $idu, 'iduser' => getid_min(), 'msg' => 'ada permintaan barang dengan kode <strong><a href="' . site_url('gudang/slug/17/4/21/a?id=' . $idlastt . '&tbl=15') . '">' . $idlastt . '</a></strong>', 'aksi' => 'request', 'time' => date('d-m-Y h:i:s'));
                                    $this->mweb->settable('notif', $notifmin);
                                }
                            }
                        }
                        break;
                    case '6':
                        if (!is_admin()) {
                            $msginv = array('from' => $idu, 'iduser' => getid_own(), 'aksi' => 'invoice', 'time' => date('d-m-Y h:i:s'), 'msg' => 'invoice kode <a href="' . site_url('gudang/slug/5/4/6/a?id=' . $idlastt . '&tbl=6') . '"><strong>' . $idlastt . '</strong></a>');
                            $this->mweb->settable('notif', $msginv);
                        }
                        break;
                    case '7':
                        if (!is_admin()) {
                            $msginv = array('from' => $idu, 'iduser' => getid_own(), 'aksi' => 'quotation', 'time' => date('d-m-Y h:i:s'), 'msg' => 'quotation kode <a href="' . site_url('gudang/slug/5/4/7/a?id=' . $idlastt . '&tbl=7') . '"><strong>' . $idlastt . '</strong></a>');
                            $this->mweb->settable('notif', $msginv);
                        }
                        break;
                    case '16':
                        $purc = $this->mweb->gettable_byid($fkolm, $idlastt, $tabel);
                        if (count($purc) > 0) {
                            foreach ($purc as $vpurc) {
                                $lb = rtrim($vpurc['linkbeli']);
                                $hb = rtrim($vpurc['hrg_beli']);
                            }
                            if (empty($lb) && empty($hb) || $hb === '0') {
                                $this->db->where('id', $idlastt);
                                $this->db->update('purchase', array('status' => 'p'));
                            } else {
                                if (strlen($lb) > 0 && empty($hb) || $hb === '0') {
                                    $this->db->where('id', $idlastt);
                                    $this->db->update('purchase', array('status' => 'w'));
                                } else {
                                    $this->db->where('id', $idlastt);
                                    $this->db->update('purchase', array('status' => 'wp'));
                                }
                            }
                        } else {
                            redirect('gudang?ep=' . $idlastt, 'refresh');
                        }
                        break;
                }
                redirect('gudang', 'refresh');
            } else {
                redirect('gudang?e=i', 'refresh');
            }
        } else {
            //If no session, redirect to login page
            redirect('login', 'refresh');
        }
    }