aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mlmmj.php152
-rw-r--r--subscribe.php2
2 files changed, 76 insertions, 78 deletions
diff --git a/mlmmj.php b/mlmmj.php
index c976372..c4ff7d3 100644
--- a/mlmmj.php
+++ b/mlmmj.php
@@ -36,84 +36,84 @@ class mlmmj
var $errors;
function is_email($string="") {
- return eregi("^[a-z0-9\._-]+".chr(64)."+[a-z0-9\._-]+\.+[a-z]{2,4}$", $string);
- }
+ return filter_var($string, FILTER_VALIDATE_EMAIL);
+ }
function error($string="") {
- $this->errors = TRUE;
- die($string);
- }
-
- function mlmmj() {
- // set mandatory vars...
- $this->errors = FALSE;
- $this->delimiter = "+";
-
- if (!isset($_POST["email"]) &&
- !isset($_POST["mailinglist"]) &&
- !isset($_POST["job"]) &&
- !isset($_POST["redirect_success"]) &&
- !isset($_POST["redirect_failure"]))
- {
- $this->errors = TRUE;
- if(isset($_POST["redirect_failure"])) {
- header("Location: ".$_POST["redirect_failure"]);
- exit;
- }
- else
- die("An error occurred. Please check contrib/web/php-user/README for details.");
- }
- else {
- if ($this->is_email($_POST["email"]))
- $this->email = $_POST["email"];
- else
- $this->error("ERROR: email is not a valid email address.");
-
- if ($this->is_email($_POST["mailinglist"]))
- $this->mailinglist = $_POST["mailinglist"];
- else
- $this->error("ERROR: mailinglist is not a valid email address.");
-
- $this->job = $_POST["job"];
-
- if (!(($this->job == "subscribe") OR ($this->job == "unsubscribe"))) {
- $this->error("ERROR: job unknown.");
- }
-
- $this->redirect_failure = $_POST["redirect_failure"];
- $this->redirect_success = $_POST["redirect_success"];
-
- }
-
- // now we should try to go ahead and {sub,unsub}scribe... ;)
-
- if(!$this->errors) {
- // @ ^= char(64)
-
- $to = str_replace(chr(64),$this->delimiter.$this->job.chr(64),$this->mailinglist);
- $subject = $this->job." to ".$this->mailinglist;
- $body = $this->job;
- $addheader = "";
- $addheader .= "Received: from ". $_SERVER["REMOTE_ADDR"]
- ." by ". $_SERVER["SERVER_NAME"]. " with HTTP;\r\n\t".date("r")."\n";
- $addheader .= "X-Originating-IP: ".$_SERVER["REMOTE_ADDR"]."\n";
- $addheader .= "X-Mailer: mlmmj-webinterface powered by PHP/". phpversion() ."\n";
- $addheader .= "From: ".$this->email."\n";
- $addheader .= "Cc: ".$this->email."\n";
-
- if(!mail($to, $subject, $body, $addheader))
- $this->error($this->job." failed.");
- }
-
- if($this->errors) {
- //header("Location: ".$this->redirect_failure);
- //exit;
- die($this->errors);
- } else {
- header("Location: ".$this->redirect_success);
- exit;
- }
- }
+ $this->errors = TRUE;
+ die($string);
+ }
+
+ function __construct() {
+ // set mandatory vars...
+ $this->errors = FALSE;
+ $this->delimiter = "+";
+
+ if (!isset($_POST["email"]) &&
+ !isset($_POST["mailinglist"]) &&
+ !isset($_POST["job"]) &&
+ !isset($_POST["redirect_success"]) &&
+ !isset($_POST["redirect_failure"]))
+ {
+ $this->errors = TRUE;
+ if(isset($_POST["redirect_failure"])) {
+ header("Location: ".$_POST["redirect_failure"]);
+ exit;
+ }
+ else
+ die("An error occurred. Please check contrib/web/php-user/README for details.");
+ }
+ else {
+ if ($this->is_email($_POST["email"]))
+ $this->email = $_POST["email"];
+ else
+ $this->error("ERROR: email is not a valid email address.");
+
+ if ($this->is_email($_POST["mailinglist"]))
+ $this->mailinglist = $_POST["mailinglist"];
+ else
+ $this->error("ERROR: mailinglist is not a valid email address.");
+
+ $this->job = $_POST["job"];
+
+ if (!(($this->job == "subscribe") OR ($this->job == "unsubscribe"))) {
+ $this->error("ERROR: job unknown.");
+ }
+
+ $this->redirect_failure = $_POST["redirect_failure"];
+ $this->redirect_success = $_POST["redirect_success"];
+
+ }
+
+ // now we should try to go ahead and {sub,unsub}scribe... ;)
+
+ if(!$this->errors) {
+ // @ ^= char(64)
+
+ $to = str_replace(chr(64),$this->delimiter.$this->job.chr(64),$this->mailinglist);
+ $subject = $this->job." to ".$this->mailinglist;
+ $body = $this->job;
+ $addheader = "";
+ $addheader .= "Received: from ". $_SERVER["REMOTE_ADDR"]
+ ." by ". $_SERVER["SERVER_NAME"]. " with HTTP;\r\n\t".date("r")."\n";
+ $addheader .= "X-Originating-IP: ".$_SERVER["REMOTE_ADDR"]."\n";
+ $addheader .= "X-Mailer: mlmmj-webinterface powered by PHP/". phpversion() ."\n";
+ $addheader .= "From: ".$this->email."\n";
+ $addheader .= "Cc: ".$this->email."\n";
+
+ if(!mail($to, $subject, $body, $addheader))
+ $this->error($this->job." failed.");
+ }
+
+ if($this->errors) {
+ //header("Location: ".$this->redirect_failure);
+ //exit;
+ die("Error: ".$this->errors);
+ } else {
+ header("Location: ".$this->redirect_success);
+ exit;
+ }
+ }
}
diff --git a/subscribe.php b/subscribe.php
index d944530..f60c15b 100644
--- a/subscribe.php
+++ b/subscribe.php
@@ -30,7 +30,6 @@ $domain = "arf20.com"
<form action="mlmmj.php" method="post">
<label>Email</label><br>
<input type="email" name="email">
- <span class="help-block"><?php echo $email_err; ?></span><br>
<input name="mailinglist" type="hidden" value="<?php echo $list."@".$domain; ?>">
<input name="job" type="hidden" value="subscribe">
<input name="redirect_failure" type="hidden" value="/error.html">
@@ -42,7 +41,6 @@ $domain = "arf20.com"
<form action="mlmmj.php" method="post">
<label>Email</label><br>
<input type="email" name="email">
- <span class="help-block"><?php echo $email_err; ?></span><br>
<input name="mailinglist" type="hidden" value="<?php echo $list."@".$domain; ?>">
<input name="job" type="hidden" value="unsubscribe">
<input name="redirect_failure" type="hidden" value="/error.html">