Functions
WebDev/*nix assorted functions & hacks
Search
find all
Array
-
Bash
-
Classes
-
Config
-
DateTime
-
Debug
-
dotjs
-
File
-
foooo
-
Git
-
HTML
-
Images
-
Javascript
-
Linux
-
Math
-
Misc
-
MySQL
-
OS X
-
Reading
-
Redis
-
Shell scripts
-
snippets
-
SQL
-
Strings
-
TextMate
-
Web
-
\(^o^)/ Fun!
-
_Misc hacks
-
_Pages
snippets
.htaccess / mod_rewrite
404 header
Ajax response page
Basic HTTP Auth
Column display sans near-empty columns
JavaScript favelets/bookmarklets
misc php stuffs
php tricks
8
found
auth
Name:
Category: snippets
Body:
ob_start(); // require_once '../../inc/site.inc.php'; // require_once '../../inc/config.inc.php'; header('Content-Type: application/json'); ini_set('display_errors', '1'); error_reporting(-1); $success = false; $message = ''; $data = array(); $debug = ''; $jsonp = isset($_REQUEST['callback']) ? $_REQUEST['callback'] : ''; $act = $_REQUEST['act']; switch ($act) { case 'value': # code... break; default: $message = 'Unknown act parameter.'; break; } $debug = ob_get_clean(); $output = json_encode(compact('success', 'data', 'message', 'debug')); if ($jsonp) { header('Content-Type: application/javascript'); $output = "$jsonp($output)"; } echo $output; /* -- Log -------------------------------- [2014-11-06 23:15:23] gave JSONP correct mimetype [2012-11-04 20:17:27] error reporting -1 [2011-06-25 21:58:49] added JSONP/callback stuff */
Footer