php forum
php mysql forum
php mysql smarty
 
Page 1 of 2 1 2 >
Topic Options
#221603 - 07/23/02 11:25 PM AdminLogger
Gardener Offline
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)
_________________________
/Gardener | Complete list of my mods

Top
#221604 - 07/24/02 12:17 AM Re: AdminLogger 1.0alfa (for 6.0.1) [Re: c0bra]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
I looked at this, but haven't had time to install it yet.<br /><br />One minor simplification would be to pass the single parameter $user to function admin_log(), rather than the three separate parameters $user['U_Username'], $user['U_Number'] and $user['U_Status'].
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#221605 - 07/24/02 12:25 AM Re: AdminLogger 1.0alfa (for 6.0.1) [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Yeah, that thought came to me after I had done them all. =] But I thought I'd keep it that way, so that the function can be used without the user object as well. Someone might want to log things not from that for some reason maybe...
_________________________
/Gardener | Complete list of my mods

Top
#221606 - 08/01/02 11:24 PM Re: AdminLogger 1.0alfa (for 6.0.1) [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
If I take the $user from the global scope I can get all the info I need without passing the user variables to the function. This makes the call to the function look a lot cleaner since it only includes what type it is and any extra information that should be saved with it. I think I'm going to go with this, but what do you others think of doing it this way?<br /><br />Example:<br /><pre><font class="small">code:</font><hr><br />// ---------------<br />// Log this action<br /> admin_log("APPROVEPOSTS", "Approved: $totalapproved; Threads: $threadtotal");<br /></pre><hr>
_________________________
/Gardener | Complete list of my mods

Top
#221607 - 08/02/02 12:05 AM Re: AdminLogger 1.0alfa (for 6.0.1) [Re: c0bra]
Dave_L_dup1 Offline
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
#221608 - 08/02/02 12:24 AM Re: AdminLogger 1.0alfa (for 6.0.1) [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Yeah, I've thought of bugging Scream to add this since I don't want to keep upgrading these many files. <br /> <br />Thanks, I'll add that. <br /> <br />I'm also thinking of changing to save the info in a db table, any thoughts on this?


Edited by Gardener (08/02/02 12:32 AM)
_________________________
/Gardener | Complete list of my mods

Top
#221609 - 08/02/02 01:13 PM Re: AdminLogger 1.0alfa (for 6.0.1) [Re: c0bra]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
Logging to a new database table, instead of a file, would probably be more convenient.<br /><br />I can only think of one issue. If someone either accidentally or maliciously changes the database, then the admin log could get changed or deleted. Since one reason for having the log is to monitor such actions, that would defeat its purpose.<br /><br />Of course, a text file on the server could also get clobbered.<br /><br />I'm not sure which is safer.
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
#221610 - 08/03/02 06:26 AM Re: AdminLogger 1.0alfa (for 6.0.1) [Re: joeuser]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
That is true... Logs are quite often in plain text files so maybe it is a good idea to keep it as that. It would be nice to know who did the "drop w3t_Logs" command...
_________________________
/Gardener | Complete list of my mods

Top
#221611 - 08/07/02 07:14 PM AdminLogger 1.0beta (for 6.0.2) [Re: c0bra]
Gardener Offline
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)

_________________________
/Gardener | Complete list of my mods

Top
#221612 - 08/10/02 11:55 PM Re: AdminLogger 1.0beta (for 6.0.2) [Re: c0bra]
Lisa_P Offline
Enthusiast

Registered: 03/09/02
Posts: 329
Loc: Michigan, USA
Yay, it works! <img src="/forum/images/icons/laugh.gif" alt="" /> I installed it a couple days ago but it wouldn't work, and I had to wait until I could go through all 5 million steps again. <img src="/forum/images/icons/laugh.gif" alt="" /> I figured it was my error, and it was. <img src="/forum/images/icons/wink.gif" alt="" /> I'd forgotten to chmod the log. <br /><br />It looks great! <img src="/forum/images/icons/grin.gif" alt="" />
_________________________
[:"red"]Lisa[/]

Top
#221613 - 08/11/02 04:50 AM Re: AdminLogger 1.0beta (for 6.0.2) [Re: JacquiL]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Sounds great that you got it to work. I'll rephrase the bit about setting the permissions so that it won't be missed.
_________________________
/Gardener | Complete list of my mods

Top
#221614 - 08/11/02 10:08 AM Re: AdminLogger 1.0beta (for 6.0.2) [Re: c0bra]
Lisa_P Offline
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
#221615 - 08/11/02 11:12 AM Re: AdminLogger 1.0beta (for 6.0.2) [Re: JacquiL]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
[]Thanks again Gardener, it's a great hack and a VERY useful one.<hr /></blockquote><br /><br />No problem, it is a really useful mod so I thought I could spend a couple of hours to let everyone have it.<br /><br />Thanks to you for the helpful hints on using Beyond Compare, I'm sure there are some who will find it useful.<br /><br />But now that you mention Beyond Compare I remember that someone said it can handle diff files, which would be very convenient. It seems that UltraEdit can use diff files as well. I will post a diff file with all changes and include instructions on how to use it from the shell, if anyone could write the instructions on how to use diff on BC and UE that would be great. I don't use either myself so I can't help with that.
_________________________
/Gardener | Complete list of my mods

Top
#221616 - 08/11/02 12:23 PM Diff-file for easier install [Re: c0bra]
Gardener Offline
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)
_________________________
/Gardener | Complete list of my mods

Top
#221617 - 08/15/02 05:00 PM AdminLogger 1.0beta2 (for 6.0.2) [Re: c0bra]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Just a small update that adds logging of when posts are deleted from outside the admin area. The complete instructions are attached.<br /><br />There is one added step, no need to download the attached file if you have already installed 1.0beta before.<br /><br />Step 49<br />Find this line in deletepost.php (at 200):<br /><pre><font class="small">code:</font><hr><br /> $html -> send_header($ubbt_lang['POST_DEL_HEAD'],$Cat,<br />"<meta http-equiv=\"Refresh\" content=\"5;url={$config['phpurl']}/postlist.php?<br />Cat=$Cat&amp;Board=$Board&amp;page=$page&amp;view=$view&amp;sb=$sb&amp;o=$o\" />",$user);<br /></pre><hr><br /><br />I've split it up into three lines so that the post won't be too wide, it is only one line in the code.<br /><br />And add these lines BEFORE:<br /><pre><font class="small">code:</font><hr><br />// ---------------<br />// Log this action<br /> admin_log("DELETEPOST", "$Postedby;{$ubbt_lang['SUBJECT_TEXT']}");<br /></pre><hr>


Edited by Gardener (10/22/02 09:23 PM)
_________________________
/Gardener | Complete list of my mods

Top
#221618 - 10/22/02 09:23 PM AdminLogger 1.0beta3 (updated for 6.1.0) [Re: c0bra]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
I've updated this script to work with v6.1.0 of UBB.threads (I don't have access to the member area anymore, so I can't check if it works with 6.1.1).<br /><br />I've changed the file in the first post of this thread to the latest version.<br /><br />The changes in this version is mostly only slight changes in the instructions to apply better to 6.1.0. There are also some new steps at the end to add logging of the new admin functions added in 6.1.0.
_________________________
/Gardener | Complete list of my mods

Top
#221619 - 10/28/02 08:29 PM Re: AdminLogger 1.0beta3 (updated for 6.1.0) [Re: c0bra]
Rick Offline
Guru

Registered: 05/11/99
Posts: 8372
Loc: Olympia, WA
Just a note. This will be in version 6.2 <img src="/forum/images/graemlins/wink.gif" alt="" />
_________________________
StogieSmokers.com

Top
#221620 - 10/28/02 08:34 PM Re: AdminLogger 1.0beta3 (updated for 6.1.0) [Re: Sally]
JoshPet Offline
I type Like navaho

Registered: 11/29/01
Posts: 11330
Loc: Charlotte, NC
Congrats Gardener! <br /><br />[]http://www.joshuapettit.com/beta/ubbthreads/images/graemlins/jump.gif[/]
_________________________
Joshua Pettit
www.JoshuaPettit.com
My abilities are for hire.

Top
#221621 - 10/28/02 08:39 PM Re: AdminLogger 1.0beta3 (updated for 6.1.0) [Re: Sally]
Gardener Offline
Addict

Registered: 05/11/99
Posts: 1956
Loc: Sweden, Uppsala
Sounds great, it's really appreciated!
_________________________
/Gardener | Complete list of my mods

Top
#221622 - 10/28/02 09:25 PM Re: AdminLogger 1.0beta3 (updated for 6.1.0) [Re: c0bra]
Dave_L_dup1 Offline
Addict

Registered: 04/23/02
Posts: 1929
Loc: Virginia, USA
Yes, I really didn't want to have to deal with that as a hack. Too many files to deal with when doing version upgrades.
_________________________
UBB.threads beta tester / threadsdev.com moderator
Software consulting services including UBB.threads problem resolution / installs / upgrades / customization.

Top
Page 1 of 2 1 2 >


Who's Online
0 registered (), 18 Guests and 10 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
Wisdom needed
by Gizmo
Yesterday at 10:54 AM
How to hide sub forums from summary page
by blaaskaak
12/03/08 09:54 AM
Spell Check [beta]
by Bill B
12/01/08 09:16 PM
PhotoPost BB Code Popup
by AllenAyres
12/01/08 09:41 AM
Problems reading a lot of old posts here
by AllenAyres
12/01/08 09:35 AM
Forum 'Trader Ratings'.
by AllenAyres
12/01/08 09:33 AM
Customization needed
by Gizmo
11/12/08 12:28 PM
New Mods
User Authentication Class
by
01/19/07 02:59 PM
Mu