PHP的一些知识点研究(1)
PHP的一些知识点研究(一)
一、基于PHP实现的webshell攻击
在乌云上看到一个基于php的webshell攻击。
高度隐蔽的webshell,使用普通的php代码将真正的shell内容经过层层加密处理之后保存到图片当中,只留下一个url,并且url还是经过加密处理的,所以对外看没有任何特征可寻,使其很难被发现,当打开上述url时,,显示的是404,而这个404页面就是伪装为404的木马,只是把标题改为了404 Not Found。
二、不用或少用else语句
对于if else 有人追求结构的完整,有if必有else,这看起来或许是不错,不过有时会带来代码的繁琐,而且可能会导致逻辑的混乱;可以以一种结果为基准,当发生其他情况时做if判断;即默认A,有异常则为B;如下面右图所示:
三、单页面结构(Single-page application)
单页面就是一切操作和布局都是在一个页面下进行,不需要页面跳转,根据不同的用户请求加载不同的内容。
优点:页面结构简单,数据量小,节省带宽,响应快,体验好,易于开发、维护以及优化;
缺点:使用ajax技术,导致不利于seo。
四、让搜索引擎抓取ajax的内容
主要针对上一案例的单页面结构,程序通过#结构url控制页面内容,但不会被搜索引擎抓取。
方法一:twitter使用"井号+感叹号"的结构,但体验不好而且繁琐;
方法二:使用History API;在不刷新页面的情况下,改变浏览器地址栏显示的地址。步骤如下:
A、用History API替代井号结构,让每个#号都变成正常路径的URL,这样搜索引擎就会抓取每一个网页。
B、定义一个JavaScript函数,处理Ajax部分,根据网址抓取内容。
C、定义鼠标的click事件,使用History对象的popstate事件处理浏览器的"前进 / 后退"按钮。
D、设置服务器端。
五、CURL_MULTI_INIT()
以前一直使用curl_init(),最近看到有curl_multi_init();本以为会带来更高效的代码,看了下curl_multi的步骤,感觉相当繁琐,而且curl_multi可能会造成cpu过高、网页假死等现象;同时对比了curl_init和curl_multi_init,多线程在速度上不一定优于单线程,多线程只是能在同时处理多任务,时间成本不一定低。附上curl_multi的使用步骤:
第一步:调用curl_multi_init;
第二步:循环调用curl_multi_add_handle;
这一步需要注意的是,curl_multi_add_handle的第二个参数是由curl_init而来的子handle;
第三步:持续调用curl_multi_exec;
第四步:根据需要循环调用curl_multi_getcontent获取结果;
第五步:调用curl_multi_remove_handle,并为每个字handle调用curl_close;
第六步:调用curl_multi_close。
六、PHP strstr()函数
strstr(string,search)搜索一个字符串在另一个字符串中的第一次出现。返回字符串的其余部分(从匹配点)。如果未找到所搜索的字符串,则返回 false。
search 必需。规定所搜索的字符串。如果该参数是数字,则搜索匹配数字 ASCII 值的字符。
参考:http://www.w3cschool.cn/func_string_strstr.html。所以,在给第二个参数时,如果需要匹配数字,建议加上引号。
七、论规范化的重要性
家附近的一条久治不下的道路,通过划分出人行通道、非机动车道、机动车道,使得问题一下子等到了解决。有时候灵活导致选择过多,问题也会很多;程序亦如此,用户输入的灵活看起来很不错,其实在后台处理时是需要更多的成本,何不在前期就进行规范化,bug止于源头,而不是亡羊补牢。规范化使一切流程变得简单高效。
八、HHVM
HHVM (HipHop Virtual Machine)会将PHP代码转换成高级别的字节码(通常称为中间语言)。然后在运行时通过即时(JIT)编译器将这些字节码转换为x64的机器码。
从各项数据表明,和Zend相比,HHVM变得更高效,CPU负载降低,平均页面加载时间也缩短。HHVM的存在是为了优化PHP运行性能,和php5相比,确实存在一些优势,还是坐等php7吧。
九、PHP源码签名收集器
当学习新的、不熟悉的源码时,对代码结构获取直观的感受是很重要的。可以通过从每个源文件中逐行获取标点进行总结,即文件签名。这可以帮助考量代码的复杂度。其实也就是提取代码文件中固定的符号呈现文件的结构。
参考:http://c2.com/doc/SignatureSurvey/
十、协同过滤推荐算法
1、基于内容的推荐算法的前提假设是:如果用户喜欢物品a,那么用户也应该会喜欢与a类似的物品。基本思想是拆分内容属性,提取相同属性的内容进行推荐。
2、协同过滤推荐算法的前提假设是:如果用户a与用户b均对一系列相同的物品表示喜欢,那么a极有可能也喜欢b用户喜欢的其他物品。基本过程是用户首先为每个item进行评价打分,通过计算不同用户评分之间的相似程度,可以找到最近邻居,根据最近邻居的评价,产生推荐。
上述算法都是运用了矩阵建模,使用到余弦相似度、皮尔逊相似度等公式。使用中可将二者合二为一推荐。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

The activation process on Windows sometimes takes a sudden turn to display an error message containing this error code 0xc004f069. Although the activation process is online, some older systems running Windows Server may experience this issue. Go through these initial checks, and if they don't help you activate your system, jump to the main solution to resolve the issue. Workaround – close the error message and activation window. Then restart the computer. Retry the Windows activation process from scratch again. Fix 1 – Activate from Terminal Activate Windows Server Edition system from cmd terminal. Stage – 1 Check Windows Server Version You have to check which type of W you are using
