127.0.0.1 site cant be reached. Connection reset

230 Views Asked by At

I am trying to delete folders and recreate new and populate with new files

My PHP Code is as below

<?php 
set_time_limit(0);

function delete_files($dir) {
  if (is_dir($dir)) {
    $objects = scandir($dir);
    foreach ($objects as $object) {
      if ($object != "." && $object != "..") {
        if (filetype($dir."/".$object) == "dir") 
           delete_files($dir."/".$object); 
        else{if(is_file($dir."/".$object)){ unlink   ($dir."/".$object);}}
      }
    }
    reset($objects);
    rmdir($dir);
  }
 }


function recurse_copy($dir,array $scmum){
//  var_dump($scmum);
        foreach($scmum as $scf){
            if(!is_dir($scf) && $scf!='.htaccess' && $scf!='.' && $scf!='..'){
                if(copy("$basedir/$scf","$dir/$scf")){
                    if(is_file("$dir/.htaccess")){
                            unlink("$dir/.htaccess");
                        }
                        echo "$dir/$scf Copied<br>";
                }else{
                    $e=error_get_last();echo "Error 0 :".$e['message']."<br>";
                }
            }
                else{
                    recurse_copy($scf,$scmum);
                }
            }
    }

$basedir="subdomainfiles";
$scmum=scandir($basedir); 
include('connnew.php');
$getcities=$maindb->query("SELECT Location from clientdata GROUP BY Location ORDER BY Location ASC") or die($maindb->error);
while($infocit=$getcities->fetch_assoc()){
    $cityU=UCfirst(strtolower(str_replace(array(" ",","),"-",$infocit['Location'])));
    $cityL=strtolower(str_replace(array(" ",","),"-",$infocit['Location']));
    $title=$cityU;
    if(is_dir($cityU)){delete_files($cityU);}
    if(is_dir($cityL)){delete_files($cityL);}
    mkdir($cityL,0777,true);
//  var_dump($scmum);
    recurse_copy($cityL,$scmum);    
}

However, I get the above captioned error. The screen shot is below

Error Page

"This site can’t be reached The connection was reset. Try:

Checking the connection Checking the proxy and the firewall Running Windows Network Diagnostics ERR_CONNECTION_RESET"

Could this be because of the looping of the functions ?

0

There are 0 best solutions below