[parasy commit] r19 - in trunk: setting sql tools upload upload/images/favicons upload/images/favicons/bbs upload...

0 views
Skip to first unread message

codesite...@google.com

unread,
Nov 23, 2007, 6:27:37 AM11/23/07
to project...@googlegroups.com
Author: Saiccc
Date: Fri Nov 23 03:26:15 2007
New Revision: 19

Added:
trunk/sql/parasy.mysql.sql
trunk/tools/
trunk/tools/parasy_env.php
trunk/upload/images/favicons/
trunk/upload/images/favicons/baidu.png (contents, props changed)
trunk/upload/images/favicons/bbs/
trunk/upload/images/favicons/bbs/fico_blinklist.gif (contents,
props changed)
trunk/upload/images/favicons/bbs/fico_blogspot.gif (contents,
props changed)
trunk/upload/images/favicons/bbs/fico_box.gif (contents, props changed)
trunk/upload/images/favicons/bbs/fico_bulaoge.gif (contents, props changed)
trunk/upload/images/favicons/bbs/fico_buzznet.gif (contents, props changed)
trunk/upload/images/favicons/bbs/fico_delicious.gif (contents,
props changed)
trunk/upload/images/favicons/bbs/fico_deviantart.gif (contents,
props changed)
trunk/upload/images/favicons/bbs/fico_douban.gif (contents, props changed)
trunk/upload/images/favicons/bbs/fico_feedburner.gif (contents,
props changed)
trunk/upload/images/favicons/bbs/fico_flickr.gif (contents, props changed)
trunk/upload/images/favicons/bbs/fico_google.gif (contents, props changed)
trunk/upload/images/favicons/bbs/fico_mac.gif (contents, props changed)
trunk/upload/images/favicons/bbs/fico_saicn.gif (contents, props changed)
trunk/upload/images/favicons/bbs/fico_spaces.gif (contents, props changed)
trunk/upload/images/favicons/bbs/fico_technorati.gif (contents,
props changed)
trunk/upload/images/favicons/bbs/fico_web.gif (contents, props changed)
trunk/upload/images/favicons/blogbus.png (contents, props changed)
trunk/upload/images/favicons/da.png (contents, props changed)
trunk/upload/images/favicons/delicious.png (contents, props changed)
trunk/upload/images/favicons/dotmac.png (contents, props changed)
trunk/upload/images/favicons/douban.png (contents, props changed)
trunk/upload/images/favicons/feedsky.png (contents, props changed)
trunk/upload/images/favicons/firefox.png (contents, props changed)
trunk/upload/images/favicons/flickr.png (contents, props changed)
trunk/upload/images/favicons/google/
trunk/upload/images/favicons/google.png (contents, props changed)
trunk/upload/images/favicons/google/blogger.png (contents, props changed)
trunk/upload/images/favicons/google/calendar.png (contents, props changed)
trunk/upload/images/favicons/google/docs.png (contents, props changed)
trunk/upload/images/favicons/google/gmail.png (contents, props changed)
trunk/upload/images/favicons/google/google.png (contents, props changed)
trunk/upload/images/favicons/google/groups.png (contents, props changed)
trunk/upload/images/favicons/google/reader.png (contents, props changed)
trunk/upload/images/favicons/ifl.png (contents, props changed)
trunk/upload/images/favicons/kijiji.png (contents, props changed)
trunk/upload/images/favicons/kooxoo.png (contents, props changed)
trunk/upload/images/favicons/mysql.png (contents, props changed)
trunk/upload/images/favicons/netvibes.png (contents, props changed)
trunk/upload/images/favicons/opera.png (contents, props changed)
trunk/upload/images/favicons/osnews.png (contents, props changed)
trunk/upload/images/favicons/pageflakes.png (contents, props changed)
trunk/upload/images/favicons/php.png (contents, props changed)
trunk/upload/images/favicons/saicn.png (contents, props changed)
trunk/upload/images/favicons/sf.png (contents, props changed)
trunk/upload/images/favicons/skype.png (contents, props changed)
trunk/upload/images/favicons/slashdot.png (contents, props changed)
trunk/upload/images/favicons/tudou.png (contents, props changed)
trunk/upload/images/favicons/twitter.png (contents, props changed)
trunk/upload/images/favicons/v2ex.png (contents, props changed)
trunk/upload/images/favicons/verycd.png (contents, props changed)
trunk/upload/images/favicons/vitamin.png (contents, props changed)
trunk/upload/images/favicons/wealink.png (contents, props changed)
trunk/upload/images/favicons/web.png (contents, props changed)
trunk/upload/images/favicons/yahoo.png (contents, props changed)
trunk/upload/images/favicons/yodao.png (contents, props changed)
trunk/upload/images/favicons/youtube.png (contents, props changed)
trunk/upload/images/favicons/yupoo.png (contents, props changed)
trunk/upload/images/favicons/zhuaxia.png (contents, props changed)
trunk/upload/images/way/bullet_go.png (contents, props changed)
trunk/upload/images/way/report_edit.png (contents, props changed)
trunk/upload/include/
trunk/upload/include/cache.func.php
trunk/upload/include/category.inc.php
trunk/upload/include/common.inc.php
trunk/upload/include/crons/
trunk/upload/include/crons/parasy_stats_daily.inc.php
trunk/upload/include/editpost.inc.php
trunk/upload/include/forum.func.php
trunk/upload/include/global.func.php
trunk/upload/include/javascript/
trunk/upload/include/javascript/ajaxtabs.js
trunk/upload/include/javascript/common.js
trunk/upload/include/javascript/greybox/
trunk/upload/include/javascript/greybox/AJS.js
trunk/upload/include/javascript/greybox/AJS_fx.js
trunk/upload/include/javascript/greybox/g_close.gif (contents,
props changed)
trunk/upload/include/javascript/greybox/gb_scripts.js
trunk/upload/include/javascript/greybox/gb_styles.css
trunk/upload/include/javascript/greybox/header_bg.gif (contents,
props changed)
trunk/upload/include/javascript/greybox/indicator.gif (contents,
props changed)
trunk/upload/include/javascript/greybox/loader_frame.html
trunk/upload/include/javascript/greybox/next.gif (contents, props changed)
trunk/upload/include/javascript/greybox/prev.gif (contents, props changed)
trunk/upload/include/javascript/greybox/w_close.gif (contents,
props changed)
trunk/upload/include/javascript/home_tabs.js
trunk/upload/include/javascript/jquery.js
trunk/upload/include/javascript/prototype.js
trunk/upload/include/javascript/swfobject.js
trunk/upload/include/libs/
trunk/upload/include/libs/magpierss/
trunk/upload/include/libs/magpierss/extlib/
trunk/upload/include/libs/magpierss/extlib/Snoopy.class.inc
trunk/upload/include/libs/magpierss/rss_cache.inc
trunk/upload/include/libs/magpierss/rss_fetch.inc
trunk/upload/include/libs/magpierss/rss_parse.inc
trunk/upload/include/libs/magpierss/rss_utils.inc
trunk/upload/include/libs/magpierss/scripts/
trunk/upload/include/libs/magpierss/scripts/magpie_debug.php
trunk/upload/include/libs/magpierss/scripts/magpie_simple.php
trunk/upload/include/libs/magpierss/scripts/magpie_slashbox.php
trunk/upload/include/libs/magpierss/scripts/simple_smarty.php
trunk/upload/include/libs/magpierss/scripts/smarty_plugin/
trunk/upload/include/libs/magpierss/scripts/smarty_plugin/modifier.rss_date_parse.php
trunk/upload/include/libs/magpierss/scripts/templates/
trunk/upload/include/libs/magpierss/scripts/templates/simple.smarty
trunk/upload/include/newreply.inc.php
trunk/upload/include/newthread.inc.php
trunk/upload/include/post.func.php
trunk/upload/include/wbg/
trunk/upload/include/wbg/wbg1.png (contents, props changed)
trunk/upload/include/wbg/wbg2.jpg (contents, props changed)
trunk/upload/include/wbg/wbg_bubble.gif (contents, props changed)
trunk/upload/parasy/ParasyNav.php
trunk/upload/templates/babel/memberlist.htm
Removed:
trunk/setting/
trunk/sql/sql.txt
trunk/upload/admincp.php
trunk/upload/attachment.php
trunk/upload/discuz_version.php
trunk/upload/inculde/
trunk/upload/member.php
trunk/upload/misc.php
trunk/upload/plugins/now/
trunk/upload/pm.php
trunk/upload/post.php
trunk/upload/rss.php
trunk/upload/search.php
trunk/upload/space.php
Modified:
trunk/upload/.htaccess
trunk/upload/memcp.php
trunk/upload/parasy.php
trunk/upload/parasy/ParasyCore.php
trunk/upload/parasy/ParasySettings.inc.php
trunk/upload/parasy_dashboard.php
trunk/upload/parasy_geo.php
trunk/upload/templates/babel/expense_view.htm
trunk/upload/templates/babel/forumdisplay.htm
trunk/upload/templates/babel/header.htm
trunk/upload/templates/babel/now.htm
trunk/upload/templates/babel/viewpro_classic.htm
trunk/upload/viewpro.php

Log:
Opps..I have nothing to say...

Added: trunk/sql/parasy.mysql.sql
==============================================================================
--- (empty file)
+++ trunk/sql/parasy.mysql.sql Fri Nov 23 03:26:15 2007
@@ -0,0 +1,176 @@
+--
+-- Project Parasynthesis Database Structure
+--
+-- [EN] You should change the 'cdb_' as the same as the $tablepre in config.inc.php
+-- [CN] ������Ĺ���ݿ����ǰ׺��������滻 'cdb_' Ϊ����
config.inc.php �����õ� $tablepre
+--
+
+--
+-- GBK
+--
+
+ALTER TABLE `cdb_forums` ADD `board_name` char(50) NOT NULL;
+ALTER TABLE `cdb_forums` ADD `idx_push` tinyint(1) NOT NULL default '0';
+ALTER TABLE `cdb_favorites` ADD `dateline` int(10) NOT NULL;
+ALTER TABLE `cdb_members` ADD `now_img` mediumint(10) NOT NULL default '0';
+ALTER TABLE `cdb_members` ADD `idx_cloud` tinyint(1) NOT NULL default '0';
+ALTER TABLE `cdb_members` ADD `usr_geo` varchar(100) NOT NULL default 'earth';
+
+--
+-- Table structure for table `cdb_savepoint`
+--
+
+CREATE TABLE `cdb_savepoint` (
+ `svp_id` int(10) unsigned NOT NULL auto_increment,
+ `svp_uid` int(10) unsigned NOT NULL default '0',
+ `svp_url` varchar(255) NOT NULL default '',
+ `svp_rank` int(10) unsigned NOT NULL default '0',
+ `svp_created` int(10) unsigned NOT NULL default '0',
+ `svp_lastupdated` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`svp_id`),
+ KEY `INDEX_UID` (`svp_uid`),
+ KEY `INDEX_URL` (`svp_url`)
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `cdb_geo_usage_simple`
+--
+
+CREATE TABLE `cdb_geo_usage_simple` (
+ `gus_geo` varchar(100) NOT NULL default 'earth',
+ `gus_name_cn` varchar(100) NOT NULL default '����',
+ `gus_name_en` varchar(100) NOT NULL default 'Earth',
+ `gus_hits` int(10) unsigned NOT NULL default '0',
+ `gus_lastupdated` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`gus_geo`),
+ UNIQUE KEY `INDEX_NAME_CN` (`gus_name_cn`),
+ UNIQUE KEY `INDEX_NAME_EN` (`gus_name_en`)
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `cdb_geo_going`
+--
+
+CREATE TABLE `cdb_geo_going` (
+ `ggg_id` int(10) unsigned NOT NULL auto_increment,
+ `ggg_uid` int(10) unsigned NOT NULL default '0',
+ `ggg_geo` varchar(100) NOT NULL,
+ `ggg_impression` text,
+ `ggg_created` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`ggg_id`),
+ KEY `INDEX_UID` (`ggg_uid`),
+ KEY `INDEX_GEO` (`ggg_geo`)
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `cdb_geo_been`
+--
+
+CREATE TABLE `cdb_geo_been` (
+ `gbn_id` int(10) unsigned NOT NULL auto_increment,
+ `gbn_uid` int(10) unsigned NOT NULL default '0',
+ `gbn_geo` varchar(100) NOT NULL,
+ `gbn_impression` text,
+ `gbn_created` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`gbn_id`),
+ KEY `INDEX_UID` (`gbn_uid`),
+ KEY `INDEX_GEO` (`gbn_geo`)
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `cdb_plugin_now`
+--
+
+CREATE TABLE IF NOT EXISTS `cdb_plugin_now` (
+ `vid` mediumint(8) NOT NULL auto_increment,
+ `dateline` int(10) NOT NULL default '0',
+ `author` varchar(15) NOT NULL default '',
+ `authorid` mediumint(8) NOT NULL default '0',
+ `content` varchar(250) NOT NULL default '',
+ `background` varchar(35) NOT NULL default '',
+ `icons` int(2) NOT NULL default '0',
+ PRIMARY KEY (`vid`)
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `cdb_plugin_now_stats`
+--
+
+CREATE TABLE IF NOT EXISTS `cdb_plugin_now_stats` (
+ `uid` mediumint(8) NOT NULL default '0',
+ `total` int(10) NOT NULL default '0',
+ `monthly` int(10) NOT NULL default '0',
+ `weekly` int(10) NOT NULL default '0',
+ `daily` mediumtext NOT NULL,
+ `firstupdate` int(10) NOT NULL default '0',
+ `lastupdate` int(10) NOT NULL default '0',
+ PRIMARY KEY (`uid`)
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `cdb_expense`
+--
+
+CREATE TABLE `cdb_expense` (
+ `exp_id` int(10) unsigned NOT NULL auto_increment,
+ `exp_uid` int(10) unsigned NOT NULL default '0',
+ `exp_amount` double NOT NULL default '0',
+ `exp_type` int(10) unsigned NOT NULL default '0',
+ `exp_memo` text,
+ `exp_created` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`exp_id`),
+ KEY `INDEX_UID` (`exp_uid`),
+ KEY `INDEX_TYPE` (`exp_type`),
+ KEY `INDEX_CREATED` (`exp_created`)
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+
+
+CREATE TABLE `cdb_plugin_tod_project` (
+ `tpr_id` int(10) unsigned NOT NULL auto_increment,
+ `tpr_uid` int(10) unsigned NOT NULL default '0',
+ `tpr_private` int(10) unsigned NOT NULL default '0',
+ `tpr_title` varchar(100) NOT NULL default '',
+ `tpr_progress` int(10) unsigned NOT NULL default '0',
+ `tpr_type` int(10) unsigned NOT NULL default '0',
+ `tpr_tasks` int(10) unsigned NOT NULL default '0',
+ `tpr_notes` int(10) unsigned NOT NULL default '0',
+ `tpr_dbs` int(10) unsigned NOT NULL default '0',
+ `tpr_created` int(10) unsigned NOT NULL default '0',
+ `tpr_lastupdated` int(10) unsigned NOT NULL default '0',
+ `tpr_lasttouched` int(10) unsigned NOT NULL default '0',
+ `tpr_completed` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`tpr_id`),
+ KEY `INDEX_UID` (`tpr_uid`),
+ KEY `INDEX_PRIVATE` (`tpr_private`),
+ KEY `INDEX_PROGRESS` (`tpr_progress`)
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+
+CREATE TABLE `cdb_plugin_tod_task` (
+ `tta_id` int(10) unsigned NOT NULL auto_increment,
+ `tta_uid` int(10) unsigned NOT NULL default '0',
+ `tta_pid` int(10) unsigned NOT NULL default '0',
+ `tta_title` varchar(100) NOT NULL default '',
+ `tta_level` int(10) unsigned NOT NULL default '0',
+ `tta_todo` int(1) unsigned NOT NULL default '0',
+ `tta_progress` int(10) unsigned NOT NULL default '0',
+ `tta_created` int(10) unsigned NOT NULL default '0',
+ `tta_lastupdated` int(10) unsigned NOT NULL default '0',
+ `tta_lasttouched` int(10) unsigned NOT NULL default '0',
+ `tta_completed` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`tta_id`),
+ KEY `INDEX_UID` (`tta_uid`),
+ KEY `INDEX_PID` (`tta_pid`),
+ KEY `INDEX_PROGRESS` (`tta_progress`)
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
\ No newline at end of file

Added: trunk/tools/parasy_env.php
==============================================================================
--- (empty file)
+++ trunk/tools/parasy_env.php Fri Nov 23 03:26:15 2007
@@ -0,0 +1,119 @@
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<title>Project Parasy</title>
+<style>
+body {
+font-family: "Lucida Grande", Verdana, Sans;
+padding: 10px;
+margin: 0px;
+background-color: #999;
+}
+
+div.error {
+background-color: #FFF;
+padding: 10px;
+font-size: 12px;
+max-width: 500px;
+border-right: 2px solid #777;
+border-bottom: 2px solid #777;
+line-height: 20px;
+}
+
+h1 {
+color: #999;
+font-size: 18px;
+font-weight: normal;
+padding: 2px 0px 10px 0px;
+margin: 0px;
+}
+
+a:link, a:visited, a:active {
+color: #577DE4;
+text-decoration: none;
+}
+
+a:hover {
+text-decoration: underline;
+}
+
+div#debug {
+border-top: 2px solid #999;
+font-size: 10px;
+color: #333;
+clear: both;
+opacity: .85;
+padding: 5px;
+}
+
+div#debug table {
+border: 1px solid #CCC;
+background-color: #333;
+}
+
+div#debug table td {
+font-size: 10px;
+color: #FFF;
+}
+
+span.ver {
+font-size: 10px;
+color: #CCC;
+display: block;
+padding: 10px 0px 0px 0px;
+}
+
+.red {
+color: #F00;
+}
+
+.green {
+color: #0C0;
+}
+
+.tip {
+color: #999;
+}
+</style>
+</head>
+<body>
+<div class="error">
+<h1>Project Parasy Environment</h1>
+<?php
+$version = PHP_VERSION;
+if (substr($version, 0, 1) == '5') {
+ echo('PHP Version: <strong>' . PHP_VERSION . '</strong><br
/>--<strong class="green">Geo System Supported</strong>');
+} else {
+ echo('PHP Version: <strong>' . PHP_VERSION . '</strong><br
/>--<strong class="red">Geo System Unsupported</strong>');
+}
+if (function_exists('json_encode')) {
+ echo('<br />--<strong class="green">Json Supported</strong>');
+} else {
+ echo('<br />--<strong class="red">Json Unsupported (View
parasy_json_tab.php to enable Zend Framework)</strong>');
+}
+echo('<br />');
+if (function_exists('apache_get_version')) {
+ echo('Runtime Environment: <strong><small>' . apache_get_version() . '</small></strong>');
+ echo('<br />');
+ $_modules = apache_get_modules();
+ if (in_array('mod_rewrite', $_modules)) {
+
+ echo('-- mod_rewrite: <strong class="green">Supported</strong>');
+ } else {
+ echo('-- mod_rewrite: <strong class="red">Missing</strong>');
+ }
+} else {
+ echo('Runtime Environment: CGI/FastCGI');
+}
+echo('<br />');
+if (function_exists('mysql_connect')) {
+
+ echo('MySQL Client API: <strong class="green">Supported</strong>');
+} else {
+ echo('MySQL Client API: <strong class="red">Missing</strong>');
+}
+?>
+<span class="ver">Project Parasynthesis | Based on Discuz! 5.5.0 |
Thanks to Livid</span>
+</div>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/upload/.htaccess
==============================================================================
--- trunk/upload/.htaccess (original)
+++ trunk/upload/.htaccess Fri Nov 23 03:26:15 2007
@@ -88,6 +88,10 @@

RewriteRule ^feed/now$ parasy_now_api.php?action=feed&type=public [L]

+RewriteRule ^tod$ plugin.php?identifier=tod&module=tod&action=home [L]
+RewriteRule ^tod/$ plugin.php?identifier=tod&module=tod&action=home [L]
+RewriteRule ^tod/([^\/]+)$
plugin.php?identifier=tod&module=tod&action=home&username=$1 [L]
+
RewriteRule ^now$ plugin.php?identifier=now&module=now&action=index [L]
RewriteRule ^now/$ plugin.php?identifier=now&module=now&action=index [L]
RewriteRule ^now/([^\/]+)$
plugin.php?identifier=now&module=now&author=$1 [L]

Added: trunk/upload/images/favicons/baidu.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_blinklist.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_blogspot.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_box.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_bulaoge.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_buzznet.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_delicious.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_deviantart.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_douban.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_feedburner.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_flickr.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_google.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_mac.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_saicn.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_spaces.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_technorati.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/bbs/fico_web.gif
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/blogbus.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/da.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/delicious.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/dotmac.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/douban.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/feedsky.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/firefox.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/flickr.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/google.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/google/blogger.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/google/calendar.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/google/docs.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/google/gmail.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/google/google.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/google/groups.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/google/reader.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/ifl.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/kijiji.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/kooxoo.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/mysql.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/netvibes.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/opera.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/osnews.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/pageflakes.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/php.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/saicn.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/sf.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/skype.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/slashdot.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/tudou.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/twitter.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/v2ex.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/verycd.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/vitamin.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/wealink.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/web.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/yahoo.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/yodao.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/youtube.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/yupoo.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/favicons/zhuaxia.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/way/bullet_go.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/images/way/report_edit.png
==============================================================================
Binary file. No diff available.

Added: trunk/upload/include/cache.func.php
==============================================================================
--- (empty file)
+++ trunk/upload/include/cache.func.php Fri Nov 23 03:26:15 2007
@@ -0,0 +1,1223 @@
+<?php
+
+/*
+ [Discuz!] (C)2001-2007 Comsenz Inc.
+ This is NOT a freeware, use is subject to license terms
+
+ $RCSfile: cache.func.php,v $
+ $Revision: 1.130.2.37 $
+ $Date: 2007/07/24 17:24:22 $
+*/
+
+define('DISCUZ_KERNEL_VERSION', '5.5.0');
+define('DISCUZ_KERNEL_RELEASE', '20070724');
+
+if(isset($_GET['kernel_version'])) {
+ exit('Crossday Discuz! Board<br>Developed by Comsenz Inc.<br><br>Version: '.DISCUZ_KERNEL_VERSION.'<br>Release: '.DISCUZ_KERNEL_RELEASE);
+} elseif(!defined('IN_DISCUZ')) {
+ exit('Access Denied');
+}
+
+function arrayeval($array, $level = 0) {
+
+ if(is_array($array) && function_exists('var_export')) {
+ return var_export($array, true);
+ }
+
+ $space = '';
+ for($i = 0; $i <= $level; $i++) {
+ $space .= "\t";
+ }
+ $evaluate = "Array\n$space(\n";
+ $comma = $space;
+ if(is_array($array)) {
+ foreach($array as $key => $val) {
+ $key = is_string($key) ? '\''.addcslashes($key, '\'\\').'\'' : $key;
+ $val = !is_array($val) && (!preg_match("/^\-?[1-9]\d*$/", $val) ||
strlen($val) > 12) ? '\''.addcslashes($val, '\'\\').'\'' : $val;
+ if(is_array($val)) {
+ $evaluate .= "$comma$key => ".arrayeval($val, $level + 1);
+ } else {
+ $evaluate .= "$comma$key => $val";
+ }
+ $comma = ",\n$space";
+ }
+ }
+ $evaluate .= "\n$space)";
+ return $evaluate;
+}
+
+function updatecache($cachename = '') {
+ global $db, $bbname, $tablepre, $maxbdays;
+
+ $cachescript = array
+ (
+ 'settings' => array('settings'),
+ 'jswizard' => array('jswizard'),
+ 'index' => array('announcements', 'onlinelist', 'forumlinks', 'advs', 'supe_updateusers', 'supe_updateitems'),
+ 'forumdisplay' => array('announcements_forum', 'pmlist', 'globalstick', 'forums', 'icons', 'onlinelist', 'smiliestable', 'advs'),
+ 'viewthread' => array('forums', 'pmlist', 'usergroups', 'ranks', 'bbcodes', 'smilies', 'fields_thread', 'smiliestable', 'advs'),
+ 'pm' => array('smiliestable'),
+ 'post' => array('bbcodes_display', 'bbcodes', 'smilies_display', 'smilies', 'icons'),
+ 'blog' => array('usergroups', 'ranks', 'bbcodes', 'smilies'),
+ 'forums' => array('forums'),
+ 'new_forums' => array('new_forums'),
+ 'profilefields' => array('fields_required', 'fields_optional'),
+ 'censor' => array('censor'),
+ 'ipbanned' => array('ipbanned'),
+ 'bbcodes' => array('bbcodes', 'smilies'),
+ 'medals' => array('medals'),
+ 'magics' => array('magics'),
+ 'usergroups' => array('usergroups'),
+ 'topicadmin' => array('modreasons'),
+ 'archiver' => array('advs'),
+ 'register' => array('advs'),
+ 'faqs' => array('faqs'),
+ 'secqaa' => array('secqaa'),
+ 'updatecircles' => array('supe_updatecircles'),
+ 'nowhere' => array('nowhere'),//nowhere
+ 'toplist'=> array('newthread'),//newthread
+ 'fav' =>array ('fav'),
+ 'lastmembers'=> array('lastmembers')//LastMember
+ );
+ if($maxbdays) {
+ $cachescript['birthdays'] = array('birthdays');
+ $cachescript['index'][] = 'birthdays_index';
+ }
+
+ foreach($cachescript as $script => $cachenames) {
+ if(!$cachename || (!is_array($cachename) && in_array($cachename,
$cachenames)) || (is_array($cachename) && array_intersect($cachename,
$cachenames))) {
+ $cachedata = '';
+ if($cachename && !is_array($cachename) && $script <> $cachename) {
+ $_DCACHE = array();
+ @include(DISCUZ_ROOT.'./forumdata/cache/cache_'.$script.'.php');
+ if($_DCACHE && isset($_DCACHE[$cachename])) {
+ foreach ($_DCACHE as $key => $val) {
+ $cachedata .= ($key == $cachename) ? getcachearray($cachename,
$script) : getcachevars(array("_DCACHE['$key']" => $val));
+ }
+ }
+ }
+ writetocache($script, $cachenames, $cachedata);
+ }
+ }
+
+ if(!$cachename || $cachename == 'styles') {
+ $stylevars = array();
+ $defaultstyleid = $_DCACHE['settings']['styleid'] ?
$_DCACHE['settings']['styleid'] : $GLOBALS['styleid'];
+ $query = $db->query("SELECT sv.* FROM {$tablepre}stylevars sv LEFT
JOIN {$tablepre}styles s ON s.styleid = sv.styleid AND (s.available=1
OR s.styleid='$defaultstyleid')");
+ while($var = $db->fetch_array($query)) {
+ $stylevars[$var['styleid']][$var['variable']] = $var['substitute'];
+ }
+ $query = $db->query("SELECT s.*, t.directory AS tpldir FROM
{$tablepre}styles s LEFT JOIN {$tablepre}templates t ON
s.templateid=t.templateid WHERE s.available=1 OR s.styleid='$defaultstyleid'");
+ while($data = $db->fetch_array($query)) {
+ $data = array_merge($data, $stylevars[$data['styleid']]);
+
+ $data['bgcode'] = strpos($data['bgcolor'], '.') ?
(preg_match('/^http:\/\//i', $data['bgcolor']) ? "background-image:
url(\"$data[bgcolor]\")" : "background-image:
url(\"$data[imgdir]/$data[bgcolor]\")") : "background-color: $data[bgcolor]";
+ $data['catbgcode'] = strpos($data['catcolor'], '.') ?
(preg_match('/^http:\/\//i', $data['catcolor']) ? "background-image:
url(\"$data[catcolor]\")" : "background-image:
url(\"$data[imgdir]/$data[catcolor]\")") : "background-color: $data[catcolor]";
+ $data['headerbgcode'] = strpos($data['headercolor'], '.') ?
(preg_match('/^http:\/\//i', $data['headercolor']) ? "background-image:
url(\"$data[headercolor]\")" : "background-image:
url(\"$data[imgdir]/$data[headercolor]\")") : "background-color: $data[headercolor]";
+ $data['headermenubgcode'] = strpos($data['headermenu'], '.') ?
(preg_match('/^http:\/\//i', $data['headermenu']) ? "background-image:
url(\"$data[headermenu]\")" : "background-image:
url(\"$data[imgdir]/$data[headermenu]\")") : "background-color: $data[headermenu]";
+ $data['framebg'] = preg_match('/^http:\/\//i', $data['framebg']) ?
$data['framebg'] : $data['imgdir'].'/'.$data['framebg'];
+ $data['frameswitch'] = preg_match('/^http:\/\//i',
$data['frameswitch']) ? $data['frameswitch'] : $data['imgdir'].'/'.$data['frameswitch'];
+ if(strstr($data['boardimg'], ',')) {
+ $flash = explode(",", $data['boardimg']);
+ $flash[0] = trim($flash[0]);
+ $flash[0] = preg_match('/^http:\/\//i', $flash[0]) ? $flash[0] : $data['imgdir'].'/'.$flash[0];
+ $data['boardlogo'] = "<embed src=\"".$flash[0]."\"
width=\"".trim($flash[1])."\" height=\"".trim($flash[2])."\" type=\"application/x-shockwave-flash\"></embed>";
+ } else {
+ $data['boardimg'] = preg_match('/^http:\/\//i',
$data['boardimg']) ? $data['boardimg'] : $data['imgdir'].'/'.$data['boardimg'];
+ $data['boardlogo'] = "<img src=\"$data[boardimg]\" alt=\"$bbname\"
border=\"0\" />";
+ }
+ $data['bold'] = $data['nobold'] ? 'normal' : 'bold';
+ writetocache($data['styleid'], '', getcachevars($data, 'CONST'), 'style_');
+ writetocsscache($data);
+ }
+ }
+
+ if(!$cachename || $cachename == 'usergroups') {
+ $query = $db->query("SELECT * FROM {$tablepre}usergroups u
+ LEFT JOIN {$tablepre}admingroups a ON u.groupid=a.admingid");
+ while($data = $db->fetch_array($query)) {
+ $ratearray = array();
+ if($data['raterange']) {
+ foreach(explode("\n", $data['raterange']) as $rating) {
+ $rating = explode("\t", $rating);
+ $ratearray[$rating[0]] = array('min' => $rating[1], 'max' =>
$rating[2], 'mrpd' => $rating[3]);
+ }
+ }
+ $data['raterange'] = $ratearray;
+ $data['grouptitle'] = $data['color'] ? '<font
color="'.$data['color'].'">'.$data['grouptitle'].'</font>' : $data['grouptitle'];
+ $data['grouptype'] = $data['type'];
+ $data['grouppublic'] = $data['system'] != 'private';
+ $data['groupcreditshigher'] = $data['creditshigher'];
+ $data['groupcreditslower'] = $data['creditslower'];
+ unset($data['type'], $data['system'], $data['creditshigher'],
$data['creditslower'], $data['color'], $data['groupavatar'], $data['admingid']);
+ foreach($data as $key => $val) {
+ if(!isset($data[$key])) {
+ unset($data[$key]);
+ }
+ }
+ writetocache($data['groupid'], '', getcachevars($data), 'usergroup_');
+ }
+ }
+
+ if(!$cachename || $cachename == 'admingroups') {
+ $query = $db->query("SELECT * FROM {$tablepre}admingroups");
+ while($data = $db->fetch_array($query)) {
+ writetocache($data['admingid'], '', getcachevars($data), 'admingroup_');
+ }
+ }
+
+ if(!$cachename || $cachename == 'plugins') {
+ $query = $db->query("SELECT pluginid, available, adminid, name,
identifier, datatables, directory, copyright, modules FROM {$tablepre}plugins");
+ while($plugin = $db->fetch_array($query)) {
+ $data = array_merge($plugin, array('modules' => array()),
array('vars' => array()));
+ $plugin['modules'] = unserialize($plugin['modules']);
+ if(is_array($plugin['modules'])) {
+ foreach($plugin['modules'] as $module) {
+ $data['modules'][$module['name']] = $module;
+ }
+ }
+ $queryvars = $db->query("SELECT variable, value FROM
{$tablepre}pluginvars WHERE pluginid='$plugin[pluginid]'");
+ while($var = $db->fetch_array($queryvars)) {
+ $data['vars'][$var['variable']] = $var['value'];
+ }
+
writetocache($plugin['identifier'], '', "\$_DPLUGIN['$plugin[identifier]'] = ".arrayeval($data), 'plugin_');
+ }
+ }
+
+ if(empty($cachename) || in_array($cachename,
array('forums', 'usergroups', 'settings'))) {
+ updatespacesettings();
+ }
+}
+
+function updatespacesettings() {
+ global $db, $tablepre, $initcredits;
+
+ $query = $db->query("SELECT groupid, readaccess FROM
{$tablepre}usergroups WHERE creditshigher<=".intval($initcredits)."
AND ".intval($initcredits)."<creditslower LIMIT 1");
+ $groupinfo = $db->fetch_array($query);
+ $fids = 0;
+ $query = $db->query("SELECT ff.fid, ff.viewperm FROM
{$tablepre}forumfields ff,{$tablepre}forums f WHERE f.fid=ff.fid AND
f.status>'0' AND ff.password=''");
+ while($forum = $db->fetch_array($query)) {
+ if(empty($forum['viewperm']) || in_array($groupinfo['groupid'],
explode("\t", $forum['viewperm']))) {
+ $fids .= ','.$forum['fid'];
+ }
+ }
+ $spacesettings = array('parms' => array('infids' => $fids, 'groupid'
=> $groupinfo['groupid'], 'readaccess' => $groupinfo['readaccess']));
+ writetocache('spacesettings', '', getcachevars($spacesettings));
+}
+
+function updatesettings() {
+ global $_DCACHE;
+ if(isset($_DCACHE['settings']) && is_array($_DCACHE['settings'])) {
+ writetocache('settings', '', '$_DCACHE[\'settings\'] = '.arrayeval($_DCACHE['settings']));
+ }
+}
+
+function writetocache($script, $cachenames, $cachedata = '', $prefix
= 'cache_') {
+ global $authkey, $timestamp;
+ if(is_array($cachenames) && !$cachedata) {
+ foreach($cachenames as $name) {
+ $cachedata .= getcachearray($name, $script);
+ }
+ }
+
+ $dir = DISCUZ_ROOT.'./forumdata/cache/';
+ if(!is_dir($dir)) {
+ @mkdir($dir, 0777);
+ }
+ if($fp = @fopen("$dir$prefix$script.php", 'wb')) {
+ fwrite($fp, "<?php\n//Discuz! cache file, DO NOT modify me!".
+ "\n//Created: ".date("M j, Y, G:i").
+ "\n//Identify: ".md5($prefix.$script.'.php'.$cachedata.$authkey)."\n\n$cachedata?>");
+ fclose($fp);
+ } else {
+ dexit('Can not write to cache files, please check
directory ./forumdata/ and ./forumdata/cache/ .');
+ }
+}
+
+function writetocsscache($data) {
+ $csstemplates = array('css', 'css_editor');
+ $styleid = $data['styleid'];
+ include_once DISCUZ_ROOT.'./forumdata/cache/style_'.$styleid.'.php';
+ $cachedir = DISCUZ_ROOT.'./forumdata/cache/';
+ foreach($csstemplates as $css) {
+ $cssfile = template($css, $styleid, $data['tpldir']);
+ $cssfile = !file_exists($cssfile) ? template($css,
1, './templates/default/') : $cssfile;
+ $fp = fopen($cssfile, 'r');
+ $cssdata = fread($fp, filesize($cssfile));
+ fclose($fp);
+ $cssdata =
preg_replace("/<\?=([A-Z0-9]+)\?>/e", '\$data[strtolower(\'\1\')]', $cssdata);
+ $cssdata = preg_replace("/<\?.+?\?>\s*/", '', $cssdata);
+ $cssdata = !preg_match('/^http:\/\//i', $data['imgdir']) ?
str_replace("url(\"$data[imgdir]", "url(\"../../$data[imgdir]",
$cssdata) : $cssdata;
+ $cssdata = !preg_match('/^http:\/\//i', $data['imgdir']) ?
str_replace("url($data[imgdir]", "url(../../$data[imgdir]", $cssdata) : $cssdata;
+ $extra = substr($css, 3);
+ if(@$fp = fopen($cachedir.'style_'.$styleid.$extra.'.css', 'w')) {
+ fwrite($fp, $cssdata);
+ fclose($fp);
+ } else {
+ dexit('Can not write to cache files, please check
directory ./forumdata/ and ./forumdata/cache/ .');
+ }
+ }
+}
+
+function getcachearray($cachename, $script = '') {
+ global $db, $timestamp, $tablepre, $timeoffset, $maxbdays, $smcols, $smrows;
+ $disinit="and f.fid!='72'and f.fid!='73'and f.fid!='76'and
f.fid!='49'and f.fid!='67'and f.fid!='74'and f.fid!='77'and f.fid!='46'
and f.fid!='6'and f.fid!='25'and f.fid!='51'and f.fid!='26'and f.fid!='64' ";
+ $cols = '*';
+ $conditions = '';
+ switch($cachename) {
+ case 'settings':
+ $table = 'settings';
+ $conditions = "WHERE variable NOT IN
('bbrules', 'bbrulestxt', 'closedreason', 'creditsnotify', 'backupdir', 'custombackup', 'jswizard', 'maxonlines', 'modreasons', 'newsletter', 'welcomemsg', 'welcomemsgtxt')
AND variable NOT LIKE 'jswizard_%'";
+ break;
+ case 'jswizard':
+ $table = 'settings';
+ $conditions = "WHERE variable LIKE 'jswizard_%'";
+ break;
+ case 'usergroups':
+ $table = 'usergroups';
+ $cols = 'groupid, type, grouptitle, creditshigher, creditslower,
stars, color, groupavatar, readaccess, allowavatar, allowcusbbcode, allowuseblog';
+ $conditions = "ORDER BY creditslower";
+ break;
+ case 'ranks':
+ $table = 'ranks';
+ $cols = 'ranktitle, postshigher, stars, color';
+ $conditions = "ORDER BY postshigher DESC";
+ break;
+ case 'announcements':
+ $table = 'announcements';
+ $cols = 'id, subject, type, starttime, endtime, message,
displayorder, groups';
+ $conditions = "WHERE starttime<='$timestamp' AND
(endtime>='$timestamp' OR endtime='0') ORDER BY displayorder, starttime
DESC, id DESC";
+ break;
+ case 'announcements_forum':
+ $table = 'announcements a';
+ $cols = 'a.id, a.author, a.message, m.uid AS authorid, a.subject,
a.type, a.starttime, a.displayorder';
+ $conditions = "LEFT JOIN {$tablepre}members m ON
m.username=a.author WHERE a.type!=2 AND a.groups = '' AND
a.starttime<='$timestamp' ORDER BY a.displayorder, a.starttime DESC,
a.id DESC LIMIT 1";
+ break;
+ case 'pmlist':
+ $table = 'announcements a';
+ $cols = 'id, subject, starttime, endtime, message, groups';
+ $conditions = "WHERE type=2 AND starttime<='$timestamp' AND
(endtime>='$timestamp' OR endtime='0') ORDER BY displayorder, starttime
DESC, id DESC";
+ break;
+ case 'globalstick':
+ $table = 'forums';
+ $cols = 'fid, type, fup';
+ $conditions = "WHERE status>0 AND type IN ('forum', 'sub') ORDER BY type";
+ break;
+ case 'forums':
+ $table = 'forums f';
+ $cols = 'f.fid, f.type, f.name, f.fup, f.idx_push,f.board_name,
ff.viewperm, a.uid';
+ $conditions = "LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid
LEFT JOIN {$tablepre}access a ON a.fid=f.fid AND a.allowview='1' WHERE
f.status>0 ORDER BY f.type, f.displayorder";
+ break;
+ case 'onlinelist':
+ $table = 'onlinelist';
+ $conditions = "ORDER BY displayorder";
+ break;
+ case 'forumlinks':
+ $table = 'forumlinks';
+ $conditions = "ORDER BY displayorder";
+ break;
+ case 'bbcodes':
+ $table = 'bbcodes';
+ $conditions = "WHERE available='1'";
+ break;
+ case 'bbcodes_display':
+ $table = 'bbcodes';
+ $cols = 'tag, icon, example, explanation, params, prompt';
+ $conditions = "WHERE available='1' AND icon!=''";
+ break;
+ case 'smilies':
+ $table = 'smilies';
+ $cols = 'id, code, url';
+ $conditions = "WHERE type='smiley' AND code<>'' ORDER BY
LENGTH(code) DESC";
+ break;
+ case in_array($cachename, array('smilies_display', 'smiliestable')):
+ $table = 'smilies';
+ $cols = 'id, code, url';
+ $limit = in_array($script,
array('forumdisplay', 'viewthread', 'pm')) ? 'LIMIT '.($smcols * $smrows) : '';
+ $conditions = "WHERE type='smiley' ORDER BY displayorder $limit";
+ break;
+ case 'icons':
+ $table = 'smilies';
+ $cols = 'id, url';
+ $conditions = "WHERE type='icon' ORDER BY displayorder";
+ break;
+ case 'fields_required':
+ $table = 'profilefields';
+ $cols = 'fieldid, invisible, title, description, required,
unchangeable, selective, choices';
+ $conditions = "WHERE available='1' AND required='1' ORDER BY displayorder";
+ break;
+ case 'fields_optional':
+ $table = 'profilefields';
+ $cols = 'fieldid, invisible, title, description, required,
unchangeable, selective, choices';
+ $conditions = "WHERE available='1' AND required='0' ORDER BY displayorder";
+ break;
+ case 'fields_thread':
+ $table = 'profilefields';
+ $cols = 'fieldid, title, selective, choices';
+ $conditions = "WHERE available='1' AND invisible='0' AND
showinthread='1' ORDER BY displayorder";
+ break;
+ case 'ipbanned':
+ $db->query("DELETE FROM {$tablepre}banned WHERE expiration<'$timestamp'");
+ $table = 'banned';
+ $cols = 'ip1, ip2, ip3, ip4, expiration';
+ break;
+ case 'censor':
+ $table = 'words';
+ $cols = 'find, replacement';
+ break;
+ case 'medals':
+ $table = 'medals';
+ $cols = 'medalid, name, image';
+ $conditions = "WHERE available='1'";
+ break;
+ case 'magics':
+ $table = 'magics';
+ $cols = 'magicid, available, identifier, name, description, weight, price';
+ break;
+ case 'birthdays_index':
+ $table = 'members';
+ $cols = 'uid, username, email, bday';
+ $conditions = "WHERE RIGHT(bday, 5)='".gmdate('m-d', $timestamp +
$timeoffset * 3600)."' ORDER BY bday LIMIT $maxbdays";
+ break;
+ case 'birthdays':
+ $table = 'members';
+ $cols = 'uid';
+ $conditions = "WHERE RIGHT(bday, 5)='".gmdate('m-d', $timestamp +
$timeoffset * 3600)."' ORDER BY bday";
+ break;
+ case 'modreasons':
+ $table = 'settings';
+ $cols = 'value';
+ $conditions = "WHERE variable='modreasons'";
+ break;
+ case 'faqs':
+ $table = 'faqs';
+ $cols = 'id, identifier, keyword';
+ $conditions = "WHERE identifier!='' AND keyword!=''";
+ break;
+ case 'secqaa':
+ $table = 'itempool';
+ $cols = 'question, answer';
+ $conditions = "ORDER BY rand() LIMIT 10";
+ break;
+ case 'nowhere':
+ $table = 'plugin_now n';
+ $cols = 'n.*,mf.avatar';
+ $conditions = "LEFT JOIN {$tablepre}memberfields mf ON mf.uid=n.authorid
+ ORDER BY dateline DESC LIMIT 50";
+ break;
+ case 'fav':
+ $table = 'favorites f';
+ $cols = 'f.*,t.tid,t.subject,mf.avatar,m.username,b.name,b.board_name';
+ $conditions = "LEFT JOIN {$tablepre}memberfields mf ON mf.uid=f.uid
LEFT JOIN {$tablepre}members m ON m.uid=f.uid LEFT JOIN
{$tablepre}threads t ON t.tid=f.tid
+ LEFT JOIN {$tablepre}forums b ON b.fid=f.fid
+ ORDER BY f.dateline DESC LIMIT 10";
+ break;
+ case 'new_forums':
+ $table = 'forums f';
+ $cols = 'f.name,f.board_name';
+ $conditions = "WHERE f.status>0 AND f.type !='group' ORDER BY f.fid
DESC LIMIT 10";
+ break;
+ case 'newthread':
+ $table = 'threads t';
+ $cols = 't.tid, t.fid, t.author,t.subject, t.dateline, t.lastpost,
t.lastposter, t.views, t.replies,f.name,f.board_name, mf.avatar,mf.uid';
+ $conditions = "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.lastpost DESC LIMIT 0, 20";
+ break;
+ case 'lastmembers':
+ $table = 'members m';
+ $cols = 'm.uid, m.username, m.regdate, mf.uid, mf.avatar';
+ $conditions = "LEFT JOIN {$tablepre}memberfields mf ON m.uid=mf.uid
ORDER BY m.regdate DESC LIMIT 5";
+ break;
+ }
+
+ $data = array();
+ if(!in_array($cachename,
array('advs', 'supe_updateusers', 'supe_updateitems', 'supe_updatecircles'))) {
+ $query = $db->query("SELECT $cols FROM {$tablepre}$table $conditions");
+ }
+ switch($cachename) {
+ case 'lastmembers':
+ while($lastm = $db->fetch_array($query)) {
+ $data[] = $lastm;
+ }
+ break;
+ case 'nowhere':
+ while ($message = $db->fetch_array($query)) {
+ $message['content'] = dhtmlspecialchars($message['content']);
+ $data[] = $message;
+ }
+ break;
+ case 'new_forums':
+ while ($nf = $db->fetch_array($query)) {
+ $data[] = $nf;
+ }
+ break;
+ case 'fav':
+ while ($fav = $db->fetch_array($query)) {
+ $fav['subject'] = cutstr($fav['subject'], 100);
+ $fav['avatar'] = avRESIZE($fav['avatar'],'s');
+ $data[] = $fav;
+ }
+ break;
+ case 'newthread':
+ while($topthread = $db->fetch_array($query)) {
+ //$topthread['uid'] = $topthread['uid'];
+ $topthread['author'] = $topthread['author'] ? $topthread['author'] : '�ο�';
+ $topthread['subjectc'] = cutstr($topthread['subject'], 50);
+ $topthread['avatar'] = avRESIZE($topthread['avatar'],'s');
+ $topthread['name'] = AddSlashes(strip_tags(trim($topthread['name'])));
+ $topthread['csscolor'] = rand_color();
+ $data[] = $topthread;
+ }
+ break;
+ case 'settings':
+ $data['qihoo_links'] = array();
+ while($setting = $db->fetch_array($query)) {
+ if($setting['variable'] == 'extcredits') {
+ if(is_array($setting['value'] = unserialize($setting['value']))) {
+ foreach($setting['value'] as $key => $value) {
+ if($value['available']) {
+ unset($setting['value'][$key]['available']);
+ } else {
+ unset($setting['value'][$key]);
+ }
+ }
+ }
+ } elseif($setting['variable'] == 'qihoo_keywords') {
+ foreach(explode("\n", trim($setting['value'])) as $keyword) {
+ if($keyword = trim($keyword)) {
+ $data['qihoo_links']['keywords'][] = '<a
href="search.php?srchtype=qihoo&amp;srchtxt='.rawurlencode($keyword).'&amp;searchsubmit=yes" target="_blank">'.dhtmlspecialchars(trim($keyword)).'</a>';
+ }
+ }
+ } elseif($setting['variable'] == 'qihoo_topics') {
+ if(is_array($topics = unserialize($setting['value']))) {
+ foreach($topics as $topic) {
+ if($topic['topic'] = trim($topic['topic'])) {
+ $data['qihoo_links']['topics'][] = '<a
href="topic.php?topic='.rawurlencode($topic['topic']).'&amp;keyword='.rawurlencode($topic['keyword']).'&amp;stype='.$topic['stype'].'&amp;length='.$topic['length'].'&amp;relate='.$topic['relate'].'" target="_blank">'.dhtmlspecialchars(trim($topic['topic'])).'</a>';
+ }
+ }
+ }
+ } elseif(in_array($setting['variable'],
array('creditspolicy', 'ftp', 'secqaa', 'supe'))) {
+ $setting['value'] = unserialize($setting['value']);
+ } elseif($setting['variable'] == 'creditsformula') {
+ if(!preg_match("/^([\+\-\*\/\.\d\(\)]|((extcredits[1-8]|
digestposts|posts|pageviews|oltime)([\+\-\*\/\(\)]|$)+))+$/",
$setting['value']) || !is_null(@eval(preg_replace("/(digestposts|posts|
pageviews|oltime|extcredits[1-8])/", "\$\\1", $setting['value']).';'))) {
+ $setting['value'] = '$member[\'extcredits1\']';
+ } else {
+ $setting['value'] = preg_replace("/(digestposts|posts|pageviews|
oltime|extcredits[1-8])/", "\$member['\\1']", $setting['value']);
+ }
+ } elseif($setting['variable'] == 'maxsmilies') {
+ $setting['value'] = $setting['value'] <= 0 ? -1 : $setting['value'];
+ } elseif($setting['variable'] == 'threadsticky') {
+ $setting['value'] = explode(',', $setting['value']);
+ } elseif($setting['variable'] == 'attachdir') {
+ $setting['value'] = preg_replace("/\.asp|\\0/i", '0', $setting['value']);
+ $setting['value'] = str_replace('\\', '/',
substr($setting['value'], 0, 2) == './' ?
DISCUZ_ROOT.$setting['value'] : $setting['value']);
+ } elseif($setting['variable'] == 'onlinehold') {
+ $setting['value'] = $setting['value'] * 60;
+ }
+
+ if(!in_array($setting['variable'],
array('qihoo_keywords', 'qihoo_topics'))) {
+ $GLOBALS[$setting['variable']] = $data[$setting['variable']] = $setting['value'];
+ }
+
+ if(in_array($setting['variable'],
array('supe_status', 'supe_tablepre', 'supe_siteurl', 'supe_sitename', 'supe_circlestatus'))) {
+ $data['supe'][substr($setting['variable'], 5)] = $setting['value'];
+ unset($data[$setting['variable']]);
+ }
+ }
+
+ $data['ftp']['connid'] = 0;
+ $data['indexname'] = empty($data['indexname']) ? 'index.php' : $data['indexname'];
+ $data['seccodedata'] = $data['seccodedata'] ?
unserialize($data['seccodedata']) : array();
+
+ if(!$data['supe']['status']) {
+ $data['supe'] = array('status' => 0);
+ } else {
+ if(!$data['supe']['items']['status']) {
+ $data['supe']['items'] = array('status' => 0);
+ }
+ global $supe;
+ if((!isset($data['supe']['attachurl']) ||
!isset($data['supe']['tpldir'])) && isset($supe['tablepre'])) {
+ supe_dbconnect();
+ $query = $supe['db']->query("SELECT * FROM
{$supe[tablepre]}settings WHERE variable IN ('attachmentdir', 'attachmenturl', 'template')");
+ $supe_settings = array();
+ while($supe_setting = $supe['db']->fetch_array($query)) {
+ $supe_settings[$supe_setting['variable']] = $supe_setting['value'];
+ }
+ if(substr($supe_settings['attachmentdir'], 0, 2) == './' &&
empty($supe_settings['attachmenturl'])) {
+ $supe_settings['attachmenturl'] =
$supe['siteurl'].substr($supe_settings['attachmentdir'], 1);
+ }
+ $data['supe']['attachurl'] = $supe_settings['attachmenturl'];
+ $data['supe']['tpldir'] = $supe_settings['template'];
+ $db->query("UPDATE {$tablepre}settings SET
value='".addslashes(serialize($data['supe']))."' WHERE variable='supe'");
+ }
+ if(!$data['supe']['dbmode']) {
+ unset($data['supe']['dbhost'], $data['supe']['dbuser'],
$data['supe']['dbpw'], $data['supe']['dbname']);
+ }
+
if($data['supe']['siteurl']{strlen($data['supe']['siteurl'])-1} != '/') {
+ $data['supe']['siteurl'] .= '/';
+ }
+ }
+
+ $secqaacheck = sprintf('%03b', $data['secqaa']['status']);
+ $data['secqaa']['status'] = array(
+ 1 => $secqaacheck{0},
+ 2 => $secqaacheck{1},
+ 3 => $secqaacheck{2}
+ );
+ if(!$data['secqaa']['status'][2] && !$data['secqaa']['status'][3]) {
+ unset($data['secqaa']['minposts']);
+ }
+
+ $data['jsmenustatus'] = sprintf('%b', $data['jsmenustatus']);
+ for($i = 1; $i <= strlen($data['jsmenustatus']); $i++) {
+ if(substr($data['jsmenustatus'], -$i, 1)) $data['jsmenu'][$i] = TRUE;
+ }
+ unset($data['jsmenustatus']);
+
+ $data['stylejumpstatus'] = $data['stylejump'];
+ $data['stylejump'] = array();
+ $query = $db->query("SELECT styleid, name FROM {$tablepre}styles
WHERE available='1'");
+ while($style = $db->fetch_array($query)) {
+ $data['stylejump'][$style['styleid']] = dhtmlspecialchars($style['name']);
+ }
+
+ $query = $db->query("SELECT COUNT(*) FROM {$tablepre}forums WHERE
status>0 AND threadcaches>0");
+ $data['cachethreadon'] = $db->result($query, 0) ? 1 : 0;
+
+ $query = $db->query("SELECT COUNT(*) FROM {$tablepre}members");
+ $GLOBALS['totalmembers'] = $data['totalmembers'] =
$db->result($query, 0);
+ $query = $db->query("SELECT username FROM {$tablepre}members ORDER
BY uid DESC LIMIT 1");
+ $GLOBALS['lastmember'] = $data['lastmember'] = $db->result($query, 0);
+ $GLOBALS['version'] = $data['version'] = DISCUZ_KERNEL_VERSION;
+
+ $query = $db->query("SELECT nextrun FROM {$tablepre}crons WHERE
available>'0' AND nextrun>'$timestamp' ORDER BY nextrun LIMIT 1");
+ $data['cronnextrun'] = $db->result($query, 0);
+ $globaladvs = advertisement('all');
+ $data['globaladvs'] = $globaladvs['all'] ? $globaladvs['all'] : array();
+ $data['redirectadvs'] = $globaladvs['redirect'] ?
$globaladvs['redirect'] : array();
+
+ if($data['qihoo_relatedthreads'] =
unserialize($data['qihoo_relatedthreads'])) {
+ $data['qihoo_relate_bbsnum'] = intval($data['qihoo_relatedthreads']['bbsnum']);
+ if($data['qihoo_relatedthreads']['webnum']) {
+ $data['qihoo_relate_webnum'] = intval($data['qihoo_relatedthreads']['webnum']);
+ $data['qihoo_relate_banurl'] =
$data['qihoo_relatedthreads']['banurl'] ? '/('.str_replace("\r\n", '|', $data['qihoo_relatedthreads']['banurl']).')/i' : '';
+ if(is_array($data['qihoo_relatedthreads']['type'])) {
+ $data['qihoo_relate_type'] = implode('|', $data['qihoo_relatedthreads']['type']);
+ }
+ }
+ $data['qihoo_relate_position'] = intval($data['qihoo_relatedthreads']['position']);
+ $data['qihoo_relate_order'] = intval($data['qihoo_relatedthreads']['order']);
+ $data['qihoo_relate_validity'] = intval($data['qihoo_relatedthreads']['validity']);
+ }
+
+ unset($data['qihoo_relatedthreads']);
+
+ $data['plugins'] = $data['pluginlinks'] = array();
+ $query = $db->query("SELECT available, name, identifier, directory,
datatables, modules FROM {$tablepre}plugins");
+ while($plugin = $db->fetch_array($query)) {
+ $plugin['modules'] = unserialize($plugin['modules']);
+ if(is_array($plugin['modules'])) {
+ foreach($plugin['modules'] as $module) {
+ if($plugin['available'] && isset($module['name'])) {
+
+ switch($module['type']) {
+ case 1:
+ $data['plugins']['links'][] = array('displayorder' =>
$module['displayorder'], 'adminid' => $module['adminid'], 'url' => "<a href=\"$module[url]\">$module[menu]</a>");
+ break;
+ case 2:
+ $data['plugins']['links'][] = array('displayorder' =>
$module['displayorder'], 'adminid' => $module['adminid'], 'url' => "<a href=\"plugin.php?identifier=$plugin[identifier]&module=$module[name]\">$module[menu]</a>");
+ $data['pluginlinks'][$plugin['identifier']][$module['name']]
= array('adminid' => $module['adminid'], 'directory' => $plugin['directory']);
+ break;
+ case 4:
+ $data['plugins']['include'][] = array('displayorder' =>
$module['displayorder'], 'adminid' => $module['adminid'], 'script' => $plugin['directory'].$module['name']);
+ break;
+ case 5:
+ $data['plugins']['jsmenu'][] = array('displayorder' =>
$module['displayorder'], 'adminid' => $module['adminid'], 'url' => "<a href=\"$module[url]\">$module[menu]</a>");
+ break;
+ case 6:
+ $data['plugins']['jsmenu'][] = array('displayorder' =>
$module['displayorder'], 'adminid' => $module['adminid'], 'url' => "<a href=\"plugin.php?identifier=$plugin[identifier]&module=$module[name]\">$module[menu]</a>");
+ $data['pluginlinks'][$plugin['identifier']][$module['name']]
= array('adminid' => $module['adminid'], 'directory' => $plugin['directory']);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if(is_array($data['plugins']['links'])) {
+ usort($data['plugins']['links'], 'pluginmodulecmp');
+ foreach($data['plugins']['links'] as $key => $module) {
+ unset($data['plugins']['links'][$key]['displayorder']);
+ }
+ }
+ if(is_array($data['plugins']['include'])) {
+ usort($data['plugins']['include'], 'pluginmodulecmp');
+ foreach($data['plugins']['include'] as $key => $module) {
+ unset($data['plugins']['include'][$key]['displayorder']);
+ }
+ }
+ if(is_array($data['plugins']['jsmenu'])) {
+ usort($data['plugins']['jsmenu'], 'pluginmodulecmp');
+ foreach($data['plugins']['jsmenu'] as $key => $module) {
+ unset($data['plugins']['jsmenu'][$key]['displayorder']);
+ }
+ }
+
+ $data['hooks'] = array();
+ $query = $db->query("SELECT ph.title, ph.code, p.identifier FROM
{$tablepre}plugins p
+ LEFT JOIN {$tablepre}pluginhooks ph ON ph.pluginid=p.pluginid AND ph.available='1'
+ WHERE p.available='1' ORDER BY p.identifier");
+ while($hook = $db->fetch_array($query)) {
+ if($hook['title'] && $hook['code']) {
+ $data['hooks'][$hook['identifier'].'_'.$hook['title']] = $hook['code'];
+ }
+ }
+ break;
+ case 'jswizard':
+ while($jswizard = $db->fetch_array($query)) {
+ $key = substr($jswizard['variable'], 9);
+ $data[$key] = unserialize($jswizard['value']);
+ unset($data[$key]['type']);
+ unset($data[$key]['parameter']);
+ }
+ break;
+ case 'usergroups':
+ global $userstatusby;
+ while($group = $db->fetch_array($query)) {
+ $groupid = $group['groupid'];
+ $group['grouptitle'] = $group['color'] ? '<font
color="'.$group['color'].'">'.$group['grouptitle'].'</font>' : $group['grouptitle'];
+ if($userstatusby == 2) {
+ $group['byrank'] = $group['type'] == 'member' ? 1 : 0;
+ }
+ if($userstatusby == 0 || ($userstatusby == 2 && $group['type']
== 'member')) {
+ unset($group['grouptitle'], $group['stars']);
+ }
+ if($group['type'] != 'member') {
+ unset($group['creditshigher'], $group['creditslower']);
+ }
+ unset($group['groupid'], $group['color']);
+ $data[$groupid] = $group;
+ }
+ break;
+ case 'ranks':
+ global $userstatusby;
+ if($userstatusby == 2) {
+ while($rank = $db->fetch_array($query)) {
+ $rank['ranktitle'] = $rank['color'] ? '<font
color="'.$rank['color'].'">'.$rank['ranktitle'].'</font>' : $rank['ranktitle'];
+ unset($rank['color']);
+ $data[] = $rank;
+ }
+ }
+ break;
+ case 'announcements':
+ $data = array();
+ while($datarow = $db->fetch_array($query)) {
+ if(empty($datarow['type'])) {
+ unset($datarow['message']);
+ } elseif($datarow['type'] == 2) {
+ $datarow['subject'] = cutstr($datarow['subject'], 20);
+ $datarow['message'] =
dhtmlspecialchars(cutstr(strip_tags($datarow['message']), 70));
+ }
+ $datarow['groups'] = empty($datarow['groups']) ? array() :
explode(',', $datarow['groups']);
+ $data[] = $datarow;
+ }
+ break;
+ case 'announcements_forum':
+ if($data = $db->fetch_array($query)) {
+ $data['authorid'] = intval($data['authorid']);
+ $data['message'] = cutstr(strip_tags($data['message']),
($data['type'] ? 250 : 18));
+ } else {
+ $data = array();
+ }
+ break;
+ case 'pmlist':
+ $data = array();
+ while($datarow = $db->fetch_array($query)) {
+ $datarow['subject'] = cutstr($datarow['subject'], 20);
+ $datarow['message'] =
dhtmlspecialchars(cutstr(strip_tags($datarow['message']), 70));
+ $datarow['groups'] = empty($datarow['groups']) ? array() :
explode(',', $datarow['groups']);
+ $data[] = $datarow;
+ }
+ break;
+ case 'globalstick':
+ $fuparray = $threadarray = array();
+ while($forum = $db->fetch_array($query)) {
+ switch($forum['type']) {
+ case 'forum':
+ $fuparray[$forum['fid']] = $forum['fup'];
+ break;
+ case 'sub':
+ $fuparray[$forum['fid']] = $fuparray[$forum['fup']];
+ break;
+ }
+ }
+ $query = $db->query("SELECT tid, fid, displayorder FROM
{$tablepre}threads WHERE displayorder IN (2, 3)");
+ while($thread = $db->fetch_array($query)) {
+ switch($thread['displayorder']) {
+ case 2:
+ $threadarray[$fuparray[$thread['fid']]][] = $thread['tid'];
+ break;
+ case 3:
+ $threadarray['global'][] = $thread['tid'];
+ break;
+ }
+ }
+ foreach(array_unique($fuparray) as $gid) {
+ if(!empty($threadarray[$gid])) {
+ $data['categories'][$gid] = array(
+ 'tids' => implode(',', $threadarray[$gid]),
+ 'count' => intval(@count($threadarray[$gid]))
+ );
+ }
+ }
+ $data['global'] = array(
+ 'tids' => empty($threadarray['global']) ? 0 : implode(',', $threadarray['global']),
+ 'count' => intval(@count($threadarray['global']))
+ );
+ break;
+ case 'censor':
+ $banned = $mod = array();
+ $data = array('filter' => array(), 'banned' => '', 'mod' => '');
+ while($censor = $db->fetch_array($query)) {
+ $censor['find'] = preg_replace("/\\\{(\d+)\\\}/", ".{0,\\1}", preg_quote($censor['find'], '/'));
+ switch($censor['replacement']) {
+ case '{BANNED}':
+ $banned[] = $censor['find'];
+ break;
+ case '{MOD}':
+ $mod[] = $censor['find'];
+ break;
+ default:
+ $data['filter']['find'][] = '/'.$censor['find'].'/i';
+ $data['filter']['replace'][] = $censor['replacement'];
+ break;
+ }
+ }
+ if($banned) {
+ $data['banned'] = '/('.implode('|', $banned).')/i';
+ }
+ if($mod) {
+ $data['mod'] = '/('.implode('|', $mod).')/i';
+ }
+ break;
+ case 'forums':
+ while($forum = $db->fetch_array($query)) {
+ if(!isset($forumlist[$forum['fid']])) {
+ $forum['name'] = strip_tags($forum['name']);
+ if($forum['uid']) {
+ $forum['users'] = "\t$forum[uid]\t";
+ }
+ unset($forum['uid']);
+ if($forum['fup']) {
+ $forumlist[$forum['fup']]['count']++;
+ }
+ $forumlist[$forum['fid']] = $forum;
+ } elseif($forum['uid']) {
+ if(!$forumlist[$forum['fid']]['users']) {
+ $forumlist[$forum['fid']]['users'] = "\t";
+ }
+ $forumlist[$forum['fid']]['users'] .= "$forum[uid]\t";
+ }
+ }
+
+ if(!empty($forumlist)) {
+ foreach($forumlist as $fid1 => $forum1) {
+ if(($forum1['type'] == 'group' && $forum1['count'])) {
+ $data[$fid1]['fid'] = $forum1['fid'];
+ $data[$fid1]['type'] = $forum1['type'];
+ $data[$fid1]['name'] = $forum1['name'];
+ $data[$fid1]['fup'] = $forum1['fup'];
+ $data[$fid1]['viewperm'] = $forum1['viewperm'];
+ foreach($forumlist as $fid2 => $forum2) {
+ if($forum2['fup'] == $fid1 && $forum2['type'] == 'forum') {
+ $data[$fid2]['fid'] = $forum2['fid'];
+ $data[$fid2]['type'] = $forum2['type'];
+ $data[$fid2]['name'] = $forum2['name'];
+ $data[$fid2]['fup'] = $forum2['fup'];
+ $data[$fid2]['viewperm'] = $forum2['viewperm'];
+ $data[$fid2]['idx_push'] = $forum2['idx_push'];
+ $data[$fid2]['board_name'] = $forum2['board_name'];
+ foreach($forumlist as $fid3 => $forum3) {
+ if($forum3['fup'] == $fid2 && $forum3['type'] == 'sub') {
+ $data[$fid3]['fid'] = $forum3['fid'];
+ $data[$fid3]['type'] = $forum3['type'];
+ $data[$fid3]['name'] = $forum3['name'];
+ $data[$fid3]['fup'] = $forum3['fup'];
+ $data[$fid3]['viewperm'] = $forum3['viewperm'];
+ $data[$fid3]['board_name'] = $forum3['board_name'];
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+ case 'onlinelist':
+ $data['legend'] = '';
+ while($list = $db->fetch_array($query)) {
+ $data[$list['groupid']] = $list['url'];
+ $data['legend'] .= "<img src=\"images/common/$list[url]\" alt=\"\"
/> $list[title] &nbsp; &nbsp; &nbsp; ";
+ }
+ break;
+ case 'forumlinks':
+ global $forumlinkstatus;
+ if($forumlinkstatus) {
+ $tightlink_text = $tightlink_logo = '';
+ while($flink = $db->fetch_array($query)) {
+ if($flink['description']) {
+ $forumlink['content'] = "<a href=\"$flink[url]\"
target=\"_blank\"><span class=\"bold\">$flink[name]</span></a><br>$flink[description]";
+ if($flink['logo']) {
+ $forumlink['type'] = 1;
+ $forumlink['logo'] = $flink['logo'];
+ } else {
+ $forumlink['type'] = 2;
+ }
+ $data[] = $forumlink;
+ } else {
+ if($flink['logo']) {
+ $tightlink_logo .= "<a href=\"$flink[url]\"
target=\"_blank\"><img src=\"$flink[logo]\" border=\"0\"
alt=\"$flink[name]\" /></a> ";
+ } else {
+ $tightlink_text .= "<a href=\"$flink[url]\" target=\"_blank\">[$flink[name]]</a> ";
+ }
+ }
+ }
+ if($tightlink_logo || $tightlink_text) {
+ $tightlink_logo .= $tightlink_logo ? '<br>' : '';
+ $data[] = array('type' => 3, 'content' => $tightlink_logo.$tightlink_text);
+ }
+ } else {
+ $data = array();
+ }
+ break;
+ case 'bbcodes':
+ $regexp = array (
+ 1 => "/\[{bbtag}](.+?)\[\/{bbtag}\]/is",
+ 2 => "/\[{bbtag}=(['\"]?)(.+?)(['\"]?)\](.+?)\[\/{bbtag}\]/is",
+ 3 => "/\[{bbtag}=(['\"]?)(.+?)(['\"]?),(['\"]?)(.+?)(['\"]?)\](.+?)\[\/{bbtag}\]/is"
+ );
+
+ while($bbcode = $db->fetch_array($query)) {
+ $search = str_replace('{bbtag}', $bbcode['tag'], $regexp[$bbcode['params']]);
+ $bbcode['replacement'] = preg_replace("/([\r\n])/", '', $bbcode['replacement']);
+ switch($bbcode['params']) {
+ case 2:
+ $bbcode['replacement'] = str_replace('{1}', '\\2', $bbcode['replacement']);
+ $bbcode['replacement'] = str_replace('{2}', '\\4', $bbcode['replacement']);
+ break;
+ case 3:
+ $bbcode['replacement'] = str_replace('{1}', '\\2', $bbcode['replacement']);
+ $bbcode['replacement'] = str_replace('{2}', '\\5', $bbcode['replacement']);
+ $bbcode['replacement'] = str_replace('{3}', '\\7', $bbcode['replacement']);
+ break;
+ default:
+ $bbcode['replacement'] = str_replace('{1}', '\\1', $bbcode['replacement']);
+ break;
+ }
+ if(preg_match("/\{(RANDOM|MD5)\}/", $bbcode['replacement'])) {
+ $search = str_replace('is', 'ies', $search);
+ $replace = '\''.str_replace('{RANDOM}', '_\'.random(6).\'',
str_replace('{MD5}', '_\'.md5(\'\\1\').\'', $bbcode['replacement'])).'\'';
+ } else {
+ $replace = $bbcode['replacement'];
+ }
+
+ for($i = 0; $i < $bbcode['nest']; $i++) {
+ $data['searcharray'][] = $search;
+ $data['replacearray'][] = $replace;
+ }
+ }
+
+ break;
+ case 'bbcodes_display':
+ while($bbcode = $db->fetch_array($query)) {
+ $tag = $bbcode['tag'];
+ $bbcode['example'] = dhtmlspecialchars(trim($bbcode['example']));
+ if(!$bbcode['example']) {
+ switch($bbcode['params']) {
+ case 2:
+ $bbcode['example'] = '['.$bbcode['tag'].'=][/'.$bbcode['tag'].']';
+ break;
+ case 3:
+ $bbcode['example'] = '['.$bbcode['tag'].'=,][/'.$bbcode['tag'].']';
+ break;
+ default:
+ $bbcode['example'] = '['.$bbcode['tag'].'][/'.$bbcode['tag'].']';
+ break;
+ }
+ }
+ $bbcode['explanation'] = dhtmlspecialchars(trim($bbcode['explanation']));
+ $bbcode['example'] = addcslashes($bbcode['example'], '\\\'');
+ $bbcode['prompt'] = addcslashes($bbcode['prompt'], '\\\'');
+ unset($bbcode['tag']);
+ $data[$tag] = $bbcode;
+ }
+ break;
+ case 'smilies':
+ $data = array('searcharray' => array(), 'replacearray' => array());
+ while($smiley = $db->fetch_array($query)) {
+ $data['searcharray'][$smiley['id']] = '/'.preg_quote(dhtmlspecialchars($smiley['code']), '/').'/';
+ $data['replacearray'][$smiley['id']] = $smiley['url'];
+ }
+ break;
+ case 'smilies_display':
+ $smdir = defined('SMDIR') ? SMDIR : './images/smilies';
+ while($smiley = $db->fetch_array($query)) {
+ if($size = @getimagesize($smdir.'/'.$smiley['url'])) {
+ $smiley['code'] = dhtmlspecialchars($smiley['code']);
+ $smileyid = $smiley['id'];
+ $s = smthumb($size, $GLOBALS['smthumb']);
+ $smiley['w'] = $s['w'];
+ $smiley['h'] = $s['h'];
+ $l = smthumb($size);
+ $smiley['lw'] = $l['w'];
+ unset($smiley['id']);
+ $data[$smileyid] = $smiley;
+ }
+ }
+ break;
+ case 'smiliestable':
+ $smdir = defined('SMDIR') ? SMDIR : './images/smilies';
+ $smilies = '';
+ $i = 0;
+ while($smiley = $db->fetch_array($query)) {
+ if($i < $smcols * $smrows) {
+ $size = @getimagesize($smdir.'/'.$smiley['url']);
+ $s = smthumb($size, $GLOBALS['smthumb']);
+ $smiley['w'] = $s['w'];
+ $smiley['h'] = $s['h'];
+ $l = smthumb($size);
+ $smiley['lw'] = $l['w'];
+ $smiley['code'] = addcslashes(addslashes(dhtmlspecialchars($smiley['code'])), '\\\'');
+ $smilies .= !($i % $smcols) && $i ? '</tr>' : '';
+ $smilies .= !($i % $smcols) ? '<tr align="center"
height="'.($GLOBALS['smthumb'] + 6).'">' : '';
+ $smilies .= '<td valign="middle"><img
src="\\\'+SMDIR+\\\'/'.$smiley['url'].'" id="smilie_'.$smiley['id'].'"
alt="'.$smiley['code'].'" border="0"
onClick="insertSmiley('.$smiley['id'].')"
onMouseover="smileyMenu(this)" width="'.$smiley['w'].'"
height="'.$smiley['h'].'" title="'.$smiley['lw'].'" /></td>';
+ }
+ $i++;
+ }
+ $smilies = $i ? $smilies.'</tr>' : '';
+ $smiliesnum = $db->result($db->query("SELECT COUNT(*) FROM
{$tablepre}smilies WHERE type='smiley'"), 0);
+ return "\$_DCACHE['$cachename']
= '".$smilies."';\n\$_DCACHE['smiliesnum'] = '".$smiliesnum."';\n";
+ case 'icons':
+ while($icon = $db->fetch_array($query)) {
+ $data[$icon['id']] = $icon['url'];
+ }
+ break;
+ case (in_array($cachename, array('fields_required', 'fields_optional', 'fields_thread'))):
+ while($field = $db->fetch_array($query)) {
+ $choices = array();
+ if($field['selective']) {
+ foreach(explode("\n", $field['choices']) as $item) {
+ list($index, $choice) = explode('=', $item);
+ $choices[trim($index)] = trim($choice);
+ }
+ $field['choices'] = $choices;
+ } else {
+ unset($field['choices']);
+ }
+ $data[] = $field;
+ }
+ break;
+ case 'ipbanned':
+ if($db->num_rows($query)) {
+ $data['expiration'] = 0;
+ $data['regexp'] = $separator = '';
+ }
+ while($banned = $db->fetch_array($query)) {
+ $data['expiration'] = !$data['expiration'] ||
$banned['expiration'] < $data['expiration'] ? $banned['expiration'] : $data['expiration'];
+ $data['regexp'] .= $separator.
+ ($banned['ip1'] == '-1' ? '\\d+\\.' : $banned['ip1'].'\\.').
+ ($banned['ip2'] == '-1' ? '\\d+\\.' : $banned['ip2'].'\\.').
+ ($banned['ip3'] == '-1' ? '\\d+\\.' : $banned['ip3'].'\\.').
+ ($banned['ip4'] == '-1' ? '\\d+' : $banned['ip4']);
+ $separator = '|';
+ }
+ break;
+ case 'medals':
+ while($medal = $db->fetch_array($query)) {
+ $data[$medal['medalid']] = array('name' => $medal['name'], 'image'
=> $medal['image']);
+ }
+ break;
+ case 'magics':
+ while($magic = $db->fetch_array($query)) {
+ $data[$magic['magicid']]['identifier'] = $magic['identifier'];
+ $data[$magic['magicid']]['available'] = $magic['available'];
+ $data[$magic['magicid']]['name'] = $magic['name'];
+ $data[$magic['magicid']]['description'] = $magic['description'];
+ $data[$magic['magicid']]['weight'] = $magic['weight'];
+ $data[$magic['magicid']]['price'] = $magic['price'];
+ }
+ break;
+ case 'birthdays_index':
+ $bdaymembers = array();
+ while($bdaymember = $db->fetch_array($query)) {
+ $birthyear = intval($bdaymember['bday']);
+ $bdaymembers[] = '<a href="space.php?uid='.$bdaymember['uid'].'" target="_blank" '.($birthyear ? 'title="'.$bdaymember['bday'].'"' : '').'>'.$bdaymember['username'].'</a>';
+ }
+ $data['todaysbdays'] = implode(', ', $bdaymembers);
+ break;
+ case 'birthdays':
+ $data['uids'] = $comma = '';
+ $data['num'] = 0;
+ while($bdaymember = $db->fetch_array($query)) {
+ $data['uids'] .= $comma.$bdaymember['uid'];
+ $comma = ',';
+ $data['num'] ++;
+ }
+ break;
+ case 'modreasons':
+ $modreasons = $db->result($query, 0);
+ $modreasons = str_replace(array("\r\n", "\r"), array("\n", "\n"), $modreasons);
+ $data = explode("\n", trim($modreasons));
+ break;
+ case 'advs':
+ $data = advertisement($script);
+ break;
+ case 'faqs':
+ while($faqs = $db->fetch_array($query)) {
+ $data[$faqs['identifier']]['id'] = $faqs['id'];
+ $data[$faqs['identifier']]['keyword'] = $faqs['keyword'];
+ }
+ break;
+ case 'secqaa':
+ while($secqaa = $db->fetch_array($query)) {
+ $secqaa['answer'] = md5($secqaa['answer']);
+ $data[] = $secqaa;
+ }
+ break;
+ case 'supe_updateusers':
+ global $supe;
+ supe_dbconnect();
+ if($supe['status'] && $supe['maxupdateusers']) {
+ $query = $supe['db']->query("SELECT uid, username FROM
{$supe[tablepre]}userspaces WHERE islock=0 ORDER BY lastpost DESC LIMIT $supe[maxupdateusers]");
+ while($datarow = $supe['db']->fetch_array($query)) {
+ $data[$datarow['uid']] = $datarow;
+ }
+ }
+ break;
+ case 'supe_updateitems':
+ global $supe;
+ supe_dbconnect();
+ if($supe['status'] && $supe['items']['status']) {
+ $limit = $supe['items']['rows'] * $supe['items']['columns'];
+ switch($supe['items']['orderby']) {
+ case '1':
+ $orderby = 'viewnum';
+ break;
+ case '2':
+ $orderby = 'replynum';
+ break;
+ case '3':
+ $orderby = 'dateline';
+ break;
+ case '4':
+ $orderby = 'lastpost';
+ break;
+ default:
+ $orderby = 'itemid';
+ }
+ $supe['items']['hours'] = $supe['items']['hours'] > 0 ?
$supe['items']['hours'] : 24;
+ $conditions = !in_array($orderby,
array('dateline', 'lastpost')) ? 'WHERE folder=1 AND type<>\'news\' AND
dateline >='.($timestamp - $supe['items']['hours'] * 3600) : 'WHERE
folder=1 AND type<>\'news\'';
+ $query = $supe['db']->query("SELECT itemid, uid, username, type,
subject FROM {$supe[tablepre]}spaceitems $conditions ORDER BY $orderby
DESC LIMIT $limit");
+ $itemtable = '';
+ $items = array();
+ include language('templates');
+ while($item = $supe['db']->fetch_array($query)) {
+ $typename = $language['supe_'.$item['type']];
+ $items[] = '<img src="\\\'+IMGDIR+\\\'/menu_collapsed_yes.gif"
align="absmiddle"> <a
href="http://blog.orzotl.com/?uid/'.$item['uid'].'" target="_blank"
style="color:'.rand_color().'"
class="var">'.addcslashes(addslashes($item['username']), '\\\'').'</a> ������<a
href="http://blog.orzotl.com/?action/'.$item['type'].'"
target="_blank">'.$typename.'</a> <span class="tip_i">[ <a
href="http://blog.orzotl.com/?action/viewspace/itemid/'.$item['itemid'].'.html"
target="_blank" style="color:'.rand_color().'"
class="var">'.addcslashes(addslashes(cutstr($item['subject'],
35)), '\\\'').'</a> ]</span>';
+ }
+ for($i = 0; $i < $limit; $i++) {
+ $itemtable .= (($i + 1) % $supe['items']['columns'] == 1 ||
$supe['items']['columns'] == 1 ? '<tr align="left" class="altbg2">' : '').
+ '<td width="'.intval(100 / $supe['items']['columns']).'%" nowrap
style="overflow: hidden;">'.(isset($items[$i]) ? $items[$i] : '&nbsp;').'</td>'.
+ (($i + 1) % $supe['items']['columns'] == 0 ? "</tr>" : '');
+ }
+ return "\$_DCACHE['$cachename'] = '".$itemtable."';\n\n";
+ }
+ case 'supe_updatecircles':
+ global $supe;
+ supe_dbconnect();
+ if($supe['status'] && $supe['circlestatus']) {
+ $query = $supe['db']->query("SELECT gid, uid, username, groupname,
logo, usernum, lastpost FROM {$supe[tablepre]}groups WHERE catid>0 AND
flag=1 ORDER BY lastpost DESC LIMIT 8");
+ while($datarow = $supe['db']->fetch_array($query)) {
+ $datarow['groupname'] = cutstr($datarow['groupname'], 30);
+ $data[] = $datarow;
+ }
+ }
+ break;
+ default:
+ while($datarow = $db->fetch_array($query)) {
+ $data[] = $datarow;
+ }
+ }
+
+ return "\$_DCACHE['$cachename'] = ".arrayeval($data).";\n\n";
+}
+
+function getcachevars($data, $type = 'VAR') {
+ $evaluate = '';
+ foreach($data as $key => $val) {
+ if(is_array($val)) {
+ $evaluate .= "\$$key = ".arrayeval($val).";\n";
+ } else {
+ $val = addcslashes($val, '\'\\');
+ $evaluate .= $type == 'VAR' ? "\$$key = '$val';\n" : "define('".strtoupper($key)."', '$val');\n";
+ }
+ }
+ return $evaluate;
+}
+
+function advertisement($range) {
+ global $db, $tablepre, $timestamp;
+ $advs = array();
+ $query = $db->query("SELECT * FROM {$tablepre}advertisements WHERE
available>'0' AND starttime<='$timestamp' ORDER BY displayorder");
+ if($db->num_rows($query)) {
+ while($adv = $db->fetch_array($query)) {
+ if(in_array($adv['type'], array('footerbanner', 'thread'))) {
+ $parameters = unserialize($adv['parameters']);
+ $position = isset($parameters['position']) &&
in_array($parameters['position'], array(2, 3)) ?
$parameters['position'] : 1;
+ $type = $adv['type'].$position;
+ } else {
+ $type = $adv['type'];
+ }
+ $adv['targets'] = $adv['targets'] == '' ? 'all' : $adv['targets'];
+ foreach(explode("\t", $adv['targets']) as $target) {
+ $target = $target == '0' ? 'index' : (in_array($target,
array('all', 'register', 'redirect', 'archiver')) ? $target : ($target == 'forum' ? 'forum_all' : 'forum_'.$target));
+ if((($range == 'forumdisplay' && !in_array($adv['type'],
array('thread', 'interthread'))) || $range == 'viewthread') &&
substr($target, 0, 6) == 'forum_') {
+ if($adv['type'] == 'thread') {
+ foreach(isset($parameters['displayorder']) ? explode("\t",
$parameters['displayorder']) : array('0') as $postcount) {
+ $advs[$type.'_'.$postcount][$target][] = $adv['code'];
+ }
+ } else {
+ $advs[$type][$target][] = $adv['code'];
+ }
+ } elseif($range == 'all' && in_array($target,
array('all', 'redirect'))) {
+ $advs[$target][$type][] = $adv['code'];
+ } elseif($target == $range) {
+ $advs[$type][] = $adv['code'];
+ }
+ }
+ }
+ }
+ return $advs;
+}
+
+function pluginmodulecmp($a, $b) {
+ return $a['displayorder'] > $b['displayorder'] ? 1 : -1;
+}
+
+function smthumb($size, $smthumb = 50) {
+ if($size[0] <= $smthumb && $size[1] <= $smthumb) {
+ return array('w' => $size[0], 'h' => $size[1]);
+ }
+ $sm = array();
+ $x_ratio = $smthumb / $size[0];
+ $y_ratio = $smthumb / $size[1];
+ if(($x_ratio * $size[1]) < $smthumb) {
+ $sm['h'] = ceil($x_ratio * $size[1]);
+ $sm['w'] = $smthumb;
+ } else {
+ $sm['w'] = ceil($y_ratio * $size[0]);
+ $sm['h'] = $smthumb;
+ }
+ return $sm;
+}
+
+?>
\ No newline at end of file

Added: trunk/upload/include/category.inc.php
==============================================================================
--- (empty file)
+++ trunk/upload/include/category.inc.php Fri Nov 23 03:26:15 2007
@@ -0,0 +1,59 @@
+<?php
+
+/*
+ [Discuz!] (C)2001-2007 Comsenz Inc.
+ This is NOT a freeware, use is subject to license terms
+
+ $RCSfile: category.inc.php,v $
+ $Revision: 1.10.2.1 $
+ $Date: 2007/03/21 15:52:38 $
+*/
+
+if(!defined('IN_DISCUZ')) {
+ exit('Access Denied');
+}
+
+
+$sql = $accessmasks ? "SELECT f.fid, f.fup, f.type,
f.name,f.board_name, f.threads, f.posts, f.todayposts, f.lastpost,
f.inheritedmod, ff.description, ff.moderators, ff.icon, ff.viewperm,
a.allowview FROM {$tablepre}forums f
+ LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid
+ LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid=f.fid
+ WHERE f.status>0 AND (f.fid='$gid' OR (f.fup='$gid' AND
f.type='forum')) ORDER BY f.type, f.displayorder"
+ : "SELECT f.fid, f.fup, f.type, f.name,f.board_name, f.threads,
f.posts, f.todayposts, f.lastpost, f.inheritedmod, ff.description,
ff.moderators, ff.icon, ff.viewperm FROM {$tablepre}forums f
+ LEFT JOIN {$tablepre}forumfields ff USING(fid)
+ WHERE f.status>0 AND (f.fid='$gid' OR (f.fup='$gid' AND
f.type='forum')) ORDER BY f.type, f.displayorder";
+
+$query = $db->query($sql);
+if($db->num_rows($query) < 2) {
+ dheader("Location: {$boardurl}");
+}
+
+while($forum = $db->fetch_array($query)) {
+ if($forum['type'] != 'group') {
+ $threads += $forum['threads'];
+ $posts += $forum['posts'];
+ $todayposts += $forum['todayposts'];
+ if(forum($forum)) {
+ $forum['orderid'] = $catlist[$forum['fup']]['forumscount'] ++;
+ $forum['subforums'] = '';
+ $forumlist[$forum['fid']] = $forum;
+ $catlist[$forum['fup']]['forums'][] = $forum['fid'];
+ $fids .= ','.$forum['fid'];
+ }
+ } else {
+ $forum['collapseimg'] = 'collapsed_no.gif';
+ $collapse['category_'.$forum['fid']] = '';
+
+ if($forum['moderators']) {
+ $forum['moderators'] = moddisplay($forum['moderators'], 'flat');
+ }
+ $forum['forumscount'] = 0;
+ $forum['forumcolumns'] = 0;
+ $catlist[$forum['fid']] = $forum;
+
+ $navigation = '&raquo; '.$forum['name'];
+ $navtitle = strip_tags($forum['name']).' - ';
+ }
+
+}
+
+?>
\ No newline at end of file

Added: trunk/upload/include/common.inc.php
==============================================================================
--- (empty file)
+++ trunk/upload/include/common.inc.php Fri Nov 23 03:26:15 2007
@@ -0,0 +1,417 @@
+<?php
+
+/*
+ [Discuz!] (C)2001-2007 Comsenz Inc.
+ This is NOT a freeware, use is subject to license terms
+
+ $RCSfile: common.inc.php,v $
+ $Revision: 1.112.2.13 $
+ $Date: 2007/07/24 13:16:52 $
+*/
+error_reporting(0);
+set_magic_quotes_runtime(0);
+$mtime = explode(' ', microtime());
+$discuz_starttime = $mtime[1] + $mtime[0];
+
+define('IN_DISCUZ', TRUE);
+define('DISCUZ_ROOT', substr(dirname(__FILE__), 0, -7));
+
+if(PHP_VERSION < '4.1.0') {
+ $_GET = &$HTTP_GET_VARS;
+ $_POST = &$HTTP_POST_VARS;
+ $_COOKIE = &$HTTP_COOKIE_VARS;
+ $_SERVER = &$HTTP_SERVER_VARS;
+ $_ENV = &$HTTP_ENV_VARS;
+ $_FILES = &$HTTP_POST_FILES;
+}
+
+if (isset($_REQUEST['GLOBALS']) OR isset($_FILES['GLOBALS'])) {
+ exit('Request tainting attempted.');
+}
+
+/* Parasy || Core Files */
+require_once DISCUZ_ROOT.'./parasy/ParasySettings.inc.php';
+require_once DISCUZ_ROOT.'./parasy/ParasyCore.php';
+require_once DISCUZ_ROOT.'./parasy/ParasyCache.php';
+if (PARASY_FEATURE_GEO){
+ require_once DISCUZ_ROOT.'./parasy/Geo.func.php';
+}
+require_once DISCUZ_ROOT.'./include/global.func.php';
+
+define('ISROBOT', getrobot());
+if(defined('NOROBOT') && ISROBOT) {
+ exit(header("HTTP/1.1 403 Forbidden"));
+}
+
+define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
+foreach(array('_COOKIE', '_POST', '_GET') as $_request) {
+ foreach($$_request as $_key => $_value) {
+ $_key{0} != '_' && $$_key = daddslashes($_value);
+ }
+}
+(!MAGIC_QUOTES_GPC) && $_FILES = daddslashes($_FILES);
+
+$charset = $dbcharset = $forumfounders = $metakeywords = $extrahead =
$seodescription = '';
+$plugins = $hooks = $admincp = $jsmenu = $forum = $thread = $language
= $actioncode = $modactioncode = $lang = array();
+
+require_once DISCUZ_ROOT.'./config.inc.php';
+
+$_DCOOKIE = $_DSESSION = $_DCACHE = $_DPLUGIN = $advlist = array();
+
+$prelength = strlen($cookiepre);
+foreach($_COOKIE as $key => $val) {
+ if(substr($key, 0, $prelength) == $cookiepre) {
+ $_DCOOKIE[(substr($key, $prelength))] = MAGIC_QUOTES_GPC ? $val : daddslashes($val);
+ }
+}
+unset($prelength, $_request, $_key, $_value, $_request, $protected);
+
+$inajax = !empty($inajax);
+$timestamp = time();
+
+if($attackevasive) {
+ require_once DISCUZ_ROOT.'./include/security.inc.php';
+}
+
+require_once DISCUZ_ROOT.'./include/db_'.$database.'.class.php';
+
+
+$PHP_SELF = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
+$SCRIPT_FILENAME = str_replace('\\\\', '/',
(isset($_SERVER['PATH_TRANSLATED']) ? $_SERVER['PATH_TRANSLATED'] : $_SERVER['SCRIPT_FILENAME']));
+$boardurl =
htmlspecialchars('http://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api|
archiver|wap)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/');
+
+if(getenv('HTTP_CLIENT_IP') &&
strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
+ $onlineip = getenv('HTTP_CLIENT_IP');
+} elseif(getenv('HTTP_X_FORWARDED_FOR') &&
strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
+ $onlineip = getenv('HTTP_X_FORWARDED_FOR');
+} elseif(getenv('REMOTE_ADDR') &&
strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
+ $onlineip = getenv('REMOTE_ADDR');
+} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] &&
strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
+ $onlineip = $_SERVER['REMOTE_ADDR'];
+}
+
+preg_match("/[\d\.]{7,15}/", $onlineip, $onlineipmatches);
+$onlineip = $onlineipmatches[0] ? $onlineipmatches[0] : 'unknown';
+unset($onlineipmatches);
+
+$cachelost = (@include DISCUZ_ROOT.'./forumdata/cache/cache_settings.php') ? '' : 'settings';
+@extract($_DCACHE['settings']);
+
+if($gzipcompress && function_exists('ob_gzhandler') &&
CURSCRIPT != 'wap') {
+ ob_start('ob_gzhandler');
+} else {
+ $gzipcompress = 0;
+ ob_start();
+}
+
+if(!empty($loadctrl) && substr(PHP_OS, 0, 3) != 'WIN') {
+ if($fp = @fopen('/proc/loadavg', 'r')) {
+ list($loadaverage) = explode(' ', fread($fp, 6));
+ fclose($fp);
+ if($loadaverage > $loadctrl) {
+ header("HTTP/1.0 503 Service Unavailable");
+ include DISCUZ_ROOT.'./include/serverbusy.htm';
+ exit();
+ }
+ }
+}
+
+if(defined('CURSCRIPT') && in_array(CURSCRIPT,
array('index', 'forumdisplay', 'viewthread', 'post', 'blog', 'pm', 'topicadmin', 'register', 'archiver'))) {
+ $cachelost .= (@include DISCUZ_ROOT.'./forumdata/cache/cache_'.CURSCRIPT.'.php') ? '' : ' '.CURSCRIPT;
+}
+
+$db = new dbstuff;
+$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
+$dbuser = $dbpw = $dbname = $pconnect = NULL;
+
+$sid = daddslashes(($transsidstatus || (defined('CURSCRIPT') &&
CURSCRIPT == 'wap'))&& (isset($_GET['sid']) || isset($_POST['sid'])) ?
+ (isset($_GET['sid']) ? $_GET['sid'] : $_POST['sid']) :
+ (isset($_DCOOKIE['sid']) ? $_DCOOKIE['sid'] : ''));
+
+$discuz_auth_key = md5($_DCACHE['settings']['authkey'].$_SERVER['HTTP_USER_AGENT']);
+list($discuz_pw, $discuz_secques, $discuz_uid) =
empty($_DCOOKIE['auth']) ? array('', '', 0) : daddslashes(explode("\t",
authcode($_DCOOKIE['auth'], 'DECODE')), 1);
+
+$newpm = $newpmexists = $sessionexists = $seccode = $bloguid = 0;
+$membertablefields = 'm.uid AS discuz_uid, m.username AS
discuz_user,m.usr_geo AS discuz_user_geo, m.password AS discuz_pw,
m.secques AS discuz_secques,m.now_img AS discuz_now_img,m.idx_cloud AS show_cloud,
+ m.adminid, m.groupid, m.groupexpiry, m.extgroupids, m.email,
m.timeoffset, m.tpp, m.ppp, m.posts, m.digestposts,
+ m.oltime, m.pageviews, m.credits, m.extcredits1, m.extcredits2,
m.extcredits3, m.extcredits4, m.extcredits5,
+ m.extcredits6, m.extcredits7, m.extcredits8, m.timeformat,
m.dateformat, m.pmsound, m.sigstatus, m.invisible,
+ m.lastvisit, m.lastactivity, m.lastpost, m.newpm, m.accessmasks,
m.xspacestatus, m.editormode, m.customshow';
+if($sid) {
+ if($discuz_uid) {
+ $query = $db->query("SELECT s.sid, s.styleid, s.groupid='6' AS
ipbanned, s.pageviews AS spageviews, s.lastolupdate, s.seccode, $membertablefields
+ FROM {$tablepre}sessions s, {$tablepre}members m
+ WHERE m.uid=s.uid AND s.sid='$sid' AND
CONCAT_WS('.',s.ip1,s.ip2,s.ip3,s.ip4)='$onlineip' AND m.uid='$discuz_uid'
+ AND m.password='$discuz_pw' AND m.secques='$discuz_secques'");
+ } else {
+ $query = $db->query("SELECT sid, uid AS sessionuid, groupid,
groupid='6' AS ipbanned, pageviews AS spageviews, styleid,
lastolupdate, seccode
+ FROM {$tablepre}sessions WHERE sid='$sid' AND CONCAT_WS('.',ip1,ip2,ip3,ip4)='$onlineip'");
+ }
+ if($_DSESSION = $db->fetch_array($query)) {
+ $sessionexists = 1;
+ if(!empty($_DSESSION['sessionuid'])) {
+ $query = $db->query("SELECT $membertablefields
+ FROM {$tablepre}members m WHERE uid='$_DSESSION[sessionuid]'");
+ $_DSESSION = array_merge($_DSESSION, $db->fetch_array($query));
+ }
+ } else {
+ $query = $db->query("SELECT sid, groupid, groupid='6' AS ipbanned,
pageviews AS spageviews, styleid, lastolupdate, seccode
+ FROM {$tablepre}sessions WHERE sid='$sid' AND CONCAT_WS('.',ip1,ip2,ip3,ip4)='$onlineip'");
+ if($_DSESSION = $db->fetch_array($query)) {
+ clearcookies();
+ $sessionexists = 1;
+ }
+ }
+}
+
+if(!$sessionexists) {
+ if($discuz_uid) {
+ $query = $db->query("SELECT $membertablefields
+ FROM {$tablepre}members m WHERE m.uid='$discuz_uid' AND
m.password='$discuz_pw' AND m.secques='$discuz_secques'");
+ if(!($_DSESSION = $db->fetch_array($query))) {
+ clearcookies();
+ }
+ }
+
+ if(ipbanned($onlineip)) $_DSESSION['ipbanned'] = 1;
+
+ $_DSESSION['sid'] = random(6);
+ $_DSESSION['seccode'] = random(6, 1);
+}
+$_DSESSION['dateformat'] = empty($_DSESSION['dateformat']) ?
$_DCACHE['settings']['dateformat'] : $_DSESSION['dateformat'];
+$_DSESSION['timeformat'] = empty($_DSESSION['timeformat']) ?
$_DCACHE['settings']['timeformat'] : ($_DSESSION['timeformat'] ==
1 ? 'h:i A' : 'H:i');
+$_DSESSION['timeoffset'] = isset($_DSESSION['timeoffset']) &&
$_DSESSION['timeoffset'] != 9999 ? $_DSESSION['timeoffset'] : $_DCACHE['settings']['timeoffset'];
+
+$membertablefields = '';
+@extract($_DSESSION);
+
+$lastvisit = empty($lastvisit) ? $timestamp - 86400 : $lastvisit;
+$timenow = array('time' => gmdate("$dateformat $timeformat",
$timestamp + 3600 * $timeoffset),
+ 'offset' => ($timeoffset >= 0 ? ($timeoffset ==
0 ? '' : '+'.$timeoffset) : $timeoffset));
+
+if(PHP_VERSION > '5.1') {
+ @date_default_timezone_set('Etc/GMT'.($timeoffset > 0 ? '-' : '+').(abs($timeoffset)));
+}
+
+$accessadd1 = $accessadd2 = $modadd1 = $modadd2 = '';
+
+if(empty($discuz_uid) || empty($discuz_user)) {
+ $show_cloud = 0;
+ $discuz_user = $extgroupids = '';
+ $discuz_uid = $adminid = $posts = $digestposts = $pageviews = $oltime
= $invisible
+ = $credits = $extcredits1 = $extcredits2 = $extcredits3 = $extcredits4
+ = $extcredits5 = $extcredits6 = $extcredits7 = $extcredits8 = 0;
+ $groupid = empty($groupid) || $groupid != 6 ? 7 : 6;
+
+} else {
+ $discuz_userss = $discuz_user;
+ $now_img_select = $discuz_now_img;
+ $geo_user = $discuz_user_geo;
+ $geo_user_md5 = md5($discuz_user_geo);
+ $discuz_user = addslashes($discuz_user);
+
+
+ if($accessmasks) {
+ $accessadd1 = ', a.allowview, a.allowpost, a.allowreply,
a.allowgetattach, a.allowpostattach';
+ $accessadd2 = "LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid'
AND a.fid=f.fid";
+ }
+
+ if($adminid == 3) {
+ $modadd1 = ', m.uid AS ismoderator';
+ $modadd2 = "LEFT JOIN {$tablepre}moderators m ON m.uid='$discuz_uid'
AND m.fid=f.fid";
+ }
+}
+
+if($errorreport == 2 || ($errorreport == 1 && $adminid > 0)) {
+ error_reporting(E_ERROR | E_WARNING | E_PARSE);
+}
+
+define('FORMHASH', formhash());
+
+$statstatus && !$inajax && require_once DISCUZ_ROOT.'./include/counter.inc.php';
+
+$extra = isset($extra) && @preg_match("/^[&=;a-z0-9]+$/i", $extra) ? $extra : '';
+
+$rsshead = $navtitle = $navigation = '';
+
+
+$_DSESSION['groupid'] = $groupid = empty($ipbanned) ?
(empty($groupid) ? 7 : intval($groupid)) : 6;
+if(!@include
DISCUZ_ROOT.'./forumdata/cache/usergroup_'.$groupid.'.php') {
+ $query = $db->query("SELECT type FROM {$tablepre}usergroups WHERE groupid='$groupid'");
+ $grouptype = $db->result($query, 0);
+ if(!empty($grouptype)) {
+ $cachelost .= ' usergroup_'.$groupid;
+ } else {
+ $grouptype = 'member';
+ }
+}
+
+if($passport_status && ($passport_status != 'shopex' ||
!$passport_shopex)) {
+ $passport_forward = rawurlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
+ $link_login =
$passport_url.$passport_login_url.(strpos($passport_login_url, '?') === FALSE ? '?' : '&amp;').'forward='.$passport_forward;
+ $link_logout =
$passport_url.$passport_logout_url.(strpos($passport_logout_url, '?')
=== FALSE ? '?' : '&amp;').'forward='.$passport_forward;
+ $link_register =
$passport_url.$passport_register_url.(strpos($passport_register_url, '?')
=== FALSE ? '?' : '&amp;').'forward='.$passport_forward;
+} else {
+ $link_login = 'logging.php?action=login';
+ $link_logout = 'logging.php?action=logout&amp;formhash='.FORMHASH;
+ $link_register = 'register.php';
+}
+
+if($discuz_uid && $_DSESSION) {
+ if(!empty($groupexpiry) && $groupexpiry < $timestamp &&
(!defined('CURSCRIPT') || (CURSCRIPT != 'wap' &&
CURSCRIPT != 'member'))) {
+ dheader("Location: {$boardurl}member.php?action=groupexpiry");
+ } elseif($grouptype && $groupid != getgroupid($discuz_uid, array
+ (
+ 'type' => $grouptype,
+ 'creditshigher' => $groupcreditshigher,
+ 'creditslower' => $groupcreditslower
+ ), $_DSESSION)) {
+ @extract($_DSESSION);
+ $cachelost .= (@include
DISCUZ_ROOT.'./forumdata/cache/usergroup_'.intval($groupid).'.php') ? '' : ' usergroup_'.$groupid;
+ }
+}
+
+$tpp = intval(empty($_DSESSION['tpp']) ? $topicperpage : $_DSESSION['tpp']);
+$ppp = intval(empty($_DSESSION['ppp']) ? $postperpage : $_DSESSION['ppp']);
+
+if(!in_array($adminid, array(1, 2, 3))) {
+ $alloweditpost = $alloweditpoll = $allowstickthread = $allowmodpost =
$allowdelpost = $allowmassprune
+ = $allowrefund = $allowcensorword = $allowviewip = $allowbanip =
$allowedituser = $allowmoduser
+ = $allowbanuser = $allowpostannounce = $allowviewlog =
$disablepostctrl = $supe_allowpushthread = 0;
+} elseif(isset($radminid) && $adminid != $radminid && $adminid !=
$groupid) {
+ $cachelost .= (@include
DISCUZ_ROOT.'./forumdata/cache/admingroup_'.intval($adminid).'.php') ? '' : ' admingroup_'.$groupid;
+}
+
+$forum = array();
+$auditstatuson = !empty($mod) && $mod == 'edit' && in_array($adminid,
array(1, 2, 3)) && $allowmodpost ? true : false;
+
+$tid = isset($tid) && is_numeric($tid) ? $tid : 0;
+$fid = isset($fid) && is_numeric($fid) ? $fid : 0;
+$typeid = isset($typeid) ? intval($typeid) : 0;
+
+if(!empty($tid) || !empty($fid) || !empty($name)) {
+ if($fid) {
+ $query = $db->query("SELECT f.fid, f.*, ff.* $accessadd1 $modadd1,
f.fid AS fid
+ FROM {$tablepre}forums f
+ LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid $accessadd2 $modadd2
+ WHERE f.fid='$fid'");
+ $forum = $db->fetch_array($query);
+ } elseif($name) {
+ $name = strtolower(trim($name));
+ $query = $db->query("SELECT f.fid, f.board_name,f.*, ff.*
$accessadd1 $modadd1, f.fid AS fid
+ FROM {$tablepre}forums f
+ LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid $accessadd2 $modadd2
+ WHERE f.board_name='{$name}'");
+ $forum = $db->fetch_array($query);
+ } else {
+ $query = $db->query("SELECT t.tid,
t.closed,".(defined('SQL_ADD_THREAD') ? SQL_ADD_THREAD : '')." f.*,
ff.* $accessadd1 $modadd1, f.fid AS fid
+ FROM {$tablepre}threads t
+ INNER JOIN {$tablepre}forums f ON f.fid=t.fid
+ LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid $accessadd2 $modadd2
+ WHERE t.tid='$tid'".($auditstatuson ? '' : " AND
t.displayorder>='0'")." LIMIT 1");
+ $forum = $db->fetch_array($query);
+ $tid = $forum['tid'];
+ }
+
+ if($forum) {
+ $fid = $forum['fid'];
+ $forum['ismoderator'] = !empty($forum['ismoderator']) || $adminid ==
1 || $adminid == 2 ? 1 : 0;
+
foreach(array('postcredits', 'replycredits', 'threadtypes', 'digestcredits', 'postattachcredits', 'getattachcredits', 'supe_pushsetting')
as $key) {
+ $forum[$key] = !empty($forum[$key]) ? unserialize($forum[$key]) : array();
+ }
+ } else {
+ $fid = 0;
+ }
+}
+
+$styleid = intval(!empty($_GET['styleid']) ? $_GET['styleid'] :
+ (!empty($_POST['styleid']) ? $_POST['styleid'] :
+ (!empty($_DSESSION['styleid']) ? $_DSESSION['styleid'] :
+ $_DCACHE['settings']['styleid'])));
+
+$styleid = intval(isset($stylejump[$styleid]) ? $styleid : $_DCACHE['settings']['styleid']);
+
+if(@!include
DISCUZ_ROOT.'./forumdata/cache/style_'.intval(!empty($forum['styleid']) ?
$forum['styleid'] : $styleid).'.php') {
+ $cachelost .= (@include
DISCUZ_ROOT.'./forumdata/cache/style_'.($styleid =
$_DCACHE['settings']['styleid']).'.php') ? '' : ' style_'.$styleid;
+}
+
+if($cachelost) {
+ require_once DISCUZ_ROOT.'./include/cache.func.php';
+ updatecache();
+ dexit('Cache List: '.$cachelost.'<br>Caches successfully created,
please refresh.');
+}
+
+if(!defined('CURSCRIPT') || CURSCRIPT != 'wap') {
+ if($nocacheheaders) {
+ @dheader("Expires: 0");
+ @dheader("Cache-Control: private, post-check=0, pre-check=0,
max-age=0", FALSE);
+ @dheader("Pragma: no-cache");
+ }
+ if($headercharset) {
+ @dheader('Content-Type: text/html; charset='.$charset);
+ }
+ if(empty($_DCOOKIE['sid']) || $sid != $_DCOOKIE['sid']) {
+ dsetcookie('sid', $sid, 604800);
+ }
+}
+
+if($cronnextrun && $cronnextrun <= $timestamp) {
+ require_once DISCUZ_ROOT.'./include/cron.func.php';
+ runcron();
+}
+if(isset($plugins['include']) && is_array($plugins['include'])) {
+ foreach($plugins['include'] as $include) {
+ if(!$include['adminid'] || ($include['adminid'] &&
$include['adminid'] >= $adminid)) {
+ @include_once DISCUZ_ROOT.'./plugins/'.$include['script'].'.inc.php';
+ }
+ }
+}
+
+if((!empty($_DCACHE['advs']) || $globaladvs || $redirectadvs)
&& !defined('IN_ADMINCP')) {
+ require_once DISCUZ_ROOT.'./include/advertisements.inc.php';
+}
+
+if(isset($allowvisit) && $allowvisit == 0 && !(defined('CURSCRIPT') &&
CURSCRIPT == 'member' && $action == 'groupexpiry')) {
+ showmessage('user_banned', NULL, 'HALTED');
+} elseif(!((defined('CURSCRIPT') && in_array(CURSCRIPT,
array('logging', 'wap', 'seccode'))) || $adminid == 1)) {
+ if($bbclosed) {
+ clearcookies();
+ $closedreason = $db->result($db->query("SELECT value FROM
{$tablepre}settings WHERE variable='closedreason'"), 0);
+ showmessage($closedreason ? $closedreason : 'board_closed', NULL, 'NOPERM');
+ }
+ periodscheck('visitbanperiods');
+}
+
+if((!empty($fromuid) || !empty($fromuser)) &&
($creditspolicy['promotion_visit'] ||
$creditspolicy['promotion_register'])) {
+ require_once DISCUZ_ROOT.'/include/promotion.inc.php';
+}
+
+$rssauth = $rssstatus && $discuz_uid ?
rawurlencode(authcode("$discuz_uid\t".($fid ?
$fid : '')."\t".substr(md5($discuz_pw.$discuz_secques), 0,
8), 'ENCODE', md5($_DCACHE['settings']['authkey']))) : '0';
+
+/* Parasy || Geo Initialization */
+if(PARASY_FEATURE_GEO && ($discuz_uid || $discuz_user)) {
+ $Geo = new Geo($geo_user, $Geo->map);
+ $Geo->geo->name->cn = iconv('utf-8', 'gbk', $Geo->geo->name->cn);
+ $portal = $Geo->geo->name->cn;
+}
+
+/* Parasy || Cache Files */
+@include DISCUZ_ROOT.'./forumdata/cache/cache_lastmembers.php';
+@include DISCUZ_ROOT.'./forumdata/cache/cache_parasy_stats.php';
+
+/* Parasy || User Files */
+@include(DISCUZ_ROOT.'./forumdata/cache_usr/f/user_fav_'.$discuz_uid.'.php');
+if(@!include('forumdata/cache_usr/f/user_fav_'.$discuz_uid.'.php')){
+ $fav = fav_update($discuz_uid);
+}
+
+if(CURSCRIPT !='viewpro' && $member['uid'] != $discuz_uid) {
+ @include(DISCUZ_ROOT.'./forumdata/cache_usr/b/user_buddy_'.$discuz_uid.'.php');
+ if(@!include('forumdata/cache_usr/b/user_buddy_'.$discuz_uid.'.php')){
+ $buddy = buddy_update($discuz_uid);
+ }
+}
+
+@include DISCUZ_ROOT.'./parasy/ParasyNav.php';
+
+?>
\ No newline at end of file

Added: trunk/upload/include/crons/parasy_stats_daily.inc.php
==============================================================================
--- (empty file)
+++ trunk/upload/include/crons/parasy_stats_daily.inc.php Fri Nov 23
03:26:15 2007
@@ -0,0 +1,25 @@
+<?php
+
+/* Project Parasynthesis
+* Author: Fujiwara Sai
+* Usage: Stats Cron
+*/
+
+if(!defined('IN_DISCUZ')) {
+ exit('Access Denied');
+}
+
+$data = array();
+$query = $db->query("SELECT COUNT(*) FROM {$tablepre}posts");
+$data['posts_total'] = $db->result($query, 0);
+$query = $db->query("SELECT COUNT(*) FROM {$tablepre}plugin_now");
+$data['nw_total'] = $db->result($query, 0);
+$query = $db->query("SELECT COUNT(*) FROM {$tablepre}savepoint");
+$data['svp_total'] = $db->result($query, 0);
+$query = $db->query("SELECT COUNT(*) FROM {$tablepre}favorites");
+$data['fav_total'] = $db->result($query, 0);
+
+require_once DISCUZ_ROOT.'./include/cache.func.php';
+writetocache('parasy_stats', '', getcachevars($data));
+
+?>
\ No newline at end of file

Added: trunk/upload/include/editpost.inc.php
==============================================================================
--- (empty file)
+++ trunk/upload/include/editpost.inc.php Fri Nov 23 03:26:15 2007
@@ -0,0 +1,636 @@
+<?php
+
+/*
+ [Discuz!] (C)2001-2007 Comsenz Inc.
+ This is NOT a freeware, use is subject to license terms
+
+ $RCSfile: editpost.inc.php,v $
+ $Revision: 1.131.2.20 $
+ $Date: 2007/07/24 13:29:59 $
+*/
+
+if(!defined('IN_DISCUZ')) {
+ exit('Access Denied');
+}
+
+$discuz_action = 13;
+
+$query = $db->query("SELECT m.adminid, p.first, p.authorid, p.author,
p.dateline, u.allowhtml, p.anonymous, p.invisible FROM {$tablepre}posts p
+ LEFT JOIN {$tablepre}members m ON m.uid=p.authorid
+ LEFT JOIN {$tablepre}usergroups u USING(groupid)
+ WHERE pid='$pid' AND tid='$tid' AND fid='$fid'");
+
+$orig = $db->fetch_array($query);
+
+if($magicstatus) {
+ $query = $db->query("SELECT magicid FROM {$tablepre}threadsmod WHERE
tid='$tid' AND magicid='10'");
+ $magicid = $db->result($query, 0);
+ $allowanonymous = $allowanonymous || $magicid ? 1 : $allowanonymous;
+}
+
+$isfirstpost = $orig['first'] ? 1 : 0;
+$isorigauthor = $discuz_uid && $discuz_uid == $orig['authorid'];
+$isanonymous = $isanonymous && $allowanonymous ? 1 : 0;
+$audit = $orig['invisible'] == -2 || $thread['displayorder'] == -2 ?
$audit : 0;
+
+if(empty($orig)) {
+ showmessage('undefined_action');
+} elseif((!$forum['ismoderator'] || !$alloweditpost ||
(in_array($orig['adminid'], array(1, 2, 3)) && $adminid >
$orig['adminid'])) && !($forum['alloweditpost'] && $isorigauthor)) {
+ showmessage('post_edit_nopermission', NULL, 'HALTED');
+} elseif($isorigauthor && !$forum['ismoderator']) {
+ if($edittimelimit && $timestamp - $orig['dateline'] > $edittimelimit
* 60) {
+ showmessage('post_edit_timelimit', NULL, 'HALTED');
+ } elseif(($isfirstpost && $modnewthreads) || (!$isfirstpost &&
$modnewreplies)) {
+ showmessage('post_edit_moderate');
+ }
+}
+
+$thread['pricedisplay'] = $thread['price'] == -1 ? 0 : $thread['price'];
+
+if(!submitcheck('editsubmit')) {
+
+ include_once language('misc');
+
+ $typeselect = typeselect($thread['typeid']);
+
+ if($iscircle) {
+ $mycircles = array();
+ if($discuz_uid) {
+ supe_dbconnect();
+ $query = $supe['db']->query("SELECT gid, groupname
FROM {$supe[tablepre]}groupuid WHERE uid='$discuz_uid' AND flag=1");
+ while($mycircle = $supe['db']->fetch_array($query)) {
+ $mycircles[$mycircle['gid']] = $mycircle['groupname'];
+ }
+ }
+ if($sgid = $thread['sgid']) {
+ supe_dbconnect();
+ $query = $supe['db']->query("SELECT g.groupname,
gf.headerimage, gf.css FROM {$supe[tablepre]}groups g,
{$supe[tablepre]}groupfields gf WHERE g.gid='$sgid' AND g.flag=1 AND g.gid=gf.gid");
+ $circle = $supe['db']->fetch_array($query);
+ }
+ }
+
+ $icons = '';
+ if(is_array($_DCACHE['icons']) && $isfirstpost) {
+ $key = 1;
+ foreach($_DCACHE['icons'] as $id => $icon) {
+ $icons .= ' <input class="radio" type="radio" name="iconid"
value="'.$id.'" '.($thread['iconid'] == $id ? 'checked' : '').'><img
src="'.SMDIR.'/'.$icon.'" alt="" />';
+ $icons .= !(++$key % 10) ? '<br>' : '';
+ }
+ }
+
+ $query = $db->query("SELECT * FROM {$tablepre}posts WHERE pid='$pid'
AND tid='$tid' AND fid='$fid'");
+ $postinfo = $db->fetch_array($query);
+
+ $usesigcheck = $postinfo['usesig'] ? 'checked' : '';
+ $urloffcheck = $postinfo['parseurloff'] ? 'checked' : '';
+ $smileyoffcheck = $postinfo['smileyoff'] == 1 ? 'checked' : '';
+ $codeoffcheck = $postinfo['bbcodeoff'] == 1 ? 'checked' : '';
+ $htmloncheck = $postinfo['htmlon'] ? 'checked' : '';
+
+ $poll = $temppoll = '';
+ if($isfirstpost) {
+ $thread['freecharge'] = $maxchargespan && $timestamp -
$thread['dateline'] >= $maxchargespan * 3600 ? 1 : 0;
+ if($thread['special'] == 1 && ($alloweditpoll || $thread['authorid']
== $discuz_uid)) {
+ $query = $db->query("SELECT polloptionid, displayorder, polloption,
multiple, visible, maxchoices, expiration FROM {$tablepre}polloptions
AS polloptions LEFT JOIN {$tablepre}polls AS polls ON
polloptions.tid=polls.tid WHERE polls.tid ='$tid' ORDER BY displayorder");
+ while($temppoll = $db->fetch_array($query)) {
+ $poll['multiple'] = $temppoll['multiple'];
+ $poll['visible'] = $temppoll['visible'];
+ $poll['maxchoices'] = $temppoll['maxchoices'];
+ $poll['expiration'] = $temppoll['expiration'];
+ $poll['polloptionid'][] = $temppoll['polloptionid'];
+ $poll['displayorder'][] = $temppoll['displayorder'];
+ $poll['polloption'][] = stripslashes($temppoll['polloption']);
+ }
+ } elseif($thread['special'] == 2 && ($allowposttrade ||
$thread['authorid'] == $discuz_uid)) {
+ $query = $db->query("SELECT * FROM {$tablepre}trades WHERE tid='$tid'");
+ $trade = $db->fetch_array($query);
+ $trade['expiration'] = $trade['expiration'] ? date('Y-m-d', $trade['expiration']) : '';
+ $expiration_7 = date('Y-m-d', $timestamp + 86400 * 7);
+ $expiration_14 = date('Y-m-d', $timestamp + 86400 * 14);
+ $expiration_month = date('Y-m-d', mktime(0, 0, 0, date('m')+1,
date('d'), date('Y')));
+ } elseif($thread['special'] == 3) {
+ $rewardprice = abs($thread['price']);
+ } elseif($thread['special'] == 4) {
+ $query = $db->query("SELECT * FROM {$tablepre}activities WHERE tid='$tid'");
+ $activity = $db->fetch_array($query);
+ $activity['starttimefrom'] = gmdate("Y-m-d H:i",
$activity['starttimefrom'] + $timeoffset * 3600);
+ $activity['starttimeto'] = $activity['starttimeto'] ? gmdate("Y-m-d
H:i", $activity['starttimeto'] + $timeoffset * 3600) : '';
+ $activity['expiration'] = $activity['expiration'] ? gmdate("Y-m-d
H:i", $activity['expiration'] + $timeoffset * 3600) : '';
+ }
+ }
+
+ if($postinfo['attachment']) {
+ require_once DISCUZ_ROOT.'./include/attachment.func.php';
+
+ $attachfind = $attachreplace = $attachments = array();
+ $query = $db->query("SELECT * FROM {$tablepre}attachments WHERE pid='$postinfo[pid]'");
+ while($attach = $db->fetch_array($query)) {
+ $attach['dateline'] = gmdate("$dateformat $timeformat",
$attach['dateline'] + $timeoffset * 3600);
+ $attach['filesize'] = sizecount($attach[filesize]);
+ $attach['filetype'] = attachtype(fileext($attach['attachment'])."\t".$attach['filetype']);
+ if($attach['isimage']) {
+ $attach['url'] = $attach['remote'] ? $ftp['attachurl'] : $attachurl;
+ list($attach['width'], $attach['height']) = @getimagesize($attach['url'].'/'.$attach['attachment']);
+ $x_ratio = $attach['width'] ? $thumbwidth / $attach['width'] : 0;
+ $y_ratio = $attach['height'] ? $thumbheight / $attach['height'] : 0;
+ if(($x_ratio * $attach['height']) < $thumbheight) {
+ $attach['width'] = $thumbwidth;
+ } else {
+ $attach['width'] = ceil($y_ratio * $attach['width']);
+ }
+ $attachfind[] = "/\[attach\]$attach[aid]\[\/attach\]/i";
+ $attachreplace[] = '[attachimg]'.$attach['aid'].'[/attachimg]';
+ }
+ $attachments[] = $attach;
+ }
+ }
+
+ $postinfo['subject'] = str_replace('"', '&quot;', $postinfo['subject']);
+ $postinfo['message'] = dhtmlspecialchars($postinfo['message']);
+ $postinfo['message'] =
preg_replace($language['post_edit_regexp'], '', $postinfo['message']);
+
+ if($postinfo['attachment'] && $attachfind) {
+ $postinfo['message'] = preg_replace($attachfind, $attachreplace, $postinfo['message']);
+ }
+
+ include template($iscircle && $sgid ? 'supesite_post_editpost' : 'post_editpost');
+
+} else {
+
+ if(empty($delete)) {
+
+ if($post_invalid = checkpost()) {
+ showmessage($post_invalid);
+ }
+
+ if($allowpostattach && is_array($_FILES['attach'])) {
+ foreach($_FILES['attach']['name'] as $attachname) {
+ if($attachname != '') {
+ checklowerlimit($creditspolicy['postattach']);
+ break;
+ }
+ }
+ }
+
+ if(!$isorigauthor && !$allowanonymous) {
+ if($orig['anonymous'] && !$isanonymous) {
+ $isanonymous = 0;
+ $authoradd = ', author=\''.addslashes($orig['author']).'\'';
+ $anonymousadd = ', anonymous=\'0\'';
+ } else {
+ $isanonymous = $orig['anonymous'];
+ $authoradd = $anonymousadd = '';
+ }
+ } else {
+ $authoradd = ', author=\''.($isanonymous ? '' : addslashes($orig['author'])).'\'';
+ $anonymousadd = ", anonymous='$isanonymous'";
+ }
+
+ if($isfirstpost) {
+
+ if($subject == '' || $message == '') {
+ showmessage('post_sm_isnull');
+ }
+
+ $typeid = isset($forum['threadtypes']['types'][$typeid]) ?
$typeid : 0;
+ $iconid = isset($_DCACHE['icons'][$iconid]) ? $iconid : 0;
+
+ if(!$typeid && $forum['threadtypes']['required']) {
+ showmessage('post_type_isnull');
+ }
+
+ $readperm = $allowsetreadperm ? intval($readperm) :
($isorigauthor ? 0 : 'readperm');
+ $price = intval($price);
+ $price = $thread['price'] < 0 && !$thread['special'] ?
+ ($isorigauthor || !$price ? -1 : $price) :
+ ($maxprice ? ($price <= $maxprice ? ($price > 0 ? $price : 0) :
$maxprice) : ($isorigauthor ? 0 : $thread['price']));
+
+ if($price > 0 && floor($price * (1 - $creditstax)) == 0) {
+ showmessage('post_net_price_iszero');
+ }
+
+ $polladd = '';
+ if($thread['special'] == 1 && ($alloweditpoll || $isorigauthor)
&& !empty($polls)) {
+ $pollarray = '';
+ $pollarray['options'] = $polloption;
+ if($pollarray['options']) {
+ if(count($pollarray['options']) > $maxpolloptions) {
+ showmessage('post_poll_option_toomany');
+ }
+ foreach($pollarray['options'] as $key => $value) {
+ if(!trim($value)) {
+ $db->query("DELETE FROM {$tablepre}polloptions WHERE
polloptionid='$key' AND tid='$tid'");
+ unset($pollarray['options'][$key]);
+ }
+ }
+ $polladd = ', special=\'1\'';
+ foreach($displayorder as $key => $value) {
+ if(preg_match("/^-?\d*$/", $value)) {
+ $pollarray['displayorder'][$key] = $value;
+ }
+ }
+ $pollarray['multiple'] = !empty($multiplepoll);
+ $pollarray['visible'] = empty($visibilitypoll);
+ $pollarray['expiration'] = $expiration;
+ foreach($polloptionid as $key => $value) {
+ if(!preg_match("/^\d*$/", $value)) {
+ showmessage('submit_invalid');
+ }
+ }
+ $maxchoices = $maxchoices >= count($pollarray['options']) ?
count($pollarray['options']) : $maxchoices;
+ if(preg_match("/^\d*$/", $maxchoices)) {
+ if(!$pollarray['multiple']) {
+ $pollarray['maxchoices'] = 1;
+ } elseif(empty($maxchoices)) {
+ $pollarray['maxchoices'] = 0;
+ } else {
+ $pollarray['maxchoices'] = $maxchoices;
+ }
+ }
+ $expiration = intval($expiration);
+ if($close) {
+ $pollarray['expiration'] = $timestamp;
+ } elseif(preg_match("/^\d*$/", $pollarray['expiration'])) {
+ if(empty($pollarray['expiration'])) {
+ $pollarray['expiration'] = 0;
+ } else {
+ $pollarray['expiration'] = $timestamp + 86400 * $expiration;
+ }
+ }
+ $optid = '';
+ $query = $db->query("SELECT polloptionid FROM
{$tablepre}polloptions WHERE tid='$tid'");
+ while($tempoptid = $db->fetch_array($query)) {
+ $optid[] = $tempoptid['polloptionid'];
+ }
+ foreach($pollarray['options'] as $key => $value) {
+ $value = dhtmlspecialchars(trim($value));
+ if(in_array($polloptionid[$key], $optid)) {
+ if($alloweditpoll) {
+ $db->query("UPDATE {$tablepre}polloptions SET
displayorder='".$pollarray['displayorder'][$key]."',
polloption='$value' WHERE polloptionid='$polloptionid[$key]' AND tid='$tid'");
+ } else {
+ $db->query("UPDATE {$tablepre}polloptions SET
displayorder='".$pollarray['displayorder'][$key]."' WHERE
polloptionid='$polloptionid[$key]' AND tid='$tid'");
+ }
+ } else {
+ $db->query("INSERT INTO {$tablepre}polloptions (tid,
displayorder, polloption) VALUES ('$tid', '".$pollarray['displayorder'][$key]."', '$value')");
+ }
+ }
+ $db->query("UPDATE {$tablepre}polls SET
multiple='$pollarray[multiple]', visible='$pollarray[visible]',
maxchoices='$pollarray[maxchoices]',
expiration='$pollarray[expiration]' WHERE tid='$tid'", 'UNBUFFERED');
+ } else {
+ $polladd = ', special=\'0\'';
+ $db->query("DELETE FROM {$tablepre}polls WHERE tid='$tid'");
+ $db->query("DELETE FROM {$tablepre}polloptions WHERE tid='$tid'");
+ }
+
+ } elseif($thread['special'] == 2 && ($allowposttrade ||
$thread['authorid'] == $discuz_uid)) {
+
+ $seller = dhtmlspecialchars(trim($seller));
+ $item_name = dhtmlspecialchars(trim($item_name));
+ $item_price = floatval($item_price);
+ $item_locus = dhtmlspecialchars(trim($item_locus));
+ $item_number = intval($item_number);
+ $item_quality = intval($item_quality);
+ $item_transport = intval($item_transport);
+ $postage_mail = intval($postage_mail);
+ $postage_express = intval(trim($postage_express));
+ $postage_ems = intval($postage_ems);
+ $item_type = intval($item_type);
+
+ if(!$seller) {
+ showmessage('trade_alipay_please');
+ } elseif(!$item_name) {
+ showmessage('trade_please_name');
+ } elseif($maxtradeprice && ($mintradeprice > $item_price ||
$maxtradeprice < $item_price)) {
+ showmessage('trade_price_between');
+ } elseif(!$maxtradeprice && $mintradeprice > $item_price) {
+ showmessage('trade_price_more_than');
+ } elseif(!trim($item_locus)) {
+ showmessage('trade_please_locus');
+ } elseif($item_number < 0) {
+ showmessage('tread_please_number');
+ }
+
+ $expiration = $item_expiration ? strtotime($item_expiration) : 0;
+ $closed = $expiration > 0 && strtotime($item_expiration) <
$timestamp ? 1 : $closed;
+
+ switch($transport) {
+ case 'seller':$item_transport = 1;break;
+ case 'buyer':$item_transport = 2;break;
+ case 'virtual':$item_transport = 3;break;
+ case 'logistics':$item_transport = 4;break;
+ }
+
+ $db->query("UPDATE {$tablepre}trades SET account='$seller',
subject='$item_name', price='$item_price', amount='$item_number',
quality='$item_quality', locus='$item_locus',
+ transport='$item_transport', ordinaryfee='$postage_mail',
expressfee='$postage_express', emsfee='$postage_ems',
itemtype='$item_type', expiration='$expiration', closed='$closed' WHERE tid='$tid'", 'UNBUFFERED');
+ } elseif($thread['special'] == 3 && ($allowpostreward ||
$thread['authorid'] == $discuz_uid)) {
+ if($thread['price'] > 0 && $thread['price'] != $rewardprice) {
+ $rewardprice = intval($rewardprice);
+ if($rewardprice <= 0){
+ showmessage("reward_credits_invalid");
+ }
+ $addprice = ceil(($rewardprice - $thread['price']) +
($rewardprice - $thread['price']) * $creditstax);
+ if(!$forum['ismoderator']) {
+ if($rewardprice < $thread['price']) {
+ showmessage("reward_credits_fall");
+ } elseif($rewardprice < $minrewardprice || ($maxrewardprice > 0
&& $rewardprice > $maxrewardprice)) {
+ showmessage("reward_credits_between");
+ } elseif($addprice > $_DSESSION["extcredits$creditstrans"]) {
+ showmessage('reward_credits_shortage');
+ }
+ }
+ $realprice = ceil($thread['price'] + $thread['price'] *
$creditstax) + $addprice;
+
+ $db->query("UPDATE {$tablepre}members SET
extcredits$creditstrans=extcredits$creditstrans-$addprice WHERE uid='$thread[authorid]'");
+ $db->query("UPDATE {$tablepre}rewardlog SET
netamount='$realprice' WHERE tid='$tid' AND authorid='$thread[authorid]'");
+ }
+
+ if(!$forum['ismoderator']) {
+ if($thread['replies'] > 1) {
+ $subject = addslashes($thread['subject']);
+ }
+
+ if($thread['price'] < 0) {
+ $rewardprice = abs($thread['price']);
+ }
+ }
+
+ $price = $thread['price'] > 0 ? $rewardprice : -$rewardprice;
+
+ } elseif($thread['special'] == 4 && $allowpostactivity) {
+
+ if(empty($starttimefrom[$activitytime])) {
+ showmessage('activity_fromtime_please');
+ } elseif(strtotime($starttimefrom[$activitytime]) === -1 ||
@strtotime($starttimefrom[$activitytime]) === FALSE) {
+ showmessage('activity_fromtime_error');
+ } elseif(@strtotime($starttimefrom[$activitytime]) < $timestamp) {
+ showmessage('activity_smaller_current');
+ } elseif($activitytime && ((@strtotime($starttimefrom) >
@strtotime($starttimeto) || !$starttimeto))) {
+ showmessage('activity_fromtime_error');
+ } elseif(!trim($activityclass)) {
+ showmessage('activity_sort_please');
+ } elseif(!trim($activityplace)) {
+ showmessage('activity_address_please');
+ } elseif(trim($activityexpiration) &&
(@strtotime($activityexpiration) === -1 ||
@strtotime($activityexpiration) === FALSE)) {
+ showmessage('activity_totime_error');
+ }
+
+ $activity = array();
+ $activity['class'] = dhtmlspecialchars(trim($activityclass));
+ $activity['starttimefrom'] = @strtotime($starttimefrom[$activitytime]);
+ $activity['starttimeto'] = $activitytime ?
@strtotime($starttimeto) : 0;
+ $activity['place'] = dhtmlspecialchars(trim($activityplace));
+ $activity['cost'] = intval($cost);
+ $activity['gender'] = intval($gender);
+ $activity['number'] = intval($activitynumber);
+ if($activityexpiration) {
+ $activity['expiration'] = @strtotime($activityexpiration);
+ } else {
+ $activity['expiration'] = 0;
+ }
+
+ $db->query("UPDATE {$tablepre}activities SET
cost='$activity[cost]', starttimefrom='$activity[starttimefrom]',
starttimeto='$activity[starttimeto]', place='$activity[place]',
class='$activity[class]', gender='$activity[gender]',
number='$activity[number]', expiration='$activity[expiration]' WHERE tid='$tid'", 'UNBUFFERED');
+ }
+
+ $sgidadd = '';
+ if($iscircle && $sgid) {
+ $sgidadd = ', sgid=0';
+ require_once DISCUZ_ROOT.'./include/supesite.func.php';
+ if(supe_circlepermission($sgid)) {
+ $sgidadd = ", sgid='$sgid'";
+ }
+ }
+
+ $db->query("UPDATE {$tablepre}threads SET iconid='$iconid',
typeid='$typeid', subject='$subject', readperm='$readperm',
price='$price' $authoradd $polladd $sgidadd ".($auditstatuson && $audit
== 1 ? ",displayorder='0', moderated='1'" : '')." WHERE tid='$tid'", 'UNBUFFERED');
+
+ } else {
+
+ if($subject == '' && $message == '') {
+ showmessage('post_sm_isnull');
+ }
+
+ }
+
+ if($editedby && ($timestamp - $orig['dateline']) > 60 && $adminid !=
1) {
+ include_once language('misc');
+
+ $editor = $isanonymous && $isorigauthor ? $language['anonymous'] : $discuz_user;
+ $edittime =
gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'],
$timestamp + $timeoffset * 3600);
+ eval("\$message .= \"$language[post_edit]\";");
+ }
+
+ $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff));
+ $smileyoff = checksmilies($message, !empty($smileyoff));
+ $htmlon = $orig['allowhtml'] && !empty($htmlon) ? 1 : 0;
+
+ $tattachment = 0;
+ $pattachment = ($allowpostattach && $attachments =
attach_upload()) ? 1 : 0;
+ $uattachment = ($allowpostattach && $uattachments =
attach_upload('attachupdate')) ? 1 : 0;
+
+ $query = $db->query("SELECT aid, readperm, price, attachment,
description, thumb, remote FROM {$tablepre}attachments WHERE pid='$pid'");
+
+ $attachdescnew = is_array($attachdescnew) ? $attachdescnew : array();
+ $attachpermnew = is_array($attachpermnew) ? $attachpermnew : array();
+ $attachpricenew = is_array($attachpricenew) ? $attachpricenew : array();
+
+ while($attach = $db->fetch_array($query)) {
+
+ $attachpermnew[$attach['aid']] = intval($attachpermnew[$attach['aid']]);
+ $attachpermadd = $allowsetattachperm && $attach['readperm'] !=
$attachpermnew[$attach['aid']] ? ", readperm='{$attachpermnew[$attach['aid']]}'" : '' ;
+
+ $attachpricenew[$attach['aid']] = intval($attachpricenew[$attach['aid']]);
+ $attachpriceadd = $maxprice && $attach['price'] !=
$attachpricenew[$attach['aid']] && $attachpricenew[$attach['aid']] <=
$maxprice ? ", price='{$attachpricenew[$attach['aid']]}'" : '' ;
+
+ $attachdescnew[$attach['aid']] =
cutstr(dhtmlspecialchars($attachdescnew[$attach['aid']]), 95);
+ $attachdescadd = $attach['description'] !=
$attachdescnew[$attach['aid']] ? 1 : 0;
+
+ if($uattachment || $attachpermadd || $attachdescadd ||
$attachpriceadd) {
+
+ $paid = 'paid'.$attach['aid'];
+ $attachfileadd = '';
+ if($uattachment && isset($uattachments[$paid])) {
+ dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
+ $attachfileadd = ', dateline=\''.$timestamp.'\',
+ filename=\''.$uattachments[$paid]['name'].'\',
+ filetype=\''.$uattachments[$paid]['type'].'\',
+ filesize=\''.$uattachments[$paid]['size'].'\',
+ attachment=\''.$uattachments[$paid]['attachment'].'\',
+ thumb=\''.$uattachments[$paid]['thumb'].'\',
+ isimage=\''.$uattachments[$paid]['isimage'].'\',
+ remote=\''.$uattachments[$paid]['remote'].'\'';
+ unset($uattachments[$paid]);
+ }
+
+ $db->query("UPDATE {$tablepre}attachments SET
description='{$attachdescnew[$attach['aid']]}' $attachpermadd
$attachpriceadd $attachfileadd WHERE aid='$attach[aid]'");
+ }
+ }
+
+ if($uattachment && !empty($uattachments)) {
+ foreach($uattachments as $attach) {
+ dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
+ }
+ }
+
+ if(!empty($deleteaid) || $pattachment) {
+
+ if(!empty($deleteaid) && is_array($deleteaid)) {
+
+ $deleteaids = '\''.implode("','", $deleteaid).'\'';
+ $query = $db->query("SELECT aid, attachment, thumb, remote FROM
{$tablepre}attachments WHERE aid IN ($deleteaids) AND pid='$pid'");
+
+ while($attach = $db->fetch_array($query)) {
+ dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
+ }
+
+ $db->query("DELETE FROM {$tablepre}attachments WHERE aid IN
($deleteaids) AND pid='$pid'");
+ updatecredits($orig['authorid'], $postattachcredits, -($db->affected_rows()));
+ }
+
+ if($pattachment) {
+ $searcharray = $pregarray = $replacearray = array();
+ foreach($attachments as $key => $attach) {
+ $db->query("INSERT INTO {$tablepre}attachments (tid, pid,
dateline, readperm, price, filename, description, filetype, filesize,
attachment, downloads, isimage, uid, thumb, remote)
+ VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]')");
+ $searcharray[] = '[local]'.$localid[$key].'[/local]';
+ $pregarray[] = '/\[localimg=(\d{1,3}),(\d{1,3})\]'.$localid[$key].'\[\/localimg\]/is';
+ $replacearray[] = '[attach]'.$db->insert_id().'[/attach]';
+ }
+ $message = str_replace($searcharray, $replacearray,
preg_replace($pregarray, $replacearray, $message));
+ updatecredits($orig['authorid'], $postattachcredits, count($attachments));
+ } else {
+ $query = $db->query("SELECT aid FROM {$tablepre}attachments WHERE
pid='$pid' LIMIT 1");
+ $pattachment = $db->result($query, 0) ? 1 : 0;
+ }
+
+ if($pattachment) {
+ $tattachment = 1;
+ } else {
+ $query = $db->query("SELECT a.aid FROM {$tablepre}posts p,
{$tablepre}attachments a WHERE a.tid='$tid' AND a.pid=p.pid AND
p.invisible='0' LIMIT 1");
+ $tattachment = $db->result($query, 0) ? 1 : 0;
+ }
+
+ $db->query("UPDATE {$tablepre}threads SET attachment='$tattachment'
WHERE tid='$tid'");
+
+ }
+
+ if($auditstatuson && $audit == 1) {
+ updatepostcredits('+', $orig['authorid'], ($isfirstpost ?
$postcredits : $replycredits));
+ updatemodworks('MOD', 1);
+ updatemodlog($tid, 'MOD');
+ }
+
+ $message =
preg_replace('/\[attachimg\](\d+)\[\/attachimg\]/is', '[attach]\1[/attach]', $message);
+ $db->query("UPDATE {$tablepre}posts SET message='$message',
usesig='$usesig', htmlon='$htmlon', bbcodeoff='$bbcodeoff', parseurloff='$parseurloff',
+ smileyoff='$smileyoff', subject='$subject' ".($pattachment ? ",
attachment='1'" : '')." $anonymousadd ".($auditstatuson && $audit ==
1 ? ",invisible='0'" : '')." WHERE pid='$pid'");
+ $forum['lastpost'] = explode("\t", $forum['lastpost']);
+
+ if($orig['dateline'] == $forum['lastpost'][2] && ($orig['author'] ==
$forum['lastpost'][3] || ($forum['lastpost'][3] == '' &&
$orig['anonymous']))) {
+ $lastpost = "$tid\t".($isfirstpost ? $subject :
addslashes($thread['subject']))."\t$orig[dateline]\t".($isanonymous ? '' : addslashes($orig['author']));
+ $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$fid'", 'UNBUFFERED');
+ }
+
+ if($thread['lastpost'] == $orig['dateline'] && ((!$orig['anonymous']
&& $thread['lastposter'] == $orig['author']) || ($orig['anonymous'] &&
$thread['lastposter'] == '')) && $orig['anonymous'] != $isanonymous) {
+ $db->query("UPDATE {$tablepre}threads SET
lastposter='".($isanonymous ? '' : addslashes($orig['author']))."'
WHERE tid='$tid'", 'UNBUFFERED');
+ }
+
+ if(!$isorigauthor) {
+ updatemodworks('EDT', 1);
+ require_once DISCUZ_ROOT.'./include/misc.func.php';
+ modlog($thread, 'EDT');
+ }
+
+ } else {
+ if(($isfirstpost && $thread['replies'] > 0) || !$isorigauthor) {
+ showmessage(($thread['special'] ==
3 ? 'post_edit_reward_already_reply' : 'post_edit_nopermission'), NULL, 'HALTED');
+ }
+ if($thread['special'] == 3) {
+ if($thread['price'] < 0 && ($thread['dateline'] + 1 ==
$orig['dateline'])) {
+ showmessage('post_edit_reward_nopermission', NULL, 'HALTED');
+ }
+ }
+
+ updatepostcredits('-', $orig['authorid'], ($isfirstpost ?
$postcredits : $replycredits));
+ eval($hooks['add_reply_in_editpost']); //add_reply
+ require_once DISCUZ_ROOT.'./include/cache.func.php';
+ updatecache('newthread');
+
+ if($thread['special'] == 3 && $isfirstpost) {
+ $db->query("UPDATE {$tablepre}members SET
extcredits$creditstrans=extcredits$creditstrans+$thread[price] WHERE uid='$orig[authorid]'", 'UNBUFFERED');
+ $db->query("DELETE FROM {$tablepre}rewardlog WHERE tid='$tid'", 'UNBUFFERED');
+ }
+
+ $thread_attachment = $post_attachment = 0;
+ $query = $db->query("SELECT pid, attachment, thumb, remote FROM
{$tablepre}attachments WHERE tid='$tid'");
+ while($attach = $db->fetch_array($query)) {
+ if($attach['pid'] == $pid) {
+ $post_attachment = 1;
+ dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
+ updatecredits($orig['authorid'], $postattachcredits, -($db->affected_rows()));
+ } else {
+ $thread_attachment = 1;
+ }
+ }
+
+ if($post_attachment) {
+ $db->query("DELETE FROM {$tablepre}attachments WHERE pid='$pid'", 'UNBUFFEREED');
+ }
+
+ $db->query("DELETE FROM {$tablepre}posts WHERE pid='$pid'");
+
+ if($isfirstpost) {
+ $forumadd = 'threads=threads-1, posts=posts-1';
+ $tablearray = array('threadsmod','relatedthreads','threads','polloptions','polls','mythreads');
+ foreach ($tablearray as $table) {
+ $db->query("DELETE FROM {$tablepre}$table WHERE tid='$tid'", 'UNBUFFERED');
+ }
+ if($globalstick && in_array($thread['displayorder'], array(2, 3))) {
+ require_once DISCUZ_ROOT.'./include/cache.func.php';
+ updatecache('globalstick');
+ }
+ } else {
+ $forumadd = 'posts=posts-1';
+ $query = $db->query("SELECT author, dateline, anonymous FROM
{$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline
DESC LIMIT 1");
+ $lastpost = $db->fetch_array($query);
+ $lastpost['author'] = !$lastpost['anonymous'] ? addslashes($lastpost['author']) : '';
+ $db->query("UPDATE {$tablepre}threads SET replies=replies-1,
attachment='$thread_attachment', lastposter='$lastpost[author]',
lastpost='$lastpost[dateline]' WHERE tid='$tid'", 'UNBUFFERED');
+ }
+
+ $forum['lastpost'] = explode("\t", $forum['lastpost']);
+ if($orig['dateline'] == $forum['lastpost'][2] && ($orig['author'] ==
$forum['lastpost'][3] || ($forum['lastpost'][3] == '' &&
$orig['anonymous']))) {
+ $query = $db->query("SELECT tid, subject, lastpost, lastposter FROM {$tablepre}threads
+ WHERE fid='$fid' AND displayorder>='0' ORDER BY lastpost DESC
LIMIT 1");
+ $lastthread = daddslashes($db->fetch_array($query), 1);
+ $forumadd .= ", lastpost='$lastthread[tid]\t$lastthread[subject]\t$lastthread[lastpost]\t$lastthread[lastposter]'";
+ }
+
+ $db->query("UPDATE {$tablepre}forums SET $forumadd WHERE fid='$fid'", 'UNBUFFERED');
+
+ }
+
+ // debug: update thread caches ?
+ if($forum['threadcaches']) {
+ if($isfirstpost || $page == 1 || $thread['replies'] <
$_DCACHE['pospperpage'] || !empty($delete)) {
+ $forum['threadcaches'] && deletethreadcaches($tid);
+ } else {
+ $query = $db->query("SELECT COUNT(*) FROM {$tablepre}posts WHERE
tid='$tid' AND pid<'$pid'");
+ if($db->result($query, 0) < $_DCACHE['settings']['postperpage']) {
+ $forum['threadcaches'] && deletethreadcaches($tid);
+ }
+ }
+ }
+
+ if($auditstatuson) {
+ if($audit == 1) {
+ showmessage('auditstatuson_succeed', "viewthread.php?tid=$tid&page=$page&extra=$extra#pid$pid");
+ } else {
+ showmessage('audit_edit_succeed');
+ }
+ } else {
+ if(!empty($delete) && $isfirstpost) {
+ showmessage('post_edit_delete_succeed', "forumdisplay.php?fid=$fid");
+ } else {
+ showmessage('post_edit_succeed', "viewthread.php?tid=$tid&page=$page&extra=$extra#pid$pid");
+ }
+ }
+
+}
+
+?>
\ No newline at end of file

Added: trunk/upload/include/forum.func.php
==============================================================================
--- (empty file)
+++ trunk/upload/include/forum.func.php Fri Nov 23 03:26:15 2007
@@ -0,0 +1,184 @@
+<?php
+
+/*
+ [Discuz!] (C)2001-2007 Comsenz Inc.
+ This is NOT a freeware, use is subject to license terms
+
+ $RCSfile: forum.func.php,v $
+ $Revision: 1.31.2.2 $
+ $Date: 2007/03/21 15:52:38 $
+*/
+
+if(!defined('IN_DISCUZ')) {
+ exit('Access Denied');
+}
+
+function checkautoclose() {
+ global $timestamp, $forum, $thread;
+
+ if(!$forum['ismoderator'] && $forum['autoclose']) {
+ $closedby = $forum['autoclose'] > 0 ? 'dateline' : 'lastpost';
+ $forum['autoclose'] = abs($forum['autoclose']);
+ if($timestamp - $thread[$closedby] > $forum['autoclose'] * 86400) {
+ return 'post_thread_closed_by_'.$closedby;
+ }
+ }
+ return FALSE;
+}
+
+function forum(&$forum) {
+ global $_DCOOKIE, $timestamp, $timeformat, $dateformat, $discuz_uid,
$groupid, $lastvisit, $moddisplay, $timeoffset, $hideprivate, $onlinehold;
+
+ if(!$forum['viewperm'] || ($forum['viewperm'] &&
forumperm($forum['viewperm'])) || !empty($forum['allowview']) ||
(isset($forum['users']) && strstr($forum['users'], "\t$discuz_uid\t"))) {
+ $forum['permission'] = 2;
+ } elseif(!$hideprivate) {
+ $forum['permission'] = 1;
+ } else {
+ return FALSE;
+ }
+
+ if($forum['icon']) {
+ if(strstr($forum['icon'], ',')) {
+ $flash = explode(",", $forum['icon']);
+ $forum['icon'] = "<a
href=\"forumdisplay.php?fid=$forum[fid]\"><embed
src=\"".trim($flash[0])."\" width=\"".trim($flash[1])."\"
height=\"".trim($flash[2])."\" type=\"application/x-shockwave-flash\" align=\"left\"></embed></a>";
+ } else {
+ $forum['icon'] = "<a href=\"forumdisplay.php?fid=$forum[fid]\"><img
src=\"$forum[icon]\" align=\"left\" alt=\"\" border=\"0\" /></a>";
+ }
+ }
+
+ $lastpost = array('tid' => 0, 'dateline' => 0, 'subject'
=> '', 'author' => '');
+ //list($lastpost['tid'], $lastpost['subject'], $lastpost['dateline'],
$lastpost['author']) = is_array($forum['lastpost']) ?
$forum['lastpost'] : explode("\t", $forum['lastpost']);
+ $forum['folder'] = '<img
src="'.IMGDIR.'/'.((isset($_DCOOKIE['fid'.$forum['fid']]) &&
$_DCOOKIE['fid'.$forum['fid']] > $lastvisit ?
$_DCOOKIE['fid'.$forum['fid']] : $lastvisit) <
$lastpost['dateline'] ? 'red_' : '').'forum.gif" alt="" />';
+
+ if($lastpost['tid']) {
+ $lastpost['dateline'] = gmdate("$dateformat $timeformat",
$lastpost['dateline'] + $timeoffset * 3600);
+ if($lastpost['author']) {
+ $lastpost['author'] = '<a href="space.php?username='.rawurlencode($lastpost['author']).'">'.$lastpost['author'].'</a>';
+ }
+ $forum['lastpost'] = $lastpost;
+ } else {
+ $forum['lastpost'] = '';
+ }
+
+ $forum['moderators'] = moddisplay($forum['moderators'], $moddisplay, !empty($forum['inheritedmod'])).'&nbsp;';
+
+ if(isset($forum['subforums'])) {
+ $forum['subforums'] = implode(', ', $forum['subforums']);
+ }
+
+ return TRUE;
+}
+
+function forumselect($groupselectable = FALSE, $tableformat = 0) {
+ global $_DCACHE, $discuz_uid, $groupid, $fid, $gid, $indexname;
+
+ if(!isset($_DCACHE['forums'])) {
+ require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
+ }
+
+ $forumlist = $tableformat ? '' : '<optgroup label="&nbsp;">';
+ foreach($_DCACHE['forums'] as $forum) {
+ if($forum['type'] == 'group') {
+ if($tableformat) {
+ $forumlist .= '<tr><td class="popupmenu_option"><a'.($gid ==
$forum['fid'] ? ' class="bold"' : '').' href="'.$indexname.'?gid='.$forum['fid'].'">'.$forum['name'].'</a></td></tr>';
+ } else {
+ $forumlist .= $groupselectable ? '<option
value="'.$forum['fid'].'">'.$forum['name'].'</option>' : '</optgroup><optgroup label="'.$forum['name'].'">';
+ }
+ $visible[$forum['fid']] = true;
+ } elseif($forum['type'] == 'forum' && isset($visible[$forum['fup']])
&& (!$forum['viewperm'] || ($forum['viewperm'] &&
forumperm($forum['viewperm'])) ||
strstr($forum['users'], "\t$discuz_uid\t"))) {
+ if($tableformat) {
+ $forumlist .= '<tr><td class="popupmenu_option">&nbsp; <a'.($fid
== $forum['fid'] ? ' class="bold"' : '').' href="forumdisplay.php?fid='.$forum['fid'].'">&gt; '.$forum['name'].'</a></td></tr>';
+ } else {
+ $forumlist .= '<option value="'.$forum['fid'].'">&nbsp; &gt; '.$forum['name'].'</option>';
+ }
+ $visible[$forum['fid']] = true;
+ } elseif($forum['type'] == 'sub' && isset($visible[$forum['fup']])
&& (!$forum['viewperm'] || ($forum['viewperm'] &&
forumperm($forum['viewperm'])) ||
strstr($forum['users'], "\t$discuz_uid\t"))) {
+ if($tableformat) {
+ $forumlist .= '<tr><td class="popupmenu_option">&nbsp; &nbsp;
&nbsp; <a'.($fid == $forum['fid'] ? ' class="bold"' : '').' href="forumdisplay.php?fid='.$forum['fid'].'">&gt; '.$forum['name'].'</a></td></tr>';
+ } else {
+ $forumlist .= '<option value="'.$forum['fid'].'">&nbsp; &nbsp;
&nbsp; &gt; '.$forum['name'].'</option>';
+ }
+ }
+ }
+ $forumlist .= $tableformat ? '' : '</optgroup>';
+ $forumlist = $tableformat ? $forumlist : str_replace('<optgroup
label="&nbsp;"></optgroup>', '', $forumlist);
+
+ return $forumlist;
+}
+
+function visitedforums() {
+ global $_DCACHE, $_DCOOKIE, $forum;
+
+ $count = 0;
+ $visitedforums = '';
+ $fidarray = array($forum['fid']);
+ foreach(explode('D', $_DCOOKIE['visitedfid']) as $fid) {
+ if(isset($_DCACHE['forums'][$fid]) && !in_array($fid, $fidarray)) {
+ $fidarray[] = $fid;
+ if($fid != $forum['fid']) {
+ $visitedforums .= '<option value="'.$fid.'">'.$_DCACHE['forums'][$fid]['name'].'</option>';
+ if(++$count >= $GLOBALS['visitedforums']) {
+ break;
+ }
+
+ }
+ }
+ }
+ if(($visitedfid = implode('D', $fidarray)) !=
$_DCOOKIE['visitedfid']) {
+ dsetcookie('visitedfid', $visitedfid, 2592000);
+ }
+ return $visitedforums;
+}
+
+function moddisplay($moderators, $type, $inherit = 0) {
+ if($type == 'selectbox') {
+ $modlist .= '<img src="images/common/online_moderator.gif"
class="absmiddle" alt="" /><select '.($moderators ? '' : 'disabled').'
name="modlist" style="width: 100px'.($inherit ? '; font-weight: bold"' : '').'">';
+
+ if($moderators) {
+ foreach(explode("\t", $moderators) as $moderator) {
+ $modlist .= '<option value="'.rawurlencode($moderator).'">'.$moderator.'</option>';
+ }
+ } else {
+ $modlist .= '<option></option>';
+ }
+ $modlist .= '</select>';
+ return $modlist;
+ } else {
+ if($moderators) {
+ $modlist = $comma = '';
+ foreach(explode("\t", $moderators) as $moderator) {
+ $modlist .= $comma.'<a
href="space.php?username='.rawurlencode($moderator).'">'.($inherit ?
$moderator : $moderator).'</a>';
+ $comma = ', ';
+ }
+ } else {
+ $modlist = '';
+ }
+ return $modlist;
+ }
+}
+
+function getcacheinfo($tid) {
+ global $timestamp, $cachethreadlife, $cachethreaddir;
+ $tid = intval($tid);
+ $cachethreaddir2 = DISCUZ_ROOT.'./'.$cachethreaddir;
+ $cache = array('filemtime' => 0, 'filename' => '');
+ $tidmd5 = substr(md5($tid), 3);
+ $fulldir = $cachethreaddir2.'/'.$tidmd5[0].'/'.$tidmd5[1].'/'.$tidmd5[2].'/';
+ $cache['filename'] = $fulldir.$tid.'.htm';
+ if(file_exists($cache['filename'])) {
+ $cache['filemtime'] = filemtime($cache['filename']);
+ } else {
+ if(!is_dir($fulldir)) {
+ for($i=0; $i<3; $i++) {
+ $cachethreaddir2 .= '/'.$tidmd5{$i};
+ if(!is_dir($cachethreaddir2)) {
+ @mkdir($cachethreaddir2, 0777);
+ @touch($cachethreaddir2.'/index.htm');
+ }
+ }
+ }
+ }
+ return $cache;
+}
+
+?>
\ No newline at end of file

Added: trunk/upload/include/global.func.php
==============================================================================
--- (empty file)
+++ trunk/upload/include/global.func.php Fri Nov 23 03:26:15 2007
@@ -0,0 +1,998 @@
+<?php
+
+/*
+ [Discuz!] (C)2001-2007 Comsenz Inc.
+ This is NOT a freeware, use is subject to license terms
+
+ $RCSfile: global.func.php,v $
+ $Revision: 1.156.2.21 $
+ $Date: 2007/07/24 13:30:21 $
+*/
+
+if(!defined('IN_DISCUZ')) {
+ exit('Access Denied');
+}
+
+function authcode($string, $operation, $key = '') {
+
+ $key = md5($key ? $key : $GLOBALS['discuz_auth_key']);
+ $key_length = strlen($key);
+
+ $string = $operation == 'DECODE' ? base64_decode($string) :
substr(md5($string.$key), 0, 8).$string;
+ $string_length = strlen($string);
+
+ $rndkey = $box = array();
+ $result = '';
+
+ for($i = 0; $i <= 255; $i++) {
+ $rndkey[$i] = ord($key[$i % $key_length]);
+ $box[$i] = $i;
+ }
+
+ for($j = $i = 0; $i < 256; $i++) {
+ $j = ($j + $box[$i] + $rndkey[$i]) % 256;
+ $tmp = $box[$i];
+ $box[$i] = $box[$j];
+ $box[$j] = $tmp;
+ }
+
+ for($a = $j = $i = 0; $i < $string_length; $i++) {
+ $a = ($a + 1) % 256;
+ $j = ($j + $box[$a]) % 256;
+ $tmp = $box[$a];
+ $box[$a] = $box[$j];
+ $box[$j] = $tmp;
+ $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
+ }
+
+ if($operation == 'DECODE') {
+ if(substr($result, 0, 8) == substr(md5(substr($result, 8).$key), 0,
8)) {
+ return substr($result, 8);
+ } else {
+ return '';
+ }
+ } else {
+ return str_replace('=', '', base64_encode($result));
+ }
+
+}
+
+function clearcookies() {
+ global $discuz_uid, $discuz_user, $discuz_pw, $discuz_secques,
$adminid, $credits;
+ dsetcookie('sid', '', -86400 * 365);
+ dsetcookie('auth', '', -86400 * 365);
+ dsetcookie('visitedfid', '', -86400 * 365);
+ dsetcookie('onlinedetail', '', -86400 * 365, 0);
+
+ $discuz_uid = $adminid = $credits = 0;
+ $discuz_user = $discuz_pw = $discuz_secques = '';
+}
+
+function checklowerlimit($creditsarray, $coef = 1) {
+ if(is_array($creditsarray)) {
+ global $extcredits, $id;
+ foreach($creditsarray as $id => $addcredits) {
+ if($addcredits * $coef < 0 && ($GLOBALS['extcredits'.$id] <
$extcredits[$id]['lowerlimit'] || (($GLOBALS['extcredits'.$id] -
$addcredits) < $extcredits[$id]['lowerlimit']))) {
+ showmessage('credits_policy_lowerlimit');
+ }
+ }
+ }
+}
+
+function cutstr($string, $length, $dot = ' ...') {
+ global $charset;
+
+ if(strlen($string) <= $length) {
+ return $string;
+ }
+
+ $string = str_replace(array('&amp;', '&quot;', '&lt;', '&gt;'),
array('&', '"', '<', '>'), $string);
+
+ $strcut = '';
+ if(strtolower($charset) == 'utf-8') {
+
+ $n = $tn = $noc = 0;
+ while($n < strlen($string)) {
+
+ $t = ord($string[$n]);
+ if($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) {
+ $tn = 1; $n++; $noc++;
+ } elseif(194 <= $t && $t <= 223) {
+ $tn = 2; $n += 2; $noc += 2;
+ } elseif(224 <= $t && $t < 239) {
+ $tn = 3; $n += 3; $noc += 2;
+ } elseif(240 <= $t && $t <= 247) {
+ $tn = 4; $n += 4; $noc += 2;
+ } elseif(248 <= $t && $t <= 251) {
+ $tn = 5; $n += 5; $noc += 2;
+ } elseif($t == 252 || $t == 253) {
+ $tn = 6; $n += 6; $noc += 2;
+ } else {
+ $n++;
+ }
+
+ if($noc >= $length) {
+ break;
+ }
+
+ }
+ if($noc > $length) {
+ $n -= $tn;
+ }
+
+ $strcut = substr($string, 0, $n);
+
+ } else {
+ for($i = 0; $i < $length - strlen($dot) - 1; $i++) {
+ $strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
+ }
+ }
+
+ $strcut = str_replace(array('&', '"', '<', '>'),
array('&amp;', '&quot;', '&lt;', '&gt;'), $strcut);
+
+ return $strcut.$dot;
+}
+
+function daddslashes($string, $force = 0) {
+ !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
+ if(!MAGIC_QUOTES_GPC || $force) {
+ if(is_array($string)) {
+ foreach($string as $key => $val) {
+ $string[$key] = daddslashes($val, $force);
+ }
+ } else {
+ $string = addslashes($string);
+ }
+ }
+ return $string;
+}
+
+function datecheck($ymd, $sep='-') {
+ if(!empty($ymd)) {
+ list($year, $month, $day) = explode($sep, $ymd);
+ return checkdate($month, $day, $year);
+ } else {
+ return FALSE;
+ }
+}
+
+function debuginfo() {
+ if($GLOBALS['debug']) {
+ global $db, $discuz_starttime, $debuginfo;
+ $mtime = explode(' ', microtime());
+ $debuginfo = array('time' => number_format(($mtime[1] + $mtime[0] -
$discuz_starttime), 6), 'queries' => $db->querynum);
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+function dexit($message = '') {
+ echo $message;
+ output();
+ exit();
+}
+
+function dhtmlspecialchars($string) {
+ if(is_array($string)) {
+ foreach($string as $key => $val) {
+ $string[$key] = dhtmlspecialchars($val);
+ }
+ } else {
+ $string = preg_replace('/&amp;((#(\d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/', '&\\1',
+ str_replace(array('&', '"', '<', '>'),
array('&amp;', '&quot;', '&lt;', '&gt;'), $string));
+ }
+ return $string;
+}
+
+function dheader($string, $replace = true, $http_response_code = 0) {
+ $string = str_replace(array("\r", "\n"), array('', ''), $string);
+ if(empty($http_response_code) || PHP_VERSION < '4.3' ) {
+ @header($string, $replace);
+ } else {
+ @header($string, $replace, $http_response_code);
+ }
+ if(preg_match('/^\s*location:/is', $string)) {
+ exit();
+ }
+}
+
+function disuploadedfile($file) {
+ return function_exists('is_uploaded_file') &&
(is_uploaded_file($file) || is_uploaded_file(str_replace('\\\\', '\\', $file)));
+}
+
+function dreferer($default = '') {
+ global $referer, $indexname;
+
+ $default = empty($default) ? $indexname : '';
+ if(empty($referer) && isset($GLOBALS['_SERVER']['HTTP_REFERER'])) {
+ $referer = preg_replace("/([\?&])((sid\=[a-z0-9]{6})(&|
$))/i", '\\1', $GLOBALS['_SERVER']['HTTP_REFERER']);
+ $referer = substr($referer, -1) == '?' ? substr($referer, 0, -1) : $referer;
+ } else {
+ $referer = dhtmlspecialchars($referer);
+ }
+
+ if(!preg_match("/(\.php|[a-z]+(\-\d+)+\.html)/", $referer) ||
strpos($referer, 'logging.php')) {
+ $referer = $default;
+ }
+ return $referer;
+}
+
+function dsetcookie($var, $value, $life = 0, $prefix = 1) {
+ global $cookiepre, $cookiedomain, $cookiepath, $timestamp, $_SERVER;
+ setcookie(($prefix ? $cookiepre : '').$var, $value,
+ $life ? $timestamp + $life : 0, $cookiepath,
+ $cookiedomain, $_SERVER['SERVER_PORT'] == 443 ? 1 : 0);
+}
+
+function dunlink($filename, $havethumb = 0, $remote = 0) {
+ global $authkey, $ftp, $attachdir;
+ if($remote) {
+ require_once DISCUZ_ROOT.'./include/ftp.func.php';
+ if(!$ftp['connid']) {
+ if(!($ftp['connid'] = dftp_connect($ftp['host'], $ftp['username'],
authcode($ftp['password'], 'DECODE', md5($authkey)), $ftp['attachdir'],
$ftp['port'], $ftp['ssl']))) {
+ return;
+ }
+ }
+ dftp_delete($ftp['connid'], $filename);
+ $havethumb && dftp_delete($ftp['connid'], $filename.'.thumb.jpg');
+ } else {
+ @unlink($attachdir.'/'.$filename);
+ $havethumb && @unlink($attachdir.'/'.$filename.'.thumb.jpg');
+ }
+}
+
+function emailconv($email, $tolink = 1) {
+ $email = str_replace(array('@', '.'), array('&#64;', '&#46;'), $email);
+ return $tolink ? '<a href="mailto: '.$email.'">'.$email.'</a>': $email;
+}
+
+function errorlog($type, $message, $halt = 1) {
+ global $timestamp, $discuz_userss, $onlineip, $_SERVER;
+ $user = empty($discuz_userss) ? '' : $discuz_userss.'<br>';
+ $user .= $onlineip.'|'.$_SERVER['REMOTE_ADDR'];
+ writelog('errorlog',
dhtmlspecialchars("$timestamp\t$type\t$user\t".str_replace(array("\r", "\n"),
array(' ', ' '), trim($message))));
+ if($halt) {
+ dexit();
+ }
+}
+
+function getrobot() {
+ if(!defined('IS_ROBOT')) {
+ $kw_spiders = 'Bot|Crawl|Spider|slurp|sohu-search|lycos|robozilla';
+ $kw_browsers = 'MSIE|Netscape|Opera|Konqueror|Mozilla';
+ if(preg_match("/($kw_browsers)/", $_SERVER['HTTP_USER_AGENT'])) {
+ define('IS_ROBOT', FALSE);
+ } elseif(preg_match("/($kw_spiders)/", $_SERVER['HTTP_USER_AGENT'])) {
+ define('IS_ROBOT', TRUE);
+ } else {
+ define('IS_ROBOT', FALSE);
+ }
+ }
+ return IS_ROBOT;
+}
+
+function fileext($filename) {
+ return trim(substr(strrchr($filename, '.'), 1, 10));
+}
+
+function formhash($specialadd = '') {
+ global $discuz_user, $discuz_uid, $discuz_pw, $timestamp, $discuz_auth_key;
+ $hashadd = defined('IN_ADMINCP') ? 'Only For Discuz! Admin Control Panel' : '';
+ return substr(md5(substr($timestamp, 0,
-7).$discuz_user.$discuz_uid.$discuz_pw.$discuz_auth_key.$hashadd.$specialadd),
8, 8);
+}
+
+function forumperm($permstr) {
+ global $groupid, $extgroupids;
+
+ $groupidarray = array($groupid);
+ foreach(explode("\t", $extgroupids) as $extgroupid) {
+ if($extgroupid = intval(trim($extgroupid))) {
+ $groupidarray[] = $extgroupid;
+ }
+ }
+ return preg_match("/(^|\t)(".implode('|', $groupidarray).")(\t|$)/", $permstr);
+}
+
+function getgroupid($uid, $group, &$member) {
+ global $creditsformula, $db, $tablepre;
+
+ if(!empty($creditsformula)) {
+ $updatearray = array();
+ eval("\$credits = round($creditsformula);");
+
+ if($credits != $member['credits']) {
+ $updatearray[] = "credits='$credits'";
+ $member['credits'] = $credits;
+ }
+ if($group['type'] == 'member' && !($member['credits'] >=
$group['creditshigher'] && $member['credits'] <
$group['creditslower'])) {
+ $query = $db->query("SELECT groupid FROM {$tablepre}usergroups
WHERE type='member' AND $member[credits]>=creditshigher AND
$member[credits]<creditslower LIMIT 1");
+ if($db->num_rows($query)) {
+ $member['groupid'] = $db->result($query, 0);
+ $updatearray[] = "groupid='$member[groupid]'";
+ }
+ }
+
+ if($updatearray) {
+ $db->query("UPDATE {$tablepre}members SET ".implode(', ',
$updatearray)." WHERE uid='$uid'");
+ }
+ }
+
+ return $member['groupid'];
+}
+
+function groupexpiry($terms) {
+ $terms = is_array($terms) ? $terms : unserialize($terms);
+ $groupexpiry = isset($terms['main']['time']) ?
intval($terms['main']['time']) : 0;
+ if(is_array($terms['ext'])) {
+ foreach($terms['ext'] as $expiry) {
+ if((!$groupexpiry && $expiry) || $expiry < $groupexpiry) {
+ $groupexpiry = $expiry;
+ }
+ }
+ }
+ return $groupexpiry;
+}
+
+function ipaccess($ip, $accesslist) {
+ return preg_match("/^(".str_replace(array("\r\n", ' '),
array('|', ''), preg_quote($accesslist, '/')).")/", $ip);
+}
+
+function ipbanned($onlineip) {
+ global $ipaccess, $timestamp, $cachelost;
+
+ if($ipaccess && !ipaccess($onlineip, $ipaccess)) {
+ return TRUE;
+ }
+
+ $cachelost .= (@include
DISCUZ_ROOT.'./forumdata/cache/cache_ipbanned.php') ? '' : ' ipbanned';
+ if(empty($_DCACHE['ipbanned'])) {
+ return FALSE;
+ } else {
+ if($_DCACHE['ipbanned']['expiration'] < $timestamp) {
+ @unlink(DISCUZ_ROOT.'./forumdata/cache/cache_ipbanned.php');
+ }
+ return preg_match("/^(".$_DCACHE['ipbanned']['regexp'].")$/", $onlineip);
+ }
+}
+
+function isemail($email) {
+ return strlen($email) > 6 &&
preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email);
+}
+
+function language($file, $templateid = 0, $tpldir = '') {
+ $tpldir = $tpldir ? $tpldir : TPLDIR;
+ $templateid = $templateid ? $templateid : TEMPLATEID;
+
+ $languagepack = DISCUZ_ROOT.'./'.$tpldir.'/'.$file.'.lang.php';
+ if(file_exists($languagepack)) {
+ return $languagepack;
+ } elseif($templateid != 1 && $tpldir != './templates/default') {
+ return language($file, 1, './templates/default');
+ } else {
+ return FALSE;
+ }
+}
+
+function multi($num, $perpage, $curpage, $mpurl, $maxpages = 0, $page
= 10, $simple = 0, $onclick = '') {
+ $multipage = '';
+ $mpurl .= strpos($mpurl, '?') ? '&amp;' : '?';
+ $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 ? '<a
href="'.$mpurl.'page=1" class="p"'.$onclick.'>|&lsaquo;</a>' : '').
+ ($curpage > 1 && !$simple ? '<a href="'.$mpurl.'page='.($curpage -
1).'" class="p">&lsaquo;&lsaquo;</a>' : '');
+ for($i = $from; $i <= $to; $i++) {
+ $multipage .= $i == $curpage ? '<strong class="p_cur">'.$i.'</strong>' :
+ '<a href="'.$mpurl.'page='.$i.'" class="p"'.$onclick.'>'.$i.'</a>';
+ }
+
+ $multipage .= ($curpage < $pages && !$simple ? '<a
href="'.$mpurl.'page='.($curpage + 1).'" class="p"'.$onclick.'>&rsaquo;&rsaquo;</a>' : '').
+ ($to < $pages ? '<a href="'.$mpurl.'page='.$pages.'"
class="p"'.$onclick.'>&rsaquo;|</a>' : '').
+ ($curpage == $maxpages ? '<a class="p" href="misc.php?action=maxpages&amp;pages='.$maxpages.'">&rsaquo;?</a>' : '').
+ (!$simple && $pages > $page ? '<a class="p_pages" style="padding:
0px"><input class="p_input" type="text" name="custompage"
onKeyDown="if(event.keyCode==13)
{window.location=\''.$mpurl.'page=\'+this.value; return false;}"></a>' : '');
+
+ $multipage = $multipage ? (!$simple ? '<strong
class="p_info">'.$num.' ITEMS / 30 PER PAGE</strong><a class="p_edge">&nbsp;'.$curpage.'/'.$realpages.'&nbsp;</a>' : '').$multipage : '';
+ }
+ return $multipage;
+}
+
+function output() {
+ global $sid, $transsidstatus, $rewritestatus, $ftp;
+
+ if(($transsidstatus = empty($GLOBALS['_DCOOKIE']['sid']) &&
$transsidstatus) || in_array($rewritestatus, array(2, 3))) {
+ if($transsidstatus) {
+ $searcharray = array
+ (
+ "/\<a(\s*[^\>]+\s*)href\=([\"|\']?)([^\"\'\s]+)/ies",
+ "/(\<form.+?\>)/is"
+ );
+ $replacearray = array
+ (
+ "transsid('\\3','<a\\1href=\\2')",
+ "\\1\n<input type=\"hidden\" name=\"sid\" value=\"$sid\">"
+ );
+ } else {
+ $searcharray = array
+ (
+ //"/\<a href\=\"index\.php\"\>/",
+ "/\<a href\=\"forumdisplay\.php\?fid\=(\d+)(&amp;page\=(\d+))?\"([^\>]*)\>/e",
+ "/\<a href\=\"viewthread\.php\?tid\=(\d+)(&amp;extra\=page\%3D(\d+))?(&amp;page\=(\d+))?\"([^\>]*)\>/e",
+ "/\<a href\=\"viewpro\.php\?(uid\=(\d+)|username\=([^&]+?))\"([^\>]*)\>/e",
+ "/\<a href\=\"space\.php\?(uid\=(\d+)|username\=([^&]+?))\"([^\>]*)\>/e"
+ );
+ $replacearray = array
+ (
+ //"<a href=\"index.html\">",
+ "rewrite_forum('\\1', '\\3', '\\4')",
+ "rewrite_thread('\\1', '\\5', '\\3', '\\6')",
+ "rewrite_profile('\\2', '\\3', '\\4')",
+ "rewrite_space('\\2', '\\3', '\\4')"
+ );
+ }
+
+ $content = preg_replace($searcharray, $replacearray, ob_get_contents());
+ ob_end_clean();
+ $GLOBALS['gzipcompress'] ? ob_start('ob_gzhandler') : ob_start();
+
+ echo $content;
+ }
+ if($ftp['connid']) {
+ @ftp_close($ftp['connid']);
+ }
+ $ftp = array();
+
+ if(defined('CACHE_FILE') && CACHE_FILE
&& !defined('CACHE_FORBIDDEN')) {
+ global $cachethreaddir;
+ if(diskfreespace(DISCUZ_ROOT.'./'.$cachethreaddir) > 1000000) {
+ $fp = fopen(CACHE_FILE, 'w');
+ if($fp) {
+ flock($fp, LOCK_EX);
+ fwrite($fp, empty($content) ? ob_get_contents() : $content);
+ }
+ @fclose($fp);
+ }
+ }
+}
+
+function rewrite_thread($tid, $page = 0, $prevpage = 0, $extra = '') {
+ global $bbsdir;
+ return '<a href="'.$bbsdir.'/thread-'.$tid.'-'.($page ? $page :
1).'-'.($prevpage ? $prevpage : 1).'.html"'.stripslashes($extra).'>';
+}
+
+function rewrite_forum($fid, $page = 0, $extra = '') {
+ global $bbsdir;
+ return '<a href="'.$bbsdir.'/forum-'.$fid.'-'.($page ? $page : 1).'.html"'.stripslashes($extra).'>';
+}
+
+function rewrite_profile($uid, $username, $extra = '') {
+ global $bbsdir;
+ //return '<a href="profile-'.($uid ? 'uid-'.$uid : 'username-'.$username).'.html"'.stripslashes($extra).'>';
+ return '<a href="'.$bbsdir.'/'.($uid ? 'u-'.$uid : 'user-'.$username).'.html"'.stripslashes($extra).'>';
+}
+
+function rewrite_space($uid, $username, $extra = '') {
+ global $bbsdir;
+ //return '<a href="space-'.($uid ? 'uid-'.$uid : 'username-'.$username).'.html"'.stripslashes($extra).'>';
+ return '<a href="'.$bbsdir.'/'.($uid ? 'u-'.$uid : 'user-'.$username).'.html"'.stripslashes($extra).'>';
+}
+
+function periodscheck($periods, $showmessage = 1) {
+ global $timestamp, $disableperiodctrl, $_DCACHE, $banperiods;
+
+ if(!$disableperiodctrl && $_DCACHE['settings'][$periods]) {
+ $now = gmdate('G.i', $timestamp + $_DCACHE['settings']['timeoffset']
* 3600);
+ foreach(explode("\r\n", str_replace(':', '.',
$_DCACHE['settings'][$periods])) as $period) {
+ list($periodbegin, $periodend) = explode('-', $period);
+ if(($periodbegin > $periodend && ($now >= $periodbegin || $now <
$periodend)) || ($periodbegin < $periodend && $now >= $periodbegin &&
$now < $periodend)) {
+ $banperiods = str_replace("\r\n", ', ', $_DCACHE['settings'][$periods]);
+ if($showmessage) {
+ showmessage('period_nopermission', NULL, 'NOPERM');
+ } else {
+ return TRUE;
+ }
+ }
+ }
+ }
+ return FALSE;
+}
+
+function quescrypt($questionid, $answer) {
+ return $questionid > 0 && $answer != '' ?
substr(md5($answer.md5($questionid)), 16, 8) : '';
+}
+
+function random($length, $numeric = 0) {
+ PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
+ if($numeric) {
+ $hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
+ } else {
+ $hash = '';
+ $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
+ $max = strlen($chars) - 1;
+ for($i = 0; $i < $length; $i++) {
+ $hash .= $chars[mt_rand(0, $max)];
+ }
+ }
+ return $hash;
+}
+
+function removedir($dirname, $keepdir = FALSE) {
+
+ $dirname = wipespecial($dirname);
+
+ if(!is_dir($dirname)) {
+ return FALSE;
+ }
+ $handle = opendir($dirname);
+ while(($file = readdir($handle)) !== FALSE) {
+ if($file != '.' && $file != '..') {
+ $dir = $dirname . DIRECTORY_SEPARATOR . $file;
+ is_dir($dir) ? removedir($dir) : unlink($dir);
+ }
+ }
+ closedir($handle);
+ return !$keepdir ? (@rmdir($dirname) ? TRUE : FALSE) : TRUE;
+}
+
+function sendmail($email_to, $email_subject, $email_message,
$email_from = '') {
+ extract($GLOBALS, EXTR_SKIP);
+ require DISCUZ_ROOT.'./include/sendmail.inc.php';
+}
+
+function sendpm($toid, $subject, $message, $fromid = '', $from = '') {
+ extract($GLOBALS, EXTR_SKIP);
+ include language('pms');
+
+ if(isset($language[$subject])) {
+ eval("\$subject = addslashes(\"".$language[$subject]."\");");
+ }
+ if(isset($language[$message])) {
+ eval("\$message = addslashes(\"".$language[$message]."\");");
+ }
+
+ if(!$fromid && !$from) {
+ $fromid = $discuz_uid;
+ $from = $discuz_user;
+ }
+
+ $pmids = array();
+ foreach(explode(',', $toid) as $uid) {
+ if(is_numeric($uid)) {
+ $query = $db->query("INSERT INTO {$tablepre}pms (msgfrom,
msgfromid, msgtoid, folder, new, subject, dateline, message)
+ VALUES ('$from', '$fromid', '$uid', 'inbox', '1', '$subject', '$timestamp', '$message')");
+ if($query) {
+ $pmids[] = $uid;
+ }
+ }
+ }
+
+ if($toid = implodeids($pmids)) {
+ $db->query("UPDATE {$tablepre}members SET newpm='1' WHERE uid IN ($toid)");
+ }
+}
+
+function showmessage($message, $url_forward = '', $extra = '') {
+ extract($GLOBALS, EXTR_SKIP);
+ global $extrahead, $discuz_action, $debuginfo, $seccode, $fid, $tid,
$supe_fromsupesite, $supe_jumpurl, $supe, $charset, $show_message, $_DCACHE;
+ define('CACHE_FORBIDDEN', TRUE);
+ $supe_messagetpl = $supe_error = '';
+ $show_message = $message;
+ $msgforward = unserialize($_DCACHE['settings']['msgforward']);
+ $msgforward['refreshtime'] = intval($msgforward['refreshtime']);
+ $url_forward = empty($url_forward) ? '' : (empty($_DCOOKIE['sid']) &&
$transsidstatus ? transsid($url_forward) : $url_forward);
+
+ if($supe_fromsupesite && $supe['status']) {
+ $supe_messagetpl = 'supesite_';
+ $extra = '';
+ $supe_error = $url_forward ? false : true;
+ $url_forward = !empty($supe_jumpurl) && !$supe_error ?
urldecode($supe_jumpurl) : $url_forward;
+ } elseif($url_forward && empty($_GET['inajax']) &&
$msgforward['quick'] && $msgforward['messages'] && @in_array($message,
$msgforward['messages'])) {
+ updatesession();
+ dheader("location: ".str_replace('&amp;', '&', $url_forward));
+ }
+
+ if(in_array($extra, array('HALTED', 'NOPERM'))) {
+ $fid = $tid = 0;
+ $discuz_action = 254;
+ } else {
+ $discuz_action = 255;
+ }
+
+ include language('messages');
+
+ if(isset($language[$message])) {
+ $supe_pre = $supe_fromsupesite ? 'supe_' : '';
+ eval("\$show_message = \"".($language[$supe_pre.$message] ?
$language[$supe_pre.$message] : $language[$message])."\";");
+ unset($supe_pre);
+ }
+
+ ajaxtemplate('showmessage_ajax');
+
+ $extrahead .= $url_forward ? '<meta http-equiv="refresh"
content="'.$msgforward['refreshtime'].' url='.$url_forward.'">' : '';
+
+ if($advlist = $advlist['redirect']) {
+ foreach($advlist AS $type => $redirectadvs) {
+ $advlist[$type] = $redirectadvs[array_rand($redirectadvs)];
+ }
+ }
+
+ if($extra == 'NOPERM' && !$passport_status) {
+ //get secure code checking status (pos. -2)
+ if($seccodecheck = substr(sprintf('%05b', $seccodestatus), -2, 1)) {
+ $seccode = random(6, 1) + $seccode{0} * 1000000;
+ }
+ include template('nopermission');
+ } else {
+ include template($supe_messagetpl.'showmessage');
+ }
+ dexit();
+}
+
+function wapshowmessage($message, $url_forward = '', $extra = '') {
+ extract($GLOBALS, EXTR_SKIP);
+ global $extrahead, $discuz_action, $debuginfo, $seccode, $fid, $tid,
$supe_fromsupesite, $supe_jumpurl, $supe, $charset, $show_message, $_DCACHE;
+ define('CACHE_FORBIDDEN', TRUE);
+ $supe_messagetpl = $supe_error = '';
+ $show_message = $message;
+ $msgforward = unserialize($_DCACHE['settings']['msgforward']);
+ $msgforward['refreshtime'] = intval($msgforward['refreshtime']);
+ $url_forward = empty($url_forward) ? '' : (empty($_DCOOKIE['sid']) &&
$transsidstatus ? transsid($url_forward) : $url_forward);
+
+ if($supe_fromsupesite && $supe['status']) {
+ $supe_messagetpl = 'supesite_';
+ $extra = '';
+ $supe_error = $url_forward ? false : true;
+ $url_forward = !empty($supe_jumpurl) && !$supe_error ?
urldecode($supe_jumpurl) : $url_forward;
+ } elseif($url_forward && empty($_GET['inajax']) &&
$msgforward['quick'] && $msgforward['messages'] && @in_array($message,
$msgforward['messages'])) {
+ updatesession();
+ dheader("location: ".str_replace('&amp;', '&', $url_forward));
+ }
+
+ if(in_array($extra, array('HALTED', 'NOPERM'))) {
+ $fid = $tid = 0;
+ $discuz_action = 254;
+ } else {
+ $discuz_action = 255;
+ }
+
+ include language('messages');
+
+ if(isset($language[$message])) {
+ $supe_pre = $supe_fromsupesite ? 'supe_' : '';
+ eval("\$show_message = \"".($language[$supe_pre.$message] ?
$language[$supe_pre.$message] : $language[$message])."\";");
+ unset($supe_pre);
+ }
+
+ ajaxtemplate('showmessage_ajax');
+
+ $extrahead .= $url_forward ? '<meta http-equiv="refresh"
content="'.$msgforward['refreshtime'].' url='.$url_forward.'">' : '';
+
+ if($advlist = $advlist['redirect']) {
+ foreach($advlist AS $type => $redirectadvs) {
+ $advlist[$type] = $redirectadvs[array_rand($redirectadvs)];
+ }
+ }
+
+ if($extra == 'NOPERM' && !$passport_status) {
+ //get secure code checking status (pos. -2)
+ if($seccodecheck = substr(sprintf('%05b', $seccodestatus), -2, 1)) {
+ $seccode = random(6, 1) + $seccode{0} * 1000000;
+ }
+ include template('nopermission');
+ } else {
+ include template($supe_messagetpl.'showmessage_wap');
+ }
+ dexit();
+}
+function showstars($num) {
+ global $starthreshold;
+
+ $alt = 'alt="Rank: '.$num.'"';
+ if(empty($starthreshold)) {
+ for($i = 0; $i < $num; $i++) {
+ echo '<img src="'.IMGDIR.'/star_level1.gif" '.$alt.' />';
+ }
+ } else {
+ for($i = 3; $i > 0; $i--) {
+ $numlevel = intval($num / pow($starthreshold, ($i - 1)));
+ $num = ($num % pow($starthreshold, ($i - 1)));
+ for($j = 0; $j < $numlevel; $j++) {
+ echo '<img src="'.IMGDIR.'/star_level'.$i.'.gif" '.$alt.' />';
+ }
+ }
+ }
+}
+
+function site() {
+ return $_SERVER['HTTP_HOST'];
+}
+
+function strexists($haystack, $needle) {
+ return !(strpos($haystack, $needle) === FALSE);
+}
+
+function seccodeconvert(&$seccode) {
+ $seccode = substr($seccode, -6);
+ $s = sprintf('%04s', base_convert($seccode, 10, 24));
+ $seccode = '';
+ $seccodeunits = 'BCEFGHJKMPQRTVWXY2346789';
+ for($i = 0; $i < 4; $i++) {
+ $unit = ord($s{$i});
+ $seccode .= ($unit >= 0x30 && $unit <= 0x39) ? $seccodeunits[$unit -
0x30] : $seccodeunits[$unit - 0x57];
+ }
+}
+
+function submitcheck($var, $allowget = 0, $seccodecheck = 0,
$secqaacheck = 0) {
+ if(empty($GLOBALS[$var])) {
+ return FALSE;
+ } else {
+ global $_SERVER, $seccode, $seccodeverify, $secanswer, $_DCACHE;
+ if($allowget || ($_SERVER['REQUEST_METHOD'] == 'POST' &&
$GLOBALS['formhash'] == formhash() && (empty($_SERVER['HTTP_REFERER']) ||
+ preg_replace("/https?:\/\/([^\:\/]+).*/i", "\\1",
$_SERVER['HTTP_REFERER']) == preg_replace("/([^\:]+).*/", "\\1",
$_SERVER['HTTP_HOST'])))) {
+ if($seccodecheck) {
+ $tmp = $seccode{0};
+ seccodeconvert($seccode);
+ if(strtoupper($seccodeverify) != $seccode) {
+ showmessage('submit_seccode_invalid');
+ }
+ $seccode = random(6, 1) + $tmp * 1000000;
+ }
+ if($secqaacheck) {
+ require_once DISCUZ_ROOT.'./forumdata/cache/cache_secqaa.php';
+ if(md5($secanswer) != $_DCACHE['secqaa'][substr($seccode,
0, 1)]['answer']) {
+ showmessage('submit_secqaa_invalid');
+ }
+ $seccode = random(1, 1) * 1000000 + substr($seccode, -6);
+ }
+ return TRUE;
+ } else {
+ showmessage('submit_invalid');
+ }
+ }
+}
+
+function supe_submitcheck($allowget = 0, $timespan = 300) {
+ global $supe_seccode, $timestamp, $_DCOOKIE, $supe, $supe_fromsupesite;
+ $supe_hash = isset($_GET['supe_hash']) || isset($_POST['supe_hash']) ?
+ (isset($_GET['supe_hash']) ? $_GET['supe_hash'] : $_POST['supe_hash']) :
+ (isset($_DCOOKIE['supe_hash']) ? $_DCOOKIE['supe_hash'] : '');
+ if($supe_fromsupesite && $supe['status'] && ($allowget ||
$_SERVER['REQUEST_METHOD'] == 'POST') && $supe_hash
&& !empty($supe_seccode)) {
+ list($check_timestamp, $check_seccode) = explode("\t", authcode($supe_hash, 'DECODE'));
+ if($timestamp - $check_timestamp <= $timespan && $check_seccode ==
$supe_seccode) {
+ return TRUE;
+ }
+ showmessage('submit_invalid');
+ }
+ return FALSE;
+}
+
+function template($file, $templateid = 0, $tpldir = '') {
+ global $tplrefresh;
+
+ $tpldir = $tpldir ? $tpldir : TPLDIR;
+ $templateid = $templateid ? $templateid : TEMPLATEID;
+
+ $tplfile = DISCUZ_ROOT.'./'.$tpldir.'/'.$file.'.htm';
+ $objfile = DISCUZ_ROOT.'./forumdata/templates/'.$templateid.'_'.$file.'.tpl.php';
+ if(TEMPLATEID != 1 && $templateid != 1 && !file_exists($tplfile)) {
+ return template($file, 1, './templates/default/');
+ }
+ if($tplrefresh == 1 || ($tplrefresh > 1 &&
substr($GLOBALS['timestamp'], -1) > $tplrefresh)) {
+ if(@filemtime($tplfile) > @filemtime($objfile)) {
+ require_once DISCUZ_ROOT.'./include/template.func.php';
+ parse_template($file, $templateid, $tpldir);
+ }
+ }
+ return $objfile;
+}
+
+function transsid($url, $tag = '', $wml = 0) {
+ global $sid;
+ $tag = stripslashes($tag);
+ if(!$tag || (!preg_match("/^(http:\/\/|mailto:|#|javascript)/i",
$url) && !strpos($url, 'sid='))) {
+ if($pos = strpos($url, '#')) {
+ $urlret = substr($url, $pos);
+ $url = substr($url, 0, $pos);
+ } else {
+ $urlret = '';
+ }
+ $url .= (strpos($url, '?') ? ($wml ? '&amp;' : '&') : '?').'sid='.$sid.$urlret;
+ }
+ return $tag.$url;
+}
+
+function typeselect($curtypeid = 0) {
+ if($threadtypes = $GLOBALS['forum']['threadtypes']) {
+ $html = '<select name="typeid"><option value="0">&nbsp;</option>';
+ foreach($threadtypes['types'] as $typeid => $name) {
+ $html .= '<option value="'.$typeid.'" '.($curtypeid == $typeid ? 'selected' : '').'>'.strip_tags($name).'</option>';
+ }
+ $html .= '</select>';
+ return $html;
+ } else {
+ return '';
+ }
+}
+
+function updatecredits($uids, $creditsarray, $coef = 1, $extrasql
= '') {
+ if($uids && ((!empty($creditsarray) && is_array($creditsarray)) ||
$extrasql)) {
+ global $db, $tablepre;
+ $creditsadd = $comma = '';
+ foreach($creditsarray as $id => $addcredits) {
+ $creditsadd .= $comma.'extcredits'.$id.'=extcredits'.$id.'+('.intval($addcredits).')*('.$coef.')';
+ $comma = ', ';
+ }
+
+ if($creditsadd || $extrasql) {
+ $db->query("UPDATE {$tablepre}members SET
$creditsadd ".($creditsadd && $extrasql ? ', ' : '')." $extrasql WHERE
uid IN ('$uids')", 'UNBUFFERED');
+ }
+ }
+}
+
+function updatesession() {
+ if(!empty($GLOBALS['sessionupdated'])) {
+ return TRUE;
+ }
+
+ global $db, $tablepre, $sessionexists, $sessionupdated, $sid,
$onlineip, $discuz_uid, $discuz_user, $timestamp, $lastactivity, $seccode,
+ $pvfrequence, $spageviews, $lastolupdate, $oltimespan, $onlinehold,
$groupid, $styleid, $invisible, $discuz_action, $fid, $tid, $bloguid;
+
+ $fid = intval($fid);
+ $tid = intval($tid);
+
+ if($oltimespan && $discuz_uid && $lastactivity && $timestamp -
($lastolupdate ? $lastolupdate : $lastactivity) > $oltimespan * 60) {
+ $lastolupdate = $timestamp;
+ $db->query("UPDATE {$tablepre}onlinetime SET
total=total+'$oltimespan', thismonth=thismonth+'$oltimespan',
lastupdate='$timestamp' WHERE uid='$discuz_uid' AND
lastupdate<='".($timestamp - $oltimespan * 60)."'");
+ if(!$db->affected_rows()) {
+ $db->query("INSERT INTO {$tablepre}onlinetime (uid, thismonth,
total, lastupdate)
+ VALUES ('$discuz_uid', '$oltimespan', '$oltimespan', '$timestamp')", 'SILENT');
+ }
+ } else {
+ $lastolupdate = intval($lastolupdate);
+ }
+
+ if($sessionexists == 1) {
+ if($pvfrequence && $discuz_uid) {
+ if($spageviews >= $pvfrequence) {
+ $pageviewsadd = ', pageviews=\'0\'';
+ $db->query("UPDATE {$tablepre}members SET
pageviews=pageviews+'$spageviews' WHERE uid='$discuz_uid'", 'UNBUFFERED');
+ } else {
+ $pageviewsadd = ', pageviews=pageviews+1';
+ }
+ } else {
+ $pageviewsadd = '';
+ }
+ $db->query("UPDATE {$tablepre}sessions SET uid='$discuz_uid',
username='$discuz_user', groupid='$groupid', styleid='$styleid',
invisible='$invisible', action='$discuz_action',
lastactivity='$timestamp', lastolupdate='$lastolupdate',
seccode='$seccode', fid='$fid', tid='$tid', bloguid='$bloguid'
$pageviewsadd WHERE sid='$sid'");
+ } else {
+ $ips = explode('.', $onlineip);
+
+ $db->query("DELETE FROM {$tablepre}sessions WHERE sid='$sid' OR
lastactivity<($timestamp-$onlinehold) OR ('$discuz_uid'<>'0' AND
uid='$discuz_uid') OR (uid='0' AND ip1='$ips[0]' AND ip2='$ips[1]' AND
ip3='$ips[2]' AND ip4='$ips[3]' AND lastactivity>$timestamp-60)");
+ $db->query("INSERT INTO {$tablepre}sessions (sid, ip1, ip2, ip3,
ip4, uid, username, groupid, styleid, invisible, action, lastactivity,
lastolupdate, seccode, fid, tid, bloguid)
+ VALUES ('$sid', '$ips[0]', '$ips[1]', '$ips[2]', '$ips[3]', '$discuz_uid', '$discuz_user', '$groupid', '$styleid', '$invisible', '$discuz_action', '$timestamp', '$lastolupdate', '$seccode', '$fid', '$tid', '$bloguid')", 'SILENT');
+ if($discuz_uid && $timestamp - $lastactivity > 21600) {
+ if($oltimespan && $timestamp - $lastactivity > 86400) {
+ $query = $db->query("SELECT total FROM {$tablepre}onlinetime WHERE uid='$discuz_uid'");
+ $oltimeadd = ', oltime='.round(intval($db->result($query, 0)) / 60);
+ } else {
+ $oltimeadd = '';
+ }
+ $db->query("UPDATE {$tablepre}members SET lastip='$onlineip',
lastvisit=lastactivity, lastactivity='$timestamp' $oltimeadd WHERE uid='$discuz_uid'", 'UNBUFFERED');
+ }
+ }
+
+ $sessionupdated = 1;
+}
+
+function updatemodworks($modaction, $posts = 1) {
+ global $modworkstatus, $db, $tablepre, $discuz_uid, $timestamp, $_DCACHE;
+ $today = gmdate('Y-m-d', $timestamp +
$_DCACHE['settings']['timeoffset'] * 3600);
+ if($modworkstatus && $modaction && $posts) {
+ $db->query("UPDATE {$tablepre}modworks SET count=count+1,
posts=posts+'$posts' WHERE uid='$discuz_uid' AND modaction='$modaction'
AND dateline='$today'");
+ if(!$db->affected_rows()) {
+ $db->query("INSERT INTO {$tablepre}modworks (uid, modaction,
dateline, count, posts) VALUES ('$discuz_uid', '$modaction', '$today', 1, '$posts')");
+ }
+ }
+}
+
+function writelog($file, $log) {
+ global $timestamp, $_DCACHE;
+ $yearmonth = gmdate('Ym', $timestamp +
$_DCACHE['settings']['timeoffset'] * 3600);
+ $logdir = DISCUZ_ROOT.'./forumdata/logs/';
+ $logfile = $logdir.$yearmonth.'_'.$file.'.php';
+ if(@filesize($logfile) > 2048000) {
+ $dir = opendir($logdir);
+ $length = strlen($file);
+ $maxid = $id = 0;
+ while($entry = readdir($dir)) {
+ if(strexists($entry, $yearmonth.'_'.$file)) {
+ $id = intval(substr($entry, $length + 8, -4));
+ $id > $maxid && $maxid = $id;
+ }
+ }
+ closedir($dir);
+
+ $logfilebak = $logdir.$yearmonth.'_'.$file.'_'.($maxid + 1).'.php';
+ @rename($logfile, $logfilebak);
+ }
+ if($fp = @fopen($logfile, 'a')) {
+ @flock($fp, 2);
+ $log = is_array($log) ? $log : array($log);
+ foreach($log as $tmp) {
+ fwrite($fp, "<?PHP exit;?>\t".str_replace(array('<?', '?>'), '', $tmp)."\n");
+ }
+ fclose($fp);
+ }
+}
+
+function implodeids($array) {
+ if(!empty($array)) {
+ return "'".implode("','", is_array($array) ? $array : array($array))."'";
+ } else {
+ return '';
+ }
+}
+
+function ajaxshowheader() {
+ global $charset;
+ @header("Expires: -1");
+ @header("Cache-Control: no-store, private, post-check=0, pre-check=0,
max-age=0", FALSE);
+ @header("Pragma: no-cache");
+ header("Content-type: application/xml; charset=$charset");
+ //header('Content-Type: text/html; charset='.$charset);
+ echo "<?xml version=\"1.0\" encoding=\"$charset\"?>\n<root><![CDATA[";
+}
+
+function ajaxshowfooter() {
+ echo ']]></root>';
+}
+
+function ajaxtemplate($tplname) {
+ if(!empty($_GET['inajax'])) {
+ extract($GLOBALS, EXTR_SKIP);
+ updatesession();
+ ajaxshowheader();
+ include template($tplname);
+ ajaxshowfooter();
+ die();
+ }
+}
+
+function wipespecial($str) {
+ return str_replace(array('..', "\n", "\r"), array('', '', ''), $str);
+}
+
+function supe_dbconnect() {
+ global $supe, $db;
+ if(empty($supe['status'])) {
+ return;
+ }
+ if(empty($supe['dbmode'])) {
+ $supe['db'] = $db;
+ } elseif(empty($supe['db'])) {
+ $supe['db'] = new dbstuff;
+ $supe['db']->connect($supe['dbhost'], $supe['dbuser'],
$supe['dbpw'], $supe['dbname'], $supe['pconnect']);
+ }
+}
+?>
\ No newline at end of file

Added: trunk/upload/include/javascript/ajaxtabs.js
==============================================================================
--- (empty file)
+++ trunk/upload/include/javascript/ajaxtabs.js Fri Nov 23 03:26:15 2007
@@ -0,0 +1,130 @@
+var bustcachevar=1 //bust potential caching of external pages after
initial request? (1=yes, 0=no)
+var loadstatustext="<img src='/bbs/images/way/loading.gif' /> <span class='tip_i'>Loading...</span>"
+var enabletabpersistence=1 //enable tab persistence via session only
cookies, so selected tab is remembered (1=yes, 0=no)?
+var loadedobjects=""
+var defaultcontentarray=new Object()
+var bustcacheparameter=""
+
+function ajaxpage(url, containerid, targetobj){
+var page_request = false
+if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
+page_request = new XMLHttpRequest()
+else if (window.ActiveXObject){ // if IE
+try {
+page_request = new ActiveXObject("Msxml2.XMLHTTP")
+}
+catch (e){
+try{
+page_request = new ActiveXObject("Microsoft.XMLHTTP")
+}
+catch (e){}
+}
+}
+else
+return false
+var ullist=targetobj.parentNode.parentNode.getElementsByTagName("li")
+for (var i=0; i<ullist.length; i++)
+ullist[i].className="" //deselect all tabs
+targetobj.parentNode.className="selected" //highlight currently
clicked on tab
+if (url.indexOf("#default")!=-1){ //if simply show default content
within container (verus fetch it via ajax)
+document.getElementById(containerid).innerHTML=defaultcontentarray[containerid]
+return
+}
+document.getElementById(containerid).innerHTML=loadstatustext
+page_request.onreadystatechange=function(){
+loadpage(page_request, containerid)
+}
+if (bustcachevar) //if bust caching of external page
+bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new
Date().getTime() : "?"+new Date().getTime()
+page_request.open('GET', url+bustcacheparameter, true)
+page_request.send(null)
+}
+
+function loadpage(page_request, containerid){
+if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
+document.getElementById(containerid).innerHTML=page_request.responseText
+}
+
+function loadobjs(revattribute){
+if (revattribute!=null && revattribute!=""){ //if "rev" attribute is
defined (load external .js or .css files)
+var objectlist=revattribute.split(/\s*,\s*/) //split the files and
store as array
+for (var i=0; i<objectlist.length; i++){
+var file=objectlist[i]
+var fileref=""
+if (loadedobjects.indexOf(file)==-1){ //Check to see if this object
has not already been added to page before proceeding
+if (file.indexOf(".js")!=-1){ //If object is a js file
+fileref=document.createElement('script')
+fileref.setAttribute("type","text/javascript");
+fileref.setAttribute("src", file);
+}
+else if (file.indexOf(".css")!=-1){ //If object is a css file
+fileref=document.createElement("link")
+fileref.setAttribute("rel", "stylesheet");
+fileref.setAttribute("type", "text/css");
+fileref.setAttribute("href", file);
+}
+}
+if (fileref!=""){
+document.getElementsByTagName("head").item(0).appendChild(fileref)
+loadedobjects+=file+" " //Remember this object as being already added
to page
+}
+}
+}
+}
+
+function expandtab(tabcontentid, tabnumber){ //interface for selecting
a tab (plus expand corresponding content)
+var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
+if (thetab.getAttribute("rel")){
+ajaxpage(thetab.getAttribute("href"), thetab.getAttribute("rel"), thetab)
+loadobjs(thetab.getAttribute("rev"))
+}
+}
+
+function savedefaultcontent(contentid){// save default ajax tab content
+if (typeof defaultcontentarray[contentid]=="undefined") //if default
content hasn't already been saved
+defaultcontentarray[contentid]=document.getElementById(contentid).innerHTML
+}
+
+function startajaxtabs(){
+for (var i=0; i<arguments.length; i++){ //loop through passed UL ids
+var ulobj=document.getElementById(arguments[i])
+var ulist=ulobj.getElementsByTagName("li") //array containing the LI
elements within UL
+var persisttabindex=(enabletabpersistence==1)?
parseInt(getCookie(arguments[i])) : "" //get index of persisted tab (if applicable)
+var isvalidpersist=(persisttabindex<ulist.length)? true : false
//check if persisted tab index falls within range of defined tabs
+for (var x=0; x<ulist.length; x++){ //loop through each LI element
+var ulistlink=ulist[x].getElementsByTagName("a")[0]
+ulistlink.index=x
+if (ulistlink.getAttribute("rel")){
+var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
+ulistlink.setAttribute("href", modifiedurl) //replace URL's root
domain with dynamic root domain, for ajax security sake
+savedefaultcontent(ulistlink.getAttribute("rel")) //save default ajax
tab content
+ulistlink.onclick=function(){
+ajaxpage(this.getAttribute("href"), this.getAttribute("rel"), this)
+loadobjs(this.getAttribute("rev"))
+saveselectedtabindex(this.parentNode.parentNode.id, this.index)
+return false
+}
+if ((enabletabpersistence==1 && persisttabindex<ulist.length &&
x==persisttabindex) || (enabletabpersistence==0 && ulist[x].className=="selected")){
+ajaxpage(ulistlink.getAttribute("href"),
ulistlink.getAttribute("rel"), ulistlink) //auto load currenly selected
tab content
+loadobjs(ulistlink.getAttribute("rev")) //auto load any
accompanying .js and .css files
+}
+}
+}
+}
+}
+
+function saveselectedtabindex(ulid, index){ //remember currently
selected tab (based on order relative to other tabs)
+if (enabletabpersistence==1) //if persistence feature turned on
+setCookie(ulid, index)
+}
+
+function getCookie(Name){
+var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for
target name/value pair
+if (document.cookie.match(re)) //if cookie found
+return document.cookie.match(re)[0].split("=")[1] //return its value
+return ""
+}
+
+function setCookie(name, value){
+document.cookie = name+"="+value //cookie value is domain wide (path=/)
+}
\ No newline at end of file

Added: trunk/upload/include/javascript/common.js
==============================================================================
--- (empty file)
+++ trunk/upload/include/javascript/common.js Fri Nov 23 03:26:15 2007
@@ -0,0 +1,525 @@
+/*
+ [Discuz!] (C)2001-2007 Comsenz Inc.
+ This is NOT a freeware, use is subject to license terms
+
+ $RCSfile: common.js,v $
+ $Revision: 1.41.2.14 $
+ $Date: 2007/03/23 15:31:51 $
+*/
+
+var sPop = null;
+var postSubmited = false;
+var smdiv = new Array();
+
+var userAgent = navigator.userAgent.toLowerCase();
+var is_webtv = userAgent.indexOf('webtv') != -1;
+var is_kon = userAgent.indexOf('konqueror') != -1;
+var is_mac = userAgent.indexOf('mac') != -1;
+var is_saf = userAgent.indexOf('applewebkit') != -1 ||
navigator.vendor == 'Apple Computer, Inc.';
+var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
+var is_moz = (navigator.product == 'Gecko' && !is_saf) &&
userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
+var is_ns = userAgent.indexOf('compatible') == -1 &&
userAgent.indexOf('mozilla') != -1 && !is_opera && !is_webtv && !is_saf;
+var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf
&& !is_webtv) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
+
+function ctlent(event, clickactive) {
+ if(postSubmited == false && (event.ctrlKey && event.keyCode == 13) ||
(event.altKey && event.keyCode == 83) && $('postsubmit')) {
+ if(in_array($('postsubmit').name,
['topicsubmit', 'replysubmit', 'editsubmit', 'pmsubmit'])
&& !validate($('postform'))) {
+ doane(event);
+ return;
+ }
+ postSubmited = true;
+ if(!isUndefined(clickactive) && clickactive) {
+ $('postsubmit').click();
+ $('postsubmit').disabled = true;
+ } else {
+ $('postsubmit').disabled = true;
+ $('postform').submit();
+ }
+ }
+}
+
+function storeCaret(textEl){
+ if(textEl.createTextRange){
+ textEl.caretPos = document.selection.createRange().duplicate();
+ }
+}
+
+function checkall(form, prefix, checkall) {
+ var checkall = checkall ? checkall : 'chkall';
+ for(var i = 0; i < form.elements.length; i++) {
+ var e = form.elements[i];
+ if(e.name != checkall && (!prefix || (prefix &&
e.name.match(prefix)))) {
+ e.checked = form.elements[checkall].checked;
+ }
+ }
+}
+
+function arraypop(a) {
+ if(typeof a != 'object' || !a.length) {
+ return null;
+ } else {
+ var response = a[a.length - 1];
+ a.length--;
+ return response;
+ }
+}
+
+function arraypush(a, value) {
+ a[a.length] = value;
+ return a.length;
+}
+
+
+function findtags(parentobj, tag) {
+ if(!isUndefined(parentobj.getElementsByTagName)) {
+ return parentobj.getElementsByTagName(tag);
+ } else if(parentobj.all && parentobj.all.tags) {
+ return parentobj.all.tags(tag);
+ } else {
+ return null;
+ }
+}
+
+function copycode(obj) {
+ if(is_ie && obj.style.display != 'none') {
+ var rng = document.body.createTextRange();
+ rng.moveToElementText(obj);
+ rng.scrollIntoView();
+ rng.select();
+ rng.execCommand("Copy");
+ rng.collapse(false);
+ }
+}
+
+function attachimg(obj, action, text) {
+ if(action == 'load') {
+ if(obj.width > screen.width * 0.7) {
+ obj.resized = true;
+ obj.width = screen.width * 0.7;
+ obj.alt = text;
+ }
+ obj.onload = null;
+ } else if(action == 'mouseover') {
+ if(obj.resized) {
+ obj.style.cursor = 'pointer';
+ }
+ } else if(action == 'click') {
+ if(!obj.resized) {
+ return false;
+ } else {
+ window.open(text);
+ }
+ }
+}
+
+function attachimginfo(obj, infoobj, show, event) {
+ var left_offset = obj.offsetLeft;
+ var top_offset = obj.offsetTop;
+ var width_offset = obj.offsetWidth;
+ var height_offset = obj.offsetHeight;
+ while ((obj = obj.offsetParent) != null) {
+ left_offset += obj.offsetLeft;
+ top_offset += obj.offsetTop;
+ }
+ if(show) {
+ $(infoobj).style.position = 'absolute';
+ $(infoobj).style.left = left_offset + 3;
+ $(infoobj).style.top = height_offset < 40 ? top_offset +
height_offset : top_offset + 3;
+ $(infoobj).style.display = '';
+ } else {
+ if(is_ie) {
+ $(infoobj).style.display = 'none';
+ return;
+ } else {
+ var mousex = document.body.scrollLeft + event.clientX;
+ var mousey = document.body.scrollTop + event.clientY;
+ if(mousex < left_offset || mousex > left_offset + width_offset ||
mousey < top_offset || mousey > top_offset + height_offset) {
+ $(infoobj).style.display = 'none';
+ }
+ }
+ }
+}
+
+function setcopy(text, alertmsg){
+ if(is_ie) {
+ clipboardData.setData('Text', text);
+ alert(alertmsg);
+ } else {
+ prompt('Please press "Ctrl+C" to copy this text', text);
+ }
+}
+
+function toggle_collapse(objname, unfolded) {
+ if(isUndefined(unfolded)) {
+ var unfolded = 1;
+ }
+ var obj = $(objname);
+ var oldstatus = obj.style.display;
+ var collapsed = getcookie('discuz_collapse');
+ var cookie_start = collapsed ? collapsed.indexOf(objname) : -1;
+ var cookie_end = cookie_start + objname.length + 1;
+
+ obj.style.display = oldstatus == 'none' ? '' : 'none';
+ collapsed = cookie_start != -1 && ((unfolded && oldstatus == 'none') |
| (!unfolded && oldstatus == '')) ?
+ collapsed.substring(0, cookie_start) +
collapsed.substring(cookie_end, collapsed.length) : (
+ cookie_start == -1 && ((unfolded && oldstatus == '') || (!unfolded
&& oldstatus == 'none')) ?
+ collapsed + objname + ' ' : collapsed);
+
+ setcookie('discuz_collapse', collapsed, (collapsed ? 86400 * 30 :
-(86400 * 30 * 1000)));
+
+ if(img = $(objname + '_img')) {
+ var img_regexp = new RegExp((oldstatus == 'none' ? '_yes' : '_no') + '\\.gif$');
+ var img_re = oldstatus == 'none' ? '_no.gif' : '_yes.gif';
+ img.src = img.src.replace(img_regexp, img_re);
+ }
+ if(symbol = $(objname + '_symbol')) {
+ symbol.innerHTML = symbol.innerHTML == '+' ? '-' : '+';
+ }
+}
+
+function imgzoom(o) {
+ if(event.ctrlKey) {
+ var zoom = parseInt(o.style.zoom, 10) || 100;
+ zoom -= event.wheelDelta / 12;
+ if(zoom > 0) {
+ o.style.zoom = zoom + '%';
+ }
+ return false;
+ } else {
+ return true;
+ }
+}
+
+function getcookie(name) {
+ var cookie_start = document.cookie.indexOf(name);
+ var cookie_end = document.cookie.indexOf(";", cookie_start);
+ return cookie_start == -1 ? '' :
unescape(document.cookie.substring(cookie_start + name.length + 1,
(cookie_end > cookie_start ? cookie_end : document.cookie.length)));
+}
+
+function setcookie(cookieName, cookieValue, seconds, path, domain,
secure) {
+ var expires = new Date();
+ expires.setTime(expires.getTime() + seconds);
+ document.cookie = escape(cookieName) + '=' + escape(cookieValue)
+ + (expires ? '; expires=' + expires.toGMTString() : '')
+ + (path ? '; path=' + path : '/')
+ + (domain ? '; domain=' + domain : '')
+ + (secure ? '; secure' : '');
+}
+
+function AddText(txt) {
+ obj = $('postform').message;
+ selection = document.selection;
+ checkFocus();
+ if(!isUndefined(obj.selectionStart)) {
+ var opn = obj.selectionStart + 0;
+ obj.value = obj.value.substr(0, obj.selectionStart) + txt + obj.value.substr(obj.selectionEnd);
+ } else if(selection && selection.createRange) {
+ var sel = selection.createRange();
+ sel.text = txt;
+ sel.moveStart('character', -strlen(txt));
+ } else {
+ obj.value += txt;
+ }
+}
+
+function insertAtCaret(textEl, text){
+ if(textEl.createTextRange && textEl.caretPos){
+ var caretPos = textEl.caretPos;
+ caretPos.text += caretPos.text.charAt(caretPos.text.length - 2)
== ' ' ? text + ' ' : text;
+ } else if(textEl) {
+ textEl.value += text;
+ } else {
+ textEl.value = text;
+ }
+}
+
+function checkFocus() {
+ var obj = typeof wysiwyg == 'undefined' || !wysiwyg ?
$('postform').message : editwin;
+ if(!obj.hasfocus) {
+ obj.focus();
+ }
+}
+
+function setCaretAtEnd() {
+ var obj = typeof wysiwyg == 'undefined' || !wysiwyg ?
$('postform').message : editwin;
+ if(typeof wysiwyg != 'undefined' && wysiwyg) {
+ if(is_moz || is_opera) {
+
+ } else {
+ var sel = editdoc.selection.createRange();
+ sel.moveStart('character', strlen(getEditorContents()));
+ sel.select();
+ }
+ } else {
+ if(obj.createTextRange) {
+ var sel = obj.createTextRange();
+ sel.moveStart('character', strlen(obj.value));
+ sel.collapse();
+ sel.select();
+ }
+ }
+}
+
+function strlen(str) {
+ return (is_ie && str.indexOf('\n') != -1) ?
str.replace(/\r?\n/g, '_').length : str.length;
+}
+
+function mb_strlen(str) {
+ var len = 0;
+ for(var i = 0; i < str.length; i++) {
+ len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset
== 'utf-8' ? 3 : 2) : 1;
+ }
+ return len;
+}
+
+function insertSmiley(smilieid) {
+ checkFocus();
+ var src = $('smilie_' + smilieid).src;
+ var code = $('smilie_' + smilieid).pop;
+ if(typeof wysiwyg != 'undefined' && wysiwyg && allowsmilies &&
(!$('smileyoff') || $('smileyoff').checked == false)) {
+ if(is_moz) {
+ applyFormat('InsertImage', false, src);
+ var smilies = findtags(editdoc.body, 'img');
+ for(var i = 0; i < smilies.length; i++) {
+ if(smilies[i].src == src && smilies[i].getAttribute('smilieid') <
1) {
+ smilies[i].setAttribute('smilieid', smilieid);
+ smilies[i].setAttribute('border', "0");
+ }
+ }
+ } else {
+ insertText('<img src="' + src + '" border="0" smilieid="' +
smilieid + '" alt="" /> ', false);
+ }
+ } else {
+ code += ' ';
+ AddText(code);
+ }
+}
+
+function smileyMenu(ctrl) {
+ ctrl.style.cursor = 'pointer';
+ if(ctrl.alt) {
+ ctrl.pop = ctrl.alt;
+ ctrl.alt = '';
+ }
+ if(ctrl.title) {
+ ctrl.lw = ctrl.title;
+ ctrl.title = '';
+ }
+ if(!smdiv[ctrl.id]) {
+ smdiv[ctrl.id] = document.createElement('div');
+ smdiv[ctrl.id].id = ctrl.id + '_menu';
+ smdiv[ctrl.id].style.display = 'none';
+ smdiv[ctrl.id].className = 'popupmenu_popup';
+ ctrl.parentNode.appendChild(smdiv[ctrl.id]);
+ }
+ smdiv[ctrl.id].innerHTML = '<table style="width: 60px;height:
60px;text-align: center;vertical-align: middle;"
class="altbg2"><tr><td><img src="' + ctrl.src + '" border="0" width="'
+ ctrl.lw + '" /></td></tr></table>';
+ showMenu(ctrl.id, 0, 0, 1, 0);
+}
+
+function announcement() {
+ $('announcement').innerHTML = '<marquee style="margin: 0px 8px"
direction="left" scrollamount="2" scrolldelay="1"
onMouseOver="this.stop();" onMouseOut="this.start();">' +
+ $('announcement').innerHTML + '</marquee>';
+ $('announcement').style.display = 'block';
+}
+
+function $(id) {
+ return document.getElementById(id);
+}
+
+function in_array(needle, haystack) {
+ if(typeof needle == 'string') {
+ for(var i in haystack) {
+ if(haystack[i] == needle) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+function saveData(data, del) {
+ if(!data && isUndefined(del)) {
+ return;
+ }
+ if(typeof wysiwyg != 'undefined' && typeof editorid != 'undefined' &&
typeof bbinsert != 'undefined' && bbinsert && $(editorid + '_mode') &&
$(editorid + '_mode').value == 1) {
+ data = html2bbcode(data);
+ }
+ if(is_ie) {
+ try {
+ var oXMLDoc = textobj.XMLDocument;
+ var root = oXMLDoc.firstChild;
+ if(root.childNodes.length > 0) {
+ root.removeChild(root.firstChild);
+ }
+ var node = oXMLDoc.createNode(1, 'POST', '');
+ var oTimeNow = new Date();
+ oTimeNow.setHours(oTimeNow.getHours() + 24);
+ textobj.expires = oTimeNow.toUTCString();
+ node.setAttribute('message', data);
+ oXMLDoc.documentElement.appendChild(node);
+ textobj.save('Discuz!');
+ } catch(e) {}
+ } else if(window.sessionStorage) {
+ try {
+ sessionStorage.setItem('Discuz!', data);
+ } catch(e) {}
+ }
+}
+
+function loadData() {
+ var message = '';
+ if(is_ie) {
+ try {
+ textobj.load('Discuz!');
+ var oXMLDoc = textobj.XMLDocument;
+ var nodes = oXMLDoc.documentElement.childNodes;
+ message = nodes.item(nodes.length - 1).getAttribute('message');
+ } catch(e) {}
+ } else if(window.sessionStorage) {
+ try {
+ message = sessionStorage.getItem('Discuz!');
+ } catch(e) {}
+ }
+
+ if(in_array((message = trim(message)), ['', 'null', 'false', null,
false])) {
+ alert(lang['post_autosave_none']);
+ return;
+ }
+ if((typeof wysiwyg == 'undefined' || !wysiwyg ? textobj.value :
editdoc.body.innerHTML) == '' ||
confirm(lang['post_autosave_confirm'])) {
+ if(typeof wysiwyg == 'undefined' || !wysiwyg) {
+ textobj.value = message;
+ } else {
+ editdoc.body.innerHTML = bbcode2html(message);
+ }
+ }
+}
+
+function deleteData() {
+ if(is_ie) {
+ saveData('', 'delete');
+ } else if(window.sessionStorage) {
+ try {
+ sessionStorage.removeItem('Discuz!');
+ } catch(e) {}
+ }
+}
+
+function updateseccode(width, height) {
+ $('seccodeimage').innerHTML = '<img id="seccode"
onclick="updateseccode(' + width + ', '+ height + ')" width="' + width
+ '" height="' + height + '" src="seccode.php?update=' + Math.random()
+ '" class="absmiddle" alt="" />';
+}
+
+function signature(obj) {
+ if(obj.style.maxHeightIE != '') {
+ var height = (obj.scrollHeight > parseInt(obj.style.maxHeightIE)) ?
obj.style.maxHeightIE : obj.scrollHeight;
+ if(obj.innerHTML.indexOf('<IMG ') == -1) {
+ obj.style.maxHeightIE = '';
+ }
+ return height;
+ }
+}
+
+function trim(str) {
+ return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
+}
+
+function fetchCheckbox(cbn) {
+ return $(cbn) && $(cbn).checked == true ? 1 : 0;
+}
+
+function parseurl(str, mode) {
+ str = str.replace(/([^>=\]"'\/]|^)((((https?|ftp):\/\/)|
www\.)([\w\-]+\.)*[\w\-\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|
\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!]*)+\.(jpg|
gif|png|bmp))/ig, mode == 'html' ? '$1<img src="$2" border="0">' : '$1[img]$2[/img]');
+ str = str.replace(/([^>=\]"'\/@]|^)((((https?|ftp|gopher|news|telnet|
rtsp|mms|callto|bctp|ed2k):\/\/)|
www\.)([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|
\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|
\/|:)+[\w\.\/=\?%\-&~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1[url]$2[/url]');
+ str = str.replace(/([^\w>=\]:"'\.\/]|
^)(([\-\.\w]+@[\.\-\w]+(\.\w+)+))/ig, mode == 'html' ? '$1<a href="mailto:$2">$2</a>' : '$1[email]$2[/email]');
+ return str;
+}
+
+function isUndefined(variable) {
+ return typeof variable == 'undefined' ? true : false;
+}
+
+function addbookmark(url, site){
+ if(is_ie) {
+ window.external.addFavorite(url, site);
+ } else {
+ alert('Please press "Ctrl+D" to add bookmark');
+ }
+}
+
+function doane(event) {
+ e = event ? event : window.event ;
+ if(is_ie) {
+ e.returnValue = false;
+ e.cancelBubble = true;
+ } else {
+ e.stopPropagation();
+ e.preventDefault();
+ }
+}
+sfHover = function() {
+ var sfEls = document.getElementById("nav_menu").getElementsByTagName("LI");
+ for (var i=0; i<sfEls.length; i++) {
+ sfEls[i].onmouseover=function() {
+ this.className+=" sfhover";
+ }
+ sfEls[i].onmouseout=function() {
+ this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
+ }
+ }
+}
+
+if (window.attachEvent) window.attachEvent("onload", sfHover);
+
+var getObj = function(objId) {
+ return document.all ? document.all[objId] : document.getElementById(objId);
+}
+
+
+function loadXML(url, cb) {
+ req = false;
+ // branch for native XMLHttpRequest object
+ if(window.XMLHttpRequest) {
+ try {
+ req = new XMLHttpRequest();
+ } catch(e) {
+ req = false;
+ }
+ // branch for IE/Windows ActiveX version
+ } else if(window.ActiveXObject) {
+ try {
+ req = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch(e) {
+ try {
+ req = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch(e) {
+ req = false;
+ }
+ }
+ }
+ if(req) {
+ req.onreadystatechange = cb;
+ req.open("GET", url, true);
+ req.send("");
+ }
+}
+
+var switchDisplay = function(objId) {
+ obj = getObj(objId);
+ if (obj.style.display != "block") {
+ obj.style.display = "block";
+ } else {
+ obj.style.display = "none";
+ }
+}
+
+var changeBlockStyle = function(objId, strBgColor) {
+ obj = getObj(objId);
+ obj.bgColor = strBgColor;
+}
+
+function textCounter(field, countfield, maxlimit) {
+if (field.value.length > maxlimit)
+field.value = field.value.substring(0, maxlimit);
+else
+countfield.value = maxlimit - field.value.length;
+}
+

Added: trunk/upload/include/javascript/greybox/AJS.js
==============================================================================
--- (empty file)
+++ trunk/upload/include/javascript/greybox/AJS.js Fri Nov 23 03:26:15 2007
@@ -0,0 +1,525 @@
+AJS={BASE_URL:"",drag_obj:null,drag_elm:null,_drop_zones:[],_cur_pos:null,join:function(_1,_2){
+try{
+return _2.join(_1);
+}
+catch(e){
+var r=_2[0]||"";
+AJS.map(_2,function(_4){
+r+=_1+_4;
+},1);
+return r+"";
+}
+},getScrollTop:function(){
+var t;
+if(document.documentElement&&document.documentElement.scrollTop){
+t=document.documentElement.scrollTop;
+}else{
+if(document.body){
+t=document.body.scrollTop;
+}
+}
+return t;
+},addClass:function(){
+var _6=AJS.forceArray(arguments);
+var _7=_6.pop();
+var _8=function(o){
+if(!new RegExp("(^|\\s)"+_7+"(\\s|$)").test(o.className)){
+o.className+=(o.className?" ":"")+_7;
+}
+};
+AJS.map(_6,function(_a){
+_8(_a);
+});
+},setStyle:function(){
+var _b=AJS.forceArray(arguments);
+var _c=_b.pop();
+var _d=_b.pop();
+AJS.map(_b,function(_e){
+_e.style[_d]=AJS.getCssDim(_c);
+});
+},_getRealScope:function(fn,_10,_11,_12){
+var _13=window;
+_10=AJS.$A(_10);
+if(fn._cscope){
+_13=fn._cscope;
+}
+return function(){
+var _14=[];
+var i=0;
+if(_11){
+i=1;
+}
+AJS.map(arguments,function(arg){
+_14.push(arg);
+},i);
+_14=_14.concat(_10);
+if(_12){
+_14=_14.reverse();
+}
+return fn.apply(_13,_14);
+};
+},preloadImages:function(){
+AJS.AEV(window,"load",AJS.$p(function(_17){
+AJS.map(_17,function(src){
+var pic=new Image();
+pic.src=src;
+});
+},arguments));
+},_createDomShortcuts:function(){
+var _1a=["ul","li","td","tr","th","tbody","table","input","span","b","a","div","img","button","h1","h2","h3","br","textarea","form","p","select","option","iframe","script","center","dl","dt","dd","small","pre"];
+var _1b=function(elm){
+var _1d="return AJS.createDOM.apply(null, ['"+elm+"', arguments]);";
+var _1e="function() { "+_1d+" }";
+eval("AJS."+elm.toUpperCase()+"="+_1e);
+};
+AJS.map(_1a,_1b);
+AJS.TN=function(_1f){
+return document.createTextNode(_1f);
+};
+},documentInsert:function(elm){
+if(typeof (elm)=="string"){
+elm=AJS.HTML2DOM(elm);
+}
+document.write("<span id=\"dummy_holder\"></span>");
+AJS.swapDOM(AJS.$("dummy_holder"),elm);
+},getWindowSize:function(doc){
+doc=doc||document;
+var _22,_23;
+if(self.innerHeight){
+_22=self.innerWidth;
+_23=self.innerHeight;
+}else{
+if(doc.documentElement&&doc.documentElement.clientHeight){
+_22=doc.documentElement.clientWidth;
+_23=doc.documentElement.clientHeight;
+}else{
+if(doc.body){
+_22=doc.body.clientWidth;
+_23=doc.body.clientHeight;
+}
+}
+}
+return {"w":_22,"h":_23};
+},flattenList:function(_24){
+var r=[];
+var _26=function(r,l){
+AJS.map(l,function(o){
+if(o==null){
+}else{
+if(AJS.isArray(o)){
+_26(r,o);
+}else{
+r.push(o);
+}
+}
+});
+};
+_26(r,_24);
+return r;
+},setEventKey:function(e){
+e.key=e.keyCode?e.keyCode:e.charCode;
+if(window.event){
+e.ctrl=window.event.ctrlKey;
+e.shift=window.event.shiftKey;
+}else{
+e.ctrl=e.ctrlKey;
+e.shift=e.shiftKey;
+}
+switch(e.key){
+case 63232:
+e.key=38;
+break;
+case 63233:
+e.key=40;
+break;
+case 63235:
+e.key=39;
+break;
+case 63234:
+e.key=37;
+break;
+}
+},removeElement:function(){
+var _2b=AJS.forceArray(arguments);
+AJS.map(_2b,function(elm){
+AJS.swapDOM(elm,null);
+});
+},_unloadListeners:function(){
+if(AJS.listeners){
+AJS.map(AJS.listeners,function(elm,_2e,fn){
+AJS.REV(elm,_2e,fn);
+});
+}
+AJS.listeners=[];
+},partial:function(fn){
+var _31=AJS.forceArray(arguments);
+return AJS.$b(fn,null,_31.slice(1,_31.length).reverse(),false,true);
+},getIndex:function(elm,_33,_34){
+for(var i=0;i<_33.length;i++){
+if(_34&&_34(_33[i])||elm==_33[i]){
+return i;
+}
+}
+return -1;
+},isDefined:function(o){
+return (o!="undefined"&&o!=null);
+},isArray:function(obj){
+return obj instanceof Array;
+},setLeft:function(){
+var _38=AJS.forceArray(arguments);
+_38.splice(_38.length-1,0,"left");
+AJS.setStyle.apply(null,_38);
+},appendChildNodes:function(elm){
+if(arguments.length>=2){
+AJS.map(arguments,function(n){
+if(AJS.isString(n)){
+n=AJS.TN(n);
+}
+if(AJS.isDefined(n)){
+elm.appendChild(n);
+}
+},1);
+}
+return elm;
+},isOpera:function(){
+return (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
+},isString:function(obj){
+return (typeof obj=="string");
+},hideElement:function(elm){
+var _3d=AJS.forceArray(arguments);
+AJS.map(_3d,function(elm){
+elm.style.display="none";
+});
+},setOpacity:function(elm,p){
+elm.style.opacity=p;
+elm.style.filter="alpha(opacity="+p*100+")";
+},setHeight:function(){
+var _41=AJS.forceArray(arguments);
+_41.splice(_41.

==============================================================================
Diff truncated at 200k characters

Reply all
Reply to author
Forward
0 new messages