aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2003-01-07 14:37:19 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2003-01-07 14:37:19 +0000
commit7bdb2816f9855a1675c25b152e3c0cadd9ee57ae (patch)
treea281bb78eb14a6efd36df7d077b23aff27bec6c1 /phpBB/includes
parentb369a1e43cdeb9edeee8b4c86fbc395c7bb5d202 (diff)
downloadforums-7bdb2816f9855a1675c25b152e3c0cadd9ee57ae.tar
forums-7bdb2816f9855a1675c25b152e3c0cadd9ee57ae.tar.gz
forums-7bdb2816f9855a1675c25b152e3c0cadd9ee57ae.tar.bz2
forums-7bdb2816f9855a1675c25b152e3c0cadd9ee57ae.tar.xz
forums-7bdb2816f9855a1675c25b152e3c0cadd9ee57ae.zip
Various updates
git-svn-id: file:///svn/phpbb/trunk@3262 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions.php199
-rw-r--r--phpBB/includes/functions_posting.php13
-rw-r--r--phpBB/includes/session.php2
3 files changed, 62 insertions, 152 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index aefef930f2..50d495f6b8 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -453,110 +453,95 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat
return;
}
-
// Marks a topic or form as read in the 'lastread' table.
-function markread($mode, $forum_id=0, $topic_id=0, $post_id=0)
+function markread($mode, $forum_id = 0, $topic_id = 0, $post_id = 0)
{
- global $db;
- global $user;
-
- $user_id = $user->data['user_id'];
- if( $user_id == ANONYMOUS)
+ global $db, $user;
+
+ if ($user->data['user_id'] == ANONYMOUS)
{
return;
}
- switch($mode)
+ switch ($mode)
{
case 'mark':
// Mark one forum as read.
// Do this by inserting a record with -$forum_id in the 'forum_id' field.
$sql = "SELECT forum_id
- FROM ".LASTREAD_TABLE."
- WHERE
- user_id = $user_id
+ FROM " . LASTREAD_TABLE . "
+ WHERE user_id = " . $user->data['user_id'] . "
AND forum_id = -$forum_id";
- if( !($result = $db->sql_query($sql)) )
- {
- trigger_error('Could not select marked read data.');
- }
- if( $db->sql_numrows($result) > 0 )
+ $result = $db->sql_query($sql);
+
+ if ($db->sql_fetchrow($result))
{
// User has marked this topic as read before: Update the record
- $sql = "UPDATE LOW_PRIORITY ".LASTREAD_TABLE."
- SET lastread_time = UNIX_TIMESTAMP()
- WHERE
- user_id = $user_id
+ $sql = "UPDATE " . LASTREAD_TABLE . "
+ SET lastread_time = " . time() . "
+ WHERE user_id = " . $user->data['user_id'] . "
AND forum_id = -$forum_id";
- if( !($result = $db->sql_query($sql)) )
- {
- trigger_error('Could not update marked read data.');
- }
+ $db->sql_query($sql);
}
else
{
// User is marking this forum for the first time.
// Insert dummy topic_id to satisfy PRIMARY KEY (user_id, topic_id)
// dummy id = -forum_id
- $sql = "INSERT DELAYED INTO ".LASTREAD_TABLE."
+ $sql = "INSERT INTO " . LASTREAD_TABLE . "
(user_id, forum_id, topic_id, lastread_time)
VALUES
- ($user_id, -$forum_id, -$forum_id, UNIX_TIMESTAMP() )";
- if( !($result = $db->sql_query($sql)) )
- {
- trigger_error('Could not insert marked read data.');
- }
+ (" . $user->data['user_id'] . ", -$forum_id, -$forum_id, " . time() . ")";
+ $db->sql_query($sql);
}
break;
+
case 'markall':
// Mark all forums as read.
// Select all forum_id's that are not yet in the lastread table
$sql = "SELECT f.forum_id
- FROM ".FORUMS_TABLE." f
- LEFT JOIN ".LASTREAD_TABLE." lr ON (
- lr.user_id = $user_id
- AND f.forum_id = -lr.forum_id)
+ FROM " . FORUMS_TABLE . " f
+ LEFT JOIN (" . LASTREAD_TABLE . " lr ON (
+ lr.user_id = " . $user->data['user_id'] . "
+ AND f.forum_id = -lr.forum_id))
WHERE lr.forum_id IS NULL";
- if( !($result = $db->sql_query($sql)) )
- {
- trigger_error('Could not join lastread and forums table.');
- }
- if( $db->sql_numrows($result) > 0)
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
{
- // Some forum_id's are missing
- // We are not taking into account the auth data, even forums the user can't see are marked as read.
- $sql = "INSERT DELAYED INTO ".LASTREAD_TABLE."
+ // Some forum_id's are missing. We are not taking into account
+ // the auth data, even forums the user can't see are marked as read.
+ $sql = "INSERT INTO " . LASTREAD_TABLE . "
(user_id, forum_id, topic_id, lastread_time)
VALUES\n";
$forum_insert = array();
- while($row = $db->sql_fetchrow($result))
+
+ do
{
// Insert dummy topic_id to satisfy PRIMARY KEY
// dummy id = -forum_id
- $forum_insert[] = "($user_id, -".$row['forum_id'].", -".$row['forum_id'].", UNIX_TIMESTAMP())";
+ $forum_insert[] = "(" . $user->data['user_id'] . ", -".$row['forum_id'].", -".$row['forum_id'].", " . time() . ")";
}
+ while ($row = $db->sql_fetchrow($result));
+
$forum_insert = implode(",\n", $forum_insert);
$sql .= $forum_insert;
- // Insert all missing forum id's
- if( !($result = $db->sql_query($sql)) )
- {
- trigger_error('Could not insert forum rows in lastread table.');
- }
+
+ $db->sql_query($sql);
}
+
// Mark all forums as read
- $sql = "UPDATE LOW_PRIORITY ".LASTREAD_TABLE."
- SET lastread_time = UNIX_TIMESTAMP()
- WHERE
- user_id = $user_id
+ $sql = "UPDATE " . LASTREAD_TABLE . "
+ SET lastread_time = " . time() . "
+ WHERE user_id = " . $user->data['user_id'] . "
AND forum_id < 0";
- if( !($result = $db->sql_query($sql)) )
- {
- trigger_error('Could not update forum_id rows in lastread table.');
- }
+ $db->sql_query($sql);
break;
+
case 'post':
// Mark a topic as read and mark it as a topic where the user has made a post.
$type = 1;
+
case 'topic':
// Mark a topic as read.
@@ -564,19 +549,13 @@ function markread($mode, $forum_id=0, $topic_id=0, $post_id=0)
// 0 = Normal topic
// 1 = user made a post in this topic
$type_update = (isset($type) && $type = 1) ? 'lastread_type = 1,' : '';
- $sql = "UPDATE LOW_PRIORITY ".LASTREAD_TABLE."
- SET
- $type_update
- forum_id = $forum_id,
- lastread_time = UNIX_TIMESTAMP()
- WHERE
- topic_id = $topic_id
- AND user_id = $user_id";
- if( !($result = $db->sql_query($sql)) )
- {
- trigger_error('Could not update forum_id rows in lastread table.');
- }
- else if ($db->sql_affectedrows($result) == 0)
+ $sql = "UPDATE " . LASTREAD_TABLE . "
+ SET $type_update forum_id = $forum_id, lastread_time = " . time() . "
+ WHERE topic_id = $topic_id
+ AND user_id = " . $user->data['user_id'];
+ $db->sql_query($sql);
+
+ if ($db->sql_affectedrows($result) == 0)
{
// Couldn't update. Row probably doesn't exist. Insert one.
if(isset($type) && $type = 1)
@@ -589,14 +568,12 @@ function markread($mode, $forum_id=0, $topic_id=0, $post_id=0)
$type_name = '';
$type_value = '';
}
- $sql = "INSERT DELAYED INTO ".LASTREAD_TABLE."
+
+ $sql = "INSERT INTO " . LASTREAD_TABLE . "
(user_id, topic_id, forum_id, $type_name lastread_time)
VALUES
- ($user_id, $topic_id, $forum_id, $type_value UNIX_TIMESTAMP())";
- if( !($result = $db->sql_query($sql)) )
- {
- trigger_error('Could not update or insert row in lastread table.');
- }
+ (" . $user->data['user_id'] . ", $topic_id, $forum_id, $type_value " . time() . ")";
+ $db->sql_query($sql);
}
break;
}
@@ -847,76 +824,6 @@ function validate_optional_fields(&$icq, &$aim, &$msnm, &$yim, &$website, &$loca
return;
}
-// This is general replacement for die(), allows templated output in users (or default)
-// language, etc. $msg_code can be one of these constants:
-//
-// -> MESSAGE : Use for any simple text message, eg. results of an operation, authorisation
-// failures, etc.
-// -> ERROR : Use for any error, a simple page will be output
-function message_die($msg_code, $msg_text = '', $msg_title = '')
-{
- global $db, $auth, $template, $config, $user, $nav_links;
- global $phpEx, $phpbb_root_path, $starttime;
-
- switch ($msg_code)
- {
- case MESSAGE:
- $msg_title = ($msg_title == '') ? $user->lang['Information'] : $msg_title;
- $msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text;
-
- if (!defined('HEADER_INC'))
- {
- if (empty($user->lang))
- {
- echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="admin/subSilver.css" type="text/css"><style type="text/css">th { background-image: url(\'admin/images/cellpic3.gif\') } td.cat { background-image: url(\'admin/images/cellpic1.gif\') }</style><title>' . $msg_title . '</title></html>' . "\n";
- echo '<body><table width="100%" height="100%" border="0"><tr><td align="center" valign="middle"><table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0"><tr><th>' . $msg_title . '</th></tr><tr><td class="row1" align="center">' . $msg_text . '</td></tr></table></td></tr></table></body></html>';
- $db->sql_close();
- exit;
- }
- else if (defined('IN_ADMIN'))
- {
- page_header('', '', false);
- }
- else
- {
- include($phpbb_root_path . 'includes/page_header.' . $phpEx);
- }
- }
-
- if (defined('IN_ADMIN'))
- {
- page_message($msg_title, $msg_text, $display_header);
- page_footer();
- }
- else
- {
- $template->set_filenames(array(
- 'body' => 'message_body.html')
- );
-
- $template->assign_vars(array(
- 'MESSAGE_TITLE' => $msg_title,
- 'MESSAGE_TEXT' => $msg_text)
- );
-
- include($phpbb_root_path . 'includes/page_tail.' . $phpEx);
- }
-
- break;
-
- case ERROR:
- $db->sql_close();
-
- echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8869-1"><meta http-equiv="Content-Style-Type" content="text/css"><link rel="stylesheet" href="../admin/subSilver.css" type="text/css"><style type="text/css">';
- echo 'th { background-image: url(\'../admin/images/cellpic3.gif\') }';
- echo 'td.cat { background-image: url(\'../admin/images/cellpic1.gif\') }';
- echo '</style><title>' . $msg_title . '</title></head><body><table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td colspan="2" height="25" align="right" nowrap="nowrap"><span class="subtitle">&#0187; <i>' . $msg_title . '</i></span> &nbsp;&nbsp;</td></tr></table><table width="95%" cellspacing="0" cellpadding="0" border="0" align="center"><tr><td><br clear="all" />' . $msg_text . '</td></tr></table><br clear="all" /></body></html>';
- break;
- }
-
- exit;
-}
-
// Error and message handler, call with trigger_error if reqd
function msg_handler($errno, $msg_text, $errfile, $errline)
{
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index a198b1dcf8..325c796b77 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -41,7 +41,7 @@ class parse_message
$match[] = "#([\r\n][\s]+){3,}#";
$replace[] = "\n\n";
- $message = preg_replace($match, $replace, $message);
+ $message = trim(preg_replace($match, $replace, $message));
// Message length check
if (!strlen($message) || ($config['max_post_chars'] && strlen($message) > intval($config['max_post_chars'])))
@@ -135,12 +135,12 @@ class parse_message
$replace[] = '<!-- l --><a href="\1" target="_blank">\1</a><!-- l -->';
// matches a xxxx://aaaaa.bbb.cccc. ...
- $match[] = '#(^|[\n ])([\w]+?://[\w\?&\#,\.\+\-!~\/=%]+)#ie';
- $replace[] = "'\\1<!-- m --><a href=\"\\2\" target=\"_blank\">' . ( ( strlen('\\2') > 55 ) ?substr('\\2', 0, 39) . ' ... ' . substr('\\2', -10) : '\\2' ) . '</a><!-- m -->'";
+ $match[] = '#(^|[\n ])([\w]+?://.*?[^\t\n\r<"]*)#ie';
+ $replace[] = "'\\1<!-- m --><a href=\"\\2\" target=\"_blank\">' . ( ( strlen(str_replace(' ', '%20', '\\2')) > 55 ) ?substr(str_replace(' ', '%20', '\\2'), 0, 39) . ' ... ' . substr(str_replace(' ', '%20', '\\2'), -10) : str_replace(' ', '%20', '\\2') ) . '</a><!-- m -->'";
// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
- $match[] = '#(^|[\n ])(www\.[\w\-]+\.[\w\-.\~]+(?:/[^\t\n\r <"\']*)?)#ie';
- $replace[] = "'\\1<!-- w --><a href=\"http://\\2\" target=\"_blank\">' . ( ( strlen('\\2') > 55 ) ?substr('\\2', 0, 39) . ' ... ' . substr('\\2', -10) : '\\2' ) . '</a><!-- w -->'";
+ $match[] = '#(^|[\n ])(www\.[\w\-]+\.[\w\-.\~]+(?:/[^\t\n\r<"]*)?)#ie';
+ $replace[] = "'\\1<!-- w --><a href=\"http://\\2\" target=\"_blank\">' . ( ( strlen(str_replace(' ', '%20', '\\2')) > 55 ) ? substr(str_replace(' ', '%20', '\\2'), 0, 39) . ' ... ' . substr(str_replace(' ', '%20', '\\2'), -10) : str_replace(' ', '%20', '\\2') ) . '</a><!-- w -->'";
// matches an email@domain type address at the start of a line, or after a space.
$match[] = '#(^|[\n ])([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)#ie';
@@ -179,8 +179,9 @@ class parse_message
global $config;
$allowed_ext = explode(',', $config['attach_ext']);
- }
+
+ }
}
// Parses a given message and updates/maintains the fulltext tables
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index d32aceafa8..7def737c02 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -43,6 +43,7 @@ class session
$sessiondata = ( isset($_COOKIE[$config['cookie_name'] . '_data']) ) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_data'])) : '';
$this->session_id = ( isset($_COOKIE[$config['cookie_name'] . '_sid']) ) ? $_COOKIE[$config['cookie_name'] . '_sid'] : '';
$SID = (defined('IN_ADMIN')) ? '?sid=' . $this->session_id : '?sid=';
+// $SID = (defined('ADD_SID')) ? '?sid=' . $this->session_id : '?sid=';
}
else
{
@@ -408,6 +409,7 @@ class user extends session
include($this->lang_path . '/' . $lang_set . '.' . $phpEx);
}
*/
+
// Set up style
$style = ($style) ? $style : ((!$config['override_user_style'] && $this->data['user_id'] != ANONYMOUS) ? $this->data['user_style'] : $config['default_style']);