# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
-$serendipity['imageList'] = array();
-include_once(S9Y_INCLUDE_PATH . "include/db/db.inc.php");
-include_once(S9Y_INCLUDE_PATH . "include/compat.inc.php");
-include_once(S9Y_INCLUDE_PATH . "include/functions_config.inc.php");
-include_once(S9Y_INCLUDE_PATH . "include/plugin_api.inc.php");
-include_once(S9Y_INCLUDE_PATH . "include/functions_images.inc.php");
-include_once(S9Y_INCLUDE_PATH . "include/functions_installer.inc.php");
-include_once(S9Y_INCLUDE_PATH . "include/functions_entries.inc.php");
-include_once(S9Y_INCLUDE_PATH . "include/functions_comments.inc.php");
-include_once(S9Y_INCLUDE_PATH . "include/functions_permalinks.inc.php");
-include_once(S9Y_INCLUDE_PATH . "include/functions_smarty.inc.php");
+if (defined('S9Y_FRAMEWORK_FUNCTIONS')) {
+ return;
+}
+@define('S9Y_FRAMEWORK_FUNCTIONS', true);
+$serendipity['imageList'] = array();
+if (!defined('S9Y_FRAMEWORK_DB')) {
+ include(S9Y_INCLUDE_PATH . "include/db/db.inc.php");
+}
+if (!defined('S9Y_FRAMEWORK_COMPAT')) {
+ include(S9Y_INCLUDE_PATH . "include/compat.inc.php");
+}
+if (!defined('S9Y_FRAMEWORK_CONFIG')) {
+ include(S9Y_INCLUDE_PATH . "include/functions_config.inc.php");
+}
+if (!defined('S9Y_FRAMEWORK_PLUGIN_API')) {
+ include(S9Y_INCLUDE_PATH . "include/plugin_api.inc.php");
+}
+if (!defined('S9Y_FRAMEWORK_IMAGES')) {
+ include(S9Y_INCLUDE_PATH . "include/functions_images.inc.php");
+}
+if (!defined('S9Y_FRAMEWORK_INSTALLER')) {
+ include(S9Y_INCLUDE_PATH . "include/functions_installer.inc.php");
+}
+if (!defined('S9Y_FRAMEWORK_ENTRIES')) {
+ include(S9Y_INCLUDE_PATH . "include/functions_entries.inc.php");
+}
+if (!defined('S9Y_FRAMEWORK_COMMENTS')) {
+ include(S9Y_INCLUDE_PATH . "include/functions_comments.inc.php");
+}
+if (!defined('S9Y_FRAMEWORK_PERMALINKS')) {
+ include(S9Y_INCLUDE_PATH . "include/functions_permalinks.inc.php");
+}
+if (!defined('S9Y_FRAMEWORK_SMARTY')) {
+ include(S9Y_INCLUDE_PATH . "include/functions_smarty.inc.php");
+}
/**
* Truncate a string to a specific length, multibyte aware. Appends '...' if successfully truncated
*
}
}
+/* Converts a date string (DD.MM.YYYY, YYYY-MM-DD, MM/DD/YYYY) into a unix timestamp
+ *
+ * @access public
+ * @param string The input date
+ * @return int The output unix timestamp
+ */
+function &serendipity_convertToTimestamp($in) {
+ if (preg_match('@([0-9]+)([/\.-])([0-9]+)([/\.-])([0-9]+)@', $in, $m)) {
+ if ($m[2] != $m[4]) {
+ return $in;
+ }
+
+ switch($m[2]) {
+ case '.':
+ return mktime(0, 0, 0, /* month */ $m[3], /* day */ $m[1], /* year */ $m[5]);
+ break;
+
+ case '/':
+ return mktime(0, 0, 0, /* month */ $m[1], /* day */ $m[3], /* year */ $m[5]);
+ break;
+
+ case '-':
+ return mktime(0, 0, 0, /* month */ $m[3], /* day */ $m[5], /* year */ $m[1]);
+ break;
+ }
+
+ return $in;
+ }
+
+ return $in;
+}
+
/**
* Format a timestamp
*
$out = strftime($format, $timestamp);
break;
- case 'jalali-utf8':
+ case 'persian-utf8':
if ($timestamp == null) {
$timestamp = serendipity_serverOffsetHour();
} elseif ($useOffset) {
}
require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
- $out = jalali_strftime_utf($format, $timestamp);
+ $out = persian_strftime_utf($format, $timestamp);
break;
}
return $out;
}
+
/**
* A wrapper function call for formatting Timestamps.
*
$maildata['message'] = str_replace("=\r\n", "", imap_8bit($maildata['message']));
} else {
$maildata['headers'][] = 'Content-Transfer-Encoding: base64';
- $maildata['message'] = base64_encode($maildata['message']);
+ $maildata['message'] = chunk_split(base64_encode($maildata['message']));
}
}
}
function serendipity_fetchReferences($id) {
global $serendipity;
- $query = "SELECT name,link FROM {$serendipity['dbPrefix']}references WHERE entry_id = '" . (int)$id . "'";
+ $query = "SELECT name,link FROM {$serendipity['dbPrefix']}references WHERE entry_id = '" . (int)$id . "' AND type = ''";
return serendipity_db_query($query);
}
if ($serendipity['enablePopup'] != true)
return "";
- if ($serendipity['XHTML11']) {
- return ' onclick="window.open(this.href, \'target' . time() . '\'); return false;" ';
- } else {
- return ' target="' . $target . '" ';
- }
+ return ' onclick="window.open(this.href, \'target' . time() . '\'); return false;" ';
}
/**
static $default = '2.0';
/* Detect type */
- if ( $name == 'comments' ) {
+ if ($name == 'comments') {
$type = 'comments';
+ } elseif ($name == 'comments_and_trackbacks') {
+ $type = 'comments_and_trackbacks';
+ } elseif ($name == 'trackbacks') {
+ $type = 'trackbacks';
} else {
$type = 'content';
}
}
+/**
+ * Ends a session, so that while a file requests happens, Serendipity can work on in that session
+ */
+function serendipity_request_start() {
+ @session_write_close();
+ return true;
+}
+
+/**
+ * Continues a session after a file request
+ */
+function serendipity_request_end() {
+ @session_start();
+ return true;
+}
+
+if (!function_exists('microtime_float')) {
+ /**
+ * Get current timestamp as microseconds
+ *
+ * @access public
+ * @return float the time
+ */
+ function microtime_float() {
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+ }
+}
+
+/**
+ * Converts Array data to be used as a GET string
+ *
+ * @access public
+ * @param array The input array
+ * @param string An array prefix
+ * @param string How to join the array
+ * @return string The HTTP query string
+ */
+function serendipity_build_query(&$array, $array_prefix = null, $comb_char = '&') {
+ $ret = array();
+ if (!is_array($array)) {
+ return '';
+ }
+
+ foreach ($array as $k => $v) {
+ $newkey = urlencode($k);
+ if ($array_prefix) {
+ $newkey = $array_prefix . '[' . $newkey . ']';
+ }
+ if (is_array($v)) {
+ $ret[] = serendipity_build_query($v, $newkey, $comb_char);
+ } else {
+ $ret[] = $newkey . '=' . urlencode($v);
+ }
+ }
+
+ return implode($comb_char, $ret);
+}
+
+/* Picks a specified key from an array and returns it
+ *
+ * @access public
+ * @param array The input array
+ * @param string The key to search for
+ * @param string The default value to return when not found
+ * @return null
+ */
+function &serendipity_pickKey(&$array, $key, $default) {
+ if (!is_array($array)) {
+ return $default;
+ }
+
+ foreach($array AS $child) {
+ if (is_array($child) && isset($child[$key]) && !empty($child[$key])) {
+ return $child[$key];
+ }
+ }
+
+ return $default;
+}
+
define("serendipity_FUNCTIONS_LOADED", true);
/* vim: set sts=4 ts=4 expandtab : */