[vhffs-dev] [773] Added javascripts to public part. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 773
Author: beuss
Date: 2007-08-26 12:59:55 +0000 (Sun, 26 Aug 2007)
Log Message:
-----------
Added javascripts to public part.
Added functionality to obfuscate emails (fixing #214).
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Conf.pm
trunk/vhffs-api/src/Vhffs/Functions.pm
trunk/vhffs-api/src/Vhffs/Panel/Main.pm
trunk/vhffs-backend/conf/vhffs.conf.dist.in
trunk/vhffs-panel/js/commons.js
trunk/vhffs-public/group.pl
trunk/vhffs-public/templates/allwebsites.tmpl
trunk/vhffs-public/templates/group.tmpl
trunk/vhffs-public/templates/index.tmpl
trunk/vhffs-public/templates/lastgroups.tmpl
trunk/vhffs-public/templates/lastusers.tmpl
trunk/vhffs-public/templates/misc/list-part.tmpl
trunk/vhffs-public/templates/simplemsg.tmpl
trunk/vhffs-public/templates/user.tmpl
Modified: trunk/vhffs-api/src/Vhffs/Conf.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Conf.pm 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-api/src/Vhffs/Conf.pm 2007-08-26 12:59:55 UTC (rev 773)
@@ -949,4 +949,9 @@
return '/tmp';
}
+sub get_mail_obfuscation {
+ return $Config{'global'}{'panel'}{'mail_obfuscation'}
+ if(defined $Config{'global'}{'panel'}{'mail_obfuscation'});
+ return 'none';
+}
1;
Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm 2007-08-26 12:59:55 UTC (rev 773)
@@ -269,6 +269,65 @@
return( 1 );
}
+sub obfuscate_email($$) {
+ my ($vhffs, $mail) = @_;
+
+ my $tech = $vhffs->get_config->get_mail_obfuscation;
+
+ return $mail if($tech eq 'none');
+ if($tech eq 'simple') {
+ $mail =~ s/@/ AT REMOVEME /g;
+ $mail =~ s/\./ DOT /g;
+ return $mail;
+ }
+ if($tech eq 'entities') {
+ my @chars = split //, $mail;
+ $mail = '';
+ foreach(@chars) {
+ if($_ eq '@') {
+ $mail .= '@';
+ } else {
+ my $ord = ord($_);
+ if( ($ord >= ord('a') && $ord <= ord('z') )
+ || ($ord >= ord('A') && $ord <= ord('Z') ) ) {
+ $mail .= "&#$ord;";
+ } else {
+ $mail .= $_;
+ }
+ }
+ }
+ return $mail;
+ }
+ if($tech eq 'javascript') {
+ return js_encode_mail($mail);
+ }
+
+ warn("Unsupported email obfuscation method !\n");
+ return $mail;
+}
+
+=head2 js_encode_mail
+
+This function does the opposite of the JS function decode_mail.
+
+=cut
+
+sub js_encode_mail($) {
+ my $clear = shift;
+ my $crypted = '';
+ my @chars = split //, $clear;
+ foreach(@chars) {
+ my $c = chr(ord($_) + 1);
+ if($c eq "'") {
+ $crypted .= '\\\'';
+ } else {
+ $crypted .= $c;
+ }
+ }
+
+ return '<script type="text/javascript">document.write(decode_mail(\''.$crypted.'\'));</script>';
+}
+
#Connect to the database
sub db_connect
{
@@ -393,10 +452,6 @@
return -1;
}
-
-
-
-
sub status_string_from_status_id($) {
my $status = shift;
return gettext($STATUS_STRINGS[$status] or 'Unknown');
Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2007-08-26 12:59:55 UTC (rev 773)
@@ -693,6 +693,23 @@
my $theme = get_theme( $panel->{'vhffs'} );
$template->param( THEME => $theme );
+
+ # Allows each theme to have its own Jscripts
+
+ my $jsglob = File::Spec->catfile($panel->{config}->get_themesdir(), $theme, '/js/*.js');
+ my $jswebpath = "/themes/$theme/js/";
+ my @jscripts;
+ # Common scripts
+ push @jscripts, {SCRIPT => '/js/prototype.js'};
+ push @jscripts, {SCRIPT => '/js/commons.js'};
+ push @jscripts, {SCRIPT => '/js/tooltip.js'};
+ while(glob($jsglob)) {
+ use File::Basename;
+ push @jscripts, {SCRIPT => $jswebpath.basename( $_ )};
+ }
+ $template->param( JSCRIPTS => \@jscripts );
+
+
if(@{$panel->{errors}} > 0) {
my $tmplerrors = new HTML::Template( filename => $panel->{templatedir}."/panel/misc/errors.tmpl" );
$tmplerrors->param( ERRORS => $panel->{errors} );
Modified: trunk/vhffs-backend/conf/vhffs.conf.dist.in
===================================================================
--- trunk/vhffs-backend/conf/vhffs.conf.dist.in 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-backend/conf/vhffs.conf.dist.in 2007-08-26 12:59:55 UTC (rev 773)
@@ -80,6 +80,10 @@
#URL to the panel
url = http://your.panel.url
+ # Obfuscation technique for emails (none, simple, entities or
+ # javascript)
+ mail_obfuscation = simple
+
#This is the URL display for the "Help" link in the panel
help_url = http://help.hoster
Modified: trunk/vhffs-panel/js/commons.js
===================================================================
--- trunk/vhffs-panel/js/commons.js 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-panel/js/commons.js 2007-08-26 12:59:55 UTC (rev 773)
@@ -96,6 +96,14 @@
return /^[\w\d\s\-]+$/.test(value);
}
+function decode_mail(crypted) {
+ var clear = '';
+ for(var i = 0 ; i < crypted.length ; ++i) {
+ clear += String.fromCharCode(crypted.charCodeAt(i) - 1);
+ }
+ return clear;
+}
+
/**
* Toggles visibility of element whose id is id.
* @param id string Id of element to toggle.
Modified: trunk/vhffs-public/group.pl
===================================================================
--- trunk/vhffs-public/group.pl 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-public/group.pl 2007-08-26 12:59:55 UTC (rev 773)
@@ -31,7 +31,7 @@
use POSIX qw(locale_h);
-use HTML::Template;
+use HTML::Template::Expr;
use locale;
use Locale::gettext;
use CGI;
@@ -207,7 +207,9 @@
{
foreach( @{$objs} )
{
- $subtemplate = new HTML::Template( filename => $templatedir."/public/misc/list-part.tmpl" );
+ $subtemplate = new HTML::Template::Expr(
+ filename => $templatedir."/public/misc/list-part.tmpl",
+ functions => { obfuscate_email => \&obfuscate_email } );
$subtemplate->param( LISTNAME => $_->get_title );
$subtemplate->param( DOMAIN => $_->get_domain );
$subtemplate->param( LOCALPART => $_->get_localpart );
@@ -236,5 +238,9 @@
$template->param( BANNER => $subtemplate->output );
}
+# This is ugly but we need it until Vhffs::Main is Singleton'ed
+sub obfuscate_email {
+ return Vhffs::Functions::obfuscate_email($vhffs, $_[0]);
+}
display_light Vhffs::Panel::Main( $panel , $template );
Modified: trunk/vhffs-public/templates/allwebsites.tmpl
===================================================================
--- trunk/vhffs-public/templates/allwebsites.tmpl 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-public/templates/allwebsites.tmpl 2007-08-26 12:59:55 UTC (rev 773)
@@ -7,7 +7,9 @@
<link rel="stylesheet" type="text/css" href="/themes/<tmpl_var name="THEME">/main.css" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-
+ <tmpl_loop name="JSCRIPTS">
+ <script language="javascript" type="text/javascript" charset="utf-8" src="<tmpl_var name="SCRIPT">"></script>
+ </tmpl_loop>
</head>
<body>
<tmpl_var name="BANNER">
Modified: trunk/vhffs-public/templates/group.tmpl
===================================================================
--- trunk/vhffs-public/templates/group.tmpl 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-public/templates/group.tmpl 2007-08-26 12:59:55 UTC (rev 773)
@@ -7,7 +7,9 @@
<link rel="stylesheet" type="text/css" href="/themes/<tmpl_var name="THEME">/main.css" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-
+ <tmpl_loop name="JSCRIPTS">
+ <script language="javascript" type="text/javascript" charset="utf-8" src="<tmpl_var name="SCRIPT">"></script>
+ </tmpl_loop>
</head>
<body>
<tmpl_var name="BANNER">
Modified: trunk/vhffs-public/templates/index.tmpl
===================================================================
--- trunk/vhffs-public/templates/index.tmpl 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-public/templates/index.tmpl 2007-08-26 12:59:55 UTC (rev 773)
@@ -9,7 +9,9 @@
<link rel="alternate" type="application/rss+xml" title="Lastgroups" href="rss/lastgroups.pl" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-
+ <tmpl_loop name="JSCRIPTS">
+ <script language="javascript" type="text/javascript" charset="utf-8" src="<tmpl_var name="SCRIPT">"></script>
+ </tmpl_loop>
</head>
<body>
<tmpl_var name="BANNER">
Modified: trunk/vhffs-public/templates/lastgroups.tmpl
===================================================================
--- trunk/vhffs-public/templates/lastgroups.tmpl 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-public/templates/lastgroups.tmpl 2007-08-26 12:59:55 UTC (rev 773)
@@ -7,7 +7,9 @@
<link rel="stylesheet" type="text/css" href="/themes/<tmpl_var name="THEME">/main.css" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-
+ <tmpl_loop name="JSCRIPTS">
+ <script language="javascript" type="text/javascript" charset="utf-8" src="<tmpl_var name="SCRIPT">"></script>
+ </tmpl_loop>
</head>
<body>
<tmpl_var name="BANNER">
Modified: trunk/vhffs-public/templates/lastusers.tmpl
===================================================================
--- trunk/vhffs-public/templates/lastusers.tmpl 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-public/templates/lastusers.tmpl 2007-08-26 12:59:55 UTC (rev 773)
@@ -7,7 +7,9 @@
<link rel="stylesheet" type="text/css" href="/themes/<tmpl_var name="THEME">/main.css" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-
+ <tmpl_loop name="JSCRIPTS">
+ <script language="javascript" type="text/javascript" charset="utf-8" src="<tmpl_var name="SCRIPT">"></script>
+ </tmpl_loop>
</head>
<body>
<tmpl_var name="BANNER">
Modified: trunk/vhffs-public/templates/misc/list-part.tmpl
===================================================================
--- trunk/vhffs-public/templates/misc/list-part.tmpl 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-public/templates/misc/list-part.tmpl 2007-08-26 12:59:55 UTC (rev 773)
@@ -1,3 +1,3 @@
<li>
-<tmpl_var name="LISTNAME"> <a href="<tmpl_var name="ARCHIVESURL">/<tmpl_var name="DOMAIN">/<tmpl_var name="LOCALPART">"><tmpl_var name="ARCHIVES_TEXT"></a>
+<tmpl_var expr="obfuscate_email(LISTNAME)"> <a href="<tmpl_var name="ARCHIVESURL">/<tmpl_var name="DOMAIN">/<tmpl_var name="LOCALPART">"><tmpl_var name="ARCHIVES_TEXT"></a>
</li>
Modified: trunk/vhffs-public/templates/simplemsg.tmpl
===================================================================
--- trunk/vhffs-public/templates/simplemsg.tmpl 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-public/templates/simplemsg.tmpl 2007-08-26 12:59:55 UTC (rev 773)
@@ -7,7 +7,9 @@
<link rel="stylesheet" type="text/css" href="/themes/<tmpl_var name="THEME">/main.css" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-
+ <tmpl_loop name="JSCRIPTS">
+ <script language="javascript" type="text/javascript" charset="utf-8" src="<tmpl_var name="SCRIPT">"></script>
+ </tmpl_loop>
</head>
<body>
<div class="logo">
Modified: trunk/vhffs-public/templates/user.tmpl
===================================================================
--- trunk/vhffs-public/templates/user.tmpl 2007-08-22 10:28:12 UTC (rev 772)
+++ trunk/vhffs-public/templates/user.tmpl 2007-08-26 12:59:55 UTC (rev 773)
@@ -7,7 +7,9 @@
<link rel="stylesheet" type="text/css" href="/themes/<tmpl_var name="THEME">/main.css" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-
+ <tmpl_loop name="JSCRIPTS">
+ <script language="javascript" type="text/javascript" charset="utf-8" src="<tmpl_var name="SCRIPT">"></script>
+ </tmpl_loop>
</head>
<body>
<tmpl_var name="BANNER">