Exemple #1
0
function recent_comments($atts, $thing = NULL)
{
    global $prefs;
    global $thisarticle, $thiscomment;
    extract(lAtts(array('break' => br, 'class' => __FUNCTION__, 'form' => '', 'label' => '', 'labeltag' => '', 'limit' => 10, 'offset' => 0, 'sort' => 'posted desc', 'wraptag' => ''), $atts));
    $sort = preg_replace('/\\bposted\\b/', 'd.posted', $sort);
    $expired = $prefs['publish_expired_articles'] ? '' : ' and (now() <= t.Expires or t.Expires = ' . NULLDATETIME . ') ';
    $rs = startRows('select d.name, d.email, d.web, d.message, d.discussid, unix_timestamp(d.Posted) as time, ' . 't.ID as thisid, unix_timestamp(t.Posted) as posted, t.Title as title, t.Section as section, t.url_title ' . 'from ' . safe_pfx('txp_discuss') . ' as d inner join ' . safe_pfx('textpattern') . ' as t on d.parentid = t.ID ' . 'where t.Status >= 4' . $expired . ' and d.visible = ' . VISIBLE . ' order by ' . doSlash($sort) . ' limit ' . intval($offset) . ',' . intval($limit));
    if ($rs) {
        $out = array();
        $old_article = $thisarticle;
        while ($c = nextRow($rs)) {
            if (empty($form) && empty($thing)) {
                $out[] = href(txpspecialchars($c['name']) . ' (' . escape_title($c['title']) . ')', permlinkurl($c) . '#c' . $c['discussid']);
            } else {
                $thiscomment['name'] = $c['name'];
                $thiscomment['email'] = $c['email'];
                $thiscomment['web'] = $c['web'];
                $thiscomment['message'] = $c['message'];
                $thiscomment['discussid'] = $c['discussid'];
                $thiscomment['time'] = $c['time'];
                // allow permlink guesstimation in permlinkurl(), elsewhere
                $thisarticle['thisid'] = $c['thisid'];
                $thisarticle['posted'] = $c['posted'];
                $thisarticle['title'] = $c['title'];
                $thisarticle['section'] = $c['section'];
                $thisarticle['url_title'] = $c['url_title'];
                $out[] = $thing ? parse($thing) : parse_form($form);
            }
        }
        if ($out) {
            unset($GLOBALS['thiscomment']);
            $thisarticle = $old_article;
            return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
        }
    }
    return '';
}
Exemple #2
0
function safe_rows_start($things, $table, $where, $debug = '')
{
    $q = "select {$things} from " . PFX . "{$table} where {$where}";
    return startRows($q, $debug);
}
Exemple #3
0
function recent_comments($atts)
{
    extract(lAtts(array('break' => br, 'class' => __FUNCTION__, 'label' => '', 'labeltag' => '', 'limit' => 10, 'sort' => 'posted desc', 'wraptag' => ''), $atts));
    $sort = preg_replace('/\\bposted\\b/', 'd.posted', $sort);
    $rs = startRows('select d.name, d.discussid, t.ID as thisid, unix_timestamp(t.Posted) as posted, t.Title as title, t.Section as section, t.url_title ' . 'from ' . safe_pfx('txp_discuss') . ' as d inner join ' . safe_pfx('textpattern') . ' as t on d.parentid = t.ID ' . 'where t.Status >= 4 and d.visible = ' . VISIBLE . ' order by ' . doSlash($sort) . ' limit 0,' . intval($limit));
    if ($rs) {
        $out = array();
        while ($c = nextRow($rs)) {
            $out[] = href($c['name'] . ' (' . escape_title($c['title']) . ')', permlinkurl($c) . '#c' . $c['discussid']);
        }
        if ($out) {
            return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
        }
    }
    return '';
}
Exemple #4
0
function safe_rows_start($things, $table, $where, $debug = '')
{
    $things = safe_remap_fields($things, $table);
    $q = "select {$things} from " . safe_pfx_j($table) . " where {$where}";
    return startRows($q, $debug);
}
Exemple #5
0
/**
 * Selects rows from a table and returns result as a resource.
 *
 * @param  string        $things The select clause
 * @param  string        $table  The table
 * @param  string        $where  The where clause
 * @param  bool          $debug  Dump query
 * @return resource|bool A result resouce or FALSE on error
 * @see    nextRow()
 * @see    numRows()
 * @example
 * if ($rs = safe_rows_start('column', 'table', '1=1'))
 * {
 *     while ($row = nextRow($rs))
 *     {
 *         echo $row['column'];
 *     }
 * }
 */
function safe_rows_start($things, $table, $where, $debug = false)
{
    $q = "select {$things} from " . safe_pfx_j($table) . " where {$where}";
    return startRows($q, $debug);
}
/**
 * Selects rows from a table and returns result as a resource.
 *
 * @param  string        $things The select clause
 * @param  string        $table  The table
 * @param  string        $where  The where clause
 * @param  bool          $debug  Dump query
 * @return resource|bool A result resouce or FALSE on error
 * @see    nextRow()
 * @see    numRows()
 * @example
 * if ($rs = safe_rows_start('column', 'table', '1 = 1'))
 * {
 *     while ($row = nextRow($rs))
 *     {
 *         echo $row['column'];
 *     }
 * }
 */
function safe_rows_start($things, $table, $where, $debug = false)
{
    $q = "SELECT {$things} FROM " . safe_pfx_j($table) . " WHERE {$where}";
    return startRows($q, $debug);
}
Exemple #7
0
function safe_rows_start($things, $table, $where, $debug = '')
{
    $table = adjust_prefix($table);
    $q = "select {$things} from {$table} where {$where}";
    return startRows($q, $debug);
}
Exemple #8
0
function safe_rows_start($things, $table, $where = '', $debug = '')
{
    $q = "select {$things} from " . safe_pfx_j($table);
    if ($where) {
        $q .= " where {$where}";
    }
    return startRows($q, $debug);
}
function recent_comments($atts, $thing = null)
{
    global $prefs;
    global $thisarticle, $thiscomment;
    extract(lAtts(array('break' => br, 'class' => __FUNCTION__, 'form' => '', 'label' => '', 'labeltag' => '', 'limit' => 10, 'offset' => 0, 'sort' => 'posted DESC', 'wraptag' => ''), $atts));
    $sort = preg_replace('/\\bposted\\b/', 'd.posted', $sort);
    $expired = $prefs['publish_expired_articles'] ? '' : " AND (" . now('expires') . " <= t.Expires OR t.Expires = " . NULLDATETIME . ") ";
    $rs = startRows("SELECT d.name, d.email, d.web, d.message, d.discussid, UNIX_TIMESTAMP(d.Posted) AS time,\n            t.ID AS thisid, UNIX_TIMESTAMP(t.Posted) AS posted, t.Title AS title, t.Section AS section, t.url_title\n        FROM " . safe_pfx('txp_discuss') . " AS d INNER JOIN " . safe_pfx('textpattern') . " AS t ON d.parentid = t.ID\n        WHERE t.Status >= " . STATUS_LIVE . $expired . " AND d.visible = " . VISIBLE . "\n        ORDER BY " . doSlash($sort) . "\n        LIMIT " . intval($offset) . ", " . intval($limit));
    if ($rs) {
        $out = array();
        $old_article = $thisarticle;
        while ($c = nextRow($rs)) {
            if ($form === '' && $thing === null) {
                $out[] = href(txpspecialchars($c['name']) . ' (' . escape_title($c['title']) . ')', permlinkurl($c) . '#c' . $c['discussid']);
            } else {
                $thiscomment['name'] = $c['name'];
                $thiscomment['email'] = $c['email'];
                $thiscomment['web'] = $c['web'];
                $thiscomment['message'] = $c['message'];
                $thiscomment['discussid'] = $c['discussid'];
                $thiscomment['time'] = $c['time'];
                // Allow permlink guesstimation in permlinkurl(), elsewhere.
                $thisarticle['thisid'] = $c['thisid'];
                $thisarticle['posted'] = $c['posted'];
                $thisarticle['title'] = $c['title'];
                $thisarticle['section'] = $c['section'];
                $thisarticle['url_title'] = $c['url_title'];
                if ($thing === null && $form !== '') {
                    $out[] = parse_form($form);
                } else {
                    $out[] = parse($thing);
                }
            }
        }
        if ($out) {
            unset($GLOBALS['thiscomment']);
            $thisarticle = $old_article;
            return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
        }
    }
    return '';
}