Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/includes/blocks/quote.php
<?php
// File: $Id: quote.php,v 1.18 2001/12/05 10:38:06 gregorrothfuss Exp $ $Name:  $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Patrick Kellum
// Purpose of file: Display a random quote
//                  Uses the quote tables and other stuff from Erik Slooff
// ----------------------------------------------------------------------

$blocks_modules['quote'] = array(
    'func_display' => 'blocks_quote_block',
    'text_type' => 'Quote',
    'text_type_long' => 'Random Quotes',
    'allow_multiple' => true,
    'form_content' => false,
    'form_refresh' => false,
    'show_preview' => true
);

// Uses security schema 'Quotes'

function blocks_quote_block($row) {
    global $pntable, $dbconn;

    if (!authorised(0, 'Quotes::', '::', ACCESS_READ)) {
        return;
    }

    $column = &$pntable['quotes_column'];
    mt_srand((double)microtime()*1000000);

    $total_result = $dbconn->Execute("SELECT COUNT($column[qid]) FROM $pntable[quotes]");
    list($total) = $total_result->fields;

    if ($total < 2) {
        $row[content] = "<div align=\"left\"><font class=\"pn-normal\"><i>There are too few quotes in the database</i></font></div>";
    } else {
        $p = mt_rand(1,($total));

        $sql = buildSimpleQuery('quotes', array('quote','author'), "{$pntable[quotes_column][qid]}=$p");
        $quote_result = $dbconn->Execute($sql);
        $quote = $quote_result->GetRowAssoc(false);
        $quote_result->MoveNext();
        $quote['quote'] = trim(stripslashes(nl2br($quote['quote'])));
        $row['content'] = "<div align=\"left\"><font class=\"pn-normal\"><i>$quote[quote]</i></font></div>";
        if($quote['author']) {
            $quote['author'] = trim(stripslashes($quote['author']));
            $row['content'] .= "<div align=\"right\"><font class=\"pn-normal\">--- $quote[author]</font></div>";
        }
    }
    themesideblock($row);
}
?>
Return current item: ProNuke. Postnuke To Oracle