No Ads Script?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    No Ads Script?

    what if ur running ads on ur site, and now site is live, how can i make a coding that if no site is running i can have my own random links on my site?

    FOR EXAMPLE, THE ADMOB CODING:

    Code:
    <?php
    
      /* editable area */
      $mob_mode = &#39;test&#39;; // change mode from "test" to "live" when you are done testing
      $mob_alternate_link = &#39;&#39;; // use this to set a default link to appear if AdMob does not return an ad.
        
      /* end editable area */
        
      //used for ad targeting
      $mob_contents = &#39;&#39;;
      $mob_ua = urlencode(getenv("HTTP_USER_AGENT"));
      $mob_ip = urlencode($_SERVER[&#39;REMOTE_ADDR&#39;]);
      
      $mob_m = &#39;&#39;;
      if ($mob_mode==&#39;test&#39;)
          $mob_m = "&m";
    
      $mob_url = &#39;http://ads.admob.com/ad_source.php?s=a147e97a3ca3d3a&u=&#39;.$mob_ua.&#39;&i=&#39;.$mob_ip.$mob_m;
    
      @$mob_ad_serve = fopen($mob_url,&#39;r&#39;);
    
      if ($mob_ad_serve) {
          while (!feof($mob_ad_serve))
              $mob_contents .= fread($mob_ad_serve,1024);
          fclose($mob_ad_serve);
      }
      $mob_link = explode("><",$mob_contents);
    
      $mob_ad_text = $mob_link[0];
      $mob_ad_link = $mob_link[1];
    
      if (isset($mob_ad_link) && ($mob_ad_link !=&#39;&#39;)) {
          //display AdMob Ad
          echo &#39;[url="&#39;. $mob_ad_link .&#39;"]&#39;. $mob_ad_text . &#39;[/url]&#39;;
      }
      else {
          //no AdMob ad, display alternate
          echo $mob_alternate_link;
      }
    ?>

    #2
    i did somethin like this where is bold, but get errors, like when ads are running, my ads also display, can any1 help me

    <?php

    /* editable area */
    $mob_mode = &#39;test&#39;; // change mode from "test" to "live" when you are done testing
    $mob_alternate_link = echo myads(); // use this to set a default link to appear if AdMob does not return an ad.

    /* end editable area */

    //used for ad targeting
    $mob_contents = &#39;&#39;;
    $mob_ua = urlencode(getenv("HTTP_USER_AGENT"));
    $mob_ip = urlencode($_SERVER[&#39;REMOTE_ADDR&#39;]);

    $mob_m = &#39;&#39;;
    if ($mob_mode==&#39;test&#39;)
    $mob_m = "&m";

    $mob_url = &#39;http://ads.admob.com/ad_source.php?s=a147e97a3ca3d3a&u=&#39;.$mob_ua.&# 39;&i=&#39;.$mob_ip.$mob_m;

    @$mob_ad_serve = fopen($mob_url,&#39;r&#39;);

    if ($mob_ad_serve) {
    while (!feof($mob_ad_serve))
    $mob_contents .= fread($mob_ad_serve,1024);
    fclose($mob_ad_serve);
    }
    $mob_link = explode("><",$mob_contents);

    $mob_ad_text = $mob_link[0];
    $mob_ad_link = $mob_link[1];

    if (isset($mob_ad_link) && ($mob_ad_link !=&#39;&#39;)) {
    //display AdMob Ad
    echo &#39;&#39;. $mob_ad_text . &#39;&#39;;
    }
    else {
    //no AdMob ad, display alternate
    echo $mob_alternate_link;
    }
    ?>

    Comment


      #3
      create a table for your own ads fields id, adurl, adlink

      the do this
      Code:
      $chk = mysql_fetch_array(mysql_query("SELECT adurl, adlink FROM ads ORDER BY RAND() LIMIT 0,1"));
      
      $mob_alternate_link = &#39;[url="&#39;.$chk[0].&#39;"]&#39;.$chk[1].&#39;[/url]&#39;;

      Comment


        #4
        do it like this mate... first call the function on the page that u want the ads to show admob(); ,then check to see if the admob ads is empty...


        Code:
        admob function///////////////////
        
        
        function admobads{
          /* editable area */
          $mob_mode = &#39;test&#39;; // change mode from "test" to "live" when you are done testing
          $mob_alternate_link = &#39;&#39;; // use this to set a default link to appear if AdMob does not return an ad.
            
          /* end editable area */
            
          //used for ad targeting
          $mob_contents = &#39;&#39;;
          $mob_ua = urlencode(getenv("HTTP_USER_AGENT"));
          $mob_ip = urlencode($_SERVER[&#39;REMOTE_ADDR&#39;]);
          
          $mob_m = &#39;&#39;;
          if ($mob_mode==&#39;test&#39;)
              $mob_m = "&m";
        
          $mob_url = &#39;http://ads.admob.com/ad_source.php?s=a147e97a3ca3d3a&u=&#39;.$mob_ua.&#39;&i=&#39;.$mob_ip.$mob_m;
        
          @$mob_ad_serve = fopen($mob_url,&#39;r&#39;);
        
          if ($mob_ad_serve) {
              while (!feof($mob_ad_serve))
                  $mob_contents .= fread($mob_ad_serve,1024);
              fclose($mob_ad_serve);
          }
          $mob_link = explode("><",$mob_contents);
        
          $mob_ad_text = $mob_link[0];
          $mob_ad_link = $mob_link[1];
        
          if (isset($mob_ad_link) && ($mob_ad_link !=&#39;&#39;)) {
              //display AdMob Ad
             /////// echo &#39;[url="&#39;. $mob_ad_link .&#39;"]&#39;. $mob_ad_text . &#39;[/url]&#39;;
          }
          else {
              //no AdMob ad, display alternate
             ///// echo $mob_alternate_link;
          }
        
        }
        
        /////////////////put this on the page where u want the ads to show
        
        $admob = admobads();
        
        
        if($admob==""){
        
        echo myads();
        
        }else {
        
        
        
        
        echo "<a href=\"$mob_ad_link\"> $mob_ad_text </a>";
        
        
        
        }
        wapZan Mobile site builder - Yours is here



        http://wapzan.com?ref=2wap

        Comment


          #5
          Thats a good way but Wizards way is simple and is not much coding todo

          Comment


            #6
            This code will work, used it loads of times with diffrent ad networks etc

            $random_url = array("http://url",
            "http://url",
            "http://url",
            "http://url",
            "http://url",
            "http://url");

            $url_title = array("my site",
            "my Sites",
            "my Sites",
            "my sites text",
            "my sites",
            "myads bla bla");



            srand(time());
            $random = (rand()%6);
            print("

            <a href=\"$random_url[$random]\">$url_title[$random]</a></p>");

            Comment

            Working...
            X