aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions.php30
-rw-r--r--phpBB/includes/functions_admin.php6
-rw-r--r--phpBB/includes/functions_posting.php10
-rw-r--r--phpBB/includes/functions_upload.php71
-rw-r--r--phpBB/includes/session.php19
5 files changed, 120 insertions, 16 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 4c749eb354..d5accb90cf 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1117,6 +1117,36 @@ function obtain_attach_extensions(&$extensions, $forum_id = false)
}
/**
+* Obtain active bots
+*/
+function obtain_bots(&$bots)
+{
+ global $db, $cache;
+
+ if ($cache->exists('bots'))
+ {
+ $bots = $cache->get('bots');
+ }
+ else
+ {
+ $sql = 'SELECT user_id, bot_agent, bot_ip
+ FROM ' . BOTS_TABLE . '
+ WHERE bot_active = 1';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $bots[] = $row;
+ }
+ $db->sql_freeresult($result);
+
+ $cache->put('bots', $bots);
+ }
+
+ return;
+}
+
+/**
* Generate board url
*/
function generate_board_url()
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index ee97ffdc76..989d34a287 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -1492,9 +1492,9 @@ function remove_comments(&$output)
$linecount = sizeof($lines);
$in_comment = false;
- for($i = 0; $i < $linecount; $i++)
+ for ($i = 0; $i < $linecount; $i++)
{
- if (preg_match('#^\/\*#', preg_quote($lines[$i])))
+ if (trim($lines[$i]) == '/*')
{
$in_comment = true;
}
@@ -1504,7 +1504,7 @@ function remove_comments(&$output)
$output .= $lines[$i] . "\n";
}
- if (preg_match('#\*\/$#', preg_quote($lines[$i])))
+ if (trim($lines[$i]) == '*/')
{
$in_comment = false;
}
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index b53492a5a7..e1055cd5f8 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -148,10 +148,18 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
include_once($phpbb_root_path . 'includes/functions_upload.php');
$upload = new fileupload();
- $filedata['post_attach'] = ($upload->is_valid($form_name)) ? true : false;
+ if (!$local)
+ {
+ $filedata['post_attach'] = ($upload->is_valid($form_name)) ? true : false;
+ }
+ else
+ {
+ $filedata['post_attach'] = true;
+ }
if (!$filedata['post_attach'])
{
+ $filedata['error'][] = 'No filedata found';
return $filedata;
}
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index 250b948c7d..28041c87fa 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -56,6 +56,12 @@ class filespec
// Opera adds the name to the mime type
$this->mimetype = (strpos($this->mimetype, '; name') !== false) ? str_replace(strstr($this->mimetype, '; name'), '', $this->mimetype) : $this->mimetype;
+
+ if (!$this->mimetype)
+ {
+ $this->mimetype = 'application/octetstream';
+ }
+
$this->extension = array_pop(explode('.', strtolower($this->realname)));
// Try to get real filesize from temporary folder (not always working) ;)
@@ -122,7 +128,12 @@ class filespec
function is_uploaded()
{
- return (file_exists($this->filename) && is_uploaded_file($this->filename)) ? true : false;
+ if (!$this->local && !is_uploaded_file($this->filename))
+ {
+ return false;
+ }
+
+ return (file_exists($this->filename)) ? true : false;
}
function remove()
@@ -394,8 +405,64 @@ class fileupload
}
// Move file from another location to phpBB
- function local_upload($source_file)
+ function local_upload($source_file, $filedata = false)
{
+ global $user;
+
+ $form_name = 'local';
+
+ $_FILES[$form_name]['local_mode'] = true;
+ $_FILES[$form_name]['tmp_name'] = $source_file;
+
+ if ($filedata === false)
+ {
+ $_FILES[$form_name]['name'] = basename($source_file);
+ $_FILES[$form_name]['size'] = 0;
+ $_FILES[$form_name]['type'] = '';
+ }
+ else
+ {
+ $_FILES[$form_name]['name'] = $filedata['realname'];
+ $_FILES[$form_name]['size'] = $filedata['size'];
+ $_FILES[$form_name]['type'] = $filedata['type'];
+ }
+
+ $file = new filespec($_FILES[$form_name], $this);
+
+ if ($file->init_error)
+ {
+ $file->error[] = '';
+ return $file;
+ }
+
+ if (isset($_FILES[$form_name]['error']))
+ {
+ $error = $this->assign_internal_error($_FILES[$form_name]['error']);
+
+ if ($error !== false)
+ {
+ $file->error[] = $error;
+ return $file;
+ }
+ }
+
+ // PHP Upload filesize exceeded
+ if ($file->get('filename') == 'none')
+ {
+ $file->error[] = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
+ return $file;
+ }
+
+ // Not correctly uploaded
+ if (!$file->is_uploaded())
+ {
+ $file->error[] = $user->lang[$this->error_prefix . 'NOT_UPLOADED'];
+ return $file;
+ }
+
+ $this->common_checks($file);
+
+ return $file;
}
/**
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 768f1dddd1..c85fa7a393 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -138,12 +138,10 @@ class session
$bot = false;
// Pull bot information from DB and loop through it
- $sql = 'SELECT user_id, bot_agent, bot_ip
- FROM ' . BOTS_TABLE . '
- WHERE bot_active = 1';
- $result = $db->sql_query($sql);
+ $active_bots = array();
+ obtain_bots($active_bots);
- while ($row = $db->sql_fetchrow($result))
+ foreach ($active_bots as $row)
{
if ($row['bot_agent'] && preg_match('#' . preg_quote($row['bot_agent'], '#') . '#i', $this->browser))
{
@@ -168,7 +166,6 @@ class session
break;
}
}
- $db->sql_freeresult($result);
// Garbage collection ... remove old sessions updating user information
// if necessary. It means (potentially) 11 queries but only infrequently
@@ -586,7 +583,7 @@ class user extends session
$style = ($style) ? $style : ((!$config['override_user_style'] && $this->data['user_id'] != ANONYMOUS) ? $this->data['user_style'] : $config['default_style']);
}
- // TODO: DISTINCT making problems with DBMS not able to distinct TEXT fields
+ // TODO: DISTINCT making problems with DBMS not able to distinct TEXT fields, test grouping
switch (SQL_LAYER)
{
case 'mssql':
@@ -596,16 +593,18 @@ class user extends session
WHERE s.style_id IN ($style, " . $config['default_style'] . ')
AND t.template_id = s.template_id
AND c.theme_id = s.theme_id
- AND i.imageset_id = s.imageset_id';
+ AND i.imageset_id = s.imageset_id
+ GROUP BY s.style_id';
break;
default:
- $sql = 'SELECT DISTINCT s.style_id, t.*, c.*, i.*
+ $sql = 'SELECT s.style_id, t.*, c.*, i.*
FROM ' . STYLES_TABLE . ' s, ' . STYLES_TPL_TABLE . ' t, ' . STYLES_CSS_TABLE . ' c, ' . STYLES_IMAGE_TABLE . " i
WHERE s.style_id IN ($style, " . $config['default_style'] . ')
AND t.template_id = s.template_id
AND c.theme_id = s.theme_id
- AND i.imageset_id = s.imageset_id';
+ AND i.imageset_id = s.imageset_id
+ GROUP BY s.style_id';
break;
}
$result = $db->sql_query($sql, 3600);