Merge remote-tracking branch 'origin' into develop-2.1.x

Conflicts:
	root/portal/includes/functions_upload.php
This commit is contained in:
Marc Alexander
2013-01-09 17:02:41 +01:00
73 changed files with 402 additions and 414 deletions

View File

@@ -61,7 +61,7 @@ function set_portal_config($config_name, $config_value)
}
$portal_config[$config_name] = $config_value;
$cache->destroy('portal_config');
}
@@ -410,7 +410,7 @@ function get_sub_taged_string($message, $bbcode_uid, $length)
{
include($phpbb_root_path . 'includes/trim_message/trim_message.' . $phpEx);
}
if(!class_exists('phpbb_trim_message_bbcodes'))
{
include($phpbb_root_path . 'includes/trim_message/bbcodes.' . $phpEx);
@@ -590,9 +590,9 @@ function sql_table_exists($table_name)
function get_portal_tracking_info($fetch_news)
{
global $config, $user;
$last_read = $topic_ids = $forum_ids = $tracking_info = $rev_forum_ids = array();
/**
* group everything by the forum IDs
*/
@@ -604,15 +604,15 @@ function get_portal_tracking_info($fetch_news)
$forum_ids[] = $fetch_news[$i]['forum_id'];
$rev_forum_ids[$fetch_news[$i]['topic_id']] = $fetch_news[$i]['forum_id']; // the other way round also helps
}
foreach ($tracking_info as $forum_id => $current_forum)
{
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
global $db;
$mark_time = array();
$sql = 'SELECT topic_id, mark_time
FROM ' . TOPICS_TRACK_TABLE . "
WHERE user_id = {$user->data['user_id']}
@@ -703,7 +703,7 @@ function get_portal_tracking_info($fetch_news)
}
}
}
return $last_read;
}
@@ -720,24 +720,24 @@ function get_portal_tracking_info($fetch_news)
function board3_basic_install($mode = 'install', $purge_modules = true, $u_action = '')
{
global $db, $phpbb_root_path, $phpEx, $cache, $user, $table_prefix, $config;
// Shouldn't happen but we should check this nonetheless
if (!defined('PORTAL_MODULES_TABLE'))
{
include($phpbb_root_path . 'portal/includes/constants.' . $phpEx);
}
if ($mode == 'install')
{
$directory = $phpbb_root_path . 'portal/modules/';
if ($purge_modules)
{
$sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE;
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
}
/*
* this is a list of the basic modules that will be installed
* module_name => array(module_column, module_order)
@@ -753,7 +753,7 @@ function board3_basic_install($mode = 'install', $purge_modules = true, $u_actio
'portal_topposters' => array(1, 8),
'portal_latest_members' => array(1, 9),
'portal_link_us' => array(1, 10),
// center column
'portal_welcome' => array(2, 1),
'portal_recent' => array(2, 2),
@@ -761,7 +761,7 @@ function board3_basic_install($mode = 'install', $purge_modules = true, $u_actio
'portal_news' => array(2, 4),
'portal_poll' => array(2, 5),
'portal_whois_online' => array(2, 6),
// right column
'portal_user_menu' => array(3, 1),
'portal_statistics' => array(3, 2),
@@ -770,7 +770,7 @@ function board3_basic_install($mode = 'install', $purge_modules = true, $u_actio
'portal_latest_bots' => array(3, 5),
'portal_links' => array(3, 6),
);
foreach ($modules_ary as $module_name => $module_data)
{
$class_name = $module_name . '_module';
@@ -782,7 +782,7 @@ function board3_basic_install($mode = 'install', $purge_modules = true, $u_actio
{
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
}
$c_class = new $class_name();
$sql_ary = array(
@@ -801,7 +801,7 @@ function board3_basic_install($mode = 'install', $purge_modules = true, $u_actio
$c_class->install($db->sql_nextid());
}
// Make sure we get rid of old data
$cache->destroy('portal_modules');
@@ -824,28 +824,28 @@ function board3_basic_install($mode = 'install', $purge_modules = true, $u_actio
$sql = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE config_name ' . $db->sql_like_expression(utf8_clean_string('board3_') . $db->any_char) . '
AND ' . $db->sql_in_set('config_name', $skip_entries, true);
$db->sql_query($sql);
return $user->lang['PORTAL_BASIC_UNINSTALL'];
}
}
/**
* check if the entered source file actually exists
*/
function check_file_src($value, $key, $module_id, $force_error = true)
{
global $db, $phpbb_root_path, $phpEx, $user;
$error = '';
// We check if the chosen file is present in all active styles
$sql = 'SELECT st.theme_path
FROM ' . STYLES_THEME_TABLE . ' st
LEFT JOIN ' . STYLES_TABLE . ' s
ON (st.theme_id = s.style_id)
WHERE s.style_active = 1';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
@@ -855,7 +855,7 @@ function check_file_src($value, $key, $module_id, $force_error = true)
}
}
$db->sql_freeresult($result);
if (!empty($error))
{
if ($force_error)

View File

@@ -22,7 +22,7 @@ class portal_upload
*/
private $upload_path;
private $u_action;
/*
* constructor function
*/
@@ -37,7 +37,7 @@ class portal_upload
$this->upload_file();
}
}
/**
* upload module zip
*/
@@ -50,7 +50,7 @@ class portal_upload
$upload = new fileupload();
// Only allow ZIP files
$upload->set_allowed_extensions(array('zip'));
$file = $upload->form_upload('modupload');
// this is for module zips so don't allow anything else
@@ -64,7 +64,7 @@ class portal_upload
{
$file->clean_filename('real');
$file->move_file(str_replace($phpbb_root_path, '', $this->upload_path), true, true);
if (!sizeof($file->error))
{
include($phpbb_root_path . 'includes/functions_compress.' . $phpEx);
@@ -86,7 +86,7 @@ class portal_upload
// We need to move that directory then
$this->directory_move($mod_dir . '_tmp/' . $folder_contents[0], $this->upload_path . $folder_contents[0]);
$new_mod_dir = $this->upload_path . $folder_contents[0];
}
else if (!is_dir($mod_dir))
{
@@ -96,24 +96,24 @@ class portal_upload
}
$this->directory_delete($mod_dir . '_tmp/');
// make sure we set $mod_dir to the correct folder after the above step
$mod_dir = (isset($new_mod_dir)) ? $new_mod_dir : $mod_dir;
// if we got until here set $actions['NEW_FILES']
$actions['NEW_FILES'] = array();
// Now we need to get the files inside the folders
//$folder_contents = $this->cut_folder(scandir($mod_dir));
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($mod_dir, FilesystemIterator::SKIP_DOTS)); // requires PHP 5
foreach($iterator as $cur_file)
{
$cur_path = $cur_file->getPathname();
$cur_path = str_replace('\\', '/', $cur_path); // we want unix-like paths
$cur_path = str_replace($mod_dir . '/', '', $cur_path);
$cut_pos = strpos($cur_path, '/');
// Only allow files in adm, language, portal and styles folder and a license.txt
if(!in_array(substr($cur_path, 0, $cut_pos), array('adm', 'language', 'portal', 'styles')) && $cur_file->getFilename() != 'license.txt')
{
@@ -154,7 +154,7 @@ class portal_upload
'TARGET' => $target,
));
}
$template->assign_vars(array(
'S_MOD_SUCCESSBOX' => true,
'MESSAGE' => $user->lang['MODULE_UPLOADED'],
@@ -170,10 +170,10 @@ class portal_upload
{
trigger_error((sizeof($file->error) ? implode('<br />', $file->error) : $user->lang['MOD_UPLOAD_INIT_FAIL']) . adm_back_link($this->u_action), E_USER_WARNING);
}
$this->tpl_name = 'portal/acp_portal_upload_module';
$this->page_title = $user->lang['ACP_PORTAL_UPLOAD'];
$template->assign_vars(array(
'L_TITLE' => $user->lang['ACP_PORTAL_UPLOAD'],
'L_TITLE_EXPLAIN' => '',
@@ -185,7 +185,7 @@ class portal_upload
));
}
}
/**
* Cuts the unneeded '.' and '..' from the folder content info scandir returns
*
@@ -195,19 +195,19 @@ class portal_upload
{
$cut_array = array('.', '..');
$folder_content = array_diff($folder_content, $cut_array);
return $folder_content;
}
private function directory_move($src, $dest)
{
$src_contents = scandir($src);
if (!is_dir($dest) && is_dir($src))
{
mkdir($dest . '/', 0755);
}
foreach ($src_contents as $src_entry)
{
if ($src_entry != '.' && $src_entry != '..')
@@ -224,26 +224,26 @@ class portal_upload
}
}
}
/**
* the following functions are from the AutoMOD package
* @copyright (c) 2008 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
private function directory_delete($dir)
{
if (!file_exists($dir))
{
return true;
}
if (!is_dir($dir) && is_file($dir))
{
phpbb_chmod($dir, CHMOD_ALL);
return unlink($dir);
}
foreach (scandir($dir) as $item)
{
if ($item == '.' || $item == '..')
@@ -259,10 +259,10 @@ class portal_upload
}
}
}
return @rmdir($dir);
}
/**
* Moves files or complete directories
*
@@ -297,7 +297,7 @@ class portal_upload
return sprintf($user->lang['MODULE_UPLOAD_MKDIR_FAILURE'], $dirname_check);
}
}
// leave a backup file if it already exists
if(file_exists($to))
{
@@ -319,7 +319,7 @@ class portal_upload
return true;
}
/**
* @author Michal Nazarewicz (from the php manual)
* Creates all non-existant directories in a path