 |
 |
 |
 |
#221603 - 07/23/02 11:25 PM
AdminLogger
|
Addict
Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
|
Mod Name / Version AdminLogger 1.0alfa<br />Description A hack that logs all activity in the admin section that changes something.<br />Working under UBB.threads 6.0.1<br />Any pre-requisites None<br />Author(s) Gardener<br />Credits Dave_L, JustDave, BryanDS<br />Demo None<br />Files Altered ubbt.inc.php, admin/dbdocommand.php, admin/dbdooptimize.php, admin/doapproveposts.php, admin/doapproveusers.php, admin/doassignmod.php, admin/dobanuser.php, admin/dochangecatorder.php, admin/dochangeorder.php, admin/dochangeugroup.php, admin/dochangeuser.php, admin/doclosethreads.php, admin/docreate.php, admin/docreatecat.php, admin/docreategroup.php, admin/dodeleteuser.php, admin/dodeleteuserpost.php, admin/doeditboard.php, admin/doeditcat.php, admin/doeditconfig.php, admin/doeditffooter.php, admin/doeditfheader.php, admin/doeditfilter.php, admin/doeditgroup.php, admin/doeditinclude.php, admin/doedittemplate.php, admin/doedittheme.php, admin/doedittitles.php, admin/doexpirethreads.php, admin/dograntadmin.php, admin/dograntmod.php, admin/dokeepthreads.php, admin/domovepost.php, admin/domovethreads.php, admin/donewskin.php, admin/doopenthreads.php, admin/dopurgemessages.php, admin/dopurgeusers.php, admin/doremovemod.php, admin/dorevokeadmin.php, admin/dorevokemod.php, admin/dosendemail.php, admin/dounbanuser.php, admin/dounkeepthreads.php, admin/loginas.php<br />Database Altered No<br />New Files adminlog.log<br />Any other info This hack changes many of the files in the admin area, so it can be tedious to install, but when it is done you will have a log of all changes done through the admin area. I might add a page to read the content of the log file later, but until then you will have to download the log file to read it.<br /><br /><br />This was the most boring hack I've ever done, more or less just copy and paste in ~45 files. But it works for me and I hope the instructions are correct as well, I've tried to be careful when writing them. But it is a Good Thing (tm) to have this log file, I've got something like 10 admins and 10 moderators, and though I trust them all it's always good to know that you can check the log if something goes wrong.<br /><br />If anyone installs this, I'd very much like to know how it goes and if I've missed anything.
Attachments
53061-AdminLogger-1_0beta3.zip (42 downloads)
Edited by Gardener (10/22/02 09:19 PM)
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#221607 - 08/02/02 12:05 AM
Re: AdminLogger 1.0alfa (for 6.0.1)
[Re: c0bra]
|
Addict
Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
|
Make sense to me. Since this hack affects so many files, you might want to run it by Rick to see if he anticipates making any changes that could impact it. (or maybe even convince him to incorporate it as a feature <img src="/forum/images/icons/wink.gif" alt="" /> ).<br /><br />Another thought:<br /><br />error_log("$time,$IP,$Operation,$Username,$Number,$Status,$Description\n",<br /><br />The Username and Description fields could potentially contain commas, so it might be a good idea to escape any commas that are present in those fields. The function addcslashes() looks like a convenient way of doing that, since it has a companion function stripcslashes(). I think it would be used like this:<br />$Username_escaped = addcslashes($Username, ',');<br />$Description_escaped = addcslashes($Description, ',');<br /><br />
_________________________
UBB.threads beta tester / threadsdev.com moderator Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#221611 - 08/07/02 07:14 PM
AdminLogger 1.0beta (for 6.0.2)
[Re: c0bra]
|
Addict
Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
|
Changes<br /> - Wrote a script to view the log files.<br />
- Checked that it works with 6.0.2<br />
- Added log file archiving.<br />
- The log function takes the user info from the global scope.<br />
- Comma is escaped in username and description.
<br />Unzip the attached file and follow the install instructions in the text file.<br /><br /> Upgrade<br />If you are upgrading from the alfa version, you can do a search and replace of all the admin files instead of inserting the code by hand. After this you only need to follow steps 1-3 to upgrade.<br />The following code should be removed from all admin-files:<br /><pre><font class="small">code:</font><hr><br />$user['U_Username'], $user['U_Number'], $user['U_Status'],<br /></pre><hr><br /><br /> Information<br /> Mod Name / Version AdminLogger 1.0beta<br /> Description A hack that logs all activity in the admin section that changes something.<br /> Working under UBB.threads 6.0.2<br /> Any pre-requisites None<br /> Author(s) Gardener<br /> Credits Dave_L, JustDave, BryanDS<br /> Demo None<br /> Files Altered ubbt.inc.php, admin/dbdocommand.php, admin/dbdooptimize.php, admin/doapproveposts.php, admin/doapproveusers.php, admin/doassignmod.php, admin/dobanuser.php, admin/dochangecatorder.php, admin/dochangeorder.php, admin/dochangeugroup.php, admin/dochangeuser.php, admin/doclosethreads.php, admin/docreate.php, admin/docreatecat.php, admin/docreategroup.php, admin/dodeleteuser.php, admin/dodeleteuserpost.php, admin/doeditboard.php, admin/doeditcat.php, admin/doeditconfig.php, admin/doeditffooter.php, admin/doeditfheader.php, admin/doeditfilter.php, admin/doeditgroup.php, admin/doeditinclude.php, admin/doedittemplate.php, admin/doedittheme.php, admin/doedittitles.php, admin/doexpirethreads.php, admin/dograntadmin.php, admin/dograntmod.php, admin/dokeepthreads.php, admin/domovepost.php, admin/domovethreads.php, admin/donewskin.php, admin/doopenthreads.php, admin/dopurgemessages.php, admin/dopurgeusers.php, admin/doremovemod.php, admin/dorevokeadmin.php, admin/dorevokemod.php, admin/dosendemail.php, admin/dounbanuser.php, admin/dounkeepthreads.php, admin/loginas.php, admin/menu.php<br /> Database Altered No<br /> New Files admin/showlog.php<br /> Any other info This hack changes many of the files in the admin area, so it can be tedious to install, but when it is done you will have a log of all changes done through the admin area. The log files can be easily viewed from the admin area.<br />
Attachments
53715-AdminLogger-1_0beta.zip (8 downloads)
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#221614 - 08/11/02 10:08 AM
Re: AdminLogger 1.0beta (for 6.0.2)
[Re: c0bra]
|
Enthusiast
Registered: 03/09/02
Posts: 329
Loc: Michigan, USA
|
Honestly, the directions were fine. I kind of glossed over the relevent section because it wasn't labeled as an actual step, and it started with "Before you install you should . . . ." and I assumed <img src="/forum/images/icons/blush.gif" alt="" /> that it was the standard "Before you install you should make a copy of your database . . . ." so I didn't really read it. {*shame on me!*}<br /><br />As a tip to anyone looking at this to install, it's really not as difficult as I expected. It only took me about an hour (not counting looking over and over for my mistake <img src="/forum/images/icons/laugh.gif" alt="" />). I used Beyond Compare (version 2.0) and I think that is what was so helpful. <img src="/forum/images/icons/smile.gif" alt="" /> If you are using Beyond Compare (and I strongly recommend you do!) here's how I did it and I think it worked quite well:<br /><br />1. Start Beyond Compare with the downloaded hack folder in the left side. You can leave it zipped if you want, since Beyond Compare can view zipped files. <img src="/forum/images/icons/smile.gif" alt="" /> Have your UBB.threads files in the right hand side. I use my live files via ftp, but only because I install to a test board first. You probably shouldn't install to live (on your server) files if you are installing to your main site board.<br /><br />2. I know I probably shouldn't, but I started with steps 2 and 3 because they are the only files being changed that aren't in the admin folder. I made the changes to config.inc.php and ubbt.inc.php.<br /><br />3. Next I right clicked on the "admin" file in the left hand side of Beyond Compare and chose "Set as Base Folder". This makes only the files in the admin folder visible. <br /><br />4. At the top of BC I have it set to show "All files" since I'm not really comparing any files.<br /><br />5. Remember to go back and do step 1 now (we skipped it earlier). It's the mod to the menu file. <img src="/forum/images/icons/smile.gif" alt="" /><br /><br />6. Start where we left off, which is step 4. Now the steps should be in order with the admin files. You're basically making changes to almost all of the "do...." files (doeditforum, doeditconfig, etc.) <br /><br />7. Right click on the instruction file in the left hand side and choose "compare to" and then in the right hand side choose the file from step 4 (dbdocommand.php). The compare window opens those two files. Read the instructions for the changes on the left hand side and make the changes to the right hand side. Save the changes, close the compare window. <br /><br />8. (This is the part that I thought was most helpful.) You should be back in the main window of BC now, with all the admin files on the right hand side. Right click on the file you just changed (dbdocommand.php) and choose "Exclude". This will hide the file from your view. That let me know I had finished with that file. It made a world of difference to me because I wasn't so paranoid about losing my place in the instructions and not knowing where to start again. <img src="/forum/images/icons/smile.gif" alt="" /><br /><br />9. Make sure you finish by creating the adminlog.log file and uploading it and chmod'ing it to 666. Also upload the showlog.php file into the admin folder.<br /><br />Thanks again Gardener, it's a great hack and a VERY useful one. <img src="/forum/images/icons/smile.gif" alt="" />
_________________________
[:"red"]Lisa[/]
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#221616 - 08/11/02 12:23 PM
Diff-file for easier install
[Re: c0bra]
|
Addict
Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
|
If you have shell access to your server you can probably run the patch command, which will make it a lot easier to install this mod. Below is the instructions on how to use the patch file from a shell account. It should be possible to use it in Beyond Compare or UltraEdit as well, but I don't know how, so check your documentation. If someone can give the instructions on how to do this it would be much appreciated.<br /><br />Patch instructions for unix<br /><ol type="1">[*]Save the file attached to this post and upload it to your ubbthreads directory.<br />[*]Make a backup of your ubbthreads directory.<br />[*]Change directory to your ubbthreads directory and patch all the admin-files:<br />> patch -p1 < AdminLogger-diff_602-1_0beta.txt<br /></ol><br /><br />Extra changes<br />The following must be done after the the files have been patched. These instructions are the same no matter which patch program you have used.<br /><br />Step 1<br />Create an empty file called adminlog.log and put it where your config file is, and change the permissions to be writeable by all:<br />> chmod 666 adminlog.log<br /><br />Step 2<br />Add the following lines at the end of your config.inc.php file, and change path and filename to whereever you have put your log file.<br /><br /> $config['adminlog'] = "/var/www/data/ubbthreads/adminlog.log";<br /> $config['adminlog_maxsize'] = "50000";<br /> $config['adminlog_keep'] = "4";<br /><br />Description of the options:<br />adminlog is the complete path to the log file.<br />adminlog_maxsize is the maximum allowed size for the log file before it is archived<br />adminlog_keep is how many old logfiles to keep (.1 will be appended to the newest arvhived log file, .2 to the second newest and so on)<br /><br />Step 3<br />Add this function to the end of ubbt.inc.php, before "?>".<br /><pre><font class="small">code:</font><hr><br />function admin_log($Operation, $Description) {<br /> GLOBAL $config, $user;<br /> $time = date("Y/m/d:H:i:s O");<br /> $IP = find_environmental ("REMOTE_ADDR");<br /> $Status = substr($user['U_Status'],0,1);<br /> $User_esc = addcslashes($user['U_Username'], ',');<br /> $Description_esc = addcslashes($Description, ',');<br /> $logsize = filesize($config['adminlog']);<br /> $keepfiles = $config['adminlog_keep'];<br /> if (!is_numeric($keepfiles)) {<br /> print "Warning: The config option adminlog_keep is not a <br />number! Using 4 as default.<br />";<br /> $keepfiles = 4;<br /> }<br /> if ($logsize > $config['adminlog_maxsize']) {<br /> for ($i=$keepfiles; $i>0; $i--) {<br /> if ($i == 1) {<br /> $oldfile = $config['adminlog'];<br /> } else {<br /> $oldfile = $config['adminlog'] . "." . ($i-1);<br /> }<br /> $newfile = $config['adminlog'] . "." . $i;<br /> if (file_exists($oldfile)) {<br /> rename($oldfile, $newfile);<br /> }<br /> }<br /> }<br /> error_log("$time,$IP,$Operation,$User_esc,{$user['U_Number']},"<br />."$Status,$Description_esc\n",<br /> 3,<br /> $config['adminlog']<br /> );<br />}<br /></pre><hr><br /><br />Step 4<br />Find these lines in ubbt.inc.php (at line 1619):<br /><pre><font class="small">code:</font><hr><br /> // -----------------------------------------------------------------<br /> // We are automatically adding StyleSheet, Status, Privates and<br /> // FrontPage to each SQL call because this information is needed by<br /> // every script that makes a call to authenticate<br /> else {<br /> if ($Query) { $Query .=","; }<br /> $Query .= "U_Username,U_Password,U_SessionId, <br />U_StyleSheet, U_Status, U_Privates, U_FrontPage";<br /> }<br /></pre><hr><br /><br />And CHANGE them into this:<br /><pre><font class="small">code:</font><hr><br /> // -----------------------------------------------------------------<br /> // We are automatically adding StyleSheet, Status, Privates and<br /> // FrontPage to each SQL call because this information is needed by<br /> // every script that makes a call to authenticate<br /> else {<br /> if ($Query) { $Query .=","; }<br /> $Query .= "U_Username,U_Password,U_SessionId, <br />U_StyleSheet, U_Status, U_Privates, U_FrontPage, U_Number";<br /> }<br /></pre><hr><br />
Attachments
53926-AdminLogger-diff_602-1_0beta.txt (11 downloads)
Edited by Gardener (10/22/02 09:28 PM)
|
|
Top
|
|
|
|
 |
 |
 |
 |
|
|