search.php 5.14 KB
<?
// http://override1592.tistory.com/20
// 소개 글

// http://dovetail.tistory.com/38
// //스누피 크롤링
// https://discussion.developer.riotgames.com/questions/4188/request-api.html
// https://discussion.developer.riotgames.com/articles/61/public-libraries-for-the-riot-games-api.html

?>

<!DOCTYPE >
<html>
<head>
<link rel='stylesheet' type='text/css' href='http://www.blueb.co.kr/data/201010/IJ12872423858253/fullcalendar.css' />
<script type='text/javascript' src='http://www.blueb.co.kr/data/201010/IJ12872423858253/jquery.js'></script>
<script type='text/javascript' src='http://www.blueb.co.kr/data/201010/IJ12872423858253/jquery-ui-custom.js'></script>
<script type='text/javascript' src='http://www.blueb.co.kr/data/201010/IJ12872423858253/fullcalendar.min.js'></script>
<script type='text/javascript'>

	$(document).ready(function() {

		var date = new Date();
		var d = date.getDate();
		var m = date.getMonth();
		var y = date.getFullYear();

		$('#calendar').fullCalendar({
			header: {
				left: 'prev,next today',
				center: 'title',
				right: 'month,basicWeek,basicDay'
			},
			editable: true,
			events: [

				<?php

				//python
				$command = escapeshellcmd('test.py');
				$output = shell_exec($command);

				//mysql
				$host = 'localhost';
				$user = 'root';
				$pw = 'autoset';
				$dbname = 'lol';

				$conn = mysqli_connect($host, $user, $pw, $dbname);

				$sql2 = "select count(day) from gametime";
				$result2=mysqli_query($conn,$sql2);
				$data2 = array();
				$row2=mysqli_fetch_array($result2);
				echo $row2[0];

				$sql="select * from gametime";


				$result=mysqli_query($conn,$sql);
				$data = array();
				$cnt = 0;
				if($result){

				  while($row=mysqli_fetch_array($result)){
				       array_push($data,  array('day'=>$row[0], 'time'=>$row[1] ));
				       $row_arr = explode('-', $row[0]);
							 ?>


							 		{
							 			title: 'Long Event',
							 			start: new Date(y, <?php echo $row_arr[1];?>, <?php echo $row_arr[2];?>),
							 			allDay: false
							 		}

									<?php $cnt++; if ( $cnt != $row[0] ) { echo ","; }?>
				   <?php} //while
				} //if ?>



					// {
					// 	title: 'Long Event',
					// 	start: new Date(y, m, 2),
					// 	end: new Date(y, m, 3)
					// },
					// {
					// 	id: 999,
					// 	title: 'Repeating Event',
					// 	start: new Date(y, m, d-3, 16, 0),
					// 	allDay: false
					// },
				// {
				// 	title: 'All Day Event',
				// 	start: new Date(y, m, 1)
				// },
				// {
				// 	title: 'Long Event',
				// 	start: new Date(y, m, 2),
				// 	end: new Date(y, m, 3)
				// },
				// {
				// 	id: 999,
				// 	title: 'Repeating Event',
				// 	start: new Date(y, m, d-3, 16, 0),
				// 	allDay: false
				// },
				// {
				// 	id: 999,
				// 	title: 'Repeating Event',
				// 	start: new Date(y, m, d+4, 16, 0),
				// 	allDay: false
				// },
				// {
				// 	title: 'Meeting',
				// 	start: new Date(y, m, d, 10, 30),
				// 	allDay: false
				// },
				// {
				// 	title: 'Lunch',
				// 	start: new Date(y, m, d, 12, 0),
				// 	end: new Date(y, m, d, 14, 0),
				// 	allDay: false
				// },
				// {
				// 	title: 'Birthday Party',
				// 	start: new Date(y, m, d+1, 19, 0),
				// 	end: new Date(y, m, d+1, 22, 30),
				// 	allDay: false
				// },
				// {
				// 	title: 'Click for Google',
				// 	start: new Date(y, m, 28),
				// 	end: new Date(y, m, 29),
				// 	url: 'http://google.com/'
				// }
			]
		});

	});

</script>
<script type='text/javascript'>

function httpGet($url)
{
	$ch = curl_init();
	curl_setopt($ch,CURLOPT_URL,$url);
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
	 // curl_setopt($ch,CURLOPT_HEADER, false);
	$output=curl_exec($ch);
	curl_close($ch);
	return $output;
}

</script>
<style type='text/css'>

	body {
		margin-top: 40px;
		text-align: center;
		font-size: 14px;
		font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
		}

	#calendar {
		width: 900px;
		margin: 0 auto;
		}

</style>
</head>
<body>

	<?php
	$api_key = "RGAPI-eb66d6f1-a940-4ded-8679-9554c559ad75"; // 자신의 api_key
	$usernames = strtolower(trim("abc"));
	$username = "바사노바";//preg_replace("/\s+/", "", $usernames);

	$url = "https://kr.api.riotgames.com/lol/summoner/v3/summoners/by-name/".$username."?api_key=".$api_key ;


	$ch = curl_init();
	curl_setopt($ch,CURLOPT_URL,$url);
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
	$output=curl_exec($ch);
	curl_close($ch);


	$get_id = json_decode($output, true);
	$userid = $get_id[$username]['id']; // ID
	$nick = $get_id[$username]['name']; // 닉네임
	$level = $get_id[$username]['summonerLevel']; // 레벨
	$profileIcon = $get_id[$username]['profileIconId']; // 프로필아이콘번호
	 echo $userid;
  //
	// $status = json_decode(httpGet("https://kr.api.pvp.net/api/lol/kr/v2.5/league/by-summoner/".$userid."/entry?api_key=".$api_key), true);
	// $tier = $status[$userid][0]['tier']; // 티어
	// $division = $status[$userid][0]['entries'][0]['division']; // 상세 티어
	// $point = $status[$userid][0]['entries'][0]['leaguePoints']; // 리그포인트
	// $win = $status[$userid][0]['entries'][0]['wins']; // 승
	// $lose = $status[$userid][0]['entries'][0]['losses']; // 패

	?>


  <div id='calendar'></div>


</body>
</html>