/** * SMTP方式发邮件 * @param string $to 目标邮箱,多个地址半角逗号分隔 * @param string $subject * @param string $content */ function sendmail($to, $subject, $content, &$error = null) { $smtp = Config::get_mail('smtp'); if (!$smtp) { return false; } $mail = new SmtpMail($smtp['host'], $smtp['ip'], $smtp['port']); $mail->setFromEnv($smtp['email'], $smtp['username'], $smtp['password'], $smtp['display']); $ret = false; foreach ($to as $item) { $ret = $mail->send($item, $subject, $content, array(), $error); } return $ret; }
public function Load() { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); parent::$PAGE_TITLE = __(ERROR_PAGE) . " - " . __(SITE_NAME); parent::$PAGE_META_ROBOTS = "noindex, nofollow"; // check if URL is not bad, but could be a good URL if (isset($_GET['error-redirect-url']) && $_GET['error-redirect-url'] != "") { $url_to_check = trim($_GET['error-redirect-url']); } else { $url_to_check = trim($this->getCurrentUrl()); } $base_url_tmp = BASE_URL; if ($base_url_tmp[strlen($base_url_tmp) - 1] == "/") { $base_url_tmp = substr($base_url_tmp, 0, strlen($base_url_tmp) - 1); } $url_to_check = str_replace("%22", "\"", str_replace("%5C", "\\", str_replace("%5c", "\\", str_replace("%27", "'", $url_to_check)))); $redirect_bad_url_to = ""; if (preg_match("@" . $base_url_tmp . "([^?]*)/'(http://|https://|http:/|https:/)(.+)/'@i", $url_to_check, $matches) == 1) { // url detect with /' in the end $redirect_bad_url_to = $matches[3]; $redirect_bad_url_to_http = $matches[2]; } else { if (preg_match("@" . $base_url_tmp . "([^?]*)/'(http://|https://|http:/|https:/)(.+)'@i", $url_to_check, $matches) == 1) { // url detect with ' $redirect_bad_url_to = $matches[3]; $redirect_bad_url_to_http = $matches[2]; } else { if (preg_match("@" . $base_url_tmp . "([^?]*)/\\\\'(http://|https://|http:/|https:/)(.+)\\\\'@i", $url_to_check, $matches) == 1) { // url detect with \' $redirect_bad_url_to = $matches[3]; $redirect_bad_url_to_http = $matches[2]; } else { if (preg_match("@" . $base_url_tmp . "([^?]*)/\"(http://|https://|http:/|https:/)(.+)\"@i", $url_to_check, $matches) == 1) { // url detect with " $redirect_bad_url_to = $matches[3]; $redirect_bad_url_to_http = $matches[2]; } else { if (preg_match("@" . $base_url_tmp . "([^?]*)/(http://|https://|http:/|https:/)(.+)@i", $url_to_check, $matches) == 1) { // url detect without no ' $redirect_bad_url_to = $matches[3]; $redirect_bad_url_to_http = $matches[2]; } else { if (preg_match("@" . BASE_URL . "combine-css/'/(.+)'@i", $url_to_check, $matches) == 1) { // combine-css url with ' $redirect_bad_url_to = BASE_URL . $matches[1]; $redirect_bad_url_to_http = ""; } } } } } } // check apple icon if ($redirect_bad_url_to == "" && find($url_to_check, "apple-touch-icon") > 0) { if ($url_to_check == BASE_URL . "apple-touch-icon.png" || $url_to_check == BASE_URL . "apple-touch-icon-precomposed.png") { if (defined('SITE_META_IPHONE_IMAGE_114PX')) { $redirect_bad_url_to = SITE_META_IPHONE_IMAGE_114PX; } else { if (defined('SITE_META_IPHONE_IMAGE_72PX')) { $redirect_bad_url_to = SITE_META_IPHONE_IMAGE_72PX; } else { if (defined('SITE_META_IPHONE_IMAGE_57PX')) { $redirect_bad_url_to = SITE_META_IPHONE_IMAGE_57PX; } } } } else { if ($url_to_check == BASE_URL . "apple-touch-icon-57x57.png" || $url_to_check == BASE_URL . "apple-touch-icon-57x57-precomposed.png") { if (defined('SITE_META_IPHONE_IMAGE_57PX')) { $redirect_bad_url_to = SITE_META_IPHONE_IMAGE_57PX; } } } if ($redirect_bad_url_to != "") { if (strtoupper(substr($redirect_bad_url_to, 0, 7)) != "HTTP://" && strtoupper(substr($redirect_bad_url_to, 0, 8)) != "HTTPS://") { $redirect_bad_url_to = BASE_URL . $redirect_bad_url_to; } } } // End check if URL is not bad if ($redirect_bad_url_to != "") { // if URL is detect as bad but can be redirect to good URL if ($redirect_bad_url_to_http != "") { $redirect_bad_url_to = str_replace(":/", "", str_replace("://", "", $redirect_bad_url_to_http)) . "://" . $redirect_bad_url_to; } $this->redirect($redirect_bad_url_to); $msg_redirect = new Label(__(REDIRECT_URL_TO, $redirect_bad_url_to, $redirect_bad_url_to)); $this->render = new ErrorTemplate($msg_redirect, parent::$PAGE_TITLE); } else { // display the error page if the URL is correct $error_msg_title = ""; $array_code_error = array(401, 403, 404, 500); if (in_array($_GET['error-redirect'], $array_code_error)) { $_SESSION['calling_page'] = ""; $error_msg = constant("ERROR_" . $_GET['error-redirect'] . "_MSG"); parent::$PAGE_TITLE = constant("ERROR_" . $_GET['error-redirect'] . "_MSG") . " - " . __(SITE_NAME); $error_msg_title = constant("ERROR_" . $_GET['error-redirect'] . "_MSG"); } else { if ($_SESSION['calling_page'] == "error-page") { if (isset($_GET['error-redirect-url']) && $_GET['error-redirect-url'] != "") { $error_msg = __(ERROR_PAGE_MSG, $_GET['error-redirect-url']); } else { if ($this->getRefererURL() != "") { $error_msg = __(ERROR_PAGE_MSG, $this->getRefererURL()); } else { $error_msg = __(ERROR_PAGE_MSG, ""); } } } else { $error_msg = __(ERROR_PAGE_MSG, $_SESSION['calling_page']); } $error_msg_title = __(ERROR_PAGE); } $error_msg = new Label($error_msg, true); $obj_error_msg = new Object(new Picture("wsp/img/warning.png", 48, 48, 0, "absmidlle"), "<br/>", $error_msg->setColor("red")); $obj_error_msg->add("<br/><br/>", __(MAIN_PAGE_GO_BACK), new Link(BASE_URL, Link::TARGET_NONE, __(SITE_NAME))); $this->render = new ErrorTemplate($obj_error_msg, $error_msg_title); // check if URL is not banned if (!isset($_GET['banned_url'])) { if (file_exists(dirname(__FILE__) . "/../../wsp/config/banned_url.cnf")) { $list_banned_url = file_get_contents(dirname(__FILE__) . "/../../wsp/config/banned_url.cnf"); $array_banned_url = explode("\n", str_replace("\r", "", $list_banned_url)); } else { $array_banned_url = array(); } if (find($this->getCurrentUrl(), $this->getBaseLanguageURL()) > 0) { $url_without_base = str_replace($this->getBaseLanguageURL(), "", $this->getCurrentUrl()); } else { $url_without_base = str_replace($this->getBaseURL(), "", $this->getCurrentUrl()); } if (isset($_GET['error-redirect-url']) && $_GET['error-redirect-url'] != "") { if (find($_GET['error-redirect-url'], $this->getBaseLanguageURL()) > 0) { $url_without_base = str_replace($this->getBaseLanguageURL(), "", $_GET['error-redirect-url']); } else { $url_without_base = str_replace($this->getBaseURL(), "", $_GET['error-redirect-url']); } } if ($url_without_base[0] != '/') { $url_without_base = "/" . $url_without_base; } $url_without_base_array = split("\\?", $url_without_base); $url_without_base = $url_without_base_array[0]; if (in_array(trim($url_without_base), $array_banned_url)) { $_GET['banned_url'] = "true"; } } $nb_user_bad_url_access = 0; if ($_GET['banned_url'] == "true" && !$this->isCrawlerBot()) { WspBannedVisitors::addIP($this->getRemoteIP()); $nb_user_bad_url_access = WspBannedVisitors::getIpNbBadAccess($this->getRemoteIP()); } // send error by mail if (defined('SEND_ERROR_BY_MAIL') && SEND_ERROR_BY_MAIL == true && !isLocalDebug()) { $send_error_mail = true; // Check if we have enougth information to send a mail if (in_array($_GET['error-redirect'], $array_code_error)) { if ($this->getRefererURL() == "") { if (!isset($_GET['error-redirect-referer']) || $_GET['error-redirect-referer'] == "") { if (!isset($_GET['error-redirect-url']) || $_GET['error-redirect-url'] == "") { $send_error_mail = false; // not enougth information to treat the error } } } } // Check if file need to send a mail $array_files_ex = array(); // list of files without error email $array_file_no_mail = array("", "crossdomain.xml", "sitemap.xml", "error-page.html", "undefined", "&", "browserconfig.xml", "favicon.gif", "favicon.png", "ui.item.id;", "url;", "javascript:void(0);"); if (defined('SEND_BY_MAIL_FILE_EX') && SEND_BY_MAIL_FILE_EX != "") { $array_files_ex = explode(',', SEND_BY_MAIL_FILE_EX); } $array_file_no_mail = array_merge($array_file_no_mail, $array_files_ex); if (isset($_GET['error-redirect-url']) && $_GET['error-redirect-url'] != "") { $tmp_current_url = explode('?', $_GET['error-redirect-url']); } else { $tmp_current_url = explode('?', $this->getCurrentUrl()); } $current_url = $tmp_current_url[0]; $array_current_url = explode('/', $current_url); $filename = $array_current_url[sizeof($array_current_url) - 1]; if (in_array($filename, $array_file_no_mail)) { $send_error_mail = false; } else { if ($this->getBrowserName() == "Firefox" && ($this->getBrowserVersion() == "3.6" || $this->getBrowserVersion() == "3.5") && (substr($filename, strlen($filename) - 6, 6) == "%5C%27" || substr($filename, strlen($filename) - 3, 3) == "%22" || substr($filename, strlen($filename) - 3, 3) == "%5C")) { // Interpretation error by firefox 3.6 and 3.5 $send_error_mail = false; } else { if ($this->getBrowserName() == "IE" && $this->getBrowserVersion() < 7) { // Error with IE <= 6.0 $send_error_mail = false; } else { if ($this->getBrowserName() == "BlackBerry" && $this->getBrowserVersion() == 0) { // Error with BlackBerry version 0 $send_error_mail = false; } else { // no mail for some referers (html transformed or base href not take into account) $array_exluded_referer = array("translate.googleusercontent.com", "webcache.googleusercontent.com"); $array_referer_url = explode('/', str_replace("http://", "", str_replace("https://", "", $this->getRefererURL()))); $base_referer_url = $array_referer_url[0]; if (in_array($base_referer_url, $array_exluded_referer)) { $send_error_mail = false; } else { // test if there is regexp in the administrator exclude list for ($i = 0; $i < sizeof($array_files_ex); $i++) { if (is_regexp($array_files_ex[$i], true)) { $path_or_filename = $filename; if (find($array_files_ex[$i], "\\/") > 0) { // detect is regex on a path $path_or_filename = str_replace(BASE_URL, "", $current_url); } if (preg_match($array_files_ex[$i], $path_or_filename)) { $send_error_mail = false; break; } } } } } } } } // send mail if ($send_error_mail) { $debug_mail = $error_msg->render(); $debug_mail .= "<br/><br/><b>General information:</b><br/>"; if (isset($_GET['error-redirect-url']) && $_GET['error-redirect-url'] != "") { $debug_mail .= "URL : " . $_GET['error-redirect-url'] . "<br/>"; } else { $debug_mail .= "URL : " . $this->getCurrentUrl() . "<br/>"; } if (isset($_GET['error-redirect-referer']) && $_GET['error-redirect-referer'] != "") { $debug_mail .= "Referer : " . $_GET['error-redirect-referer'] . "<br/>"; } else { $debug_mail .= "Referer : " . $this->getRefererURL() . "<br/>"; } $debug_mail .= "IP : <a href='http://www.infosniper.net/index.php?ip_address=" . $this->getRemoteIP() . "' target='_blank'>" . $this->getRemoteIP() . "</a><br/>"; $debug_mail .= "Browser : "; if ($this->getBrowserName() == "Default Browser") { $debug_mail .= $this->getBrowserUserAgent(); } else { $debug_mail .= $this->getBrowserName() . " (version: " . $this->getBrowserVersion() . ")"; } $debug_mail .= "<br/>"; $debug_mail .= "Crawler : " . ($this->isCrawlerBot() ? "true" : "false") . "<br/>"; if ($_GET['banned_url'] == "true" && $nb_user_bad_url_access > 0) { $debug_mail .= "<br/><font color='red'>This user already tried to access to " . $nb_user_bad_url_access . " forbidden URL.</font><br/>"; $debug_mail .= "(User will be blocked with captcha code after " . MAX_BAD_URL_BEFORE_BANNED . " attempts)<br/>"; } try { $mail = new SmtpMail(SEND_ERROR_BY_MAIL_TO, __(SEND_ERROR_BY_MAIL_TO), "ERROR on " . __(SITE_NAME) . " !!!", __($debug_mail), SMTP_MAIL, __(SMTP_NAME)); $mail->setPriority(SmtpMail::PRIORITY_HIGH); $mail->send(); } catch (Exception $e) { } } } } }
<?php //测试页面 include "SmtpMail.php"; //你用这个类的时候你修改成你自己的信箱就可以了 $smtp = new SmtpMail("mail3.ctsi.com.cn", "25", "*****@*****.**", "p0o9I8U7", true); //如果你需要显示会话信息,请将上面的修改成 //$smtp = new smtp_mail("smtp.qq.com","25","你的qq.com的帐号","你的密码",true); $smtp->send("*****@*****.**", "*****@*****.**", "你好", "<a href='http://www.baidu.com'>百度</a>"); ?>
/** * 用内置的邮箱发送邮件 * * $mpid * $subject string * $content string HTML格式 * $to 收件人的邮箱 */ protected function send_email($mpid, $subject, $content, $to) { $features = $this->model('mp\\mpaccount')->getFeatures($mpid); if (!empty($features->admin_email) && !empty($features->admin_email_pwd) && !empty($features->admin_email_smtp)) { $smtp = $features->admin_email_smtp; $port = $features->admin_email_port; $email = $features->admin_email; $pwd = $this->model()->encrypt($features->admin_email_pwd, 'DECODE', $mpid); } else { /** * todo 是否考虑去掉? */ $smtp = 'smtp.163.com'; $port = 25; $email = '*****@*****.**'; $pwd = 'p0o9i8u7'; } if (defined('SAE_MYSQL_DB')) { // sae $mail = new \SaeMail(); if ($mail->setOpt(array('from' => $email, 'to' => $to, 'subject' => $subject, 'content' => $content, 'content_type' => 'HTML', 'smtp_host' => $smtp, 'smtp_port' => $port, 'smtp_username' => $email, 'smtp_password' => $pwd, 'tls' => false))) { if (!$mail->send()) { return '邮件发送错误(' . $mail->errno() . '):' . $mail->errmsg(); } } else { return '邮件参数设置错误(' . $mail->errno() . '):' . $mail->errmsg(); } } else { require_once dirname(dirname(__FILE__)) . '/lib/mail/SmtpMail.php'; $smtp = new \SmtpMail($smtp, $port, $email, $pwd); $smtp->send($email, $to, $subject, $content); } return true; }
/** * Method sendErrorByMail * @access static * @param mixed $debug_msg * @param string $attachment_file * @param string $error_log_file [default value: error_send_by_mail.log] * @param mixed $cache_time [default value: CacheFile::CACHE_TIME_2MIN] * @since 1.0.100 */ public static function sendErrorByMail($debug_msg, $attachment_file = "", $error_log_file = "error_send_by_mail.log", $cache_time = CacheFile::CACHE_TIME_2MIN) { if (defined('SEND_ERROR_BY_MAIL') && SEND_ERROR_BY_MAIL == true && !isLocalDebug()) { $caching_file = new CacheFile(dirname(__FILE__) . "/../cache/" . $error_log_file, $cache_time); if ($caching_file->readCache() == false) { $debug_mail = $debug_msg; $page_object = Page::getInstance($_GET['p']); $debug_mail .= "<br/><b>General information:</b><br/>"; $debug_mail .= "URL : " . $page_object->getCurrentUrl() . "<br/>"; $debug_mail .= "Referer : " . $page_object->getRefererURL() . "<br/>"; $debug_mail .= "IP : <a href='http://www.infosniper.net/index.php?ip_address=" . $page_object->getRemoteIP() . "' target='_blank'>" . $page_object->getRemoteIP() . "</a><br/>"; $debug_mail .= "Browser : "; if (!isset($_SESSION['browser_info']) || $page_object->getBrowserName() == "Default Browser" || $page_object->getBrowserName() == "") { $debug_mail .= $page_object->getBrowserUserAgent(); } else { $debug_mail .= $page_object->getBrowserName() . " (version: " . $page_object->getBrowserVersion() . ")"; } $debug_mail .= "<br/>"; if (isset($_SESSION['browser_info'])) { $debug_mail .= "Crawler : " . ($page_object->isCrawlerBot() ? "true" : "false") . "<br/>"; } $caching_file->writeCache($debug_mail); try { $mail = new SmtpMail(SEND_ERROR_BY_MAIL_TO, __(SEND_ERROR_BY_MAIL_TO), "ERROR on " . __(SITE_NAME) . " !!!", __($debug_mail), SMTP_MAIL, __(SMTP_NAME)); $mail->setPriority(SmtpMail::PRIORITY_HIGH); if ($attachment_file != "" && is_file($attachment_file)) { $mail->addAttachment($attachment_file, basename(str_replace(".cache", ".txt", $attachment_file))); } if (($send_result = $mail->send()) != true) { $caching_file->writeCache("Error when sent mail: " . $send_result . "\nMail: " . $debug_mail); //echo $send_result; } } catch (Exception $e) { $caching_file->writeCache("\n\nMail sending error:\n" . $e); } $caching_file->close(); } } }
/** * Method sendMail * @access public * @since 1.0.59 */ public function sendMail() { if (!$this->captcha->check()) { $this->captcha->forceObjectChange(); $dialog = new DialogBox(__(ERROR), __(ERROR_CAPTCHA)); $this->page_object->addObject($dialog->activateCloseButton()); } else { try { $message = __(CONTACTFORM_NAME) . ": " . utf8encode($this->getContactName()) . "<br/>" . __(CONTACTFORM_EMAIL) . ": " . $this->getContactEmail() . "<br/>" . __(CONTACTFORM_SUBJECT) . ": " . utf8encode($this->getContactSubject()) . "<br/><br/>" . __(CONTACTFORM_MESSAGE) . ": <br/>" . utf8encode($this->getContactMessage()); $mail = new SmtpMail($this->mail_to, __($this->mail_to_name), __(SITE_NAME) . " : " . utf8encode($this->getContactSubject()), $message, $this->getContactEmail(), utf8encode($this->getContactName())); if (!$mail->Send()) { $dialog = new DialogBox(__(CONTACTFORM_MAIL) . " " . __(ERROR), $mail->getErrorInfo()); $this->page_object->addObject($dialog->activateCloseButton()); } else { if ($this->send_wait_mail) { if ($this->send_wait_mail_message == "") { $this->send_wait_mail_message = __(CONTACTFORM_SEND_WAIT_MAIL_MESSAGE, $this->getContactName(), __(SITE_NAME), $this->mail_to_name); } $wait_mail = new SmtpMail($this->getContactEmail(), utf8encode($this->getContactName()), __(SITE_NAME), utf8encode($this->send_wait_mail_message), $this->mail_to, utf8encode($this->mail_to_name)); $wait_mail->Send(); } $dialog = new DialogBox(__(CONTACTFORM_MAIL), __(CONTACTFORM_MAIL_SENT)); $this->page_object->addObject($dialog->activateCloseButton()); $this->page_object->forceObjectsDefaultValues(); } } catch (Exception $ex) { $dialog = new DialogBox(__(ERROR), __(ERROR) . ": " . $ex->getMessage()); $this->page_object->addObject($dialog->activateCloseButton()); } } }
public function connect() { if (!isset($_SESSION['user_try_connect_wsp_admin']) && $_SESSION['user_try_connect_wsp_admin'] != true) { if (defined('SEND_ADMIN_CONNECT_BY_MAIL') && SEND_ADMIN_CONNECT_BY_MAIL == true && !isLocalDebug()) { $connect_mail .= "<b>User tried or is connected on administration :</b><br/>"; $connect_mail .= "URL : " . $this->getCurrentUrl() . "<br/>"; $connect_mail .= "Referer : " . $this->getRefererURL() . "<br/>"; $connect_mail .= "IP : <a href='http://www.infosniper.net/index.php?ip_address=" . $this->getRemoteIP() . "' target='_blank'>" . $this->getRemoteIP() . "</a><br/>"; $connect_mail .= "Browser : "; if ($this->getBrowserName() == "Default Browser") { $connect_mail .= $this->getBrowserUserAgent(); } else { $connect_mail .= $this->getBrowserName() . " (version: " . $this->getBrowserVersion() . ")"; } $connect_mail .= "<br/>"; $connect_mail .= "Crawler : " . ($this->isCrawlerBot() ? "true" : "false") . "<br/><br/>"; $connect_mail .= "If it's not you or another member of your organisation, we recommand to ban this IP.<br/>"; try { $mail = new SmtpMail(SEND_ADMIN_CONNECT_BY_MAIL_TO, __(SEND_ADMIN_CONNECT_BY_MAIL_TO), "Admin connection on " . __(SITE_NAME) . " !!!", __($connect_mail), SMTP_MAIL, __(SMTP_NAME)); $mail->setPriority(SmtpMail::PRIORITY_HIGH); $mail->send(); } catch (Exception $e) { } $_SESSION['user_try_connect_wsp_admin'] = true; } } $this->auth_obj->connect(); }
function create_label_translation($constantValue) { $translate_file = $_GET['p'] . ".inc.php"; // Check if translation needs to be writed in all.inc.php $trace_array = explode("\n", getDebugBacktrace(2)); if (isset($trace_array[1])) { $trace_array[1] = str_replace("\\", "/", $trace_array[1]); if (find($trace_array[1], "wsp/includes/utils_label.inc.php") > 0) { // call function __() $trace = isset($trace_array[4]) ? $trace_array[4] : ""; } else { // call function translate() $trace = isset($trace_array[1]) ? $trace_array[1] : ""; } $trace = str_replace("\\", "/", $trace); if (($pos = find($trace, SITE_DIRECTORY)) > 0) { $trace_file = substr($trace, $pos, strlen($trace)); $page_label = str_replace("/pages/", "", substr($trace_file, 0, strlen($trace_file) - 4)); if ($page_label != $_GET['p']) { $translate_file = "all.inc.php"; } } } // Create new label in each languages $creation_message = ""; $base_dir = dirname(__FILE__) . "/../.."; $array_lang_dir = scandir($base_dir . "/lang"); for ($i = 0; $i < sizeof($array_lang_dir); $i++) { if (is_dir($base_dir . "/lang/" . $array_lang_dir[$i]) && $array_lang_dir[$i] != "" && $array_lang_dir[$i] != "." && $array_lang_dir[$i] != ".." && $array_lang_dir[$i] != ".svn" && strlen($array_lang_dir[$i]) == 2) { $lang_file_path = str_replace("\\", "/", realpath($base_dir . "/lang/" . $array_lang_dir[$i])) . "/" . $translate_file; // Read File $lang_file_content = ""; if (file_exists($lang_file_path)) { $lang_file = new File($lang_file_path); $lang_file_content = $lang_file->read(); $lang_file->close(); } // Check if the label doesn't already exists for this language if (!label_exists($lang_file_content, $constantValue)) { // Create new label if ($lang_file_content == "") { $lang_file_content = "<?php\n"; } $lang_file_content = str_replace("\r", "", $lang_file_content); $lang_file_content = str_replace_last("?>", "", $lang_file_content); $lang_file_content .= "\tdefine('" . addslashes($constantValue) . "', '" . addslashes($constantValue) . "'); // TODO: Label needs to be translated\n"; $lang_file_content .= "?>"; // Write File if ($GLOBALS['WSP_AUTO_CREATE_CONSTANT']) { $lang_file = new File($lang_file_path, false, true); if ($lang_file->write($lang_file_content) !== false) { $creation_message .= "Information: Constant <font color='blue'>" . $constantValue . "</font> automatically <font color='green'>CREATED</font> in the file " . $lang_file_path . ".<br/>"; } $lang_file->close(); } // Check if this label doesn't exists in other language for the current page if ($translate_file == "all.inc.php") { $page_lang_file_path = str_replace("\\", "/", realpath($base_dir . "/lang/" . $array_lang_dir[$i])) . "/" . $_GET['p'] . ".inc.php"; if (file_exists($page_lang_file_path)) { $lang_file = new File($page_lang_file_path); $lang_file_content = $lang_file->read(); $lang_file->close(); if (!label_exists($lang_file_content, $constantValue)) { $label_found = false; if (find($lang_file_content, "define(\"" . $constantValue . "\"") > 0) { $lang_file_content = str_replace_first("define(\"" . $constantValue . "\"", "// TODO: Remove label (now in all.inc.php) -> define(\"" . $constantValue . "\"", $lang_file_content); $label_found = true; } else { if (find($lang_file_content, "define('" . $constantValue . "'") > 0) { $lang_file_content = str_replace_first("define('" . $constantValue . "'", "// TODO: Remove label (now in all.inc.php) -> define('" . $constantValue . "'", $lang_file_content); $label_found = true; } } // Write File if ($label_found && $GLOBALS['WSP_AUTO_CREATE_CONSTANT']) { $lang_file = new File($page_lang_file_path, false, true); if ($lang_file->write($lang_file_content) !== false) { $creation_message .= "Information: Constant <font color='blue'>" . $constantValue . "</font> automatically <font color='red'>COMMENT</font> in the file " . $page_lang_file_path . ".<br/>"; } $lang_file->close(); } } } } } } } if ($creation_message != "") { // Simulate the new label is loaded define($constantValue, $constantValue); // Inform the developer by DialogBox if ($GLOBALS['__AJAX_LOAD_PAGE__'] == false || $GLOBALS['__AJAX_LOAD_PAGE__'] == true && find($_GET['mime'], "html") > 0) { $dialog = new DialogBox("Alert translation", $creation_message); $dialog->activateCloseButton()->setWidth(600); Page::getInstance($_GET['p'])->addObject($dialog); } // Inform the developer by mail if (defined('SEND_ERROR_BY_MAIL') && SEND_ERROR_BY_MAIL == true && !isLocalDebug()) { try { $mail = new SmtpMail(SEND_ERROR_BY_MAIL_TO, __(SEND_ERROR_BY_MAIL_TO), "New label on " . __(SITE_NAME) . " !!!", $creation_message, SMTP_MAIL, __(SMTP_NAME)); $mail->setPriority(SmtpMail::PRIORITY_HIGH); $mail->send(); } catch (Exception $e) { } } } }