Results 1 to 8 of 8
  1. #1

    extremely simple ad server (just to count impressions)

    hey guys


    anyone know of an extremely basic script that would count impressions on a banner? anything like phpadsnew is just overkill for what i want.

    thanks

  2. #2
    Join Date
    May 2004
    Location
    Lansing, MI, USA
    Posts
    1,548
    heh...
    PHP Code:
    <?php
      $id 
    addslashes($_GET['id']);
      if (
    file_exists($id.'.txt')
        
    $currentcount trim(@shell_exec('cat '.$id.'.txt'));
      else
        
    $currentcount 0;
      
    $currentcount++;
      @
    shell_exec('echo -n '.$currentcount.' > '.$id.'.txt');
      
    header('Location: http://ads.yourdomain.com/images/'.$id.'.gif');
    ?>
    Just make sure the directory the script is in is world-writable, or owned b the group nobody and group writable, or php is ran as your user via suexec... the rest should explain itself...

    Edited to make code display right...
    Jacob - WebOnce Technologies - 30 Day 100% Satisfaction Guarantee - Over 5 Years Going Strong!
    Website Hosting, PHP4&5, RoR, MySQL 5.0, Reseller Hosting, Development, and Designs
    Powered By JAM - Professional Website Development - PHP, MySQL, JavaScript, AJAX - Projects Small & Large

  3. #3
    cool, i'll give that a go thanks

  4. #4
    Join Date
    May 2004
    Location
    Lansing, MI, USA
    Posts
    1,548
    No problem. Might need a little tweaking, but in 'theory' it should be good to go
    Jacob - WebOnce Technologies - 30 Day 100% Satisfaction Guarantee - Over 5 Years Going Strong!
    Website Hosting, PHP4&5, RoR, MySQL 5.0, Reseller Hosting, Development, and Designs
    Powered By JAM - Professional Website Development - PHP, MySQL, JavaScript, AJAX - Projects Small & Large

  5. #5
    Join Date
    Oct 2003
    Location
    West Yorkshire, UK
    Posts
    2,813
    aqi32,

    If the script that Jacob gave you, doesn't do it for you, then try looking at http://www.hotscripts.com and http://php.resourceindex.com

    I'm sure you will find something at one of those two Websites, which meets your needs.
    - Jamie Harrop

  6. #6
    thanks Jamie, i did look at hotscripts first, but couldn't find anything basic.

    i got a parse error from your code Jacob, unfortunately i'm not a programmer to be able to understand it

    Parse error: parse error, unexpected T_VARIABLE in /home/username/public_html/impressioncounttest.php on line 4

  7. #7
    Join Date
    May 2005
    Posts
    41
    PHP Code:
    <?php
      $id 
    addslashes($_GET['id']);
      if (
    file_exists($id.'.txt'){
        
    $currentcount trim(@shell_exec('cat '.$id.'.txt'));
      }else{
        
    $currentcount 0;
      
    $currentcount++;
      @
    shell_exec('echo -n '.$currentcount.' > '.$id.'.txt');
      
    header('Location: [url]http://ads.yourdomain.com/images/[/url]'.$id.'.gif');
    }
    ?>
    Need curly brackets for if-else conditionals.
    < !-- Place sig here //-- >

  8. #8
    Join Date
    May 2004
    Location
    Lansing, MI, USA
    Posts
    1,548
    Originally posted by WebOnce
    heh...
    PHP Code:
    <?php
      $id 
    addslashes($_GET['id']);
      if (
    file_exists($id.'.txt')
        
    $currentcount trim(@shell_exec('cat '.$id.'.txt'));
      else
        
    $currentcount 0;
      
    $currentcount++;
      @
    shell_exec('echo -n '.$currentcount.' > '.$id.'.txt');
      
    header('Location: [url]http://ads.yourdomain.com/images/[/url]'.$id.'.gif');
    ?>
    Make:

    if (file_exists($id.'.txt')

    to
    if (file_exists($id.'.txt'))

    I missed a )

    If/else's do not need {}
    Jacob - WebOnce Technologies - 30 Day 100% Satisfaction Guarantee - Over 5 Years Going Strong!
    Website Hosting, PHP4&5, RoR, MySQL 5.0, Reseller Hosting, Development, and Designs
    Powered By JAM - Professional Website Development - PHP, MySQL, JavaScript, AJAX - Projects Small & Large

Posting Permissions

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