技术笔记 第10页
记录一些我自己使用过的东西,备忘用!

几个情况需要重装系统 1.我的VPS装了一堆东西,很乱,想还原 2.我的VPS之前东西和现在要装的东西冲突了。无法进行安装了 3.我的VPS被人侵入当矿机了,机器满负荷运载 4.想尝试bbr其他版本,ARM目前还是会失联 5.更纯净更稳定 最关键是甲骨文云你删机不一定能开出新机!所以重装系统很重要! 重装前的故事背景 甲骨文云ARM或者AMD架构,Ubuntu系统 几分钟内dd成debian或者ubuntu 群友分享的,他经常用。我也成功重装了! 1.一键脚本 bash <(wget –no-check-certificate -qO- ‘https://moeclub.org/attachment/LinuxShell/InstallNET.sh’) -d 10 -v 64 -a -firmware -p 12345 系统参数 -d 10 【7、8、9、10,11】Debian -u 20.04 【14.04、16.04、18.04、20.04】Ubuntu 密码参数,可以改成别的 -p 12345 2.刚开始,都是自动的等 3.这就结束了 重装后3分钟VPS自动重启, 4.用户名root 5.密码就是你自己设置的12345或者别的 6.好了直接重装完了,直接root权限了,又可以愉快的玩耍了! 这时候想改root账户对的密码输入以下命令,输入时密码不显示,感觉像是没输进去,正常盲打即可!输入两次! passwd 这个系统装BBR前先走这个命令 apt update -y && apt install -y curl && apt install -y socat && apt install wget -y BBR PLUS 四合一脚本 wget -N –no-check-certificate “https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh” && chmod +x tcp.sh && ./tcp.sh
There is no excerpt because this is a protected post.
There is no excerpt because this is a protected post.
There is no excerpt because this is a protected post.
<?php $user = "root"; //数据库用户名 $password = "123";//数据库密码 $db_name = "root";//数据库名 $link = mysql_connect("localhost:3306",$user,$password); mysql_select_db("$db_name",$link); echo "<p>;正在清空数据库..."; $result=mysql_query("SHOW tables",$link); while ($currow=mysql_fetch_array($result)) { mysql_query("drop TABLE IF EXISTS $currow[0]"); echo $currow[0]."<br>;"; } echo "成功</p>;"; ?>;

近几年各大搜索引擎平台提供了更快捷的数据提交方式,如百度的自动提交,API推送(在下篇内容中讲解),那么本次的内容重点去讲必应Bing的内容推广. 打开必应站长平台(https://www.bing.com/webmasters),如果你没注册或者没绑定,这里就不做过多的说明,这些简单的东西太浪费时间。 点击URL Submission ,看到右侧可以看到今天剩余的提交的数量只有86条,今天主动提交了9900多条,目前给到企易推的每天的限额是10000条。 右上角选择API 然后查看需要提交的密钥: import requests def get_(data): headers={'User-Agent':'curl/7.12.1 ', 'Content-Type':'application/json'} try: r = requests.post(url='https://ssl.bing.com/webmaster/api.svc/json/SubmitUrl?apikey=密钥',json=data) except Exception.e: print(e) # 把所有链接放置到了文件夹里面,所以只需要去读取文件夹里面的链接就成了。 fp = open("website.txt", "r+") for i in fp.readlines()[0:10000]: cjhpush={ "siteUrl": "https://www.1004619.com", "url": 'https://www.1004619.com/' + i[1:-1], } print(cjhpush) get_(cjhpush) fp.close() 第二种方法就是直接提交每日最新的内容sitemap.xml import requests import re def bing(urls): global bing_number headers = { 'Content-Type': 'application/json; charset=utf-8', 'Host': 'ssl.bing.com', } api = 'https://ssl.bing.com/webmaster/api.svc/json/SubmitUrl?apikey=API秘钥' print('Bing站长推送中...') for page in urls: json = { 'siteUrl': 'https://www.1004619.com', #domain.com 'url': page } response = requests.post(api, json=json, headers=headers).json() if 'd' in response.keys(): bing_number = bing_number + 1 else: break if __name__ == '__main__': bing_number = 0 url = 'https://www.1004619.com/sitemap.xml' response_html = requests.get(url) html = response_html.text urls = re.findall('<loc>(.*?)</loc>', html) bing(urls) print('Bing站长共计推送:%s' % bing_number) 自此关于bing网站自动推送的2种方法介绍完毕,这些python代码稍微有点代码基础的人都可以看懂.修改起来也很方便.有问题可以来咨询我.
if(strpos($_SERVER['REQUEST_URI'],'?')!==false)//如果当前网址含有?就跳转 { header('HTTP/1.1 301 Moved Permanently');//发出301重定向跳转头部 header('Location:http://www.sinafans.com');//跳转到带www的网址 } 感谢群友go9go提供方法思路

把下面的代码存为php文件,下面的整段代码是验证过程,然后在你入口页进行调用 例如命名为MkEncrypt.php,那么在入口页 进行 require_once('MkEncrypt.php'); 然后设置密码为 MkEncrypt('1234'); 此时密码为1234 则密码正确才能进去页面,进入后会存下cookies值,下一次登录的时候则不需要再次输入了;如果不想给人看了,只需要更改密码,cookies就会立即失效,必须要重新登陆才能看。 代码简介 为你的页面 支持 加密访问 无论什么程序 只要是PHP程序 都是支持这代码的 来实现加密访问你的加密页面 或文章等等的页面 不保证其他程序可以正常使用 麻烦先测试! 代码如下 <?php /******************************************** * 使用方法: * * 1、将本段代码保存为 MkEncrypt.php * * 2、在要加密的页面前面引入这个 php 文件 * require_once('MkEncrypt.php'); * * 3、设置页面 访问密码 * MkEncrypt('页面密码'); * ********************************************/ // 密码 Cookie 加密盐 if(!defined('MK_ENCRYPT_SALT')) define('MK_ENCRYPT_SALT', 'Kgs$JC!V'); /** * 设置访问密码 * * @param $password 访问密码 * @param $pageid 页面唯一 ID 值,用于区分同一网站的不同加密页面 */ function MkEncrypt($password, $pageid = 'default') { $pageid = md5($pageid); $md5pw = md5(md5($password).MK_ENCRYPT_SALT); $postpwd = isset($_POST['pagepwd']) ? addslashes(trim($_POST['pagepwd'])) : ''; $cookiepwd = isset($_COOKIE['mk_encrypt_'.$pageid]) ? addslashes(trim($_COOKIE['mk_encrypt_'.$pageid])) : ''; if($cookiepwd == $md5pw) return; // Cookie密码验证正确 if($postpwd == $password) { // 提交的密码正确 setcookie('mk_encrypt_' . $pageid, $md5pw, time() + 3600000, '/'); return; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="renderer" content="webkit"> <meta name="author" content="mengkun"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <title>该页面已被加密</title> <style type="text/css"> *{font-family:"Microsoft Yahei",微软雅黑,"Helvetica Neue",Helvetica,"Hiragino Sans GB","WenQuanYi Micro Hei",sans-serif;box-sizing:border-box;margin:0px;padding:0px;font-size:14px;-webkit-transition:.2s;-moz-transition:.2s;-ms-transition:.2s;-o-transition:.2s;transition:.2s} html,body{width:100%;height:100%} body{background-color:#F4F6F9;color:#768093} input,button{font-size:1em;border-radius:3px;-webkit-appearance:none} input{width:100%;padding:5px;box-sizing:border-box;border:1px solid #e5e9ef;background-color:#f4f5f7;resize:vertical} input:focus{background-color:#fff;outline:none} button{border:0;background:#6abd09;color:#fff;cursor:pointer;opacity:1;user-select:none} button:hover,button:focus{opacity:.9} button:active{opacity:1} .main{width:100%;max-width:500px;height:300px;padding:30px;background-color:#fff;border-radius:2px;box-shadow:0 10px 60px 0 rgba(29,29,31,0.09);transition:all .12s ease-out;position:absolute;left:0;top:0;bottom:0;right:0;margin:auto;text-align:center} .alert{width:80px} .mk-side-form{margin-bottom:28px} .mk-side-form input{float:left;padding:2px 10px;width:77%;height:37px;border:1px solid #ebebeb;border-right-color:transparent;border-radius:2px 0 0 2px;line-height:37px} .mk-side-form button{position:relative;overflow:visible;width:23%;height:37px;border-radius:0 2px 2px 0;text-transform:uppercase} .pw-tip{font-weight:normal;font-size:26px;text-align:center;margin:25px auto} #pw-error {color: red;margin-top: 15px;margin-bottom: -20px;} .return-home{text-decoration:none;color:#b1b1b1;font-size:16px} .return-home:hover{color:#1E9FFF;letter-spacing:5px} </style> </head> <body> <div class="main"> <svg class="alert" viewBox="0 0 1084 1024" xmlns="http://www.w3.org/2000/svg" width="80" height="80"> <defs><style/></defs> <path d="M1060.744 895.036L590.547 80.656a55.959 55.959 0 0 0-96.919 0L22.588 896.662a55.959 55.959 0 0 0 48.43 83.907h942.14a55.959 55.959 0 0 0 47.525-85.534zm-470.619-85.172a48.008 48.008 0 1 1-96.015 0v-1.567a48.008 48.008 0 1 1 96.015 0v1.567zm0-175.345a48.008 48.008 0 1 1-96.015 0V379.362a48.008 48.008 0 1 1 96.015 0v255.157z" fill="#FF9800"/> </svg> <form action="" method="post" class="mk-side-form"> <h2 class="pw-tip">该页面已被加密</h2> <input type="password" name="pagepwd" placeholder="请输入访问密码查看" required><button type="submit">提交</button> <?php if($postpwd): ?> <p id="pw-error">Oops!密码不对哦~</p> <script>setTimeout(function() {document.getElementById("pw-error").style.display = "none"}, 2000);</script> <?php endif; ?> </form> <a href="/" class="return-home" title="点击回到网站首页">- 返回首页 - </a> </div> </body> </html> <?php exit(); }
如果你的网站打算将链接主动推送到 bing\indexnow\yandex 搜索引擎,你可以使用下面的代码来自动推送。 基本php版本越高越好 下面的代码 去掉了PHP新版本语法,理论上php>=7即可使用。 <?php // 配置 // 网站的主域名 $host = 'www.4414.cn'; // 配置的key,自己生成32位字符串 $key = 'c29f72027ef343988ef0d1cdcdcc40ee'; // 给平台验证key的链接,名称随意,不一定叫mykey.txt。但是这个文件里的内容就是你自己生成的 32位字符串 key $keyLocation = 'https://www.4414.cn/mykey.txt'; $messages = []; if (!empty($_SERVER['HTTP_REFERER'])) { $url = $_SERVER['HTTP_REFERER']; $messages[] = '推送链接:' . $url; $result = indexNowPush('www.bing.com', [ 'http://www.example.com/' ]); $messages[] = 'www.bing.com 推送结果:' . ($result ? '成功' : '失败'); $result = indexNowPush('api.indexnow.org', [ 'http://www.example.com/' ]); $messages[] = 'api.indexnow.org 推送结果:' . ($result ? '成功' : '失败'); $result = indexNowPush('yandex.com', [ 'http://www.example.com/' ]); $messages[] = 'yandex.com 推送结果:' . ($result ? '成功' : '失败'); } else { $messages[] = '没有读取到推送链接,无需推送'; } header('Content-Type: application/javascript'); foreach ($messages as $message) { echo 'console.log("' . $message . '");'; } /** * indexnow推送 * @param string $searchengine 推送的搜索引擎,api.indexnow.org、www.bing.com、yandex.com * @param array $urls 推送网址 * @return bool */ function indexNowPush($searchengine, $urls) { global $host; global $key; global $keyLocation; if (empty($urls)) { return false; } $data = [ 'host' => $host, 'key' => $key, 'keyLocation' => $keyLocation, 'urlList' => $urls ]; $data = json_encode($data, JSON_UNESCAPED_UNICODE); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://' . $searchengine . '/indexnow'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Host: ' . $searchengine, 'Content-Type: application/json', 'Content-Length:' . strlen($data) ]); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_exec($ch); $httpCode = 0; if (!curl_errno($ch)) { $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); } curl_close($ch); return $httpCode === 200; } 使用说明:将上面代码保存到某个php文件内容里,例如:indexnow.php。然后将这个php文件上传到你的服务器可以运行的位置,放在网站根目录即可。 修改上面代码中的配置部分。 // 配置 // 网站的主域名 $host = 'www.4414.cn'; // 配置的key,自己生成32位字符串 $key = 'c29f72027ef343988ef0d1cdcdcc40ee'; // 给平台验证key的链接,名称随意,不一定叫mykey.txt。但是这个文件里的内容就是你自己生成的 32位字符串 key $keyLocation = 'https://www.4414.cn/mykey.txt'; 然后在你的网站每个页面加入引用代码,类似于js引用。 <script src="http://192.168.1.100:5004/indexnow.php"></script> 上面那个链接地址换成你的网站indexnow.php链接地址。 下面是完整的示例。 访问你的网站页面地址,然后按f12打开开发者调试工具,控制台会打印推送结果。 如果出现php错误41的问题。可以尝试以下方法解决 你可以将这行代码改一下:function indexNowPush(string $searchengine, array $urls): bool 改为:function indexNowPush($searchengine, $urls)

1.首先连接进入mysql,查看慢日志的状态,show variables like ‘%slow%’; 2.此时慢日志的状态是开启的,且慢日志的路径也可以看到,接下来就是要先关闭慢日志,使用 set global slow_query_log=0; 关闭之后再次检查下慢日志的状态,已经是关闭了,如图: 3.关闭慢日志后,我们重置慢日志的路径,路径可以根据自己的服务器配置,语句如下: set global slow_query_log_file=’/home/mysql/mysql-5.5.22/bak/slow_querys_20180105.log’; 4.重置完成后,再次开启慢日志:set global slow_query_log=1; 5.再次检查慢日志的状态:show variables like ‘%slow%’; 可以看到慢日志已经开启,路径也变了 6.接下来我们测试一下慢日志记录是否成功,使用语句:select sleep(10) as a, 1 as b; 效果如图: 7.最后一步就是打卡慢日志查看是否记录成功了,如果记录成功会有如下记录: 8.最后一步就是把之前的慢日志文件给删除了,释放空间。但我使用的方式是清空文件内容,但是保留文件。 在慢日志的文件夹路径下,执行语句:>slow_querys.log 下一步把大文件删除就可以了