Hello! There is a script

<?php $to="info@info.ru"; $subj="info.ru: WARNING! MODIFY FILES"; $from="info.ru"; $url="http://info.ru"; $listfile="1txt.txt"; $list_file="2txt.txt"; GLOBAL $no_check,$total_size,$files,$folders; $no_check=array("index1.html","1txt.txt","2txt.txt","../../public_html/temp"); $root_dir="../../public_html"; $total_size=$files=$folders=0; $dir=opendir($root_dir); scan_dir($root_dir); function scan_dir($dirname){ GLOBAL $arr; $dir=opendir($dirname); while(($file=readdir($dir))!==false){ if($file!="."&&$file!=".."){ if(is_file($dirname."/".$file)){ if(!in_array($file,$GLOBALS['no_check'])){ $arr[]=str_replace($root_dir,"../",$dirname)."/".$file." &nbsp;***&nbsp; ВРЕМЯ ОБРАЩЕНИЯ К ФАЙЛУ: ".date("dmy H:i:s",filemtime($dirname."/".$file))." &nbsp;***&nbsp; РАЗМЕР В БАЙТАХ: ".filesize($dirname."/".$file); } $GLOBALS['files']++; $GLOBALS['total_size']+=filesize($dirname."/".$file); } if(is_dir($dirname."/".$file)){ $arr[]=$dirname."/".$file; $GLOBALS['folders']++; scan_dir($dirname."/".$file); } } } closedir($dir); } $list=fopen($listfile,"r+"); if($list AND filesize($listfile)>0){ $file=fopen($listfile,"r"); $bufer=fread($file,filesize($listfile)); fclose($file); $arr1=unserialize($bufer); $arr2=array_diff($arr,$arr1); $arr3=array_diff($arr1,$arr); if((count($arr2)+count($arr3))==0){ if($id==1) echo " Изменений файлов со времени последнего сканирования не обнаружено<br>"; }else{ $mess1="<span style='font-family:courier new;font-weight:bold;font-size:1.2em;'>Новые и измененные файлы</span><br /><br />\n"; if($id==1) $mess1.="<br />"; foreach($arr2 as $val){ $list_links=$val; $val1=substr($val,1); if(substr($val1,0,1)==".") $val1=substr($val1,1); if(substr($val1,0,1)==".") $val1=substr($val1,1); $val1=str_replace($root_dir,"",$val); $val2=str_replace($root_dir,"",$val); $val1="<a href=$url$val1 target=_blank>".$val1."</a><br><br>"; $mess1=$mess1."$val1 \n"; $links.=$list_links."\n"; } $mess2="<br />____________________________________________________________<br /><br />\n\n<span style='font-family:courier new;font-weight:bold;font-size:1.2em;'>Удаленные файлы и файлы измененные ранее</span><br /><br />\n"; foreach($arr3 as $val){ $mess2=$mess2."$val <br><br>\n"; } $mess=$mess1.$mess2; if(((1024*1024)>$total_size)&&($total_size>1024)) $size=(round($total_size/1024))." KИЛОБАЙТ"; elseif($total_size>(1024*1024)) $size=(round($total_size/1024/1024))." MЕГАБАЙТ"; $mess.="<br />____________________________________________________________<br /><br />\n<span style='font-family:courier new;font-size:1.2em;'>ОБЩИЙ ОБЪЕМ ФАЙЛОВ: $size ($total_size БАЙТ), ВСЕГО ФАЙЛОВ: $files, ПАПОК: $folders</span>"; if($id==1) echo $mess; $subj=convert_cyr_string(stripslashes($subj),w,k); $headers="MIME-Version: 1.0\n"; $headers.="From: $from\n"; $headers.="Content-type: text/html; charset=windows-1251"; mail($to,$subj,$mess,$headers); $str=serialize($arr); $file=fopen($listfile,"w"); fwrite($file,$str); fclose($file); $file_list_links=fopen($list_file,"w"); fwrite($file_list_links,$links); fclose($file_list_links); } }else{ $str=serialize($arr); $file=fopen($listfile,"w"); fwrite($file,$str); fclose($file); } ?> 

which scans the ubuntu file system for the presence / absence of changes in files, the presence of extraneous (new) files. The $ no_check array lists the files excluded from scanning. Can you please tell me how to add an entire directory to the exception (and with files in it, and an empty one)?

  • and where is your scan code? - teran
  • And why do you need a whole code? The only question is: "how to add an entire directory to the exception, i.e., how to specify something in the array so that the script considers this something as a folder and not as a file" ps If this is possible at all. - andry
  • @andry add the directory name to the array and check the directory or not. The code is needed for a minimally reproducible example and therefore for better answers - Alex
  • He pointed out the whole, de-mined as he could, so that quickly. - andry
  • 2
    you have an is_dir($dirname) check is_dir($dirname) in there and check that this $dirname does not fall into the exception array. - teran

0