private function send_welcome_mail() { $fTo = $this->id; $fFrom = smtp_get_admin_email(); if (empty($fFrom) || $fFrom == 'CLI') { $fFrom = $this->id; } $fSubject = Config::lang('pSendmail_subject_text'); $fBody = Config::read('welcome_text'); if (!smtp_mail($fTo, $fFrom, $fSubject, $fBody)) { $this->errormsg[] = Config::lang_f('pSendmail_result_error', $this->id); return false; } return true; }
$b_subject = mb_encode_mimeheader($_POST['subject'], 'UTF-8', 'Q'); $b_message = base64_encode($_POST['message']); $i = 0; while ($row = db_array($result['result'])) { $fTo = $row[0]; $fHeaders = 'To: ' . $fTo . "\n"; $fHeaders .= 'From: ' . $b_name . ' <' . $smtp_from_email . ">\n"; $fHeaders .= 'Subject: ' . $b_subject . "\n"; $fHeaders .= 'MIME-Version: 1.0' . "\n"; $fHeaders .= 'Content-Type: text/plain; charset=UTF-8' . "\n"; $fHeaders .= 'Content-Transfer-Encoding: base64' . "\n"; $fHeaders .= $b_message; if (!smtp_mail($fTo, $smtp_from_email, $fHeaders)) { flash_error(Config::lang_f('pSendmail_result_error', $fTo)); } else { flash_info(Config::lang_f('pSendmail_result_success', $fTo)); } } } flash_info($PALANG['pBroadcast_success']); $smarty->assign('smarty_template', 'message'); $smarty->display('index.tpl'); // echo '<p>'.$PALANG['pBroadcast_success'].'</p>'; } } if ($_SERVER['REQUEST_METHOD'] == "GET" || $error == 1) { $smarty->assign('smtp_from_email', $smtp_from_email); $smarty->assign('error', $error); $smarty->assign('smarty_template', 'broadcast-message'); $smarty->display('index.tpl'); // include ("templates/broadcast-message.tpl");
/** * store $this->values in the database * * converts values based on $this->struct[*][type] (boolean, password encryption) * * calls $this->storemore() where additional things can be done * @return bool - true if all values were stored in the database, otherwise false * error messages (if any) are stored in $this->errormsg */ public function store() { if ($this->values_valid == false) { $this->errormsg[] = "one or more values are invalid!"; return false; } if (!$this->beforestore()) { return false; } $db_values = $this->values; foreach (array_keys($db_values) as $key) { switch ($this->struct[$key]['type']) { # modify field content for some types case 'bool': $db_values[$key] = db_get_boolean($db_values[$key]); break; case 'pass': $db_values[$key] = pacrypt($db_values[$key]); break; case 'b64p': $db_values[$key] = base64_encode($db_values[$key]); break; case 'quot': case 'vnum': case 'vtxt': unset($db_values[$key]); # virtual field, never write it break; } if ($this->struct[$key]['not_in_db'] == 1) { unset($db_values[$key]); } # remove 'not in db' columns if ($this->struct[$key]['dont_write_to_db'] == 1) { unset($db_values[$key]); } # remove 'dont_write_to_db' columns } if ($this->new) { $result = db_insert($this->db_table, $db_values); } else { $result = db_update($this->db_table, $this->id_field, $this->id, $db_values); } if ($result != 1) { $this->errormsg[] = Config::lang_f($this->msg['store_error'], $this->label); return false; } $result = $this->storemore(); # db_log() even if storemore() failed db_log($this->domain, $this->msg['logname'], $this->id); if ($result) { # return success message # TODO: add option to override the success message (for example to include autogenerated passwords) $this->infomsg['success'] = Config::lang_f($this->msg['successmessage'], $this->label); } return $result; }
/** * check_email * Checks if an email is valid - if it is, return true, else false. * @param String $email - a string that may be an email address. * @return empty string if it's a valid email address, otherwise string with the errormessage * TODO: make check_email able to handle already added domains */ function check_email($email) { $ce_email = $email; //strip the vacation domain out if we are using it //and change from blah#foo.com@autoreply.foo.com to blah@foo.com if (Config::bool('vacation')) { $vacation_domain = Config::read('vacation_domain'); $ce_email = preg_replace("/@{$vacation_domain}\$/", '', $ce_email); $ce_email = preg_replace("/#/", '@', $ce_email); } // Perform non-domain-part sanity checks if (!preg_match('/^[-!#$%&\'*+\\.\\/0-9=?A-Z^_{|}~]+' . '@' . '[^@]+$/i', $ce_email)) { return Config::lang_f('pInvalidMailRegex', $email); } // Determine domain name $matches = array(); if (!preg_match('|@(.+)$|', $ce_email, $matches)) { return Config::lang_f('pInvalidMailRegex', $email); } $domain = $matches[1]; # check domain name return check_domain($domain); }