Первый сайт на PHP

ТЕКСТ СЦЕНАРИЯ



ТЕКСТ СЦЕНАРИЯ

Для лучшего восприятия информации данной главы далее приводится текст разобранного выше сценария без каких-либо комментариев.

Файл index.php

<html> <?php

$begin="files";

if ((strpos($fold,$begin)!=0)(strpos($fold,"..")!=False) | | ($fold== ¦¦'¦)) {

$dirct=$begin; }

else {

$dirct=$fold; }

echo ("<form action=zapros.php?folder=$dirct method=post>");

if ($dirct!=$begin) {

$back=substr ($dirct, 0, strrpos($dirct, "/")); echo ("<br><bxa href=index.php?fold=$back>KopHeBaH папка</ах/Ь><br>") ;

}



$hdl=opendir($dirct); while ($file = readdir($hdl)) {

if (($file!="..")&&($file!=".")) { $a[]=$file;

} }

closedir($hdl);

175

if (sizeof($a)>0)

asort($a); foreach ($a as $k)

$full=$dirct."/". $k;

echo ("<input name=fl[] value=$k type=checkbox>") ;

if (is_dir($full)==True)

echo ("<a href=index.php?fold=$fullxb>rianKa $k</bx/a>") ;

else

echo ("<a href=$full>$k</a>"); echo ("<br>");

?><brxinput type=submit value= "Удалить " name=udalxbr><input type=submit value="Переименовать" name=renxbrxinput type=submit value="Копировать" name=copyxbrxinput type=submit value="Создать папку" name=md>

</form></html>

Файл zapros.php

<htmlx?php

echo ("<form action=do.php?folder=$folder method=post>"); if ($udal!="") {

echo ("Удалить файлы?<br>"); foreach ($fl as $i) {

echo ("<input type=hidden name=fl[] value=$i>$i из папки $folder<br>");

}

echo ("<input type=submit value=\"Удалить\" name=udal>"); }

function tree($fld) {

global $ folder; global $fl;

176

$hdl=opendir($fld); while ($file = readdir($hdl)) {

if (($file!=".")&&($file!="..")) {

$fllnm=$fld."/".$file; if (is_dir($fllnm)==True) {


else {

unlink ($folder."/".$i); } } }

if ($ren!="") {

for ($i = 0; $i < sizeof ($afl); $i++) {

if (($rfl[$i] ! = -)&($rfl[$i] !=$afl[$i])& (strpos($afl[$i],"..")==False)) {

$rfl[$i]=strtr($rfl[$i], " []{},/\!@#$%л&*",

'.__________________________" ) I

rename ($folder."/".$af1[$i] , $folder."/".$rfl[$i]); }

} }

function copyfold ($rt, $fld, $tgt) {

if (file_exists($tgt."/".$fId)!=True) {

mkdir ($tgt."/".$fld, 0666); }

179

$hdl=opendir($rt.V".$fld); while ($file = readdir($hdl)) {

if (($file!="..")&&($file!=".")) {

if (is_dir($rt."/".$fld."/".$file)==True) {

copyfold($rt."/"-$fld, $file, $tgt."/".$fId); }

else {

copy ($rt."/".$fld."/".$file, $tgt."/".$fld."/".$file) ;

} } } closedir($hdl);

}

if ($copy!="") {

foreach ($fl as $i) {

if (is_dir($folder."/".$i)==True) {

if (!(strpos ($rd, $folder."/".$i)===0)) {

copyfold($folder, $i, $rd); } }

else { copy ($folder."/".$i, $rd."/".$i);

} } }

if ($md!="") { $newname=$folder."/".strtr($newname,

{},/\!@#$%л&*",

"____________________")

mkdir ($newname, 0666);

Header ("Location: index.php?fold=$folder")


Содержание раздела