⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 friends.php

📁 BLOG HOSTER---PHP & MYSQL Create Blogs in seconds Installation of your BlogHoster system is easy.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?
include "header.php";
if(isset($_POST['page'])) { $page = $_POST['page']; } elseif(isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; }

// 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("&lt;", "&gt;", "&quot;", "<%WindowTitle%>", "<%Title%>", "<%Description%>", "<%Avatar%>", "<%Email%>", "<%ProfileURL%>", "<%MainPageURL%>", "<%ArchiveURL%>", "<%SiteFeedURL%>", "<%FriendsPageURL%>");
$replace_array = Array("<", ">", "\"", "$user_info[title] - $friends3 - 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 <IFENTRYPAGE> CONTAINERS
$ifentrypagecount = occurrencecount("<IfEntryPage>", "</IfEntryPage>", $template, "0");
for($a=0;$a<$ifentrypagecount;$a++) {
$template = str_replace("<IfEntryPage>".between("<IfEntryPage>", "</IfEntryPage>", $template)."</IfEntryPage>", "", $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 <IFMAINPAGE> CONTAINERS
$ifmainpagecount = occurrencecount("<IfMainPage>", "</IfMainPage>", $template, "0");
for($a=0;$a<$ifmainpagecount;$a++) {
$template = str_replace("<IfMainPage>".between("<IfMainPage>", "</IfMainPage>", $template)."</IfMainPage>", "", $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>$friends1</i>"; } else { $title = $recent_info[title]; }
  $title = str_replace("&lt;", "<", $title);
  $title = str_replace("&gt;", ">", $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);
}


// BUILD FRIENDS QUERY
$query = "";
$count = 0;
$friends = mysql_query("SELECT m_id, member_u_id FROM bhost_members WHERE u_id='$user_info[u_id]'");
while($friend = mysql_fetch_assoc($friends)) {
$friend_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_users WHERE u_id='$friend[member_u_id]'"));
$group_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_groups WHERE g_id='$friend_info[g_id]'"));
 if($group_info[allow_privacy] != 1) {
  $privacy = "AND (privacy='0' OR privacy='1' OR privacy='2' OR privacy='3')";
 } else {
  if($is_admin_logged_in == "yes") {
  $privacy = "AND (privacy='0' OR privacy='1' OR privacy='2' OR privacy='3')";
  } elseif($member_info[u_id] == $friend_info[u_id]) {
  $privacy = "AND (privacy='0' OR privacy='1' OR privacy='2' OR privacy='3')";
  } elseif($group_info[allow_members] == "1" & $is_logged_in == "yes" & mysql_num_rows(mysql_query("SELECT m_id FROM bhost_members WHERE u_id='$friend_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($count != 0) { $query .= "OR "; }
$query .= "(draft='0' AND u_id='$friend[member_u_id]' $privacy) ";
$count++;
}

// CREATE PAGE VARIABLES
$total_entries = mysql_num_rows(mysql_query("SELECT e_id FROM bhost_entries WHERE $query"));

if($user_info[entries_per_page] == 0) { $user_info[entries_per_page] = 5; }
if(($total_entries % $user_info[entries_per_page]) != 0) {
$maxpage = ($total_entries) / $user_info[entries_per_page] + 1;
} else {
$maxpage = ($total_entries) / $user_info[entries_per_page];
}
$maxpage = (int) $maxpage;
if($maxpage == 0) { $maxpage = 1; }
if($page > $maxpage) { $page = $maxpage; } elseif($page < 1) { $page = 1; }
$start = ($page - 1) * $user_info[entries_per_page];
$prev = $page - 1;
$next = $page + 1;

// REMOVE ANYTHING BETWEEN <IFPAGES> CONTAINERS IF ONLY ONE PAGE
if($maxpage == 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($page == 1) {
 $template = str_replace("<LaterLink>", "", $template);
 $template = str_replace("</LaterLink>", "", $template);
}

// REMOVE ANYTHING BETWEEN <EARLIERLINK> IF NOTHING EARLIER
if($page == $maxpage) {
 $template = str_replace("<EarlierLink>", "", $template);
 $template = str_replace("</EarlierLink>", "", $template);
}

// INPUT PAGE VARIABLES
$search_array2 = Array("<LaterLink>", "</LaterLink>", "<EarlierLink>", "</EarlierLink>", "<%CurrentPage%>", "<%TotalPages%>");
$replace_array2 = Array("<a class='laterlink' href='".url("index", "$user_info[username]", "", "", "", "", "$prev")."'>", "</a>", "<a class='earlierlink' href='".url("index", "$user_info[username]", "", "", "", "", "$next")."'>", "</a>", "$page", "$maxpage");
$template = str_replace($search_array2, $replace_array2, $template);

// REMOVE ENTRY CATEGORIES IF NOT ALLOWED
if($group_info[allow_entry_cat] != "1") {
 $ifcategoriesallowedcount = occurrencecount("<IfCategoriesAllowed>", "</IfCategoriesAllowed>", $template, "0");
 for($a=0;$a<$ifcategoriesallowedcount;$a++) {
 $template = str_replace("<IfCategoriesAllowed>".between("<IfCategoriesAllowed>", "</IfCategoriesAllowed>", $template)."</IfCategoriesAllowed>", "", $template);
 }
 $template = str_replace("<%EntryCategory%>", "", $template);
}


$entries = mysql_query("SELECT * FROM bhost_entries WHERE $query ORDER BY date DESC, e_id DESC LIMIT $start, $user_info[entries_per_page]");

// CHECK FOR ENTRIES
$entrycount = occurrencecount("<Entry>", "</Entry>", $template, "0");
for($i=0;$i<$entrycount;$i++) {
$insert = "";


$entry = between("<Entry>", "</Entry>", $template);
while($entry_info = mysql_fetch_assoc($entries)) {
$entry_author = mysql_fetch_assoc(mysql_query("SELECT u_id, g_id, username, display_name, avatar, format_date, format_time, show_comments, who_comments FROM bhost_users WHERE u_id='$entry_info[u_id]'"));
$numofcomments = mysql_num_rows(mysql_query("SELECT c_id FROM bhost_comments WHERE u_id='$entry_info[u_id]' AND e_id='$entry_info[e_id]'"));
$numoftrackbacks = mysql_num_rows(mysql_query("SELECT tb_id FROM bhost_trackbacks WHERE e_id='$entry_info[e_id]'"));
$author_group_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_groups WHERE g_id='$entry_author[g_id]'"));


$remove_entry_comments = "no";
$this_entry = $entry;
if($entry_info[comments] == "0") { 
 // REMOVE ANYTHING BETWEEN <IFCOMMENTSALLOWED> AND <COMMENT> CONTAINERS IF COMMENTS NOT ALLOWED IN ENTRY
 $ifcommentsallowedcount = occurrencecount("<IfCommentsAllowed>", "</IfCommentsAllowed>", $this_entry, "0");
 for($a=0;$a<$ifcommentsallowedcount;$a++) {
 $this_entry = str_replace("<IfCommentsAllowed>".between("<IfCommentsAllowed>", "</IfCommentsAllowed>", $this_entry)."</IfCommentsAllowed>", "", $this_entry);
 }
 $commentcontcount = occurrencecount("<Comment>", "</Comment>", $this_entry, "0");
 for($a=0;$a<$commentcontcount;$a++) {
 $this_entry = str_replace("<Comment>".between("<Comment>", "</Comment>", $this_entry)."</Comment>", "", $this_entry);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -