function main() { // mesage contains error string if applicable $msg = validate_request(); if ($msg != 'success') { return json_encode(ret_error(401, $msg)); } $result = array(); switch ($_GET['command']) { case 'projects': $result = call_projects($_GET['data']); break; default: $result = ret_error(400, "'{$_GET['command']}' is not a command."); } return json_encode($result); }
$twitter = new twitter(); $twitter->username = $_REQUEST['twuser']; $twitter->password = $_REQUEST['twpass']; if (!$twitter->verifyCredentials()) { $errors['twitter'][] = 'The Twitter username and password you entered is incorrect. Do you need <a href="http://twitter.com/account/resend_password">a reminder of your password</a>?'; } // make sure tag has a value // make sure title and subtitle exists // make sure cache is writable if (count($errors) == 0) { return NULL; } return $errors; } if (isset($_REQUEST['submit'])) { $errors = validate_request(); if (!isset($errors)) { mysql_query("DROP TABLE IF EXISTS tweets"); mysql_query("DROP TABLE IF EXISTS tags"); $sql1 = <<<ENDSQL CREATE TABLE tags ( id int(10) NOT NULL auto_increment, tweet_id varchar(50) NOT NULL default '0', tag varchar(20) NOT NULL default '', PRIMARY KEY (id), INDEX tag (tag), CONSTRAINT tag_tweet UNIQUE (tweet_id,tag) ) TYPE=MyISAM PACK_KEYS=1; ENDSQL; $sql2 = <<<ENDSQL CREATE TABLE tweets (
<?php require_once "../classes/bank_operations.php"; require_once "../classes/api_operations.php"; $response = array(); $p = $_POST; if (isset($_POST) && !empty($_POST)) { if (validate_request($_POST, $response)) { $response['status'] = 200; $banklink = create_banklink($_POST['api_key'], $_POST['amount'], htmlspecialchars($_POST['description'])); $response['banklink'] = "http://localhost/banklink/{$banklink}"; } else { $response['status'] = 400; http_response_code(400); } deliver_response($response); } else { require_once 'instructions.php'; }
<?php $data = file_get_contents("php://input"); $query = json_decode($data); # error_log( print_r( $query, 1 ) ); $me = array('version' => '0.2', 'name' => 'OpenStack'); $guid = '5c33db4b-91b8-4e40-8765-b8f849de6b68'; $userid = 'AFPPR46VI4HFCERSD2ENKTJBTCGHF6J6ERFIWCEI7GP4YDXFRBEJI'; $help = "Help Message Goes Here"; include '../validate-echo-request-php/valid_request.php'; $valid = validate_request($guid, $userid); if (!$valid['success']) { error_log('Request failed: ' . $valid['message']); die; } if ($query) { $action = $query->request->intent->name; if ($action == "RandomProject") { $response = randomproject(); } elseif ($action == "GetProject") { $response = getproject($query); } elseif ($action = 'GetHelp') { $response = $help; } else { $response = $help; } sendresponse($response, $me); } else { sendresponse($help, $me); } /*
{ $cmid = required_param('cmid', PARAM_INT); $userid = required_param('user', PARAM_INT); $filenum = required_param('cn', PARAM_INT); $vmsession = required_param('sesseionkey', PARAM_FILE); $data = required_param('record_data', PARAM_RAW); return array($cmid, $userid, $filenum, $vmsession, $data); } /* The function is executed which is passed by get */ function execute_action($valid_parameters, $DB) { $getdata = received_get_data(); if ($getdata && isset($getdata['methodname'])) { $postdata = received_post_data(); if ($postdata) { $function_list = unserialize(Functions_list); if (in_array($getdata['methodname'], $function_list)) { //call_user_func($getdata['methodname'], $getdata, $postdata, $valid_parameters, $DB); $getdata['methodname']($getdata, $postdata, $valid_parameters, $DB); } else { throw new Exception('There is no ' . $getdata['methodname'] . ' method to execute.'); } } } else { throw new Exception('There is no method to execute.'); } } set_header(); exit_if_request_is_options(); $validparams = validate_request(); execute_action($validparams, $DB);
<?php /* Proxy to redirect https conections from a Server with Trusted Certifcate to a server with a self signed certificate Use Get params, u => url, k => validation key inorder to get the validation key you need to make a call using 'u' and '<your-secret-key>' (aka PROXY_KEY) as params */ require "../config/config.php"; if (validate_request($_GET['u'], $_GET['k'])) { $request_body = file_get_contents('php://input'); $ch = curl_init($_GET['u']); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($request_body))); curl_setopt($ch, CURLOPT_POSTFIELDS, $request_body); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //curl_setopt( $ch, CURLOPT_HEADER, true ); //curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); curl_setopt($ch, CURLOPT_USERAGENT, PROXY_USER_AGENT); curl_exec($ch); $status = curl_getinfo($ch); print_r($status); curl_close($ch); } else { header("HTTP/1.0 403 Forbidden"); echo "403 Forbidden"; }