#include <stdio.h>
#include <dirent.h>
#include <string.h>
void listOfAllFilesWithSpecificExtension(char *mainpath) {
char path[1024];
struct dirent *drnt;
DIR *dir = opendir(mainpath);
if (!dir)
return;
while ((drnt = readdir(dir)) != NULL) {
if (strcmp(drnt->d_name, ".") != 0 && strcmp(drnt->d_name, "..") != 0) {
if (strcmp(drnt->d_name + strlen(drnt->d_name) - 4, ".php") == 0) {
printf("%s\n", drnt->d_name);
}
strcpy(path, mainpath);
strcat(path, "/");
strcat(path, drnt->d_name);
listOfAllFilesWithSpecificExtension(path);
}
}
closedir(dir);
}
int main(int argc, char **argv)
{
listOfAllFilesWithSpecificExtension("c:\\xampp\\htdocs\\allonpage.com");
return 0;
}
/*
run:
db.php
functions.php
connect.php
email.php
footer.php
header.php
index.php
...
*/