www.gusucode.com > 网猫影视系统NetMao Movie 4.6.6 开源版源码程序 > upload/templates/default/diy.ctrl.php
<?php if(!defined('IN_NetMao')) exit('Access Denied'); function htmlpage($num, $perpage, $curr_page, $mpurl) { $htmlpage = ''; 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; } } } $htmlpage .= '<a href="'.$mpurl.'.htm"><<</a> '; for($i = $from; $i <= $to; $i++) { if($i != $curr_page) { if($i==1){ $htmlpage .= '<a href="'.$mpurl.'.htm'.'">'.$i.'</a> '; } else{ $htmlpage .= '<a href="'.$mpurl.'_'.$i.'.htm'.'">'.$i.'</a> '; } } else { $htmlpage .= '<strong>'.$i.'</strong> '; } } $htmlpage .= $pages > $page ? " ... <a href=\"$mpurl"."_$pages.htm\"> [$pages] >></a>" : " <a href=\"$mpurl"."_$pages.htm\">>></a>"; } return $htmlpage; } function cutstr($string, $length) { // $strcut = ''; $string = strip_tags($string); if(strlen($string) > $length) { for($i = 0; $i < $length - 3; $i++) { $strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i]; } return $strcut.'...'; } else { return $string; } } function moviepic($string){ $string = empty($string) ? "images/default/nopic.gif" : $string; $picture = eregi("http://",$string) ? $string : ROOTDIR.'/'.$string; return $picture; } function movierun($string){ $isrun = $string>0 ? ($string>998 ? "[<font color=green>完</font>]" : "[<font color=green>$string</font>]") : ''; return $isrun; } function showplay(){ global $_NCACHE, $en_movie; updatecache('files'); @require_once NetMao_ROOT.'./'.movieurl($en_movie[mid]).'.php'; $movie_files = $_NM['files']; include template('tag_play'); } function movielist($cid=0,$mnum=10,$titlelen=20,$ordertype=1,$showtype=0,$datenum=0,$offset=0,$datetypes=0) { global $db, $tablepre, $_NCACHE; $ordertypes = array('1'=>' addtime DESC ','2'=>' addtime ASC ','3'=>' hits DESC ','4'=>' hits '); $datetypes = array('1'=>'Y-m-d','2'=>'m-d','3'=>'Y/m/d','4'=>'Y.m.d'); $cids = $cid ; $condition .= $cids ? (is_numeric($cids) ? " and cid='$cid' " : " and cid IN ($cids) ") : ""; $condition .= $showtype ? (showtype=='index' ? " and isindex>0 " : " and ismlist>0 ") : ""; $condition .= $datenum ? " and addtime>$timestamp-86400*$datenum " : ""; $otype = $ordertype ? $ordertypes[$ordertype] : $ordertypes[1]; $offset = $offset; $limit = $mnum ? " LIMIT $offset,$mnum" : ''; $result = $db->query("SELECT * FROM {$tablepre}movies where isshow>0 $condition ORDER BY $otype $limit "); while($r=$db->fetch_array($result)){ $r[category]=$_NCACHE['categorys'][$r[cid]]; $r[movieurl]=movieurl($r[mid]); $r[picture]=moviepic($r[picture]); $r[srun]=movierun($r[isrun]); $r[stime]=date("Y-m-d",$r[addtime]); $r[sname]=cutstr($r[name],$titlelen); $mlists[]=$r; } include template('tag_movielist'); } ?>