Research on some knowledge points of PHP (i)

Source: Internet
Author: User
Tags hhvm

Webshell attack based on PHP implementation

See a PHP-based Webshell attack on a cloud.

Highly covert Webshell, the use of ordinary PHP code to the real shell content after layers of encryption to save to the picture, leaving only a URL, and the URL is encrypted, so there is no external features can be found, making it difficult to find, when opening the above URL, The display is 404, and this 404 page is disguised as 404 Trojan, just changed the title to 404 Not Found.

Second, no or less with the Else statement

For if else someone pursues the integrity of the structure, if there must be else, this may seem good, but sometimes it can lead to cumbersome code, and may result in logic confusion, and can be based on a result, when other circumstances to do if judgment, that is, default A, the exception is B;

Three, single page structure (single-page application)

Single page is all the operation and layout is done under a page, do not need page jump, according to different user requests to load different content.

Advantages: The page structure is simple, data volume is small, bandwidth saving, fast response, good experience, easy to develop, maintain and optimize;

Cons: Using AJAX technology, resulting in unfavorable SEO.

Four, let the search engine crawl Ajax content

Mainly for the previous case of the single page structure, the program through the # Structure URL control page content, but will not be crawled by the search engine.

Method One: Twitter uses the "pound + exclamation" structure, but the experience is not good and cumbersome;

Method Two: Use the history API to change the address displayed in the browser's address bar without refreshing the page. The steps are as follows:

A, with the history API to replace the structure of the well, so that each # has become a normal path URL, so that the search engine will crawl every page.

B. Define a JavaScript function to handle the AJAX part and crawl the content according to the URL.

C, define the mouse click event, use the Popstate event of the history object to handle the browser's forward/Back button.

D, set the server side.

Wu, Curl_multi_init ()

Used to have been using Curl_init (), recently saw Curl_multi_init (); This thought will bring more efficient code, looked at the next curl_multi steps, feel quite cumbersome, and curl_multi may cause excessive CPU, Web page suspended animation and other phenomena At the same time, compared with Curl_init and Curl_multi_init, multithreading in the speed is not necessarily better than single-threaded, multithreading is only able to handle multitasking at the same time, the cost is not necessarily low. Attach the steps for using Curl_multi:

The first step: Call Curl_multi_init;

The second step: cyclic call curl_multi_add_handle;

This step needs to be noted that the second parameter of Curl_multi_add_handle is a sub-handle from Curl_init;

The third step: continue to call curl_multi_exec;

Fourth step: Loop call Curl_multi_getcontent to get the result as needed;

Fifth step: Call Curl_multi_remove_handle, and call curl_close for each word handle;

Sixth step: Call Curl_multi_close.

Vi. PHP strstr () function

STRSTR (String,search) searches for the first occurrence of a string in another string. Returns the remainder of the string (from the matching point). returns false if the searched string is not found.


Search required. Specifies the string to search for. If the parameter is a number, the character that matches the ASCII value of the number is searched.

Reference: Http://www.w3cschool.cn/func_string_strstr.html. Therefore, when giving the second argument, if you need to match the number, it is recommended to enclose the quotation marks.

Vii. on the importance of standardization

Near the home of a Jiuzhi road, by dividing the pedestrian channel, non-motorized road, the motorway, so that the problem suddenly wait until the solution. Sometimes the flexibility leads to too much choice, the problem will be many, the program is also so, the flexibility of user input looks very good, in fact, in the background processing is needed more cost, why not in the early period of standardization, bug stop at the source, not to mend. Normalization makes all processes simple and efficient.

Eight, HHVM

HHVM (HipHop Virtual machine) translates the PHP code into a high-level bytecode (often referred to as an intermediate language). These bytecode are then converted to the x64 machine code by the Instant (JIT) compiler at run time.

The data show that, compared to Zend, HHVM becomes more efficient, CPU load is reduced, and average page load times are shortened. The existence of HHVM is to optimize PHP performance, compared with PHP5, there are some advantages, or wait for the PHP7 bar.

Nine, PHP source signature collector

When learning new and unfamiliar source code, it is important to get an intuitive sense of the structure of the codes. You can summarize the file signature by getting the punctuation line from each source file. This can help to consider the complexity of the code. In fact, it is the structure of the file that extracts the fixed symbol in the code file.

Reference: http://c2.com/doc/SignatureSurvey/

Ten, collaborative filtering recommendation algorithm

1, the premise of the content-based recommendation algorithm is: If the user likes item A, then the user should also like a similar items. The basic idea is to split the content properties and extract the contents of the same attribute for recommendation.

2. The premise of collaborative filtering recommendation algorithm is that if both user A and User B are interested in a series of identical items, a is likely to like other items that B users like. The basic process is that the user first evaluates each item, and by calculating the similarity between different user ratings, the nearest neighbor can be found, based on the nearest neighbor's evaluation, to generate recommendations.

The above algorithms are based on the matrix modeling, using the cosine similarity, Pearson similarity and other formulas. It is recommended to combine the two in use.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.