Drupal 4.6 ad sprinkling
I had been wondering how sites sprinkle ads in irregular parts of their index page. As it turns out, it's just a matter of a simple if statement I put at the end of my Drupal node.tpl.php template file.
<?php if (!$page && ($seqid == 2 || $seqid == 6) && !preg_match("/^(132\.170|68\.2[0-2]{1}\d{1}|24\.\d{2,3}|70\.243|204\.210|209\.86)\.\d{1,3}\.\d{1,3}$/", $_SERVER['REMOTE_ADDR'])): ?>
<div class="node_ad"><!--ad code here--></div>
<?php endif; ?>What does the preg_match do you ask? I don't think professors at school should see the ads on my site, since I do occasionally post assignments on my own site in addition to or instead of WebCT. The regex doesn't show the ads to the ucf.edu netblock or major local ISP address blocks.
» deekayen's blog ·
·
·
Topics: deekayen.net · Drupal · PHP
·
·
Topics: deekayen.net · Drupal · PHP

Post new comment