]> ruin.nu Git - ndwebbie.git/commitdiff
implemented motd
authorMichael Andreen <harv@ruin.nu>
Tue, 12 Dec 2006 10:07:58 +0000 (10:07 +0000)
committerMichael Andreen <harv@ruin.nu>
Tue, 12 Dec 2006 10:07:58 +0000 (10:07 +0000)
include.pl
index.pl
motd.pl [new file with mode: 0644]
templates/motd.tmpl [new file with mode: 0644]

index 0f85f92b8d20bd3da2ae2ef276993b8417e84177..9cb4f7d55c0dc0f6928c8dd3170d9f79be01cd29 100644 (file)
@@ -48,7 +48,7 @@ sub parseMarkup {
        my ($text) = @_;
 
        $text =~ s{\n}{\n<br/>}g;
-       $text =~ s{\[B\](.*?)\[B\]}{<b>$1</b>};
+       $text =~ s{\[B\](.*?)\[/B\]}{<b>$1</b>};
        return $text;
 }
 
index f19ced961b3656ae6d4742382db50e0ef27a1a1a..118d0332e80db9d62f3079ac00c3dca939db1c38 100755 (executable)
--- a/index.pl
+++ b/index.pl
@@ -66,7 +66,7 @@ while (my ($name,$attack,$gid) = $query->fetchrow()){
 our $LOG = $DBH->prepare('INSERT INTO log (uid,text) VALUES(?,?)');
 
 my $page = 'main';
-if (param('page') =~ /^(main|check)$/){
+if (param('page') =~ /^(main|check|motd)$/){
        $page = $1;
 }
 
diff --git a/motd.pl b/motd.pl
new file mode 100644 (file)
index 0000000..f69a54a
--- /dev/null
+++ b/motd.pl
@@ -0,0 +1,43 @@
+#**************************************************************************
+#   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
+#                                                                         *
+#   This program is free software; you can redistribute it and/or modify  *
+#   it under the terms of the GNU General Public License as published by  *
+#   the Free Software Foundation; either version 2 of the License, or     *
+#   (at your option) any later version.                                   *
+#                                                                         *
+#   This program is distributed in the hope that it will be useful,       *
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+#   GNU General Public License for more details.                          *
+#                                                                         *
+#   You should have received a copy of the GNU General Public License     *
+#   along with this program; if not, write to the                         *
+#   Free Software Foundation, Inc.,                                       *
+#   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
+#**************************************************************************/
+
+use strict;
+
+$ND::TEMPLATE->param(TITLE => 'Edit MOTD');
+
+our $BODY;
+our $DBH;
+our $LOG;
+
+die "You don't have access" unless isHC();
+
+if (param('cmd') eq 'change'){
+       $DBH->begin_work;
+       my $query = $DBH->prepare(q{UPDATE misc SET value= ? WHERE id='MOTD'});
+       my $motd = escapeHTML(param('motd'));
+       $query->execute($motd);
+       $LOG->execute($ND::UID,"Updated MOTD");
+       $DBH->commit;
+       $BODY->param(MOTD => $motd);
+}else{
+       my ($motd) = $DBH->selectrow_array(q{SELECT value FROM misc WHERE id='MOTD'});
+       $BODY->param(MOTD => $motd);
+}
+
+1;
diff --git a/templates/motd.tmpl b/templates/motd.tmpl
new file mode 100644 (file)
index 0000000..0fd2f7f
--- /dev/null
@@ -0,0 +1,6 @@
+<form action="/index.pl" method="post"><fieldset> <legend>Motd</legend>
+       <textarea rows="25" cols="80" name="motd"><TMPL_VAR NAME=MOTD></textarea>
+       <input type="hidden" name="cmd" value="change"/>
+       <input type="hidden" name="page" value="motd"/>
+       <br/><input type="submit" value="Change"/>
+</fieldset></form>