﻿<?php
	$r_id=$_GET['r_id'];
	$stop_id=$_GET['stop_id'];
	ini_set("display_errors", 1);
	error_reporting(E_ALL);
	$con = @mysql_connect("localhost","event","L523GpA");
	if(!$con){
		unset($con);
		die();
	}
	$db_select = @mysql_select_db("eventdb");
	mysql_query("set names utf8");
	//レコードのカウント
	$sql = "select bus_name,url_id,file_name from community_bus_master inner join busstop_image using(image_id) where r_id = ".$r_id." and busstop_id = ".$stop_id;
	$res = @mysql_query($sql);
	$row = mysql_fetch_array($res);
	mysql_free_result($res);
	$close = @mysql_close($con);
	if(!$close){
		unset($con,$sql,$res,$max,$db_select);
		die();
	}
	$file_path="./bus_image/".$row['file_name'];
	if(file_exists($file_path)){
		echo $row['bus_name'] .','.$row['file_name'].','.$row['url_id'];
	}else{
		//echo $row['bus_name'] .',toshinaga.jpg,'.urldecode(preg_replace('/(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/', '<A href="\\1\\2" target="_blank">\\1\\2</A>', $row['url_id']));
		//echo $row['bus_name'] .',toshinaga.jpg,'.$row['url_id'];
		echo $row['bus_name'] .',toshinaga.jpg,'.urldecode(htmlspecialchars($row['url_id']));
	}
	unset($con,$sql,$res,$db_select,$r_id,$row);
?>
