New Concept of PHP thief Program-resource localization (I)

Source: Internet
Author: User

Recently, I launched an seo project targeting some excellent websites and turning their resources into our own.

The requirement is: Real-time update, static page localization, and localized pages cannot contain the original themes.

Real-time update and replacement of theme can be implemented by common thieves, but the page must be downloaded for localization. In this way, attention should be paid to a series of problems such as style, image path, and real-time update.

Css, js, images, and other resources must be downloaded to the local device. It is okay to download one or two of these files. Once you download them in batch, you must carefully observe their path rules. In addition, css usually contains background images, this also requires local images. So first, we need to solve the resource localization problem. I wrote a class for the localization of thieves. There are several methods to implement resource localization. Currently, we will first demonstrate the methods for resource localization, the following describes all the code that will be open-source and how to use it:

/*** Generate a folder without generating a file ** @ param $ address */public function get_file_adress ($ address) {// $ first = substr ($ address, 0, 1); $ dirs = explode ('/', $ address); $ this-> array_remove_empty ($ dirs); // $ address = implode ($ dirs, '/'); // if ($ first = '/') $ address = '/'. $ address; $ dirs = array_values ($ dirs); $ nums = count ($ dirs); if ($ nums> 1) {$ s = 0; while ($ s <$ nums-1) {$ dirs [$ s] = self: filename_safe ($ dirs [$ s]); if (! File_exists ($ dirs [$ s]) {if (self: filename_check ($ dirs [$ s]) {if (! File_exists ($ dirs [$ s]) @ $ mkdir = mkdir ($ dirs [$ s], 0777) ;}++ $ s; $ dirs [$ s] = $ dirs [$ s-1]. "/". $ dirs [$ s] ;}}/ *** generate a file ** @ param $ filename * @ param $ url */private function grab_file ($ filename, $ url) {if ($ url = "") return false; if ($ filename = "") return false; // echo $ filename. '| '. $ url. '

Use the get_file_adress function to generate the folder where the file is stored, and then use grab_file to generate the file.

Demo: http://news.80jiaju.com/

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.