*/
function serendipity_strftime($format, $timestamp = null, $useOffset = true) {
global $serendipity;
-
+
switch($serendipity['calendar']) {
default:
case 'gregorian':
$timestamp = serendipity_serverOffsetHour($timestamp);
}
return strftime($format, $timestamp);
-
+
case 'jalali-utf8':
if ($timestamp == null) {
$timestamp = serendipity_serverOffsetHour();
$data[$k] = implode("\n", $v);
}
- if ( $theme != 'default' && $theme != 'default-rtl'
- && @is_dir($serendipity['templatePath'] . $theme . '/admin')
+ if ( $theme != 'default' && $theme != 'default-rtl'
+ && @is_dir($serendipity['templatePath'] . $theme . '/admin')
&& @is_readable($serendipity['templatePath'] . $theme . '/admin/style.css') ) {
-
+
$data['custom_admin_interface'] = YES;
} else {
$data['custom_admin_interface'] = NO;
$query_join = "LEFT OUTER JOIN {$serendipity['dbPrefix']}entries AS e
ON a.authorid = e.authorid";
}
-
+
if ($is_count || $group != null) {
if ($serendipity['dbType'] == 'postgres') {
// Why does PostgreSQL keep doing this to us? :-)
if ($group === null) {
$querystring = "SELECT $query_distinct
- a.authorid,
+ a.authorid,
a.realname,
a.username,
a.password,
$query_select
FROM {$serendipity['dbPrefix']}authors AS a
$query_join
- $where
+ $where
$query_group
ORDER BY a.realname ASC";
} else {
}
$querystring = "SELECT $query_distinct
- a.authorid,
+ a.authorid,
a.realname,
a.username,
a.password,
a.userlevel,
a.right_publish
$query_select
- FROM {$serendipity['dbPrefix']}authors AS a
+ FROM {$serendipity['dbPrefix']}authors AS a
LEFT OUTER JOIN {$serendipity['dbPrefix']}authorgroups AS ag
ON a.authorid = ag.authorid
LEFT OUTER JOIN {$serendipity['dbPrefix']}groups AS g
$query_group
ORDER BY a.realname ASC";
}
-
+
return serendipity_db_query($querystring);
}
function serendipity_sendMail($to, $subject, $message, $fromMail, $headers = NULL, $fromName = NULL) {
global $serendipity;
- if ( !is_null($headers) && !is_array($headers) ) {
+ if (!is_null($headers) && !is_array($headers)) {
trigger_error(__FUNCTION__ . ': $headers must be either an array or null', E_USER_ERROR);
}
- if ( is_null($fromName) || empty($fromName)) {
+ if (is_null($fromName) || empty($fromName)) {
$fromName = $serendipity['blogTitle'];
}
- if ( is_null($fromMail) || empty($fromMail)) {
+ if (is_null($fromMail) || empty($fromMail)) {
$fromMail = $to;
}
+
+ if (is_null($headers)) {
+ $headers = array();
+ }
// Fix special characters
$fromName = str_replace(array('"', "\r", "\n"), array("'", '', ''), $fromName);
$fromMail = str_replace(array("\r","\n"), array('', ''), $fromMail);
- /* Prefix all mail with weblog title */
+ // Prefix all mail with weblog title
$subject = '['. $serendipity['blogTitle'] . '] '. $subject;
- /* Append signature to every mail */
+ // Append signature to every mail
$message .= "\n" . sprintf(SIGNATURE, $serendipity['blogTitle']);
+ $maildata = array(
+ 'to' => &$to,
+ 'subject' => &$subject,
+ 'fromName' => &$fromName,
+ 'fromMail' => &$fromMail,
+ 'blogMail' => $serendipity['blogMail'],
+ 'version' => 'Serendipity/' . $serendipity['version'],
+ 'legacy' => true,
+ 'headers' => &$headers,
+ 'message' => &$message
+ );
- /* Check for mb_* function, and use it to encode headers etc. */
- if ( function_exists('mb_encode_mimeheader') ) {
- // Funky mb_encode_mimeheader function insertes linebreaks after 74 chars.
- // Most MTA I've personally spoken with told me they don't like this at all. ;)
- // Regards to Mark Kronsbein for finding this issue!
- $subject = str_replace(array("\n", "\r"), array('', ''), mb_encode_mimeheader($subject, LANG_CHARSET));
- $fromName = str_replace(array("\n", "\r"), array('', ''), mb_encode_mimeheader($fromName, LANG_CHARSET));
- }
-
-
- /* Always add these headers */
- if (!empty($serendipity['blogMail'])) {
- $headers[] = 'From: "'. $fromName .'" <'. $serendipity['blogMail'] .'>';
+ serendipity_plugin_api('backend_sendmail', $maildata, LANG_CHARSET);
+
+ // This routine can be overridden by a plugin.
+ if ($maildata['legacy']) {
+ // Check for mb_* function, and use it to encode headers etc. */
+ if (function_exists('mb_encode_mimeheader')) {
+ // mb_encode_mimeheader function insertes linebreaks after 74 chars.
+ // Usually this is according to spec, but for us it caused more trouble than
+ // it prevented.
+ // Regards to Mark Kronsbein for finding this issue!
+ $maildata['subject'] = str_replace(array("\n", "\r"), array('', ''), mb_encode_mimeheader($maildata['subject'], LANG_CHARSET));
+ $maildata['fromName'] = str_replace(array("\n", "\r"), array('', ''), mb_encode_mimeheader($maildata['fromName'], LANG_CHARSET));
+ }
+
+
+ // Always add these headers
+ if (!empty($maildata['blogMail'])) {
+ $maildata['headers'][] = 'From: "'. $maildata['fromName'] .'" <'. $maildata['blogMail'] .'>';
+ }
+ $maildata['headers'][] = 'Reply-To: "'. $maildata['fromName'] .'" <'. $maildata['fromMail'] .'>';
+ $maildata['headers'][] = 'X-Mailer: ' . $maildata['version'];
+ $maildata['headers'][] = 'X-Engine: PHP/'. phpversion();
+ $maildata['headers'][] = 'Message-ID: <'. md5(microtime() . uniqid(time())) .'@'. $_SERVER['HTTP_HOST'] .'>';
+ $maildata['headers'][] = 'MIME-Version: 1.0';
+ $maildata['headers'][] = 'Precedence: bulk';
+ $maildata['headers'][] = 'Content-Type: text/plain; charset=' . LANG_CHARSET;
+
+ if (LANG_CHARSET == 'UTF-8') {
+ if (function_exists('imap_8bit')) {
+ $maildata['headers'][] = 'Content-Transfer-Encoding: quoted-printable';
+ $maildata['message'] = imap_8bit($maildata['message']);
+ } else {
+ $maildata['headers'][] = 'Content-Transfer-Encoding: base64';
+ $maildata['message'] = base64_encode($maildata['message']);
+ }
+ }
}
- $headers[] = 'Reply-To: "'. $fromName .'" <'. $fromMail .'>';
- $headers[] = 'X-Mailer: Serendipity/'. $serendipity['version'];
- $headers[] = 'X-Engine: PHP/'. phpversion();
- $headers[] = 'Message-ID: <'. md5(microtime() . uniqid(time())) .'@'. $_SERVER['HTTP_HOST'] .'>';
- $headers[] = 'MIME-Version: 1.0';
- $headers[] = 'Precedence: bulk';
- $headers[] = 'Content-Type: text/plain; charset=' . LANG_CHARSET;
- return mail($to, $subject, $message, implode("\n", $headers));
+ return mail($maildata['to'], $maildata['subject'], $maildata['message'], implode("\n", $maildata['headers']));
}
/**
}
$guid = serendipity_archiveURL(
- $id,
- $title,
- 'baseURL',
- true,
+ $id,
+ $title,
+ 'baseURL',
+ true,
array('timestamp' => $entry['timestamp'])
);
* @see serendipity_displayTopUrlList()
* @param int Number of referrers to show
* @param boolean Whether to use HTML links for URLs
- * @param int Interval for which the top referrers are aggregated
+ * @param int Interval for which the top referrers are aggregated
* @return string List of Top referrers
*/
function serendipity_displayTopReferrers($limit = 10, $use_links = true, $interval = 7) {
* @see serendipity_displayTopUrlList()
* @param int Number of exits to show
* @param boolean Whether to use HTML links for URLs
- * @param int Interval for which the top exits are aggregated
+ * @param int Interval for which the top exits are aggregated
* @return string List of Top exits
*/
function serendipity_displayTopExits($limit = 10, $use_links = true, $interval = 7) {
* @see serendipity_displayTopReferrers()
* @param string Name of the DB table to show data from (exits|referrers)
* @param boolean Whether to use HTML links for URLs
- * @param int Interval for which the top exits are aggregated
+ * @param int Interval for which the top exits are aggregated
* @return
*/
function serendipity_displayTopUrlList($list, $limit, $use_links = true, $interval = 7) {
global $serendipity;
$query = "INSERT INTO {$serendipity['dbPrefix']}category
(category_name, category_description, authorid, category_icon, parentid, category_left, category_right)
- VALUES
- ('". serendipity_db_escape_string($name) ."',
- '". serendipity_db_escape_string($desc) ."',
- ". (int)$authorid .",
- '". serendipity_db_escape_string($icon) ."',
- ". (int)$parentid .",
- 0,
+ VALUES
+ ('". serendipity_db_escape_string($name) ."',
+ '". serendipity_db_escape_string($desc) ."',
+ ". (int)$authorid .",
+ '". serendipity_db_escape_string($icon) ."',
+ ". (int)$parentid .",
+ 0,
0)";
serendipity_db_query($query);