|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verifica se <EFBFBD> o primeiro acesso a pagina
|
|
|
|
|
* @return bool
|
|
|
|
|
*
|
|
|
|
|
* @see isPostback()
|
|
|
|
|
*/
|
|
|
|
|
function isPostBackRequest() {
|
|
|
|
|
return (getRequest('idProg', INPUT_POST) && IsPostBack());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $name nome do par<EFBFBD>metro da requisi<EFBFBD><EFBFBD>o
|
|
|
|
|
* @param int $type <p>
|
|
|
|
|
* One of <b>INPUT_GET</b>, <b>INPUT_POST</b>,
|
|
|
|
|
* <b>INPUT_COOKIE</b>, <b>INPUT_SERVER</b>, or
|
|
|
|
|
* <b>INPUT_ENV</b>.
|
|
|
|
|
* @param int $filter [optional] <p>
|
|
|
|
|
* The ID of the filter to apply. The
|
|
|
|
|
* manual page lists the available filters.
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @see filter_input()
|
|
|
|
|
*
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
function getRequest($name, $type = INPUT_POST, $filter = FILTER_SANITIZE_SPECIAL_CHARS) {
|
|
|
|
|
switch ($type) {
|
|
|
|
|
case INPUT_POST:
|
|
|
|
|
default:
|
|
|
|
|
if (!isset($_POST[$name])) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case INPUT_GET:
|
|
|
|
|
if (!isset($_GET[$name])) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case INPUT_REQUEST:
|
|
|
|
|
if (!isset($_REQUEST[$name])) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case INPUT_SESSION:
|
|
|
|
|
if (!isset($_SESSION[$name]) || session_status() === PHP_SESSION_DISABLED ||
|
|
|
|
|
session_status() === PHP_SESSION_NONE) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case INPUT_COOKIE:
|
|
|
|
|
if (!isset($_COOKIE[$name])) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return filter_input($type, $name, $filter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function sendPostData($url, $data) {
|
|
|
|
|
// Initialize and get the curl handle
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
|
|
|
|
|
// Include possible headers in the reply from the server as well
|
|
|
|
|
curl_setopt($ch, CURLOPT_HEADER, true);
|
|
|
|
|
|
|
|
|
|
// Return the reply as a string from curl_exec() instead of directly to stdout
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
|
|
|
|
|
|
// The URI we want to send the post data to
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
|
|
|
|
|
|
// Use the POST method
|
|
|
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
|
|
|
|
|
|
|
|
// All the data to be sent
|
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
|
|
|
|
|
|
|
$reply = curl_exec($ch);
|
|
|
|
|
|
|
|
|
|
curl_close($ch);
|
|
|
|
|
return $reply;
|
|
|
|
|
}
|