本文整理汇总了PHP中dispatch_post函数的典型用法代码示例。如果您正苦于以下问题:PHP dispatch_post函数的具体用法?PHP dispatch_post怎么用?PHP dispatch_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dispatch_post函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
<?php
require_once 'autoload.php';
//load app classes
require_once 'lib/limonade.php';
dispatch('/css/:css', 'AssetController::css');
dispatch('/js/:js', 'AssetController::js');
//ROUTES
dispatch_get('/', 'PostController::index');
dispatch_get('/new', 'PostController::neew');
//R
dispatch_get('/edit/:post', 'PostController::edit');
//R
dispatch_post('/:post', 'PostController::save');
//C, U
dispatch_get('/:post', 'PostController::post');
dispatch_post('/remove/:post', 'PostController::remove');
//D
run();
示例2: post
/**
* Define a POST route for AJAX POST with token validation
* @param string $route
* @param \Closure $closure
*/
public static function post($route, \Closure $closure, $getNewStuff = true)
{
if (!\CODOF\User\CurrentUser\CurrentUser::loggedIn()) {
$getNewStuff = false;
//not available for guests
}
dispatch_post($route, function () use($closure, $getNewStuff) {
Request::processReq($closure, $getNewStuff, func_get_args());
});
}
示例3: html
return html('index.html.php');
}
dispatch('/info', 'info');
function info()
{
return html('info.html.php');
}
dispatch('/book', 'book');
function book()
{
// $event = option('tito')->getEvent('funconf');
// set('event', $event->event);
// set('ticket_types', $event->event->ticket_types);
return html('book.html.php');
}
dispatch_post('/book', 'book_post');
function book_post()
{
$event = option('tito')->getEvent('funconf');
set('event', $event->event);
set('ticket_types', $event->event->ticket_types);
$ticketInfo = new stdClass();
$ticketInfo->{1} = new stdClass();
$ticketInfo->{1}->ticket_type_id = $_POST['ticket_type_id'];
$ticketInfo->{1}->release_id = $_POST['release_id'];
$ticketInfo->{1}->quantity = $_POST['quantity'];
// Here you set your own data.
$name = $_POST['name'];
$email = $_POST['email'];
// The first param is the event to add the ticket to. The second parameter
// is the array of information to pass. See the ticketInfo hack above, this has
示例4: dispatch_post
if ($choice == "3") {
$tropo->say("You picked the Star Wars prequels. Stop calling this number, Mr. Lucas, we know it's you.");
}
if ($choice == "4") {
$tropo->say("You picked the Matrix. Dude, woe.");
}
// Tell Tropo what to do next. This redirects to the instructions under dispatch_post('/hangup', 'app_hangup').
$tropo->on(array("event" => "continue", "next" => "favorite-movie-webapi.php?uri=hangup"));
// Tell Tropo what to do if there's an problem, like a timeout. This redirects to the instructions under dispatch_post('/incomplete', 'app_incomplete').
$tropo->on(array("event" => "incomplete", "next" => "favorite-movie-webapi.php?uri=incomplete"));
// Render the JSON for the Tropo WebAPI to consume.
return $tropo->RenderJson();
}
dispatch_post('/hangup', 'app_hangup');
function app_hangup()
{
$tropo = new Tropo();
$tropo->say("Thanks for voting!");
$tropo->hangup();
return $tropo->RenderJson();
}
dispatch_post('/incomplete', 'app_incomplete');
function app_error()
{
$tropo = new Tropo();
$tropo->say("Something has gone wrong, please call back.");
$tropo->hangup();
return $tropo->RenderJson();
}
// Run this sucker!
run();
示例5: dispatch
dispatch('/', 'index');
function index()
{
$o = "HELLO";
if (array_key_exists('sort', $_GET)) {
$o .= " | sort=" . $_GET['sort'];
}
return $o;
}
dispatch('/books/:lang', 'books');
function books()
{
$o = "lang=" . params('lang');
if (array_key_exists('sort', $_GET)) {
$o .= " | sort=" . $_GET['sort'];
}
if (array_key_exists('page', $_GET)) {
$o .= " | page=" . $_GET['page'];
}
return $o;
}
dispatch_post('/books', 'create');
function create()
{
$o = '';
if (array_key_exists('title', $_POST)) {
$o = "title=" . $_POST['title'];
}
return $o;
}
run();
示例6: error_reporting
<?php
require 'tropo.class.php';
require 'limonade/lib/limonade.php';
error_reporting(0);
dispatch_post('/', 'app_start');
function app_start()
{
$tropo = new Tropo();
$tropo->call("+14071234321", array("machineDetection" => "This is just a test to see if you are a human or a machine. PLease hold while we determine. Almost finished. Thank you!", "voice" => "Kate"));
$tropo->on(array("event" => "continue", "next" => "your_app.php?uri=continue"));
$tropo->RenderJson();
}
dispatch_post('/continue', 'app_continue');
function app_continue()
{
$tropo = new Tropo();
@($result = new Result());
$userType = $result->getUserType();
$tropo->say("You are a {$userType}");
$tropo->RenderJson();
}
run();
示例7: dispatch
<?php
# render a view for connecting roles with services
dispatch('/roles_services', 'roles_services_index');
function roles_services_index()
{
$cfg = $GLOBALS['cfg'];
$db = $GLOBALS['db'];
$arrRoles = fetchRolesServices();
set('roles', $arrRoles);
$arrServices = $db->select("SELECT {$cfg['tblService']}.id as sid,\n {$cfg['tblService']}.`desc` as service_desc,\n {$cfg['tblDaemon']}.name as daemon_name,\n {$cfg['tblServer']}.fqdn as fqdn\n FROM {$cfg['tblService']}\n LEFT OUTER JOIN {$cfg['tblServer']}\n ON {$cfg['tblServer']}.id = {$cfg['tblService']}.server_id\n LEFT OUTER JOIN {$cfg['tblDaemon']}\n ON {$cfg['tblDaemon']}.id = {$cfg['tblService']}.daemon_id\n ORDER BY {$cfg['tblDaemon']}.name ASC");
set('services', $arrServices);
return html('roles_services/index.html.php');
}
# associate a role with a service
dispatch_post('/roles_services', 'roles_services_create');
function roles_services_create()
{
$cfg = $GLOBALS['cfg'];
$db = $GLOBALS['db'];
$role_id = intval($_POST['role_id']);
$service_id = intval($_POST['service_id']);
$connect = isset($_POST['connect']) ? true : false;
$result = $db->insert("INSERT INTO {$cfg['tblAccess']}\n (rolle_id, dienst_id) VALUES\n ('{$role_id}', '{$service_id}')");
if (!$result) {
halt(SERVER_ERROR);
return;
}
if (isAjaxRequest() && $connect) {
$arrRoles = fetchRolesServices("WHERE {$cfg['tblRole']}.id = {$role_id}");
return js('roles_services/role.js.php', null, array('role' => array_pop($arrRoles)));
示例8: dispatch
<?php
require_once 'lib/limonade.php';
require_once 'lib/php-activerecord/ActiveRecord.php';
require_once "lib/JBBCode/Parser.php";
require_once 'ServiceLocator.php';
//My own locator
ActiveRecord\Config::initialize(function ($cfg) {
$cfg->set_model_directory('models');
$cfg->set_connections(array('development' => 'mysql://root@localhost/xii'));
});
dispatch('/', 'PostController::index');
//visitors
dispatch('/blog/:user_id', 'PostController::blog');
//dispatch('/blog/:user_id/:id', 'PostController::post');
//AUTH
dispatch('/google-auth', 'GoogleAuthController::auth');
dispatch('/logout', 'GoogleAuthController::logout');
//POST CRUD
dispatch('/new', 'PostController::newpost');
dispatch('/:id', 'PostController::post');
dispatch('/:id/edit', 'PostController::edit');
dispatch_post('/:id/save', 'PostController::save');
dispatch('/:id/delete', 'PostController::delete');
run();
示例9: dispatch_get
<?php
require_once "lib/limonade.php";
dispatch_get("/", "redirect_data");
dispatch_get("/data", "data");
dispatch_get("/data/extract", "data_extract");
dispatch_get("/document", "document");
dispatch_get("/promo", "promo");
dispatch_post("/document", "add_document");
dispatch_post("/promo", "add_promo");
dispatch_put("/data/:dataid", "alter_data");
dispatch_put("/document/:documentid", "alter_document");
dispatch_put("/promo/:promoid", "alter_promo");
dispatch_delete("/document/:fileid", "delete_document");
dispatch_delete("/promo/:promoid", "delete_promo");
try {
run();
} catch (Exception $e) {
error_log($e);
}
示例10: configure
<?php
function configure()
{
option('app_dir', file_path(dirname(option('root_dir')), 'app'));
option('lib_dir', file_path(option('app_dir'), 'lib'));
option('views_dir', file_path(option('app_dir'), 'views'));
option('session', "app_session");
option('debug', false);
setlocale(LC_TIME, "ro_RO");
}
/**
* Start the logic
*/
dispatch('/', 'index');
dispatch('/creare', 'creare');
dispatch_post('/creare', 'cont_nou');
dispatch('/contact', 'contact');
dispatch_post('/contact', 'trimite');
run();
示例11: option
option('env', $env);
option('dsn', $dsn);
option('db_conn', $db);
option('debug', true);
}
function after($output)
{
$time = number_format((double) substr(microtime(), 0, 10) - LIM_START_MICROTIME, 6);
$output .= "<!-- page rendered in {$time} sec., on " . date(DATE_RFC822) . "-->";
return $output;
}
layout('layout/default.html.php');
// main controller
dispatch('/', 'main_page');
// books controller
dispatch_get('books', 'books_index');
dispatch_post('books', 'books_create');
dispatch_get('books/new', 'books_new');
dispatch_get('books/:id/edit', 'books_edit');
dispatch_get('books/:id', 'books_show');
dispatch_put('books/:id', 'books_update');
dispatch_delete('books/:id', 'books_destroy');
// authors controller
dispatch_get('authors', 'authors_index');
dispatch_post('authors', 'authors_create');
dispatch_get('authors/new', 'authors_new');
dispatch_get('authors/:id/edit', 'authors_edit');
dispatch_get('authors/:id', 'authors_show');
dispatch_put('authors/:id', 'authors_update');
dispatch_delete('authors/:id', 'authors_destroy');
run();
示例12: option
$db = option('db_conn');
$user = get('user');
$stmt = $db->prepare('SELECT id, content, is_private, created_at, updated_at FROM memos WHERE user = :user ORDER BY created_at DESC');
$stmt->bindValue(':user', $user['id']);
$stmt->execute();
$memos = $stmt->fetchAll(PDO::FETCH_ASSOC);
set('memos', $memos);
return html('mypage.html.php');
});
dispatch_post('/memo', function () {
$db = option('db_conn');
$user = get('user');
$content = $_POST["content"];
$is_private = $_POST["is_private"] != 0 ? 1 : 0;
$stmt = $db->prepare('INSERT INTO memos (user, content, is_private, created_at) VALUES (:user, :content, :is_private, now())');
$stmt->bindValue(':user', $user['id']);
$stmt->bindValue(':content', $content);
$stmt->bindValue(':is_private', $is_private);
$stmt->execute();
$memo_id = $db->lastInsertId();
return redirect('/memo/' . $memo_id);
});
dispatch_get('/memo/:id', function () {
$db = option('db_conn');
$user = get('user');
$stmt = $db->prepare('SELECT id, user, content, is_private, created_at, updated_at FROM memos WHERE id = :id');
$stmt->bindValue(':id', params('id'));
$stmt->execute();
$memo = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$memo) {
return halt(404);
示例13: dispatch
# matches GET /posts/1
dispatch('/posts/:id', 'blog_posts_show');
function blog_posts_show()
{
if ($post = post_find(params('id'))) {
set('post', $post);
# passing the post the the view
return html('posts/show.html.php');
# rendering the view
} else {
halt(NOT_FOUND, "This post doesn't exists");
# raises error / renders an error page
}
}
# matches POST /posts
dispatch_post('/posts', 'blog_posts_create');
function blog_posts_create()
{
if ($post_id = post_create($_POST['post'])) {
redirect_to('posts', $post_id);
# redirects to the show page of this newly created post
} else {
halt(SERVER_ERROR, "AN error occured while trying to create a new post");
# raises error / renders an error page
}
}
# matches GET /posts/1/edit
dispatch('/posts/:id/edit', 'blog_posts_edit');
function blog_posts_edit()
{
if ($post = post_find(params('id'))) {
示例14: logit
$argstr = $args;
}
logit("calling " . "return {$name}::{$message}({$argstr});");
$result = eval("return {$name}::{$message}({$argstr});");
}
logit("result", $result);
return json_encode(array($result));
} catch (LoadError $e) {
halt(422, json_encode(array("exception" => "LoadError", "error" => $e->getMessage())));
} catch (Exception $e) {
logit('Exception ' . $e->getMessage());
halt(422, json_encode(array("exception" => get_class($e), "error" => $e->getMessage())));
// return json_encode(array('error' => $e->getMessage()));
}
}
dispatch_post('/class/:name', 'new_object');
function new_object()
{
try {
$name = params('name');
$args = $_POST['args'];
$argstr = $args;
logit('POST: args ', $args);
if (is_null($args) || $args == '[]') {
logit("calling new {$name}()");
$object = new $name();
logit("got object:" . get_class($object));
} else {
logit('args b4 decode', $args);
$args = json_decode($args, true);
logit('args after decode', $args);
示例15: set
set('seat_id', $seat_id);
return html('complete.html.php');
} else {
$db->rollback();
return html('soldout.html.php');
}
});
dispatch('/admin', function () {
return html('admin.html.php');
});
dispatch_post('/admin', function () {
$db = option('db_conn');
$fh = fopen(realpath(__DIR__ . '/../config/database/initial_data.sql'), 'r');
while ($sql = fgets($fh)) {
$sql = rtrim($sql);
if (!empty($sql)) {
$db->exec($sql);
}
}
fclose($fh);
redirect_to('/admin');
});
dispatch('/admin/order.csv', function () {
$db = option('db_conn');
$stmt = $db->query(<<<SQL
SELECT order_request.*, stock.seat_id, stock.variation_id, stock.updated_at
FROM order_request JOIN stock ON order_request.id = stock.order_id
ORDER BY order_request.id ASC
SQL
);
$body = '';
$orders = $stmt->fetchAll(PDO::FETCH_ASSOC);