www.gusucode.com > 网猫影视系统NetMao Movie 4.6.6 开源版源码程序 > upload/inc/global.func.php
<?php /* *###################################### * Netmao Movie 4.x - NetMao Movie System * Copyright (c) 2007-2008 NetMao.cn * For further information go to http://www.netmao.cn/ * This copyright notice must stay intact for use. *###################################### */ if(!defined('IN_NetMao')) exit('Access Denied'); function daddslashes($string, $force = 0) { !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()); if(!MAGIC_QUOTES_GPC || $force) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = daddslashes($val, $force); } } else { $string = addslashes($string); } } return $string; } function createdir($dir=''){ if (!is_dir($dir)){ $temp = explode('/',$dir); $cur_dir = ''; for($i=0;$i<count($temp);$i++){ $cur_dir .= $temp[$i].'/'; if (!is_dir($cur_dir)){ @mkdir($cur_dir,0777); } } } } function template($file, $templateid = 0, $tpldir = '') { global $tplrefresh; $tpldir = $tpldir ? $tpldir : TPLDIR; $templateid = $templateid ? $templateid : TEMPLATEID; $tplfile = NetMao_ROOT.'./'.$tpldir.'/'.$file.'.htm'; $objfile = NetMao_ROOT.'./mdata/templates/'.$templateid.'_'.$file.'.tpl.php'; if(TEMPLATEID != 1 && $templateid != 1 && !file_exists($tplfile)) { return template($file, 1, './templates/default/'); } if($tplrefresh == 1 || ($tplrefresh > 1 && substr($GLOBALS['timestamp'], -1) > $tplrefresh)) { require_once NetMao_ROOT.'./inc/template.func.php'; parse_template($file, $templateid, $tpldir); } return $objfile; } function language($file, $templateid = 0, $tpldir = '') { $tpldir = $tpldir ? $tpldir : TPLDIR; $templateid = $templateid ? $templateid : TEMPLATEID; $languagepack = NetMao_ROOT.'./'.$tpldir.'/'.$file.'.lang.php'; if(file_exists($languagepack)) { return $languagepack; } elseif($templateid != 1 && $tpldir != './templates/default') { return language($file, 1, './templates/default'); } else { return FALSE; } } function control($file, $templateid = 0, $tpldir = '') { $tpldir = $tpldir ? $tpldir : TPLDIR; $templateid = $templateid ? $templateid : TEMPLATEID; $controlpack = NetMao_ROOT.'./'.$tpldir.'/'.$file.'.ctrl.php'; if(file_exists($controlpack)) { return $controlpack; } elseif($templateid != 1 && $tpldir != './templates/default') { return control($file, 1, './templates/default'); } else { return FALSE; } } function implodeids($array) { if(!empty($array)) { return "'".implode("','", is_array($array) ? $array : array($array))."'"; } else { return ''; } } function shownmsg($message,$goback='') { extract($GLOBALS, EXTR_SKIP); eval("\$message = \"".(isset($msglang[$message]) ? $msglang[$message] : $message)."\";"); eval("\$goback = \"".(isset($goback) ? $goback : 'back')."\";"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><title>NetMao NMsg</title><meta http-equiv="Content-Type" content="text/html; charset=<?=$charset?>"> <link href="./images/admin/style.css" rel="stylesheet" type="text/css" /> </head> <body> <table width="500" height="100" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> </td> </tr> </table> <table width="500" border="0" align="center" cellpadding="0" cellspacing="0"> <tr><td> <table width="100%" border='0' align='center' cellpadding='1' cellspacing='1' class="tableborder"> <tr><th height="25">NetMao <?=$cplang[netmao_message]?></th></tr> <tr align='center'><td height='100' valign='middle' bgcolor="#FFFFFF"><br><br><?=$message?><br><br> <?php if ($goback=='back'){ ?> <br><a href="javascript:history.go(-1);" ><?=$cplang[message_return]?></a> <?php }elseif ($goback=='close'){ ?> <br> <a href="javascript:window.close();"><?=$cplang[message_close]?></a> <?php }else{ ?> <br> <a href="<?=$goback?>"><?=$cplang[message_redirect]?></a> <script>setTimeout("redirect('<?=$goback?>');", 1250);</script> <?php } ?> </td></tr> </table> </td></tr> </table> <table width="500" height="60" border="0" align="center" cellpadding="0" cellspacing="0"> <tr><td align="center"> <?=NetMao_CP_CopyRight?> </td></tr> </table> <script language="JavaScript">function redirect(url) {window.location.replace(url);}</script> </body> </html> <?php exit(); } function netmao_key($txt, $encode_key) { $encode_key = md5('ilovenetmao'.$encode_key); $ctr = 0; $tmp = ''; for($i = 0; $i < strlen($txt); $i++) { $ctr = $ctr == strlen($encode_key) ? 0 : $ctr; $tmp .= $txt[$i] ^ $encode_key[$ctr++]; } return $tmp; } function netmao_setcode($array) { $arraycode = array(); foreach($array as $key => $val) { $arraycode[] = $key.'='.urlencode($val); } return implode('&', $arraycode); } function netmao_encode($txt, $key) { srand((double)microtime() * 1000000); $encode_key = md5(rand(0, 32000)); $ctr = 0; $tmp = ''; for($i = 0; $i < strlen($txt); $i++) { $ctr = $ctr == strlen($encode_key) ? 0 : $ctr; $tmp .= $encode_key[$ctr].($txt[$i] ^ $encode_key[$ctr++]); } return base64_encode(netmao_key($tmp, $key)); } function netmao_decode($txt, $key) { $txt = netmao_key(base64_decode($txt), $key); $tmp = ''; for ($i = 0; $i < strlen($txt); $i++) { $tmp .= $txt[$i] ^ $txt[++$i]; } return $tmp; } function movieurl($mid){ global $site_mdir; $mid=intval($mid); $mid < 1 ? 1 : $mid; $a = $mid / 250; $b = ceil($a); $c = substr(md5(netmao_key($b,NetMao_AuthKey)),-3).$b; $d = $site_mdir=='' ? $c : $site_mdir.'/'.$c; $e = md5(netmao_key($mid,NetMao_AuthKey)); $f = substr($e.$mid,-6); $g = $d.'/'.$f; createdir($d); return $g; } function netmao_playcode($txt){ $en_n = ''; $en_m = ''; $en_code = ''; $en_n = netmao_encode(netmao_setcode($txt),NetMao_AuthKey); $en_m = md5($en_n.NetMao_AuthKey); $en_code = "n=".rawurlencode($en_n)."&m=".rawurlencode($en_m); return $en_code; } function isemail($email) { return strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-]+(\.\w+)+$/", $email); } function phppage($num, $perpage, $curr_page, $mpurl) { $phppage = ''; if($num > $perpage) { $page = 10; $offset = 2; $pages = ceil($num / $perpage); $from = $curr_page - $offset; $to = $curr_page + $page - $offset - 1; if($page > $pages) { $from = 1; $to = $pages; } else { if($from < 1) { $to = $curr_page + 1 - $from; $from = 1; if(($to - $from) < $page && ($to - $from) < $pages) { $to = $page; } } elseif($to > $pages) { $from = $curr_page - $pages + $to; $to = $pages; if(($to - $from) < $page && ($to - $from) < $pages) { $from = $pages - $page + 1; } } } $phppage .= '<a href="'.$mpurl.'&page=1"><<</a> '; for($i = $from; $i <= $to; $i++) { if($i != $curr_page) { $phppage .= '<a href="'.$mpurl.'&page='.$i.'">'.$i.'</a> '; } else { $phppage .= '<strong>'.$i.'</strong> '; } } $phppage .= $pages > $page ? " ... <a href=\"$mpurl&page=$pages\"> $pages >></a>" : " <a href=\"$mpurl&page=$pages\">>></a>"; } return $phppage; } function random($length, $numeric = 0) { mt_srand((double)microtime() * 1000000); if($numeric) { $hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1)); }else{ $hash = ''; $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; $max = strlen($chars) - 1; for($i = 0; $i < $length; $i++) { $hash .= $chars[mt_rand(0, $max)]; } } return $hash; } ?>