WordPress.org

Ready to get started?Download WordPress

Forums

[Req / Search for] Quote-File reader block/widget (1 post)

  1. Space-Rat
    Member
    Posted 5 years ago #

    Hiyas!

    I'm currently switching from Geeklog to WP and I'm looking for a plugin / widget that displays me 1 line out of a txt file on the server (containing irc quotes). In Geeklog there was a very simple solution "Chalkboard": A php function which was called within a sidebar block. I tried to use this code within a php widget (php-code-widget.1.1) but that didn't work...

    So anyone an idea how to solve this?

    Like said the goal is to display 1 single line out of a txt file which is filled with several quotes. That line should be displayed in a sidebar widget box.

    Here's the org. code from the Geeklog Chalkboard:

    - - -
    function phpblock_chalkboard($quotefile = "/home/andrew/bot/quoteable.quotes", $delim = "\n%\n")
    {
    if(!IsSet($quotefile))
    {
    die ("You forgot to specify $quotefile");
    }
    if(!file_exists($quotefile))
    {
    die ("$quotefile does not exist! check your paths?");
    }
    else
    {
    $fp = fopen($quotefile, "r")
    or die ("Error opening file!");
    }
    $contents = fread($fp, filesize($quotefile));
    $quote_arr = explode($delim,$contents);
    fclose($fp);
    srand((double)microtime()*1000000);
    $quote_index = (rand(1, sizeof($quote_arr)) - 1);
    $returnquote = $quote_arr[$quote_index];
    return $returnquote;
    }
    - - -

    Maybe there's already such a small gimmick out there which I just didn't find?!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.