Revision: 2762
          http://ipcop.svn.sourceforge.net/ipcop/?rev=2762&view=rev
Author:   riddles
Date:     2009-05-01 10:30:25 +0000 (Fri, 01 May 2009)

Log Message:
-----------
Add three new functions, needed for passing information to the templates

Modified Paths:
--------------
    ipcop/branches/template-branch/src/libs/header.pl

Modified: ipcop/branches/template-branch/src/libs/header.pl
===================================================================
--- ipcop/branches/template-branch/src/libs/header.pl   2009-05-01 10:29:20 UTC 
(rev 2761)
+++ ipcop/branches/template-branch/src/libs/header.pl   2009-05-01 10:30:25 UTC 
(rev 2762)
@@ -871,4 +871,67 @@
     return $connstate;
 }
 
+######
+## New for Template Toolkit
+######
+sub maketext {
+    return $Lang::tr{$_[0]};
+}
+sub get_page_vars {
+    my $title_prefix = '';
+    my %settings = ();
+    my @warnmessages = ();
+    my @errormessages = ();
+    &General::readhash("${General::swroot}/main/settings", \%settings);
+    if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
+        $title_prefix = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}";
+    } else {
+        $title_prefix = "IPCop";
+    }
+
+    my %page = (
+        'theme' => 'default',
+        'javascript' => 1,
+        'extrahead' => '',
+        'title_prefix' => $title_prefix,
+        'url' => $ENV{'SCRIPT_NAME'},
+        'datetime' => `/bin/date "+%Y-%m-%d %H:%M::%S"`,
+        'warnmessages' => \...@warnmessages,
+        'errormessages' => \...@errormessages,
+    );
+    return \%page;
+}
+sub get_system_vars{
+    my $red_ip = '';
+    my $red_hostname = '';
+    my $connstate = &connectionstatus();
+
+    if (open(IPADDR, "${General::swroot}/red/local-ipaddress")) {
+        my $red_ip = <IPADDR>;
+        my $red_hostname = (gethostbyaddr(pack("C4", split(/\./, 
$red_ip)),2))[0];
+        close IPADDR;
+        chomp($red_ip);
+    }
+
+    my $public_ip = '';
+    my $public_hostname = '';
+    if ($connstate =~ /$Lang::tr{'connected'}/) {
+        $public_ip = &General::GetDyndnsRedIP;
+        $public_hostname = (gethostbyaddr(pack("C4", split(/\./, 
$public_ip)),2))[0];
+    }
+
+    my %system = (
+        'version' => '1.9.3',
+        'hostname' => `/bin/uname -n`,
+        'red_ip' => $red_ip,
+        'red_hostname' => $red_hostname,
+        'public_ip' => $public_ip,
+        'public_hostname' => $public_hostname,
+        'connstate' => $connstate,
+        'uptime' => `/usr/bin/uptime`,
+        'adminmanualurl' => $General::adminmanualurl,
+    );
+    return \%system;
+}
+
 1;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Ipcop-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ipcop-svn

Reply via email to