function setPrimaryTxPayload() { $card_holder_name = $card_number = $card_type = $card_cvv = $card_expiry = $currency_code = $merchant_ref = ""; $card_holder_name = processInput("John Smith"); $card_number = processInput("4788250000028291"); $card_type = processInput("visa"); $card_cvv = processInput("123"); $card_expiry = processInput("1218"); $amount = processInput("1200"); $currency_code = processInput("USD"); $merchant_ref = processInput("Astonishing-Sale"); $primaryTxPayload = array("amount" => $amount, "card_number" => $card_number, "card_type" => $card_type, "card_holder_name" => $card_holder_name, "card_cvv" => $card_cvv, "card_expiry" => $card_expiry, "merchant_ref" => $merchant_ref, "currency_code" => $currency_code); return $primaryTxPayload; }
function returnHappiness($input) { $table = processInput($input); $results = []; $combinations = permute(array_keys($table)); foreach ($combinations as $c) { $happiness = 0; for ($i = 0; $i < strlen($c); $i++) { $personA = $c[$i]; $personB = $i === strlen($c) - 1 ? $c[0] : $c[$i + 1]; $happiness = happiness($happiness, $table[$personA][$personB]); $happiness = happiness($happiness, $table[$personB][$personA]); } // echo $c . ': ' . $happiness . '<br>'; $results[] = $happiness; } return $results; }
if (isset($_POST['confirm'][$i])) { $input['files'][$i]['confirm'] = $_POST['confirm'][$i]; } } // for ($i = 1; $i <= $config['upload']['maxFiles']; $i++) // Uploader first name (REQUIRED) if (isset($_POST['uploaderfirstname'])) { $input['uploaderfirstname'] = processInput($_POST['uploaderfirstname']); } // Uploader last name (REQUIRED) if (isset($_POST['uploaderlastname'])) { $input['uploaderlastname'] = processInput($_POST['uploaderlastname']); } // Uploader email address (REQUIRED) if (isset($_POST['uploaderemail'])) { $input['uploaderemail'] = processInput($_POST['uploaderemail']); } // Confirmation that none of the images violate the TOS (REQUIRED) if (isset($_POST['confirmtos'])) { $input['confirmtos'] = $_POST['confirmtos']; } // Confirmation that all of the form information is accurate if (isset($_POST['confirmaccurate'])) { $input['confirmaccurate'] = $_POST['confirmaccurate']; } ////////////////////////////////////////// // Process input and generate any errors ////////////////////////////////////////// // Validate the uploader information // Assume it is valid until proven otherwise $input['invalid'] = false;
public static function processInput($fieldValues, $expectedValues) { $hookfile = SimpleSAML_Module::getModuleDir('selfregister') . '/hooks/hook_attributes.php'; include_once $hookfile; return processInput($fieldValues, $expectedValues); }
foreach ($playersPositions[0] as $position) { $grid[$position] = 'X'; } foreach ($playersPositions[1] as $position) { $grid[$position] = 'O'; } return $grid; } /** * Generates data to be used in the template file * * @return array */ function getTemplateData($input, $game) { if ($game->isOver()) { if ($game->winner() === false) { $message = "It's a draw"; } else { $winner = $game->winner() == 0 ? 'X' : 'O'; $message = "{$winner} won"; } } else { $message = ''; } $playersPositions = $game->getPlayersPositions(); return ['gameOver' => $game->isOver(), 'message' => $message, 'grid' => getGrid($playersPositions), 'currentPlayer' => count($playersPositions[0]) > count($playersPositions[1]) ? 'O' : 'X', 'gameType' => $input['gameType']]; } $input = processInput(); $game = playRound($input['playersPositions'], $input['gameType'], $input['humanStarts']); $data = getTemplateData($input, $game);
function getResponse() { global $RESPONSE, $SESSION; if (!isset($_POST['sessionID'])) { $RESPONSE = 'missing session ID'; return; } try { $SESSION = Session::fromSessionID($_POST['sessionID']); } catch (DoesNotExistException $e) { $RESPONSE = 'invalid session ID'; return; } switch ($SESSION->getStatus()) { case Session::awaiting_user_input: processInput(); break; case Session::group_request_pending: // assuming a request is pending in the queue, has it expired? if ($request = GroupRequestQueue::retrieveRequest($SESSION)) { if ($request->expired()) { // okay, we're done with this request // delete it from the database GroupRequestQueue::deleteRequests(array($request)); // $RESPONSE = 'no partner found! exiting. (TODO: exit trail)'; //TODO: exit trail $SESSION->startExitTrail(); startStep(); return; } } // nothing to do, except wait, because if a suitable partner comes along, the request pending status will be changed $RESPONSE = array('action' => 'wait'); // TODO: countdown? break; case Session::group_request_fulfilled: startStep(); break; case Session::finished_step: if (readyToMoveOn()) { executeGroupCallbacks(); advanceStep(); } else { /* * readyToMoveOn sets the RESPONSE to the HTML of the waiting file. * But because their status was already finished_step, * we can assume that the waiting screen has already been loaded. * So we just tell them to wait (overriding the response). */ // $RESPONSE = array('action' => 'wait'); } break; case Session::callback_done: advanceStep(); break; case Session::finished: case Session::terminated: $RESPONSE = 'session ended'; break; default: throw new Exception('unknown session status'); break; } }
function setSecondaryTxPayload($transaction_id, $transaction_tag, $amount) { $transaction_type = $merchant_ref = $currency_code = ""; $transaction_type = processInput("void"); $transaction_id = processInput($transaction_id); $transaction_tag = processInput($transaction_tag); $amount = processInput($amount); $currency_code = processInput("USD"); $merchant_ref = processInput("Astonishing-Sale"); $card_type = processInput("visa"); $card_expiry = processInput("1250"); $card_number = processInput("4788250000028291"); $secondaryTxPayload = array("amount" => $amount, "transaction_tag" => $transaction_tag, "transaction_id" => $transaction_id, "merchant_ref" => $merchant_ref, "currency_code" => $currency_code, "card_expiry" => $card_expiry, "card_type" => $card_type, "card_number" => $card_number, "transaction_type" => $transaction_type); return $secondaryTxPayload; }
/* * This example is simply an example of how a provisioning page may look * which includes such funcationality as createing users, initialising their * data, create a token for them, testing the token and resyncing it as needed * */ // Require our php libraries require_once "token.php"; require_once "dbfunctions.php"; require_once "input.php"; // now lets get an instance of our class $myga = new myGA(); global $myga; // this part of the page resonds to user input processInput(); ?> <html> <h1>Welcome to GA Provisioning!</h1> <?php // in this part of the code we look for "success" or "fail" things if (isset($_REQUEST["success"])) { echo "<br><font color=\"green\">" . $_REQUEST["success"] . "</font><br>"; } if (isset($_REQUEST["failure"])) { echo "<br><font color=\"red\">" . $_REQUEST["failure"] . "</font><br>"; } ?>
$finalArr = []; foreach ($arr as $value) { $finalArr[$value] = mysqli_real_escape_string($conn, $value); } return $finalArr; } function processInput($input) { $input = trim($input); $input = strip_tags($input); $input = stripslashes($input); $input = htmlspecialchars($input); return $input; } $score = $_GET['score']; $uname = processInput($_POST['username']); //check whether a user exists $queryUser = "******"; $selected = mysqli_query($conn, $queryUser); $arr = escapeAll([$uname, $score], $conn); if ($selected->num_rows) { echo "<script>alert('There is already such user')</script>"; } else { //create new user $query = "INSERT INTO Users (Name, Score)\n VALUES ('{$arr[$uname]}','{$arr[$score]}')"; $result = mysqli_query($conn, $query); if ($result) { redirect_to('JustShootMe.php'); } else { echo mysqli_error($conn); }
use Symfony\Component\HttpFoundation\Response; use Phroute\Phroute\Exception\HttpRouteNotFoundException; use Phroute\Phroute\Exception\HttpMethodNotAllowedException; use Pimple\Container; $app = new Container(); Facade::setApp($app); (new Error\Handler())->error(function (HttpRouteNotFoundException $e) { echo "404"; })->error(function (HttpMethodNotAllowedException $e) { echo "405"; })->error(function (Exception $e) { throw $e; }); $app['paths'] = array('app' => __DIR__, 'config' => __DIR__ . '/config', 'public' => __DIR__ . '/../public'); $app['config'] = function (Pimple $app) { return new Config\Repository(new Config\FileLoader($app['paths']['config'])); }; $app['request'] = function () { return Request::createFromGlobals(); }; $app['router'] = new Phroute\Phroute\RouteCollector(new Phroute\Phroute\RouteParser()); include __DIR__ . '/routes.php'; $dispatcher = new Phroute\Phroute\Dispatcher($app['router']->getData()); $response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], processInput($_SERVER['REQUEST_URI'])); $response instanceof Response or $response = Response::create($response); $response->send(); function processInput($uri) { $uri = implode('/', array_slice(explode('/', $_SERVER['REQUEST_URI']), 3)); return $uri; }
} return $floor; } function decodeFloor(string $value) : int { $valid = ['(', ')']; if (!in_array($value, $valid)) { throw new \Exception($value . ' is neither ( nor )'); } if ($value === '(') { return 1; } return -1; } /** * Tests */ assert(decodeFloor('(') === 1); assert(decodeFloor(')') === -1); assert(processInput('((((((((()))))))))') === 0); assert(processInput('(((((((((') === 9); assert(processInput('((())))', -1) === 7); /** * DO IT! */ $input = <<<INPUT ((((()(()(((((((()))(((()((((()())(())()(((()((((((()((()(()(((()(()((())))()((()()())))))))))()((((((())((()))(((((()(((((((((()()))((()(())()((())((()(()))((()))()))()(((((()(((()()))()())((()((((())()())()((((())()(()(()(((()(())(()(())(((((((())()()(((())(()(()(()(())))(()((((())((()))(((()(()()(((((()()(()(((()(((((())()))()((()(()))()((()((((())((((())(()(((())()()(()()()()()(())((((())((())(()()))()((((())))((((()())()((((())((()())((())(())(((((()((((()(((()((((())(()(((()()))()))((((((()((())()())))(((()(()))(()()(()(((()(()))((()()()())((()()()(((())())()())())())((()))(()(()))(((((()(()(())((()(())(())()((((()())()))((((())(())((())())((((()(((())(())((()()((((()((((((()(())()()(()(()()((((()))(())()())()))(())))(())))())()()(())(()))()((()(()(())()()))(()())))))(()))(()()))(())(((((()(()(()()((())()())))))((())())((())(()(())((()))(())(((()((((((((()()()(()))()()(((()))()((()()(())(())())()(()(())))(((((()(())(())(()))))())()))(()))()(()(((((((()((((())))())())())())()((((((((((((((()()((((((()()()())())()())())())(())(())))())((()())((()(()))))))()))))))))))))))))())((())((())()()))))))(((()((()(()()))((())(()()))()()())))(())))))))(()(((())))())()())))()()(())()))()(()))())((()()))))(()))))()))(()()(())))))))()(((()))))()(()))(())())))))()))((()))((()))())(())))))))))((((())()))()))()))())(())()()(())))())))(()())()))((()()(())))(())((((((()(())((()(((()(()()(())))()))))))()))()(()((()))()(()))(()(((())((((())())(())(()))))))))())))))))())())))))())))))()()(((())()(()))))))))())))))(())()()()))()))()))(()(())()()())())))))))())()(()(()))))()()()))))())(()))))()()))))()())))))(((())()()))(()))))))))))()()))))()()()))))(()())())()()())()(()))))()(()))(())))))))(((((())(())())()()))()()))(())))))()(()))))(())(()()))()())()))()))()))()))))())()()))())())))(()))(()))))))())()(((())()))))))))()))()())))())))())))()))))))))))()()))(()()))))))(())()(()))))())(()))))(()))))(()())))))())())()()))))())()))))))))(()))))()))))))()(()())))))))()))())))())))())))())))))))())(()()))))))(()())())))()())()))))))))))))))())))()(())))()))())()()(())(()()))(())))())()())(()(()(()))))())))))))))))())(()))()))()))))(())()())()())))))))))))()()))))))))))))())())))))(()())))))))))))())(())))()))))))))())())(()))()))(())))()))()()(())()))))))()((((())()))())())))))()))()))))((()())()))))())))(())))))))))))))))))()))))()()())()))()()))))())()))((()())))())))(()))(()())))))))()))()))))(())))))))(())))))())()()(()))())()))()()))))())()()))))())()))())))))))(()))))()())()))))))))(()))())))(()))()))))(())()))())())(())())())))))))((((())))))()))()))()())()(())))()))()))()())(()())()()(()())()))))())())))))(()))()))))())(()()(())))))(())()()((())())))))(())(())))))))())))))))))()(())))))))()())())())()(()))))))))(()))))))))())()()))()(()))))))()))))))())))))))(())))()()(())()())))))(((())))()((())()))())))(()()))())(())())))()(((()())))))()(()()())))()()(()()(()()))())()(()()()))())()()))()())(()))))())))))())))(())()()))))(()))))(())(()))(())))))()()))()))))())()))()()(())())))((()))())()))))))()()))))((()(()))))()()))))))())))))())(()((()())))))))))))()())())))()))(()))))))(()))(())()())))(()))))))))())()()()()))))(()())))))))((())))()))(()))(())(())()())()))))))))(())))())))(()))()()))(()()))(()))())))()(())))())((()((()(())))((())))()))))((((())())()())))(())))()))))))())(()()((())))())()(()())))))(()())()))())))))))((())())))))))(()(()))())()()(()()(((()(((()())))))()))))))()(())(()()((()()(())()()))())()())()))()())())())))))))(((())))))))()()))))))(((())()))(()()))(()()))))(()(()()((((())()())((()()))))(()(())))))()((()()()())()()((()((()()))(()))(((()()()))(((())))()(((())()))))))((()(())())))(()())(((((()(()))(()((()))(()())()))))(()(()))()(()))(())(((())(()()))))()()))(((()))))(()()()()))())))((()()()(())()))()))))()()))()))))))((((((()()()))))())((()()(((()))))(()(())(()()())())())))()(((()()))(())((())))(()))(()()()())((())())())(()))))()))()((()(())()(()()(())(()))(())()))(())(()))))(())(())())(()()(()((()()((())))((()))()((())))(((()()()()((((()))(()()))()()()(((())((())())(()()(()()()))()((())(())()))())(((()()(())))()((()()())()())(()(())())(((())(())())((())(())()(((()()))(())))((())(()())())(())((()()()((((((())))((()(((((())()))()))(())(()()))()))(())()()))(())((()()())()()(()))())()((())))()((()()())((((()())((())())())((()((()))()))((())((()()(()((()()(((())(()()))))((()((())()(((())(()((())())((())(()((((((())())()(()())()(())(((())((((((()(())(()((()()()((()()(()()()())))()()(((((()()))()((((((()))()(()(()(()(((()())((()))())()((()))(())))()))()()))())()()))())((((())(()(()))(((((((())(((()(((((()(((()()((((())(((())())))(()()()(()(()))()))((((((()))((()(((()(())((()((((()((((((())(((((())))(((()(()))))(((()(((())()((())(()((()))(((()()(((())((((()(()(((((()))(((()(((((((()(()()()(()(()(()()())(())(((((()(())())()())(()(()(()))()(()()()())(()()(()((()))()((())())()(()))((())(()))()(()))()(((()(()(()((((((()()()()())()(((((()()(((()()()((()(((((()))((((((((()()()(((((()))))))(()()()(())(()))(()()))))(())()))(((((()(((((()()(()(()())(((()))((((()((()(()(()((()(()((())))()(((()((()))((()))(((((((((()((()((()(())))()((((()((()()))((())(((()(((((()()(()(()()((()(()()()(((((((())())()())))))((((()()(()))()))(()((())()(()(((((((((()()(((()(()())(()((()())((())())((((()(((()(((()((((()((()((((()(()((((((())((((((((((((()()(()()((((((((((((((()((()()))()((((((((((((())((((()(()())((()(()(()))()(((((()()(((()()))()())(())((()(((((()((())(((((()((()(((((()))()()((((())()((((())(((((((((()(())(()(())))())(()((())(((())(())(())())(()(()(())()()((()((())()(((()(((((()(())))()(((()((())))((()()()(((()(((()((()(()(())(()((()())(()(()(((()(((((((((())(()((((()()))(()((((()()()()(((()((((((((()(()()((((((()(()()(()((()((((((((((()()(((((((()())(())))(((()()))(((((()((()()())(()()((((())((()((((()))))(())((()(()()(((()(()(((()((((()(((((()))())())(()((())()))(((()())((())((())((((()((()((((((())(()((((()()))((((((())()(()))((()(((())((((((((((()()(((((()(((((()((()()()((((())))(()))()((()(())()()((()((((((((((()((())(())(((((()(()(()()))((((()((((()()((()(((()(((((((((()(()((()((()))((((((()(((())()()((()(((((((()())))()()(()((()((()()(((()(()()()()((((()((())((((()(((((((((()(((()()(((()(()(((()(((()((())()(()((()(()(()(()))()(((()))(()((((()((())((((())((((((())(()))(()((((())((()(()((((((((()()((((((()(()(()()()(())((()((()()(((()(((((((()()((()(((((((()))(((((()(((()(()()()(()(((()((()()((())(()(((((((((()(()((()((((((()()((())()))(((((()((())()())()(((((((((((()))((((()()()()())(()()(()(()()))()))(()))(()(((()()))())(()(()))()()((())(()())()())()(()))()))(()()(()((((((())((()(((((((((((()(())()((()(()((()((()(()((()((((((((((()()())((())()(())))((())()())()(((((()(()())((((()((()(())(()))(((())()((()))(((((())(()))()()(()))(((())((((()((((()(())))(((((((()))))())()())(())((())()(()()((()(()))()(()()(()()((()())((())((()()))((((()))()()))(()()(())()()(((((()(())((()((((()))()))(()())())(((()()(()()))(())))))(()))((())(((((()((((()))()((((()))()((())(((())))(((()())))((()(()()(( INPUT; echo processInput($input) . PHP_EOL; echo processInput($input, -1) . PHP_EOL;