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'); }
public static function add($vehicle, $form_type, $status) { $log = new Axon('admin_log'); $log->date = date("Y-m-d H:i:s"); $log->admin_username = F3::get('SESSION.username'); //admin id $log->vehicle_no = $vehicle; $log->status = $status; $log->form_type = $form_type; $log->save(); }
function pictureFolder($id = 4) { echo 123; //var_dump($_FILES);die; $filename = $id; // die(F3::get('FILES.uploadfile.tmp_name')); $path = "photo/"; if (move_uploaded_file(F3::get('FILES.uploadfile.tmp_name'), $path . $filename . ".jpg")) { $picture = new Axon("owner_photo"); $picture->picture = $filename; $picture->save(); } else { echo "there weas an error"; } }
function edit() { $username = F3::get('PARAMS.id'); $user = new Axon('admin'); if ($user->found(array('username =:id', array(':id' => $username)))) { $user->load(array('username =:id', array(':id' => $username))); $user->username = F3::get("POST.username"); $user->fullname = F3::get("POST.fullname"); $user->type = F3::get("POST.type"); if (F3::get("POST.password") != "") { $user->password = md5(F3::get("POST.password")); } //die(); $user->save(); F3::reroute("/admin/viewUsers"); } }
<?php // Reset previous error message, if any F3::clear('message'); // Form field validation F3::call(':common'); if (!F3::exists('message')) { // No input errors; add record to database $blog = new Axon('kul'); $blog->copyFrom('REQUEST'); $blog->save(); // Return to home page; new blog entry should now be there F3::reroute('/'); /*$payload = json_encode(array(F3::get('REQUEST.title'), F3::get('REQUEST.entry'))); F3::reroute('http://192.168.140.86/receiver.php?payload=' . $payload );*/ } // Display the blog form again F3::call(':createkul');
function pictureFolder($id) { $path = "photo/"; if (move_uploaded_file(F3::get('FILES.uploadfile.tmp_name'), $path . $id . ".jpg")) { $picture = new Axon("owner_photo"); $picture->vehicle_id = $id; $picture->picture = $id . ".jpg"; $picture->save(); } else { $id = 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();
/** 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; }); }
if (!F3::exists('error')) { $kul = new Axon('kul'); $kul->copyFrom('REQUEST'); $kul->tarih = date("d-m-Y H:i"); // artık elimizde temiz bir tc no var, resmi kaydedelim // ilk kurulum sırasında bu <uploaddir> dizinini oluştur // php prosesi yazacağına göre izinleri doğru ayarla // chgrp -R www-data <uploaddir> && chmod g+w <uploaddir> $tc = $kul->tc; F3::set('tc', $tc); if (!empty($tc)) { $resim = F3::get('uploaddir') . $kul->tc . '.jpg'; yukle($resim); } if (!F3::exists('error')) { // here we go! $kul->save(); // TODO: burada bir özet verelim F3::set('message', 'Kaydınız başarıyla yapıldı.'); // tc no'yu oturuma gömelim ve oradan alalım F3::set('SESSION.tc', $tc); return F3::call(':ok'); } else { if (file_exists($yeni) && !unlink($yeni)) { // TODO ne yazayım ben şimdi buraya } } } // hata var, dön başa ve tekrar kayıt al. // error alanı dolu ve layout.htm'de görüntülenecek F3::call(':goster');