Archive for the ‘Web’ Category

Choice of RIA platform (Flex, Silverlight, OpenLaszlo)

Friday, May 9th, 2008
Rich internet applications or RIA is widely used in the Web nowadays. When we say Web, that’s money. I need money and I need to know how to develop unique web services through RIA. Emerging technologies like Adobe Flex/AIR, Silverlight/WPFe, XulRunner, JavaFX and OpenLaszlo are on the front of developing rich web services. And Hey! [...]

Code completion of Portlet API in JSP pages

Friday, April 4th, 2008

Including the tag <portlet:defineObjects/> in JSP pages is enough to access portlets specific elements, RenderRequest and RenderResponse. But sometimes, IDE like Eclipse would not offer code completion/assistance by just including that tag.

Including this, instead of the tag:

<%@ page import=”javax.portlet.RenderRequest” %>
<%@ page import=”javax.portlet.RenderResponse” %>
<%@ page import=”javax.portlet.PortletConfig” %>

<%
RenderRequest renderRequest = (RenderRequest)request.getAttribute(”javax.portlet.request”);
RenderResponse renderResponse = (RenderResponse)request.getAttribute(”javax.portlet.response”);
PortletConfig portletConfig = (PortletConfig)request.getAttribute(”javax.portlet.config”);
%>

Including this , Eclipse would offer code completion for you presentation pages.(eg. JSP )

Never forget to include portlet.jar on the build path.

traversing child input items using JQuery

Friday, April 4th, 2008

The script.

function getItems() {
childs = $(’#ad’).children();
for(i = 0; i < childs.length; i++) {
// get the value
id = $(childs[i]).attr(”id”);
val = $(childs[i]).val();
$(’#log’).append(id + “=>” + val + “<br/>”);
}
}

<div id=”ad”>
<input type=’text’ id=’text1′ /> <br/>
<input type=’text’ id=’text2′ /> <br/>
<input type=’text’ id=’text3′ /> <br/>
</div>

<div id=”log”>
</div>

<input type=’button’ value=’get’ onclick=’javascript:getItems()’/>

Twitter with Twhirl

Friday, February 1st, 2008
As I’ve been using Twitter these days and also of my frustration on having the best twitter app around the world. At last I found one. After browsing on every app at the Twitter Fan Wiki. I found out about Twhirl, a desktop client for twitter that is based on the Adobe AIR platform. Among all [...]

Twit Twitter

Wednesday, January 30th, 2008
I already had account in twitter but I normally don’t use it. Just last night, I found out that so many people are using it. Mostly are bloggers. As I understand Twitter is the very right tool for microblogging. Just 140 characters for one post, imagine that. Twitter is also a much better tool that [...]

SharedReader and ReadBurner

Sunday, January 27th, 2008
I found SharedReader last January 16 while reading through the blog of Dennes Abing (founder of Amigoas.com). And after a few days, people have already found SharedReader on their own: Mashable.com Louisgray.com Killerstartups.com ReadBurner was launched first than SharedReader and admittedly Readburner has more features than Shareburner. And also SharedReader undergone downtime as Dennes stated the problem in his [...]

checking http proxy server

Saturday, November 17th, 2007

There are 3 basic proxy type servers ( Actually I lied, theres more than three) :

1. Anonymous
These HTTP proxy servers does not send a HTTP_X_FORWARDED_FOR, HTTP_FORWARDED, and HTTP_CLIENT_IP variable for a host( the page you are requesting or the host of a website). Those variables are holds the IP address of the requesting side. (But this can be altered, like sending a wrong HTTP request). Your IP Address cannot be logged, but the host will now that a proxy server were used in the connection, by the HTTP_VIA variable.

2. High Anonymous
These kind of HTTP proxy servers does not send a HTTP_X_FORWARDED_FOR, HTTP_FORWARDED, HTTP_CLIENT_IP, HTTP_VIA, HTTP_XROXY_CONNECTION, HTTP_PROXY_CONNECTION. Without these variables, the host can’t determine if youre using a proxy server, and you IP will never be logged.

3. Transparent
Client’s IP address is easily seen by the host, by looking at the HTTP_X_FORWARDED_FOR variable.

This is a fast and dirty code. I assume you have some very basic knowledge using curl in Php.


// file: testsite.php
// A simple if else in checking server variables.
if ( isset($_SERVER[’HTTP_X_FORWARDED_FOR’]) || isset($_SERVER[’HTTP_FORWARDED’]) || isset($_SERVER[’HTTP_CLIENT_IP’]) )
{
if ( isset($_SERVER[’HTTP_VIA’]) )
{
echo “Transparent Proxy Type [PT1]
“;
}
}

if (!isset($_SERVER[’HTTP_X_FORWARDED_FOR’]) && !isset($_SERVER[’HTTP_FORWARDED’]) && !isset($_SERVER[’HTTP_CLIENT_IP’]) )
{
if ( isset($_SERVER[’HTTP_VIA’]) )
{
echo “Anonymous Proxy Type [PT2]
“;
}
}

if (!isset($_SERVER[’HTTP_X_FORWARDED_FOR’]) && !isset($_SERVER[’HTTP_FORWARDED’]) && !isset( $_SERVER[’HTTP_CLIENT_IP’]) )
{
if ( !isset($_SERVER[’HTTP_VIA’]) && !isset($_SERVER[’HTTP_PROXY_CONNECTION ‘]) )
{
echo “High Anonymous Proxy Type[PT3](if your using a proxy)
“;
}
}

// file: index.php
// $proxy = the proxy server, in the form of ip:port
// $test_url = the test site you want to access
// $timeout = number of seconds to wait for the server before considering it a bad request

function check_proxy($proxy, $test_url, $timeout)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $test_url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); /* We what the content of the test site*/
curl_setopt($ch, CURLOPT_HEADER, 1); /* Include the HTTP Header in the content */
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); /*We dont want to be follow when we see a Location header when the server sends a response*/
}
if ($transfer = curl_exec($ch))
{
if (!isset($transfer))
{
echo “TimeOut or BAD PROXY
“;
}
else
{
if ( strpos($html_body, “[PT1]”) )
{
echo “Transparent
“;
}
else if ( strpos($html_body, “[PT2]”) )
{
echo “Anonymous
“;
}
else
{
echo “High Anonymous
“;
}
}
}
else
{
echo “TimeOut or BAD PROXY
“;
}

curl_close($ch);
echo ““;

}

checkProxy(”"your proxy server:port”, “testsite.php”, 10);

How it works:
The the index.php script will fetch the content of testsite.php , using a proxy server. If the proxy server is present, testsite.php script will be executed , check the server variables and output one of these [PT1], [PT2], or [PT3] in its content. Basically, $transfer is the html content generated by the testsite.php. This is a stupid trick since we will use a strpos in checking the proxy types.

Checking a thousand proxy in the php script would take you some time. A C program using libcurl, and pthreads would do the job, if you want a batch checking proxy servers. The code tag of this theme sucks.