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

📄 functions.php

📁 1、上传所有文件至服务器目录。 2、使用 MYSQL 管理工具
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php
error_reporting(7);

// start prep shutdown function
$noshutdownfunc = 0; // #CHANGE ME IF YOU CAN'T USE register_shutdown_function
$ourtimenow = time(); // Make this available to all files

unset($table);

$table["user"] = $table_prefix."user";
$table["useractivation"] = $table_prefix."useractivation";
$table["usergroup"] = $table_prefix."usergroup";
$table["template"] = $table_prefix."template";
$table["musiclist"] = $table_prefix."musiclist";
$table["special"] = $table_prefix."special";
$table["musicbox"] = $table_prefix."box";
$table["class"] = $table_prefix."class";
$table["nclass"] = $table_prefix."nclass";
$table["sclass"] = $table_prefix."sclass";
$table["setting"] = $table_prefix."setting";
$table["settinggroup"] = $table_prefix."settinggroup";
$table["session"] = $table_prefix."session";
$table["lyric"] = $table_prefix."lyric";

unset($templatecache);


// ###################### Start getMusicListPage #######################
function getMusicListPage($results) {
  global $numOfListMusicPage,$curpage;
  $perpage = $numOfListMusicPage;
  $totalmusics = $results;

  if ($results <= $perpage) {
    return "";
  }

  $totalpages = ceil($results/$perpage);

  if ($curpage<1 || $curpage>$totalpages) {
    $curpage = 1;
  }

  if ($curpage>1) {
    $prevpage = $curpage-1;
    eval("\$prevpagelink = \"".gettemplate("musiclist_page_prevlink")."\";");
    eval("\$firstpagelink = \"".gettemplate("musiclist_page_firstpage")."\";");
  }
  if ($curpage<$totalpages) {
    $nextpage = $curpage+1;
    eval("\$nextpagelink = \"".gettemplate("musiclist_page_nextlink")."\";");
    eval("\$lastpagelink = \"".gettemplate("musiclist_page_lastpage")."\";");
  }
  eval("\$pages = \"".gettemplate("musiclist_page")."\";");
  return $pages;
}

// ###################### Start getfirststr #######################
function getfirststr($str,$length,$morestr="...") {
  if (strlen($str)>$length) {
    $returnstr = msubstr($str,0,$length).$morestr;
  } else {
    $returnstr = $str;
  }

  return $returnstr;
}

// ###################### Start msubstr #######################
function msubstr($str,$start,$length="") {
  if ($length=="") {
    $length = strlen($str);
  } else if ($length<0) {
    $length = strlen($str)-(-$length);
  }

  if ($start>strlen($str))
    return FALSE;

  $tmpstr = "";
  for ($i=$start; $i<$length; $i++) {
    if (ord(substr($str,$i,1))>0xa0) {
      $tmpstr.=substr($str,$i,2);
      $i++;
    } else {
      $tmpstr.=substr($str,$i,1);
    }
  }
  return $tmpstr;
}

// ###################### Start text2html ########################
function text2html($string, $allowhtml = true) {
  if ($allowhtml == false) {
    $string = htmlspecialchars($string);
  }
  $string = str_replace("  ", "&nbsp;&nbsp;", $string);
  $string = ereg_replace("(\r\n|\n|\r)", "<br />", $string);
  // $string = nl2br($string);
  return $string;
}

// ###################### Start stripenglishname ########################
function stripenglishname($string) {
  $string = preg_replace ("/\[[a-zA-Z, ]+\]/",
                         "",
                         $string); 
  return $string;
}

// ###################### Start getmusicinfo ######################
function getmusicinfo(&$musicid) {
  global $DB_site,$table;
  static $musiccache;

  $musicid = intval($musicid);
  if (!isset($musiccache[$musicid])) {
    $musiccache["$musicid"]=$DB_site->query_first("SELECT * FROM ".$table["musiclist"]."
                                                   WHERE ID='$musicid'");
  }

  return $musiccache[$musicid];
}

// ###################### Start getuserinfo #######################
function getuserinfo (&$userid) {
  global $DB_site,$table;
  static $usercache;

  $userid = intval($userid);
  if (!isset($usercache[$userid])) {
    $usercache["$userid"]=$DB_site->query_first("SELECT * FROM ".$table["user"]." 
                                         	WHERE ".$table["user"].".userid='$userid'");

  }

  return $usercache[$userid];
}

// ###################### Start dooutput #######################
function dooutput($vartext,$sendheader=1) {

  global $pagestarttime,$query_count,$showqueries,$querytime;

  if ($showqueries) {
    $pageendtime=microtime();

    $starttime=explode(" ",$pagestarttime);
    $endtime=explode(" ",$pageendtime);

    $totaltime=$endtime[0]-$starttime[0]+$endtime[1]-$starttime[1];

    $vartext.="<!-- Page generated in $totaltime seconds with $query_count queries -->";
  }

  if (!$showqueries) {
    echo dovars($vartext,$sendheader);
    flush();
  } else {
    $output=dovars($vartext,$sendheader);
    echo "\n<b>Page generated in $totaltime seconds with $query_count queries,\nspending $querytime doing MySQL queries and ".($totaltime-$querytime)." doing PHP things.</b></pre>";
    flush();
  }
}

// ###################### Start dovars #######################
function dovars($newtext,$sendheader=1) {
  // parses replacement vars

  global $replacementsetid,$gzipoutput,$gziplevel,$newpmmsg,$table;
  static $vars;

  if (connection_status()) {
    exit;
  }

  if ($gzipoutput and !headers_sent()) {
    $newtext=gzipoutput($newtext,$gziplevel);
  }

  if ($sendheader) {
    @header("Content-Length: ".strlen($newtext));
  }

  return $newtext;
}

// ###################### Start standarderror( #######################
function standarderror($error="",$headinsert="") {
  // print standard error page
  global $header,$footer,$headinclude,$webtitle,$hometitle,$bburl,$homeurl,$copyrighttext,$privacyurl,$contactuslink,$webmasteremail,$technicalemail,$faxnumber,$address,$companyname,$titleimage,$replyimage,$newthreadimage,$closedthreadimage,$lastvisitdate,$timenow,$session,$logincode;

  $title=$webtitle;

  $pagetitle = "$title";
  $errormessage = $error;

  eval("dooutput(\"".gettemplate("standarderror")."\");");
  exit;

}

// ###################### Start standardredirect( #######################
function standardredirect($message="",$url="") {
  // print standard redirect page

  global $header,$footer,$headinclude,$headnewpm,$toplinks,$forumjump,$timezone,$webtitle,$hometitle,$bburl,$homeurl,$copyrighttext,$privacyurl,$contactuslink,$webmasteremail,$technicalemail,$faxnumber,$address,$companyname,$titleimage,$replyimage,$newthreadimage,$closedthreadimage,$lastvisitdate,$timenow,$session;

  $title=$webtitle;

  $pagetitle = "$title";
  $errormessage = $message;

  $url = str_replace("\"", "", $url);

  eval("dooutput(\"".gettemplate("standardredirect")."\");");
  exit;

}

// ###################### Start smallredirect( #######################
function smallredirect($message="",$url="") {
  // print standard redirect page

  global $headinclude,$toplinks,$webtitle,$hometitle,$bburl,$homeurl,$copyrighttext,$privacyurl,$contactuslink,$webmasteremail,$technicalemail,$faxnumber,$address,$companyname,$titleimage,$replyimage,$newthreadimage,$closedthreadimage,$lastvisitdate,$timenow,$session;

  $errormessage = $message;

  $url = str_replace("\"", "", $url);

  eval("dooutput(\"".gettemplate("smallredirect")."\");");
  exit;

}

// ###################### Start iif #######################
function iif ($expression,$returntrue,$returnfalse) {

  if ($expression==0) {
    return $returnfalse;
  } else {
    return $returntrue;
  }

}

// ###################### Start repeatchar #######################
function repeatchar($char,$times) {
  // returns the contents of $char repeatd $times times
  $counter=0;

  while ($counter++<$times) {
    $retstring.=$char;
  }

  return $retstring;
}

// ###################### Start censortext #######################
unset($censorword);
function censortext($text) {
  global $enablecensor,$censorwords,$censorword,$censorchar;
  if ($enablecensor==1 and $censorwords!="") {
    if (!isset($censorword)) {
      $censorwords = preg_quote($censorwords);
      $censorwords = str_replace('/', '\\/', $censorwords);
      $censorword=explode(" ",$censorwords);
    } else {
      reset($censorword);
    }

    while (list($key,$val)=each($censorword)) {
      if ($val!="") {
        if (substr($val,0,2)=="\\{") {
          $val=substr($val,2,-2);

          $text=trim(preg_replace("/([^A-Za-z])".$val."(?=[^A-Za-z])/si","\\1".repeatchar($censorchar,strlen($val))," $text "));
        } else {
          $text=trim(preg_replace("/$val/si",repeatchar($censorchar,strlen($val))," $text "));
        }
      }
    }
  }

  $text = str_replace(chr(173), '_', $text);
  $text = str_replace(chr(160), '_', $text);

  return $text;
}

// ###################### Start customcensortext #######################
function customcensortext($text) {
  global $ctCensorWords,$censorchar;

  if (!isset($ctcensorword)) {
    $ctcensorword=explode(" ",$ctCensorWords);
  }

  while (list($key,$val)=each($ctcensorword)) {
    if ($val!="") {
      if (substr($val,0,1)=="{") {
        $val=substr($val,1,-1);
        $text=trim(eregi_replace("([^A-Za-z])".$val."([^A-Za-z])","\\1".repeatchar($censorchar,strlen($val))."\\2"," $text "));
      } else {
        $text=trim(eregi_replace($val,repeatchar($censorchar,strlen($val))," $text "));
      }
    }
  }
  return $text;
}

// ###################### Start cachetemplate #######################
function cachetemplates($templateslist) {
  // $templateslist: comma delimited list
  global $templatecache,$DB_site,$table;

  // add in sql info
  //$templateslist=str_replace(",","' OR title='",$templateslist);
  $templateslist=str_replace(',', "','", addslashes($templateslist));

  // run query
  $temps=$DB_site->query("SELECT template,title
                          FROM ".$table["template"]."
                          WHERE title IN ('$templateslist')");

  // cache templates
  while ($temp=$DB_site->fetch_array($temps)) {
    $templatecache["$temp[title]"]=$temp['template'];
  }
  unset($temp);
  $DB_site->free_result($temps);

}

// ###################### Start gettemplate #######################
function gettemplate($templatename,$escape=1,$gethtmlcomments=1) {
  // gets a template from the db or from the local cache
  global $templatecache,$DB_site,$addtemplatename,$table;

  if (isset($templatecache[$templatename])) {
    $template=$templatecache[$templatename];
  } else {
    $gettemp=$DB_site->query_first("SELECT template FROM ".$table["template"]." WHERE title='".addslashes($templatename)."'");
    $template=$gettemp[template];
    $templatecache[$templatename]=$template;
 }

⌨️ 快捷键说明

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