<?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>Sosuke &#187; AS3</title>
	<atom:link href="http://www.sosuke.com/index.php/tag/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sosuke.com</link>
	<description>Dark music of the gods.</description>
	<lastBuildDate>Wed, 06 Jan 2010 01:34:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sizing the buttons on the NumericStepper</title>
		<link>http://www.sosuke.com/index.php/2010/01/05/sizing-the-buttons-on-the-numericstepper/</link>
		<comments>http://www.sosuke.com/index.php/2010/01/05/sizing-the-buttons-on-the-numericstepper/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 01:34:42 +0000</pubDate>
		<dc:creator>sosuke</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[skinning]]></category>

		<guid isPermaLink="false">http://www.sosuke.com/?p=53</guid>
		<description><![CDATA[So your working on a new RIA in Flash and you want to use the built in NumericStepper, or any other Flash component for that matter but you aren&#8217;t happy with the skin. You&#8217;ve already seen Customizing the NumericStepper component by Adobe and you&#8217;re ready to move past changing the color of the component and [...]]]></description>
			<content:encoded><![CDATA[<p>So your working on a new RIA in Flash and you want to use the built in NumericStepper, or any other Flash component for that matter but you aren&#8217;t happy with the skin. You&#8217;ve already seen <a href="http://help.adobe.com/en_US/ActionScript/3.0_UsingComponentsAS3/WS5b3ccc516d4fbf351e63e3d118a9c65b32-7f42.html">Customizing the NumericStepper component</a> by Adobe and you&#8217;re ready to move past changing the color of the component and want to update the buttons. Every time I updated the component skin after it has been added to the Library in Flash and tested the Movie, the smaller button graphics I created get stretched and distorted. It was always 21 pixels wide and 12 pixels tall! The Adobe documentation on the <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/controls/NumericStepper.html">NumericStepper</a> didn&#8217;t provide any help in resizing these buttons that control the increase and decrease for the NumericStepper component.</p>
<p>What you need to do is open up the source and take a look to figure out what was going on. I found the source files here C:\Program Files (x86)\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\NumericStepper.as on my system. I found out what was going wrong by doing a quick search for that pesky 21 pixel width and found my answer starting on line 527.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> configUI<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">super</span>.configUI<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	upArrow = <span style="color: #0033ff; font-weight: bold;">new</span> BaseButton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	copyStylesToChild<span style="color: #000000;">&#40;</span>upArrow, UP_ARROW_STYLES<span style="color: #000000;">&#41;</span>;
	upArrow.autoRepeat = <span style="color: #0033ff; font-weight: bold;">true</span>;
	upArrow.setSize<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">21</span>, <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000000;">&#41;</span>;
	upArrow.focusEnabled = <span style="color: #0033ff; font-weight: bold;">false</span>;
	<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>upArrow<span style="color: #000000;">&#41;</span>;
&nbsp;
	downArrow = <span style="color: #0033ff; font-weight: bold;">new</span> BaseButton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	copyStylesToChild<span style="color: #000000;">&#40;</span>downArrow, DOWN_ARROW_STYLES<span style="color: #000000;">&#41;</span>;
	downArrow.autoRepeat = <span style="color: #0033ff; font-weight: bold;">true</span>;
	downArrow.setSize<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">21</span>, <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000000;">&#41;</span>;
	downArrow.focusEnabled = <span style="color: #0033ff; font-weight: bold;">false</span>;
	<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>downArrow<span style="color: #000000;">&#41;</span>;
&nbsp;
	inputField = <span style="color: #0033ff; font-weight: bold;">new</span> TextInput<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	copyStylesToChild<span style="color: #000000;">&#40;</span>inputField, TEXT_INPUT_STYLES<span style="color: #000000;">&#41;</span>;
	inputField.<span style="color: #004993;">restrict</span> = <span style="color: #990000;">&quot;0-9<span style="">\\</span>-<span style="">\\</span>.<span style="">\\</span>,&quot;</span>;
	inputField.<span style="color: #004993;">text</span> = _value.<span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	inputField.setSize<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">21</span>, <span style="color: #000000; font-weight:bold;">24</span><span style="color: #000000;">&#41;</span>;
	inputField.focusTarget = <span style="color: #0033ff; font-weight: bold;">this</span> <span style="color: #0033ff; font-weight: bold;">as</span> IFocusManagerComponent;
	inputField.focusEnabled = <span style="color: #0033ff; font-weight: bold;">false</span>;
	inputField.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">FocusEvent</span>.<span style="color: #004993;">FOCUS_IN</span>, passEvent<span style="color: #000000;">&#41;</span>;
	inputField.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">FocusEvent</span>.<span style="color: #004993;">FOCUS_OUT</span>, passEvent<span style="color: #000000;">&#41;</span>;
	<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>inputField<span style="color: #000000;">&#41;</span>;
&nbsp;
	inputField.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">CHANGE</span>, onTextChange, <span style="color: #0033ff; font-weight: bold;">false</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
	upArrow.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ComponentEvent.BUTTON_DOWN, stepperPressHandler, <span style="color: #0033ff; font-weight: bold;">false</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
	downArrow.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ComponentEvent.BUTTON_DOWN, stepperPressHandler, <span style="color: #0033ff; font-weight: bold;">false</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Ah ha! They set the size of the buttons when the component is initialized on the stage. You can&#8217;t edit this file to solve your problem though you&#8217;ll need to extend the fl.controls.NumericStepper class and override the configUI function to change the size of your buttons. I suspect there are several other instances of hard-coded component sizes in the Flash component library but you just need to look to the source they provided to extend the components to your liking.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sosuke.com/index.php/2010/01/05/sizing-the-buttons-on-the-numericstepper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blocking IP addresses by country on IIS shared hosting</title>
		<link>http://www.sosuke.com/index.php/2009/05/20/blocking-ip-addresses-by-country-on-iis-shared-hosting/</link>
		<comments>http://www.sosuke.com/index.php/2009/05/20/blocking-ip-addresses-by-country-on-iis-shared-hosting/#comments</comments>
		<pubDate>Thu, 21 May 2009 06:23:08 +0000</pubDate>
		<dc:creator>sosuke</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[shared hosting]]></category>

		<guid isPermaLink="false">http://www.sosuke.com/?p=32</guid>
		<description><![CDATA[On a shared hosting environment you often won&#8217;t have access to ban IP addresses on the IIS level and my shared host didn&#8217;t offer the Firewall module for Plesk so I had to come up with a programmatic way of blocking large blocks of IPs. You can setup in your web.config file something called a [...]]]></description>
			<content:encoded><![CDATA[<p>On a shared hosting environment you often won&#8217;t have access to ban IP addresses on the IIS level and my shared host didn&#8217;t offer the Firewall module for Plesk so I had to come up with a programmatic way of blocking large blocks of IPs. You can setup in your web.config file something called a HTTPModule that works before the page is delivered to the client computer. For this sample I added a key and value to my web.config file that holds my comma separated IP list that I want to block. Since I&#8217;m running a site that is focused on the United States there isn&#8217;t much overlap on the /24 block area 255.255.255.* so I am only checking the first 3 digit blocks for matches. When a request comes in IpTwentyFourBlockingModule will check the users IP address against the key value blockiptwentyfour to see if there is a match and if it is a match will return 403 forbidden to the client browser, banned! </p>
<p>Coming up with a IP list is another problem. I found <a href="http://iplocationtools.com">IP Location Tools</a> that gives out an API that generates a updated <a href="http://iplocationtools.com/ip_country_block_iptables.php">list of IPs for a given country</a>. The problem is the list gets broken out into IP blocks other than /24, you&#8217;ll see all ranges of IP blocks that get very complicated very fast and more than I wanted to try and pull off in a days work. I wrote a Flash ActionScript 3 application to consume this data and give me a list of unique IPs 255.255.255 that I could then drop in as the value for blockiptwentyfour. I then added IP tracking for new users and have had to ban some rogue /24 blocks that escaped this list but its kept them at bay and more manageable for now. I&#8217;ve already had a colleague suggest that this is still only a stopgap at best and I should develop some kind of throttling system to help prevent spam when I&#8217;m not around to watch the site like a hawk.</p>
<p>web.config</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;appSettings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;blockiptwentyfour&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;41.210.29,41.210.28&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/appSettings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system.web<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;httpModules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;IpTwentyFourBlockingModule&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;IpTwentyFourBlockingModule&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/httpModules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system.web<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>IpTwentyFourBlockingModule.cs &#8211; put this is in your App_Code</p>

<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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080;">#region Using</span>
&nbsp;
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Web</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Configuration</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Collections.Specialized</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080;">#endregion</span>
&nbsp;
<span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// Block the response to certain IP addresses</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> IpTwentyFourBlockingModule <span style="color: #008000;">:</span> IHttpModule
<span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #008080;">#region IHttpModule Members</span>
&nbsp;
    <span style="color: #0600FF;">void</span> IHttpModule.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// Nothing to dispose; </span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">void</span> IHttpModule.<span style="color: #0000FF;">Init</span><span style="color: #000000;">&#40;</span>HttpApplication context<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        context.<span style="color: #0000FF;">BeginRequest</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> EventHandler<span style="color: #000000;">&#40;</span>context_BeginRequest<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Checks the requesting IP address in the collection</span>
    <span style="color: #008080; font-style: italic;">/// and block the response if it's on the list.</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> context_BeginRequest<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #FF0000;">string</span> ip <span style="color: #008000;">=</span> HttpContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Request</span>.<span style="color: #0000FF;">UserHostAddress</span><span style="color: #008000;">;</span>
        <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> tempIpArray <span style="color: #008000;">=</span> ip.<span style="color: #0000FF;">Split</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">'.'</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #FF0000;">string</span> iptwentyfour <span style="color: #008000;">=</span> tempIpArray<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;.&quot;</span> <span style="color: #008000;">+</span> tempIpArray<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#93;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;.&quot;</span> <span style="color: #008000;">+</span> tempIpArray<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>_IpAdresses.<span style="color: #0000FF;">Contains</span><span style="color: #000000;">&#40;</span>iptwentyfour<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            HttpContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Response</span>.<span style="color: #0000FF;">StatusCode</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">403</span><span style="color: #008000;">;</span>
            HttpContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Response</span>.<span style="color: #0000FF;">End</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> StringCollection _IpAdresses <span style="color: #008000;">=</span> FillBlockedIps<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Retrieves the IP addresses from the web.config</span>
    <span style="color: #008080; font-style: italic;">/// and adds them to a StringCollection.</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;A StringCollection of IP addresses.&lt;/returns&gt;</span>
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> StringCollection FillBlockedIps<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        StringCollection col <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StringCollection<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #FF0000;">string</span> raw <span style="color: #008000;">=</span> ConfigurationManager.<span style="color: #0000FF;">AppSettings</span>.<span style="color: #0000FF;">Get</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;blockiptwentyfour&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> ip <span style="color: #0600FF;">in</span> raw.<span style="color: #0000FF;">Split</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">','</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            col.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>ip.<span style="color: #0000FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">return</span> col<span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>collectipaddresses.as</p>

<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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #000000; font-weight: bold;">*</span>;
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #000000; font-weight: bold;">*</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> myRequest<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://iplocationtools.com/country_query.php?country=CI,SN,GH,NA,NG&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #004993;">loader</span>.<span style="color: #004993;">dataFormat</span> = <span style="color: #004993;">URLLoaderDataFormat</span>.<span style="color: #004993;">TEXT</span>;
<span style="color: #004993;">loader</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>, handleComplete<span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">loader</span>.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>myRequest<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> handleComplete<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span>event.<span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #009900;">//trace(loader.data.replace(/\n/g, &quot;|&quot;));</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> ipArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #004993;">loader</span>.<span style="color: #004993;">data</span>.<span style="color: #004993;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>\n<span style="color: #000000; font-weight: bold;">/</span>g, <span style="color: #990000;">&quot;|&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">split</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;|&quot;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>ipArray.<span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span>;
	setTwentyFourBlock<span style="color: #000000;">&#40;</span>ipArray<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> setTwentyFourBlock<span style="color: #000000;">&#40;</span>ipArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">var</span>	shortIpArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #6699cc; font-weight: bold;">var</span>	lastUniqueIp<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;&quot;</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> ip<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #0033ff; font-weight: bold;">in</span> ipArray<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> tempIpArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = ip.<span style="color: #004993;">split</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;.&quot;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #6699cc; font-weight: bold;">var</span> stringCurrentIp<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = tempIpArray<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">&quot;.&quot;</span><span style="color: #000000; font-weight: bold;">+</span>tempIpArray<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">&quot;.&quot;</span><span style="color: #000000; font-weight: bold;">+</span>tempIpArray<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">&quot;.0&quot;</span>;
		<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>stringCurrentIp <span style="color: #000000; font-weight: bold;">!</span>= lastUniqueIp<span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			lastUniqueIp = stringCurrentIp;
			shortIpArray.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>stringCurrentIp<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>shortIpArray.<span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>shortIpArray.<span style="color: #004993;">join</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">','</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>All of this work has really kept my <a href="http://www.diveintothepool.com/">free online dating</a> site almost spam free for now but I&#8217;m adding IP blocks I&#8217;ve missed from time to time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sosuke.com/index.php/2009/05/20/blocking-ip-addresses-by-country-on-iis-shared-hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
