Example #1
0
File: app.php Project: pshreez/PHP
 function test()
 {
     echo $_SERVER['SERVER_PORT'];
     $user = new Axon('tbl_user');
     $user->load(array("id=:id", array(":id" => 1537994726)));
     $this->set('SESSION.user', $user);
     $this->set('SESSION.sid', Snippets::_getRN());
 }
Example #2
0
File: user.php Project: pshreez/PHP
 function toggleActive()
 {
     $id = F3::get("PARAMS.id");
     $user = new Axon('tbl_user');
     $user->load(array("id=:id", array(":id" => $id)));
     $user->active = $user->active == 'y' ? 'n' : 'y';
     $user->save();
     F3::reroute('/admin/user');
 }
Example #3
0
 function adminLogin()
 {
     $admin = new Axon('tbl_admin');
     $username = F3::get('POST.usr');
     $password = F3::get('POST.pwd');
     if ($admin->found(array('username=:username and password=:password', array(':username' => $username, ':password' => md5($password)))) == 1) {
         $admin->load(array('username=:username and password=:password', array(':username' => $username, ':password' => md5($password))));
         F3::set('SESSION.admin', $admin);
         F3::set('SESSION.asid', Snippets::_getRN());
         echo json_encode(array('message' => "You have been logged in "));
     } else {
         echo json_encode(array('mes' => "Either password or usernaem is wrong"));
     }
 }
Example #4
0
 function transfer_feedback()
 {
     $id = F3::get("PARAMS.id");
     $vehicle = new Axon("vehicle");
     $vehicle->load(array('id=:id', array(':id' => $id)));
     $zone_id = $vehicle->zone_id;
     $wheeler = $vehicle->wheeler;
     $dates = $vehicle->date;
     $date = DB::sql("SELECT DATE_ADD( date, INTERVAL 15 DAY ) AS ds FROM vehicle WHERE id='{$id}' and date='{$dates}'");
     $dt = new Form_elements();
     $nepDate = $dt->dateConvertEn($date[0]["ds"]);
     // var_dump($date[0]["ds"]);die;
     //echo $nepDate;die;
     $zone = Admin::getZone($vehicle->zone_id);
     $symbol = Admin::getSymbolType($vehicle->vehicle_symbol_type);
     $vehicleNo = $zone . $vehicle->lot_number . $symbol . $vehicle->number;
     $zone = new Axon("zonal_office");
     if ($zone->found(array('zone_id=:id and wheeler=:vid', array(':id' => $zone_id, ':vid' => $wheeler))) > 0) {
         $zone->load(array('zone_id=:id and wheeler=:vid', array(':id' => $zone_id, ':vid' => $wheeler)));
         $photos = new Axon("owner_photo");
         if ($photos->found(array('vehicle_id =:id', array(':id' => $id)))) {
             $photos->load(array('vehicle_id =:id', array(':id' => $id)));
             F3::set('pic', $photos);
         } else {
             F3::set('pic', 'no photo available');
         }
         F3::set('date', $nepDate);
         F3::set('refer', $id);
         F3::set('vehicle', $vehicleNo);
         F3::set('value', $zone->name);
         F3::set('navUser', 'userNav');
         F3::set('template', 'feedbacktransfer');
         echo Template::serve("template/layout.html");
     } else {
         $photos = new Axon("owner_photo");
         if ($photos->found(array('vehicle_id =:id', array(':id' => $id)))) {
             $photos->load(array('vehicle_id =:id', array(':id' => $id)));
             F3::set('pic', $photos);
         } else {
             F3::set('pic', 'no photo available');
         }
         F3::set('date', $nepDate);
         F3::set('refer', $id);
         F3::set('navUser', 'userNav');
         F3::set('value', 'no office available');
         F3::set('template', 'feedbacktransfer');
         echo Template::serve("template/layout.html");
     }
 }
Example #5
0
 function login()
 {
     $user = new Axon('online_user');
     $username = F3::get("POST.username");
     $password = F3::get("POST.password");
     if ($user->found(array('username=:username and password=:password', array(':username' => $username, ':password' => $password))) == 1) {
         $user->load(array('username=:username and password=:password', array(':username' => $username, ':password' => $password)));
         F3::set("SESSION.onlineUser", $user->username);
         F3::reroute('/user/home');
     } else {
         F3::set('error', 'Username or password entered is wrong !!!');
         F3::set('navUser', 'userNav');
         F3::set('template', 'user_login');
         echo Template::serve("template/layout.html");
     }
 }
Example #6
0
File: zone.php Project: pshreez/PHP
 function getVdc()
 {
     //die(var_dump($this->get('PARAMS')));
     $district_name = $this->get('PARAMS.district_id');
     $content = $this->get('PARAMS.term');
     $district = new Axon('district');
     $district->load(array('name=:n', array(':n' => $district_name)));
     $district_id = $district->id;
     $vdc = new Axon('vdc_list');
     $vdc_list = $vdc->find(array("district_id=:did and name regexp '{$content}'", array(':did' => $district_id)));
     $return_vdcs = array();
     foreach ($vdc_list as $vl) {
         $return_vdcs[] = $vl->name;
     }
     echo json_encode($return_vdcs);
 }
Example #7
0
 /**
 		Authenticate against SQL database;
 			AUTH global array elements:
 				db:<SQL-database> (default:'DB'),
 				table:<table-name>,
 				id:<userID-field>,
 				pw:<password-field>
 			@return mixed
 			@param $id string
 			@param $pw string
 			@public
 	**/
 static function sql($id, $pw)
 {
     $auth = self::$vars['AUTH'];
     foreach (array('table', 'id', 'pw') as $param) {
         if (!isset($auth[$param])) {
             trigger_error(self::TEXT_AuthSetup);
             return FALSE;
         }
     }
     if (!isset($auth['db'])) {
         $auth['db'] = self::ref('DB');
     }
     $axon = new Axon($auth['table'], $auth['db']);
     $axon->load('{{@AUTH.id}}="' . $id . '" AND {{@AUTH.pw}}="' . $pw . '"');
     return $axon->dry() ? FALSE : $axon;
 }
Example #8
0
 /**
 		Authenticate against SQL database;
 			AUTH global array elements:
 				db:<database-id> (default:'DB'),
 				table:<table-name>,
 				id:<userID-field>,
 				pw:<password-field>
 			@return mixed
 			@param $id string
 			@param $pw string
 			@public
 	**/
 static function sql($id, $pw)
 {
     $auth =& self::$vars['AUTH'];
     foreach (array('table', 'id', 'pw') as $param) {
         if (!isset($auth[$param])) {
             trigger_error(self::TEXT_AuthSetup);
             return FALSE;
         }
     }
     if (!isset($auth['db'])) {
         $auth['db'] = self::ref('DB');
     }
     $axon = new Axon($auth['table'], self::ref('AUTH.db'));
     $axon->load(array(self::ref('AUTH.id') . '=:id AND ' . self::ref('AUTH.pw') . '=:pw', array(':id' => $id, ':pw' => $pw)));
     return $axon->dry() ? FALSE : $axon;
 }
Example #9
0
 static function getSymbolType($id)
 {
     $zone = new Axon("type_symbol");
     $zone->load(array("id=:id", array(":id" => $id)));
     return $zone->name;
 }
Example #10
0
<?php

// Reset previous error message, if any
F3::clear('message');
// Form field validation
F3::call(':common');
if (!F3::exists('message')) {
    // No input errors; update record
    $blog = new Axon('kul');
    $blog->load('tc="{@PARAMS.tc}"');
    $blog->copyFrom('REQUEST');
    $blog->save();
    // Return to home page
    F3::reroute('/');
}
// Display the blog form again
F3::call(':editkul');
Example #11
0
    $ne = "Tc No";
    if ($hata = denetle($value, array('dolu' => array(true, "{$ne} boş bırakılamaz"), 'esit' => array(11, "{$ne} 11 haneli olmalıdır"), 'tamsayi' => array(true, "{$ne} sadece rakam içermeli"), 'ozel' => array(function ($value) {
        return !is_tc($value);
    }, "Geçerli bir {$ne} değil")))) {
        F3::set('error', $hata);
        return;
    }
});
F3::input($alan = 'kizliksoyad', function ($value) use($alan) {
    $ne = "Kızlık Soyadı";
    if ($hata = denetle($value, array('dolu' => array(true, "{$ne} boş bırakılamaz")))) {
        F3::set('error', $hata);
        return;
    }
});
if (!F3::exists('error')) {
    $tc = F3::get('REQUEST.tc');
    $kizliksoyad = F3::get('REQUEST.kizliksoyad');
    $kul = new Axon('kul');
    $kul->load("tc={$tc}");
    if (!$kul->dry() && streq_turkish($kul->kizliksoyad, $kizliksoyad)) {
        // tc no'yu oturuma gömelim ve oradan alalım
        F3::set('SESSION.sorgutc', $tc);
        F3::set('SESSION.sorgukizliksoyad', $kizliksoyad);
        return F3::call(':sorguok');
    }
    F3::set('error', "Girdiğiniz bilgilere uygun bir kayıt bulunamadı.  Lütfen verdiğiniz bilgileri kontrol edin.");
}
// hata var, dön başa ve tekrar sorgu al.
// error alanı dolu ve layout.htm'de görüntülenecek
F3::call(':sorgual');
Example #12
0
    if (isset($_SESSION['message'])) {
        F3::set('message', $_SESSION['message']);
        F3::set('extra_js', array('bootstrap-alert.js'));
        unset($_SESSION['message']);
    }
    F3::set('extra_css', array('settings.css'));
    echo Template::serve('templates/header.html');
    F3::set('page', 'general_settings');
    echo Template::serve('templates/settings.html');
    echo Template::serve('templates/footer.html');
    die;
});
F3::route('POST /settings/save', function () {
    $facebook = F3::get('Facebook');
    $uid = $facebook->getUser();
    if (!$uid) {
        _force_logout();
    }
    $user = new Axon('user');
    $user->load(array('fb_id=:fb_id', array(':fb_id' => $uid)));
    if ($user->dry()) {
        _force_logout();
    }
    $email_opt = F3::get('POST.email_opt') == 'on' ? TRUE : False;
    $user->email_opt = $email_opt;
    $user->save();
    $_SESSION['message'] = _create_alert_message('alert-success', 'Settings updated successfully!');
    F3::reroute('/settings/');
});
/****************************************************************************/
F3::run();
Example #13
0
<?php

if (F3::get('SESSION.user')) {
    $kul = new Axon('kul');
    // Delete record from database
    $kul->load('tc="{@PARAMS.tc}"');
    $kul->erase();
    // Return to home page
    F3::reroute('/');
} else {
    // Render blog.htm template
    F3::set('pagetitle', 'Kullanıcıyı sil');
    F3::set('template', 'kul');
    F3::call('render');
}
Example #14
0
 function register_print()
 {
     $id = F3::get("PARAMS.id");
     $vehicle = F3::get("PARAMS.id");
     $data = new Axon("vehicle");
     $owner = new Axon("owner");
     if ($data->found(array('id=:id', array(':id' => $id))) && $owner->found(array('vehicleid =:id', array(':id' => $id)))) {
         // echo 123;
         $data->load(array('id=:id', array(':id' => $vehicle)));
         $owner->load(array('vehicleid =:id', array(':id' => $vehicle)));
         //  $namsari->load(array('vehicle_id =:id', array(':id' => $vehicle)));
         $zone_code = $id->zone_view($data->zone_id);
         // F3::set('code', $zone_code);
         $symbol_view = $id->symbol_view($data->vehicle_symbol_type);
         $owner_view = $id->owner_view($owner->owner_type);
         $p_zone_id = $id->zone_view($owner->p_zone_id);
         $temp_zone_id = $id->zone_view($owner->temp_zone_id);
         //  F3::set('zone', $p_zone_id);
         //$p_district_id = $id->district_view($data->p_district_id);
         // $temp_district_id = $id->district_view($data->temp_district_id);
         $nabalik_district = $id->district_view($data->nabalik_district);
         $creditor_district = $id->district_view($data->creditor_district);
         $per_district = $id->district_view($data->per_district);
         $owner->copyTo("POST");
         $data->copyTo("POST");
         $namsari->copyTo("POST");
         F3::set('date', $date);
         //  F3::set('nav', 'navigation');
         echo Template::serve("template/admin/registration_print.htm");
     }
 }
Example #15
0
 /**
 		Custom session handler
 			@param $table string
 			@public
 	**/
 function session($table = 'sessions')
 {
     $self = $this;
     session_set_save_handler(function ($path, $name) use($self, $table) {
         // Support these engines
         $cmd = array('sqlite2?' => 'SELECT name FROM sqlite_master ' . 'WHERE type=\'table\' AND name=\'' . $table . '\';', 'mysql|mssql|sybase|dblib|pgsql' => 'SELECT table_name FROM information_schema.tables ' . 'WHERE ' . (preg_match('/pgsql/', $self->backend) ? 'table_catalog' : 'table_schema') . '=\'' . $self->dbname . '\' AND ' . 'table_name=\'' . $table . '\'');
         foreach ($cmd as $backend => $val) {
             if (preg_match('/' . $backend . '/', $self->backend)) {
                 break;
             }
         }
         $result = $self->exec($val, NULL);
         if (!$result) {
             // Create SQL table
             $self->exec('CREATE TABLE ' . (preg_match('/sqlite2?/', $self->backend) ? '' : $self->dbname . '.') . $table . ' (' . 'id VARCHAR(40),' . 'data LONGTEXT,' . 'stamp INTEGER' . ');');
         }
         register_shutdown_function('session_commit');
         return TRUE;
     }, function () {
         return TRUE;
     }, function ($id) use($table) {
         $axon = new Axon($table);
         $axon->load(array('id=:id', array(':id' => $id)));
         return $axon->dry() ? FALSE : $axon->data;
     }, function ($id, $data) use($table) {
         $axon = new Axon($table);
         $axon->load(array('id=:id', array(':id' => $id)));
         $axon->id = $id;
         $axon->data = $data;
         $axon->stamp = time();
         $axon->save();
         return TRUE;
     }, function ($id) use($table) {
         $axon = new Axon($table);
         $axon->erase(array('id=:id', array(':id' => $id)));
         return TRUE;
     }, function ($max) use($table) {
         $axon = new Axon($table);
         $axon->erase('stamp+' . $max . '<' . time());
         return TRUE;
     });
 }
Example #16
0
 function dismissNamsari()
 {
     if (!F3::get('SESSION.asid')) {
         F3::reroute("/admin");
     }
     $id = F3::get("PARAMS.id");
     $vrs = new Axon("vehicle");
     $vrs->load(array("id=:id", array(":id" => $id)));
     $zone = Admin::getZone($vrs->zone_id);
     $symbol = Admin::getSymbolType($vrs->vehicle_symbol_type);
     $vehicleNo = $zone . $vrs->lot_number . $symbol . $vrs->number;
     AdminLog::add($vehicleNo, $vrs->form_type, "dismissed");
     $vrs->erase();
     F3::reroute("/admin/ownershipTransfer/s");
 }
Example #17
0
 function deleteForm()
 {
     if (!F3::get('SESSION.onlineUser')) {
         F3::reroute("/");
     }
     $id = F3::get("PARAMS.id");
     $vehicle = new Axon('vehicle');
     if ($vehicle->found(array('id =:id', array(':id' => $id)))) {
         $vehicle->load(array('id =:id', array(':id' => $id)));
         $vehicle->erase();
         F3::reroute('/');
     } else {
         F3::reroute('/');
     }
 }
Example #18
0
 function symbol_view($id)
 {
     $symbol = new Axon('type_symbol');
     $symbol->load(array('id=:id', array(':id' => $id)));
     F3::set('symbol', $symbol->name);
     // F3::set('zonecode',$color->code);
 }
Example #19
0
 function namsari($id)
 {
     $namsari = new Axon("namsari");
     if ($namsari->found(array("vehicle_id=:id", array(":id" => $id)))) {
         $namsari->load(array("vehicle_id=:id", array(":id" => $id)));
         echo 123;
         die;
     }
 }