Please forgive me for being stupid, but I find the setup directions very confusing. Here are some details on my site: Server = Linux Apache with PHP support The home page has a .shtml extension but the rest of the pages do not. The home page contains a small bit of (canned) PHP code but the rest of the pages do not. So, given that, here are my questions: (I'm referring to the page at http://www.digitalpoint.com/tools/ad-network/setup.php?type=99) Is my site 'PHP based'? Is it 'SHTML based'? How do I know if I have the right permissions for the ad_network_ads.txt file, and if not, where, how and why do I enter the 'chmod' command? Should I use option 3, 4, or 5 from the above mentioned instruction page? I see on the instruction page code for headers, support files, etc. but not code that actually goes in the body of my pages - you know, the stuff that determines exactly where the ads will be placed. Am I missing something (likely)? If you can stand to hand-hold a newbie through this process, I would be greatly appreciative. I know HTML pretty well and some CSS, but I'm clueless about PHP and server stuff.. TIA!
Looking at this again, it seems like one really does need to know PHP in order to set this up... bummer. Any quick, easy references out there for someone who doesn't really need to know PHP, just wants to join the co-op?
If only your homepage is shtml than what are the rest of your pages? if they are htm or html I have succesfully setup the ad network with them, I can paste the code here if you want. According to Shawn, there is no code that goes into the body of your pages, the ads are automatically on every page after you setup the network and this is the same problem I'm having, I can't position my ads differently, right now they are at the same spot on every page and are either overlapping with something or compelete off. So I just took them off for now until I can figure this out. To set permission to the file, go to your FTP software ( I use Smart FTP) and login to your server, than left click on that file and you should see Properties/CHMOD, click on that and you will see a 3 digit number, change that to 777 for that file only and it will be writeable.
Yes, please.. that would be very helpful. The rest of my pages are htm. Ahh! Very clever! Well, if it's better (more positioning flexibility) to put a snippet in each page, I could do that too, if I knew how I've been using WS_FTP, and there doesn't seem to be any properties function. I'll check with the tools my hoster provides, maybe there's a way to do it from CPanel. Thanks for your help, and good luck!!
OK, I figured out how to set the permissions to 777 for .htaccess through CPanel. My site still loads but no ads appear and it won't validate. Here's how I'm set up: .htaccess = <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR] RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC] RewriteRule ^(.*) /passthru.php?file=$1 </IfModule> Code (markup): passthru.php = <?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']))); ?> Code (markup): ad_network.php = <?php // Last update: Jan 21, 2005 8:51 am 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); } mt_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); $ads_temp = explode ('|', $ads[0]); $file = fopen($ad_file, 'r+'); if (flock ($file, LOCK_EX|LOCK_NB, $would_block) && !$would_block) { if ((count ($ads) < $ads_temp[3] + 1 && $ads_temp[0] + $ads_temp[5] < time()) || $ads_temp[0] + $ads_temp[4] < time()) { $new_ad = file_get_contents ('http://ads.digitalpoint.com/network.php?b=' . $_SERVER['SERVER_NAME'] . '&type=link'); if ($new_ad) { $ads_param = explode ('<ad_param>' , $new_ad); $new_ad = $ads_param[1]; unset ($ads_param[1]); $ads_temp = explode ('|', $ads_temp[0] . '|' . $ads_temp[1] . '|' . $ads_param[0]); } else { $ads_param = array_slice ($ads_temp, 2, 4); } $ads[0] = time() . '|' . gethostbyname('validate.digitalpoint.com') . '|' . implode ('|', $ads_param); if ($new_ad) { $ads[] = $new_ad; if (count ($ads) > $ads_temp[3] + 1) $ads = array_merge ((array)$ads[0], (array)array_slice ($ads, -$ads_temp[3])); } fwrite ($file, implode ('<ad_break>', $ads)); ftruncate ($file, ftell($file)); $ad_network[] = $new_ad; } flock ($file, LOCK_UN); fclose ($file); } while (count ($ad_network) < 5) { $ad_network[] = $ads[mt_rand(1,count($ads) - 1)]; } foreach ($ad_network as $key => $ad) { if ($ads_temp[1] == $_SERVER['REMOTE_ADDR'] || $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR']) { $ad_network[$key] = str_replace ('" />', '" class="' . $ads_temp[2] . '" />', $ad); } else { $ad_network[$key] = str_replace ('" />', '">', $ad); } } } 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); } ?> Code (markup): and of course I also included the ad_network_ads.txt file (blank) as well. All of these files are in my root directory, the same directory that my domain points to. I only changed the permissions on the .htaccess file. Does this look OK to you gurus? What's wrong and how do I fix it? Eternal gratitude to anyone who cares to lend a hand!!
I am not sure but that looks like what I have. It may be as simple as changing your homepage to .htm as well if you can do that.
Well, changing my home page to .htm disabled my rotating image feature (which I expected) but it was worth trying to see if it helped... but it didn't . I still get the dreaded 500 error, and nothing actually shows up in my server logs, so I'm kinda stuck. I'll ask my hoster if they support modrewrites but it takes a full two days for a response to my emails. I just wish this system could be set up to be a little less fragile and hard to get up and running Thx fer yer help...
Yes, as much as the co-op wants new members there is limited help. I am in a little situation myself. Apart from not being able to position the ads where I want them. I have a mix of .htm pages and .php pages. The .php pages are for an affiliate program. So if I setup for .htm, the php pages get no ads and therefore my site won't validate because the co-op requires all pages of your site to be running ads. I don't know, I'm going to try to figure it out, maybe I can "duel-boot" it somehow to be setup for both cases.
Did you already have a .htaccess file before the co-op? I know I had one so I had to put the co-op code after what was already in it so my whole file looks like this: # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> AuthName www.weight-lifting-world.com AuthUserFile /home/weightl/public_html/_vti_pvt/service.pwd AuthGroupFile /home/weightl/public_html/_vti_pvt/service.grp <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR] RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC] RewriteRule ^(.*) /passthru.php?file=$1 </IfModule> Code (markup): My passthru is (setup to run 5 ads): <?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']))); ?> Code (markup): ad_network is the same. So if your host allows mod rewrite it should be working.
To my knowledge there was no .htaccess file before I uploaded mine. Curiously enough the File Manager utility in my web hoster's control panel app (CPanel) continues to show .htaccess as being there even after I delete it. When I upload the file (via Dreamweaver MX) Dreamweaver and CPanel both show its existence on the server, and my site bombs with a 500 error. When I delete the file (either through DW or CPanel) Dreamweaver says it's gone, CPanel says it's still there, site comes up just fine. I have to assume this is a freak out within CPanel because DW sees every other file. Wierd, but beside the point...
I was making it too hard on myself.. all I had to do was rename ALL of my .htm files to .shtml files then my site became 'SHTML based'. I just used the setup instructions for SHTML based sites and life is sweet now! Except it won't validate... but that's food for another thread. THanks for your help!!
lol now why didn't i think of that..glad its working for you, if you ever figure out the positioning, please enlighten me
Maybe you can do what I did.. instead of using the modrewrite method, just change the extensions of all your .htm files to .shtml then insert this <!--#include virtual="/ad_network.php" --> Code (markup): into each .shtml file at the place where you want the ads to appear. Insert this <?php ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../'); include ('ad_network.php'); echo $ad_network[0]; ?> Code (markup): into each of your .php files, again at the point where you want the ads to appear. I suggest you test it on a couple files of each type first, before making wholesale changes. My site has only 1 .php file so it wasn't too hard. I hope this helps. It worked for me - now if I can just get validated
To CHMOD your ad_network. txt file in WS-FTP, just open your WS_FTP, and on the right side with the uploaded files, right click on the txt file and scroll down to CHMOD, click it, and then check the top six boxes, for it to be 666 or all of them for it to be 777