mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
Move mod_rewrite detection to the client side
This commit is contained in:
parent
86bd1b531d
commit
43098721b1
5 changed files with 55 additions and 57 deletions
|
|
@ -452,52 +452,6 @@ class installController extends install
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check this server can use rewrite module
|
||||
* make a file to files/config and check url approach by ".htaccess" rules
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function checkRewriteUsable() {
|
||||
$checkString = "isApproached";
|
||||
$checkFilePath = 'files/config/tmpRewriteCheck.txt';
|
||||
|
||||
FileHandler::writeFile(_XE_PATH_.$checkFilePath, trim($checkString));
|
||||
|
||||
$scheme = ($_SERVER['HTTPS'] === 'on') ? 'https' : 'http';
|
||||
$hostname = $_SERVER['SERVER_NAME'];
|
||||
$port = $_SERVER['SERVER_PORT'];
|
||||
$str_port = '';
|
||||
if($port)
|
||||
{
|
||||
$str_port = ':' . $port;
|
||||
}
|
||||
|
||||
$tmpPath = $_SERVER['DOCUMENT_ROOT'];
|
||||
|
||||
//if DIRECTORY_SEPARATOR is not /(IIS)
|
||||
if(DIRECTORY_SEPARATOR !== '/')
|
||||
{
|
||||
//change to slash for compare
|
||||
$tmpPath = str_replace(DIRECTORY_SEPARATOR, '/', $_SERVER['DOCUMENT_ROOT']);
|
||||
}
|
||||
|
||||
$query = "/JUST/CHECK/REWRITE/" . $checkFilePath;
|
||||
$currentPath = str_replace($tmpPath, "", _XE_PATH_);
|
||||
if($currentPath != "")
|
||||
{
|
||||
$query = $currentPath . $query;
|
||||
}
|
||||
$requestUrl = sprintf('%s://%s%s%s', $scheme, $hostname, $str_port, $query);
|
||||
$requestConfig = array();
|
||||
$requestConfig['ssl_verify_peer'] = false;
|
||||
$buff = FileHandler::getRemoteResource($requestUrl, null, 3, 'GET', null, array(), array(), array(), $requestConfig);
|
||||
|
||||
FileHandler::removeFile(_XE_PATH_.$checkFilePath);
|
||||
|
||||
return (trim($buff) == $checkString);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create files and subdirectories
|
||||
* Local evironment setting before installation by using DB information
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@
|
|||
*/
|
||||
class installView extends install
|
||||
{
|
||||
var $install_enable = false;
|
||||
public $install_enable = false;
|
||||
|
||||
public static $rewriteCheckFilePath = 'files/cache/tmpRewriteCheck.txt';
|
||||
public static $rewriteCheckString = '';
|
||||
|
||||
/**
|
||||
* @brief Initialization
|
||||
|
|
@ -97,12 +100,11 @@ class installView extends install
|
|||
function dispInstallCheckEnv()
|
||||
{
|
||||
$oInstallController = getController('install');
|
||||
$useRewrite = $oInstallController->checkRewriteUsable() ? 'Y' : 'N';
|
||||
$_SESSION['use_rewrite'] = $useRewrite;
|
||||
Context::set('use_rewrite', $useRewrite);
|
||||
|
||||
// nginx 체크, rewrite 사용법 안내
|
||||
if($useRewrite == 'N' && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) Context::set('use_nginx', 'Y');
|
||||
|
||||
self::$rewriteCheckString = Password::createSecureSalt(32);
|
||||
FileHandler::writeFile(_XE_PATH_ . self::$rewriteCheckFilePath, self::$rewriteCheckString);;
|
||||
Context::set('use_rewrite', $_SESSION['use_rewrite'] = 'N');
|
||||
Context::set('use_nginx', stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false);
|
||||
|
||||
$this->setTemplateFile('check_env');
|
||||
}
|
||||
|
|
@ -114,6 +116,16 @@ class installView extends install
|
|||
{
|
||||
// Display check_env if it is not installable
|
||||
if(!$this->install_enable) return $this->dispInstallCheckEnv();
|
||||
|
||||
// Delete mod_rewrite check file
|
||||
FileHandler::removeFile(_XE_PATH_ . self::$rewriteCheckFilePath);
|
||||
|
||||
// Save mod_rewrite check status
|
||||
if(Context::get('rewrite') === 'Y')
|
||||
{
|
||||
Context::set('use_rewrite', $_SESSION['use_rewrite'] = 'Y');
|
||||
}
|
||||
|
||||
// Enter ftp information
|
||||
if(ini_get('safe_mode') && !Context::isFTPRegisted())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -722,6 +722,11 @@
|
|||
<value xml:lang="tr"><![CDATA[Eğer websunucusu yenidenyazma(rewritemod) destekliyorsa, http://ornek/?dosya_no=123 gibi URLler http://ornek/123 olarak kısaltılabilir]]></value>
|
||||
<value xml:lang="vi"><![CDATA[Nếu Host của bạn hỗ trợ Mod Rewrite, khi địa chỉ có dạng <b>http://blah/?document_srl=123</b> sẽ được rút ngắn thành <b>http://blah/123</b>]]></value>
|
||||
</item>
|
||||
<item name="checking_rewrite">
|
||||
<value xml:lang="ko"><![CDATA[짧은 주소를 사용할 수 있는지 확인하는 중입니다...]]></value>
|
||||
<value xml:lang="en"><![CDATA[Checking whether "Friendly URL" feature is available...]]></value>
|
||||
<value xml:lang="jp"><![CDATA[短縮アドレスを使用できるかどうかを確認しています...]]></value>
|
||||
</item>
|
||||
<item name="disable_rewrite">
|
||||
<value xml:lang="ko"><![CDATA[짧은 주소를 사용할 수 없습니다. 웹 서버 담당자에게 mod_rewrite 지원 여부를 확인 바랍니다.]]></value>
|
||||
<value xml:lang="en"><![CDATA["Friendly URL" feature is not available. Please check with the server administrator about mod_rewrite module support.]]></value>
|
||||
|
|
|
|||
|
|
@ -29,12 +29,17 @@
|
|||
</block>
|
||||
<tr>
|
||||
<td class="check_env_item">mod_rewrite</td>
|
||||
<td class="check_env_status">
|
||||
<span cond="$use_rewrite === 'Y'" class="ok">OK</span>
|
||||
<span cond="$use_rewrite === 'N'">—</span>
|
||||
<td class="check_env_status" id="mod_write_status">
|
||||
<span class="ok" style="display:none">OK</span>
|
||||
<span class="no">—</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr cond="$use_rewrite === 'N'">
|
||||
<tr id="mod_rewrite_checking" data-url="{Context::getRequestUri()}REWRITE/CHECK/SRSLY/ANYTHING/GOES/{InstallView::$rewriteCheckFilePath}" data-verify="{InstallView::$rewriteCheckString}">
|
||||
<td colspan="2" class="error_description">
|
||||
{$lang->checking_rewrite}
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="mod_rewrite_no_support" style="display:none">
|
||||
<td colspan="2" class="error_description">
|
||||
{$lang->disable_rewrite}
|
||||
<block cond="$use_nginx == 'Y'"><br />{$lang->about_nginx_rewrite}</block>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,28 @@ jQuery(function($){
|
|||
$("p.db_type_" + $(this).val()).show();
|
||||
}).triggerHandler("click");
|
||||
}
|
||||
if($("#mod_rewrite_checking").size()) {
|
||||
var checking = $("#mod_rewrite_checking");
|
||||
$.ajax({
|
||||
url: checking.data("url"),
|
||||
cache : false,
|
||||
dataType: "text",
|
||||
success: function(data) {
|
||||
if($.trim(data) === checking.data("verify")) {
|
||||
$("#mod_write_status span.ok").show();
|
||||
$("#mod_write_status span.no").hide();
|
||||
$("#task-checklist-confirm").attr("href", $("#task-checklist-confirm").attr("href") + "&rewrite=Y");
|
||||
} else {
|
||||
$("#mod_rewrite_no_support").show();
|
||||
}
|
||||
checking.hide();
|
||||
},
|
||||
error: function() {
|
||||
$("#mod_rewrite_no_support").show();
|
||||
checking.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
if($("input[name='user_id']").size() && $("input[name='email_address']").size()) {
|
||||
var user_id_input = $("input[name='user_id']");
|
||||
var email_input = $("input[name='email_address']");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue