Jump to content

Updating definitions and such over many websites at once


dannyb785

Recommended Posts

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
Share on other sites

#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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.