issue 846 add case http resource import

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9801 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2011-11-07 01:16:04 +00:00
parent 21f3aee7f4
commit 82a1c530f8
2 changed files with 59 additions and 11 deletions

View file

@ -24,23 +24,55 @@
*/
function procImporterAdminCheckXmlFile() {
$filename = Context::get('filename');
$realPath = FileHandler::getRealPath($filename);
$isExists = 'false';
if(file_exists($realPath) && is_file($realPath)) $isExists = 'true';
$this->add('exists', $isExists);
if($isExists == 'true')
if(preg_match('/^http/i', $filename))
{
$type = 'XML';
if(ini_get('allow_url_fopen'))
{
$fp = @fopen($filename, "r");
if($fp)
{
$str = fgets($fp, 100);
if(strlen($str) > 0)
{
$isExists = 'true';
$type = 'XML';
if(stristr($str, 'tattertools')) $type = 'TTXML';
$fp = fopen($realPath, "r");
$str = fgets($fp, 100);
if(stristr($str, 'tattertools')) $type = 'TTXML';
fclose($fp);
$this->add('type', $type);
}
fclose($fp);
$resultMessage = $lang->found_xml_file;
}
else $resultMessage = $lang->cannot_url_file;
}
else $resultMessage = $lang->cannot_allow_fopen_in_phpini;
$this->add('type', $type);
$this->add('exists', $isExists);
}
else
{
$realPath = FileHandler::getRealPath($filename);
if(file_exists($realPath) && is_file($realPath)) $isExists = 'true';
$this->add('exists', $isExists);
if($isExists == 'true')
{
$type = 'XML';
$fp = fopen($realPath, "r");
$str = fgets($fp, 100);
if(stristr($str, 'tattertools')) $type = 'TTXML';
fclose($fp);
$this->add('type', $type);
$resultMessage = $lang->found_xml_file;
}
else $resultMessage = $lang->not_found_xml_file;
}
$this->add('result_message', $resultMessage);
}
/**

View file

@ -354,6 +354,22 @@ Hãy nhập đường dẫn cho File chứa Data trên Host dưới dạng http:
<value xml:lang="tr"><![CDATA[Lütfen senkronizasyonu başlatmak için Senkronizasyon düğmesine basınız.]]></value>
<value xml:lang="vi"><![CDATA[Data thành viên và bài viết sẽ được đồng bộ hóa sau khi bấm "Đồng bộ".]]></value>
</item>
<item name="found_xml_file">
<value xml:lang="ko"><![CDATA[XML 파일을 찾았습니다.]]></value>
<value xml:lang="en"><![CDATA[found XML file]]></value>
</item>
<item name="not_found_xml_file">
<value xml:lang="ko"><![CDATA[XML 파일을 찾을 수 없습니다.]]></value>
<value xml:lang="en"><![CDATA[Can not found XML file]]></value>
</item>
<item name="cannot_allow_fopen_in_phpini">
<value xml:lang="ko"><![CDATA[php.ini 환경설정에서 원격지의 파일을 열지 못하도록 되어 있습니다.]]></value>
<value xml:lang="en"><![CDATA[Can not found XML file]]></value>
</item>
<item name="cannot_url_file">
<value xml:lang="ko"><![CDATA[원격지의 파일을 열지 못하였습니다.]]></value>
<value xml:lang="en"><![CDATA[Can not found XML file]]></value>
</item>
<item name="cmd_check_path">
<value xml:lang="ko"><![CDATA[경로 확인]]></value>
<value xml:lang="en"><![CDATA[Check the path]]></value>