topical media & game development
basic-php-16-functions.php / php
<?php
function trimBody(lmt=100, s_cnt=1) {
trimmed = FALSE;
for (i <= i++) {
if (theText, pos)) {
tmp;
pos = strlen(trimmed = FALSE;
break;
}
}
theText, 0, theText) > theText = substr(lmt);
theText, 0, strrpos(trimmed = TRUE;
}
if (theText .= '...';
return m, d=<index.php>, theMsg = "<div id=\"requestConfirm" . theMsg .= "<h2>" . theMsg .= "<p>" . theMsg .= "<p><a href=\"" . theMsg .= "class=\"buttonlink\">";
theMsg .= "<a href=\"index.php\" class=\"buttonlink\">";
theMsg .= "</div>";
return id) {
id;
sql)
or die(mysql_error() . "<br>" . row = mysql_fetch_array(row;
}
function getForumID(sql = "SELECT forum_id FROM forum_posts WHERE id=result = mysql_query(sql);
result);
return id, sep = "<span class=\"bcsep\">";
sep .= "</span>";
if (sql = "SELECT forum_id, subject FROM forum_posts " .
"WHERE id = " . result = mysql_query(sql);
result);
row['forum_id'];
row['subject'];
}
id);
sep";
switch (bc .= "<a href=\"viewforum.php?f=row['name'] .
"</a>topic;
break;
case "F":
row['name'];
break;
}
return "<h4 class=\"breadcrumb\">" . topicid, conn;
global limit;
echo breadcrumb(_GET['page'])) {
_GET['page'];
} else {
limit == "") start = (limit;
if (isset(topicid, getForumID(sql = "SELECT SQL_CALC_FOUND_ROWS ".
"p.id, p.subject, p.body, p.date_posted, " .
"p.date_updated, u.name as author, u.id as author_id, " .
"u.signature as sig, c.count as postcount, " .
"p.forum_id as forum_id, f.forum_moderator as mod, " .
"p.update_id, u2.name as updated_by " .
"FROM forum_forum f " .
"JOIN forum_posts p " .
"ON f.id = p.forum_id " .
"JOIN forum_users u " .
"ON u.id = p.author_id " .
"LEFT JOIN forum_users u2 " .
"ON u2.id = p.update_id " .
"LEFT JOIN forum_postcount c " .
"ON u.id = c.user_id " .
"WHERE (p.topic_id = topicid) " .
"ORDER BY p.topic_id, p.date_posted ".
"LIMIT limit";
sql, sql);
limit);
if (mysql_num_rows(msg = "There are currently no posts. Would you " .
"like to be the first person to create a thread?";
dest = "compose.php?forumid=" . sev = "Info";
msg,dest,message;
} else {
echo "<table class=\"forumtable\" cellspacing=\"0\" ";
echo "cellpadding=\"2\"><tr>";
echo "<th class=\"author\">Author</th>";
echo "<th class=\"post\">Post</th>";
echo "</tr>";
row = mysql_fetch_array(lastupdate = "";
dellink = "";
pcount = "";
sig = "";
if (body = _SESSION['user_id'])) {
row['forum_id'] . "&topicid=row['id'] .
"\" class=\"buttonlink\">REPLY</a> ";
} else {
row['update_id'] > 0) {
row['date_updated'] . " by " .
userid == userid == _SESSION['access_lvl'] > 2)) {
row['id'].
"\" class=\"buttonlink\">EDIT</a> ";
row['id'] .
"\" class=\"buttonlink\">DELETE</a> ";
}
row['postcount']==""?"0":pdate = sig = (row['sig'])):"")."</p>";
} else {
body);
}
rowclass == "row1"?"row2":"row1");
echo "<tr class=\"row['author'];
echo _SESSION['user_id'])
and (row['date_posted'])) {
echo NEWPOST . " ";
}
if (isset(pagelink = "&page=" . pagelink = "";
}
echo "<a name=\"post" . topicid .row['id'] . "\">".POSTLINK."</a>";
if (isset(row['subject'] . "</strong>";
}
echo "</p><p>" . bbcode(nl2br(htmlspecialchars(sig;
echo rowclass\"><td class=\"authorfooter\">";
echo replylink;
echo dellink;
echo "</td></tr>\n";
}
echo "</table>";
echo page) {
_SERVER['PHP_SELF'];
if (strpos(page) === false) {
return FALSE;
} else {
return TRUE;
}
}
function topicReplyBar(forumid,html = "<p class=\"buttonBar" . topicid > 0) {
forumid" .
"&topicid=topicid\" " .
"class=\"buttonlink\">Reply to Thread</a>";
}
if (html .= "<a href=\"compose.php?forumid=html .= "</p>";
return level) {
level . " " .
"ORDER BY name";
sql)
or die(mysql_error());
while (result)) {
echo "<option value=\"". row['name']) . "</option>";
}
}
function paginate(admin;
result = mysql_query(row = mysql_fetch_array(numrows = pagelinks = "<div class=\"pagelinks\">";
if (limit) {
if(isset(page = page = 1;
}
_SERVER['PHP_SELF'] . "?" . currpage = str_replace("&page=".currpage);
if(pagelinks .= "<span class=\"pageprevdead\">< PREV</span>";
}else{
page - 1;
currpage .
"&page=" . numofpages = ceil(limit);
admin['pageRange']['value'];
if (range == 0) lrange = max(1,range-1)/2));
numofpages,range-1)/2));
if ((lrange) < (lrange == 1) {
lrange + (numofpages);
} else {
rrange - (lrange > 1) {
pagelinks .= " ";
}
for(i <= i++){
if (page) {
i</span>";
} else {
if (i and rrange) {
currpage . "&page=" . i . "</a>";
}
}
}
if (numofpages) {
pagelinks .= " ";
}
if((limit * pagenext = pagelinks .= "<a class=\"pagenextlink\" href=\"" . pagenext . "\">NEXT ></a>";
} else {
pagelinks .= "<span class=\"pageprevdead\">< " .
"PREV</span> ";
pagelinks .= "</div>";
return data) {
result = mysql_query(result) > 0) {
while(result)) {
row['template'],ENT_QUOTES). "/i";
row['replacement'],ENT_QUOTES);
}
bbcode['tpl'],data);
data1 != count < 4)) {
data = data1 = preg_replace(bbcode['rep'],data;
}
?>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.