location ~* /wp-login\.php|/wp-admin/.*\.php$ {
set $auth_basic "INPUT ID & PASSWORD";
if ($arg_action = 'postpass') {
set $auth_basic off;
}
auth_basic $auth_basic;
auth_basic_user_file /etc/nginx/conf.d/htpasswd;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
WordPressの関連記事をカテゴリーとタグからプラグインなしで取得する(自作)
global $wpdb;
$sql = 'SELECT object_id,COUNT(object_id) AS c FROM wp_term_relationships WHERE term_taxonomy_id IN (SELECT term_taxonomy_id FROM wp_term_relationships WHERE object_id = '.get_the_ID().') GROUP BY object_id ORDER BY c DESC, object_id DESC LIMIT 12;';
$object = $wpdb->get_results($sql);
$ids = [];
foreach($object as $v){
if(get_the_ID() == $v->object_id){
continue;
}
$ids[] = $v->object_id;
}
$params = [
'post_type' => 'post',
'include'=> $ids,
'orderby' => 'post__in',
];
$relposts = get_posts($params);
foreach ( array_slice($relposts,0,6) as $post ) :
setup_postdata( $post );
endforeach;
SELECT object_id,COUNT(object_id) AS c FROM wp_term_relationships WHERE term_taxonomy_id IN (SELECT term_taxonomy_id FROM wp_term_relationships WHERE object_id = '.get_the_ID().') GROUP BY object_id ORDER BY c DESC, object_id DESC LIMIT 12;
このSQLが肝
このSQLでterm一覧を取得しその中の記事を集計して関連度の高い順に取得している
includeを使うとexcludeが効かないので取得時に除外
記事数も制御できないのでarray_sliceでカット
多めに取得しているのは非公開記事や固定ページを弾くため
Google Apps Scriptでサーバを監視しメール通知
/* サイトを監視し、ダウンしてたらメール通知 */
const URL = 'https://wp.wkbr.net'; // 監視したいサイトのURL
const EMAIL = 'wkbr@gmail.com'; // エラーを知らせるメールアドレス
var message;
function main() {
if(isUrlActive()) {
Logger.log('正常に作動しています'); // ログに出力
} else {
Logger.log('サイトエラー'); // ログに出力
sendMail();
}
}
function isUrlActive() {
try {
const response = UrlFetchApp.fetch(URL);
message = 'responsecode = ' + response.getResponseCode();
return (response.getResponseCode() == 200);
} catch (e) {
Logger.log(e);
message = e;
return false;
}
}
function sendMail() {
const dateTime = Utilities.formatDate(new Date(), 'JST', 'yyyy年MM月dd日 HH:mm');
MailApp.sendEmail({
to: EMAIL,
subject: '【サイトダウン】検知しました',
htmlBody: `
以下のURLでサイトダウンを検知しました。<hr>
URL: <a href="${URL}">${URL}</a><br>
日時: ${dateTime} <br>
${message}`
});
}
curlエラーのときだけメール送信する crontab用
curl -s -o /dev/null -f https://wp.wkbr.net || mail -s "server error" -r wkbr@gmail.com
Reno5Aの初期設定
※自分用のメモ
googleログインやアプリのアプデはしておく
adguard,gcam(googlecamera)のインストール
アプリの削除(調整中) adbの使い方
adb shell pm uninstall -k –user 0 com.agoda.mobile.consumer
adb shell pm uninstall -k –user 0 com.facebook.system
adb shell pm uninstall -k –user 0 com.facebook.appmanager
adb shell pm uninstall -k –user 0 com.facebook.services
adb shell pm uninstall -k –user 0 com.facebook.katana
adb shell pm uninstall -k –user 0 com.google.android.youtube
adb shell pm uninstall -k –user 0 com.google.android.apps.youtube.music
adb shell pm uninstall -k –user 0 com.google.android.videos
adb shell pm uninstall -k –user 0 com.google.android.apps.podcasts
adb shell pm uninstall -k –user 0 com.google.android.keep
adb shell pm uninstall -k –user 0 com.google.android.apps.photos
adb shell pm uninstall -k –user 0 com.google.android.apps.googleassistant
adb shell pm uninstall -k –user 0 com.google.android.googlequicksearchbox
adb shell pm uninstall -k –user 0 com.google.android.apps.nbu.files
adb shell pm uninstall -k –user 0 com.coloros.backuprestore
adb shell pm uninstall -k –user 0 com.coloros.gamespaceui
adb shell pm uninstall -k –user 0 com.coloros.childrenspace
adb shell pm uninstall -k –user 0 com.coloros.soundrecorder
adb shell pm uninstall -k –user 0 com.coloros.videoeditor
adb shell pm uninstall -k –user 0 com.coloros.karaoke
adb shell pm uninstall -k –user 0 com.google.android.apps.wellbeing
adb shell pm uninstall -k –user 0 com.google.android.apps.docs
adb shell pm uninstall -k –user 0 com.google.android.gms.location.history
adb shell pm uninstall -k –user 0 com.google.android.apps.magazines
adb shell pm uninstall -k –user 0 com.google.android.apps.subscriptions.red
adb shell pm uninstall -k –user 0 com.google.ar.core
adb shell pm uninstall -k –user 0 com.heytap.cloud
adb shell pm uninstall -k –user 0 com.heytap.pictorial
adb shell pm uninstall -k –user 0 com.heytap.music
adb shell pm uninstall -k –user 0 com.coloros.musiclink
adb shell pm uninstall -k –user 0 com.coloros.relax
adb shell pm uninstall -k –user 0 com.coloros.weather2
:adb shell pm uninstall -k –user 0 com.coloros.weather.service 消すと再起動を繰り返すので生かす
adb shell pm uninstall -k –user 0 com.coloros.athena
adb shell pm uninstall -k –user 0 com.coloros.phonemanager
adb shell pm uninstall -k –user 0 com.caf.fmradio
adb shell pm uninstall -k –user 0 com.felicanetworks.mfm.main
adb shell pm uninstall -k –user 0 com.oppo.usercenter
adb shell pm uninstall -k –user 0 com.oppo.sos
WPの記事本文の改ページ無効化
add_filter('content_pagination',function($pages){
$pages = array(implode("\n",$pages));
return $pages;
});
WordPressでパスワード保護記事を非表示
add_action('pre_get_posts',function($query){
if(is_admin()){
//管理画面は除外
return;
}
if($query->get('post_status') == 'publish' || $query->is_archive()){
// get_posts と query_posts両方対応
$query->set('has_password', false);
}
});
UbuntuでのVPN(L2TP/IPsec)サーバの設定メモ
apt-get install strongswan xl2tpd
/etc/xl2tpd/xl2tpd.conf
[lns default] ip range = 192.168.11.128-192.168.11.254 local ip = 192.168.11.99 pppoptfile=/etc/ppp/options.l2tpd
/etc/ppp/options.l2tpd
ms-dns 8.8.8.8 mtu 1358 mru 1358 refuse-pap refuse-chap refuse-mschap require-mschap-v2 name xl2tpd
この2ファイルはpermission 644
cat /etc/ppp/chap-secrets "user" xl2tpd "password" * cat /etc/ipsec.secrets : PSK "secret"
/etc/ipsec.conf
config setup virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v4:25.0.0.0/8,%v4:100.64.0.0/10,%v6:fd00::/8,%v6:fe80::/10 conn L2TP-PSK-NAT dpddelay=10 dpdtimeout=20 dpdaction=clear rightsubnet=0.0.0.0/0 also=L2TP-PSK-noNAT conn L2TP-PSK-noNAT authby=secret pfs=no auto=add keyingtries=3 rekey=no ikelifetime=8h keylife=1h type=transport left=%defaultroute leftprotoport=17/1701 right=%any rightprotoport=17/%any ike=aes256-sha1-modp1024
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf sysctl -p
ufwでport 1701 4500 500 許可
サーバ再起動
systemctl restart strongswan systemctl restart xl2tpd
androidのyoutubeの削除(無効化しても復活するので)
SDK Platform ToolsをDLしてコマンドを実行
C:\platform-tools\adb shell pm uninstall -k --user 0 "com.google.android.youtube"
参考
https://sp7pc.com/google/android/34263
https://developer.android.com/studio/releases/platform-tools
WordPressでリスト画面のタイトルの修正
add_filter('get_the_archive_title', function($title){
$tmp = explode(':',$title);
if(count($tmp) < 2){
return $title;
}
return sprintf('%s %s',$tmp[1],$tmp[0]);
});