当前位置: 首页>>代码示例>>PHP>>正文


PHP serendipity_db_limit_sql函数代码示例

本文整理汇总了PHP中serendipity_db_limit_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_db_limit_sql函数的具体用法?PHP serendipity_db_limit_sql怎么用?PHP serendipity_db_limit_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了serendipity_db_limit_sql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: AND

/**
 * Fetch a list of trackbacks for an entry
 *
 * @access public
 * @param   int     The ID of the entry
 * @param   string  How many trackbacks to show
 * @param   boolean If true, also non-approved trackbacks will be shown
 * @return
 */
function &serendipity_fetchTrackbacks($id, $limit = null, $showAll = false)
{
    global $serendipity;
    if (!$showAll) {
        $and = "AND status = 'approved'";
    }
    $query = "SELECT * FROM {$serendipity['dbPrefix']}comments WHERE entry_id = '" . (int) $id . "' AND (type = 'TRACKBACK' OR type = 'PINGBACK') {$and} ORDER BY id";
    if (isset($limit)) {
        $limit = serendipity_db_limit_sql($limit);
        $query .= " {$limit}";
    }
    $comments = serendipity_db_query($query);
    if (!is_array($comments)) {
        return array();
    }
    return $comments;
}
开发者ID:REAP720801,项目名称:Serendipity,代码行数:26,代码来源:functions_smarty.inc.php

示例2: serendipity_fetchComments

/**
 * Fetch an array of comments to a specific entry id
 *
 * @access public
 * @param   int     The Entry ID to fetch comments for
 * @param   int     How many comments to fetch (empty: all)
 * @param   string  How shall comments be ordered (ASC|DESC)
 * @param   boolean Shall non-approved comments be displayed?
 * @param   string  Comment type to fetch
 * @return  array   The SQL result of comments
 */
function serendipity_fetchComments($id, $limit = null, $order = '', $showAll = false, $type = 'NORMAL', $where = '')
{
    global $serendipity;
    $and = '';
    if (!empty($limit)) {
        $limit = serendipity_db_limit_sql($limit);
    } else {
        $limit = '';
    }
    if ($type == 'comments' || empty($type)) {
        $type = 'NORMAL';
    } elseif ($type == 'trackbacks') {
        $type = 'TRACKBACK';
    } elseif ($type == 'pingbacks') {
        $type = 'PINGBACK';
    } elseif ($type == 'comments_and_trackbacks') {
        $type = '%';
    }
    if (!empty($id)) {
        $and .= " AND co.entry_id = '" . (int) $id . "'";
    }
    if (!$showAll) {
        $and .= ' AND co.status = \'approved\'';
    }
    $and .= $where;
    if ($serendipity['dbType'] == 'postgres' || $serendipity['dbType'] == 'pdo-postgres') {
        $group = '';
        $distinct = 'DISTINCT';
    } else {
        $group = 'GROUP BY co.id';
        $distinct = '';
    }
    $query = "SELECT {$distinct}\n                    co.id,\n                    co.entry_id, co.timestamp, co.title AS ctitle, co.email, co.url, co.ip, co.body, co.type, co.subscribed,\n                    co.author,\n                    e.title,\n                    e.timestamp AS entrytimestamp,\n                    e.id AS entryid,\n                    e.authorid,\n                    co.id AS commentid,\n                    co.parent_id AS parent_id\n              FROM\n                    {$serendipity['dbPrefix']}comments AS co\n                    LEFT JOIN {$serendipity['dbPrefix']}entries AS e ON (co.entry_id = e.id)\n              WHERE co.type LIKE '" . $type . "' AND co.entry_id > 0 {$and}\n              {$group}\n              ORDER BY\n                    " . ($where != '' ? '' : 'co.id') . " " . ($order != '' ? $order : '') . "\n                    {$limit}";
    $comments = serendipity_db_query($query, false, 'assoc');
    if (!is_array($comments)) {
        $comments = array();
    }
    $addData = array('id' => $id, 'limit' => $limit, 'order' => $order, 'showAll' => $showAll, 'type' => $type, 'where' => $where);
    serendipity_plugin_api::hook_event('fetchcomments', $comments, $addData);
    return $comments;
}
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:52,代码来源:functions_comments.inc.php

示例3: generate_content

 function generate_content(&$title)
 {
     global $serendipity;
     $number = $this->get_config('number');
     $dateformat = $this->get_config('dateformat');
     $category = $this->get_config('category', 'none');
     $show_where = $this->get_config('show_where', 'both');
     if ($show_where == 'extended' && (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id']))) {
         return false;
     } else {
         if ($show_where == 'overview' && isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) {
             return false;
         }
     }
     if ($category == '_cur') {
         $category = $serendipity['GET']['category'];
         if (empty($category) && !empty($serendipity['GET']['id'])) {
             $entry = serendipity_fetchEntry('id', $serendipity['GET']['id']);
             $category = $entry['categories'][0]['categoryid'];
         }
     }
     $title = $this->get_config('title', $this->title);
     $number_from_sw = $this->get_config('number_from');
     $randomize = $this->get_config('randomize') == "yes" ? true : false;
     $sql_condition = array();
     $sql_condition['joins'] = '';
     $sql_condition['and'] = '';
     if ($category != 'none' && !empty($category)) {
         $sql_categories = array();
         if (is_numeric($category)) {
             $sql_categories[] = $category;
         } else {
             $sql_categories = explode('^', $category);
         }
         $category_parts = array();
         foreach ($sql_categories as $sql_category) {
             $category_parts[] = "\n" . implode(' AND ', serendipity_fetchCategoryRange($sql_category));
         }
         $sql_condition['and'] .= ' AND (c.category_left BETWEEN ' . implode(' OR c.category_left BETWEEN ', $category_parts) . ')';
     }
     if (!$number || !is_numeric($number) || $number < 1) {
         $number = 10;
     }
     $sql_number = serendipity_db_limit_sql($number);
     $db = $serendipity['dbType'];
     switch ($number_from_sw) {
         case 'skip':
             $sql_number = serendipity_db_limit_sql(serendipity_db_limit($serendipity['fetchLimit'], $number));
             break;
     }
     if (!$dateformat || strlen($dateformat) < 1) {
         $dateformat = '%A, %B %e %Y';
     }
     if ($randomize) {
         if ($db == 'mysql' || $db == 'mysqli') {
             $sql_order = "ORDER BY RAND()";
         } else {
             // SQLite and PostgreSQL support this, hooray.
             $sql_order = "ORDER BY RANDOM()";
         }
     } else {
         $sql_order = "ORDER BY timestamp DESC ";
     }
     $sql_condition['and'] .= "AND timestamp <= " . time();
     serendipity_ACL_SQL($sql_condition, $category == 'none');
     if (!stristr($sql_condition['joins'], $serendipity['dbPrefix'] . 'category')) {
         $sql_condition['joins'] = ' LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'category AS c  ON ec.categoryid = c.categoryid ' . $sql_condition['joins'];
     }
     if (!stristr($sql_condition['joins'], $serendipity['dbPrefix'] . 'entrycat')) {
         $sql_condition['joins'] = ' LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'entrycat AS ec ON id = ec.entryid ' . $sql_condition['joins'];
     }
     $entries_query = "SELECT DISTINCT id,\n                                title,\n                                timestamp,\n                                epm.value AS multilingual_title\n                           FROM {$serendipity['dbPrefix']}entries AS e\n                                {$sql_condition['joins']}\n\n                LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties AS epm\n                             ON (epm.entryid = e.id AND epm.property = 'multilingual_title_" . $serendipity['lang'] . "')\n\n                          WHERE isdraft = 'false' {$sql_condition['and']}\n                                {$sql_order}\n                                {$sql_number}";
     $entries = serendipity_db_query($entries_query);
     if (is_string($entries)) {
         echo $entries . "<br />\n";
         echo $entries_query . "<br />\n";
     }
     if (isset($entries) && is_array($entries)) {
         echo '<dl>' . "\n";
         foreach ($entries as $k => $entry) {
             if (!empty($entry['multilingual_title'])) {
                 $entry['title'] = $entry['multilingual_title'];
             }
             $entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
             if (empty($entry['title'])) {
                 $entry['title'] = '#' . $entry['id'];
             }
             echo '<dt class="serendipity_recententries_entrylink"><a href="' . $entryLink . '" title="' . serendipity_specialchars($entry['title']) . '">' . serendipity_specialchars($entry['title']) . '</a></dt>' . "\n" . '<dd class="serendipity_recententries_entrydate serendipitySideBarDate">' . serendipity_specialchars(serendipity_strftime($dateformat, $entry['timestamp'])) . '</dd>' . "\n";
         }
         echo '</dl>' . "\n\n";
     }
 }
开发者ID:jimjag,项目名称:Serendipity,代码行数:92,代码来源:serendipity_plugin_recententries.php

示例4: serendipity_fetchImagesFromDatabase

/**
 * Gets a list of media items from our media database
 *
 * LONG
 *
 * @access public
 * @param   int     The offset to start fetching media files
 * @param   int     How many items to fetch
 * @param   int     The number (referenced varaible) of fetched items
 * @param   string  The "ORDER BY" sql part when fetching items
 * @param   string  Order by DESC or ASC
 * @param   string  Only fetch files from a specific directory
 * @param   string  Only fetch specific filenames
 * @param   string  Only fetch media with specific keyword
 * @param   array   An array of restricting filter sets
 * @param   boolean Apply strict directory checks, or include subdirectories?
 * @return  array   Resultset of images
 */
function serendipity_fetchImagesFromDatabase($start = 0, $limit = 0, &$total, $order = false, $ordermode = false, $directory = '', $filename = '', $keywords = '', $filter = array(), $strict_directory = false)
{
    global $serendipity;
    $cond = array('joinparts' => array(), 'parts' => array());
    $orderfields = serendipity_getImageFields();
    if (empty($order) || !isset($orderfields[$order])) {
        $order = 'i.date';
    }
    if (!is_array($filter)) {
        $filter = array();
    }
    if (empty($ordermode) || $ordermode != 'DESC' && $ordermode != 'ASC') {
        $ordermode = 'DESC';
    }
    if ($order == 'name') {
        $order = 'realname ' . $ordermode . ', name';
    }
    if ($limit != 0) {
        $limitsql = serendipity_db_limit_sql(serendipity_db_limit($start, $limit));
    }
    if ($strict_directory) {
        $cond['parts']['directory'] = " AND i.path = '" . serendipity_db_escape_string($directory) . "'\n";
    } elseif (!empty($directory)) {
        $cond['parts']['directory'] = " AND i.path LIKE '" . serendipity_db_escape_string($directory) . "%'\n";
    }
    if (!empty($filename)) {
        $cond['parts']['filename'] = " AND (i.name     like '%" . serendipity_db_escape_string($filename) . "%' OR\n                  i.realname like '%" . serendipity_db_escape_string($filename) . "%')\n";
    }
    if (!is_array($keywords)) {
        if (!empty($keywords)) {
            $keywords = explode(';', $keywords);
        } else {
            $keywords = array();
        }
    }
    if (count($keywords) > 0) {
        $cond['parts']['keywords'] = " AND (mk.property IN ('" . serendipity_db_implode("', '", $keywords, 'string') . "'))\n";
        $cond['joinparts']['keywords'] = true;
    }
    foreach ($filter as $f => $fval) {
        if (!isset($orderfields[$f]) || empty($fval)) {
            continue;
        }
        if (is_array($fval)) {
            if (empty($fval['from']) || empty($fval['to'])) {
                continue;
            }
            if ($orderfields[$f]['type'] == 'date') {
                $fval['from'] = serendipity_convertToTimestamp(trim($fval['from']));
                $fval['to'] = serendipity_convertToTimestamp(trim($fval['to']));
            }
            if (substr($f, 0, 3) === 'bp.') {
                $realf = substr($f, 3);
                $cond['parts']['filter'] .= " AND (bp2.property = '{$realf}' AND bp2.value >= " . (int) $fval['from'] . " AND bp2.value <= " . (int) $fval['to'] . ")\n";
            } else {
                $cond['parts']['filter'] .= " AND ({$f} >= " . (int) $fval['from'] . " AND {$f} <= " . (int) $fval['to'] . ")\n";
            }
        } elseif ($f == 'i.authorid') {
            $cond['parts']['filter'] .= " AND (\n                                    (hp.property = 'authorid' AND hp.value = " . (int) $fval . ")\n                                    OR\n                                    (i.authorid = " . (int) $fval . ")\n                                )\n";
            $cond['joinparts']['hiddenproperties'] = true;
        } elseif ($orderfields[$f]['type'] == 'int') {
            if (substr($f, 0, 3) === 'bp.') {
                $realf = substr($f, 3);
                $cond['parts']['filter'] .= " AND (bp2.property = '{$realf}' AND bp2.value = '" . serendipity_db_escape_string(trim($fval)) . "')\n";
            } else {
                $cond['parts']['filter'] .= " AND ({$f} = '" . serendipity_db_escape_string(trim($fval)) . "')\n";
            }
        } else {
            if (substr($f, 0, 3) === 'bp.') {
                $realf = substr($f, 3);
                $cond['parts']['filter'] .= " AND (bp2.property = '{$realf}' AND bp2.value LIKE '%" . serendipity_db_escape_string(trim($fval)) . "%')\n";
            } else {
                $cond['parts']['filter'] .= " AND ({$f} LIKE '%" . serendipity_db_escape_string(trim($fval)) . "%')\n";
            }
        }
        $cond['joinparts']['filterproperties'] = true;
    }
    if (isset($serendipity['authorid']) && !serendipity_checkPermission('adminImagesViewOthers')) {
        $cond['parts']['authorid'] .= " AND (i.authorid = 0 OR i.authorid = " . (int) $serendipity['authorid'] . ")\n";
    }
    $cond['and'] = 'WHERE 1=1 ' . implode("\n", $cond['parts']);
    $cond['args'] = func_get_args();
//.........这里部分代码省略.........
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:functions_images.inc.php

示例5: fopen

/**
 * Searches the list of entries by a specific term
 *
 * @todo: Allow to show results of staticpage plugins or others
 * @access public
 * @param   string      The searchterm (may contain wildcards)
 * @param   int         Restrict the number of results [also uses $serendipity['GET']['page'] for pagination]
 * @param   array       Add search Results at the top
 * @return  array       Returns the superarray of entries found
 */
function &serendipity_searchEntries($term, $limit = '', $searchresults = '')
{
    global $serendipity;
    static $log_queries = false;
    if ($log_queries) {
        $fp = fopen($serendipity['serendipityPath'] . '/archives/queries.csv', 'a');
        fwrite($fp, date('Y-m-d H:i') . ';' . $_SERVER['REMOTE_ADDR'] . ';' . $term . "\n");
        fclose($fp);
    }
    $orig_limit = $limit;
    if ($limit == '') {
        $limit = $serendipity['fetchLimit'];
    }
    if (isset($serendipity['GET']['page']) && $serendipity['GET']['page'] > 1 && !strstr($limit, ',')) {
        $limit = serendipity_db_limit(($serendipity['GET']['page'] - 1) * $limit, $limit);
    }
    $limit = serendipity_db_limit_sql($limit);
    $term = serendipity_db_escape_string($term);
    $cond = array();
    $relevance_enabled = false;
    if ($serendipity['dbType'] == 'postgres' || $serendipity['dbType'] == 'pdo-postgres') {
        $cond['group'] = '';
        $cond['distinct'] = 'DISTINCT';
        $r = serendipity_db_query("SELECT count(routine_name) AS counter\n                                     FROM information_schema.routines\n                                    WHERE routine_name LIKE 'to_tsvector'\n                                      AND specific_catalog = '" . $serendipity['dbName'] . "'");
        if (is_array($r) && $r[0]['counter'] > 0) {
            $term = str_replace('&amp;', '&', $term);
            $cond['find_part'] = "(\n            to_tsvector('english', title)    @@to_tsquery('{$term}') OR\n            to_tsvector('english', body)     @@to_tsquery('{$term}') OR\n            to_tsvector('english', extended) @@to_tsquery('{$term}')\n            )";
        } else {
            $cond['find_part'] = "(title ILIKE '%{$term}%' OR body ILIKE '%{$term}%' OR extended ILIKE '%{$term}%')";
        }
    } elseif ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3') {
        // Very extensive SQLite search. There currently seems no other way to perform fulltext search in SQLite
        // But it's better than no search at all :-D
        $cond['group'] = 'GROUP BY e.id';
        $cond['distinct'] = '';
        $term = serendipity_mb('strtolower', $term);
        $cond['find_part'] = "(lower(title) LIKE '%{$term}%' OR lower(body) LIKE '%{$term}%' OR lower(extended) LIKE '%{$term}%')";
    } else {
        $cond['group'] = 'GROUP BY e.id';
        $cond['distinct'] = '';
        $term = str_replace('&quot;', '"', $term);
        $relevance_enabled = true;
        if (preg_match('@["\\+\\-\\*~<>\\(\\)]+@', $term)) {
            $cond['find_part'] = "MATCH(title,body,extended) AGAINST('{$term}' IN BOOLEAN MODE)";
        } else {
            $cond['find_part'] = "MATCH(title,body,extended) AGAINST('{$term}')";
        }
    }
    switch ($serendipity['searchsort']) {
        case 'relevance':
            if ($relevance_enabled) {
                $cond['searchorderby'] = $cond['find_part'] . " DESC";
            } else {
                $cond['searchorderby'] = "timestamp DESC";
            }
            break;
        case 'timestamp':
        default:
            $cond['searchorderby'] = "timestamp DESC";
            break;
    }
    $cond['and'] = " AND isdraft = 'false' " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . serendipity_db_time() : '');
    serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'search', 'term' => $term));
    serendipity_ACL_SQL($cond, 'limited');
    $serendipity['fullCountQuery'] = "\n                      FROM\n                            {$serendipity['dbPrefix']}entries e\n                 LEFT JOIN  {$serendipity['dbPrefix']}authors a\n                        ON  e.authorid = a.authorid\n                 LEFT JOIN  {$serendipity['dbPrefix']}entrycat ec\n                        ON  e.id = ec.entryid\n                            {$cond['joins']}\n                     WHERE\n                            ({$cond['find_part']})\n                            {$cond['and']}";
    $querystring = "SELECT {$cond['distinct']}\n                            {$cond['addkey']}\n                            e.id,\n                            e.authorid,\n                            a.realname AS author,\n                            e.allow_comments,\n                            e.moderate_comments,\n                            a.email,\n                            e.timestamp,\n                            e.comments,\n                            e.title,\n                            e.body,\n                            e.extended,\n                            e.trackbacks,\n                            e.exflag,\n                            e.isdraft,\n                            e.last_modified,\n                            a.username AS loginname\n                    {$serendipity['fullCountQuery']}\n                    {$cond['group']}\n                    {$cond['having']}\n                  ORDER BY  {$cond['searchorderby']}\n                    {$limit}";
    $search =& serendipity_db_query($querystring);
    //Add param searchresults at the top and remove duplicates.
    if (is_array($searchresults)) {
        $ids_current = array();
        foreach ($searchresults as $idx => $data) {
            $ids_current[$data['id']] = true;
        }
        foreach ($search as $idx => $data) {
            if (isset($ids_current[$data['id']])) {
                unset($search[$idx]);
            }
        }
        $search = array_merge($searchresults, $search);
    }
    //if * wasn't already appended and if there are none or not enough
    //results, search again for entries containing the searchterm as a part
    if (strpos($term, '*') === false) {
        if (!is_array($search)) {
            return serendipity_searchEntries($term . '*', $orig_limit);
        } else {
            if (count($search) < 4) {
                return serendipity_searchEntries($term . '*', $orig_limit, $search);
            }
        }
//.........这里部分代码省略.........
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:functions_entries.inc.php

示例6: event_hook


//.........这里部分代码省略.........
                    $sort_order = array('votetime' => DATE, 'user_agent' => USER_AGENT, 'title' => TITLE, 'entryid' => 'ID');
                    if (empty($serendipity['GET']['sort']['ordermode']) || $serendipity['GET']['sort']['ordermode'] != 'ASC') {
                        $desc = true;
                        $serendipity['GET']['sort']['ordermode'] = 'DESC';
                    }
                    if (!empty($serendipity['GET']['sort']['order']) && !empty($sort_order[$serendipity['GET']['sort']['order']])) {
                        $curr_order = $serendipity['GET']['sort']['order'];
                        $orderby = serendipity_db_escape_string($curr_order . ' ' . $serendipity['GET']['sort']['ordermode']);
                    } else {
                        $curr_order = 'votetime';
                        $orderby = 'votetime ' . serendipity_db_escape_string($serendipity['GET']['sort']['ordermode']);
                    }
                    print "\n    <fieldset id='serendipity_admin_sort' class='additional_info filter_pane'>\n        <legend><span class='visuallyhidden'>" . SORT_ORDER . "</span></legend>\n\n        <div class='clearfix'>\n            <div class='form_select'>\n                <label for='serendipity_sort_order'>" . SORT_BY . "</label>\n                <select id='serendipity_sort_order' name='serendipity[sort][order]'>\n";
                    foreach ($sort_order as $order => $val) {
                        print "\n  <option value='{$order}'" . ($curr_order == $order ? " selected='selected'" : '') . ">{$val}</option>\n";
                    }
                    print "\n                </select>\n            </div>\n            <div class='form_select'>\n                <label for='serendipity_sort_ordermode'>" . SORT_ORDER . "</label>\n                <select id='serendipity_sort_ordermode' name='serendipity[sort][ordermode]'>\n                    <option value='DESC'" . ($desc ? " selected='selected'" : '') . ">" . SORT_ORDER_DESC . "</option>\n                    <option value='ASC'" . ($desc ? '' : " selected='selected'") . ">" . SORT_ORDER_ASC . "</option>\n                </select>\n            </div>\n        </div>\n\n        <div class='form_buttons'>\n            <input name='submit' type='submit' value='" . GO . "'>\n        </div>\n    </fieldset>\n</form>\n";
                    // Paging (partly ripped from include/admin/comments.inc.php)
                    $commentsPerPage = (int) (!empty($serendipity['GET']['filter']['perpage']) ? $serendipity['GET']['filter']['perpage'] : 25);
                    $sql = serendipity_db_query("SELECT COUNT(*) AS total FROM {$serendipity['dbPrefix']}karmalog l WHERE 1 = 1 " . $and, true);
                    if (is_string($sql)) {
                        print "<span class='msg_error'><span class='icon-attention-circled'></span> " . $sql . "</span>\n";
                    }
                    $totalVotes = is_array($sql) && is_int($sql['total']) ? $sql['total'] : 0;
                    $pages = $commentsPerPage == COMMENTS_FILTER_ALL ? 1 : ceil($totalVotes / (int) $commentsPerPage);
                    $page = (int) $serendipity['GET']['page'];
                    if ($page == 0 || $page > $pages) {
                        $page = 1;
                    }
                    if ($page > 1) {
                        $linkPrevious = $url . '&amp;serendipity[page]=' . ($page - 1) . $searchString;
                    }
                    if ($pages > $page) {
                        $linkNext = $url . '&amp;serendipity[page]=' . ($page + 1) . $searchString;
                    }
                    if ($commentsPerPage == COMMENTS_FILTER_ALL) {
                        $limit = '';
                    } else {
                        $limit = serendipity_db_limit_sql(serendipity_db_limit(($page - 1) * (int) $commentsPerPage, (int) $commentsPerPage));
                    }
                    // Variables for display
                    if ($linkPrevious) {
                        $linkPrevious = '<a class="button_link" href="' . $linkPrevious . '" title="' . PREVIOUS . '"><span class="icon-left-dir"></span><span class="visuallyhidden"> ' . PREVIOUS . '</span></a>';
                    } else {
                        $linkPrevious = '<span class="visuallyhidden">' . NO_ENTRIES_TO_PRINT . '</span>';
                    }
                    if ($linkNext) {
                        $linkNext = '<a class="button_link" href="' . $linkNext . '" title="' . NEXT . '"><span class="visuallyhidden">' . NEXT . ' </span><span class="icon-right-dir"></span></a>';
                    } else {
                        $linkNext = '<span class="visuallyhidden">' . NO_ENTRIES_TO_PRINT . '</span>';
                    }
                    $paging = sprintf(PAGE_BROWSE_COMMENTS, $page, $pages, $totalVotes);
                    // Retrieve the next batch of karma votes
                    // [entryid, points, ip, user_agent, votetime]
                    $sql = serendipity_db_query("SELECT l.entryid AS entryid, l.points AS points, l.ip AS ip, l.user_agent AS user_agent, l.votetime AS votetime, e.title AS title FROM {$serendipity['dbPrefix']}karmalog l\n                        LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = l.entryid)\n                        WHERE 1 = 1 " . $and . "\n                        ORDER BY {$orderby} {$limit}");
                    // Start the form for display and deleting
                    if (is_array($sql)) {
                        print "<form action='' method='post' name='formMultiDelete' id='formMultiDelete'>\n" . serendipity_setFormToken();
                        // Start the vote table
                        print "\n<div class='clearfix karma_pane'>\n<ul id='karmalog' class='clearfix karmalog plainList zebra_list'>\n";
                        // Print each vote
                        $i = 0;
                        foreach ($sql as $vote) {
                            $i++;
                            // entryid, title, points, ip, user_agent, votetime
                            if (strlen($vote['title']) > 40) {
                                $votetitle = substr($vote['title'], 0, 40) . '&hellip;';
                            } else {
                                $votetitle = $vote['title'];
                            }
                            $entrylink = serendipity_archiveURL($vote['entryid'], $vote['title'], 'serendipityHTTPPath', true);
                            $entryFilterHtml = "<a class='button_link filter_karma' href='{$url}&serendipity[filter][entryid]={$vote['entryid']}' title='" . FILTERS . "'><span class='icon-filter'></span><span class='visuallyhidden'>" . FILTERS . "</span></a>";
                            $ipFilterHtml = "<a class='button_link filter_karma' href='{$url}&serendipity[filter][ip]={$vote['ip']}' title='" . FILTERS . "'><span class='icon-filter'></span><span class='visuallyhidden'>" . FILTERS . "</span></a>";
                            $timestr = strftime('%a %b %d %Y, %H:%M:%S', $vote['votetime']);
                            $cssClass = $i % 2 == 0 ? 'even' : 'odd';
                            $barClass = str_replace(array('.', ' '), array('_', '_'), $this->image_name);
                            $barHtml = $this->createRatingBar(null, $vote['points'], 1, $barClass);
                            $barHtml = sprintf($barHtml, 'what', $vote['points'], '1');
                            print "\n    <li id='karma_{$i}' class='{$cssClass} clearfix'>\n        <input type='hidden' name='serendipity[karmalog{$i}][points]' value='{$vote['points']}'>\n        <input type='hidden' name='serendipity[karmalog{$i}][entryid]' value='{$vote['entryid']}'>\n        <input type='hidden' name='serendipity[karmalog{$i}][votetime]' value='{$vote['votetime']}'>\n        <input type='hidden' name='serendipity[karmalog{$i}][ip]' value='{$vote['ip']}'>\n        <input type='hidden' name='serendipity[karmalog{$i}][user_agent]' value='{$vote['user_agent']}'>\n\n        <div class='form_check'>\n            <input id='multidelete_karma_{$i}' class='multidelete' type='checkbox' name='serendipity[delete][{$i}]' value='{$i}' data-multidelid='karma_{$i}'>\n            <label for='multidelete_karma_{$i}' class='visuallyhidden'>" . TOGGLE_SELECT . "</label>\n        </div>\n\n        <h4><a href='{$entrylink}' title='ID: {$vote['entryid']}'>{$votetitle}</a>\n            <button class='toggle_info button_link' type='button' data-href='#karma_data_{$i}'><span class='icon-info-circled'></span><span class='visuallyhidden'> " . MORE . "</span></button>\n            {$entryFilterHtml}\n        </h4>\n\n        {$barHtml}\n\n        <div id='karma_data_{$i}' class='additional_info'>\n            <dl class='clearfix comment_data'>\n                <dt>" . ON . "</dt>\n                <dd>{$timestr}</dd>\n                <dt>IP</dt>\n                <dd>{$vote['ip']} {$ipFilterHtml}</dd>\n                <dt><abbr title='User-Agent' lang='en'>UA</abbr></dt>\n                <dd>{$vote['user_agent']}</dd>\n            </dl>\n        </div>\n    </li>\n";
                        }
                        // End the vote table
                        print "\n                            </ul>\n                            ";
                        // Print the footer paging table
                        print "\n<nav class='pagination'>\n    <h3>{$paging}</h3>\n    <ul class='clearfix'>\n        <li class='prev'>{$linkPrevious}</li>\n        <li class='next'>{$linkNext}</li>\n    </ul>\n</nav>\n</div>\n";
                        if (is_array($sql)) {
                            print "\n<div class='form_buttons'>\n<input class='invert_selection' name='toggle' type='button' value='" . INVERT_SELECTIONS . "'> \n<input class='state_cancel' name='serendipity[delete_button]' type='submit' title='" . PLUGIN_KARMA_DELETE_VOTES . "' value='" . DELETE . "'>\n</div>\n</form>\n";
                        }
                    } else {
                        print "\n<span class='msg_notice'><span class='icon-info-circled'></span> No logs to display. You need to enable karma logging, if you want to see single votes displayed here.</span>\n";
                    }
                    return true;
                    break;
                default:
                    return false;
            }
            // End switch on event hooks
        } else {
            return false;
        }
    }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:101,代码来源:serendipity_event_karma.php

示例7: serendipity_displayTopUrlList

/**
 * Display HTML output data of a Exit/Referrer list
 *
 * @access public
 * @see serendipity_displayTopExits()
 * @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
 * @return
 */
function serendipity_displayTopUrlList($list, $limit, $use_links = true, $interval = 7)
{
    global $serendipity;
    if ($limit) {
        $limit = serendipity_db_limit_sql($limit);
    }
    /* HACK */
    if (preg_match('/^mysqli?/', $serendipity['dbType'])) {
        /* Nonportable SQL due to MySQL date functions,
         * but produces rolling 7 day totals, which is more
         * interesting
         */
        $query = "SELECT scheme, host, SUM(count) AS total\n                  FROM {$serendipity['dbPrefix']}{$list}\n                  WHERE day > date_sub(current_date, interval " . (int) $interval . " day)\n                  GROUP BY host\n                  ORDER BY total DESC, host\n                  {$limit}";
    } else {
        /* Portable version of the same query */
        $query = "SELECT scheme, host, SUM(count) AS total\n                  FROM {$serendipity['dbPrefix']}{$list}\n                  GROUP BY scheme, host\n                  ORDER BY total DESC, host\n                  {$limit}";
    }
    $rows = serendipity_db_query($query);
    echo "<span class='serendipityReferer'>";
    if (is_array($rows)) {
        foreach ($rows as $row) {
            if ($use_links) {
                printf('<a href="%1$s://%2$s" title="%2$s" >%2$s</a> (%3$s)<br />', htmlspecialchars($row['scheme']), htmlspecialchars($row['host']), htmlspecialchars($row['total']));
            } else {
                printf('%1$s (%2$s)<br />', htmlspecialchars($row['host']), htmlspecialchars($row['total']));
            }
        }
    }
    echo "</span>";
}
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:41,代码来源:functions.inc.php

示例8: event_hook


//.........这里部分代码省略.........
                        $val = $serendipity['GET']['filter']['title'];
                        $and .= "AND e.title LIKE '%" . serendipity_db_escape_string($val) . "%'";
                        $searchString .= "&amp;serendipity['filter']['title']=" . htmlspecialchars($val);
                    }
                    // Sorting (controls go after filtering controls in form above)
                    $sort_order = array('votetime' => DATE, 'user_agent' => USER_AGENT, 'title' => TITLE, 'entryid' => 'ID');
                    if (empty($serendipity['GET']['sort']['ordermode']) || $serendipity['GET']['sort']['ordermode'] != 'ASC') {
                        $desc = true;
                        $serendipity['GET']['sort']['ordermode'] = 'DESC';
                    }
                    if (!empty($serendipity['GET']['sort']['order']) && !empty($sort_order[$serendipity['GET']['sort']['order']])) {
                        $curr_order = $serendipity['GET']['sort']['order'];
                        $orderby = serendipity_db_escape_string($curr_order . ' ' . $serendipity['GET']['sort']['ordermode']);
                    } else {
                        $curr_order = 'votetime';
                        $orderby = 'votetime ' . serendipity_db_escape_string($serendipity['GET']['sort']['ordermode']);
                    }
                    print "\n<div>" . SORT_BY . "\n<select name='serendipity[sort][order]'>\n";
                    foreach ($sort_order as $order => $val) {
                        print "\n  <option value='{$order}'" . ($curr_order == $order ? " selected='selected'" : '') . ">{$val}</option>\n";
                    }
                    print "\n</select>\n<select name='serendipity[sort][ordermode]'>\n  <option value='DESC'" . ($desc ? "selected='selected'" : '') . ">" . SORT_ORDER_DESC . "</option>\n  <option value='ASC'" . ($desc ? '' : "selected='selected'") . ">" . SORT_ORDER_ASC . "</option>\n</select>\n</div>\n<input type='submit' name='submit' value=' - " . GO . " - ' class='serendipityPrettyButton input_button' /> \n</form>\n";
                    // Paging (partly ripped from include/admin/comments.inc.php)
                    $commentsPerPage = (int) (!empty($serendipity['GET']['filter']['perpage']) ? $serendipity['GET']['filter']['perpage'] : 25);
                    $sql = serendipity_db_query("SELECT COUNT(*) AS total FROM {$serendipity['dbPrefix']}karmalog l WHERE 1 = 1 " . $and, true);
                    $totalVotes = $sql['total'];
                    $pages = $commentsPerPage == COMMENTS_FILTER_ALL ? 1 : ceil($totalVotes / (int) $commentsPerPage);
                    $page = (int) $serendipity['GET']['page'];
                    if ($page == 0 || $page > $pages) {
                        $page = 1;
                    }
                    if ($page > 1) {
                        $linkPrevious = $url . '&amp;serendipity[page]=' . ($page - 1) . $searchString;
                    }
                    if ($pages > $page) {
                        $linkNext = $url . '&amp;serendipity[page]=' . ($page + 1) . $searchString;
                    }
                    if ($commentsPerPage == COMMENTS_FILTER_ALL) {
                        $limit = '';
                    } else {
                        $limit = serendipity_db_limit_sql(serendipity_db_limit(($page - 1) * (int) $commentsPerPage, (int) $commentsPerPage));
                    }
                    // Variables for display
                    if ($linkPrevious) {
                        $linkPrevious = '<a href="' . $linkPrevious . '" class="serendipityIconLink"><img src="' . serendipity_getTemplateFile('admin/img/previous.png') . '" /></a>';
                    } else {
                        $linkPrevious = '&nbsp;';
                    }
                    if ($linkNext) {
                        $linkNext = '<a href="' . $linkNext . '" class="serendipityIconLinkRight"><img src="' . serendipity_getTemplateFile('admin/img/next.png') . '" /></a>';
                    } else {
                        $linkNext = '&nbsp;';
                    }
                    $paging = sprintf(PAGE_BROWSE_COMMENTS, $page, $pages, $totalVotes);
                    // Retrieve the next batch of karma votes
                    // [entryid, points, ip, user_agent, votetime]
                    $sql = serendipity_db_query("SELECT l.entryid AS entryid, l.points AS points, l.ip AS ip, l.user_agent AS user_agent, l.votetime AS votetime, e.title AS title FROM {$serendipity['dbPrefix']}karmalog l\n                        LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = l.entryid)\n                        WHERE 1 = 1 " . $and . "\n                        ORDER BY {$orderby} {$limit}");
                    // Start the form for display and deleting
                    if (is_array($sql)) {
                        print "<form action='' method='post' name='formMultiDelete' id='formMultiDelete'>\n" . serendipity_setFormToken() . "\n<script type='text/javascript'>\nfunction invertSelection() {\n    var f = document.formMultiDelete;\n    for (var i = 0; i < f.elements.length; i++) {\n        if( f.elements[i].type == 'checkbox' ) {\n            f.elements[i].checked = !(f.elements[i].checked);\n        }\n    }\n}\n</script>\n";
                        // Print the header paging table
                        print "\n<table width='100%' style='border-collapse: collapse;'>\n  <tr>\n  <td align='left'>{$linkPrevious}</td>\n  <td align='center'>{$paging}</td>\n  <td align='right'>{$linkNext}</td>\n  </tr>\n</table>\n";
                        // Start the vote table
                        print "\n<table class='karmalog' width='100%'>\n";
                        // Print each vote
                        $i = 0;
                        foreach ($sql as $vote) {
                            $i++;
                            // entryid, title, points, ip, user_agent, votetime
                            $entrylink = serendipity_archiveURL($vote['entryid'], $vote['title'], 'serendipityHTTPPath', true);
                            $entryFilterHtml = "<a class='serendipityIconLink' href='{$url}&serendipity[filter][entryid]={$vote['entryid']}'><img src='" . serendipity_getTemplateFile('admin/img/zoom.png') . "' /></a>";
                            $ipFilterHtml = "<a class='serendipityIconLink' href='{$url}&serendipity[filter][ip]={$vote['ip']}'><img src='" . serendipity_getTemplateFile('admin/img/zoom.png') . "' /></a>";
                            $timestr = strftime('%H:%M:%S<br />%n%a %b %d %Y', $vote['votetime']);
                            $cssClass = 'serendipity_admin_list_item serendipity_admin_list_item_';
                            $cssClass .= $i % 2 == 0 ? 'even' : 'uneven';
                            $barClass = str_replace(array('.', ' '), array('_', '_'), $this->image_name);
                            $barHtml = $this->createRatingBar(null, $vote['points'], 1, $barClass);
                            $barHtml = sprintf($barHtml, 'what', $vote['points'], '1');
                            print "\n  <tr class='{$cssClass}'>\n    <td rowspan='2' width='20' align='center'>\n      <input class='input_checkbox' type='checkbox' name='serendipity[delete][{$i}]' value='{$i}' tabindex='{$i}' />\n      <input type='hidden' name='serendipity[karmalog{$i}][points]' value='{$vote['points']}' />\n      <input type='hidden' name='serendipity[karmalog{$i}][entryid]' value='{$vote['entryid']}' />\n      <input type='hidden' name='serendipity[karmalog{$i}][votetime]' value='{$vote['votetime']}' />\n      <input type='hidden' name='serendipity[karmalog{$i}][ip]' value='{$vote['ip']}' />\n      <input type='hidden' name='serendipity[karmalog{$i}][user_agent]' value='{$vote['user_agent']}' />\n    </td>\n    <td>{$barHtml}</td>\n    <td colspan='2'><a href='{$entrylink}' title='{$vote['entryid']}' alt='{$vote['title']}'>{$vote['title']}</a> {$entryFilterHtml}</td>\n  </tr>\n  <tr class='{$cssClass}'>\n    <td>{$timestr}</td>\n    <td>{$vote['ip']} {$ipFilterHtml}</td>\n    <td>{$vote['user_agent']}</td>\n  </tr>\n";
                        }
                        // End the vote table
                        print "\n                            </table>\n                            ";
                        if (is_array($sql)) {
                            print "\n<input type='button' name='toggle' value='" . INVERT_SELECTIONS . "' onclick='invertSelection()' class='serendipityPrettyButton input_button' /> \n<input class='serendipityPrettyButton input_button' type='submit' value='" . PLUGIN_KARMA_DELETE_VOTES . "' name='serendipity[delete_button]' />\n<input class='serendipityPrettyButton input_button' type='submit' value='" . PLUGIN_KARMA_APPROVE_VOTES . "' name='serendipity[approve_button]' />\n</form>\n";
                        }
                        // Print the footer paging table
                        print "\n<table width='100%' style='border-collapse: collapse;'>\n  <tr>\n  <td align='left'>{$linkPrevious}</td>\n  <td align='center'>{$paging}</td>\n  <td align='right'>{$linkNext}</td>\n  </tr>\n</table>\n";
                    } else {
                        print "\n<div class='serendipityAdminMsgNotice'>No entries to display.</div>\n";
                    }
                    return true;
                    break;
                default:
                    return false;
            }
            // End switch on event hooks
        } else {
            return false;
        }
    }
开发者ID:rustyx,项目名称:Serendipity,代码行数:101,代码来源:serendipity_event_karma.php

示例9: getMyNotes

 function getMyNotes($limited = true)
 {
     global $serendipity;
     $this->setupDB();
     $sql = "SELECT a.noteid, a.authorid, a.notetime, a.subject, a.body, a.notetype,\n                       ar.realname\n                  FROM {$serendipity['dbPrefix']}adminnotes\n                    AS a\n\n                  JOIN {$serendipity['dbPrefix']}adminnotes_to_groups\n                    AS atg\n                    ON atg.noteid = a.noteid\n\n                  JOIN {$serendipity['dbPrefix']}authorgroups\n                    AS ag\n                    ON (ag.groupid = atg.groupid AND ag.authorid = {$serendipity['authorid']})\n\n                  JOIN {$serendipity['dbPrefix']}authors\n                    AS axs\n                    ON axs.authorid = ag.authorid\n\n                  JOIN {$serendipity['dbPrefix']}authors\n                    AS ar\n                    ON ar.authorid = a.authorid\n                " . (is_int($limited) ? 'WHERE a.noteid = ' . (int) $limited : '') . "\n              GROUP BY a.noteid\n              ORDER BY a.notetime DESC";
     if ($limited) {
         $sql .= ' ' . serendipity_db_limit_sql($this->get_config('limit'));
     }
     return serendipity_db_query($sql, is_int($limited) ? true : false, 'assoc');
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:10,代码来源:serendipity_event_adminnotes.php

示例10: getAllRecyclerComments

 function getAllRecyclerComments($page = false)
 {
     global $serendipity;
     if ($page === false) {
         $sql = "SELECT * FROM {$serendipity['dbPrefix']}spamblock_bayes_recycler ORDER BY id DESC";
     } else {
         $first = $page * 20;
         $amount = 21;
         $sql = "SELECT * FROM {$serendipity['dbPrefix']}spamblock_bayes_recycler ORDER BY id DESC" . serendipity_db_limit_sql(sprintf("%d,%d", $first, $amount));
     }
     $comments = serendipity_db_query($sql, false, 'assoc');
     return $comments;
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:13,代码来源:serendipity_event_spamblock_bayes.php

示例11: serendipity_setFormToken

$searchString .= '&amp;' . serendipity_setFormToken('url');
/* Paging */
$sql = serendipity_db_query("SELECT COUNT(*) AS total FROM {$serendipity['dbPrefix']}comments c WHERE 1 = 1 " . ($c_type !== null ? " AND c.type = '{$c_type}' " : '') . $and, true);
$totalComments = $sql['total'];
$pages = $commentsPerPage == COMMENTS_FILTER_ALL ? 1 : ceil($totalComments / (int) $commentsPerPage);
$page = (int) $serendipity['GET']['page'];
if ($page == 0 || $page > $pages) {
    $page = 1;
}
$linkPrevious = 'serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[page]=' . ($page - 1) . $searchString;
$linkNext = 'serendipity_admin.php?serendipity[adminModule]=comments&amp;serendipity[page]=' . ($page + 1) . $searchString;
$filter_vals = array(10, 20, 50, COMMENTS_FILTER_ALL);
if ($commentsPerPage == COMMENTS_FILTER_ALL) {
    $limit = '';
} else {
    $limit = serendipity_db_limit_sql(serendipity_db_limit(($page - 1) * (int) $commentsPerPage, (int) $commentsPerPage));
}
$sql = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPrefix']}comments c\n                                LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)\n                                WHERE 1 = 1 " . ($c_type !== null ? " AND c.type = '{$c_type}' " : '') . $and . (!serendipity_checkPermission('adminEntriesMaintainOthers') ? 'AND e.authorid = ' . (int) $serendipity['authorid'] : '') . "\n                                ORDER BY c.id DESC {$limit}");
if (serendipity_checkPermission('adminComments')) {
    ob_start();
    # This event has to get send here so the spamblock-plugin can block an author now and the comment_page show that on this pageload
    serendipity_plugin_api::hook_event('backend_comments_top', $sql);
    $data['backend_comments_top'] = ob_get_contents();
    ob_end_clean();
}
$data['commentsPerPage'] = $commentsPerPage;
$data['totalComments'] = $totalComments;
$data['pages'] = $pages;
$data['page'] = $page;
$data['linkPrevious'] = $linkPrevious;
$data['linkNext'] = $linkNext;
开发者ID:amirchrist,项目名称:Serendipity,代码行数:31,代码来源:comments.inc.php

示例12: displayTopUrlList

function displayTopUrlList($list, $limit, $use_links = true, $filter_out = "", $daylimit = 7)
{
    global $serendipity;
    if ($limit) {
        $limit = serendipity_db_limit_sql($limit);
    }
    $filter_out_sql = !$filter_out ? "" : "host NOT LIKE '" . join("' AND host NOT LIKE '", explode(";", preg_replace('@^;|;$@', '', str_replace("*", "%", $filter_out)))) . "'";
    /* HACK */
    if (preg_match('/^mysqli?/', $serendipity['dbType'])) {
        if ($filter_out) {
            $filter_out_sql = "AND " . $filter_out_sql;
        }
        /* Nonportable SQL due to MySQL date functions,
         * but produces rolling 7 day totals, which is more
         * interesting
         */
        $query = "SELECT scheme, host, SUM(count) AS total\n                  FROM {$serendipity['dbPrefix']}{$list}\n                  WHERE " . ($daylimit > 0 ? "day > date_sub(current_date, interval " . (int) $daylimit . " day)" : "1 = 1") . "\n                  {$filter_out_sql}\n                  GROUP BY host\n                  ORDER BY total DESC, host\n                  {$limit}";
    } else {
        if ($filter_out) {
            $filter_out_sql = "WHERE " . $filter_out_sql;
        }
        /* Portable version of the same query */
        $query = "SELECT scheme, host, SUM(count) AS total\n                  FROM {$serendipity['dbPrefix']}{$list}\n                  {$filter_out_sql}\n                  GROUP BY scheme, host\n                  ORDER BY total DESC, host\n                  {$limit}";
    }
    $rows = serendipity_db_query($query);
    echo "<span class='serendipityReferer'>";
    if (is_array($rows)) {
        foreach ($rows as $row) {
            if ($use_links) {
                printf('<a href="%1$s://%2$s" title="%2$s" >%2$s</a> (%3$s)<br />', function_exists('serendipity_specialchars') ? serendipity_specialchars($row['scheme']) : htmlspecialchars($row['scheme'], ENT_COMPAT, LANG_CHARSET), function_exists('serendipity_specialchars') ? serendipity_specialchars($row['host']) : htmlspecialchars($row['host'], ENT_COMPAT, LANG_CHARSET), function_exists('serendipity_specialchars') ? serendipity_specialchars($row['total']) : htmlspecialchars($row['total'], ENT_COMPAT, LANG_CHARSET));
            } else {
                printf('%1$s (%2$s)<br />', function_exists('serendipity_specialchars') ? serendipity_specialchars($row['host']) : htmlspecialchars($row['host'], ENT_COMPAT, LANG_CHARSET), function_exists('serendipity_specialchars') ? serendipity_specialchars($row['total']) : htmlspecialchars($row['total'], ENT_COMPAT, LANG_CHARSET));
            }
        }
    }
    echo "</span>";
}
开发者ID:sqall01,项目名称:additional_plugins,代码行数:37,代码来源:serendipity_plugin_topreferers.php

示例13: getEntriesDB

 /**
  * Guestbook Select entries
  *
  * @param  int   $cp   limit from
  * @param  int   $rp   limit to
  * @param  int   $ap   approved
  * @return mixed boolean/array $entries
  */
 function getEntriesDB($cp, $rp, $ap)
 {
     global $serendipity;
     $whe = serendipity_db_bool($this->get_config('showapp')) || serendipity_db_bool($this->get_config('automoderate')) ? "WHERE approved={$ap}" : '';
     // generate guestbook entries and send them to entries template
     $sql = "SELECT * FROM {$serendipity['dbPrefix']}guestbook {$whe} ORDER BY timestamp DESC ";
     $entries = serendipity_db_query($sql . serendipity_db_limit_sql(serendipity_db_limit($cp * $rp, $rp)), false, 'assoc');
     return is_array($entries) ? $entries : false;
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:17,代码来源:serendipity_event_guestbook.php

示例14: generate_content


//.........这里部分代码省略.........
<div id="quick_link_tip" style="position:absolute; visibility: hidden"></div>
<script language="JavaScript"><!--

var toolTipSTYLE="";
function initToolTips()
{
  toolTipSTYLE = document.getElementById("quick_link_tip").style;
  toolTipSTYLE.visibility = "visible";
  toolTipSTYLE.display = "none";
  document.onmousemove = moveToMouseLoc;
}
function toolTip(msg, bg)
{
  if(toolTip.arguments.length < 1) //hide
  {
	toolTipSTYLE.display = "none";
  }
  else // show
  {
    if(!bg) bg = "#FFFFFF";
    var content =
    '<table border="1" cellspacing="0" cellpadding="0" bgcolor="' + bg +
    '"><td><font size="-1">&nbsp\;' + msg +
    '&nbsp\;</font></td></table>';
    document.getElementById("quick_link_tip").innerHTML = content;
    toolTipSTYLE.display='block'
  }
}
function moveToMouseLoc(e)
{
  if (e && e.pageX) {
    x = e.pageX;
    y = e.pageY;
    toolTipSTYLE.left = x + 0 + 'px';
    toolTipSTYLE.top = y + 20 + 'px';
  }
  return true;
}
initToolTips();
//--></script>
<div style="margin: 0px; padding: 0px; text-align: left;">
<?php 
        $q = 'SELECT    s.description       AS description,
						s.link              AS link,
						s.label             AS label,
                        s.timestamp         AS stamp,
                        s.id                AS link_id
              FROM    ' . $serendipity['dbPrefix'] . 'quicklink AS s
              ORDER BY    s.timestamp DESC
              ' . serendipity_db_limit_sql(serendipity_db_limit($start, $max_entries));
        $sql = serendipity_db_query($q);
        if ($sql && is_array($sql)) {
            foreach ($sql as $key => $row) {
                if (!preg_match('@^https?://@', trim($row['link']))) {
                    $row['link'] = 'http://' . $row['link'];
                }
                $row['link'] = str_replace('javascript:', '', $row['link']);
                // create tool tip string
                $tip = '';
                if ($show_tip == 'true') {
                    $tip = function_exists('serendipity_specialchars') ? serendipity_specialchars(serendipity_strftime($timestamp, $row['stamp'])) : htmlspecialchars(serendipity_strftime($timestamp, $row['stamp']), ENT_COMPAT, LANG_CHARSET);
                    if (trim($row['description']) != '') {
                        $tip .= '<br />' . nl2br(function_exists('serendipity_specialchars') ? serendipity_specialchars($row['description']) : htmlspecialchars($row['description'], ENT_COMPAT, LANG_CHARSET));
                    }
                    $tip = ' onMouseOver="toolTip(\'' . $tip . '\')" onMouseOut="toolTip()"';
                }
                // create label of link
                if (trim($row['label']) == '' || $row['label'] == PLUGIN_QUICKLINK_LABEL) {
                    $label = $row['link'];
                } else {
                    $label = $row['label'];
                }
                // create link string
                $link = '<a href="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($row['link']) : htmlspecialchars($row['link'], ENT_COMPAT, LANG_CHARSET)) . '"' . $tip . ' target="_blank">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($label) : htmlspecialchars($label, ENT_COMPAT, LANG_CHARSET)) . '</a>';
                // create telete link string
                $deleteLink = '';
                if ($_SESSION['serendipityAuthedUser'] === true && $serendipity['serendipityUserlevel'] >= USERLEVEL_CHIEF) {
                    $deleteLink = ' | <a href="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[action]=quicklinkdelete&amp;serendipity[link_id]=' . $row['link_id'] . '" onclick="return confirm(\'' . PLUGIN_QUICKLINK_ALERT . '\');">' . $del_str . '</a>';
                }
                $entry = array('link' => $link);
                serendipity_plugin_api::hook_event('frontend_display', $entry);
                echo $entry['link'] . $deleteLink . '<br />' . "\n\n";
            }
        }
        if ($prev !== false || $next !== false) {
            if ($prev !== false) {
                echo '<br /><div align="center"><a href="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[start]=' . $prev . '">' . PREVIOUS . '</a> | ';
            } else {
                echo '<br /><div align="center">' . PREVIOUS . ' | ';
            }
            if ($next !== false) {
                echo '<a href="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[start]=' . $next . '">' . NEXT . '</a></div><br />' . "\n";
            } else {
                echo NEXT . '</div><br />' . "\n";
            }
        }
        ?>
</div>
<?php 
    }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:101,代码来源:serendipity_plugin_quicklink.php

示例15: generate_content

 function generate_content(&$title)
 {
     global $serendipity;
     $number = $this->get_config('number');
     $category = $this->get_config('category', 'none');
     $title = $this->get_config('title', $this->title);
     $number_from_sw = $this->get_config('number_from');
     if ($category == '_cur') {
         $category = $serendipity['GET']['category'];
     }
     $sql_join = '';
     $sql_where = '';
     if ($category != 'none' && is_numeric($category)) {
         $sql_join = 'LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'entrycat AS ec ON e.id = ec.entryid
                      LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'category AS c  ON ec.categoryid = c.categoryid';
         $sql_where = ' AND (c.category_left BETWEEN ' . implode(' AND ', serendipity_fetchCategoryRange($category)) . ')';
     }
     if (!$number || !is_numeric($number) || $number < 1) {
         $number = 10;
     }
     $sql_number = $number;
     switch ($number_from_sw) {
         case 'skip':
             $sql_number = serendipity_db_limit_sql(serendipity_db_limit($serendipity['fetchLimit'], $sql_number));
             break;
         default:
             $sql_number = serendipity_db_limit_sql(serendipity_db_limit(0, $sql_number));
             break;
     }
     $sortby = $this->get_config('sortby', 'comments');
     switch ($sortby) {
         case 'comments':
             $entries_query = "SELECT e.id,\n                                         e.title,\n                                         e.comments AS points,\n                                         e.timestamp\n                                    FROM {$serendipity['dbPrefix']}entries AS e\n                                         {$sql_join}\n                                   WHERE e.isdraft = 'false' AND e.timestamp <= " . time() . "\n                                         {$sql_where}\n                                ORDER BY e.comments DESC\n                                   {$sql_number}";
             break;
         case 'commentors':
             $entries_query = "SELECT c.author, count(c.id) AS points\n                                    FROM {$serendipity['dbPrefix']}entries AS e\n                                    JOIN {$serendipity['dbPrefix']}comments AS c\n                                         ON c.entry_id = e.id\n                                         {$sql_join}\n                                   WHERE e.isdraft = 'false' AND e.timestamp <= " . time() . "\n                                     AND c.status = 'approved'\n                                         {$sql_where}\n                                GROUP BY c.author\n                                ORDER BY points DESC\n                                   {$sql_number}";
             break;
         case 'karma':
             $entries_query = "SELECT e.id,\n                                         e.title,\n                                         e.comments,\n                                         e.timestamp,\n                                         k.points AS points\n                                    FROM {$serendipity['dbPrefix']}entries AS e\n                                         {$sql_join}\n                         LEFT OUTER JOIN {$serendipity['dbPrefix']}karma AS k\n                                      ON k.entryid = e.id\n                                   WHERE e.isdraft = 'false' AND e.timestamp <= " . time() . "\n                                         {$sql_where}\n                                GROUP BY e.id, e.title, e.comments, e.timestamp, k.visits\n                                ORDER BY k.points DESC\n                                    {$sql_number}";
             break;
         case 'visits':
             $entries_query = "SELECT e.id,\n                                         e.title,\n                                         e.comments,\n                                         e.timestamp,\n                                         k.visits AS points\n                                    FROM {$serendipity['dbPrefix']}entries AS e\n                                         {$sql_join}\n                         LEFT OUTER JOIN {$serendipity['dbPrefix']}karma AS k\n                                      ON k.entryid = e.id\n                                   WHERE e.isdraft = 'false' AND e.timestamp <= " . time() . "\n                                         {$sql_where}\n                                GROUP BY e.id, e.title, e.comments, e.timestamp, k.visits\n                                ORDER BY k.visits DESC\n                                    {$sql_number}";
             break;
         case 'lowvisits':
             $entries_query = "SELECT e.id,\n                                         e.title,\n                                         e.comments,\n                                         e.timestamp,\n                                         k.visits AS points\n                                    FROM {$serendipity['dbPrefix']}entries AS e\n                                         {$sql_join}\n                         LEFT OUTER JOIN {$serendipity['dbPrefix']}karma AS k\n                                      ON k.entryid = e.id\n                                   WHERE e.isdraft = 'false' AND e.timestamp <= " . time() . "\n                                         {$sql_where}\n                                GROUP BY e.id, e.title, e.comments, e.timestamp, k.visits         \n                                ORDER BY k.visits ASC\n                    {$sql_number}";
             break;
         case 'exits':
             $entries_query = "SELECT e.id,\n                                         e.title,\n                                         e.comments,\n                                         e.timestamp,\n                                         SUM(ex.count) AS points\n                                    FROM {$serendipity['dbPrefix']}entries AS e\n                                         {$sql_join}\n                         LEFT OUTER JOIN {$serendipity['dbPrefix']}exits AS ex\n                                      ON ex.entry_id = e.id\n                                   WHERE e.isdraft = 'false' AND e.timestamp <= " . time() . "\n                                         {$sql_where}\n                                GROUP BY ex.entry_id\n                                ORDER BY points DESC\n                                    {$sql_number}";
             break;
     }
     $entries = serendipity_db_query($entries_query);
     $hidden = explode(',', trim($this->get_config('commentors_hide')));
     echo '<ul class="plainList">';
     if (isset($entries) && is_array($entries)) {
         foreach ($entries as $k => $entry) {
             if ($sortby == 'commentors') {
                 if (in_array($entry['author'], $hidden)) {
                     continue;
                 }
                 $entryLink = $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_COMMENTS . '/' . urlencode($entry['author']);
                 echo '<li><a href="' . $entryLink . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['author']) : htmlspecialchars($entry['author'], ENT_COMPAT, LANG_CHARSET)) . '">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['author']) : htmlspecialchars($entry['author'], ENT_COMPAT, LANG_CHARSET)) . '</a>';
                 echo ' <span class="serendipitySideBarDate">(' . (!empty($entry['points']) ? function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['points']) : htmlspecialchars($entry['points'], ENT_COMPAT, LANG_CHARSET) : 0) . ')</span></li>';
             } else {
                 $entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
                 echo '<li><a href="' . $entryLink . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '">' . $entry['title'] . '</a>';
                 echo ' <span class="serendipitySideBarDate">(' . (!empty($entry['points']) ? function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['points']) : htmlspecialchars($entry['points'], ENT_COMPAT, LANG_CHARSET) : 0) . ')</span></li>';
             }
         }
     }
     echo '</ul>';
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:71,代码来源:serendipity_plugin_popularentries.php


注:本文中的serendipity_db_limit_sql函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。