| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- <?php
- function custom($flag = '', $js = 'html')
- {
- global $db;
- global $db_mymps;
- global $jswizard_lists;
- global $jssettings;
- global $jscharset;
- global $mymps_global;
- global $charset;
- global $timestamp;
- if (empty($flag)) {
- exit($js == 'js' ? html2js('Access Diened!') : 'Access Diened!');
- }
- $jswizard_lists = array();
- $data = '';
- $allowflag = '';
- include MYMPS_ROOT . '/data/caches/jswizard_lists.php';
- $jswizard_lists = $data;
- unset($data);
- !in_array($flag, array_keys($jswizard_lists)) && exit(html2js('NO flag exists!'));
- require_once MYMPS_ROOT . '/include/cache.fun.php';
- @include MYMPS_ROOT . '/data/caches/jswizard_settings.php';
- $jssettings = $data;
- unset($data);
- if (empty($jssettings['jsstatus'])) {
- exit(html2js('<font color=red>The webmaster did not enable this feature.</font>'));
- }
- $nocache = empty($jssettings['jscachelife']) ? true : NULL;
- $jsrefdomains = isset($jssettings['jsrefdomains']) ? $jssettings['jsrefdomains'] : preg_replace('/([^\\:]+).*/', '\\1', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : NULL);
- $REFERER = parse_url($_SERVER['HTTP_REFERER']);
- if ($jsrefdomains && (empty($REFERER) || !in_array($REFERER['host'], explode('
- ', trim($jsrefdomains))))) {
- exit($js == 'js' ? html2js('<font color=red>Referer restriction is taking effect.</font>') : '<font color=red>Referer restriction is taking effect.</font>');
- }
- $cachefile = MYMPS_ROOT . '/data/caches/custom_' . $flag . '.php';
- $expiration = NULL;
- @include $cachefile;
- if (!$expiration || $timestamp <= $expiration) {
- require_once MYMPS_ROOT . '/data/config.db.php';
- require_once MYMPS_ROOT . '/include/db.class.php';
- $customtag = customtag($flag);
- $writedata = procdata($customtag);
- if ($js == 'js') {
- $datalist = procdata('document.write("' . $customtag . '");');
- }
- else if ($js == 'html') {
- $datalist = $writedata;
- }
- unset($customtag);
- if (!$nocache) {
- $writedata = '$datalist = \'' . addcslashes($writedata, '\\\'') . '\';';
- UpdateCache($cachefile, $writedata);
- }
- }
- else if ($js == 'js') {
- $datalist = procdata('document.write("' . $datalist . '");');
- }
- return $datalist;
- }
- function customtag($flag = '')
- {
- global $db;
- global $db_mymps;
- global $jswizard_lists;
- global $jssettings;
- global $jscharset;
- global $mymps_global;
- global $charset;
- global $timestamp;
- $parameter = $jswizard_lists[$flag]['parameter'];
- $customtype = $jswizard_lists[$flag]['customtype'];
- switch ($customtype) {
- case 'info':
- $catid = is_array($parameter['catid']) ? implode('\',\'', $parameter['catid']) : NULL;
- $areaid = is_array($parameter['areaid']) ? implode('\',\'', $parameter['areaid']) : NULL;
- $newwindow = !empty($parameter['newwindow']) ? $parameter['newwindow'] : 1;
- $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
- $maxlength = !empty($parameter['maxlength']) ? intval($parameter['maxlength']) : 50;
- $ids = !empty($parameter['ids']) ? str_replace(',', '\',\'', trim($parameter['ids'])) : NULL;
- $keyword = !empty($parameter['keyword']) ? $parameter['keyword'] : NULL;
- $special = is_array($parameter['special']) ? $parameter['special'] : NULL;
- $orderby = !empty($parameter['orderby']) ? ($parameter['orderby'] == 'views' ? 'hit' : 'begintime') : 'begintime';
- $jstemplate = !empty($parameter['jstemplate']) ? $parameter['jstemplate'] : '{title}<br />';
- $jscharset = !empty($parameter['jscharset']) ? $parameter['jscharset'] : NULL;
- $target = $newwindow == 1 ? 'target=_blank' : 'target=_self';
- $jsdateformat = isset($jssettings['jsdateformat']) ? $jssettings['jsdateformat'] : 'Y-m-d';
- $datalist = array();
- if ($keyword) {
- if (preg_match('(AND|\\+|&|\\s)', $keyword) && !preg_match('(OR|\\|)', $keyword)) {
- $andor = ' AND ';
- $keywordsrch = '1';
- $keyword = preg_replace('/( AND |&| )/is', '+', $keyword);
- }
- else {
- $andor = ' OR ';
- $keywordsrch = '0';
- $keyword = preg_replace('/( OR |\\|)/is', '+', $keyword);
- }
- $keyword = str_replace('*', '%', addcslashes($keyword, '%_'));
- foreach (explode('+', $keyword) as $text) {
- $text = trim($text);
- if ($text) {
- $keywordsrch .= $andor;
- $keywordsrch .= 't.title LIKE \'%' . $text . '%\'';
- }
- }
- $keyword = ' AND (' . $keywordsrch . ')';
- }
- else {
- $keyword = '';
- }
- require_once MYMPS_ROOT . '/data/info_special.inc.php';
- $sql = ($catid ? ' AND t.catid IN (\'' . $catid . '\')' : '') . $keyword . ($ids ? ' AND t.id IN (\'' . $ids . '\')' : '') . ($areaid ? ' AND t.areaid IN (\'' . $areaid . '\')' : '');
- if (is_array($special) && $special != array('1', '2', '3', '4', '5', '6', '7', '8', '9')) {
- foreach ($special as $k => $v) {
- switch ($v) {
- case 1:
- $sql .= ' AND t.upgrade_type = \'2\' AND t.upgrade_time > \'$timestamp\'';
- break;
- case 2:
- $sql .= ' AND t.upgrade_type_list = \'2\' AND t.upgrade_time_list > \'$timestamp\'';
- break;
- case 3:
- $sql .= ' AND t.upgrade_type_index = \'2\' AND t.upgrade_time_index > \'$timestamp\'';
- break;
- case 4:
- $sql .= ' AND t.info_level = \'0\'';
- break;
- case 5:
- $sql .= ' AND t.info_level = \'1\'';
- break;
- case 6:
- $sql .= ' AND t.info_level = \'2\'';
- break;
- case 7:
- $sql .= ' AND t.ifred = \'1\'';
- break;
- case 8:
- $sql .= ' AND t.ifbold = \'1\'';
- break;
- case 9:
- $sql .= ' AND t.certify = \'1\'';
- break;
- }
- }
- }
- else {
- $sql .= ' AND t.info_level > \'0\'';
- }
- $sqlfrom = ',t.catname,t.dir_typename FROM `' . $db_mymps . 'information` AS t';
- $query = $db->query('SELECT t.id,t.areaid,t.img_path,t.catid,t.title,t.content,t.userid,t.contact_who,t.ismember,t.begintime,t.hit,t.ifbold,t.ifred
- ' . $sqlfrom . ' WHERE 1
- ' . $sql . '
- ORDER BY t.' . $orderby . ' DESC
- LIMIT 0,' . $items . ';');
- while ($data = $db->fetchRow($query)) {
- $datalist[$data['id']]['catid'] = $data['catid'];
- $datalist[$data['id']]['catname'] = $data['catname'];
- $datalist[$data['id']]['caturl'] = Rewrite('category', array('catid' => $data['catid'], 'dir_typename' => $data['dir_typename'], 'areaid' => $data['areaid']));
- $datalist[$data['id']]['img_path'] = $data['img_path'];
- $datalist[$data['id']]['catnamelength'] = strlen($datalist[$data['id']]['catname']);
- $datalist[$data['id']]['title'] = isset($data['title']) ? str_replace('\'', ' ', addslashes($data['title'])) : NULL;
- $datalist[$data['id']]['link'] = $mymps_global[SiteUrl] . Rewrite('info', array('id' => $data['id'], 'dir_typename' => $data['dir_typename'], 'areaid' => $data['areaid']));
- $datalist[$data['id']]['begintime'] = date($jsdateformat, $data['begintime']);
- $datalist[$data['id']]['hit'] = $data['hit'];
- $datalist[$data['id']]['ifbold'] = $data['ifbold'];
- $datalist[$data['id']]['ifred'] = $data['ifred'];
- $datalist[$data['id']]['introduce'] = str_replace(array('\'', '
- ', '
- '), array(' ', '', ''), addslashes(cutstr(mhtmlspecialchars(preg_replace('/(\\[.+\\])/s', '', strip_tags(nl2br($data['content'])))), 255)));
- if ($data['userid'] && $data['ismember'] == 1) {
- $datalist[$data['id']]['author'] = '<a href=\'' . Rewrite('space', array('user' => $data['userid'])) . '\' target=\'_blank\'>' . $data[userid] . '</a>';
- }
- else {
- $datalist[$data['id']]['author'] = !empty($data['contact_who']) ? $data['contact_who'] : '游客';
- }
- }
- $writedata = '';
- if (is_array($datalist)) {
- foreach ($datalist as $t => $val) {
- $SubjectStyles = '';
- $SubjectStyles .= ' style=\'';
- $SubjectStyles .= $val['ifbold'] == 1 ? 'font-weight: bold;' : NULL;
- $SubjectStyles .= $val['ifred'] == 1 ? 'color: red;' : NULL;
- $SubjectStyles .= '\'';
- $val['title'] = cutstr($val['title'], $catnamelength ? $maxlength - $val['catnamelength'] : $maxlength);
- $replace['{link}'] = $val['link'];
- $replace['{title}'] = '<a title=' . $val['title'] . ' href=\'' . $val['link'] . '\' ' . $SubjectStyles . ' ' . $target . '>' . $val['title'] . '</a>';
- $replace['{title_nolink}'] = $val['title'];
- $replace['{catname}'] = '<a href=\'' . $val['caturl'] . '\' ' . $target . '>' . $val['catname'] . '</a>';
- $replace['{begintime}'] = $val['begintime'];
- $replace['{introduce}'] = $val['introduce'];
- $replace['{author}'] = $val['author'];
- $replace['{hit}'] = $val['hit'];
- $replace['{imgpath}'] = $mymps_global['SiteUrl'] . ($val['img_path'] ? $val['img_path'] : '/images/nophoto.gif');
- $writedata .= str_replace(array_keys($replace), $replace, $jstemplate);
- }
- }
- break;
- case 'news':
- $catid = $parameter['catid'] ? $parameter['catid'] : NULL;
- $newwindow = !empty($parameter['newwindow']) ? $parameter['newwindow'] : 1;
- $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
- $maxlength = !empty($parameter['maxlength']) ? intval($parameter['maxlength']) : 40;
- $special = $parameter['special'];
- $orderby = !empty($parameter['orderby']) ? ($parameter['orderby'] == 'views' ? 'hit' : NULL) : NULL;
- $jstemplate = !empty($parameter['jstemplate']) ? $parameter['jstemplate'] : '<li>{title}</li>';
- $jscharset = !empty($parameter['jscharset']) ? $parameter['jscharset'] : NULL;
- $target = $newwindow == 1 ? 'target=_blank' : 'target=_self';
- $jsdateformat = isset($jssettings['jsdateformat']) ? $jssettings['jsdateformat'] : 'Y-m-d';
- $if_img = $special[0];
- $if_commend = $special[1];
- $datalist = mymps_get_news($items, $catid, $if_img, strexists($jstemplate, '{catname}') ? 1 : 0, $if_commend, $orderby);
- $writedata = '';
- if (is_array($datalist)) {
- foreach ($datalist as $t => $val) {
- $SubjectStyles = '';
- $SubjectStyles .= ' style=\'';
- $SubjectStyles .= $val['is_commend'] == 1 ? 'font-weight: bold;' : NULL;
- $SubjectStyles .= $val['is_commend'] == 1 ? 'color: red;' : NULL;
- $SubjectStyles .= '\'';
- $val['title'] = cutstr($val['title'], $maxlength);
- $replace['{link}'] = $val['uri'];
- $replace['{title}'] = '<a title=' . $val['title'] . ' href=\'' . $val['uri'] . '\' ' . $SubjectStyles . ' ' . $target . '>' . $val['title'] . '</a>';
- $replace['{title_nolink}'] = $val['title'];
- $replace['{catname}'] = '<a href=\'' . $val['caturi'] . '\' ' . $target . '>' . $val['catname'] . '</a>';
- $replace['{begintime}'] = date($jsdateformat, $val['begintime']);
- $replace['{introduce}'] = str_replace(array('\'', '
- ', '
- '), array(' ', '', ''), addslashes(cutstr(mhtmlspecialchars(preg_replace('/(\\[.+\\])/s', '', strip_tags(nl2br($val['content'])))), 255)));
- $replace['{hit}'] = $val['hit'];
- $replace['{imgpath}'] = $mymps_global['SiteUrl'] . ($val['imgpath'] ? $val['imgpath'] : '/images/nophoto.gif');
- $writedata .= str_replace(array_keys($replace), $replace, $jstemplate);
- }
- }
- break;
- case 'store':
- $catid = $parameter['catid'] ? $parameter['catid'] : NULL;
- $newwindow = !empty($parameter['newwindow']) ? $parameter['newwindow'] : 1;
- $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
- $maxlength = !empty($parameter['maxlength']) ? intval($parameter['maxlength']) : 40;
- $special = $parameter['special'];
- $areaid = $parameter['areaid'];
- $levelid = $parameter['levelid'];
- $orderby = !empty($parameter['orderby']) ? ($parameter['orderby'] == 'dateline' ? 0 : 1) : 0;
- $jstemplate = !empty($parameter['jstemplate']) ? $parameter['jstemplate'] : '<li>{title}</li>';
- $jscharset = !empty($parameter['jscharset']) ? $parameter['jscharset'] : NULL;
- $target = $newwindow == 1 ? 'target=_blank' : 'target=_self';
- $jsdateformat = isset($jssettings['jsdateformat']) ? $jssettings['jsdateformat'] : 'Y-m-d';
- $if_certify = $special[0];
- $ifindex = $special[1];
- $iflist = $special[2];
- $datalist = mymps_get_members($items, $levelid, $orderby, 1, $if_certify, $ifindex, $iflist, $areaid, $catid);
- $writedata = '';
- if (is_array($datalist)) {
- foreach ($datalist as $t => $val) {
- $val['tname'] = cutstr($val['tname'], $maxlength);
- $replace['{link}'] = $val['uri'];
- $replace['{tname}'] = '<a title=' . $val['tname'] . ' href=\'' . $val['uri'] . '\' ' . $target . '>' . $val['tname'] . '</a>';
- $replace['{tname_nolink}'] = $val['tname'];
- $replace['{jointime}'] = date($jsdateformat, $val['jointime']);
- $replace['{introduce}'] = str_replace(array('\'', '
- ', '
- '), array(' ', '', ''), addslashes(cutstr(mhtmlspecialchars(preg_replace('/(\\[.+\\])/s', '', strip_tags(nl2br($val['content'])))), 255)));
- $replace['{hit}'] = $val['hit'];
- $replace['{qq}'] = $val['qq'];
- $replace['{tel}'] = $val['tel'];
- $replace['{address}'] = $val['address'];
- $replace['{userid}'] = $val['userid'];
- $replace['{prelogo}'] = $mymps_global['SiteUrl'] . $val['prelogo'];
- $writedata .= str_replace(array_keys($replace), $replace, $jstemplate);
- }
- }
- break;
- case 'goods':
- $catid = $parameter['catid'] ? $parameter['catid'] : NULL;
- $newwindow = !empty($parameter['newwindow']) ? $parameter['newwindow'] : 1;
- $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
- $maxlength = !empty($parameter['maxlength']) ? intval($parameter['maxlength']) : 40;
- $special = $parameter['special'];
- $areaid = $parameter['areaid'];
- $orderby = !empty($parameter['orderby']) ? ($parameter['orderby'] == 'dateline' ? 0 : 1) : 0;
- $jstemplate = !empty($parameter['jstemplate']) ? $parameter['jstemplate'] : '<li>{title}</li>';
- $jscharset = !empty($parameter['jscharset']) ? $parameter['jscharset'] : NULL;
- $target = $newwindow == 1 ? 'target=_blank' : 'target=_self';
- $jsdateformat = isset($jssettings['jsdateformat']) ? $jssettings['jsdateformat'] : 'Y-m-d';
- if ($special[0] == 1) {
- $shuxing = 'tuijian';
- }
- else if ($special[1] == 1) {
- $shuxing = 'remai';
- }
- else if ($special[2] == 1) {
- $shuxing = 'cuxiao';
- }
- $datalist = mymps_get_goods($items, 1, $shuxing, $catid, $areaid, $orderby);
- $writedata = '';
- if (is_array($datalist)) {
- foreach ($datalist as $t => $val) {
- $val['uri'] = $val['uri'];
- $val['goodsname'] = cutstr($val['goodsname'], $maxlength);
- $replace['{link}'] = $val['uri'];
- $replace['{goodsname}'] = '<a title=' . $val['goodsname'] . ' href=\'' . $val['uri'] . '\' ' . $target . '>' . $val['goodsname'] . '</a>';
- $replace['{goodsname_nolink}'] = $val['goodsname'];
- $replace['{jointime}'] = date($jsdateformat, $val['jointime']);
- $replace['{introduce}'] = str_replace(array('\'', '
- ', '
- '), array(' ', '', ''), addslashes(cutstr(mhtmlspecialchars(preg_replace('/(\\[.+\\])/s', '', strip_tags(nl2br($val['content'])))), 255)));
- $replace['{oldprice}'] = $val['oldprice'];
- $replace['{nowprice}'] = $val['nowprice'];
- $replace['{userid}'] = $val['userid'];
- $replace['{picture}'] = $mymps_global['SiteUrl'] . $val['picture'];
- $replace['{prepicture}'] = $mymps_global['SiteUrl'] . $val['prepicture'];
- $writedata .= str_replace(array_keys($replace), $replace, $jstemplate);
- }
- }
- break;
- }
- unset($mymps_global);
- return parsenode($writedata);
- }
- function parsenode($data)
- {
- global $jstemplate;
- if ($jstemplate) {
- $data = preg_replace('/\\[node\\](.+?)\\[\\/node\\]/is', $data, $jstemplate, 1);
- $data = preg_replace('/\\[node\\](.+?)\\[\\/node\\]/is', '', $data);
- }
- return $data;
- }
- function procdata($data)
- {
- global $jscharset;
- global $charset;
- if ($jscharset && strtoupper($charset) == 'GBK') {
- $data = iconv('GBK', 'UTF-8', $data);
- }
- return $data;
- }
- function UpdateCache($cachefile, $data = '')
- {
- global $timestamp;
- global $jscachelife;
- if (!($fp = @fopen($cachefile, 'wb'))) {
- exit('document.write("Unable to write to cache file!<br />Please chmod ./data/caches to 777 and try again.");');
- }
- $fp = @fopen($cachefile, 'wb');
- $cachedata = 'if(!defined(\'IN_MYMPS\')) exit(\'Access Denied\');
- $expiration = \'' . ($timestamp + $jscachelife) . '\';
- ' . $data . '
- ';
- @fwrite($fp, '<?php
- //Mymps cache file, DO NOT modify me!' . '
- //Created: ' . date('M j, Y, G:i') . '
- //Identify: ' . md5(basename($cachefile) . $cachedata) . ('
- ' . $cachedata . '?>'));
- @fclose($fp);
- }
- ?>
|