本文整理汇总了PHP中serendipity_db_escape_string函数的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_db_escape_string函数的具体用法?PHP serendipity_db_escape_string怎么用?PHP serendipity_db_escape_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serendipity_db_escape_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_config
function set_config($item, $value)
{
global $serendipity;
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}options\n WHERE okey = 't_" . serendipity_db_escape_string($serendipity['template']) . "'\n AND name = '" . serendipity_db_escape_string($item) . "'");
serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}options (okey, name, value)\n VALUES ('t_" . serendipity_db_escape_string($serendipity['template']) . "', '" . serendipity_db_escape_string($item) . "', '" . serendipity_db_escape_string($value) . "')");
return true;
}
示例2: addEntryProperties
static function addEntryProperties($entryId, $supported_properties, &$properties, $deleteMissing = true)
{
global $serendipity;
// Get existing data
$property = serendipity_fetchEntryProperties($entryId);
foreach ($supported_properties as $prop_key) {
$prop_val = isset($properties[$prop_key]) ? $properties[$prop_key] : null;
if (!$deleteMissing && empty($prop_val)) {
continue;
}
// Don't clear data if not allowed.
$q = '';
if (!isset($property[$prop_key]) && !empty($prop_val)) {
if ($prop_val != '#') {
$q = "INSERT INTO {$serendipity['dbPrefix']}entryproperties (entryid, property, value) VALUES (" . (int) $entryId . ", '" . serendipity_db_escape_string($prop_key) . "', '" . serendipity_db_escape_string($prop_val) . "')";
}
} elseif ($property[$prop_key] != $prop_val && !empty($prop_val)) {
if ($prop_val == '#') {
$q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int) $entryId . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
} else {
$q = "UPDATE {$serendipity['dbPrefix']}entryproperties SET value = '" . serendipity_db_escape_string($prop_val) . "' WHERE entryid = " . (int) $entryId . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
}
} elseif (empty($property[$prop_key])) {
$q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int) $entryId . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
}
if (!empty($q)) {
serendipity_db_query($q);
}
}
}
示例3: staticpage_display
function staticpage_display($params, &$smarty)
{
global $serendipity;
if (empty($params['template'])) {
$params['template'] = 'plugin_staticpage.tpl';
}
if (empty($params['pagevar'])) {
$params['pagevar'] = 'staticpage_';
}
if (!empty($params['id'])) {
$where = "id = '" . serendipity_db_escape_string($params['id']) . "'";
} elseif (!empty($params['pagetitle'])) {
$where = "pagetitle = '" . serendipity_db_escape_string($params['pagetitle']) . "'";
} elseif (!empty($params['permalink'])) {
$where = "permalink = '" . serendipity_db_escape_string($params['permalink']) . "'";
} else {
$smarty->trigger_error(__FUNCTION__ . ": missing 'id', 'permalink' or 'pagetitle' parameter");
return;
}
if (!empty($params['authorid'])) {
$where .= " AND authorid = " . (int) $params['authorid'];
}
if (empty($params['query'])) {
$params['query'] = "SELECT *\n FROM {$serendipity['dbPrefix']}staticpages\n WHERE {$where}\n LIMIT 1";
}
$page = serendipity_db_query($params['query'], true, 'assoc');
if (is_array($page)) {
$old_staticpage = $serendipity['staticpage_plugin']->staticpage;
$serendipity['staticpage_plugin']->staticpage =& $page;
$serendipity['staticpage_plugin']->checkPage();
echo $serendipity['staticpage_plugin']->parseStaticPage($params['pagevar'], $params['template']);
$serendipity['staticpage_plugin']->staticpage = $old_staticpage;
return;
}
}
示例4: generate_content
function generate_content(&$title)
{
global $serendipity;
$number = $this->get_config('number');
$showpicsonly = $this->get_config('showpicsonly');
if (!$number || !is_numeric($number) || $number < 1) {
$number = 5;
}
$title = PLUGIN_PHOTOBLOG_TITLE;
if (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id'])) {
$number = $number * $number + 1;
$entries = serendipity_db_query("SELECT id,\n title,\n timestamp\n FROM {$serendipity['dbPrefix']}entries\n WHERE isdraft = 'false'\n ORDER BY timestamp DESC\n LIMIT {$number}");
} else {
$id = serendipity_db_escape_string($serendipity['GET']['id']);
$entries1 = serendipity_db_query("SELECT id,\n title,\n timestamp\n FROM {$serendipity['dbPrefix']}entries\n WHERE isdraft = 'false'\n AND id > {$id}\n ORDER BY timestamp ASC\n LIMIT {$number}");
$number++;
$entries2 = serendipity_db_query("SELECT id,\n title,\n timestamp\n FROM {$serendipity['dbPrefix']}entries\n WHERE isdraft = 'false'\n AND id <= {$id}\n ORDER BY timestamp DESC\n LIMIT {$number}");
if (isset($entries1) && is_array($entries1) && isset($entries2) && is_array($entries2)) {
$entries = array_merge(array_reverse($entries1), $entries2);
} elseif (isset($entries1) && is_array($entries1)) {
$entries = array_reverse($entries1);
} elseif (isset($entries2) && is_array($entries2)) {
$entries = $entries2;
}
}
if (isset($entries) && is_array($entries)) {
foreach ($entries as $k => $entry) {
$entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
$photo = $this->getPhoto($entry['id']);
if ($showpicsonly == 'true' && isset($photo) || $showpicsonly != 'true') {
if (isset($photo)) {
$file = serendipity_fetchImageFromDatabase($photo['photoid']);
$imgsrc = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'];
$thumbbasename = $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'];
$thumbName = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $thumbbasename;
$thumbsize = @getimagesize($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $thumbbasename);
}
echo '<a href="' . $entryLink . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '">';
if (isset($photo)) {
echo '<img style="margin:5px;" src="' . $imgsrc . '" width=' . $thumbsize[0] . ' height=' . $thumbsize[1];
if (isset($id) && $id == $entry['id']) {
echo ' border=4';
}
echo ' />';
} else {
if (isset($id) && $id == $entry['id']) {
echo '<b>';
}
echo $entry['title'];
if (isset($id) && $id == $entry['id']) {
echo '</b>';
}
}
echo '</a><br />';
}
}
}
}
示例5: countComments
static function countComments($email)
{
global $serendipity;
if (empty($email)) {
return 0;
}
$db_email = serendipity_db_escape_string($email);
$q = "SELECT COUNT(*) AS commentcount FROM {$serendipity['dbPrefix']}comments WHERE email='{$db_email}'";
$row = serendipity_db_query($q, true);
return $row['commentcount'];
}
示例6: showSearch
function showSearch()
{
global $serendipity;
$this->setupDB();
$term = serendipity_db_escape_string($serendipity['GET']['searchTerm']);
if ($serendipity['dbType'] == 'postgres') {
$group = '';
$distinct = 'DISTINCT';
$find_part = "(c.title ILIKE '%{$term}%' OR c.body ILIKE '%{$term}%')";
} elseif ($serendipity['dbType'] == 'sqlite') {
$group = 'GROUP BY id';
$distinct = '';
$term = serendipity_mb('strtolower', $term);
$find_part = "(lower(c.title) LIKE '%{$term}%' OR lower(c.body) LIKE '%{$term}%')";
} else {
$group = 'GROUP BY id';
$distinct = '';
$term = str_replace('"', '"', $term);
if (preg_match('@["\\+\\-\\*~<>\\(\\)]+@', $term)) {
$find_part = "MATCH(c.title,c.body) AGAINST('{$term}' IN BOOLEAN MODE)";
} else {
$find_part = "MATCH(c.title,c.body) AGAINST('{$term}')";
}
}
$querystring = "SELECT c.title AS ctitle, c.body, c.author, c.entry_id, c.timestamp AS ctimestamp, c.url, c.type,\n e.id, e.title, e.timestamp\n FROM {$serendipity['dbPrefix']}comments AS c\n LEFT OUTER JOIN {$serendipity['dbPrefix']}entries AS e\n ON e.id = c.entry_id\n WHERE c.status = 'approved'\n AND {$find_part}\n {$group}\n ORDER BY c.timestamp DESC";
$results = serendipity_db_query($querystring, false, 'assoc');
if (!is_array($results)) {
if ($results !== 1 && $results !== true) {
echo function_exists('serendipity_specialchars') ? serendipity_specialchars($results) : htmlspecialchars($results, ENT_COMPAT, LANG_CHARSET);
}
$results = array();
}
$myAddData = array("from" => "serendipity_plugin_commentsearch:generate_content");
foreach ($results as $idx => $result) {
$results[$idx]['permalink'] = serendipity_archiveURL($result['id'], $result['title'], 'baseURL', true, $result);
$results[$idx]['comment'] = $result['body'];
//(function_exists('serendipity_specialchars') ? serendipity_specialchars(strip_tags($result['body'])) : htmlspecialchars(strip_tags($result['body']), ENT_COMPAT, LANG_CHARSET));
serendipity_plugin_api::hook_event('frontend_display', $results[$idx], $myAddData);
// let the template decide, if we want to have tags or not
$results[$idx]['commenthtml'] = $results[$idx]['comment'];
$results[$idx]['comment'] = strip_tags($results[$idx]['comment']);
}
$serendipity['smarty']->assign(array('comment_searchresults' => count($results), 'comment_results' => $results));
$filename = 'plugin_commentsearch_searchresults.tpl';
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
if (!$tfile) {
$tfile = dirname(__FILE__) . '/' . $filename;
}
$inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
$serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
$content = $serendipity['smarty']->fetch('file:' . $tfile);
$serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
echo $content;
}
示例7: export_items
function export_items($table, $primary_key, $ref_key, $primary_key_value)
{
global $serendipity;
$result = serendipity_db_Query("SELECT * FROM {$serendipity['dbPrefix']}{$table} WHERE {$ref_key} = {$primary_key_value}", false, 'assoc');
foreach ($result as $row) {
$row[$ref_key] = '@last';
if ($primary_key !== null) {
unset($row[$primary_key]);
}
foreach ($row as $key => $val) {
if ($val != '@last') {
$row[$key] = "'" . serendipity_db_escape_string($val) . "'";
}
}
echo "INSERT INTO {$serendipity['dbPrefix']}{$table} (" . implode(', ', array_keys($row)) . ") VALUES (" . implode(', ', $row) . ");\n";
}
}
示例8: import
function import()
{
global $serendipity;
// Save this so we can return it to its original value at the end of this method.
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
if ($this->data['autodiscovery'] == 'false') {
$serendipity['noautodiscovery'] = 1;
}
$this->getTransTable();
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
$users = array();
$categories = array();
$entries = array();
if (!extension_loaded('pgsql')) {
return PGSQL_REQUIRED;
}
$wpdb = pg_connect("{$this->data}['host'], {$this->data}['port'], {$this->data}['user'], {$this->data}['pass'], {$this->data}['name']");
if (!$wpdb) {
return sprintf(PGSQL_COULDNT_CONNECT, $this->data['pass']);
}
/* Users */
$res = pg_query($wpdb, "SELECT ID, user_login, user_pass, user_email, user_level FROM {$this->data['prefix']}users;");
if (!$res) {
return sprintf(COULDNT_SELECT_USER_INFO, pg_last_error($wpdb));
}
for ($x = 0; $x < pg_num_rows($res); $x++) {
$users[$x] = pg_fetch_assoc($res);
$data = array('right_publish' => $users[$x]['user_level'] >= 1 ? 1 : 0, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'password' => $users[$x]['user_pass']);
// WP uses md5, too.
if ($users[$x]['user_level'] <= 1) {
$data['userlevel'] = USERLEVEL_EDITOR;
} elseif ($users[$x]['user_level'] < 5) {
$data['userlevel'] = USERLEVEL_CHIEF;
} else {
$data['userlevel'] = USERLEVEL_ADMIN;
}
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
$data['userlevel'] = $serendipity['serendipityUserlevel'];
}
serendipity_db_insert('authors', $this->strtrRecursive($data));
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
}
/* Categories */
$res = @pg_query($wpdb, "SELECT cat_ID, cat_name, category_description, category_parent FROM {$this->data['prefix']}categories ORDER BY category_parent, cat_ID;");
if (!$res) {
return sprintf(COULDNT_SELECT_CATEGORY_INFO, pg_last_error($wpdb));
}
// Get all the info we need
for ($x = 0; $x < pg_num_rows($res); $x++) {
$categories[] = pg_fetch_assoc($res);
}
// Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
for ($x = 0; $x < sizeof($categories); $x++) {
$cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
serendipity_db_insert('category', $this->strtrRecursive($cat));
$categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
}
// There has to be a more efficient way of doing this...
foreach ($categories as $cat) {
if ($cat['category_parent'] != 0) {
// Find the parent
$par_id = 0;
foreach ($categories as $possible_par) {
if ($possible_par['cat_ID'] == $cat['category_parent']) {
$par_id = $possible_par['categoryid'];
break;
}
}
if ($par_id != 0) {
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category SET parentid={$par_id} WHERE categoryid={$cat['categoryid']};");
}
// else { echo "D'oh! " . random_string_of_profanity(); }
}
}
serendipity_rebuildCategoryTree();
/* Entries */
$res = @pg_query($wpdb, "SELECT * FROM {$this->data['prefix']}posts ORDER BY post_date;");
if (!$res) {
return sprintf(COULDNT_SELECT_ENTRY_INFO, pg_last_error($wpdb));
}
for ($x = 0; $x < pg_num_rows($res); $x++) {
$entries[$x] = pg_fetch_assoc($res);
$entry = array('title' => $this->decode($entries[$x]['post_title']), 'isdraft' => $entries[$x]['post_status'] == 'publish' ? 'false' : 'true', 'allow_comments' => $entries[$x]['comment_status'] == 'open' ? 'true' : 'false', 'timestamp' => strtotime($entries[$x]['post_date']), 'body' => $this->strtr($entries[$x]['post_content']));
foreach ($users as $user) {
if ($user['ID'] == $entries[$x]['post_author']) {
$entry['authorid'] = $user['authorid'];
break;
}
}
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
return $entries[$x]['entryid'];
}
}
/* Entry/category */
$res = @pg_query($wpdb, "SELECT * FROM {$this->data['prefix']}post2cat;");
if (!$res) {
return sprintf(COULDNT_SELECT_ENTRY_INFO, pg_last_error($wpdb));
}
while ($a = pg_fetch_assoc($res)) {
foreach ($categories as $category) {
//.........这里部分代码省略.........
示例9: serendipity_db_implode
/**
* Operates on an array to prepare it for SQL usage.
*
* @access public
* @param string Concatenation character
* @param array Input array
* @param string How to convert (int: Only numbers, string: serendipity_db_escape_String)
* @return string Imploded string
*/
function serendipity_db_implode($string, &$array, $type = 'int')
{
$new_array = array();
if (!is_array($array)) {
return '';
}
foreach ($array as $idx => $key) {
if ($type == 'int') {
$new_array[$idx] = (int) $key;
} else {
$new_array[$idx] = serendipity_db_escape_string($key);
}
}
$string = implode($string, $new_array);
return $string;
}
示例10: generate_content
function generate_content(&$title)
{
global $serendipity;
$title = $this->get_config('title', $this->title);
$max_entries = $this->get_config('max_entries');
$max_chars = $this->get_config('max_chars');
$wordwrap = $this->get_config('wordwrap');
$dateformat = $this->get_config('dateformat');
if (!$max_entries || !is_numeric($max_entries) || $max_entries < 1) {
$max_entries = 15;
}
if (!$max_chars || !is_numeric($max_chars) || $max_chars < 1) {
$max_chars = 120;
}
if (!$wordwrap || !is_numeric($wordwrap) || $wordwrap < 1) {
$wordwrap = 30;
}
if (!$dateformat || strlen($dateformat) < 1) {
$dateformat = '%a, %d.%m.%Y %H:%M';
}
$viewtype = '';
if ($this->get_config('viewmode') == 'comments') {
$viewtype .= ' AND co.type = \'NORMAL\'';
} elseif ($this->get_config('viewmode') == 'trackbacks') {
$viewtype .= ' AND (co.type = \'TRACKBACK\' OR co.type = \'PINGBACK\')';
}
$cond = array();
$cond['and'] = ' AND e.isdraft = \'false\' ';
if ($this->get_config('authorid') == 'login') {
serendipity_ACL_SQL($cond, true);
serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'entries'));
}
$q = 'SELECT co.body AS comment,
co.timestamp AS stamp,
co.author AS user,
e.title AS subject,
e.timestamp AS entrystamp,
e.id AS entry_id,
co.id AS comment_id,
co.type AS comment_type,
co.url AS comment_url,
co.title AS comment_title,
co.email AS comment_email
FROM ' . $serendipity['dbPrefix'] . 'comments AS co,
' . $serendipity['dbPrefix'] . 'entries AS e
' . $cond['joins'] . '
WHERE e.id = co.entry_id
AND NOT (co.type = \'TRACKBACK\' AND co.author = \'' . serendipity_db_escape_string($serendipity['blogTitle']) . '\' AND co.title != \'\')
AND co.status = \'approved\'
' . $viewtype . '
' . $cond['and'] . '
ORDER BY co.timestamp DESC
LIMIT ' . $max_entries;
$sql = serendipity_db_query($q);
// echo $q;
if ($sql && is_array($sql)) {
foreach ($sql as $key => $row) {
if (function_exists('mb_strimwidth')) {
$comment = mb_strimwidth(strip_tags($row['comment']), 0, $max_chars, " [...]", LANG_CHARSET);
} else {
$comments = wordwrap(strip_tags($row['comment']), $max_chars, '@@@', 1);
$aComment = explode('@@@', $comments);
$comment = $aComment[0];
if (count($aComment) > 1) {
$comment .= ' [...]';
}
}
$showurls = $this->get_config('showurls', 'trackbacks');
$isTrackBack = $row['comment_type'] == 'TRACKBACK' || $row['comment_type'] == 'PINGBACK';
if ($row['comment_url'] != '' && ($isTrackBack && ($showurls == 'trackbacks' || $showurls == 'all') || !$isTrackBack && ($showurls == 'comments' || $showurls == 'all'))) {
/* Fix invalid cases in protocoll part */
$row['comment_url'] = preg_replace('@^http://@i', 'http://', $row['comment_url']);
$row['comment_url'] = preg_replace('@^https://@i', 'https://', $row['comment_url']);
if (substr($row['comment_url'], 0, 7) != 'http://' && substr($row['comment_url'], 0, 8) != 'https://') {
$row['comment_url'] = 'http://' . $row['comment_url'];
}
$user = '<a class="highlight" href="' . htmlspecialchars(strip_tags($row['comment_url'])) . '" title="' . htmlspecialchars(strip_tags($row['comment_title'])) . '">' . htmlspecialchars(strip_tags($row['user'])) . '</a>';
} else {
$user = htmlspecialchars(strip_tags($row['user']));
}
$user = trim($user);
if (empty($user)) {
$user = PLUGIN_COMMENTS_ANONYMOUS;
}
if (function_exists('mb_strimwidth')) {
$pos = 0;
$parts = array();
$enc = LANG_CHARSET;
$comment_len = mb_strlen($comment, $enc);
while ($pos < $comment_len) {
$part = mb_strimwidth($comment, $pos, $wordwrap, '', $enc);
$pos += mb_strlen($part, $enc);
$parts[] = $part;
}
$comment = implode("\n", $parts);
} else {
$comment = wordwrap($comment, $wordwrap, "\n", 1);
}
$entry = array('comment' => $comment, 'email' => $row['comment_email'], 'url' => $row['comment_url'], 'author' => $row['user']);
// Let's help the BBCOde plugin a bit:
//.........这里部分代码省略.........
示例11: serendipity_drawList
/**
* Shows the entry panel overview
*
* Shows a list of existing entries, with pagination and cookie-remember settings.
*
* @access public
* @return null
*/
function serendipity_drawList()
{
global $serendipity, $sort_order, $per_page;
$filter_import = array('author', 'category', 'isdraft');
$sort_import = array('perPage', 'ordermode', 'order');
foreach ($filter_import as $f_import) {
serendipity_restoreVar($serendipity['COOKIE']['entrylist_filter_' . $f_import], $serendipity['GET']['filter'][$f_import]);
serendipity_JSsetCookie('entrylist_filter_' . $f_import, $serendipity['GET']['filter'][$f_import]);
}
foreach ($sort_import as $s_import) {
serendipity_restoreVar($serendipity['COOKIE']['entrylist_sort_' . $s_import], $serendipity['GET']['sort'][$s_import]);
serendipity_JSsetCookie('entrylist_sort_' . $s_import, $serendipity['GET']['sort'][$s_import]);
}
$perPage = !empty($serendipity['GET']['sort']['perPage']) ? $serendipity['GET']['sort']['perPage'] : $per_page[0];
$page = (int) $serendipity['GET']['page'];
$offSet = $perPage * $page;
if (empty($serendipity['GET']['sort']['ordermode']) || $serendipity['GET']['sort']['ordermode'] != 'ASC') {
$serendipity['GET']['sort']['ordermode'] = 'DESC';
}
if (!empty($serendipity['GET']['sort']['order']) && !empty($sort_order[$serendipity['GET']['sort']['order']])) {
$orderby = serendipity_db_escape_string($serendipity['GET']['sort']['order'] . ' ' . $serendipity['GET']['sort']['ordermode']);
} else {
$orderby = 'timestamp ' . serendipity_db_escape_string($serendipity['GET']['sort']['ordermode']);
}
$filter = array();
if (!empty($serendipity['GET']['filter']['author'])) {
$filter[] = "e.authorid = '" . serendipity_db_escape_string($serendipity['GET']['filter']['author']) . "'";
}
if (!empty($serendipity['GET']['filter']['category'])) {
$filter[] = "ec.categoryid = '" . serendipity_db_escape_string($serendipity['GET']['filter']['category']) . "'";
}
if (!empty($serendipity['GET']['filter']['isdraft'])) {
if ($serendipity['GET']['filter']['isdraft'] == 'draft') {
$filter[] = "e.isdraft = 'true'";
} elseif ($serendipity['GET']['filter']['isdraft'] == 'publish') {
$filter[] = "e.isdraft = 'false'";
}
}
if (!empty($serendipity['GET']['filter']['body'])) {
if ($serendipity['dbType'] == 'mysql') {
$filter[] = "MATCH (title,body,extended) AGAINST ('" . serendipity_db_escape_string($serendipity['GET']['filter']['body']) . "')";
$full = true;
}
}
$filter_sql = implode(' AND ', $filter);
// Fetch the entries
$entries = serendipity_fetchEntries(false, false, serendipity_db_limit($offSet, $perPage + 1), true, false, $orderby, $filter_sql);
?>
<div class="serendipity_admin_list">
<form action="?" method="get">
<input type="hidden" name="serendipity[action]" value="admin" />
<input type="hidden" name="serendipity[adminModule]" value="entries" />
<input type="hidden" name="serendipity[adminAction]" value="editSelect" />
<table width="100%" class="serendipity_admin_filters">
<tr>
<td class="serendipity_admin_filters_headline" colspan="6"><strong><?php
echo FILTERS;
?>
</strong> - <?php
echo FIND_ENTRIES;
?>
</td>
</tr>
<tr>
<td valign="top" width="80"><?php
echo AUTHOR;
?>
</td>
<td valign="top">
<select name="serendipity[filter][author]">
<option value="">--</option>
<?php
$users = serendipity_fetchUsers('', null, true);
if (is_array($users)) {
foreach ($users as $user) {
if (isset($user['artcount']) && $user['artcount'] < 1) {
continue;
}
echo '<option value="' . $user['authorid'] . '" ' . (isset($serendipity['GET']['filter']['author']) && $serendipity['GET']['filter']['author'] == $user['authorid'] ? 'selected="selected"' : '') . '>' . htmlspecialchars($user['realname']) . '</option>' . "\n";
}
}
?>
</select> <select name="serendipity[filter][isdraft]">
<option value="all"><?php
echo COMMENTS_FILTER_ALL;
?>
</option>
<option value="draft" <?php
echo isset($serendipity['GET']['filter']['isdraft']) && $serendipity['GET']['filter']['isdraft'] == 'draft' ? 'selected="selected"' : '';
?>
><?php
echo DRAFT;
//.........这里部分代码省略.........
示例12: log
function log($logfile, $id, $switch, $reason, $comment)
{
global $serendipity;
$method = $this->get_config('logtype');
switch ($method) {
case 'file':
if (empty($logfile)) {
return;
}
if (strpos($logfile, '%') !== false) {
$logfile = strftime($logfile);
}
$fp = @fopen($logfile, 'a+');
if (!is_resource($fp)) {
return;
}
fwrite($fp, sprintf('[%s] - [%s: %s] - [#%s, Name "%s", E-Mail "%s", URL "%s", User-Agent "%s", IP %s] - [%s]' . "\n", date('Y-m-d H:i:s', serendipity_serverOffsetHour()), $switch, $reason, $id, str_replace("\n", ' ', $comment['name']), str_replace("\n", ' ', $comment['email']), str_replace("\n", ' ', $comment['url']), str_replace("\n", ' ', $_SERVER['HTTP_USER_AGENT']), $_SERVER['REMOTE_ADDR'], str_replace("\n", ' ', $comment['comment'])));
fclose($fp);
break;
case 'none':
return;
break;
case 'db':
default:
$q = sprintf("INSERT INTO {$serendipity['dbPrefix']}spamblocklog\n (timestamp, type, reason, entry_id, author, email, url, useragent, ip, referer, body)\n VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", serendipity_serverOffsetHour(), serendipity_db_escape_string($switch), serendipity_db_escape_string($reason), serendipity_db_escape_string($id), serendipity_db_escape_string($comment['name']), serendipity_db_escape_string($comment['email']), serendipity_db_escape_string($comment['url']), substr(serendipity_db_escape_string($_SERVER['HTTP_USER_AGENT']), 0, 255), serendipity_db_escape_string($_SERVER['REMOTE_ADDR']), substr(serendipity_db_escape_string(isset($_SESSION['HTTP_REFERER']) ? $_SESSION['HTTP_REFERER'] : $_SERVER['HTTP_REFERER']), 0, 255), serendipity_db_escape_string($comment['comment']));
serendipity_db_query($q);
break;
}
}
示例13: show_plugins
/**
* Show the list of plugins
*
* Shows a HTML list of all installed plugins, complete with config/delete/sort order options
*
* @access public
* @param boolean Indicates if event plugins (TRUE) or sidebar plugins (FALSE) shall be shown
* @return null
*/
function show_plugins($event_only = false, $sidebars = null)
{
global $serendipity;
$sql_filter = '';
if (is_array($sidebars)) {
foreach ($sidebars as $sidebar) {
$up = strtoupper($sidebar);
if ($sidebar == 'hide') {
$opts[$sidebar] = HIDDEN;
} elseif (defined('SIDEBAR_' . $up)) {
$opts[$sidebar] = constant('SIDEBAR_' . $up);
} elseif (defined($up)) {
$opts[$sidebar] = constant($up);
} else {
$opts[$sidebar] = $up;
}
$sql_filter .= "AND placement != '" . serendipity_db_escape_string($sidebar) . "' ";
}
}
if (!$event_only) {
$sql = "SELECT * from {$serendipity['dbPrefix']}plugins\n WHERE placement != 'event'\n AND placement != 'eventh'\n " . $sql_filter;
$invisible_plugins = serendipity_db_query($sql);
if (is_array($invisible_plugins)) {
$sidebars[] = 'NONE';
$opts['NONE'] = NONE;
}
}
$opts['event'] = PLUGIN_ACTIVE;
$opts['eventh'] = PLUGIN_INACTIVE;
$data['event_only'] = $event_only;
if (!$event_only) {
$data['is_first'] = true;
}
$data['serendipity_setFormToken'] = serendipity_setFormToken();
$data['serendipity_setFormTokenUrl'] = serendipity_setFormToken('url');
/* Block display the plugins per placement location. */
if ($event_only) {
$plugin_placements = array('event', 'eventh');
} else {
$plugin_placements = $sidebars;
}
$data['plugin_placements'] = $plugin_placements;
static $users = array();
if (empty($users)) {
$users = serendipity_fetchUsers('', 'hidden');
}
$data['users'] = $users;
$i = 0;
foreach ($plugin_placements as $plugin_placement) {
if (!$event_only && $plugin_placement == 'NONE') {
$is_invisible = true;
} else {
$is_invisible = false;
}
$data['placement'][$plugin_placement]['ptitle'] = $ptitle = $opts[$plugin_placement];
$data['placement'][$plugin_placement]['pid'] = $pid = $plugin_placement;
if ($is_invisible) {
$plugins = $invisible_plugins;
} else {
$plugins = serendipity_plugin_api::enum_plugins($plugin_placement);
}
if (!is_array($plugins)) {
continue;
}
$sort_idx = 0;
foreach ($plugins as $plugin_data) {
$i++;
$plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']);
$key = urlencode($plugin_data['name']);
$css_key = 's9ycid' . str_replace('%', '-', $key);
$is_plugin_owner = $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers');
$is_plugin_editable = $is_plugin_owner || $plugin_data['authorid'] == '0';
$cname = explode(':', $plugin_data['name']);
if (!is_object($plugin)) {
$name = $title = ERROR . '!';
$desc = ERROR . ': ' . $plugin_data['name'];
$can_configure = false;
} else {
/* query for its name, description and configuration data */
$bag = new serendipity_property_bag();
$plugin->introspect($bag);
$name = serendipity_specialchars($bag->get('name'));
$desc = '<details class="plugin_data">';
$desc .= '<summary><var class="perm_name">' . $cname[0] . '</var></summary>';
$desc .= '<div class="plugin_desc clearfix">' . serendipity_specialchars($bag->get('description')) . '</div>';
$desc .= '<span class="block_level">' . VERSION . ': ' . $bag->get('version') . '</span>';
$desc .= '</details>';
$title = serendipity_plugin_api::get_plugin_title($plugin, '[' . $name . ']');
if ($bag->is_set('configuration') && ($plugin->protected === FALSE || $plugin_data['authorid'] == '0' || $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'))) {
$can_configure = true;
} else {
//.........这里部分代码省略.........
示例14: serendipity_printEntries_rss
/**
* Parses entries to display them for RSS/Atom feeds to be passed on to generic Smarty templates
*
* This function searches for existing RSS feed template customizations. As long as a template
* with the same name as the $version variable exists, it will be emitted.
*
* @access public
* @see serendipity_fetchEntries(), rss.php
* @param array A superarray of entries to output
* @param string The version/type of a RSS/Atom feed to display (atom1_0, rss2_0 etc)
* @param boolean If true, this is a comments feed. If false, it's an Entry feed.
* @param boolean Indicates if this feed is a fulltext feed (true) or only excercpt (false)
* @param boolean Indicates if E-Mail addresses should be shown (true) or hidden (false)
* @return
*/
function serendipity_printEntries_rss(&$entries, $version, $comments = false, $fullFeed = false, $showMail = true)
{
global $serendipity;
$options = array('version' => $version, 'comments' => $comments, 'fullFeed' => $fullFeed, 'showMail' => $showMail);
serendipity_plugin_api::hook_event('frontend_entries_rss', $entries, $options);
if (is_array($entries)) {
foreach ($entries as $key => $_entry) {
$entry =& $entries[$key];
if (isset($entry['entrytimestamp'])) {
$e_ts = $entry['entrytimestamp'];
} else {
$e_ts = $entry['timestamp'];
}
$entry['feed_id'] = isset($entry['entryid']) && !empty($entry['entryid']) ? $entry['entryid'] : $entry['id'];
// set feed guid only, if not already defined externaly
if (empty($entry['feed_guid'])) {
$entry['feed_guid'] = serendipity_rss_getguid($entry, $options['comments']);
}
$entry['feed_entryLink'] = serendipity_archiveURL($entry['feed_id'], $entry['title'], 'baseURL', true, array('timestamp' => $e_ts));
if ($options['comments'] == true) {
// Display username as part of the title for easier feed-readability
if ($entry['type'] == 'TRACKBACK' && !empty($entry['ctitle'])) {
$entry['author'] .= ' - ' . $entry['ctitle'];
}
$entry['title'] = (!empty($entry['author']) ? $entry['author'] : ANONYMOUS) . ': ' . $entry['title'];
// No HTML allowed here:
$entry['body'] = strip_tags($entry['body']);
}
// Embed a link to extended entry, if existing
if ($options['fullFeed']) {
$entry['body'] .= ' ' . $entry['extended'];
$ext = '';
} elseif ($entry['exflag']) {
$ext = '<br /><a href="' . $entry['feed_entryLink'] . '#extended">' . sprintf(VIEW_EXTENDED_ENTRY, htmlspecialchars($entry['title'])) . '</a>';
} else {
$ext = '';
}
$addData = array('from' => 'functions_entries:printEntries_rss', 'rss_options' => $options);
serendipity_plugin_api::hook_event('frontend_display', $entry, $addData);
// Do some relative -> absolute URI replacing magic. Replaces all HREF/SRC (<a>, <img>, ...) references to only the serendipitypath with the full baseURL URI
// garvin: Could impose some problems. Closely watch this one.
$entry['body'] = preg_replace('@(href|src)=("|\')(' . preg_quote($serendipity['serendipityHTTPPath']) . ')(.*)("|\')(.*)>@imsU', '\\1=\\2' . $serendipity['baseURL'] . '\\4\\2\\6>', $entry['body']);
// jbalcorn: clean up body for XML compliance as best we can.
$entry['body'] = xhtml_cleanup($entry['body']);
// extract author information
if (isset($entry['no_email']) && $entry['no_email'] || $options['showMail'] === FALSE) {
$entry['email'] = 'nospam@example.com';
// RSS Feeds need an E-Mail address!
} elseif (empty($entry['email'])) {
$query = "select email FROM {$serendipity['dbPrefix']}authors WHERE authorid = '" . serendipity_db_escape_string($entry['authorid']) . "'";
$results = serendipity_db_query($query);
$entry['email'] = $results[0]['email'];
}
if (!is_array($entry['categories'])) {
$entry['categories'] = array(0 => array('category_name' => $entry['category_name'], 'feed_category_name' => serendipity_utf8_encode(htmlspecialchars($entry['category_name'])), 'categoryURL' => serendipity_categoryURL($entry, 'baseURL')));
} else {
foreach ($entry['categories'] as $cid => $_cat) {
$cat =& $entry['categories'][$cid];
$cat['categoryURL'] = serendipity_categoryURL($cat, 'baseURL');
$cat['feed_category_name'] = serendipity_utf8_encode(htmlspecialchars($cat['category_name']));
}
}
// Prepare variables
// 1. UTF8 encoding + htmlspecialchars.
$entry['feed_title'] = serendipity_utf8_encode(htmlspecialchars($entry['title']));
$entry['feed_blogTitle'] = serendipity_utf8_encode(htmlspecialchars($serendipity['blogTitle']));
$entry['feed_title'] = serendipity_utf8_encode(htmlspecialchars($entry['title']));
$entry['feed_author'] = serendipity_utf8_encode(htmlspecialchars($entry['author']));
$entry['feed_email'] = serendipity_utf8_encode(htmlspecialchars($entry['email']));
// 2. gmdate
$entry['feed_timestamp'] = gmdate('Y-m-d\\TH:i:s\\Z', serendipity_serverOffsetHour($entry['timestamp']));
$entry['feed_last_modified'] = gmdate('Y-m-d\\TH:i:s\\Z', serendipity_serverOffsetHour($entry['last_modified']));
$entry['feed_timestamp_r'] = date('r', serendipity_serverOffsetHour($entry['timestamp']));
// 3. UTF8 encoding
$entry['feed_body'] = serendipity_utf8_encode($entry['body']);
$entry['feed_ext'] = serendipity_utf8_encode($ext);
$entry_hook = 'frontend_display:unknown:per-entry';
switch ($version) {
case 'opml1.0':
$entry_hook = 'frontend_display:opml-1.0:per_entry';
break;
case '0.91':
$entry_hook = 'frontend_display:rss-0.91:per_entry';
break;
case '1.0':
//.........这里部分代码省略.........
示例15: import
function import()
{
global $serendipity;
// Save this so we can return it to its original value at the end of this method.
$noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false;
if ($this->data['autodiscovery'] == 'false') {
$serendipity['noautodiscovery'] = 1;
}
$this->getTransTable();
$this->data['prefix'] = serendipity_db_escape_string($this->data['prefix']);
$users = array();
$entries = array();
if (!extension_loaded('mysqli')) {
return MYSQL_REQUIRED;
}
$gdb = @mysqli_connect($this->data['host'], $this->data['user'], $this->data['pass']);
if (!$gdb || mysqli_connect_error()) {
return sprintf(COULDNT_CONNECT, serendipity_specialchars($this->data['host']));
}
if (!@mysqli_select_db($gdb, $this->data['name'])) {
return sprintf(COULDNT_SELECT_DB, mysqli_error($gdb));
}
/* Users */
$res = @$this->nativeQuery("SELECT user_id AS ID,\n username AS user_login,\n user_password AS user_pass,\n user_email AS user_email,\n user_website AS user_url,\n user_level\n FROM {$this->data['prefix']}users\n WHERE user_active = 1", $gdb);
if (!$res) {
return sprintf(COULDNT_SELECT_USER_INFO, mysqli_error($gdb));
}
for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
$users[$x] = mysqli_fetch_assoc($res);
$data = array('right_publish' => 1, 'realname' => $users[$x]['user_login'], 'username' => $users[$x]['user_login'], 'email' => $users[$x]['user_email'], 'userlevel' => $users[$x]['user_level'] == 0 ? USERLEVEL_EDITOR : USERLEVEL_ADMIN, 'password' => $users[$x]['user_pass']);
// MD5 compatible
if ($serendipity['serendipityUserlevel'] < $data['userlevel']) {
$data['userlevel'] = $serendipity['serendipityUserlevel'];
}
serendipity_db_insert('authors', $this->strtrRecursive($data));
echo mysqli_error();
$users[$x]['authorid'] = serendipity_db_insert_id('authors', 'authorid');
}
/* Categories */
$res = @$this->nativeQuery("SELECT cat_id AS cat_ID, \n cat_title AS cat_name \n FROM {$this->data['prefix']}categories", $gdb);
if (!$res) {
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysqli_error($gdb));
}
// Get all the info we need
for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
$parent_categories[] = mysqli_fetch_assoc($res);
}
for ($x = 0, $max_x = sizeof($parent_categories); $x < $max_x; $x++) {
$cat = array('category_name' => $parent_categories[$x]['cat_name'], 'category_description' => '', 'parentid' => 0, 'category_left' => 0, 'category_right' => 0);
serendipity_db_insert('category', $this->strtrRecursive($cat));
$parent_categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
}
/* Categories */
$res = @$this->nativeQuery("SELECT forum_id AS cat_ID,\n cat_id AS parent_cat_id, \n forum_name AS cat_name, \n forum_desc AS category_description \n FROM {$this->data['prefix']}forums ORDER BY forum_order;", $gdb);
if (!$res) {
return sprintf(COULDNT_SELECT_CATEGORY_INFO, mysqli_error($gdb));
}
// Get all the info we need
for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
$categories[] = mysqli_fetch_assoc($res);
}
// Insert all categories as top level (we need to know everyone's ID before we can represent the hierarchy).
for ($x = 0, $max_x = sizeof($categories); $x < $max_x; $x++) {
$pcatid = 0;
foreach ($parent_categories as $pcat) {
if ($pcat['cat_ID'] == $categories[$x]['parent_cat_id']) {
$pcatid = $pcat['cat_ID'];
break;
}
}
$cat = array('category_name' => $categories[$x]['cat_name'], 'category_description' => $categories[$x]['category_description'], 'parentid' => $pcatid, 'category_left' => 0, 'category_right' => 0);
serendipity_db_insert('category', $this->strtrRecursive($cat));
$categories[$x]['categoryid'] = serendipity_db_insert_id('category', 'categoryid');
}
serendipity_rebuildCategoryTree();
/* Entries */
$res = @$this->nativeQuery("SELECT t.topic_title, \n t.topic_poster,\n t.forum_id,\n p.post_time,\n pt.post_subject,\n pt.post_text,\n count(p.topic_id) AS ccount,\n p.topic_id,\n MIN(p.post_id) AS post_id\n FROM {$this->data['prefix']}topics AS t\n LEFT OUTER JOIN {$this->data['prefix']}posts AS p\n ON t.topic_id = p.topic_id\n LEFT OUTER JOIN {$this->data['prefix']}posts_text AS pt\n ON pt.post_id = p.post_id\n GROUP BY p.topic_id\n ", $gdb);
if (!$res) {
return sprintf(COULDNT_SELECT_ENTRY_INFO, mysqli_error($gdb));
}
for ($x = 0, $max_x = mysqli_num_rows($res); $x < $max_x; $x++) {
$entries[$x] = mysqli_fetch_assoc($res);
$entry = array('title' => $this->decode($entries[$x]['post_subject']), 'isdraft' => 'false', 'allow_comments' => 'true', 'timestamp' => $entries[$x]['post_time'], 'body' => $this->strtr($entries[$x]['post_text']), 'extended' => '');
$entry['authorid'] = '';
$entry['author'] = '';
foreach ($users as $user) {
if ($user['ID'] == $entries[$x]['topic_poster']) {
$entry['authorid'] = $user['authorid'];
$entry['author'] = $user['user_login'];
break;
}
}
if (!is_int($entries[$x]['entryid'] = serendipity_updertEntry($entry))) {
return $entries[$x]['entryid'];
}
/* Entry/category */
foreach ($categories as $category) {
if ($category['cat_ID'] == $entries[$x]['forum_id']) {
$data = array('entryid' => $entries[$x]['entryid'], 'categoryid' => $category['categoryid']);
serendipity_db_insert('entrycat', $this->strtrRecursive($data));
//.........这里部分代码省略.........