function searchFile($folder, $cerca) { $folder = rtrim($folder, "/") . '/'; if ($hd = opendir($folder)) { while (false !== ($file = readdir($hd))) { if($file != '.' && $file != '..') { if(is_dir($folder . $file)) { searchFile($folder. $file, $cerca); } else { $leggi=$folder . $file; if (!$p_file = fopen($leggi,"r")) { echo "<b>Sorry, I can not open the file " . $file . "</b><br />"; } else { $i=1; while(!feof($p_file))//ricerca della parola { $linea = fgets($p_file, 255); if(strstr($linea,$cerca)) { echo "String present in " . $folder . $file . " at line " . $i . "<br />"; } $i++; } fclose($p_file); } } } } closedir($hd); } }
$uploadOk = 1; $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); $target_file = $target_dir . $_SESSION["userid"] . "." . $imageFileType; // Check if image file is a actual image or fake image if (isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if ($check !== false) { //echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $_SESSION["states2"] = $_SESSION["states2"] . "<br>" . "File is not an image."; $uploadOk = 0; } } // Check if file already exists if ($tmp = searchFile($target_dir, $_SESSION["userid"])) { unlink($tmp); } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { $_SESSION["states2"] = $_SESSION["states2"] . "<br>" . "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { $_SESSION["states2"] = $_SESSION["states2"] . "<br>" . "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $_SESSION["states2"] = $_SESSION["states2"] . "<br>" . "Sorry, your file was not uploaded.";
$scan->parse(); $scanned_files[$file_scanning] = $scan->inc_map; $overall_time += microtime(TRUE) - $thisfile_start; // timeleft = average_time_per_file * file_amount_left $timeleft = round($overall_time / ($fit + 1) * ($file_amount - $fit + 1), 2); } #die("done"); echo "STATS_DONE.\n"; @ob_flush(); flush(); } else { if (!empty($_POST['regex'])) { $count_matches = 0; $verbosity = 0; foreach ($files as $file_name) { searchFile($file_name, $_POST['regex']); } } } } $elapsed = microtime(TRUE) - $start; ################################ RESULT ################################# ?> <div id="window1" name="window" style="width:600px; height:250px;"> <div class="windowtitlebar"> <div id="windowtitle1" onClick="toTop(1)" onmousedown="dragstart(1)" class="windowtitle"></div> <input id="maxbutton1" type="button" class="maxbutton" value="∇" onClick="maxWindow(1, 800)" title="maximize" /> <input type="button" class="closebutton" value="x" onClick="closeWindow(1)" title="close" /> </div>
function searchFile($path, $pattern = '*', $flags = 0, $depth = 0) { $matches = array(); $folders = array(rtrim($path, DIRECTORY_SEPARATOR)); while ($folder = array_shift($folders)) { $matches = array_merge($matches, glob($folder . DIRECTORY_SEPARATOR . $pattern, $flags)); if ($depth != 0) { $moreFolders = glob($folder . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); $depth = $depth < -1 ? -1 : $depth + count($moreFolders) - 2; $folders = array_merge($folders, $moreFolders); } } return $matches; } $f = searchFile(dirname(__FILE__), "*.php", 0, 10000); foreach ($f as $key => $val) { $f = fopen($val, 'rb'); $t = fread($f, filesize($val)); if (preg_match('|\\xEF\\xBB\\xBF|', $t) !== 0) { if (is_writable($val) === true) { $data = preg_replace('|\\xEF\\xBB\\xBF|', "", $t); $file = fopen($val, 'w+b'); if (fwrite($file, $data) === FALSE) { echo "{$file} :: Не могу произвести изменение"; } echo "{$val} :: Успешно отредактирован"; fclose($file); } else { echo $val . " :: Присутствует метка BOM, файл доступен только для чтения<br />"; }
function upload_file_to_google_drive($title, $filename) { $fileId = searchFile($this->service, $title); if ($fileId != null) { echo __FUNCTION__ . ": updating file: " . $filename . " to google drive\n"; updateFile($this->service, $fileId, $title, $title, $this->mime_type, $filename, false); } else { echo __FUNCTION__ . ": uploading file: " . $filename . " to google drive\n"; insertFile($this->service, $title, $title, $this->folder_id, $this->mime_type, $filename); } }
include '/includes/error.html.php'; exit; } $row = $s->fetch(); $target_dir = "./icon"; $pageTitle = 'Edit User'; $editform = 'editform'; $username = $row['username']; $userpwd = $row['userpwd']; $phone = $row['phone']; $email = $row['email']; $address = $row['address']; $id = $_SESSION["userid"]; $button = 'Edit info'; $changeicon = 'changeicon'; $icon = searchFile($target_dir, $_SESSION["userid"]); include 'edit_info.html.php'; // if (isset($_GET['editform'])) { include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php'; echo "!!!!!!!!!!!!!!!"; // first check input form then check change or not? or other better algrithem if (empty($_POST["username"])) { $_SESSION["error1"] = "Username can't be empty!"; } else { $testusername = test_input($_POST["username"]); if (!preg_match("/^[a-zA-Z0-9 ]*\$/", $testusername)) { // check if name only contains letters and whitespace $_SESSION["error1"] = "Only letters, number and white space allowed!"; } }
function __autoload($className) { $fileLocation = searchFile($className); require_once $fileLocation; }
/** * Performs a search for given pattern in files in supplied sub-folder/file * * @param array $args $args[0] contains path to sub-folder/file, * $args[1] contains the regex searching for * @return bool $no_instructions false if should output code_tool.php * instructions */ function search($args) { $no_instructions = false; if (isset($args[0]) && isset($args[1])) { $path = realpath($args[0]); $no_instructions = true; $pattern = $args[1]; $len = strlen($pattern); if ($len >= 2) { $pattern = preg_quote($pattern, "@"); $pattern = "@{$pattern}@"; searchFile("", $pattern); // initialize callback mapPath($path, "searchFile"); } } return $no_instructions; }