⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fe_adminlib.inc

📁 Typo3, 开源里边最强大的
💻 INC
📖 第 1 页 / 共 5 页
字号:
							$markerArray['###'.$specialPrefix.'PCE_'.$theKey.'###'] = $cObjCode;						}					}				}			}		}		return $markerArray;	}	/*****************************************	 *	 * Emailing	 *	 *****************************************/	/**	 * Sends info mail to user	 *	 * @return	string		HTML content message	 * @see init(),compileMail(), sendMail()	 */	function sendInfoMail()	{		if ($this->conf['infomail'] && $this->conf['email.']['field'])	{			$fetch = t3lib_div::_GP('fetch');			if ($fetch)	{					// Getting infomail config.				$key= trim(t3lib_div::_GP('key'));				if (is_array($this->conf['infomail.'][$key.'.']))		{					$config = $this->conf['infomail.'][$key.'.'];				} else {					$config = $this->conf['infomail.']['default.'];				}				$pidLock='';				if (!$config['dontLockPid'])	{					$pidLock='AND pid IN ('.$this->thePid.') ';				}					// Getting records				if (t3lib_div::testInt($fetch))	{					$DBrows = $GLOBALS['TSFE']->sys_page->getRecordsByField($this->theTable,'uid',$fetch,$pidLock,'','','1');				} elseif ($fetch) {	// $this->conf['email.']['field'] must be a valid field in the table!					$DBrows = $GLOBALS['TSFE']->sys_page->getRecordsByField($this->theTable,$this->conf['email.']['field'],$fetch,$pidLock,'','','100');				}					// Processing records				if (is_array($DBrows))	{					$recipient = $DBrows[0][$this->conf['email.']['field']];					$this->compileMail($config['label'], $DBrows, $recipient, $this->conf['setfixed.']);				} elseif ($this->cObj->checkEmail($fetch)) {					$this->sendMail($fetch, '', trim($this->cObj->getSubpart($this->templateCode, '###'.$this->emailMarkPrefix.'NORECORD###')));				}				$content = $this->getPlainTemplate('###TEMPLATE_INFOMAIL_SENT###');			} else {				$content = $this->getPlainTemplate('###TEMPLATE_INFOMAIL###');			}		} else $content='Error: infomail option is not available or emailField is not setup in TypoScript';		return $content;	}	/**	 * Compiles and sends a mail based on input values + template parts. Looks for a normal and an "-admin" template and may send both kinds of emails. See documentation in TSref.	 *	 * @param	string		A key which together with $this->emailMarkPrefix will identify the part from the template code to use for the email.	 * @param	array		An array of records which fields are substituted in the templates	 * @param	mixed		Mail recipient. If string then its supposed to be an email address. If integer then its a uid of a fe_users record which is looked up and the email address from here is used for sending the mail.	 * @param	array		Additional fields to set in the markerArray used in the substitution process	 * @return	void	 */	function compileMail($key, $DBrows, $recipient, $setFixedConfig=array())	{		$GLOBALS['TT']->push('compileMail');		$mailContent='';		$key = $this->emailMarkPrefix.$key;		$userContent['all'] = trim($this->cObj->getSubpart($this->templateCode, '###'.$key.'###'));		$adminContent['all'] = trim($this->cObj->getSubpart($this->templateCode, '###'.$key.'-ADMIN###'));		$userContent['rec'] = $this->cObj->getSubpart($userContent['all'], '###SUB_RECORD###');		$adminContent['rec'] = $this->cObj->getSubpart($adminContent['all'], '###SUB_RECORD###');		reset($DBrows);		while(list(,$r)=each($DBrows))	{			$markerArray = $this->cObj->fillInMarkerArray($this->markerArray, $r,'',0);			$markerArray = $this->setCObjects($userContent['rec'].$adminContent['rec'],$r,$markerArray,'ITEM_');			$markerArray['###SYS_AUTHCODE###'] = $this->authCode($r);			$markerArray = $this->setfixed($markerArray, $setFixedConfig, $r);			if ($userContent['rec'])	$userContent['accum'] .=$this->cObj->substituteMarkerArray($userContent['rec'], $markerArray);			if ($adminContent['rec'])	$adminContent['accum'].=$this->cObj->substituteMarkerArray($adminContent['rec'], $markerArray);		}		if ($userContent['all'])	$userContent['final'] .=$this->cObj->substituteSubpart($userContent['all'], '###SUB_RECORD###', $userContent['accum']);		if ($adminContent['all'])	$adminContent['final'].=$this->cObj->substituteSubpart($adminContent['all'], '###SUB_RECORD###', $adminContent['accum']);		if (t3lib_div::testInt($recipient))	{			$fe_userRec = $GLOBALS['TSFE']->sys_page->getRawRecord('fe_users',$recipient);			$recipient=$fe_userRec['email'];		}		$GLOBALS['TT']->setTSlogMessage('Template key: ###'.$key.'###, userContentLength: '.strlen($userContent['final']).', adminContentLength: '.strlen($adminContent['final']));		$this->sendMail($recipient, $this->conf['email.']['admin'], $userContent['final'], $adminContent['final']);		$GLOBALS['TT']->pull();	}	/**	 * Actually sends the requested mails (through $this->cObj->sendNotifyEmail)	 *	 * @param	string		Recipient email address (or list)	 * @param	string		Possible "admin" email address. Will enable sending of admin emails if also $adminContent is provided	 * @param	string		Content for the regular email to user	 * @param	string		Content for the admin email to administrator	 * @return	void	 * @access private	 * @see compileMail(), sendInfoMail()	 */	function sendMail($recipient, $admin, $content='', $adminContent='')	{			// Admin mail:		if ($admin && $adminContent)	{			if (!$this->isHTMLContent($adminContent))	{				$admMail = $this->cObj->sendNotifyEmail($adminContent,									$admin,									'',									$this->conf['email.']['from'],									$this->conf['email.']['fromName'],									$recipient							);			} else {				$this->sendHTMLMail($adminContent,									$admin,									'',									$this->conf['email.']['from'],									$this->conf['email.']['fromName'],									$recipient							);			}		}			// user mail:		if (!$this->isHTMLContent($content))	{			$this->cObj->sendNotifyEmail($content,								$recipient,								'',			// ($admMail ? '' : $admin), 		// If the special administration mail was not found and send, the regular is...								$this->conf['email.']['from'],								$this->conf['email.']['fromName']						);		} else {			$this->sendHTMLMail($content,								$recipient,								'',			// ($admMail ? '' : $admin), 		// If the special administration mail was not found and send, the regular is...								$this->conf['email.']['from'],								$this->conf['email.']['fromName']						);		}	}	/**	 * Detects if content is HTML (looking for <html> tag as first and last in string)	 *	 * @param	string		Content string to test	 * @return	boolean		Returns true if the content begins and ends with <html></html>-tags	 */	function isHTMLContent($c)	{		$c = trim($c);		$first = strtolower(substr($c,0,6));		$last = strtolower(substr($c,-7));		if ($first.$last=='<html></html>')	return 1;	}	/**	 * Sending HTML email, using same parameters as tslib_cObj::sendNotifyEmail()	 * NOTICE: "t3lib_htmlmail" library must be included for this to work, otherwise an error message is outputted.	 *	 * @param	string		The message content. If blank, no email is sent.	 * @param	string		Comma list of recipient email addresses	 * @param	string		IGNORE this parameter	 * @param	string		"From" email address	 * @param	string		Optional "From" name	 * @param	string		Optional "Reply-To" header email address.	 * @return	void	 * @access private	 * @see sendMail(), tslib_cObj::sendNotifyEmail()	 */	function sendHTMLMail($content,$recipient,$dummy,$fromEmail,$fromName,$replyTo='')	{		if (trim($recipient) && trim($content))	{			$cls=t3lib_div::makeInstanceClassName('t3lib_htmlmail');			if (class_exists($cls))	{	// If htmlmail lib is included, then generate a nice HTML-email				$parts = spliti('<title>|</title>',$content,3);				$subject = trim($parts[1]) ? trim($parts[1]) : 'TYPO3 FE Admin message';				$Typo3_htmlmail = t3lib_div::makeInstance('t3lib_htmlmail');				$Typo3_htmlmail->start();				$Typo3_htmlmail->useBase64();				$Typo3_htmlmail->subject = $subject;				$Typo3_htmlmail->from_email = $fromEmail;				$Typo3_htmlmail->from_name = $fromName;				$Typo3_htmlmail->replyto_email = $replyTo ? $replyTo : $fromEmail;				$Typo3_htmlmail->replyto_name = $replyTo ? '' : $fromName;				$Typo3_htmlmail->organisation = '';				$Typo3_htmlmail->priority = 3;					// HTML				$Typo3_htmlmail->theParts['html']['content'] = $content;	// Fetches the content of the page				$Typo3_htmlmail->theParts['html']['path'] = '';				$Typo3_htmlmail->extractMediaLinks();				$Typo3_htmlmail->extractHyperLinks();				$Typo3_htmlmail->fetchHTMLMedia();				$Typo3_htmlmail->substMediaNamesInHTML(0);	// 0 = relative				$Typo3_htmlmail->substHREFsInHTML();				$Typo3_htmlmail->setHTML($Typo3_htmlmail->encodeMsg($Typo3_htmlmail->theParts['html']['content']));					// PLAIN				$Typo3_htmlmail->addPlain('');					// SET Headers and Content				$Typo3_htmlmail->setHeaders();				$Typo3_htmlmail->setContent();				$Typo3_htmlmail->setRecipient($recipient);		//		debug($Typo3_htmlmail->theParts);				$Typo3_htmlmail->sendtheMail();			} else {				debug('SYSTEM ERROR: No HTML-mail library loaded. Set "page.config.incT3Lib_htmlmail = 1" is your TypoScript template.');			}		}	}	/*****************************************	 *	 * Various helper functions	 *	 *****************************************/	/**	 * Returns true if authentication is OK based on the "aC" code which is a GET parameter set from outside with a hash string which must match some internal hash string.	 * This allows to authenticate editing without having a fe_users login	 * Uses $this->authCode which is set in init() by "t3lib_div::_GP('aC');"	 *	 * @param	array		The data array for which to evaluate authentication	 * @return	boolean		True if authenticated OK	 * @see authCode(), init()	 */	function aCAuth($r)	{		if ($this->authCode && !strcmp($this->authCode,$this->authCode($r)))	{			return true;		}	}	/**	 * Creating authentication hash string based on input record and the fields listed in TypoScript property "authcodeFields"	 *	 * @param	array		The data record	 * @param	string		Additional string to include in the hash	 * @return	string		Hash string of $this->codeLength (if TypoScript "authcodeFields" was set)	 * @see aCAuth()	 */	function authCode($r,$extra='')	{		$l=$this->codeLength;		if ($this->conf['authcodeFields'])	{			$fieldArr = t3lib_div::trimExplode(',', $this->conf['authcodeFields'], 1);			$value='';			while(list(,$field)=each($fieldArr))	{				$value.=$r[$field].'|';			}			$value.=$extra.'|'.$this->conf['authcodeFields.']['addKey'];			if ($this->conf['authcodeFields.']['addDate'])	{				$value.='|'.date($this->conf['authcodeFields.']['addDate']);			}			$value.=$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];			return substr(md5($value), 0,$l);		}	}	/**	 * Adding keys to the marker array with "setfixed" GET parameters	 *	 * @param	array		Marker-array to modify/add a key to.	 * @param	array		TypoScript properties configuring "setfixed" for the plugin. Basically this is $this->conf['setfixed.'] passed along.	 * @param	array		The data record	 * @return	array		Processed $markerArray	 * @see compileMail()	 */	function setfixed($markerArray, $setfixed, $r)	{		if (is_array($setfixed))	{			reset($setfixed);			while(list($theKey,$data)=each($setfixed))	{				if (!strcmp($theKey,'DELETE'))	{					$recCopy = $r;					$string='&cmd=setfixed&sFK='.rawurlencode($theKey).'&rU='.$r['uid'];					$string.='&aC='.$this->setfixedHash($recCopy,$data['_FIELDLIST']);					$markerArray['###SYS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -