mihomes Posted April 6, 2011 Share Posted April 6, 2011 Someone wrote this script for me ages ago - works fine on php4, but having some issues with php5 and the installation & reflect changes files... In a nutshell it takes a file called state.txt (all 50 states one per line) and creates a directory for each. There is then a text file for each state, for instance Alabama.txt, which has all the cities of that state. You end up with a directory for each state with directories of each city within them. Header and footer files as well as an index.php are used for each level. Trying to use this it creates the directores for each state, but does so in the root folder rather than the actual location of the file on the particular site. I realize $_SERVER['PATH_TRANSLATED'] has been removed, but replacing this with $_SERVER['SCRIPT_FILENAME'] doesn't seem to correct the issue. install.php <?php set_time_limit(0) ; $arr = explode("/",$_SERVER['PATH_TRANSLATED']); $ct = count($arr); unset($arr[$ct-1]); $path=implode("/",$arr); $path=$path."/"; if(is_file($path."state.txt")) { $lines = file($path."state.txt"); if($lines) { foreach($lines as $line) { if($line) { $state = trim($line); if(!is_dir($state)) { @mkdir($state,0777); if(is_file($path."copieble/state/index.php")) { $from = $path."copieble/state/index.php"; $to = $path.$state."/index.php"; @copy($from,$to); } } } } } } @chdir($path); $handle=opendir('.'); while (($file = readdir($handle))!==false) { @chdir($path); if (($file != ".") && ($file != "..")) { if(is_dir($file) && $file != "copieble" && $file !="_vti_cnf") { if(is_file($path.$file.".txt")) { $lines = file($path.$file.".txt"); if($lines) { foreach($lines as $line) { if($line) { $city = trim($line); @chdir($path.$file); if(!is_dir($city)) { @mkdir($city,0777); if(is_file($path."copieble/city/index.php")) { $from = $path."copieble/city/index.php"; $to = $path.$file."/".$city."/index.php"; @copy($from,$to); } } } } } } } } } closedir($handle); include("reflect_changes.php"); ?> reflect_changes.php <?php $arr = explode("/",$_SERVER['PATH_TRANSLATED']); $ct = count($arr); unset($arr[$ct-1]); $path=implode("/",$arr); $filepath=$path."/copieble/state/index.php"; //print_r($_SERVER); // Copy here the index file for all the states folder if(is_file($filepath)) { chdir($path); //echo "<br>".$path."/state"; $handle=opendir('.'); while (($file = readdir($handle))!==false) { if (($file != ".") && ($file != "..")) { if (is_dir($file) && $file !="copieble" && $file !="_vti_cnf") { $dst = $path."/".$file."/index.php"; @copy($filepath,$dst); } } } closedir($handle); } // Copy here the index file for all the cities in each states $filepath = $path."/copieble/city/index.php"; if(is_file($filepath)) { if(is_dir($path)) { chdir($path); //echo "<br>".$path."/state"; $handle=opendir('.'); while (($file = readdir($handle))!==false) { if (($file != ".") && ($file != "..")) { if (is_dir($file) && $file != "copieble" && $file !="_vti_cnf") { chdir($path."/".$file); $handle1=opendir('.'); while (($file1 = readdir($handle1))!==false) { if (($file1 != ".") && ($file1 != "..")) { if (is_dir($file1)) { $dst = $path."/".$file."/".$file1."/index.php"; @copy($filepath,$dst); } } } closedir($handle1); } chdir($path); } } closedir($handle); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/232823-deprecated-code-need-help/ Share on other sites More sharing options...
requinix Posted April 6, 2011 Share Posted April 6, 2011 Why aren't you doing the city and state stuff dynamically? Quote Link to comment https://forums.phpfreaks.com/topic/232823-deprecated-code-need-help/#findComment-1197617 Share on other sites More sharing options...
mihomes Posted April 6, 2011 Author Share Posted April 6, 2011 Why aren't you doing the city and state stuff dynamically? Like I said, I didn't write it... Quote Link to comment https://forums.phpfreaks.com/topic/232823-deprecated-code-need-help/#findComment-1197621 Share on other sites More sharing options...
matthew9090 Posted April 6, 2011 Share Posted April 6, 2011 itnt this thread supposed to be in the 3rd party scripts section then? Quote Link to comment https://forums.phpfreaks.com/topic/232823-deprecated-code-need-help/#findComment-1197623 Share on other sites More sharing options...
mihomes Posted April 6, 2011 Author Share Posted April 6, 2011 well I am the only person who has it - a friend wrote it for me years and years ago - its not like its for sale or anything so I wouldnt consider it a third party... Quote Link to comment https://forums.phpfreaks.com/topic/232823-deprecated-code-need-help/#findComment-1197625 Share on other sites More sharing options...
btherl Posted April 7, 2011 Share Posted April 7, 2011 If you add this code at the top it should help you find the right variable: print "<pre>"; var_dump($_SERVER); exit; That will show you everything in $_SERVER. Then you can choose whichever is suitable. If nothing is suitable you can try `pwd` (That's pwd in backquotes), and see if that works. Another option is the getcwd() function. Quote Link to comment https://forums.phpfreaks.com/topic/232823-deprecated-code-need-help/#findComment-1197983 Share on other sites More sharing options...
mihomes Posted April 7, 2011 Author Share Posted April 7, 2011 Played around with it today... a view path variables were wrong that I fixed and everything is working smoothly. At some point though I am going to clean up the code, but for now it is working correctly. Quote Link to comment https://forums.phpfreaks.com/topic/232823-deprecated-code-need-help/#findComment-1198042 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.