Solution: Install Chinese font in the server
yum install wqy-unibit-fonts.noarch wqy-zenhei-fonts.noarch -y
Find the files older than 30 days
Find the files that is older than 30 days:
find . -atime +30 -exec stat -c “%n %y” {} \;
Delete the files that is older than 30 days:
find . -atime +30 -print0 | xargs -0 -r rm
Reference: https://stackoverflow.com/a/21451441/126639
Bypass ERR_CERT_INVALID in Chrome
Open Advanced and press the “proceed to website” button.
If there is no “proceed to website” button, type “thisisunsafe” on chrome.
Example of addslashes Multibyte SQL injection
CREATE TABLE users ( username VARCHAR(32) CHARACTER SET GBK, password VARCHAR(32) CHARACTER SET GBK, PRIMARY KEY (username) );
$db = mysqli_init(); $db->real_connect('localhost', 'username', 'password', 'database'); $db->query('SET NAMES gbk'); $_POST['username'] = chr(0x87)."' OR username = username -- "; $username = addslashes($_POST['username']); $sql = "SELECT * FROM users WHERE username = '{$username}'"; $res = $db->query($sql); if ($res->num_rows) { echo 'success'; } else { echo 'fail'; }
Amazon AMI – Upgrade PHP from 5.6 to 7.3
cp /etc/php.ini php.ini.20200708 yum remove php* yum install php73 php73-mysqlnd php73-common php73-gd php73-mbstring php73-mcrypt php73-devel php73-xml
Remember to check apache log to make sure there is no error or warning.
Create a certificate for localhost on Mac OS (2020)
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
The certificate for this server is invalid
If you try to access a https website in iOS simulator, you will see the error below.
Error loading page
Domain: NSURLErrorDomain
Error Code: -1202
Description: The certificate for this server is invalid. You might be connecting to a server that is pretending to be "your-domain.com" which could put your confidential information at risk.
Follow the steps below to bypass the ssl cert validation:
1. Drag and drop the .crt file to the iOS simulator.
2. Go to Settings > General > Profile, Select the cert and click “Install”.
3. Go to Settings > General > About > Certificate Trust Settings, Turn on the “Enable Full Trust for Root Certificates” option.
Force MySQL to use a specific key to JOIN table
SELECT table1.id, table2.id FROM table1 LEFT OUTER JOIN table2 FORCE INDEX FOR JOIN (table1_id) ON (table2.table1_id = table1.id) Reference: https://stackoverflow.com/a/1272402
STRAIGHT_JOIN
When using JOIN query, sometimes MySQL’s JOIN optimizer would process the tables in a suboptimal order. STRAIGHT_JOIN can be used to resolve this problem. When using STRAIGHT_JOIN, the left table is always read before the right table.
Upgrade PHP on CentOS in Digital Ocean
yum remove php* yum --enablerepo=remi-php73 install php yum --enablerepo=remi-php73 install php-gd php-mbstring php-mcrypt php-devel php-xml php-zip php-mysqlnd php-common phpmyadmin
Reference: https://www.digitalocean.com/community/questions/trying-to-install-latest-php-version-on-centos-7