%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/old2/_music/ingress/
Upload File :
Create Path :
Current File : /www/old2/_music/ingress/actionsApi.php

<?php
	function getPlayerResonatorDeploy($pid, $name, $side, $starttime = 0, $endtime = 0)
	{
		if($starttime != 0)
		{
			$start = "AND `when` >= ".mysql_real_escape_string($starttime);
		}
		if($endtime != 0)
		{
			$end = "AND `when` <= ".mysql_real_escape_string($endtime);
		}
		$query = "select distinct level, count(level) as `count` from actions where who=".mysql_real_escape_string($pid)." and action='resonator_create' $start $end group by level order by level asc";
		$res = mysql_query($query);
		if(!$res || mysql_num_rows($res) == 0) return false;
		$play = new stdClass();
		$play->name = $name;
		$play->side = $side;
		$play->resonators = array();
		while($r = mysql_fetch_object($res))
		{
			$play->resonators[] = $r;
		}
		return $play;
	}
	function getPlayerResonatorDestroy($pid, $name, $side, $starttime = 0, $endtime = 0)
	{
		if($starttime != 0)
		{
			$start = "AND `when` >= ".mysql_real_escape_string($starttime);
		}
		if($endtime != 0)
		{
			$end = "AND `when` <= $endtime";
		}
		$query = "select distinct level, count(level) as `count` from actions where who=".mysql_real_escape_string($pid)." and action='resonator_destroy' $start $end group by level order by level asc";
		$res = mysql_query($query);
		if(!$res || mysql_num_rows($res) == 0) return false;
		$play = new stdClass();
		$play->name = $name;
		$play->side = $side;
		$play->resonators = array();
		while($r = mysql_fetch_object($res))
		{
			$play->resonators[] = $r;
		}
		return $play;
	}

	require("config.php");
	header("Content-type: text/plain");
	$spojeni = mysql_connect($srv, $usr, $pwd);
	mysql_select_db($dbname, $spojeni);
	if($_GET['action'] == 'player_ap_week')
	{
		$res = mysql_query("select name, ap, side from (select distinct `actions`.`who` AS `player`,sum(`actions`.`ap`) AS `ap` from `actions` where (`actions`.`when` >= (unix_timestamp() - ((3600 * 24) * 7))) group by `actions`.`who`) as player_ap_week join players on player_ap_week.player=players.id order by ap desc");
		$out = array();
		while($r = mysql_fetch_object($res))
		{
			$out[] = $r;
		}
	}
	if($_GET['action'] == 'player_ap_overall' && isset($_GET['start']))
	{
		$res = mysql_query("select name, ap, side from (select distinct `actions`.`who` AS `player`,sum(`actions`.`ap`) AS `ap` from `actions` where (`actions`.`when` >= ".mysql_real_escape_string($_GET['start']).") group by `actions`.`who`) as player_ap_week join players on player_ap_week.player=players.id order by ap desc");
		$out = array();
		while($r = mysql_fetch_object($res))
		{
			$out[] = $r;
		}
	}
	if($_GET['action'] == 'player_ap' && isset($_GET['start']))
	{
		$res = mysql_query("select sum(ap) from ");
	}
	if($_GET['action'] == 'player_max_level')	
	{
		$res = mysql_query("SELECT name, level, side FROM (select distinct `actions`.`who` AS `player`,max(`actions`.`level`) AS `level` from `actions` where (`actions`.`action` = 'resonator_create') group by `actions`.`who`) as `player_max_level` JOIN players ON player_max_level.player = players.id order by level desc, name");
		$out = array();
		while($r = mysql_fetch_object($res))
		{
			$out[] = $r;
		}
	}
	if($_GET['action'] == 'player_resonator_deploy')
	{
		$starttime = 0;
		$endtime = 0;
		if(isset($_GET['start']))
		{
			$starttime = $_GET['start'];
		}
		if(isset($_GET['end']))
		{
			$endtime = $_GET['end'];
		}
		if((isset($_GET['all']) && $_GET['all'] == "true") || !isset($_GET['name']))
		{
			$players = mysql_query("select distinct who, name, side from actions join players on actions.who = players.id order by name");
			$out = array();
			while($pl = mysql_fetch_object($players))
			{
				$play = getPlayerResonatorDeploy($pl->who, $pl->name, $pl->side, $starttime, $endtime);
				if($play != false)
				{
					$out[] = $play;
				}
			}
		}
		elseif(isset($_GET['name']))
		{
			$player = mysql_query("select id, name, side from players where name like '".mysql_real_escape_string($_GET['name'])."'");
			if($player != false && mysql_num_rows($player) > 0)
			{
				if($pl = mysql_fetch_object($player))
				{
					$play = getPlayerResonatorDeploy($pl->id, $pl->name, $pl->side, $starttime, $endtime);
					if($play != false)
					{
						$out = $play;
					}
				}
			}
		}
	}
	if($_GET['action'] == 'player_resonator_destroy')
	{
		$starttime = 0;
		$endtime = 0;
		if(isset($_GET['start']))
		{
			$starttime = $_GET['start'];
		}
		if(isset($_GET['end']))
		{
			$endtime = $_GET['end'];
		}
		if((isset($_GET['all']) && $_GET['all'] == "true") || !isset($_GET['name']))
		{
			$players = mysql_query("select distinct who, name, side from actions join players on actions.who = players.id order by name");
			$out = array();
			while($pl = mysql_fetch_object($players))
			{
				$play = getPlayerResonatorDestroy($pl->who, $pl->name, $pl->side, $starttime, $endtime);
				if($play != false)
				{
					$out[] = $play;
				}
			}
		}
		elseif(isset($_GET['name']))
		{
			$player = mysql_query("select id, name, side from players where name like '".$_GET['name']."'");
			if($player != false && mysql_num_rows($player) > 0)
			{
				if($pl = mysql_fetch_object($player))
				{
					$play = getPlayerResonatorDestroy($pl->id, $pl->name, $pl->side, $starttime, $endtime);
					if($play != false)
					{
						$out = $play;
					}
				}
			}
		}
	}
	echo json_encode($out, JSON_PRETTY_PRINT);
	mysql_close($spojeni);
?>

Zerion Mini Shell 1.0