26 Apr, 2002
More info on restricted post hack
Posted by: Jennifer In: MT hacks
A few things here. First Below is a sample Main Index Template so you can see how all that junk is set up on the templates. (I hope it doesn't confuse people even more! LOL!)
Also – the author of the blog software b2 had some suggestions for me on how to improve the code on this – which I have not yet implemented. But you can see his comments here.
Ok – now the template…
<?
include("/home/PATH_TO_FILES/header1.php");
?>
<!– I use includes for my header and footer HTML files. Makes it easier for rebuilds –>
<MTEntries>
<p class="date">
<MTDateHeader>
<$MTEntryDate format="%B %d, %Y"$></p>
</MTDateHeader>
<a name="<$MTEntryID pad="1"$>"></a>
<?
$ip = $REMOTE_ADDR;
$cookievalue = $HTTP_COOKIE_VARS["id"];
$array = parse_ini_file("/home/PATH_TO_FILES/accesslist.ini");
$cat = "<$MTEntryCategory$>";
$restricted = "restricted";
$accessallowed = FALSE;
if (in_array($ip, $array, TRUE) || in_array($cookievalue, $array, TRUE))
{
$accessallowed = TRUE;
}
$pretitle = "";
if (!strcasecmp($cat, $restricted)) {
$pretitle = "Restricted Post: ";
}
?>
<p class="headline"><? echo $pretitle; ?><$MTEntryTitle$></p>
<!– the "pretitle stuff is so that if it's a restricted post, it'll automatically put the text "Restricted Post:" before the actual title –>
<?
if ((!strcasecmp($cat, $restricted)) && !($accessallowed))
{
PRINT "<p>This post is a restricted post. To gain access to view this post, simply click <a href='mailto:scriptyATscriptygoddessDOTcom?subject=access_for_";
PRINT $cookievalue;
PRINT "_and_";
PRINT $ip;
PRINT "' >*here*</a> and send me an email (make sure you do NOT change the subject line), and I will give you access ASAP. (Access is usually given within 6 hours, or so (it's done manually)… if after that time you're still not able to see the restricted posts, please email me to let me know and I'll give you password access).</p>";
PRINT "<p class=\"footer\">To gain access via password <a href=\"<$MTEntryLink$>\">click here</a></p>";
} else {
print <<<EOF
<$MTEntryBody$>
</p>
<MTEntryIfExtended>
<p><a href="<$MTEntryLink$>">yadda yadda yadda… (click here to read more)</a></p>
</MTEntryIfExtended>
<p align="right" class="footer">posted at <$MTEntryDate format="%I:%M %p"$>
<!– below is the script for showing custom text based on if there are comments or not –>
<script language=javascript>
document.write(' || <a href="<$MTEntryLink$>">permalink</a>');
</script>
<MTEntryIfAllowComments><script language=javascript>
<!–
document.write(' || <a href="<$MTEntryLink$>#comments">')
if (<$MTEntryCommentCount$> == 0)
{
document.write('speak up</a>')
} else if (<$MTEntryCommentCount$> == 1)
{
document.write('<$MTEntryCommentCount$> voice</a>')
} else if (<$MTEntryCommentCount$> > 1)
{
document.write('<$MTEntryCommentCount$> voices</a>')
}
//–>
</script></p>
</MTEntryIfAllowComments>
EOF;
}
?>
</MTEntries>
<?
include("/home/PATH_TO_FILES/footer1.php");
?>