Header("Content-type: image/png"); /*Notify the browser that an image is to be output*/
$im = imagecreate(400, 300); /*Define the image Size*/
$gray = ImageColorAllocate($im, 235, 235, 235);
$pink = ImageColorAllocate($im, 255, 128, 255);
$fontfile = "simkai.ttf";
/* $fontfile The path of the font, depending on the operating system, can be simhei.ttf (Heold), SIMKAI.TTF (Italic), SIMFANG.TTF (Imitation Song), SIMSUN.TTC (Song style & New Song style) and other Chinese fonts supported by GD*/
$str = iconv('GB2312','UTF-8','Chinese watermark'); /*Convert gb2312 character set to UTF-8 characters*/
**Description: This is a custom class used to add a bottom watermark to the specified image (does not occupy the image display area), you need to create an object to call
* *Created: 2007-10-09
**Updated: 2007-10-09
**Instructions: 1. Requires gd library support and iconv support (php5 is already included and does not need to be loaded)
2. Only suitable for three types of images , jpg/jpeg/gif/png, other types are not processed
3. Note that the attributes of the directory where the image is located must be writable
var $Path = " ./"; //The relative path of the directory where the picture is located relative to the page that calls this class
var $FileName = ""; //The name of the picture, such as "1.jpg"
var $Text = ""; //Picture The watermark text to be added supports Chinese
var $TextColor = "#ffffff"; //The color of the text. For gif pictures, the font color can only be black
var $TextBgColor = "#000000"; //The background of the text Bar color
var $Font = "c://windows//fonts//simhei.ttf"; //Font storage directory, relative path
var $OverFlag = true; //Whether to overwrite the original image, the default is Overwrite. When not overwriting, it will automatically add "_water_down" after the original image file name, such as "1.jpg" => "1_water_down.jpg"
var $BaseWidth = 200; //The width of the image must be at least >=200, Watermark text will be added.
//-------------
//Function: Class constructor (php5.0 or above)
//Parameters: None
//Return: None
function __construct( ){;}
//---------------------
//Function: Class destructor (php5.0 or above)
//Parameters: None
//Returns: None
function __destruct(){;}
//----------------------
//Function: Object Run the function and add watermark to the image
//Parameters: None
//Return: None
function Run()
{
if($this->FileName == "" || $this->Text == "")
return;
//Check whether the GD library is installed
if(false == function_exists("gd_info"))
{
echo "The GD library is not installed on the system, and the image cannot be watermarked.";
return;
}
//Set the input and output image path names
$arr_in_name = explode(".",$this->FileName);
//
$inImg = $this->Path.$this->FileName;
$outImg = $inImg;
$tmpImg = $this->Path.$arr_in_name[0]."_tmp.".$arr_in_name[1]; //Temporarily processed pictures, very important
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,
Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo
Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.
Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.
The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.
Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.