diff --git a/.idea/ConLite.iml b/.idea/ConLite.iml new file mode 100644 index 0000000..bc308a5 --- /dev/null +++ b/.idea/ConLite.iml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 58ca2d4..b8c79cb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ ----------------------------------------------------------------------------------------------------- This is the readme file for ConLite 2.2.0 beta Any help you need you may find by visiting the following links. diff --git a/cms/includes/class.input.helper.php b/cms/includes/class.input.helper.php index bd0bc52..4526bc6 100644 --- a/cms/includes/class.input.helper.php +++ b/cms/includes/class.input.helper.php @@ -144,8 +144,7 @@ class cHTMLInputSelectElement extends cHTMLSelectElement { * * @return int Number of items added * */ - function addCategories($iMaxLevel = 0, $bColored = false, $bCatVisible = true, $bCatPublic = true, - $bWithArt = false, $bArtOnline = true) { + function addCategories($iMaxLevel = 0, $bColored = false, $bCatVisible = true, $bCatPublic = true, $bWithArt = false, $bArtOnline = true) { global $cfg, $client, $lang; $oDB = new DB_Contenido; @@ -259,27 +258,18 @@ class cHTMLInputSelectElement extends cHTMLSelectElement { } } - /** - * Selects specified elements as selected - * - * @param array $aElements Array with "values" of the cHTMLOptionElement to set - * - * @return none - */ - function setSelected($aElements) { - if (is_array($this->_options) && is_array($aElements)) { - foreach ($this->_options as $sKey => $oOption) { - if (in_array($oOption->getAttribute("value"), $aElements)) { - $oOption->setSelected(true); - $this->_options[$sKey] = $oOption; - } else { - $oOption->setSelected(false); - $this->_options[$sKey] = $oOption; - } - } - } + public function addFiles($sPath) { + $iCount = 0; + $aFiles = cDirHandler::read($sPath); + asort($aFiles); + $iCounter = count($this->_options); + foreach ($aFiles as $sValue) { + $oOption = new cHTMLOptionElement($sValue, $sValue); + $this->addOptionElement($iCounter, $oOption); + $iCounter++; + } + return count($aFiles); } - } class UI_Config_Table { @@ -302,16 +292,24 @@ class UI_Config_Table { var $_sColorLight; var $_sColorDark; + /** + * + * @var type + */ + protected $_iRowCnt = 0; + function __construct() { - global $cfg; + $cfg = cRegistry::getConfig(); $this->_sPadding = 2; $this->_sBorder = 0; - $this->_sBorderColor = $cfg['color']['table_border']; - $this->_sTplCellCode = ' {CONTENT}' . "\n"; + $this->_sBorderColor = cRegistry::getConfigValue('color', 'table_border'); + $this->_sTplCellCode = '' . "\n" + . '{CONTENT}' . "\n" + . '' . "\n"; $this->_sTplTableFile = $cfg['path']['contenido'] . $cfg['path']['templates'] . $cfg['templates']['generic_list']; - $this->_sColorLight = $cfg['color']['table_light']; - $this->_sColorDark = $cfg['color']['table_dark']; + $this->_sColorLight = cRegistry::getConfigValue('color', 'table_light'); + $this->_sColorDark = cRegistry::getConfigValue('color', 'table_dark'); } function setCellTemplate($sCode) { @@ -417,8 +415,37 @@ class UI_Config_Table { return $sSkript; } - function render($bPrint = false) { - $oTable = new Template; + /** + * increase row counter + */ + public function nextRow() { + $this->_iRowCnt++; + } + + /** + * get current row count + * + * @return int row count + */ + public function getRowCount() : int { + return $this->_iRowCnt; + } + + public function setRowCell(int $iCell, $mContent) { + $this->setCell($this->_iRowCnt, $iCell, $mContent); + } + + public function setRowBorder(string $sWhich = 'bottom') { + $sStyle = ''; + switch ($sWhich) { + case 'bottom': + $this->setRowExtra($this->_iRowCnt, 'border-bottom: 1px solid silver;'); + break; + } + } + + public function render($bPrint = false) { + $oTable = new Template(); $oTable->reset(); $oTable->set('s', 'CELLPADDING', $this->_sPadding); @@ -437,6 +464,8 @@ class UI_Config_Table { $iCount = 0; foreach ($aCells as $sCell => $sData) { + $sData = $this->_processContentData($sData); + $iCount++; $sTplCell = $this->_sTplCellCode; @@ -525,6 +554,57 @@ class UI_Config_Table { } } -} + /** + * returns different types of content data as string + * you can use + * - string + * - object, needs to have a render method + * - array of objects and/or strings + * + * @author Ortwin Pinke + * @since 2.3.0 + * + * + * @param mixed $mData + * @return string + */ + protected function _processContentData($mData): string { + if (is_string($mData)) { + return $mData; + } -?> \ No newline at end of file + $sData = ''; + + if (is_array($mData) && count($mData) > 0) { + foreach ($mData as $mElement) { + if (is_string($mElement)) { + $sData .= $mElement; + continue; + } + $sData .= $this->_renderObject($mElement); + } + } else { + $sData = $this->_renderObject($mData); + } + + return $sData; + } + + /** + * Renders an object using its render method + * + * @author Ortwin Pinke + * @since 2.3.0 + * + * @param type $oObject + * @return string rendered string from object | empty string + */ + protected function _renderObject($oObject): string { + $sReturn = ''; + if (is_object($oObject) && method_exists($oObject, 'render')) { + $sReturn = $oObject->render(); + } + return $sReturn; + } + +} diff --git a/conlib/perm.inc b/conlib/perm.inc index 9c41d13..50719b3 100644 --- a/conlib/perm.inc +++ b/conlib/perm.inc @@ -232,8 +232,8 @@ class Contenido_Perm { return true; } elseif ($item_rights[$area] != "noright") { - $groupsForUser = $this->getGroupsForUser($auth->auth[uid]); - $groupsForUser[] = $auth->auth[uid]; + $groupsForUser = $this->getGroupsForUser($auth->auth['uid']); + $groupsForUser[] = $auth->auth['uid']; $tmp_userstring = implode("','", $groupsForUser); @@ -596,8 +596,8 @@ class Contenido_Perm { } } elseif ($item_rights[$value] != "noright") { - $groupsForUser = $this->getGroupsForUser($auth->auth[uid]); - $groupsForUser[] = $auth->auth[uid]; + $groupsForUser = $this->getGroupsForUser($auth->auth['uid']); + $groupsForUser[] = $auth->auth['uid']; //else search for rights for this user in this area $sql = "SELECT diff --git a/conlite/backend_search.php b/conlite/backend_search.php index aeb740a..e63390f 100644 --- a/conlite/backend_search.php +++ b/conlite/backend_search.php @@ -555,8 +555,8 @@ if (empty($where) || $iAffectedRows <= 0) { #Check rights per cat if (!$check_rights) { //hotfix timo trautmann 2008-12-10 also check rights in associated groups - $aGroupsForUser = $perm->getGroupsForUser($auth->auth[uid]); - $aGroupsForUser[] = $auth->auth[uid]; + $aGroupsForUser = $perm->getGroupsForUser($auth->auth['uid']); + $aGroupsForUser[] = $auth->auth['uid']; $sTmpUserString = implode("','", $aGroupsForUser); #Check if any rights are applied to current user or his groups diff --git a/conlite/classes/cHTML5/class.chtml.php b/conlite/classes/cHTML5/class.chtml.php index 1448d46..605504c 100644 --- a/conlite/classes/cHTML5/class.chtml.php +++ b/conlite/classes/cHTML5/class.chtml.php @@ -20,11 +20,7 @@ // security check defined('CON_FRAMEWORK') or die('Illegal call'); -/* -if (!class_exists("HTML_Common2")) { - cInclude("pear", "HTML/Common2.php"); -} -*/ + /* Global ID counter */ $cHTMLIDCount = 0; @@ -415,7 +411,7 @@ class cHTML extends cHTML5Common { $style = $this->getAttribute("style"); /* If the style doesn't end with a semicolon, append one */ - if(is_string($style)) { + if(!empty($style) && is_string($style)) { $style = trim($style); if (substr($style, strlen($style) - 1) != ";") { @@ -423,12 +419,20 @@ class cHTML extends cHTML5Common { } } - foreach($this->_aStyleDefinitions as $sEntry) { - $style .= $sEntry; + foreach($this->_aStyleDefinitions as $sKey => $sEntry) { + $style .= $sKey.': '.$sEntry; if (substr($style, strlen($style) - 1) != ";") { $style .= ";"; } + } + /* Apply all stored styles */ + foreach ($this->_styledefs as $key => $value) { + $style .= "$key: $value;"; + } + + if ($style != "") { + $this->setStyle($style); } foreach($this->_aEventDefinitions as $sEventName => $sEntry) { @@ -440,15 +444,6 @@ class cHTML extends cHTML5Common { $this->setAttribute($sEventName, $this->getAttribute($sEventName).implode(" ", $aFullCode)); } - /* Apply all stored styles */ - foreach ($this->_styledefs as $key => $value) { - $style .= "$key: $value;"; - } - - if ($style != "") { - $this->setStyle($style); - } - if ($this->_content != "" || $this->_contentlessTag == false) { $attributes = $this->getAttributes(true); return $this->fillSkeleton($attributes).$this->_content.$this->fillCloseSkeleton(); diff --git a/conlite/classes/class.article.collector.php b/conlite/classes/class.article.collector.php index 0d9a25e..26a3bdb 100644 --- a/conlite/classes/class.article.collector.php +++ b/conlite/classes/class.article.collector.php @@ -34,7 +34,7 @@ class cArticleCollector implements SeekableIterator, Countable { protected $_aStartArticles = array(); protected $_aOptions = array(); protected $_aOptionsDefault = array(); - private $_bAsObject = TRUE; + private $_bAsObject = true; /** * @@ -65,14 +65,12 @@ class cArticleCollector implements SeekableIterator, Countable { } if (count($this->_aStartArticles) > 0) { - print_r($this->_aStartArticles); if ($this->_aOptions['start'] == false) { $oArtLangColl->setWhere("cApiArticleLanguageCollection.idartlang", $this->_aStartArticles, "NOTIN"); //$sqlStartArticles = "a.idartlang NOT IN ('" . implode("','", $this->_startArticles) . "') AND "; } if ($this->_aOptions['startonly'] == true) { - echo "startonly"; $oArtLangColl->setWhere("cApiArticleLanguageCollection.idartlang", $this->_aStartArticles, "IN"); //$sqlStartArticles = "a.idartlang IN ('" . implode("','", $this->_startArticles) . "') AND "; } @@ -89,7 +87,6 @@ class cArticleCollector implements SeekableIterator, Countable { $oArtLangColl->setWhere("cApiArticleLanguageCollection.idlang", $this->_aOptions['lang']); $oArtLangColl->query(); - echo $oArtLangColl->_lastSQL; if ($oArtLangColl->count() > 0) { $aTable = $oArtLangColl->fetchTable(); //echo $oArtLangColl->_lastSQL; @@ -97,7 +94,6 @@ class cArticleCollector implements SeekableIterator, Countable { foreach ($aTable as $aItem) { $this->_aArticles[] = $aItem['idartlang']; } - print_r($this->_aArticles); } } @@ -162,7 +158,7 @@ class cArticleCollector implements SeekableIterator, Countable { * * @return cApiArticleLanguage|int returns article language object or idartlang */ - public function current() { + public function current() :cApiArticleLanguage|int{ $iIdartlang = $this->_aArticles[$this->_iCurrentPosition]; if ($this->_bAsObject) { $oArticle = new cApiArticleLanguage($iIdartlang); diff --git a/conlite/classes/class.genericdb.php b/conlite/classes/class.genericdb.php index ee774fd..ba08eda 100644 --- a/conlite/classes/class.genericdb.php +++ b/conlite/classes/class.genericdb.php @@ -1311,7 +1311,7 @@ abstract class Item extends cItemBaseAbstract { * List of funcion names of the filtersused when data is retrieved from the db * @var array */ - protected $_arrOutFilters = array('stripslashes', 'htmldecode', 'urldecode'); + protected $_arrOutFilters = array('stripslashes', 'htmldecode','urldecode', 'utf8_encode'); /** * Class name of meta object diff --git a/conlite/classes/class.htmlelements.php b/conlite/classes/class.htmlelements.php index 0bab486..c20f353 100644 --- a/conlite/classes/class.htmlelements.php +++ b/conlite/classes/class.htmlelements.php @@ -57,8 +57,7 @@ class cHTMLFormElement extends cHTML { if (is_string($id) && !empty($id)) { $this->updateAttributes(array("id" => $id)); } - - $this->setClass("text_medium"); // TODO: Remove this... + $this->setDisabled($disabled); $this->setTabindex($tabindex); $this->setAccessKey($accesskey); @@ -594,7 +593,7 @@ class cHTMLSelectElement extends cHTMLFormElement { * All cHTMLOptionElements * @var array */ - var $_options; + var $_options = []; /** * Constructor. Creates an HTML select field (aka "DropDown"). @@ -931,7 +930,7 @@ class cHTMLRadiobutton extends cHTMLFormElement { */ function toHtml($renderLabel = true) { $attributes = $this->getAttributes(true); - + //print_r($attributes); if ($renderLabel == false) { return $this->fillSkeleton($attributes); } @@ -1029,37 +1028,30 @@ class cHTMLCheckbox extends cHTMLFormElement { * @return string Rendered HTML */ function toHtml($renderlabel = true) { + $attributes = $this->getAttributes(true); + + if ($renderlabel == false) { + return $this->fillSkeleton($attributes); + } + $id = $this->getAttribute("id"); + $renderedLabel = ""; - if ($renderlabel == true) { - if ($id != "") { - $label = new cHTMLLabel($this->_value, $this->getAttribute("id")); + if ($id != "") { + $label = new cHTMLLabel($this->_value, $this->getAttribute("id")); - $label->setClass($this->getAttribute("class")); - - if ($this->_labelText != "") { - $label->setLabelText($this->_labelText); - } - - $renderedLabel = $label->toHtml(); - } else { - - $renderedLabel = $this->_value; - - if ($this->_labelText != "") { - $label = new cHTMLLabel($this->_value, $this->getAttribute("id")); - $label->setLabelText($this->_labelText); - $renderedLabel = $label->toHtml(); - } + if ($this->_labelText != "") { + $label->setLabelText($this->_labelText); } - return '
' . parent::toHTML() . '' . $renderedLabel . '
'; + $renderedLabel = $label->toHtml(); } else { - return parent::toHTML(); + $renderedLabel = $this->_value; } - } + return $this->fillSkeleton($attributes) . $renderedLabel; + } } /** diff --git a/conlite/classes/class.i18n.php b/conlite/classes/class.i18n.php index 0c68760..469575e 100644 --- a/conlite/classes/class.i18n.php +++ b/conlite/classes/class.i18n.php @@ -130,7 +130,7 @@ class cI18n { // Is emulator to use? if (!$cfg['native_i18n']) { - return htmlentities(self::emulateGettext($string, $domain)); + return self::emulateGettext($string, $domain); } // Try to use native gettext implementation diff --git a/conlite/classes/class.inuse.php b/conlite/classes/class.inuse.php index 7108270..d995f5a 100644 --- a/conlite/classes/class.inuse.php +++ b/conlite/classes/class.inuse.php @@ -255,7 +255,7 @@ class InUseCollection extends ItemCollection } if (!is_object($notification)) { - $notification = new Contenido_Notification; + $notification = new Contenido_Notification(); } $noti = $notification->messageBox("warning", $message.$override, 0); @@ -293,6 +293,4 @@ class InUseItem extends Item $this->loadByPrimaryKey($mId); } } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/conlite/classes/class.search.php b/conlite/classes/class.search.php index b2f6599..5d314b5 100644 --- a/conlite/classes/class.search.php +++ b/conlite/classes/class.search.php @@ -225,13 +225,13 @@ class Index extends SearchBaseAbstract { * * @var array */ - var $cms_type = array(); + protected static $_cms_type = []; /** * the suffix of all available cms types * @var array */ - var $cms_type_suffix = array(); + protected static $_cms_type_suffix = []; /** * Constructor, set object properties @@ -270,6 +270,8 @@ class Index extends SearchBaseAbstract { $this->idart = $idart; } + $this->_debug('Start Index for ', $this->idart); + $this->place = $place; $this->keycode = $aContent; $this->setStopwords($aStopwords); @@ -283,7 +285,14 @@ class Index extends SearchBaseAbstract { $old_keys = array_keys($this->keywords_old); $this->keywords_del = array_diff($old_keys, $new_keys); - + /* + echo '
';
+          print_r($new_keys);
+          print_r($old_keys);
+          print_r($this->keywords_del);
+          echo '
'; + * + */ if (count($this->keywords_del) > 0) { $this->deleteKeywords(); } @@ -312,7 +321,7 @@ class Index extends SearchBaseAbstract { foreach ($this->keycode as $idtype => $data) { if ($this->checkCmsType($idtype)) { foreach ($data as $typeid => $code) { - $this->_debug('code', $code); + $this->_debug('createKeywords: raw code from data array', $code); $code = stripslashes($code); // remove backslash $code = str_ireplace(array('
', '
'), "\n", $code); // replace HTML line breaks with newlines @@ -320,13 +329,18 @@ class Index extends SearchBaseAbstract { if (strlen($code) > 0) { $code = clHtmlEntityDecode($code); } - $this->_debug('code', $code); + $this->_debug('createKeywords: code after clean', $code); $tmp_keys = preg_split('/[\s,]+/', trim($code)); // split content by any number of commas or space characters - $this->_debug('tmp_keys', $tmp_keys); + $this->_debug('createKeywords: tmp_keys', $tmp_keys); foreach ($tmp_keys as $value) { $value = strtolower($value); // index terms are stored with lower case + $value = preg_replace('/[^\w]+/u', '', $value); + + if (empty(trim($value))) { + continue; + } if (!in_array($value, $this->stopwords)) { // eliminate stopwords @@ -335,6 +349,7 @@ class Index extends SearchBaseAbstract { if (strlen($value) > 1) { // do not index single characters $this->keywords[$value] = $this->keywords[$value] . $idtype . '-' . $typeid . ' '; + $this->_debug('createKeywords: entry array keywords', $this->keywords); } } } @@ -345,7 +360,7 @@ class Index extends SearchBaseAbstract { } } - $this->_debug('keywords', $this->keywords); + $this->_debug('createKeywords: keywords returned', $this->keywords); } /** @@ -357,9 +372,10 @@ class Index extends SearchBaseAbstract { $tmp_count = array(); foreach ($this->keywords as $keyword => $count) { + $bProceed = true; + $this->_debug('keyword', $keyword); $tmp_count = preg_split('/[\s]/', trim($count)); $this->_debug('tmp_count', $tmp_count); - $occurrence = count($tmp_count); $tmp_count = array_unique($tmp_count); $cms_types = implode(',', $tmp_count); @@ -376,8 +392,12 @@ class Index extends SearchBaseAbstract { ('" . Contenido_Security::escapeDB($keyword, $this->db) . "', '" . Contenido_Security::escapeDB($index_string, $this->db) . "', " . Contenido_Security::toInteger($this->lang) . ", " . Contenido_Security::toInteger($nextid) . ")"; } else { // if keyword allready exists, create new index_string - if (preg_match("/&$this->idart=/", $this->keywords_old[$keyword])) { - $index_string = preg_replace("/&$this->idart=[0-9]+\([\w-,]+\)/", $index_string, $this->keywords_old[$keyword]); + if (preg_match("/&" . $this->idart . "=/", $this->keywords_old[$keyword])) { + $index_string = preg_replace("/&" . $this->idart . "=[0-9]+\([,\w-]+\)/", $index_string, $this->keywords_old[$keyword]); + if ($index_string === $this->keywords_old[$keyword]) { + $bProceed = false; + $this->_debug('db update', 'no update needed'); + } } else { $index_string = $this->keywords_old[$keyword] . $index_string; } @@ -386,9 +406,11 @@ class Index extends SearchBaseAbstract { SET " . $this->place . " = '" . $index_string . "' WHERE idlang='" . Contenido_Security::toInteger($this->lang) . "' AND keyword='" . Contenido_Security::escapeDB($keyword, $this->db) . "'"; } - $this->_debug('sql', $sql); - $this->db->query($sql); + if ($bProceed) { + $this->_debug('sql', $sql); + $this->db->query($sql); + } } } @@ -431,7 +453,7 @@ class Index extends SearchBaseAbstract { idlang=" . Contenido_Security::toInteger($this->lang) . " AND (keyword IN ('" . $keys . "') OR " . $this->place . " REGEXP '&" . Contenido_Security::toInteger($this->idart) . "=')"; - $this->_debug('sql', $sql); + $this->_debug('getKeywords: sql', $sql); $this->db->query($sql); @@ -440,6 +462,8 @@ class Index extends SearchBaseAbstract { while ($this->db->next_record()) { $this->keywords_old[$this->db->f('keyword')] = $this->db->f($place); } + + $this->_debug('getKeywords: array keywords_old', $this->keywords_old); } /** @@ -448,6 +472,7 @@ class Index extends SearchBaseAbstract { * @return $key */ function removeSpecialChars($key) { + $aSpecialChars = array( "-", "_", "'", ".", "!", "\"", "#", "$", "%", "&", "(", ")", "*", "+", ",", "/", ":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "`", "{", "|", "}", "~" @@ -461,6 +486,7 @@ class Index extends SearchBaseAbstract { // a client and should not be treated in this method. // modified 2007-10-01, H. Librenz - added as hotfix for encoding problems (doesn't find any words with // umlaut vowels in it since you turn on UTF-8 as language encoding) + $sEncoding = getEncodingByLanguage($this->db, $this->lang, $this->cfg); if (strtolower($sEncoding) != 'iso-8859-2') { @@ -486,6 +512,9 @@ class Index extends SearchBaseAbstract { $key = clHtmlEntityDecode($key); $key = str_replace($aSpecialChars, '', $key); + ini_set('mbstring.substitute_character', "none"); + $key = mb_convert_encoding($key, 'UTF-8', 'UTF-8'); + return $key; } @@ -516,6 +545,21 @@ class Index extends SearchBaseAbstract { return $key; } + /** + * + * @return array array with arrays of type and typesuffix + */ + public function getContentTypes(): array { + if (empty(self::$_cms_type)) { + $this->setContentTypes(); + } + + return array( + 'cms_type' => self::$_cms_type, + 'cms_type_suffix' => self::$_cms_type_suffix + ); + } + /** * set the array of stopwords which should not be indexed * @param array $aStopwords @@ -537,8 +581,8 @@ class Index extends SearchBaseAbstract { $this->_debug('sql', $sql); $this->db->query($sql); while ($this->db->next_record()) { - $this->cms_type[$this->db->f('type')] = $this->db->f('idtype'); - $this->cms_type_suffix[$this->db->f('idtype')] = substr($this->db->f('type'), 4, strlen($this->db->f('type'))); + self::$_cms_type[$this->db->f('type')] = $this->db->f('idtype'); + self::$_cms_type_suffix[$this->db->f('idtype')] = substr($this->db->f('type'), 4, strlen($this->db->f('type'))); } } @@ -554,11 +598,11 @@ class Index extends SearchBaseAbstract { if (strlen($opt) > 0) { if (!stristr($opt, 'cms_')) { - if (in_array($opt, $this->cms_type_suffix)) { + if (in_array($opt, $this->getContentTypes()['cms_type_suffix'])) { $this->cms_options[$opt] = 'CMS_' . $opt; } } else { - if (array_key_exists($opt, $this->cms_type)) { + if (array_key_exists($opt, $this->getContentTypes()['cms_type'])) { $this->cms_options[$opt] = $opt; } } @@ -788,8 +832,8 @@ class Search extends SearchBaseAbstract { $this->index = new Index($oDB); - $this->cms_type = $this->index->cms_type; - $this->cms_type_suffix = $this->index->cms_type_suffix; + $this->cms_type = $this->index->getContentTypes()['cms_type']; + $this->cms_type_suffix = $this->index->getContentTypes()['cms_type_suffix']; $this->search_option = (array_key_exists('db', $options)) ? strtolower($options['db']) : 'regexp'; $this->search_combination = (array_key_exists('combine', $options)) ? strtolower($options['combine']) : 'or'; @@ -1339,11 +1383,11 @@ class SearchResult extends SearchBaseAbstract { $cms_type = strtoupper($cms_type); if (strlen($cms_type) > 0) { if (!stristr($cms_type, 'cms_')) { - if (in_array($cms_type, $this->index->cms_type_suffix)) { + if (in_array($cms_type, $this->index->getContentTypes()['cms_type'])) { $cms_type = 'CMS_' . $cms_type; } } else { - if (!array_key_exists($cms_type, $this->index->cms_type)) { + if (!array_key_exists($cms_type, $this->index->getContentTypes()['cms_type_suffix'])) { return array(); } } diff --git a/conlite/classes/class.smtp.php b/conlite/classes/class.smtp.php deleted file mode 100644 index ef4da76..0000000 --- a/conlite/classes/class.smtp.php +++ /dev/null @@ -1,1065 +0,0 @@ -smtp_conn = 0; - $this->error = null; - $this->helo_rply = null; - - $this->do_debug = 0; - } - - /************************************************************* - * CONNECTION FUNCTIONS * - ***********************************************************/ - - /** - * Connect to the server specified on the port specified. - * If the port is not specified use the default SMTP_PORT. - * If tval is specified then a connection will try and be - * established with the server for that number of seconds. - * If tval is not specified the default is 30 seconds to - * try on the connection. - * - * SMTP CODE SUCCESS: 220 - * SMTP CODE FAILURE: 421 - * @access public - * @return bool - */ - function Connect($host,$port=0,$tval=30) { - # set the error val to null so there is no confusion - $this->error = null; - - # make sure we are __not__ connected - if($this->connected()) { - # ok we are connected! what should we do? - # for now we will just give an error saying we - # are already connected - $this->error = - array("error" => "Already connected to a server"); - return false; - } - - if(empty($port)) { - $port = $this->SMTP_PORT; - } - - #connect to the smtp server - $this->smtp_conn = fsockopen($host, # the host of the server - $port, # the port to use - $errno, # error number if any - $errstr, # error message if any - $tval); # give up after ? secs - # verify we connected properly - if(empty($this->smtp_conn)) { - $this->error = array("error" => "Failed to connect to server", - "errno" => $errno, - "errstr" => $errstr); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": $errstr ($errno)" . $this->CRLF; - } - return false; - } - - # sometimes the SMTP server takes a little longer to respond - # so we will give it a longer timeout for the first read - // Windows still does not have support for this timeout function - if(substr(PHP_OS, 0, 3) != "WIN") - socket_set_timeout($this->smtp_conn, $tval, 0); - - # get any announcement stuff - $announce = $this->get_lines(); - - # set the timeout of any socket functions at 1/10 of a second - //if(function_exists("socket_set_timeout")) - // socket_set_timeout($this->smtp_conn, 0, 100000); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; - } - - return true; - } - - /** - * Performs SMTP authentication. Must be run after running the - * Hello() method. Returns true if successfully authenticated. - * @access public - * @return bool - */ - function Authenticate($username, $password) { - // Start authentication - fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 334) { - $this->error = - array("error" => "AUTH not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - // Send encoded username - fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 334) { - $this->error = - array("error" => "Username not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - // Send encoded password - fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 235) { - $this->error = - array("error" => "Password not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - return true; - } - - /** - * Returns true if connected to a server otherwise false - * @access private - * @return bool - */ - function Connected() { - if(!empty($this->smtp_conn)) { - $sock_status = socket_get_status($this->smtp_conn); - if($sock_status["eof"]) { - # hmm this is an odd situation... the socket is - # valid but we aren't connected anymore - if($this->do_debug >= 1) { - echo "SMTP -> NOTICE:" . $this->CRLF . - "EOF caught while checking if connected"; - } - $this->Close(); - return false; - } - return true; # everything looks good - } - return false; - } - - /** - * Closes the socket and cleans up the state of the class. - * It is not considered good to use this function without - * first trying to use QUIT. - * @access public - * @return void - */ - function Close() { - $this->error = null; # so there is no confusion - $this->helo_rply = null; - if(!empty($this->smtp_conn)) { - # close the connection and cleanup - fclose($this->smtp_conn); - $this->smtp_conn = 0; - } - } - - - /*************************************************************** - * SMTP COMMANDS * - *************************************************************/ - - /** - * Issues a data command and sends the msg_data to the server - * finializing the mail transaction. $msg_data is the message - * that is to be send with the headers. Each header needs to be - * on a single line followed by a with the message headers - * and the message body being seperated by and additional . - * - * Implements rfc 821: DATA - * - * SMTP CODE INTERMEDIATE: 354 - * [data] - * . - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 552,554,451,452 - * SMTP CODE FAILURE: 451,554 - * SMTP CODE ERROR : 500,501,503,421 - * @access public - * @return bool - */ - function Data($msg_data) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Data() without being connected"); - return false; - } - - fputs($this->smtp_conn,"DATA" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 354) { - $this->error = - array("error" => "DATA command not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - # the server is ready to accept data! - # according to rfc 821 we should not send more than 1000 - # including the CRLF - # characters on a single line so we will break the data up - # into lines by \r and/or \n then if needed we will break - # each of those into smaller lines to fit within the limit. - # in addition we will be looking for lines that start with - # a period '.' and append and additional period '.' to that - # line. NOTE: this does not count towards are limit. - - # normalize the line breaks so we know the explode works - $msg_data = str_replace("\r\n","\n",$msg_data); - $msg_data = str_replace("\r","\n",$msg_data); - $lines = explode("\n",$msg_data); - - # we need to find a good way to determine is headers are - # in the msg_data or if it is a straight msg body - # currently I'm assuming rfc 822 definitions of msg headers - # and if the first field of the first line (':' sperated) - # does not contain a space then it _should_ be a header - # and we can process all lines before a blank "" line as - # headers. - $field = substr($lines[0],0,strpos($lines[0],":")); - $in_headers = false; - if(!empty($field) && !strstr($field," ")) { - $in_headers = true; - } - - $max_line_length = 998; # used below; set here for ease in change - - while(list(,$line) = @each($lines)) { - $lines_out = null; - if($line == "" && $in_headers) { - $in_headers = false; - } - # ok we need to break this line up into several - # smaller lines - while(strlen($line) > $max_line_length) { - $pos = strrpos(substr($line,0,$max_line_length)," "); - - # Patch to fix DOS attack - if(!$pos) { - $pos = $max_line_length - 1; - } - - $lines_out[] = substr($line,0,$pos); - $line = substr($line,$pos + 1); - # if we are processing headers we need to - # add a LWSP-char to the front of the new line - # rfc 822 on long msg headers - if($in_headers) { - $line = "\t" . $line; - } - } - $lines_out[] = $line; - - # now send the lines to the server - while(list(,$line_out) = @each($lines_out)) { - if(strlen($line_out) > 0) - { - if(substr($line_out, 0, 1) == ".") { - $line_out = "." . $line_out; - } - } - fputs($this->smtp_conn,$line_out . $this->CRLF); - } - } - - # ok all the message data has been sent so lets get this - # over with aleady - fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "DATA not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Expand takes the name and asks the server to list all the - * people who are members of the _list_. Expand will return - * back and array of the result or false if an error occurs. - * Each value in the array returned has the format of: - * [ ] - * The definition of is defined in rfc 821 - * - * Implements rfc 821: EXPN - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 550 - * SMTP CODE ERROR : 500,501,502,504,421 - * @access public - * @return string array - */ - function Expand($name) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Expand() without being connected"); - return false; - } - - fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "EXPN not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - # parse the reply and place in our array to return to user - $entries = explode($this->CRLF,$rply); - while(list(,$l) = @each($entries)) { - $list[] = substr($l,4); - } - - return $list; - } - - /** - * Sends the HELO command to the smtp server. - * This makes sure that we and the server are in - * the same known state. - * - * Implements from rfc 821: HELO - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500, 501, 504, 421 - * @access public - * @return bool - */ - function Hello($host="") { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Hello() without being connected"); - return false; - } - - # if a hostname for the HELO wasn't specified determine - # a suitable one to send - if(empty($host)) { - # we need to determine some sort of appopiate default - # to send to the server - $host = "localhost"; - } - - // Send extended hello first (RFC 2821) - if(!$this->SendHello("EHLO", $host)) - { - if(!$this->SendHello("HELO", $host)) - return false; - } - - return true; - } - - /** - * Sends a HELO/EHLO command. - * @access private - * @return bool - */ - function SendHello($hello, $host) { - fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => $hello . " not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - $this->helo_rply = $rply; - - return true; - } - - /** - * Gets help information on the keyword specified. If the keyword - * is not specified then returns generic help, ussually contianing - * A list of keywords that help is available on. This function - * returns the results back to the user. It is up to the user to - * handle the returned data. If an error occurs then false is - * returned with $this->error set appropiately. - * - * Implements rfc 821: HELP [ ] - * - * SMTP CODE SUCCESS: 211,214 - * SMTP CODE ERROR : 500,501,502,504,421 - * @access public - * @return string - */ - function Help($keyword="") { - $this->error = null; # to avoid confusion - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Help() without being connected"); - return false; - } - - $extra = ""; - if(!empty($keyword)) { - $extra = " " . $keyword; - } - - fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 211 && $code != 214) { - $this->error = - array("error" => "HELP not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - return $rply; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. - * - * Implements rfc 821: MAIL FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,421 - * @access public - * @return bool - */ - function Mail($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Mail() without being connected"); - return false; - } - - fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "MAIL not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Sends the command NOOP to the SMTP server. - * - * Implements from rfc 821: NOOP - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500, 421 - * @access public - * @return bool - */ - function Noop() { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Noop() without being connected"); - return false; - } - - fputs($this->smtp_conn,"NOOP" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "NOOP not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Sends the quit command to the server and then closes the socket - * if there is no error or the $close_on_error argument is true. - * - * Implements from rfc 821: QUIT - * - * SMTP CODE SUCCESS: 221 - * SMTP CODE ERROR : 500 - * @access public - * @return bool - */ - function Quit($close_on_error=true) { - $this->error = null; # so there is no confusion - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Quit() without being connected"); - return false; - } - - # send the quit command to the server - fputs($this->smtp_conn,"quit" . $this->CRLF); - - # get any good-bye messages - $byemsg = $this->get_lines(); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg; - } - - $rval = true; - $e = null; - - $code = substr($byemsg,0,3); - if($code != 221) { - # use e as a tmp var cause Close will overwrite $this->error - $e = array("error" => "SMTP server rejected quit command", - "smtp_code" => $code, - "smtp_rply" => substr($byemsg,4)); - $rval = false; - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $e["error"] . ": " . - $byemsg . $this->CRLF; - } - } - - if(empty($e) || $close_on_error) { - $this->Close(); - } - - return $rval; - } - - /** - * Sends the command RCPT to the SMTP server with the TO: argument of $to. - * Returns true if the recipient was accepted false if it was rejected. - * - * Implements from rfc 821: RCPT TO: - * - * SMTP CODE SUCCESS: 250,251 - * SMTP CODE FAILURE: 550,551,552,553,450,451,452 - * SMTP CODE ERROR : 500,501,503,421 - * @access public - * @return bool - */ - function Recipient($to) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Recipient() without being connected"); - return false; - } - - fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250 && $code != 251) { - $this->error = - array("error" => "RCPT not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Sends the RSET command to abort and transaction that is - * currently in progress. Returns true if successful false - * otherwise. - * - * Implements rfc 821: RSET - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500,501,504,421 - * @access public - * @return bool - */ - function Reset() { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Reset() without being connected"); - return false; - } - - fputs($this->smtp_conn,"RSET" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "RSET failed", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. This command - * will send the message to the users terminal if they are logged - * in. - * - * Implements rfc 821: SEND FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - * @access public - * @return bool - */ - function Send($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Send() without being connected"); - return false; - } - - fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "SEND not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. This command - * will send the message to the users terminal if they are logged - * in and send them an email. - * - * Implements rfc 821: SAML FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - * @access public - * @return bool - */ - function SendAndMail($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called SendAndMail() without being connected"); - return false; - } - - fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "SAML not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. This command - * will send the message to the users terminal if they are logged - * in or mail it to them if they are not. - * - * Implements rfc 821: SOML FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - * @access public - * @return bool - */ - function SendOrMail($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called SendOrMail() without being connected"); - return false; - } - - fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "SOML not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * This is an optional command for SMTP that this class does not - * support. This method is here to make the RFC821 Definition - * complete for this class and __may__ be implimented in the future - * - * Implements from rfc 821: TURN - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 502 - * SMTP CODE ERROR : 500, 503 - * @access public - * @return bool - */ - function Turn() { - $this->error = array("error" => "This method, TURN, of the SMTP ". - "is not implemented"); - if($this->do_debug >= 1) { - echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF; - } - return false; - } - - /** - * Verifies that the name is recognized by the server. - * Returns false if the name could not be verified otherwise - * the response from the server is returned. - * - * Implements rfc 821: VRFY - * - * SMTP CODE SUCCESS: 250,251 - * SMTP CODE FAILURE: 550,551,553 - * SMTP CODE ERROR : 500,501,502,421 - * @access public - * @return int - */ - function Verify($name) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Verify() without being connected"); - return false; - } - - fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250 && $code != 251) { - $this->error = - array("error" => "VRFY failed on name '$name'", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return $rply; - } - - /******************************************************************* - * INTERNAL FUNCTIONS * - ******************************************************************/ - - /** - * Read in as many lines as possible - * either before eof or socket timeout occurs on the operation. - * With SMTP we can tell if we have more lines to read if the - * 4th character is '-' symbol. If it is a space then we don't - * need to read anything else. - * @access private - * @return string - */ - function get_lines() { - $data = ""; - while($str = fgets($this->smtp_conn,515)) { - if($this->do_debug >= 4) { - echo "SMTP -> get_lines(): \$data was \"$data\"" . - $this->CRLF; - echo "SMTP -> get_lines(): \$str is \"$str\"" . - $this->CRLF; - } - $data .= $str; - if($this->do_debug >= 4) { - echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF; - } - # if the 4th character is a space then we are done reading - # so just break the loop - if(substr($str,3,1) == " ") { break; } - } - return $data; - } - -} - - - ?> diff --git a/conlite/classes/class.update.notifier.php b/conlite/classes/class.update.notifier.php index 7a74a31..75e2b1f 100644 --- a/conlite/classes/class.update.notifier.php +++ b/conlite/classes/class.update.notifier.php @@ -508,23 +508,47 @@ class Contenido_UpdateNotifier { $response = false; if ($this->_bUseCurl) { - if ($bCheckCon) { - $ch = $this->_checkCon2Host($sHost); - } else { - $ch = curl_init("http://" . $sHost); - } - if (is_resource($ch)) { - curl_setopt($ch, CURLOPT_URL, "http://" . $sHost . $sFile); + $sUrl = "https://" . $sHost . $sFile; + $ch = $this->_checkCon2Host($sUrl); + + if ($ch !== false) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close')); - curl_setopt($ch, CURLOPT_TIMEOUT, 2); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); + + //Check for errors. + if (curl_errno($ch)) { + throw new Exception(curl_error($ch)); + } curl_close($ch); } + /* + if ($bCheckCon) { + $ch = $this->_checkCon2Host($sHost); + } else { + $ch = curl_init("https://" . $sHost); + } + if (is_resource($ch)) { + curl_setopt($ch, CURLOPT_URL, "https://" . $sHost . $sFile); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close')); + curl_setopt($ch, CURLOPT_TIMEOUT, 2); + $response = curl_exec($ch); + curl_close($ch); + } */ } else { - $source = file_get_contents("http://" . $sHost . $sFile); - if ($source !== false AND ! empty($source)) { + $arrContextOptions = array( + "ssl" => array( + "verify_peer" => false, + "verify_peer_name" => false, + ) + ); + + $source = file_get_contents("https://" . $sHost . $sFile, false, stream_context_create($arrContextOptions)); + + if ($source !== false AND !empty($source)) { $response = $source; } } @@ -539,13 +563,12 @@ class Contenido_UpdateNotifier { * @param string $sHost * @return obj|boolean curl object or false */ - protected function _checkCon2Host($sHost) { - $ch = curl_init("http://" . $sHost); - if (!is_resource($ch)) { + protected function _checkCon2Host($sUrl) { + $ch = curl_init($sUrl); + if ($ch === false) { $sErrorMessage = i18n('Unable to check for updates!') . " " . sprintf(i18n('Connection to %s failed!'), $sHost); $this->sErrorOutput = $this->renderOutput($sErrorMessage); - return false; } return $ch; } @@ -700,7 +723,7 @@ class Contenido_UpdateNotifier { if (strlen($sText) > 150) { $sText = capiStrTrimAfterWord($sText, 150) . '...'; } - //echo $aItem->title; + //echo $aItem->title; $oTpl->set("d", "NEWS_DATE", $aItem->pubDate); $oTpl->set("d", "NEWS_TITLE", utf8_decode($aItem->title)); $oTpl->set("d", "NEWS_TEXT", $sText); diff --git a/conlite/classes/contenido/class.articlelanguage.php b/conlite/classes/contenido/class.articlelanguage.php index 3f12816..3327008 100644 --- a/conlite/classes/contenido/class.articlelanguage.php +++ b/conlite/classes/contenido/class.articlelanguage.php @@ -1,4 +1,5 @@ select($select); } } - + public function getIdArtLang($iIdart, $iIdlang) { $this->setWhere('idart', Contenido_Security::toInteger($iIdart)); $this->setWhere('idlang', Contenido_Security::toInteger($iIdlang)); - if($this->query() && $this->count() > 0) { + if ($this->query() && $this->count() > 0) { return $this->next()->get('idartlang'); } return false; } + } +class cApiArticleLanguage extends Item { -class cApiArticleLanguage extends Item -{ /** - * Constructor Function - * @param mixed $mId Specifies the ID of item to load + * + * @global type $cfg + * @param type $mId */ - public function __construct($mId = false) - { + public function __construct($mId = false) { global $cfg; parent::__construct($cfg["tab"]["art_lang"], "idartlang"); $this->setFilters(array(), array()); @@ -63,24 +62,23 @@ class cApiArticleLanguage extends Item $this->loadByPrimaryKey($mId); } } - + public function loadByArticleAndLanguageId($idart, $idlang) { $result = true; - if (!$this->isLoaded()) { + if (!$this->isLoaded()) { $idartlang = $this->_getIdArtLang($idart, $idlang); $result = $this->loadByPrimaryKey($idartlang); } return $result; } - - + protected function _getIdArtLang($idart, $idlang) { $sql = sprintf('SELECT idartlang FROM `%s` WHERE idart = %d AND idlang = %d', cRegistry::getConfigValue('tab', 'art_lang'), $idart, $idlang); $this->db->query($sql); $this->db->next_record(); return $this->db->f('idartlang'); } - + public function getContent($type = '', $id = NULL) { if (NULL === $this->content) { $this->_loadArticleContent(); @@ -108,16 +106,16 @@ class cApiArticleLanguage extends Item // return String return (isset($this->content[$type][$id])) ? $this->content[$type][$id] : ''; } - + protected function _loadArticleContent() { if (NULL !== $this->content) { return; } - $sql = "SELECT b.type, a.typeid, a.value FROM `".cRegistry::getConfigValue('tab', 'content') - ."` AS a, `".cRegistry::getConfigValue('tab', 'type') - ."` AS b WHERE a.idartlang = ".$this->get('idartlang') - ." AND b.idtype = a.idtype ORDER BY a.idtype, a.typeid"; + $sql = "SELECT b.type, a.typeid, a.value FROM `" . cRegistry::getConfigValue('tab', 'content') + . "` AS a, `" . cRegistry::getConfigValue('tab', 'type') + . "` AS b WHERE a.idartlang = " . $this->get('idartlang') + . " AND b.idtype = a.idtype ORDER BY a.idtype, a.typeid"; $this->db->query($sql); @@ -126,5 +124,7 @@ class cApiArticleLanguage extends Item $this->content[strtolower($this->db->f('type'))][$this->db->f('typeid')] = urldecode($this->db->f('value')); } } + } + ?> \ No newline at end of file diff --git a/conlite/classes/contenido/class.category.php b/conlite/classes/contenido/class.category.php index ffe743d..f560e7a 100644 --- a/conlite/classes/contenido/class.category.php +++ b/conlite/classes/contenido/class.category.php @@ -52,6 +52,4 @@ class cApiCategory extends Item { } } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/conlite/classes/template/class.template.php b/conlite/classes/template/class.template.php index 8004a23..738eb90 100644 --- a/conlite/classes/template/class.template.php +++ b/conlite/classes/template/class.template.php @@ -209,7 +209,11 @@ class Template { if (!is_file($template)) { $content = & $template; //template is a string (it is a reference to save memory!!!) } else { - $content = implode("", file($template)); //template is a file + if(cFileHandler::readable($template)) { + $content = implode("", file($template)); //template is a file + } else { + return $template; + } } $content = (($note) ? "\n" : "") . $content; diff --git a/conlite/classes/widgets/class.widgets.page.php b/conlite/classes/widgets/class.widgets.page.php index de56dae..54495b7 100644 --- a/conlite/classes/widgets/class.widgets.page.php +++ b/conlite/classes/widgets/class.widgets.page.php @@ -320,8 +320,12 @@ class cPage extends cHTML { } $meta = ''; - if ($this->_encoding != "" && !$this->_isHtml5) { - $meta .= '' . "\n"; + if(!empty($this->_encoding)) { + if($this->_isHtml5) { + $meta .= '' . "\n"; + } else { + $meta .= '' . "\n"; + } } if ($this->_object !== false && method_exists($this->_object, "render")) { diff --git a/conlite/external/backendedit/front_content.php b/conlite/external/backendedit/front_content.php index aa37f37..848cd38 100644 --- a/conlite/external/backendedit/front_content.php +++ b/conlite/external/backendedit/front_content.php @@ -92,7 +92,7 @@ if ($cfg["use_pseudocron"] == true) { * PHPLIB application development toolkit * @see http://sourceforge.net/projects/phplib */ -if (!empty($contenido)) { +if (isset($contenido)) { //Backend page_open(array('sess' => 'Contenido_Session', 'auth' => 'Contenido_Challenge_Crypt_Auth', 'perm' => 'Contenido_Perm')); i18nInit($cfg["path"]["contenido"] . $cfg["path"]["locale"], $belang); @@ -130,9 +130,6 @@ if (isset($_GET['action']) && $_GET['action'] == 'get_compressed') { exit(); } -// Call hook after plugins are loaded, added by Murat Purc, 2008-09-07 -CEC_Hook::execute('Contenido.Frontend.AfterLoadPlugins'); - if (!isset($encoding) || !is_array($encoding) || count($encoding) == 0) { // get encodings of all languages $encoding = array(); @@ -241,7 +238,7 @@ $errsite = 'Location: ' . Contenido_Url::getInstance()->buildRedirect($aParams); * Note: These variables can be set via http globals e.g. front_content.php?idcat=41&idart=34&idcatart=35&idartlang=42 * If not the values will be computed. */ -if ($idart && !$idcat && !$idcatart) { +if (!empty($idart) && empty($idcat) && empty($idcatart)) { /* Try to fetch the first idcat */ $sql = "SELECT idcat FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = '" . Contenido_Security::toInteger($idart) . "'"; $db->query($sql); @@ -410,7 +407,7 @@ if ($cfg["cache"]["disable"] != '1') { * The reason is to avoid cross-site scripting errors in the backend, if the backend domain differs from * the frontend domain. */ -if ($contenido) { +if (isset($contenido)) { $perm->load_permissions(); /* Change mode edit / view */ @@ -533,7 +530,7 @@ if (empty($inUse) && (isset($allow) && $allow == true) && $view == "edit" && ($p ############################################## /* Mark submenuitem 'Preview' in the Contenido Backend (Area: Contenido --> Articles --> Preview) */ - if ($contenido) { + if (isset($contenido)) { $markscript = markSubMenuItem(4, true); } @@ -610,9 +607,11 @@ if (empty($inUse) && (isset($allow) && $allow == true) && $view == "edit" && ($p /* If article is in use, display notification */ if (!empty($sHtmlInUseCss) && !empty($sHtmlInUseMessage)) { $code = preg_replace("/<\/head>/i", "$sHtmlInUseCss\n", $code, 1); - $code = preg_replace("/(]*)>/i", "\${1}> \n $sHtmlInUseMessage", $code, 1); + if(!preg_match("/(]*)>.*/i", $code)) { + $code = preg_replace("/(]*)>/i", "\${1}> \n $sHtmlInUseMessage", $code, 1); + $bInUseSet = true; + } } - /* Check if category is public */ $sql = "SELECT public FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat='" . Contenido_Security::toInteger($idcat) . "' AND idlang='" . Contenido_Security::toInteger($lang) . "'"; @@ -651,7 +650,7 @@ if (empty($inUse) && (isset($allow) && $allow == true) && $view == "edit" && ($p WHERE B.name = 'front_allow' AND C.name = 'str' AND A.user_id = '" . Contenido_Security::escapeDB($user_id, $db2) . "' AND A.idcat = '" . Contenido_Security::toInteger($idcat) . "' AND A.idarea = C.idarea AND B.idaction = A.idaction"; - $db2 = new DB_ConLite; + $db2 = new DB_ConLite(); $db2->query($sql); if ($db2->num_rows() > 0) { @@ -795,12 +794,16 @@ if (empty($inUse) && (isset($allow) && $allow == true) && $view == "edit" && ($p if (in_array(Contenido_Security::toInteger($idart), $aExclude)) { eval("?>\n" . $code . "\n\n" . $code . "\n]*)>/i", "\${1}> \n $sHtmlInUseMessage", $htmlCode, 1); + } // process CEC to do some preparations before output $htmlCode = CEC_Hook::executeAndReturn('Contenido.Frontend.HTMLCodeOutput', $htmlCode); diff --git a/conlite/external/phpmailer/phpmailer/COMMITMENT b/conlite/external/phpmailer/phpmailer/COMMITMENT new file mode 100644 index 0000000..a687e0d --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/COMMITMENT @@ -0,0 +1,46 @@ +GPL Cooperation Commitment +Version 1.0 + +Before filing or continuing to prosecute any legal proceeding or claim +(other than a Defensive Action) arising from termination of a Covered +License, we commit to extend to the person or entity ('you') accused +of violating the Covered License the following provisions regarding +cure and reinstatement, taken from GPL version 3. As used here, the +term 'this License' refers to the specific Covered License being +enforced. + + However, if you cease all violation of this License, then your + license from a particular copyright holder is reinstated (a) + provisionally, unless and until the copyright holder explicitly + and finally terminates your license, and (b) permanently, if the + copyright holder fails to notify you of the violation by some + reasonable means prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is + reinstated permanently if the copyright holder notifies you of the + violation by some reasonable means, this is the first time you + have received notice of violation of this License (for any work) + from that copyright holder, and you cure the violation prior to 30 + days after your receipt of the notice. + +We intend this Commitment to be irrevocable, and binding and +enforceable against us and assignees of or successors to our +copyrights. + +Definitions + +'Covered License' means the GNU General Public License, version 2 +(GPLv2), the GNU Lesser General Public License, version 2.1 +(LGPLv2.1), or the GNU Library General Public License, version 2 +(LGPLv2), all as published by the Free Software Foundation. + +'Defensive Action' means a legal proceeding or claim that We bring +against you in response to a prior proceeding or claim initiated by +you or your affiliate. + +'We' means each contributor to this repository as of the date of +inclusion of this file, including subsidiaries of a corporate +contributor. + +This work is available under a Creative Commons Attribution-ShareAlike +4.0 International license (https://creativecommons.org/licenses/by-sa/4.0/). diff --git a/conlite/external/phpmailer/phpmailer/README.md b/conlite/external/phpmailer/phpmailer/README.md new file mode 100644 index 0000000..53e66f1 --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/README.md @@ -0,0 +1,230 @@ +[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://supportukrainenow.org/) + +![PHPMailer](https://raw.github.com/PHPMailer/PHPMailer/master/examples/images/phpmailer.png) + +# PHPMailer – A full-featured email creation and transfer class for PHP + +[![Test status](https://github.com/PHPMailer/PHPMailer/workflows/Tests/badge.svg)](https://github.com/PHPMailer/PHPMailer/actions) +[![codecov.io](https://codecov.io/gh/PHPMailer/PHPMailer/branch/master/graph/badge.svg?token=iORZpwmYmM)](https://codecov.io/gh/PHPMailer/PHPMailer) +[![Latest Stable Version](https://poser.pugx.org/phpmailer/phpmailer/v/stable.svg)](https://packagist.org/packages/phpmailer/phpmailer) +[![Total Downloads](https://poser.pugx.org/phpmailer/phpmailer/downloads)](https://packagist.org/packages/phpmailer/phpmailer) +[![License](https://poser.pugx.org/phpmailer/phpmailer/license.svg)](https://packagist.org/packages/phpmailer/phpmailer) +[![API Docs](https://github.com/phpmailer/phpmailer/workflows/Docs/badge.svg)](https://phpmailer.github.io/PHPMailer/) +[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/PHPMailer/PHPMailer/badge)](https://api.securityscorecards.dev/projects/github.com/PHPMailer/PHPMailer) + +## Features +- Probably the world's most popular code for sending email from PHP! +- Used by many open-source projects: WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla! and many more +- Integrated SMTP support – send without a local mail server +- Send emails with multiple To, CC, BCC, and Reply-to addresses +- Multipart/alternative emails for mail clients that do not read HTML email +- Add attachments, including inline +- Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings +- SMTP authentication with LOGIN, PLAIN, CRAM-MD5, and XOAUTH2 mechanisms over SMTPS and SMTP+STARTTLS transports +- Validates email addresses automatically +- Protects against header injection attacks +- Error messages in over 50 languages! +- DKIM and S/MIME signing support +- Compatible with PHP 5.5 and later, including PHP 8.2 +- Namespaced to prevent name clashes +- Much more! + +## Why you might need it +Many PHP developers need to send email from their code. The only PHP function that supports this directly is [`mail()`](https://www.php.net/manual/en/function.mail.php). However, it does not provide any assistance for making use of popular features such as encryption, authentication, HTML messages, and attachments. + +Formatting email correctly is surprisingly difficult. There are myriad overlapping (and conflicting) standards, requiring tight adherence to horribly complicated formatting and encoding rules – the vast majority of code that you'll find online that uses the `mail()` function directly is just plain wrong, if not unsafe! + +The PHP `mail()` function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD, and macOS platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP client allows email sending on all platforms without needing a local mail server. Be aware though, that the `mail()` function should be avoided when possible; it's both faster and [safer](https://exploitbox.io/paper/Pwning-PHP-Mail-Function-For-Fun-And-RCE.html) to use SMTP to localhost. + +*Please* don't be tempted to do it yourself – if you don't use PHPMailer, there are many other excellent libraries that +you should look at before rolling your own. Try [SwiftMailer](https://swiftmailer.symfony.com/) +, [Laminas/Mail](https://docs.laminas.dev/laminas-mail/), [ZetaComponents](https://github.com/zetacomponents/Mail), etc. + +## License +This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) license, along with the [GPL Cooperation Commitment](https://gplcc.github.io/gplcc/). Please read [LICENSE](https://github.com/PHPMailer/PHPMailer/blob/master/LICENSE) for information on the software availability and distribution. + +## Installation & loading +PHPMailer is available on [Packagist](https://packagist.org/packages/phpmailer/phpmailer) (using semantic versioning), and installation via [Composer](https://getcomposer.org) is the recommended way to install PHPMailer. Just add this line to your `composer.json` file: + +```json +"phpmailer/phpmailer": "^6.8.0" +``` + +or run + +```sh +composer require phpmailer/phpmailer +``` + +Note that the `vendor` folder and the `vendor/autoload.php` script are generated by Composer; they are not part of PHPMailer. + +If you want to use the Gmail XOAUTH2 authentication class, you will also need to add a dependency on the `league/oauth2-client` package in your `composer.json`. + +Alternatively, if you're not using Composer, you +can [download PHPMailer as a zip file](https://github.com/PHPMailer/PHPMailer/archive/master.zip), (note that docs and examples are not included in the zip file), then copy the contents of the PHPMailer folder into one of the `include_path` directories specified in your PHP configuration and load each class file manually: + +```php +SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output + $mail->isSMTP(); //Send using SMTP + $mail->Host = 'smtp.example.com'; //Set the SMTP server to send through + $mail->SMTPAuth = true; //Enable SMTP authentication + $mail->Username = 'user@example.com'; //SMTP username + $mail->Password = 'secret'; //SMTP password + $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption + $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` + + //Recipients + $mail->setFrom('from@example.com', 'Mailer'); + $mail->addAddress('joe@example.net', 'Joe User'); //Add a recipient + $mail->addAddress('ellen@example.com'); //Name is optional + $mail->addReplyTo('info@example.com', 'Information'); + $mail->addCC('cc@example.com'); + $mail->addBCC('bcc@example.com'); + + //Attachments + $mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments + $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name + + //Content + $mail->isHTML(true); //Set email format to HTML + $mail->Subject = 'Here is the subject'; + $mail->Body = 'This is the HTML message body in bold!'; + $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; + + $mail->send(); + echo 'Message has been sent'; +} catch (Exception $e) { + echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; +} +``` + +You'll find plenty to play with in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder, which covers many common scenarios including sending through Gmail, building contact forms, sending to mailing lists, and more. + +If you are re-using the instance (e.g. when sending to a mailing list), you may need to clear the recipient list to avoid sending duplicate messages. See [the mailing list example](https://github.com/PHPMailer/PHPMailer/blob/master/examples/mailing_list.phps) for further guidance. + +That's it. You should now be ready to use PHPMailer! + +## Localization +PHPMailer defaults to English, but in the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder, you'll find many translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this: + +```php +//To load the French version +$mail->setLanguage('fr', '/optional/path/to/language/directory/'); +``` + +We welcome corrections and new languages – if you're looking for corrections, run the [PHPMailerLangTest.php](https://github.com/PHPMailer/PHPMailer/tree/master/test/PHPMailerLangTest.php) script in the tests folder and it will show any missing translations. + +## Documentation +Start reading at the [GitHub wiki](https://github.com/PHPMailer/PHPMailer/wiki). If you're having trouble, head for [the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting) as it's frequently updated. + +Examples of how to use PHPMailer for common scenarios can be found in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder. If you're looking for a good starting point, we recommend you start with [the Gmail example](https://github.com/PHPMailer/PHPMailer/tree/master/examples/gmail.phps). + +To reduce PHPMailer's deployed code footprint, examples are not included if you load PHPMailer via Composer or via [GitHub's zip file download](https://github.com/PHPMailer/PHPMailer/archive/master.zip), so you'll need to either clone the git repository or use the above links to get to the examples directly. + +Complete generated API documentation is [available online](https://phpmailer.github.io/PHPMailer/). + +You can generate complete API-level documentation by running `phpdoc` in the top-level folder, and documentation will appear in the `docs` folder, though you'll need to have [PHPDocumentor](http://www.phpdoc.org) installed. You may find [the unit tests](https://github.com/PHPMailer/PHPMailer/blob/master/test/PHPMailerTest.php) a good reference for how to do various operations such as encryption. + +If the documentation doesn't cover what you need, search the [many questions on Stack Overflow](http://stackoverflow.com/questions/tagged/phpmailer), and before you ask a question about "SMTP Error: Could not connect to SMTP host.", [read the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting). + +## Tests +[PHPMailer tests](https://github.com/PHPMailer/PHPMailer/tree/master/test/) use PHPUnit 9, with [a polyfill](https://github.com/Yoast/PHPUnit-Polyfills) to let 9-style tests run on older PHPUnit and PHP versions. + +[![Test status](https://github.com/PHPMailer/PHPMailer/workflows/Tests/badge.svg)](https://github.com/PHPMailer/PHPMailer/actions) + +If this isn't passing, is there something you can do to help? + +## Security +Please disclose any vulnerabilities found responsibly – report security issues to the maintainers privately. + +See [SECURITY](https://github.com/PHPMailer/PHPMailer/tree/master/SECURITY.md) and [PHPMailer's security advisories on GitHub](https://github.com/PHPMailer/PHPMailer/security). + +## Contributing +Please submit bug reports, suggestions, and pull requests to the [GitHub issue tracker](https://github.com/PHPMailer/PHPMailer/issues). + +We're particularly interested in fixing edge cases, expanding test coverage, and updating translations. + +If you found a mistake in the docs, or want to add something, go ahead and amend the wiki – anyone can edit it. + +If you have git clones from prior to the move to the PHPMailer GitHub organisation, you'll need to update any remote URLs referencing the old GitHub location with a command like this from within your clone: + +```sh +git remote set-url upstream https://github.com/PHPMailer/PHPMailer.git +``` + +Please *don't* use the SourceForge or Google Code projects any more; they are obsolete and no longer maintained. + +## Sponsorship +Development time and resources for PHPMailer are provided by [Smartmessages.net](https://info.smartmessages.net/), the world's only privacy-first email marketing system. + +Smartmessages.net privacy-first email marketing logo + +Donations are very welcome, whether in beer 🍺, T-shirts 👕, or cold, hard cash 💰. Sponsorship through GitHub is a simple and convenient way to say "thank you" to PHPMailer's maintainers and contributors – just click the "Sponsor" button [on the project page](https://github.com/PHPMailer/PHPMailer). If your company uses PHPMailer, consider taking part in Tidelift's enterprise support programme. + +## PHPMailer For Enterprise + +Available as part of the Tidelift Subscription. + +The maintainers of PHPMailer and thousands of other packages are working with Tidelift to deliver commercial +support and maintenance for the open-source packages you use to build your applications. Save time, reduce risk, and +improve code health, while paying the maintainers of the exact packages you +use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-phpmailer-phpmailer?utm_source=packagist-phpmailer-phpmailer&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) + +## Changelog +See [changelog](changelog.md). + +## History +- PHPMailer was originally written in 2001 by Brent R. Matzelle as a [SourceForge project](http://sourceforge.net/projects/phpmailer/). +- [Marcus Bointon](https://github.com/Synchro) (`coolbru` on SF) and Andy Prevost (`codeworxtech`) took over the project in 2004. +- Became an Apache incubator project on Google Code in 2010, managed by Jim Jagielski. +- Marcus created [his fork on GitHub](https://github.com/Synchro/PHPMailer) in 2008. +- Jim and Marcus decide to join forces and use GitHub as the canonical and official repo for PHPMailer in 2013. +- PHPMailer moves to [the PHPMailer organisation](https://github.com/PHPMailer) on GitHub in 2013. + +### What's changed since moving from SourceForge? +- Official successor to the SourceForge and Google Code projects. +- Test suite. +- Continuous integration with GitHub Actions. +- Composer support. +- Public development. +- Additional languages and language strings. +- CRAM-MD5 authentication support. +- Preserves full repo history of authors, commits, and branches from the original SourceForge project. diff --git a/conlite/external/phpmailer/phpmailer/SECURITY.md b/conlite/external/phpmailer/phpmailer/SECURITY.md new file mode 100644 index 0000000..035a87f --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/SECURITY.md @@ -0,0 +1,37 @@ +# Security notices relating to PHPMailer + +Please disclose any security issues or vulnerabilities found through [Tidelift's coordinated disclosure system](https://tidelift.com/security) or to the maintainers privately. + +PHPMailer 6.4.1 and earlier contain a vulnerability that can result in untrusted code being called (if such code is injected into the host project's scope by other means). If the `$patternselect` parameter to `validateAddress()` is set to `'php'` (the default, defined by `PHPMailer::$validator`), and the global namespace contains a function called `php`, it will be called in preference to the built-in validator of the same name. Mitigated in PHPMailer 6.5.0 by denying the use of simple strings as validator function names. Recorded as [CVE-2021-3603](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2021-3603). Reported by [Vikrant Singh Chauhan](mailto:vi@hackberry.xyz) via [huntr.dev](https://www.huntr.dev/). + +PHPMailer versions 6.4.1 and earlier contain a possible remote code execution vulnerability through the `$lang_path` parameter of the `setLanguage()` method. If the `$lang_path` parameter is passed unfiltered from user input, it can be set to [a UNC path](https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats#unc-paths), and if an attacker is also able to persuade the server to load a file from that UNC path, a script file under their control may be executed. This vulnerability only applies to systems that resolve UNC paths, typically only Microsoft Windows. +PHPMailer 6.5.0 mitigates this by no longer treating translation files as PHP code, but by parsing their text content directly. This approach avoids the possibility of executing unknown code while retaining backward compatibility. This isn't ideal, so the current translation format is deprecated and will be replaced in the next major release. Recorded as [CVE-2021-34551](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2021-34551). Reported by [Jilin Diting Information Technology Co., Ltd](https://listensec.com) via Tidelift. + +PHPMailer versions between 6.1.8 and 6.4.0 contain a regression of the earlier CVE-2018-19296 object injection vulnerability as a result of [a fix for Windows UNC paths in 6.1.8](https://github.com/PHPMailer/PHPMailer/commit/e2e07a355ee8ff36aba21d0242c5950c56e4c6f9). Recorded as [CVE-2020-36326](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-36326). Reported by Fariskhi Vidyan via Tidelift. 6.4.1 fixes this issue, and also enforces stricter checks for URL schemes in local path contexts. + +PHPMailer versions 6.1.5 and earlier contain an output escaping bug that occurs in `Content-Type` and `Content-Disposition` when filenames passed into `addAttachment` and other methods that accept attachment names contain double quote characters, in contravention of RFC822 3.4.1. No specific vulnerability has been found relating to this, but it could allow file attachments to bypass attachment filters that are based on matching filename extensions. Recorded as [CVE-2020-13625](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-13625). Reported by Elar Lang of Clarified Security. + +PHPMailer versions prior to 6.0.6 and 5.2.27 are vulnerable to an object injection attack by passing `phar://` paths into `addAttachment()` and other functions that may receive unfiltered local paths, possibly leading to RCE. Recorded as [CVE-2018-19296](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2018-19296). See [this article](https://knasmueller.net/5-answers-about-php-phar-exploitation) for more info on this type of vulnerability. Mitigated by blocking the use of paths containing URL-protocol style prefixes such as `phar://`. Reported by Sehun Oh of cyberone.kr. + +PHPMailer versions prior to 5.2.24 (released July 26th 2017) have an XSS vulnerability in one of the code examples, [CVE-2017-11503](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-11503). The `code_generator.phps` example did not filter user input prior to output. This file is distributed with a `.phps` extension, so it it not normally executable unless it is explicitly renamed, and the file is not included when PHPMailer is loaded through composer, so it is safe by default. There was also an undisclosed potential XSS vulnerability in the default exception handler (unused by default). Patches for both issues kindly provided by Patrick Monnerat of the Fedora Project. + +PHPMailer versions prior to 5.2.22 (released January 9th 2017) have a local file disclosure vulnerability, [CVE-2017-5223](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-5223). If content passed into `msgHTML()` is sourced from unfiltered user input, relative paths can map to absolute local file paths and added as attachments. Also note that `addAttachment` (just like `file_get_contents`, `passthru`, `unlink`, etc) should not be passed user-sourced params either! Reported by Yongxiang Li of Asiasecurity. + +PHPMailer versions prior to 5.2.20 (released December 28th 2016) are vulnerable to [CVE-2016-10045](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10045) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10045-Vuln-Patch-Bypass.html), and patched by Paul Buonopane (@Zenexer). + +PHPMailer versions prior to 5.2.18 (released December 2016) are vulnerable to [CVE-2016-10033](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10033) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](http://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10033-Vuln.html). + +PHPMailer versions prior to 5.2.14 (released November 2015) are vulnerable to [CVE-2015-8476](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2015-8476) an SMTP CRLF injection bug permitting arbitrary message sending. + +PHPMailer versions prior to 5.2.10 (released May 2015) are vulnerable to [CVE-2008-5619](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2008-5619), a remote code execution vulnerability in the bundled html2text library. This file was removed in 5.2.10, so if you are using a version prior to that and make use of the html2text function, it's vitally important that you upgrade and remove this file. + +PHPMailer versions prior to 2.0.7 and 2.2.1 are vulnerable to [CVE-2012-0796](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-0796), an email header injection attack. + +Joomla 1.6.0 uses PHPMailer in an unsafe way, allowing it to reveal local file paths, reported in [CVE-2011-3747](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2011-3747). + +PHPMailer didn't sanitise the `$lang_path` parameter in `SetLanguage`. This wasn't a problem in itself, but some apps (PHPClassifieds, ATutor) also failed to sanitise user-provided parameters passed to it, permitting semi-arbitrary local file inclusion, reported in [CVE-2010-4914](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2010-4914), [CVE-2007-2021](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2007-2021) and [CVE-2006-5734](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2006-5734). + +PHPMailer 1.7.2 and earlier contained a possible DDoS vulnerability reported in [CVE-2005-1807](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-1807). + +PHPMailer 1.7 and earlier (June 2003) have a possible vulnerability in the `SendmailSend` method where shell commands may not be sanitised. Reported in [CVE-2007-3215](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2007-3215). + diff --git a/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-af.php b/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-af.php new file mode 100644 index 0000000..0b2a72d --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-af.php @@ -0,0 +1,26 @@ + + * Rewrite and extension of the work by Jayanti Suthar + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP त्रुटि: प्रामाणिकता की जांच नहीं हो सका। '; +$PHPMAILER_LANG['buggy_php'] = 'PHP का आपका संस्करण एक बग से प्रभावित है जिसके परिणामस्वरूप संदेश दूषित हो सकते हैं. इसे ठीक करने हेतु, भेजने के लिए SMTP का उपयोग करे, अपने php.ini में mail.add_x_header विकल्प को अक्षम करें, MacOS या Linux पर जाए, या अपने PHP संस्करण को 7.0.17+ या 7.1.3+ बदले.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP त्रुटि: SMTP सर्वर से कनेक्ट नहीं हो सका। '; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP त्रुटि: डेटा स्वीकार नहीं किया जाता है। '; +$PHPMAILER_LANG['empty_message'] = 'संदेश खाली है। '; +$PHPMAILER_LANG['encoding'] = 'अज्ञात एन्कोडिंग प्रकार। '; +$PHPMAILER_LANG['execute'] = 'आदेश को निष्पादित करने में विफल। '; +$PHPMAILER_LANG['extension_missing'] = 'एक्सटेन्षन गायब है: '; +$PHPMAILER_LANG['file_access'] = 'फ़ाइल उपलब्ध नहीं है। '; +$PHPMAILER_LANG['file_open'] = 'फ़ाइल त्रुटि: फाइल को खोला नहीं जा सका। '; +$PHPMAILER_LANG['from_failed'] = 'प्रेषक का पता गलत है। '; +$PHPMAILER_LANG['instantiate'] = 'मेल फ़ंक्शन कॉल नहीं कर सकता है।'; +$PHPMAILER_LANG['invalid_address'] = 'पता गलत है। '; +$PHPMAILER_LANG['invalid_header'] = 'अमान्य हेडर नाम या मान'; +$PHPMAILER_LANG['invalid_hostentry'] = 'अमान्य hostentry: '; +$PHPMAILER_LANG['invalid_host'] = 'अमान्य होस्ट: '; +$PHPMAILER_LANG['mailer_not_supported'] = 'मेल सर्वर के साथ काम नहीं करता है। '; +$PHPMAILER_LANG['provide_address'] = 'आपको कम से कम एक प्राप्तकर्ता का ई-मेल पता प्रदान करना होगा।'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP त्रुटि: निम्न प्राप्तकर्ताओं को पते भेजने में विफल। '; +$PHPMAILER_LANG['signing'] = 'साइनअप त्रुटि: '; +$PHPMAILER_LANG['smtp_code'] = 'SMTP कोड: '; +$PHPMAILER_LANG['smtp_code_ex'] = 'अतिरिक्त SMTP जानकारी: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP का connect () फ़ंक्शन विफल हुआ। '; +$PHPMAILER_LANG['smtp_detail'] = 'विवरण: '; +$PHPMAILER_LANG['smtp_error'] = 'SMTP सर्वर त्रुटि। '; +$PHPMAILER_LANG['variable_set'] = 'चर को बना या संशोधित नहीं किया जा सकता। '; diff --git a/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-mg.php b/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-mg.php new file mode 100644 index 0000000..8a94f6a --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-mg.php @@ -0,0 +1,27 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'Hadisoana SMTP: Tsy nahomby ny fanamarinana.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Tsy afaka mampifandray amin\'ny mpampiantrano SMTP.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP diso: tsy voarakitra ny angona.'; +$PHPMAILER_LANG['empty_message'] = 'Tsy misy ny votoaty mailaka.'; +$PHPMAILER_LANG['encoding'] = 'Tsy fantatra encoding: '; +$PHPMAILER_LANG['execute'] = 'Tsy afaka manatanteraka ity baiko manaraka ity: '; +$PHPMAILER_LANG['file_access'] = 'Tsy nahomby ny fidirana amin\'ity rakitra ity: '; +$PHPMAILER_LANG['file_open'] = 'Hadisoana diso: Tsy afaka nanokatra ity file manaraka ity: '; +$PHPMAILER_LANG['from_failed'] = 'Ny adiresy iraka manaraka dia diso: '; +$PHPMAILER_LANG['instantiate'] = 'Tsy afaka nanomboka ny hetsika mail.'; +$PHPMAILER_LANG['invalid_address'] = 'Tsy mety ny adiresy: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' mailer tsy manohana.'; +$PHPMAILER_LANG['provide_address'] = 'Alefaso azafady iray adiresy iray farafahakeliny.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: Tsy mety ireo mpanaraka ireto: '; +$PHPMAILER_LANG['signing'] = 'Error nandritra ny sonia:'; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Tsy nahomby ny fifandraisana tamin\'ny server SMTP.'; +$PHPMAILER_LANG['smtp_error'] = 'Fahadisoana tamin\'ny server SMTP: '; +$PHPMAILER_LANG['variable_set'] = 'Tsy azo atao ny mametraka na mamerina ny variable: '; +$PHPMAILER_LANG['extension_missing'] = 'Tsy hita ny ampahany: '; diff --git a/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-mn.php b/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-mn.php new file mode 100644 index 0000000..04d262c --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-mn.php @@ -0,0 +1,27 @@ + + * @author Miloš Milanović + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP greška: autentifikacija nije uspela.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP greška: povezivanje sa SMTP serverom nije uspelo.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP greška: podaci nisu prihvaćeni.'; +$PHPMAILER_LANG['empty_message'] = 'Sadržaj poruke je prazan.'; +$PHPMAILER_LANG['encoding'] = 'Nepoznato kodiranje: '; +$PHPMAILER_LANG['execute'] = 'Nije moguće izvršiti naredbu: '; +$PHPMAILER_LANG['file_access'] = 'Nije moguće pristupiti datoteci: '; +$PHPMAILER_LANG['file_open'] = 'Nije moguće otvoriti datoteku: '; +$PHPMAILER_LANG['from_failed'] = 'SMTP greška: slanje sa sledećih adresa nije uspelo: '; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP greška: slanje na sledeće adrese nije uspelo: '; +$PHPMAILER_LANG['instantiate'] = 'Nije moguće pokrenuti mail funkciju.'; +$PHPMAILER_LANG['invalid_address'] = 'Poruka nije poslata. Neispravna adresa: '; +$PHPMAILER_LANG['mailer_not_supported'] = ' majler nije podržan.'; +$PHPMAILER_LANG['provide_address'] = 'Definišite bar jednu adresu primaoca.'; +$PHPMAILER_LANG['signing'] = 'Greška prilikom prijave: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Povezivanje sa SMTP serverom nije uspelo.'; +$PHPMAILER_LANG['smtp_error'] = 'Greška SMTP servera: '; +$PHPMAILER_LANG['variable_set'] = 'Nije moguće zadati niti resetovati promenljivu: '; +$PHPMAILER_LANG['extension_missing'] = 'Nedostaje proširenje: '; diff --git a/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-tl.php b/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-tl.php new file mode 100644 index 0000000..d15bed1 --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/language/phpmailer.lang-tl.php @@ -0,0 +1,28 @@ + + */ + +$PHPMAILER_LANG['authenticate'] = 'SMTP Error: Hindi mapatotohanan.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Hindi makakonekta sa SMTP host.'; +$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Ang datos ay hindi naitanggap.'; +$PHPMAILER_LANG['empty_message'] = 'Walang laman ang mensahe'; +$PHPMAILER_LANG['encoding'] = 'Hindi alam ang encoding: '; +$PHPMAILER_LANG['execute'] = 'Hindi maisasagawa: '; +$PHPMAILER_LANG['file_access'] = 'Hindi ma-access ang file: '; +$PHPMAILER_LANG['file_open'] = 'File Error: Hindi mabuksan ang file: '; +$PHPMAILER_LANG['from_failed'] = 'Ang sumusunod na address ay nabigo: '; +$PHPMAILER_LANG['instantiate'] = 'Hindi maisimulan ang instance ng mail function.'; +$PHPMAILER_LANG['invalid_address'] = 'Hindi wasto ang address na naibigay: '; +$PHPMAILER_LANG['mailer_not_supported'] = 'Ang mailer ay hindi suportado.'; +$PHPMAILER_LANG['provide_address'] = 'Kailangan mong magbigay ng kahit isang email address na tatanggap.'; +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: Ang mga sumusunod na tatanggap ay nabigo: '; +$PHPMAILER_LANG['signing'] = 'Hindi ma-sign: '; +$PHPMAILER_LANG['smtp_connect_failed'] = 'Ang SMTP connect() ay nabigo.'; +$PHPMAILER_LANG['smtp_error'] = 'Ang server ng SMTP ay nabigo: '; +$PHPMAILER_LANG['variable_set'] = 'Hindi matatakda o ma-reset ang mga variables: '; +$PHPMAILER_LANG['extension_missing'] = 'Nawawala ang extension: '; diff --git a/conlite/external/phpmailer/phpmailer/src/DSNConfigurator.php b/conlite/external/phpmailer/phpmailer/src/DSNConfigurator.php new file mode 100644 index 0000000..ab707d2 --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/src/DSNConfigurator.php @@ -0,0 +1,247 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2023 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +namespace PHPMailer\PHPMailer; + +/** + * Configure PHPMailer with DSN string. + * + * @see https://en.wikipedia.org/wiki/Data_source_name + * + * @author Oleg Voronkovich + */ +class DSNConfigurator +{ + /** + * Create new PHPMailer instance configured by DSN. + * + * @param string $dsn DSN + * @param bool $exceptions Should we throw external exceptions? + * + * @return PHPMailer + */ + public static function mailer($dsn, $exceptions = null) + { + static $configurator = null; + + if (null === $configurator) { + $configurator = new DSNConfigurator(); + } + + return $configurator->configure(new PHPMailer($exceptions), $dsn); + } + + /** + * Configure PHPMailer instance with DSN string. + * + * @param PHPMailer $mailer PHPMailer instance + * @param string $dsn DSN + * + * @return PHPMailer + */ + public function configure(PHPMailer $mailer, $dsn) + { + $config = $this->parseDSN($dsn); + + $this->applyConfig($mailer, $config); + + return $mailer; + } + + /** + * Parse DSN string. + * + * @param string $dsn DSN + * + * @throws Exception If DSN is malformed + * + * @return array Configuration + */ + private function parseDSN($dsn) + { + $config = $this->parseUrl($dsn); + + if (false === $config || !isset($config['scheme']) || !isset($config['host'])) { + throw new Exception( + sprintf('Malformed DSN: "%s".', $dsn) + ); + } + + if (isset($config['query'])) { + parse_str($config['query'], $config['query']); + } + + return $config; + } + + /** + * Apply configuration to mailer. + * + * @param PHPMailer $mailer PHPMailer instance + * @param array $config Configuration + * + * @throws Exception If scheme is invalid + */ + private function applyConfig(PHPMailer $mailer, $config) + { + switch ($config['scheme']) { + case 'mail': + $mailer->isMail(); + break; + case 'sendmail': + $mailer->isSendmail(); + break; + case 'qmail': + $mailer->isQmail(); + break; + case 'smtp': + case 'smtps': + $mailer->isSMTP(); + $this->configureSMTP($mailer, $config); + break; + default: + throw new Exception( + sprintf( + 'Invalid scheme: "%s". Allowed values: "mail", "sendmail", "qmail", "smtp", "smtps".', + $config['scheme'] + ) + ); + } + + if (isset($config['query'])) { + $this->configureOptions($mailer, $config['query']); + } + } + + /** + * Configure SMTP. + * + * @param PHPMailer $mailer PHPMailer instance + * @param array $config Configuration + */ + private function configureSMTP($mailer, $config) + { + $isSMTPS = 'smtps' === $config['scheme']; + + if ($isSMTPS) { + $mailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; + } + + $mailer->Host = $config['host']; + + if (isset($config['port'])) { + $mailer->Port = $config['port']; + } elseif ($isSMTPS) { + $mailer->Port = SMTP::DEFAULT_SECURE_PORT; + } + + $mailer->SMTPAuth = isset($config['user']) || isset($config['pass']); + + if (isset($config['user'])) { + $mailer->Username = $config['user']; + } + + if (isset($config['pass'])) { + $mailer->Password = $config['pass']; + } + } + + /** + * Configure options. + * + * @param PHPMailer $mailer PHPMailer instance + * @param array $options Options + * + * @throws Exception If option is unknown + */ + private function configureOptions(PHPMailer $mailer, $options) + { + $allowedOptions = get_object_vars($mailer); + + unset($allowedOptions['Mailer']); + unset($allowedOptions['SMTPAuth']); + unset($allowedOptions['Username']); + unset($allowedOptions['Password']); + unset($allowedOptions['Hostname']); + unset($allowedOptions['Port']); + unset($allowedOptions['ErrorInfo']); + + $allowedOptions = \array_keys($allowedOptions); + + foreach ($options as $key => $value) { + if (!in_array($key, $allowedOptions)) { + throw new Exception( + sprintf( + 'Unknown option: "%s". Allowed values: "%s"', + $key, + implode('", "', $allowedOptions) + ) + ); + } + + switch ($key) { + case 'AllowEmpty': + case 'SMTPAutoTLS': + case 'SMTPKeepAlive': + case 'SingleTo': + case 'UseSendmailOptions': + case 'do_verp': + case 'DKIM_copyHeaderFields': + $mailer->$key = (bool) $value; + break; + case 'Priority': + case 'SMTPDebug': + case 'WordWrap': + $mailer->$key = (int) $value; + break; + default: + $mailer->$key = $value; + break; + } + } + } + + /** + * Parse a URL. + * Wrapper for the built-in parse_url function to work around a bug in PHP 5.5. + * + * @param string $url URL + * + * @return array|false + */ + protected function parseUrl($url) + { + if (\PHP_VERSION_ID >= 50600 || false === strpos($url, '?')) { + return parse_url($url); + } + + $chunks = explode('?', $url); + if (is_array($chunks)) { + $result = parse_url($chunks[0]); + if (is_array($result)) { + $result['query'] = $chunks[1]; + } + return $result; + } + + return false; + } +} diff --git a/conlite/external/phpmailer/phpmailer/src/Exception.php b/conlite/external/phpmailer/phpmailer/src/Exception.php new file mode 100644 index 0000000..52eaf95 --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/src/Exception.php @@ -0,0 +1,40 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2020 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +namespace PHPMailer\PHPMailer; + +/** + * PHPMailer exception handler. + * + * @author Marcus Bointon + */ +class Exception extends \Exception +{ + /** + * Prettify error message output. + * + * @return string + */ + public function errorMessage() + { + return '' . htmlspecialchars($this->getMessage(), ENT_COMPAT | ENT_HTML401) . "
\n"; + } +} diff --git a/conlite/external/phpmailer/phpmailer/src/OAuth.php b/conlite/external/phpmailer/phpmailer/src/OAuth.php new file mode 100644 index 0000000..c1d5b77 --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/src/OAuth.php @@ -0,0 +1,139 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2020 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +namespace PHPMailer\PHPMailer; + +use League\OAuth2\Client\Grant\RefreshToken; +use League\OAuth2\Client\Provider\AbstractProvider; +use League\OAuth2\Client\Token\AccessToken; + +/** + * OAuth - OAuth2 authentication wrapper class. + * Uses the oauth2-client package from the League of Extraordinary Packages. + * + * @see http://oauth2-client.thephpleague.com + * + * @author Marcus Bointon (Synchro/coolbru) + */ +class OAuth implements OAuthTokenProvider +{ + /** + * An instance of the League OAuth Client Provider. + * + * @var AbstractProvider + */ + protected $provider; + + /** + * The current OAuth access token. + * + * @var AccessToken + */ + protected $oauthToken; + + /** + * The user's email address, usually used as the login ID + * and also the from address when sending email. + * + * @var string + */ + protected $oauthUserEmail = ''; + + /** + * The client secret, generated in the app definition of the service you're connecting to. + * + * @var string + */ + protected $oauthClientSecret = ''; + + /** + * The client ID, generated in the app definition of the service you're connecting to. + * + * @var string + */ + protected $oauthClientId = ''; + + /** + * The refresh token, used to obtain new AccessTokens. + * + * @var string + */ + protected $oauthRefreshToken = ''; + + /** + * OAuth constructor. + * + * @param array $options Associative array containing + * `provider`, `userName`, `clientSecret`, `clientId` and `refreshToken` elements + */ + public function __construct($options) + { + $this->provider = $options['provider']; + $this->oauthUserEmail = $options['userName']; + $this->oauthClientSecret = $options['clientSecret']; + $this->oauthClientId = $options['clientId']; + $this->oauthRefreshToken = $options['refreshToken']; + } + + /** + * Get a new RefreshToken. + * + * @return RefreshToken + */ + protected function getGrant() + { + return new RefreshToken(); + } + + /** + * Get a new AccessToken. + * + * @return AccessToken + */ + protected function getToken() + { + return $this->provider->getAccessToken( + $this->getGrant(), + ['refresh_token' => $this->oauthRefreshToken] + ); + } + + /** + * Generate a base64-encoded OAuth token. + * + * @return string + */ + public function getOauth64() + { + //Get a new token if it's not available or has expired + if (null === $this->oauthToken || $this->oauthToken->hasExpired()) { + $this->oauthToken = $this->getToken(); + } + + return base64_encode( + 'user=' . + $this->oauthUserEmail . + "\001auth=Bearer " . + $this->oauthToken . + "\001\001" + ); + } +} diff --git a/conlite/external/phpmailer/phpmailer/src/OAuthTokenProvider.php b/conlite/external/phpmailer/phpmailer/src/OAuthTokenProvider.php new file mode 100644 index 0000000..1155507 --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/src/OAuthTokenProvider.php @@ -0,0 +1,44 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2020 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +namespace PHPMailer\PHPMailer; + +/** + * OAuthTokenProvider - OAuth2 token provider interface. + * Provides base64 encoded OAuth2 auth strings for SMTP authentication. + * + * @see OAuth + * @see SMTP::authenticate() + * + * @author Peter Scopes (pdscopes) + * @author Marcus Bointon (Synchro/coolbru) + */ +interface OAuthTokenProvider +{ + /** + * Generate a base64-encoded OAuth token ensuring that the access token has not expired. + * The string to be base 64 encoded should be in the form: + * "user=\001auth=Bearer \001\001" + * + * @return string + */ + public function getOauth64(); +} diff --git a/conlite/external/phpmailer/phpmailer/src/PHPMailer.php b/conlite/external/phpmailer/phpmailer/src/PHPMailer.php new file mode 100644 index 0000000..a644d2c --- /dev/null +++ b/conlite/external/phpmailer/phpmailer/src/PHPMailer.php @@ -0,0 +1,5126 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2020 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +namespace PHPMailer\PHPMailer; + +/** + * PHPMailer - PHP email creation and transport class. + * + * @author Marcus Bointon (Synchro/coolbru) + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + */ +class PHPMailer +{ + const CHARSET_ASCII = 'us-ascii'; + const CHARSET_ISO88591 = 'iso-8859-1'; + const CHARSET_UTF8 = 'utf-8'; + + const CONTENT_TYPE_PLAINTEXT = 'text/plain'; + const CONTENT_TYPE_TEXT_CALENDAR = 'text/calendar'; + const CONTENT_TYPE_TEXT_HTML = 'text/html'; + const CONTENT_TYPE_MULTIPART_ALTERNATIVE = 'multipart/alternative'; + const CONTENT_TYPE_MULTIPART_MIXED = 'multipart/mixed'; + const CONTENT_TYPE_MULTIPART_RELATED = 'multipart/related'; + + const ENCODING_7BIT = '7bit'; + const ENCODING_8BIT = '8bit'; + const ENCODING_BASE64 = 'base64'; + const ENCODING_BINARY = 'binary'; + const ENCODING_QUOTED_PRINTABLE = 'quoted-printable'; + + const ENCRYPTION_STARTTLS = 'tls'; + const ENCRYPTION_SMTPS = 'ssl'; + + const ICAL_METHOD_REQUEST = 'REQUEST'; + const ICAL_METHOD_PUBLISH = 'PUBLISH'; + const ICAL_METHOD_REPLY = 'REPLY'; + const ICAL_METHOD_ADD = 'ADD'; + const ICAL_METHOD_CANCEL = 'CANCEL'; + const ICAL_METHOD_REFRESH = 'REFRESH'; + const ICAL_METHOD_COUNTER = 'COUNTER'; + const ICAL_METHOD_DECLINECOUNTER = 'DECLINECOUNTER'; + + /** + * Email priority. + * Options: null (default), 1 = High, 3 = Normal, 5 = low. + * When null, the header is not set at all. + * + * @var int|null + */ + public $Priority; + + /** + * The character set of the message. + * + * @var string + */ + public $CharSet = self::CHARSET_ISO88591; + + /** + * The MIME Content-type of the message. + * + * @var string + */ + public $ContentType = self::CONTENT_TYPE_PLAINTEXT; + + /** + * The message encoding. + * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable". + * + * @var string + */ + public $Encoding = self::ENCODING_8BIT; + + /** + * Holds the most recent mailer error message. + * + * @var string + */ + public $ErrorInfo = ''; + + /** + * The From email address for the message. + * + * @var string + */ + public $From = ''; + + /** + * The From name of the message. + * + * @var string + */ + public $FromName = ''; + + /** + * The envelope sender of the message. + * This will usually be turned into a Return-Path header by the receiver, + * and is the address that bounces will be sent to. + * If not empty, will be passed via `-f` to sendmail or as the 'MAIL FROM' value over SMTP. + * + * @var string + */ + public $Sender = ''; + + /** + * The Subject of the message. + * + * @var string + */ + public $Subject = ''; + + /** + * An HTML or plain text message body. + * If HTML then call isHTML(true). + * + * @var string + */ + public $Body = ''; + + /** + * The plain-text message body. + * This body can be read by mail clients that do not have HTML email + * capability such as mutt & Eudora. + * Clients that can read HTML will view the normal Body. + * + * @var string + */ + public $AltBody = ''; + + /** + * An iCal message part body. + * Only supported in simple alt or alt_inline message types + * To generate iCal event structures, use classes like EasyPeasyICS or iCalcreator. + * + * @see http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/ + * @see http://kigkonsult.se/iCalcreator/ + * + * @var string + */ + public $Ical = ''; + + /** + * Value-array of "method" in Contenttype header "text/calendar" + * + * @var string[] + */ + protected static $IcalMethods = [ + self::ICAL_METHOD_REQUEST, + self::ICAL_METHOD_PUBLISH, + self::ICAL_METHOD_REPLY, + self::ICAL_METHOD_ADD, + self::ICAL_METHOD_CANCEL, + self::ICAL_METHOD_REFRESH, + self::ICAL_METHOD_COUNTER, + self::ICAL_METHOD_DECLINECOUNTER, + ]; + + /** + * The complete compiled MIME message body. + * + * @var string + */ + protected $MIMEBody = ''; + + /** + * The complete compiled MIME message headers. + * + * @var string + */ + protected $MIMEHeader = ''; + + /** + * Extra headers that createHeader() doesn't fold in. + * + * @var string + */ + protected $mailHeader = ''; + + /** + * Word-wrap the message body to this number of chars. + * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance. + * + * @see static::STD_LINE_LENGTH + * + * @var int + */ + public $WordWrap = 0; + + /** + * Which method to use to send mail. + * Options: "mail", "sendmail", or "smtp". + * + * @var string + */ + public $Mailer = 'mail'; + + /** + * The path to the sendmail program. + * + * @var string + */ + public $Sendmail = '/usr/sbin/sendmail'; + + /** + * Whether mail() uses a fully sendmail-compatible MTA. + * One which supports sendmail's "-oi -f" options. + * + * @var bool + */ + public $UseSendmailOptions = true; + + /** + * The email address that a reading confirmation should be sent to, also known as read receipt. + * + * @var string + */ + public $ConfirmReadingTo = ''; + + /** + * The hostname to use in the Message-ID header and as default HELO string. + * If empty, PHPMailer attempts to find one with, in order, + * $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value + * 'localhost.localdomain'. + * + * @see PHPMailer::$Helo + * + * @var string + */ + public $Hostname = ''; + + /** + * An ID to be used in the Message-ID header. + * If empty, a unique id will be generated. + * You can set your own, but it must be in the format "", + * as defined in RFC5322 section 3.6.4 or it will be ignored. + * + * @see https://tools.ietf.org/html/rfc5322#section-3.6.4 + * + * @var string + */ + public $MessageID = ''; + + /** + * The message Date to be used in the Date header. + * If empty, the current date will be added. + * + * @var string + */ + public $MessageDate = ''; + + /** + * SMTP hosts. + * Either a single hostname or multiple semicolon-delimited hostnames. + * You can also specify a different port + * for each host by using this format: [hostname:port] + * (e.g. "smtp1.example.com:25;smtp2.example.com"). + * You can also specify encryption type, for example: + * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465"). + * Hosts will be tried in order. + * + * @var string + */ + public $Host = 'localhost'; + + /** + * The default SMTP server port. + * + * @var int + */ + public $Port = 25; + + /** + * The SMTP HELO/EHLO name used for the SMTP connection. + * Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find + * one with the same method described above for $Hostname. + * + * @see PHPMailer::$Hostname + * + * @var string + */ + public $Helo = ''; + + /** + * What kind of encryption to use on the SMTP connection. + * Options: '', static::ENCRYPTION_STARTTLS, or static::ENCRYPTION_SMTPS. + * + * @var string + */ + public $SMTPSecure = ''; + + /** + * Whether to enable TLS encryption automatically if a server supports it, + * even if `SMTPSecure` is not set to 'tls'. + * Be aware that in PHP >= 5.6 this requires that the server's certificates are valid. + * + * @var bool + */ + public $SMTPAutoTLS = true; + + /** + * Whether to use SMTP authentication. + * Uses the Username and Password properties. + * + * @see PHPMailer::$Username + * @see PHPMailer::$Password + * + * @var bool + */ + public $SMTPAuth = false; + + /** + * Options array passed to stream_context_create when connecting via SMTP. + * + * @var array + */ + public $SMTPOptions = []; + + /** + * SMTP username. + * + * @var string + */ + public $Username = ''; + + /** + * SMTP password. + * + * @var string + */ + public $Password = ''; + + /** + * SMTP authentication type. Options are CRAM-MD5, LOGIN, PLAIN, XOAUTH2. + * If not specified, the first one from that list that the server supports will be selected. + * + * @var string + */ + public $AuthType = ''; + + /** + * An implementation of the PHPMailer OAuthTokenProvider interface. + * + * @var OAuthTokenProvider + */ + protected $oauth; + + /** + * The SMTP server timeout in seconds. + * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2. + * + * @var int + */ + public $Timeout = 300; + + /** + * Comma separated list of DSN notifications + * 'NEVER' under no circumstances a DSN must be returned to the sender. + * If you use NEVER all other notifications will be ignored. + * 'SUCCESS' will notify you when your mail has arrived at its destination. + * 'FAILURE' will arrive if an error occurred during delivery. + * 'DELAY' will notify you if there is an unusual delay in delivery, but the actual + * delivery's outcome (success or failure) is not yet decided. + * + * @see https://tools.ietf.org/html/rfc3461 See section 4.1 for more information about NOTIFY + */ + public $dsn = ''; + + /** + * SMTP class debug output mode. + * Debug output level. + * Options: + * @see SMTP::DEBUG_OFF: No output + * @see SMTP::DEBUG_CLIENT: Client messages + * @see SMTP::DEBUG_SERVER: Client and server messages + * @see SMTP::DEBUG_CONNECTION: As SERVER plus connection status + * @see SMTP::DEBUG_LOWLEVEL: Noisy, low-level data output, rarely needed + * + * @see SMTP::$do_debug + * + * @var int + */ + public $SMTPDebug = 0; + + /** + * How to handle debug output. + * Options: + * * `echo` Output plain-text as-is, appropriate for CLI + * * `html` Output escaped, line breaks converted to `
`, appropriate for browser output + * * `error_log` Output to error log as configured in php.ini + * By default PHPMailer will use `echo` if run from a `cli` or `cli-server` SAPI, `html` otherwise. + * Alternatively, you can provide a callable expecting two params: a message string and the debug level: + * + * ```php + * $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; + * ``` + * + * Alternatively, you can pass in an instance of a PSR-3 compatible logger, though only `debug` + * level output is used: + * + * ```php + * $mail->Debugoutput = new myPsr3Logger; + * ``` + * + * @see SMTP::$Debugoutput + * + * @var string|callable|\Psr\Log\LoggerInterface + */ + public $Debugoutput = 'echo'; + + /** + * Whether to keep the SMTP connection open after each message. + * If this is set to true then the connection will remain open after a send, + * and closing the connection will require an explicit call to smtpClose(). + * It's a good idea to use this if you are sending multiple messages as it reduces overhead. + * See the mailing list example for how to use it. + * + * @var bool + */ + public $SMTPKeepAlive = false; + + /** + * Whether to split multiple to addresses into multiple messages + * or send them all in one message. + * Only supported in `mail` and `sendmail` transports, not in SMTP. + * + * @var bool + * + * @deprecated 6.0.0 PHPMailer isn't a mailing list manager! + */ + public $SingleTo = false; + + /** + * Storage for addresses when SingleTo is enabled. + * + * @var array + */ + protected $SingleToArray = []; + + /** + * Whether to generate VERP addresses on send. + * Only applicable when sending via SMTP. + * + * @see https://en.wikipedia.org/wiki/Variable_envelope_return_path + * @see http://www.postfix.org/VERP_README.html Postfix VERP info + * + * @var bool + */ + public $do_verp = false; + + /** + * Whether to allow sending messages with an empty body. + * + * @var bool + */ + public $AllowEmpty = false; + + /** + * DKIM selector. + * + * @var string + */ + public $DKIM_selector = ''; + + /** + * DKIM Identity. + * Usually the email address used as the source of the email. + * + * @var string + */ + public $DKIM_identity = ''; + + /** + * DKIM passphrase. + * Used if your key is encrypted. + * + * @var string + */ + public $DKIM_passphrase = ''; + + /** + * DKIM signing domain name. + * + * @example 'example.com' + * + * @var string + */ + public $DKIM_domain = ''; + + /** + * DKIM Copy header field values for diagnostic use. + * + * @var bool + */ + public $DKIM_copyHeaderFields = true; + + /** + * DKIM Extra signing headers. + * + * @example ['List-Unsubscribe', 'List-Help'] + * + * @var array + */ + public $DKIM_extraHeaders = []; + + /** + * DKIM private key file path. + * + * @var string + */ + public $DKIM_private = ''; + + /** + * DKIM private key string. + * + * If set, takes precedence over `$DKIM_private`. + * + * @var string + */ + public $DKIM_private_string = ''; + + /** + * Callback Action function name. + * + * The function that handles the result of the send email action. + * It is called out by send() for each email sent. + * + * Value can be any php callable: http://www.php.net/is_callable + * + * Parameters: + * bool $result result of the send action + * array $to email addresses of the recipients + * array $cc cc email addresses + * array $bcc bcc email addresses + * string $subject the subject + * string $body the email body + * string $from email address of sender + * string $extra extra information of possible use + * "smtp_transaction_id' => last smtp transaction id + * + * @var string + */ + public $action_function = ''; + + /** + * What to put in the X-Mailer header. + * Options: An empty string for PHPMailer default, whitespace/null for none, or a string to use. + * + * @var string|null + */ + public $XMailer = ''; + + /** + * Which validator to use by default when validating email addresses. + * May be a callable to inject your own validator, but there are several built-in validators. + * The default validator uses PHP's FILTER_VALIDATE_EMAIL filter_var option. + * + * @see PHPMailer::validateAddress() + * + * @var string|callable + */ + public static $validator = 'php'; + + /** + * An instance of the SMTP sender class. + * + * @var SMTP + */ + protected $smtp; + + /** + * The array of 'to' names and addresses. + * + * @var array + */ + protected $to = []; + + /** + * The array of 'cc' names and addresses. + * + * @var array + */ + protected $cc = []; + + /** + * The array of 'bcc' names and addresses. + * + * @var array + */ + protected $bcc = []; + + /** + * The array of reply-to names and addresses. + * + * @var array + */ + protected $ReplyTo = []; + + /** + * An array of all kinds of addresses. + * Includes all of $to, $cc, $bcc. + * + * @see PHPMailer::$to + * @see PHPMailer::$cc + * @see PHPMailer::$bcc + * + * @var array + */ + protected $all_recipients = []; + + /** + * An array of names and addresses queued for validation. + * In send(), valid and non duplicate entries are moved to $all_recipients + * and one of $to, $cc, or $bcc. + * This array is used only for addresses with IDN. + * + * @see PHPMailer::$to + * @see PHPMailer::$cc + * @see PHPMailer::$bcc + * @see PHPMailer::$all_recipients + * + * @var array + */ + protected $RecipientsQueue = []; + + /** + * An array of reply-to names and addresses queued for validation. + * In send(), valid and non duplicate entries are moved to $ReplyTo. + * This array is used only for addresses with IDN. + * + * @see PHPMailer::$ReplyTo + * + * @var array + */ + protected $ReplyToQueue = []; + + /** + * The array of attachments. + * + * @var array + */ + protected $attachment = []; + + /** + * The array of custom headers. + * + * @var array + */ + protected $CustomHeader = []; + + /** + * The most recent Message-ID (including angular brackets). + * + * @var string + */ + protected $lastMessageID = ''; + + /** + * The message's MIME type. + * + * @var string + */ + protected $message_type = ''; + + /** + * The array of MIME boundary strings. + * + * @var array + */ + protected $boundary = []; + + /** + * The array of available text strings for the current language. + * + * @var array + */ + protected $language = []; + + /** + * The number of errors encountered. + * + * @var int + */ + protected $error_count = 0; + + /** + * The S/MIME certificate file path. + * + * @var string + */ + protected $sign_cert_file = ''; + + /** + * The S/MIME key file path. + * + * @var string + */ + protected $sign_key_file = ''; + + /** + * The optional S/MIME extra certificates ("CA Chain") file path. + * + * @var string + */ + protected $sign_extracerts_file = ''; + + /** + * The S/MIME password for the key. + * Used only if the key is encrypted. + * + * @var string + */ + protected $sign_key_pass = ''; + + /** + * Whether to throw exceptions for errors. + * + * @var bool + */ + protected $exceptions = false; + + /** + * Unique ID used for message ID and boundaries. + * + * @var string + */ + protected $uniqueid = ''; + + /** + * The PHPMailer Version number. + * + * @var string + */ + const VERSION = '6.8.0'; + + /** + * Error severity: message only, continue processing. + * + * @var int + */ + const STOP_MESSAGE = 0; + + /** + * Error severity: message, likely ok to continue processing. + * + * @var int + */ + const STOP_CONTINUE = 1; + + /** + * Error severity: message, plus full stop, critical error reached. + * + * @var int + */ + const STOP_CRITICAL = 2; + + /** + * The SMTP standard CRLF line break. + * If you want to change line break format, change static::$LE, not this. + */ + const CRLF = "\r\n"; + + /** + * "Folding White Space" a white space string used for line folding. + */ + const FWS = ' '; + + /** + * SMTP RFC standard line ending; Carriage Return, Line Feed. + * + * @var string + */ + protected static $LE = self::CRLF; + + /** + * The maximum line length supported by mail(). + * + * Background: mail() will sometimes corrupt messages + * with headers headers longer than 65 chars, see #818. + * + * @var int + */ + const MAIL_MAX_LINE_LENGTH = 63; + + /** + * The maximum line length allowed by RFC 2822 section 2.1.1. + * + * @var int + */ + const MAX_LINE_LENGTH = 998; + + /** + * The lower maximum line length allowed by RFC 2822 section 2.1.1. + * This length does NOT include the line break + * 76 means that lines will be 77 or 78 chars depending on whether + * the line break format is LF or CRLF; both are valid. + * + * @var int + */ + const STD_LINE_LENGTH = 76; + + /** + * Constructor. + * + * @param bool $exceptions Should we throw external exceptions? + */ + public function __construct($exceptions = null) + { + if (null !== $exceptions) { + $this->exceptions = (bool) $exceptions; + } + //Pick an appropriate debug output format automatically + $this->Debugoutput = (strpos(PHP_SAPI, 'cli') !== false ? 'echo' : 'html'); + } + + /** + * Destructor. + */ + public function __destruct() + { + //Close any open SMTP connection nicely + $this->smtpClose(); + } + + /** + * Call mail() in a safe_mode-aware fashion. + * Also, unless sendmail_path points to sendmail (or something that + * claims to be sendmail), don't pass params (not a perfect fix, + * but it will do). + * + * @param string $to To + * @param string $subject Subject + * @param string $body Message Body + * @param string $header Additional Header(s) + * @param string|null $params Params + * + * @return bool + */ + private function mailPassthru($to, $subject, $body, $header, $params) + { + //Check overloading of mail function to avoid double-encoding + if ((int)ini_get('mbstring.func_overload') & 1) { + $subject = $this->secureHeader($subject); + } else { + $subject = $this->encodeHeader($this->secureHeader($subject)); + } + //Calling mail() with null params breaks + $this->edebug('Sending with mail()'); + $this->edebug('Sendmail path: ' . ini_get('sendmail_path')); + $this->edebug("Envelope sender: {$this->Sender}"); + $this->edebug("To: {$to}"); + $this->edebug("Subject: {$subject}"); + $this->edebug("Headers: {$header}"); + if (!$this->UseSendmailOptions || null === $params) { + $result = @mail($to, $subject, $body, $header); + } else { + $this->edebug("Additional params: {$params}"); + $result = @mail($to, $subject, $body, $header, $params); + } + $this->edebug('Result: ' . ($result ? 'true' : 'false')); + return $result; + } + + /** + * Output debugging info via a user-defined method. + * Only generates output if debug output is enabled. + * + * @see PHPMailer::$Debugoutput + * @see PHPMailer::$SMTPDebug + * + * @param string $str + */ + protected function edebug($str) + { + if ($this->SMTPDebug <= 0) { + return; + } + //Is this a PSR-3 logger? + if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) { + $this->Debugoutput->debug($str); + + return; + } + //Avoid clash with built-in function names + if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, ['error_log', 'html', 'echo'])) { + call_user_func($this->Debugoutput, $str, $this->SMTPDebug); + + return; + } + switch ($this->Debugoutput) { + case 'error_log': + //Don't output, just log + /** @noinspection ForgottenDebugOutputInspection */ + error_log($str); + break; + case 'html': + //Cleans up output a bit for a better looking, HTML-safe output + echo htmlentities( + preg_replace('/[\r\n]+/', '', $str), + ENT_QUOTES, + 'UTF-8' + ), "
\n"; + break; + case 'echo': + default: + //Normalize line breaks + $str = preg_replace('/\r\n|\r/m', "\n", $str); + echo gmdate('Y-m-d H:i:s'), + "\t", + //Trim trailing space + trim( + //Indent for readability, except for trailing break + str_replace( + "\n", + "\n \t ", + trim($str) + ) + ), + "\n"; + } + } + + /** + * Sets message type to HTML or plain. + * + * @param bool $isHtml True for HTML mode + */ + public function isHTML($isHtml = true) + { + if ($isHtml) { + $this->ContentType = static::CONTENT_TYPE_TEXT_HTML; + } else { + $this->ContentType = static::CONTENT_TYPE_PLAINTEXT; + } + } + + /** + * Send messages using SMTP. + */ + public function isSMTP() + { + $this->Mailer = 'smtp'; + } + + /** + * Send messages using PHP's mail() function. + */ + public function isMail() + { + $this->Mailer = 'mail'; + } + + /** + * Send messages using $Sendmail. + */ + public function isSendmail() + { + $ini_sendmail_path = ini_get('sendmail_path'); + + if (false === stripos($ini_sendmail_path, 'sendmail')) { + $this->Sendmail = '/usr/sbin/sendmail'; + } else { + $this->Sendmail = $ini_sendmail_path; + } + $this->Mailer = 'sendmail'; + } + + /** + * Send messages using qmail. + */ + public function isQmail() + { + $ini_sendmail_path = ini_get('sendmail_path'); + + if (false === stripos($ini_sendmail_path, 'qmail')) { + $this->Sendmail = '/var/qmail/bin/qmail-inject'; + } else { + $this->Sendmail = $ini_sendmail_path; + } + $this->Mailer = 'qmail'; + } + + /** + * Add a "To" address. + * + * @param string $address The email address to send to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + public function addAddress($address, $name = '') + { + return $this->addOrEnqueueAnAddress('to', $address, $name); + } + + /** + * Add a "CC" address. + * + * @param string $address The email address to send to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + public function addCC($address, $name = '') + { + return $this->addOrEnqueueAnAddress('cc', $address, $name); + } + + /** + * Add a "BCC" address. + * + * @param string $address The email address to send to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + public function addBCC($address, $name = '') + { + return $this->addOrEnqueueAnAddress('bcc', $address, $name); + } + + /** + * Add a "Reply-To" address. + * + * @param string $address The email address to reply to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + public function addReplyTo($address, $name = '') + { + return $this->addOrEnqueueAnAddress('Reply-To', $address, $name); + } + + /** + * Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer + * can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still + * be modified after calling this function), addition of such addresses is delayed until send(). + * Addresses that have been added already return false, but do not throw exceptions. + * + * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' + * @param string $address The email address + * @param string $name An optional username associated with the address + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + protected function addOrEnqueueAnAddress($kind, $address, $name) + { + $pos = false; + if ($address !== null) { + $address = trim($address); + $pos = strrpos($address, '@'); + } + if (false === $pos) { + //At-sign is missing. + $error_message = sprintf( + '%s (%s): %s', + $this->lang('invalid_address'), + $kind, + $address + ); + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new Exception($error_message); + } + + return false; + } + if ($name !== null && is_string($name)) { + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + } else { + $name = ''; + } + $params = [$kind, $address, $name]; + //Enqueue addresses with IDN until we know the PHPMailer::$CharSet. + //Domain is assumed to be whatever is after the last @ symbol in the address + if (static::idnSupported() && $this->has8bitChars(substr($address, ++$pos))) { + if ('Reply-To' !== $kind) { + if (!array_key_exists($address, $this->RecipientsQueue)) { + $this->RecipientsQueue[$address] = $params; + + return true; + } + } elseif (!array_key_exists($address, $this->ReplyToQueue)) { + $this->ReplyToQueue[$address] = $params; + + return true; + } + + return false; + } + + //Immediately add standard addresses without IDN. + return call_user_func_array([$this, 'addAnAddress'], $params); + } + + /** + * Set the boundaries to use for delimiting MIME parts. + * If you override this, ensure you set all 3 boundaries to unique values. + * The default boundaries include a "=_" sequence which cannot occur in quoted-printable bodies, + * as suggested by https://www.rfc-editor.org/rfc/rfc2045#section-6.7 + * + * @return void + */ + public function setBoundaries() + { + $this->uniqueid = $this->generateId(); + $this->boundary[1] = 'b1=_' . $this->uniqueid; + $this->boundary[2] = 'b2=_' . $this->uniqueid; + $this->boundary[3] = 'b3=_' . $this->uniqueid; + } + + /** + * Add an address to one of the recipient arrays or to the ReplyTo array. + * Addresses that have been added already return false, but do not throw exceptions. + * + * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' + * @param string $address The email address to send, resp. to reply to + * @param string $name + * + * @throws Exception + * + * @return bool true on success, false if address already used or invalid in some way + */ + protected function addAnAddress($kind, $address, $name = '') + { + if (!in_array($kind, ['to', 'cc', 'bcc', 'Reply-To'])) { + $error_message = sprintf( + '%s: %s', + $this->lang('Invalid recipient kind'), + $kind + ); + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new Exception($error_message); + } + + return false; + } + if (!static::validateAddress($address)) { + $error_message = sprintf( + '%s (%s): %s', + $this->lang('invalid_address'), + $kind, + $address + ); + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new Exception($error_message); + } + + return false; + } + if ('Reply-To' !== $kind) { + if (!array_key_exists(strtolower($address), $this->all_recipients)) { + $this->{$kind}[] = [$address, $name]; + $this->all_recipients[strtolower($address)] = true; + + return true; + } + } elseif (!array_key_exists(strtolower($address), $this->ReplyTo)) { + $this->ReplyTo[strtolower($address)] = [$address, $name]; + + return true; + } + + return false; + } + + /** + * Parse and validate a string containing one or more RFC822-style comma-separated email addresses + * of the form "display name
" into an array of name/address pairs. + * Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. + * Note that quotes in the name part are removed. + * + * @see http://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation + * + * @param string $addrstr The address list string + * @param bool $useimap Whether to use the IMAP extension to parse the list + * @param string $charset The charset to use when decoding the address list string. + * + * @return array + */ + public static function parseAddresses($addrstr, $useimap = true, $charset = self::CHARSET_ISO88591) + { + $addresses = []; + if ($useimap && function_exists('imap_rfc822_parse_adrlist')) { + //Use this built-in parser if it's available + $list = imap_rfc822_parse_adrlist($addrstr, ''); + // Clear any potential IMAP errors to get rid of notices being thrown at end of script. + imap_errors(); + foreach ($list as $address) { + if ( + '.SYNTAX-ERROR.' !== $address->host && + static::validateAddress($address->mailbox . '@' . $address->host) + ) { + //Decode the name part if it's present and encoded + if ( + property_exists($address, 'personal') && + //Check for a Mbstring constant rather than using extension_loaded, which is sometimes disabled + defined('MB_CASE_UPPER') && + preg_match('/^=\?.*\?=$/s', $address->personal) + ) { + $origCharset = mb_internal_encoding(); + mb_internal_encoding($charset); + //Undo any RFC2047-encoded spaces-as-underscores + $address->personal = str_replace('_', '=20', $address->personal); + //Decode the name + $address->personal = mb_decode_mimeheader($address->personal); + mb_internal_encoding($origCharset); + } + + $addresses[] = [ + 'name' => (property_exists($address, 'personal') ? $address->personal : ''), + 'address' => $address->mailbox . '@' . $address->host, + ]; + } + } + } else { + //Use this simpler parser + $list = explode(',', $addrstr); + foreach ($list as $address) { + $address = trim($address); + //Is there a separate name part? + if (strpos($address, '<') === false) { + //No separate name, just use the whole thing + if (static::validateAddress($address)) { + $addresses[] = [ + 'name' => '', + 'address' => $address, + ]; + } + } else { + list($name, $email) = explode('<', $address); + $email = trim(str_replace('>', '', $email)); + $name = trim($name); + if (static::validateAddress($email)) { + //Check for a Mbstring constant rather than using extension_loaded, which is sometimes disabled + //If this name is encoded, decode it + if (defined('MB_CASE_UPPER') && preg_match('/^=\?.*\?=$/s', $name)) { + $origCharset = mb_internal_encoding(); + mb_internal_encoding($charset); + //Undo any RFC2047-encoded spaces-as-underscores + $name = str_replace('_', '=20', $name); + //Decode the name + $name = mb_decode_mimeheader($name); + mb_internal_encoding($origCharset); + } + $addresses[] = [ + //Remove any surrounding quotes and spaces from the name + 'name' => trim($name, '\'" '), + 'address' => $email, + ]; + } + } + } + } + + return $addresses; + } + + /** + * Set the From and FromName properties. + * + * @param string $address + * @param string $name + * @param bool $auto Whether to also set the Sender address, defaults to true + * + * @throws Exception + * + * @return bool + */ + public function setFrom($address, $name = '', $auto = true) + { + $address = trim((string)$address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + //Don't validate now addresses with IDN. Will be done in send(). + $pos = strrpos($address, '@'); + if ( + (false === $pos) + || ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported()) + && !static::validateAddress($address)) + ) { + $error_message = sprintf( + '%s (From): %s', + $this->lang('invalid_address'), + $address + ); + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new Exception($error_message); + } + + return false; + } + $this->From = $address; + $this->FromName = $name; + if ($auto && empty($this->Sender)) { + $this->Sender = $address; + } + + return true; + } + + /** + * Return the Message-ID header of the last email. + * Technically this is the value from the last time the headers were created, + * but it's also the message ID of the last sent message except in + * pathological cases. + * + * @return string + */ + public function getLastMessageID() + { + return $this->lastMessageID; + } + + /** + * Check that a string looks like an email address. + * Validation patterns supported: + * * `auto` Pick best pattern automatically; + * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0; + * * `pcre` Use old PCRE implementation; + * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; + * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. + * * `noregex` Don't use a regex: super fast, really dumb. + * Alternatively you may pass in a callable to inject your own validator, for example: + * + * ```php + * PHPMailer::validateAddress('user@example.com', function($address) { + * return (strpos($address, '@') !== false); + * }); + * ``` + * + * You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator. + * + * @param string $address The email address to check + * @param string|callable $patternselect Which pattern to use + * + * @return bool + */ + public static function validateAddress($address, $patternselect = null) + { + if (null === $patternselect) { + $patternselect = static::$validator; + } + //Don't allow strings as callables, see SECURITY.md and CVE-2021-3603 + if (is_callable($patternselect) && !is_string($patternselect)) { + return call_user_func($patternselect, $address); + } + //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321 + if (strpos($address, "\n") !== false || strpos($address, "\r") !== false) { + return false; + } + switch ($patternselect) { + case 'pcre': //Kept for BC + case 'pcre8': + /* + * A more complex and more permissive version of the RFC5322 regex on which FILTER_VALIDATE_EMAIL + * is based. + * In addition to the addresses allowed by filter_var, also permits: + * * dotless domains: `a@b` + * * comments: `1234 @ local(blah) .machine .example` + * * quoted elements: `'"test blah"@example.org'` + * * numeric TLDs: `a@b.123` + * * unbracketed IPv4 literals: `a@192.168.0.1` + * * IPv6 literals: 'first.last@[IPv6:a1::]' + * Not all of these will necessarily work for sending! + * + * @see http://squiloople.com/2009/12/20/email-address-validation/ + * @copyright 2009-2010 Michael Rushton + * Feel free to use and redistribute this code. But please keep this copyright notice. + */ + return (bool) preg_match( + '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . + '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . + '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . + '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . + '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . + '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . + '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . + '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . + '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', + $address + ); + case 'html5': + /* + * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements. + * + * @see https://html.spec.whatwg.org/#e-mail-state-(type=email) + */ + return (bool) preg_match( + '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . + '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', + $address + ); + case 'php': + default: + return filter_var($address, FILTER_VALIDATE_EMAIL) !== false; + } + } + + /** + * Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the + * `intl` and `mbstring` PHP extensions. + * + * @return bool `true` if required functions for IDN support are present + */ + public static function idnSupported() + { + return function_exists('idn_to_ascii') && function_exists('mb_convert_encoding'); + } + + /** + * Converts IDN in given email address to its ASCII form, also known as punycode, if possible. + * Important: Address must be passed in same encoding as currently set in PHPMailer::$CharSet. + * This function silently returns unmodified address if: + * - No conversion is necessary (i.e. domain name is not an IDN, or is already in ASCII form) + * - Conversion to punycode is impossible (e.g. required PHP functions are not available) + * or fails for any reason (e.g. domain contains characters not allowed in an IDN). + * + * @see PHPMailer::$CharSet + * + * @param string $address The email address to convert + * + * @return string The encoded address in ASCII form + */ + public function punyencodeAddress($address) + { + //Verify we have required functions, CharSet, and at-sign. + $pos = strrpos($address, '@'); + if ( + !empty($this->CharSet) && + false !== $pos && + static::idnSupported() + ) { + $domain = substr($address, ++$pos); + //Verify CharSet string is a valid one, and domain properly encoded in this CharSet. + if ($this->has8bitChars($domain) && @mb_check_encoding($domain, $this->CharSet)) { + //Convert the domain from whatever charset it's in to UTF-8 + $domain = mb_convert_encoding($domain, self::CHARSET_UTF8, $this->CharSet); + //Ignore IDE complaints about this line - method signature changed in PHP 5.4 + $errorcode = 0; + if (defined('INTL_IDNA_VARIANT_UTS46')) { + //Use the current punycode standard (appeared in PHP 7.2) + $punycode = idn_to_ascii( + $domain, + \IDNA_DEFAULT | \IDNA_USE_STD3_RULES | \IDNA_CHECK_BIDI | + \IDNA_CHECK_CONTEXTJ | \IDNA_NONTRANSITIONAL_TO_ASCII, + \INTL_IDNA_VARIANT_UTS46 + ); + } elseif (defined('INTL_IDNA_VARIANT_2003')) { + //Fall back to this old, deprecated/removed encoding + $punycode = idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_2003); + } else { + //Fall back to a default we don't know about + $punycode = idn_to_ascii($domain, $errorcode); + } + if (false !== $punycode) { + return substr($address, 0, $pos) . $punycode; + } + } + } + + return $address; + } + + /** + * Create a message and send it. + * Uses the sending method specified by $Mailer. + * + * @throws Exception + * + * @return bool false on error - See the ErrorInfo property for details of the error + */ + public function send() + { + try { + if (!$this->preSend()) { + return false; + } + + return $this->postSend(); + } catch (Exception $exc) { + $this->mailHeader = ''; + $this->setError($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + + return false; + } + } + + /** + * Prepare a message for sending. + * + * @throws Exception + * + * @return bool + */ + public function preSend() + { + if ( + 'smtp' === $this->Mailer + || ('mail' === $this->Mailer && (\PHP_VERSION_ID >= 80000 || stripos(PHP_OS, 'WIN') === 0)) + ) { + //SMTP mandates RFC-compliant line endings + //and it's also used with mail() on Windows + static::setLE(self::CRLF); + } else { + //Maintain backward compatibility with legacy Linux command line mailers + static::setLE(PHP_EOL); + } + //Check for buggy PHP versions that add a header with an incorrect line break + if ( + 'mail' === $this->Mailer + && ((\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70017) + || (\PHP_VERSION_ID >= 70100 && \PHP_VERSION_ID < 70103)) + && ini_get('mail.add_x_header') === '1' + && stripos(PHP_OS, 'WIN') === 0 + ) { + trigger_error($this->lang('buggy_php'), E_USER_WARNING); + } + + try { + $this->error_count = 0; //Reset errors + $this->mailHeader = ''; + + //Dequeue recipient and Reply-To addresses with IDN + foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) { + $params[1] = $this->punyencodeAddress($params[1]); + call_user_func_array([$this, 'addAnAddress'], $params); + } + if (count($this->to) + count($this->cc) + count($this->bcc) < 1) { + throw new Exception($this->lang('provide_address'), self::STOP_CRITICAL); + } + + //Validate From, Sender, and ConfirmReadingTo addresses + foreach (['From', 'Sender', 'ConfirmReadingTo'] as $address_kind) { + $this->{$address_kind} = trim($this->{$address_kind}); + if (empty($this->{$address_kind})) { + continue; + } + $this->{$address_kind} = $this->punyencodeAddress($this->{$address_kind}); + if (!static::validateAddress($this->{$address_kind})) { + $error_message = sprintf( + '%s (%s): %s', + $this->lang('invalid_address'), + $address_kind, + $this->{$address_kind} + ); + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new Exception($error_message); + } + + return false; + } + } + + //Set whether the message is multipart/alternative + if ($this->alternativeExists()) { + $this->ContentType = static::CONTENT_TYPE_MULTIPART_ALTERNATIVE; + } + + $this->setMessageType(); + //Refuse to send an empty message unless we are specifically allowing it + if (!$this->AllowEmpty && empty($this->Body)) { + throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL); + } + + //Trim subject consistently + $this->Subject = trim($this->Subject); + //Create body before headers in case body makes changes to headers (e.g. altering transfer encoding) + $this->MIMEHeader = ''; + $this->MIMEBody = $this->createBody(); + //createBody may have added some headers, so retain them + $tempheaders = $this->MIMEHeader; + $this->MIMEHeader = $this->createHeader(); + $this->MIMEHeader .= $tempheaders; + + //To capture the complete message when using mail(), create + //an extra header list which createHeader() doesn't fold in + if ('mail' === $this->Mailer) { + if (count($this->to) > 0) { + $this->mailHeader .= $this->addrAppend('To', $this->to); + } else { + $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;'); + } + $this->mailHeader .= $this->headerLine( + 'Subject', + $this->encodeHeader($this->secureHeader($this->Subject)) + ); + } + + //Sign with DKIM if enabled + if ( + !empty($this->DKIM_domain) + && !empty($this->DKIM_selector) + && (!empty($this->DKIM_private_string) + || (!empty($this->DKIM_private) + && static::isPermittedPath($this->DKIM_private) + && file_exists($this->DKIM_private) + ) + ) + ) { + $header_dkim = $this->DKIM_Add( + $this->MIMEHeader . $this->mailHeader, + $this->encodeHeader($this->secureHeader($this->Subject)), + $this->MIMEBody + ); + $this->MIMEHeader = static::stripTrailingWSP($this->MIMEHeader) . static::$LE . + static::normalizeBreaks($header_dkim) . static::$LE; + } + + return true; + } catch (Exception $exc) { + $this->setError($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + + return false; + } + } + + /** + * Actually send a message via the selected mechanism. + * + * @throws Exception + * + * @return bool + */ + public function postSend() + { + try { + //Choose the mailer and send through it + switch ($this->Mailer) { + case 'sendmail': + case 'qmail': + return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody); + case 'smtp': + return $this->smtpSend($this->MIMEHeader, $this->MIMEBody); + case 'mail': + return $this->mailSend($this->MIMEHeader, $this->MIMEBody); + default: + $sendMethod = $this->Mailer . 'Send'; + if (method_exists($this, $sendMethod)) { + return $this->{$sendMethod}($this->MIMEHeader, $this->MIMEBody); + } + + return $this->mailSend($this->MIMEHeader, $this->MIMEBody); + } + } catch (Exception $exc) { + $this->setError($exc->getMessage()); + $this->edebug($exc->getMessage()); + if ($this->Mailer === 'smtp' && $this->SMTPKeepAlive == true && $this->smtp->connected()) { + $this->smtp->reset(); + } + if ($this->exceptions) { + throw $exc; + } + } + + return false; + } + + /** + * Send mail using the $Sendmail program. + * + * @see PHPMailer::$Sendmail + * + * @param string $header The message headers + * @param string $body The message body + * + * @throws Exception + * + * @return bool + */ + protected function sendmailSend($header, $body) + { + if ($this->Mailer === 'qmail') { + $this->edebug('Sending with qmail'); + } else { + $this->edebug('Sending with sendmail'); + } + $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; + //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver + //A space after `-f` is optional, but there is a long history of its presence + //causing problems, so we don't use one + //Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html + //Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html + //Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html + //Example problem: https://www.drupal.org/node/1057954 + + //PHP 5.6 workaround + $sendmail_from_value = ini_get('sendmail_from'); + if (empty($this->Sender) && !empty($sendmail_from_value)) { + //PHP config has a sender address we can use + $this->Sender = ini_get('sendmail_from'); + } + //CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. + if (!empty($this->Sender) && static::validateAddress($this->Sender) && self::isShellSafe($this->Sender)) { + if ($this->Mailer === 'qmail') { + $sendmailFmt = '%s -f%s'; + } else { + $sendmailFmt = '%s -oi -f%s -t'; + } + } else { + //allow sendmail to choose a default envelope sender. It may + //seem preferable to force it to use the From header as with + //SMTP, but that introduces new problems (see + //), and + //it has historically worked this way. + $sendmailFmt = '%s -oi -t'; + } + + $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender); + $this->edebug('Sendmail path: ' . $this->Sendmail); + $this->edebug('Sendmail command: ' . $sendmail); + $this->edebug('Envelope sender: ' . $this->Sender); + $this->edebug("Headers: {$header}"); + + if ($this->SingleTo) { + foreach ($this->SingleToArray as $toAddr) { + $mail = @popen($sendmail, 'w'); + if (!$mail) { + throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + $this->edebug("To: {$toAddr}"); + fwrite($mail, 'To: ' . $toAddr . "\n"); + fwrite($mail, $header); + fwrite($mail, $body); + $result = pclose($mail); + $addrinfo = static::parseAddresses($toAddr, true, $this->CharSet); + $this->doCallback( + ($result === 0), + [[$addrinfo['address'], $addrinfo['name']]], + $this->cc, + $this->bcc, + $this->Subject, + $body, + $this->From, + [] + ); + $this->edebug("Result: " . ($result === 0 ? 'true' : 'false')); + if (0 !== $result) { + throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + } else { + $mail = @popen($sendmail, 'w'); + if (!$mail) { + throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + fwrite($mail, $header); + fwrite($mail, $body); + $result = pclose($mail); + $this->doCallback( + ($result === 0), + $this->to, + $this->cc, + $this->bcc, + $this->Subject, + $body, + $this->From, + [] + ); + $this->edebug("Result: " . ($result === 0 ? 'true' : 'false')); + if (0 !== $result) { + throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + + return true; + } + + /** + * Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters. + * Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows. + * + * @see https://github.com/PHPMailer/PHPMailer/issues/924 CVE-2016-10045 bug report + * + * @param string $string The string to be validated + * + * @return bool + */ + protected static function isShellSafe($string) + { + //It's not possible to use shell commands safely (which includes the mail() function) without escapeshellarg, + //but some hosting providers disable it, creating a security problem that we don't want to have to deal with, + //so we don't. + if (!function_exists('escapeshellarg') || !function_exists('escapeshellcmd')) { + return false; + } + + if ( + escapeshellcmd($string) !== $string + || !in_array(escapeshellarg($string), ["'$string'", "\"$string\""]) + ) { + return false; + } + + $length = strlen($string); + + for ($i = 0; $i < $length; ++$i) { + $c = $string[$i]; + + //All other characters have a special meaning in at least one common shell, including = and +. + //Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here. + //Note that this does permit non-Latin alphanumeric characters based on the current locale. + if (!ctype_alnum($c) && strpos('@_-.', $c) === false) { + return false; + } + } + + return true; + } + + /** + * Check whether a file path is of a permitted type. + * Used to reject URLs and phar files from functions that access local file paths, + * such as addAttachment. + * + * @param string $path A relative or absolute path to a file + * + * @return bool + */ + protected static function isPermittedPath($path) + { + //Matches scheme definition from https://tools.ietf.org/html/rfc3986#section-3.1 + return !preg_match('#^[a-z][a-z\d+.-]*://#i', $path); + } + + /** + * Check whether a file path is safe, accessible, and readable. + * + * @param string $path A relative or absolute path to a file + * + * @return bool + */ + protected static function fileIsAccessible($path) + { + if (!static::isPermittedPath($path)) { + return false; + } + $readable = is_file($path); + //If not a UNC path (expected to start with \\), check read permission, see #2069 + if (strpos($path, '\\\\') !== 0) { + $readable = $readable && is_readable($path); + } + return $readable; + } + + /** + * Send mail using the PHP mail() function. + * + * @see http://www.php.net/manual/en/book.mail.php + * + * @param string $header The message headers + * @param string $body The message body + * + * @throws Exception + * + * @return bool + */ + protected function mailSend($header, $body) + { + $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; + + $toArr = []; + foreach ($this->to as $toaddr) { + $toArr[] = $this->addrFormat($toaddr); + } + $to = trim(implode(', ', $toArr)); + + //If there are no To-addresses (e.g. when sending only to BCC-addresses) + //the following should be added to get a correct DKIM-signature. + //Compare with $this->preSend() + if ($to === '') { + $to = 'undisclosed-recipients:;'; + } + + $params = null; + //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver + //A space after `-f` is optional, but there is a long history of its presence + //causing problems, so we don't use one + //Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html + //Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html + //Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html + //Example problem: https://www.drupal.org/node/1057954 + //CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. + + //PHP 5.6 workaround + $sendmail_from_value = ini_get('sendmail_from'); + if (empty($this->Sender) && !empty($sendmail_from_value)) { + //PHP config has a sender address we can use + $this->Sender = ini_get('sendmail_from'); + } + if (!empty($this->Sender) && static::validateAddress($this->Sender)) { + if (self::isShellSafe($this->Sender)) { + $params = sprintf('-f%s', $this->Sender); + } + $old_from = ini_get('sendmail_from'); + ini_set('sendmail_from', $this->Sender); + } + $result = false; + if ($this->SingleTo && count($toArr) > 1) { + foreach ($toArr as $toAddr) { + $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); + $addrinfo = static::parseAddresses($toAddr, true, $this->CharSet); + $this->doCallback( + $result, + [[$addrinfo['address'], $addrinfo['name']]], + $this->cc, + $this->bcc, + $this->Subject, + $body, + $this->From, + [] + ); + } + } else { + $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params); + $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, []); + } + if (isset($old_from)) { + ini_set('sendmail_from', $old_from); + } + if (!$result) { + throw new Exception($this->lang('instantiate'), self::STOP_CRITICAL); + } + + return true; + } + + /** + * Get an instance to use for SMTP operations. + * Override this function to load your own SMTP implementation, + * or set one with setSMTPInstance. + * + * @return SMTP + */ + public function getSMTPInstance() + { + if (!is_object($this->smtp)) { + $this->smtp = new SMTP(); + } + + return $this->smtp; + } + + /** + * Provide an instance to use for SMTP operations. + * + * @return SMTP + */ + public function setSMTPInstance(SMTP $smtp) + { + $this->smtp = $smtp; + + return $this->smtp; + } + + /** + * Send mail via SMTP. + * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. + * + * @see PHPMailer::setSMTPInstance() to use a different class. + * + * @uses \PHPMailer\PHPMailer\SMTP + * + * @param string $header The message headers + * @param string $body The message body + * + * @throws Exception + * + * @return bool + */ + protected function smtpSend($header, $body) + { + $header = static::stripTrailingWSP($header) . static::$LE . static::$LE; + $bad_rcpt = []; + if (!$this->smtpConnect($this->SMTPOptions)) { + throw new Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); + } + //Sender already validated in preSend() + if ('' === $this->Sender) { + $smtp_from = $this->From; + } else { + $smtp_from = $this->Sender; + } + if (!$this->smtp->mail($smtp_from)) { + $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); + throw new Exception($this->ErrorInfo, self::STOP_CRITICAL); + } + + $callbacks = []; + //Attempt to send to all recipients + foreach ([$this->to, $this->cc, $this->bcc] as $togroup) { + foreach ($togroup as $to) { + if (!$this->smtp->recipient($to[0], $this->dsn)) { + $error = $this->smtp->getError(); + $bad_rcpt[] = ['to' => $to[0], 'error' => $error['detail']]; + $isSent = false; + } else { + $isSent = true; + } + + $callbacks[] = ['issent' => $isSent, 'to' => $to[0], 'name' => $to[1]]; + } + } + + //Only send the DATA command if we have viable recipients + if ((count($this->all_recipients) > count($bad_rcpt)) && !$this->smtp->data($header . $body)) { + throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL); + } + + $smtp_transaction_id = $this->smtp->getLastTransactionID(); + + if ($this->SMTPKeepAlive) { + $this->smtp->reset(); + } else { + $this->smtp->quit(); + $this->smtp->close(); + } + + foreach ($callbacks as $cb) { + $this->doCallback( + $cb['issent'], + [[$cb['to'], $cb['name']]], + [], + [], + $this->Subject, + $body, + $this->From, + ['smtp_transaction_id' => $smtp_transaction_id] + ); + } + + //Create error message for any bad addresses + if (count($bad_rcpt) > 0) { + $errstr = ''; + foreach ($bad_rcpt as $bad) { + $errstr .= $bad['to'] . ': ' . $bad['error']; + } + throw new Exception($this->lang('recipients_failed') . $errstr, self::STOP_CONTINUE); + } + + return true; + } + + /** + * Initiate a connection to an SMTP server. + * Returns false if the operation failed. + * + * @param array $options An array of options compatible with stream_context_create() + * + * @throws Exception + * + * @uses \PHPMailer\PHPMailer\SMTP + * + * @return bool + */ + public function smtpConnect($options = null) + { + if (null === $this->smtp) { + $this->smtp = $this->getSMTPInstance(); + } + + //If no options are provided, use whatever is set in the instance + if (null === $options) { + $options = $this->SMTPOptions; + } + + //Already connected? + if ($this->smtp->connected()) { + return true; + } + + $this->smtp->setTimeout($this->Timeout); + $this->smtp->setDebugLevel($this->SMTPDebug); + $this->smtp->setDebugOutput($this->Debugoutput); + $this->smtp->setVerp($this->do_verp); + if ($this->Host === null) { + $this->Host = 'localhost'; + } + $hosts = explode(';', $this->Host); + $lastexception = null; + + foreach ($hosts as $hostentry) { + $hostinfo = []; + if ( + !preg_match( + '/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/', + trim($hostentry), + $hostinfo + ) + ) { + $this->edebug($this->lang('invalid_hostentry') . ' ' . trim($hostentry)); + //Not a valid host entry + continue; + } + //$hostinfo[1]: optional ssl or tls prefix + //$hostinfo[2]: the hostname + //$hostinfo[3]: optional port number + //The host string prefix can temporarily override the current setting for SMTPSecure + //If it's not specified, the default value is used + + //Check the host name is a valid name or IP address before trying to use it + if (!static::isValidHost($hostinfo[2])) { + $this->edebug($this->lang('invalid_host') . ' ' . $hostinfo[2]); + continue; + } + $prefix = ''; + $secure = $this->SMTPSecure; + $tls = (static::ENCRYPTION_STARTTLS === $this->SMTPSecure); + if ('ssl' === $hostinfo[1] || ('' === $hostinfo[1] && static::ENCRYPTION_SMTPS === $this->SMTPSecure)) { + $prefix = 'ssl://'; + $tls = false; //Can't have SSL and TLS at the same time + $secure = static::ENCRYPTION_SMTPS; + } elseif ('tls' === $hostinfo[1]) { + $tls = true; + //TLS doesn't use a prefix + $secure = static::ENCRYPTION_STARTTLS; + } + //Do we need the OpenSSL extension? + $sslext = defined('OPENSSL_ALGO_SHA256'); + if (static::ENCRYPTION_STARTTLS === $secure || static::ENCRYPTION_SMTPS === $secure) { + //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled + if (!$sslext) { + throw new Exception($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL); + } + } + $host = $hostinfo[2]; + $port = $this->Port; + if ( + array_key_exists(3, $hostinfo) && + is_numeric($hostinfo[3]) && + $hostinfo[3] > 0 && + $hostinfo[3] < 65536 + ) { + $port = (int) $hostinfo[3]; + } + if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { + try { + if ($this->Helo) { + $hello = $this->Helo; + } else { + $hello = $this->serverHostname(); + } + $this->smtp->hello($hello); + //Automatically enable TLS encryption if: + //* it's not disabled + //* we have openssl extension + //* we are not already using SSL + //* the server offers STARTTLS + if ($this->SMTPAutoTLS && $sslext && 'ssl' !== $secure && $this->smtp->getServerExt('STARTTLS')) { + $tls = true; + } + if ($tls) { + if (!$this->smtp->startTLS()) { + $message = $this->getSmtpErrorMessage('connect_host'); + throw new Exception($message); + } + //We must resend EHLO after TLS negotiation + $this->smtp->hello($hello); + } + if ( + $this->SMTPAuth && !$this->smtp->authenticate( + $this->Username, + $this->Password, + $this->AuthType, + $this->oauth + ) + ) { + throw new Exception($this->lang('authenticate')); + } + + return true; + } catch (Exception $exc) { + $lastexception = $exc; + $this->edebug($exc->getMessage()); + //We must have connected, but then failed TLS or Auth, so close connection nicely + $this->smtp->quit(); + } + } + } + //If we get here, all connection attempts have failed, so close connection hard + $this->smtp->close(); + //As we've caught all exceptions, just report whatever the last one was + if ($this->exceptions && null !== $lastexception) { + throw $lastexception; + } + if ($this->exceptions) { + // no exception was thrown, likely $this->smtp->connect() failed + $message = $this->getSmtpErrorMessage('connect_host'); + throw new Exception($message); + } + + return false; + } + + /** + * Close the active SMTP session if one exists. + */ + public function smtpClose() + { + if ((null !== $this->smtp) && $this->smtp->connected()) { + $this->smtp->quit(); + $this->smtp->close(); + } + } + + /** + * Set the language for error messages. + * The default language is English. + * + * @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr") + * Optionally, the language code can be enhanced with a 4-character + * script annotation and/or a 2-character country annotation. + * @param string $lang_path Path to the language file directory, with trailing separator (slash) + * Do not set this from user input! + * + * @return bool Returns true if the requested language was loaded, false otherwise. + */ + public function setLanguage($langcode = 'en', $lang_path = '') + { + //Backwards compatibility for renamed language codes + $renamed_langcodes = [ + 'br' => 'pt_br', + 'cz' => 'cs', + 'dk' => 'da', + 'no' => 'nb', + 'se' => 'sv', + 'rs' => 'sr', + 'tg' => 'tl', + 'am' => 'hy', + ]; + + if (array_key_exists($langcode, $renamed_langcodes)) { + $langcode = $renamed_langcodes[$langcode]; + } + + //Define full set of translatable strings in English + $PHPMAILER_LANG = [ + 'authenticate' => 'SMTP Error: Could not authenticate.', + 'buggy_php' => 'Your version of PHP is affected by a bug that may result in corrupted messages.' . + ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in' . + ' your php.ini, switch to MacOS or Linux, or upgrade your PHP to version 7.0.17+ or 7.1.3+.', + 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', + 'data_not_accepted' => 'SMTP Error: data not accepted.', + 'empty_message' => 'Message body empty', + 'encoding' => 'Unknown encoding: ', + 'execute' => 'Could not execute: ', + 'extension_missing' => 'Extension missing: ', + 'file_access' => 'Could not access file: ', + 'file_open' => 'File Error: Could not open file: ', + 'from_failed' => 'The following From address failed: ', + 'instantiate' => 'Could not instantiate mail function.', + 'invalid_address' => 'Invalid address: ', + 'invalid_header' => 'Invalid header name or value', + 'invalid_hostentry' => 'Invalid hostentry: ', + 'invalid_host' => 'Invalid host: ', + 'mailer_not_supported' => ' mailer is not supported.', + 'provide_address' => 'You must provide at least one recipient email address.', + 'recipients_failed' => 'SMTP Error: The following recipients failed: ', + 'signing' => 'Signing Error: ', + 'smtp_code' => 'SMTP code: ', + 'smtp_code_ex' => 'Additional SMTP info: ', + 'smtp_connect_failed' => 'SMTP connect() failed.', + 'smtp_detail' => 'Detail: ', + 'smtp_error' => 'SMTP server error: ', + 'variable_set' => 'Cannot set or reset variable: ', + ]; + if (empty($lang_path)) { + //Calculate an absolute path so it can work if CWD is not here + $lang_path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR; + } + + //Validate $langcode + $foundlang = true; + $langcode = strtolower($langcode); + if ( + !preg_match('/^(?P[a-z]{2})(?P'; - $import = new cHTMLRadiobutton("mode", "import"); $export = new cHTMLRadiobutton("mode", "export"); $export->setLabelText(i18n("Export to file")); @@ -189,15 +174,14 @@ $form2->setVar("idmod", $idmod); $form2->setVar("idmodtranslation", $idmodtranslation); $form2->custom["submit"]["accesskey"] = ''; -$page->setContent($form->render(). $mark ."
". $form2->render()); +$page->setContent($form->render() . $mark . "
" . $form2->render()); $page->setMarkScript(2); $clang = new cApiLanguage($lang); $page->setEncoding($clang->get("encoding")); -if (!($action == "mod_importexport_translation" && $mode == "export")) -{ - $page->render(); +if (!($action == "mod_importexport_translation" && $mode == "export")) { + $page->render(); } ?> \ No newline at end of file diff --git a/conlite/includes/include.mod_translate_stringlist.php b/conlite/includes/include.mod_translate_stringlist.php index d11653c..ab03558 100644 --- a/conlite/includes/include.mod_translate_stringlist.php +++ b/conlite/includes/include.mod_translate_stringlist.php @@ -1,4 +1,5 @@ select("idmod = '$idmod' AND idlang='$lang'"); $page = new cPage; +$page->setHtml5(); +$page->setEncoding('UTF-8'); $page->setMargin(0); $v = ''; @@ -46,32 +48,35 @@ $link->setCLink("mod_translate", 4, ""); $mylink = new cHTMLLink; -while ($translation = $translations->next()) -{ - $string = $translation->get("original"); - $tstring = $translation->get("translation"); - +while ($translation = $translations->next()) { + + $string = utf8_encode($translation->get("original")); + $tstring = utf8_encode($translation->get("translation")); + $link->setCustom("idmod", $idmod); $link->setCustom("idmodtranslation", $translation->get("idmodtranslation")); $href = $link->getHREF(); - - $mylink->setLink('javascript:parent.location="'.$href.'"'); + + $mylink->setLink('javascript:parent.location="' . $href . '"'); $mylink->setContent($string); - $dark = !$dark; + $dark = !$dark; - if ($dark) - { - $bgcol = $cfg["color"]["table_dark"]; - } else { - $bgcol = $cfg["color"]["table_light"]; - } + if ($dark) { + $bgcol = $cfg["color"]["table_dark"]; + } else { + $bgcol = $cfg["color"]["table_light"]; + } - if ($idmodtranslation == $translation->get("idmodtranslation")) - { - $bgcol = $cfg["color"]["table_active"]; - } - $v .= ''; + if ($idmodtranslation == $translation->get("idmodtranslation")) { + $bgcol = $cfg["color"]["table_active"]; + } + $v .= ''."\n" + . ''."\n" + . ''."\n" + . ''."\n"; } $v .= '
'.$mylink->render().''.$tstring.'
'."\n" + . ''."\n" + . $mylink->render() . '' . $tstring . '
'; @@ -82,5 +87,4 @@ $clang = new cApiLanguage($lang); $page->setEncoding($clang->get("encoding")); $page->render(); - ?> \ No newline at end of file diff --git a/conlite/includes/include.pretplcfg_edit_form.php b/conlite/includes/include.pretplcfg_edit_form.php index 8cc4e41..17fbf4c 100644 --- a/conlite/includes/include.pretplcfg_edit_form.php +++ b/conlite/includes/include.pretplcfg_edit_form.php @@ -50,8 +50,8 @@ $formaction = $sess->url("main.php"); # $hidden = ' - - + + @@ -154,7 +154,5 @@ $buttons = ''; $tpl->set('s', 'BUTTONS', $buttons); - # Generate template -$tpl->generate($cfg['path']['templates'] . $cfg['templates']['tplcfg_edit_form']); -?> \ No newline at end of file +$tpl->generate($cfg['path']['templates'] . $cfg['templates']['tplcfg_edit_form']); \ No newline at end of file diff --git a/conlite/includes/include.str_overview.php b/conlite/includes/include.str_overview.php index 3563da8..1a4631b 100644 --- a/conlite/includes/include.str_overview.php +++ b/conlite/includes/include.str_overview.php @@ -233,101 +233,6 @@ if (!isset($idcat)) $idcat = 0; if (!isset($action)) $action = 0; -/* -function buildTree(&$rootItem, &$items) { - global $nextItem, $perm, $tmp_area; - - while ($item_list = each($items)) { - list($key, $item) = $item_list; - - unset($newItem); - - $bCheck = false; - if (!$bCheck) { - $bCheck = $perm->have_perm_area_action($tmp_area, "str_newtree"); - } - if (!$bCheck) { - $bCheck = $perm->have_perm_area_action($tmp_area, "str_newcat"); - } - if (!$bCheck) { - $bCheck = $perm->have_perm_area_action($tmp_area, "str_makevisible"); - } - if (!$bCheck) { - $bCheck = $perm->have_perm_area_action($tmp_area, "str_makepublic"); - } - if (!$bCheck) { - $bCheck = $perm->have_perm_area_action($tmp_area, "str_deletecat"); - } - if (!$bCheck) { - $bCheck = $perm->have_perm_area_action($tmp_area, "str_moveupcat"); - } - if (!$bCheck) { - $bCheck = $perm->have_perm_area_action($tmp_area, "str_movedowncat"); - } - if (!$bCheck) { - $bCheck = $perm->have_perm_area_action($tmp_area, "str_movesubtree"); - } - if (!$bCheck) { - $bCheck = $perm->have_perm_area_action($tmp_area, "str_renamecat"); - } - if (!$bCheck) { - $bCheck = $perm->have_perm_area_action("str_tplcfg", "str_tplcfg"); - } - if (!$bCheck) { - $bCheck = $perm->have_perm_item($tmp_area, $item['idcat']); - } - - if ($bCheck) { - $newItem = new TreeItem($item['name'], $item['idcat'], true); - } else { - $newItem = new TreeItem($item['name'], $item['idcat'], false); - } - - $newItem->collapsed_icon = 'images/open_all.gif'; - $newItem->expanded_icon = 'images/close_all.gif'; - $newItem->custom['idtree'] = $item['idtree']; - $newItem->custom['level'] = $item['level']; - $newItem->custom['idcat'] = $item['idcat']; - $newItem->custom['idtree'] = $item['idtree']; - $newItem->custom['parentid'] = $item['parentid']; - $newItem->custom['alias'] = $item['alias']; - $newItem->custom['preid'] = $item['preid']; - $newItem->custom['postid'] = $item['postid']; - $newItem->custom['visible'] = $item['visible']; - $newItem->custom['idtplcfg'] = $item['idtplcfg']; - $newItem->custom['public'] = $item['public']; - - if ($perm->have_perm_item("str", $item['idcat'])) { - $newItem->custom['forcedisplay'] = 1; - } - - if (array_key_exists($key + 1, $items)) { - $nextItem = $items[$key + 1]; - } else { - $nextItem = 0; - } - - if (array_key_exists($key - 1, $items)) { - $lastItem = $items[$key - 1]; - } else { - $lastItem = 0; - } - - $rootItem->addItem($newItem); - - if ($nextItem['level'] > $item['level']) { - $oldRoot = $rootItem; - buildTree($newItem, $items); - $rootItem = $oldRoot; - } - - if ($nextItem['level'] < $item['level']) { - return; - } - } -} - * - */ function buildTree(&$rootItem, $itemsIterator) { global $nextItem, $perm, $tmp_area; diff --git a/conlite/includes/include.style_edit_form.php b/conlite/includes/include.style_edit_form.php index 078bcc7..8c59965 100644 --- a/conlite/includes/include.style_edit_form.php +++ b/conlite/includes/include.style_edit_form.php @@ -158,11 +158,9 @@ if (!$perm->have_perm_area_action($area, $action)) { if ($_REQUEST['action'] == $sActionEdit) { $sCode = getFileContent($sFilename, $path); } else { - $sCode = $_REQUEST['code']; # stripslashes is required here in case of creating a new file + $sCode = empty($_REQUEST['code'])?'':$_REQUEST['code']; } - $aFileInfo = getFileInformation($client, $sTempFilename, "css", $db); - $form = new UI_Table_Form("file_editor"); $form->addHeader(i18n("Edit file")); $form->setWidth("100%"); @@ -173,16 +171,24 @@ if (!$perm->have_perm_area_action($area, $action)) { $form->setVar("tmp_file", $sTempFilename); $tb_name = new cHTMLTextbox("file", $sFilename, 60); - $ta_code = new cHTMLTextarea("code", clHtmlSpecialChars($sCode), 100, 35, "code"); - $descr = new cHTMLTextarea("description", clHtmlSpecialChars($aFileInfo["description"]), 100, 5); - - $ta_code->setStyle("font-family: monospace;width: 100%;"); - $descr->setStyle("font-family: monospace;width: 100%;"); - $ta_code->updateAttributes(array("wrap" => getEffectiveSetting('style_editor', 'wrap', 'off'))); - $form->add(i18n("Name"), $tb_name); - $form->add(i18n("Description"), $descr->render()); + + $ta_code = new cHTMLTextarea("code", clHtmlSpecialChars($sCode), 100, 35, "code"); + $ta_code->updateAttributes(array("wrap" => getEffectiveSetting('style_editor', 'wrap', 'off'))); + $ta_code->setStyle("font-family: monospace;width: 100%;"); $form->add(i18n("Code"), $ta_code); + + $aFileInfo = getFileInformation($client, $sTempFilename, "css", $db); + if(!empty($aFileInfo["description"])) { + $sDescription = clHtmlSpecialChars($aFileInfo["description"]); + } else { + $sDescription = ''; + } + + $descr = new cHTMLTextarea("description", $sDescription, 100, 5); + + $descr->setStyle("font-family: monospace;width: 100%;"); + $form->add(i18n("Description"), $descr->render()); $page->setContent($form->render()); @@ -192,5 +198,4 @@ if (!$perm->have_perm_area_action($area, $action)) { $page->addScript('reload', $sReloadScript); $page->render(); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/conlite/includes/rights_lay.inc.php b/conlite/includes/rights_lay.inc.php index daf534a..5c23b2d 100644 --- a/conlite/includes/rights_lay.inc.php +++ b/conlite/includes/rights_lay.inc.php @@ -118,7 +118,7 @@ $db->query($sql); while ($db->next_record()) { $tplname = clHtmlEntities($db->f("name")); - $description = clHtmlEntities($db->f("description")); + $description = empty($db->f("description"))?'':clHtmlEntities($db->f("description")); $sTable .= $table->row(); $sTable .= $table->cell($tplname,"", "", " class=\"td_rights0\"", false); diff --git a/conlite/includes/rights_mod.inc.php b/conlite/includes/rights_mod.inc.php index 390f7f2..1230fdf 100644 --- a/conlite/includes/rights_mod.inc.php +++ b/conlite/includes/rights_mod.inc.php @@ -117,7 +117,7 @@ $db->query($sql); while ($db->next_record()) { $tplname = clHtmlEntities($db->f("name")); - $description = clHtmlEntities($db->f("description")); + $description = empty($db->f("description"))?'':clHtmlEntities($db->f("description")); $sTable .= $table->row(); $sTable .= $table->cell($tplname,"", "", " class=\"td_rights0\"", false); diff --git a/conlite/includes/rights_tpl.inc.php b/conlite/includes/rights_tpl.inc.php index d045243..4aeba1f 100644 --- a/conlite/includes/rights_tpl.inc.php +++ b/conlite/includes/rights_tpl.inc.php @@ -112,14 +112,14 @@ foreach ($aSecondHeaderRow as $value) { $sTable .= $table->end_row(); -//Select the itemid�s +//Select the itemid $sql = "SELECT * FROM ".$cfg["tab"]["tpl"]." WHERE idclient='".Contenido_Security::toInteger($rights_client)."' ORDER BY name"; $db->query($sql); while ($db->next_record()) { - $tplname = clHtmlEntities($db->f("name")); - $description = clHtmlEntities($db->f("description")); + $tplname = clHtmlEntities($db->f("name")); + $description = empty($db->f("description"))?'':clHtmlEntities($db->f("description")); $sTable .= $table->row(); $sTable .= $table->cell($tplname,"", "", " class=\"td_rights0\"", false); diff --git a/conlite/includes/startup.php b/conlite/includes/startup.php index 14ba9a2..6b0588d 100644 --- a/conlite/includes/startup.php +++ b/conlite/includes/startup.php @@ -71,7 +71,7 @@ if (!defined('CL_ENVIRONMENT')) { */ if (!defined('CL_VERSION')) { -define('CL_VERSION', '2.2.0 beta'); +define('CL_VERSION', '3.0.0 RC'); } diff --git a/conlite/plugins/chains/createmetatags/include.chain.content.createmetatags.php b/conlite/plugins/chains/createmetatags/include.chain.content.createmetatags.php index c827743..c2b2c88 100644 --- a/conlite/plugins/chains/createmetatags/include.chain.content.createmetatags.php +++ b/conlite/plugins/chains/createmetatags/include.chain.content.createmetatags.php @@ -1,4 +1,5 @@ = 5.3 -if(version_compare(PHP_VERSION, "5.3", "<")) { - cInclude("plugins", "chains/createmetatags/includes/keyword_density_php52.php"); -} else { - cInclude("plugins", "chains/createmetatags/includes/keyword_density.php"); -} + +cInclude("plugins", "chains/createmetatags/includes/keyword_density.php"); cInclude("plugins", "chains/createmetatags/classes/class.metatag.creator.html5.php"); function cecCreateMetatags($metatags) { global $cfg, $lang, $idart, $client, $cfgClient, $idcat, $idartlang; - - $bIsHTML5 = ((getEffectiveSetting('generator', 'html5', 'false') == 'false') ? false : true); - - if($bIsHTML5) { + + $bIsHTML5 = ((getEffectiveSetting('generator', 'html5', 'false') == 'false') ? false : true); + + if ($bIsHTML5) { $aConfig = array( 'cachetime' => 3600, - 'cachedir' => $cfgClient[$client]['path']['frontend'] . "cache/" + 'cachedir' => $cfgClient[$client]['path']['frontend'] . "cache/" ); - - $oHtml5MetaCreator = new MetaTagCreatorHtml5($metatags, $aConfig); + + $oHtml5MetaCreator = new MetaTagCreatorHtml5($metatags, $aConfig); return $oHtml5MetaCreator->generateMetaTags(); - } + } //Basic settings $cachetime = 3600; // measured in seconds @@ -59,8 +55,8 @@ function cecCreateMetatags($metatags) { $metatags = array(); } - $hash = 'metatag_'.md5($idart.'/'.$lang); - $cachefilename = $cachedir.$hash.'.tmp'; + $hash = 'metatag_' . md5($idart . '/' . $lang); + $cachefilename = $cachedir . $hash . '.tmp'; #Check if rebuilding of metatags is necessary $reload = true; @@ -70,7 +66,7 @@ function cecCreateMetatags($metatags) { if (file_exists($cachefilename)) { $fileexists = true; - $diff = time() - filemtime($cachefilename); + $diff = time() - filemtime($cachefilename); if ($diff > $cachetime) { $reload = true; @@ -84,7 +80,7 @@ function cecCreateMetatags($metatags) { $db = new DB_ConLite(); #Get encoding - $sql = "SELECT * FROM ".$cfg['tab']['lang']." WHERE idlang=".(int)$lang; + $sql = "SELECT * FROM " . $cfg['tab']['lang'] . " WHERE idlang=" . (int) $lang; $db->query($sql); if ($db->next_record()) { $sEncoding = strtoupper($db->f('encoding')); @@ -95,12 +91,12 @@ function cecCreateMetatags($metatags) { #Get idcat of homepage $sql = "SELECT a.idcat FROM - ".$cfg['tab']['cat_tree']." AS a, - ".$cfg['tab']['cat_lang']." AS b + " . $cfg['tab']['cat_tree'] . " AS a, + " . $cfg['tab']['cat_lang'] . " AS b WHERE (a.idcat = b.idcat) AND (b.visible = 1) AND - (b.idlang = ".Contenido_Security::toInteger($lang).") + (b.idlang = " . Contenido_Security::toInteger($lang) . ") ORDER BY a.idtree LIMIT 1"; $db->query($sql); @@ -112,7 +108,7 @@ function cecCreateMetatags($metatags) { $availableTags = conGetAvailableMetaTagTypes(); #Get first headline and first text for current article - $oArt = new Article ($idart, $client, $lang); + $oArt = new Article($idart, $client, $lang); #Set idartlang, if not set if ($idartlang == '') { @@ -140,7 +136,7 @@ function cecCreateMetatags($metatags) { } $sHeadline = strip_tags($sHeadline); - $sHeadline = substr(str_replace(chr(13).chr(10),' ',$sHeadline),0,100); + $sHeadline = substr(str_replace(chr(13) . chr(10), ' ', $sHeadline), 0, 100); $arrText1 = $oArt->getContent("html"); $arrText2 = $oArt->getContent("text"); @@ -163,19 +159,19 @@ function cecCreateMetatags($metatags) { } $sText = strip_tags(urldecode($sText)); - $sText = keywordDensity ('', $sText); + $sText = keywordDensity('', $sText); //Get metatags for homeapge $arrHomepageMetaTags = array(); - $sql = "SELECT startidartlang FROM ".$cfg["tab"]["cat_lang"]." WHERE (idcat=".Contenido_Security::toInteger($idcat_homepage).") AND(idlang=".Contenido_Security::toInteger($lang).")"; + $sql = "SELECT startidartlang FROM " . $cfg["tab"]["cat_lang"] . " WHERE (idcat=" . Contenido_Security::toInteger($idcat_homepage) . ") AND(idlang=" . Contenido_Security::toInteger($lang) . ")"; $db->query($sql); - if($db->next_record()){ + if ($db->next_record()) { $iIdArtLangHomepage = $db->f('startidartlang'); #get idart of homepage - $sql = "SELECT idart FROM ".$cfg["tab"]["art_lang"]." WHERE idartlang =".Contenido_Security::toInteger($iIdArtLangHomepage); + $sql = "SELECT idart FROM " . $cfg["tab"]["art_lang"] . " WHERE idartlang =" . Contenido_Security::toInteger($iIdArtLangHomepage); $db->query($sql); @@ -186,10 +182,10 @@ function cecCreateMetatags($metatags) { $t1 = $cfg["tab"]["meta_tag"]; $t2 = $cfg["tab"]["meta_type"]; - $sql = "SELECT ".$t1.".metavalue,".$t2.".metatype FROM ".$t1. - " INNER JOIN ".$t2." ON ".$t1.".idmetatype = ".$t2.".idmetatype WHERE ". - $t1.".idartlang =".$iIdArtLangHomepage. - " ORDER BY ".$t2.".metatype"; + $sql = "SELECT " . $t1 . ".metavalue," . $t2 . ".metatype FROM " . $t1 . + " INNER JOIN " . $t2 . " ON " . $t1 . ".idmetatype = " . $t2 . ".idmetatype WHERE " . + $t1 . ".idartlang =" . $iIdArtLangHomepage . + " ORDER BY " . $t2 . ".metatype"; $db->query($sql); @@ -197,7 +193,7 @@ function cecCreateMetatags($metatags) { $arrHomepageMetaTags[$db->f("metatype")] = $db->f("metavalue"); } - $oArt = new Article ($iIdArtHomepage, $client, $lang); + $oArt = new Article($iIdArtHomepage, $client, $lang); $arrHomepageMetaTags['pagetitle'] = $oArt->getField('title'); } @@ -206,12 +202,12 @@ function cecCreateMetatags($metatags) { foreach ($availableTags as $key => $value) { $metavalue = conGetMetaValue($idartlang, $key); - if (strlen($metavalue) == 0){ + if (strlen($metavalue) == 0) { //Add values for metatags that don't have a value in the current article - switch(strtolower($value["name"])){ + switch (strtolower($value["name"])) { case 'author': //Build author metatag from name of last modifier - $oArt = new Article ($idart, $client, $lang); + $oArt = new Article($idart, $client, $lang); $lastmodifier = $oArt->getField("modifiedby"); $oUser = new User(); $oUser->loadUserByUserID(md5($lastmodifier)); @@ -224,7 +220,7 @@ function cecCreateMetatags($metatags) { break; case 'date': //Build date metatag from date of last modification - $oArt = new Article ($idart, $client, $lang); + $oArt = new Article($idart, $client, $lang); $lastmodified = $oArt->getField("lastmodified"); $iCheck = CheckIfMetaTagExists($metatags, 'date'); @@ -260,7 +256,6 @@ function cecCreateMetatags($metatags) { // save metatags in cache file file_put_contents($cachefilename, serialize($metatags)); - } else { #Get metatags from file system cache $metatags = unserialize(file_get_contents($cachefilename)); @@ -269,7 +264,6 @@ function cecCreateMetatags($metatags) { return $metatags; } - /** * Checks if the metatag allready exists inside the metatag list. * @@ -295,4 +289,5 @@ function CheckIfMetaTagExists($arrMetatags, $sCheckForMetaTag) { // metatag doesn't exists, return next position return count($arrMetatags); } + ?> \ No newline at end of file diff --git a/conlite/plugins/chains/createmetatags/includes/keyword_density_php52.php b/conlite/plugins/chains/createmetatags/includes/keyword_density_php52.php deleted file mode 100644 index 887f9c4..0000000 --- a/conlite/plugins/chains/createmetatags/includes/keyword_density_php52.php +++ /dev/null @@ -1,221 +0,0 @@ - $b) ? -1 : 1; -} - -/** - * - * @param array $singlewordcounter - * @param int $maxKeywords - * @return array Array with valued keywords - */ -function stripCount($singlewordcounter, $maxKeywords = 15) { - // strip all with only 1 - $tmp = array(); - $result = array(); - $tmpToRemove = 1; - - foreach ($singlewordcounter as $key => $value) { - if ($value > $tmpToRemove) { - $tmp[$key] = $value; - } - } - - if (sizeof($tmp) <= $maxKeywords) { - foreach ($tmp as $key => $value) { - $result[] = $key; - } - } else { - $dist = array(); - foreach ($tmp as $key => $value) { - $dist[$value]++; - } - uksort($dist, "__cmp"); - reset($dist); - $count = 0; - $resultset = array(); - $useQuantity = array(); - - foreach ($dist as $key => $value) { - $_count = $count + $value; - if ($_count <= $maxKeywords) { - $count += $value; - $useQuantity[] = $key; - } else { - break; - } - } - // run all keywords and select by quantities to use - foreach ($singlewordcounter as $key => $value) { - if (in_array($value, $useQuantity)) { - $result[] = $key; - } - } - } - return $result; -} - -/** - * Generate keywords from content - * - * @version 1.0 - * @since 2.0.0 - * @author Ortwin Pinke - * - * @param string $sHeadline - * @param string $sText - * @param string $sEncoding - * @param int $iMinLen - * @return mixed commaseparated string of keywords or false - */ -function keywordDensity($sHeadline, $sText, $sEncoding = "UTF-8", $iMinLen = 5) { - global $aAllWords; - $sHeadline = strip_tags($sHeadline); - $sText = strip_tags($sText); - $sText = clHtmlEntityDecode($sText, ENT_QUOTES, $sEncoding); - - $aSingleWordHeadline = str_word_count($sHeadline, 1); - // double array for higher valenz of headline - $aSingleWordHeadline = array_merge($aSingleWordHeadline,$aSingleWordHeadline); - $aSingleWordHeadline = array_count_values($aSingleWordHeadline); - - $aSingleWordText = str_word_count($sText, 1); - $aSingleWordText = array_count_values($aSingleWordText); - - $aAllWords = array_merge($aSingleWordHeadline, $aSingleWordText); - array_walk($aAllWords, create_function('&$n, $key, $iLen', ' - global $aAllWords; - if(strlen($key) < $iLen || clIsStopWord($key)) { - unset($aAllWords[$key]); - }'), $iMinLen); - arsort($aAllWords, SORT_NUMERIC); - $aAllWords = stripCount($aAllWords); - if(is_array($aAllWords)) { - return implode(', ', $aAllWords); - } - return false; -} - -/** - * Check keyword against stopword list - * - * @version 1.0 - * @since 2.0.0 - * @author Ortwin Pinke - * @todo move stopwords to sqlite - * - * @global int $lang - * @global array $encoding - * @param string $sWord - * @return boolean - */ -function clIsStopWord($sWord) { - global $lang, $encoding; - $aStopWords = array(); - $aStopWords['de_DE'] = array("aber", "als", "am", "an", "auch", "auf", "aus", "bei", "bin", - "bis", "bist", "da", "dadurch", "daher", "darum", "das", "daß", "dass", "dein", - "deine", "dem", "den", "der", "des", "dessen", "deshalb", "die", "dies", "dieser", "dieses", - "doch", "dort", "du", "durch", "ein", "eine", "einem", "einen", "einer", "eines", "er", - "es", "euer", "eure", "für", "hatte", "hatten", "hattest", "hattet", "hier", "hinter", - "ich", "ihr", "ihre", "im", "in", "ist", "ja", "jede", "jedem", "jeden", "jeder", "jedes", - "jener", "jenes", "jetzt", "kann", "kannst", "können", "könnt", "machen", "mein", - "meine", "mit", "muß", "mußt", "musst", "müssen", "müßt", "nach", "nachdem", "nein", - "nicht", "nun", "oder", "seid", "sein", "seine", "sich", "sie", - "sind", "soll", "sollen", "sollst", "sollt", "sonst", "soweit", "sowie", "und", "unser", - "unsere", "unter", "vom", "von", "vor", "wann", "warum", "was", "weiter", "weitere", "wenn", - "wer", "werde", "werden", "werdet", "weshalb", "wie", "wieder", "wieso", "wir", "wird", - "wirst", "wo", "woher", "wohin", "zu", "zum", "zur", "über"); - $aStopWords['en_EN'] = $aStopWords['en_US'] = array("a", "able", "about", "above", "abst", - "accordance", "according", "accordingly", "across", "act", "actually", "added", "adj", - "affected", "affecting", "affects", "after", "afterwards", "again", "against", "ah", "all", - "almost", "alone", "along", "already", "also", "although", "always", "am", "among", - "amongst", "an", "and", "announce", "another", "any", "anybody", "anyhow", "anymore", - "anyone", "anything", "anyway", "anyways", "anywhere", "apparently", "approximately", - "are", "aren", "arent", "arise", "around", "as", "aside", "ask", "asking", "at", "auth", - "available", "away", "awfully", "b", "back", "be", "became", "because", "become", "becomes", - "becoming", "been", "before", "beforehand", "begin", "beginning", "beginnings", "begins", - "behind", "being", "believe", "below", "beside", "besides", "between", "beyond", "biol", - "both", "brief", "briefly", "but", "by", "c", "ca", "came", "can", "cannot", "can't", - "cause", "causes", "certain", "certainly", "co", "com", "come", "comes", "contain", - "containing", "contains", "could", "couldnt", "d", "date", "did", "didn't", "different", - "do", "does", "doesn't", "doing", "done", "don't", "down", "downwards", "due", "during", - "e", "each", "ed", "edu", "effect", "eg", "eight", "eighty", "either", "else", "elsewhere", - "end", "ending", "enough", "especially", "et", "et-al", "etc", "even", "ever", "every", - "everybody", "everyone", "everything", "everywhere", "ex", "except", "f", "far", "few", - "ff", "fifth", "first", "five", "fix", "followed", "following", "follows", "for", "former", - "formerly", "forth", "found", "four", "from", "further", "furthermore", "g", "gave", "get", - "gets", "getting", "give", "given", "gives", "giving", "go", "goes", "gone", "got", "gotten", - "h", "had", "happens", "hardly", "has", "hasn't", "have", "haven't", "having", "he", "hed", - "hence", "her", "here", "hereafter", "hereby", "herein", "heres", "hereupon", "hers", - "herself", "hes", "hi", "hid", "him", "himself", "his", "hither", "home", "how", "howbeit", - "however", "hundred", "i", "id", "ie", "if", "i'll", "im", "immediate", "immediately", - "importance", "important", "in", "inc", "indeed", "index", "information", "instead", "into", - "invention", "inward", "is", "isn't", "it", "itd", "it'll", "its", "itself", "i've", "j", - "just", "k", "keep", "keeps", "kept", "kg", "km", "know", "known", "knows", "l", "largely", - "last", "lately", "later", "latter", "latterly", "least", "less", "lest", "let", "lets", - "like", "liked", "likely", "line", "little", "'ll", "look", "looking", "looks", "ltd", "m", - "made", "mainly", "make", "makes", "many", "may", "maybe", "me", "mean", "means", "meantime", - "meanwhile", "merely", "mg", "might", "million", "miss", "ml", "more", "moreover", "most", - "mostly", "mr", "mrs", "much", "mug", "must", "my", "myself", "n", "na", "name", "namely", - "nay", "nd", "near", "nearly", "necessarily", "necessary", "need", "needs", "neither", - "never", "nevertheless", "new", "next", "nine", "ninety", "no", "nobody", "non", "none", - "nonetheless", "noone", "nor", "normally", "nos", "not", "noted", "nothing", "now", "nowhere", - "o", "obtain", "obtained", "obviously", "of", "off", "often", "oh", "ok", "okay", "old", - "omitted", "on", "once", "one", "ones", "only", "onto", "or", "ord", "other", "others", - "otherwise", "ought", "our", "ours", "ourselves", "out", "outside", "over", "overall", "owing", - "own", "p", "page", "pages", "part", "particular", "particularly", "past", "per", "perhaps", - "placed", "please", "plus", "poorly", "possible", "possibly", "potentially", "pp", "predominantly", - "present", "previously", "primarily", "probably", "promptly", "proud", "provides", "put", - "q", "que", "quickly", "quite", "qv", "r", "ran", "rather", "rd", "re", "readily", "really", - "recent", "recently", "ref", "refs", "regarding", "regardless", "regards", "related", - "relatively", "research", "respectively", "resulted", "resulting", "results", "right", - "run", "s", "said", "same", "saw", "say", "saying", "says", "sec", "section", "see", - "seeing", "seem", "seemed", "seeming", "seems", "seen", "self", "selves", "sent", "seven", - "several", "shall", "she", "shed", "she'll", "shes", "should", "shouldn't", "show", - "showed", "shown", "showns", "shows", "significant", "significantly", "similar", "similarly", - "since", "six", "slightly", "so", "some", "somebody", "somehow", "someone", "somethan", - "something", "sometime", "sometimes", "somewhat", "somewhere", "soon", "sorry", "specifically", - "specified", "specify", "specifying", "still", "stop", "strongly", "sub", "substantially", - "successfully", "such", "sufficiently", "suggest", "sup", "sure", "t", "take", "taken", - "taking", "tell", "tends", "th", "than", "thank", "thanks", "thanx", "that", "that'll", - "thats", "that've", "the", "their", "theirs", "them", "themselves", "then", "thence", - "there", "thereafter", "thereby", "thered", "therefore", "therein", "there'll", "thereof", - "therere", "theres", "thereto", "thereupon", "there've", "these", "they", "theyd", "they'll", - "theyre", "they've", "think", "this", "those", "thou", "though", "thoughh", "thousand", - "throug", "through", "throughout", "thru", "thus", "til", "tip", "to", "together", "too", - "took", "toward", "towards", "tried", "tries", "truly", "try", "trying", "ts", "twice", - "two", "u", "un", "under", "unfortunately", "unless", "unlike", "unlikely", "until", "unto", - "up", "upon", "ups", "us", "use", "used", "useful", "usefully", "usefulness", "uses", "using", - "usually", "v", "value", "various", "'ve", "very", "via", "viz", "vol", "vols", "vs", "w", - "want", "wants", "was", "wasn't", "way", "we", "wed", "welcome", "we'll", "went", "were", - "weren't", "we've", "what", "whatever", "what'll", "whats", "when", "whence", "whenever", - "where", "whereafter", "whereas", "whereby", "wherein", "wheres", "whereupon", "wherever", - "whether", "which", "while", "whim", "whither", "who", "whod", "whoever", "whole", "who'll", - "whom", "whomever", "whos", "whose", "why", "widely", "willing", "wish", "with", "within", - "without", "won't", "words", "world", "would", "wouldn't", "www", "x", "y", "yes", "yet", - "you", "youd", "you'll", "your", "youre", "yours", "yourself", "yourselves", "you've", "z", "zero"); - - if(is_int($lang) && is_array($encoding)) { - $sUseEnc = $encoding[$lang]; - if(empty($sUseEnc) || !array_key_exists($sUseEnc, $aStopWords)) { - $sUseEnc = "de_DE"; - } - } - - if(in_array(utf8_encode($sWord), $aStopWords['de_DE'])) { - return true; - } - return false; -} -?> \ No newline at end of file diff --git a/conlite/plugins/cl-content-allocation b/conlite/plugins/cl-content-allocation deleted file mode 160000 index 9fab054..0000000 --- a/conlite/plugins/cl-content-allocation +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9fab0549299f5a17d8b242f3aaa13cdfe83c90d5 diff --git a/conlite/plugins/cl-mod-rewrite b/conlite/plugins/cl-mod-rewrite deleted file mode 160000 index 91b0fd8..0000000 --- a/conlite/plugins/cl-mod-rewrite +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 91b0fd8c15cdf1b5e9704c8720a40f959e7eb4fe diff --git a/conlite/plugins/cl-newsletter b/conlite/plugins/cl-newsletter deleted file mode 160000 index c0e41ea..0000000 --- a/conlite/plugins/cl-newsletter +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c0e41ea0fa3e8c738893dfe8faacbbb71797be57 diff --git a/conlite/templates/standard/html5/template.generic_page.html b/conlite/templates/standard/html5/template.generic_page.html index 47ef937..eea3476 100644 --- a/conlite/templates/standard/html5/template.generic_page.html +++ b/conlite/templates/standard/html5/template.generic_page.html @@ -1,7 +1,6 @@ - {META} diff --git a/conlite/templates/standard/template.con_edit_form.html b/conlite/templates/standard/template.con_edit_form.html index 0076951..6155f23 100644 --- a/conlite/templates/standard/template.con_edit_form.html +++ b/conlite/templates/standard/template.con_edit_form.html @@ -1,3 +1,4 @@ + @@ -220,9 +221,7 @@ parent.parent.frames["right"].frames["right_top"].sub.clicked(menuItem.firstChild); } - { - DATAPUSH - } + {DATAPUSH} diff --git a/conlite/templates/standard/template.tplcfg_edit_form.html b/conlite/templates/standard/template.tplcfg_edit_form.html index 3c00b3b..4167106 100644 --- a/conlite/templates/standard/template.tplcfg_edit_form.html +++ b/conlite/templates/standard/template.tplcfg_edit_form.html @@ -1,7 +1,7 @@ - + template.tplcfg_edit_form.html @@ -56,7 +56,7 @@ {MARKSUBMENU} diff --git a/setup/lib/defines.php b/setup/lib/defines.php index 1ee4ecd..4ea1ba8 100644 --- a/setup/lib/defines.php +++ b/setup/lib/defines.php @@ -39,4 +39,9 @@ define('C_SETUP_STEPWIDTH', 28); define('C_SETUP_STEPHEIGHT', 28); define('C_SETUP_MIN_PHP_VERSION', '7.4.0'); define('C_SETUP_MAX_PHP_VERSION', '8.3.0'); -define('C_SETUP_VERSION', '2.3.0 alpha'); +define('C_SETUP_VERSION', '3.0.0'); + +$sDefLocalPath = dirname(__FILE__).DIRECTORY_SEPARATOR.'defines.local.php'; +if(file_exists($sDefLocalPath)) { + include_once $sDefLocalPath; +} \ No newline at end of file diff --git a/setup/lib/functions.filesystem.php b/setup/lib/functions.filesystem.php index 5ea0950..bf5b40b 100644 --- a/setup/lib/functions.filesystem.php +++ b/setup/lib/functions.filesystem.php @@ -122,7 +122,7 @@ function canWriteFile($sFilename) { * a wrong information */ $fp = @fopen($sRandFilenamePath, "w"); - if ($fp) { + if (is_resource($fp)) { @fclose($fp); unlink($sRandFilenamePath); return true; @@ -143,8 +143,10 @@ function canWriteFile($sFilename) { /* Ignore errors in case isWriteable() returns * a wrong information */ - $fp = @fopen($sFilename, "w"); - @fclose($fp); + $fp = fopen($sFilename, "w"); + if (is_resource($fp)) { + fclose($fp); + } if (file_exists($sFilename)) { @unlink($sFilename);