Friday, November 19, 2010

Grab the URL from Site or Page

If you want to crawel links from all the site or pages, Below is the function:

$arrGetAllLinks = array();

// if you want all links from site, set $isRecuressive = 1
// if you want all links from page, set $isRecuressive = 0

function fnGrabTHeURLFromLink($strLink,$isRecuressive = 0)
{
$parse = parse_url($strLink);
$strMainHost = $parse['host'];

global $arrGetAllLinks;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$strLink);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);

if( $result )
{
preg_match_all( '/href="(http:\/\/www.[^0-9].+?)"/', $result, $output, PREG_SET_ORDER );

foreach( $output as $item )
{
$parse = parse_url($item[1]);
$strHostOfURL = $parse['host'];

// ALL LINKS DISPLAY HERE
//print "
";
//print_r($item);

if(($strMainHost == $strHostOfURL) && !in_array($item[1], $arrGetAllLinks))
{
$arrGetAllLinks[] = $item[1];
if($isRecuressive == 1)
{
$arrTempGetAllLinks = fnGrabTHeURLFromLink($item[1]);
$arrGetAllLinks = array_merge((array)$arrGetAllLinks, (array)$arrTempGetAllLinks);
$arrGetAllLinks = array_unique($arrGetAllLinks);
}
}
}

}

return array_unique($arrGetAllLinks);
}

print_r(fnGrabTHeURLFromLink("MENTION SITE HERE"));

Thursday, November 4, 2010

Fragment Id Messaging Concept

we use a hack called fragment id messaging. This should be cross-browser, provided the page containing your iframe is the top level.

In other words, there are a total of two levels.
Basically, the child sets the fragment of the parent, and the parent watches for this.

Generally fragment id messaging use for cross-domain communication.
Technically, this hack uses window.location.hash (the part of the URL following #) to communicate.

Historically, any window could change the location of any other window. This turned out to be a problem because, among other things, it meant embedding a login iframe in a window was unsafe (because then a malicious site could replace the login iframe with a spoofed version). Over time further restrictions have been applied to location changes to browser windows, until now, when HTML5 and most browsers have reached common agreement on the ancestor policy. In a nutshell, paraphrasing the HTML5 specification, a window A can change the location of another window B if:

* the locations of A and B have the same origin, which is to say they have the same scheme, host, and port (http, stackoverflow.com, 80 for example), or
* B is a top-level window, and A is a window in a frame nested at some depth within B (direct child, child of a child, etc.), or
* B is a window opened using window.open and A can change the location of the window that opened B (so B is a popup opened by A, by a popup window opened by A, or at greater depth), or
* B isn't a top-level window, but its parent window, or its parent's parent window, or at some similar amount of parentage the locations of that window and A are same-origin

(Same origin is more complicated than this, but the embedded description above catches its essence and covers the most common cases.)

Under this policy, C may change the location of A, and A may change the location of B or C, but C may not change the location of B. If you need to work around this, then you should change your page A's location to something that changes B as appropriate; alternately, you could ask your page B to change its own location.

Configuring SSL (Godaddy) for Apache 2.X

While configuring SSL you will need to provide Certificate Signing Request (CSR).

Steps to generate CSR can be found on below url:
http://help.godaddy.com/topic/746/article/5269

Steps are also described below:

Creating a CSR (required while registering ssl certificate)

Create a directory /usr/bin/ssl/ where your csr files will be stored.

Type below command from the shell:

1 . cd /usr/bin/ (/your path to openssl/)
which will change your directory to the one which is going to store the CSR files.
Then type below command on shell
2. openssl genrsa -des3 -out .key 2048
Replace with the name which you want.
3. openssl req -new -key .key -out .csr
Replace with the name which you want.
The above two commands will create a .key and .csr file at the location which you have specified above.

Note – while creation of a CSR you will be asked the details about organization.
Once the certificate is registered you will get two files with .crt extension. Place these two files in the same directory as the one which you have created while CSR.



Now for apache server configuration:
Go to /etc/httpd/conf.d folder where you will find a ssl.conf file.

In ssl.conf file you will find below lines
SSLCertificateFile – replace the path of your SSL certificate file (from above e.g. /usr/bin/ssl/yourcertificate.crt)

SSLCertificateKeyFile - replace the path of your SSL key file (from above e.g. /usr/bin/ssl/key.crt)

SSLCertificateChainFile – replace with the path of 2nd .crt file which you got after registering the certificate. (its generally named as gd_bundle.crt) (from above e.g. /usr/bin/ssl/gd_bundle.crt)

Tuesday, July 6, 2010

How to Get the Base Url with Javascript for a Domain or Localhost

In the code below, you will be able to find the baseUrl of your website using javascript. The following javascript code will work when used on your localhost or when it's used in a live site (finds the root url of the domain address).


function fnGetBaseURL() {
var strUrl = location.href;
// entire url including querystring - also: window.location.href;
var strBaseURL = strUrl.substring(0, strUrl.indexOf('/', 14));


if (strBaseURL.indexOf('http://localhost') != -1) {
// Base Url for localhost
var strUrl = location.href; // window.location.href;
var strPathName = location.pathname; // window.location.pathname;
var intIndex1 = strUrl.indexOf(strPathName);
var intIndex2 = strUrl.indexOf("/",intIndex1 + 1);
var strBaseLocalUrl = strUrl.substr(0, intIndex2);

return strBaseLocalUrl + "/";
}
else {
// Root Url for domain name
return strBaseURL + "/";
}

}

If you'd like to test the fnGetBaseURL function in an html page and view the result, simply add the following after the closing tag of the fnGetBaseURL () function:
document.write(fnGetBaseURL());

Saturday, February 13, 2010

linkedin API.... Exploring Frustration Discovering Satisfaction

Hi All,

last month Me and My team from CueLogic implemented LinkedIn connect with Oauth for Justmeans.... Its really frustrated.......... at last we Succeed....

True Said:

linkedin API.... Exploring Frustration Discovering Satisfaction


Stay tuned... API's coming soon.............................