Files
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

70 lines
1.5 KiB
PHP

<?php
/*
* Created on Nov 8, 2012
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$result = array();
if(!isset($_GET["un"]))
{
$result["result"] = -1;
}
if(!isset($_GET["pwd"]))
{
$result["result"] = -1;
}
if(!isset($_GET["type"]))
{
$result["result"] = -1;
}
if ($result["result"] == -1)
{
$jsonencode = $_GET['callback'].'('.json_encode($result).');';
echo $jsonencode;
exit;
}
$type = $_GET["type"];
if (!($type == 100 || $type == 200 || $type == 500))
{
$result["result"] = 0;
$jsonencode = $_GET['callback'].'('.json_encode($result).');';
echo $jsonencode;
exit;
}
//for update credits;
$remoteURL = "http://localhost:35555/update-user-credits.api?apipwd=" . $_GET["pwd"] . "&un=" . $_GET["un"] . "&crds=-" . $_GET["type"];
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $remoteURL);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'update credits');
$mofifyContents = curl_exec($curl_handle);
curl_close($curl_handle);
if ($mofifyContents != 0) {
$result["result"] = 2;
} else if ($mofifyContents == 0) {
$roomSeatsFile = "probability".$type.".txt";
$bb = file_get_contents($roomSeatsFile);
$random = mt_rand(0, 100);
if ($random > (int)$bb)
{
$result["result"] = 0;
}
else
{
$result["result"] = 1;
}
}
$jsonencode = $_GET['callback'].'('.json_encode($result).');';
echo $jsonencode;
?>