dannyb785 Posted November 15, 2010 Share Posted November 15, 2010 I got a good one for you guys, I run 20 or so websites on my server all that have very similar coding structures. On all sites, I have a php script for a mysql table that logs visitors and I filter out bots(google, yahoo, etc, as many as I know of), but since many new ones are discovered weekly/monthly, I hate manually going through all sites and adding the new bot to the array of existing bots for detection. I know there are a few ways to do this, but I'd like to know the most efficient way of basically doing one function/task/opertation and it automatically updating all website's to know the new bots without manually modifying all 20 php files every time. The sites are all on the same server, but at different domains. a few ideas, which are prob not the best 1) have a universal text file that I could update that would be located in some file on one of my sites that just has a list of all bots and then each site would read from that text file to know what bots to filter. 2) have a huge php file to execute that has all connection info/passwords for every site and runs a php script to update the corresponding website's mysql table that would hold each bot as a row in the table. the script would just add a new row with the new bot info. so then ultimately when logging visitors, it would have to read the database each time 3) try to "include" a universal .php file that's located on one of my sites that has the array of all bots. But I've tried to include a file from another domain and I know that's a security error and won't include the file as a .php, but rather the file after it's been processed. There's gotta be a better solution. any ideas? Link to comment https://forums.phpfreaks.com/topic/218697-updating-definitions-and-such-over-many-websites-at-once/ Share on other sites More sharing options...
requinix Posted November 15, 2010 Share Posted November 15, 2010 #3 sounds like a good idea. Create a PHP file in the global PHP include folder (eg, /usr/share/php) and have it, say, define an array like $bots = array(); $bots["useragents"] = array( // list of user agents ); $bots["ipaddrs"] = array( // list of bot IP addresses ); ?> Could go more sophisticated than that like with a class. To use the file, include "bots.php"; // or whatever it's called No path necessary and you get $bots available immediately. But it also kinda depends on how often this gets updated. Maybe there's a list online somewhere you can periodically check? Like every week or so download it to your server in place of the handmade list? Link to comment https://forums.phpfreaks.com/topic/218697-updating-definitions-and-such-over-many-websites-at-once/#findComment-1134314 Share on other sites More sharing options...
dannyb785 Posted November 18, 2010 Author Share Posted November 18, 2010 That's awesome, I didn't know there was a folder for global include folder. Does this count for all websites on the same server? So since I'm using shared hosting, could someone also on my server include my .php file in their code?(not that they'd probably care). Link to comment https://forums.phpfreaks.com/topic/218697-updating-definitions-and-such-over-many-websites-at-once/#findComment-1136134 Share on other sites More sharing options...
BlueSkyIS Posted November 18, 2010 Share Posted November 18, 2010 another option: store the bots in the database and access the list from each site via mysql. Link to comment https://forums.phpfreaks.com/topic/218697-updating-definitions-and-such-over-many-websites-at-once/#findComment-1136154 Share on other sites More sharing options...
dannyb785 Posted November 18, 2010 Author Share Posted November 18, 2010 another option: store the bots in the database and access the list from each site via mysql. That was an option I thought of, but the pain would be having to go into each mysql database and updating the table with that info for all 20+ sites. If all sites are on the same server, can I enable them to access each other's databases? Like I could create one table in one database with the bot info and all sites would check that one database? Link to comment https://forums.phpfreaks.com/topic/218697-updating-definitions-and-such-over-many-websites-at-once/#findComment-1136309 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.