Merge pull request '「Cloudflare経由または不使用の場合に正しく利用者のIPアドレスを取得出来るように分岐を設定」「いくつかの機能を管理画面にてオプションとして選択できるように変更」' (#35) from konkon-fox/delightly-v2fork:main into main

Reviewed-on: #35
This commit is contained in:
統計部員2 2023-10-25 05:39:30 +09:00
commit 7f5563f96d
4 changed files with 75 additions and 31 deletions

0
test/.use_cloudflare Normal file
View File

View File

@ -10,7 +10,9 @@ if (getenv('SKIP_VERIFICATION')) {
$FORCESSL = false;
}
$NOWTIME = time();
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
if (file_exists(__DIR__ . '/.use_cloudflare') && isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$HOST = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$area = [];
$area["district"] = $area['proxy'] = $area['hosting'] = $area['regionName'] = $area['city'] = $area['countryCode'] = $area['mobile'] = $area["asname"] = '';

View File

@ -13,8 +13,19 @@ if (!isset($_SERVER['HTTP_SEC_CH_UA_ARCH'])) $_SERVER['HTTP_SEC_CH_UA_ARCH'] = '
if (!isset($_SERVER['HTTP_SEC_CH_UA_MODEL'])) $_SERVER['HTTP_SEC_CH_UA_MODEL'] = '';
if (!isset($_SERVER['HTTP_SEC_CH_UA_MOBILE'])) $_SERVER['HTTP_SEC_CH_UA_MOBILE'] = '';
if (!isset($_SERVER['HTTP_SEC_CH_UA_FULL_VERSION_LIST'])) $_SERVER['HTTP_SEC_CH_UA_FULL_VERSION_LIST'] = '';
$DATE = date("Y/m/d H:i:s", $NOWTIME);
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
if(isset($SETTING['date_comma_digit']) && $SETTING['date_comma_digit'] !== '0'){
$NOWMICROTIME= microtime(true);
$microTime = $NOWMICROTIME - floor($NOWMICROTIME);
$commaDigit = (int) $SETTING['date_comma_digit'];
$commaTime = floor($microTime * pow(10, $commaDigit));
$commaTime = sprintf('%0'.$commaDigit.'d', $commaTime);
$DATE = date("Y/m/d H:i:s", $NOWMICROTIME).'.'.$commaTime;
}else{
$DATE = date("Y/m/d H:i:s", $NOWTIME);
}
if (file_exists(__DIR__ . '/.use_cloudflare') && isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$HOST = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$subjectfile = $PATH."subject.json"; //スレッド一覧
$LTLFILE = $PATH."index.json"; //ローカルタイムライン
@ -468,10 +479,11 @@ elseif ($SETTING['id'] == "siberia"){
$ID = "発信元:".$_SERVER['REMOTE_ADDR'];
}
elseif ($SETTING['id']){
if(isset($SETTING['id_9th_char']) && $SETTING['id_9th_char'] === 'checked'){
$rawID .= substr(hash('sha256', $IP_ADDR.md5($IP_ADDR)), 2, 1);
}
$ID = "ID:".$rawID;
}
// 最後の1文字は飛行機で変わるので不要
// if (!$CAPID && $SETTING['id'] != "siberia" && $SETTING['id']) $ID .= substr(hash('sha256', $IP_ADDR.md5($IP_ADDR)), 2, 1);
// 未ログイン時で本文が半角文字のみ
if ($SETTING['unauthorized_half_check'] == "checked" && strlen($_POST['comment']) == mb_strlen($_POST['comment'],"UTF-8") && !$authorized) DispError("この掲示板・スレッドでは未承認ユーザでの日本語を含まない投稿が禁止されています");
@ -480,32 +492,34 @@ if ($SETTING['unauthorized_half_check'] == "checked" && strlen($_POST['comment']
$_POST['comment'] = str_replace('>>',' >>',$_POST['comment']);
//レス表示用の装飾
// 折りたたみ・要約
$_POST['comment'] = str_replace('&lt;details&gt;','<details>',$_POST['comment']);
$_POST['comment'] = str_replace('&lt;/details&gt;','</details>',$_POST['comment']);
$_POST['comment'] = str_replace('&lt;summary&gt;','<summary>',$_POST['comment']);
$_POST['comment'] = str_replace('&lt;/summary&gt;','</summary>',$_POST['comment']);
// 返信
$_POST['comment'] = preg_replace('/&gt;(No\.[0-9]+?)(<br>|\s|$)/','<a class="reply" href="javascript:IdClick(\'$1\')">&gt;$1</a>',$_POST['comment']);
// 引用
$_POST['comment'] = preg_replace('/(<br>|^)&gt;(.*?)(<br>|$)/','$1<div class="quote">&gt;$2</div>$3',$_POST['comment']);
$_POST['comment'] = preg_replace('/(<br>|^)(.*?)(<br>|$)/','$1<font color="gray">$2</font>$3',$_POST['comment']);
// 太字&斜体
$_POST['comment'] = preg_replace('/\*\*\*(.*?)\*\*\*/','<em><strong>$1</strong></em>',$_POST['comment']);
// 太字
$_POST['comment'] = preg_replace('/\*\*(.*?)\*\*/','<strong>$1</strong>',$_POST['comment']);
// 斜体
//$_POST['comment'] = preg_replace('/\*(.*?)\*/','<em>$1</em>',$_POST['comment']);
// 取り消し線
$_POST['comment'] = preg_replace('/~~(.*?)~~/','<del>$1</del>',$_POST['comment']);
// 目立たなくする
//$_POST['comment'] = preg_replace('/\^(.*?)\^/','<small style="opacity: 0.7;">$1</small>',$_POST['comment']);
// ぼかし
//$_POST['comment'] = preg_replace('/{(.*?)}/','<span class="_mfm_blur_">$1</span>',$_POST['comment']);
// マーカー
$_POST['comment'] = preg_replace('/==(.*?)==/','<mark>$1</mark>',$_POST['comment']);
// 下線
$_POST['comment'] = preg_replace('/\+\+(.*?)\+\+/','<ins>$1</ins>',$_POST['comment']);
if(isset($SETTING['res_decoration']) && $SETTING['res_decoration'] === 'checked'){
// 折りたたみ・要約
$_POST['comment'] = str_replace('&lt;details&gt;','<details>',$_POST['comment']);
$_POST['comment'] = str_replace('&lt;/details&gt;','</details>',$_POST['comment']);
$_POST['comment'] = str_replace('&lt;summary&gt;','<summary>',$_POST['comment']);
$_POST['comment'] = str_replace('&lt;/summary&gt;','</summary>',$_POST['comment']);
// 返信
$_POST['comment'] = preg_replace('/&gt;(No\.[0-9]+?)(<br>|\s|$)/','<a class="reply" href="javascript:IdClick(\'$1\')">&gt;$1</a>',$_POST['comment']);
// 引用
$_POST['comment'] = preg_replace('/(<br>|^)&gt;(.*?)(<br>|$)/','$1<div class="quote">&gt;$2</div>$3',$_POST['comment']);
$_POST['comment'] = preg_replace('/(<br>|^)(.*?)(<br>|$)/','$1<font color="gray">$2</font>$3',$_POST['comment']);
// 太字&斜体
$_POST['comment'] = preg_replace('/\*\*\*(.*?)\*\*\*/','<em><strong>$1</strong></em>',$_POST['comment']);
// 太字
$_POST['comment'] = preg_replace('/\*\*(.*?)\*\*/','<strong>$1</strong>',$_POST['comment']);
// 斜体
$_POST['comment'] = preg_replace('/\*(.*?)\*/','<em>$1</em>',$_POST['comment']);
// 取り消し線
$_POST['comment'] = preg_replace('/~~(.*?)~~/','<del>$1</del>',$_POST['comment']);
// 目立たなくする
$_POST['comment'] = preg_replace('/\^(.*?)\^/','<small style="opacity: 0.7;">$1</small>',$_POST['comment']);
// ぼかし
$_POST['comment'] = preg_replace('/{(.*?)}/','<span class="_mfm_blur_">$1</span>',$_POST['comment']);
// マーカー
$_POST['comment'] = preg_replace('/==(.*?)==/','<mark>$1</mark>',$_POST['comment']);
// 下線
$_POST['comment'] = preg_replace('/\+\+(.*?)\+\+/','<ins>$1</ins>',$_POST['comment']);
}
// アイコン
if ($_POST['icon'] == "on" && $_COOKIE['icon'] && $SETTING['DISABLE_ICON'] != "checked") {

View File

@ -23,10 +23,24 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['edit'] == "yes") {
if (!isset($_POST['disable_kakolog'])) $_POST['disable_kakolog'] = '';
if (!isset($_POST['thread_supervisor'])) $_POST['thread_supervisor'] = '';
if (!isset($_POST['aa_check'])) $_POST['aa_check'] = '';
$extraSettingsList = [
'id_9th_char',
'res_decoration',
'date_comma_digit'
];
foreach ($SETTING as $name => $value) {
if(in_array($name, $extraSettingsList, true)) continue;
if (isset($_POST[$name])) $SETTING[$name] = $_POST[$name];
$SET .= $name."=".$SETTING[$name]."\n";
}
foreach ($extraSettingsList as $settingName) {
if(isset($_POST[$settingName])){
$SETTING[$settingName] = $_POST[$settingName];
}else{
$SETTING[$settingName] = '';
}
if(isset($SETTING[$settingName])) $SET .= $settingName."=".$SETTING[$settingName]."\n";
}
file_put_contents($setfile, json_encode($SETTING, JSON_UNESCAPED_UNICODE), LOCK_EX);
file_put_contents($settxt, mb_convert_encoding($SET, "SJIS-win", "UTF-8"), LOCK_EX);
}
@ -87,6 +101,20 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['edit'] == "yes") {
<div><input type="radio" name="commands" value="checked"<?php if ($SETTING['commands'] == "checked") echo " checked"; ?>>有効<input type="radio" name="commands" value=""<?php if (!$SETTING['commands']) echo " checked"; ?>>無効</div>
<div><b>投稿最大ログ保存件数</b><small class="notice mt5">無記入の場合は上限なし</small></div>
<div><input type="text" value="<?=$SETTING['LOG_LIMIT']?>" name="LOG_LIMIT"></div>
<!-- 以降新規追加設定 -->
<div><b>9桁目のIDを有効にする</b></div>
<div><input type="checkbox" value="checked" name="id_9th_char"<?php if (isset($SETTING['id_9th_char']) && $SETTING['id_9th_char']=="checked") echo " checked"; ?>>する</div>
<div><b>レスの装飾機能を有効にする</b></div>
<div><input type="checkbox" value="checked" name="res_decoration"<?php if (isset($SETTING['res_decoration']) && $SETTING['res_decoration']=="checked") echo " checked"; ?>>する</div>
<div><b>レスの投稿日時のコンマ桁数</b></div>
<div>
<select name="date_comma_digit">
<option value="0">0(表示しない)</option>
<option value="1"<?php if (isset($SETTING['date_comma_digit']) && $SETTING['date_comma_digit']=="1") echo " selected"; ?>>1</option>
<option value="2"<?php if (isset($SETTING['date_comma_digit']) && $SETTING['date_comma_digit']=="2") echo " selected"; ?>>2</option>
<option value="3"<?php if (isset($SETTING['date_comma_digit']) && $SETTING['date_comma_digit']=="3") echo " selected"; ?>>3</option>
</select>
</div>
<hr><div class="contents"><input type="submit" name="Submit" class="btn btn-primary btn-block" value="適用"></div>
</form>
</div>