Skip to content

Commit

Permalink
Merge branch 'hotfix/1.8.27' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bnu committed Oct 28, 2016
2 parents ab322cc + 92073d0 commit 3e0455a
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 37 deletions.
124 changes: 91 additions & 33 deletions addons/blogapi/blogapi.addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@
$category_list = $oDocumentModel->getCategoryList($this->module_srl);

// Specifies a temporary file storage
$tmp_uploaded_path = sprintf(_XE_PATH_ . 'files/cache/blogapi/%s/%s/', $this->mid, $user_id);
$uploaded_target_path = sprintf(_XE_PATH_ . 'files/cache/blogapi/%s/%s/', $this->mid, $user_id);
$logged_info = Context::get('logged_info');
$mediaPath = sprintf('files/cache/blogapi/%s/%s/', $this->mid, $logged_info->member_srl);
$mediaAbsPath = _XE_PATH_ . $mediaPath;
$mediaUrlPath = Context::getRequestUri() . $mediaPath;

switch($method_name)
{
Expand Down Expand Up @@ -167,22 +169,56 @@
foreach($fileinfo as $key => $val)
{
$nodename = (string)$val->name;
if($nodename == 'bits')
if($nodename === 'bits')
{
$filedata = base64_decode((string)$val->value->base64);
elseif($nodename == 'name')
$filename = (string)$val->value->string;
}
else if($nodename === 'name')
{
$filename = pathinfo((string)$val->value->string, PATHINFO_BASENAME);
}
}

$tmp_arr = explode('/', $filename);
$filename = array_pop($tmp_arr);
if($logged_info->is_admin != 'Y')
{
// check file type
if(isset($file_module_config->allowed_filetypes) && $file_module_config->allowed_filetypes !== '*.*')
{
$filetypes = explode(';', $file_module_config->allowed_filetypes);
$ext = array();

foreach($filetypes as $item)
{
$item = explode('.', $item);
$ext[] = strtolower(array_pop($item));
}

$uploaded_ext = explode('.', $filename);
$uploaded_ext = strtolower(array_pop($uploaded_ext));

FileHandler::makeDir($tmp_uploaded_path);
if(!in_array($uploaded_ext, $ext))
{
printContent(getXmlRpcFailure(1, 'Not allowed file type'));
break;
}
}

$allowed_filesize = $file_module_config->allowed_filesize * 1024 * 1024;
if($allowed_filesize < strlen($filedata))
{
printContent(getXmlRpcFailure(1, 'This file exceeds the attachment limit'));
break;
}
}

$target_filename = sprintf('%s%s', $tmp_uploaded_path, $filename);
$temp_filename = Password::createSecureSalt(12, 'alnum');
$target_filename = sprintf('%s%s', $mediaAbsPath, $temp_filename);
FileHandler::makeDir($mediaAbsPath);
FileHandler::writeFile($target_filename, $filedata);
$obj = new stdClass();
$obj->url = Context::getRequestUri() . $target_filename;
FileHandler::writeFile($target_filename . '_source_filename', $filename);

$obj = new stdClass();
$obj->url = Context::getRequestUri() . $mediaPath . $temp_filename;
$content = getXmlRpcResponse($obj);
printContent($content);
break;
Expand Down Expand Up @@ -291,21 +327,34 @@
$obj->module_srl = $this->module_srl;

// Attachment
if(is_dir($tmp_uploaded_path))
if(is_dir($mediaAbsPath))
{
$file_list = FileHandler::readDir($tmp_uploaded_path);
$file_list = FileHandler::readDir($mediaAbsPath, '/(_source_filename)$/is');
$file_count = count($file_list);
if($file_count)
{
$oFileController = getController('file');
for($i = 0; $i < $file_count; $i++)
$oFileModel = getModel('file');
foreach($file_list as $file)
{
$file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]);
$file_info['name'] = $file_list[$i];
$filename = FileHandler::readFile($mediaAbsPath . $file);
$temp_filename = str_replace('_source_filename', '', $file);

$file_info = array();
$file_info['tmp_name'] = sprintf('%s%s', $mediaAbsPath, $temp_filename);
$file_info['name'] = $filename;
$fileOutput = $oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true);
$uploaded_filename = $fileOutput->get('uploaded_filename');
$source_filename = $fileOutput->get('source_filename');
$obj->content = str_replace($uploaded_target_path . $source_filename, sprintf('/files/attach/images/%s/%s%s', $this->module_srl, getNumberingPath($document_srl, 3), $uploaded_filename), $obj->content);

if($fileOutput->get('direct_download') === 'N')
{
$replace_url = Context::getRequestUri() . $oFileModel->getDownloadUrl($fileOutput->file_srl, $fileOutput->sid, $this->module_srl);
}
else
{
$replace_url = Context::getRequestUri() . $fileOutput->get('uploaded_filename');
}

$obj->content = str_replace($mediaUrlPath . $temp_filename, $replace_url, $obj->content);
}
$obj->uploaded_count = $file_count;
}
Expand All @@ -332,7 +381,7 @@
{
$content = getXmlRpcResponse(strval($document_srl));
}
FileHandler::removeDir($tmp_uploaded_path);
FileHandler::removeDir($mediaAbsPath);

printContent($content);
break;
Expand Down Expand Up @@ -404,27 +453,36 @@
// Document srl
$obj->document_srl = $document_srl;
$obj->module_srl = $this->module_srl;

// Attachment
if(is_dir($tmp_uploaded_path))
if(is_dir($mediaAbsPath))
{
$file_list = FileHandler::readDir($tmp_uploaded_path);
$file_list = FileHandler::readDir($mediaAbsPath, '/(_source_filename)$/is');
$file_count = count($file_list);
if($file_count)
{
$oFileController = getController('file');
for($i = 0; $i < $file_count; $i++)
$oFileModel = getModel('file');
foreach($file_list as $file)
{
$file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]);
$file_info['name'] = $file_list[$i];

$moved_filename = sprintf('./files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $file_info['name']);
if(file_exists($moved_filename))
continue;
$filename = FileHandler::readFile($mediaAbsPath . $file);
$temp_filename = str_replace('_source_filename', '', $file);

$file_info = array();
$file_info['tmp_name'] = sprintf('%s%s', $mediaAbsPath, $temp_filename);
$file_info['name'] = $filename;
$fileOutput = $oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true);
$uploaded_filename = $fileOutput->get('uploaded_filename');
$source_filename = $fileOutput->get('source_filename');
$obj->content = str_replace($uploaded_target_path . $source_filename, sprintf('/files/attach/images/%s/%s%s', $this->module_srl, getNumberingPath($document_srl, 3), $uploaded_filename), $obj->content);

if($fileOutput->get('direct_download') === 'N')
{
$replace_url = Context::getRequestUri() . $oFileModel->getDownloadUrl($fileOutput->file_srl, $fileOutput->sid, $this->module_srl);
}
else
{
$replace_url = Context::getRequestUri() . $fileOutput->get('uploaded_filename');
}

$obj->content = str_replace($mediaUrlPath . $temp_filename, $replace_url, $obj->content);
}
$obj->uploaded_count += $file_count;
}
Expand All @@ -440,7 +498,7 @@
else
{
$content = getXmlRpcResponse(true);
FileHandler::removeDir($tmp_uploaded_path);
FileHandler::removeDir($mediaAbsPath);
}

printContent($content);
Expand Down
2 changes: 1 addition & 1 deletion config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* Display XE's full version.
*/
define('__XE_VERSION__', '1.8.26');
define('__XE_VERSION__', '1.8.27');
define('__XE_VERSION_ALPHA__', (stripos(__XE_VERSION__, 'alpha') !== false));
define('__XE_VERSION_BETA__', (stripos(__XE_VERSION__, 'beta') !== false));
define('__XE_VERSION_RC__', (stripos(__XE_VERSION__, 'rc') !== false));
Expand Down
1 change: 1 addition & 0 deletions modules/member/member.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,7 @@ function putSignature($member_srl, $signature)
{
$signature = trim(removeHackTag($signature));
$signature = preg_replace('/<(\/?)(embed|object|param)/is', '&lt;$1$2', $signature);
$signature = removeHackTag($signature);

$check_signature = trim(str_replace(array('&nbsp;',"\n","\r"),'',strip_tags($signature,'<img><object>')));
$path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($member_srl));
Expand Down
2 changes: 1 addition & 1 deletion modules/member/member.model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ function getSignature($member_srl)
{
$buff = FileHandler::readFile($filename);
$signature = preg_replace('/<\?.*\?>/', '', $buff);
$GLOBALS['__member_info__']['signature'][$member_srl] = $signature;
$GLOBALS['__member_info__']['signature'][$member_srl] = removeHackTag($signature);
}
else $GLOBALS['__member_info__']['signature'][$member_srl] = null;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Install/AutoinstallCept.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$db_config = $config['modules']['config']['Db'];

$dsn = $db_config['dsn'];
$dsn = split('[;:]', $dsn);
$dsn = preg_split('/[;:]/', $dsn);
$db_type = array_shift($dsn);
$dbinfo = [
'type' => $db_type,
Expand Down
2 changes: 1 addition & 1 deletion tests/Install/InstallCept.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$db_config = $config['modules']['config']['Db'];

$dsn = $db_config['dsn'];
$dsn = split('[;:]', $dsn);
$dsn = preg_split('/[;:]/', $dsn);
$db_type = array_shift($dsn);
$dbinfo = [
'type' => $db_type,
Expand Down

0 comments on commit 3e0455a

Please sign in to comment.