PHP handles mht files
<span><?php </span><span>/** </span><span> * Created by PhpStorm. </span><span> * User: kungyu </span><span> * Date: 2015/12/3 </span><span> * Time: 15:30 </span><span> */ </span><span>class </span>mhtparse { <span>var </span><span>$file </span><span>= </span><span>''</span><span>; </span><span>var </span><span>$boundary </span><span>= </span><span>''</span><span>; </span><span>var </span><span>$filedata </span><span>= </span><span>''</span><span>; </span><span>var </span><span>$countparts </span><span>= </span><span>1</span><span>; </span><span>var </span><span>$log </span><span>= </span><span>''</span><span>; </span><span>function </span>extract() { <span>$this</span><span>-></span>read_filedata ()<span>; </span><span>$this</span><span>-></span>file_parts ()<span>; </span><span>return </span><span>1</span><span>; </span>} <span>function </span>set_file(<span>$p</span>) { <span>$this</span><span>-></span>file <span>= </span><span>$p</span><span>; </span>} <span>function </span>get_log() { <span>return </span><span>$this</span><span>-></span>log<span>; </span>} <span>function </span>file_parts() { <span>$lines </span><span>= </span>explode ( <span>"</span><span>\n</span><span>"</span>, substr ( <span>$this</span><span>-></span>filedata, <span>0</span>, <span>8192 </span>) )<span>; </span><span>foreach </span>( <span>$lines </span><span>as </span><span>$line </span>) { <span>$line </span><span>= </span>trim ( <span>$line </span>)<span>; </span><span>if </span>(strpos ( <span>$line</span>, <span>'=' </span>) <span>!== </span><span>FALSE</span>) { <span>if </span>(strpos ( <span>$line</span>, <span>'boundary'</span>, <span>0 </span>) <span>!== </span><span>FALSE</span>) { <span>$range </span><span>= </span><span>$this</span><span>-></span>getrange ( <span>$line</span>, <span>'"'</span>, <span>'"'</span>, <span>0 </span>)<span>; </span><span>$this</span><span>-></span>boundary <span>= </span><span>"--" </span><span>. </span><span>$range </span><span>[</span><span>'range'</span><span>]</span><span>; </span><span>$this</span><span>-></span>filedata <span>= </span>str_replace ( <span>$line</span>, <span>''</span>, <span>$this</span><span>-></span>filedata )<span>; </span><span>break</span><span>; </span>} } } <span>if </span>(<span>$this</span><span>-></span>boundary <span>!= </span><span>''</span>) { <span>$this</span><span>-></span>filedata <span>= </span>explode ( <span>$this</span><span>-></span>boundary, <span>$this</span><span>-></span>filedata )<span>; </span><span>unset </span>( <span>$this</span><span>-></span>filedata <span>[</span><span>0</span><span>] </span>)<span>; </span><span>$this</span><span>-></span>filedata <span>= </span>array_values ( <span>$this</span><span>-></span>filedata )<span>; </span><span>$this</span><span>-></span>countparts <span>= </span>count ( <span>$this</span><span>-></span>filedata )<span>; </span>} <span>else </span>{ <span>$tmp </span><span>= </span><span>$this</span><span>-></span>filedata<span>; </span><span>$this</span><span>-></span>filedata <span>= </span><span>array </span>( <span>$tmp </span>)<span>; </span>} } <span>function </span>get_all_part_file() { <span>return </span><span>$this</span><span>-></span>filedata<span>; </span>} <span>function </span>get_part_to_file(<span>$i</span>) { <span>$line_dat<strong>a_star</strong>t </span><span>= </span><span>0</span><span>; </span><span>$encoding </span><span>= </span><span>''</span><span>; </span><span>$part_lines </span><span>= </span>explode ( <span>"</span><span>\n</span><span>"</span>, ltrim ( <span>$this</span><span>-></span>filedata <span>[</span><span>$i</span><span>] </span>) )<span>; </span><span>foreach </span>( <span>$part_lines </span><span>as </span><span>$line_id </span>=> <span>$line </span>) { <span>$line </span><span>= </span>trim ( <span>$line </span>)<span>; </span><span>if </span>(<span>$line </span><span>== </span><span>''</span>) { <span>if </span>(trim ( <span>$part_lines </span><span>[</span><span>0</span><span>] </span>) <span>== </span><span>'--'</span>) <span>return </span><span>1</span><span>; </span><span>$line_dat<strong>a_star</strong>t </span><span>= </span><span>$line_id</span><span>; </span><span>break</span><span>; </span>} <span>if </span>(strpos ( <span>$line</span>, <span>':' </span>) <span>!== </span><span>FALSE</span>) { <span>$pos </span><span>= </span>strpos ( <span>$line</span>, <span>':' </span>)<span>; </span><span>$k </span><span>= </span>strtolower ( trim ( substr ( <span>$line</span>, <span>0</span>, <span>$pos </span>) ) )<span>; </span><span>$v </span><span>= </span>trim ( substr ( <span>$line</span>, <span>$pos </span><span>+ </span><span>1</span>, strlen ( <span>$line </span>) ) )<span>; </span><span>if </span>(<span>$k </span><span>== </span><span>'content-transfer-encoding'</span>) { <span>$encoding </span><span>= </span><span>$v</span><span>; </span>} <span>if </span>(<span>$k </span><span>== </span><span>'content-location'</span>) { <span>$location </span><span>= </span><span>$v</span><span>; </span>} <span>if </span>(<span>$k </span><span>== </span><span>'content-type'</span>) { <span>$contenttype </span><span>= </span><span>$v</span><span>; </span>} } } <span>foreach </span>( <span>$part_lines </span><span>as </span><span>$line_id </span>=> <span>$line </span>) { <span>if </span>(<span>$line_id </span><span><= </span><span>$line_dat<strong>a_star</strong>t</span>) <span>$part_lines </span><span>[</span><span>$line_id</span><span>] = </span><span>''</span><span>; </span>} <span>$part_lines </span><span>= </span>implode ( <span>''</span>, <span>$part_lines </span>)<span>; </span><span>if </span>(<span>$encoding </span><span>== </span><span>'base64'</span>) <span>$part_lines </span><span>= </span>base64_decode ( <span>$part_lines </span>)<span>; </span><span>elseif </span>(<span>$encoding </span><span>== </span><span>'quoted-printable'</span>) <span>$part_lines </span><span>= </span>imap_qprint ( <span>$part_lines </span>)<span>; </span><span>return </span><span>$part_lines</span><span>; </span>} <span>function </span>read_filedata() { <span>$handle </span><span>= </span>fopen ( <span>$this</span><span>-></span>file, <span>'r' </span>)<span>; </span><span>$this</span><span>-></span>filedata <span>= </span>fread ( <span>$handle</span>, filesize ( <span>$this</span><span>-></span>file ) )<span>; </span>fclose ( <span>$handle </span>)<span>; </span>} <span>function </span>getrange(<span>&</span><span>$subject</span>, <span>$Beginmark_str </span><span>= </span><span>'{'</span>, <span>$Endmark_str </span><span>= </span><span>'}'</span>, <span>$Start_pos </span><span>= </span><span>0</span>) { <span>/* </span><span> * $str="sssss { x { xx } {xx{xx } x} x} sssss"; $range=string::getRange($str,'{','}',0); echo $range['range']; //tulem: " x { xx } {xx{xx } x} x" echo $range['behin']; //tulem: 6 echo $range['end']; //tulem: 30 (' ') -- l5pum?¤rgist j?¤rgnev out: array('range'=>$Range,'begin'=>$Begin_firstOccurence_pos,'end'=>$End_sequel_pos) | false v1.1 2004-2006,Uku-Kaarel J5esaar,ukjoesaar@hot.ee,http://www.hot.ee/ukjoesaar,+3725110693 </span><span> */ </span><span>if </span>(<span>empty </span>( <span>$Beginmark_str </span>)) <span>$Beginmark_str </span><span>= </span><span>'{'</span><span>; </span><span>$Beginmark_str_len </span><span>= </span>strlen ( <span>$Beginmark_str </span>)<span>; </span><span>if </span>(<span>empty </span>( <span>$Endmark_str </span>)) <span>$Endmark_str </span><span>= </span><span>'}'</span><span>; </span><span>$Endmark_str_len </span><span>= </span>strlen ( <span>$Endmark_str </span>)<span>; </span><span>/* $Start_pos_cache = 0; */ </span><span>do </span>{ <span>/* !algus */ </span><span>if </span>(<span>! </span>is_int ( <span>$Begin_firstOccurence_pos </span>)) <span>$Start_pos_cache </span><span>= </span><span>$Start_pos</span><span>; </span><span>/* ?algus-test */ </span><span>$Start_pos_cache </span><span>= @</span>strpos ( <span>$subject</span>, <span>$Beginmark_str</span>, <span>$Start_pos_cache </span>)<span>; </span><span>/* this is possible start for range */ </span><span>if </span>(is_int ( <span>$Start_pos_cache </span>)) { <span>/* skip */ </span><span>$Start_pos_cache </span><span>= </span>(<span>$Start_pos_cache </span><span>+ </span><span>$Beginmark_str_len</span>)<span>; </span><span>/* test possible range start pos */ </span><span>if </span>(is_int ( <span>$Begin_firstOccurence_pos </span>)) { <span>if </span>(<span>$Start_pos_cache </span><span>< </span><span>$range_end_pos</span>) <span>$rangeClean </span><span>= </span><span>0</span><span>; </span><span>elseif </span>(<span>$Start_pos_cache </span><span>> </span><span>$range_end_pos</span>) <span>$rangeClean </span><span>= </span><span>1</span><span>; </span>} <span>/* here it is */ </span><span>if </span>(<span>! </span>is_int ( <span>$Begin_firstOccurence_pos </span>)) <span>$Begin_firstOccurence_pos </span><span>= </span><span>$Start_pos_cache</span><span>; </span>} <span>/* VIGA NR 0 ALGUST EI OLE */ </span><span>if </span>(<span>! </span>is_int ( <span>$Start_pos_cache </span>)) { <span>/* !algus */ </span><span> /* VIGA NR 1 ALGUSMARKI EI LEITUD : VIIMANE VOIMALIK ALGUS */ </span><span>if </span>(is_int ( <span>$Begin_firstOccurence_pos </span>) <span>and </span>(<span>$Start_pos_cache </span><span>< </span><span>$range_end_pos</span>)) <span>$rangeClean </span><span>= </span><span>1</span><span>; </span><span>else </span><span> return false</span><span>; </span>} <span>if </span>(is_int ( <span>$Begin_firstOccurence_pos </span>) <span>and </span>(<span>$rangeClean </span><span>!= </span><span>1</span>)) { <span>if </span>(<span>! </span>is_int ( <span>$End_pos_cache </span>)) <span>$End_sequel_pos </span><span>= </span><span>$Begin_firstOccurence_pos</span><span>; </span><span>$End_pos_cache </span><span>= </span>strpos ( <span>$subject</span>, <span>$Endmark_str</span>, <span>$End_sequel_pos </span>)<span>; </span><span>/* ok */ </span><span>if </span>(is_int ( <span>$End_pos_cache </span>) <span>and </span>(<span>$rangeClean </span><span>!= </span><span>1</span>)) { <span>$range_current_lenght </span><span>= </span>(<span>$End_pos_cache </span><span>- </span><span>$Begin_firstOccurence_pos</span>)<span>; </span><span>$End_sequel_pos </span><span>= </span>(<span>$End_pos_cache </span><span>+ </span><span>$Endmark_str_len</span>)<span>; </span><span>$range_end_pos </span><span>= </span><span>$End_pos_cache</span><span>; </span>} <span>/* VIGA NR 2 LOPPU EI LEITUD */ </span><span>if </span>(<span>! </span>is_int ( <span>$End_pos_cache </span>)) <span>if </span>(<span>$End_pos_cache </span><span>== </span><span>false</span>) <span>return false</span><span>; </span>} } <span>while </span>( <span>$rangeClean </span><span>< </span><span>1 </span>)<span>; </span><span>if </span>(is_int ( <span>$Begin_firstOccurence_pos </span>) <span>and </span>is_int ( <span>$range_current_lenght </span>)) <span>$Range </span><span>= </span>substr ( <span>$subject</span>, <span>$Begin_firstOccurence_pos</span>, <span>$range_current_lenght </span>)<span>; </span><span>else </span><span> return false</span><span>; </span><span>return array </span>( <span>'range' </span>=> <span>$Range</span>, <span>'begin' </span>=> <span>$Begin_firstOccurence_pos</span>, <span>'end' </span>=> <span>$End_sequel_pos </span>)<span>; </span>} <span>// end getrange() </span>} <span>// class </span><span>/*$filename = './test.mht'; </span><span>if (file_exists ( $filename )) { </span><span> if (is_dir ( $filename )) return false; </span><span> $filename = strtolower ( $filename ); </span><span> if (strpos ( $filename, '.mht', 1 ) == FALSE) return false; </span><span> $o_mhtml = new mhtparse (); </span><span> $o_mhtml->set_file ( $filename ); </span><span> $o_mhtml->extract (); </span><span> $res = $o_mhtml->get_part_to_file(0); </span><span> var_dump($res); </span><span>}*/</span></span>
The above introduces PHP's processing of mht files, including a_star content. I hope it will be helpful to friends who are interested in PHP tutorials.

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

AI Hentai Generator
Generate AI Hentai for free.

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

According to news from this website on February 14, Yahoo LINE announced today that a Korean outsourcing company was illegally accessed, and the information of about 57,000 LINE employees may have been leaked. It has not yet been confirmed whether any user or business partner information has been leaked. Following the leakage of user information by the LINE app in November 2023, the company's lax information management was exposed one after another. According to Yahoo LINE officials, between August and November 2023, two outsourcing Korean companies received unauthorized access and third-party intrusions, and the email addresses, phone numbers and photos of 57,611 employees were potentially leaked. It has not yet been confirmed whether secondary damage was caused by the use of employee information. Yahoo LINE announces its service in November 2023

This article will explain in detail how PHP returns all the values of an array to form an array. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. Using the array_values() function The array_values() function returns an array of all the values in an array. It does not preserve the keys of the original array. $array=["foo"=>"bar","baz"=>"qux"];$values=array_values($array);//$values will be ["bar","qux"]Using a loop can Use a loop to manually get all the values of the array and add them to a new

Line is an instant messaging software launched by NHN Japan, the Japanese subsidiary of the Korean Internet group NHN. Its main functions include: 1. You can make free calls at any time when data traffic is activated or connected to wifi; 2. As long as it is a LINE smartphone Users can make free calls between users; 3. Stickers that can better express moods, etc.

What is POS coin? POS coin, that is, ProofofStake coin, is a cryptocurrency consensus mechanism, which is different from Bitcoin's proof of work (ProofofWork). The consensus algorithm of POS coins depends on the number and time of coins held. Holders can earn corresponding rewards by holding coins and locking them up (usually taking a certain amount of time). In short, POS coin rewards holders based on the amount of coins they hold and the lock-up time. Advantages of POS currency Compared with POW currency, POS currency pays more attention to the trust and participation of holders, so its consensus mechanism is more energy efficient. POW coins require a large amount of electricity to complete the consensus process, while POS coins ensure the security and stability of the network through the investment and trust of holders. This kind of base

Preface In Java, the Range method is available in both IntStream and LongStream classes. In IntStream class, it helps to return the sequential value of IntStream within function parameter scope. In the method, startInclusive(inclusive) and endExclusive(exclusive) are the two parameters used along with the increment step size, as mentioned before, the start value will be included and the end value will be excluded. In the case of LongStream, the only difference is the addition of the LongStream value. Range Syntax Let us see the syntax of range method in Java. IntStream range

Go language is a concise and powerful programming language with unique design and features in many aspects. One of the most impressive features is the range keyword, which is used to iterate over data structures such as arrays, slices, maps, and channels. The flexibility and convenience of range make it easy to traverse complex data structures, but many people are confused about how it works. This article will explain how range works in a simple and in-depth way, and use specific code examples to help readers better understand. First, let's look at a simple example

A colleague got stuck due to a bug pointed by this. Vue2’s this pointing problem caused an arrow function to be used, resulting in the inability to get the corresponding props. He didn't know it when I introduced it to him, and then I deliberately looked at the front-end communication group. So far, at least 70% of front-end programmers still don't understand it. Today I will share with you this link. If everything is wrong If you haven’t learned it yet, please give me a big mouth.

GM's electric take on the legendary Escalade just got its configurator up, and the price ranges from$130,000 to about $170,000 after incentives. This is more than nearly any other luxury electric vehicle, pickup, or SUV out there, including Tesla's C
