コード例 #1
0
 function loadExcel($file = false)
 {
     // error_reporting(E_ALL ^ E_NOTICE);
     global $CONFIG, $EXCEL;
     if (!$file) {
         return false;
     }
     if (!in_array($_FILES[$file]['type'], $EXCEL[0]['filetype'])) {
         return false;
     }
     if (array_key_exists('admin', $CONFIG)) {
         $this->configkey = 'admin';
     }
     if (array_key_exists('dashboard', $CONFIG)) {
         $this->configkey = 'dashboard';
     }
     $excel = "";
     $filename = $_FILES[$file]['tmp_name'];
     $excelEngine = LIBS . 'excel/excel_reader' . $CONFIG[$this->configkey]['php_ext'];
     if (is_file($excelEngine)) {
         require_once $excelEngine;
         $excel = new Spreadsheet_Excel_Reader($filename);
         logFile('load excel success');
     } else {
         logFile('excel lib not found');
     }
     return $excel;
 }
コード例 #2
0
ファイル: mlogin.php プロジェクト: TrinataBhayanaka/cat.polda
 function insert_data($data, $table)
 {
     $check = $this->insert($data, $table);
     logFile($check);
     if ($check) {
         return true;
     } else {
         return false;
     }
 }
コード例 #3
0
ファイル: mgallery.php プロジェクト: Trinata/pondokgurubakti
 function inputgallery($judul, $deskripsi, $namafile, $id_album, $jns_file)
 {
     $query = "INSERT INTO gallery(id_album,nm_gallery,jns_file,path_lokasi,deskripsi)\n\t\t\t\t\tVALUES('" . $id_album . "','" . $judul . "','" . $jns_file . "','" . $namafile . "','" . $deskripsi . "')";
     //eksekusi query
     logFile($query);
     $exec = $this->query($query, 0);
     //kondisi apabila eksekusi berhasil mengembalikan notif 1, jika gagal mencetak query gagal
     if ($exec) {
         return 1;
     } else {
         pr('query gagal');
     }
 }
コード例 #4
0
ファイル: home.php プロジェクト: Trinata/pondokgurubakti
 function logout()
 {
     global $basedomain;
     $doLogout = $this->userHelper->logoutUser();
     if ($doLogout) {
         redirect($basedomain . 'logout.php');
         exit;
     } else {
         redirect($basedomain);
         logFile('can not logout user');
         exit;
     }
 }
コード例 #5
0
ファイル: mgallery.php プロジェクト: Trinata/pondokgurubakti
 function inputgallery($judul, $deskripsi, $filename, $id_gmb, $jns_file, $status, $tipe_album)
 {
     $date = date("Y-m-d H:i:s");
     $query = "INSERT INTO gallery(other_id,judul,jns_file,filename,deskripsi,status,date_upload,tipe_album)\n\t\t\t\t\tVALUES('" . $id_gmb . "','" . $judul . "','" . $jns_file . "','" . $filename . "','" . $deskripsi . "','" . $status . "', '{$date}', '" . $tipe_album . "')";
     //eksekusi query
     logFile($query);
     $exec = $this->query($query, 0);
     //kondisi apabila eksekusi berhasil mengembalikan notif 1, jika gagal mencetak query gagal
     if ($exec) {
         return 1;
     } else {
         pr('query gagal');
     }
 }
コード例 #6
0
 function dataAset($oldSatker, $newSatker, $debug = false)
 {
     /*
         - ambil aset di satker lama
         - looping asetid, ambil kode kelompok untuk menentukan no register baru
         - ambil noregister terakhir di satker baru dengan kode kelompok
         - bentuk satker, lokasi, no register
         - insert ke tabel tmp_merger
     
         execute
         - select data dari tmp_merger
         - update ke tabel masing2
     */
     $sql = array('table' => "aset AS a", 'field' => "a.Aset_ID, a.kodeKelompok, a.kodeSatker, a.kodeLokasi, a.noRegister, a.TipeAset, a.Tahun", 'condition' => "a.kodeSatker = '{$oldSatker}'");
     $aset = $this->db->lazyQuery($sql, $debug);
     if ($aset) {
         foreach ($aset as $key => $value) {
             $listTableAbjad = array('A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6);
             $sql = array('table' => "aset AS a, satker AS s", 'field' => "a.kodeLokasi, s.NamaSatker", 'condition' => "a.kodeSatker = '{$newSatker}' AND s.kd_Ruang IS NULL", 'joinmethod' => 'LEFT JOIN', 'join' => 'a.kodeSatker = s.kode', 'limit' => 1);
             $satker = $this->db->lazyQuery($sql, $debug);
             $table = $this->getTableKibAlias($listTableAbjad[$value['TipeAset']]);
             $tmpKodeLokasi = explode('.', $satker[0]['kodeLokasi']);
             $tmpKodeSatker = explode('.', $newSatker);
             $prefix = $tmpKodeLokasi[0] . '.' . $tmpKodeLokasi[1] . '.' . $tmpKodeLokasi[2];
             $prefixkodesatker = $tmpKodeSatker[0] . '.' . $tmpKodeSatker[1];
             $prefixTahun = substr($value['Tahun'], 2, 2);
             $postfixkodeSatker = $tmpKodeSatker[2] . '.' . $tmpKodeSatker[3];
             $implLokasi = $prefix . '.' . $prefixkodesatker . '.' . $prefixTahun . '.' . $postfixkodeSatker;
             $data[$key]['Aset_ID'] = $value['Aset_ID'];
             $data[$key]['kodeSatker'] = $newSatker;
             $data[$key]['oldKodeSatker'] = $oldSatker;
             $data[$key]['NamaSatker'] = $satker[0]['NamaSatker'];
             $data[$key]['kodeKelompok'] = $value['kodeKelompok'];
             $data[$key]['kodeLokasi'] = $implLokasi;
             $data[$key]['TipeAset'] = $listTableAbjad[$value['TipeAset']];
         }
         $totalAset = count($aset);
         $dataevent = serialize($data);
         $shufle = str_shuffle('ABCDEFGHIJKLMNOPQR');
         logFile($dataevent, $shufle);
         $date = date('Y-m-d H:i:s');
         $sql = array('table' => "tmp_merger", 'field' => "Aset, event, target, data, create_date", 'value' => "{$totalAset}, '{$oldSatker}', '{$newSatker}', '{$shufle}','{$date}'");
         usleep(100);
         $res = $this->db->lazyQuery($sql, $debug, 1);
         if ($res) {
             echo "Sukses insert data \n";
         }
     }
 }
コード例 #7
0
 function select_data_selesai($years, $month)
 {
     $filter = "";
     if ($years and $years != 3) {
         $filter .= " AND YEAR(tanggal) = '{$years}'";
     }
     if ($month and $month != 15) {
         $filter .= " AND MONTH(tanggal) = '{$month}'";
     }
     $query = "SELECT COUNT(1) AS total FROM bsn_pengaduan WHERE status = '4' {$filter}";
     logFile($query);
     $result = $this->fetch($query);
     // pr($result);
     return $result;
 }
コード例 #8
0
 function forgotPassword()
 {
     global $CONFIG;
     $token = _p('token');
     $this->view->assign('status', true);
     if ($token) {
         // pr($_POST);
         $getToken = $this->loginHelper->getUserEmail(_p('email'), true);
         if ($getToken) {
             // send mail before activate account
             $dataArr['email'] = $getToken['email'];
             $dataArr['username'] = $getToken['username'];
             $dataArr['password'] = $getToken['password'];
             $dataArr['token'] = sha1('reset' . $getToken['email']);
             $dataArr['validby'] = $getToken['email_token'];
             $dataArr['regfrom'] = 1;
             $dataArr['reset'] = 1;
             $inflatData = encode(serialize($dataArr));
             logFile($inflatData);
             $to = $getToken['email'];
             $from = $CONFIG['email']['EMAIL_FROM_DEFAULT'];
             // $msg = "To activate your account please <a href='{$basedomain}login/validate/?ref={$inflatData}'>click here</a>";
             $this->view->assign('email', $getToken['email']);
             $this->view->assign('username', $getToken['username']);
             $this->view->assign('encode', $inflatData);
             $this->view->assign('content', "reset");
             $msg = "<p>Hi " . $getToken['username'] . "!</p>";
             $msg .= $this->loadView('emailTemplate');
             // try to send mail
             // pr($getToken);
             // exit;
             $sendMail = sendGlobalMail($to, $from, $msg, true);
             logFile('mail reset account send ' . serialize($sendMail));
             $this->view->assign('status', true);
         } else {
             $this->view->assign('status', false);
         }
         // $this->activityHelper->updateEmailLog(false,$to,'account',0);
         /*$verifiedData = $this->loginHelper->resetAccount($to);
          	if ($verifiedData){
          		echo 'true';
          	}*/
     }
     return $this->loadView('forgot-password');
 }
コード例 #9
0
 function generateEmail($email = false, $username = false, $regfrom = 1, $token = CODEKIR)
 {
     global $CONFIG, $basedomain;
     if (!$email && !$username) {
         return false;
     }
     $dataArr['email'] = $email;
     $dataArr['username'] = $username;
     $dataArr['token'] = sha1('register' . $email);
     $dataArr['validby'] = $token;
     $dataArr['regfrom'] = $regfrom;
     logFile('token ori : ' . $token);
     $inflatData = encode(serialize($dataArr));
     logFile(serialize($dataArr));
     $return['to'] = $email;
     $return['from'] = $CONFIG['email']['EMAIL_FROM_DEFAULT'];
     $return['subject'] = "[NOTIFICATION]";
     $return['msg'] = "To activate your account please <a href='{$basedomain}login/validate/?ref={$inflatData}'>click here</a>";
     $return['encode'] = $inflatData;
     return $return;
 }
コード例 #10
0
			$query2 = "INSERT INTO Satker VALUES (NULL, NULL, '$data->KodeSektor', '$data->KodeSatker', ".$NamaSatker.", NULL, 
					0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, {$Gudang}, ".$KodeUnit.", '$tmp_kode', ".$KotaSatker.", ".$BuatKIB.",NULL)";
			// pr($query2);
			$result2 = mysql_query($query2) or die (mysql_error());
			usleep(500);
			*/

			// pr($data);
			// pr($_POST);
			$tmpKodeRuang ="$data->KodeSatker.$_POST[KodeUnit].$_POST[KodeUPB].$_POST[KodeRuangan]"; 
			$tmp_kode = "$data->KodeSatker.$_POST[KodeUnit].$_POST[KodeUPB]";
			$query3 = "INSERT INTO Satker (Satker_ID, Tahun, KodeSektor, KodeSatker, NamaSatker, AlamatSatker, NGO, RAND_ID, IndukSatker, NGO1_ID, NGO2_ID, NGO3_ID, NGO4_ID, CNOTE1, CNOTE2, Gudang, KodeUnit, Tmp_KodeSatker, KotaSatker, BuatKIB, Kd_Ruang, kode)  VALUES (NULL, NULL, '$data->KodeSektor', '$data->KodeSatker', ".$NamaSatker.", NULL, 
					0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, {$Gudang}, ".$KodeUnit.", '$tmpKodeRuang', ".$KotaSatker.", ".$BuatKIB.",{$KodeRuangan},'$tmp_kode')";
			// pr($query3);

			logFile($query3);
			$result3 = mysql_query($query3) or die (mysql_error());

			// exit;
			if ($result3 > 0) echo "<script type='text/javascript'>alert('Sukses'); window.location.href='?page=$_GET[page]&a=v'; </script>" ;
			else echo '<script type=text/javascript>alert("Gagal");</script>';
		}
		else
		{
			echo '<script type=text/javascript>alert("Silahkan mengisi form Ruang");</script>' ;
		}
		/*
		$query = "INSERT INTO Satker VALUES (NULL, NULL, ".$KodeSektor.", NULL, ".$NamaSatker.", NULL, 
				0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, 0)";
		$result = mysql_query($query) or die (mysql_error());
		$query1 = "INSERT INTO Satker VALUES (NULL, NULL, ".$KodeSektor.", ".$KodeSatker.", ".$NamaSatker.", NULL, 
コード例 #11
0
function sendGlobalMail($to, $from, $msg, $config = true)
{
    global $CONFIG, $LOCALE;
    if (!$config) {
        @mail($to, "[ NOTIFICATION ] Flora Kalbar", $msg, "From: {$from}\n");
        return array('message' => 'success send mail', 'result' => true);
    }
    require_once LIBS . "PHPMailer/class.phpmailer.php";
    if ($from != '') {
        $from = $from;
    } else {
        $from = $CONFIG['email']['EMAIL_FROM_DEFAULT'];
    }
    $mail = new PHPMailer(true);
    $mail->IsSMTP();
    // telling the class to use SMTP
    try {
        logFile('ready to send mail');
        $mail->Host = $CONFIG['email']['EMAIL_SMTP_HOST'];
        // SMTP server
        $mail->SMTPDebug = 1;
        // enables SMTP debug information (for testing)
        $mail->SMTPAuth = true;
        // enable SMTP authentication
        $mail->SMTPSecure = "ssl";
        // sets the prefix to the servier
        $mail->Host = "smtp.gmail.com";
        // sets GMAIL as the SMTP server
        $mail->Port = 465;
        // set the SMTP port for the GMAIL server
        $mail->Username = $CONFIG['email']['EMAIL_FROM_DEFAULT'];
        // GMAIL username
        $mail->Password = $CONFIG['email']['EMAIL_SMTP_PASSWORD'];
        // GMAIL password
        $mail->AddAddress($to);
        $mail->SetFrom($CONFIG['email']['EMAIL_FROM_DEFAULT'], 'No Reply Account');
        $mail->Subject = "[ NOTIFICATION ] Flora Kalbar";
        $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
        // optional - MsgHTML will create an alternate automatically
        $mail->MsgHTML($msg);
        $result = $mail->Send();
        logFile('status send = ' . $result);
        if ($result) {
            return array('message' => 'success send mail', 'result' => true, 'res' => $result);
        } else {
            return array('message' => 'error mail setting', 'result' => false, 'res' => $mail->ErrorInfo);
        }
    } catch (phpmailerException $e) {
        // echo $e->errorMessage(); //Pretty error messages from PHPMailer
    } catch (Exception $e) {
        // echo $e->getMessage(); //Boring error messages from anything else!
    }
}
コード例 #12
0
 /**
  * @todo extract zip function basedomain/zip/extract
  * 
  * @see s_linux_unzip Function
  * @see unzip Function
  * @see createFolder Function
  * @see getContents Function
  * @see resize & crop Function
  * @see validateUsername Function
  * @see imagezip class
  * 
  * */
 function extract($status = NULL, $msg = NULL, $data = NULL)
 {
     global $CONFIG;
     $name = $_POST['imagezip'];
     $path = '';
     $path_file = $CONFIG['default']['upload_path'];
     //get data user from session
     $session = new Session();
     //$sess_user = $session->get_session();
     //$sess_data = $sess_user['ses_user'];
     $sess_data = $session->get_session();
     $username = $sess_data['login']['username'];
     $personID = $sess_data['login']['id'];
     $password = $sess_data['login']['password'];
     if (empty($username) || empty($personID) || empty($password)) {
         $status = "error";
         $msg = "Kesalahan terjadi saat validasi data pengguna, silakan logout kemudian login kembali";
         echo json_encode(array('status' => $status, 'message' => $msg));
         exit;
     }
     //$email = $_POST['email'];
     /*$username = $_POST['username'];
             
             $validateUsername = $this->validateUsername($username);
     
             if($validateUsername['status'] != 'success'){
                 $status = "error";
                 $msg = "Error occured while validating username";
                 
                 echo json_encode(array('status' => $status, 'message' => $msg));
                 exit;
             }
             
             $personID = $validateUsername['personID'];*/
     // input with email
     /*$validateEmail = $this->validateEmail($email);
       if($validateEmail['status'] != 'success'){
           $status = "error";
           $msg = "Error occured while validating email";
           
           echo json_encode(array('status' => $status, 'message' => $msg));
           exit;
       }
       $personID = $validateEmail['personID'];
       $username = $validateEmail['short_namecode'];*/
     //end input with email
     //move zip file to tmp folder
     $copy_zip = sftpServices($CONFIG['default']['hostname'], $username, $password, $name);
     logFile($copy_zip);
     if (!$copy_zip) {
         $status = "error";
         $msg = "Kesalahan saat mengambil file zip atau file zip tidak ditemukan";
         echo json_encode(array('status' => $status, 'message' => $msg));
         exit;
     }
     if (!empty($name)) {
         if (preg_match('#\\.(zip|ZIP)$#i', $name)) {
             $tmp_path = md5($name);
             $path_extract = $path_file . 'imgprocess/' . $tmp_path;
             $file = $path_file . $name;
             //check file zip exist
             if (!file_exists($file)) {
                 $status = "error";
                 $msg = "Sistem tidak dapat menemukan file yang ditentukan";
                 echo json_encode(array('status' => $status, 'message' => $msg));
                 exit;
             }
             if ($CONFIG['default']['unzip'] == 's_linux_unzip') {
                 s_linux_unzip($file, $path_extract);
             } elseif ($CONFIG['default']['unzip'] == 'zipArchive') {
                 unzip($file, $path_extract);
             }
             $path_data = 'public_assets/';
             //$path_user = $path_data.$username;
             $path_img = $path_data . '/img';
             $path_img_ori = $path_img . '/ori';
             $path_img_1000px = $path_img . '/1000px';
             $path_img_500px = $path_img . '/500px';
             $path_img_100px = $path_img . '/100px';
             $toCreate = array($path_img, $path_img_ori, $path_img_1000px, $path_img_500px, $path_img_100px);
             $permissions = 0755;
             if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                 createFolder($toCreate, $permissions);
             } else {
                 shell_createFolder($toCreate);
             }
             $images = $this->GetContents($path_extract);
             $list = count($images);
             $dataNotExist = array();
             foreach ($images as $image) {
                 $entry = $image['filename'];
                 $path_entry = $image['path'];
                 $len = strlen($path_extract);
                 $folder = substr($path_entry, $len);
                 if (preg_match('#\\.(jpg|jpeg|JPG|JPEG)$#i', $entry)) {
                     $image_name_encrypt = md5(str_shuffle($CONFIG['default']['salt'] . $entry));
                     $fileinfo = getimagesize($path_entry . '/' . $entry);
                     if (!$fileinfo) {
                         $status = "error";
                         $msg = "Tidak ada informasi jenis berkas";
                     } else {
                         $valid_types = array(IMAGETYPE_JPEG);
                         $valid_mime = array('image/jpeg');
                         if (in_array($fileinfo[2], $valid_types) || in_array($fileinfo['mime'], $valid_mime)) {
                             $mime = true;
                         } else {
                             $mime = false;
                         }
                         if ($mime) {
                             //check file exist here
                             //$dataExist = $this->imagezip->dataExist($entry);
                             $dataExist = $this->imagezip->imageExist($entry);
                             //add file information to array
                             $fileToInsert = array('filename' => $entry, 'md5sum' => $image_name_encrypt, 'directory' => $folder, 'mimetype' => $fileinfo['mime']);
                             if ($dataExist) {
                                 //get detail image
                                 $detail_image = $this->imagezip->get_image_by_name($entry);
                                 if ($detail_image['md5sum']) {
                                     $delete_image = array($path_img_ori . '/' . $detail_image['md5sum'] . '.ori.jpg', $path_img_1000px . '/' . $detail_image['md5sum'] . '.1000px.jpg', $path_img_500px . '/' . $detail_image['md5sum'] . '.500px.jpg', $path_img_100px . '/' . $detail_image['md5sum'] . '.100px.jpg');
                                     //delete old image
                                     $this->delete_img($delete_image);
                                 }
                                 copy($path_entry . "/" . $entry, $path_img_ori . '/' . $image_name_encrypt . '.ori.jpg');
                                 copy($path_entry . "/" . $entry, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg');
                                 if (!@copy($path_entry . "/" . $entry, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg')) {
                                     $status = "error";
                                     $msg = error_get_last();
                                 } else {
                                     $src_tmp = $path_entry . "/" . $entry;
                                     $dest_1000px = $CONFIG['default']['root_path'] . '/' . $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg';
                                     $dest_500px = $CONFIG['default']['root_path'] . '/' . $path_img_500px . '/' . $image_name_encrypt . '.500px.jpg';
                                     $dest_100px = $CONFIG['default']['root_path'] . '/' . $path_img_100px . '/' . $image_name_encrypt . '.100px.jpg';
                                     if ($fileinfo[0] >= 1000 || $fileinfo[1] >= 1000) {
                                         if ($fileinfo[0] > $fileinfo[1]) {
                                             $percentage = 1000 / $fileinfo[0];
                                             $config['width'] = $percentage * $fileinfo[0];
                                             $config['height'] = $percentage * $fileinfo[1];
                                         } else {
                                             $percentage = 1000 / $fileinfo[1];
                                             $config['width'] = $percentage * $fileinfo[0];
                                             $config['height'] = $percentage * $fileinfo[1];
                                         }
                                         $this->resize_pic($src_tmp, $dest_1000px, $config);
                                         unset($config);
                                     }
                                     //Set cropping for y or x axis, depending on image orientation
                                     if ($fileinfo[0] > $fileinfo[1]) {
                                         $config['width'] = $fileinfo[1];
                                         $config['height'] = $fileinfo[1];
                                         $config['x_axis'] = $fileinfo[0] / 2 - $config['width'] / 2;
                                         $config['y_axis'] = 0;
                                     } else {
                                         $config['width'] = $fileinfo[0];
                                         $config['height'] = $fileinfo[0];
                                         $config['x_axis'] = 0;
                                         $config['y_axis'] = $fileinfo[1] / 2 - $config['height'] / 2;
                                     }
                                     $this->cropToSquare($src_tmp, $dest_500px, $config);
                                     unset($config);
                                     //set new config
                                     $config['width'] = 500;
                                     $config['height'] = 500;
                                     $this->resize_pic($dest_500px, $dest_500px, $config);
                                     unset($config);
                                     $config['width'] = 100;
                                     $config['height'] = 100;
                                     $this->resize_pic($dest_500px, $dest_100px, $config);
                                     unset($config);
                                     //update data
                                     $insertImage = $this->imagezip->updateImage($personID, $fileToInsert);
                                 }
                                 // end if copy
                             } else {
                                 //add data information to array
                                 array_push($dataNotExist, $fileToInsert);
                             }
                         }
                     }
                 }
             }
             $count_dataNotExist = count($dataNotExist);
             if ($list == $count_dataNotExist) {
                 $status = 'warning';
                 $msg = 'File berhasil diekstrak. Tidak ada gambar yang sesuai dengan data.';
                 $data['dataNotExist'] = $dataNotExist;
             } else {
                 //send dataNotExist information to user
                 $status = 'success';
                 $msg = 'File berhasil diekstrak.';
                 $data['dataNotExist'] = $dataNotExist;
             }
             deleteDir($path_extract);
         } else {
             $status = "error";
             $msg = 'Nama file harus file zip';
         }
     } else {
         $status = "error";
         $msg = 'Nama file tidak boleh kosong';
     }
     echo json_encode(array('status' => $status, 'message' => $msg, 'data' => $data));
     exit;
 }
コード例 #13
0
 /**
  * @todo commit sql transaction
  * 
  * @return boolean true/false
  * 
  * */
 function commitTransaction()
 {
     $this->commit();
     logFile('====COMMIT TRANSACTION====');
     return true;
 }
コード例 #14
0
 /**
  * @todo check if twitter of user exist or not
  * 
  * @param $data = inputted twitter
  * @return boolean
  */
 function checkTwitter($data)
 {
     if ($data == '') {
         return true;
     } else {
         $sql = "SELECT COUNT(`id`) AS total FROM `person` WHERE `twitter` = '" . $data . "' ";
         $res = $this->fetch($sql, 0);
         if ($res['total'] > 0) {
             logFile('Twitter EXIST/');
             return false;
         }
     }
     return true;
 }
コード例 #15
0
ファイル: UssdLogin.php プロジェクト: buddhiv/unipro3
            $_SESSION['menu-Opt'] = $menuName;
            //Assign previous session menu name
            break;
    }
    if ($receiver->getMessage() == "000") {
        $responseExitMsg = "Exit Program!";
        $response = loadUssdSender($sessionId, $responseExitMsg);
        session_destroy();
    }
    if ($receiver->getMessage() == "exit") {
        $responseExitMsg = "Exit Program!";
        $response = loadUssdSender($sessionId, $responseExitMsg);
        session_destroy();
    } else {
        logFile("Selected response message := " . $responseMsg[$menuName]);
        logFile("cat" . $_SESSION['cat']);
        //$response = loadUssdSender($sessionId, $responseMsg[$menuName]);
        $response = send($sessionId, $responseMsg[$menuName], $address);
    }
}
/*
    Get the session id and Response message as parameter
    Create sender object and send ussd with appropriate parameters
**/
function send($sessionId, $responseMessage, $destinationAddress)
{
    $password = "******";
    if ($responseMessage == "000") {
        $ussdOperation = "mt-fin";
    } else {
        $ussdOperation = "mt-cont";
コード例 #16
0
 /**
  * @todo create new user
  *           
  * @return $statusName and $msgName = status and message for validating name
  * @return $statusEmail and $msgEmail = status and message for validating email
  * @return $statusUsername and $msgUsername = status and message for validating username
  * @return $statusTwitter and $msgTwitter = status and message for validating twitter                  
  */
 function doSignup()
 {
     global $CONFIG;
     $data = $_POST;
     $checkEmail = $this->loginHelper->checkEmail($data['email']);
     $checkUsername = $this->loginHelper->checkUsername($data['username']);
     $checkTwitter = $this->loginHelper->checkTwitter($data['twitter']);
     if ($checkEmail !== true || $checkUsername !== true || $checkTwitter !== true) {
         $statusEmail = "";
         $msgEmail = "";
         $statusUsername = "";
         $msgUsername = "";
         $statusTwitter = "";
         $msgTwitter = "";
         if ($checkEmail !== true) {
             $statusEmail = "exist";
             $msgEmail = "Email already exist";
         }
         if ($checkUsername !== true) {
             $statusUsername = "******";
             $msgUsername = "******";
         }
         if ($checkTwitter !== true) {
             $statusTwitter = "exist";
             $msgTwitter = "Twitter already exist";
         }
         echo json_encode(array('statusEmail' => $statusEmail, 'msgEmail' => $msgEmail, 'statusUsername' => $statusUsername, 'msgUsername' => $msgUsername, 'statusTwitter' => $statusTwitter, 'msgTwitter' => $msgTwitter));
         exit;
     }
     // else{
     //     echo json_encode(array('status' => 'error'));
     //     exit;
     // }
     if ($checkEmail && $checkUsername && $checkTwitter) {
         $signup = $this->loginHelper->createUser($data);
         // uncomment in server
         // if ($signup){
         $getToken = $this->loginHelper->getEmailToken($data['username']);
         // send mail before activate account
         $dataArr['email'] = $data['email'];
         $dataArr['username'] = $data['username'];
         $dataArr['password'] = $data['password'];
         $dataArr['token'] = sha1('register' . $data['email']);
         $dataArr['validby'] = $getToken['email_token'];
         $dataArr['regfrom'] = 1;
         $inflatData = encode(serialize($dataArr));
         logFile($inflatData);
         $to = $data['email'];
         $from = $CONFIG['email']['EMAIL_FROM_DEFAULT'];
         // $msg = "To activate your account please <a href='{$basedomain}login/validate/?ref={$inflatData}'>click here</a>";
         $this->view->assign('email', $data['email']);
         $this->view->assign('username', $data['username']);
         $this->view->assign('encode', $inflatData);
         $this->view->assign('content', "pembuatan");
         $msg = "<p>Hi " . $data['username'] . "!</p>";
         $msg .= $this->loadView('emailTemplate');
         // try to send mail
         $sendMail = sendGlobalMail($to, $from, $msg, true);
         logFile('mail send ' . serialize($sendMail));
         $this->activityHelper->updateEmailLog(false, $to, 'account', 0);
         // }
         echo json_encode(array('status' => true));
         exit;
     }
     exit;
 }
コード例 #17
0
 /**
  * @todo send user mail
  * 
  * @return boolean true/false
  * 
  * */
 function sendMail()
 {
     ob_start();
     // pr('ada');
     $checkBefore = $this->activityHelper->getEmailLog('');
     // pr($checkBefore);exit;
     if ($checkBefore) {
         foreach ($checkBefore as $key => $value) {
             $dataArr['email'] = $value['receipt'];
             $getEmail = $this->userHelper->getUserData('email', $value['receipt']);
             if ($getEmail) {
                 $getUserName = $this->userHelper->getUserappData('id', $getEmail['id'], 0);
                 // $dataArr['username'] = substr(str_shuffle('abcdefghjkmn123456789'), 0, 8) ;
                 $dataArr['username'] = $getUserName['username'];
                 logFile('generate account ' . serialize($dataArr));
                 $getToken = $this->loginHelper->getEmailToken($dataArr['username']);
                 logFile('get email token ' . serialize($getToken));
                 $generateMail = $this->activityHelper->generateEmail($dataArr['email'], $dataArr['username'], 2, $getToken['email_token']);
                 if (is_array($generateMail)) {
                     logFile(' generate mail : ' . serialize($generateMail));
                     $msg = null;
                     $this->view->assign('username', $dataArr['username']);
                     $this->view->assign('email', $dataArr['email']);
                     $this->view->assign('encode', $generateMail['encode']);
                     $msg .= "<p>Hi " . $dataArr['username'] . "!</p>";
                     $msg .= $this->loadView('emailTemplate');
                     // try to send mail
                     $sendMail = sendGlobalMail($to, $from, $msg, true);
                     logFile('generate account status ');
                     $sendUserAccount = sendGlobalMail($generateMail['to'], $generateMail['from'], $msg);
                     logFile('generate account success ' . serialize($sendUserAccount));
                     if ($sendUserAccount['result']) {
                         // usleep(500);
                         $this->activityHelper->updateEmailLog(true, $generateMail['to'], 'account', 1);
                         logFile('send account to email via xls success');
                     } else {
                         logFile('send account to email via xls failed');
                         // echo "Person data not complete"; exit;
                         return false;
                     }
                 } else {
                     logFile('generate email failed');
                     // echo "Person data not complete"; exit;
                     return false;
                 }
             } else {
                 logFile('user not exist');
             }
         }
     } else {
         logFile('email status 1');
         // echo "Person data not complete"; exit;
         return false;
     }
 }
コード例 #18
0
     mysql_connect(DBSERVER, DBUSER, DBPWD) or header('location:errorPage.php&code=');
     //Select Database
     mysql_select_db(DB) or header('location:errorPage.php&code=');
     $result = mysql_query($SQL1) or header('location:errorPage.php&code=');
     foreach ($_SESSION['EDIT_INVENT']['ligne'] as $key => $row) {
         if ($row['oldidArticle'] != '' && $row['idArticle'] != '') {
             $SQL2 = "UPDATE {$table2} SET `ID_ARTICLE`='" . addslashes($row['idArticle']) . "' ,\r\n\t\t\t\t`ID_INVENTAIRE`='" . addslashes($xreference) . "',\r\n\t\t\t\t`QTE_INVENTAIRE`=" . addslashes($row['qte']) . " , \r\n\t\t\t\t`UNITE`='" . addslashes($row['unite']) . "' , \r\n\t\t\t\t`TYPE_INVENTAIRE`='" . addslashes($row['typeinventaire']) . "',\r\n\t\t\t\t`PU_INVENTAIRE`=" . addslashes($row['prixUnit']) . ",\r\n\t\t\t\t`NUM`={$key} \r\n\t\t\t\tWHERE ID_INVENTAIRE='{$xidInvent}' AND ID_ARTICLE='" . addslashes($row['oldidArticle']) . "'";
             $result = mysql_query($SQL2) or header('location:errorPage.php&code=');
         } elseif ($row['oldidArticle'] == '' && $row['idArticle'] != '') {
             $SQL2 = "INSERT INTO {$table2} (`ID_ARTICLE`, `ID_INVENTAIRE`,`ID_EXERCICE` , `QTE_INVENTAIRE`, `UNITE`, `TYPE_INVENTAIRE`,`PU_INVENTAIRE`,`NUM` ) \r\n\t\t\t\tVALUES ('" . addslashes($row['idArticle']) . "' ,'" . addslashes($xreference) . "','{$exercice}',  " . addslashes($row['qte']) . ", \r\n\t\t\t\t'" . addslashes($row['unite']) . "', '" . addslashes($row['typeinventaire']) . "', " . addslashes($row['prixUnit']) . ", {$key});";
             $result = mysql_query($SQL2) or header('location:errorPage.php&code=');
         }
     }
     mysql_close();
     //Log fils
     $log = logFile($_SESSION['GL_USER']['LOGIN'], date("Y-m-d H:i:s"), "Modification d'un inventaire ID:{$xrefernce} par " . $_SESSION['GL_USER']['LOGIN']);
     //Add one ligne
     array_push($_SESSION['EDIT_INVENT']['ligne'], array('oldidArticle' => '', 'idArticle' => '', 'designat' => '', 'prixUnit' => '', 'typeinventaire' => '', 'qte' => '', 'unite' => ''));
     $_SESSION['EDIT_INVENT']['nbreLigne'] = $xnbreLigne + 1;
     header('location:editinventaire.php?selectedTab=inputs&id=' . $xrefernce);
     break;
 case 'ETAT':
     $table1 = "stocks_inventaire";
     $table2 = "stocks_ligne_inventaire";
     $table3 = "stocks_article";
     $exercice = $_SESSION['GL_USER']['EXERCICE'];
     isset($_POST['reference']) ? $xreference = $_POST['reference'] : ($xreference = '');
     isset($_POST['article']) ? $xarticle = $_POST['article'] : ($xarticle = '');
     isset($_POST['dateDebut']) ? $xdateDebut = $_POST['dateDebut'] : ($xdateDebut = '');
     isset($_POST['dateFin']) ? $xdateFin = $_POST['dateFin'] : ($xdateFin = '');
     isset($_POST['typeetat']) ? $xtypeetat = $_POST['typeetat'] : ($xtypeetat = '');
コード例 #19
0
ファイル: class_db.php プロジェクト: Trinata/new-codekir
 function cacheTable()
 {
     $pathcache = CODEKIR_TMP . 'table/';
     if (!file_exists($pathcache)) {
         mkdir($pathcache);
     }
     $getTableList = $this->getTableList();
     if ($getTableList) {
         foreach ($getTableList as $key => $value) {
             if (!file_exists($pathcache . $value)) {
                 $sturcture = $this->getTableStructure($value);
                 logFile('create table cache ' . $value);
                 $handle = fopen($pathcache . $value, "a");
                 fwrite($handle, serialize($sturcture) . "\n");
                 fclose($handle);
             }
         }
     }
 }
コード例 #20
0
 function register()
 {
     global $basedomain, $CONFIG, $LOCALE;
     $salt = md5('register');
     if ($_POST['submit']) {
         $checkBefore['table'] = "bsn_users";
         $checkBefore['condition'] = array('email' => $_POST['email']);
         $checkDataBefore = $this->contentHelper->fetchData($checkBefore);
         if ($checkDataBefore) {
             if ($checkDataBefore) {
                 echo "<script>alert('Email sudah digunakan');window.location.href='{$basedomain}home/register'</script>";
             }
             exit;
         }
         $pass = _p('pass');
         $pass1 = _p('retypePass');
         if ($pass === $pass1) {
             $_POST['password'] = sha1($salt . $pass . $salt);
             $_POST['salt'] = $salt;
             $_POST['n_status'] = 0;
             $_POST['register_date'] = date('Y-m-d H:i:s');
             $_POST['login_count'] = 0;
             $_POST['type'] = 2;
             $_POST['email_token'] = $this->token;
             if ($_POST['receiveNotif']) {
                 $_POST['data'] = serialize(array('getNotif' => 1));
             }
             $signup = $this->contentHelper->saveData($_POST, "_users");
             if ($signup) {
                 $data['table'] = "bsn_users";
                 $data['condition'] = array('email' => $_POST['email']);
                 $checkData = $this->contentHelper->fetchData($data);
                 if ($checkData) {
                     // send mail
                     $dataSend['email'] = $checkData[0]['email'];
                     $dataSend['email_token'] = $checkData[0]['email_token'];
                     $serial = encode($dataSend);
                     $this->view->assign('encode', $serial);
                     $this->view->assign('email', $checkData[0]['email']);
                     $this->view->assign('password', $pass);
                     $this->view->assign('name', $checkData[0]['name']);
                     $this->view->assign('text', "Your request for new account.");
                     $link = "<a href='{$basedomain}home/verified/?token={$serial}'>{$LOCALE['default']['email_verification']}</a>";
                     $this->view->assign('link', $link);
                     $html = $this->loadView('emailTemplate');
                     $send = sendGlobalMail(trim($checkData[0]['email']), $CONFIG['email']['EMAIL_FROM_DEFAULT'], $html);
                     logFile($send);
                     if ($send) {
                         redirect($basedomain . 'home/register_confirmation/?status=1');
                     }
                 }
             } else {
                 redirect($basedomain . 'home/register');
             }
         }
     }
     return $this->loadView('akun/register');
 }
コード例 #21
0
 public function insert()
 {
     global $CONFIG;
     $post = $_POST;
     $message = '';
     $tbl_locn = 'locn';
     $tbl_indiv = 'indiv';
     $tbl_obs = 'obs';
     $tbl_img = 'img';
     $data[$tbl_locn] = array('locality' => $post['locality']);
     $data[$tbl_indiv] = array('personID' => $post['personID']);
     $data[$tbl_obs] = array('personID' => $post['personID'], 'localname' => $post['localname']);
     $data[$tbl_img] = array();
     $insertLocn = $this->mspecimen->insertTransaction($tbl_locn, $data[$tbl_locn]);
     $locn_id = $insertLocn['lastid'];
     $data[$tbl_indiv]['locnID'] = $locn_id;
     $insertIndiv = $this->mspecimen->insertTransaction('indiv', $data[$tbl_indiv]);
     $indiv_id = $insertIndiv['lastid'];
     $data[$tbl_obs]['indivID'] = $indiv_id;
     $data[$tbl_img]['indivID'] = $indiv_id;
     $data[$tbl_img]['personID'] = $post['personID'];
     $insertObs = $this->mspecimen->insertTransaction('obs', $data[$tbl_obs]);
     $name = 'image';
     $path = '';
     $uploaded_file = uploadFile($name, $path, 'image');
     //if uploaded
     if ($uploaded_file['status'] != '0') {
         logFile('Upload Success');
         if (extension_loaded('gd') && function_exists('gd_info')) {
             logFile('GD2 is installed. Checking image data.');
             $tmp_name = $uploaded_file['full_name'];
             $entry = str_replace(array('\'', '"'), '', $uploaded_file['real_name']);
             $image_name_encrypt = md5(str_shuffle($CONFIG['default']['salt'] . $entry));
             //check filename
             //$dataExist = $this->mspecimen->imageExist($personID, $entry);
             $path_entry = $CONFIG['default']['upload_path'];
             $src_tmp = $path_entry . "/" . $tmp_name;
             logFile('Prepare to cropping image');
             $path_data = 'public_assets/';
             //$path_user = $path_data.$username;
             $path_img = $path_data . '/img';
             $path_img_1000px = $path_img . '/1000px';
             $path_img_500px = $path_img . '/500px';
             $path_img_100px = $path_img . '/100px';
             $fileinfo = getimagesize($path_entry . '/' . $tmp_name);
             $toCreate = array($path_img, $path_img_1000px, $path_img_500px, $path_img_100px);
             createFolder($toCreate, 0755);
             copy($path_entry . "/" . $tmp_name, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg');
             if (!@copy($path_entry . "/" . $tmp_name, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg')) {
                 logFile('Copy file failed');
                 $status = "error";
                 $msg = error_get_last();
             } else {
                 logFile('Copy file success');
                 $dest_1000px = $CONFIG['default']['root_path'] . '/' . $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg';
                 $dest_500px = $CONFIG['default']['root_path'] . '/' . $path_img_500px . '/' . $image_name_encrypt . '.500px.jpg';
                 $dest_100px = $CONFIG['default']['root_path'] . '/' . $path_img_100px . '/' . $image_name_encrypt . '.100px.jpg';
                 if ($fileinfo[0] >= 1000 || $fileinfo[1] >= 1000) {
                     if ($fileinfo[0] > $fileinfo[1]) {
                         $percentage = 1000 / $fileinfo[0];
                         $config['width'] = $percentage * $fileinfo[0];
                         $config['height'] = $percentage * $fileinfo[1];
                     } else {
                         $percentage = 1000 / $fileinfo[1];
                         $config['width'] = $percentage * $fileinfo[0];
                         $config['height'] = $percentage * $fileinfo[1];
                     }
                     $this->resize_pic($src_tmp, $dest_1000px, $config);
                     unset($config);
                 }
                 logFile('Cropping to 1000px image');
                 //Set cropping for y or x axis, depending on image orientation
                 if ($fileinfo[0] > $fileinfo[1]) {
                     $config['width'] = $fileinfo[1];
                     $config['height'] = $fileinfo[1];
                     $config['x_axis'] = $fileinfo[0] / 2 - $config['width'] / 2;
                     $config['y_axis'] = 0;
                 } else {
                     $config['width'] = $fileinfo[0];
                     $config['height'] = $fileinfo[0];
                     $config['x_axis'] = 0;
                     $config['y_axis'] = $fileinfo[1] / 2 - $config['height'] / 2;
                 }
                 $this->cropToSquare($src_tmp, $dest_500px, $config);
                 unset($config);
                 logFile('Cropping to square image');
                 //set new config
                 $config['width'] = 500;
                 $config['height'] = 500;
                 $this->resize_pic($dest_500px, $dest_500px, $config);
                 unset($config);
                 logFile('Cropping to 500px image');
                 $config['width'] = 100;
                 $config['height'] = 100;
                 $this->resize_pic($dest_500px, $dest_100px, $config);
                 unset($config);
                 logFile('Cropping to 100px image');
                 //add file information to array
                 /*$fileToInsert = array('filename' => $entry,'md5sum' => $image_name_encrypt, 'directory' => '', 'mimetype' => $fileinfo['mime']);
                   
                   $insertImage = $this->imagezip->updateImage($personID, $fileToInsert);*/
                 $data[$tbl_img]['filename'] = $entry;
                 $data[$tbl_img]['md5sum'] = $image_name_encrypt;
                 $data[$tbl_img]['mimetype'] = $fileinfo['mime'];
                 $insertImg = $this->mspecimen->insertTransaction('img', $data[$tbl_img]);
                 if ($insertImg) {
                     logFile('Insert Image Success');
                 } else {
                     logFile('Insert Image Failed');
                 }
                 $return['status'] = TRUE;
                 $return['message'] = 'Data berhasil disimpan';
             }
             // end if copy
             unlink($src_tmp);
         } else {
             logFile('GD2 is not installed');
             $return['message'] = 'Error: Sistem Error. Harap menghubungi tim developer kami.';
         }
     } else {
         logFile('Upload Image Failed');
         $return['message'] = 'Error: ' . $uploaded_file['message'];
     }
     echo json_encode($return);
     exit;
 }
コード例 #22
0
 function generateSoal($idKursus, $idMateri = 1, $n_status = 1, $debug = 0)
 {
     $isCourseReady = $this->isCourseReady();
     $idUser = $this->user['idUser'];
     /*
     $sql = array(
             'table'=>"banksoal",
             'field'=>"idSoal",
             'condition' => " idKursus = {$idKursus} AND idMateri = {$idMateri} AND n_status = {$n_status} ORDER BY RAND()",
             );
     */
     $quizLimit = intval($isCourseReady[$idKursus]['jumlahpembagian']);
     $whatCourse = $isCourseReady[$idKursus]['soalkursus'];
     $timeCourse = $isCourseReady[$idKursus]['waktu'] * 60;
     $sumGroupCOurse = count($whatCourse);
     // pr($isCourseReady);
     if ($whatCourse) {
         $i = 1;
         $tmpCount = array();
         foreach ($whatCourse as $key => $value) {
             if ($i == $sumGroupCOurse) {
                 $jumlahindex = array_sum($tmpCount);
                 $quizLimit = intval($isCourseReady[$idKursus]['maxSoal']) - intval($jumlahindex);
             }
             $sql = array('table' => "banksoal", 'field' => "idSoal", 'condition' => " idGrup_kursus = {$value['idGrup_kursus']} AND idKursus = {$value['idKursus']} AND n_status = {$n_status} ORDER BY RAND() LIMIT {$quizLimit}");
             $res[] = $this->lazyQuery($sql, $debug);
             $tmpCount[] = $quizLimit;
             $i++;
         }
         // db($res);
         foreach ($res as $key => $value) {
             foreach ($value as $key => $val) {
                 $newRes[] = $val;
             }
         }
     }
     // db($newRes);
     $userAttempQuiz = $this->userAttempQuiz();
     // pr($userAttempQuiz);
     $countAttemp = $userAttempQuiz[0]['total'] + 1;
     if ($newRes) {
         foreach ($newRes as $key => $value) {
             $listSoal[] = $value['idSoal'];
         }
         // db($listSoal);
         $starttolerance = strtotime($this->date) + 3;
         // Add 1 hour
         $tolerancetime = date('Y-m-d H:i:s', $starttolerance);
         // Back to string
         $counttime = strtotime($tolerancetime) + $timeCourse;
         // Add 1 hour
         $endtime = date('Y-m-d H:i:s', $counttime);
         // Back to string
         $soal = serialize($listSoal);
         /*
         $sql = "INSERT IGNORE INTO tbl_generate_soal (idKursus, idMateri, idUser, soal, generate_date, start_date, end_date, n_status) 
                 VALUES ({$idKursus}, {$idMateri}, {$idUser}, '{$soal}', '{$this->date}','{$tolerancetime}','{$endtime}', 1)
                 ";
         */
         $sql = "INSERT IGNORE INTO tbl_generate_soal (idGrupKursus, idUser, soal, generate_date, start_date, end_date, attempt, n_status) \n                    VALUES ({$idKursus}, {$idUser}, '{$soal}', '{$this->date}','{$tolerancetime}','{$endtime}', {$countAttemp}, 1)\n                    ";
         logFile($sql);
         // pr($sql);
         // $sql = array(
         //         'table'=>"tbl_generate_soal",
         //         'field'=>"idKursus, idMateri, idUser, soal, generate_date, n_status",
         //         'value' => "{$idKursus}, {$idMateri}, {$idUser}, '{$soal}', '{$this->date}', 1",
         //         );
         $resins = $this->query($sql);
         if ($resins) {
             /*
             $sql = array(
                     'table'=>"tbl_generate_soal",
                     'field'=>"id, start_date, end_date",
                     'condition' => " idKursus = {$idKursus} AND idMateri = {$idMateri} AND finish = 0 AND idUser = {$idUser} AND n_status = 1 ORDER BY id DESC LIMIT 1",
                     );
             */
             $sql = array('table' => "tbl_generate_soal", 'field' => "id, start_date, end_date, attempt", 'condition' => " idGrupKursus = {$idKursus} AND finish = 0 AND idUser = {$idUser} AND n_status = 1 ORDER BY id DESC LIMIT 1");
             $result = $this->lazyQuery($sql, $debug);
             // pr($result);
             return $result;
         }
     } else {
     }
     return false;
 }
コード例 #23
0
 function parseMasterData($newData = array(), $subtitute = false, $index = 0, $table = 'indiv')
 {
     global $C_SPEC;
     if (empty($newData)) {
         return false;
     }
     $arrTmp = array();
     // pr($newData);exit;
     $sql = array();
     $numberTable = array(0);
     if ($subtitute) {
         $defineTable = array($index => $table);
         $startconvert = 0;
     } else {
         $defineTable = array(1 => 'det', 2 => 'obs', 3 => 'coll');
         $startconvert = 1;
     }
     $fieldFetch = array();
     $fieldUnique = array();
     // Indiv table identified
     $fieldFetch[0] = array('locnID', 'plot', 'tag', 'unique_key', 'personID');
     $fieldConvert[0] = array('tmp_location_key' => 'locnID', 'tmp_person_key' => 'personID');
     $fieldUnique[0] = array('unique_key');
     // Det table identified
     $fieldFetch[1] = array('indivID', 'personID', 'det_date', 'taxonID', 'confid', 'notes', 'using');
     $fieldConvert[1] = array('tmp_indiv_key' => 'indivID', 'tmp_taxon_key' => 'taxonID', 'tmp_person_key' => 'personID', 'det_notes' => 'notes');
     $fieldUnique[1] = array('unique_key');
     // Obs table identified
     $fieldFetch[2] = array('indivID', 'date', 'personID', 'microhab', 'habit', 'dbh', 'height', 'bud', 'flower', 'fruit', 'localname', 'notes', 'char_lf_insert_alt', 'char_lf_insert_opp');
     $fieldConvert[2] = array('tmp_indiv_key' => 'indivID', 'tmp_person_key' => 'personID');
     $fieldUnique[2] = array('unique_key');
     // Coll table identified
     $fieldFetch[3] = array('dateColl', 'indivID', 'collReps', 'dnaColl', 'notes', 'deposit');
     $fieldConvert[3] = array('tmp_indiv_key' => 'indivID', 'indiv_notes' => 'notes');
     $fieldUnique[3] = array('indivID');
     // Image table identified
     $fieldFetch[4] = array('indivID', 'personID', 'filename', 'notes');
     $fieldConvert[4] = array('tmp_person_key' => 'personID', 'tmp_indiv_key' => 'indivID');
     $fieldUnique[4] = array('unique_key');
     // Collector table identified
     $fieldFetch[5] = array('collID', 'personID', 'order');
     $fieldConvert[5] = array('tmp_person_key' => 'personID', 'tmp_coll_key' => 'collID');
     $fieldUnique[5] = array('unique_key');
     $fieldNotNull = array('personID', 'indivID', 'taxonID', 'locnID');
     //,'gen','sp','subtype','ssp','auth');
     $convert = $startconvert;
     $dataKey = array();
     $returnArr = array();
     foreach ($defineTable as $a => $b) {
         foreach ($newData as $key => $values) {
             if (in_array($key, $numberTable)) {
                 foreach ($values['data'] as $k => $val) {
                     $keyField = array();
                     $tmpField = array();
                     $tmpData = array();
                     $t_field = array();
                     $t_data = array();
                     $t_dataraw = array();
                     $uniqueKey = array();
                     $tmpupdate = array();
                     $fieldKey = @array_keys($fieldConvert[$a]);
                     foreach ($val as $keys => $v) {
                         if (in_array($keys, $fieldKey)) {
                             // check if field excel not same with table DB, run convert field
                             $keyField = $fieldConvert[$a][$keys];
                             if (in_array($keyField, $fieldFetch[$a])) {
                                 $tmpkeyField = $keyField;
                                 // check collection libs before
                                 $keyData = $this->validateField($defineTable[$key], $keyField, $v);
                             } else {
                                 $tmpkeyField = false;
                             }
                         } else {
                             // if field exist in table, then insert to array
                             if (in_array($keys, $fieldFetch[$a])) {
                                 $tmpkeyField = $keys;
                                 // check collection libs before
                                 $keyData = $this->validateField($defineTable[$key], $keyField, $v);
                             } else {
                                 $tmpkeyField = false;
                             }
                         }
                         // if field empty don't store to array
                         if ($tmpkeyField) {
                             // pr($tmpkeyField);
                             if ($b == 'indiv') {
                                 if (in_array($tmpkeyField, $fieldUnique[$convert])) {
                                     if ($keyData) {
                                         $uniqueKey = $keyData;
                                     }
                                 } else {
                                     $t_field[] = $tmpkeyField;
                                     if (in_array($tmpkeyField, array('plot', 'tag'))) {
                                         if ($tmpkeyField == 'plot') {
                                             if ($keyData != '') {
                                                 $t_data[] = "'{$keyData}'";
                                             } else {
                                                 $t_data[] = "0";
                                             }
                                         }
                                         if ($tmpkeyField == 'tag') {
                                             if ($keyData != '') {
                                                 $t_data[] = "'{$keyData}'";
                                             } else {
                                                 $t_data[] = "0";
                                             }
                                         }
                                     } else {
                                         $t_data[] = "'{$keyData}'";
                                     }
                                     $t_dataraw[$tmpkeyField] = $keyData;
                                     $tmpupdate[] = "`{$tmpkeyField}` = '{$keyData}'";
                                     // pr($tmpkeyField);
                                     logFile('data field :' . $tmpkeyField . '=' . $keyData);
                                     if (in_array($tmpkeyField, $fieldNotNull)) {
                                         // echo 'field '.$tmpkeyField. ' data ='.$keyData;
                                         if ($keyData == "") {
                                             echo json_encode(array('status' => false, 'msg' => "Error ! {$b} {$this->locale['default']['upload_xls_error']}"));
                                             exit;
                                         }
                                     }
                                 }
                             } else {
                                 if (in_array($tmpkeyField, $fieldUnique[$convert])) {
                                     if ($keyData) {
                                         $uniqueKey = $keyData;
                                     }
                                 }
                                 $t_field[] = $tmpkeyField;
                                 if (in_array($tmpkeyField, array('dbh', 'height'))) {
                                     if ($tmpkeyField == 'dbh') {
                                         if ($keyData != '') {
                                             $t_data[] = "'{$keyData}'";
                                         } else {
                                             $t_data[] = "0.0";
                                         }
                                     }
                                     if ($tmpkeyField == 'height') {
                                         if ($keyData != '') {
                                             $t_data[] = "'{$keyData}'";
                                         } else {
                                             $t_data[] = "0.00";
                                         }
                                     }
                                 } else {
                                     $t_data[] = "'{$keyData}'";
                                 }
                                 $t_dataraw[$tmpkeyField] = $keyData;
                                 $tmpupdate[] = "`{$tmpkeyField}` = '{$keyData}'";
                                 // if unique data field is empty do nothing
                                 logFile('data field :' . $tmpkeyField . '=' . $keyData);
                                 if (in_array($tmpkeyField, $fieldNotNull)) {
                                     if ($keyData == "") {
                                         echo json_encode(array('status' => false, 'msg' => "Error ! {$tmpkeyField} {$this->locale['default']['upload_xls_error']}"));
                                         exit;
                                     }
                                 }
                             }
                         }
                     }
                     /* inject data to table */
                     if ($b == 'coll') {
                         $t_field[] = 'collCode';
                         $tmpCode = str_shuffle('ABCDEFGHIJ1234567890');
                         $t_data[] = "'{$tmpCode}'";
                         // $dataKey[$b][] = $tmpCode;
                         $tmpupdate[] = "`collCode` = '{$tmpCode}'";
                         logFile('data field :' . $tmpkeyField . '=' . $keyData);
                         if (in_array($tmpkeyField, $fieldNotNull)) {
                             if ($keyData == "") {
                                 echo json_encode(array('status' => false, 'msg' => "Error ! {$b} {$this->locale['default']['upload_xls_error']}"));
                                 exit;
                             }
                         }
                     }
                     // pr($tmpkeyField);
                     // generate query
                     $tmpField = implode(',', $t_field);
                     $tmpData = implode(',', $t_data);
                     $update = implode(',', $tmpupdate);
                     $sql[$b][] = "INSERT INTO {$b} ({$tmpField}) VALUES ({$tmpData}) ON DUPLICATE KEY UPDATE {$update} , id=LAST_INSERT_ID(id)";
                     // $sql[$b][] = "REPLACE INTO {$b} ({$tmpField}) VALUES ({$tmpData})";
                     $arrTmp[$b]['data'][] = $t_dataraw;
                     if ($uniqueKey) {
                         $dataKey[$b][] = $uniqueKey;
                     }
                 }
             }
             $convert++;
         }
     }
     // pr($dataKey);
     // exit;
     $returnArr['query'] = $sql;
     $returnArr['uniqkey'] = $dataKey;
     $returnArr['rawdata'] = $arrTmp;
     // pr($returnArr);
     logFile(serialize($sql));
     logFile('parseMasterData success');
     return $returnArr;
 }
コード例 #24
0
 function dataIndivId($id)
 {
     $sql = "SELECT {$this->prefix}_indiv.id as indivCode, {$this->prefix}_locn.locality as locality, {$this->prefix}_person.name as pendata\r\n                FROM `{$this->prefix}_indiv` INNER JOIN `{$this->prefix}_person` ON\r\n                    {$this->prefix}_indiv.personID={$this->prefix}_person.id AND {$this->prefix}_indiv.n_status='0'\r\n                INNER JOIN `{$this->prefix}_locn` ON\r\n                    {$this->prefix}_indiv.locnID={$this->prefix}_locn.id\r\n                where {$this->prefix}_indiv.id = '{$id}'";
     logFile($sql);
     $res = $this->fetch($sql, 1);
     $rowsFilter = $this->fetch("SELECT FOUND_ROWS() AS total");
     $rowsTotal = $this->fetch("SELECT COUNT({$this->prefix}_indiv.id) AS total FROM `{$this->prefix}_indiv` INNER JOIN `{$this->prefix}_person` ON\r\n                    {$this->prefix}_indiv.personID={$this->prefix}_person.id AND {$this->prefix}_indiv.n_status='0'\r\n                INNER JOIN `{$this->prefix}_locn` ON\r\n                    {$this->prefix}_indiv.locnID={$this->prefix}_locn.id \r\n                where {$this->prefix}_indiv.id = '{$id}'");
     if ($res) {
         foreach ($res as $key => $value) {
             //print_r($value);exit;
             $sql = "SELECT md5sum FROM `{$this->prefix}_img` WHERE indivID = {$res[$key]['indivCode']}  LIMIT 3";
             //pr($sql);
             $result = $this->fetch($sql, 1);
             $img = array();
             if (is_array($result)) {
                 foreach ($result as $val) {
                     if ($val['md5sum']) {
                         $img[] = $val['md5sum'];
                     }
                 }
                 $res[$key]['img'] = $img;
             }
         }
     }
     //pr($res);exit;
     // $return['result'] = $res;
     // return $return;
     $dataArray['dataset'] = $rowsFilter['total'];
     $dataArray['dataTotal'] = $rowsTotal['total'];
     $dataArray['data'] = $res;
     return $dataArray;
 }
コード例 #25
0
 function insertData($res, $noKontrak)
 {
     $count = 1;
     foreach ($res as $key => $value) {
         $sql = array('table' => "aset", 'field' => "*", 'condition' => "Aset_ID = {$value['Aset_ID']} AND TipeAset = 'H'");
         $res1 = $this->db->lazyQuery($sql, $debug);
         if ($res1) {
             $date = date('Y-m-d H:i:s');
             $actionText = "Mutasi sukses";
             $tglProses = "2014-12-31";
             $action = 3;
             $addField = array('changeDate' => $date, 'action' => $actionText, 'operator' => 1, 'TglPerubahan' => $tglProses, 'Kd_Riwayat' => $action, 'Aset_ID_Penambahan' => 0, 'No_Dokumen' => $noKontrak);
             // pr($value);
             $field = $this->db->getFieldName('aset', $value['Aset_ID']);
             $mergeField = array_merge($field, $addField);
             // pr($mergeField);
             if ($mergeField) {
                 $ignoreField = array('kodeSatker', 'kodeLokasi');
                 foreach ($mergeField as $key => $val) {
                     if (!in_array($key, $ignoreField)) {
                         $tmpField[] = $key;
                         $tmpValue[] = "'" . $val . "'";
                     }
                     if ($key == 'NilaiPerolehan') {
                         $NilaiPerolehan_Awal = "'" . $val . "'";
                     }
                     if ($key == 'kodeSatker') {
                         $kodeSatker = "'" . $value['SatkerAwal'] . "'";
                     }
                     if ($key == 'kodeLokasi') {
                         $tmpSatker = explode('.', $value['SatkerAwal']);
                         $tmpLokasi = explode('.', $val);
                         $imp = array($tmpLokasi[0], $tmpLokasi[1], $tmpLokasi[2], $tmpSatker[0], $tmpSatker[1], $tmpLokasi[5], $tmpSatker[2], $tmpSatker[3]);
                         $implode = implode('.', $imp);
                         $kodeLokasi = "'" . $implode . "'";
                     }
                 }
                 $tmpField[] = 'NilaiPerolehan_Awal';
                 $tmpField[] = 'kodeSatker';
                 $tmpField[] = 'kodeLokasi';
                 $tmpValue[] = $NilaiPerolehan_Awal;
                 $tmpValue[] = $kodeSatker;
                 $tmpValue[] = $kodeLokasi;
                 $fileldImp = implode(',', $tmpField);
                 $dataImp = implode(',', $tmpValue);
                 // pr($fileldImp);
                 // pr($dataImp);exit;
                 $sql = "INSERT INTO log_aset ({$fileldImp}) VALUES ({$dataImp})";
                 logFile($sql);
                 if ($debug) {
                     pr($sql);
                     exit;
                 }
                 $res = $this->query($sql);
                 if ($res) {
                     // logFile($res);
                     logFile('action = ' . $action);
                     usleep(100);
                     if ($action == 3) {
                         $insert_id = $this->insert_id();
                         $sqlu = "UPDATE log_aset SET TglPembukuan = '{$tglProses}' WHERE log_id = {$insert_id} LIMIT 1";
                         logFile($sqlu);
                         $result = $this->query($sqlu);
                     }
                     usleep(100);
                     if ($action == 28) {
                         $insert_id = $this->insert_id();
                         $sqlu = "UPDATE log_aset SET StatusValidasi = 1, Status_Validasi_Barang = 1, StatusTampil = 1 WHERE log_id = {$insert_id} LIMIT 1";
                         logFile($sqlu);
                         $result = $this->query($sqlu);
                     }
                 }
             }
         }
         echo "insert data ke -" . $count . "\n";
         $count++;
     }
 }
コード例 #26
0
ファイル: SampleDeliveryReport.php プロジェクト: akriot/iot
<?php

/**
 *   (C) Copyright 1997-2013 hSenid International (pvt) Limited.
 *   All Rights Reserved.
 *
 *   These materials are unpublished, proprietary, confidential source code of
 *   hSenid International (pvt) Limited and constitute a TRADE SECRET of hSenid
 *   International (pvt) Limited.
 *
 *   hSenid International (pvt) Limited retains all title to and intellectual
 *   property rights in these materials.
 */
include_once '../../lib/sms/SmsDeliveryReport.php';
include_once '../log.php';
ini_set('error_log', 'sms-delivery-report-error.log');
try {
    $receiver = new SmsDeliveryReport();
    // Create the Receiver object
    $destinationAddress = $receiver->getDesAddress();
    $timeStamp = $receiver->getTimeStamp();
    $requestId = $receiver->getRequestId();
    $deliveryStatus = $receiver->getDeliveryStatus();
    logFile("Sms delivery report received from SDP : ");
    logFile("[ destinationAddress={$destinationAddress}, timeStamp={$timeStamp}, requestId={$requestId}, deliveryStatus={$deliveryStatus} ]");
} catch (SmsException $ex) {
    //throws when failed delivery report receiving
    error_log("ERROR: {$ex->getStatusCode()} | {$ex->getStatusMessage()}");
}
コード例 #27
0
 /**
  * @todo insert image from posted data
  * */
 public function addImg()
 {
     global $CONFIG;
     $data = $_POST;
     $indivID = $_GET['id'];
     $name = 'filename';
     $path = '';
     $uploaded_file = uploadFile($name, $path, 'image');
     //if uploaded
     if ($uploaded_file['status'] != '0') {
         logFile('Upload Success');
         if (extension_loaded('gd') && function_exists('gd_info')) {
             logFile('GD2 is installed. Checking image data.');
             //validate email and get short_namecode
             $ses_user = $this->isUserOnline();
             $username = $ses_user['login']['username'];
             $personID = $ses_user['login']['id'];
             $tmp_name = $uploaded_file['full_name'];
             $entry = str_replace(array('\'', '"'), '', $uploaded_file['real_name']);
             $image_name_encrypt = md5($entry);
             //check filename
             $dataExist = $this->imagezip->dataExist($personID, $entry);
             $path_entry = $CONFIG['default']['upload_path'];
             $src_tmp = $path_entry . "/" . $tmp_name;
             if (!$dataExist) {
                 logFile('Prepare to cropping image');
                 $path_data = 'public_assets/';
                 //$path_user = $path_data.$username;
                 $path_img = $path_data . '/img';
                 $path_img_1000px = $path_img . '/1000px';
                 $path_img_500px = $path_img . '/500px';
                 $path_img_100px = $path_img . '/100px';
                 $fileinfo = getimagesize($path_entry . '/' . $tmp_name);
                 $toCreate = array($path_img, $path_img_1000px, $path_img_500px, $path_img_100px);
                 createFolder($toCreate, 0755);
                 copy($path_entry . "/" . $tmp_name, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg');
                 if (!@copy($path_entry . "/" . $tmp_name, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg')) {
                     logFile('Copy file failed');
                     $status = "error";
                     $msg = error_get_last();
                 } else {
                     logFile('Copy file success');
                     $dest_1000px = $CONFIG['default']['root_path'] . '/' . $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg';
                     $dest_500px = $CONFIG['default']['root_path'] . '/' . $path_img_500px . '/' . $image_name_encrypt . '.500px.jpg';
                     $dest_100px = $CONFIG['default']['root_path'] . '/' . $path_img_100px . '/' . $image_name_encrypt . '.100px.jpg';
                     if ($fileinfo[0] >= 1000 || $fileinfo[1] >= 1000) {
                         if ($fileinfo[0] > $fileinfo[1]) {
                             $percentage = 1000 / $fileinfo[0];
                             $config['width'] = $percentage * $fileinfo[0];
                             $config['height'] = $percentage * $fileinfo[1];
                         } else {
                             $percentage = 1000 / $fileinfo[1];
                             $config['width'] = $percentage * $fileinfo[0];
                             $config['height'] = $percentage * $fileinfo[1];
                         }
                         $this->resize_pic($src_tmp, $dest_1000px, $config);
                         unset($config);
                     }
                     logFile('Cropping to 1000px image');
                     //Set cropping for y or x axis, depending on image orientation
                     if ($fileinfo[0] > $fileinfo[1]) {
                         $config['width'] = $fileinfo[1];
                         $config['height'] = $fileinfo[1];
                         $config['x_axis'] = $fileinfo[0] / 2 - $config['width'] / 2;
                         $config['y_axis'] = 0;
                     } else {
                         $config['width'] = $fileinfo[0];
                         $config['height'] = $fileinfo[0];
                         $config['x_axis'] = 0;
                         $config['y_axis'] = $fileinfo[1] / 2 - $config['height'] / 2;
                     }
                     $this->cropToSquare($src_tmp, $dest_500px, $config);
                     unset($config);
                     logFile('Cropping to square image');
                     //set new config
                     $config['width'] = 500;
                     $config['height'] = 500;
                     $this->resize_pic($dest_500px, $dest_500px, $config);
                     unset($config);
                     logFile('Cropping to 500px image');
                     $config['width'] = 100;
                     $config['height'] = 100;
                     $this->resize_pic($dest_500px, $dest_100px, $config);
                     unset($config);
                     logFile('Cropping to 100px image');
                     //add file information to array
                     $data['filename'] = $entry;
                     $data['md5sum'] = $image_name_encrypt;
                     $data['mimetype'] = $fileinfo['mime'];
                     $data['indivID'] = $indivID;
                     $data['personID'] = $personID;
                     $insertData = $this->insertonebyone->insertTransaction('img', $data);
                     if ($insertData) {
                         logFile('Insert Data Success');
                         $this->msg->add('s', 'Sukses Memperbarui Gambar');
                         $session = new Session();
                         $dataSession = array();
                         $sess_image = $session->get_session();
                         if (isset($sess_image['image_sess'])) {
                             logFile('Fetch image session');
                             foreach ($sess_image['image_sess'] as $data_before) {
                                 array_push($dataSession, $data_before);
                             }
                         }
                         array_push($dataSession, $data);
                         $session->set_session($dataSession, 'image_sess');
                         //$session->delete_session('onebyone');
                     } else {
                         logFile('Insert Data Failed');
                         $this->msg->add('e', 'Gagal Memperbarui Gambar');
                     }
                 }
                 // end if copy
             } else {
                 logFile('File Image exist');
                 $this->msg->add('e', 'Data Gambar Telah Ada');
             }
             unlink($src_tmp);
         } else {
             logFile('GD2 is not installed');
             $this->msg->add('e', 'Sistem Error. Harap menghubungi tim developer kami.');
         }
     } else {
         logFile('Upload Image Failed');
         $this->msg->add('e', $uploaded_file['message']);
     }
     //header('Location: ../../browse/editIndiv/?id='.$indivID);
     redirect($basedomain . '../editIndiv/?id=' . $indivID . '#img');
 }
コード例 #28
0
      $kib['Kd_Riwayat'] = 77;    

     
            unset($tmpField);
            unset($tmpValue);
            foreach ($kib as $key => $val) {
              $tmpField[] = $key;
              $tmpValue[] = "'".$val."'";
            }
             
            $fileldImp = implode(',', $tmpField);
            $dataImp = implode(',', $tmpValue);

            $sql = "INSERT INTO log_{$tabel} ({$fileldImp}) VALUES ({$dataImp})";
            $execquery = mysql_query($sql);
              logFile($sql);
            if(!$execquery){
              $DBVAR->rollback();
              echo "<script>alert('Data gagal masuk. Silahkan coba lagi');</script><meta http-equiv=\"Refresh\" content=\"0; url={$url_rewrite}/module/perolehan/kontrak_posting.php\">";              
              exit;
            } 

  
  }
  // exit;
  $DBVAR->commit();

  echo "<meta http-equiv=\"Refresh\" content=\"0; url={$url_rewrite}/module/perolehan/kontrak_posting.php\">";
  exit;

?>
コード例 #29
0
ファイル: recievesms - Copy.php プロジェクト: akriot/iot
ini_set('error_log', 'sms-app-error.log');
$receiver = new SmsReceiver();
// Create the Receiver object
$content = $receiver->getMessage();
// get the message content
$address = $receiver->getAddress();
// get the sender's address
$requestId = $receiver->getRequestID();
// get the request ID
$applicationId = $receiver->getApplicationId();
// get application ID
$encoding = $receiver->getEncoding();
// get the encoding value
$version = $receiver->getVersion();
// get the version
logFile("[ content={$content}, address={$address}, requestId={$requestId}, applicationId={$applicationId}, encoding={$encoding}, version={$version} ]");
$responseMsg;
//your logic goes here......
$split = explode(' ', $content);
$split_number = explode(':', $address);
//split address
$tag = "{$split['2']} {$split['3']}";
// set tag name
$responseMsg = $split[1];
$time_to_stop = $split[4];
$user_iD = $split_number[1];
$contentarray = $split[0];
$store_data = $split[1];
//echo $responseMsg;
// $responseMsg = $user_iD;
$update_time = time() + $time_to_stop * 60 * 60;
コード例 #30
0
 public function ubahAset($data)
 {
     global $url_rewrite;
     // pr($data);exit;
     if (isset($data['kodeKelompok'])) {
         $tblAset['kodeKelompok'] = $data['kodeKelompok'];
     }
     if (isset($data['kodeSatker'])) {
         $tblAset['kodeSatker'] = $data['kodeSatker'];
         $kodeSatker = explode(".", $data['kodeSatker']);
     }
     if (isset($data['kodeLokasi'])) {
         $tblAset['kodeLokasi'] = $data['kodeLokasi'];
     }
     if (isset($data['tglPerolehan'])) {
         $tblAset['TglPerolehan'] = $data['tglPerolehan'];
         $tblAset['Tahun'] = date('Y', strtotime($data['tglPerolehan']));
     }
     if (isset($data['tglPembukuan'])) {
         $tblAset['TglPembukuan'] = $data['tglPembukuan'];
     }
     if (isset($data['NilaiPerolehan'])) {
         $tblAset['NilaiPerolehan'] = $data['Satuan'];
     }
     if (isset($data['kondisi'])) {
         $tblAset['kondisi'] = $data['kondisi'];
     }
     if (isset($data['asalusul'])) {
         $tblAset['AsalUsul'] = $data['asalusul'];
     }
     if (isset($data['Kuantitas'])) {
         $tblAset['Kuantitas'] = $data['Kuantitas'];
     }
     if (isset($data['Satuan'])) {
         $tblAset['Satuan'] = $data['Satuan'];
     }
     if (isset($data['Info'])) {
         $tblAset['Info'] = $data['Info'];
     }
     if (isset($data['Alamat'])) {
         $tblAset['Alamat'] = $data['Alamat'];
     }
     $tblAset['UserNm'] = $data['UserNm'];
     if (isset($data['TipeAset'])) {
         $tblAset['TipeAset'] = $data['TipeAset'];
     }
     $tblAset['kodeKA'] = 1;
     if (isset($data['kodeRuangan'])) {
         $tblAset['kodeRuangan'] = $data['kodeRuangan'];
     }
     foreach ($tblAset as $key => $val) {
         $tmpfield[] = $key . "='{$val}'";
     }
     $field = implode(',', $tmpfield);
     $query = "UPDATE aset SET {$field} WHERE Aset_ID = '{$data['Aset_ID']}' ";
     //pr($query);exit;
     $result = $this->query($query) or die($this->error());
     if ($data['TipeAset'] == "A") {
         $tblKib['HakTanah'] = $data['HakTanah'];
         $tblKib['LuasTotal'] = $data['LuasTotal'];
         $tblKib['NoSertifikat'] = $data['NoSertifikat'];
         $tblKib['TglSertifikat'] = $data['TglSertifikat'];
         $tblKib['Penggunaan'] = $data['Penggunaan'];
         $tabel = "tanah";
         $logtabel = "log_tanah";
         $idkey = "Tanah_ID";
     } elseif ($data['TipeAset'] == "B") {
         $tblKib['Pabrik'] = $data['Pabrik'];
         $tblKib['Merk'] = $data['Merk'];
         $tblKib['Model'] = $data['Model'];
         $tblKib['Ukuran'] = $data['Ukuran'];
         $tblKib['NoMesin'] = $data['NoMesin'];
         $tblKib['NoBPKB'] = $data['NoBPKB'];
         $tblKib['NoSeri'] = $data['NoSeri'];
         $tblKib['Material'] = $data['Material'];
         $tblKib['NoRangka'] = $data['NoRangka'];
         $tabel = "mesin";
         $logtabel = "log_mesin";
         $idkey = "Mesin_ID";
     } elseif ($data['TipeAset'] == "C") {
         $tblKib['JumlahLantai'] = $data['JumlahLantai'];
         $tblKib['LuasLantai'] = $data['LuasLantai'];
         $tblKib['Beton'] = $data['Beton'];
         $tblKib['NoSurat'] = $data['NoSurat'];
         $tblKib['tglSurat'] = $data['tglSurat'];
         $tabel = "bangunan";
         $logtabel = "log_bangunan";
         $idkey = "Bangunan_ID";
     } elseif ($data['TipeAset'] == "D") {
         $tblKib['Panjang'] = $data['Panjang'];
         $tblKib['Lebar'] = $data['Lebar'];
         $tblKib['LuasJaringan'] = $data['LuasJaringan'];
         $tblKib['Konstruksi'] = $data['Konstruksi'];
         $tblKib['NoDokumen'] = $data['NoDokumen'];
         $tblKib['tglDokumen'] = $data['tglDokumen'];
         $tabel = "jaringan";
         $logtabel = "log_jaringan";
         $idkey = "Jaringan_ID";
     } elseif ($data['TipeAset'] == "E") {
         $tblKib['Judul'] = $data['Judul'];
         $tblKib['Pengarang'] = $data['Pengarang'];
         $tblKib['Penerbit'] = $data['Penerbit'];
         $tblKib['Spesifikasi'] = $data['Spesifikasi'];
         $tblKib['AsalDaerah'] = $data['AsalDaerah'];
         $tblKib['Material'] = $data['Material'];
         $tblKib['Ukuran'] = $data['Ukuran'];
         $tabel = "asetlain";
         $logtabel = "log_asetlain";
         $idkey = "AsetLain_ID";
     } elseif ($data['TipeAset'] == "F") {
         $tblKib['JumlahLantai'] = $data['JumlahLantai'];
         $tblKib['LuasLantai'] = $data['LuasLantai'];
         $tblKib['Beton'] = $data['Beton'];
         $tabel = "kdp";
         $logtabel = "log_kdp";
         $idkey = "KDP_ID";
     } elseif ($data['TipeAset'] == "G") {
         echo "<meta http-equiv=\"Refresh\" content=\"0; url={$url_rewrite}/module/perolehan/kontrak_barang.php?id={$data['id']}\">";
         exit;
     } elseif ($data['TipeAset'] == "H") {
         echo "<meta http-equiv=\"Refresh\" content=\"0; url={$url_rewrite}/module/perolehan/kontrak_barang.php?id={$data['id']}\">";
         exit;
     }
     if (isset($data['kodeKelompok'])) {
         $tblKib['kodeKelompok'] = $data['kodeKelompok'];
     }
     if (isset($data['kodeSatker'])) {
         $tblKib['kodeSatker'] = $data['kodeSatker'];
     }
     if (isset($data['kodeLokasi'])) {
         $tblKib['kodeLokasi'] = $tblAset['kodeLokasi'];
     }
     if (isset($tblAset['Tglperolehan'])) {
         $tblKib['TglPerolehan'] = $tblAset['TglPerolehan'];
     }
     if (isset($tblAset['TglPembukuan'])) {
         $tblKib['TglPembukuan'] = $tblAset['TglPembukuan'];
     }
     if (isset($data['Satuan'])) {
         $tblKib['NilaiPerolehan'] = $data['Satuan'];
     }
     $tblKib['StatusTampil'] = 1;
     if (isset($data['kondisi'])) {
         $tblKib['kondisi'] = $data['kondisi'];
     }
     if (isset($data['AsalUsul'])) {
         $tblKib['AsalUsul'] = $data['AsalUsul'];
     }
     if (isset($data['Info'])) {
         $tblKib['Info'] = $data['Info'];
     }
     if (isset($data['Alamat'])) {
         $tblKib['Alamat'] = $data['Alamat'];
     }
     if (isset($data['Tahun'])) {
         $tblKib['Tahun'] = $tblAset['Tahun'];
     }
     $tblKib['kodeKA'] = 1;
     if (isset($data['noRegister'])) {
         $tblKib['noRegister'] = $data['noRegister'];
     }
     if (isset($data['kodeRuangan'])) {
         $tblKib['kodeRuangan'] = $data['kodeRuangan'];
     }
     $sqlkib = "SELECT * FROM {$tabel} WHERE Aset_ID = '{$data['Aset_ID']}'";
     $sqlquery = mysql_query($sqlkib);
     while ($dataAset = mysql_fetch_assoc($sqlquery)) {
         $kib_old = $dataAset;
     }
     foreach ($tblKib as $key => $val) {
         $tmpfield2[] = $key . "='{$val}'";
     }
     $field = implode(',', $tmpfield2);
     // $value = implode(',', $tmpvalue2);
     $query = "UPDATE {$tabel} SET {$field} WHERE {$idkey} = '{$data[$idkey]}'";
     // pr($query);exit;
     $result = $this->query($query) or die($this->error());
     //log
     $sqlkib = "SELECT * FROM {$tabel} WHERE Aset_ID = '{$data['Aset_ID']}'";
     $sqlquery = mysql_query($sqlkib);
     while ($dataAset = mysql_fetch_assoc($sqlquery)) {
         $kib = $dataAset;
     }
     $kib['changeDate'] = date("Y-m-d");
     $kib['action'] = 3;
     $kib['operator'] = $_SESSION['ses_uoperatorid'];
     $kib['NilaiPerolehan_Awal'] = $kib_old['NilaiPerolehan'];
     $kib['GUID'] = $data['GUID'];
     $kib['Kd_Riwayat'] = 25;
     // pr($kib);
     unset($tmpField);
     unset($tmpValue);
     foreach ($kib as $key => $val) {
         $tmpField[] = $key;
         $tmpValue[] = "'" . $val . "'";
     }
     $fileldImp = implode(',', $tmpField);
     $dataImp = implode(',', $tmpValue);
     $sql = "INSERT INTO log_{$tabel} ({$fileldImp}) VALUES ({$dataImp})";
     logFile($sql);
     if ($debug) {
         pr($sql);
         exit;
     }
     $execquery = mysql_query($sql);
     echo "<script>alert('Data Berhasil Disimpan');</script><meta http-equiv=\"Refresh\" content=\"0; url={$url_rewrite}/module/koreksi/ubah_data_aset.php\">";
     exit;
 }