1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Setup For .html/.htm Files Without A Footer File

Discussion in 'Co-op Advertising Network' started by digitalpoint, Dec 1, 2004.

  1. OnSEO

    OnSEO Guest

    Messages:
    170
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #41
    Glad you could...I couldn't
     
    OnSEO, Dec 7, 2004 IP
  2. Bulldog San

    Bulldog San Peon

    Messages:
    195
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #42
    I'm a complete newbie. Built my first site in October - didn't even know what a footer file was until today. I'm using Dreamhost - it's not a problem there.
     
    Bulldog San, Dec 7, 2004 IP
  3. Bulldog San

    Bulldog San Peon

    Messages:
    195
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #43
    Oh, here's the instructions I got...

    1. Place this code in your .htaccess file:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
    RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
    RewriteRule ^(.*) /passthru.php?file=$1
    </IfModule>

    2. Create a new file in the root folder titled "passthru.php" and insert this code:

    <?php

    if (!function_exists('file_get_contents')) {
    function file_get_contents($url) {
    $handle = fopen($url, 'r');
    $string = fread($handle, 4096000);
    fclose($handle);
    return $string;
    }
    }

    include ('ad_network.php');
    echo preg_replace ("/<\/body>/i", $ad_network[0] . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));

    ?>

    3. Create a new file in the root folder titled "ad_network.php" and insert this code:
    <?php

    if (!function_exists('file_get_contents')) {
    function file_get_contents($url) {
    $handle = fopen($url, 'r');
    $string = fread($handle, 4096000);
    fclose($handle);
    return $string;
    }
    }

    if (!function_exists('make_seed')) {
    function make_seed() {
    list($usec, $sec) = explode(' ', microtime());
    return (float) $sec + ((float) $usec * 100000);
    }
    srand (make_seed());
    }

    if (!isset($_SERVER)) $_SERVER = $HTTP_SERVER_VARS;

    $ad_file = 'ad_network_ads.txt';
    for ($i = 0; $i <= 11; $i++) {
    $p = substr ('../../../../../../../../../../', 0, $i * 3);
    if (file_exists ($p . $ad_file)) {
    $ad_file = $p . $ad_file;
    break;
    }
    }

    if (is_writable ($ad_file)) {
    $ads = file_get_contents ($ad_file);
    $ads = explode ('<ad_break>', $ads);

    if (count ($ads) < 401 || $ads[0] + 900 < time()) {
    $new_ad = file_get_contents ('http://ads.digitalpoint.com/network.php?s=' . $_SERVER['SERVER_NAME'] . '&type=link');
    $ads[] = $new_ad;
    $ads[0] = time();
    if (count ($ads) > 401) unset ($ads[1]);
    if ($new_ad) {
    $file = fopen($ad_file, 'w');
    fwrite ($file, implode ('<ad_break>', $ads));
    fclose ($file);
    }
    $ad = end ($ads);
    } else {
    $ad = $ads[rand(1,count($ads) - 1)];
    }
    $ad_network[] = $ad;
    while (count ($ad_network) < 5) {
    $ad_network[] = $ads[rand(1,count($ads) - 1)];
    }
    } else {
    $ad_network[] = 'You must set the "ad_network_ads.txt" file to be writable.';
    }
    if (substr (@$_SERVER['DOCUMENT_NAME'], -6) == '.shtml') {
    ini_set ('zlib.output_compression', 0);
    echo end ($ad_network);
    }

    ?>

    4. Create a new file in the root folder titled "ad_network_ads.txt" and leave it empty. Also change the file permissions to 777.
     
    Bulldog San, Dec 7, 2004 IP
    Fishing Forum likes this.
  4. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #44
    We have helped someone get the Ad Network running on their HTML site and everything is running great.

    We would like to format the text to match their font.

    I'm assuming this would be done in the passthru.php file. Can anyone provide an example?
     
    ResaleBroker, Dec 8, 2004 IP
  5. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #45
    You would want to surround the ads with <span> or <div> tags and do it with CSS.
     
    digitalpoint, Dec 8, 2004 IP
  6. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #46
    Like this?

    <div class="menu">
    <?php

    if (!function_exists('file_get_contents')) {
    function file_get_contents($url) {
    $handle = fopen($url, 'r');
    $string = fread($handle, 4096000);
    fclose($handle);
    return $string;
    }
    }

    include ('ad_network.php');
    echo preg_replace ("/<\/body>/i", $ad_network[0] . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));

    ?>
    </div>
     
    ResaleBroker, Dec 8, 2004 IP
  7. seohome

    seohome Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #47
    Well, I just finished uploading the working version. This site gave me the 500 error (as some of yours) and I simply added the code 1 by 1. That way, it didn't return any errors. You have to upload all your files but it's not that bad. I hope you can make it work too :) .
     
    seohome, Dec 8, 2004 IP
  8. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #48
    On the passthru.php method, you would want to add it before and after the $ad_network[0] in the preg_replace function.
     
    digitalpoint, Dec 8, 2004 IP
  9. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #49
    Thanks Shawn!
     
    ResaleBroker, Dec 8, 2004 IP
  10. Hank

    Hank Guest

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #50
    Bulldog San or Shawn:

    For the above listed .htaccess and other files (for .htm or .html use in the ad network), what code(s) exactly needs to go into the actual .htm files?

    I've got the files created and uploaded to my site, but cannot quite figure out what code to put into the actual website pages.

    My site is http://www.everensec.com/

    So as you can see, this is currently a small 4 page straight html site. The site is on a Linux / Apache shared server where php etal are supported.

    Thanks for any help!

    Hank
     
    Hank, Dec 9, 2004 IP
  11. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #51
    Nothing needs to go in your html files.
     
    digitalpoint, Dec 9, 2004 IP
  12. Bulldog San

    Bulldog San Peon

    Messages:
    195
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #52
    Magically, it puts the text links just before the </body> tag. Don't ask me how.
     
    Bulldog San, Dec 10, 2004 IP
  13. Hank

    Hank Guest

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #53
    Thanks Shawn.

    I've had several go arounds with my host and their techies. I happen to have a very good relationship with them.

    Anyway, I'm still not having any luck. The mod_rewrite is enabled. I'm getting this error:

    --
    [Fri Dec 10 10:19:33 2004] [error] [client 202.88.230.11] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
    [Fri Dec 10 10:19:33 2004] [error] [client 202.88.230.11] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
    --

    then, my engineer said this:

    It is very clear the reason of that error from the error logs itself. The redirect rules specified in .htaccess file were the following:

    --
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
    RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
    RewriteRule ^(.*) /passthru.php?file=$1
    </IfModule>
    --

    Among those rules, the rewritecond REQUEST_FILENAME doesn't exist (or an invalid condition) and it triggers only the RewriteRule, ie without checking any prior conditions. And it was falling in an infinite loop, giving those errors.

    ---

    All my files are .html extensions.

    The engineer has suggested to replace REQUEST_FILENAME with SCRIPT_NAME, which we did as a test. That ceased the 500 server error, but there are still no ads on my site.

    :confused:

    Also, I've put the two php files and the .txt file in both my WWW and my root directories to do some tests. I still get 500 errors when those files are in the WWW directory (the .txt with 777 chmod) and the specified .htaccess proper code from Shawn.

    Any ideas or suggestions?

    I'd love to get this going. Have over a dozen sites, most using .html files. This is killing me!

    Hank
     
    Hank, Dec 10, 2004 IP
  14. Hank

    Hank Guest

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #54
    I couldn't get the .htm / .html workaround to function properly.

    So I renamed my files to .shtml, renamed the internal links to .shtml for all visible files, put the specified files and additions together and IT WORKS!

    Yehaw! :D

    So I go log into the coop network section to validate the site, and the tool tells me a bunch of .html pages aren't valid. I delete those pages, as I no longer need them anyway.

    The odd thing is none of those pages are linked anywhere on the live site.

    Shawn, now that I have deleted them, your tool is still saying they are in the directory and they are "not valid". I cannot see the deleted files in my FTP client, nor in the File Manager of Cpanel (the site control panel).

    Any suggestions?

    Also, I have some optin email confirmation pages that I've left as .html files. Will your tool find those and prevent activation?

    For some reason I just figured the validation tool would seek live and linked pages.

    Thanks for any tips.

    Hank
     
    Hank, Dec 10, 2004 IP
  15. Foxy

    Foxy Chief Natural Foodie

    Messages:
    1,614
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #55
    You will always find this problem Hank until Google 'sees' that the pages have gone - remember it uses the API to get all of its information.

    Generally speaking though it only picks up the more relevant files [which is obvious as a page you forgot somewhere deep could kick out the system and yet its chance of being seen is very small] so when it does kick you out it reports the page - go fix the page and revalidate. :)
     
    Foxy, Dec 10, 2004 IP
  16. Hank

    Hank Guest

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #56
    Shawn:

    For my 4 page site, I was able to rename the pages to .php and move them to a new domain and the tool validated it.

    However, I've got several sites well over 100 .html pages, and I'd really like to get in and contribute to this network and receive a little too.

    So today I'm back to trying the different methods and still generating 500 server errors.

    In a previous post, you asked another person to post their error log.

    I'm getting this error:

    mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.

    I'm using a shared host who uses Linux / Cpanel. I've got two entirely different sites on two different hosts, and no matter what I try when using the .htaccess / passthru.php method, I still get the error above.

    Do you think the host doesn't have the mod_rewrite set to proper levels?

    Thanks for any suggestions.

    Hank
     
    Hank, Dec 13, 2004 IP
  17. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #57
    I'm having trouble with formatting with the passthru.php method. Can anyone give an example with the code below of where the formatting should be placed?

    <?php

    if (!function_exists('file_get_contents')) {
    function file_get_contents($url) {
    $handle = fopen($url, 'r');
    $string = fread($handle, 4096000);
    fclose($handle);
    return $string;
    }
    }

    include ('ad_network.php');
    echo preg_replace ("/<\/body>/i", $ad_network[0]. ' - ' . $ad_network[1]. ' - ' . $ad_network[2] . ' - ' . $ad_network[3] . ' - ' . $ad_network[4] . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));

    ?>
     
    ResaleBroker, Dec 13, 2004 IP
  18. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #58
    Like this:
    echo preg_replace ("/<\/body>/i", '<div class="menu">' . $ad_network[0]. ' - ' . $ad_network[1]. ' - ' . $ad_network[2] . ' - ' . $ad_network[3] . ' - ' . $ad_network[4] . '</div></body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
    PHP:
     
    digitalpoint, Dec 13, 2004 IP
  19. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #59
    Thanks Shawn!:)
     
    ResaleBroker, Dec 13, 2004 IP
  20. g00gl3r

    g00gl3r Well-Known Member

    Messages:
    167
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #60
    g00gl3r, Dec 14, 2004 IP