?? global.php
字號(hào):
<?php
/**
* HaCn.Com 哈克! 主流音樂系統(tǒng) V1.0
* Copyright (c) 2007 Ghost. All rights reserved.
* Authors: Ghost
* http://www.HaCn.Com
* xuedd@163.com
*
**/
$magic_quotes_gpc = get_magic_quotes_gpc();
$register_globals = @ini_get('register_globals');
if(!$register_globals || !$magic_quotes_gpc)
{
@extract($HTTP_POST_FILES, EXTR_SKIP);
@extract($HTTP_POST_VARS, EXTR_SKIP);
@extract($HTTP_GET_VARS, EXTR_SKIP);
}
@extract($_REQUEST);
@extract($GLOBALS, EXTR_SKIP);
require("inc/config.php");
require("inc/text_function.php");
require("$datadir/manager.php");
error_reporting(0);
unset($_ENV,$HTTP_ENV_VARS,$_REQUEST,$HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_POST_FILES,$HTTP_COOKIE_VARS);
foreach($_POST as $_key=>$_value){
$_POST[$_key]=str_replace(array('|','$','..'),array('|','$','..'),$_POST[$_key]);
!ereg("^\_",$_key) && !$$_key && $$_key=$_POST[$_key];
}
foreach($_GET as $_key=>$_value){
$_GET[$_key]=str_replace(array('|','$','..'),array('|','$','..'),$_GET[$_key]);
!ereg("^\_",$_key) && !$$_key && $$_key=$_GET[$_key];
}
$timestamp=time();
if ($REQUEST_URI == $HTTP_COOKIE_VARS['lastpath'] && ($timestamp-$HTTP_COOKIE_VARS['lastvisit_fr']<$refreshtime)) {
Showmsg("no","本次顯示禁止,原因:訪問同一URL的刷新時(shí)間小于$refreshtime秒。","關(guān)閉本頁","javascript:window.close()");
exit;
}
//Cookie功能
function Cookie($ck_Var,$ck_Value,$ck_Time = 'F'){
global $timestamp;
$ck_Time = $ck_Time == 'F' ? $timestamp + 31536000 : ($ck_Value == '' && $ck_Time == 0 ? $timestamp - 31536000 : $ck_Time);
setcookie($ck_Var,$ck_Value,$ck_Time);
}
function GetCookie($Var){
return $_COOKIE[$Var];
}
//禁止IP訪問
$i_p=getenv('REMOTE_ADDR');
$i_p1 = getenv('HTTP_X_FORWARDED_FOR');
if (($i_p1 != "") && ($i_p1 != "unknown")) $i_p=$i_p1;
ipbanned();
function ipbanned() {
global $i_p,$datadir;
if (!file_exists("$datadir/ipbans.php")) return;
$term_bannedmembers = file("$datadir/ipbans.php");
if (empty($term_bannedmembers)) return;
$count = count($term_bannedmembers);
for ($i=0; $i<$count; $i++) {
$bannedip = trim($term_bannedmembers[$i]);
if (!$bannedip) continue;
if ( strpos($i_p , $bannedip)===0 ) {
Showmsg("no","對(duì)不起,你的 IP 被禁止訪問站!如有疑問,請(qǐng)聯(lián)系管理員。","關(guān)閉本頁","javascript:window.close()");
exit;
}
}
}
// 安全轉(zhuǎn)換函數(shù),把部分系統(tǒng)禁止的標(biāo)簽剔除
function safeconvert($msg){
$msg = str_replace('&','&',$msg);
$msg = str_replace(' ',' ',$msg);
$msg = str_replace('"','"',$msg);
$msg = str_replace("'",''',$msg);
$msg = str_replace("\t"," ",$msg);
$msg = str_replace("<","<",$msg);
$msg = str_replace(">",">",$msg);
$msg = str_replace("\r","",$msg);
$msg = str_replace("\n","<br />",$msg);
$msg = str_replace("|","│",$msg);//|
$msg = str_replace(" "," ",$msg);
return $msg;
}
// 讀文件
function readfromfile($file_name)
{
$filenum = fopen($file_name, "r");
flock($filenum, LOCK_SH);
$file_data = fread($filenum, filesize($file_name));
fclose($filenum);
return $file_data;
}
// 寫文件
function writetofile($file_name, $data, $method = "w")
{
$filenum = fopen($file_name, $method);
flock($filenum, LOCK_EX);
$file_data = fwrite($filenum, $data);
fclose($filenum);
return $file_data;
}
//獲取文件后綴名
function lastfilename($file_name)
{
$lastname=explode(".",$file_name);
$lastnum=count($lastname)-1;
return $lastname[$lastnum];
}
// 中文字符串截取
function gbsubstr($str, $start, $len)
{
$tmpstr="";
if (strlen($str) > $len) {
$strlen = $start + ($len-4);
for($i = 0;$i < $strlen;$i++) {
if (ord(substr($str, $i, 1)) > 0xa0){
$tmpstr .= substr($str, $i, 2);
$i++;
}
else {
$tmpstr .= substr($str, $i, 1);
}
}
$tmpstr .= "...";
return $tmpstr;
}
else {
return $str;
}
}
//分頁函數(shù)
function numofpage($count,$page,$numofpage,$url,$max=0)
{
$total=$numofpage;
$max && $numofpage > $max && $numofpage=$max;
$pages="<span class=\"PageNav\">";
if ($numofpage <= 1 || !is_numeric($page)){
$pages.="共有記錄 {$count} 條 | 只有一頁</span><br>";
return $pages;
}else{
$pages.="分頁:$page/$numofpage <a href=\"{$url}page=1\"><< </a>";
$flag=0;
for($i=$page-3;$i<=$page-1;$i++)
{
if($i<1) continue;
$pages.=" <a href='{$url}page=$i'> $i </a>";
}
$pages.=" <b>[$page]</b> ";
if($page<$numofpage)
{
for($i=$page+1;$i<=$numofpage;$i++)
{
$pages.=" <a href='{$url}page=$i'> $i </a>";
$flag++;
if($flag==4) break;
}
}
$pages.=" <input type='text' size='2' style='height:16px; border:1px solid #698CC3' onkeydown=\"javascript: if(event.keyCode==13) location='{$url}page='+this.value;\"> <a href=\"{$url}page=$numofpage\"> >></a> </span><br>";
return $pages;
}
}
//時(shí)間函數(shù)
function get_time($infoatetime){
$t=getdate($infoatetime);
$hour=$t['hours'];
$min=$t['minutes'];
if (strlen($min)==1) $min="0".$min;
return "{$hour}:{$min}";
}
function get_date($infoatetime){
$t=getdate($infoatetime);
$year=$t['year'];
$mon=$t['mon'];
$mday=$t['mday'];
return "{$year}-{$mon}-{$mday}";
}
function get_datetime($infoatetime){
$t=getdate($infoatetime);
$year=$t['year'];
$mon=$t['mon'];
$mday=$t['mday'];
$hour=$t['hours'];
$min=$t['minutes'];
return "{$year}-{$mon}-{$mday} {$hour}:{$min}";
}
//音樂分類顯示
function MusicNav(){
global $datadir;
$list=file("$datadir/cat.php");
$count=count($list);
$catlist="-->\n";
for($i=0;$i<$count;$i++){
$detail=explode("|", trim($list[$i]));
$catlist.="<li><a href=\"list.php?catid=$detail[0]\">$detail[1]</a></li>";
}
$catlist.="<!--";
echo $catlist;
}
//取得音樂分類
function get_catid() {
global $cat_name,$catid,$cat_time,$ckeckid,$datadir;
$list=file("$datadir/cat.php");
$ckeckid=0;
$count=count($list);
for ($i=0; $i<$count; $i++) {
$detail=explode("|", trim($list[$i]));
if ($detail[0]==$catid) {
$cat_name=$detail[1];
$cat_time=$detail[2];
$ckeckid=1;
break;
}
}
}
//取得歌手分類
function get_singerid() {
global $singer_name,$catid,$singerid,$singer_time,$nckeckid,$datadir;
$list=file("$datadir/singer.php");
$nckeckid=0;
$count=count($list);
for ($i=0; $i<$count; $i++) {
$detail=explode("|", trim($list[$i]));
if ($detail[1]==$singerid && $detail[0]==$catid) {
$singer_name=$detail[2];
$singer_time=$detail[3];
$nckeckid=1;
break;
}
}
}
//推薦歌曲
//$j 為截?cái)嘧址麄€(gè)數(shù)類型;$num為顯示條數(shù)
function commend($url,$num,$j){
if(empty($j)) $j=0;
global $datadir;
$song_info=@file("$datadir/$url.php");
$c=min(count($song_info),$num);
echo"-->";
for ($i=0; $i<$c; $i++){
$detail=explode("|",$song_info[$i]);
$allname=$detail[3];
$listshow="";
if($j!=0) {if (strlen($detail[3])>=24) $detail[3]=substr($detail[3],0,22)."...";}
else{ if (strlen($detail[3])>=32) $detail[3]=substr($detail[3],0,30)."...";} //截取字符串
$listshow.= "<li><a href=\"play.php?id=$detail[2]\" title=\"$allname\" target=\"_blank\">$detail[3]</a></li>\n";
echo $listshow;
}
echo"<!--";
}
//排行
//$j 為截?cái)嘧址麄€(gè)數(shù)類型;$num為顯示條數(shù)
function top($url,$num,$j){
if(empty($j)) $j=0;
global $datadir,$skinpath,$skin;
$song_info=@file("$datadir/$url.php");
$c=min(count($song_info),$num);
echo"-->";
for ($i=0; $i<$c; $i++){
$detail=explode("|",$song_info[$i]);
$allname=$detail[3];
$listshow="";
if($j!=0) {if (strlen($detail[3])>=24) $detail[3]=substr($detail[3],0,22)."..";}
elseif (strlen($detail[3])>=32) { $detail[3]=substr($detail[3],0,30)."...";} //截取字符串
$listshow.= "<li><a href=\"play.php?id=$detail[2]\" title=\"$allname\" target=_blank>$detail[3]</a></li>\n";
echo $listshow;
}
echo"<!--";
}
//信息顯示
function Showmsg($yesno,$msg_info,$goto,$url){
global $skinpath,$skin;
require_once PrintEot('showmsg');
exit;
}
//頁面底部
function footer(){
global $site_name,$site_url,$admin_email,$manager;
include PrintEot('footer');
exit;
}
function SafePath($Path){
if(strpos($Path,'..')!==false){
Showmsg("no","非法操作,請(qǐng)返回!","返回","javascript:history.back(1)");
}
}
//頁面模板輸出
function PrintEot($template,$EXT="html"){
global $skinpath,$skin;
SafePath($template);
if(empty($template)) $template='Nopage.$EXT';
if(file_exists("./$skinpath/$skin/$template.$EXT"))
$path="./$skinpath/$skin/$template.$EXT";
else $path="./$skinpath/default/$template.$EXT";
return $path;
}
?>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -