包含标签 php articles

php防止wordpress网站被f5刷新的例子

最近比较晕了,博客经常给朋友f5不停的刷新了,这个让一个空间根据搞不定呀,后来网上整理了一些防止刷新的代码才得己解决,下面来看到整理的代码吧,希望这些例子对你有帮助. 搬家到阿里云的头两天头痛了,主机配置低,尼玛的wp的需求高,F5几下就刷死了,你让俺情何以堪,以前用过的主机配置哪……

Continue reading

PHPExcel读取excel并导入mysql数据库

本文章来给大家介绍一款PHPExcel读取excel并导入数据库代码实现,有需要了解的朋友可参考,这里我们介绍的是读取表格之后再创建mysql连接,然后保存到mysql数据库. PHPExcel是相当强大的 MS Office Excel 文档生成类库,当需要输出比较复杂格式数据的时候,PHPExcel 是个不……

Continue reading

php破解apache,nginx,iis防盗链图片

现在多数网站都有防盗链一些简单设置了最常用的就是apache,nginx,iis设置了,那么这种设置是不是不可破的呢,答案是否写了,下面我们一起来看破解方法. 有自己的主机一般都会设计”防盗链”,其实包括图片防盗链,和下载防盗链等,使用.htaccess设置防盗链,代码如下: 1RewriteEngine on 2RewriteCond……

Continue reading

php采集类snoopy

Snoopy是一个php类,用来模拟浏览器的功能,可以获取网页内容,发送表单。下载地址:http://sourceforge.net/projects/snoopy/files/ 。snoopy具有的特点如下: 抓取网页的内容 fetch 抓取网页的文本内容 (去除HTML标签) fetchtext 抓取网页的链接,……

Continue reading

php正则过滤html标签、空格、换行符

1$str=preg_replace("/s+/", " ", $str); //过滤多余回车 2$str=preg_replace("/<[ ]+/si","<",$str); //过滤<__("<"号后面带空格) 3$str=preg_replace("/<!--.*?-->/si","",$str); //注释 4$str=preg_replace("/<(!.*?)>/si","",$str); //过滤DOCTYPE 5$str=preg_replace("/<(/?html.*?)>/si","",$str); //过滤html标签 6$str=preg_replace("/<(/?head.*?)>/si","",$str); //过滤head标签 7$str=preg_replace("/<(/?meta.*?)>/si","",$str); //过滤meta标签 8$str=preg_replace("/<(/?body.*?)>/si","",$str); //过滤body标签 9$str=preg_replace("/<(/?link.*?)>/si","",$str); //过滤link标签 10$str=preg_replace("/<(/?form.*?)>/si","",$str); //过滤form标签 11$str=preg_replace("/cookie/si","COOKIE",$str); //过滤COOKIE……

Continue reading

php采集与js和css

php采集过程中,对页面的某些无用信息或有用信息需要进行过滤。这里以js和css为例。如一些站点的js文件可能不是我们想要的,而别人的css样式可能又是你所机要的。现以两者为例说下php下的实现。 1、删除HTML中的JS部分 js在html的标记为…… ,根据该规则,可以通过下面的代……

Continue reading

php curl获取页面所有的链接

本文承接上面两篇,本篇中的示例要调用到前两篇中的函数,做一个简单的URL采集。一般php采集网络数据会用file_get_contents、file和cURL。不过据说cURL会比file_get_contents、file更快更专业,更适合采集。今天就试试用cURL来获取网页上……

Continue reading

从Snoopy类中提取函数:获取链接标签

通分析过了Snoopy类,它里面有比较完善的匹配源码,可以看到有function fetchlinks($URI)。也就是获取”< a >”中链接的函数,可以很简单的提取出来,此外还发现,它的正则还支持高级语言中的三目运算,函数及示例如下: 1<?php 2function _striplinks($document) { 3 preg_match_all("'<s*as.*?hrefs*=s*(["'])?(?(1) (.*?)\1 | ([^s>]+))'isx", $document, $links); 4 // catenate the non-empty matches……

Continue reading

PHP采集链接:相对链接转为绝对链接

该采集链接是从Snoopy中提取出来的,也是一个很好的函数,可以根据URL是相对链接还是绝对链接采集到链接,如果是相对链接会根据相对链接和主域名,返回绝对链接,也支持不同端口。 1<?php 2/*===================================================================* 3 Function: _expandlinks 4 Purpose: expand each link into a fully qualified URL 5 Input: $links the links to qualify 6 $URI the full URI to get the base from 7 Output: $expandedLinks the expanded links 8*===================================================================*/ 9function _expandlinks($links,$URI) 10{ 11 $URI_PARTS = parse_url($URI); 12 $host = $URI_PARTS["host"]; 13 preg_match("/^[^?]+/",$URI,$match);……

Continue reading

php自动创建目录并保存文件

php保存文件,还可以根据文件路径自动连续创建目录,代码如下(注:PHP要版本5以上): 1<?php 2 /** 3 * 保存文件 4 * 5 * @param string $fileName 文件名(含相对路径) 6 * @param string $text 文件内容 7 * @return boolean 8 */ 9 function saveFile($fileName, $text) { 10 if (!$fileName || !$text) 11 return false; 12 if (makeDir(dirname($fileName))) { 13 if ($fp = fopen($fileName, "w")) { 14 if (@fwrite($fp, $text)) { 15 fclose($fp); 16 return true; 17 } else { 18 fclose($fp); 19 return false; 20 } 21 } 22 } 23 return false; 24 } 25……

Continue reading

Latest articles

Categories

Tags

ACL AD AES AI AWS Ansible Atlassian Azure BMC Blockchain Brocade CDH5 CL210 Cobbler Confd C语言 DDOS DISTINCT DNS Duckdb EKS ELK GCP Ghost Git Glusterfs Go Godaddy Grafana HBA HCIE Hotspot HttpWatch IBM IIS IOS InfluxDB Ingress InnoDB JavaScript Jinja2 KVM Keepalived Mplayer MySQLdb Netlify OpenResty PM PostgreSQL QoS RH318 RH442 RHCA RHCE RHEV RSA SRE SecureCRT Statuscode SublimeText2 TC Telecom Tencentcloud VBA aira2 alpine android anpic apache apm apparmor appfog apr apt-get aria2 array atop audit awk awstats axel backdoor backup bamboo bash bat benchmark bigdata bin bind bitwise book bootstrap bsd c1000 cache capistrano catlog centos centos7 chatops chattr check_mk checkinstall cisco clearall clickhouse cloud-desktop cmdb cms collectd comm compress conver corosync cpu crontab crunchbang css curl date decode dell desktop devops df dhcp diff diskpart django docker dos2unix dpkg drupal etcd excel fail2ban fastcgi fdisk fiddler find firewalld flask flvtool ftp function fuser geek gin github gitlab glances golang google gooupadd graphviz gravatra grep grub2 hadoop haproxy hardware heartbeat helm hexdump hhvm history html http/html/web httplogs https huawei huaweicloud hugo icmp iconv ifconfig inotify iopp ipmitool iptables iredmail iscsi isito it-news java jdk jenkins jira join joomla k3s k8s kdump kernel kingate lamp last leetcode lib light-http linux linux高级篇 ln ls lsi lsof lvm lvs mac mail man mark markdown matplotlib maven memcached microservice mimikatz mkdocs mkpasswd mmonit mod_jk mongodb monit monitor mono moodle mosh mount mpm mrtg mtr my.cnf mysql mysqlbinlog mysqld_multi mysqldump mysqlhotcopy nagios nc nethogs nexus nfs nginx nmon nocatlog node.js nrpe ntfs ntop ntp obs ocr open-falcon openbox opencv openldap openssl openstack oracle oswatch paas pacemaker pam pandas parted pcp pcre pdf percona perl pexpect pgrep php php-fpm ping plsql develope postfix powershell prettify proc prometheus puppeteer pushd pwgen pxe pyecharts python python模块 radmin raid rdesktop read redhat redis redmine regex rh134 rhel7 rhel8 rm rman rootkit route rpm rpmforge rrdtool rsync rsyslog safe saltstack samba scapy screen sed selenium selinux seo seq session set shc sheepdog shell shopt sitemap skydns smokeping snffier snmp socket soft sort spider sql sqlserver squid ss ssh sshpass strace strings su sudo suse svn sysbench syslog-ng sysstat systemd t tar tcpcopy tcpdump tech telnet tengine test testlink threads time tmux tomcat touch tr tsar twisted ubuntu udev ulimit unix unixbench user-agent useradd varnish vbs vercel vi vim visudo vmstat vmware vnc voice vpn vscode vsftp vsftpd vue watchdog web webcam webistrano wget wiki windows wol wordpress workshop wsl x-windows xampp xcache xmllint xtrabackup yule yum zabbix zeromq zip zonetime zookeeper 下载工具 云主机 云原生 代理 加密 古意 吐槽 圈里圈外 娱乐 字符串函数 安全 平台架构 意林 推理 提权 故事汇 故障案例 数据结构 每日看点 民国史 生活 科学记录 站长管理工具 算法 管理 网站架构 翻墙 股票 行业 诗韵 负载均衡 远程管理 面试题

Links

Meta