PHP Scripts
Website Security Against hackers, more rigorous.
Ignore folders of your choice.
Counts main folder byte sizes and file numbers and then subfolder byte sizes.
What is quite nice here is that it detects hidden files, and detects any changes
If you haven't experienced someone hacking your website, then that's good.
If you have however, you wil appreciate being informed of any changes at all, so you can quickly go check whats happening.
The easy script (here) is okay if your webhost doesn't update your website with statistics.
Many do however, with folders like webalizer, modlogan, or websitestats.
Consequently, your site is constantly changing and the simple script sends false alarms.
If your website does have folders for statistics, you need to keep track of your website, but ignore the stats folders.
1. Connect to the
database
2. Create some tables for each folder on your site, using "createsizes.php" - run it once then delete it from your folder.
A table will be created for the main folder of your website, and for every subfolder, apart from the ones you don't want to include.
3. Collect folder filesize and store in your database tables, but ignoring specific folders of your choice using "sizes.php".
In the example page here, the folders to be ignored are: cgi-bin, stats, modlogan, and webalizer.
4. Every time you click the file sizes.php (bookmarked in your browser perhaps), the page will update and check against the database.
If there's any discrepancy, by as much as a byte, you get an email.
The three images, cross, yes and no, are here, if you want them. Just click each one to save :
![]()
(createsizes.php) <?php echo "Success in database selection<br>"; $array=array_diff(glob('*', GLOB_ONLYDIR), array("cgi-bin", "stats", "modlogan", "webalizer")); ?> After running the createsizes file, delete it from your server(sizes.php) <?php function GetFolderSize($d ="." ) { while ($f=readdir($h)){ echo "$f0>Your Website Name </font><br>"; $query="SELECT * FROM s_sizes"; $q1 = "INSERT INTO s_sizes (size, count) VALUES ('$totalsize','$count')"; if ($countm == $count && $sizem == $totalsize) { $q2 = "UPDATE s_sizes SET size='$totalsize', count='$count'"; // check the file s_sizes in the folders $query="SELECT * FROM s_sizes_$d"; // alert if there is a new folder $q1 = "INSERT INTO s_sizes_$d (size) VALUES ('$size')"; $q2 = "UPDATE s_sizes_$d SET size='$size'"; }
font color="#006666" size="2" face="Verdana, Arial, Helvetica, sans-serif"> |