标签:span back 图片 vat chm 无限 script || oca
// 把这两个文件放到一个文件夹,然后放到要更改的文件根目录。
像这样:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>SearchMatchStr</title> </head> <script src="https://cdn.bootcss.com/vue/2.4.2/vue.min.js"></script> <body> <div id="container"> <form action="searchReplaceStr.php" method="post" @submit="onSubmit"> <input type="text" name="target" v-model="target"> <span style="color:red;">替换为</span> <input type="text" name="strReplace" v-model="strReplace"> <button>Submit!</button> </form> </div> </body> <script type="text/javascript"> var app = new Vue({ el: ‘#container‘, data: { target: null, strReplace: null, }, methods: { onSubmit: function (e) { if (this.target && this.strReplace) { return true; } e.preventDefault(); } }, }) </script> </html>
// php脚本文件
<?php class searchReplaceStr{ private $search = null; private $matchStr = null; public function __construct ($search, $matchStr) { if ($search == null || $matchStr == null) { return false; } $this->search = $search; $this->matchStr = $matchStr; } private function modifyFile ($filename) { $fileHandler = fopen($filename, ‘r+‘); $modify = ‘‘; while (!feof($fileHandler)) { $source = fgets($fileHandler); $modify .= str_replace($this->search, $this->matchStr, $source); } if (!@unlink($filename)) { echo "delete file " . $filename . " success<br>"; } $newFileHandler = fopen($filename, ‘w‘); if (!feof($newFileHandler)) { fwrite($newFileHandler, $modify); } if (file_exists($filename)) { echo "create file " . $filename . " success<br>"; } } public function sourceDir($dir) { $files = array(); if ($dir != ".idea" && $dir != ‘serchReplaceStr‘) { if(@$handle = opendir($dir)) { while(($file = readdir($handle)) !== false) { if($file != ".." && $file != "." && $file != "searchReplaceStr.php" && $file != ‘index.html‘) { if(is_dir($dir."/".$file)) { $files[$file] = $this->sourceDir($dir."/".$file); } else { $this->modifyFile($dir . "/" .$file); } } } } } } } if (!is_null($_POST)) { $searchReplaceStr = new searchReplaceStr($_POST[‘target‘], $_POST[‘strReplace‘]); print_r($searchReplaceStr->sourceDir(‘../‘)); } else { echo "<script> alert(‘Please input value‘); location.href = ‘./index.html‘; </script>"; }
标签:span back 图片 vat chm 无限 script || oca
原文地址:https://www.cnblogs.com/phpcurd/p/9608049.html