aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_language.php16
-rw-r--r--phpBB/includes/acp/acp_styles.php16
-rw-r--r--phpBB/includes/bbcode.php16
-rw-r--r--phpBB/includes/functions_compress.php23
-rw-r--r--phpBB/includes/functions_display.php4
-rw-r--r--phpBB/includes/functions_template.php5
6 files changed, 35 insertions, 45 deletions
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index 0949311ae7..7bf8563440 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -479,7 +479,7 @@ class acp_language
{
if ($is_email_file)
{
- $lang = implode('', file($phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, $file_from_store)));
+ $lang = file_get_contents($phpbb_root_path . $this->get_filename($lang_iso, $this->language_directory, $this->language_file, $file_from_store));
}
else
{
@@ -627,9 +627,9 @@ class acp_language
$db->sql_freeresult($result);
$use_method = request_var('use_method', '');
- $methods = array('tar');
+ $methods = array('.tar');
- $available_methods = array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib');
+ $available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib');
foreach ($available_methods as $type => $module)
{
if (!@extension_loaded($module))
@@ -640,11 +640,6 @@ class acp_language
$methods[] = $type;
}
- if (!in_array($use_method, $methods))
- {
- $use_method = 'tar';
- }
-
// Let the user decide in which format he wants to have the pack
if (!$use_method)
{
@@ -666,6 +661,11 @@ class acp_language
return;
}
+ if (!in_array($use_method, $methods))
+ {
+ $use_method = '.tar';
+ }
+
include_once($phpbb_root_path . 'includes/functions_compress.' . $phpEx);
if ($use_method == 'zip')
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index a4dae97559..72cc82ee4b 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -768,23 +768,23 @@ pagination_sep = \'{PAGINATION_SEP}\'
switch ($format)
{
case 'tar':
- $ext = 'tar';
+ $ext = '.tar';
$mimetype = 'x-tar';
$compress = 'compress_tar';
break;
case 'zip':
- $ext = 'zip';
+ $ext = '.zip';
$mimetype = 'zip';
break;
case 'tar.gz':
- $ext = 'tar.gz';
+ $ext = '.tar.gz';
$mimetype = 'x-gzip';
break;
case 'tar.bz2':
- $ext = 'tar.bz2';
+ $ext = '.tar.bz2';
$mimetype = 'x-bzip2';
break;
@@ -800,11 +800,11 @@ pagination_sep = \'{PAGINATION_SEP}\'
if ($format == 'zip')
{
- $compress = new compress_zip('w', $phpbb_root_path . "store/$path.$ext");
+ $compress = new compress_zip('w', $phpbb_root_path . "store/$path$ext");
}
else
{
- $compress = new compress_tar('w', $phpbb_root_path . "store/$path.$ext", $ext);
+ $compress = new compress_tar('w', $phpbb_root_path . "store/$path$ext", $ext);
}
if (sizeof($files))
@@ -830,11 +830,11 @@ pagination_sep = \'{PAGINATION_SEP}\'
if (!$store)
{
$compress->download($path);
- @unlink("{$phpbb_root_path}store/$path.$ext");
+ @unlink("{$phpbb_root_path}store/$path$ext");
exit;
}
- trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$path.$ext") . adm_back_link($this->u_action));
+ trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$path$ext") . adm_back_link($this->u_action));
}
}
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index ab0d742ede..a030151ac3 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -342,12 +342,10 @@ class bbcode
if (empty($this->bbcode_template))
{
- if (!($fp = @fopen($this->template_filename, 'rb')))
+ if (($tpl = file_get_contents($this->template_filename)) === false)
{
trigger_error('Could not load bbcode template');
}
- $tpl = fread($fp, filesize($this->template_filename));
- @fclose($fp);
// replace \ with \\ and then ' with \'.
$tpl = str_replace('\\', '\\\\', $tpl);
@@ -355,12 +353,16 @@ class bbcode
// strip newlines and indent
$tpl = preg_replace("/\n[\n\r\s\t]*/", '', $tpl);
-
+
// Turn template blocks into PHP assignment statements for the values of $bbcode_tpl..
- $tpl = preg_replace('#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#', "\n" . "\$this->bbcode_template['\$1'] = \$this->bbcode_tpl_replace('\$1','\$2');", $tpl);
-
$this->bbcode_template = array();
- eval($tpl);
+
+ $matches = preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END (?:.*?) -->#', $tpl, $match);
+
+ for ($i = 0; $i < $matches - 1; $i++)
+ {
+ $this->bbcode_template[$match[1][$i]] = $this->bbcode_tpl_replace($match[1][$i], $match[2][$i]);
+ }
}
return (isset($this->bbcode_template[$tpl_name])) ? $this->bbcode_template[$tpl_name] : ((isset($bbcode_hardtpl[$tpl_name])) ? $bbcode_hardtpl[$tpl_name] : false);
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index 55457bc226..4443292182 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -31,15 +31,7 @@ class compress
if (is_file($phpbb_root_path . $src))
{
- if (!($fp = @fopen("$phpbb_root_path$src", 'rb')))
- {
- return false;
- }
-
- $data = fread($fp, filesize("$phpbb_root_path$src"));
- fclose($fp);
-
- $this->data($src_path, $data, false, stat("$phpbb_root_path$src"));
+ $this->data($src_path, file_get_contents("$phpbb_root_path$src"), false, stat("$phpbb_root_path$src"));
}
else if (is_dir($phpbb_root_path . $src))
{
@@ -73,7 +65,7 @@ class compress
continue;
}
- $this->data("$src_path$path$file", implode('', file("$phpbb_root_path$src$path$file")), false, stat("$phpbb_root_path$src$path$file"));
+ $this->data("$src_path$path$file", file_get_contents("$phpbb_root_path$src$path$file"), false, stat("$phpbb_root_path$src$path$file"));
}
}
@@ -99,8 +91,8 @@ class compress
function methods()
{
- $methods = array('tar');
- $available_methods = array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib');
+ $methods = array('.tar');
+ $available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib');
foreach ($available_methods as $type => $module)
{
@@ -314,8 +306,7 @@ class compress_zip extends compress
$name = str_replace('\\', '/', $name);
$dtime = dechex($this->unix_to_dos_time($stat[9]));
- $hexdtime = '\x' . $dtime[6] . $dtime[7] . '\x' . $dtime[4] . $dtime[5] . '\x' . $dtime[2] . $dtime[3] . '\x' . $dtime[0] . $dtime[1];
- eval('$hexdtime = "' . $hexdtime . '";');
+ $hexdtime = pack('H*', $dtime[6] . $dtime[7] . $dtime[4] . $dtime[5] . $dtime[2] . $dtime[3] . $dtime[0] . $dtime[1]);
if ($is_dir)
{
@@ -563,11 +554,11 @@ class compress_tar extends compress
function close()
{
- $fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && extension_loaded('zlib')) ? 'gzwrite' : 'fwrite');
$fzclose = ($this->isbz && function_exists('bzclose')) ? 'bzclose' : (($this->isgz && extension_loaded('zlib')) ? 'gzclose' : 'fclose');
- if ($this->wrote)
+ if ($this->wrote)
{
+ $fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && extension_loaded('zlib')) ? 'gzwrite' : 'fwrite');
$fzwrite($this->fp, pack("a1024", ""));
}
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 15f48e10b4..647fb0f972 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -675,12 +675,10 @@ function display_attachments($forum_id, $blockname, &$attachment_data, &$update_
$attachment_tpl = array();
$template_filename = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template/attachment.html';
- if (!($fp = @fopen($template_filename, 'rb')))
+ if (($attachment_template = file_get_contents($template_filename)) === false)
{
trigger_error('Could not load template file "' . $template_filename . '"');
}
- $attachment_template = fread($fp, filesize($template_filename));
- @fclose($fp);
// replace \ with \\ and then ' with \'.
$attachment_template = str_replace('\\', '\\\\', $attachment_template);
diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php
index 429346b7a4..88ea84d41d 100644
--- a/phpBB/includes/functions_template.php
+++ b/phpBB/includes/functions_template.php
@@ -44,13 +44,12 @@ class template_compile
function _tpl_load_file($handle)
{
// Try and open template for read
- if (!($fp = @fopen($this->template->files[$handle], 'r')))
+ if (!file_exists($this->template->files[$handle]))
{
trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR);
}
- $this->template->compiled_code[$handle] = $this->compile(trim(@fread($fp, filesize($this->template->files[$handle]))));
- @fclose($fp);
+ $this->template->compiled_code[$handle] = $this->compile(trim(@file_get_contents($this->template->files[$handle])));
// Actually compile the code now.
$this->compile_write($handle, $this->template->compiled_code[$handle]);