3 # This plug-in will eMail the page to the specified eMail address
4 # Plug-in written by Alfred Sterphone, III
7 $ewiki_t["en"]["EMAILPAGE"] = "This will e-mail the current page to the specified address.<br />When you are ready, click the \"_{EMAIL_THIS_PAGE}\" button.<hr>";
8 $ewiki_t["en"]["EMAIL_THIS_PAGE"] = "Email this page";
11 if(function_exists("mail"))
13 $ewiki_plugins["action"]['emailpage'] = "ewiki_page_wiki_email_page";
14 $ewiki_config["action_links"]["view"]["emailpage"] = "EMAIL_THIS_PAGE";
17 $ewiki_t["c"]["EWIKIEMAILCSS"] = '
18 <style TYPE="text/css">
21 background-color:#eeeeff;
28 border:1px solid #000000;
34 function isRequestNotSet($email_page,$email_address)
36 return ( empty($email_page) || empty($email_address) );
39 function checkEmailField($email_page_to,$not_first_time)
41 if ( empty($email_page_to) && $not_first_time == "1" )
42 return "<p><b>Please enter a valid e-mail address</b>";
47 function isUserInfoDefined($from_email,$from_name)
49 return ( !empty($from_email) && !empty($from_name) );
52 function getUserInfo(&$email,&$name)
54 global $ewiki_uservars;
56 $email = $ewiki_uservars["E-Mail Address"];
57 $name = $ewiki_uservars["Name"];
60 function htmlFormGenerate($defined,$id,$warning,$from_email,$from_name)
62 $url = ewiki_script("emailpage", "$id");
63 $info_url = ewiki_script("view","UserInfo");
67 return(ewiki_make_title($id, $id, 2) . ewiki_t(
68 //--------------------------------------------
73 <form action="$url" method="POST" enctype="multipart/form-data">
75 Your e-mail address: <b><i>$from_email</i></b>.<br />Your name: <b><i>$from_name</i></b><br />These will be included in the e-mail content and used in the "From" header of the e-mail.
77 If this is incorrect, please <a href="$info_url">update your information</a>
80 <input type="text" name="email_address">
82 Send an additional note to the sender:<br />
83 (Use <br> for a new line if necessary)<br />
84 <textarea rows="5" cols="40" name="email_text"></textarea>
86 <input type="hidden" name="not_first_time" value="1">
87 <input type="submit" name="email_page" value= "_{EMAIL_THIS_PAGE}">
91 //--------------------------------------------
95 return(ewiki_make_title($id, $id, 2) . ewiki_t(
96 //--------------------------------------------
100 <b>Your e-mail address and/or name are currently not defined.</b>
102 In order to use this feature you must <a href="$info_url">update your information</a> and fill out both fields.
106 //--------------------------------------------
110 function buildEmail($id,$data,$emailText)
113 $preamble = getPreamble($id,$emailText);
114 $page = renderPage($id,$data);
115 $disclaimer = getDisclaimer();
116 $bottom = getBottom();
118 $body = $top.$preamble.$page.$disclaimer.$bottom;
123 function renderPage($id,$data)
125 global $ewiki_plugins, $ewiki_links;
128 getUserInfo($from_email,$from_name);
130 //allowed html tags for the email
131 $allow = "<p> <b> <i> <ul> <li> <br /> <hr> <em> <tt> <h1> <h2> <h3> <h4> <h5> <font> <ol> <div> <dl> <dt> <dd> <font>";
133 //Assume all links in page exist (eliminate the ? after undefined pages)
134 $render_args = array("scan_links" => 0,"html" => (EWIKI_ALLOW_HTML||(@$data["flags"]&EWIKI_DB_F_HTML)),);
136 $page = ewiki_make_title($id, $id, 2);
137 $page .= $ewiki_plugins["render"][0] ($data["content"], $render_args);
138 $page = strip_tags($page,$allow);
143 function getNote($emailText)
145 if (empty($emailText))
151 //allowed html tags for the note
152 $allow_note = "<br />";
154 $note = "<p>Here is a small message from the sender:<br />$emailText<hr>";
155 $note = strip_tags($note,$allow_note);
163 $top = "<html><head>";
164 $top .= ewiki_t("EWIKIEMAILCSS");
165 $top .= "<title>[LiveWeb Snapshot]</title></head><body><div id=\"PageText\">";
169 function getPreamble($id,$emailText)
171 getUserInfo($from_email,$from_name);
173 $link_url = ewiki_script("view","$id");
174 $link="https://www.burgiss.com/liveweb/$link_url";
176 $note = getNote($emailText);
178 $preamble = "<p>The following e-mail is a stripped down snapshot of the \"$id\" page from Burgiss LiveWeb. ";
179 $preamble .= "If you have an account with us, click <a href=\"$link\">here</a> to view it. ";
180 $preamble .= "This was sent from $from_name with an e-mail address registered as $from_email</p>";
181 $preamble .= "$note<hr><font face=\"Arial\" size=\"-1\">";
186 function getDisclaimer()
188 $disclaimer = "</font><hr><p><tt><b>NOTICE:</b> If you have received this in error, rest asured that you are not on any mailing lists. ";
189 $disclaimer .= "If you have any concerns, please e-mail the <a href=\"mailto:webmaster@burgiss.com\">webmaster</a>.</tt></p>";
194 $bottom = "</div></body></html>";
197 function getSubject($id)
199 $subject = "[LiveWeb Snapshot] \"$id\"";
203 function getHeaders($from_email,$from_name)
205 /* To send HTML mail, you can set the Content-type header. */
206 $headers = "MIME-Version: 1.0\r\n";
207 $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
209 /* additional headers */
210 $headers .= "From: \"$from_name\" <$from_email>\r\n";
211 $headers .= "X-Mailer: ErfurtWiki/".EWIKI_VERSION."\r\n";
216 function ewiki_page_wiki_email_page($id=0, $data=0, $action=0)
218 if ( isRequestNotSet($_REQUEST["email_page"],$_REQUEST["email_address"]) )
220 if($action == "emailpage")
222 getUserInfo($from_email,$from_name);
223 $defined = isUserInfoDefined($from_email,$from_name);
225 $warning = checkEmailField($_REQUEST["email_address"],$_REQUEST["not_first_time"]);
227 $html = htmlFormGenerate($defined,$id,$warning,$from_email,$from_name);
233 return "You shouldn't be here.";
237 #-- email generation and sending
240 $emailAddress = $_REQUEST["email_address"];
241 $emailText = $_REQUEST["email_text"];
243 getUserInfo($from_email,$from_name);
244 $headers = getHeaders($from_email,$from_name);
245 $subject = getSubject($id);
247 $body = buildEmail($id,$data,$emailText);
249 mail($emailAddress,$subject,$body,$headers);
251 $success_message = "<p><h4>Success!</h4></p><p>Page sent to <a href=mailto:$emailAddress>$emailAddress</a></p>";
252 $success_message .= "<p>Click <a href=\"" . ewiki_script("view",$id) . "\">here</a> to return to the page you just sent.</p>";
254 return ( ewiki_t($success_message) );