Example #1
0
<?php

defined('ALT_PATH') or exit('No direct script access allowed');
$dbo = new System_User();
// validasi
$validate = Alt_Validation::instance()->rule(Alt_Validation::required($_REQUEST["username"]), "Username tidak boleh kosong!")->rule(Alt_Validation::required($_REQUEST["password"]), "Password tidak boleh kosong!")->rule(Alt_Validation::required($_REQUEST["name"]), "Nama tidak boleh kosong!")->rule(Alt_Validation::required($_REQUEST["usergroupid"]), "Pilih usergroup terlebih dahulu!")->validate();
// ubah password
$_REQUEST["password"] = md5($_REQUEST["password"]);
return $dbo->insert($_REQUEST);
Example #2
0
<?php

defined('ALT_PATH') or die('No direct access allowed.');
Alt_Validation::instance()->rule(Alt_Validation::not_empty($_REQUEST['description']), 'Deskripsi harus diisi!')->check();
$dbo = new Todo_Item();
return $dbo->insert($_REQUEST);
<?php

defined('ALT_PATH') or die('No direct access allowed.');
Alt_Validation::instance()->rule(Alt_Validation::not_empty($_REQUEST['itemid']), 'Item belum dipilih!')->check();
$dbo = new Todo_Item();
return $dbo->retrieve($_REQUEST);
<?php

defined('ALT_PATH') or exit('No direct script access allowed');
$dbo = new System_File();
// validasi
Alt_Validation::instance()->rule(Alt_Validation::required($_REQUEST[$dbo->pkey]), "Pilih file terlebih dahulu!")->check();
return $dbo->retrieve($_REQUEST);
Example #5
0
        return System_Auth::get_token();
    }
    // logout
    $dbo = new System_Session();
    $res = $dbo->delete(array('where' => 'userid = ' . $dbo->quote($userdata['userid']) . ' and token like ' . $dbo->quote(System_Auth::get_token())));
    System_Auth::clear_token();
}
// user not logged in but token is exist, try to force logout
if (!System_Auth::islogin() && System_Auth::get_token() != '') {
    try {
        include 'logout.php';
    } catch (Exception $e) {
    }
}
// validate username and password
Alt_Validation::instance()->rule(Alt_Validation::not_empty($username), 'Username harus diisi!')->rule(Alt_Validation::not_empty($password), 'Password harus diisi!')->check();
// check is exist within database
$user = new System_User();
$res = $user->get(array('where' => 'username = '******'User tidak ditemukan!');
}
// set userdata
$userdata = $res[0];
// checking if password correct
if (md5($password) != $userdata['password']) {
    throw new Alt_Exception('Password tidak cocok!');
}
unset($userdata['password']);
$token = System_Auth::generate_token($userdata);
Example #6
0
<?php

defined('ALT_PATH') or die('No direct access allowed.');
Alt_Validation::instance()->rule(Alt_Validation::not_empty($_REQUEST['itemid']), 'Item belum dipilih!')->rule(Alt_Validation::not_empty($_REQUEST['description']), 'Deskripsi harus diisi!')->check();
$dbo = new Todo_Item();
return $dbo->update($_REQUEST);
Example #7
0
<?php

defined('ALT_PATH') or exit('No direct script access allowed');
$dbo = new System_File();
$validate = Alt_Validation::instance()->rule(Alt_Validation::required($_REQUEST[$dbo->pkey]), "File id tidak boleh kosong!")->validate();
if (!$validate[0]) {
    throw new Alt_Exception($validate[1]);
}
return $dbo->delete($_REQUEST);
Example #8
0
<?php

defined('ALT_PATH') or exit('No direct script access allowed');
$dbo = new System_File();
// validasi
$validate = Alt_Validation::instance()->rule(Alt_Validation::required($_REQUEST["name"]), "Nama tidak boleh kosong!")->rule(Alt_Validation::required($_REQUEST["description"]), "Deskripsi tidak boleh kosong!")->rule(Alt_Validation::required($_FILES['file']), "File tidak ditemukan!")->validate();
$fileid = $dbo->insert($_REQUEST);
$dbo->upload(array('srctable' => 'master_file', 'srcid' => $fileid, 'fileid' => $fileid), $_FILES['file']);
return $fileid;
 /**
  * Validates a credit card number, with a Luhn check if possible.
  *
  * @param   integer         $number credit card number
  * @param   string|array    $type   card type, or an array of card types
  * @return  boolean
  * @uses    Alt_Validation::luhn
  */
 public static function credit_card($number, $type = NULL)
 {
     // Remove all non-digit characters from the number
     if (($number = preg_replace('/\\D+/', '', $number)) === '') {
         return FALSE;
     }
     if ($type == NULL) {
         // Use the default type
         $type = 'default';
     } elseif (is_array($type)) {
         foreach ($type as $t) {
             // Test each type for validity
             if (Alt_Validation::credit_card($number, $t)) {
                 return TRUE;
             }
         }
         return FALSE;
     }
     $cards = Kohana::$config->load('credit_cards');
     // Check card type
     $type = strtolower($type);
     if (!isset($cards[$type])) {
         return FALSE;
     }
     // Check card number length
     $length = strlen($number);
     // Validate the card length by the card type
     if (!in_array($length, preg_split('/\\D+/', $cards[$type]['length']))) {
         return FALSE;
     }
     // Check card number prefix
     if (!preg_match('/^' . $cards[$type]['prefix'] . '/', $number)) {
         return FALSE;
     }
     // No Luhn check required
     if ($cards[$type]['luhn'] == FALSE) {
         return TRUE;
     }
     return Alt_Validation::luhn($number);
 }
Example #10
0
<?php

defined('ALT_PATH') or exit('No direct script access allowed');
$dbo = new System_User();
Alt_Validation::instance()->rule(Alt_Validation::required($_REQUEST[$dbo->pkey]), "User id tidak boleh kosong!")->check();
if (isset($_REQUEST["password"])) {
    $_REQUEST["password"] = md5($_REQUEST["newpassword"] ? $_REQUEST["newpassword"] : $_REQUEST["password"]);
}
return $dbo->update($_REQUEST);