'0', 1 => '3', 2 => '6', 3 => '9', 4 => 'C', 5 => 'F'); while (($o ='#' . $color[rand($color_start, $color_end)] . $color[rand($color_start, $color_end)] . $color[rand($color_start, $color_end)]) != '#FFF') { return $o; } } function rand_gray($color_start = 1, $color_end = 3) { $color = array(0 => '0', 1 => '3', 2 => '6', 3 => '9', 4 => 'C', 5 => 'F'); $g = $color[rand($color_start, $color_end)]; while (($o = '#' . $g . $g . $g) != '#FFF') { return $o; } } function make_descriptive_time($unix_timestamp) { $now = time(); $diff = $now - $unix_timestamp; if ($diff > (86400 * 30)) { $m_span = intval($diff / (86400 * 30)); $d_diff = $diff % ($m_span * (86400 * 30)); if ($d_diff > 86400) { $d_span = intval($d_diff / 86400); return $m_span . ' 月 ' . $d_span . ' 天前'; } else { return $m_span . ' 月前'; } } if ($diff > 86400) { $d_span = intval($diff / 86400); $h_diff = $diff % 86400; if ($h_diff > 3600) { $h_span = intval($h_diff / 3600); return $d_span . ' 天 ' . $h_span . ' 小时前'; } else { return $d_span . ' 天前'; } } if ($diff > 3600) { $h_span = intval($diff / 3600); $m_diff = $diff % 3600; if ($m_diff > 60) { $m_span = intval($m_diff / 60); return $h_span . ' 小时 ' . $m_span . ' 分钟前'; } else { return $h_span . ' 小时前'; } } if ($diff > 60) { $span = floor($diff / 60); $secs = $diff % 60; if ($secs > 0) { return $span . ' 分 ' . $secs . ' 秒前'; } else { return $span . ' 分钟前'; } } return $diff . ' 秒前'; } function make_desc_time($unix_timestamp) { $now = time(); $diff = $now - $unix_timestamp; if ($diff > 86400) { $d_span = intval($diff / 86400); $h_diff = $diff % 86400; if ($h_diff > 3600) { $h_span = intval($h_diff / 3600); return $d_span . 'd ' . $h_span . 'h'; } else { return $d_span . 'd'; } } if ($diff > 3600) { $h_span = intval($diff / 3600); $m_diff = $diff % 3600; if ($m_diff > 60) { $m_span = intval($m_diff / 60); return $h_span . 'h ' . $m_span . 'm'; } else { return $h_span . 'h'; } } if ($diff > 60) { $span = intval($diff / 60); return $span . 'm'; } return $diff . 's'; } function vxGetItemSize($posts) { if ($posts > 400) { return 19; } else { if ($posts > 200) { return 18; } else { if ($posts > 100) { return 17; } else { if ($posts >= 50) { return 16; } else { if ($posts >= 26) { return 15; } else { if ($posts >= 10) { return 14; } else { if ($posts >= 4) { return 13; } else { return 12; } } } } } } } } function avRESIZE($source,$avdir = 'm',$dir_default = '0') { if ($dir_default==0){ if (preg_match("/^(customavatars\/.+?)$/i",$source)) { $source = str_replace("customavatars/","customavatars/".$avdir."/",$source); } elseif (preg_match("/^(images\/avatars\/.+?)$/i",$source)) { $source = str_replace("images/avatars/","images/avatars/".$avdir."/",$source); } else { $source = "images/common/nohead_".$avdir.".gif"; } } else { if (preg_match("/^(customavatars\/.+?)$/i",$source)) { $source = str_replace("customavatars/","customavatars/",$source); } elseif (preg_match("/^(images\/avatars\/.+?)$/i",$source)) { $source = str_replace("images/avatars/","images/avatars/",$source); } else { $source = "images/common/nohead.gif"; } } return $source; } function microtime_float() { $ms = explode(' ', microtime()); $usec = $ms[0]; $sec = $ms[1]; return ((float)$usec + (float)$sec); } function strip_quotes($text) { $text = str_replace('"', '', $text); $text = str_replace("'", '', $text); return $text; } function nmGetURLHost($url) { $o = array(); $o['type'] = 'web'; $o['url'] = strtolower($url); if (preg_match('/flickr\.com/', $url)) { $o['type'] = 'flickr'; return $o; } if (preg_match('/feedburner\.com/', $url)) { $o['type'] = 'feedburner'; return $o; } if (preg_match('/buzznet\.com/', $url)) { $o['type'] = 'buzznet'; return $o; } if (preg_match('/technorati\.com/', $url)) { $o['type'] = 'technorati'; return $o; } if (preg_match('/douban\.com/', $url)) { $o['type'] = 'douban'; return $o; } if (preg_match('/mac\.com/', $url)) { $o['type'] = 'mac'; return $o; } if (preg_match('/spaces\.msn\.com/', $url)) { $o['type'] = 'spaces'; return $o; } if (preg_match('/spaces\.live\.com/', $url)) { $o['type'] = 'spaces'; return $o; } if (preg_match('/live\.com/', $url)) { $o['type'] = 'spaces'; return $o; } if (preg_match('/blinklist\.com/', $url)) { $o['type'] = 'blinklist'; return $o; } if (preg_match('/bulaoge\.com/', $url)) { $o['type'] = 'bulaoge'; return $o; } if (preg_match('/box\.net/', $url)) { $o['type'] = 'box'; return $o; } if (preg_match('/deviantart\.com/', $url)) { $o['type'] = 'deviantart'; return $o; } if (preg_match('/(google\.com)|(googlepages\.com)|(gfans\.org)/', $url)) { $o['type'] = 'google'; return $o; } if (preg_match('/(blogspot\.com)/', $url)) { $o['type'] = 'blogspot'; return $o; } if (preg_match('/del\.icio\.us/', $url)) { $o['type'] = 'delicious'; return $o; } if (preg_match('/(saicn\.com)|(orzotl\.com)|(n2design\.cn)/', $url)) { $o['type'] = 'saicn'; return $o; } return $o; } function make_safe_display($txt) { $txt = str_ireplace(' width="100%"', ' ', $txt); return $txt; } function make_single_return($value, $strip = 1) { if (get_magic_quotes_gpc()) { if ($strip == 1) { $value = stripslashes($value); } return str_replace('"', '"', $value); } else { return str_replace('"', '"', $value); } } function make_multi_return($value, $strip = 1) { if ($strip == 1) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } } $value = str_replace('<', '<', $value); $value = str_replace('>', '>', $value); return $value; } function make_single_safe($value) { $value = trim($value); $value = str_replace(chr(10), '', $value); $value = str_replace(chr(13), '', $value); return $value; } function make_multi_safe($value) { $value = trim($value); return $value; } function make_plaintext($text) { $text = str_replace('<', '<', $text); $text = str_replace('>', '>', $text); $text = nl2br($text); return $text; } /* Nowhere Functions */ function nwFROM($source = 0){ if ($source=='1') { $source = 'mobile'; } else if ($source=='2') { $source = 'im'; } else if ($source=='3') { $source = 'Wii'; } else if ($source=='4') { $source = 'iPhone'; } else { $source = 'web'; } return $source; } function nwICONS($source = 0, $type='pic'){ global $bbsdir; $icons = array( 'PIC' => array(0 => '', 1 => 'straitjacket', 2 => 'book', 3 => 'song', 4 => 'tv', 5 => 'computing', 6 => 'eat', 7 => 'home', 8 => 'hurry', 9 => 'morning', 10 => 'sleep', 11 => 'football', 12 => 'happy', 13 => 'love', 14 => 'pils', 15 => 'shop', 16 => 'game', 17 => 'makeup', 18 => 'icecream',19 => 'coffee',20 => 'beer',21 => 'toiletpaper',22 => 'bus',23 => 'car',24 => 'bomb',25 => 'taxi',26 => 'train',27 => 'strom',28 => 'toilet', 29 => 'ballon', 30 => 'bike', 31 => 'wallclock',99 => 'computing'), 'TEXT' => array(0 => '', 1 => 'THINKING', 2 => 'READING', 3 => 'LISTENING', 4 => 'WATCHING', 5 => 'COMPUTING', 6 => 'EATING', 7 => 'HOME', 8 => 'HURRY', 9 => 'MORNING', 10 => 'SLEEP', 11 => 'WALKING', 12 => 'HAPPY', 13 => 'LOVE', 14 => 'Pils', 15 => 'SHOPPING', 16 => 'GAME', 17 => 'MAKEUP', 18 => 'ICECREAM',19 => 'COFFEE',20 => 'BEER',21 => 'FLIGHT',22 => 'BUS',23 => 'CAR',24 => 'BOMB',25 => 'TAXI',26 => 'TRAIN',27 => 'STROM',28 => 'TOILET', 29 => 'BALLON', 30 => 'BIKE', 31 => 'ToDo',99 => 'NEW FEATURE'), ); if ($source != 0) { if ($type == 'pic') { return $bbsdir.'/images/now/icons/web-'.$icons['PIC'][$source].'.gif'; } elseif ($type=='text') { return '['.$icons['TEXT'][$source].']'; } elseif ($type =='xml') { return $icons['TEXT'][$source]; } else { return $bbsdir.'/images/now/icons/web-'.$icons['PIC'][$source].'.gif'; } } else { return false; } } function navforum($groupselectable = FALSE, $tableformat = 0) { global $_DCACHE, $discuz_uid, $groupid, $fid, $gid, $indexname,$bbsdir; if(!isset($_DCACHE['forums'])) { require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php'; } $forumlist = $tableformat ? '' : '
  •  '.$forum['name'].'   
  • '; $forumlist = $tableformat ? $forumlist : str_replace('', '', $forumlist); return $forumlist; } /* Thread List */ function timeline_remix () { global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid, $groupid, $fid; $_timeline = array(); @include(DISCUZ_ROOT.'./forumdata/cache/parasy_topic_timeline.php'); if((@!include('forumdata/cache/parasy_topic_timeline.php')) || $topics_expiration < time()) { $topics = topic_update('timeline','t.dateline DESC','20','m'); } else { $topics = $topics; } $i = 0; foreach($topics as $_topic) { $i++; if ($i < 21){ $_timeline['timeline'][$_topic['dateline']] = array(); $_timeline['timeline'][$_topic['dateline']]['type'] = 'topic'; $_timeline['timeline'][$_topic['dateline']]['author'] = $_topic['author'] ? $_topic['author'] : '游客'; $_timeline['timeline'][$_topic['dateline']]['clean_title'] = str_replace("'","‘",$_topic['subject']); $_timeline['timeline'][$_topic['dateline']]['title'] = $_topic['subject']; $_timeline['timeline'][$_topic['dateline']]['id'] = $_topic['tid']; $_timeline['timeline'][$_topic['dateline']]['uid'] = $_topic['authorid']; $_timeline['timeline'][$_topic['dateline']]['name'] = $_topic['name']; $_timeline['timeline'][$_topic['dateline']]['board_name'] = $_topic['board_name']; $_timeline['timeline'][$_topic['dateline']]['time'] = $_topic['dateline']; $_timeline['timeline'][$_topic['dateline']]['avatar'] = $_topic['avatar']; $_timeline['timeline'][$_topic['dateline']]['size'] = vxGetItemSize($_topic['replies']).'px'; } } require_once DISCUZ_ROOT.'./forumdata/cache/cache_nowhere.php'; foreach($_DCACHE['nowhere'] as $_now) { $_timeline['timeline'][$_now['dateline']] = array(); $_timeline['timeline'][$_now['dateline']]['type'] = 'now'; $_timeline['timeline'][$_now['dateline']]['author'] = $_now['author'] ? $_now['author'] : '游客'; $_timeline['timeline'][$_now['dateline']]['uid'] = $_now['authorid']; $_timeline['timeline'][$_now['dateline']]['id'] = $_now['vid']; $_timeline['timeline'][$_now['dateline']]['title'] = dhtmlspecialchars($_now['content']); $_timeline['timeline'][$_now['dateline']]['avatar'] = avRESIZE($_now['avatar']); $_timeline['timeline'][$_now['dateline']]['time'] = $_now['dateline']; $_timeline['timeline'][$_now['dateline']]['via'] = nwFROM($_now['background']); $_timeline['timeline'][$_now['dateline']]['icons'] = nwICONS($_now['icons'],'text'); } krsort($_timeline['timeline']); return $_timeline['timeline']; } function update_timeline($update =0) { global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid, $groupid, $fid; if((!include('forumdata/cache/cache_dashboard_timeline.php')) || $update = 1) { $_timeline = array(); $query_timeline_topic = $db->query("SELECT t.tid, t.author,t.authorid,t.subject,t.replies,t.views,t.dateline,mf.avatar,f.name,f.board_name FROM {$tablepre}threads t LEFT JOIN {$tablepre}forums f ON f.fid=t.fid LEFT JOIN {$tablepre}memberfields mf ON mf.uid=t.authorid WHERE t.displayorder!='-1' ORDER BY t.dateline DESC LIMIT 30"); while($_topic = $db->fetch_array($query_timeline_topic)) { $_timeline['timeline'][$_topic['dateline']] = array(); $_timeline['timeline'][$_topic['dateline']]['type'] = 'topic'; $_timeline['timeline'][$_topic['dateline']]['author'] = $_topic['author'] ? $_topic['author'] : '游客'; $_timeline['timeline'][$_topic['dateline']]['clean_title'] = str_replace("'","‘",$_topic['subject']); $_timeline['timeline'][$_topic['dateline']]['title'] = $_topic['subject']; $_timeline['timeline'][$_topic['dateline']]['id'] = $_topic['tid']; $_timeline['timeline'][$_topic['dateline']]['uid'] = $_topic['authorid']; $_timeline['timeline'][$_topic['dateline']]['name'] = $_topic['name']; $_timeline['timeline'][$_topic['dateline']]['board_name'] = $_topic['board_name']; $_timeline['timeline'][$_topic['dateline']]['time'] = $_topic['dateline']; $_timeline['timeline'][$_topic['dateline']]['avatar'] = avRESIZE($_topic['avatar']); $_timeline['timeline'][$_topic['dateline']]['size'] = vxGetItemSize($_topic['replies']).'px'; } $query_dateline_now = $db->query("SELECT n.*,mf.avatar FROM {$tablepre}plugin_now n LEFT JOIN {$tablepre}memberfields mf ON mf.uid=n.authorid ORDER BY dateline DESC LIMIT 20"); while ($_now = $db->fetch_array($query_dateline_now)) { $_timeline['timeline'][$_now['dateline']] = array(); $_timeline['timeline'][$_now['dateline']]['type'] = 'now'; $_timeline['timeline'][$_now['dateline']]['author'] = $_now['author'] ? $_now['author'] : '游客'; $_timeline['timeline'][$_now['dateline']]['uid'] = $_now['authorid']; $_timeline['timeline'][$_now['dateline']]['id'] = $_now['vid']; $_timeline['timeline'][$_now['dateline']]['title'] = dhtmlspecialchars($_now['content']); $_timeline['timeline'][$_now['dateline']]['avatar'] = avRESIZE($_now['avatar']); $_timeline['timeline'][$_now['dateline']]['time'] = $_now['dateline']; $_timeline['timeline'][$_now['dateline']]['via'] = nwFROM($_now['background']); $_timeline['timeline'][$_now['dateline']]['icons'] = nwtextICONS($_now['icons']); } krsort($_timeline['timeline']); $_timeline['timeline_expiration'] = time(); writetocache(dashboard_timeline, '', nmgetcachevars($_timeline)); } } function rand_topic($fup,$items = 14) { global $db, $_DCACHE, $timestamp, $tablepre, $timeoffset, $maxbdays,$smcols, $smrows,$discuz_uid, $groupid, $fid, $indexname; $_seed = rand(1, 10); @include DISCUZ_ROOT.'./forumdata/cache_idx/cache_idx_'.$fup.'_'.$_seed.'.php'; if((@!include(DISCUZ_ROOT.'forumdata/cache_idx/cache_idx_'.$fup.'_'.$_seed.'.php')) || $idx_expiration < time()) { require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php'; foreach($_DCACHE['forums'] as $forum_all) { if($forum_all['type'] == 'group' ) { $visible[$forum_all['fid']] = true; } elseif($forum_all['type'] == 'forum' && $forum_all['fup']== $fup&& isset($visible[$forum_all['fup']]) && (!$forum_all['viewperm'] ||($forum_all['viewperm'] && forumperm($forum_all['viewperm'])) ||strstr($forum_all['users'], "\t$discuz_uid\t"))) { $_forums[] =$forum_all['fid']; $visible[$forum_all['fid']] = true; } } $forum_list_sql = implode(',', $_forums); $forum_topic_list = array(); $query = $db->query("SELECT t.tid,t.subject,t.replies FROM {$tablepre}threads t WHERE t.displayorder!='-1' and t.fid IN ({$forum_list_sql}) ORDER BY rand() LIMIT 0, 20"); while($topic = $db->fetch_array($query)) { $data['topic'][$topic[tid]]['tid'] = $topic['tid']; $data['topic'][$topic[tid]]['subject'] = $topic['subject']; $data['topic'][$topic[tid]]['replies'] = $topic['replies']; $data['topic'][$topic[tid]]['size'] = vxGetItemSize($topic['replies']).'px'; } $data['idx_expiration'] = 900 + time(); nmwritetocache('cache_idx_'.$fup.'_'.$_seed, '', nmgetcachevars($data),'','cache_idx'); $topic = $data['topic']; @shuffle($topic); if(is_array($topic)) { foreach($topic as $toploop) { if ($toploop['replies'] < 5){ $toploop['color'] = rand_gray(); }else{ $toploop['color'] = rand_color(); } $i ++; if ($i < $items) { echo ''.$toploop['subject'].'   '; } } } } else { @shuffle($topic); if(is_array($topic)) { foreach($topic as $toploop) { if ($toploop['replies'] < 5){ $toploop['color'] = rand_gray(); }else{ $toploop['color'] = rand_color(); } $i ++; if ($i < $items) { echo ''.$toploop['subject'].'   '; } } } } } function hot_topic() { global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid, $member; $data = array(); $query_commend = $db->query("SELECT t.tid, t.fid, t.author,t.subject,t.replies,mf.avatar,mf.uid,f.name,f.board_name FROM {$tablepre}threads t LEFT JOIN {$tablepre}forums f ON f.fid=t.fid LEFT JOIN {$tablepre}memberfields mf ON mf.uid=t.authorid WHERE t.displayorder!='-1' and t.replies > 10 ORDER BY t.dateline DESC LIMIT 5"); while($dash_commend = $db->fetch_array($query_commend)) { $data['dash_commend'][$dash_commend[tid]]['uid'] = $dash_commend['uid']; $data['dash_commend'][$dash_commend[tid]]['author'] = $dash_commend['author'] ? $dash_commend['author'] : '游客'; $data['dash_commend'][$dash_commend[tid]]['tid'] = $dash_commend['tid']; $data['dash_commend'][$dash_commend[tid]]['subject'] = $dash_commend['subject']; $data['dash_commend'][$dash_commend[tid]]['subjectc'] = str_replace("'","‘",cutstr($dash_commend['subject'], 40)); $data['dash_commend'][$dash_commend[tid]]['avatar'] = avRESIZE($dash_commend['avatar']); $data['dash_commend'][$dash_commend[tid]]['avatar_s'] = avRESIZE($dash_commend['avatar'],'s'); $data['dash_commend'][$dash_commend[tid]]['size'] = vxGetItemSize($dash_commend['replies']).'px'; $data['dash_commend'][$dash_commend[tid]]['replies'] = $dash_commend['replies']; $data['dash_commend'][$dash_commend[tid]]['name'] = $dash_commend['name']; $data['dash_commend'][$dash_commend[tid]]['board_name'] = $dash_commend['board_name']; } $data['commend_expiration'] = 300 + time(); nmwritetocache(cache_dashboard_commend, '', nmgetcachevars($data),'','cache'); return $data['dash_commend']; } /* S:Index Avatar Show || written by Exgbit */ function rand_avatars() { global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid, $member,$Geo,$charset; $data = array(); $query_avatar = $db->query("SELECT m.uid,m.username,m.usr_geo,mf.nickname,mf.avatar from {$tablepre}members m LEFT JOIN {$tablepre}memberfields mf ON m.uid=mf.uid WHERE mf.avatar !='' AND mf.hits >'".AVATAR_SHOW_HITS."' ORDER BY rand() LIMIT 20"); while($avatar = $db->fetch_array($query_avatar)) { $data['avatar_show'][$avatar[uid]]['uid'] = $avatar['uid']; $data['avatar_show'][$avatar[uid]]['name'] = $avatar['username']; $data['avatar_show'][$avatar[uid]]['nickname'] = $avatar['nickname']; $data['avatar_show'][$avatar[uid]]['geo'] = iconv('utf-8', $charset, $Geo['user']->map['name'][$avatar[usr_geo]]); $data['avatar_show'][$avatar[uid]]['avatar'] = $avatar['avatar']; } $data['avatar_expiration'] = 900 + time(); nmwritetocache(cache_avatar_show, '', nmgetcachevars($data),'','cache'); return $data['avatar_show']; } /* E:Index Avatar Show || written by Exgbit */ /* Page Functions */ function now_multi($num, $perpage, $curpage, $mpurl, $maxpages = 0, $page = 10, $simple = 0, $onclick = '',$postfix ='') { $multipage = ''; //$mpurl .= strpos($mpurl, '?') ? '&' : '?'; $onclick = $onclick ? ' onclick="'.$onclick.'(event)"' : ''; if($num > $perpage) { $offset = 2; $realpages = @ceil($num / $perpage); $pages = $maxpages && $maxpages < $realpages ? $maxpages : $realpages; if($page > $pages) { $from = 1; $to = $pages; } else { $from = $curpage - $offset; $to = $from + $page - 1; if($from < 1) { $to = $curpage + 1 - $from; $from = 1; if($to - $from < $page) { $to = $page; } } elseif($to > $pages) { $from = $pages - $page + 1; $to = $pages; } } $multipage = ($curpage - $offset > 1 && $pages > $page ? '|‹' : ''). ($curpage > 1 && !$simple ? '‹‹' : ''); for($i = $from; $i <= $to; $i++) { $multipage .= $i == $curpage ? ''.$i.'' : ''.$i.''; } $multipage .= ($curpage < $pages && !$simple ? '››' : ''). ($to < $pages ? '›|' : ''). ($curpage == $maxpages ? '›?' : ''). (!$simple && $pages > $page ? '' : ''); $multipage = $multipage ? (!$simple ? ''.$num.' ITEMS / '.$perpage.' PER PAGE '.$curpage.'/'.$realpages.' ' : '').$multipage : ''; } return $multipage; } function now_wap_multi($num, $perpage, $curpage, $mpurl, $maxpages = 0, $page = 10, $simple = 0, $onclick = '') { $multipage = ''; if($num > $perpage) { $offset = 2; $realpages = @ceil($num / $perpage); $pages = $maxpages && $maxpages < $realpages ? $maxpages : $realpages; if($page > $pages) { $from = 1; $to = $pages; } else { $from = $curpage - $offset; $to = $from + $page - 1; if($from < 1) { $to = $curpage + 1 - $from; $from = 1; if($to - $from < $page) { $to = $page; } } elseif($to > $pages) { $from = $pages - $page + 1; $to = $pages; } } $multipage = /*($curpage - $offset > 1 && $pages > $page ? '|‹' : '').*/ ($curpage > 1 && !$simple ? ' 上一页 ' : ''); $multipage .= ($curpage < $pages && !$simple ? ' 下一页' : ''). /*($to < $pages ? '›|' : ''). ($curpage == $maxpages ? '›?' : '').*/ (!$simple && $pages > $page ? '' : ''); $multipage = $multipage ? $multipage.(!$simple ? ' '.$curpage.'/'.$realpages.' ' : '') : ''; } return $multipage; } function thread_multi($num, $perpage, $curpage, $mpurl, $maxpages = 0, $page = 10, $simple = 0, $onclick = '',$postfix ='') { $multipage = ''; //$mpurl .= strpos($mpurl, '?') ? '&' : '?'; $onclick = $onclick ? ' onclick="'.$onclick.'(event)"' : ''; if($num > $perpage) { $offset = 2; $realpages = @ceil($num / $perpage); $pages = $maxpages && $maxpages < $realpages ? $maxpages : $realpages; if($page > $pages) { $from = 1; $to = $pages; } else { $from = $curpage - $offset; $to = $from + $page - 1; if($from < 1) { $to = $curpage + 1 - $from; $from = 1; if($to - $from < $page) { $to = $page; } } elseif($to > $pages) { $from = $pages - $page + 1; $to = $pages; } } $multipage = ($curpage - $offset > 1 && $pages > $page ? '|‹' : ''). ($curpage > 1 && !$simple ? '‹‹' : ''); for($i = $from; $i <= $to; $i++) { $multipage .= $i == $curpage ? ''.$i.'' : ''.$i.''; } $multipage .= ($curpage < $pages && !$simple ? '››' : ''). ($to < $pages ? '›|' : ''). ($curpage == $maxpages ? '›?' : ''). (!$simple && $pages > $page ? '' : ''); $multipage = $multipage ? (!$simple ? ''.$num.' ITEMS / 30 PER PAGE '.$curpage.'/'.$realpages.' ' : '').$multipage : ''; } return $multipage; } function forum_pic($fid){ global $bbsdir; $forum_pic_dir = './images/m_pic/'.$fid.'.jpg'; if ($_SERVER[HTTP_HOST]=='127.0.0.1' || $_SERVER[HTTP_HOST]=='localhost' || !CDN_FORUM_PIC){ $cdn_dir= $bbsdir.'/images/m_pic/'; } else { $cdn_dir= CDN_FORUM_PIC.'/'; } if (file_exists($forum_pic_dir)) { $forum_pic = $cdn_dir.''.$fid.'.jpg'; } else { $forum_pic =$cdn_dir.'n.jpg'; } return $forum_pic; } /* User Functions */ function add_hits($uid) { global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid, $member; if ($uid != $discuz_uid) { session_start(); if (isset($_SESSION['add_hits'][$uid])) { $_SESSION['add_hits'][$uid] = 1; } else { $_SESSION['add_hits'][$uid] = 1; $query = $db->query("UPDATE {$tablepre}memberfields SET hits = (hits + 1) WHERE uid = {$uid} LIMIT 1"); } } return true; } function svp_update($uid,$del = 0) { global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid, $member; $data = array(); $query = $db->query("SELECT COUNT(*) FROM {$tablepre}savepoint WHERE svp_uid = '{$uid}'"); $count = $db->result($query, 0); if ($count > 0 || $del == 1) { $query = $db->query("SELECT svp_id, svp_url, svp_rank FROM {$tablepre}savepoint WHERE svp_uid = '{$uid}' ORDER BY svp_url"); while($svp = $db->fetch_array($query)) { $data['svp'][$svp['svp_id']]['svp_id'] = $svp['svp_id']; $data['svp'][$svp['svp_id']]['svp_url'] = htmlspecialchars($svp['svp_url']); $data['svp'][$svp['svp_id']]['bg'] = $v2bg = isset($v2bg) && $v2bg == 'even' ? 'odd' : 'even'; } nmwritetocache('user_svp_'.$uid, '', nmgetcachevars($data),'','cache_usr/svp'); } return $data['svp']; } function fav_update($uid) { global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid, $member; $data = array(); $query = $db->query("SELECT f.board_name, f.name,f.fid FROM {$tablepre}favorites fav, {$tablepre}forums f WHERE fav.fid=f.fid AND fav.uid='{$uid}' ORDER BY fav.dateline ASC"); while($fav = $db->fetch_array($query)) { $data['fav'][$fav['fid']]['board_name'] = $fav['board_name']; $data['fav'][$fav['fid']]['name'] = $fav['name']; } nmwritetocache('user_fav_'.$uid, '', nmgetcachevars($data),'','cache_usr/f'); return $data['fav']; } function buddy_update($uid,$del = 0) { global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid, $member; $data = array(); $query = $db->query("SELECT COUNT(*) FROM {$tablepre}buddys WHERE uid = '{$uid}'"); $count = $db->result($query, 0); if ($count > 0 || $del == 1) { $query = $db->query("SELECT b.*, m.username, mf.avatar FROM {$tablepre}buddys b LEFT JOIN {$tablepre}members m ON m.uid=b.buddyid LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid WHERE b.uid='{$uid}' ORDER BY dateline ASC"); while($buddy = $db->fetch_array($query)) { $data['buddy'][$buddy['buddyid']]['buddyid'] = $buddy['buddyid']; $data['buddy'][$buddy['buddyid']]['username'] = $buddy['username']; $data['buddy'][$buddy['buddyid']]['friendavatar'] = avRESIZE($buddy['avatar'],'',1); } nmwritetocache('user_buddy_'.$uid, '', nmgetcachevars($data),'','cache_usr/b'); } return $data['buddy']; } function geo_going_update($uid) { global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid, $member,$Geo; $data = array(); $query_going = $db->query("SELECT ggg_id,ggg_geo FROM cdb_geo_going WHERE ggg_uid = {$uid} ORDER BY ggg_created DESC"); while($going = $db->fetch_array($query_going)) { $data['geo_going'][$going['ggg_id']]['geo'] = $going['ggg_geo']; $data['geo_going'][$going['ggg_id']]['name'] = iconv('utf-8', 'gbk', $Geo->map['name'][$going['ggg_geo']]); $data['geo_going_flag']='1'; } $query_been = $db->query("SELECT gbn_id,gbn_geo FROM cdb_geo_been WHERE gbn_uid = {$uid} ORDER BY gbn_created DESC"); while($been = $db->fetch_array($query_been)) { $data['geo_been'][$been['gbn_id']]['geo'] = $been['gbn_geo']; $data['geo_been'][$been['gbn_id']]['name'] = iconv('utf-8', 'gbk', $Geo->map['name'][$been['gbn_geo']]); $data['geo_been_flag']='1'; } if (mysql_num_rows($query_going) > 0 || mysql_num_rows($query_been) > 0) { nmwritetocache('user_geo_'.$uid, '', nmgetcachevars($data),'','cache_usr/g'); } return $data['going']; } /* Display Functions */ function nmTitle($msgSiteTitle = '',$bbname) { global $bbsdir; if ($msgSiteTitle != '') { $msgSiteTitle = $msgSiteTitle.''.$bbname; } else { $msgSiteTitle = $bbname; } session_start(); $this_time = time(); $this_page = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $disabled_pages = array($bbsdir.'/session/stats.nnm',$bbsdir.'/signup.nnm',$bbsdir.'/login.nnm',$bbsdir.'/register.php',$bbsdir.'/logging.php',$bbsdir.'/index.php',$bbsdir.'/search.nnm',$bbsdir.'/online.html',$bbsdir.'/about'); if ((!in_array($_SERVER['SCRIPT_URL'], $disabled_pages)) && (substr($_SERVER['SCRIPT_URL'], 0, 12) != '/online/view') && (substr($_SERVER['SCRIPT_URL'], 0, 3) != '/q/') && ($_SERVER['SCRIPT_URL'] != '/')) { if (isset($_SESSION['hits'])) { $_SESSION['hits'] = intval($_SESSION['hits']) + 1; $_SESSION['pages'][$this_time] = $this_page; $_SESSION['titles'][$this_time] = $msgSiteTitle; } else { $_SESSION['hits'] = 1; $_SESSION['pages'] = array(); $_SESSION['pages'][$this_time] = $this_page; $_SESSION['titles'] = array(); $_SESSION['titles'][$this_time] = $msgSiteTitle; } } else { if (!isset($_SESSION['hits'])) { $_SESSION['hits'] = 0; } } //unset($_SESSION['hits']); } function nmSessionStats() { $s .= ''; $i = 0; $pages = array_reverse($_SESSION['pages'], true); foreach ($pages as $time => $page) { $i++; $css_color = rand_color(); $s .= ''; if ($i == count($pages)) { $time_start = $time; } } $duration = time() - $time_start; $stay = intval($duration / count($pages)); $s .= ''; $s .= '
     ' . $i . '. ' . $_SESSION['titles'][$time] . ' ... ' . make_descriptive_time($time); $s .= '
    本次访问到目前为止持续时间 ' . $duration . ' 秒,一共访问了至少 ' . $i . ' 个页面,在每个页面上的平均停留时间 ' . $stay . ' 秒 ...
    '; echo $s; } function topic_update($type='latest',$order='t.dateline DESC',$limit='100',$avatar='s') { global $db, $_DCACHE, $timestamp, $tablepre, $discuz_uid; $data = array(); $query = $db->query("SELECT t.subject, t.authorid,t.author,t.tid, t.lastpost, t.views, t.replies,t.dateline,t.lastpost, mf.uid, mf.avatar,f.board_name,f.name FROM {$tablepre}members m, {$tablepre}threads t LEFT JOIN {$tablepre}forums f ON f.fid=t.fid LEFT JOIN {$tablepre}memberfields mf ON mf.uid=t.authorid WHERE m.uid = t.authorid AND m.uid ORDER BY {$order} LIMIT {$limit}"); if (mysql_num_rows($query) > 0) { while($t = $db->fetch_array($query)) { $data['topics'][$t['tid']]['tid'] = $t['tid']; $data['topics'][$t['tid']]['subject'] = $t['subject']; $data['topics'][$t['tid']]['dateline'] = $t['dateline']; $data['topics'][$t['tid']]['lastpost'] = $t['lastpost']; $data['topics'][$t['tid']]['views'] = $t['views']; $data['topics'][$t['tid']]['replies'] = $t['replies']; $data['topics'][$t['tid']]['name'] = $t['name']; $data['topics'][$t['tid']]['board_name'] = $t['board_name']; $data['topics'][$t['tid']]['author'] = $t['author'] ? $t['author'] : '游客'; $data['topics'][$t['tid']]['authorid'] = $t['authorid']; $data['topics'][$t['tid']]['avatar'] = avRESIZE($t['avatar'],$avatar); } $data['topics_expiration'] = 600 + time(); nmwritetocache('parasy_topic_'.$type, '', nmgetcachevars($data),'','cache'); } return $data['topics']; } function expense_log($operator, $uid, $type='0',$memo='0') { global $db, $tablepre, $discuz_uid, $timestamp; if (PARASY_FEATURE_EXP){ $db->query("INSERT INTO {$tablepre}expense(exp_uid, exp_amount, exp_type, exp_memo, exp_created) VALUES($uid, $operator, $type, '$memo', " . time() . ")"); } } /* Today Functions */ function notehash($note_id) { global $discuz_user, $discuz_uid, $discuz_pw, $timestamp, $discuz_auth_key; return strtoupper(substr(md5(substr($timestamp, 0, -7).$discuz_user.$discuz_uid.$discuz_pw.$discuz_auth_key.$note_id), 8, 8)); } function autoVer($url) { $path = pathinfo($url); $ver = '.'.filemtime($_SERVER['DOCUMENT_ROOT'].$url).'.'; return str_replace('.', $ver, $path['basename']); } function clean_cache_dir($cache_dir) { global $filesnum,$adminid; if ($adminid == '1') { $d = dir($cache_dir); $filesnum = 0; while($entry=$d->read()) { if (is_dir($cache_dir.$entry)){ continue; } else { unlink($cache_dir.$entry); $filesnum++; } } $d->close(); } } function css_hack() { if(preg_match('/(Firefox\/3.0)/i', $_SERVER['HTTP_USER_AGENT'])) { echo ''; echo "\n"; } } ?>