__DOUYA_ROUTE_FACTS__']) && is_array($GLOBALS['__DOUYA_ROUTE_FACTS__'])) { $rf = $GLOBALS['__DOUYA_ROUTE_FACTS__']; if (!empty($rf['id'])) $id = (int)$rf['id']; } if ($id <= 0 && isset($navinfor) && is_array($navinfor) && !empty($navinfor['id'])) { $id = (int)$navinfor['id']; } $pathid = isset($_GET['pathid']) ? (int)$_GET['pathid'] : 0; if ($pathid < 0) $pathid = 0; if (!defined('DOUYA_PATH')) { if (defined('ECMS_PATH')) define('DOUYA_PATH', ECMS_PATH . 'e/douya'); else define('DOUYA_PATH', rtrim((string)$_SERVER['DOCUMENT_ROOT'], '/') . '/e/douya'); } $catHelper = DOUYA_PATH . '/lib/category/helpers.php'; if (is_file($catHelper)) require_once $catHelper; $cid = 0; $catSlug = ''; if (isset($GLOBALS['__DOUYA_ROUTE_FACTS__']) && is_array($GLOBALS['__DOUYA_ROUTE_FACTS__'])) { $rf = $GLOBALS['__DOUYA_ROUTE_FACTS__']; if (isset($rf['cat']) && is_array($rf['cat'])) { if (!empty($rf['cat']['id'])) $cid = (int)$rf['cat']['id']; if (!empty($rf['cat']['slug'])) $catSlug = trim((string)$rf['cat']['slug'], '/'); } } if ($cid <= 0) { $cid = isset($GLOBALS['navclassid']) ? (int)$GLOBALS['navclassid'] : 0; } if ($cid <= 0 && function_exists('dy_cat_current_from_ctx_or_bind')) { $cid = (int)dy_cat_current_from_ctx_or_bind(array(), 0); } if ($catSlug === '' && function_exists('douya_cat_current')) { $cur = douya_cat_current(0); if (is_array($cur) && !empty($cur['slug'])) $catSlug = trim((string)$cur['slug'], '/'); } $title = ''; if ($id > 0) { $douyaRow = $empire->fetch1("SELECT word FROM phome_douya WHERE id = ".$id." LIMIT 1"); if (is_array($douyaRow) && !empty($douyaRow['word'])) $title = (string)$douyaRow['word']; } if ($title === '') $title = '{title}'; if (!function_exists('dy_pick_one_by_seed')) { function dy_pick_one_by_seed($empire, $table, $seedStr, $maxId, $fieldsSql) { $maxId = (int)$maxId; if ($maxId <= 0) return array(); $h = crc32((string)$seedStr); if ($h < 0) $h = $h & 0x7fffffff; $start = 1 + ($h % $maxId); $row = $empire->fetch1("SELECT {$fieldsSql} FROM {$table} WHERE id >= {$start} ORDER BY id LIMIT 1"); if (is_array($row) && !empty($row)) return $row; $row = $empire->fetch1("SELECT {$fieldsSql} FROM {$table} WHERE id < {$start} ORDER BY id LIMIT 1"); return is_array($row) ? $row : array(); } } $newsMax = 0; $mxn = $empire->fetch1("SELECT MAX(id) AS mx FROM phome_ecms_news"); if (is_array($mxn) && !empty($mxn['mx'])) $newsMax = (int)$mxn['mx']; $seedNews = $host . '|info|cid:' . $cid . '|title:' . $title; $news = ($newsMax > 0) ? dy_pick_one_by_seed( $empire, 'phome_ecms_news', $seedNews, $newsMax, 'id,titlepic,onlinepath,smalltext,newstime,downpath,tpjb,leixing,diqu,nianfen,yuyan,pf,zhuyan,daoyan' ) : array(); $newsData = array(); $newsId = (is_array($news) && !empty($news['id'])) ? (int)$news['id'] : 0; if ($newsId > 0) { $tmp = $empire->fetch1("SELECT newstext,writer,befrom FROM phome_ecms_news_data_1 WHERE id=".$newsId." LIMIT 1"); if (is_array($tmp)) $newsData = $tmp; } $newstext = isset($newsData['newstext']) ? (string)$newsData['newstext'] : ''; $director = isset($news['daoyan']) ? (string)$news['daoyan'] : ''; $actor = isset($news['zhuyan']) ? (string)$news['zhuyan'] : ''; $fromsite = isset($newsData['befrom']) ? (string)$newsData['befrom'] : ''; $onlinepath = isset($news['onlinepath']) ? (string)$news['onlinepath'] : ''; $smalltext = isset($news['smalltext']) ? (string)$news['smalltext'] : ''; $titlepic = isset($news['titlepic']) ? trim((string)$news['titlepic']) : ''; $newstime = isset($news['newstime']) ? (int)$news['newstime'] : time(); $tpjb = isset($news['tpjb']) ? (string)$news['tpjb'] : ''; $downpath = isset($news['downpath']) ? (string)$news['downpath'] : ''; $titlepic = isset($news['titlepic']) ? trim((string)$news['titlepic']) : ''; if ($titlepic !== '' && !preg_match('#^(https?:)?//#i', $titlepic)) { if ($titlepic[0] !== '/') $titlepic = '/'.ltrim($titlepic, '/'); $titlepic = douya_asset($titlepic); } if ($titlepic === '') $titlepic = douya_asset('/skin/ecms107/images/nopic.gif'); $onlinepath = isset($news['onlinepath']) ? (string)$news['onlinepath'] : ''; $smalltext = isset($news['smalltext']) ? (string)$news['smalltext'] : ''; $newstext = isset($news['newstext']) ? (string)$news['newstext'] : ''; $newstime = isset($news['newstime']) ? (int)$news['newstime'] : time(); if ($newstime <= 0) $newstime = time(); $newstime_fmt = date('Y-m-d H:i:s', $newstime); $director = isset($news['writer']) ? (string)$news['writer'] : ''; $fromsite = isset($news['befrom']) ? (string)$news['befrom'] : ''; $tpjb = ''; $downpath = ''; $hasOnline = (trim($onlinepath) !== ''); $hasDown = (trim($downpath) !== ''); $playBase = ($catSlug !== '') ? url('', 'scene=inner|id='.$id.'|cat_slug='.$catSlug.'|title='.$title.'|tdk=4|source=normal') : url('', 'scene=inner|id='.$id.'|classid='.$cid.'|title='.$title.'|tdk=4|source=normal'); $groups = array(); $curG = -1; $firstPlayablePathid = 0; if ($hasOnline) { $op = str_replace(array(chr(13).chr(10), chr(13)), chr(10), (string)$onlinepath); $rr = explode(chr(10), $op); $rcount = count($rr); for ($i=0; $i<$rcount; $i++) { $line = trim((string)$rr[$i]); if ($line === '') continue; $fr = explode('::::::', $line); $n0 = isset($fr[0]) ? trim((string)$fr[0]) : ''; $n1 = isset($fr[1]) ? trim((string)$fr[1]) : ''; if ($n1 === '###@@@') { $groups[] = array('name'=>$n0, 'items'=>array(), 'first'=>-1); $curG = count($groups) - 1; continue; } if ($curG < 0) { $groups[] = array('name'=>'默认线路', 'items'=>array(), 'first'=>-1); $curG = 0; } if ($n0 === '') continue; $href = $playBase . '?pathid=' . $i; $groups[$curG]['items'][] = array('name'=>$n0, 'pathid'=>$i, 'href'=>$href); if ($groups[$curG]['first'] < 0) { $groups[$curG]['first'] = $i; if ($firstPlayablePathid === 0) $firstPlayablePathid = $i; } } } $activeG = 0; if (!empty($groups)) { for ($gi=0; $gifetch1("SELECT MAX(id) AS mx FROM phome_douya"); if (is_array($mxd) && !empty($mxd['mx'])) $douyaMax = (int)$mxd['mx']; if (!function_exists('dy_pick_rows_by_seed')) { function dy_pick_rows_by_seed($empire, $table, $want, $seedStr, $maxId) { $want = (int)$want; $maxId = (int)$maxId; if ($want <= 0 || $maxId <= 0) return array(); $h = crc32((string)$seedStr); if ($h < 0) $h = $h & 0x7fffffff; $start = 1 + ($h % $maxId); $rows = array(); $rs = $empire->query("SELECT id, word FROM {$table} WHERE id >= {$start} ORDER BY id LIMIT {$want}"); while ($r = $empire->fetch($rs)) $rows[] = $r; $need = $want - count($rows); if ($need > 0) { $rs2 = $empire->query("SELECT id, word FROM {$table} WHERE id < {$start} ORDER BY id LIMIT {$need}"); while ($r2 = $empire->fetch($rs2)) $rows[] = $r2; } return $rows; } } $likeData = array(); $rankData = array(); $rawLike = dy_pick_rows_by_seed($empire, 'phome_douya', 30, $host.'|like|'.$title, $douyaMax); foreach ($rawLike as $r) { $rid = (int)$r['id']; if ($rid === $id) continue; $likeData[] = array('id'=>$rid, 'title'=>(string)$r['word']); if (count($likeData) >= 10) break; } $rawRank = dy_pick_rows_by_seed($empire, 'phome_douya', 30, $host.'|rank|'.$title, $douyaMax); foreach ($rawRank as $r) { $rid = (int)$r['id']; if ($rid === $id) continue; $rankData[] = array('id'=>$rid, 'title'=>(string)$r['word']); if (count($rankData) >= 10) break; } $tagsData = array(); $resTag = $empire->query("SELECT tagid, tagname FROM phome_enewstags LIMIT 200"); while ($row = $empire->fetch($resTag)) { $tagsData[] = array('tagid'=>(int)$row['tagid'], 'tagname'=>(string)$row['tagname']); } if (!function_exists('getStableRandomItem')) { function getStableRandomItem($key, $items) { if (empty($items)) return null; $hash = crc32((string)$key); if ($hash < 0) $hash = $hash & 0x7fffffff; $index = $hash % count($items); return $items[$index]; } } ?>
{site} / {main}