📄 functions.php
字号:
<?php/*======================================================================*\|| #################################################################### |||| # VirtuaNews - 1.0.4 Pro License ID - [WDYL-WTN]|| # ---------------------------------------------------------------- # |||| # All code in this file is ?2002 VirtuaSystems . # |||| # This file may not be redistributed in whole or significant part. # |||| # --------------- VIRTUANEWS IS NOT FREE SOFTWARE ---------------- # |||| # http://www.virtuanews.co.uk # |||| # http://www.virtuanews.co.uk/license.php # |||| #################################################################### ||\*======================================================================*/function autoparseurl ($string) { $searcharray[] = "/(\s)(((https?||ftp):\/\/|www\.)\w+[^\s\[\]]+)/i"; $searcharray[] = "/^(((https?|ftp):\/\/|www\.)\w+[^\s\[\]]+)/i"; $replacearray[] = "\\1[url]\\2[/url]"; $replacearray[] = "[url]\\1[/url]"; $string = preg_replace($searcharray,$replacearray,$string); return $string;}function checkipban() { global $ipaddress,$banhost,$banip,$themeid,$pagesetid,$stylevar,$defaultcat_loggedout,$cat_arr,$theme_arr; if ($banip != "") { $addresses = explode(' ', trim($banip)); foreach ($addresses AS $val) { $val = trim($val); if (strpos($val, '*') !== false) { $check = explode('.', $val); if (!isset($iparray)) { $iparray = explode('.', $ipaddress); } $match = 0; foreach ($check AS $key => $val) { if (($val == $iparray[$key]) || ($val == '*')) { $match ++; } } if ($match == 4) { $themeid = $cat_arr[$defaultcat_loggedout][defaulttheme]; $pagesetid = $theme_arr[$themeid][pagesetid]; $stylevar = getstylevars($theme_arr[$themeid][stylesetid]); standarderror("ip_banned"); } } elseif ($ipaddress == $val) { $themeid = $cat_arr[$defaultcat_loggedout][defaulttheme]; $pagesetid = $theme_arr[$themeid][pagesetid]; $stylevar = getstylevars($theme_arr[$themeid][stylesetid]); standarderror("ip_banned"); } } } if ($banhost != "") { $hostnamelist = explode(" ",preg_replace("/[[:space:]]+/"," ",trim($banhost))); $hostname = gethostbyaddr($ipaddress); while (list($key,$val) = each($hostnamelist)) { if (preg_match("/$val/i",$hostname)) { $themeid = $cat_arr[$defaultcat_loggedout][defaulttheme]; $pagesetid = $theme_arr[$themeid][pagesetid]; $stylevar = getstylevars($theme_arr[$themeid][stylesetid]); standarderror("ip_banned"); } } } return true;}function checknewsprogram() { $getdata = query("SELECT id,catid,time FROM news_news WHERE program = 1"); while ($data_arr = fetch_array($getdata)) { if ($data_arr['time'] < time()) { $newsids .= iif($newsids,",'$data_arr[id]'","'$data_arr[id]'"); } } if ($newsids) { query("UPDATE news_news SET program = '0' WHERE id IN($newsids)"); include("includes/adminfunctions.php"); include("includes/writefunctions.php"); writeallpages(); } unset($newsids);}function checkurl($url,$text="") { $newurl = $url; if(!preg_match("![a-z]://!si", $url)) { $newurl = "http://$newurl"; } $newurl = str_replace("&","&",$newurl); $newurl = str_replace("&amp;","&",$newurl); $text = iif((trim($text) == "") | ($text == $url),iif(strlen($url)>55,substr($url,0,35)."...".substr($url,-15),$url),$text); return "<a href=\"$newurl\" target=\"_blank\">".str_replace('\"','"',$text)."</a>";}function codetagparse($string,$allowhtml,$donewline) { $string = str_replace("\r\n","\n",trim($string)); if ($donewline) { $string = str_replace("<br />\n","\n",$string); } if ($allowhtml) { $string = str_replace("<","&lt;",$string); $string = str_replace(">","&gt;",$string); $string = str_replace("<","<",$string); $string = str_replace(">",">",$string); $string = str_replace("\\\"",""",$string); } $string = str_replace("\\\"","\"",$string); $string = "<blockquote><b>代码:</b><hr /><pre>$string</pre><hr /></blockquote>"; return $string;}function countchar($string,$char) { $charpos = strstr($string,$char); if ($charpos != "") { return countchar(substr($charpos,strlen($char)),$char)+1; } else { return 0; }}function echooutput($page) { global $gzipoutput,$gziplevel,$showqueries,$pagestarttime,$db_query_count,$themeid,$db_query_time,$stylevar; static $replace_data; if ($gzipoutput) { $page = gzipoutput($page,$gziplevel); header("Content-Length: ".strlen($page)); } if ($showqueries) { $output = $page; $pageendtime = microtime(); $starttime = explode(" ",$pagestarttime); $endtime = explode(" ",$pageendtime); $totaltime = $endtime[0]-$starttime[0]+$endtime[1]-$starttime[1]; echo "Page generated in $totaltime seconds with $db_query_count queries<br>".round((($db_query_time/$totaltime)*100),2)."% of the time doing MySQL things and ".round(((($totaltime-$db_query_time)/$totaltime)*100),2)."% doing PHP things"; flush(); exit; } else { echo $page; flush(); exit; }}function emailusers($newsid,$postername) { global $webmasteremail,$enableemail,$homeurl,$sitename,$userid,$posttime,$insertid,$foruminfo,$cat_arr; $lastcommentid = $insertid; $postername = stripslashes($postername); if ($enableemail) { $getdata = query(" SELECT news_subscribe.id AS subscribeid, ".$foruminfo[user_table].".".$foruminfo[userid_field]." AS userid, ".$foruminfo[user_table].".".$foruminfo[email_field]." AS email, ".$foruminfo[user_table].".".$foruminfo[username_field]." AS username, news_news.title, news_news.catid FROM news_subscribe LEFT JOIN $foruminfo[user_table] ON news_subscribe.userid = ".$foruminfo[user_table].".".$foruminfo[userid_field]." LEFT JOIN news_news ON news_news.id = $newsid WHERE (news_subscribe.newsid = $newsid) AND (news_subscribe.emailupdate = 1) AND (".$foruminfo[user_table].".".$foruminfo[userid_field]." <> $userid) AND (news_subscribe.lastview < $posttime) "); while ($data_arr = fetch_array($getdata)) { $subscribeids .= iif($subscribeids,",'$data_arr[subscribeid]'","'$data_arr[subscribeid]'"); $newstitle = $data_arr[title]; $newscatid = $data_arr[catid]; $newscategory = $cat_arr[$newscatid][name]; $emailtoname = $data_arr[username]; eval("\$email_subject = \"".returnpagebit("comments_emailnotify_subject")."\";"); eval("\$email_msg = \"".returnpagebit("comments_emailnotify_msg")."\";"); @mail($data_arr[email],$email_subject,$email_msg,"从: \"$sitename Mailer\" <$webmasteremail>"); } if ($subscribeids) { query("UPDATE news_subscribe SET emailupdate = '0' WHERE id IN ($subscribeids)"); } } else { return false; }}function getbrowser() { global $useragent; if ((ereg("Nav",$useragent) | ereg("Gold",$useragent) | ereg("X11",$useragent) | ereg("Mozilla",$useragent) | ereg("Netscape",$useragent)) & (!ereg("MSIE",$useragent) & !ereg("Konqueror",$useragent))) { $browser = "Netscape"; } elseif (ereg("Opera",$useragent)) { $browser = "Opera"; } elseif (ereg("MSIE",$useragent)) { $browser = "MSIE"; } elseif (ereg("Lynx",$useragent)) { $browser = "Lynx"; } elseif (ereg("WebTV",$useragent)) { $browser = "WebTV"; } elseif (ereg("Konqueror",$useragent)) { $browser = "Konqueror"; } elseif (eregi("bot",$useragent) | ereg("Google",$useragent) | ereg("Slurp",$useragent) | ereg("Scooter",$useragent) | eregi("Spider",$useragent) | eregi("Infoseek",$useragent)) { $browser = "Bot"; } else { $browser = "Other"; } return $browser;}function getcat_arr() { $cat_arr = array(); $getdata = query("SELECT * FROM news_category ORDER BY displayorder"); while ($data_arr = fetch_array($getdata)) { $catid = $data_arr[id]; $cat_arr[$catid] = array(); $cat_arr[$catid][parentid] = $data_arr[parentid]; $cat_arr[$catid][children] = $data_arr[children]; $cat_arr[$catid][name] = $data_arr[name]; $cat_arr[$catid][description] = $data_arr[description]; $cat_arr[$catid][image] = $data_arr[image]; $cat_arr[$catid][posts] = $data_arr[posts]; $cat_arr[$catid][allowcomments] = $data_arr[allowcomments]; $cat_arr[$catid][allowview] = $data_arr[allowview]; $cat_arr[$catid][showsitestats] = $data_arr[showsitestats]; $cat_arr[$catid][showforumstats] = $data_arr[showforumstats]; $cat_arr[$catid][showforumoptions] = $data_arr[showforumoptions]; $cat_arr[$catid][showpoll] = $data_arr[showpoll]; $cat_arr[$catid][showannouncement] = $data_arr[showannouncement]; $cat_arr[$catid][showsubcats] = $data_arr[showsubcats]; $cat_arr[$catid][defaulttheme] = $data_arr[defaulttheme]; $cat_arr[$catid][forcetheme] = $data_arr[forcetheme]; $cat_arr[$catid][recentpost] = $data_arr[recentpost]; $cat_arr[$catid][display] = $data_arr[display]; $cat_arr[$catid][displayorder] = $data_arr[displayorder]; $cat_arr[$catid][displaymain] = $data_arr[displaymain]; $cat_arr[$catid][pollid] = $data_arr[pollid]; } foreach ($cat_arr AS $key => $val) { if ($val[parentid] == 0) { $cat_arr[$key][topid] = $key; } elseif ($cat_arr[$val[parentid]][parentid] == 0) { $cat_arr[$key][topid] = $val[parentid]; } else { $cat_arr[$key][topid] = $cat_arr[$val[parentid]][parentid]; } } return $cat_arr;}function getcat_nav() { global $cat_arr,$catid,$location; if (!empty($cat_arr)) { foreach ($cat_arr as $key => $cat) { $cat[id] = $key; $cat_nav .= returncatnav($cat,0,1); } } return $cat_nav;}function getmodoptions($modid="",$modname="",$options="") { if (!$options) { if ($modid) { $data_arr = query_first("SELECT options FROM news_module WHERE id = $modid"); } else { if ($data_arr = query_first("SELECT options FROM news_module WHERE name = '$modname'")) { } else { standarderror("invalid_id"); } } $options = $data_arr[options]; } $options = explode("||||||",$options); foreach ($options AS $temp) { $option_temp = explode("/\\/\\/\\",$temp); $GLOBALS[$option_temp[0]] = $option_temp[1]; } unset($data_arr);}function getos() { global $useragent; if (ereg("Win",$useragent)) { $os = "Windows"; } elseif (ereg("Mac",$useragent) | ereg("PPC",$useragent)) { $os = "Mac"; } elseif (ereg("Linux",$useragent)) { $os = "Linux"; } elseif (ereg("SunOS",$useragent)) { $os = "SunOS"; } elseif (ereg("IRIX",$useragent)) { $os = "IRIX"; } elseif (ereg("BeOS",$useragent)) { $os = "BeOS"; } elseif (eregi("OS/2",$useragent)) { $os = "OS/2"; } else { $os = "Other"; } return $os;}function getsmiliedata() { global $foruminfo; static $smilie_data; if ($smilie_data) { data_seek($smilie_data,0); } else { $smilie_data = query("SELECT ".$foruminfo[smilietitle_field]." AS title,".$foruminfo[smilietext_field]." AS smilietext,".$foruminfo[smiliepath_field]." AS smiliepath FROM ".$foruminfo[smilie_table]); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -