[art-web] [views] Obfuscate the e-mail address in html by using rot13



commit 89d79767a507ad6fecea03200c3c010050b5b5e9
Author: Thomas Wood <thos gnome org>
Date:   Sun Nov 15 20:12:04 2009 +0000

    [views] Obfuscate the e-mail address in html by using rot13
    
    Obfuscate e-mail address to prevent harvesting by spam bots. Print the
    address to html using rot13 encoding and then convert back to normal using
    client side javascript. In the case that javascript is not available, the
    e-mail addresses are not made available either.

 views/backgrounds.php |   11 ++++++++++-
 views/themes.php      |   11 ++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/views/backgrounds.php b/views/backgrounds.php
index c8d0191..954ba5c 100644
--- a/views/backgrounds.php
+++ b/views/backgrounds.php
@@ -70,11 +70,20 @@ else
 <div style="text-align:center"><?php $p->print_pagination (); ?></div>
 <br>
 
+<script type='text/javascript'>
+// add a rot13 function to strings.
+// found at: http://stackoverflow.com/questions/617647/where-is-my-one-line-implementation-of-rot13-in-javascript-going-wrong
+String.prototype.rot13 = rot13 = function(s)
+{
+  return (s ? s : this).replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});
+}
+</script>
+
 <?php foreach ($view_data as $row): ?>
 <div class="list-item">
     <b><?php echo $row['name']?></b>
     <br>
-    <span class="item-detail">by <a href="mailto:<?php echo $row['email']?>"><?php echo $row['realname']?></a></span>
+    <span class="item-detail">by <script type='text/javascript'>document.write ('<a href="mailto:' + '<?php echo str_rot13 ($row['email'])?>'.rot13() + '">');</script><?php echo $row['realname']?><script type='text/javascript'>document.write ('</a>');</script></span>
     <br><span class="item-detail"><?php echo $license_config_link_array[$row['license']]?></span>
     <br>
     <img width="96" alt="Preview" src='/images/thumbnails/backgrounds/<?php echo $row['thumbnail_filename']?>'>
diff --git a/views/themes.php b/views/themes.php
index 685ba21..c7404da 100644
--- a/views/themes.php
+++ b/views/themes.php
@@ -72,6 +72,15 @@ $display_cat = array (
     $d_category = $display_cat [$category];
 
 ?>
+
+
+<script type='text/javascript'>
+String.prototype.rot13 = rot13 = function(s)
+{
+  return (s ? s : this).replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});
+}
+</script>
+
 <h2><a href="/themes">Themes</a> / <?php echo $d_category; ?></h2>
 <div style="text-align:center"><?php $p->print_pagination (); ?></div>
 <br>
@@ -79,7 +88,7 @@ $display_cat = array (
 
 <div class="list-item">
   <b><?php echo $row['name']?></b>
-  <br><span class="item-detail"> by <a href="mailto:<?php echo $row['email']?>"><?php echo $row['realname']?></a></span>
+  <br><span class="item-detail"> by <script type='text/javascript'>document.write ('<a href="mailto:' + '<?php echo str_rot13 ($row['email'])?>'.rot13() + '">');</script><?php echo $row['realname']?><script type='text/javascript'>document.write ('</a>');</script></span>
    <br><span class="item-detail"><?php echo $license_config_link_array[$row['license']]?></span>
   <br>
   <img style="margin:0.5em;" width="96" alt="Preview" src='/images/thumbnails/<?php echo $row['category']?>/<?php echo $row['thumbnail_filename']?>'>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]