Jnerocorp Posted October 4, 2009 Share Posted October 4, 2009 Hello, I have this script im making that does all kinds of pagerank types of things .. but i want to make it more ajax like instead of just php. Here is what my script looks like and how it loads: MyDomainPagerank.com and This is what I want it to look like and how it loads. http://www.greatdb.com/ Here are the codes I have for my site: Index.php: <?php include('data.class.php'); ?> <html> <head> <title>JayDesign's PR script</title> <script language=Javascript> function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) // if too long...trim it! field.value = field.value.substring(0, maxlimit); // otherwise, update 'characters left' counter else countfield.value = maxlimit - field.value.length; } </script> <style type="text/css"> /*Example CSS for the two demo scrollers*/ #searchbox { background-color: lightblue; width: 350px; height: 150px; border: 1px solid black; } #pscroller1{ width: 200px; height: 200px; border: 1px solid black; padding: 5px; background-color: lightyellow; } #pscroller2{ width: 350px; height: 20px; border: 1px solid black; padding: 3px; } #pscroller2 a{ text-decoration: none; } .someclass{ //class to apply to your scroller(s) if desired } </style> <script type="text/javascript"> /*Example message arrays for the two demo scrollers*/ var pausecontent=new Array() pausecontent[7]='Updated Yahoo Backlink Checker <br> <b>Added: Oct. 3d <br> 2:26 PM -5est</b>' pausecontent[6]='Added Domain Estimated Value <br> <b>Added: Oct. 3d <br> 2:37 PM -5est</b>' pausecontent[5]='Added Bing.com Backlinks <br> <b>Added: Oct. 3d <br> 3:04 PM -5est</b> ' pausecontent[4]='Added Ask.com Backlinks <br> <b>Added: Oct. 3d <br> 6:46 PM -5est</b>' pausecontent[3]='Added Google Ads <br> <b>Added: Oct. 4th <br> 9:27 AM -5est</b>' pausecontent[2]='Added CSS to form <br> <b>Added: Oct. 4th <br> 9:39 AM -5est</b>' pausecontent[1]='Added New Logo <br> <b>Added: Oct. 5th <br> 9:51 AM -5est</b>' pausecontent[0]='Added Multi Url <br> <b>Added: Oct. 5th <br> 12:07PM -5est</b>' var pausecontent2=new Array() pausecontent2[0]='<a href="http://www.news.com">News.com: Technology and business reports</a>' pausecontent2[1]='<a href="http://www.cnn.com">CNN: Headline and breaking news 24/7</a>' pausecontent2[2]='<a href="http://news.bbc.co.uk">BBC News: UK and international news</a>' </script> <script type="text/javascript"> function pausescroller(content, divId, divClass, delay){ this.content=content //message array content this.tickerid=divId //ID of ticker div to display information this.delay=delay //Delay between msg change, in miliseconds. this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is) this.hiddendivpointer=1 //index of message array for hidden div document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>') var scrollerinstance=this if (window.addEventListener) //run onload in DOM2 browsers window.addEventListener("load", function(){scrollerinstance.initialize()}, false) else if (window.attachEvent) //run onload in IE5.5+ window.attachEvent("onload", function(){scrollerinstance.initialize()}) else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec setTimeout(function(){scrollerinstance.initialize()}, 500) } // ------------------------------------------------------------------- // initialize()- Initialize scroller method. // -Get div objects, set initial positions, start up down animation // ------------------------------------------------------------------- pausescroller.prototype.initialize=function(){ this.tickerdiv=document.getElementById(this.tickerid) this.visiblediv=document.getElementById(this.tickerid+"1") this.hiddendiv=document.getElementById(this.tickerid+"2") this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv)) //set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2) this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px" this.getinline(this.visiblediv, this.hiddendiv) this.hiddendiv.style.visibility="visible" var scrollerinstance=this document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1} document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0} if (window.attachEvent) //Clean up loose references in IE window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null}) setTimeout(function(){scrollerinstance.animateup()}, this.delay) } // ------------------------------------------------------------------- // animateup()- Move the two inner divs of the scroller up and in sync // ------------------------------------------------------------------- pausescroller.prototype.animateup=function(){ var scrollerinstance=this if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){ this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px" this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px" setTimeout(function(){scrollerinstance.animateup()}, 50) } else{ this.getinline(this.hiddendiv, this.visiblediv) this.swapdivs() setTimeout(function(){scrollerinstance.setmessage()}, this.delay) } } // ------------------------------------------------------------------- // swapdivs()- Swap between which is the visible and which is the hidden div // ------------------------------------------------------------------- pausescroller.prototype.swapdivs=function(){ var tempcontainer=this.visiblediv this.visiblediv=this.hiddendiv this.hiddendiv=tempcontainer } pausescroller.prototype.getinline=function(div1, div2){ div1.style.top=this.visibledivtop+"px" div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px" } // ------------------------------------------------------------------- // setmessage()- Populate the hidden div with the next message before it's visible // ------------------------------------------------------------------- pausescroller.prototype.setmessage=function(){ var scrollerinstance=this if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it) setTimeout(function(){scrollerinstance.setmessage()}, 100) else{ var i=this.hiddendivpointer var ceiling=this.content.length this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1 this.hiddendiv.innerHTML=this.content[this.hiddendivpointer] this.animateup() } } pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any if (tickerobj.currentStyle) return tickerobj.currentStyle["paddingTop"] else if (window.getComputedStyle) //if DOM2 return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top") else return 0 } </script> <link rel="shortcut icon" href="./images/favicon.png" type="image/x-icon" /> </head> <body> <center> <a href="./index.php"><img src="./images/logo.png" border="0"></a> <br><br> <script type="text/javascript"><!-- google_ad_client = "pub-8851304100025267"; /* 468x60, created 10/4/09 */ google_ad_slot = "8140420963"; google_ad_width = 468; google_ad_height = 60; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <br><br> <div id="searchbox" class="searchbox"> <form name="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>" id="form1"> <label><strong>Url:</strong></label> <textarea cols="35" rows="4" name="urls" id="urls" onKeyDown="textCounter(this.form.urls,this.form.remLen,125);" onKeyUp="textCounter(this.form.urls,this.form.remLen,125);"></textarea><br <input type="submit" name="button" id="button" value="Submit" /> <input type="hidden" name="submitted" value="TRUE" /> <input readonly type=hidden name=remLen size=3 maxlength=3 value="125"> </form> <font size="1"><b>Place 1 url per line</b><br> <b>Note</b>: It may take some time for results to show up</font> </div> <br> <!-- Begin Results --> <?php if ($results) { ?> <?php foreach ($results as $result) { ?> Website Thumbnail:<br> <img src="<?php echo $result['thumb']; ?>"><br> <table border="0"> <?php $url = $result['url']; $pagerank = $result['pagerank']; $alexarank = $result['alexarank']; $dmoz = ($result['dmoz']) ? 'Yes' : 'No'; $yahoodir = ($result['yahooDirectory']) ? 'Yes' : 'No'; $googlebl = $result['backlinksGoogle']; $yahoobl = $result['backlinksYahoo']; $bingbl = $result['backlinksBing']; $askbl = $result['backlinksAsk']; $altavista = $result['altavista']; $alltheweb = $result['alltheweb']; $estibot = $result['estibot']; $domainage = $result['age']; $a = array("Website Url:</td> <td> $url", "Pagerank: </td> <td> $pagerank", "Alexa Rank </td> <td> $alexarank", "Dmoz: </td> <td> $dmoz", "Yahoo Directory: </td> <td> $yahoodir", "Google Backlinks: </td> <td> $googlebl", "Yahoo Backlinks: </td> <td> $yahoobl", "Bing Backlinks: </td> <td> $bingbl", "Ask Backlinks: </td> <td> $askbl", "AltaVista Backlinks: </td> <td> $altavista", "AllTheWeb: </td> <td> $alltheweb", "Estimated Value: </td> <td> $$estibot", "Domain Age:</td> <td> $domainage"); foreach($a as $row){ echo "<tr><td> $row </td></tr>"; } ?> </table> <?php } } ?> <br> <script type="text/javascript"> //new pausescroller(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds) new pausescroller(pausecontent, "pscroller1", "someclass", 3000) </script> <br /> <a href="./updates.php">View All Updates</a> <br /> <br /> Copyright © 2009, <a href="index.php">MyDomainPagerank.com</a></center><br><br><br> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> </body> </html> data.class.php: <?php class pagerank { var $url; function pagerank ($url) { $this->url = parse_url('http://' . ereg_replace('^http://', '', $url)); $this->url['full'] = 'http://' . ereg_replace('^http://', '', $url); } function getPage ($url) { if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com/search?hl=en&q=google&btnG=Google+Search'); return curl_exec($ch); } else { return file_get_contents($url); } } function getPagerank () { $url = 'info:' . $this->url['host']; $checksum = $this->checksum($this->strord($url)); $url = "http://www.google.com/search?client=navclient-auto&ch=6$checksum&features=Rank&q=$url"; $drbug_url = "http://www.google.com/search?client=navclient-auto&ch=6$checksum&features=Rank&q=$url"; $data = $this->getPage($url); preg_match('#Rank_[0-9]:[0-9][0-9]+){1,}#si', $data, $p); $value = ($p[1]) ? $p[1] : 0; return $value; } function getAlexaRank ($url) { $xml = simplexml_load_file('http://data.alexa.com/data?cli=10&dat=s&url=' . $url); return $xml->SD->POPULARITY['TEXT']; } function getDmoz () { $url = ereg_replace('^www\.', '', $this->url['host']); $url = "http://search.dmoz.org/cgi-bin/search?search=$url"; $data = $this->getPage($url); if (ereg('<center>No <b><a href="http://dmoz\.org/">Open Directory Project</a></b> results found</center>', $data)) { $value = false; } else { $value = true; } return $value; } function getYahooDirectory () { $url = ereg_replace('^www\.', '', $this->url['host']); $url = "http://search.yahoo.com/search/dir?p=$url"; $data = $this->getPage($url); if (ereg('No Directory Search results were found\.', $data)) { $value = false; } else { $value = true; } return $value; } function getBacklinksGoogle () { $url = $this->url['host']; $url = 'http://www.google.com/search?q=' . urlencode($url); $data = $this->getPage($url); preg_match('/of about \<b\>([0-9\,]+)\<\/b\>/si', $data, $p); $value = ($p[1]) ? number_format($this->toInt($p[1])) : 0; return $value; } function getBacklinksYahoo () { $url = $this->url['host']; $url = 'http://search.yahoo.com/search?p=' . urlencode("http://$url"); $data = $this->getPage($url); preg_match('#<strong id="resultCount">([0-9\,]+)</strong>#si', $data, $p); $value = ($p[1]) ? number_format($this->toInt($p[1])) : 0; return $value; } function getBacklinksBing () { $url = $this->url['host']; $url = 'http://www.bing.com/search?q=' . urlencode($url); $data = $this->getPage($url); preg_match('#of ([0-9\,]+) results</span>#si', $data, $p); $value = ($p[1]) ? number_format($this->toInt($p[1])) : 0; return $value; } function getResultsAltaVista () { $url = $this->url['host']; $url = 'http://www.altavista.com/web/results?q=' . urlencode($url); $data = $this->getPage($url); preg_match('#AltaVista found ([0-9,]+){1,} results#si', $data, $p); $value = ($p[1]) ? number_format($this->toInt($p[1])) : 0; return $value; } function getResultsAllTheWeb () { $url = $this->url['host']; $url = 'http://www.alltheweb.com/search?q=' . urlencode($url); $data = $this->getPage($url); preg_match('#<span class="ofSoMany">([0-9,]+){1,}</span>#si', $data, $p); $value = ($p[1]) ? number_format($this->toInt($p[1])) : 0; return $value; } function getBacklinksAsk () { $url = $this->url['host']; $url = 'http://www.ask.com/web?q=' . urlencode($url); $data = $this->getPage($url); preg_match('#of ([0-9,]+){1,} for#si', $data, $p); $value = ($p[1]) ? number_format($this->toInt($p[1])) : 0; return $value; } function getValueEstibot () { $url = $this->url['host']; $url = "http://estibot.com/results.php?domain=$url"; $data = $this->getPage($url); preg_match('#<span class="bold_text"> USD ([a-z0-9,]+) </span>#si', $data, $p); $value = ($p[1]) ? number_format($this->toInt($p[1])) : 0; return $value; } function getAge () { $url = ereg_replace('^www\.', '', $this->url['host']); $url = "http://who.is/whois/$url"; $data = $this->getPage($url); preg_match('#Creation Date: ([a-z0-9-]+)#si', $data, $p); if ($p[1]) { $time = time() - strtotime($p[1]); $years = round($time / 31556926); $days = round(($time % 31556926) / 86400); $value = "$years years, $days days"; } else { $value = 'Unknown'; } return $value; } function toInt ($string) { return preg_replace('#[^0-9]#si', '', $string); } function to_int_32 (&$x) { $z = hexdec(80000000); $y = (int) $x; if($y ==- $z && $x <- $z){ $y = (int) ((-1) * $x); $y = (-1) * $y; } $x = $y; } function zero_fill ($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a >> 1); $a &= (~$z); $a |= 0x40000000; $a = ($a >> ($b - 1)); } else { $a = ($a >> $b); } return $a; } function mix ($a, $b, $c) { $a -= $b; $a -= $c; $this->to_int_32($a); $a = (int)($a ^ ($this->zero_fill($c, 13))); $b -= $c; $b -= $a; $this->to_int_32($b); $b = (int)($b ^ ($a << ); $c -= $a; $c -= $b; $this->to_int_32($c); $c = (int)($c ^ ($this->zero_fill($b, 13))); $a -= $b; $a -= $c; $this->to_int_32($a); $a = (int)($a ^ ($this->zero_fill($c, 12))); $b -= $c; $b -= $a; $this->to_int_32($b); $b = (int)($b ^ ($a << 16)); $c -= $a; $c -= $b; $this->to_int_32($c); $c = (int)($c ^ ($this->zero_fill($b, 5))); $a -= $b; $a -= $c; $this->to_int_32($a); $a = (int)($a ^ ($this->zero_fill($c, 3))); $b -= $c; $b -= $a; $this->to_int_32($b); $b = (int)($b ^ ($a << 10)); $c -= $a; $c -= $b; $this->to_int_32($c); $c = (int)($c ^ ($this->zero_fill($b, 15))); return array($a,$b,$c); } function checksum ($url, $length = null, $init = 0xE6359A60) { if (is_null($length)) { $length = sizeof($url); } $a = $b = 0x9E3779B9; $c = $init; $k = 0; $len = $length; while($len >= 12) { $a += ($url[$k + 0] + ($url[$k + 1] << + ($url[$k + 2] << 16) + ($url[$k +3] << 24)); $b += ($url[$k + 4] + ($url[$k + 5] << + ($url[$k + 6] << 16) + ($url[$k +7] << 24)); $c += ($url[$k + 8] + ($url[$k + 9] << + ($url[$k + 10] << 16) + ($url[$k +11] << 24)); $mix = $this->mix($a, $b, $c); $a = $mix[0]; $b = $mix[1]; $c = $mix[2]; $k += 12; $len -= 12; } $c += $length; switch($len) { case 11: $c += ($url[$k + 10] << 24); case 10: $c += ($url[$k + 9] << 16); case 9 : $c += ($url[$k + 8] << ; case 8 : $b += ($url[$k + 7] << 24); case 7 : $b += ($url[$k + 6] << 16); case 6 : $b += ($url[$k + 5] << ; case 5 : $b += ($url[$k + 4]); case 4 : $a += ($url[$k + 3] << 24); case 3 : $a += ($url[$k + 2] << 16); case 2 : $a += ($url[$k + 1] << ; case 1 : $a += ($url[$k + 0]); } $mix = $this->mix($a, $b, $c); return $mix[2]; } function strord ($string) { for($i = 0; $i < strlen($string); $i++) { $result[$i] = ord($string{$i}); } return $result; } } $options = array( 'pagerank' => true, 'dmoz' => true, 'yahooDirectory' => true, 'backlinksYahoo' => true, 'backlinksGoogle' => true, 'backlinksBing' => true, 'backlinksAsk' => true, 'altavista' => true, 'alltheweb' => true, 'alexarank' => true, 'age' => true, 'estibot' => true, 'thumb' => true ); if ($_POST['urls']) { $rep=array("\r"," "); $_POST['urls']=str_replace($rep,'',$_POST['urls']); $urls = split("\n", $_POST['urls']); $results = array(); foreach ($urls as $url) { if(!empty($url)||trim($url!='')){ $data = new pagerank(trim($url)); $results[] = array( 'url' => $data->url['host'], 'pagerank' => $data->getPagerank(), 'dmoz' => $data->getDmoz(), 'yahooDirectory' => $data->getYahooDirectory(), 'backlinksYahoo' => $data->getBacklinksYahoo(), 'backlinksGoogle' => $data->getBacklinksGoogle(), 'backlinksBing' => $data->getBacklinksBing(), 'backlinksAsk' => $data->getBacklinksAsk(), 'altavista' => $data->getResultsAltaVista(), 'alltheweb' => $data->getResultsAllTheWeb(), 'alexarank' => $data->getAlexaRank($url), 'age' => $data->getAge(), 'estibot' => $data->getValueEstibot(), 'thumb' =>"http://images.websnapr.com/?size=T&key=C5VIuGtdv2Kd&url=".$url ); } } } ?> -John Quote Link to comment Share on other sites More sharing options...
ProXy_ Posted October 4, 2009 Share Posted October 4, 2009 i could possibly convert your code into ajax. I'm still learning myself on how to show a Loader GIF & hide the GIf after but i'd figure just being ajax is a start, right? Quote Link to comment Share on other sites More sharing options...
Jnerocorp Posted October 4, 2009 Author Share Posted October 4, 2009 if you think you want to have a go at it go right ahead this would also be a great learning expierience to touch you up on your skills. -John Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.