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

📄 archive.php

📁 一个全功能的国外博客商业程序
💻 PHP
字号:
<?
include "header.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" & $is_logged_in == "yes" & 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')";
}


if(isset($_GET['m'])) { 
$m = $_GET['m'];
 if((int)$m < 1 | (int)$m > 12) {
 $newest_entry = 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 1"));
 $thism = cdate("n", $newest_entry[date]);
 } else {
 $thism = $m;
 } 
} else { 
$newest_entry = 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 1"));
$thism = cdate("n", $newest_entry[date]);
}

if(isset($_GET['y'])) { 
$y = $_GET['y'];
 if((int)$y != $y | !is_numeric($y)) {
 $newest_entry = 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 1"));
 $thisy = cdate("Y", $newest_entry[date]);
 } else {
 $thisy = $y;
 } 
} else { 
$newest_entry = 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 1"));
$thisy = cdate("Y", $newest_entry[date]);
}


// 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;", "<%Title%>", "<%Description%>", "<%Avatar%>", "<%Email%>", "<%ProfileURL%>", "<%MainPageURL%>", "<%ArchiveURL%>", "<%SiteFeedURL%>", "<%FriendsPageURL%>");
$replace_array = Array("<", ">", "\"", "$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 <IFMAINPAGE> CONTAINERS
$ifentrypagecount = occurrencecount("<IfMainPage>", "</IfMainPage>", $template, "0");
for($a=0;$a<$ifentrypagecount;$a++) {
$template = str_replace("<IfMainPage>".between("<IfMainPage>", "</IfMainPage>", $template)."</IfMainPage>", "", $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);
}

// REMOVE ANYTHING BETWEEN <IFPAGES> CONTAINERS
$ifpagescount = occurrencecount("<IfPages>", "</IfPages>", $template, "0");
for($a=0;$a<$ifpagescount;$a++) {
$template = str_replace("<IfPages>".between("<IfPages>", "</IfPages>", $template)."</IfPages>", "", $template);
}

// REMOVE ENTRY CATEGORIES IF NOT ALLOWED
 $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);


// 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>$archive1</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);
}

// REMOVE ANYTHING BETWEEN <IFCOMMENTSALLOWED> AND <COMMENT> CONTAINERS
 $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);
 }

// REMOVE ANYTHING BETWEEN <IFCOMMENTPOSTALLOWED> CONTAINERS
 $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
 $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);
 }

// REMOVE ANYTHING BETWEEN <ENTRY> CONTAINERS
$entrycount = occurrencecount("<Entry>", "</Entry>", $template, "0");
for($i=0;$i<$entrycount;$i++) {
$template = str_replace("<Entry>".between("<Entry>", "</Entry>", $template)."</Entry>", "", $template);
}



// BUILD ARCHIVES
$archive_data = "";
 $month_date = strtotime("$thism/1/$thisy 12:00:00 am");

  //REPLACE WindowTitle VARIABLE
  $template = str_replace("<%WindowTitle%>", "$user_info[title] - $archive2 (".cdate("F Y", $month_date).") - BlogHoster", $template);

  if(cdate("n", $month_date) == 1 | cdate("n", $month_date) == 3 | cdate("n", $month_date) == 5 | cdate("n", $month_date) == 7 | cdate("n", $month_date) == 8 | cdate("n", $month_date) == 10 | cdate("n", $month_date) == 12) {
  $days = 31;
  } elseif(cdate("n", $month_date) == 4 | cdate("n", $month_date) == 6 | cdate("n", $month_date) == 9 | cdate("n", $month_date) == 11) {
  $days = 30;
  } elseif(cdate("n", $month_date) == 2) {
  $days = 28;
  }
 $next_month_date = $month_date+(60*60*24*$days);
 $month_entries = mysql_query("SELECT e_id, title, date FROM bhost_entries WHERE u_id='$user_info[u_id]' AND date >= '$month_date' AND date < '$next_month_date' AND draft='0' $privacy ORDER BY date DESC");
  while($month_info = mysql_fetch_assoc($month_entries)) {
  if(str_replace(" ", "", $month_info[title]) == "") { $title = "<i>$archive1</i>"; } else { $title = $month_info[title]; }
  $title = str_replace("&lt;", "<", $title);
  $title = str_replace("&gt;", ">", $title);
  $archive_data .= "<a href='".url("entry", "$user_info[username]", "$month_info[e_id]")."'>".cdate($user_info[format_date], $month_info[date]);
  if($user_info[showtitle] == "1") { $archive_data .= ": $title"; }
  $archive_data .= "</a><br>";
  }

  $newest_entry = 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 1"));
  $newest_year = cdate("Y", $newest_entry[date]);
  $oldest_entry = 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 ASC LIMIT 1"));
  $oldest_year = cdate("Y", $oldest_entry[date]);
  $loop = $newest_year - $oldest_year + 1;
  $year = $newest_year;
  for($a=0;$a<$loop;$a++) {
   $year_date = strtotime("1/1/$year 12:00:00 am");
   $next_year_date = $year_date+(60*60*24*365) + cdate("L", $year_date)*60*60*24;
   if(mysql_num_rows(mysql_query("SELECT e_id FROM bhost_entries WHERE u_id='$user_info[u_id]' AND date >= '$year_date' AND date < '$next_year_date' AND draft='0' $privacy")) != 0) {
   $archive_data .= "<br><b>$year</b><br>";
     for($c=12;$c>0;$c--) {
       $month_date = strtotime("$c/1/$year 12:00:00 am");
       if(cdate("n", $month_date) == 1 | cdate("n", $month_date) == 3 | cdate("n", $month_date) == 5 | cdate("n", $month_date) == 7 | cdate("n", $month_date) == 8 | cdate("n", $month_date) == 10 | cdate("n", $month_date) == 12) {
       $days = 31;
       } elseif(cdate("n", $month_date) == 4 | cdate("n", $month_date) == 6 | cdate("n", $month_date) == 9 | cdate("n", $month_date) == 11) {
       $days = 30;
       } elseif(cdate("n", $month_date) == 2) {
       $days = 28;
       }
       $next_month_date = $month_date+(60*60*24*$days);
       if(mysql_num_rows(mysql_query("SELECT e_id, title, date FROM bhost_entries WHERE u_id='$user_info[u_id]' AND date >= '$month_date' AND date < '$next_month_date' AND draft='0' $privacy")) != 0) {
       $archive_data .= "<a href='".url("archive", "$user_info[username]", "", "$year", "$c")."'>".cdate("F Y", $month_date)."</a><br>";
       }
     }
   }
   $year = $year-1;
  }


// INPUT ARCHIVES
$template = str_replace("<%ArchiveInfo%>", "$archive_data", $template);
$template = str_replace("<%CurrentPage%>", "1", $template);
$template = str_replace("<%TotalPages%>", "1", $template);


// REPLACE ADS AT TOP
if(($group_info[show_ad] == 1 OR $group_info[show_ad] == 3) AND $group_info[html_ad] != "") {
  // FIRST CHECK FOR BODY TAG
  if(preg_match("/<(body)(.*)>/i", $template, $match1)) {
  $template = str_replace($match1[0], "$match1[0]$group_info[html_ad]", $template); 
  // IF BODY TAG CANNOT BE FOUND, CHECK FOR HEAD TAG
  } elseif(preg_match("/<(head)(.*)>/i", $template, $match2)) {
  $template = str_replace($match2[0], "$group_info[html_ad]$match2[0]", $template); 
  // IF BODY AND HEAD TAGS CANT BE FOUND, STICK AD AT VERY TOP
  } else {
  $template = "$group_info[html_ad]$template"; 
  }
}

// REPLACE ADS AT BOTTOM
if(($group_info[show_ad] == 2 OR $group_info[show_ad] == 3) AND $group_info[html_ad_bottom] != "") {
  // FIRST CHECK FOR ENDING BODY TAG
  if(preg_match("/(<\/body>)/i", $template, $match1)) {
  $template = str_replace($match1[0], "$group_info[html_ad_bottom]$match1[0]", $template); 
  } elseif(preg_match("/<(\/html)(.*)>/i", $template, $match2)) {
  $template = str_replace($match2[0], "$group_info[html_ad_bottom]$match2[0]", $template); 
  } else {
  $template = "$template$group_info[html_ad_bottom]"; 
  }
}


$search_vars = Array("<IfPages>", "</IfPages>", "<EarlierLink>", "</EarlierLink>", "<LaterLink>", "</LaterLink>", "<RecentEntry>", "</RecentEntry>", "<Entry>", "</Entry>", "<IfCommentsAllowed>", "</IfCommentsAllowed>", "<IfCommentPostAllowed>", "</IfCommentPostAllowed>", "<Comment>", "</Comment>", "<CommentEdit>", "</CommentEdit>", "<CommentDelete>", "</CommentDelete>", "<IfMainPage>", "</IfMainPage>", "<IfEntryPage>", "</IfEntryPage>", "<IfArchivePage>", "</IfArchivePage>", "<%TrackbackRDF%>", "<IfTrackbacksAllowed>", "</IfTrackbacksAllowed>");
$template = str_replace($search_vars, "", $template);



// OUTPUT WEBLOG
echo $template;


?>

⌨️ 快捷键说明

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