글에서 날씨 정보를 얻어오기 위해서 필요한 국가별 도시 정보를 가져오는 클래스입니다. 간단하긴 한데, 출력 데이터가 validate 되지 않은 JSON이라서 그거 수정하는데 30분 정도 걸렸네요.(미워요 구글~~)
그 부분 메쏘드는 convertJson(한줄짜리 -_-;) 이구요, 나머지는 쉬우니까 패스~~
소스 들어갑니다.
<?php
$iso = 'KR';
$City = new CompanyCity($iso);
print_r($City->get());
class CompanyCity {
const KOURL = 'http://www.google.co.kr/ig/cities?country=';
const ENURL = 'http://www.google.com/ig/cities?country=';
const UTF8 = '&oe=UTF-8';
private $country;
private $city;
private $type = 'array'; // OR object
public function __construct($iso3166)
{
$this->country = $iso3166;
}
private static function convertJson($v)
{
return preg_replace('/(cities|name|lat|lon|code|selected|true)/', "\""."\\1"."\"", $v);
}
public function get()
{
$this->city = file_get_contents(self::KOURL.$this->country.self::UTF8);
return $this->type=='array' ? json_decode(self::convertJson($this->city), true) : json_decode(self::convertJson($this->city));
}
}
?>
입력할 때 ISO-3166-1-alpha-2 에 맞는 코드를 입력해야 출력이 제대로 나옵니다.
[이 게시물은 최고관리자님에 의해 2010-02-11 03:18:53 B16에서 이동 됨]
그 부분 메쏘드는 convertJson(한줄짜리 -_-;) 이구요, 나머지는 쉬우니까 패스~~
소스 들어갑니다.
<?php
$iso = 'KR';
$City = new CompanyCity($iso);
print_r($City->get());
class CompanyCity {
const KOURL = 'http://www.google.co.kr/ig/cities?country=';
const ENURL = 'http://www.google.com/ig/cities?country=';
const UTF8 = '&oe=UTF-8';
private $country;
private $city;
private $type = 'array'; // OR object
public function __construct($iso3166)
{
$this->country = $iso3166;
}
private static function convertJson($v)
{
return preg_replace('/(cities|name|lat|lon|code|selected|true)/', "\""."\\1"."\"", $v);
}
public function get()
{
$this->city = file_get_contents(self::KOURL.$this->country.self::UTF8);
return $this->type=='array' ? json_decode(self::convertJson($this->city), true) : json_decode(self::convertJson($this->city));
}
}
?>
입력할 때 ISO-3166-1-alpha-2 에 맞는 코드를 입력해야 출력이 제대로 나옵니다.
[이 게시물은 최고관리자님에 의해 2010-02-11 03:18:53 B16에서 이동 됨]
2011. 8. 19. 10:23
특정 포트 사용하는 프로세스 확인
2011. 8. 19. 10:23 in 카테고리 없음
==> fuser -n tcp 80
결과 80/tcp: 13512
결과 80/tcp: 13512
==> ps -ef | grep 13512
결과
톰캣이 사용했으리라 추측
tomcat server.xml 확인
grep 80 /usr/local/tomcat/tweb-ver1/conf/server.xml
확인완료
root 13512 1 0 2010 ? 03:34:06 /usr/java/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/tweb-ver1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dserver.mode=dev -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat/tweb-ver1 -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/tweb-ver1/temp org.apache.catalina.startup.Bootstrap start
톰캣이 사용했으리라 추측
tomcat server.xml 확인
grep 80 /usr/local/tomcat/tweb-ver1/conf/server.xml
<Server port="38005" shutdown="SHUTDOWN">
Define a non-SSL HTTP/1.1 Connector on port 8080
<Connector port="80" protocol="HTTP/1.1"
port="8080" protocol="HTTP/1.1"
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="38009" protocol="AJP/1.3" redirectPort="38443" />
확인완료