Ok, here are the changes I made to DBMan to make a "View/Edit" "MOD".
I'm sure there are ways it can be improved, but for now it suits my needs perfectly.
Feel free to hack away, comment, suggest, etc...
One quick note, while I'm sure you should'nt have any problems,
please back up your log file before testing, just to be safe.
Code:
##########################################################
## CHANGES TO HTML.PL ##
##########################################################
#
# Add the following SubRoutine for your version
# (either user-friendly or original) to the "Authentication"
# area (under html_admin_display will do fine)
#
# How you link to it is up to you. I put a simple link under
# the Admin section, eg:
# <a href="$db_script_link_url&view_log=1">View / Edit Log</a>
#
##########################################################
##########################################################
#
# For JPDeni's User Friendly HTML.PL
#
sub html_admin_view_log {
# --------------------------------------------------------
# Displays the LOG file in a TEXTAREA for modifying
#
$page_title = "Log File";
&html_page_top;
$submit_button = "Save Changes";
$reset_button = "Undo Changes";
# < -- Start page text -- >
print qq|<p><$font>
</font></p>|;
# < -- End page text -->
print qq|
<form action="$db_script_url" method="post">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="edit_log" value="1">
<div align="center">
<textarea name="adminlog" rows="10" cols="80">|;
open(LOG, "< $auth_log_file") or &cgierr("error in view_log. unable to open log file: $auth_log_file.\nReason: $!");
if ($db_use_flock) { flock(LOG, 1); }
while (<LOG>) {
print $_;
}
close (LOG);
print qq|</textarea>
<P><center><input type="submit" value="$submit_button"> <input type="reset" value="$reset_button"></center>
</form></div>
|;
&html_footer;
&html_page_bottom;
} # End of SUB
##########################################################
#
# For the original HTML.PL
#
sub html_admin_view_log {
# --------------------------------------------------------
# Displays the LOG file in a TEXTAREA for modifying
#
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Log File.</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form action="$db_script_url" method="post">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="edit_log" value="1">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=85% align=center valign=top>
<tr><td colspan=2 bgcolor="$title_color">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR=white>
<b>$html_title: Log File</b>
</td></tr>
</table>
<table border=0 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=85% align=center valign=top>
<tr><td>
<p><center><$font_title>
<b>Log File</b></font></center>
<textarea name="adminlog" rows="10" cols="80">
|;
open(LOG, "< $auth_log_file") or &cgierr("error in view_log. unable to open log file: $auth_log_file.\nReason: $!");
if ($db_use_flock) { flock(LOG, 1); }
while (<LOG>) {
print $_;
}
close (LOG);
print qq|</textarea>
<P><center><input type="submit" value="Save Changes"> <input type="reset" value="Undo Changes"></center>
</form>
<P>|; &html_footer; print qq|
</td></tr>
</table>
</center>
</body>
</html>
|;
} # End of SUB
##########################################################
## CHANGES TO DB.CGI ##
##########################################################
##########################################################
#
# Add the following under the line:
# elsif ($in{'admin_display'}) { if ($per_admin) { &admin_display; } else { &html_unauth; } }
#
elsif ($in{'view_log'}) { if ($per_admin) { &html_admin_view_log; } else { &html_unauth; } }
elsif ($in{'edit_log'}) { if ($per_admin) { &edit_log; } else { &html_unauth; } }
##########################################################
#
# Add the following SubRoutine (can go anywhere, I put it down bottom)
#
#######################################
## Log Editting ##
#######################################
sub edit_log {
# --------------------------------------------------------
# Edits the log file. Logging is optional, if you don't
# want to log changes to the log, comment out the line:
# &auth_logging("modified log file") if ($auth_logging);
#
open(LOG, "> $auth_log_file");
if ($db_use_flock) {
flock(LOG, 2) or &cgierr("unable to get exclusive lock on $auth_log_file.\nReason: $!");
}
print LOG $in{'adminlog'};
close (LOG);
&auth_logging("modified log file") if ($auth_logging);
&html_admin_view_log;
} # End of SUB
Enjoy!
- Mark
Astro-Boy!!
http://www.zip.com.au/~astroboy/