Submit Your Article Forum Rules

Results 1 to 9 of 9

Thread: can someone please help me!

  1. #1
    Member
    Join Date
    Jul 2011
    Posts
    32

    Unhappy can someone please help me!

    Hello everyone. I copied some code to my website (it is a form) and it is not working.

    It looks like it is very simple code, but I do not know how to get it to work.

    In the form, you are supposed to be able to submit a domain name and the results will show up but its not working.

    It is located at thundertutorials.com/testing.html


    thanks,
    Kyle

    I would appreciate any help

  2. #2
    Rest in Peace 1946 - 2013 deepsand's Avatar
    Join Date
    May 2004
    Location
    State College, PA
    Posts
    16,376
    Looks like you either miscopied the code, or copied from a dynamically generated page, rather than a static one.

    Code:
    <form method="post" action="">
    <p><b>Domain/Host Name:</b> <input type="text" name="sitehost" size='30' maxlength='50' value=" Put Your Site In Here "> <input type="submit" value="Grab Details"></p>
    </form>
    <ul>
    Note that the code that follows the above does not use form data, but is hard coded to refer to your own Domain Name.

    Code:
    <li>Google indexed pages: <a href="http://www.google.com/search?q=site%3Awww.thundertutorials.com&amp;hl=en">n/a</a></li>
    <li>Yahoo indexed pages: <a href="http://siteexplorer.search.yahoo.com/search?p=www.thundertutorials.com">1</a></li>
    <li>Yahoo inbound links: <a href="http://siteexplorer.search.yahoo.com/search?p=www.thundertutorials.com&amp;bwm=i">1</a></li>
    <li>Bing indexed pages: <a href="http://www.bing.com/search?q=site%3Awww.thundertutorials.com&amp;mkt=en-US">n/a</a></li>
    <li>Bing inbound links: <a href="http://www.bing.com/search?q=inbody%3Awww.thundertutorials.com&amp;mkt=en-US">2</a></li>
    </ul>

  3. #3
    Member
    Join Date
    Jul 2011
    Posts
    32
    thank you very much for the reply

    so, i did copy the code, but i'm not sure if it was from a a "dynamically generated page" or not. The place where the code was copied from (and I have permission) was from targetedgemarketing.com
    thanks,
    kyle

  4. #4
    Rest in Peace 1946 - 2013 deepsand's Avatar
    Join Date
    May 2004
    Location
    State College, PA
    Posts
    16,376
    The Form code - that in the first Code box above - returns the input URL to them when the Submit button, named "Grab Details," is clicked on.

    Their server then regenerates the page, with that URL plugged into the the display code shown in the second Code box above.

    When first viewed, their page has their own URL in that 2nd block of code. You copied the page after having entered & submitted your own URL.

    You are missing the server side code.

  5. #5
    Member
    Join Date
    Jul 2011
    Posts
    32
    Quote Originally Posted by deepsand View Post
    The Form code - that in the first Code box above - returns the input URL to them when the Submit button, named "Grab Details," is clicked on.

    Their server then regenerates the page, with that URL plugged into the the display code shown in the second Code box above.

    When first viewed, their page has their own URL in that 2nd block of code. You copied the page after having entered & submitted your own URL.

    You are missing the server side code.
    Thank you again for helping me out. Do you know where I could get the "server side code?" Would I be able to find it from viewing the page source, or would I have to contact the owners of the website?

    thanks,
    Kyle

  6. #6
    Rest in Peace 1946 - 2013 deepsand's Avatar
    Join Date
    May 2004
    Location
    State College, PA
    Posts
    16,376
    The source code visible to us is only the client side code. For the server side, you'll need to go to the owner/operator of the site.

  7. #7
    Member
    Join Date
    Jul 2011
    Posts
    32
    I got this code that they said is for that form thing. It is in PHP. How would I get this to work?
    Here is what I got.

    Code:
    <head>
     <script type="text/javascript" src="http://www.websnapr.com/js/websnapr.js"></script>
    </head>


    then for the form i have this code
    Code:
    <form method="post" action="<?$_SERVER['PHP_SELF'];?>">
    <p><b>Domain/Host Name:</b> <input type="text" name="sitehost" size='30' maxlength='50' value=" Put Your Site In Here "> <input type="submit" value="Grab Details"></p>
    </form>
    <ul>
    <li>Google indexed pages: <?=getGooglePages($sitehost);?></li>
    <li>Yahoo indexed pages: <?=getYahooPages($sitehost);?></li>
    <li>Yahoo inbound links: <?=getYahooLinks($sitehost);?></li>
    <li>Bing indexed pages: <?=getBingPages($sitehost);?></li>
    <li>Bing inbound links: <?=getBingLinks($sitehost);?></li>
    <li>Domain age: <?=getDomainAge($sitedomain);?></li>
    </ul>



    Code:
    <?php
    function getGooglePages($host) {
     $request = "http://www.google.com/search?q=" . urlencode("site:" . $host) . "&amp;hl=en";
     $data = getPageData($request);
     preg_match('/<div id=resultStats>(About )?([\d,]+) result/si', $data, $p);
     $value = ($p[2]) ? $p[2] : "n/a";
     $string = "<a href=\"" . $request . "\">" . $value . "</a>";
     return $string;
    }
     
    function getGoogleLinks($host) {
     $request = "http://www.google.com/search?q=" . urlencode("link:" . $host) . "&amp;hl=en";
     $data = getPageData($request);
     preg_match('/<div id=resultStats>(About )?([\d,]+) result/si', $data, $l);
     $value = ($l[2]) ? $l[2] : "n/a";
     $string = "<a href=\"" . $request . "\">" . $value . "</a>";
     return $string;
    }
     
    function getYahooPages($host) {
     $request = "http://siteexplorer.search.yahoo.com/search?p=" . urlencode($host);
     $data = getPageData($request);
     preg_match('/Pages \(([\d,]+)/si', $data, $p);
     $value = ($p[1]) ? $p[1] : "n/a";
     $string = "<a href=\"" . $request . "\">" . $value . "</a>";
     return $string;
    }
     
    function getYahooLinks($host) {
     $request = "http://siteexplorer.search.yahoo.com/search?p=" . urlencode($host);
     $data = getPageData($request);
     preg_match('/Inlinks \(([\d,]+)/si', $data, $l);
     $value = ($l[1]) ? $l[1] : "n/a";
     $string.= "<a href=\"" . $request . "&amp;bwm=i\">" . $value . "</a>";
     return $string;
    }
     
    function getBingPages($host) {
     $request = "http://www.bing.com/search?q=" . urlencode("site:" . $host) . "&amp;mkt=en-US";
     $data = getPageData($request);
     preg_match('/1-([\d]+) of ([\d,]+)/si', $data, $p);
     $value = ($p[2]) ? $p[2] : "n/a";
     $string = "<a href=\"" . $request . "\">" . $value . "</a>";
     return $string;
    }
     
    function getBingLinks($host) {
     $request = "http://www.bing.com/search?q=" . urlencode("inbody:" . $host) . "&amp;mkt=en-US";
     $data = getPageData($request);
     preg_match('/1-([\d]+) of ([\d,]+)/si', $data, $p);
     $value = ($p[2]) ? $p[2] : "n/a";
     $string = "<a href=\"" . $request . "\">" . $value . "</a>";
     return $string;
    }
     
    function getAlexaRank($domain) {
     $request = "http://data.alexa.com/data?cli=10&amp;dat=s&amp;url=" . $domain;
     $data = getPageData($request);
     preg_match('/<POPULARITY URL="(.*?)" TEXT="([\d]+)"\/>/si', $data, $p);
     $value = ($p[2]) ? number_format($p[2]) : "n/a";
     $string = "<a href=\"http://www.alexa.com/siteinfo/" . $domain . "\">" . $value . "</a>";
     return $string;
    }
     
    function getAlexaLinks($domain) {
     $request = "http://data.alexa.com/data?cli=10&amp;dat=s&amp;url=" . $domain;
     $data = getPageData($request);
     preg_match('/<LINKSIN NUM="([\d]+)"\/>/si', $data, $l);
     $value = ($l[1]) ? number_format($l[1]) : "n/a";
     $string = "<a href=\"http://www.alexa.com/site/linksin/" . $domain . "\">" . $value . "</a>";
     return $string;
    }
     
    function getDMOZListings($domain) {
     $request = "http://data.alexa.com/data?cli=10&amp;url=" . $domain;
     $data = getPageData($request);
     preg_match('/<SITE BASE="(.*?)" TITLE="(.*?)" DESC="(.*?)">/si', $data, $s);
     $value1 = ($s[1]) ? $s[1] : "";
     $value2 = ($s[2]) ? $s[2] : "";
     $value3 = ($s[3]) ? $s[3] : "";
     preg_match('/<CAT ID="(.*?)" TITLE="(.*?)" CID="(.*?)"\/>/si', $data, $c);
     $value4 = ($c[1]) ? $c[1] : "";
     $value5 = ($c[2]) ? $c[2] : "";
     $value6 = ($c[3]) ? $c[3] : "";
     $string = "";
     if($value4) {
      $string = "<a href=\"http://www.dmoz.org/" . str_replace("Top/","", $value4) . "\" title=\"" . $value2 . " - " . $value3 . "\">" . $value5 . "</a>";
     }
     else $string = "n/a";
     return $string;
    }
     
    function getSiteAdvisorRating($domain) {
     $request = "http://www.siteadvisor.com/sites/" . $domain . "?ref=safe&amp;locale=en-US";
     $data = getPageData($request);
     preg_match('/(green|yellow|red)-xbg2\.gif/si', $data, $r);
     $value = ($r[1]) ? $r[1] : "grey";
     $string = "<a href=\"" . $request . "\">" . $value . "</a>";
     return $string;
    }
     
    function getWOTRating($domain) {
     $request = "http://api.mywot.com/0.4/public_query2?target=" . $domain;
     $data = getPageData($request);
     preg_match_all('/<application name="(\d+)" r="(\d+)" c="(\d+)"\/>/si', $data, $regs);
     $trustworthiness = ($regs[2][0]) ? $regs[2][0] : -1;
     $values = array("trustworthy","mostly","suspicious","untrustworthy","dangerous","unknown");
     if($trustworthiness>=80) $value = $values[0];
     elseif($trustworthiness>=60) $value = $values[1];
     elseif($trustworthiness>=40) $value = $values[2];
     elseif($trustworthiness>=20) $value = $values[3];
     elseif($trustworthiness>=0) $value = $values[4];
     else $value = $values[5];
     $string = "<a href=\"http://www.mywot.com/en/scorecard/" . $domain . "\">" . $value . "</a>";
     return $string;
    }
     
    function getDomainAge($domain) {
     $request = "http://reports.internic.net/cgi/whois?whois_nic=" . $domain . "&type=domain";
     $data = getPageData($request);
     preg_match('/Creation Date: ([a-z0-9-]+)/si', $data, $p);
     if(!$p[1]) {
      $value = "Unknown";
     }
     else {
      $time = time() - strtotime($p[1]);
      $years = floor($time / 31556926);
      $days = floor(($time % 31556926) / 86400);
      if($years == "1") {
       $y= "1 year";
      }
      else {
       $y = $years . " years";
      }
      if($days == "1") {
       $d = "1 day";
      }
      else {
       $d = $days . " days";
      }
      $value = "$y, $d";
     }
     $string = "<a href=\"" . $request . "\">" . $value . "</a>";
     return $string;
    }
     
    function getPageData($url) {
     if(function_exists('curl_init')) {
      $ch = curl_init($url); // initialize curl with given url
      curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // add useragent
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable
      if((ini_get('open_basedir') == '') && (ini_get('safe_mode') == 'Off')) {
       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any
      }
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // max. seconds to execute
      curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error
      return @curl_exec($ch);
     }
     else {
      return @file_get_contents($url);
     }
    }
     
    function getDomainFromHost($host) {
     $hostparts = explode('.', $host); // split host name to parts
     $num = count($hostparts); // get parts number
     if(preg_match('/^(ac|arpa|biz|co|com|edu|gov|info|int|me|mil|mobi|museum|name|net|org|pp|tv)$/i', $hostparts[$num-2])) { // for ccTLDs like .co.uk etc.
      $domain = $hostparts[$num-3] . '.' . $hostparts[$num-2] . '.' . $hostparts[$num-1];
     }
     else {
      $domain = $hostparts[$num-2] . '.' . $hostparts[$num-1];
     }
     return $domain;
    }
     
    $sitehost = ($_POST['sitehost']) ? $_POST['sitehost'] : $_SERVER['HTTP_HOST'];
    $sitedomain = getDomainFromHost($sitehost);
     
    ?>
    thank you so much for your help! you helped a lot more than you would think. so I got this to work on my website now, but it is slow to load. is there any way to speed it up?

    Never mind, i figured out everything. but thanks for your posts up above you really did help me.
    Last edited by weegillis; 07-25-2011 at 11:16 PM.

  8. #8
    WebProWorld MVP williamc's Avatar
    Join Date
    Jul 2003
    Location
    On a really big hill in Kentucky
    Posts
    4,538
    helped me too, got one new regexp from it that I hadn't thought about using

    Tho I must say this is just horrible...

    Code:
     if(preg_match('/^(ac|arpa|biz|co|com|edu|gov|info|int|me|mil|mobi|museum|name|net|org|pp|tv)$/i', $hostparts[$num-2])) { // for ccTLDs like .co.uk etc.
    William Cross
    Web Development by Those Damn Coders
    Firearm Friendly Websites because our constitution matters

  9. #9
    Administrator weegillis's Avatar
    Join Date
    Oct 2003
    Posts
    5,772
    Quote Originally Posted by williamc View Post
    helped me too, got one new regexp from it that I hadn't thought about using

    Tho I must say this is just horrible...

    Code:
     if(preg_match('/^(ac|arpa|biz|co|com|edu|gov|info|int|me|mil|mobi|museum|name|net|org|pp|tv)$/i', $hostparts[$num-2])) { // for ccTLDs like .co.uk etc.
    What's it going to be come January 13th?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •