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.
<span style="color: #000000"><span style="color: #0000BB"><?php </span><span style="color: #007700">if (!</span><span style="color: #0000BB">$page </span><span style="color: #007700">&& (</span><span style="color: #0000BB">$seqid </span><span style="color: #007700">== </span><span style="color: #0000BB">2 </span><span style="color: #007700">|| </span><span style="color: #0000BB">$seqid </span><span style="color: #007700">== </span><span style="color: #0000BB">6</span><span style="color: #007700">) && !</span><span style="color: #0000BB">preg_match</span><span style="color: #007700">(</span><span style="color: #DD0000">"/^(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}$/"</span><span style="color: #007700">, </span><span style="color: #0000BB">$_SERVER</span><span style="color: #007700">[</span><span style="color: #DD0000">'REMOTE_ADDR'</span><span style="color: #007700">])): </span><span style="color: #0000BB">?></span></span><br> <div class="node_ad"><!--ad code here--></div><br> <span style="color: #000000"><span style="color: #0000BB"><?php </span><span style="color: #007700">endif; </span><span style="color: #0000BB">?></span></span>
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.
Post categories