-
- $file="aa.php" ;
- $code="";
- $ f=fopen($file,"r+");
- $content=fread($f,filesize($file));
- fclose($f);
- if(!strstr($content,$code)){
- $arrInsert = insertContent($file, $code, 3);
- unlink($file);
- foreach($arrInsert as $value)
- {
- file_put_contents($file, $value, FILE_APPEND);
- }
- }
- function insertContent($source, $s, $iLine) {
- $file_handle = fopen($source, "r");
- $i = 0;
- $arr = array();
- while (!feof($file_handle)) {
- $line = fgets($file_handle);
- ++$i;
- if ($i == $iLine) {
- $arr[] = $line .$s . "n";
- }else {
- $ arr[] = $line;
- }
- }
- fclose($file_handle);
- return $arr;
- }
- ?>
-
Copy the code
and save it as demo.php, and then use a small program to separate it It only takes a few minutes to execute it.
Browsers like Opera have this function. But I added another html code to run it. You can use IE. You can just open the html and throw it wherever you want.
Instructions:
These codes will be written in php, and you can write a rule to prohibit modification of php files.
|