function __construct() { if (getperms('B')) { $this->moderator = true; } $this->engine = e107::pref('core', 'comments_engine', 'e107'); //TODO - add a pref for comments per page. // $this->commentsPerPage = pref; global $COMMENTSTYLE; if (!$COMMENTSTYLE) { require e107::coreTemplatePath('comment'); // using require_once() could cause an empty template if the template is already loaded, for example, by the comment-menu al } elseif (!vartrue($COMMENT_TEMPLATE)) { global $sc_style; /* $COMMENTSTYLE = " <table class='fborder' style='".USER_WIDTH."'> <tr> <td colspan='2' class='forumheader'> {SUBJECT} {USERNAME} {TIMEDATE} {REPLY} {COMMENTEDIT} </td> </tr> <tr> <td style='width:30%; vertical-align:top;'> {AVATAR}<span class='smalltext'>{COMMENTS}{JOINED}</span> </td> <td style='width:70%; vertical-align:top;'> {COMMENT} {RATING} {IPADDRESS} {LEVEL} {LOCATION} {SIGNATURE} </td> </tr> </table> <br />"; */ $COMMENT_TEMPLATE['ITEM'] = $COMMENTSTYLE; $COMMENT_TEMPLATE['LAYOUT'] = "{COMMENTS}{COMMENTFORM}{MODERATE}{COMMENTNAV}"; $COMMENT_TEMPLATE['FORM'] = "<table style='width:100%'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{SUBJECT_INPUT}\n\t\t\t\t\t\t\t\t\t\t\t\t\t{AUTHOR_INPUT}\n\t\t\t\t\t\t\t\t\t\t\t\t\t{RATE_INPUT}\n\t\t\t\t\t\t\t\t\t\t\t\t\t{COMMENT_INPUT}\n\t\t\t\t\t\t\t\t\t\t\t\t\t{COMMENT_BUTTON}\n\t\t\t\t\t\t\t\t\t\t\t\t</table>"; $sc_style['SUBJECT_INPUT']['pre'] = "<tr><td style='width:20%'>" . COMLAN_324 . "</td><td style='width:80%'>"; $sc_style['SUBJECT_INPUT']['post'] = "</td></tr>"; $sc_style['AUTHOR_INPUT']['pre'] = "<tr><td style='width:20%; vertical-align:top;'>" . COMLAN_16 . "</td><td style='width:80%'>"; $sc_style['AUTHOR_INPUT']['post'] = "</td></tr>"; $sc_style['RATE_INPUT']['pre'] = "<tr><td style='width:20%; vertical-align:top;'>" . LAN_RATING . ":</td><td style='width:80%;'>"; $sc_style['RATE_INPUT']['post'] = "</td></tr>"; $sc_style['COMMENT_INPUT']['pre'] = "<tr><td style='width:20%; vertical-align:top;'>" . COMLAN_8 . ":</td><td id='commentform' style='width:80%;'>"; $sc_style['COMMENT_INPUT']['post'] = "</td></tr>"; $sc_style['COMMENT_BUTTON']['pre'] = "<tr style='vertical-align:top'><td colspan='2' id='commentformbutton' style='width:80%;'>"; $sc_style['COMMENT_BUTTON']['post'] = "</td></tr>"; } $this->template = array_change_key_case($COMMENT_TEMPLATE); }
/* * e107 website system * * Copyright (C) 2008-2009 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * * * $Source: /cvs_backup/e107_0.8/e107_admin/admin.php,v $ * $Revision$ * $Date$ * $Author$ */ require_once '../class2.php'; include_once e107::coreTemplatePath('admin_icons'); // Needs to be loaded before infopanel AND in boot.php if (vartrue($_GET['iframe']) == 1) { define('e_IFRAME', true); } $e_sub_cat = 'main'; if (varset($pref['adminstyle']) == 'cascade' || varset($pref['adminstyle']) == 'beginner') { $pref['adminstyle'] = 'infopanel'; } if (strpos($pref['adminstyle'], 'infopanel') === 0) { require_once e_ADMIN . 'includes/' . $pref['adminstyle'] . '.php'; $_class = 'adminstyle_' . $pref['adminstyle']; if (class_exists($_class, false)) { $adp = new $_class(); } else { $adp = new adminstyle_infopanel();
function renderButtons($template, $id = '', $options = array()) { $tp = e107::getParser(); require e107::coreTemplatePath('bbcode'); //correct way to load a core template. $pref = e107::getPref('e_bb_list'); if (!empty($pref)) { foreach ($pref as $val) { if (is_readable(e_PLUGIN . $val . "/e_bb.php")) { require e_PLUGIN . $val . "/e_bb.php"; } } } $temp = array(); $temp['news'] = $BBCODE_TEMPLATE_NEWSPOST; $temp['submitnews'] = $BBCODE_TEMPLATE_SUBMITNEWS; $temp['extended'] = $BBCODE_TEMPLATE_NEWSPOST; $temp['admin'] = $BBCODE_TEMPLATE_ADMIN; $temp['mailout'] = $BBCODE_TEMPLATE_MAILOUT; $temp['page'] = $BBCODE_TEMPLATE_CPAGE; $temp['maintenance'] = $BBCODE_TEMPLATE_ADMIN; $temp['comment'] = $BBCODE_TEMPLATE_COMMENT; $temp['signature'] = $BBCODE_TEMPLATE_SIGNATURE; if (isset($temp[$template])) { $BBCODE_TEMPLATE = $temp[$template]; } elseif (strpos($template, "{") !== false) { $BBCODE_TEMPLATE = $template; $template = 'comment'; } elseif (ADMIN_AREA) { $BBCODE_TEMPLATE = $BBCODE_TEMPLATE_ADMIN; } else { $BBCODE_TEMPLATE = $BBCODE_TEMPLATE; } $bbcode_shortcodes = e107::getScBatch('bbcode'); $data = array('tagid' => $id, 'template' => $template, 'trigger' => vartrue($options['trigger']), 'size' => vartrue($helpsize), 'eplug_bb' => varset($eplug_bb)); $bbcode_shortcodes->setVars($data); return "<div id='bbcode-panel-" . $id . "' class='mceToolbar bbcode-panel'>" . $tp->parseTemplate($BBCODE_TEMPLATE, TRUE, $bbcode_shortcodes) . "</div>"; }
require_once e_HANDLER . 'validator_class.php'; $ue = new e107_user_extended(); $userMethods = e107::getUserSession(); require_once e_HANDLER . 'ren_help.php'; if (deftrue('BOOTSTRAP') === 3) { $template = e107::getCoreTemplate('usersettings', '', true, true); // always merge $USERSETTINGS_MESSAGE = "{MESSAGE}"; $USERSETTINGS_MESSAGE_CAPTION = LAN_OK; $USERSETTINGS_EDIT_CAPTION = LAN_USET_39; // 'Update User Settings' $USERSETTINGS_EDIT = $template['edit']; $usersettings_shortcodes = e107::getScBatch('usersettings'); $usersettings_shortcodes->wrapper('usersettings/edit'); } else { include_once e107::coreTemplatePath('usersettings'); //correct way to load a core template. e107::scStyle($sc_style); $usersettings_shortcodes = e107::getScBatch('usersettings'); } e107::js('footer-inline', "\n\tfunction addtext_us(sc)\n\t{\n\t\tdocument.getElementById('dataform').image.value = sc;\n\t}\n\t"); $photo_to_delete = ''; $avatar_to_delete = ''; $ue_fields = ''; $promptPassword = false; $error = FALSE; $extraErrors = array(); $eufVals = array(); $savePassword = ''; $inp = USERID; // Initially assume that user is modifying their own data.
if (USERID == $tmp[1] || ADMIN && getperms("4")) { $sql->select("user", "user_sess", "user_id='" . USERID . "'"); $row = $sql->db_Fetch(); @unlink(e_AVATAR_UPLOAD . $row['user_sess']); $sql->update("user", "user_sess='' WHERE user_id=" . intval($tmp[1])); header("location:" . e_SELF . "?id." . $tmp[1]); exit; } } $qs = explode(".", e_QUERY); $self_page = $qs[0] == 'id' && intval($qs[1]) == USERID; $USER_TEMPLATE = e107::getCoreTemplate('user'); e107::scStyle($sc_style); if (empty($USER_TEMPLATE)) { e107::getMessage()->addDebug("Using v1.x user template"); include_once e107::coreTemplatePath('user'); //correct way to load a core template. } else { $USER_FULL_TEMPLATE = $USER_TEMPLATE['view']; $USER_SHORT_TEMPLATE_START = $USER_TEMPLATE['list']['start']; $USER_SHORT_TEMPLATE = $USER_TEMPLATE['list']['item']; $USER_SHORT_TEMPLATE_END = $USER_TEMPLATE['list']['end']; } $TEMPLATE = str_replace('{USER_EMBED_USERPROFILE}', '{USER_ADDONS}', $TEMPLATE); // BC Fix $user_shortcodes = e107::getScBatch('user'); $user_shortcodes->wrapper('user/view'); /* if (file_exists(THEME."user_template.php")) { require_once(THEME."user_template.php");
/* if (USE_IMAGECODE) { $sc = array ( 'FPW_TABLE_SECIMG_LAN' => LAN_FPW2, 'FPW_TABLE_SECIMG_HIDDEN' => "<input type='hidden' name='rand_num' value='".$sec_img->random_number."' />", 'FPW_TABLE_SECIMG_SECIMG' => $sec_img->r_image(), 'FPW_TABLE_SECIMG_TEXTBOC' => "<input class='tbox' type='text' name='code_verify' size='15' maxlength='20' />" ); } */ if (deftrue('BOOTSTRAP')) { // TODO do we want the <form> element outside the template? $FPW_TABLE = "<form method='post' action='" . SITEURL . "fpw.php' autocomplete='off'>"; $FPW_TABLE .= e107::getCoreTemplate('fpw', 'form'); $FPW_TABLE .= "</form>"; $caption = deftrue('LAN_FPW_100', "Forgot your password?"); } elseif (!$FPW_TABLE) { require_once e107::coreTemplatePath('fpw'); //correct way to load a core template. $caption = LAN_03; } $sc = new fpw_shortcodes(); // New Shortcode names in v2. BC Fix. $bcShortcodes = array('{FPW_TABLE_SECIMG_LAN}', '{FPW_TABLE_SECIMG_HIDDEN}', '{FPW_TABLE_SECIMG_SECIMG}', '{FPW_TABLE_SECIMG_TEXTBOC}'); $nwShortcodes = array('{FPW_CAPTCHA_LAN}', '{FPW_CAPTCHA_HIDDEN}', '{FPW_CAPTCHA_IMG}', '{FPW_CAPTCHA_INPUT}'); $FPW_TABLE = str_replace($bcShortcodes, $nwShortcodes, $FPW_TABLE); $text = $tp->parseTemplate($FPW_TABLE, true, $sc); // $text = $tp->simpleParse($FPW_TABLE, $sc); $ns->tablerender($caption, $text); require_once FOOTERF;
/** * Render user email. * Additional user fields: * 'mail_subject' -> required when type is not signup * 'mail_body' -> required when type is not signup * 'mail_copy_to' -> optional, carbon copy, used when type is not signup * 'mail_bcopy_to' -> optional, blind carbon copy, used when type is not signup * 'mail_attach' -> optional, attach files, available for all types, additionally it overrides $SIGNUPEMAIL_ATTACHMENTS when type is signup * 'mail_options' -> optional, available for all types, any additional valid mailer option as described in e107Email::sendEmail() phpDoc help (options above can override them) * All standard user fields from the DB (user_name, user_loginname, etc.) * * @param string $type signup|notify|email|quickadd * @param array $userInfo * @return array */ public function renderEmail($type, $userInfo) { $pref = e107::getPref(); $ret = array(); $tp = e107::getParser(); $mes = e107::getMessage(); // mailer options if (isset($userInfo['mail_options']) && is_array($userInfo['mail_options'])) { $ret = $userInfo['mail_options']; } // required for signup and quickadd email type e107::coreLan('signup'); $EMAIL_TEMPLATE = e107::getCoreTemplate('email'); if (!is_array($EMAIL_TEMPLATE)) { // load from old location. (root of theme folder if it exists) if (file_exists(THEME . 'email_template.php')) { include THEME . 'email_template.php'; } else { // include core default. include e107::coreTemplatePath('email'); } // BC Fixes. $EMAIL_TEMPLATE['signup']['subject'] = $SIGNUPEMAIL_SUBJECT; $EMAIL_TEMPLATE['signup']['cc'] = $SIGNUPEMAIL_CC; $EMAIL_TEMPLATE['signup']['bcc'] = $SIGNUPEMAIL_BCC; $EMAIL_TEMPLATE['signup']['attachments'] = $SIGNUPEMAIL_ATTACHMENTS; $EMAIL_TEMPLATE['signup']['body'] = $SIGNUPEMAIL_TEMPLATE; $EMAIL_TEMPLATE['quickadduser']['body'] = $QUICKADDUSER_TEMPLATE['email_body']; $EMAIL_TEMPLATE['notify']['body'] = $NOTIFY_TEMPLATE['email_body']; } $template = ''; switch ($type) { case 'signup': $template = vartrue($SIGNUPPROVIDEREMAIL_TEMPLATE) ? $SIGNUPPROVIDEREMAIL_TEMPLATE : $EMAIL_TEMPLATE['signup']['body']; $ret['template'] = 'signup'; // // false Don't allow additional headers (mailer) ?? break; case 'quickadd': $template = $EMAIL_TEMPLATE['quickadduser']['body']; $ret['template'] = 'quickadduser'; // Don't allow additional headers (mailer) break; case 'notify': if (vartrue($userInfo['mail_body'])) { $template = $userInfo['mail_body']; } //$NOTIFY_HEADER.$userInfo['mail_body'].$NOTIFY_FOOTER; $ret['template'] = 'notify'; break; case 'email': case 'default': if (vartrue($userInfo['mail_body'])) { $template = $userInfo['mail_body']; } //$EMAIL_HEADER.$userInfo['mail_body'].$EMAIL_FOOTER; $ret['template'] = 'default'; break; } if (!$template) { $mes->addDebug('$template is empty in user_model.php line 1171.'); // Debug only, do not translate. return array(); } $pass_show = varset($userInfo['user_password']); // signup email only if ($type == 'signup') { $HEAD = ''; $FOOT = ''; $ret['e107_header'] = $userInfo['user_id']; if (vartrue($EMAIL_TEMPLATE['signup']['cc'])) { $ret['email_copy_to'] = $EMAIL_TEMPLATE['signup']['cc']; } if (vartrue($EMAIL_TEMPLATE['signup']['bcc'])) { $ret['email_bcopy_to'] = $EMAIL_TEMPLATE['signup']['bcc']; } if (vartrue($userInfo['email_attach'])) { $ret['email_attach'] = $userInfo['mail_attach']; } elseif (vartrue($EMAIL_TEMPLATE['signup']['attachments'])) { $ret['email_attach'] = $EMAIL_TEMPLATE['signup']['attachments']; } $style = vartrue($SIGNUPEMAIL_LINKSTYLE) ? "style='{$SIGNUPEMAIL_LINKSTYLE}'" : ""; if (empty($userInfo['activation_url']) && !empty($userInfo['user_sess']) && !empty($userInfo['user_id'])) { $userInfo['activation_url'] = SITEURL . "signup.php?activate." . $userInfo['user_id'] . "." . $userInfo['user_sess']; } $sc = array(); $sc['LOGINNAME'] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email']; $sc['PASSWORD'] = $pass_show ? $pass_show : '******'; $sc['ACTIVATION_LINK'] = strpos($userInfo['activation_url'], 'http') === 0 ? '<a href="' . $userInfo['activation_url'] . '">' . $userInfo['activation_url'] . '</a>' : $userInfo['activation_url']; // $sc['SITENAME'] = SITENAME; $sc['SITEURL'] = "<a href='" . SITEURL . "' {$style}>" . SITEURL . "</a>"; $sc['USERNAME'] = $userInfo['user_name']; $sc['USERURL'] = vartrue($userInfo['user_website']) ? $userInfo['user_website'] : ""; $sc['DISPLAYNAME'] = $userInfo['user_login'] ? $userInfo['user_login'] : $userInfo['user_name']; $sc['EMAIL'] = $userInfo['user_email']; $sc['ACTIVATION_URL'] = $userInfo['activation_url']; $ret['email_subject'] = $EMAIL_TEMPLATE['signup']['subject']; // $subject; $ret['send_html'] = TRUE; $ret['shortcodes'] = $sc; if (!varset($EMAIL_TEMPLATE['signup']['header'])) { $HEAD = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"; $HEAD .= "<html xmlns='http://www.w3.org/1999/xhtml' >\n"; $HEAD .= "<head><meta http-equiv='content-type' content='text/html; charset=utf-8' />\n"; $HEAD .= $SIGNUPEMAIL_USETHEME == 1 ? "<link rel=\"stylesheet\" href=\"" . SITEURLBASE . THEME_ABS . "style.css\" type=\"text/css\" />\n" : ""; $HEAD .= "<title>" . LAN_SIGNUP_58 . "</title>\n"; if ($SIGNUPEMAIL_USETHEME == 2) { $CSS = file_get_contents(THEME . "style.css"); $HEAD .= "<style>\n" . $CSS . "\n</style>"; } $HEAD .= "</head>\n"; if (vartrue($SIGNUPEMAIL_BACKGROUNDIMAGE)) { $HEAD .= "<body background=\"" . $SIGNUPEMAIL_BACKGROUNDIMAGE . "\" >\n"; } else { $HEAD .= "<body>\n"; } } else { $HEAD = ""; // $tp->parseTemplate($EMAIL_TEMPLATE['signup']['header'], true); } if (!varset($EMAIL_TEMPLATE['signup']['footer'])) { $FOOT = "\n</body>\n</html>\n"; } else { $FOOT = ""; // $tp->parseTemplate($EMAIL_TEMPLATE['signup']['footer'], true); } $ret['send_html'] = TRUE; $ret['email_body'] = $HEAD . $template . $FOOT; // e107::getParser()->parseTemplate(str_replace($search,$replace,$HEAD.$template.$FOOT), true); $ret['preview'] = $tp->parseTemplate($ret['email_body'], true, $sc); // Non-standard field $ret['shortcodes'] = $sc; return $ret; } // all other email types if (!$userInfo['mail_subject']) { $mes->addDebug('No Email subject provided to renderEmail() method.'); // Debug only, do not translate. return array(); } $templateName = $ret['template']; $ret['email_subject'] = varset($EMAIL_TEMPLATE[$templateName]['subject'], $EMAIL_TEMPLATE['default']['subject']); // $subject; $ret['e107_header'] = $userInfo['user_id']; if (vartrue($userInfo['email_copy_to'])) { $ret['email_copy_to'] = $userInfo['email_copy_to']; } if (vartrue($userInfo['email_bcopy_to'])) { $ret['email_bcopy_to'] = $userInfo['email_bcopy_to']; } if (vartrue($userInfo['email_attach'])) { $ret['email_attach'] = $userInfo['email_attach']; } $sc = array(); $sc['LOGINNAME'] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email']; $sc['DISPLAYNAME'] = $userInfo['user_login'] ? $userInfo['user_login'] : $userInfo['user_name']; $sc['SITEURL'] = "<a href='" . SITEURL . "'>" . SITEURL . "</a>"; $sc['USERNAME'] = $userInfo['user_name']; $sc['USERURL'] = vartrue($userInfo['user_website']) ? $userInfo['user_website'] : ""; $sc['PASSWORD'] = $pass_show ? $pass_show : '******'; $sc['SUBJECT'] = $userInfo['mail_subject']; /* $search[0] = '{LOGINNAME}'; $replace[0] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email']; $search[1] = '{DISPLAYNAME}'; $replace[1] = $userInfo['user_login'] ? $userInfo['user_login'] : $userInfo['user_name']; $search[2] = '{EMAIL}'; $replace[2] = $userInfo['user_email']; $search[3] = '{SITENAME}'; $replace[3] = SITENAME; $search[4] = '{SITEURL}'; $replace[4] = "<a href='".SITEURL."'>".SITEURL."</a>"; $search[5] = '{USERNAME}'; $replace[5] = $userInfo['user_name']; $search[6] = '{USERURL}'; $replace[6] = vartrue($userInfo['user_website']) ? $userInfo['user_website'] : ""; $ret['email_subject'] = $subject; // str_replace($search, $replace, $subject); - performed in mail handler. $search[7] = '{PASSWORD}'; $replace[7] = $pass_show ? $pass_show : '******'; */ if (isset($userInfo['activation_url'])) { $sc['ACTIVATION_URL'] = $userInfo['activation_url']; $sc['ACTIVATION_LINK'] = strpos($userInfo['activation_url'], 'http') === 0 ? '<a href="' . $userInfo['activation_url'] . '">' . $userInfo['activation_url'] . '</a>' : $userInfo['activation_url']; /* $search[8] = '{ACTIVATION_URL}'; $replace[8] = $userInfo['activation_url']; $search[9] = '{ACTIVATION_LINK}'; $replace[9] = strpos($userInfo['activation_url'], 'http') === 0 ? '<a href="'.$userInfo['activation_url'].'">'.$userInfo['activation_url'].'</a>' : $userInfo['activation_url']; */ } $ret['send_html'] = TRUE; $ret['email_body'] = $template; // e107::getParser()->parseTemplate(str_replace($search, $replace, $template)); - performed in mail handler. $ret['preview'] = $ret['mail_body']; // Non-standard field $ret['shortcodes'] = $sc; return $ret; }
e107::coreLan('signup'); //include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE); // include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_usersettings.php"); Shouldn't need this now } e107::coreLan('user'); // Generic user-related language defines define('SIGNUP_DEBUG', FALSE); e107::js('core', 'jquery.mailcheck.min.js', 'jquery', 2); include_once e_HANDLER . 'user_extended_class.php'; $usere = new e107_user_extended(); require_once e_HANDLER . 'validator_class.php'; // require_once(e_HANDLER.'user_handler.php'); $userMethods = e107::getUserSession(); $userMethods->deleteExpired(); // Delete time-expired partial registrations require_once e107::coreTemplatePath('signup'); //correct way to load a core template. $signup_shortcodes = e107::getScBatch('signup'); // $facebook_shortcodes = e107::getScBatch('facebook',TRUE); $signup_imagecode = $pref['signcode'] && extension_loaded('gd'); $text = ''; $extraErrors = array(); $error = FALSE; // ------------------------------------------------------------------ if (!$_POST) { $error = ''; $text = ' '; $password1 = ''; $password2 = ''; $email = ''; // Used in shortcodes
/** * Constructor sets up all the global options, and sensible defaults - it should be the only place the prefs are accessed * * @var array $overrides - array of values which override mail-related prefs. Key is the same as the corresponding pref. * @return none */ public function __construct($overrides = FALSE) { parent::__construct(FALSE); // Parent constructor - no exceptions for now $e107 = e107::getInstance(); global $pref; //Load up Email Templates include e107::coreTemplatePath('email', 'front'); $this->templateOption['email'] = array('header' => $EMAIL_HEADER, 'footer' => $EMAIL_FOOTER); $this->templateOption['notify'] = array('header' => $NOTIFY_HEADER, 'footer' => $NOTIFY_FOOTER); $this->templateOption['mailout'] = array('header' => $MAILOUT_HEADER, 'footer' => $MAILOUT_FOOTER); $this->CharSet = 'utf-8'; $this->SetLanguage(CORE_LC); if ($overrides === FALSE || !is_array($overrides)) { $overrides = array(); } foreach (array('mailer', 'smtp_server', 'smtp_username', 'smtp_password', 'sendmail', 'siteadminemail', 'siteadmin', 'smtp_pop3auth') as $k) { if (!isset($overrides[$k])) { $overrides[$k] = $pref[$k]; } } $this->pause_amount = varset($pref['mail_pause'], 10); $this->pause_time = varset($pref['mail_pausetime'], 1); if (varsettrue($pref['mail_options'])) { $this->general_opts = explode(',', $pref['mail_options'], ''); } if (defined('MAIL_DEBUG')) { echo 'Mail_options: ' . $pref['mail_options'] . ' Count: ' . count($this->general_opts) . '<br />'; } foreach ($this->general_opts as $k => $v) { $v = trim($v); $this->general_opts[$k] = $v; if (strpos($v, 'hostname') === 0) { list(, $this->HostName) = explode('=', $v); if (defined('MAIL_DEBUG')) { echo "Host name set to: {$this->HostName}<br />"; } } } list($this->logEnable, $this->add_email) = explode(',', varset($pref['mail_log_options'], '0,0')); switch ($overrides['mailer']) { case 'smtp': $smtp_options = array(); $temp_opts = explode(',', varset($pref['smtp_options'], '')); if (varsettrue($overrides['smtp_pop3auth'])) { $temp_opts[] = 'pop3auth'; } // Legacy option - remove later if (varsettrue($pref['smtp_keepalive'])) { $temp_opts[] = 'keepalive'; } // Legacy option - remove later foreach ($temp_opts as $k => $v) { if (strpos($v, '=') !== FALSE) { list($v, $k) = explode('=', $v, 2); $smtp_options[trim($v)] = trim($k); } else { $smtp_options[trim($v)] = TRUE; // Simple on/off option } } unset($temp_opts); $this->IsSMTP(); // Enable SMTP functions if (varsettrue($smtp_options['helo'])) { $this->Helo = $smtp_options['helo']; } if (isset($smtp_options['pop3auth'])) { // Need POP-before-SMTP authorisation require_once e_HANDLER . 'phpmailer/class.pop3.php'; $pop = new POP3(); $pop->Authorise($overrides['smtp_server'], 110, 30, $overrides['smtp_username'], $overrides['smtp_password'], 1); } $this->Mailer = 'smtp'; $this->localUseVerp = isset($smtp_options['useVERP']); if (isset($smtp_options['secure'])) { switch ($smtp_options['secure']) { case 'TLS': $this->SMTPSecure = 'tls'; $this->Port = 465; // Can also use port 587, and maybe even 25 break; case 'SSL': $this->SMTPSecure = 'ssl'; $this->Port = 465; break; default: if (defined('MAIL_DEBUG')) { echo "Invalid option: {$smtp_options['secure']}<br />"; } } } $this->SMTPKeepAlive = varset($smtp_options['keepalive'], FALSE); // ***** Control this $this->Host = $overrides['smtp_server']; if ($overrides['smtp_username'] && $overrides['smtp_password']) { $this->SMTPAuth = !isset($smtp_options['pop3auth']); $this->Username = $overrides['smtp_username']; $this->Password = $overrides['smtp_password']; } break; case 'sendmail': $this->Mailer = 'sendmail'; $this->Sendmail = $overrides['sendmail'] ? $overrides['sendmail'] : '/usr/sbin/sendmail -t -i -r ' . varsettrue($pref['replyto_email'], $overrides['siteadminemail']); break; case 'php': $this->Mailer = 'mail'; break; } if (varsettrue($pref['mail_bounce_email'])) { $this->Sender = $pref['mail_bounce_email']; } $this->FromName = $e107->tp->toHTML(varsettrue($pref['replyto_name'], $overrides['siteadmin']), '', 'RAWTEXT'); $this->From = $e107->tp->toHTML(varsettrue($pref['replyto_email'], $overrides['siteadminemail']), '', 'RAWTEXT'); $this->WordWrap = 76; // Set a sensible default // Now look for any overrides - slightly cumbersome way of doing it, but does give control over what can be set from here // Options are those accepted by the arraySet() method. foreach (array('SMTPDebug', 'subject', 'from', 'fromname', 'replyto', 'send_html', 'add_html_header', 'attachments', 'cc', 'bcc', 'bouncepath', 'returnreceipt', 'priority', 'extra_header', 'wordwrap', 'split') as $opt) { if (isset($overrides[$opt])) { $this->arraySet(array($opt => $overrides[$opt])); } } }
/** * Render user email. * Additional user fields: * 'mail_subject' -> required when type is not signup * 'mail_body' -> required when type is not signup * 'mail_copy_to' -> optional, carbon copy, used when type is not signup * 'mail_bcopy_to' -> optional, blind carbon copy, used when type is not signup * 'mail_attach' -> optional, attach files, available for all types, additionally it overrides $SIGNUPEMAIL_ATTACHMENTS when type is signup * 'mail_options' -> optional, available for all types, any additional valid mailer option as described in e107Email::sendEmail() phpDoc help (options above can override them) * All standard user fields from the DB (user_name, user_loginname, etc.) * * @param array $userInfo * @param string $type signup|notify|default * @return array */ public function renderEmail($type, $userInfo) { $pref = e107::getPref(); $ret = array(); // mailer options if (isset($userInfo['mail_options']) && is_array($userInfo['mail_options'])) { $ret = $userInfo['mail_options']; } // FIXME convert to the new template to avoid include on every call // BC if (file_exists(THEME . 'email_template.php')) { include THEME . 'email_template.php'; } else { // new standards include e107::coreTemplatePath('email'); } $template = ''; switch ($type) { case 'signup': if (vartrue($SIGNUPPROVIDEREMAIL_TEMPLATE)) { $template = $SIGNUPPROVIDEREMAIL_TEMPLATE; } else { $template = $SIGNUPEMAIL_TEMPLATE; } break; case 'notify': if (vartrue($userInfo['mail_body'])) { $template = $NOTIFY_HEADER . $userInfo['mail_body'] . $NOTIFY_FOOTER; } break; case 'default': if (vartrue($userInfo['mail_body'])) { $template = $EMAIL_HEADER . $userInfo['mail_body'] . $EMAIL_FOOTER; } break; } if (!$template) { return array(); } // signup email only if ($type == 'signup') { $pass_show = $userInfo['user_password']; $ret['mail_recipient_id'] = $userInfo['user_id']; if (vartrue($SIGNUPEMAIL_CC)) { $ret['mail_copy_to'] = $SIGNUPEMAIL_CC; } if (vartrue($SIGNUPEMAIL_BCC)) { $ret['mail_bcopy_to'] = $SIGNUPEMAIL_BCC; } if (vartrue($userInfo['mail_attach'])) { $ret['mail_attach'] = $userInfo['mail_attach']; } elseif (vartrue($SIGNUPEMAIL_ATTACHMENTS)) { $ret['mail_attach'] = $SIGNUPEMAIL_ATTACHMENTS; } $style = vartrue($SIGNUPEMAIL_LINKSTYLE) ? "style='{$SIGNUPEMAIL_LINKSTYLE}'" : ""; $search[0] = '{LOGINNAME}'; $replace[0] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email']; $search[1] = '{PASSWORD}'; $replace[1] = $pass_show; $search[2] = '{ACTIVATION_LINK}'; $replace[2] = ''; $search[3] = '{SITENAME}'; $replace[3] = SITENAME; $search[4] = '{SITEURL}'; $replace[4] = "<a href='" . SITEURL . "' {$style}>" . SITEURL . "</a>"; $search[5] = '{USERNAME}'; $replace[5] = $userInfo['user_name']; $search[6] = '{USERURL}'; $replace[6] = varsettrue($userInfo['user_website']) ? $userInfo['user_website'] : ""; $search[7] = '{DISPLAYNAME}'; $replace[7] = $userInfo['user_login'] ? $userInfo['user_login'] : $userInfo['user_name']; $search[8] = '{EMAIL}'; $replace[8] = $userInfo['user_email']; $subject = str_replace($search, $replace, $SIGNUPEMAIL_SUBJECT); $ret['mail_subject'] = $subject; $ret['send_html'] = TRUE; $HEAD = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"; $HEAD .= "<html xmlns='http://www.w3.org/1999/xhtml' >\n"; $HEAD .= "<head><meta http-equiv='content-type' content='text/html; charset=utf-8' />\n"; $HEAD .= $SIGNUPEMAIL_USETHEME == 1 ? "<link rel=\"stylesheet\" href=\"" . SITEURLBASE . THEME_ABS . "style.css\" type=\"text/css\" />\n" : ""; $HEAD .= "<title>" . LAN_SIGNUP_58 . "</title>\n"; if ($SIGNUPEMAIL_USETHEME == 2) { $CSS = file_get_contents(THEME . "style.css"); $HEAD .= "<style>\n" . $CSS . "\n</style>"; } $HEAD .= "</head>\n"; if (vartrue($SIGNUPEMAIL_BACKGROUNDIMAGE)) { $HEAD .= "<body background=\"" . $SIGNUPEMAIL_BACKGROUNDIMAGE . "\" >\n"; } else { $HEAD .= "<body>\n"; } $FOOT = "\n</body>\n</html>\n"; $ret['mail_body'] = str_replace($search, $replace, $HEAD . $template . $FOOT); $ret['preview'] = $ret['mail_body']; // Non-standard field return $ret; } // all other email types $subject = $userInfo['mail_subject']; if (!$subject) { return array(); } $ret['mail_recipient_id'] = $userInfo['user_id']; if (vartrue($userInfo['mail_copy_to'])) { $ret['mail_copy_to'] = $userInfo['mail_copy_to']; } if (vartrue($userInfo['mail_bcopy_to'])) { $ret['mail_bcopy_to'] = $userInfo['mail_bcopy_to']; } if (vartrue($userInfo['mail_attach'])) { $ret['mail_attach'] = $userInfo['mail_attach']; } $search[0] = '{LOGINNAME}'; $replace[0] = intval($pref['allowEmailLogin']) === 0 ? $userInfo['user_loginname'] : $userInfo['user_email']; $search[1] = '{DISPLAYNAME}'; $replace[1] = $userInfo['user_login'] ? $userInfo['user_login'] : $userInfo['user_name']; $search[2] = '{EMAIL}'; $replace[2] = $userInfo['user_email']; $search[3] = '{SITENAME}'; $replace[3] = SITENAME; $search[4] = '{SITEURL}'; $replace[4] = "<a href='" . SITEURL . "'>" . SITEURL . "</a>"; $search[5] = '{USERNAME}'; $replace[5] = $userInfo['user_name']; $search[6] = '{USERURL}'; $replace[6] = vartrue($userInfo['user_website']) ? $userInfo['user_website'] : ""; $ret['mail_subject'] = str_replace($search, $replace, $subject); $ret['send_html'] = TRUE; $ret['mail_body'] = str_replace($search, $replace, $template); $ret['preview'] = $ret['mail_body']; // Non-standard field return $ret; }
function addUser() { $e107cache = e107::getCache(); $userMethods = e107::getUserSession(); $mes = e107::getMessage(); $sql = e107::getDb(); $e_event = e107::getEvent(); global $admin_log; if (!$_POST['ac'] == md5(ADMINPWCHANGE)) { exit; } $e107cache->clear('online_menu_member_total'); $e107cache->clear('online_menu_member_newest'); $error = false; if (isset($_POST['generateloginname'])) { $_POST['loginname'] = $userMethods->generateUserLogin($pref['predefinedLoginName']); } /* if (isset ($_POST['generatepassword'])) { $_POST['password1'] = $userMethods->generateRandomString('**********'); // 10-char password should be enough $_POST['password2'] = $_POST['password1']; } */ $_POST['password2'] = $_POST['password1']; // Now validate everything $allData = validatorClass::validateFields($_POST, $userMethods->userVettingInfo, true); // Do basic validation validatorClass::checkMandatory('user_name,user_loginname', $allData); // Check for missing fields (email done in userValidation() ) validatorClass::dbValidateArray($allData, $userMethods->userVettingInfo, 'user', 0); // Do basic DB-related checks $userMethods->userValidation($allData); // Do user-specific DB checks if (!isset($allData['errors']['user_password'])) { // No errors in password - keep it outside the main data array $savePassword = $allData['data']['user_password']; unset($allData['data']['user_password']); // Delete the password value in the output array } unset($_POST['password1']); // Restrict the scope of this unset($_POST['password2']); if (!check_class($pref['displayname_class'], $allData['data']['user_class'])) { if ($allData['data']['user_name'] != $allData['data']['user_loginname']) { $allData['errors']['user_name'] = ERR_FIELDS_DIFFERENT; } } if (count($allData['errors'])) { // require_once (e_HANDLER."message_handler.php"); $temp = validatorClass::makeErrorList($allData, 'USER_ERR_', '%n - %x - %t: %v', '<br />', $userMethods->userVettingInfo); // message_handler('P_ALERT',$temp); $mes->addError($temp); $error = true; } // Always save some of the entered data - then we can redisplay on error $user_data =& $allData['data']; if (!$error) { if (varset($_POST['perms'])) { $allData['data']['user_admin'] = 1; $allData['data']['user_perms'] = implode('.', $_POST['perms']); } $message = ''; $user_data['user_password'] = $userMethods->HashPassword($savePassword, $user_data['user_login']); $user_data['user_join'] = time(); if ($userMethods->needEmailPassword()) { // Save separate password encryption for use with email address $user_data['user_prefs'] = serialize(array('email_password' => $userMethods->HashPassword($savePassword, $user_data['user_email']))); } $userMethods->userClassUpdate($allData['data'], 'userall'); // Set any initial classes $userMethods->addNonDefaulted($user_data); validatorClass::addFieldTypes($userMethods->userVettingInfo, $allData); //FIXME - (SecretR) there is a better way to fix this (missing default value, sql error in strict mode - user_realm is to be deleted from DB later) $allData['data']['user_realm'] = ''; if ($sql->db_Insert('user', $allData)) { // Add to admin log $admin_log->log_event('USET_02', "UName: {$user_data['user_name']}; Email: {$user_data['user_email']}", E_LOG_INFORMATIVE); // Add to user audit trail $admin_log->user_audit(USER_AUDIT_ADD_ADMIN, $user_data, 0, $user_data['user_loginname']); $e_event->trigger('userfull', $user_data); // send everything available for user data - bit sparse compared with user-generated signup if (isset($_POST['sendconfemail'])) { // Send confirmation email to user require_once e_HANDLER . 'mail.php'; include_once e107::coreTemplatePath('email', 'front'); //correct way to load a core template. if (!isset($QUICKADDUSER_TEMPLATE)) { $QUICKADDUSER_TEMPLATE = USRLAN_185 . USRLAN_186; } $var_search = array('{SITEURL}', '{LOGIN}', '{USERNAME}', '{PASSWORD}', '{EMAIL}'); $var_replace = array(SITEURL, $user_data['user_name'], $user_data['user_login'], $savePassword, $user_data['user_email']); $e_message = str_replace($var_search, $var_replace, $QUICKADDUSER_TEMPLATE); if (sendemail($user_data['user_email'], USRLAN_187 . SITEURL, $e_message, $user_data['user_login'], '', '')) { $message = USRLAN_188 . '<br /><br />'; } else { $message = USRLAN_189 . '<br /><br />'; } } $message .= str_replace('--NAME--', $user_data['user_name'], USRLAN_174); if (isset($_POST['generateloginname'])) { $message .= '<br /><br />' . USRLAN_173 . ': ' . $user_data['user_login']; } if (isset($_POST['generatepassword'])) { $message .= '<br /><br />' . USRLAN_172 . ': ' . $savePassword; } unset($user_data); // Don't recycle the data once the user's been accepted without error } $mes->addSuccess($message); } else { } // $mes = e107::getMessage(); }