Mercurial > hg > mlmmj
comparison contrib/web/php-user/mlmmj.php @ 769:fc5892d87716
Update php code to use superglobals
author | Ben Schmidt |
---|---|
date | Fri, 29 Oct 2010 22:13:47 +1100 |
parents | 1180bcbc90d9 |
children |
comparison
equal
deleted
inserted
replaced
768:5c46136b0359 | 769:fc5892d87716 |
---|---|
53 // die($string); | 53 // die($string); |
54 } | 54 } |
55 | 55 |
56 function mlmmj() | 56 function mlmmj() |
57 { | 57 { |
58 global $HTTP_POST_VARS, $HTTP_SERVER_VARS; | |
59 | |
60 // set mandatory vars... | 58 // set mandatory vars... |
61 $this->errors = FALSE; | 59 $this->errors = FALSE; |
62 $this->delimiter = "+"; | 60 $this->delimiter = "+"; |
63 | 61 |
64 if (!isset($HTTP_POST_VARS["email"]) && | 62 if (!isset($_POST["email"]) && |
65 !isset($HTTP_POST_VARS["mailinglist"]) && | 63 !isset($_POST["mailinglist"]) && |
66 !isset($HTTP_POST_VARS["job"]) && | 64 !isset($_POST["job"]) && |
67 !isset($HTTP_POST_VARS["redirect_success"]) && | 65 !isset($_POST["redirect_success"]) && |
68 !isset($HTTP_POST_VARS["redirect_failure"])) | 66 !isset($_POST["redirect_failure"])) |
69 { | 67 { |
70 $this->errors = TRUE; | 68 $this->errors = TRUE; |
71 if(isset($HTTP_POST_VARS["redirect_failure"])) | 69 if(isset($_POST["redirect_failure"])) |
72 { | 70 { |
73 header("Location: ".$HTTP_POST_VARS["redirect_failure"]); | 71 header("Location: ".$_POST["redirect_failure"]); |
74 exit; | 72 exit; |
75 } | 73 } |
76 else | 74 else |
77 die("An error occurred. Please check contrib/web/php-user/README for details."); | 75 die("An error occurred. Please check contrib/web/php-user/README for details."); |
78 } | 76 } |
79 else | 77 else |
80 { | 78 { |
81 if($this->is_email($HTTP_POST_VARS["email"])) | 79 if($this->is_email($_POST["email"])) |
82 $this->email = $HTTP_POST_VARS["email"]; | 80 $this->email = $_POST["email"]; |
83 else | 81 else |
84 $this->error("ERROR: email is not a valid email address."); | 82 $this->error("ERROR: email is not a valid email address."); |
85 | 83 |
86 if($this->is_email($HTTP_POST_VARS["mailinglist"])) | 84 if($this->is_email($_POST["mailinglist"])) |
87 $this->mailinglist = $HTTP_POST_VARS["mailinglist"]; | 85 $this->mailinglist = $_POST["mailinglist"]; |
88 else | 86 else |
89 $this->error("ERROR: mailinglist is not a valid email address."); | 87 $this->error("ERROR: mailinglist is not a valid email address."); |
90 | 88 |
91 $this->job = $HTTP_POST_VARS["job"]; | 89 $this->job = $_POST["job"]; |
92 | 90 |
93 if(!(($this->job == "subscribe") OR ($this->job == "unsubscribe"))) | 91 if(!(($this->job == "subscribe") OR ($this->job == "unsubscribe"))) |
94 { | 92 { |
95 $this->error("ERROR: job unknown."); | 93 $this->error("ERROR: job unknown."); |
96 } | 94 } |
97 | 95 |
98 $this->redirect_failure = $HTTP_POST_VARS["redirect_failure"]; | 96 $this->redirect_failure = $_POST["redirect_failure"]; |
99 $this->redirect_success = $HTTP_POST_VARS["redirect_success"]; | 97 $this->redirect_success = $_POST["redirect_success"]; |
100 | 98 |
101 } | 99 } |
102 | 100 |
103 // now we should try to go ahead and {sub,unsub}scribe... ;) | 101 // now we should try to go ahead and {sub,unsub}scribe... ;) |
104 | 102 |
108 | 106 |
109 $to = str_replace(chr(64),$this->delimiter.$this->job.chr(64),$this->mailinglist); | 107 $to = str_replace(chr(64),$this->delimiter.$this->job.chr(64),$this->mailinglist); |
110 $subject = $this->job." to ".$this->mailinglist; | 108 $subject = $this->job." to ".$this->mailinglist; |
111 $body = $this->job; | 109 $body = $this->job; |
112 $addheader = ""; | 110 $addheader = ""; |
113 $addheader .= "Received: from ". $HTTP_SERVER_VARS["REMOTE_ADDR"] | 111 $addheader .= "Received: from ". $_SERVER["REMOTE_ADDR"] |
114 ." by ". $HTTP_SERVER_VARS["SERVER_NAME"]. " with HTTP;\r\n\t".date("r")."\n"; | 112 ." by ". $_SERVER["SERVER_NAME"]. " with HTTP;\r\n\t".date("r")."\n"; |
115 $addheader .= "X-Originating-IP: ".$HTTP_SERVER_VARS["REMOTE_ADDR"]."\n"; | 113 $addheader .= "X-Originating-IP: ".$_SERVER["REMOTE_ADDR"]."\n"; |
116 $addheader .= "X-Mailer: mlmmj-webinterface powered by PHP/". phpversion() ."\n"; | 114 $addheader .= "X-Mailer: mlmmj-webinterface powered by PHP/". phpversion() ."\n"; |
117 $addheader .= "From: ".$this->email."\n"; | 115 $addheader .= "From: ".$this->email."\n"; |
118 $addheader .= "Cc: ".$this->email."\n"; | 116 $addheader .= "Cc: ".$this->email."\n"; |
119 | 117 |
120 if(!mail($to, $subject, $body, $addheader)) | 118 if(!mail($to, $subject, $body, $addheader)) |