国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1050 line
45KB

  1. <?php
  2. if (!defined('DEDEINC')) exit ('dedebiz');
  3. /**
  4. * 自定义模型列表
  5. *
  6. * @version $id:sglistview.class.php 15:48 2010年7月7日 tianya $
  7. * @package DedeBIZ.Libraries
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(DEDEINC."/archive/partview.class.php");
  13. @set_time_limit(0);
  14. class SgListView
  15. {
  16. var $dsql;
  17. var $dtp;
  18. var $dtp2;
  19. var $TypeID;
  20. var $TypeLink;
  21. var $PageNo;
  22. var $TotalPage;
  23. var $TotalResult;
  24. var $pagesize;
  25. var $ChannelUnit;
  26. var $ListType;
  27. var $Fields;
  28. var $PartView;
  29. var $addSql;
  30. var $IsError;
  31. var $CrossID;
  32. var $IsReplace;
  33. var $AddTable;
  34. var $ListFields;
  35. var $searchArr;
  36. var $sAddTable;
  37. var $mod;
  38. /**
  39. * php5构造函数
  40. *
  41. * @access public
  42. * @param int $typeid 栏目id
  43. * @param array $searchArr 检索数组
  44. * @param int $mod 渲染类型 0:HTML 1:JSON
  45. * @return void
  46. */
  47. function __construct($typeid, $searchArr = array(), $mod = 0)
  48. {
  49. global $dsql, $envs;
  50. $envs['url_type'] = 1;
  51. $this->TypeID = $typeid;
  52. $this->dsql = $dsql;
  53. $this->CrossID = '';
  54. $this->IsReplace = false;
  55. $this->IsError = false;
  56. $this->dtp = new DedeTagParse();
  57. $this->dtp->SetRefObj($this);
  58. $this->sAddTable = false;
  59. $this->dtp->SetNameSpace("dede", "{", "}");
  60. $this->dtp2 = new DedeTagParse();
  61. $this->dtp2->SetNameSpace("field", "[", "]");
  62. $this->TypeLink = new TypeLink($typeid);
  63. $this->searchArr = $searchArr;
  64. $this->mod = $mod;
  65. if (!is_array($this->TypeLink->TypeInfos)) {
  66. $this->IsError = true;
  67. }
  68. if (!$this->IsError) {
  69. $this->ChannelUnit = new ChannelUnit($this->TypeLink->TypeInfos['channeltype']);
  70. $this->Fields = $this->TypeLink->TypeInfos;
  71. $this->Fields['id'] = $typeid;
  72. $this->Fields['position'] = $this->TypeLink->GetPositionLink(true);
  73. $this->Fields['title'] = preg_replace("/[<>]/", " / ", $this->TypeLink->GetPositionLink(false));
  74. //获得附加表和列表字段信息
  75. $this->AddTable = $this->ChannelUnit->ChannelInfos['addtable'];
  76. $listfield = trim($this->ChannelUnit->ChannelInfos['listfields']);
  77. $this->ListFields = explode(',', $listfield);
  78. //设置一些全局参数的值
  79. foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v;
  80. $this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."/static/rss/".$this->TypeID.".xml";
  81. //api相关逻辑处理
  82. if ($this->mod == 1 && empty($this->Fields['apikey'])) {
  83. echo json_encode(array(
  84. "code" => -1,
  85. "msg" => "api key is empty",
  86. ));
  87. exit;
  88. }
  89. if ($this->mod == 1) {
  90. if (empty($GLOBALS['sign'])) {
  91. echo json_encode(array(
  92. "code" => -1,
  93. "msg" => "sign is empty",
  94. ));
  95. exit;
  96. }
  97. //验签算法md5(typeid+timestamp+apikey+PageNo+PageSize)
  98. $sign = md5($this->TypeID.$GLOBALS['timestamp'].$this->Fields['apikey'].$GLOBALS['PageNo'].$GLOBALS['PageSize']);
  99. if ($sign !== $GLOBALS['sign']) {
  100. echo json_encode(array(
  101. "code" => -1,
  102. "msg" => "sign check failed",
  103. ));
  104. exit;
  105. }
  106. }
  107. //设置环境变量
  108. SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list');
  109. $this->Fields['typeid'] = $this->TypeID;
  110. //获得交叉栏目id
  111. if ($this->TypeLink->TypeInfos['cross'] > 0 && $this->TypeLink->TypeInfos['ispart'] == 0) {
  112. $selquery = '';
  113. if ($this->TypeLink->TypeInfos['cross'] == 1) {
  114. $selquery = "SELECT id,topid FROM `#@__arctype` WHERE typename LIKE '{$this->Fields['typename']}' AND id<>'{$this->TypeID}' AND topid<>'{$this->TypeID}' ";
  115. } else {
  116. $this->Fields['crossid'] = preg_replace("/[^0-9,]/", '', trim($this->Fields['crossid']));
  117. if ($this->Fields['crossid'] != '') {
  118. $selquery = "SELECT id,topid FROM `#@__arctype` WHERE id IN({$this->Fields['crossid']}) AND id<>{$this->TypeID} AND topid<>{$this->TypeID} ";
  119. }
  120. }
  121. if ($selquery != '') {
  122. $this->dsql->SetQuery($selquery);
  123. $this->dsql->Execute();
  124. while ($arr = $this->dsql->GetArray()) {
  125. $this->CrossID .= ($this->CrossID == '' ? $arr['id'] : ','.$arr['id']);
  126. }
  127. }
  128. }
  129. } //!error
  130. }
  131. //php4构造函数
  132. function SgListView($typeid, $searchArr = array(), $mod = 0)
  133. {
  134. $this->__construct($typeid, $searchArr, $mod);
  135. }
  136. //关闭相关资源
  137. function Close()
  138. {
  139. }
  140. /**
  141. * 统计列表里的记录
  142. *
  143. * @access public
  144. * @return void
  145. */
  146. function CountRecord()
  147. {
  148. global $cfg_list_son;
  149. //统计数据库记录
  150. $this->TotalResult = -1;
  151. if (isset($GLOBALS['TotalResult'])) $this->TotalResult = $GLOBALS['TotalResult'];
  152. if (isset($GLOBALS['PageNo'])) $this->PageNo = $GLOBALS['PageNo'];
  153. else $this->PageNo = 1;
  154. $this->addSql = " arc.arcrank > -1 ";
  155. //栏目id条件
  156. if (!empty($this->TypeID)) {
  157. if ($cfg_list_son == 'N') {
  158. if ($this->CrossID == '') $this->addSql .= " AND (arc.typeid='".$this->TypeID."') ";
  159. else $this->addSql .= " AND (arc.typeid IN({$this->CrossID},{$this->TypeID})) ";
  160. } else {
  161. if ($this->CrossID == '') $this->addSql .= " AND (arc.typeid IN (".GetSonIds($this->TypeID, $this->Fields['channeltype']).") ) ";
  162. else $this->addSql .= " AND (arc.typeid IN (".GetSonIds($this->TypeID, $this->Fields['channeltype']).",{$this->CrossID}) ) ";
  163. }
  164. }
  165. $naddQuery = '';
  166. //地区与信息类型条件
  167. if (count($this->searchArr) > 0) {
  168. if (!empty($this->searchArr['nativeplace'])) {
  169. if ($this->searchArr['nativeplace'] % 500 == 0) {
  170. $naddQuery .= " AND arc.nativeplace >= '{$this->searchArr['nativeplace']}' AND arc.nativeplace < '".($this->searchArr['nativeplace'] + 500)."'";
  171. } else {
  172. $naddQuery .= "AND arc.nativeplace = '{$this->searchArr['nativeplace']}'";
  173. }
  174. }
  175. if (!empty($this->searchArr['infotype'])) {
  176. if ($this->searchArr['infotype'] % 500 == 0) {
  177. $naddQuery .= " AND arc.infotype >= '{$this->searchArr['infotype']}' AND arc.infotype < '".($this->searchArr['infotype'] + 500)."'";
  178. } else {
  179. $naddQuery .= "AND arc.infotype = '{$this->searchArr['infotype']}'";
  180. }
  181. }
  182. if (!empty($this->searchArr['keyword'])) {
  183. $naddQuery .= "AND arc.title like '%{$this->searchArr['keyword']}%' ";
  184. }
  185. }
  186. if ($naddQuery != '') {
  187. $this->sAddTable = true;
  188. $this->addSql .= $naddQuery;
  189. }
  190. if ($this->TotalResult == -1) {
  191. if ($this->sAddTable) {
  192. $cquery = "SELECT COUNT(*) AS dd FROM `{$this->AddTable}` arc WHERE ".$this->addSql;
  193. } else {
  194. $cquery = "SELECT COUNT(*) AS dd FROM `#@__arctiny` arc WHERE ".$this->addSql;
  195. }
  196. $row = $this->dsql->GetOne($cquery);
  197. if (is_array($row)) {
  198. $this->TotalResult = $row['dd'];
  199. } else {
  200. $this->TotalResult = 0;
  201. }
  202. }
  203. if ($this->mod === 0) {
  204. //初始化列表模板,并统计页面总数
  205. $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist'];
  206. $tempfile = str_replace("{tid}", $this->TypeID, $tempfile);
  207. $tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile);
  208. if (!file_exists($tempfile)) {
  209. $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default_sg.htm";
  210. }
  211. if (!file_exists($tempfile) || !is_file($tempfile)) {
  212. echo "栏目:{$this->TypeLink->TypeInfos['typename']},主题模板文件不存在,无法更新栏目";
  213. exit();
  214. }
  215. $this->dtp->LoadTemplate($tempfile);
  216. $ctag = $this->dtp->GetTag("page");
  217. if (!is_object($ctag)) {
  218. $ctag = $this->dtp->GetTag("list");
  219. }
  220. if (!is_object($ctag)) {
  221. $this->pagesize = 20;
  222. } else {
  223. if ($ctag->GetAtt('pagesize') != '') {
  224. $this->pagesize = $ctag->GetAtt('pagesize');
  225. } else {
  226. $this->pagesize = 20;
  227. }
  228. }
  229. } else {
  230. $this->pagesize = isset($GLOBALS['PageSize'])? intval($GLOBALS['PageSize']) : 10;
  231. $this->pagesize = $this->pagesize > 20 ? 20 : $this->pagesize;
  232. }
  233. $this->TotalPage = ceil($this->TotalResult / $this->pagesize);
  234. }
  235. /**
  236. * 列表创建网页
  237. *
  238. * @access public
  239. * @param string $startpage 开始页面
  240. * @param string $makepagesize 生成尺寸
  241. * @return string
  242. */
  243. function MakeHtml($startpage = 1, $makepagesize = 0)
  244. {
  245. if (empty($startpage)) {
  246. $startpage = 1;
  247. }
  248. //创建封面模板文件
  249. if ($this->TypeLink->TypeInfos['isdefault'] == -1) {
  250. return '/apps/list.php?tid='.$this->TypeLink->TypeInfos['id'];
  251. }
  252. //单独页面
  253. else if ($this->TypeLink->TypeInfos['ispart'] > 0) {
  254. $reurl = $this->MakePartTemplets();
  255. return $reurl;
  256. }
  257. if (empty($this->TotalResult)) $this->CountRecord();
  258. //初步给固定值的标记赋值
  259. $this->ParseTempletsFirst();
  260. $totalpage = ceil($this->TotalResult / $this->pagesize);
  261. if ($totalpage == 0) {
  262. $totalpage = 1;
  263. }
  264. CreateDir(MfTypedir($this->Fields['typedir']));
  265. $murl = '';
  266. if ($makepagesize > 0) {
  267. $endpage = $startpage + $makepagesize;
  268. } else {
  269. $endpage = ($totalpage + 1);
  270. }
  271. if ($endpage >= $totalpage + 1) {
  272. $endpage = $totalpage + 1;
  273. }
  274. if ($endpage == 1) {
  275. $endpage = 2;
  276. }
  277. for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) {
  278. $this->ParseDMFields($this->PageNo, 1);
  279. $makeFile = $this->GetMakeFileRule($this->Fields['id'], 'list', $this->Fields['typedir'], '', $this->Fields['namerule2']);
  280. $makeFile = str_replace("{page}", $this->PageNo, $makeFile);
  281. $murl = $makeFile;
  282. if (!preg_match("/^\//", $makeFile)) {
  283. $makeFile = "/".$makeFile;
  284. }
  285. $makeFile = $this->GetTruePath().$makeFile;
  286. $makeFile = preg_replace("/\/{1,}/", "/", $makeFile);
  287. $murl = $this->GetTrueUrl($murl);
  288. $this->dtp->SaveTo($makeFile);
  289. if (PHP_SAPI === 'cli') {
  290. DedeCli::showProgress(ceil(($this->PageNo / $endpage) * 100), 100);
  291. }
  292. }
  293. if ($startpage == 1) {
  294. //如果列表启用封面文件,复制这个文件第一页
  295. if (
  296. $this->TypeLink->TypeInfos['isdefault'] == 1
  297. && $this->TypeLink->TypeInfos['ispart'] == 0
  298. ) {
  299. $onlyrule = $this->GetMakeFileRule($this->Fields['id'], "list", $this->Fields['typedir'], '', $this->Fields['namerule2']);
  300. $onlyrule = str_replace("{page}", "1", $onlyrule);
  301. $list_1 = $this->GetTruePath().$onlyrule;
  302. $murl = MfTypedir($this->Fields['typedir']).'/'.$this->Fields['defaultname'];
  303. $indexname = $this->GetTruePath().$murl;
  304. copy($list_1, $indexname);
  305. }
  306. }
  307. return $murl;
  308. }
  309. /**
  310. * 显示列表
  311. *
  312. * @access public
  313. * @return void
  314. */
  315. function Display()
  316. {
  317. if ($this->mod === 0) {
  318. if ($this->TypeLink->TypeInfos['ispart'] > 0 && count($this->searchArr) == 0) {
  319. $this->DisplayPartTemplets();
  320. return;
  321. }
  322. $this->CountRecord();
  323. $this->ParseTempletsFirst();
  324. $this->ParseDMFields($this->PageNo, 0);
  325. $this->dtp->Display();
  326. } else {
  327. $this->CountRecord();
  328. $result = $this->GetAPIList($this->PageNo,$this->pagesize);
  329. if (!is_array($result)) {
  330. echo json_encode(array(
  331. "code" => -1,
  332. "msg" => "none result",
  333. ));
  334. } else {
  335. echo json_encode(array(
  336. "code" => 0,
  337. "msg" => "",
  338. "lists" => $result,
  339. "total" => intval($this->TotalResult),
  340. ));
  341. }
  342. }
  343. }
  344. /**
  345. * GetAPIList
  346. *
  347. * @param mixed $PageNo 页码
  348. * @param mixed $row 行数
  349. * @param mixed $titlelen 标题宽度
  350. * @param mixed $orderby 排序
  351. * @param mixed $orderWay 排序方式
  352. * @return void
  353. */
  354. function GetAPIList($PageNo, $row = 10, $titlelen = 30, $orderby = "default", $orderWay = 'desc')
  355. {
  356. $limitstart = ($PageNo - 1) * $row;
  357. if ($titlelen == '') $titlelen = 100;
  358. if ($orderby == '') $orderby = 'id';
  359. else $orderby = strtolower($orderby);
  360. if ($orderWay == '') $orderWay = 'desc';
  361. //排序方式
  362. $ordersql = '';
  363. if ($orderby == "senddate") {
  364. $ordersql = " ORDER BY arc.senddate $orderWay";
  365. } else if ($orderby == "pubdate") {
  366. $ordersql = " ORDER BY arc.pubdate $orderWay";
  367. } else if ($orderby == "id") {
  368. $ordersql = " ORDER BY arc.id $orderWay";
  369. } else if ($orderby == "hot" || $orderby == "click") {
  370. $ordersql = " ORDER BY arc.click $orderWay";
  371. } else if ($orderby == "lastpost") {
  372. $ordersql = " ORDER BY arc.lastpost $orderWay";
  373. } else if ($orderby == "scores") {
  374. $ordersql = " ORDER BY arc.scores $orderWay";
  375. } else if ($orderby == "rand") {
  376. $ordersql = " ORDER BY rand()";
  377. } else {
  378. $ordersql = " ORDER BY arc.sortrank $orderWay";
  379. }
  380. $addField = 'arc.'.join(',arc.', $this->ListFields);
  381. //如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢
  382. if (preg_match('/hot|click/', $orderby) || $this->sAddTable) {
  383. $query = "SELECT tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,arc.aid,arc.aid AS id,arc.typeid,mb.uname,mb.face,$addField FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb on arc.mid = mb.mid WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row";
  384. }
  385. //普通情况先从arctiny表查出id,然后按id查询速度非常快
  386. else {
  387. $t1 = ExecTime();
  388. $ids = array();
  389. $nordersql = str_replace('.aid', '.id', $ordersql);
  390. $query = "SELECT id FROM `#@__arctiny` arc WHERE {$this->addSql} $nordersql LIMIT $limitstart,$row";
  391. $this->dsql->SetQuery($query);
  392. $this->dsql->Execute();
  393. while ($arr = $this->dsql->GetArray()) {
  394. $ids[] = $arr['id'];
  395. }
  396. $idstr = join(',', $ids);
  397. if ($idstr == '') {
  398. return '';
  399. } else {
  400. $query = "SELECT tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,arc.aid,arc.aid AS id,arc.typeid,mb.uname,mb.face,mb.userid,$addField FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb on arc.mid = mb.mid WHERE arc.aid IN($idstr) AND arc.arcrank >-1 $ordersql";
  401. }
  402. $t2 = ExecTime();
  403. }
  404. $this->dsql->SetQuery($query);
  405. $this->dsql->Execute('al');
  406. $t2 = ExecTime();
  407. $GLOBALS['autoindex'] = 0;
  408. $result = array();
  409. while ($row = $this->dsql->GetArray("al")) {
  410. $GLOBALS['autoindex']++;
  411. $ids[$row['aid']] = $row['id'] = $row['aid'];
  412. //处理一些特殊字段
  413. $row['ismake'] = 1;
  414. $row['money'] = 0;
  415. $row['arcrank'] = 0;
  416. $row['filename'] = '';
  417. $row['filename'] = $row['arcurl'] = GetFileUrl(
  418. $row['id'],
  419. $row['typeid'],
  420. $row['senddate'],
  421. $row['title'],
  422. $row['ismake'],
  423. $row['arcrank'],
  424. $row['namerule'],
  425. $row['typedir'],
  426. $row['money'],
  427. $row['filename'],
  428. $row['moresite'],
  429. $row['siteurl'],
  430. $row['sitepath']
  431. );
  432. $row['typeurl'] = GetTypeUrl(
  433. $row['typeid'],
  434. MfTypedir($row['typedir']),
  435. $row['isdefault'],
  436. $row['defaultname'],
  437. $row['ispart'],
  438. $row['namerule2'],
  439. $row['moresite'],
  440. $row['siteurl'],
  441. $row['sitepath']
  442. );
  443. if ($row['litpic'] == '-' || $row['litpic'] == '') {
  444. $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg';
  445. }
  446. /*if (!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
  447. $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
  448. }*/
  449. $row['picname'] = $row['litpic'];
  450. $row['pubdate'] = $row['senddate'];
  451. $row['stime'] = GetDateMK($row['pubdate']);
  452. $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
  453. $row['fulltitle'] = $row['title'];
  454. $row['title'] = cn_substr($row['title'], $titlelen);
  455. if (preg_match('/b/', $row['flag'])) {
  456. $row['title'] = "".$row['title']."";
  457. }
  458. $row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
  459. $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
  460. $row['memberurl'] = $GLOBALS['cfg_memberurl'];
  461. $row['templeturl'] = $GLOBALS['cfg_templeturl'];
  462. $row['face'] = empty($row['face'])? $GLOBALS['cfg_mainsite'].'/static/web/img/admin.png' : $row['face'];
  463. $row['userurl'] = $GLOBALS['cfg_memberurl'].'/index.php?uid='.$row['userid'];
  464. //编译附加表里的数据
  465. foreach ($row as $k => $v) $row[strtolower($k)] = $v;
  466. foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
  467. if (isset($row[$k])) {
  468. $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]);
  469. }
  470. }
  471. $result[] = $row;
  472. } //if hasRow
  473. $t3 = ExecTime();
  474. $this->dsql->FreeResult('al');
  475. return $result;
  476. }
  477. /**
  478. * 创建单独模板页面
  479. *
  480. * @access public
  481. * @return string
  482. */
  483. function MakePartTemplets()
  484. {
  485. $this->PartView = new PartView($this->TypeID, false);
  486. $this->PartView->SetTypeLink($this->TypeLink);
  487. $nmfa = 0;
  488. $tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir'];
  489. if ($this->Fields['ispart'] == 1) {
  490. $tempfile = str_replace("{tid}", $this->TypeID, $this->Fields['tempindex']);
  491. $tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile);
  492. $tempfile = $tmpdir."/".$tempfile;
  493. if (!file_exists($tempfile)) {
  494. $tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default_sg.htm";
  495. }
  496. $this->PartView->SetTemplet($tempfile);
  497. } else if ($this->Fields['ispart'] == 2) {
  498. //跳转网址
  499. return $this->Fields['typedir'];
  500. }
  501. CreateDir(MfTypedir($this->Fields['typedir']));
  502. $makeUrl = $this->GetMakeFileRule($this->Fields['id'], "index", MfTypedir($this->Fields['typedir']), $this->Fields['defaultname'], $this->Fields['namerule2']);
  503. $makeUrl = preg_replace("/\/{1,}/", "/", $makeUrl);
  504. $makeFile = $this->GetTruePath().$makeUrl;
  505. if ($nmfa == 0) {
  506. $this->PartView->SaveToHtml($makeFile);
  507. } else {
  508. if (!file_exists($makeFile)) {
  509. $this->PartView->SaveToHtml($makeFile);
  510. }
  511. }
  512. return $this->GetTrueUrl($makeUrl);
  513. }
  514. /**
  515. * 显示单独模板页面
  516. *
  517. * @access public
  518. * @return void
  519. */
  520. function DisplayPartTemplets()
  521. {
  522. $this->PartView = new PartView($this->TypeID, false);
  523. $this->PartView->SetTypeLink($this->TypeLink);
  524. $nmfa = 0;
  525. $tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir'];
  526. if ($this->Fields['ispart'] == 1) {
  527. //封面模板
  528. $tempfile = str_replace("{tid}", $this->TypeID, $this->Fields['tempindex']);
  529. $tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile);
  530. $tempfile = $tmpdir."/".$tempfile;
  531. if (!file_exists($tempfile)) {
  532. $tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default_sg.htm";
  533. }
  534. $this->PartView->SetTemplet($tempfile);
  535. } else if ($this->Fields['ispart'] == 2) {
  536. //跳转网址
  537. $gotourl = $this->Fields['typedir'];
  538. header("Location:$gotourl");
  539. exit();
  540. }
  541. CreateDir(MfTypedir($this->Fields['typedir']));
  542. $makeUrl = $this->GetMakeFileRule($this->Fields['id'], "index", MfTypedir($this->Fields['typedir']), $this->Fields['defaultname'], $this->Fields['namerule2']);
  543. $makeFile = $this->GetTruePath().$makeUrl;
  544. if ($nmfa == 0) {
  545. $this->PartView->Display();
  546. } else {
  547. if (!file_exists($makeFile)) {
  548. $this->PartView->Display();
  549. } else {
  550. include($makeFile);
  551. }
  552. }
  553. }
  554. /**
  555. * 获得站点的真实根路径
  556. *
  557. * @access public
  558. * @return string
  559. */
  560. function GetTruePath()
  561. {
  562. $truepath = $GLOBALS["cfg_basedir"];
  563. return $truepath;
  564. }
  565. /**
  566. * 获得真实连接路径
  567. *
  568. * @access public
  569. * @param string $nurl 连接地址
  570. * @return string
  571. */
  572. function GetTrueUrl($nurl)
  573. {
  574. if (preg_match("/^http[s]?:\/\//", $nurl)) return $nurl;
  575. if ($this->Fields['moresite'] == 1) {
  576. if ($this->Fields['sitepath'] != '') {
  577. $nurl = preg_replace("/^".$this->Fields['sitepath']."/", '', $nurl);
  578. }
  579. $nurl = $this->Fields['siteurl'].$nurl;
  580. }
  581. return $nurl;
  582. }
  583. /**
  584. * 解析模板,对固定的标记进行初始给值
  585. *
  586. * @access private
  587. * @return void
  588. */
  589. function ParseTempletsFirst()
  590. {
  591. if (isset($this->TypeLink->TypeInfos['reid'])) {
  592. $GLOBALS['envs']['reid'] = $this->TypeLink->TypeInfos['reid'];
  593. }
  594. $GLOBALS['envs']['channelid'] = $this->TypeLink->TypeInfos['channeltype'];
  595. $GLOBALS['envs']['typeid'] = $this->TypeID;
  596. $GLOBALS['envs']['cross'] = 1;
  597. MakeOneTag($this->dtp, $this);
  598. }
  599. /**
  600. * 解析模板,对文档里的变动进行赋值
  601. *
  602. * @access public
  603. * @param int $PageNo 页码
  604. * @param int $ismake 是否编译
  605. * @return void
  606. */
  607. function ParseDMFields($PageNo, $ismake = 1)
  608. {
  609. //替换第二页后的文档
  610. if (($PageNo > 1 || strlen($this->Fields['content']) < 10) && !$this->IsReplace) {
  611. $this->dtp->SourceString = str_replace('[cmsreplace]', 'display:none', $this->dtp->SourceString);
  612. $this->IsReplace = true;
  613. }
  614. foreach ($this->dtp->CTags as $tagid => $ctag) {
  615. if ($ctag->GetName() == "list") {
  616. $limitstart = ($this->PageNo - 1) * $this->pagesize;
  617. $row = $this->pagesize;
  618. if (trim($ctag->GetInnerText()) == "") {
  619. $InnerText = GetSysTemplets("list_fulllist.htm");
  620. } else {
  621. $InnerText = trim($ctag->GetInnerText());
  622. }
  623. $this->dtp->Assign(
  624. $tagid,
  625. $this->GetArcList(
  626. $limitstart,
  627. $row,
  628. $ctag->GetAtt("col"),
  629. $ctag->GetAtt("titlelen"),
  630. $ctag->GetAtt("listtype"),
  631. $ctag->GetAtt("orderby"),
  632. $InnerText,
  633. $ctag->GetAtt("tablewidth"),
  634. $ismake,
  635. $ctag->GetAtt("orderway")
  636. )
  637. );
  638. } else if ($ctag->GetName() == "pagelist") {
  639. $list_len = trim($ctag->GetAtt("listsize"));
  640. $ctag->GetAtt("listitem") == "" ? $listitem = "index,pre,pageno,next,end,option" : $listitem = $ctag->GetAtt("listitem");
  641. if ($list_len == "") {
  642. $list_len = 3;
  643. }
  644. if ($ismake == 0) {
  645. $this->dtp->Assign($tagid, $this->GetPageListDM($list_len, $listitem));
  646. } else {
  647. $this->dtp->Assign($tagid, $this->GetPageListST($list_len, $listitem));
  648. }
  649. } else if ($PageNo != 1 && $ctag->GetName() == 'field' && $ctag->GetAtt('display') != '') {
  650. $this->dtp->Assign($tagid, '');
  651. }
  652. }
  653. }
  654. /**
  655. * 获得要创建的文件名称规则
  656. *
  657. * @access public
  658. * @param string $typeid 栏目id
  659. * @param string $wname
  660. * @param string $typedir 栏目目录
  661. * @param string $defaultname 默认名称
  662. * @param string $namerule2 名称规则
  663. * @return string
  664. */
  665. function GetMakeFileRule($typeid, $wname, $typedir, $defaultname, $namerule2)
  666. {
  667. $typedir = MfTypedir($typedir);
  668. if ($wname == 'index') {
  669. return $typedir.'/'.$defaultname;
  670. } else {
  671. $namerule2 = str_replace('{tid}', $typeid, $namerule2);
  672. $namerule2 = str_replace('{typedir}', $typedir, $namerule2);
  673. return $namerule2;
  674. }
  675. }
  676. /**
  677. * 获得一个单列的文档列表
  678. *
  679. * @access public
  680. * @param int $limitstart 限制开始
  681. * @param int $row 行数
  682. * @param int $col 列数
  683. * @param int $titlelen 标题长度
  684. * @param int $infolen 描述长度
  685. * @param int $imgwidth 图片宽度
  686. * @param int $imgheight 图片高度
  687. * @param string $listtype 列表类型
  688. * @param string $orderby 排列顺序
  689. * @param string $innertext 底层模板
  690. * @param string $tablewidth 表格宽度
  691. * @param string $ismake 是否编译
  692. * @param string $orderWay 排序方式
  693. * @return string
  694. */
  695. function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $listtype = "all", $orderby = "default", $innertext = "", $tablewidth = "100", $ismake = 1, $orderWay = 'desc')
  696. {
  697. global $cfg_list_son;
  698. $typeid = $this->TypeID;
  699. if ($row == '') $row = 10;
  700. if ($limitstart == '') $limitstart = 0;
  701. if ($titlelen == '') $titlelen = 100;
  702. if ($listtype == '') $listtype = "all";
  703. if ($orderby == '') $orderby = 'id';
  704. else $orderby = strtolower($orderby);
  705. if ($orderWay == '') $orderWay = 'desc';
  706. $tablewidth = str_replace("%", "", $tablewidth);
  707. if ($tablewidth == '') $tablewidth = 100;
  708. if ($col == '') $col = 1;
  709. $colWidth = ceil(100 / $col);
  710. $tablewidth = $tablewidth."%";
  711. $colWidth = $colWidth."%";
  712. $innertext = trim($innertext);
  713. if ($innertext == '') $innertext = GetSysTemplets('list_sglist.htm');
  714. //排序方式
  715. $ordersql = '';
  716. if ($orderby == "senddate") {
  717. $ordersql = " ORDER BY arc.senddate $orderWay";
  718. } else if ($orderby == "pubdate") {
  719. $ordersql = " ORDER BY arc.pubdate $orderWay";
  720. } else if ($orderby == "id") {
  721. $ordersql = " ORDER BY arc.id $orderWay";
  722. } else if ($orderby == "hot" || $orderby == "click") {
  723. $ordersql = " ORDER BY arc.click $orderWay";
  724. } else if ($orderby == "lastpost") {
  725. $ordersql = " ORDER BY arc.lastpost $orderWay";
  726. } else if ($orderby == "scores") {
  727. $ordersql = " ORDER BY arc.scores $orderWay";
  728. } else if ($orderby == "rand") {
  729. $ordersql = " ORDER BY rand()";
  730. } else {
  731. $ordersql = " ORDER BY arc.sortrank $orderWay";
  732. }
  733. $addField = 'arc.'.join(',arc.', $this->ListFields);
  734. //如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢
  735. if (preg_match('/hot|click/', $orderby) || $this->sAddTable) {
  736. $query = "SELECT tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,arc.aid,arc.aid AS id,arc.typeid,mb.uname,mb.face,mb.userid,$addField FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb on arc.mid = mb.mid WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row";
  737. }
  738. //普通情况先从arctiny表查出id,然后按id查询速度非常快
  739. else {
  740. $t1 = ExecTime();
  741. $ids = array();
  742. $nordersql = str_replace('.aid', '.id', $ordersql);
  743. $query = "SELECT id FROM `#@__arctiny` arc WHERE {$this->addSql} $nordersql LIMIT $limitstart,$row";
  744. $this->dsql->SetQuery($query);
  745. $this->dsql->Execute();
  746. while ($arr = $this->dsql->GetArray()) {
  747. $ids[] = $arr['id'];
  748. }
  749. $idstr = join(',', $ids);
  750. if ($idstr == '') {
  751. return '';
  752. } else {
  753. $query = "SELECT tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,arc.aid,arc.aid AS id,arc.typeid,mb.uname,mb.face,mb.userid,$addField FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb on arc.mid = mb.mid WHERE arc.aid IN($idstr) AND arc.arcrank >-1 $ordersql";
  754. }
  755. $t2 = ExecTime();
  756. }
  757. $this->dsql->SetQuery($query);
  758. $this->dsql->Execute('al');
  759. $t2 = ExecTime();
  760. $artlist = '';
  761. $this->dtp2->LoadSource($innertext);
  762. $GLOBALS['autoindex'] = 0;
  763. for ($i = 0; $i < $row; $i++) {
  764. if ($col > 1) {
  765. $artlist .= "<div>";
  766. }
  767. for ($j = 0; $j < $col; $j++) {
  768. if ($row = $this->dsql->GetArray("al")) {
  769. $GLOBALS['autoindex']++;
  770. $ids[$row['aid']] = $row['id'] = $row['aid'];
  771. //处理一些特殊字段
  772. $row['ismake'] = 1;
  773. $row['money'] = 0;
  774. $row['arcrank'] = 0;
  775. $row['filename'] = '';
  776. $row['filename'] = $row['arcurl'] = GetFileUrl(
  777. $row['id'],
  778. $row['typeid'],
  779. $row['senddate'],
  780. $row['title'],
  781. $row['ismake'],
  782. $row['arcrank'],
  783. $row['namerule'],
  784. $row['typedir'],
  785. $row['money'],
  786. $row['filename'],
  787. $row['moresite'],
  788. $row['siteurl'],
  789. $row['sitepath']
  790. );
  791. $row['typeurl'] = GetTypeUrl(
  792. $row['typeid'],
  793. MfTypedir($row['typedir']),
  794. $row['isdefault'],
  795. $row['defaultname'],
  796. $row['ispart'],
  797. $row['namerule2'],
  798. $row['moresite'],
  799. $row['siteurl'],
  800. $row['sitepath']
  801. );
  802. if ($row['litpic'] == '-' || $row['litpic'] == '') {
  803. $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg';
  804. }
  805. if (!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
  806. $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
  807. }
  808. $row['picname'] = $row['litpic'];
  809. $row['pubdate'] = $row['senddate'];
  810. $row['stime'] = GetDateMK($row['pubdate']);
  811. $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
  812. $row['fulltitle'] = $row['title'];
  813. $row['title'] = cn_substr($row['title'], $titlelen);
  814. if (preg_match('/b/', $row['flag'])) {
  815. $row['title'] = "".$row['title']."";
  816. }
  817. $row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
  818. $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
  819. $row['memberurl'] = $GLOBALS['cfg_memberurl'];
  820. $row['templeturl'] = $GLOBALS['cfg_templeturl'];
  821. $row['face'] = empty($row['face'])? $GLOBALS['cfg_mainsite'].'/static/web/img/admin.png' : $row['face'];
  822. $row['userurl'] = $GLOBALS['cfg_memberurl'].'/index.php?uid='.$row['userid'];
  823. //编译附加表里的数据
  824. foreach ($row as $k => $v) $row[strtolower($k)] = $v;
  825. foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
  826. if (isset($row[$k])) {
  827. $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]);
  828. }
  829. }
  830. if (is_array($this->dtp2->CTags)) {
  831. foreach ($this->dtp2->CTags as $k => $ctag) {
  832. if ($ctag->GetName() == 'array') {
  833. //传递整个数组,在runphp模式中有特殊作用
  834. $this->dtp2->Assign($k, $row);
  835. } else {
  836. if (isset($row[$ctag->GetName()])) {
  837. $this->dtp2->Assign($k, $row[$ctag->GetName()]);
  838. } else {
  839. $this->dtp2->Assign($k, '');
  840. }
  841. }
  842. }
  843. }
  844. $artlist .= $this->dtp2->GetResult();
  845. } //if hasRow
  846. }//Loop Col
  847. if ($col > 1) {
  848. $i += $col - 1;
  849. $artlist .= "</div>";
  850. }
  851. }//Loop Line
  852. $t3 = ExecTime();
  853. $this->dsql->FreeResult('al');
  854. return $artlist;
  855. }
  856. /**
  857. * 获取静态的分页列表
  858. *
  859. * @access public
  860. * @param int $list_len 列表宽度
  861. * @param string $listitem 列表样式
  862. * @return string
  863. */
  864. function GetPageListST($list_len, $listitem = "index,end,pre,next,pageno")
  865. {
  866. $prepage = '';
  867. $nextpage = '';
  868. $prepagenum = $this->PageNo - 1;
  869. $nextpagenum = $this->PageNo + 1;
  870. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  871. $list_len = 3;
  872. }
  873. $totalpage = ceil($this->TotalResult / $this->pagesize);
  874. if ($totalpage <= 1 && $this->TotalResult > 0) {
  875. return "<li class='page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>";
  876. }
  877. if ($this->TotalResult == 0) {
  878. return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>";
  879. }
  880. $purl = $this->GetCurUrl();
  881. $maininfo = "<li class='page-item disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>";
  882. $tnamerule = $this->GetMakeFileRule($this->Fields['id'], "list", $this->Fields['typedir'], $this->Fields['defaultname'], $this->Fields['namerule2']);
  883. $tnamerule = preg_replace("/^(.*)\//", '', $tnamerule);
  884. //获得上页和首页的链接
  885. if ($this->PageNo != 1) {
  886. $prepage .= "<li class='page-item'><a href='".str_replace("{page}", $prepagenum, $tnamerule)."' class='page-link'>上页</a></li>";
  887. $indexpage = "<li class='page-item'><a href='".str_replace("{page}", 1, $tnamerule)."' class='page-link'>首页</a></li>";
  888. } else {
  889. $indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>";
  890. }
  891. //下页和未页的链接
  892. if ($this->PageNo != $totalpage && $totalpage > 1) {
  893. $nextpage .= "<li class='page-item'><a href='".str_replace("{page}", $nextpagenum, $tnamerule)."' class='page-link'>下页</a></li>";
  894. $endpage = "<li class='page-item'><a href='".str_replace("{page}", $totalpage, $tnamerule)."' class='page-link'>末页</a></li>";
  895. } else {
  896. $endpage = "<li class='page-item'><span class='page-link'>末页</span></li>";
  897. }
  898. //option链接
  899. $optionlist = '';
  900. //获得数字链接
  901. $listdd = '';
  902. $total_list = $list_len * 2 + 1;
  903. if ($this->PageNo >= $total_list) {
  904. $j = $this->PageNo - $list_len;
  905. $total_list = $this->PageNo + $list_len;
  906. if ($total_list > $totalpage) {
  907. $total_list = $totalpage;
  908. }
  909. } else {
  910. $j = 1;
  911. if ($total_list > $totalpage) {
  912. $total_list = $totalpage;
  913. }
  914. }
  915. for ($j; $j <= $total_list; $j++) {
  916. if ($j == $this->PageNo) {
  917. $listdd .= "<li class='page-item active'><span class='page-link'>$j</span></li>";
  918. } else {
  919. $listdd .= "<li class='page-item'><a href='".str_replace("{page}", $j, $tnamerule)."' class='page-link'>$j</a></li>";
  920. }
  921. }
  922. $plist = '';
  923. if (preg_match('/info/i', $listitem)) {
  924. $plist .= $maininfo.' ';
  925. }
  926. if (preg_match('/index/i', $listitem)) {
  927. $plist .= $indexpage.' ';
  928. }
  929. if (preg_match('/pre/i', $listitem)) {
  930. $plist .= $prepage.' ';
  931. }
  932. if (preg_match('/pageno/i', $listitem)) {
  933. $plist .= $listdd.' ';
  934. }
  935. if (preg_match('/next/i', $listitem)) {
  936. $plist .= $nextpage.' ';
  937. }
  938. if (preg_match('/end/i', $listitem)) {
  939. $plist .= $endpage.' ';
  940. }
  941. if (preg_match('/option/i', $listitem)) {
  942. $plist .= $optionlist;
  943. }
  944. return $plist;
  945. }
  946. /**
  947. * 获取动态的分页列表
  948. *
  949. * @access public
  950. * @param int $list_len 列表宽度
  951. * @param string $listitem 列表样式
  952. * @return string
  953. */
  954. function GetPageListDM($list_len, $listitem = "index,end,pre,next,pageno")
  955. {
  956. global $nativeplace, $infotype, $keyword, $cfg_rewrite;
  957. if (empty($nativeplace)) $nativeplace = 0;
  958. if (empty($infotype)) $infotype = 0;
  959. if (empty($keyword)) $keyword = '';
  960. $prepage = $nextpage = '';
  961. $prepagenum = $this->PageNo - 1;
  962. $nextpagenum = $this->PageNo + 1;
  963. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  964. $list_len = 3;
  965. }
  966. $totalpage = ceil($this->TotalResult / $this->pagesize);
  967. if ($totalpage <= 1 && $this->TotalResult > 0) {
  968. return "<li class='page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>";
  969. }
  970. if ($this->TotalResult == 0) {
  971. return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>";
  972. }
  973. $purl = $this->GetCurUrl();
  974. //开启伪静态对规则替换
  975. if ($cfg_rewrite == 'Y') {
  976. $purl = str_replace("/apps", "", $purl);
  977. $nowurls = preg_replace("/\-/", ".php?", $purl);
  978. $nowurls = explode("?", $nowurls);
  979. $purl = $nowurls[0];
  980. }
  981. $geturl = "&TotalResult=".$this->TotalResult."&nativeplace=$nativeplace&infotype=$infotype&keyword=".urlencode($keyword)."&";
  982. $hidenform = "<input type='hidden' name='tid' value='".$this->TypeID."' />";
  983. $hidenform = "<input type='hidden' name='nativeplace' value='$nativeplace' />";
  984. $hidenform = "<input type='hidden' name='infotype' value='$infotype' />";
  985. $hidenform = "<input type='hidden' name='keyword' value='$keyword' />";
  986. $hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."' />";
  987. $purl .= "?tid=".$this->TypeID."&";
  988. //获得上页和下页的链接
  989. if ($this->PageNo != 1) {
  990. $prepage .= "<li class='page-item'><a href='".$purl."PageNo=$prepagenum{$geturl}' class='page-link'>上页</a></li>";
  991. $indexpage = "<li class='page-item'><a href='".$purl."PageNo=1{$geturl}' class='page-link'>首页</a></li>";
  992. } else {
  993. $indexpage = "<li class='page-item disabled'><span class='page-link'>首页</span></li>";
  994. }
  995. if ($this->PageNo != $totalpage && $totalpage > 1) {
  996. $nextpage .= "<li class='page-item'><a href='".$purl."PageNo=$nextpagenum{$geturl}' class='page-link'>下页</a></li>";
  997. $endpage = "<li class='page-item'><a href='".$purl."PageNo=$totalpage{$geturl}' class='page-link'>末页</a></li>";
  998. } else {
  999. $endpage = "<li class='page-item disabled'><span class='page-link'>末页</span></li>";
  1000. }
  1001. //获得数字链接
  1002. $listdd = '';
  1003. $total_list = $list_len * 2 + 1;
  1004. if ($this->PageNo >= $total_list) {
  1005. $j = $this->PageNo - $list_len;
  1006. $total_list = $this->PageNo + $list_len;
  1007. if ($total_list > $totalpage) {
  1008. $total_list = $totalpage;
  1009. }
  1010. } else {
  1011. $j = 1;
  1012. if ($total_list > $totalpage) {
  1013. $total_list = $totalpage;
  1014. }
  1015. }
  1016. for ($j; $j <= $total_list; $j++) {
  1017. if ($j == $this->PageNo) {
  1018. $listdd .= "<li class='page-item active'><span class='page-link'>$j</span></li>";
  1019. } else {
  1020. $listdd .= "<li class='page-item'><a href='".$purl."PageNo=$j{$geturl}' class='page-link'>$j</a></li>";
  1021. }
  1022. }
  1023. $plist = $indexpage.$prepage.$listdd.$nextpage.$endpage;
  1024. //伪静态栏目分页
  1025. if ($cfg_rewrite == 'Y') {
  1026. $plist = str_replace(".php?tid=", "-", $plist);
  1027. $plist = preg_replace("/&PageNo=(\d+)/i", "-\\1", $plist);
  1028. $plist = preg_replace("/&TotalResult=(\d+)&/i", "?", $plist);//去掉分页数值
  1029. }
  1030. return $plist;
  1031. }
  1032. /**
  1033. * 获得当前的页面文件链接
  1034. *
  1035. * @access private
  1036. * @return string
  1037. */
  1038. function GetCurUrl()
  1039. {
  1040. if (!empty($_SERVER["REQUEST_URI"])) {
  1041. $nowurl = $_SERVER["REQUEST_URI"];
  1042. $nowurls = explode("?", $nowurl);
  1043. $nowurl = $nowurls[0];
  1044. } else {
  1045. $nowurl = $_SERVER["PHP_SELF"];
  1046. }
  1047. return $nowurl;
  1048. }
  1049. }//End Class
  1050. ?>