Skip to content

Commit

Permalink
v0.95.7 通知メールの投稿された記事のURLに投稿時刻のIDを追加。URLをクリックすると該当発言の位置までスクロールするようにした。
Browse files Browse the repository at this point in the history
  • Loading branch information
satopian committed Oct 20, 2023
1 parent f3e88a1 commit 095281d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
4 changes: 2 additions & 2 deletions petitnote/index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
//Petit Note (c)さとぴあ @satopian 2021-2023
//1スレッド1ログファイル形式のスレッド式画像掲示板
$petit_ver='v0.95.5';
$petit_ver='v0.95.7';
$petit_lot='lot.20231019';
$lang = ($http_langs = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '')
? explode( ',', $http_langs )[0] : '';
Expand Down Expand Up @@ -706,7 +706,7 @@ function post(){
$data['subject'] = '['.$boardname.'] '.NOTICE_MAIL_NEWPOST;
}

$data['option'][] = NOTICE_MAIL_URL.','.$root_url.'?resno='.$resno;
$data['option'][] = NOTICE_MAIL_URL.",{$root_url}?resno={$resno}#{$time}";
$data['comment'] = str_replace('"\n"',"\n",$com);

noticemail::send($data);
Expand Down
40 changes: 16 additions & 24 deletions petitnote/noticemail.inc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/*
** メール通知クラス(UTF-8) lot.221219 for PetitNote
**
** https://paintbbs.sakura.ne.jp/poti/
** by POTI改
** メール通知クラス(UTF-8) lot.231020 for PetitNote
** https://paintbbs.sakura.ne.jp/
**
** originalscript (C)SakaQ 2004-2007
** http://www.punyu.net/php/
**
**
** 2023/10/20 Subjectのダブルクオートをエスケープ。
** 2022/12/19 コード整理。
** 2022/09/18 URLがURLとして正しい事を確認できるようにした。
** 2022/09/18 多国語対応。mb_language( 'uni' )。
Expand Down Expand Up @@ -91,13 +91,17 @@ noticemail::send($data);

class noticemail{

public static function send($data=''){
public static function send($data){

mb_language( 'uni' );
mb_internal_encoding("UTF-8");

$name = isset($data['name']) ? $data['name'] : '';
$url = isset($data['url']) ? $data['url'] : '';
$title = isset($data['title']) ? $data['title'] : '';
$comment = isset($data['comment']) ? $data['comment'] : '';
$subject = isset($data['subject']) ? $data['subject'] : '';
$option = isset($data['option']) ? $data['option'] : [];

$line = "---------------------------------------------------------------------\n";

Expand All @@ -111,24 +115,23 @@ class noticemail{
$Message = ''.$data['subject']."\n";
$Message .= 'Date: '.date("Y/m/d H:i:s",time())."\n";
//ユーザーip
$userip = self::get_uip();
$userip = get_uip();
$host= $userip ? gethostbyaddr($userip) :'';
$Message .= 'Host: '.$host."\n";
$Message .= 'UserAgent: '.$_SERVER["HTTP_USER_AGENT"]."\n";
$Message .= $line;
$Message .= $name ? ('Name: '.$name."\n") :'';
$Message .= filter_var($url,FILTER_VALIDATE_URL) ? ('URL: '.$url."\n") : '';
$Message .= $title ? ('Subject: '.$title."\n") : '';
$option = $data['option'];
if(is_array($option)){
foreach($option as $value){
list($optitle,$opvalue)=explode(",", rtrim($value));
$Message .=$optitle.': '.$opvalue." \n";
}
}
$Message .= $line;
if($data['comment']){
$com = str_replace(["\r\n","\r"], "\n", $data['comment']);// 改行文字の統一
if($comment){
$com = str_replace(["\r\n","\r"], "\n", $comment);// 改行文字の統一
$com = preg_replace("/^(\n)+|(\n)+$/i", "", $com); // 連続改行を消す
$Message .= $com;
}
Expand All @@ -142,23 +145,12 @@ class noticemail{
$name = mb_encode_mimeheader($name);
// ヘッダにFrom追加
$MailHeaders .= 'From: '.$name.' <'.$from.'>'."\n";
// メール送信
mb_send_mail($data['to'],
$data['subject'],
// メール送信
$subject = str_replace('"', '\"', $subject);//ダブルクオートをエスケープ
mb_send_mail($data['to'],
$subject,
$Message,$MailHeaders);

return true;
}
//ユーザーip
private static function get_uip(){
$ip = isset($_SERVER["HTTP_CLIENT_IP"]) ? $_SERVER["HTTP_CLIENT_IP"] :'';
$ip = $ip ? $ip : (isset($_SERVER["HTTP_INCAP_CLIENT_IP"]) ? $_SERVER["HTTP_INCAP_CLIENT_IP"] : '');
$ip = $ip ? $ip : (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : '');
$ip = $ip ? $ip : (isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : '');
if (strstr($ip, ', ')) {
$ips = explode(', ', $ip);
$ip = $ips[0];
}
return $ip;
}
}
6 changes: 3 additions & 3 deletions petitnote/template/basic/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ jQuery(function() {
const luminousElems = document.querySelectorAll('.luminous');
//取得した要素の数が 0 より大きければ
if( luminousElems.length > 0 ) {
luminousElems.forEach( (elem) => {
new Luminous(elem);
});
for(const elem of luminousElems) {
new Luminous(elem);
};
}
});

0 comments on commit 095281d

Please sign in to comment.