Results 1 to 10 of 31
Hybrid View
-
6th Jul 2010, 06:03 PM #1OPMemberWebsite's:
maxneeds.infoPHP Scan dir for idetical files
I am not good with php and will ask for help...
* The folder is named 'fav'
* There are subfolders in 'fav'
* Each subfolder may contain a .txt file
Needed -->
* Check for identical .txt file names in all subfolders
* Sort 10 most repeating identicals,show(echo) their contents and show(echo) times repeated (in brackets such as this one )
And.. that's it !
I hope you'll code it easily for me..
THANKS !Porsche_maniak Reviewed by Porsche_maniak on . PHP Scan dir for idetical files I am not good with php and will ask for help... * The folder is named 'fav' * There are subfolders in 'fav' * Each subfolder may contain a .txt file Needed --> * Check for identical .txt file names in all subfolders * Sort 10 most repeating identicals,show(echo) their contents and show(echo) times repeated (in brackets such as this one :D ) Rating: 5
-
7th Jul 2010, 09:28 AM #2OPMemberWebsite's:
maxneeds.infoIf i am unclear with something please tell..
-
7th Jul 2010, 06:23 PM #3MemberWebsite's:
litewarez.net litewarez.com triniwarez.comWell this would have to be done recursively.
PHP Code:
$storage = array();
function ScanForTextFiles($folder)
{
global $storage;
$resource = opendir($folder);
while(false != ($file = readdir($resource)))
{
$current = $folder . $file;
if($file != '.' || $file != '..' && is_dir( $current )) //Changed to file from current
{
ScanForTextFiles($current);
}elseif(is_file($current) && substr($current,-3) == 'txt') //Updated to check format
{
if(!isset($storage[$file]))
{
$storage[$file] = 0; //Start with 0 counts
}else
{
$storage[$file]++; //Add 1 more count
}
}
}
}
ScanForTextFiles('path/to/fav/'); //WITH LAST SLASH
Code is untested.Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
7th Jul 2010, 07:04 PM #4OPMemberWebsite's:
maxneeds.infoI tried everything and gives errors.
Also i saw that it finds files in fav folder which are outside it (one level down).
Btw the folder is just 'fav/' and i want to be sorted in numeric and show the most 10..
opendir(fav/..login.php) [function.opendir]: failed to open dir: No such file or directory in
-
7th Jul 2010, 08:13 PM #5MemberWebsite's:
litewarez.net litewarez.com triniwarez.comtry now and report back.
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
8th Jul 2010, 11:06 AM #6OPMemberWebsite's:
maxneeds.infoerror without last slash
Code:Warning: opendir(fav....................................................................................................................................................................................................................................New Text Document.txt) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\downloads\stats.php on line 219 Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\downloads\stats.php on line 220 Warning: opendir(fav.......................................................................................................................................................................................................................................) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\downloads\stats.php on line 219
Code:Warning: opendir(fav/..options_cgi.php) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\downloads\stats.php on line 219 Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\downloads\stats.php on line 220 Warning: opendir(fav/..partner1.html) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\downloads\stats.php on line 219 Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\downloads\stats.php on line 220 Warning: opendir(fav/..people.html) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\downloads\stats.php on line 219
-
8th Jul 2010, 12:01 PM #7MemberWebsite's:
litewarez.net litewarez.com triniwarez.comPHP Code:<?php
function RecurseFolderLister($d)
{
$BasePath = realpath($d);
$Storage = array();
if(is_dir($BasePath))
{
$resource = opendir($BasePath);
while(false !== ($directory = readdir($resource)))
{
if(is_dir($BasePath . '/' . $directory) && !in_array($directory,array('.','..'))) //DirCheck the TypeCheck
{
$Storage = array_merge($Storage,RecurseFolderLister($BasePath . '/' . $directory));
}else
{
if(is_file($BasePath . '/' . $directory) && substr($directory,-3) == 'txt')
{
//We have text file
$key = basename($BasePath . '/' . $directory);
if(!isset($Storage[$key]))
{
$Storage[$key] = 0;
}
$Storage[$key]++;
}
}
}
}
return $Storage;
}
$Storage = RecurseFolderLister('fav');
asort($Storage); //Sort them
var_dump($Storage);
?>Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
8th Jul 2010, 01:29 PM #8OPMemberWebsite's:
maxneeds.infoSo far so good...
I used :
Code:$entry_arrayz[ 'entry' ] .= $Storage = RecurseFolderLister('fav'); asort($Storage); var_dump($Storage);
Code:array(1) { ["entry100620-034822.txt"]=> int(1) } Array How to print that thing ?
Code:array(2) { ["a.txt"]=> int(1) ["entry100620-034822.txt"]=> int(1) } Array
I am really bad in PHP so sorry that i am asking such a stupid questions.
-
8th Jul 2010, 01:40 PM #9MemberWebsite's:
litewarez.net litewarez.com triniwarez.comhmm,
Just do
PHP Code:$entry_arrayz[ 'entry' ] = RecurseFolderLister('fav');
var_dump($entry_arrayz['entry']);
And this code will do the following
scann all directories within the directory you specify, load all files that are .txt files into an array, and count how many times it came accross that file
The output would be like so
Code:Array( 'Name' > Count 'Name' > Count 'Name' > Count 'Name' > Count )
Code:Array( 'readme.txt' > 12 'about.txt' > 3 'test.txt' > 1 'readmeAgain.txt' > 1 )
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
8th Jul 2010, 01:50 PM #10OPMemberWebsite's:
maxneeds.infoI've tried
Code:$entry_arrayz[ 'entry' ] = RecurseFolderLister('fav'); var_dump($entry_arrayz['entry']);
Btw read my prev post if haven't (i edited it)..
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 2 users browsing this thread. (0 members and 2 guests)
Similar Threads
-
[PHP] Scan a Website using CURL and PHP, using Sucuri SiteCheck
By _Vick in forum Web Development AreaReplies: 0Last Post: 30th Nov 2011, 03:02 AM -
Scan Forum Ids
By vietnammoney in forum Webmaster ResourcesReplies: 1Last Post: 12th Oct 2011, 05:36 PM -
Boot Time Scan In Quick Heal
By supernova in forum General DiscussionReplies: 5Last Post: 17th Mar 2011, 08:07 PM -
Always scan files befor opeing...
By MrPeanut420 in forum Useful SitesReplies: 3Last Post: 5th Feb 2010, 09:57 AM -
How to Scan & Stop Uploading Infected Files to Your Server
By ashutariyal in forum Tutorials and GuidesReplies: 8Last Post: 13th Aug 2009, 06:09 AM
themaCreator - create posts from...
Version 3.24 released. Open older version (or...