Skip to content

Commit 06d09cf

Browse files
committed
Merge pull request #47 from sman591/hide-email
Added email address obfuscation
2 parents 9aa4373 + 008d9c7 commit 06d09cf

5 files changed

Lines changed: 44 additions & 14 deletions

File tree

contact.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php include "header.php"; ?>
2+
<?php require_once('hide_email.php'); ?>
23
<div id="big" class="title">
34
<div class="wrapper">
45
<h1>
@@ -14,11 +15,11 @@
1415
3999 Nathaniel Rochester Hall<br/>
1516
Rochester, NY 14623<br/>
1617
<br/>
17-
<b>Chairman:</b> chairman&#64;csh.rit.edu<br/>
18-
<b>Membership:</b> eval&#64;csh.rit.edu<br/>
19-
<b>Alumni Contact:</b> history&#64;csh.rit.edu<br/>
20-
<b>Scholarship:</b> scholarship&#64;csh.rit.edu<br/>
21-
<b>Webmaster:</b> webmaster&#64;csh.rit.edu<br/>
18+
<b>Chairman:</b> <?php echo hide_email("chairman@csh.rit.edu"); ?><br/>
19+
<b>Membership:</b> <?php echo hide_email("eval@csh.rit.edu"); ?><br/>
20+
<b>Alumni Contact:</b> <?php echo hide_email("history@csh.rit.edu"); ?><br/>
21+
<b>Scholarship:</b> <?php echo hide_email("scholarship@csh.rit.edu"); ?><br/>
22+
<b>Webmaster:</b> <?php echo hide_email("webmaster@csh.rit.edu"); ?><br/>
2223
</p>
2324
</div>
2425

footer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
<div class="wrapper">
8484
<div id="under">
8585
<p>
86-
<a href="/contact.php">webmaster@csh.rit.edu</a>
86+
<?php require_once('hide_email.php'); ?>
87+
<a href="/contact.php"><?php echo hide_email("webmaster@csh.rit.edu", false); ?></a>
8788
</p>
8889
<p>
8990
<a href="https://github.com/computersciencehouse/CSHPublicSite">Website on Github</a>

hide_email.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
// Original: http://www.maurits.vdschee.nl/php_hide_email/
4+
function hide_email($email, $wrap_link = true, $link_content = null)
5+
{
6+
$character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
7+
$key = str_shuffle($character_set); $cipher_text = ''; $id = 'e'.rand(1,999999999);
8+
for ($i=0;$i<strlen($email);$i+=1) $cipher_text.= $key[strpos($character_set,$email[$i])];
9+
$script = 'var a="'.$key.'";var b=a.split("").sort().join("");var c="'.$cipher_text.'";var d="";';
10+
$script.= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));';
11+
$script.= 'document.getElementById("'.$id.'").innerHTML=';
12+
if ($wrap_link) {
13+
$script.= '"<a href=\\"mailto:"+d+"\\">';
14+
if ($link_content)
15+
$script.= str_replace('"', '\"', $link_content);
16+
else
17+
$script.= '"+d+"';
18+
$script.= '</a>"';
19+
}
20+
else {
21+
$script.= 'd';
22+
}
23+
$script = "eval(\"".str_replace(array("\\",'"'),array("\\\\",'\"'), $script)."\")";
24+
$script = '<script type="text/javascript">/*<![CDATA[*/'.$script.'/*]]>*/</script>';
25+
return '<span id="'.$id.'">[javascript protected email address]</span>'.$script;
26+
}
27+
28+
?>

insights.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
<img src="images/insights/header.jpg" alt="Insights Header"/>
1313
</div>
1414
<p>
15-
Insights is a promotional program where prospective students have the option to spend a weekend at Computer Science House. As the name would suggest,
16-
Insights gives students a real, first-hand experience of campus life the likes of which no tour guide can convey. Students will spend a weekend hosted
17-
by members of CSH, a Special Interest Floor dedicated to students interested in computing. They will have to opportunity to participate in learning
15+
Insights is a promotional program where prospective students have the option to spend a weekend at Computer Science House. As the name would suggest,
16+
Insights gives students a real, first-hand experience of campus life the likes of which no tour guide can convey. Students will spend a weekend hosted
17+
by members of CSH, a Special Interest Floor dedicated to students interested in computing. They will have to opportunity to participate in learning
1818
workshops hosted by house members, join in on CSH traditions like Capture the Disk, and much more.
1919
</p>
2020
<div id="insights_button_wrapper">
@@ -24,9 +24,8 @@
2424
<a href="https://form.jotform.com/52914750434152">
2525
<div id="insights_button">Registration Form</div>
2626
</a>
27-
<a href="mailto:insights@csh.rit.edu">
28-
<div id="insights_button">Contact Us</div>
29-
</a>
27+
<?php require_once('hide_email.php'); ?>
28+
<?php echo hide_email("insights@csh.rit.edu", true, '<div id="insights_button">Contact Us</div>'); ?>
3029
</div>
3130
</div>
3231
</div>

scholarship.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php include "header.php"; ?>
2+
<?php require_once('hide_email.php'); ?>
23
<div id="big" class="title">
34
<div class="wrapper">
45
<h1>
@@ -20,7 +21,7 @@
2021
<br/>
2122

2223
<h2>Contact</h2>
23-
<p>Email <a href="contact.php">scholarship@csh.rit.edu</a> with any questions about the Scholarship Fund.</p>
24+
<p>Email <a href="contact.php"><?php echo hide_email("scholarship@csh.rit.edu", false); ?></a> with any questions about the Scholarship Fund.</p>
2425
<br/>
2526

2627
<h2>FAQ</h2>
@@ -37,4 +38,4 @@
3738
Yes. Running this program through the Alumni Association allows us to make all donations tax-deductible.
3839
</div>
3940
</div>
40-
<?php include "footer.php"; ?>
41+
<?php include "footer.php"; ?>

0 commit comments

Comments
 (0)