Sanity Check

Discussion in 'Co-op Advertising Network' started by toddmc, Dec 23, 2004.

  1. #1
    I just want to make sure I'm not losing my mind.

    I placed the following in the footer of my php link directory:

    <table width="100%" border="0" cellspacing="0" cellpadding="1">
    <tr>
    <td height="1" align="center" bgcolor="#ffffff"></td>
    </tr>
    </table>
    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo $ad_network[0];
    ?>



    I placed this in my ad_network.php file in the root of my site:

    <?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, 'r+');
    if (flock ($file, LOCK_EX)) {
    fwrite ($file, implode ('<ad_break>', $ads));
    ftruncate ($file, ftell($file));
    flock ($file, LOCK_UN);
    }
    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);
    }

    ?>


    I created a file called ad_network_ads.txt and placed it in the root.

    Now when you go to: http://www.playgroundmall.com/resources/addlink.php you should be able to see the ad running in the footer. I'm not seeing anything running there. Have I lost my mind?
     
    toddmc, Dec 23, 2004 IP