Example #1
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 #2
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 #3
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 #4
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 #5
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 #6
0
<?php

// Retrieve matching record
$kul = new Axon('kul');
$kul->load('tc="{@PARAMS.tc}"');
if (!$kul->dry()) {
    // Populate REQUEST global with retrieved values
    $kul->copyTo('REQUEST');
    // Render blog.htm template
    F3::set('pagetitle', 'Kullanıcıyı güncelle');
    F3::set('template', 'kul');
    F3::call('render');
} else {
    // Invalid blog entry; display our 404 page
    F3::http404();
}