function getAPIStats() { $xml = @simplexml_load_file("https://sciigears.appspot.com/parsing?protVer=1&op=info&apiKey=U25UU-V061N-LM6XA-SLDPV-AA6M9"); if (!$xml) { echo "General Error."; exit(1); } if ($xml->result['code'] != 0) { loga("Erro ao carregar Info da API"); } else { //echo print_r($xml); $this->engineVer = $xml->engineVer['value']; $this->serverTime = $xml->serverTime['value']; $this->paidOps = $xml->paidOps['value']; $this->availOps = $xml->availOps['value']; echo $this->engineVer . "<BR>"; echo $this->serverTime . "<BR>"; echo $this->paidOps . "<BR>"; echo $this->availOps . "<BR>"; $GLOBALS['calls'][] = new Call("TOTAL"); foreach ($GLOBALS['calls'] as $call) { $call->apiCalls = $xml->callStats->callStat->apiCalls['value']; $call->usedOps = $xml->callStats->callStat->usedOps['value']; $call->avgExecTime = $xml->callStats->callStat->avgExecTime['value'] . $xml->callStats->callStat->avgExecTime['unit']; $call->deniedCalls = $xml->callStats->callStat->deniedCalls['value']; $call->errors = $xml->callStats->callStat->errors['value']; $call->infoCalls = $xml->callStats->callStat->infoCalls['value']; $call->avgInfoExecTime = $xml->callStats->callStat->avgInfoExecTime['value'] . $xml->callStats->callStat->avgInfoExecTime['unit']; $call->mapInfoCalls = $xml->callStats->callStat->mapInfoCalls['value']; $call->avgMapInfoExecTime = $xml->callStats->callStat->avgMapInfoExecTime['value'] . $xml->callStats->callStat->avgMapInfoExecTime['unit']; $call->parseRepCalls = $xml->callStats->callStat->parseRepCalls['value']; $call->avgParseRepExecTime = $xml->callStats->callStat->avgParseRepExecTime['value'] . $xml->callStats->callStat->avgParseRepExecTime['unit']; $call->profInfoCalls = $xml->callStats->callStat->profInfoCalls['value']; $call->avgProfInfoExecTime = $xml->callStats->callStat->avgProfInfoExecTime['value'] . $xml->callStats->callStat->avgProfInfoExecTime['unit']; echo "apiCalls: " . $call->apiCalls; echo "usedOps: " . $call->usedOps . "<BR>"; echo "avgExecTime: " . $call->avgExecTime . "<BR>"; echo "deniedCalls: " . $call->deniedCalls . "<BR>"; echo "errors: " . $call->errors . "<BR>"; echo "infoCalls: " . $call->infoCalls . "<BR>"; echo "avgInfoExecTime: " . $call->avgInfoExecTime . "<BR>"; echo "mapInfoCalls: " . $call->mapInfoCalls . "<BR>"; echo "avgMapInfoExecTime: " . $call->avgMapInfoExecTime . "<BR>"; echo "parseRepCalls: " . $call->parseRepCalls . "<BR>"; echo "avgParseRepExecTime: " . $call->avgParseRepExecTime . "<BR>"; echo "profInfoCalls: " . $call->profInfoCalls . "<BR>"; echo "avgProfInfoExecTime: " . $call->avgProfInfoExecTime . "<BR>"; } } }
<?php include_once 'functions.php'; $username = ""; $password = ""; $hostname = ""; $dbname = ""; $conn = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); if (!mysql_select_db($dbname, $conn)) { loga('Could not select database ' . $dbname); exit; } function queryDB($sql) { $rs = mysql_query($sql, $GLOBALS['conn']); if (!$rs) { //loga("DB Error, could not query the database"); //loga('MySQL Error: ' . mysql_error()); return false; } return $rs; }
function saveHistoryData() { // https://us.api.battle.net/sc2/profile/96953/2/HanzoJR/matches?locale=en_US&apikey=fxhpgcfu4m2m9ssecb3vvq56ws9yssfc $url = "https://us.api.battle.net/sc2/profile/{$this->bnetId}/{$this->realm}/{$this->name}/matches?locale=en_US&apikey=fxhpgcfu4m2m9ssecb3vvq56ws9yssfc"; // echo "URL: $url<br>"; $content = @file_get_contents($url); if (!$content) { echo "Erro ao pegar conteudo."; return false; } $json = json_decode($content); if (isset($json->status)) { if ($json->status = "nok") { echo "Erro ao decodificar JSON."; return false; } } $gmtManaus = 4 * 3600; // $sql = "truncate table tb_history"; // queryDB($sql); $dateUltima = $this->getLastHistory(); // echo "data calculada: ".$dateUltima->format('Y-m-d H:i:s') . "\n"; foreach ($json->matches as $match) { $match->date = $match->date - $gmtManaus; $datePartida = gmdate('Y-m-d H:i:s', $match->date); if ($dateUltima < new DateTime($datePartida)) { $sql = "INSERT INTO tb_history (id_player, seasonYear, seasonNumber, map, type, decision, speed, date) VALUES (\n\t\t\t\t\t{$this->idPlayer}, {$this->seasonYear}, {$this->seasonNumber}, '{$match->map}', '{$match->type}','{$match->decision}','{$match->speed}', '{$datePartida}')"; // echo $sql . "<br><br>"; if (!queryDB($sql)) { loga($this->name . ": ERROR! Cant save History data."); } else { loga($this->name . ": History data Ok."); } } } }
<?php /* * !!! THIS IS JUST AN EXAMPLE !!!, PLEASE USE ImageMagick or some other quality image processing libraries */ loga($_POST); $imgUrl = $_POST['imgUrl']; // original sizes $imgInitW = $_POST['imgInitW']; $imgInitH = $_POST['imgInitH']; // resized sizes $imgW = $_POST['imgW']; $imgH = $_POST['imgH']; // offsets $imgY1 = $_POST['imgY1']; $imgX1 = $_POST['imgX1']; // crop box $cropW = $_POST['cropW']; $cropH = $_POST['cropH']; // rotation angle $angle = $_POST['rotation']; $jpeg_quality = 100; $output_filename = "temp/croppedImg_" . rand(); // uncomment line below to save the cropped image in the same location as the original image. //$output_filename = dirname($imgUrl). "/croppedImg_".rand(); $what = getimagesize($imgUrl); switch (strtolower($what['mime'])) { case 'image/png': $img_r = imagecreatefrompng($imgUrl); $source_image = imagecreatefrompng($imgUrl); $type = '.png';
<p>Aguarde...</p> <?php include_once 'bancoUsuario.php'; $email = $_POST['login']; $senha = $_POST['senha']; loga($email, $senha); session_start(); if (!isset($_SESSION['email'])) { header("Location: ../index.php"); $_SESSION['danger'] = "login/senha incorreto"; } echo '<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=../home.php">'; die;
<?php if (!isset($_SESSION)) { session_start(); } include 'b_funcoes.php'; if ($_REQUEST['op'] == 'loga') { $usuario = $_POST['login']; $senha = $_POST['senha']; //$senha = crypt($_POST['senha']); if ($usuario == "" || $senha == "") { echo "Usuario e senha devem estar preenchidos!"; } else { loga($usuario, $senha); } } else { switch ($_REQUEST['op']) { case 'desloga': desloga(); break; case 'cria': switch ($_REQUEST['entidade']) { case 'quarto': insert_quarto($_REQUEST['quarto'], $_REQUEST['tipo_quarto']); break; case 'paciente': insert_paciente($_REQUEST['nome'], $_REQUEST['cpf']); break; case 'funcionario': case 'usuario': insert_funcionario($_REQUEST['login'], $_REQUEST['senha'], $_REQUEST['tipo_funcionario'], $_REQUEST['nome'], $_REQUEST['cpf'], $_REQUEST['email']);
ini_set('max_execution_time', 300); //300 seconds = 5 minutes include_once 'db.php'; //acesso ao DB include_once 'class.php'; //acesso a classe Player include_once 'functions.php'; //acesso a funcoes diversas //cria um vetor e carrega a lista de players ativos da tabela $players = loadPlayerList(); //limpa os dados do dia de hoje da tabela cleanDay(); //$player = $players[0]; //varre o vetor de Players carregando o XML do webservice e salvando na tabela foreach ($players as $player) { // //verifica se ocorreu erro ao acessar o webservice if ($player->loadJSONData()) { //carrega todos os dados do JSON na instancia de Player $player->saveHistoryData(); //carrega e persiste os dados pertinentes a historico de partidas; $player->getIACounters(); $player->saveSeasonData(); //persiste os dados de season do objeto Player $player->savePlayerData(); //persiste os dados do Player } else { loga("ERROR! Cant get data from {$player->name}."); } } //echo getToday(); echo "Finish!<BR>";