{ $pwgenURL = "http://androm.ru/pwgen/passwordGenerator.php?"; $curl = curl_init($pwgenURL . $params); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($curl); curl_close($curl); return $result; } function debugEcho($string) { echo $string . "\n"; } function logData($data, $flag = True) { if ($flag) { $string = implode(" | ", $data); file_put_contents("./log.txt", $string . "\n", FILE_APPEND); } else { file_put_contents("./log.txt", var_export($data, true) . "\n", FILE_APPEND); } } debugEcho("Starting"); if ($_GET) { debugEcho("It's GET"); processGET($_GET); } elseif ($json = file_get_contents("php://input")) { processUpdate($json); } else { header("Location: https://telegram.me/FlimFlamBot"); exit; }
<?php include "funzioni.php"; //carico i metodi GET POST DELETE dal file funzioni.php $method = $_SERVER['REQUEST_METHOD']; //assume il valore del tipo di richiesta ricevuta (GET/POST/DELETE) $url = $_SERVER['REQUEST_URI']; //indirizzo della richiesta // //dati database $username = '******'; $pass = '******'; $server = 'awsdbistance.cl04jmikh4zc.eu-west-1.rds.amazonaws.com'; $database = "Museo"; $link = mysqli_connect($server, $username, $pass, $database) or die("connessione fallita"); //connessione al DB $stringa = explode('/', $url); //separo l'indirizzo in un array usando come separatore il / if ($method == 'GET') { processGET($stringa, $link); //metodo gestione richieste GET } elseif ($method == 'POST') { $post = $_POST; //array contenente i dati da inserire nel DB processPOST($stringa, $link, $post); //metodo gestione richieste POST } elseif ($method == 'DELETE') { processDELETE($stringa, $link); //metodo gestione richieste DELETE } mysqli_close($link);
$resType = 'json'; } // Base Result Data $resRoot = str_replace($req_url, "", 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . "{$_SERVER['HTTP_HOST']}" . $_SERVER['REQUEST_URI']); $resServer = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . "{$_SERVER['HTTP_HOST']}" . str_replace("." . $resType, "", $_SERVER['REQUEST_URI']); // Remove Trailing forward slash if (substr($resServer, -1) == '/') { $resServer = trim($resServer, '/'); } // Remove Result Type $input_data = str_replace('.xml', '', $input_data); $input_data = str_replace('.json', '', $input_data); // Check Request Method switch (strtolower($reqMethod)) { case "get": processGET($input_data); break; case "post": case "delete": case "put": default: exit(Error400($input_data)); } // Exit Page exit; /** * Function to showResults from GET * Results are displayed as XML or JSON depending on the $resType * @param string $resServer * @param string $reqURL * @param integer $resCount