Advanced PHP programming skills in Linux (3)

Source: Internet
Author: User
Tags password protection
PHP advanced programming skills in Linux (3)-Linux general technology-Linux programming and kernel information. The following is a detailed description. 6. to create dynamic images, you only need to install some third-party library files and have some geometric knowledge. You can use PHP to create and process images. In fact, this does not require much geometric knowledge, because I have not graduated from college and can still use PHP to create images. Install the GD library file before using basic image creation functions. If you want to create a function using JPEG-related images, you also need to install the jpeg-6b, and if you want to use the Type 1 Font in the image, you must install t1lib. Before creating an image creation environment, make some preparations. First, install t1lib; then install the jpeg-6b, and then install the GD library file. Be sure to install it in the order given here, because the jpeg-6b is used when compiling GD as the Library, and errors occur during compilation if the jpeg-6b is not installed. After installing these three components, you also need to reconfigure PHP, which is also one of the places you are glad to install PHP using DSO. Run make clean and add the following content to the current configuration: -- with-gd = [/path/to/gd] -- with-jpeg-dir = [/path/to/jpeg-6b] -- with-t1lib = [/path/to/t1lib] Done run the make command after adding the file, then run the make install command. Restart Apache and run phpinfo () to check whether the new settings have taken effect. Now you can start image creation. Depending on the version of the installed GD library file, you may or may not be able to create GIF or PNG format graphics files if installed with a gd-1.6 or a previous version, you can use a file in GIF format, but you cannot create a PNG file. If you are installing a version later than the gd-1.6, you can create a PNG file but not a file in GIF format. Many functions are required to create a simple image. In this example, we will create an image file in PNG format. The following code is a header containing the MIME type of the created image: The code for creating an image is as follows: If you save the script file as skyblue. php and access it with a browser, you will see an image in PNG format of the sky blue 250X250. We can also use the image creation function to process the image, for example, to make a large image into a small image: Suppose you have an image and want to crop A 35x35 image. What you need to do is to create a 35x35 blank image, create an image stream containing the original image, and then put the original image after the adjusted size into the new blank image. The key function to complete this task is ImageCopyResized (). The required format is as follows: ImageCopyResized ([new image handle], [original image handle], [new image X], [new Image Y], [original image X], [original image Y], [new image X], [new image Y], [original image X], [original image Y]) If you save this short script as resized. php and access it using a browser, you will see a 35x35 PNG image. 7. PHP-based user authentication if you want to implement password protection on each script, you can use the header () Statement, $ PHP_AUTH_USER, and $ PHP_AUTH_PW to establish a basic authentication scheme, generally, the server-based question/response sequence is as follows: 1. The user requests a file from the server. If the file is protected on the server, a 401 (indicating authorized users) string is returned to the user in the response header. 2. After the browser receives the response, a dialog box asking the user to enter the user name/password is displayed. 3. Enter a user name and password in the dialog box and click OK to return the information to the server for authentication. 4. If the user name and password are valid, the protected file will be open to the user. Authentication will always be valid as long as the user is still using the file. A simple PHP script file sends an appropriate HTTP header that can automatically display the user name/Password dialog box to imitate the HTTP question/response system, PHP stores the user input information in the username/password dialog box in $ PHP_AUTH_USER and $ PHP_AUTH_PW. These two variables are used, it can be compared with the user name/password stored in text files, databases, and other files. In this example, two hard-coded values are used for authentication. However, no matter where the user name and password are stored, the principles are the same. You're authorized!

";}}?> Note that if you are using a file-based protection mechanism, it does not guarantee the security of all files in the directory. It may protect most files. If you think it can protect all files in a given directory, you need to change your understanding. 8. PHP and COM if you like to take risks and run CGI, ISAPI, or Apache module version PHP on Windows, you can access COM functions. Well, I will give a detailed explanation of COM work to Microsoft and many big part books. In order to get a simple understanding of COM functions, the following is a short common script. This PHP script starts Microsoft Word processing on the backend, opens a new document, enters some text, saves the document, and closes the Word. Version}
"; // Set its visibility to 0 (false). If you want to enable it at the frontend, use 1 (true) // to open the application in the forefront, use 1 (true) $ word-> Visible = 0; // create a document in Word $ word-> Documents-> Add (); // Add the text $ word-> Selection-> TypeText ("Testing 1-2-3... "); // Save the document in the temporary Windows directory $ word-> Documents [1]-> SaveAs ("/Windows/temp/comtest.doc "); // close the connection to the COM component $ word-> Quit (); // display other information on the screen echo "Check for the file... ";?> If you have an intranet website where data is stored in SQL Server and you need the Excel format of the data, you can run the necessary SQL query in PHP and format the output, then, use COM to open Excel, convert the data into Excel format, and save the data on your desktop.
Related Article

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.