<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Go3.co.kr MintState BBS &amp;gt; Tech &amp;gt; Ajax &amp;amp; Issue</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax</link>
<description>테스트 버전 0.2 (2004-04-26)</description>
<language>ko</language>


<item>
<title>Swiper - Most Modern Mobile Touch Slider</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=5030</link>
<description><![CDATA[[U]Swiper - Most Modern Mobile Touch Slider[/U]<br/><br/>다양한 스와프 기능을 탑제한 js 이다.<br/><br/>해당 홈페이지는 <A HREF="http://www.idangero.us/swiper/" TARGET="_blank"  rel="nofollow">http://www.idangero.us/swiper/</A> 에서 확인 할 수 있고<br/>데모는 <A HREF="http://www.idangero.us/swiper/demos/" TARGET="_blank"  rel="nofollow">http://www.idangero.us/swiper/demos/</A> 에서 확인 가능 하다.<br/>.]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Tue, 02 Feb 2016 10:33:28 +0900</dc:date>
</item>


<item>
<title>[jquery] 스와프 가능한 이미지 배너 - OWL Carousel</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=5029</link>
<description><![CDATA[[jquery] 스와프 가능한 이미지 배너 - OWL Carousel 

OWL Carousel 
Touch enabled jQuery plugin that lets you create beautiful responsive carousel slider.

http://owlgraphic.com/owlcarousel/]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Fri, 30 May 2014 11:57:39 +0900</dc:date>
</item>


<item>
<title>구글맵 api 편리하기 사용가능하게 해주는 gmaps.js</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=5028</link>
<description><![CDATA[[U]구글맵 api 편리하기 사용가능하게 해주는 gmaps.js[/U]<br/><br/>[ATTACH]776[/ATTACH]<br/>[URL]<A HREF="http://hpneo.github.com/gmaps/" TARGET="_blank"  rel="nofollow">http://hpneo.github.com/gmaps/</A>[/URL]<br/><br/>gmaps.js allows you to use the potential of Google Maps in a simple way.<br/>No more extensive documentation or large amount of code.<br/><br/>가장쉽게 구글 맵을 적용시킬수 있습니다.<br/><br/>[CODE js]&lt;script type=&#034;text/javascript&#034;&gt;<br/>var map;<br/>$(document).ready(function(){<br/>	map = new GMaps({<br/>		div: &#039;#map&#039;,<br/>		lat: -12.043333,<br/>		lng: -77.028333<br/>	});<br/>	GMaps.geolocate({<br/>		success: function(position){<br/>			map.setCenter(position.coords.latitude, position.coords.longitude);<br/>		},<br/>		error: function(error){<br/>			alert(&#039;Geolocation failed: &#039;+error.message);<br/>		},<br/>		not_supported: function(){<br/>			alert(&#034;Your browser does not support geolocation&#034;);<br/>		},<br/>		always: function(){<br/>			alert(&#034;Done!&#034;);<br/>		}<br/>	});<br/>});<br/>&lt;/script&gt;[/CODE]<br/><br/>아래 주소로 접속하셔서 샘플을 보신후 자신의 홈페이지에 적용하세요<br/>[URL]<A HREF="http://hpneo.github.com/gmaps/examples.html" TARGET="_blank"  rel="nofollow">http://hpneo.github.com/gmaps/examples.html</A>[/URL]]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Mon, 04 Mar 2013 09:44:46 +0900</dc:date>
</item>


<item>
<title>jQuery - FullCalendar</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=31</link>
<description><![CDATA[[U]jQuery - FullCalendar[/U]<br/><br/>FullCalendar 는 구글 카렌다와 비슷하게 표시해 줄수 있는 jQuery Plugin 입니다.<br/>사이즈(날짜)조절, Drag&Drop 이 가능하고 구글이나 자체의 json 데이터를 이용할 수 있습니다.<br/><br/><A HREF="http://arshaw.com/fullcalendar/" TARGET="_blank"  rel="nofollow">http://arshaw.com/fullcalendar/</A>]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Wed, 21 Mar 2012 14:32:45 +0900</dc:date>
</item>


<item>
<title>jquery - select box</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=30</link>
<description><![CDATA[[U]jquery - select box[/U]<br/><br/>jQuery로 선택된 값 읽기<br/>$(&#034;#myselect option:selected&#034;).val();<br/>$(&#034;select[name=name]&#034;).val();<br/><br/>jQuery로 선택된 내용 읽기<br/>$(&#034;#myselect option:selected&#034;).text();<br/><br/>선택된 위치<br/>var index = $(&#034;#test option&#034;).index($(&#034;#test option:selected&#034;)); <br/><br/>-------------------------------------------------------------------<br/>// option 항목 추가<br/>$(&#034;#myselect&#034;).append(&#034;&lt;option value=&#039;1&#039;&gt;Apples&lt;/option&gt;&#034;);<br/>$(&#034;#myselect&#034;).append(&#034;&lt;option value=&#039;2&#039;&gt;After Apples&lt;/option&gt;&#034;);<br/><br/>// option 항목 맨 첫 위치에 추가<br/>$(&#034;#myselect&#034;).prepend(&#034;&lt;option value=&#039;0&#039;&gt;Before Apples&lt;/option&gt;&#034;);<br/><br/>// 전체 option 변경<br/>$(&#034;#myselect&#034;).html(&#034;&lt;option value=&#039;1&#039;&gt;Some oranges&lt;/option&gt;&lt;option value=&#039;2&#039;&gt;More Oranges&lt;/option&gt;&lt;option value=&#039;3&#039;&gt;Even more oranges&lt;/option&gt;&#034;);<br/><br/>// 지정된 index 위치의 option 변경<br/>$(&#034;#myselect option:eq(1)&#034;).replaceWith(&#034;&lt;option value=&#039;2&#039;&gt;Some apples&lt;/option&gt;&#034;);<br/>$(&#034;#myselect option:eq(2)&#034;).replaceWith(&#034;&lt;option value=&#039;3&#039;&gt;Some bananas&lt;/option&gt;&#034;);<br/><br/>// 지정된 index 값으로 select 하기<br/>$(&#034;#myselect option:eq(2)&#034;).attr(&#034;selected&#034;, &#034;selected&#034;);<br/><br/>// text 값으로 select 하기<br/>$(&#034;#myselect option&#034;).text(&#034;학생&#034;).attr(&#034;selected&#034;, &#034;selected&#034;);<br/><br/>// value 값으로 select 하기<br/>$(&#034;#myselect&#034;).val(&#034;2&#034;);<br/><br/>// 지정된 인덱스 값의 item 삭제<br/>$(&#034;#myselect option:eq(0)&#034;).remove();<br/><br/>// 첫번째 item 삭제<br/>$(&#034;#myselect option:first&#034;).remove();<br/><br/>// 마지막 item 삭제<br/>$(&#034;#myselect option:last&#034;).remove();<br/><br/>// 선택된 옵션의 text 구하기<br/>alert($(&#034;#myselect option:selected&#034;).text());<br/><br/>// 선택된 옵션의 value 구하기<br/>alert($(&#034;#myselect option:selected&#034;).val());<br/><br/>// 선택된 옵션 index 구하기<br/>alert($(&#034;#myselect option&#034;).index($(&#034;#myselect option:selected&#034;)));<br/><br/>// SelecBox 아이템 갯수 구하기<br/>alert($(&#034;#myselect option&#034;).size());<br/><br/>// 선택된 옵션 앞의 아이템 갯수<br/>alert($(&#034;#myselect option:selected&#034;).prevAll().size());<br/><br/>// 선택된 옵션 후의 아이템 갯수<br/>alert($(&#034;#myselect option:selected&#034;).nextAll().size());<br/><br/>// 지정된 index 위치 바로 다음에 option 추가<br/>$(&#034;#myselect option:eq(0)&#034;).after(&#034;&lt;option value=&#039;4&#039;&gt;Some pears&lt;/option&gt;&#034;);<br/><br/>// 지정된 index 위치 바로 앞에 option 추가<br/>$(&#034;#myselect option:eq(3)&#034;).before(&#034;&lt;option value=&#039;5&#039;&gt;Some apricots&lt;/option&gt;&#034;);<br/><br/>// Getting values when item is selected<br/>$(&#034;#myselect&#034;).change(function() {<br/>alert($(this).val());<br/>alert($(&#034;&gt; option:selected&#034;, this).text());<br/>});]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Fri, 25 Nov 2011 12:49:02 +0900</dc:date>
</item>


<item>
<title>Wowza Streaming Server</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=29</link>
<description><![CDATA[[U]Wowza Streaming Server[/U]<br/><br/>여러가지 스트리밍서버들이 존재한다.<br/>아이폰이나 안드로이드폰은 http를 이용해서 스트리밍을 할 수 있다.<br/>아이폰 경우 H.264, AAC 로 인코딩이 되어 있다면 특별한 방법이 없어도 스트리밍이 가능하다.<br/>안드로이도 HTML5태그를 이용 [URL=http://www.videohelp.com/tools/mp4box]MP4BOX[/URL] 처리만 해주면 된다.<br/><br/>예) mp4box -hint video.mp4 <br/><br/>그런데 문제는 PC에서는 http 프로토콜로 스트리밍을 할수 없다.<br/>이제 mms도 한물 갔고.. [URL=http://h264.code-shop.com/trac/wiki]H264 Streaming Module[/URL]를 사용하면 된다는데 안정화 되지 않았고 완벽히 지원되지 않는다.<br/>무료로 지원되는것은 한계가 있다.<br/>Flash Media Server 도 설치, 사용하기는 불편하다.<br/>APPLE서 공개된 [URL=http://dss.macosforge.org/]Darwin Streaming Server[/URL]는 APPLE이 아닌 다른 서버에서는 지원이 잘 안된다.<br/><br/>그럼 유료지만 쓸만한 것은 바로 [URL=http://www.wowza.com]Wowza Streaming Server[/URL]다.<br/><br/>이제 wmv 에서 mp4가 대세인 시대가 왔다. divx도 아이폰이 지원하지 않는 관계로 많이 사라졌다.<br/><br/>그럼 Wowza는 어떤 기능이 있는지 알아보자.<br/>Wowza Media Server 2, a video streaming server for live and on-demand is the proven, unified, industrial strength media server for live and on-demand video/audio streaming, video/audio/text chat, recording and more. It takes your H.264 content to any screen - the desktop, mobile and the living room - to all popular media platforms: <br/>[LIST][*]Adobe® Flash® <br/>[*]Apple® iOS: iPhone®, iPad™, and iPod® touch <br/>[*]Microsoft® Silverlight® <br/>[*]Apple QuickTime™ <br/>[*]Android™, Blackberry® and other 3GPP platforms <br/>[*]Set-top boxes and more... <br/>[/LIST:u]<br/>H.264로 인코딩된 컨텐츠를 어떠한 플랫폼에서든 사용할 수 있다고 한다. 또한 video/audio 스트리밍 뿐만아니라 챗팅, 레코딩도 지원한다.<br/>한마디로 거의 모든 기능을 지원한다.<br/>그리고 동시접속 10건만 가능한 개발자 버전은 무료이다.<br/><br/>그렇다고 모든 플랫폼에서 서비스를 하는 것이 쉬운일은 아니다.<br/>서버를 설치하고 세팅하고 각각 플랫폼에 맞게 코딩을 해주어야 한다.<br/><br/>설치는 무지 간단하다. <A HREF="http://www.wowza.com/store.html" TARGET="_blank"  rel="nofollow">http://www.wowza.com/store.html</A> 에서 설치하고자 하는 운영체제의 설치 파일을 받아 인스톨만 하면 된다. <br/>라이센스는 우선 무료로 받을 수 있다.<br/><br/>VOD 서비스를 기준으로 윈도우에서 설치를 해보자.<br/>자바가 필수로 필요하기 때문에 jdk를 다운받아 설치를 해준다.<br/>그리고 인스톨을 하고 중간에 라이센스를 넣어 준다.<br/>설치가 완료되면 설치폴더 밑에 conf 폴더에 [B]vod[/B]라는 이름으로 폴더를 만들어 준다.<br/>그 폴더에 conf 폴더의 [COLOR=blue]Apllication.xml[/COLOR]파일을 복사해 준다.<br/>그리고 설피폴더 밑의 applications 폴더에도 [B]vod[/B]라는 이름으로 폴더를 만들어 준다.<br/>vod 폴더에 복사한 Aplication.xml 파일이 설정파일 이다. 입맛에 맞게 고쳐 주면 된다.<br/>거의 건드릴게 없다.<br/>[COLOR=blue]&lt;StorageDir&gt;컨텐츠폴더&lt;/StorageDir&gt;[/COLOR] 만 고치면 된다.<br/>&lt;StorageDir&gt;I:\LocalUser\minidisk\wowza&lt;/StorageDir&gt; 이런식으로 고치고 해당 폴더에 컨텐츠(mp4파일)을 넣어준다.<br/>그리고 프로그램을 실행 시켜 주면 끝이다.<br/><br/>[URL=http://www.longtailvideo.com/]JW Player[/URL]를 이용하면 더욱 편하게 서비스를 할 수 있다.<br/><br/>PHP 의 경우&nbsp; $_SERVER[HTTP_USER_AGENT] 를 판별해서 안드로이드와 아이폰 PC를 구분하여 서비스를 한다.<br/>안드로이드는 rtsp를 사용하고 PC는 rtmp를 사용한다 또한 아이폰은 http를 사용하여 서비스를 하면 된다.<br/><br/>rtsp를 사용하는 안드로이드나 퀵타임은 rtp에대한 [COLOR=blue]Apllication.xml[/COLOR]설정을 약간 수정해야 한다.<br/>PlayMethod 부분을 기본인 digest을 none로 바꾸어준다.<br/>[CODE]&lt;RTP&gt;<br/>	&lt;!-- RTP/Authentication/[type]Methods defined in Authentication.xml. Default setup includes; none, basic, digest --&gt;<br/>	&lt;Authentication&gt;<br/>		&lt;PublishMethod&gt;digest&lt;/PublishMethod&gt;<br/>		&lt;PlayMethod&gt;none&lt;/PlayMethod&gt;<br/>	&lt;/Authentication&gt;[/CODE]<br/><br/>만일 재생되지 않는 다면 [COLOR=blue]conf/VHost.xml[/COLOR] 설정 중에<br/>&lt;Port&gt;1935&lt;/Port&gt; 를 &lt;Port&gt;1935, 554&lt;/Port&gt; 로 수정해주면 된다.<br/>RTSP 가 기본으로 554포트를 쓰기 때문이다.<br/><br/>다음과 같은 URL로 서비스를 할 수 있다. 참고 하길 바란다.<br/>안드로이드 : rtsp://IP:1935/vod/mp4:sample.mp4<br/>일반PC : rtmp://IP/vod/mp4:sample.mp4<br/>아이폰 : http://IP:1935/vod/mp4:sample.mp4/playlist.m3u8<br/><br/>스마트폰은 HTML5 VIDEO 태그를 지원한다. 다음과 같이 하면 된다.<br/>[CODE html]&lt;video id=&#034;video&#034; autobuffer style=&#034;width:480px;height:272px&#034;&gt;<br/>	&lt;source src=&#034;rtsp://IP:1935/vod/mp4:sample.mp4&#034;&gt;<br/>&lt;/video&gt;<br/>&lt;script language=&#034;javascript&#034;&gt;<br/>var video = document.getElementById(&#039;video&#039;);<br/>video.addEventListener(&#039;click&#039;,function(){<br/>	video.play();<br/>},false);<br/>&lt;/script&gt;[/CODE]<br/><br/>컨텐츠에 하위 폴더의 파일을 재생하기 위해서는 /_definst_/ 를 써주면 된다. <br/>http://IP:1935/vod/_definst_/mp4:FOLDER/sample.mp4<br/><br/>마지막으로 서비스를 등록시켜 주면 된다.<br/>리눅스의 경우는 chkconfig를 이용하면 되고 윈도우즈는 서비스 항목을 자동으로 하면 된다.<br/><br/>웹에서 구한 간단한 설명서를 첨부한다.<br/><br/>참고) rtsp 를 이용할 경우 안드로이드에서 mp4box를 이용 hint 를 해주지 않아도 된다. 만일 http 프로토콜을 쓴다면 <br/>mp4box -hint sample.mp4 와 같이 hint 처리를 해준다.]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Mon, 19 Sep 2011 21:55:54 +0900</dc:date>
</item>


<item>
<title>jQuery Datepicker</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=28</link>
<description><![CDATA[[U]jQuery Datepicker[/U]<br/><br/>jQuery UI에 카렌더 기능이 있습니다.<br/>하지만 좀 무겁죠..<br/>그래서 좀 찾아 봤습니다.<br/><br/>[B]Date Picker - jQuery plugin[/B]<br/>[URL]<A HREF="http://www.eyecon.ro/datepicker" TARGET="_blank"  rel="nofollow">http://www.eyecon.ro/datepicker</A>[/URL]<br/><br/>[B]jQuery Datepicker[/B]<br/>[URL]<A HREF="http://keith-wood.name/datepick.html" TARGET="_blank"  rel="nofollow">http://keith-wood.name/datepick.html</A>[/URL]<br/><br/>[B]jQuery date picker plug-in[/B]<br/>[URL]<A HREF="http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/index.html" TARGET="_blank"  rel="nofollow">http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/index.html</A>[/URL]<br/><br/>[B]Date Range Picker using jQuery UI 1.7 and jQuery UI CSS Framework[/B]<br/>[URL]<A HREF="http://www.filamentgroup.com/lab/date_range_picker_using_jquery_ui_16_and_jquery_ui_css_framework/" TARGET="_blank"  rel="nofollow">http://www.filamentgroup.com/lab/date_range_picker_using_jquery_ui_16_and_jquery_ui_css_framework/</A>[/URL]<br/><br/><br/>이 밖에도 많이 있습니다.]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Thu, 23 Jun 2011 14:13:40 +0900</dc:date>
</item>


<item>
<title>Using the Twitter Search API</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=27</link>
<description><![CDATA[[U]Using the Twitter Search API[/U]<br/><br/>Twitters new search feature is great for finding interesting people and topics to follow. So i wrote a script to get search results from twitter and display them on your site. This could be integrated into an existing application or used standalone to follow a particular topic or keyword on twitter,Â&nbsp; [URL=http://papermashup.com/demos/twitter-search.php]Check the Demo[/URL].<br/><br/>The script uses PHP and CURL to get the twitter search results to display them on the page. for the demo i’ve set an if statement to display results for ‘papermashup.com’ if no get variable is present.<br/><br/>Here’s the code that allows us to enter our search term, on submit it posts a get variable to the URL which PHP then processes with CURL.<br/><br/>[CODE html]&lt;div id=&#034;search&#034;&gt;<br/>&lt;form action=&#034;&#034; method=&#034;get&#034;&gt;<br/>&nbsp; &lt;label&gt;<br/>&nbsp; Search twitter<br/>&nbsp; &lt;input type=&#034;text&#034; name=&#034;q&#034; id=&#034;searchbox&#034; /&gt;<br/>&nbsp; &lt;input type=&#034;submit&#034; name=&#034;submit&#034; id=&#034;submit&#034; value=&#034;Search&#034; /&gt;<br/>&nbsp; &lt;/label&gt;<br/>&lt;/form&gt;<br/>&lt;/div&gt;[/CODE]<br/><br/>So we use PHP, CURL, and the SimpleXMLElement() class in PHP5 to parse the XML file. Once we have the xml data, regular expression is used to find the links in the xml content element, which is then saved in $description.<br/><br/>[CODE php]// Date function (this could be included in a seperate script to keep it clean)<br/>function date_diff($d1, $d2){<br/>	$d1 = (is_string($d1) ? strtotime($d1) : $d1);<br/>	$d2 = (is_string($d2) ? strtotime($d2) : $d2);<br/><br/>	$diff_secs = abs($d1 - $d2);<br/>	$base_year = min(date(&#034;Y&#034;, $d1), date(&#034;Y&#034;, $d2));<br/><br/>	$diff = mktime(0, 0, $diff_secs, 1, 1, $base_year);<br/>	$diffArray = array(<br/>		&#034;years&#034; =&gt; date(&#034;Y&#034;, $diff) - $base_year,<br/>		&#034;months_total&#034; =&gt; (date(&#034;Y&#034;, $diff) - $base_year) * 12 + date(&#034;n&#034;, $diff) - 1,<br/>		&#034;months&#034; =&gt; date(&#034;n&#034;, $diff) - 1,<br/>		&#034;days_total&#034; =&gt; floor($diff_secs / (3600 * 24)),<br/>		&#034;days&#034; =&gt; date(&#034;j&#034;, $diff) - 1,<br/>		&#034;hours_total&#034; =&gt; floor($diff_secs / 3600),<br/>		&#034;hours&#034; =&gt; date(&#034;G&#034;, $diff),<br/>		&#034;minutes_total&#034; =&gt; floor($diff_secs / 60),<br/>		&#034;minutes&#034; =&gt; (int) date(&#034;i&#034;, $diff),<br/>		&#034;seconds_total&#034; =&gt; $diff_secs,<br/>		&#034;seconds&#034; =&gt; (int) date(&#034;s&#034;, $diff)<br/>	);<br/>	if($diffArray[&#039;days&#039;] &gt; 0){<br/>		if($diffArray[&#039;days&#039;] == 1){<br/>			$days = &#039;1 day&#039;;<br/>		}else{<br/>			$days = $diffArray[&#039;days&#039;] . &#039; days&#039;;<br/>		}<br/>		return $days . &#039; and &#039; . $diffArray[&#039;hours&#039;] . &#039; hours ago&#039;;<br/>	}else if($diffArray[&#039;hours&#039;] &gt; 0){<br/>		if($diffArray[&#039;hours&#039;] == 1){<br/>			$hours = &#039;1 hour&#039;;<br/>		}else{<br/>			$hours = $diffArray[&#039;hours&#039;] . &#039; hours&#039;;<br/>		}<br/>		return $hours . &#039; and &#039; . $diffArray[&#039;minutes&#039;] . &#039; minutes ago&#039;;<br/>	}else if($diffArray[&#039;minutes&#039;] &gt; 0){<br/>		if($diffArray[&#039;minutes&#039;] == 1){<br/>			$minutes = &#039;1 minute&#039;;<br/>		}else{<br/>			$minutes = $diffArray[&#039;minutes&#039;] . &#039; minutes&#039;;<br/>		}<br/>		return $minutes . &#039; and &#039; . $diffArray[&#039;seconds&#039;] . &#039; seconds ago&#039;;<br/>	}else{<br/>		return &#039;Less than a minute ago&#039;;<br/>	}<br/>}<br/><br/>// Work out the Date plus 8 hours<br/>// get the current timestamp into an array<br/>$timestamp = time();<br/>$date_time_array = getdate($timestamp);<br/><br/>$hours = $date_time_array[&#039;hours&#039;];<br/>$minutes = $date_time_array[&#039;minutes&#039;];<br/>$seconds = $date_time_array[&#039;seconds&#039;];<br/>$month = $date_time_array[&#039;mon&#039;];<br/>$day = $date_time_array[&#039;mday&#039;];<br/>$year = $date_time_array[&#039;year&#039;];<br/><br/>// use mktime to recreate the unix timestamp<br/>// adding 19 hours to $hours<br/>$timestamp = mktime($hours + 0,$minutes,$seconds,$month,$day,$year);<br/>$theDate = strftime(&#039;%Y-%m-%d %H:%M:%S&#039;,$timestamp);	<br/><br/>// END DATE FUNCTION<br/><br/>//Search API Script<br/><br/>$q=$_GET[&#039;q&#039;];<br/><br/>if($_GET[&#039;q&#039;]==&#039;&#039;){<br/><br/>$q = &#039;papermashup.com&#039;;}<br/><br/>$search = &#034;<A HREF="http://search.twitter.com/search.atom?q=&#034;." TARGET="_blank"  rel="nofollow">http://search.twitter.com/search.atom?q=&#034;.</A>$q.&#034;&#034;;<br/><br/>$tw = curl_init();<br/><br/>curl_setopt($tw, CURLOPT_URL, $search);<br/>curl_setopt($tw, CURLOPT_RETURNTRANSFER, TRUE);<br/>$twi = curl_exec($tw);<br/>$search_res = new SimpleXMLElement($twi);<br/><br/>echo &#034;&lt;h3&gt;Twitter search results for &#039;&#034;.$q.&#034;&#039;&lt;/h3&gt;&#034;;<br/><br/>## Echo the Search Data<br/><br/>foreach ($search_res-&gt;entry as $twit1) {<br/><br/>$description = $twit1-&gt;content;<br/><br/>$description = preg_replace(&#034;#(^|[\n ])@([^ \&#034;\t\n\r&lt;]*)#ise&#034;, &#034;&#039;\\1&lt;a href=\&#034;<A HREF="http://www.twitter.com/" TARGET="_blank"  rel="nofollow">http://www.twitter.com/</A>\\2\&#034; &gt;@\\2&lt;/a&gt;&#039;&#034;, $description);<br/>$description = preg_replace(&#034;#(^|[\n ])([\w]+?://[\w]+[^ \&#034;\n\r\t&lt;]*)#ise&#034;, &#034;&#039;\\1&lt;a href=\&#034;\\2\&#034; &gt;\\2&lt;/a&gt;&#039;&#034;, $description);<br/>$description = preg_replace(&#034;#(^|[\n ])((www|ftp)\.[^ \&#034;\t\n\r&lt;]*)#ise&#034;, &#034;&#039;\\1&lt;a href=\&#034;http://\\2\&#034; &gt;\\2&lt;/a&gt;&#039;&#034;, $description);<br/><br/>$retweet = strip_tags($description);<br/><br/>$date =&nbsp; strtotime($twit1-&gt;updated);<br/>$dayMonth = date(&#039;d M&#039;, $date);<br/>$year = date(&#039;y&#039;, $date);<br/>$message = $row[&#039;content&#039;];<br/>$datediff = date_diff($theDate, $date);<br/><br/>echo &#034;&lt;div class=&#039;user&#039;&gt;&lt;a href=\&#034;&#034;,$twit1-&gt;author-&gt;uri,&#034;\&#034; target=\&#034;_blank\&#034;&gt;&lt;img border=\&#034;0\&#034; width=\&#034;48\&#034; class=\&#034;twitter_thumb\&#034; src=\&#034;&#034;,$twit1-&gt;link[1]-&gt;attributes()-&gt;href,&#034;\&#034; title=\&#034;&#034;, $twit1-&gt;author-&gt;name, &#034;\&#034; /&gt;&lt;/a&gt;\n&#034;;<br/>echo &#034;&lt;div class=&#039;text&#039;&gt;&#034;.$description.&#034;&lt;div class=&#039;description&#039;&gt;From: &#034;, $twit1-&gt;author-&gt;name,&#034; &lt;a href=&#039;http://twitter.com/home?status=RT: &#034;.$retweet.&#034;&#039; target=&#039;_blank&#039;&gt;Retweet!&lt;/a&gt;&lt;/div&gt;&lt;strong&gt;&#034;.$datediff.&#034;&lt;/strong&gt;&lt;/div&gt;&lt;div class=&#039;clear&#039;&gt;&lt;/div&gt;&lt;/div&gt;&#034;;<br/><br/>}<br/><br/>curl_close($tw);[/CODE]<br/><br/><br/>URL : <A HREF="http://papermashup.com/using-the-twitter-search-api/" TARGET="_blank"  rel="nofollow">http://papermashup.com/using-the-twitter-search-api/</A>]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Wed, 01 Jun 2011 15:46:30 +0900</dc:date>
</item>


<item>
<title>Twitter Search using the Twitter API and PHP</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=26</link>
<description><![CDATA[[U]Twitter Search using the Twitter API and PHP[/U]<br/><br/>In this tutorial we will show you ho-to use the Twitter API for some simple search requests. For all requests we send to the Twitter API we will be using cURL with PHP. You need to check if you have cURL enabled on your server. To test this create a file which contains:<br/><br/>[CODE php]echo phpinfo();[/CODE]<br/><br/>Search the page for cURL section. If you do not have cURL enabled on your server then you will either have to contact technical assistance. If you&#039;re using a local server, a quick Google search will tell you tell you how-to enable cURL.<br/>Using Twitter&#039;s search api, we don&#039;t need to authenticate on the API server what means we don&#039;t need to register for an API key and/or secret.<br/><br/><br/>[B]The Twitter PHP Class[/B]<br/><br/>To make our script easy to use we&#039;re going to build a class to return search results from twitter.<br/><br/>So first of all we are just going to declare our class and define the return type.<br/><br/>[CODE php]class Twitter {<br/>	public function __construct(){	}<br/>}[/CODE]<br/><br/>Next we are going to build our actual search results function. For this function we will have one parameter which contains the search query.<br/><br/>[CODE php]public function searchResults( $search = null ) {<br/>	$url = &#034;<A HREF="http://search.twitter.com/search.atom?q=&#034;" TARGET="_blank"  rel="nofollow">http://search.twitter.com/search.atom?q=&#034;</A> . urlencode( $search ) . &#034;&lang=en&rpp=50&#034;;<br/>	$curl = curl_init();<br/>	curl_setopt( $curl, CURLOPT_URL, $url );<br/>	curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );<br/>	$result = curl_exec( $curl );<br/>	curl_close( $curl );<br/>	$return = new SimpleXMLElement( $result );<br/>	return $return;<br/>}[/CODE]<br/><br/>This function is just using some basic cURL functions and then creating a Simple XML Element and returning it. If you look for the [URL=http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search]Twitter Search API Method[/URL]&#034; you will see that the two options for the response are JSON and Atom/XML. For the example above we used Atom/XML. Notice, when making requests you should always urlencode() the q parameter. We also have two other parameters in our url, we have lang and rrp. I&#039;m sure I don&#039;t need to explain what lang is (for ISO language codes check this [URL=http://en.wikipedia.org/wiki/ISO_639-1]Wiki[/URL] page). [COLOR=blue]rrp[/COLOR] is the number of tweets to [COLOR=blue]Return Per Page[/COLOR], the maximum is 100. This function returns an object so we will have to keep this in mind when using this function later on.<br/><br/>The next function we&#039;re going to write will request the weekly trends from twitter and return them in an array.<br/><br/>For the trends we cannot request the data in Atom format, Twitter will return it as JSON so we will use PHP to decode the return.<br/><br/>[CODE php]public function weeklyTrends() {<br/>	$url = &#034;<A HREF="http://search.twitter.com/trends/weekly.json&#034;;" TARGET="_blank"  rel="nofollow">http://search.twitter.com/trends/weekly.json&#034;;</A><br/>	$curl = curl_init();<br/>	curl_setopt( $curl, CURLOPT_URL, $url );<br/>	curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );<br/>	$result = curl_exec( $curl );<br/>	curl_close( $curl );<br/>	$return = json_decode( $result, true );<br/>	return $return;<br/>}[/CODE]<br/><br/>The function is very similar to the first except this time instead of creating a simple xml element we use json_decode (The second parameter for this function is telling php to convert objects into array elements).<br/><br/>Trends have two parameters dates and exclude which you can read about at this [URL=http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-trends-weekly]Twitter API page[/URL]<br/><br/><br/>[B]The finished Twitter class[/B]<br/><br/>[CODE php]class Twitter {<br/>	public function __construct(){	}<br/>	public function searchResults( $search = null ) {<br/>		$url = &#034;<A HREF="http://search.twitter.com/search.atom?q=&#034;" TARGET="_blank"  rel="nofollow">http://search.twitter.com/search.atom?q=&#034;</A> . urlencode( $search ) . &#034;&lang=en&rpp=50&#034;;<br/>		$curl = curl_init();<br/>		curl_setopt( $curl, CURLOPT_URL, $url );<br/>		curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );<br/>		$result = curl_exec( $curl );<br/>		curl_close( $curl );<br/>		$return = new SimpleXMLElement( $result );<br/>		return $return;<br/>		$return = new SimpleXMLElement( $result );<br/>	}<br/>	public function weeklyTrends() {<br/>		$url = &#034;<A HREF="http://search.twitter.com/trends/weekly.json&#034;;" TARGET="_blank"  rel="nofollow">http://search.twitter.com/trends/weekly.json&#034;;</A><br/>		$curl = curl_init();<br/>		curl_setopt( $curl, CURLOPT_URL, $url );<br/>		curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );<br/>		$result = curl_exec( $curl );<br/>		curl_close( $curl );<br/>		$return = json_decode( $result, true );<br/>		return $return;<br/>	}<br/>}[/CODE]<br/><br/><br/>[B]Using the Twitter class[/B]<br/><br/>Save the class as something like twitter.class.php and then create a new blank document. The first thing we want to do in this document is include the class and then create a new instance of the class.<br/><br/>[CODE php]require_once(&#034;twitter.class.php&#034;);<br/>$Twitter = new Twitter;[/CODE]<br/><br/>Next we can use a foreach loop to output the data.<br/><br/>[CODE php]foreach( $results-&gt;entry as $result ) {<br/>	echo &#034;&lt;h3&gt;&lt;a&gt;author-&gt;uri .&#034;\&#034;&gt;&#034;. $result-&gt;author-&gt;name .&#034;&lt;a/&gt;&lt;/a&gt;&lt;/h3&gt;&lt;img /&gt;link[1]-&gt;attributes()-&gt;href .&#034;\&#034; style=\&#034;float: left;\&#034;&gt;&lt;p&gt;&#034;. $result-&gt;content .&#034;&lt;/p&gt;&lt;div style=\&#034;clear:both;\&#034;&gt; &lt;/div&gt;&#034;;<br/>}[/CODE]<br/><br/>Remember that searchResults does not return an array.<br/>Our weekly trends function on the other hand does return an array.<br/><br/>[CODE php]require_once(&#034;twitter.class.php&#034;);<br/>$Twitter = new Twitter;<br/>$trends = $Twitter-&gt;weeklyTrends();<br/>foreach( $trends[&#034;trends&#034;] as $date =&gt; $trends ) {<br/>	echo &#034;&lt;h3&gt;&#034;. $date .&#034; trends&lt;/h3&gt;&#034;;<br/>	foreach( $trends as $k =&gt; $trend ) {<br/>		echo $trend[&#034;query&#034;] .&#034;&#034;;<br/>	}<br/>}[/CODE]<br/><br/>The trends function returns a 3 dimensional array making it slightly harder to use but we still get the results that we want.<br/><br/>You can [URL=http://www.finalwebsites.com/forums/class/twitter]download the source code[/URL] used in this tutorial.<br/><br/><br/>URL : <A HREF="http://www.finalwebsites.com/forums/topic/twitter-search-using-the-twitter-api-and-php" TARGET="_blank"  rel="nofollow">http://www.finalwebsites.com/forums/topic/twitter-search-using-the-twitter-api-and-php</A>]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Wed, 01 Jun 2011 15:43:49 +0900</dc:date>
</item>


<item>
<title>PHP Twitter Search API</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=25</link>
<description><![CDATA[[U]PHP Twitter Search API[/U]<br/><br/>I&#039;ve implemented the twitter search API in a PHP class just for fun. It implements the entire search API as of February 25, 2009. I&#039;ve only tested this with PHP 5.2.6 but I am fairly confident that most installations of PHP5 should work just fine. If you try it with PHP4 and it works (or if you have to jigger it) let me know.<br/><br/>You can get the source code at <A HREF="http://greenservr.com/projects/twittersearch/TwitterSearch.phps" TARGET="_blank"  rel="nofollow">http://greenservr.com/projects/twittersearch/TwitterSearch.phps</A><br/><br/>Here are a couple examples (after including the class):<br/><br/>This example makes use of method chaining to create a &#034;sentence&#034;. Chaining isn&#039;t a requirement but I think it works here. What this example does is search for tweets from the user &#034;ryanfaerman&#034; with the hashtag &#034;#flsccc&#034;.<br/><br/>$search = new TwitterSearch();<br/>$search-&gt;user_agent = &#039;phptwittersearch:ryan.<a href="mailto:faerman@gmail.com"  rel="nofollow">faerman@gmail.com</a>&#039;;<br/><br/>$results = $search-&gt;from(&#039;ryanfaerman&#039;)-&gt;with(&#039;flsccc&#039;)-&gt;results();<br/>The user agent is optional, but is recommended. This way the folks over at Twitter know who is hitting their server. I&#039;ll be leaving it out in other examples for clarity.<br/><br/>If you want to put in the query during instantiation, you can do that too. Anything that you&#039;d use on search.twitter.com can be passed as the argument. This example searches all twitter for any tweets that mention the word &#034;monkey&#034;.<br/><br/>$search = new TwitterSearch(&#039;monkey&#039;);<br/>$results = $search-&gt;results();<br/>Each time you add another search term, it is appended to the query you are building. Once you get the results, the query is cleared.<br/><br/>This example searches for the last 50 tweets from the user ?darthvader? where he mentions ?storm trooper?.<br/><br/>$search-&gt;from(&#039;darthvader&#039;);<br/>$search-&gt;contains(&#039;storm trooper&#039;);<br/>$results = $search-&gt;rpp(50)-&gt;results();<br/>This example searches for any tweets within a 25 mile radius of the provided coordinates.<br/><br/>$results = $search-&gt;geocode(40.757929, -73.985506, 25)-&gt;results();<br/>There are quite a few more search operators which are clear from the source code, so I encourage you to take a look. Lastly, there is the trends function. Calling this method returns the top ten queries that are currently trending on Twitter.<br/><br/>$trends = $search-&gt;trends();<br/>If you end up using this in a project of yours, I&#039;d really enjoy hearing about it.<br/><br/><br/>URL : <A HREF="http://ryanfaerman.com/twittersearch/" TARGET="_blank"  rel="nofollow">http://ryanfaerman.com/twittersearch/</A>]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Wed, 01 Jun 2011 15:34:32 +0900</dc:date>
</item>


<item>
<title>모바일(iOS 용) 터치 관련 jQuery 플러그인</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=24</link>
<description><![CDATA[[U]모바일(iOS 용) 터치 관련 jQuery 플러그인[/U]<br/><br/>링크 주소 : [URL]<A HREF="http://lab.koism.com/source/jquery/mobileTest6.html" TARGET="_blank"  rel="nofollow">http://lab.koism.com/source/jquery/mobileTest6.html</A>[/URL] <br/>위 링크는 아이폰,안드로이드 폰으로 들어가셔야 동작 확인이 가능합니다. <br/><br/>첨부파일을 확인 하세요.<br/><br/>출처 : <A HREF="http://lab.koism.com" TARGET="_blank"  rel="nofollow">http://lab.koism.com</A>]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Mon, 18 Apr 2011 00:08:59 +0900</dc:date>
</item>


<item>
<title>GEO &lt;-&gt; KATEC  변환</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=23</link>
<description><![CDATA[[U]GEO &lt;-&gt; KATEC&nbsp; 변환[/U]<br/><br/>[B]PHP 방법[/B]<br/>[CODE php]&lt;?php<br/>class GeoTrans{<br/>	var $srctype;<br/>	var $dsttype;<br/>	var $m_Ind, $m_Es, $m_Esp, $src_m, $dst_m;<br/><br/>	var $EPSLN = 0.0000000001;<br/>	var $m_arMajor = 6378137.0;<br/>	var $m_arMinor = 6356752.3142;<br/><br/>	var $m_arScaleFactor = array();<br/>	var $m_arLonCenter = array();<br/>	var $m_arLatCenter = array();<br/>	var $m_arFalseNorthing = array();<br/>	var $m_arFalseEasting = array();<br/><br/><br/>	function GeoTrans($srctype = &#034;katec&#034;, $dsttype = &#034;geo&#034;)<br/>	{<br/>		$this-&gt;m_arScaleFactor[&#034;geo&#034;] = 1;<br/>		$this-&gt;m_arLonCenter[&#034;geo&#034;] = 0.0;<br/>		$this-&gt;m_arLatCenter[&#034;geo&#034;] = 0.0;<br/>		$this-&gt;m_arFalseNorthing[&#034;geo&#034;] = 0.0;<br/>		$this-&gt;m_arFalseEasting[&#034;geo&#034;] = 0.0;<br/><br/>		$this-&gt;m_arScaleFactor[&#034;katec&#034;] = 0.9999;<br/>		$this-&gt;m_arLonCenter[&#034;katec&#034;] = 2.23402144255274;<br/>		$this-&gt;m_arLatCenter[&#034;katec&#034;] = 0.663225115757845;<br/>		$this-&gt;m_arFalseNorthing[&#034;katec&#034;] = 600000.0;<br/>		$this-&gt;m_arFalseEasting[&#034;katec&#034;] = 400000.0;<br/><br/>		$this-&gt;srctype = $srctype;<br/>		$this-&gt;dsttype = $dsttype;<br/><br/>		$temp = $this-&gt;m_arMinor / $this-&gt;m_arMajor;<br/>		$this-&gt;m_Es = 1.0 - $temp * $temp;<br/>		$this-&gt;m_Esp = $this-&gt;m_Es / (1.0 - $this-&gt;m_Es);<br/><br/>		if ($this-&gt;m_Es &lt; 0.00001) {<br/>			$this-&gt;m_Ind = 1.0;<br/>		}<br/>		else {<br/>			$this-&gt;m_Ind = 0.0;<br/>		}<br/><br/>		$this-&gt;src_m = $this-&gt;m_arMajor * $this-&gt;mlfn($this-&gt;e0fn($this-&gt;m_Es), $this-&gt;e1fn($this-&gt;m_Es), $this-&gt;e2fn($this-&gt;m_Es), $this-&gt;e3fn($this-&gt;m_Es), $this-&gt;m_arLatCenter[$srctype]);<br/>		$this-&gt;dst_m = $this-&gt;m_arMajor * $this-&gt;mlfn($this-&gt;e0fn($this-&gt;m_Es), $this-&gt;e1fn($this-&gt;m_Es), $this-&gt;e2fn($this-&gt;m_Es), $this-&gt;e3fn($this-&gt;m_Es), $this-&gt;m_arLatCenter[$dsttype]);<br/>	}<br/><br/>	function D2R($degree)<br/>	{<br/>		return $degree * M_PI / 180.0;<br/>	}<br/><br/>	function R2D($radian)<br/>	{<br/>		return $radian * 180.0 / M_PI;<br/>	}<br/><br/>	function e0fn($x)<br/>	{<br/>		return 1.0 - 0.25 * $x * (1.0 + $x / 16.0 * (3.0 + 1.25 * $x));<br/>	}<br/><br/>	function e1fn($x)<br/>	{<br/>		return 0.375 * $x * (1.0 + 0.25 * $x * (1.0 + 0.46875 * $x));<br/>	}<br/><br/>	function e2fn($x)<br/>	{<br/>		return 0.05859375 * $x * $x * (1.0 + 0.75 * $x);<br/>	}<br/><br/>	function e3fn($x)<br/>	{<br/>		return $x * $x * $x * (35.0 / 3072.0);<br/>	}<br/><br/>	function mlfn($e0, $e1, $e2, $e3, $phi)<br/>	{<br/>		return $e0 * $phi - $e1 * sin(2.0 * $phi) + $e2 * sin(4.0 * $phi) - $e3 * sin(6.0 * $phi);<br/>	}<br/><br/>	function asinz($value)<br/>	{<br/>		if (abs($value) &gt; 1.0) $value = ($value &gt; 0 ? 1 : -1);<br/>		return asin($value);<br/>	}<br/><br/>	function conv($in_x, $in_y, &$out_x, &$out_y)<br/>	{<br/>		if ($this-&gt;srctype == &#034;geo&#034;) {<br/>			$inlon = $this-&gt;D2R($in_x);<br/>			$inlat = $this-&gt;D2R($in_y);<br/>		}<br/>		else {<br/>			$this-&gt;tm2geo($in_x, $in_y, $inlon, $inlat);<br/>		}<br/><br/>		$outlon = $inlon;<br/>		$outlat = $inlat;<br/><br/>		if ($this-&gt;dsttype == &#034;geo&#034;) {<br/>			$out_x = $this-&gt;R2D($outlon);<br/>			$out_y = $this-&gt;R2D($outlat);<br/>		}<br/>		else {<br/>			$this-&gt;geo2tm($outlon, $outlat, $out_x, $out_y);<br/>			$out_x = round($out_x);<br/>			$out_y = round($out_y);<br/>		}<br/>	}<br/><br/>	function geo2tm($lon, $lat, &$x, &$y)<br/>	{<br/>		$delta_lon = $lon - $this-&gt;m_arLonCenter[$this-&gt;dsttype];<br/>		$sin_phi = sin($lat);<br/>		$cos_phi = cos($lat);<br/><br/>		if ($this-&gt;m_Ind != 0) {<br/>			$b = $cos_phi * sin($delta_lon);<br/><br/>			if ((abs(abs($b) - 1.0)) &lt; $this-&gt;EPSLN) {<br/>				echo (&#034;geo2tm: 무한대 에러&#034;);<br/>			}<br/>		}<br/>		else {<br/>			$b = 0;<br/>			$x = 0.5 * $this-&gt;m_arMajor * $this-&gt;m_arScaleFactor[$this-&gt;dsttype] * log((1.0 + $b) / (1.0 - $b));<br/>			$con = acos($cos_phi * cos($delta_lon) / sqrt(1.0 - $b * $b));<br/><br/>			if ($lat &lt; 0) {<br/>				$con = $con * -1;<br/>				$y = $this-&gt;m_arMajor * $this-&gt;m_arScaleFactor[$this-&gt;dsttype] * ($con - $this-&gt;m_arLatCenter[$this-&gt;dsttype]);<br/>			}<br/>		}<br/><br/>		$al = $cos_phi * $delta_lon;<br/>		$als = $al * $al;<br/>		$c = $this-&gt;m_Esp * $cos_phi * $cos_phi;<br/>		$tq = tan($lat);<br/>		$t = $tq * $tq;<br/>		$con = 1.0 - $this-&gt;m_Es * $sin_phi * $sin_phi;<br/>		$n = $this-&gt;m_arMajor / sqrt($con);<br/>		$ml = $this-&gt;m_arMajor * $this-&gt;mlfn($this-&gt;e0fn($this-&gt;m_Es), $this-&gt;e1fn($this-&gt;m_Es), $this-&gt;e2fn($this-&gt;m_Es), $this-&gt;e3fn($this-&gt;m_Es), $lat);<br/><br/>		$x = $this-&gt;m_arScaleFactor[$this-&gt;dsttype] * $n * $al * (1.0 + $als / 6.0 * (1.0 - $t + $c + $als / 20.0 * (5.0 - 18.0 * $t + $t * $t + 72.0 * $c - 58.0 * $this-&gt;m_Esp))) + $this-&gt;m_arFalseEasting[$this-&gt;dsttype];<br/>		$y = $this-&gt;m_arScaleFactor[$this-&gt;dsttype] * ($ml - $this-&gt;dst_m + $n * $tq * ($als * (0.5 + $als / 24.0 * (5.0 - $t + 9.0 * $c + 4.0 * $c * $c + $als / 30.0 * (61.0 - 58.0 * $t + $t * $t + 600.0 * $c - 330.0 * $this-&gt;m_Esp))))) + $this-&gt;m_arFalseNorthing[$this-&gt;dsttype];<br/>	}<br/><br/>	function tm2geo($x, $y, &$lon, &$lat)<br/>	{<br/>		$max_iter = 6;<br/><br/>		if ($this-&gt;m_Ind != 0) {<br/>			$f = exp($x / ($this-&gt;m_arMajor * $this-&gt;m_arScaleFactor[$this-&gt;srctype]));<br/>			$g = 0.5 * ($f - 1.0 / $f);<br/>			$temp = $this-&gt;m_arLatCenter[$this-&gt;srctype] + $y / ($this-&gt;m_arMajor * $this-&gt;m_arScaleFactor[$this-&gt;srctype]);<br/>			$h = cos($temp);<br/>			$con = sqrt((1.0 - $h * $h) / (1.0 + $g * $g));<br/>			$lat = asinz($con);<br/><br/>			if ($temp &lt; 0) $lat *= -1;<br/><br/>			if (($g == 0) && ($h == 0))<br/>				$lon = $this-&gt;m_arLonCenter[$this-&gt;srctype];<br/>			else<br/>				$lon = atan($g / $h) + $this-&gt;m_arLonCenter[$this-&gt;srctype];<br/>		}<br/><br/>		$x -= $this-&gt;m_arFalseEasting[$this-&gt;srctype];<br/>		$y -= $this-&gt;m_arFalseNorthing[$this-&gt;srctype];<br/><br/>		$con = ($this-&gt;src_m + $y / $this-&gt;m_arScaleFactor[$this-&gt;srctype]) / $this-&gt;m_arMajor;<br/>		$phi = $con;<br/><br/>		$i = 0;<br/><br/>		while (true) {<br/>			$delta_Phi = (($con + $this-&gt;e1fn($this-&gt;m_Es) * sin(2.0 * $phi) - $this-&gt;e2fn($this-&gt;m_Es) * sin(4.0 * $phi) + $this-&gt;e3fn($this-&gt;m_Es) * sin(6.0 * $phi)) / $this-&gt;e0fn($this-&gt;m_Es)) - $phi;<br/>			$phi = $phi + $delta_Phi;<br/>			if (abs($delta_Phi) &lt;= $this-&gt;EPSLN) break;<br/><br/>			if ($i &gt;= $max_iter) <br/>				echo (&#034;tm2geo: 무한대 에러&#034;);<br/><br/>			$i++;<br/>		}<br/><br/>		if (abs($phi) &lt; (M_PI / 2)) {<br/>			$sin_phi = sin($phi);<br/>			$cos_phi = cos($phi);<br/>			$tan_phi = tan($phi);<br/>			$c = $this-&gt;m_Esp * $cos_phi * $cos_phi;<br/>			$cs = $c * $c;<br/>			$t = $tan_phi * $tan_phi;<br/>			$ts = $t * $t;<br/>			$con = 1.0 - $this-&gt;m_Es * $sin_phi * $sin_phi;<br/>			$n = $this-&gt;m_arMajor / sqrt($con);<br/>			$r = $n * (1.0 - $this-&gt;m_Es) / $con;<br/>			$d = $x / ($n * $this-&gt;m_arScaleFactor[$this-&gt;srctype]);<br/>			$ds = $d * $d;<br/>			$lat = $phi - ($n * $tan_phi * $ds / $r) * (0.5 - $ds / 24.0 * (5.0 + 3.0 * $t + 10.0 * $c - 4.0 * $cs - 9.0 * $this-&gt;m_Esp - $ds / 30.0 * (61.0 + 90.0 * $t + 298.0 * $c + 45.0 * $ts - 252.0 * $this-&gt;m_Esp - 3.0 * $cs)));<br/>			$lon = $this-&gt;m_arLonCenter[$this-&gt;srctype] + ($d * (1.0 - $ds / 6.0 * (1.0 + 2.0 * $t + $c - $ds / 20.0 * (5.0 - 2.0 * $c + 28.0 * $t - 3.0 * $cs + 8.0 * $this-&gt;m_Esp + 24.0 * $ts))) / $cos_phi);<br/>		}<br/>		else {<br/>			$lat = M_PI * 0.5 * sin($y);<br/>			$lon = $this-&gt;m_arLonCenter[$this-&gt;srctype];<br/>		}<br/>	}<br/><br/>	function getDistancebyGeo($lon1, $lat1, $lon2, $lat2)<br/>	{<br/>		$lat1 = $this-&gt;D2R($lat1);<br/>		$lon1 = $this-&gt;D2R($lon1);<br/>		$lat2 = $this-&gt;D2R($lat2);<br/>		$lon2 = $this-&gt;D2R($lon2);<br/><br/>		$longitude = $lon2 - $lon1;<br/>		$latitude&nbsp; = $lat2 - $lat1;<br/><br/>		$a = pow(sin($latitude / 2.0), 2) + cos($lat1) * cos($lat2) * pow(sin($longitude / 2.0), 2);<br/>		return 6376.5 * 2.0 * atan2(sqrt($a), sqrt(1.0 - $a));<br/>	}<br/><br/>	function getDistancebyKatec($x1, $y1, $x2, $y2)<br/>	{<br/>		$geo = new GeoTrans;<br/>		$geo-&gt;conv($x1, $y1, $lon1, $lat1);<br/>		$geo-&gt;conv($x2, $y2, $lon2, $lat2);<br/><br/>		return $this-&gt;getDistancebyGeo($lon1, $lat1, $lon2, $lat2);<br/>	}<br/><br/>	function getTimebySec($distance)<br/>	{<br/>		return round(3600 * $distance / 4);<br/>	}<br/><br/>	function getTimebyMin($distance)<br/>	{<br/>		return (int)ceil($this-&gt;getTimebySec($distance) / 60);<br/>	}<br/>}<br/><br/>$naverx = &#034;306151&#034;;<br/>$navery = &#034;556443&#034;;<br/><br/>$geo = new GeoTrans;<br/>$geo-&gt;conv($naverx,$navery,$x,$y);<br/><br/>echo(&#034;======input naver postion=======\n&#034;);<br/>echo(&#034;naver x: &#034;.$naverx);<br/>echo(&#034;\n&#034;);<br/>echo(&#034;naver y: &#034;.$navery);<br/>echo(&#034;\n&#034;);<br/>echo(&#034;======convert naver to google=======\n&#034;);<br/>echo(&#034;google lng: &#034;.$x);<br/>echo(&#034;\n&#034;);<br/>echo(&#034;google lat: &#034;.$y);<br/>echo(&#034;\n&#034;);<br/><br/>$geo = new GeoTrans(&#034;geo&#034;,&#034;katec&#034;);<br/>$geo-&gt;conv($x,$y,$final_naverx,$final_navery);<br/>echo(&#034;======convert google to naver=======\n&#034;);<br/>echo(&#034;final naver x: &#034;.$final_naverx);<br/>echo(&#034;\n&#034;);<br/>echo(&#034;final naver y: &#034;.$final_navery);<br/>echo(&#034;\n&#034;);<br/>?&gt;[/CODE]<br/><br/><br/>[U]Javascript 방법[/U]<br/>[CODE js]var Point = function(x, y) {<br/>	this.x = x;<br/>	this.y = y;<br/>}<br/><br/>var GeoTrans = function() {<br/>	this.srctype = &#034;katec&#034;;<br/>	this.dsttype = &#034;geo&#034;;<br/>	this.m_Ind = 0;<br/>	this.m_Es = 0;<br/>	this.m_Esp = 0;<br/>	this.src_m = 0;<br/>	this.dst_m = 0;<br/><br/>	this.EPSLN = 0.0000000001;<br/>	this.m_arMajor = 6378137.0;<br/>	this.m_arMinor = 6356752.3142;<br/><br/>	this.m_arScaleFactor = new Array();<br/>	this.m_arLonCenter = new Array();<br/>	this.m_arLatCenter = new Array();<br/>	this.m_arFalseNorthing = new Array();<br/>	this.m_arFalseEasting = new Array();<br/>};<br/><br/>GeoTrans.prototype.init = function(srctype, dsttype) {<br/>	this.m_arScaleFactor[&#034;geo&#034;] = 1;<br/>	this.m_arLonCenter[&#034;geo&#034;] = 0.0;<br/>	this.m_arLatCenter[&#034;geo&#034;] = 0.0;<br/>	this.m_arFalseNorthing[&#034;geo&#034;] = 0.0;<br/>	this.m_arFalseEasting[&#034;geo&#034;] = 0.0;<br/><br/>	this.m_arScaleFactor[&#034;katec&#034;] = 0.9999;<br/>	this.m_arLonCenter[&#034;katec&#034;] = 2.23402144255274;<br/>	this.m_arLatCenter[&#034;katec&#034;] = 0.663225115757845;<br/>	this.m_arFalseNorthing[&#034;katec&#034;] = 600000.0;<br/>	this.m_arFalseEasting[&#034;katec&#034;] = 400000.0;<br/><br/>	this.srctype = srctype;<br/>	this.dsttype = dsttype;<br/><br/>	var tmp = this.m_arMinor / this.m_arMajor;<br/>	this.m_Es = 1.0 - tmp * tmp;<br/>	this.m_Esp = this.m_Es / (1.0 - this.m_Es);<br/><br/>	if(this.m_Es &lt; 0.00001) {<br/>		this.m_Ind = 1.0;<br/>	} else {<br/>		this.m_Ind = 0.0;<br/>	}<br/><br/>	this.src_m = this.m_arMajor * this.mlfn(this.e0fn(this.m_Es), this.e1fn(this.m_Es), this.e2fn(this.m_Es), this.e3fn(this.m_Es), this.m_arLatCenter[srctype]);<br/>	this.dst_m = this.m_arMajor * this.mlfn(this.e0fn(this.m_Es), this.e1fn(this.m_Es), this.e2fn(this.m_Es), this.e3fn(this.m_Es), this.m_arLatCenter[dsttype]);<br/>}<br/><br/>GeoTrans.prototype.D2R = function(degree) {<br/>	return degree* Math.PI / 180.0;<br/>}<br/><br/>GeoTrans.prototype.R2D = function(radian) {<br/>	return radian * 180.0 / Math.PI;<br/>}<br/><br/>GeoTrans.prototype.e0fn = function(x) {<br/>	return 1.0 - 0.25 * x * (1.0 + x / 16.0 * (3.0 + 1.25 * x));<br/>}<br/><br/>GeoTrans.prototype.e1fn = function(x) {<br/>	return 0.375 * x * (1.0 + 0.25 * x * (1.0 + 0.46875 * x));<br/>}<br/><br/>GeoTrans.prototype.e2fn = function(x) {<br/>	return 0.05859375 * x * x * (1.0 + 0.75 * x);<br/>}<br/><br/>GeoTrans.prototype.e3fn = function(x) {<br/>	return x * x * x * (35.0 / 3072.0);<br/>}<br/><br/>GeoTrans.prototype.mlfn = function(e0, e1, e2, e3, phi) {<br/>	return e0 * phi - e1 * Math.sin(2.0 * phi) + e2 * Math.sin(4.0 * phi) - e3 * Math.sin(6.0 * phi);<br/>}<br/><br/>GeoTrans.prototype.asinz = function(value) {<br/>	if(Math.abs(value) &gt; 1.0) value = (value &gt; 0 ? 1: -1);<br/>	return Math.asin(value);<br/>}<br/><br/>GeoTrans.prototype.conv = function(in_pt) {<br/>	var inlon, inlat, outlon, outlat;<br/><br/>	var tmpPt = new Point();<br/>	var out_pt = new Point();<br/><br/>	if(this.srctype == &#034;geo&#034;) {<br/>		tmpPt.x = this.D2R(in_pt.x);<br/>		tmpPt.y = this.D2R(in_pt.y);<br/>	} else {<br/>		this.tm2geo(in_pt, tmpPt);<br/>	}<br/><br/>	outlon = inlon;<br/>	outlat = inlat;<br/><br/>	if(this.dsttype == &#034;geo&#034;) {<br/>		out_pt.x = this.R2D(tmpPt.x);<br/>		out_pt.y = this.R2D(tmpPt.y);<br/>	} else {<br/>		this.geo2tm(tmpPt, out_pt);<br/>		out_pt.x = Math.round(out_pt.x);<br/>		out_pt.y = Math.round(out_pt.y);<br/>	}<br/><br/>	return out_pt;<br/>}<br/><br/>GeoTrans.prototype.geo2tm = function(in_pt, out_pt) {<br/>	var delta_lon = in_pt.x - this.m_arLonCenter[this.dsttype];<br/>	var sin_phi = Math.sin(in_pt.y);<br/>	var cos_phi = Math.cos(in_pt.y);<br/><br/>	if(this.m_Ind != 0) {<br/>		var b = cos_phi * Math.sin(delta_lon);<br/><br/>		if((Math.abs(Math.abs(b) - 1.0)) &lt; this.EPSLN) {<br/>			alert(&#034;무한대 에러&#034;);<br/>		}<br/>	} else {<br/>		var b = 0;<br/>		x = 0.5 * this.m_arMajor * this.m_arScaleFactor[this.dsttype] * Math.log((1.0 + b) / (1.0 - b));<br/>		var con = Math.acos(cos_phi * Math.cos(delta_lon) / Math.sqrt(1.0 - b * b));<br/><br/>		if(in_pt.y &lt; 0) {<br/>			con = con * -1;<br/>			y = this.m_arMajor * this.m_arScaleFactor[this.dsttype] * (con - this.m_arLatCenter[this.dsttype]);<br/>		}<br/>	}<br/><br/>	var al = cos_phi * delta_lon;<br/>	var als = al * al;<br/>	var c = this.m_Esp * cos_phi * cos_phi;<br/>	var tq = Math.tan(in_pt.y);<br/>	var t = tq * tq;<br/>	var con = 1.0 - this.m_Es * sin_phi * sin_phi;<br/>	var n = this.m_arMajor / Math.sqrt(con);<br/>	var ml = this.m_arMajor * this.mlfn(this.e0fn(this.m_Es), this.e1fn(this.m_Es), this.e2fn(this.m_Es), this.e3fn(this.m_Es), in_pt.y);<br/><br/>	out_pt.x = this.m_arScaleFactor[this.dsttype] * n * al * (1.0 + als / 6.0 * (1.0 - t + c + als / 20.0 * (5.0 - 18.0 * t + t * t + 72.0 * c - 58.0 * this.m_Esp))) + this.m_arFalseEasting[this.dsttype];<br/>	out_pt.y = this.m_arScaleFactor[this.dsttype] * (ml - this.dst_m + n * tq * (als * (0.5 + als / 24.0 * (5.0 - t + 9.0 * c + 4.0 * c * c + als / 30.0 * (61.0 - 58.0 * t + t * t + 600.0 * c - 330.0 * this.m_Esp))))) + this.m_arFalseNorthing[this.dsttype];<br/>}<br/><br/><br/>GeoTrans.prototype.tm2geo = function(in_pt, out_pt) {<br/>	var max_iter = 6;<br/><br/>	if(this.m_Ind != 0) {<br/>		var f = Math.exp(in_pt.x / (this.m_arMajor * this.m_arScaleFactor[this.srctype]));<br/>		var g = 0.5 * (f - 1.0 / f);<br/>		var temp = this.m_arLatCenter[this.srctype] + in_pt.y / (this.m_arMajor * this.m_arScaleFactor[this.srctype]);<br/>		var h = Math.cos(temp);<br/>		var con = Math.sqrt((1.0 - h * h) / (1.0 + g * g));<br/>		out_pt.y = asinz(con);<br/><br/>		if(temp &lt; 0) out_pt.y *= -1;<br/><br/>		if((g == 0) && (h == 0)) {<br/>			out_pt.x = this.m_arLonCenter[this.srctype];<br/>		} else {<br/>			out_pt.x = Math.atan(g / h) + this.m_arLonCenter[this.srctype];<br/>		}<br/>	}<br/><br/>	in_pt.x -= this.m_arFalseEasting[this.srctype];<br/>	in_pt.y -= this.m_arFalseNorthing[this.srctype];<br/><br/>	var con = (this.src_m + in_pt.y / this.m_arScaleFactor[this.srctype]) / this.m_arMajor;<br/>	var phi = con;<br/><br/>	var i = 0;<br/><br/>	while(true) {<br/>		var delta_Phi = ((con + this.e1fn(this.m_Es) * Math.sin(2.0 * phi) - this.e2fn(this.m_Es) * Math.sin(4.0 * phi) + this.e3fn(this.m_Es) * Math.sin(6.0 * phi)) / this.e0fn(this.m_Es)) - phi;<br/>		phi = phi + delta_Phi;<br/><br/>		if(Math.abs(delta_Phi) &lt;= this.EPSLN) break;<br/><br/>		if(i &gt;= max_iter) {<br/>			alert(&#034;무한대 에러&#034;);<br/>			break;<br/>		}<br/><br/>		i++;<br/>	}<br/><br/>	if(Math.abs(phi) &lt; (Math.PI / 2)) {<br/>		var sin_phi = Math.sin(phi);<br/>		var cos_phi = Math.cos(phi);<br/>		var tan_phi = Math.tan(phi);<br/>		var c = this.m_Esp * cos_phi * cos_phi;<br/>		var cs = c * c;<br/>		var t = tan_phi * tan_phi;<br/>		var ts = t * t;<br/>		var con = 1.0 - this.m_Es * sin_phi * sin_phi;<br/>		var n = this.m_arMajor / Math.sqrt(con);<br/>		var r = n * (1.0 - this.m_Es) / con;<br/>		var d = in_pt.x / (n * this.m_arScaleFactor[this.srctype]);<br/>		var ds = d * d;<br/>		out_pt.y = phi - (n * tan_phi * ds / r) * (0.5 - ds / 24.0 * (5.0 + 3.0 * t + 10.0 * c - 4.0 * cs - 9.0 * this.m_Esp - ds / 30.0 * (61.0 + 90.0 * t + 298.0 * c + 45.0 * ts - 252.0 * this.m_Esp - 3.0 * cs)));<br/>		out_pt.x = this.m_arLonCenter[this.srctype] + (d * (1.0 - ds / 6.0 * (1.0 + 2.0 * t + c - ds / 20.0 * (5.0 - 2.0 * c + 28.0 * t - 3.0 * cs + 8.0 * this.m_Esp + 24.0 * ts))) / cos_phi);<br/>	} else {<br/>		out_pt.y = Math.PI * 0.5 * Math.sin(in_pt.y);<br/>		out_pt.x = this.m_arLonCenter[this.srctype];<br/>	}<br/>}<br/><br/>GeoTrans.prototype.getDistancebyGeo = function(pt1, pt2) {<br/>	var lat1 = this.D2R(pt1.y);<br/>	var lon1 = this.D2R(pt1.x);<br/>	var lat2 = this.D2R(pt2.y);<br/>	var lon2 = this.D2R(pt2.x);<br/><br/>	var longitude = lon2 - lon1;<br/>	var latitude = lat2 - lat1;<br/><br/>	var a = Math.pow(Math.sin(latitude / 2.0), 2) + Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(longitude / 2.0), 2);<br/>	return 6376.5 * 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a));<br/>}<br/><br/>GeoTrans.prototype.getDistancebyKatec = function(pt1, pt2) {<br/>	var geo = new GeoTrans(&#034;katec&#034;, &#034;geo&#034;);<br/>	pt1 = geo.conv(pt1);<br/>	pt2 = geo.conv(pt2);<br/><br/>	return this.getDistancebyGeo(pt1, pt2);<br/>}<br/><br/>GeoTrans.prototype.getTimebySec = function(distance) {<br/>	return Math.round(3600 * distance / 4);<br/>}<br/><br/>GeoTrans.prototype.getTimebyMin = function(distance) {<br/>	return Number(Math.ceil(this.getTimebySec(distance) / 60));<br/>}<br/><br/><br/>var geo = new GeoTrans();<br/><br/>geo.init(&#034;katec&#034;, &#034;geo&#034;);<br/>var pt = new Point(306151, 556443);<br/>var out_pt = geo.conv(pt);<br/><br/>alert(&#034;경도 : &#034;+out_pt.x+&#034;\n위도 : &#034;+out_pt.y);<br/><br/>//역변환<br/>geo.init(&#034;geo&#034;, &#034;katec&#034;);<br/>out_pt = geo.conv(out_pt);<br/><br/>alert(&#034;[KATEC 좌표]\nx : &#034;+out_pt.x+&#034;\ny : &#034;+out_pt.y);[/CODE]<br/><br/>[U]기타 참고 URL[/U]<br/><A HREF="http://aero.sarang.net/map/analysis.html" TARGET="_blank"  rel="nofollow">http://aero.sarang.net/map/analysis.html</A><br/><A HREF="http://aero.sarang.net/map/coordinate_naver.html" TARGET="_blank"  rel="nofollow">http://aero.sarang.net/map/coordinate_naver.html</A><br/><A HREF="http://code.google.com/intl/ko/apis/maps/" TARGET="_blank"  rel="nofollow">http://code.google.com/intl/ko/apis/maps/</A><br/><A HREF="http://dev.naver.com/openapi/apis/map/javascript/reference" TARGET="_blank"  rel="nofollow">http://dev.naver.com/openapi/apis/map/javascript/reference</A>]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Mon, 21 Feb 2011 11:17:22 +0900</dc:date>
</item>


<item>
<title>Twitter API 링크</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=21</link>
<description><![CDATA[[URL]<A HREF="http://dev.twitter.com/" TARGET="_blank"  rel="nofollow">http://dev.twitter.com/</A>[/URL]<br/>[URL]<A HREF="http://blog.yesyo.com/entry/twitter-Anywhere-적용-방법" TARGET="_blank"  rel="nofollow">http://blog.yesyo.com/entry/twitter-Anywhere-적용-방법</A>[/URL]<br/>[URL]<A HREF="http://blog.yesyo.com/entry/twitter-API-for-PHP" TARGET="_blank"  rel="nofollow">http://blog.yesyo.com/entry/twitter-API-for-PHP</A>[/URL]<br/><br/>[URL]<A HREF="http://twtkr.com" TARGET="_blank"  rel="nofollow">http://twtkr.com</A>[/URL] -&gt; 한국어 트위터<br/>[URL]<A HREF="http://bit.ly" TARGET="_blank"  rel="nofollow">http://bit.ly</A>[/URL] -&gt; 주소를 잛게 만들어주는 사이트 API 제공]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Tue, 13 Jul 2010 11:02:21 +0900</dc:date>
</item>


<item>
<title>jQuery Simple WYSIWYG Editor</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=20</link>
<description><![CDATA[[U]jQuery Simple WYSIWYG Editor[/U]<br/><br/>완전한 이지윅 에디터는 아니지만 공부용으로 좋을것 같네요. [URL=http://de77.com/code-examples/editor2]{데모}[/URL]<br/><br/>[URL]<A HREF="http://de77.com/javascript/jquery-simple-wysiwyg-editor" TARGET="_blank"  rel="nofollow">http://de77.com/javascript/jquery-simple-wysiwyg-editor</A>[/URL]<br/><br/>[ATTACH]574[/ATTACH]<br/><br/>[CODE js]function action(e,a,p)<br/>{<br/>	/*<br/>	$(e).parents().each(function(){<br/>		var obj = $(this);<br/>		var classes = obj.attr(&#039;class&#039;).split(&#039; &#039;);<br/>		if ($.inArray(&#039;de77_wysiwyg&#039;, classes) &gt; -1)<br/>		{<br/>			obj.find(&#039;.de77_editor&#039;).focus();<br/>		}<br/>	});<br/>	*/<br/>	if (p == null) p = false;<br/>	document.execCommand(a,null,p);<br/>}[/CODE]<br/><br/><br/>jQuery 를 사용하지 않는 것도 있습니다. [URL=http://de77.com/code-examples/editor]{데모}[/URL]<br/><br/>[URL]<A HREF="http://de77.com/html/how-to-make-a-wysiwyg-editor-in-javascript" TARGET="_blank"  rel="nofollow">http://de77.com/html/how-to-make-a-wysiwyg-editor-in-javascript</A>[/URL]<br/><br/><br/>ps.&nbsp; 참고로 execCommand 를 지원하는 브라우저를 정리 해놓은 곳이 있습니다. [URL]<A HREF="http://www.quirksmode.org/dom/execCommand.html" TARGET="_blank"  rel="nofollow">http://www.quirksmode.org/dom/execCommand.html</A>[/URL]]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Fri, 02 Jul 2010 12:05:56 +0900</dc:date>
</item>


<item>
<title>Prototype.js 의 Object 객체의 메소드</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=19</link>
<description><![CDATA[[U]Prototype.js 의 Object 객체의 메소드[/U]<br/><br/>[B]1. Object.extend[/B]<br/>A 라는 원본 개체가 가지고 있는 프로퍼티를 B라는 대상 개체에 복사합니다. 반환은 B 를 돌려 줍니다.<br/><br/>[CODE js]var dog = {<br/>	sound : function(){<br/>		return &#039;bark bark&#039;;<br/>	}<br/>}<br/>var bird = {<br/>	sound : function (){<br/>		return &#039;jack jack&#039;;<br/>	},<br/>	fly&nbsp;  : function(){<br/>		return &#039;fly fly&#039;;<br/>	}<br/>}<br/>Object.extend(dog, bird);<br/>alert(dog.sound());<br/>alert(dog.fly());[/CODE]<br/>예제를 보시면 개에다가 새의 프로퍼티들을 복사 합니다. <br/>개에 나는 기능이 추가되고 원본(dog) 개체가 가지고 있던 프로퍼티인 sound 가 bird 개체의 sound 로 덮어 씌워집니다.<br/><br/><br/>[B]2. Object.inspect[/B]<br/>디버그를 할수 있도록 문자열을 리턴합니다. 사실 자바스크립트 코어 메소드인 toString 을 사용할수도 있으나 toString 은 보통 개발자가 보고 싶어하는 유용한 정보를 보여주지 않습니다.<br/>때문에 이 메소드를 사용합니다. 유저가 직접 만든 객체에도 inspect 메소드를 추가한다면 마찬가지로 노출해 줍니다.<br/><br/>[CODE js]var arr = [1,2];<br/>var str = &#039;hello javascript&#039;;<br/>var hash = $H({<br/>	a1 : &#039;3&#039;,<br/>	a2 : function(){<br/>		return &#039;4&#039;<br/>	},<br/>	a3 : {<br/>		b1 : &#039;1&#039;<br/>	}<br/>});<br/>var userMake = {<br/>	name : &#039;nice guy&#039;,<br/>	inspect : function(){<br/>		return &#039;i am &#039;+ this.name;<br/>	}<br/>};<br/>alert(Object.inspect(arr));<br/>alert(Object.inspect(str));<br/>alert(Object.inspect(hash));<br/>alert(Object.inspect(userMake));[/CODE]<br/><br/>순서 대로 결과는 <br/>[1, 2]<br/><br/>&#039;hello javascript&#039;<br/><br/>#&lt;Hash:{&#039;a1&#039;: &#039;3&#039;, &#039;a2&#039;: function () {<br/>	return &#034;4&#034;;<br/>}, &#039;a3&#039;: [object Object]}&gt;<br/><br/>i am nice guy<br/><br/>를 리턴합니다. prototype.js 가 가지고 있는 개체인 Hash, Enumerable 의 내용을 확인 할수도 있습니다.<br/><br/><br/>[B]3. Object.toJSON[/B]<br/>json 형식으로 리턴합니다.<br/><br/>[CODE js]var arr = [1,2];<br/>var str = &#039;hello javascript&#039;;<br/>var hash = $H({<br/>	a1 : &#039;3&#039;,<br/>	a2 : function(){<br/>		return &#039;4&#039;<br/>	},<br/>	a3 : {<br/>		b1 : &#039;1&#039;<br/>	},<br/>	a4 : [1, 2]<br/>});<br/>var userMake = {<br/>	name : &#039;nice guy&#039;,<br/>	inspect : function(){<br/>		return &#039;i am &#039;+ this.name;<br/>	}<br/>}<br/>alert(Object.toJSON(arr));<br/>alert(Object.toJSON(str));<br/>alert(Object.toJSON(hash));<br/>alert(Object.toJSON(userMake));[/CODE]	<br/><br/>순서대로 결과는 <br/>[1, 2]<br/><br/>&#034;hello javascript&#034;<br/><br/>{&#034;a1&#034;: &#034;3&#034;, &#034;a3&#034;: {&#034;b1&#034;: &#034;1&#034;}, &#034;a4&#034;: [1, 2]}<br/><br/>{&#034;name&#034;: &#034;nice guy&#034;}<br/><br/>입니다.<br/>Array , String , Number 형 등은 그냥&nbsp; 바로 리턴 해 버리고 객체 안에서의 Array, String, Number 형은 Json 의 키와 값으로 설정 됩니다.<br/>undefined, function , unknown 등은 패스 해버립니다. (userMake 개체의 inspect 메소드를 패스해버린걸 봐도 알수 있습니다)<br/><br/><br/>[B]4. Object.toQueryString[/B]<br/>queryString 형식의 값으로 반환 합니다.<br/>e.x) name=niceguy&height=200&weight=80 <br/><br/>[B]5. toHTML[/B]<br/>해당 객체의 toHTML 을 호출 합니다.&nbsp; toHTML 메소드가 존재 하지 않으면 Sting 의 interpret 메소드를 호출 합니다.<br/><br/>[CODE js]var Bookmark = Class.create({<br/>	initialize: function(name, url) {<br/>		this.name = name;<br/>		this.url = url;<br/>	},<br/>	toHTML: function() {<br/>		return &#039;&lt;a href=&#034;#{url}&#034;&gt;#{name}&lt;/a&gt;&#039;.interpolate(this);<br/>	}<br/>});<br/>var api = new Bookmark(&#039;Prototype API&#039;, &#039;http://prototypejs.org/api&#039;);<br/>alert(Object.toHTML(api));[/CODE]<br/><br/>결과는&nbsp; &lt;a href=&#034;<A HREF="http://prototypejs.org/api&#034;" TARGET="_blank"  rel="nofollow">http://prototypejs.org/api&#034;</A>&gt;Prototype API&lt;/a&gt; 입니다.<br/><br/><br/>[B]6. clone[/B]<br/>빈 개체에 개체의 프로퍼티를 복사합니다.<br/>실제 내부적으론 Object.extend 를 사용합니다.<br/>대상 개체의 프로퍼티를 빈객체에 복사한다 정도입니다.<br/><br/><br/>[B]7. 기타[/B]<br/>[CODE js]Object.extend = function(destination, source) {<br/>	/*<br/>	source 객체의 프로퍼티를 destination 개체의 프로퍼티로 복사 합니다. <br/>	리턴은 destination 을 돌려줍니다.<br/>	prototype.js 소스를 보시면 Array.prototype 처럼 prototype 을 복사 하기도 합니다.<br/>	*/<br/>	for (var property in source)<br/>		destination[property] = source[property];<br/>	return destination;<br/>};<br/><br/>Object.extend(Object, {<br/>	inspect: function(object) {<br/>		try {<br/>			if (Object.isUndefined(object)) return &#039;undefined&#039;;<br/>			if (object === null) return &#039;null&#039;;<br/>			return object.inspect ? object.inspect() : String(object);<br/>			/*<br/>			해당 개체의 inspect 메소드가 존재하면 inspect 메소드를 뿌려주며 존재 하지 않을시 String 형으로 반환 합니다.<br/>			개발자가 생성한 객체의 경우 inspect 메소드를 지정함으로써 디버깅시 용이하게 만들수 있습니다.<br/>			*/<br/>		} catch (e) {<br/>			if (e instanceof RangeError) return &#039;...&#039;;<br/>			throw e;<br/>		}<br/>	},<br/><br/>	toJSON: function(object) {<br/>		var type = typeof object;<br/>		switch (type) {<br/>			case &#039;undefined&#039;:<br/>			case &#039;function&#039;:<br/>			case &#039;unknown&#039;: return;<br/>			case &#039;boolean&#039;: return object.toString();<br/>		}<br/>		/*<br/>		(undefined , function, unkown) type 일시 json 형으로 만들지 않고 넘어가며 boolean 형일경우 &#039;true&#039;, &#039;false&#039; 형의 문자로 return 해줍니다.<br/>		*/<br/>		if (object === null) return &#039;null&#039;;<br/>		// null 은 &#039;null&#039; 문자로 리턴해줍니다.<br/>		if (object.toJSON) return object.toJSON();<br/>		// 해당 객체가 toJSON 메소드가 지정되었을시 메소드를 실행한 값을 리턴해 줍니다.<br/>		if (Object.isElement(object)) return;<br/>		// nodeType 이 1 즉 속성일시 그냥 넘어갑니다.<br/>		var results = [];<br/>		for (var property in object) {<br/>			var value = Object.toJSON(object[property]);<br/>			if (!Object.isUndefined(value))<br/>				results.push(property.toJSON() + &#039;: &#039; + value);<br/>		}<br/>		/*<br/>		객체가 넘어 왔을시 해당 객체를 돌면서 해당객체의 프로퍼티중 JSON 으로 쓸만한 녀석들만 배열에 넣은뒤 아래에서 JSON 타입으로 반환해 줍니다.<br/>		*/<br/>		return &#039;{&#039; + results.join(&#039;, &#039;) + &#039;}&#039;;<br/>	},<br/>});[/CODE]<br/><br/><br/>ps. 출처 : <A HREF="http://run2you.tistory.com/32" TARGET="_blank"  rel="nofollow">http://run2you.tistory.com/32</A>]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Tue, 19 Jan 2010 11:38:09 +0900</dc:date>
</item>


<item>
<title>prototype.js 를 이용한 JSON사용 예제</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=18</link>
<description><![CDATA[[U]prototype.js 를 이용한 JSON사용 예제[/U]<br/><br/>아래는 JSON 사용의 간단한 예제 입니다.<br/><br/>[B]1번 예제[/B]<br/>[CODE html]&lt;html&gt;<br/>&lt;head&gt;<br/>&lt;meta http-equiv=&#034;Content-Type&#034; content=&#034;text/html; charset=utf-8&#034;&gt;<br/>&lt;script type=&#034;text/javascript&#034; src=&#034;prototype.js&#034;&gt;&lt;/script&gt;<br/>&lt;script type=&#034;text/javascript&#034;&gt;<br/>Event.observe(window , &#039;load&#039; , init);<br/>function init() {<br/>		$(&#039;jsonBtn&#039;).observe(&#039;click&#039; , getJsonData);<br/>}<br/>function getJsonData() {<br/>		new Ajax.Request(<br/>				&#039;json.php&#039;<br/>				,{onSuccess: function(jsonData) {<br/>						var jsonOBJ = jsonData.responseText.evalJSON(true);<br/>						if(jsonOBJ.books.length&gt;0) {<br/>								jsonOBJ.books.each(<br/>										function(book) {<br/>												$(&#039;bookDiv&#039;).insert(&#039;책이름: &#039;+book.title)<br/>												.insert(&#039; , 저자:&#039;+book.author)<br/>												.insert(&#039; , 출판사:&#039;+book.publisher+&#039;&lt;br/&gt;&#039;);<br/>										}<br/>								);<br/>						}<br/>				} <br/>		}); <br/>}<br/>&lt;/script&gt;<br/>&lt;/head&gt;<br/>&lt;body&gt;<br/>&lt;h1&gt;JSON데이터 얻어오기&lt;/h1&gt;<br/>&lt;input type=&#034;button&#034; id=&#039;jsonBtn&#039; value=&#034;getJsonData&#034;&gt;<br/>&lt;div id=&#039;bookDiv&#039;&gt;&lt;/div&gt;<br/>&lt;/body&gt;<br/>&lt;/html&gt;[/CODE]<br/><br/>json.php 파일 내용<br/>[CODE]{&#034;books&#034;:[<br/>	{&#034;title&#034;: &#034;경량데이터JSON&#034;, &#034;author&#034;: &#034;김성운&#034;, &#034;publisher&#034;: &#034;야메출판사&#034;}, <br/>	{&#034;title&#034;: &#034;JSON의 활용&#034;, &#034;author&#034;: &#034;한동열&#034;, &#034;publisher&#034;: &#034;노을과책&#034;}, <br/>	{&#034;title&#034;: &#034;XML vs JSON&#034;, &#034;author&#034;: &#034;홍길동&#034;, &#034;publisher&#034;: &#034;꽃보다책&#034;}, <br/>]}[/CODE]<br/><br/><br/>[B]2번 예제[/B]<br/>[CODE html]&lt;html&gt;<br/>&lt;head&gt;<br/>&lt;meta http-equiv=&#034;Content-Type&#034; content=&#034;text/html; charset=utf-8&#034; /&gt;<br/>&lt;title&gt;Ajax 통신&lt;/title&gt;<br/>&lt;!-- Ajax 객체 및 오브젝트를 브라우저에 상관없이 핸들링할 수 있는 prototype.js --&gt;<br/>&lt;script language=&#034;javascript&#034; type=&#034;text/javascript&#034; src=&#034;js/prototype.js&#034;&gt;&lt;/script&gt;<br/>&lt;script language=&#034;javascript&#034;&gt;<br/>// 화면상의 각종 이벤트를 catch할 수 있는 모듈<br/>Event.observe(window, &#039;load&#039;, function() {<br/>		Event.observe(&#039;textField&#039;, &#039;keydown&#039;, AJAXComm.fileReceive);<br/>});<br/>// Ajax와 통신할 객체를 생성하는 부분으로<br/>// URL : 호출할 서버 액션 기술<br/>// DataShow.jsonData(xmlHttp)은 서버 호출 후 response를 받아 처리하는 함수부분<br/>var AJAXComm = {<br/>		fileReceive: function(event) {<br/>				var URL = &#039;put.php&#039;;<br/>				var rqst = new Ajax.Request(URL, {<br/>						onSuccess: function(xmlHttp) {<br/>								DataShow.jsonData(xmlHttp);<br/>						}<br/>				});<br/>		}<br/>}<br/>// Ajax통신 후 response값(JSON)을 처리하는 함수<br/>var DataShow = {<br/>		jsonData: function(xmlHttp) {<br/>				var serverData = xmlHttp.responseText;<br/>				var evalData = eval(&#039;(&#039; + serverData + &#039;)&#039;);<br/>				for (var i=0; i&lt;evalData. keyword.length; i++) {<br/>						var varCode = evalData. keyword [i];<br/>						var editData = &#034;&lt;div&gt;&#034;+varCode+&#034;&lt;/div&gt;&#034;;<br/>						new Insertion.Bottom(&#039;srchWord&#039;,editData);<br/>				}<br/>		}<br/>}<br/>&lt;/script&gt;<br/>&lt;/head&gt;<br/>&lt;body&gt;<br/>&lt;form method=&#034;get&#034;&gt;<br/>&lt;h1&gt;AJAX 추천검색&lt;/h1&gt;<br/>&lt;div id=&#034;firstDivision&#034;&gt;<br/>	&lt;br /&gt;<br/>	&lt;div&gt;<br/>		&lt;input type=&#034;text&#034; id=&#034;textField&#034; value=&#034;검색어를 입력하세요&#034; class=&#034;applyText&#034; /&gt;<br/>		&lt;input type=&#034;button&#034; value=&#034;검색&#034;&gt;<br/>		&lt;div id=&#034;srchWord&#034; class=&#034;applyBorder&#034;&gt;&lt;/div&gt;<br/>	&lt;/div&gt;<br/>&lt;/div&gt;<br/>&lt;/form&gt;<br/>&lt;/body&gt;<br/>&lt;/html&gt;[/CODE]<br/><br/>json.php 파일 내용<br/>[CODE]{&#034;keyword&#034;: [<br/>	&#034;가방&#034;, <br/>	&#034;가방끝&#034;, <br/>	&#034;가방수리&#034;, <br/>	&#034;가방수선점&#034;<br/>]}[/CODE]]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Tue, 19 Jan 2010 11:02:31 +0900</dc:date>
</item>


<item>
<title>php 내장함수을 이용한 XML Parser</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=17</link>
<description><![CDATA[[U]php 내장함수을 이용한 XML Parser[/U]<br/><br/>[URL=http://kr.php.net/manual/kr/book.xml.php]php.net XML Parser[/URL] 에 보시면 자세한 설명을 보실 수 있습니다.<br/>보통 4.3 버전 이상이면 무리없이 돌아가는것 같네요.<br/><br/>[CODE php]&lt;?<br/>/**<br/>&nbsp;*XML Parser 을 이용하여 XML을 다룬다. <br/>&nbsp;* <br/>&nbsp;* 자세한 설명및 레퍼런스는 <A HREF="http://kr.php.net/manual/kr/book.xml.php" TARGET="_blank"  rel="nofollow">http://kr.php.net/manual/kr/book.xml.php</A> 를 참고 <br/>&nbsp;*/<br/><br/>$rXml = xml_parser_create();	// xml 파서를 생성시킨다. <br/>$arXml = array();			// 임시 배열<br/>$strXml = &#039;&#039;;				// xml의 내용을 저장할 변수<br/>/**<br/>&nbsp;* file_get_contents 등의 파일 내용을 읽는 여러 함수를 이용할 수 있다. <br/>&nbsp;*/<br/>$fp = fopen(&#039;./test.xml&#039;, &#039;r&#039;);	// xml 파일을 읽는다. <br/>if($fp)	// 정상적으로 파일이 열렸다면 <br/>{<br/>	while (!feof($fp)) {	// EOF가 될때까지<br/>		$strXml .= fread($fp, 1024);	// 1024 바이트씩 읽어서 임시 변수에 넣는다.<br/>	}<br/>	fclose($fp);	// 파일을 닫는다.<br/>}<br/>xml_parser_set_option($rXml, XML_OPTION_CASE_FOLDING, 0); 	// 대문자로 변경 (기본이 enable이라 disable함)<br/>xml_parser_set_option($rXml, XML_OPTION_SKIP_WHITE, 1);		// 공백값을 무시힌다. <br/>xml_parse_into_struct($rXml, $strXml, $arXml);	// 읽어들인 XML을 이용해서 배열에 XML구조를 담는다.<br/>xml_parser_free($rXml);<br/><br/>$strNodeKey = null;<br/>$arXmlAssoc = array();<br/>// 연관배열 형식으로 하기 위해서 아래와 같이 처리<br/>foreach ($arXml as $key =&gt; $arNode)<br/>{<br/>	switch ($arNode[&#039;type&#039;])<br/>	{<br/>		case &#039;open&#039;:<br/>			$strNodeKey = $arNode[&#039;tag&#039;];<br/>			$arXmlAssoc[$arNode[&#039;tag&#039;]];<br/>			break;<br/><br/>		case &#039;complete&#039;:<br/>			if(is_array($arNode[&#039;attributes&#039;]))<br/>			{<br/>				$arXmlAssoc[$strNodeKey][$arNode[&#039;tag&#039;]][] = array(&#039;attr&#039; =&gt; $arNode[&#039;attributes&#039;], &#039;value&#039; =&gt; $arNode[&#039;value&#039;]);<br/>			}<br/>			else <br/>			{<br/>				$arXmlAssoc[$strNodeKey][$arNode[&#039;tag&#039;]][] = $arNode[&#039;value&#039;];<br/>			}<br/>			break;<br/><br/>		case &#039;close&#039;:<br/>			$nOpenNodeKey = null;<br/>			break;<br/>	}<br/>}<br/><br/><br/><br/><br/>// Echo<br/>foreach ($arXmlAssoc[&#039;Province&#039;][&#039;Area&#039;] as $arElement)<br/>{<br/>	echo $arElement[&#039;attr&#039;][&#039;code&#039;];<br/>	echo &#039;=&gt;&#039;;<br/>	echo $arElement[&#039;value&#039;];<br/>	echo &#039;&lt;BR&gt;&#039;;<br/>}<br/>?&gt;[/CODE]]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Thu, 27 Aug 2009 15:01:00 +0900</dc:date>
</item>


<item>
<title>XML 파싱(xml2array)</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=16</link>
<description><![CDATA[[U]XML 파싱(xml2array)[/U]<br/><br/>몇가지 xml parser를 찾아 봤는데 딱 마음에 드는것은 없네요.. <br/>아래는 [URL]<A HREF="http://www.bin-co.com/php/scripts/xml2array/" TARGET="_blank"  rel="nofollow">http://www.bin-co.com/php/scripts/xml2array/</A>[/URL] 에서 공개된 xml2array 소스입니다.<br/><br/>[CODE php]&lt;?php <br/>/** <br/>&nbsp;* xml2array() will convert the given XML text to an array in the XML structure. <br/>&nbsp;* Link: <A HREF="http://www.bin-co.com/php/scripts/xml2array/" TARGET="_blank"  rel="nofollow">http://www.bin-co.com/php/scripts/xml2array/</A> <br/>&nbsp;* Arguments : $contents - The XML text <br/>&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag values - this results in a different array structure in the return value. <br/>&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $priority - Can be &#039;tag&#039; or &#039;attribute&#039;. This will change the way the resulting array sturcture. For &#039;tag&#039;, the tags are given more importance. <br/>&nbsp;* Return: The parsed XML in an array form. Use print_r() to see the resulting array structure. <br/>&nbsp;* Examples: $array =&nbsp; xml2array(file_get_contents(&#039;feed.xml&#039;)); <br/>&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $array =&nbsp; xml2array(file_get_contents(&#039;feed.xml&#039;, 1, &#039;attribute&#039;)); <br/>&nbsp;*/ <br/>function xml2array($contents, $get_attributes=1, $priority = &#039;tag&#039;) { <br/>&nbsp; &nbsp; if(!$contents) return array(); <br/><br/>&nbsp; &nbsp; if(!function_exists(&#039;xml_parser_create&#039;)) { <br/>&nbsp; &nbsp; &nbsp; &nbsp; //print &#034;&#039;xml_parser_create()&#039; function not found!&#034;; <br/>&nbsp; &nbsp; &nbsp; &nbsp; return array(); <br/>&nbsp; &nbsp; } <br/><br/>&nbsp; &nbsp; //Get the XML parser of PHP - PHP must have this module for the parser to work <br/>&nbsp; &nbsp; $parser = xml_parser_create(&#039;&#039;); <br/>&nbsp; &nbsp; @xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, &#034;euc-kr&#034;); # <A HREF="http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss" TARGET="_blank"  rel="nofollow">http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss</A> <br/>&nbsp; &nbsp; xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); <br/>&nbsp; &nbsp; xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); <br/>&nbsp; &nbsp; xml_parse_into_struct($parser, trim($contents), $xml_values); <br/>&nbsp; &nbsp; xml_parser_free($parser); <br/><br/>&nbsp; &nbsp; if(!$xml_values) return;//Hmm... <br/><br/>&nbsp; &nbsp; //Initializations <br/>&nbsp; &nbsp; $xml_array = array(); <br/>&nbsp; &nbsp; $parents = array(); <br/>&nbsp; &nbsp; $opened_tags = array(); <br/>&nbsp; &nbsp; $arr = array(); <br/><br/>&nbsp; &nbsp; $current = &$xml_array; //Refference <br/><br/>&nbsp; &nbsp; //Go through the tags. <br/>&nbsp; &nbsp; $repeated_tag_index = array();//Multiple tags with same name will be turned into an array <br/>&nbsp; &nbsp; foreach($xml_values as $data) { <br/>&nbsp; &nbsp; &nbsp; &nbsp; unset($attributes,$value);//Remove existing values, or there will be trouble <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; //This command will extract these variables into the foreach scope <br/>&nbsp; &nbsp; &nbsp; &nbsp; // tag(string), type(string), level(int), attributes(array). <br/>&nbsp; &nbsp; &nbsp; &nbsp; extract($data);//We could use the array by itself, but this cooler. <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; $result = array(); <br/>&nbsp; &nbsp; &nbsp; &nbsp; $attributes_data = array(); <br/>&nbsp; &nbsp; &nbsp; &nbsp;  <br/>&nbsp; &nbsp; &nbsp; &nbsp; if(isset($value)) { <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($priority == &#039;tag&#039;) $result = $value; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else $result[&#039;value&#039;] = $value; //Put the value in a assoc array if we are in the &#039;Attribute&#039; mode <br/>&nbsp; &nbsp; &nbsp; &nbsp; } <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; //Set the attributes too. <br/>&nbsp; &nbsp; &nbsp; &nbsp; if(isset($attributes) and $get_attributes) { <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach($attributes as $attr =&gt; $val) { <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($priority == &#039;tag&#039;) $attributes_data[$attr] = $val; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else $result[&#039;attr&#039;][$attr] = $val; //Set all the attributes in a array called &#039;attr&#039; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br/>&nbsp; &nbsp; &nbsp; &nbsp; } <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; //See tag status and do the needed. <br/>&nbsp; &nbsp; &nbsp; &nbsp; if($type == &#034;open&#034;) {//The starting of the tag &#039;&lt;tag&gt;&#039; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $parent[$level-1] = &$current; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current[$tag] = $result; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($attributes_data) $current[$tag. &#039;_attr&#039;] = $attributes_data; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $repeated_tag_index[$tag.&#039;_&#039;.$level] = 1; <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current = &$current[$tag]; <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else { //There was another element with the same tag name <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(isset($current[$tag][0])) {//If there is a 0th element it is already an array <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current[$tag][$repeated_tag_index[$tag.&#039;_&#039;.$level]] = $result; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $repeated_tag_index[$tag.&#039;_&#039;.$level]++; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {//This section will make the value an array if multiple tags with the same name appear together <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $repeated_tag_index[$tag.&#039;_&#039;.$level] = 2; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(isset($current[$tag.&#039;_attr&#039;])) { //The attribute of the last(0th) tag must be moved as well <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current[$tag][&#039;0_attr&#039;] = $current[$tag.&#039;_attr&#039;]; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unset($current[$tag.&#039;_attr&#039;]); <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $last_item_index = $repeated_tag_index[$tag.&#039;_&#039;.$level]-1; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current = &$current[$tag][$last_item_index]; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; } elseif($type == &#034;complete&#034;) { //Tags that ends in 1 line &#039;&lt;tag /&gt;&#039; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //See if the key is already taken. <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!isset($current[$tag])) { //New Key <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current[$tag] = $result; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $repeated_tag_index[$tag.&#039;_&#039;.$level] = 1; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($priority == &#039;tag&#039; and $attributes_data) $current[$tag. &#039;_attr&#039;] = $attributes_data; <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else { //If taken, put all things inside a list(array) <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array... <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // ...push the new element into that array. <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current[$tag][$repeated_tag_index[$tag.&#039;_&#039;.$level]] = $result; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($priority == &#039;tag&#039; and $get_attributes and $attributes_data) { <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current[$tag][$repeated_tag_index[$tag.&#039;_&#039;.$level] . &#039;_attr&#039;] = $attributes_data; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $repeated_tag_index[$tag.&#039;_&#039;.$level]++; <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else { //If it is not an array... <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $repeated_tag_index[$tag.&#039;_&#039;.$level] = 1; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($priority == &#039;tag&#039; and $get_attributes) { <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(isset($current[$tag.&#039;_attr&#039;])) { //The attribute of the last(0th) tag must be moved as well <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current[$tag][&#039;0_attr&#039;] = $current[$tag.&#039;_attr&#039;]; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unset($current[$tag.&#039;_attr&#039;]); <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($attributes_data) { <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current[$tag][$repeated_tag_index[$tag.&#039;_&#039;.$level] . &#039;_attr&#039;] = $attributes_data; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $repeated_tag_index[$tag.&#039;_&#039;.$level]++; //0 and 1 index is already taken <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; } elseif($type == &#039;close&#039;) { //End of tag &#039;&lt;/tag&gt;&#039; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $current = &$parent[$level-1]; <br/>&nbsp; &nbsp; &nbsp; &nbsp; } <br/>&nbsp; &nbsp; } <br/>&nbsp; &nbsp;  <br/>&nbsp; &nbsp; return($xml_array); <br/>}<br/><br/>?&gt;[/CODE]<br/><br/><br/>[B]추가 : [/B]<br/>괜찮은 소스가 있어서 추가 합니다. 클레스로 되어있네요.<br/>[URL]<A HREF="http://www.phpbuilder.com/snippet/detail.php?id=868&type=snippet" TARGET="_blank"  rel="nofollow">http://www.phpbuilder.com/snippet/detail.php?id=868&type=snippet</A>[/URL]<br/><br/>[CODE php]&lt;?php<br/>/**<br/>*	=============================================================<br/>*	The simple class for parse XML content to&nbsp;  PHP array.<br/>*	Version&nbsp; &nbsp;  :&nbsp;  1.0.1<br/>*	Last Upd&nbsp; &nbsp; :&nbsp;  Thu Jan 30 14:51:18 GMT 2003<br/>*	Created By&nbsp; :&nbsp;  Heiko&nbsp;  Mundle [<a href="mailto:hmundle1@gmx.net"  rel="nofollow">hmundle1@gmx.net</a>]<br/>*	New Features:&nbsp;  reads all attributes of a xml tag<br/>*					doesn&#039;t overwrite tags with same tag name (and same tag attribute)<br/>*<br/>*	The simple class for parse XML content to&nbsp;  PHP array.<br/>*	Version&nbsp; &nbsp;  :&nbsp;  1.0<br/>*	Last Upd&nbsp; &nbsp; :&nbsp;  Thu Oct 24 11:51:18 GMT 2002<br/>*	Created By&nbsp; :&nbsp;  Phairote Charoen [<a href="mailto:phairotec@hotmail.com"  rel="nofollow">phairotec@hotmail.com</a>]<br/>*	=============================================================<br/>*	This XML content must&nbsp;  specific some&nbsp;  attribute&nbsp;  for the key of record.<br/>*	&lt;root&gt;<br/>*		&lt;item&nbsp; &nbsp; id=&#034;1&#034; class=&#034;myclass&#034;&gt;<br/>*			&lt;name&gt;xxxx&lt;/name&gt;<br/>*			&lt;price&gt;100&lt;/price&gt;<br/>*		&lt;/item&gt;<br/>*		more content<br/>*	&lt;/root&gt;<br/>*<br/>*	Result :<br/>*Array<br/>*(<br/>* [0] =&gt; Array<br/>*&nbsp;  (<br/>*&nbsp; &nbsp;  [name] =&gt; root<br/>*&nbsp; &nbsp;  [attr] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp;  )<br/>*&nbsp; &nbsp;  [cont] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp; &nbsp;  [0] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [name] =&gt; item<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [attr] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [id] =&gt; 1<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [class] =&gt; myclass<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [cont] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [0] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [name] =&gt; name<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [attr] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [cont] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [0] =&gt; xxxx<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [1] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [name] =&gt; price<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [attr] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [cont] =&gt; Array<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  [0] =&gt; 100<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br/>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br/>*&nbsp; &nbsp; &nbsp; &nbsp;  [1] =&gt; more content<br/>*&nbsp; &nbsp; &nbsp;  )<br/>*&nbsp;  )<br/>*)<br/>*<br/>*/<br/>define(WRITE_FLAG_NOT_NULL, 1);<br/>define(WRITE_FLAG_NULL, 2);<br/>define(WRITE_FLAG_EMPTY_ARRAY, 4);<br/><br/>class&nbsp;  Xml2Array<br/>{<br/>	/**<br/>	*&nbsp;  The XML file name( can be&nbsp;  also real&nbsp;  path and web url ).<br/>	*/<br/>	var $xmlFile;<br/>	/**<br/>	*&nbsp;  The array&nbsp;  result from this class.<br/>	*/<br/>	var $arrResult&nbsp; =&nbsp;  array();<br/>	/**<br/>	*&nbsp;  The key stack, I keep&nbsp;  each tag name&nbsp;  of each level&nbsp;  to stack array.<br/>	*/<br/>	var $keyStack&nbsp;  =&nbsp;  array();<br/>	/**<br/>	*&nbsp;  Deep of stack&nbsp;  array.<br/>	*/<br/>	var $stackIndex =&nbsp;  0;<br/><br/>	/**<br/>	*&nbsp;  The XML Parser ..&nbsp; <br/>	*/<br/>	var $parser;<br/><br/>	/**<br/>	*&nbsp;  The constructor.<br/>	*&nbsp;  @xmlFile (string)&nbsp;  -&nbsp;  XML source file name<br/>	*/<br/>	function Xml2Array($xmlFile)<br/>	{<br/>		$this-&gt;xmlFile&nbsp;  =&nbsp;  $xmlFile;<br/>		$this-&gt;parser&nbsp; &nbsp; =&nbsp;  xml_parser_create();<br/>		xml_set_object($this-&gt;parser,&nbsp; &nbsp; &$this);<br/>		xml_parser_set_option($this-&gt;parser, XML_OPTION_CASE_FOLDING,&nbsp; &nbsp; false);<br/>		xml_parser_set_option($this-&gt;parser, XML_OPTION_SKIP_WHITE,true);<br/>		xml_set_element_handler($this-&gt;parser, &#034;startElement&#034;, &#034;endElement&#034;);<br/>		xml_set_character_data_handler($this-&gt;parser,&nbsp; &nbsp; &#034;characterData&#034;);<br/>	}<br/><br/>	/**<br/>	*&nbsp;  start&nbsp;  element handler<br/>	*/<br/>	function startElement($parser, $name,&nbsp;  $atts)<br/>	{<br/>		$name&nbsp;  =&nbsp;  trim($name);<br/><br/>		$txt = &#034;\$arr&nbsp;  =&nbsp;  &#034;&nbsp;  .&nbsp;  $this-&gt;getArrayName($this-&gt;stackIndex) . &#034;;&#034;;<br/>		eval($txt);<br/><br/>		$this-&gt;keyStack[$this-&gt;stackIndex] = count($arr);<br/>		$this-&gt;stackIndex++;<br/>		$this-&gt;writeData(&#034;&#034;, WRITE_FLAG_EMPTY_ARRAY);<br/><br/>		if(!empty($name))<br/>		{<br/>			// using the element name&nbsp;  to array key..<br/>			$this-&gt;keyStack[$this-&gt;stackIndex] = &#034;&#039;name&#039;&#034;;<br/>			$this-&gt;stackIndex++;<br/>			$this-&gt;writeData($name,&nbsp; WRITE_FLAG_NULL);<br/>			$this-&gt;stackIndex--;<br/><br/>			$this-&gt;keyStack[$this-&gt;stackIndex] = &#034;&#039;attr&#039;&#034;;<br/>			$this-&gt;stackIndex++;<br/>			if(!empty($atts))<br/>			{<br/>				// using the attributes to array key..<br/>				foreach($atts&nbsp;  as $attKey =&gt;&nbsp; &nbsp; $attVal)<br/>				{<br/>					$this-&gt;keyStack[$this-&gt;stackIndex] = &#034;&#039;&#034;.$attKey.&#034;&#039;&#034;;<br/>					$this-&gt;stackIndex++;<br/>					$this-&gt;writeData($attVal,&nbsp; &nbsp; WRITE_FLAG_NULL);<br/>					$this-&gt;stackIndex--;<br/>				}<br/>			}<br/>			else<br/>			{<br/>				$this-&gt;writeData(&#034;&#034;, WRITE_FLAG_EMPTY_ARRAY);<br/>			}<br/>			$this-&gt;stackIndex--;<br/><br/>			$this-&gt;keyStack[$this-&gt;stackIndex] = &#034;&#039;cont&#039;&#034;;<br/>			$this-&gt;stackIndex++;<br/>		}<br/>	}<br/><br/>	/**<br/>	*&nbsp;  end element handler<br/>	*/<br/>	function endElement($parser, $name)<br/>	{<br/>		$this-&gt;stackIndex-=2;<br/>	}<br/>&nbsp; &nbsp;  <br/>	/**<br/>	*&nbsp;  none tag element handler<br/>	*/<br/>	function characterData($parser, $data)<br/>	{<br/>		$data&nbsp;  =&nbsp;  trim($data);<br/>		if(!empty($data))<br/>		{<br/>			$txt = &#034;\$arr&nbsp;  =&nbsp;  &#034;&nbsp;  .&nbsp;  $this-&gt;getArrayName($this-&gt;stackIndex) . &#034;;&#034;;<br/>			eval($txt);<br/><br/>			$this-&gt;keyStack[$this-&gt;stackIndex] = count($arr);<br/>			$this-&gt;stackIndex++;<br/>			$this-&gt;writeData($data,&nbsp; WRITE_FLAG_NOT_NULL);<br/>			$this-&gt;stackIndex--;<br/>		}<br/>	}<br/><br/>	/**<br/>	*&nbsp;  write&nbsp;  data in array<br/>	*/<br/>	function writeData($data,&nbsp;  $flag)<br/>	{<br/>		$data&nbsp;  =&nbsp;  trim($data);<br/>		$dataStr = &#034;\&#034;&#034; .&nbsp;  $data&nbsp;  .&nbsp;  &#034;\&#034;&#034;;<br/>		switch( $flag&nbsp;  )<br/>		{<br/>			case WRITE_FLAG_NOT_NULL:<br/>			default:<br/>				// stop if there isn&#039;t any data<br/>				if(empty($data))<br/>					break;<br/>			case WRITE_FLAG_EMPTY_ARRAY:<br/>				// overwrite default dataStr<br/>				if(empty($data))<br/>					$dataStr = &#034;array()&#034;;<br/>			case WRITE_FLAG_NULL:<br/>				$txt = $this-&gt;getArrayName($this-&gt;stackIndex).&#034;&nbsp;  =&nbsp;  &#034;.$dataStr.&#034;;&#034;;<br/>				// assign&nbsp;  value&nbsp;  to the result&nbsp;  array&nbsp;  ..<br/>				eval($txt);<br/><br/>			break;<br/>		}<br/>	}<br/><br/>	/**<br/>	*&nbsp;  get name of array<br/>	*/<br/>	function getArrayName($depth)<br/>	{<br/>		if($depth)<br/>		{<br/>			for($i=0;&nbsp;  $i&lt;$depth; $i++)<br/>			{<br/>				$key .= $this-&gt;keyStack[$i].&#034;|&#034;;<br/>			}<br/>			$key = preg_replace(&#034;/\|$/&#034;, &#034;]&#034;,&nbsp;  $key);<br/>			$key = preg_replace(&#034;/\|/&#034;, &#034;][&#034;,&nbsp;  $key);<br/>			return &#034;\$this-&gt;arrResult[&#034;.$key;<br/>		}<br/>		else<br/>		{<br/>			return &#034;\$this-&gt;arrResult&#034;;<br/>		}<br/>	}<br/><br/>	/**<br/>	*&nbsp;  parsing ..<br/>	*/<br/>	function parse()<br/>	{<br/>		if (!($fp&nbsp;  =&nbsp;  fopen($this-&gt;xmlFile,&nbsp; &nbsp; &#034;r&#034;)))<br/>		{<br/>			die(&#034;Could not open XML input!&#034;);<br/>		}<br/><br/>		while&nbsp;  ($data = fread($fp, 4096))<br/>		{<br/>			if (!xml_parse($this-&gt;parser,&nbsp; &nbsp; $data, feof($fp)))<br/>			{<br/>				die(sprintf(&#034;XML error: %s at&nbsp;  line %d&#034;,&nbsp;  xml_error_string(xml_get_error_code($this-&gt;parser)),xml_get_current_line_number($this-&gt;parser)));<br/>			}<br/>		}<br/>		fclose($fp);<br/>	}<br/><br/>	/**<br/>	*&nbsp;  @return the result array<br/>	*/<br/>	function getResult()<br/>	{<br/>		return $this-&gt;arrResult;<br/>	}<br/><br/>	/**<br/>	*&nbsp;  free the XML parser result ..&nbsp; <br/>	*/<br/>	function freeResult()<br/>	{<br/>		xml_parser_free($this-&gt;parser);<br/>	}<br/><br/>}&nbsp;  // end class&nbsp;  <br/><br/>?&gt;[/CODE]<br/><br/>[CODE php]&lt;?php<br/>	// Testing the clsXml2Array class.<br/>	$xmlFile&nbsp; &nbsp; = &#034;test.xml&#034;;<br/>	$r = new clsXml2Array($xmlFile);<br/>	$r-&gt;parse();<br/>	$arrResult = $r-&gt;getResult();<br/>	$r-&gt;freeResult();<br/><br/>	echo &#034;&lt;PRE&gt;&#034;;<br/>	print_r($arrResult);<br/>	echo &#034;&lt;/PRE&gt;&#034;;<br/>?&gt;[/CODE]]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Thu, 27 Aug 2009 14:54:53 +0900</dc:date>
</item>


<item>
<title>ajax의 xml을 javascript 객체형식으로 자동 변환</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=15</link>
<description><![CDATA[[U]ajax의 xml을 javascript 객체형식으로 자동 변환[/U]<br/><br/>[CODE js]/** <br/>* Author	: MC 심새 (<a href="mailto:ganer9r@naver.com"  rel="nofollow">ganer9r@naver.com</a>) <br/>* Make Date : 2006-09-22<br/>* comment	: ajax의 xml을 javascript 객체형식으로 자동 변환<br/>**/<br/><br/>/* Ajax 사용을 위한 기본 콤포넌트 Start */<br/>function AjaxDataControl(){<br/>	this.xmlHttp			= null;<br/><br/>	this.getHttpRequest		= function(URL, object){<br/>		var xmlHttp		= this.xmlHttp;<br/>		var xmlData		= null;<br/>		// FF일 경우 window.XMLHttpRequest 객체가 존재한다.<br/>		if(!xmlHttp){<br/>			if(window.XMLHttpRequest) { <br/>				xmlHttp	= new XMLHttpRequest();<br/>			} else { <br/>				xmlHttp	= new ActiveXObject(&#034;Microsoft.XMLHTTP&#034;); <br/>			} <br/>			this.xmlHttp	= xmlHttp;<br/>		}<br/><br/>		xmlHttp.open(&#039;GET&#039;, URL, true); <br/>		xmlHttp.onreadystatechange = function() { <br/>			// readyState 가 4 고 status 가 200 일 경우 올바르게 가져옴 <br/>			if(xmlHttp.readyState==4 && xmlHttp.status == 200 && xmlHttp.statusText==&#039;OK&#039;) {<br/>				var xmlData		= xmlHttp.responseXML;<br/>				object.setXmlData(xmlData);<br/><br/>			} <br/>		} <br/><br/>		xmlHttp.send(&#039;&#039;);<br/><br/>	}<br/><br/>	this.getXmlRootNode		= function(nodes, rootName){<br/>		var rootNode	= nodes.getElementsByTagName(rootName);<br/><br/>		return rootNode;<br/>	}<br/>}<br/>/* Ajax 사용을 위한 기본 콤포넌트 End */<br/><br/><br/><br/><br/>/* Ajax에서 리턴받은 XML NODE를 JAVASCRIPT OBJECT 형식으로 변환 Start */<br/>function AjaxObject(){<br/>	this.ac				= null;<br/>	this.xmlData		= null;<br/>	this.rootName		= null;<br/>	this.functionName	= null;<br/>	this.arguments		= new Array();<br/><br/>	this.inArray			= function(array, value){<br/>		var result	= false;<br/><br/>		for(var i=0; i &lt; array.length; i++){<br/>			if(array[i] == value){<br/>				result	= true;<br/>				break;<br/>			}<br/>		}<br/><br/>		return result;<br/>	}<br/><br/><br/>	this.getHttpRequest		= function(Url, functionName){<br/>		if(this.ac == null){<br/>			this.ac			= new AjaxDataControl();<br/>		}<br/>		this.functionName	= functionName;<br/><br/>		for(var i=2; i &lt;arguments.length; i++){<br/>			this.arguments.push(arguments[i]);<br/>		}<br/><br/>		this.ac.getHttpRequest(Url, this);<br/>	}<br/><br/><br/><br/><br/>	this.setMakeObject		= function(nodeData){<br/>		var resultObject	= new Object;<br/>		resultObject.length	= 0;<br/><br/>		if(nodeData.hasChildNodes() ){<br/>			var nodeChilds		= nodeData.childNodes;<br/>			var nodeNameList	= new Array();<br/>			var isNodeChilds	= false;<br/><br/>			for(var i = 0; i&lt;nodeChilds.length;i++){<br/><br/>				if(nodeChilds[i].nodeType == &#039;1&#039;){<br/><br/>					var returnObj	= this.setMakeObject(nodeChilds[i] );<br/><br/>					if( typeof(returnObj) == &#034;string&#034;){<br/>						resultObject[ nodeChilds[i].nodeName ]	= this.setMakeObject(nodeChilds[i] );<br/>						resultObject.length	+= 1;<br/>					}else{<br/><br/>						if(resultObject[ nodeChilds[i].nodeName ]){<br/>							resultObject[ nodeChilds[i].nodeName ].push( returnObj );<br/>						}else{<br/>							resultObject[ nodeChilds[i].nodeName ]	= new Array();<br/>							resultObject[ nodeChilds[i].nodeName ].push( returnObj );<br/><br/>							resultObject.length	+= 1;<br/>						}<br/>					}<br/>					isNodeChilds	= true;<br/><br/>				}<br/>			}<br/><br/>			if(!isNodeChilds){<br/>				resultObject	= nodeChilds[0].nodeValue;<br/>			}else{<br/><br/>			}<br/>		}<br/><br/>		return resultObject;<br/>	}<br/><br/><br/>	this.setMakeControl		= function(){<br/>		if(this.xmlData != null){<br/>			var rootNode	= this.ac.getXmlRootNode(this.xmlData, this.rootName);<br/>			var list		= this.setMakeObject(rootNode[0]);<br/>			var	args		= &#034;&#034;;<br/><br/>			for(var i=0; i&lt;this.arguments.length; i++){<br/>				args	+= &#034;, this.arguments[&#034;+i+&#034;]&#034;;<br/>			}<br/><br/>			eval( this.functionName+&#034;(list &#034;+args+&#034;)&#034; );<br/>		}<br/>	}<br/><br/>	this.setXmlData			= function(data){<br/>		this.xmlData		= data;<br/>		this.rootName		= data.documentElement.nodeName;<br/><br/>		this.setMakeControl();<br/>	}<br/><br/>}<br/>/* Ajax에서 리턴받은 XML NODE를 JAVASCRIPT OBJECT 형식으로 변환 End */<br/><br/><br/>/* 사용법 Start*/<br/>//	var aObj	= new AjaxObject;&nbsp; &nbsp; &nbsp; &nbsp;  // AjaxList 선언<br/>//	aObj.getHttpRequest(&#034;test.xml&#034;, &#034;displayBoardList&#034;, [인자값]);		//참조Url, 리턴 함수명<br/>//	리턴 함수에는 obj를 받을 인자 필수!!!<br/>//<br/>//	리턴 함수에, 변환된 데이터 이외의 인자를 받고 싶으면 계속 이어서 쓰세요<br/>//	예] aObj.getHttpRequest(&#034;test.xml&#034;, &#034;displayBoardList&#034;, &#034;test&#034;, 1, &#034;all&#034;, ... );<br/>/* 사용법 End */[/CODE]]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Tue, 07 Jul 2009 13:41:01 +0900</dc:date>
</item>


<item>
<title>Google Maps API</title>
<link>https://go3.co.kr/mintbbs/bbs/board.php?bo_table=ajax&amp;amp;wr_id=14</link>
<description><![CDATA[[U]Google Maps API[/U]<br/><br/>본 내용은 <A HREF="http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/Google/Service/GoogleMapAPI" TARGET="_blank"  rel="nofollow">http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/Google/Service/GoogleMapAPI</A> 을 정리한 것입니다.<br/><br/>Google Map을 사용하기 위해서는 Map Key를 발급 받아야 합니다.<br/>Key는 [URL=http://www.google.com/apis/maps]<A HREF="http://www.google.com/apis/maps" TARGET="_blank"  rel="nofollow">http://www.google.com/apis/maps</A>[/URL] 에서 받으실 수 있습니다.<br/><br/>Google Map은 우선 google Maps Javascript를 명시해야 합니다. 이때 발급 받은 Map Key를 적으시면 됩니다.<br/>[CODE html]&lt;script src=&#034;<A HREF="http://maps.google.co.kr/maps?file=api&v=2&key=abcdefg&#034;" TARGET="_blank"  rel="nofollow">http://maps.google.co.kr/maps?file=api&v=2&key=abcdefg&#034;</A> type=&#034;text/javascript&#034;&gt;&lt;/script&gt;[/CODE]<br/><br/><br/>[B]1. 기본[/B]<br/>구글 Map을 불러오기 위한 가장 기본이 되는코드다. 서울주변을 보여준다.<br/>[CODE js]var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>map.setCenter(new GLatLng(36.615527631349245, 127.353515625), 4);[/CODE]<br/><br/>setCenter을 이용해서 보여줄 위치를 지정한다. 첫번째 인자는 좌표를 지정하기 위해서 사용한다. 두번째 인자는 지도의 해상도를 결정하기 위해서 사용한다. 숫자가 클 수록 더 자세한 결과를 보여준다. <br/><br/>예제 : simple.html<br/><br/>구글 맵은 [COLOR=blue]맵, 위성, 합성[/COLOR]의 3가지 모드를 제공된다. [COLOR=blue]setMapType[/COLOR]메서드를 이용하면 모드를 변경할 수 있다. 따로 지정하지 않을 경우 [COLOR=blue]맵[/COLOR]모드로 실행된다.<br/>[LIST]<br/>[*]setMapType(G_SATELLITE_TYPE) : 위성모드<br/>[*]setMapType(G_HYBRID_TYPE) : 합성모드<br/>[/LIST:u]<br/><br/><br/>[B]2. Map에서의 이동[/B]<br/>다음은 맵에서 중심을 이동하는 예제다. [COLOR=blue]panTo[/COLOR] 메서드를 이용하면 해당 중심으로 지도를 부드럽게 이동시킨다. 길찾기등의 기능구현에 유용하게 사용할 수 있을 거 같다. <br/>[CODE js]var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>map.setCenter(new GLatLng(36.615527631349245, 127.353515625), 4);<br/>window.setTimeout(function() {<br/>&nbsp; &nbsp; map.panTo(new GLatLng(42.615527631349245, 128.353515625));<br/>}, 2000);[/CODE]<br/><br/>예제 : animate.html<br/><br/><br/>[B]3. Control 버튼 추가하기[/B]<br/>맵을 확대기시커나 모드를 바꾸거나 하는등의 제어를 위한 컨트롤 버튼을 추가한다.<br/>[CODE js]var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>map.addControl(new GSmallMapControl());<br/>map.addControl(new GMapTypeControl());<br/>map.setCenter(new GLatLng(36.615527631349245, 127.353515625), 4);[/CODE]<br/><br/>예제 : control.html<br/><br/><br/>[B]4. Event Listener[/B]<br/>event listener는 [COLOR=blue]GEvent.addListener[/COLOR]를 호출해서 생성한다. 이것은 맵에서 발생하는 이벤트를 알려준다. 아래의 예제에서 맵을 움직일 경우 변경된 좌표가 출력되는걸 확인할 수 있을 것이다.<br/>[CODE js]var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>GEvent.addListener(map, &#034;moveend&#034;, function() {<br/>	var center = map.getCenter();<br/>	document.getElementById(&#034;message&#034;).innerHTML = center.toString();<br/>});<br/>map.addControl(new GSmallMapControl());<br/>map.addControl(new GMapTypeControl());<br/>map.setCenter(new GLatLng(36.615527631349245, 127.353515625), 4);[/CODE]<br/><br/>예제 : event.html<br/><br/><br/>[B]5. 정보창 열기[/B]<br/>[COLOR=blue]openInfoWindow[/COLOR]를 이용하면 원하는 지역에 [COLOR=blue]DOM[/COLOR]정보를 출력할 수 있다. 다음은 맵중앙에 &#034;저는 여기에 살아요&#034;메시지를 출력하는 코드다.<br/>[CODE js]map.setCenter(new GLatLng(36.615527631349245, 127.353515625), 4);<br/>map.openInfoWindow(map.getCenter(), document.createTextNode(&#034;저는 여기에 살아요&#034;));[/CODE]<br/><br/>예제 : infowindow.html<br/><br/><br/>[B]6. 맵에 표시하기[/B]<br/>이번 예제는 overlay기능을 이용해서 지도에 랜덤하게 10개의 마크를 표시한다. 마크에 사용되는 이미지는 기본 이미지이며, 사용자 정의 아이콘을 만들 수도 있다. 일본의 동경시를 기준으로 예제를 만들었다.<br/>[CODE js]map.setCenter(new GLatLng(35.76873101871279, 139.5413875579834), 12);<br/><br/>var bounds = map.getBounds();<br/>var southWest = bounds.getSouthWest();<br/>var northEast = bounds.getNorthEast();<br/>var lngSpan = northEast.lng() - southWest.lng();<br/>var latSpan = northEast.lat() - southWest.lat();<br/><br/>// 랜덤 포인트를 만들고 각각의 포인트에 마킹을 한다.<br/>for (var i = 0; i &lt; 10; i++) {<br/>	var point = new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random());<br/>	map.addOverlay(new GMarker(point));<br/>}<br/>// 랜덤 포인트를 만들고 이것을 연결한다. <br/>var points = [];<br/>for (var i = 0; i &lt; 5; i++) {<br/>	points.push(new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random()));<br/>}<br/>points.sort(function(p1, p2) {<br/>	return p1.lng() - p2.lng();<br/>});<br/>map.addOverlay(new GPolyline(points));[/CODE]<br/><br/>예제 : overlay.html<br/><br/><br/>[B]7. 클릭 이벤트 제어[/B]<br/>맵에 클릭을 할경우 이벤트를 받아서 마킹을 하는 예제다. 앞서 배웠던 [COLOR=blue]addListenr[/COLOR]메서드를 이용해서 click 이벤트를 기다리고, 클릭이 발생하면 [COLOR=blue]addOverlay[/COLOR]메서드를 이용해서 마킹을 한다.<br/>[CODE js]map.addControl(new GSmallMapControl());<br/>map.addControl(new GMapTypeControl());<br/>map.setCenter(new GLatLng(35.76873101871279, 139.5413875579834), 12);<br/>GEvent.addListener(map, &#034;click&#034;, function(marker, point) {<br/>	if (marker) {<br/>		map.removeOverlay(marker);<br/>	} else {<br/>		map.addOverlay(new GMarker(point));<br/>	}<br/>});[/CODE]<br/><br/>예제 : click.html<br/><br/><br/>[B]8. 마커에 정보 창 출력하기[/B] <br/>10개의 마커를 랜덤하게 표시하고, 마커를 클릭하면 클릭이벤트에 대한 Listener가 작동하도록 해보자. Listener 함수는 [COLOR=blue]openInfoWindowHtml[/COLOR]메서드를 이용해서 정보창을 출력한다.<br/>[CODE js]var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>map.addControl(new GSmallMapControl());<br/>map.addControl(new GMapTypeControl());<br/>map.setCenter(new GLatLng(35.76873101871279, 139.5413875579834), 12);<br/>function createMarker(point, number) {<br/>	var marker = new GMarker(point);<br/>	GEvent.addListener(marker, &#034;click&#034;, function() {<br/>		marker.openInfoWindowHtml(&#034;Marker #&lt;b&gt;&#034; + number + &#034;&lt;/b&gt;&#034;);<br/>	});<br/>	return marker;<br/>}<br/><br/>var bounds = map.getBounds();<br/>var southWest = bounds.getSouthWest();<br/>var northEast = bounds.getNorthEast();<br/>var lngSpan = northEast.lng() - southWest.lng();<br/>var latSpan = northEast.lat() - southWest.lat();<br/>for (var i = 0; i &lt; 10; i++) {<br/>	var point = new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random());<br/>	map.addOverlay(createMarker(point, i + 1));<br/>}[/CODE]<br/><br/>예제 : markerinfo.html<br/><br/><br/>[B]9. 탭 사용하기[/B]<br/>[COLOR=blue]openInfoWindowsTabs[/COLOR]메서드 와 [COLOR=blue]GInfoWindowTab[/COLOR]클래스를 이용하면, 탭을 제어할 수 있다. 다음 예제는 마커를 클릭하면 2개의 tab을 가진 Info Windows를 띄운다.<br/>var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>map.addControl(new GSmallMapControl());<br/>map.addControl(new GMapTypeControl());<br/>map.setCenter(new GLatLng(35.76873101871279, 139.5413875579834), 12);<br/><br/>var infoTabs = [<br/>	new GInfoWindowTab(&#034;탭1&#034;, &#034;안녕하세요.&lt;br&gt;&lt;img src=http://www.joinc.co.kr/images/joinc.png border=0&gt;&#034;),<br/>	new GInfoWindowTab(&#034;탭2&#034;, &#034;반갑습니다.&#034;)<br/>];<br/><br/>var marker = new GMarker(map.getCenter());<br/>GEvent.addListener(marker, &#034;click&#034;, function() {<br/>	marker.openInfoWindowTabsHtml(infoTabs);<br/>});<br/>map.addOverlay(marker);<br/>marker.openInfoWindowTabsHtml(infoTabs);<br/><br/>예제 : tab.html<br/><br/>[B]10. 사용자 정의 아이콘 사용하기[/B]<br/>사용자 정의 아이콘을 사용하는 예제다. 아이콘은 구글에서 제공하는 [COLOR=blue]mini marker[/COLOR]이미지들을 사용하기로 했다. 완전한 사용자 정의 아이콘을 만들기 위해서는 원본이미지와 함께 [COLOR=blue]그림자 이미지[/COLOR]가 쌍으로 준비되어야 한다.<br/>[CODE js]var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>map.addControl(new GSmallMapControl());<br/>map.addControl(new GMapTypeControl());<br/>map.setCenter(new GLatLng(35.76873101871279, 139.5413875579834), 12);<br/><br/>var icon = new GIcon();<br/>icon.image = &#034;<A HREF="http://labs.google.com/ridefinder/images/mm_20_red.png&#034;;" TARGET="_blank"  rel="nofollow">http://labs.google.com/ridefinder/images/mm_20_red.png&#034;;</A><br/>icon.shadow = &#034;<A HREF="http://labs.google.com/ridefinder/images/mm_20_shadow.png&#034;;" TARGET="_blank"  rel="nofollow">http://labs.google.com/ridefinder/images/mm_20_shadow.png&#034;;</A><br/>icon.iconSize = new GSize(12, 20);<br/>icon.shadowSize = new GSize(22, 20);<br/>icon.iconAnchor = new GPoint(6, 20);<br/>icon.infoWindowAnchor = new GPoint(5, 1);<br/><br/>// 10개의 랜덤위치를 찾아서 marking한다.<br/>var bounds = map.getBounds();<br/>var southWest = bounds.getSouthWest();<br/>var northEast = bounds.getNorthEast();<br/>var lngSpan = northEast.lng() - southWest.lng();<br/>var latSpan = northEast.lat() - southWest.lat();<br/>for (var i = 0; i &lt; 10; i++) {<br/>	var point = new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random());<br/>	map.addOverlay(new GMarker(point, icon));<br/>}[/CODE]<br/><br/><br/>예제 : icon.html<br/><br/><br/>[B]11. 아이콘 클래스 사용하기[/B]<br/>지도서비스를 하게 된다면, 여러개의 아이콘들이 사용될 것이다. [COLOR=blue]GIcon[/COLOR]클래스를 이용하면 아이콘을 쉽게 관리할 수 있다.<br/>[CODE js]var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>map.addControl(new GSmallMapControl());<br/>map.addControl(new GMapTypeControl());<br/>map.setCenter(new GLatLng(37.4419, -122.1419), 13);<br/><br/>// 아이콘에서 사용할 이미지/그림자 이미지, Info Windows등 객체의 <br/>// 속성을 결정한다.<br/>var baseIcon = new GIcon();<br/>baseIcon.shadow = &#034;<A HREF="http://www.google.com/mapfiles/shadow50.png&#034;;" TARGET="_blank"  rel="nofollow">http://www.google.com/mapfiles/shadow50.png&#034;;</A><br/>baseIcon.iconSize = new GSize(20, 34);<br/>baseIcon.shadowSize = new GSize(37, 34);<br/>baseIcon.iconAnchor = new GPoint(9, 34);<br/>baseIcon.infoWindowAnchor = new GPoint(9, 2);<br/>baseIcon.infoShadowAnchor = new GPoint(18, 25);<br/><br/>function createMarker(point, index) {<br/>	// Create a lettered icon for this point using our icon class<br/>	var letter = String.fromCharCode(&#034;A&#034;.charCodeAt(0) + index);<br/>	var icon = new GIcon(baseIcon);<br/>	icon.image = &#034;<A HREF="http://www.google.com/mapfiles/marker&#034;" TARGET="_blank"  rel="nofollow">http://www.google.com/mapfiles/marker&#034;</A> + letter + &#034;.png&#034;;<br/>	var marker = new GMarker(point, icon);<br/><br/>	GEvent.addListener(marker, &#034;click&#034;, function() {<br/>		marker.openInfoWindowHtml(&#034;지역 &lt;b&gt;&#034; + letter + &#034;&lt;/b&gt;&#034;);<br/>	});<br/>	return marker;<br/>}<br/><br/>var bounds = map.getBounds();<br/>var southWest = bounds.getSouthWest();<br/>var northEast = bounds.getNorthEast();<br/>var lngSpan = northEast.lng() - southWest.lng();<br/>var latSpan = northEast.lat() - southWest.lat();<br/>for (var i = 0; i &lt; 10; i++) {<br/>	var point = new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random());<br/>	map.addOverlay(createMarker(point, i));<br/>}[/CODE]<br/><br/>예제 : iconclass.html<br/><br/><br/>[B]12. 마커 드래그[/B]<br/>마커는 클릭, 다른장소로의 드래그 등이 가능한 상호작용하는 객체다. 이 예제는 맵에서 마커를 클릭하고 드래그하는 이벤트를 처리하는 방법을 알려준다. 드래그는 [COLOR=blue]click, dragstart, drag, dragend[/COLOR]의 4가지 타입의 이벤트를 발생한다.<br/>[CODE js]var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>var center = new GLatLng(37.51025350131836, 127.06023216247559);<br/>map.setCenter(center, 16);<br/>map.setMapType(G_SATELLITE_MAP);<br/><br/>var marker = new GMarker(center, {draggable: true});<br/><br/>GEvent.addListener(marker, &#034;dragstart&#034;, function() {<br/>	map.closeInfoWindow();<br/>});<br/><br/>GEvent.addListener(marker, &#034;dragend&#034;, function() {<br/>	map.openInfoWindowHtml(&#034;여기를 약속장소로...&#034;); <br/>});<br/><br/>map.addOverlay(marker);[/CODE]<br/><br/>예제 : drag.html<br/><br/><br/>[B]13. SideBar를 통한 맵 링크[/B]<br/>[URL=http://maps.google.co.kr/]Google Map[/URL]에서 검색을 해보면 지도 옆에 SideBar를 통해서 맵을 제어하는 걸 볼수 있다. 여기에서는 SideBar를 이용해서 map을 제어하는 방법에 대해서 알아보겠다. <br/>[CODE js]// 이 변수에 side bar에 이벤트가 발생했을 때 출력할 HTML코드가 저장된다.<br/>var side_bar_html = &#034;&#034;;<br/><br/>// side bar에는 여러개의 마커에 대한 HTML요소가 사용될 수 있으므로<br/>// 배열로 정의 된다.<br/>var gmarkers = [];<br/>var htmls = [];<br/>var i = 0;<br/>/*<br/>var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>var center = new GLatLng(37.51030456483467, 127.05190658569336);<br/>map.addControl(new GSmallMapControl());<br/>map.addControl(new GMapTypeControl());<br/>map.setCenter(center, 14);<br/>*/<br/><br/>function createMarker(point, name, html) {<br/>	var marker = new GMarker(point);<br/>	GEvent.addListener(marker, &#034;click&#034;, function() {<br/>		marker.openInfoWindowHtml(html);<br/>	});<br/>	gmarkers[i] = marker;<br/>	htmls[i] = html;<br/>	side_bar_html += &#039;&lt;a href=&#034;javascript:myclick(&#039; + i + &#039;)&#034;&gt;&#039; + name + &#039;&lt;/a&gt;&lt;br&gt;&#039;;<br/>	i++;<br/>	return marker;<br/>}<br/><br/>function myclick(i) {<br/>	gmarkers[i].openInfoWindowHtml(htmls[i]);<br/>}<br/>var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>map.addControl(new GLargeMapControl());<br/>map.addControl(new GMapTypeControl());<br/>map.setCenter(new GLatLng(37.51030456483467, 127.05190658569336),14);<br/>map.setMapType(G_SATELLITE_MAP);<br/><br/>// 테스트에 사용할 point를 만들자.<br/>var point = new GLatLng(37.508500299402435, 127.06263542175293);<br/>var marker = createMarker(point, &#034;반디엔 루인스&#034;, &#034;제가 애용하는 서점 입니다&#034;);<br/>map.addOverlay(marker);<br/><br/>var point = new GLatLng(37.50209991181568, 127.03652143478394);<br/>var marker = createMarker(point, &#034;시티문고&#034;, &#034;가끔 강남에 갈일이 있으면 시간을 때우는 장소로..&#034;);<br/>map.addOverlay(marker);<br/><br/>var point = new GLatLng(37.517802011991854, 127.0405125617981);<br/>var marker = createMarker(point, &#034;로터리 오락실&#034;, &#034;드럼메니아 V2때문에 갑니다&#034;);<br/>map.addOverlay(marker);<br/><br/>var point = new GLatLng(37.5056235973398, 127.0512306690216);<br/>var marker = createMarker(point, &#034;onnet&#034;, &#034;제가 다니는 회사지요&#034;);<br/>map.addOverlay(marker);<br/><br/>// &lt;div&gt; side_bar에 side_bar_html 문서를 배치한다. <br/>document.getElementById(&#034;side_bar&#034;).innerHTML = side_bar_html;[/CODE]<br/><br/>예제 : sidebar.html<br/><br/><br/>[B]14. XML과 비동기 HTTP를 이용한 지도 생성[/B]<br/>이번 예제는 경도/위도와 지역정보를 포함한 [COLOR=blue]async_data.xml[/COLOR]을 다운로드 받아서, 지도에 마커를 표시한다. [COLOR=blue]GDownloadUrl[/COLOR]메서드를 이용해서 파일을 다운로드 받을 수 있다. 다운로드 받은 XML파일은 [COLOR=blue]GXml[/COLOR]메서드를 이용해서 처리한다. 마커를 클릭하면 지역정보가 표시된다. <br/>[CODE js]function load() {<br/>	var map = new GMap2(document.getElementById(&#034;map&#034;));<br/>	var center = new GLatLng(37.51030456483467, 127.05190658569336);<br/>	map.addControl(new GSmallMapControl());<br/>	map.addControl(new GMapTypeControl());<br/>	map.setCenter(center, 14);<br/>	map.setMapType(G_SATELLITE_MAP);<br/><br/>	function createMarker(point, name) {<br/>		var marker = new GMarker(point);<br/>		GEvent.addListener(marker, &#034;click&#034;, function() {<br/>			marker.openInfoWindowHtml(&#034;&lt;b&gt;&#034; + name + &#034;&lt;/b&gt;&#034;);<br/>		});<br/>		return marker;<br/>	}<br/><br/>	GDownloadUrl(&#034;async_data.xml&#034;, function(data, responseCode) {<br/>		var xml = GXml.parse(data);<br/>		var markers = xml.documentElement.getElementsByTagName(&#034;marker&#034;);<br/>		for (var i = 0; i &lt; markers.length; i++) {<br/>			var point = new GLatLng(parseFloat(markers[i].getAttribute(&#034;lat&#034;)), parseFloat(markers[i].getAttribute(&#034;lng&#034;)));<br/>			map.addOverlay(new GMarker(point));<br/>			map.addOverlay(createMarker(point, markers[i].getAttribute(&#034;name&#034;)));<br/>		}<br/>	});<br/>}[/CODE]<br/><br/>다음은 async_data.xml의 내용이다.<br/>[CODE]&lt;markers&gt;<br/>&lt;marker lat=&#034;37.508500299402435&#034; lng=&#034;127.06263542175293&#034; name=&#034;반디앤 루인스&#034;/&gt;<br/>&lt;marker lat=&#034;37.50209991181568&#034; lng=&#034;127.03652143478394&#034; name=&#034;시티문고&#034;/&gt;<br/>&lt;marker lat=&#034;37.50312128705489&#034; lng=&#034;127.05825805664062&#034; name=&#034;개미책방&#034;/&gt;<br/>&lt;marker lat=&#034;37.517802011991854&#034; lng=&#034;127.0405125617981&#034; name=&#034;로터리오락실&#034;/&gt;<br/>&lt;marker lat=&#034;37.5056235973398&#034; lng=&#034;127.0512306690216&#034; name=&#034;울회사&#034;/&gt;<br/>&lt;/markers&gt;[/CODE]<br/><br/>예제 : async.html<br/><br/><br/>[B]* 관련 링크[/B]<br/>[URL]<A HREF="http://mapki.com" TARGET="_blank"  rel="nofollow">http://mapki.com</A>[/URL]<br/>[URL]<A HREF="http://econym.org.uk/gmap/" TARGET="_blank"  rel="nofollow">http://econym.org.uk/gmap/</A>[/URL] -&gt; 위의 예제가 거의다 이 사이트에 존재 합니다.<br/><br/><br/>==================================================================================<br/>[B]* 예제 모음[/B]<br/>[URL=http://www.google.com/uds/solutions/wizards/mapsearch.html]Map Search Wizard - Put a Searchable Map on Your Web Page[/URL] 는 쉽게 자신의 홈페이지에 Google Map을 달 수 있도록 코드를 생성해 줍니다.<br/>[ATTACH]433[/ATTACH]]]></description>
<dc:creator>MintState</dc:creator>
<dc:date>Wed, 18 Mar 2009 13:13:37 +0900</dc:date>
</item>

</channel>
</rss>
