} } else { $data = json_encode($doc); } $cb = getparam('callback'); if ($cb) { echo $cb . '(' . $data . ')'; } else { echo $data; } } F3::route('POST /@db/objects/@model', function () { $dbName = F3::get('PARAMS["db"]'); $model = F3::get('PARAMS["model"]'); $doc = json_decode(file_get_contents('php://input')); if (!isset($doc->_id)) { $doc->_id = $model; } $response = saveDocument($dbName, $doc, true); if (isset($response->rev)) { $doc->_rev = $response->rev; } wrapResponse($response, $doc); }); F3::route('GET /@db/objects/@model', function () { $dbName = F3::get('PARAMS["db"]'); $model = F3::get('PARAMS["model"]'); $response = getDocument($dbName, $model); wrapResponse($response, $response); }); F3::run();
<!-- 1) Url: http://192.168.56.101/ Çıktı: We rock!We roll.... 2) Url: http://192.168.56.101/ Çıktı: We rock!What's a rattle?We roll.... --> <?php require_once 'F3/F3.php'; F3::route('GET /', 'rock|roll'); function rock() { echo 'We rock!'; } function roll() { echo 'We roll...'; } F3::route('GET /barrel', 'rock|rattle|roll'); function rattle() { echo 'What\'s a rattle?'; } F3::run();
<?php require_once 'lib/base.php'; F3::route('GET /', 'home'); function home() { echo 'Hello world'; } F3::run();
<?php require __DIR__ . '/lib/base.php'; F3::set('CACHE', FALSE); F3::set('DEBUG', 1); F3::set('UI', 'ui/'); F3::route('GET /index.php', function () { F3::set('modules', array('apc' => 'Cache engine', 'gd' => 'Graphics plugin', 'hash' => 'Framework core', 'imap' => 'Authentication', 'json' => 'Various plugins', 'ldap' => 'Authentication', 'memcache' => 'Cache engine', 'mongo' => 'M2 MongoDB mapper', 'pcre' => 'Framework core', 'pdo_mssql' => 'SQL handler, Axon ORM, Authentication', 'pdo_mysql' => 'SQL handler, Axon ORM, Authentication', 'pdo_pgsql' => 'SQL handler, Axon ORM, Authentication', 'pdo_sqlite' => 'SQL handler, Axon ORM, Authentication', 'session' => 'Framework core', 'sockets' => 'Network plugin', 'xcache' => 'Cache engine')); echo Template::serve('welcome.htm'); }); F3::run();
F3::set('config_permissions', $settings->config_permissions); $status_buttons = Template::serve('ui/status_buttons.html'); F3::set('status_buttons', Template::serve('ui/status_buttons.html')); F3::set('content', Template::serve('ui/settings.html')); echo Template::serve('ui/template.html'); } */ F3::route('GET /settings', function () { global $settings; $settings->settings_page_data(); F3::set('company_logos', $settings->company_logos); // F3::set('debug', $settings->debug); F3::set('config_permissions', $settings->config_permissions); $status_buttons = Template::serve('ui/status_buttons.html'); F3::set('status_buttons', Template::serve('ui/status_buttons.html')); F3::set('content', Template::serve('ui/settings.html')); echo Template::serve('ui/template.html'); }); F3::route('GET /set_permissions', function () { global $settings; $settings->set_permissions(); F3::reroute('/settings'); }); F3::route('POST /save_settings', function () { $post_data = $_POST; $settings = new Settings(); $settings->save(); F3::reroute('/settings'); }); F3::route('GET /debug', 'debug.php'); F3::run();
$access->policy('deny'); $access->allow('/admin/*', 'admin'); $access->allow('GET|POST /admin/Auth*'); $access->allow('GET|POST /admin/auth*'); if (!$f3->exists('SESSION.user_type') && !$f3->exists('COOKIE.user')) { $f3->set('SESSION.user_type', 'guest'); } $access->authorize($f3->get('SESSION.user_type'), function ($route, $subject) { \F3::reroute('@admin_pack(@pack=Auth)'); }); /* Default settings for template #1 */ if ($f3->exists("COOKIE.user") or $f3->exists("SESSION.user")) { $userz = \User::createUser(\kksd\Sesi::$DB); $userz->load(array('id=?', $f3->exists("COOKIE.user") ? $f3->COOKIE['user'] : $f3->SESSION['user'])); $f3->set("system.user", $userz); } \Template::instance()->extend('php', function ($args) { $html = isset($args[0]) ? $args[0] : ''; return "<?php {$html} ?>"; }); }); \F3::route("GET @admin: /admin", "\\Control\\Admin\\App->home"); \F3::route("GET @admin_home: /admin/dash", "\\Control\\Admin\\App->dash"); \F3::route("GET @admin_pack: /admin/@pack", "\\Control\\Admin\\@pack->index"); \F3::route("POST @admin_pack", "\\Control\\Admin\\@pack->post_index"); \F3::route("GET @admin_pack_func: /admin/@pack/@func", "\\Control\\Admin\\@pack->get_@func"); \F3::route("POST @admin_pack_func", "\\Control\\Admin\\@pack->post_@func"); \Middleware::instance()->run(); //we've settinged a middleware, be4.
<?php include 'lib/F1.php'; F3::set('template', 'goster'); function render() { echo F3::serve('layout.htm'); } F3::config(".f3.ini"); F3::route("GET {$F3}/captcha", ':captcha'); F3::route("GET {$F3}/", ':goster'); F3::route("GET {$F3}/cikti", ':cikti'); F3::route("POST {$F3}/kaydet", ':kaydet'); F3::route("GET {$F3}/sorgu", ':sorgual'); F3::route("POST {$F3}/sorguyap", ':sorguyap'); F3::route("GET {$F3}/sorgucikti", ':sorgucikti'); F3::run(); ?>
<!-- Url: http://192.168.56.101/ Çıktı: Hello world --> <?php require_once 'F3/F3.php'; F3::route('GET /', 'main'); function main() { F3::set('name', 'world'); F3::set('buddy', array('Tom', 'Dick', 'Harry')); F3::set('gender', 'M'); F3::set('loggedin', 'true'); F3::set('div', array('coffee' => array('arabica', 'barako', 'liberica', 'kopiluwak'), 'tea' => array('darjeeling', 'pekoe', 'samovar'))); F3::set('rows', array(1, 2, 3, 4, 5)); echo F3::serve('5template.htm'); } F3::run();
<!--Usage: Url: http://192.168.56.101/brew/1 Çıktı: http://192.168.56.101/brew/1 http://fatfree.sourceforge.net/#router --> <?php require_once 'F3/F3.php'; F3::route('GET /brew/@count', 'drink'); function drink() { echo F3::get('PARAMS["count"]') . ' bottles of beer on the wall.'; } F3::run();
<?php require __DIR__ . '/lib/base.php'; include_once 'avro.php'; F3::route('GET /', 'home'); function home() { echo "Hello, X.commerce! You should be posting to /cse/offer/create\n"; } F3::route('GET /testphp', function () { echo print_r(get_loaded_extensions(), true); echo print_r(phpInfo(), true); }); F3::route('POST /cse/offer/create', 'cse'); function cse() { // Open the log file to which to write outputs $fp = fopen('test.log', 'at'); // Get all http headers in the received message $headers = getallheaders(); // Get the posted message body // NOTE: The message body is currently in Avro binary form $post_data = file_get_contents("php://input"); // Get the URI of the Avro schema on the OCL server that adheres to the /cse/offer/create contract $schema_uri = $headers['X-XC-SCHEMA-URI']; // Get the contents of the Avro schema identified by the URI retrieved above $content = file_get_contents($schema_uri); // Parse the CSE Avro schema and place results in an AvroSchema object $schema = AvroSchema::parse($content); //fwrite($fp, $schema); //fwrite($fp, "\n");
curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: avro/json", "Authorization: " . F3::get('SESSION.ship_token'), "X-XC-MESSAGE-GUID-CONTINUATION: ", "X-XC-WORKFLOW-ID: " . F3::get('wf_id'), "X-XC-TRANSACTION-ID: " . F3::get('transaction_id'), "X-XC-SCHEMA-VERSION: " . F3::get('SESSION.ship_ver'))); curl_setopt($ch, CURLOPT_POSTFIELDS, $write_io->string()); $response = curl_exec($ch); echo $response; }); F3::route('POST /reset', function () { F3::set('SESSION.cart_token', "Bearer EmD5+rI5JWO0w4DEev8+HQMYOszwD6M8FoXG9J/50GBSE8LDeOCjOFqf4XwGKHmfS+y13vd4"); F3::set('SESSION.ship_order_token', "Bearer EmD5+rI5JWO0w4DEev8+HQMYOszwD6M8FoXG9J/50GBSE8LDeOCjOFqf4XwGKHmfS+y13vd4"); F3::set('SESSION.ship_token', "Bearer DTnGqOEPTffZyQ/byw/IwTedDIhtL+m3P+EsCI4br/dtNc5njBCx217Imh3QPGyBH2cFa5XE"); $return_array = array("ctoken" => F3::get('SESSION.cart_token'), "stoken" => F3::get('SESSION.ship_token')); echo json_encode($return_array); }); F3::route('POST /update', function () { if (!empty($_POST["cart_token"])) { F3::set('SESSION.cart_token', $_POST["cart_token"]); error_log(F3::get('SESSION.cart_token')); } if (!empty($_POST["cart_token"])) { F3::set('SESSION.ship_order_token', $_POST["cart_token"]); } if (!empty($_POST["ship_token"])) { F3::set('SESSION.ship_token', $_POST["ship_token"]); } error_log(print_r($_POST, true)); // F3::reroute('/'); $return_array = array("ctoken" => F3::get('SESSION.cart_token'), "stoken" => F3::get('SESSION.ship_token')); echo json_encode($return_array); }); F3::run();
<?php // Application Configuration include "../config.php"; // PHP Fat Free Framework (http://fatfree.sourceforge.net/) require_once __SITE_PATH . "/library/F3/lib/base.php"; // Framework Configuration and Database Info require_once __SITE_PATH . "/F3Config.php"; // Autoload Assets F3::set('AUTOLOAD', __SITE_PATH . "/application/controllers/|" . __SITE_PATH . "/application/models/|" . __SITE_PATH . "/library/F3/lib/"); // Framework Variables F3::set('GUI', __SITE_PATH . "/application/views/"); // Application Routes F3::route('GET /', "RootController->get"); F3::route('GET /about', "RootController->about"); F3::route('GET /loot', "LootDirectoryController->get", 604800); F3::route('GET /loot/@item', "LootController->get", 3600); F3::route('GET /search', "SearchController->get"); F3::route('GET /ajax/loot', "AjaxController->loot"); // Let's Roll Out, Autobots! F3::run();
} else { F3::reroute('/admin'); } $view = new View(); echo $view->render('layout.htm'); }); F3::route('GET /admin/list', function () { (new app\controllers\GalleryController())->viewAll(); }); F3::route('GET /admin/upload', function () { F3::set('html_title', 'My Blog Create'); F3::set('content', 'admin_edit.html'); if (!F3::get('SESSION.user')) { F3::set('content', 'security.html'); } $view = new View(); echo $view->render('upload.html'); }); F3::route('POST /admin/loadToServer', function () { echo (new app\controllers\UploadController())->load(); }); F3::route('DELETE /admin/deleteFromServer/@id', function () { echo (new app\controllers\UploadController())->delete(); }); F3::route('GET /admin/delete/@name', function () { (new app\controllers\GalleryController())->delete(F3::get('PARAMS.name')); }); F3::route('GET /admin/addToGallery', function () { (new app\controllers\GalleryController())->loadAll(); }); F3::run();
F3::route('GET /delete/@cn', ':erasekul'); F3::route('GET /rename/@cn', ':todo'); // Logout F3::route('GET /logout', ':logout'); // RSS feed F3::route('GET /rss', ':rss'); // Generate CAPTCHA image F3::route('GET /captcha', ':captcha'); F3::route('GET /ldap/search', ':ldap_search'); F3::route('GET /ldap/modify', ':ldap_modify'); F3::route('GET /ldap/create', ':ldap_add'); F3::route('GET /ldap/erase', ':ldap_erase'); F3::route('GET /ldap/rename', ':ldap_rename'); F3::route('GET /ldap/compare', ':ldap_compare'); F3::route('GET /info', ':info'); F3::route('GET /tester/@foo', 'tester'); function tester() { echo F3::get('PARAMS.foo'); } // Execute application F3::run(); /** The function below could have been saved as an import file (render.php) loaded by the F3::route method like the other route handlers; but let's embed it here so you can see how you can mix and match MVC functions and import files. Although allowed by Fat-Free, functions like these are not recommended because they pollute the global namespace, specially when it's defined in the main controller. In addition, the separation of the controller
<?php //include 'lib/F1.php'; require_once 'lib/F3.php'; function render() { echo F3::serve('layout.htm'); } F3::config(".f3.ini"); F3::route("GET /captcha", ':captcha'); F3::route("GET /min", ':minified', 3600); F3::route("GET /", ':home'); F3::route("GET /create", ':createkul'); F3::route("POST /create", ':savekul'); F3::route("GET /test", "test"); function test() { echo F3::serve("example.htm"); } F3::route("GET /ajax/adresAjax/@parameter", ":adresAjax"); F3::route("GET /ajax/tc/@tc", ":tc"); F3::run(); ?>
<!-- Url: http://192.168.56.101/omu Çıktı: OMU nun sayfasi --> <?php require_once 'F3/F3.php'; F3::route('GET /omu', function () { F3::reroute('http://www.omu.edu.tr'); }); F3::run();
F3::route('GET /show', ':showkul'); /* // Edit blog entry F3::route('GET /edit/@tc',':editkul'); // Update blog entry F3::route('POST /edit/@tc',':updatekul'); // Delete blog entry F3::route('GET /delete/@tc',':erasekul'); */ // Logout F3::route('GET /logout', ':logout'); // RSS feed F3::route('GET /rss', ':rss'); // Generate CAPTCHA image F3::route('GET /captcha', ':captcha'); // Execute application F3::run(); /** The function below could have been saved as an import file (render.php) loaded by the F3::route method like the other route handlers; but let's embed it here so you can see how you can mix and match MVC functions and import files. Although allowed by Fat-Free, functions like these are not recommended because they pollute the global namespace, specially when it's defined in the main controller. In addition, the separation of the controller component and the business logic becomes blurred when we do this - not good MVC practice. It's all right to define the function here if you're still figuring out
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();
F3::route('GET|POST /callbacks/signature_callback', 'callbacks/signature_callback.php'); F3::route('GET|POST /callbacks/signature_check_file', 'callbacks/signature_check_file.php'); F3::route('GET|POST /callbacks/annotation_callback', 'callbacks/annotation_callback.php'); F3::route('GET|POST /callbacks/annotation_check_file', 'callbacks/annotation_check_file.php'); F3::route('GET|POST /callbacks/check_guid', 'callbacks/check_guid.php'); F3::route('GET|POST /callbacks/compare_callback', 'callbacks/compare_callback.php'); F3::route('GET|POST /callbacks/compare_check_file', 'callbacks/compare_check_file.php'); F3::route('GET|POST /callbacks/convert_callback', 'callbacks/convert_callback.php'); F3::route('GET|POST /callbacks/check_file', 'callbacks/check_file.php'); F3::route('GET|POST /callbacks/download_file', 'callbacks/download_file.php'); F3::route('GET|POST /callbacks/sample37_callback', 'callbacks/sample37_callback.php'); F3::route('GET|POST /callbacks/sample39_callback', 'callbacks/sample39_callback.php'); F3::route('GET|POST /callbacks/sample40_callback', 'callbacks/sample40_callback.php'); F3::route('GET|POST /callbacks/sample41_callback', 'callbacks/sample41_callback.php'); F3::route('GET|POST /callbacks/publish_callback', 'callbacks/publish_callback.php'); F3::route('GET /about_framework.php', 'about'); function home() { //sample code //$apiKey = 'cebff9b66782df9e519c1fc11c0a7ac3'; //$clientId = '60bef2f950c9cd0e'; //$fileId = '47d86daacf8bbcd66c1dab08791a459272dcfa48cbc5ed8f07ec297f43d21186'; //$signer = new GroupDocsRequestSigner($apiKey); //$apiClient = new APIClient($signer); // PHP SDK V1.1 //$antApi = new AntApi($apiClient); //$annotations = $antApi->ListAnnotations($clientId, $fileId); //echo var_dump($annotations); echo Template::serve('index.htm'); } function about() {