* * @package System * @author Vallo Reima * @copyright (C)2015 */ error_reporting(E_ALL | E_STRICT); ini_set('display_errors', true); ini_set('log_errors', false); /* sample default options */ $def = array('sgn' => true, 'exf' => ['*.min.*'], 'sfx' => '_pkd', 'aon' => [], 'arc' => 'zip', 'tml' => 30); /* sample request */ $_GET = array('sgn' => '', 'arc' => '7z', 'aon' => ['add']); $_POST = array('sfx' => '', 'arc' => 'tar', 'exf' => null); require 'ParmOpts.php'; // load the class $obj = new ParmOpts(); // instantiate with default priority $opt = $obj->Opts($def); // assign settings, update with the request values $prm = $obj->Get(); // request parameters /* display result */ header('Content-Type: text/html; charset=utf-8'); echo 'ParmOpts usage sample<br><br>'; echo 'Options<br>'; echo '<pre>'; print_r($opt); // updated options echo '</pre>'; echo 'Parameters<br>'; echo '<pre>';
* @package ParmTran * @author Vallo Reima * @copyright (C)2015 */ error_reporting(E_ALL | E_STRICT); ini_set('display_errors', true); ini_set('log_errors', false); date_default_timezone_set(@date_default_timezone_get()); // define if not defined $a = explode(' ', $_SERVER['SERVER_SOFTWARE']); $def = array('server' => array_shift($a), 'timezone' => date_default_timezone_get(), 'browser' => '...', 'offset' => '', 'btn' => ''); $bts = array('p' => array('POST', 'Send the client details via POST method'), 'a' => array('AJAX', 'Use AJAX to send/receive the client details'), 'g' => array('GET', 'Get to the beginning via GET method')); $sts = array('opn' => 'Use either POST or AJAX to request', 'rqa' => 'Try AJAX this time', 'rqp' => 'Try POST this time', 'rsp' => 'The POST response', 'rsa' => 'The AJAX response'); require 'ParmOpts.php'; // load the class $obj = new ParmOpts(); // receive request data $opt = $obj->Opts($def); // update defaults with the request values $ajx = $obj->Get('jsn'); // ajax call flag if ($opt['offset'] == '') { // startup/get if ($opt['btn'] == 'p') { // buton was pressed $s = 'rqa'; } else { if ($opt['btn'] == 'a') { $s = 'rqp'; } else { $s = 'opn';