ShadowIce Posted February 2, 2011 Share Posted February 2, 2011 Hi all. I'm having a bit of trouble with my script. I can't get "getDirectoryListings()" to return what folders are inside of #SharedObjects Here's my 2 files, 1 is sollib.php, the other is solindex.php. solindex.php: <?php require('sollib.php'); $shell= new COM('WScript.Shell'); $data=$shell->regRead('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir'); $regval = trim($data, "Program Files"); if(getenv('AppData')!=''){ $filename = getenv('AppData')."\\Macromedia\\FlashPlayer\\#SharedObjects\\".getDirectoryListings(); die($filename); } ?> sollib.php: <?php die(getDirectoryListings()); function getDirectoryListings() { $final = ""; $filename = getenv('AppData')."\\Macromedia\\FlashPlayer\\#SharedObjects\\"; if ($handle = opendir($filename)) { while (false !== ($file = readdir($handle))) { if(($file != '.') && ($file != '..')) { if(!strpos($file,'.')) { if ($handle2 = opendir($filename.$file)) { while (false !== ($file2 = readdir($handle2))) { die($file2); if(($file2 != '.') && ($file2 != '..')) { $final = $filename."$file\\$file2\\".get_files($file2); die($final); if($file2 == 'www.xatech.com'){ die('files: '.get_files($file2)); } } } } }else{ $final = $file; } } } closedir($handle); } return $final; } function get_files($dir){ //path to directory to scan $directory = $dir; //get all sol files with a .sol extension. $file11 = glob("" . $directory . "*.sol"); //print each file name foreach($file11 as $files10){ $final = $files10; die($final); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/ Share on other sites More sharing options...
BlueSkyIS Posted February 2, 2011 Share Posted February 2, 2011 echo $filename. does it exist? Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/#findComment-1168861 Share on other sites More sharing options...
ShadowIce Posted February 2, 2011 Author Share Posted February 2, 2011 No. it's not supposed to echo it out. it's supposed to return a value. Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/#findComment-1168863 Share on other sites More sharing options...
BlueSkyIS Posted February 2, 2011 Share Posted February 2, 2011 i mean echo the value of $filename to see if it is a valid path to a file. Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/#findComment-1168875 Share on other sites More sharing options...
ShadowIce Posted February 2, 2011 Author Share Posted February 2, 2011 Hey guys, can someone please tell me why print_r($file11); is returning a blank Array? It returns: Array( ) solindex.php: <?php require('sollib.php'); $shell = new COM('WScript.Shell'); $data = $shell->regRead('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir'); $regval = trim($data, "Program Files"); if (getenv('AppData') != '') { $filename = getenv('AppData') . "\\Macromedia\\FlashPlayer\\#SharedObjects\\" . getDirectoryListings(); print_r($filename); } ?> sollib.php: <?php function getDirectoryListings() { $files = ""; $directory = getenv('AppData') . "\\Macromedia\\FlashPlayer\\#SharedObjects\\"; $files = $directory . "/" . $files; $array_items[] = preg_replace("/\/\//si", "/", $files); $dir = get_files($files); print_r($dir); return $dir; } function get_files($dir) { $final = ""; //path to directory to scan $directory = $dir; //get all sol files with a .sol extension. $file11 = glob($directory . "*/*/*.sol"); print_r($file11); //print each file name foreach ($file11 as $files10) { $final = $files10; print_r($final); } return $final; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/#findComment-1168961 Share on other sites More sharing options...
BlueSkyIS Posted February 2, 2011 Share Posted February 2, 2011 deleted due to incorrect info. Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/#findComment-1168984 Share on other sites More sharing options...
kenrbnsn Posted February 2, 2011 Share Posted February 2, 2011 No, "." means same directory, the "*" is the wild character which means match any file. Ken Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/#findComment-1168989 Share on other sites More sharing options...
BlueSkyIS Posted February 2, 2011 Share Posted February 2, 2011 No, "." means same directory, the "*" is the wild character which means match any file. Ken Yes, you are correct. I spaced and was thinking ././././. sorry for the misinformation, and thank you for the correction! Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/#findComment-1168991 Share on other sites More sharing options...
ShadowIce Posted February 2, 2011 Author Share Posted February 2, 2011 Ok guys. i redid the ENTIRE code. Can someone make this code simply return all the folders in the #SharedObjects directory, and all the files in the MF8YJLJR/www.xatech.com folder? i simply want it to echo out. solindex.php: <?php $shell = new COM('WScript.Shell'); $data = $shell->regRead('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir'); $regval = trim($data, "Program Files"); require('sollib.php'); ?> sollib.php: <?php $dir = getenv('AppData') . "\\Macromedia\\FlashPlayer\\#SharedObjects\\"; function get_dirs() { $final = ""; return $final; } function get_files($dir) { $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $files[] = $filename; } } function getDirectoryListings() { $dir = getenv('AppData') . "\\Macromedia\\FlashPlayer\\#SharedObjects\\MF8YJLJR\\www.xatech.com" . "\\"; $dirs = $dir . get_dirs() . get_files($dir); print_r($dirs); return $dirs; } getDirectoryListings(); ?> thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/#findComment-1169034 Share on other sites More sharing options...
ShadowIce Posted February 2, 2011 Author Share Posted February 2, 2011 Forgot to mention, MF8YJLJR should be replaced with the get_dirs() function. Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/#findComment-1169036 Share on other sites More sharing options...
ShadowIce Posted February 2, 2011 Author Share Posted February 2, 2011 Anyone? :/ Quote Link to comment https://forums.phpfreaks.com/topic/226455-getdirectorylistings-not-returning-anything/#findComment-1169084 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.