PHP 常用
file_put_contents("awlog.txt", '---time:'.date('Y-m-d H:i:s',time()).'---xml:'.GLOBALS\['HTTP_RAW_POST_DATA'\].var_export(_POST,TRUE).PHP_EOL, FILE_APPEND);
error_reporting(0);
register_shutdown_function(function(){ var_dump(error_get_last()); });
if (isset($_COOKIE["debug"]) && $_COOKIE["debug"]=='1234'){
ini_set('max_execution_time', '0');
if(isset(_SERVER\["HTTP_X_REQUESTED_WITH"\]) \&\& strtolower(_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest"){
register_shutdown_function(function(){ error = error_get_last(); if(error && error\['type'\] != 8){echo json_encode(array('code'=\>'调试模式','error'=\>error));} });
}else{
echo "<h1 style='text-align: center;background: #F00;color: #FFF;padding: 6px 0;'>调试模式</h1>";
register_shutdown_function(function(){ if(error_get_last()){var_dump(error_get_last());} });
}
}
nginx log_format 请求中转
bash
log_format main '$remote_addr - $remote_user [$time_iso8601] $request_time $upstream_response_time '
'$status "$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$upstream_addr"';
server {
listen 80;
server_name sscn.www.top;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://ssc.www.top/;
}
location ^~ /Application
{deny all;}
location ^~ /Runtime
{deny all;}
location ~* /.*.(zip|svn|rar|gz|txt|log)$ {deny all;}
location ^~ /images/ {
root /www/wwwroot/site/;
expires 12h;
error_log off;
access_log /dev/null;
}
}
统计ip awk '{print $1}' /www/wwwlogs/www.xxx.com.log| sort -r |uniq -c | wc -l
add_header Access-Control-Allow-Credentials false;
add_header Access-Control-Allow-Methods *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
add_header Access-Control-Allow-Origin $http_origin;
#PROXY-START/
location /assets/ {
alias /www/wwwroot/app1/webapp/assets/;
expires 30d;
access_log /dev/null;
}
location /upload/ {
alias /www/wwwroot/app1/webapp/upload/;
expires 30d;
access_log /dev/null;
}
location /aac
{
proxy_pass http://127.0.0.1:2121;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_http_version 1.1;
# proxy_hide_header Upgrade;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
set $static_fileYYZqXIqe 0;
if ( $uri ~* "\.(gif|png|jpg|css|ico|js|woff|woff2)$" )
{
set $static_fileYYZqXIqe 1;
expires 30d;
access_log /dev/null;
}
if ( $static_fileYYZqXIqe = 0 )
{
add_header Cache-Control no-cache;
}
}
location /socket.io/
{
proxy_pass http://127.0.0.1:2120;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_http_version 1.1;
# proxy_hide_header Upgrade;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
set $static_fileYYZqXIqe 0;
if ( $uri ~* "\.(gif|png|jpg|css|ico|js|woff|woff2)$" )
{
set $static_fileYYZqXIqe 1;
expires 30d;
access_log /dev/null;
}
if ( $static_fileYYZqXIqe = 0 )
{
add_header Cache-Control no-cache;
}
}
location /websocket23
{
proxy_pass http://127.0.0.1:9666;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_http_version 1.1;
# proxy_hide_header Upgrade;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
set $static_fileYYZqXIqe 0;
if ( $uri ~* "\.(gif|png|jpg|css|ico|js|woff|woff2)$" )
{
set $static_fileYYZqXIqe 1;
expires 30d;
access_log /dev/null;
}
if ( $static_fileYYZqXIqe = 0 )
{
add_header Cache-Control no-cache;
}
}
location /
{
proxy_pass http://app1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 11s;
proxy_send_timeout 11s;
proxy_http_version 1.1;
# proxy_hide_header Upgrade;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
set $static_fileYYZqXIqe 0;
if ( $uri ~* "\.(gif|png|jpg|css|ico|js|woff|woff2)$" )
{
set $static_fileYYZqXIqe 1;
expires 30d;
access_log /dev/null;
}
if ( $static_fileYYZqXIqe = 0 )
{
add_header Cache-Control no-cache;
}
}
#PROXY-END/
重载脚本
bash
#!/bin/bash
#--------------------------------------------
# 去掉负载后同步最新jar包后重启,然后再启动负载
#--------------------------------------------
APP_BASE_PATH=$(cd `dirname $0`; pwd)
MAIN_CLASS=com.StartClass
JAVA_OPTS="-Djava.awt.headless=true"
CP=${APP_BASE_PATH}/config:${APP_BASE_PATH}/lib/*
upstream="127.0.0.2:20282"
t1=`date '+%Y-%m-%d %H:%M:%S'`
echo $t1" 修改负载"
`sed -i "s/server $upstream/#server $upstream/g" /etc/nginx/nginx.conf`
t1=`date '+%Y-%m-%d %H:%M:%S'`
echo $t1" 重载nginx配置"
`nginx -s reload`
sleep 5
t1=`date '+%Y-%m-%d %H:%M:%S'`
echo $t1" 同步jar"
`zip -r ../bakuu/conf$(date +\%Y\%m\%d%H%M%S).zip config/ $APP_BASE_PATH/lib/app-1.0.jar`
`scp -r -P 34822 administrator@127.0.0.1:/C:/code/web/target/app-release/uuapp/lib/app-1.0.jar $APP_BASE_PATH/lib/`
t1=`date '+%Y-%m-%d %H:%M:%S'`
echo $t1" 重启APP1"
kill `pgrep -f ${APP_BASE_PATH}/` 2>/dev/null
`nohup java -Xverify:none ${JAVA_OPTS} -cp ${CP} ${MAIN_CLASS} > log/output$(date +\%Y\%m\%d\%H\%M).log &`
#`sh $START1 restart`
t1=`date '+%Y-%m-%d %H:%M:%S'`
echo $t1" APP1启动完成"
sleep 3
t1=`date '+%Y-%m-%d %H:%M:%S'`
echo $t1" 修改负载"
`sed -i "s/#server $upstream/server $upstream/g" /etc/nginx/nginx.conf`
t1=`date '+%Y-%m-%d %H:%M:%S'`
echo $t1" 重载nginx配置"
`nginx -s reload`
find ./ -type f -name "*202207*"| xargs -I {} mv {} ./08/
find . -name "*.sh"|xargs sed -i "s/140.143.66.174/123.206.56.8/g"
find . -name "nginx.conf"|xargs sed -i "s/'etc/letsencrypt/live'/nginx/g"
linux 批量查找 find /www/web/webapp1/public_html/ -type f -name "*.php" |xargs grep "eval(" > /www/web/webapp1/test.txt
find . -name "*.*"|xargs sed -i "s/aaaaa/bbbbbb/g"
cat access.log | awk '{print $8" "$1" "$10}' | sort -nr | head -n 230
centos nginx 自启动命令: chkconfig --levels 2345 nginx on
white-space: nowrap;text-overflow:ellipsis; overflow:hidden;
show open tables where in_use >0;
SHOW PROCESSLIST;
select concat('kill ',id,';') kill_process from information_schema.processlist a where a.state like '%lock%'; #解锁
Flush logs
mysqlbinlog --no-defaults mysql-bin.000127>mysql-bin.000127.txt
select * from hk_test where uid in (select username from hk_test group by uid having count(uid) > 1)
show global variables like 'max_allowed_packet';
set global max_allowed_packet = 2*1024*1024*10;
show variables like "group_concat_max_len";
group_concat_max_len=4294967295
/www/server/mysql/bin/mysqlbinlog --no-defaults --start-datetime="2020-12-16 11:01:55" --stop-datetime="2020-12-16 18:10:18" --database=www_database /www/mysql-bin.000010>/www/02.log
/www/server/mysql/bin/mysql -uroot -p123456 www_database < /www/02.log
JAVA_OPTS="-Xms512m -Xmx2048m -Xss1024K -XX:PermSize=256m -XX:MaxPermSize=512m -XX:-UseGCOverheadLimit"
scp -r -P 34822 administrator@123.0.0.1:/C:/backup/2/* ./
linux 批量查找 find / -type f -name "*.html" |xargs grep "关键词" > /aaaaa.txt
find / -type f -name "*.log" -mtime -400>test.log
find . -size -1b -a -exec ls -lh {} \; 列出空白文件
find . -size -1b -a -exec rm -rf {} \; 删除空白文件
sed -n '5925626,5926226p' mysql-general.log > fxq.log
sed -n '175983,275983p' mysql-general.log > fxq.log
mv -i `find . -maxdepth 1 -inum 12899196463 -print` a.zip
cat /etc/passwd | grep -v /sbin/nologin | cut -d : -f 1 #查看可以登录系统的用户
css去掉换行 white-space: nowrap;text-overflow:ellipsis; overflow:hidden;
D:\dev\java\jdk8\bin\keytool -exportcert -alias game -keystore 5q9rj6cu.jks | openssl sha1 -binary | openssl base64
java -jar pepk.jar --keystore=Fy8xRXcHUbw.jks --alias=key0 --output=Fy8xRXcHUbw_output.zip --signing-keystore=Fy8xRXcHUbw.jks --signing-key-alias=key0 --encryptionkey=eb10fe8f7c7c9df715022017b00c6471f8ba8170b13049a11e6c09ffe3056a104a3bbe4ac5a955f4ba4fe93fc8cef27558a3eb9d2a529a2092761fb833b656cd48b9de6a
java -jar bundletool-all-1.9.0.jar get-device-spec --output=./device-spec.json
java -jar bundletool-all-1.9.0.jar build-apks --bundle=./WZQP-release.aab --output=./app-debug.apks --overwrite --device-spec=./device-spec.json
java -jar bundletool-all-1.9.0.jar install-apks --apks=./app-debug.apks
ps -aux --sort=-pcpu|head -10
top -H p 76698
jstack -F 76646 >76646_err_1.log
###### mqtt start ########
bash
mkdir /usr/java
cd /usr/java/
chmod +x jdk-7u67-linux-x64.rpm
rpm -ivh jdk-7u67-linux-x64.rpm
vi /etc/profile
source /etc/profile
mkdir /www
cd /www
wget http://archive.apache.org/dist/activemq/activemq-apollo/1.7/apache-apollo-1.7-unix-distro.tar.gz
tar -zxvf apache-apollo-1.7-unix-distro.tar.gz
cd /www/apache-apollo-1.7/
./bin/apollo create mqtt_test
ln -s "/www/apache-apollo-1.7/mqtt_test/bin/apollo-broker-service" /etc/init.d/
cd /www/apache-apollo-1.7/mqtt_test/
vi etc/users.properties
vi etc/apollo.xml
/etc/init.d/apollo-broker-service start
/etc/init.d/apollo-broker-service restart
###### v2ray start ########
bash
bash <(curl -s -L https://git.io/v2ray.sh)
systemctl stop firewalld
find / -name 'v2ray.service'
/usr/local/bin/v2ray -config /etc/v2ray/config.json
/usr/bin/v2ray/v2ray -config /etc/v2ray/config.json
cp -r /usr/bin/v2ray/systemd/system/v2ray.service ./
vi v2ray.service
cp v2ray.service /etc/systemd/system/
systemctl start v2ray
systemctl status v2ray
vi /usr/local/sbin/v2ray
systemctl enable v2ray
v2ray start
v2ray status
防广告iframe
javascript
<script type="text/javascript">
if (window!=top) top.location.href =window.location.href;
var clearFrameAds = function () {
var iframes = document.getElementsByTagName('iframe')
for (var i = 0; i < iframes.length; i++) {
var iframe = iframes[i]
if (iframe.src && iframe.src.search('domain.com/') !== 0) {
iframe.parentNode.removeChild(iframe)
}
}
}
setInterval(function () {clearFrameAds() }, 100)
</script>
javascript
function Setcookie (name, value){
//设置名称为name,值为value的Cookie
var expdate = new Date(); //初始化时间
expdate.setTime(expdate.getTime() + 10 * 60 * 1000); //时间单位毫秒
document.cookie = name+"="+value+";expires="+expdate.toGMTString()+";path=/";
}
Setcookie('uutoken','9f38523992c9407892d7bf04b3fb11a8');
(function () {
window.shellApp = 1;
window.isVestShell = 1;
if (location.href.indexOf(globaUniUrl) > -1 || location.href.indexOf(globaUniUrl) > -1) return;
var b = document.getElementById("_uniapp_b");
if (b) return;
b = document.createElement("img");
b.setAttribute("id", "_uniapp_b");
b.setAttribute("src", globaUniUrl+"/static/image/icon/back.png");
b.setAttribute("style", "position:fixed;top:15px;left:15px;width:40px;z-index:99999");
b.onclick = function () {
/*if(history.length > 5 && location.href.indexOf("payment/checkout") > -1){history.go(-3);}else{history.back(-1);}*/
location.replace(globaUniUrl);
}
document.body.appendChild(b);
})();
js input 模拟输入
javascript
function input1(obj,val){
//log(obj.getAttribute('id')+":"+val);
obj.click();
obj.value = val;
obj.dispatchEvent(new Event('input', {
bubbles: true,
cancelable: true
}));
}
function input2(obj,val){
// log(obj.getAttribute('id')+":"+val);
var element_input = obj
var _templMethod = element_input._valueTracker.getValue
var _templMethod = element_input.getValue
element_input._valueTracker.getValue = () => ''
element_input.value = val
var event = new InputEvent('input', {
'bubbles': true,
'cancelable': true,
})
element_input.dispatchEvent(event)
element_input._valueTracker.getValue = _templMethod
}
谷歌创建应用js脚本
javascript
function sleep(time){return new Promise(resolve=>setTimeout(resolve,time))}function ck(class1){let a=document.querySelector(class1);if(a!=undefined){a.click();return true}return false}function ck2(class1){let a=document.querySelector(class1);if(a.querySelector("div").getAttribute("class").indexOf("mdc-checkbox--selected")==-1){a.click()}}function setVal(class1,val){let _e=new Event("input");let el=document.querySelector(class1);el.value=val;el.dispatchEvent(_e)}
async function load(item){
var el,a = location.href;
console.log(new Date().toLocaleString()+" : "+a.split('developers')[1]);
if(a.indexOf('/store-settings')!=-1){
el = document.querySelector('[debug-id="category-value"]');
if(el!=undefined){
if('Action' != el.innerText){
ck('[debug-id="edit-app-category-section-button"]');
await sleep(1000);
document.querySelector('[debug-id="category-dropdown"] dropdown-button div').click();
await sleep(1000);
document.querySelector('material-select-dropdown-item').click();
await sleep(1300);
ck('[debug-id="main-button"]');
await sleep(1300);
document.querySelectorAll('.close-icon-button')[1].click();
await sleep(1300);
}
el = document.querySelector('[debug-id="email-value"]');
if(el!=undefined && item['email'] == el.innerText){
ck('a[href*="/main-store-listing"]');
console.timeEnd('runTime:');
console.log('结束');
return;
}else{
setVal('[debug-id="email-input"] input',item['email']);
setVal('[debug-id="phone-input"] input',item['phone']);
await sleep(1300);
ck('[pane-id="default--3"] [debug-id="main-button"]');
await sleep(2300);
ck('a[href*="/app-content/overview"]');
await sleep(2300);
}
}
}
if(a.indexOf('/app-content/target-audience-content')!=-1){
el = document.querySelectorAll('[debug-id="age-band-checkboxes"]');
if(el.length==0){
el = document.querySelectorAll('[debug-id="appeals-children-radio-group"] material-radio');
}
if(el.length>0){
el[el.length-1].click();
await sleep(30);
ck('[debug-id="next-button"]');
}else{
ck('[debug-id="main-button"]');
await sleep(1300);
ck('a[href*="/app-content/overview"]');
}
}
if(a.indexOf('/app-content/privacy-policy')!=-1){
setVal('[debug-id="privacy-policy-url-input"] input',item['policy']);
await sleep(300);ck('[debug-id="main-button"]');await sleep(1300);ck('a[href*="/app-content/overview"]');
}
if(a.indexOf('/app-content/news-declaration')!=-1){
ck('[debug-id="app-type-radio-not-news"]');
await sleep(300);ck('[debug-id="main-button"]');await sleep(1300);ck('a[href*="/app-content/overview"]');
}
if(a.indexOf('/app-content/government-apps')!=-1 || a.indexOf('/app-content/ad-id-declaration')!=-1){
ck('[debug-id="no-radio"]');
await sleep(300);ck('[debug-id="main-button"]');await sleep(1300);ck('a[href*="/app-content/overview"]');
}
if(a.indexOf('/app-content/regulated-health-apps')!=-1){
ck('[debug-id="none"]');
await sleep(300);ck('[debug-id="main-button"]');await sleep(1300);ck('a[href*="/app-content/overview"]');
}
if(a.indexOf('/app-content/financial-features')!=-1){
ck2('[debug-id="none-response"]');
await sleep(100);
ck('[debug-id="button-next"]');
await sleep(1300);ck('[debug-id="main-button"]');await sleep(1300);ck('a[href*="/app-content/overview"]');
}
if(a.indexOf('/app-content/data-privacy-security')!=-1){
ck('[debug-id="button-next"]');
await sleep(300);
ck('[debug-id="personal-data-no"] material-radio');
await sleep(300);ck('[debug-id="button-next"]');
await sleep(1300);ck('[debug-id="main-button"]');await sleep(1300);ck('a[href*="/app-content/overview"]');
}
if(a.indexOf('/app-content/ads-declaration')!=-1){
document.querySelectorAll('[debug-id="contains-ads-radio-group"] material-radio')[1].click();
await sleep(300);ck('[debug-id="main-button"]');await sleep(1300);ck('a[href*="/app-content/overview"]');
}
if(a.indexOf('/app-content/testing-credentials')!=-1){
ck('[debug-id="login-not-required-expandable-section"] material-radio');
await sleep(300);ck('[debug-id="main-button"]');await sleep(1300);ck('a[href*="/app-content/overview"]');
}
if(a.indexOf('/app-content/content-rating-overview')!=-1){
el = document.querySelectorAll('[debug-id="get-started-start-button"]');
if(el.length>0){
ck('[debug-id="get-started-start-button"]');
}else{
ck('a[href*="/app-content/overview"]');
}
}
if(a.indexOf('/app-content/content-rating-iarc-questionnaire')!=-1){
el = document.querySelectorAll('[debug-id="email-address-input"] input');
if(el.length>0){
setVal('[debug-id="email-address-input"] input',item['email']);
document.querySelector('[debug-id="app-category-radio-group"] material-radio').click();
ck('[debug-id="next-button"]');
}else{
el = document.querySelectorAll('[debug-id="single-response-radio-group"]');
if(el.length>0){
for(let k=0;k<el.length;k++){
el[k].querySelectorAll('material-radio')[1].click();
}
await sleep(300);ck('[debug-id="save-button"]');await sleep(1300);ck('[debug-id="next-button"]');
}else{
ck('[debug-id="main-button"]');
}
}
}
if(a.indexOf('/app-content/overview')!=-1){
el = document.querySelectorAll('.mdc-button');
if(el.length>0){
el[0].click();
}else{
el = document.querySelectorAll('empty-state');
if(el.length>0){
ck('a[href*="/store-settings"]');
}
}
}
if(a.indexOf('/app-dashboard?')!=-1){
ck('a[href*="/app-content/overview"]');
}
if(a.indexOf('/app-list')!=-1){
document.querySelector('[debug-id="create-app-button"]').click();
}
if(a.indexOf('/create-new-app')!=-1){
setVal('[debug-id="app-name-input"] input',item['name']);
ck('[debug-id="game-radio"]');
ck('[debug-id="free-radio"]');
ck2('[debug-id="guidelines-checkbox"]');
ck2('[debug-id="play-signing-checkbox"]');
ck2('[debug-id="export-laws-checkbox"]');
ck('[debug-id="create-app-button"]');
}
await sleep(1300);
load(item);
}
var item1={};
item1['name'] = 'Atomic Busy Wild Man';
item1['email'] = 'grouchowilliams98@gmail.com';
item1['phone'] = '+1 3132001882';
item1['policy'] = 'https://privacypolicy.atomicbusywildman.top/';
console.time('runTime:');
load(item1);
php目录下文件数统计
php
$hostdir=dirname(__FILE__).'/Application/'; //要读取的文件夹
$filesnames = scanFile2($hostdir);
$t2 = 0;
foreach ($filesnames as $name) {
if(file_exists($name)){
$t2 = $t2+1;
}
}
if($t2 != 225) {
echo '文件数错误 :'.$t2;
file_get_contents('https://api.xxxx.com/app/notify/wxmsg?openid=oPxuEt2RJy753w_hmo01-QCIzaYU&msg1=xbqp2&msg2=xbqp2&msg3=文件数错误'.$t2);
}
function scanFile2($path) {
global $result2;
$files = scandir($path);
foreach ($files as $file) {
if ($file != '.' && $file != '..') {
if (is_dir($path . '/' . $file)) {
scanFile2($path . '/' . $file);
} else {
$result2[] = $path . '/' . $file;
}
}
}
return $result2;
}
php请求转发
php
<?php
$json_data = file_get_contents('php://input');
$data = json_decode($json_data,true);
$url = $data['url'];
$data1 = $data['data'];
$header = getHeader($data['header']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // 设置请求的 URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 返回响应结果而不直接输出
curl_setopt($ch, CURLOPT_POST, true); // 设置为 POST 请求
curl_setopt($ch, CURLOPT_POSTFIELDS, $data1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$response = curl_exec($ch);
if(curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
}else{
curl_close($ch);
echo ($response);
}
function getHeader($s){
$s = json_decode($s,true);
$arr = [];
foreach ($s as $k=>$v){
$arr[] = $k.':'.$v;
}
return $arr;
}
?>