📄 entry.php
字号:
<?
include "header.php";
include "./include/trackback_cls.php";
//SET PRIVACY SETTINGS
if($is_admin_logged_in == "yes") {
$privacy = "AND (privacy='0' OR privacy='1' OR privacy='2' OR privacy='3')";
} elseif($member_info[u_id] == $user_info[u_id]) {
$privacy = "AND (privacy='0' OR privacy='1' OR privacy='2' OR privacy='3')";
} elseif($group_info[allow_members] == "1" & mysql_num_rows(mysql_query("SELECT m_id FROM bhost_members WHERE u_id='$user_info[u_id]' AND member_u_id='$member_info[u_id]'")) == "1") {
$privacy = "AND (privacy='1' OR privacy='2' OR privacy='3')";
} elseif($is_logged_in == "yes") {
$privacy = "AND (privacy='2' OR privacy='3')";
} else {
$privacy = "AND privacy='3'";
}
// IF PRIVACY FEATURE IS DISABLED BY ADMIN
if($group_info[allow_privacy] != 1) {
$privacy = "AND (privacy='0' OR privacy='1' OR privacy='2' OR privacy='3')";
}
$user_url = url("index", "$user_info[username]");
if(isset($_GET['e_id'])) { $e_id = $_GET['e_id']; } else { header("Location: $user_url"); exit(); }
if(mysql_num_rows(mysql_query("SELECT e_id FROM bhost_entries WHERE e_id='$e_id' AND u_id='$user_info[u_id]' AND draft='0' $privacy")) != 1) {
if(mysql_num_rows(mysql_query("SELECT e_id FROM bhost_entries WHERE e_id='$e_id' AND u_id='$user_info[u_id]' AND draft='0'")) != 0) {
$entry_info = mysql_fetch_assoc(mysql_query("SELECT privacy FROM bhost_entries WHERE u_id='$user_info[u_id]' AND e_id='$e_id'"));
if($entry_info[privacy] == "2") {
$error = "<b>$entry1</b><br>$entry2 <a href='".url("login", "$user_info[username]", "$e_id", "", "", "&ref=1")."'>$entry3</a>.";
} elseif($entry_info[privacy] == "1") {
$error = "<b>$entry1</b><br>$entry4 <a href='".url("login", "$user_info[username]", "$e_id", "", "", "&ref=1")."'>$entry3</a>.";
} elseif($entry_info[privacy] == "0") {
$error = "<b>$entry1</b><br>$entry5 <a href='".url("login", "$user_info[username]", "$e_id", "", "", "&ref=1")."'>$entry3</a>.";
}
echo $head;
echo "
<div class='float'><img src='".url("/images/", "images/key.gif")."' border='0'></div>
<div>
$error
</div>
";
echo $foot;
exit();
}
header("Location: $user_url");
exit();
}
$entry_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_entries WHERE u_id='$user_info[u_id]' AND e_id='$e_id'"));
// RETRIEVE TEMPLATE
$template = $user_info[template];
// REPLACE RELATIVE PATHS WITH ABSOLUTE PATHS IF SUBDOMAIN URLS ARE ON
if($admin_info[url] == "1") {
$server_array = explode("/", $_SERVER['PHP_SELF']);
$server_array_mod = array_pop($server_array);
$server_info = implode("/", $server_array);
$prefix = "http://".$_SERVER['HTTP_HOST'].$server_info."/images/templates/";
$template = str_replace("./images/templates/", "$prefix", $template);
}
// CHECK FOR MISSING AVATAR FIRST
$avatar = $user_info[avatar];
$avatar_stripped = str_replace(" ", "", $avatar);
if($avatar_stripped == "" OR $avatar_stripped == "http://") {
$avatar = url("/images/", "images/noavatar2.gif");
}
// CHANGE <, >, ", AND STATIC VARIABLES
$search_array = Array("<", ">", """, "<%WindowTitle%>", "<%Title%>", "<%Description%>", "<%Avatar%>", "<%Email%>", "<%ProfileURL%>", "<%MainPageURL%>", "<%ArchiveURL%>", "<%SiteFeedURL%>", "<%FriendsPageURL%>");
$replace_array = Array("<", ">", "\"", "$user_info[title] - $entry_info[title] - BlogHoster", "$user_info[title]", "$user_info[description]", "$avatar", "$user_info[email]", url("profile", "$user_info[username]"), url("index", "$user_info[username]"), url("archive", "$user_info[username]"), url("rss", "$user_info[username]"), url("friends", "$user_info[username]"));
$template = str_replace($search_array, $replace_array, $template);
// REMOVE ANYTHING BETWEEN <IFMAINPAGE> CONTAINERS
$ifmainpagecount = occurrencecount("<IfMainPage>", "</IfMainPage>", $template, "0");
for($a=0;$a<$ifmainpagecount;$a++) {
$template = str_replace("<IfMainPage>".between("<IfMainPage>", "</IfMainPage>", $template)."</IfMainPage>", "", $template);
}
// REMOVE ANYTHING BETWEEN <IFARCHIVEPAGE> CONTAINERS
$ifarchivepagecount = occurrencecount("<IfArchivePage>", "</IfArchivePage>", $template, "0");
for($a=0;$a<$ifarchivepagecount;$a++) {
$template = str_replace("<IfArchivePage>".between("<IfArchivePage>", "</IfArchivePage>", $template)."</IfArchivePage>", "", $template);
}
// REMOVE ANYTHING BETWEEN <IFFRIENDSPAGE> CONTAINERS
$iffriendspagecount = occurrencecount("<IfFriendsPage>", "</IfFriendsPage>", $template, "0");
for($a=0;$a<$iffriendspagecount;$a++) {
$template = str_replace("<IfFriendsPage>".between("<IfFriendsPage>", "</IfFriendsPage>", $template)."</IfFriendsPage>", "", $template);
}
// INPUT FRIENDS
$friendscount = occurrencecount("<Friends>", "</Friends>", $template, "0");
for($f=0;$f<$friendscount;$f++) {
$insert = "";
$friends = between("<Friends>", "</Friends>", $template);
$allfriends = mysql_query("SELECT m_id, member_u_id FROM bhost_members WHERE u_id='$user_info[u_id]'");
while($friend = mysql_fetch_assoc($allfriends)) {
$friend_info = mysql_fetch_assoc(mysql_query("SELECT u_id, username FROM bhost_users WHERE u_id='$friend[member_u_id]'"));
$insert .= $friends;
$insert = str_replace("<%FriendUsername%>", "$friend_info[username]", $insert);
$insert = str_replace("<%FriendURL%>", url("index", "$friend_info[username]"), $insert);
$insert = str_replace("<%FriendProfileURL%>", url("profile", "$friend_info[username]"), $insert);
}
$template = str_replace("<Friends>".$friends."</Friends>", $insert, $template);
}
// INPUT LINKS
$linkscount = occurrencecount("<Link>", "</Link>", $template, "0");
for($f=0;$f<$linkscount;$f++) {
$insert = "";
$link = between("<Link>", "</Link>", $template);
if($user_info[links_url] != "") {
$links_url = explode("<!>", trim($user_info[links_url]));
$links_title = explode("<!>", trim($user_info[links_title]));
for($l=0;$l<count($links_url);$l++) {
$insert .= $link;
$insert = str_replace("<%LinkTitle%>", "$links_title[$l]", $insert);
$insert = str_replace("<%LinkURL%>", "$links_url[$l]", $insert);
}}
$template = str_replace("<Link>".$link."</Link>", $insert, $template);
}
// INPUT RECENT ENTRIES
$recententrycount = occurrencecount("<RecentEntry>", "</RecentEntry>", $template, "0");
for($r=0;$r<$recententrycount;$r++) {
$insert = "";
$recententry = between("<RecentEntry>", "</RecentEntry>", $template);
$recent = mysql_query("SELECT e_id, title, date FROM bhost_entries WHERE u_id='$user_info[u_id]' AND draft='0' $privacy ORDER BY date DESC LIMIT $user_info[recent_entries]");
while($recent_info = mysql_fetch_assoc($recent)) {
if(str_replace(" ", "", $recent_info[title]) == "") { $title = "<i>$entry6</i>"; } else { $title = $recent_info[title]; }
$title = str_replace("<", "<", $title);
$title = str_replace(">", ">", $title);
$insert .= $recententry;
$insert = str_replace("<%RecentEntryTitle%>", "<a href='".url("entry", "$user_info[username]", "$recent_info[e_id]")."'>$title</a>", $insert);
$insert = str_replace("<%RecentEntryDate%>", cdate("$user_info[format_date]", "<a href='".url("entry", "$user_info[username]", "$recent_info[e_id]")."'>".timezone($recent_info[date]))."</a>", $insert);
$insert = str_replace("<%RecentEntryTime%>", cdate("$user_info[format_time]", "<a href='".url("entry", "$user_info[username]", "$recent_info[e_id]")."'>".timezone($recent_info[date]))."</a>", $insert);
}
$template = str_replace("<RecentEntry>".$recententry."</RecentEntry>", $insert, $template);
}
// CHECK FOR SHOW COMMENT PERMISSIONS
if($group_info[allow_comments] == "0" | $user_info[show_comments] == "0") {
$remove_comments = "yes";
} elseif($group_info[allow_members] == "1" & $user_info[show_comments] == "1" & $member_info[u_id] != $user_info[u_id] & $is_admin_logged_in != "yes" & ($is_logged_in == "no" | mysql_num_rows(mysql_query("SELECT m_id FROM bhost_members WHERE u_id='$user_info[u_id]' AND member_u_id='$member_info[u_id]'")) != "1")) {
$remove_comments = "yes";
} elseif($user_info[show_comments] == "2" & $is_logged_in == "no" & $is_admin_logged_in != "yes") {
$remove_comments = "yes";
} elseif($entry_info[comments] == "0") {
$remove_comments = "yes";
} else {
$remove_comments = "no";
}
// REMOVE ANYTHING BETWEEN <IFCOMMENTSALLOWED> AND <COMMENT> CONTAINERS IF COMMENTS NOT ALLOWED
if($remove_comments == "yes") {
$ifcommentsallowedcount = occurrencecount("<IfCommentsAllowed>", "</IfCommentsAllowed>", $template, "0");
for($a=0;$a<$ifcommentsallowedcount;$a++) {
$template = str_replace("<IfCommentsAllowed>".between("<IfCommentsAllowed>", "</IfCommentsAllowed>", $template)."</IfCommentsAllowed>", "", $template);
}
$commentcontcount = occurrencecount("<Comment>", "</Comment>", $template, "0");
for($a=0;$a<$commentcontcount;$a++) {
$template = str_replace("<Comment>".between("<Comment>", "</Comment>", $template)."</Comment>", "", $template);
}
}
// CHECK FOR POST COMMENT PERMISSIONS
if($group_info[allow_comments] == "0" | $user_info[show_comments] == "0" | $user_info[who_comments] == "0") {
$remove_post_comments = "yes";
} elseif($group_info[allow_members] == "1" & $user_info[who_comments] == "1" & $member_info[u_id] != $user_info[u_id] & $is_admin_logged_in != "yes" & ($is_logged_in == "no" | mysql_num_rows(mysql_query("SELECT m_id FROM bhost_members WHERE u_id='$user_info[u_id]' AND member_u_id='$member_info[u_id]'")) != "1")) {
$remove_post_comments = "yes";
} elseif($user_info[who_comments] == "2" & $is_logged_in == "no" & $is_admin_logged_in != "yes") {
$remove_post_comments = "yes";
} elseif($entry_info[comments] == "0") {
$remove_post_comments = "yes";
} else {
$remove_post_comments = "no";
}
// REMOVE ANYTHING BETWEEN <IFCOMMENTPOSTALLOWED> CONTAINERS IF POST COMMENTS NOT ALLOWED
if($remove_post_comments == "yes") {
$ifpostcommentsallowedcount = occurrencecount("<IfCommentPostAllowed>", "</IfCommentPostAllowed>", $template, "0");
for($a=0;$a<$ifpostcommentsallowedcount;$a++) {
$template = str_replace("<IfCommentPostAllowed>".between("<IfCommentPostAllowed>", "</IfCommentPostAllowed>", $template)."</IfCommentPostAllowed>", "", $template);
}
}
// REMOVE ANYTHING BETWEEN <IFTRACKBACKSALLOWED> AND <TRACKBACK> CONTAINERS IF TRACKBACKS NOT ALLOWED
if($group_info[allow_trackback] == "0" | $entry_info[trackbacks] == "0") {
$iftrackbacksallowedcount = occurrencecount("<IfTrackbacksAllowed>", "</IfTrackbacksAllowed>", $template, "0");
for($a=0;$a<$iftrackbacksallowedcount;$a++) {
$template = str_replace("<IfTrackbacksAllowed>".between("<IfTrackbacksAllowed>", "</IfTrackbacksAllowed>", $template)."</IfTrackbacksAllowed>", "", $template);
}
$trackbackcontcount = occurrencecount("<Trackback>", "</Trackback>", $template, "0");
for($a=0;$a<$trackbackcontcount;$a++) {
$template = str_replace("<Trackback>".between("<Trackback>", "</Trackback>", $template)."</Trackback>", "", $template);
}
}
// CREATE PAGE VARIABLES
$entry_date = mysql_fetch_assoc(mysql_query("SELECT date FROM bhost_entries WHERE u_id='$user_info[u_id]' AND e_id='$e_id'"));
$total_entries = mysql_num_rows(mysql_query("SELECT e_id FROM bhost_entries WHERE u_id='$user_info[u_id]' AND draft='0' $privacy"));
$current_page = mysql_num_rows(mysql_query("SELECT e_id FROM bhost_entries WHERE u_id='$user_info[u_id]' AND date >= '$entry_date[date]' AND draft='0' $privacy"));
$prev = mysql_fetch_assoc(mysql_query("SELECT e_id, date FROM bhost_entries WHERE u_id='$user_info[u_id]' AND date > '$entry_date[date]' AND draft='0' $privacy ORDER BY date ASC LIMIT 0,1"));
$next = mysql_fetch_assoc(mysql_query("SELECT e_id, date FROM bhost_entries WHERE u_id='$user_info[u_id]' AND date < '$entry_date[date]' AND draft='0' $privacy ORDER BY date DESC LIMIT 0,1"));
$minimum = mysql_fetch_assoc(mysql_query("SELECT e_id, date FROM bhost_entries WHERE u_id='$user_info[u_id]' AND draft='0' $privacy ORDER BY date LIMIT 0,1"));
$maximum = mysql_fetch_assoc(mysql_query("SELECT e_id, date FROM bhost_entries WHERE u_id='$user_info[u_id]' AND draft='0' $privacy ORDER BY date DESC LIMIT 0,1"));
if($next[date] < $minimum[date] | $next == FALSE) { $next[e_id] = $minimum[e_id]; }
if($prev[date] > $maximum[date] | $prev == FALSE) { $prev[e_id] = $maximum[e_id]; }
// REMOVE ANYTHING BETWEEN <IFPAGES> CONTAINERS IF ONLY ONE PAGE
if($total_entries == 1) {
$ifpagescount = occurrencecount("<IfPages>", "</IfPages>", $template, "0");
for($a=0;$a<$ifpagescount;$a++) {
$template = str_replace("<IfPages>".between("<IfPages>", "</IfPages>", $template)."</IfPages>", "", $template);
}
}
// REMOVE ANYTHING BETWEEN <LATERLINK> IF NOTHING LATER
if($e_id == $maximum[e_id]) {
$template = str_replace("<LaterLink>", "", $template);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -