<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Андрей Зубарь, записки на лету.</title>
	<atom:link href="http://blog.ifreework.org/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.ifreework.org</link>
	<description>Одна жизнь, один дом, одна женщина, один проект</description>
	<lastBuildDate>Fri, 18 May 2012 07:55:07 +0000</lastBuildDate>
	<language>ru</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Определить город по IP на русском</title>
		<link>http://blog.ifreework.org/?p=1087</link>
		<comments>http://blog.ifreework.org/?p=1087#comments</comments>
		<pubDate>Fri, 18 May 2012 07:55:07 +0000</pubDate>
		<dc:creator>Андрей Зубарь</dc:creator>
				<category><![CDATA[Записки на лету]]></category>

		<guid isPermaLink="false">http://blog.ifreework.org/?p=1087</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 &#60;?php function occurrence&#40;$ip='', $to = 'windows-1251'&#41;&#123; &#160; $ip = &#40;$ip&#41; ? $ip : $_SERVER&#91;'REMOTE_ADDR'&#93; ; &#160; $xml =  simplexml_load_file&#40;'http://ipgeobase.ru:7020/geo?ip='.$ip&#41;; &#160; if&#40;$xml-&#62;ip-&#62;message&#41;&#123; &#160; if&#40; $to == 'utf-8' &#41; &#123;return $xml-&#62;ip-&#62;message;&#125; else &#123; &#160; if&#40; function_exists&#40; 'iconv' &#41; [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> occurrence<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$to</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'windows-1251'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$ip</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span>  <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://ipgeobase.ru:7020/geo?ip='</span><span style="color: #339933;">.</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">message</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$to</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'utf-8'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">return</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">message</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'iconv'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">iconv</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$to</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;//IGNORE&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>else <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;The library iconv is not supported by your server&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$to</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'utf-8'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">return</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">city</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'iconv'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #990000;">iconv</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$to</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;//IGNORE&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">city</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>else <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;The library iconv is not supported by your server&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> occurrence<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'utf-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$data</span> &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

В записи нет меток.]]></content:encoded>
			<wfw:commentRss>http://blog.ifreework.org/?feed=rss2&#038;p=1087</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

