Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Sun Apr 17, 2005 8:17 pm Reply with quote

Anybody have problems getting the older Random Quotes working in Nuke.

I am running 7.3 and can't get an older version of qotd to work.

The block has this at the top.

Quote:
<?
// qotd (Quote of the day) function for phpnuke, based on
// software originally by Joe Stump of miester.org.
//
// adapted for phpnuke 4.x and 5.x by Erik Sooff (erik@slooff.com)
//
// 22-5-2001
//////////////////////////////////////////////////////////////////////
// 16-08-2001
// Converted to the new PHP-Nuke 5.1 Blocks System by Thiago Campos
// You can contact me at mrhemp@amigoz.org
/////////////////////////////////////////////////////////////////////


Here is the entire qotd.php page.

Code:
<?php


######################################################################
# PHP-NUKE: Web Portal System
# ===========================
#
# Copyright (c) 2000 by Francisco Burzi (fburzi@ncc.org.ve)
# http://phpnuke.org
#
# This module is the main administration part
#
# This program is free software. You can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
######################################################################
# PHP-NUKE 5.0 Version by Erik Slooff (erik@slooff.com)
# http://www.slooff.com
######################################################################
# PHP-NUKE 5.1 Blocks Version by Thiago Campos (mrhemp@amigoz.org)
# http://www.amigoz.org
######################################################################

if (!eregi("admin.php", $PHP_SELF)) { die ("Access Denied"); }

global $prefix, $currentlang;

if(file_exists("language/qotd/qotd-$currentlang.php")) {
   include("language/qotd/qotd-$currentlang.php");
}
else {
   include("language/qotd/qotd-english.php");
}

// only do this stuff if the user is authorised (superadmin)
$result = mysql_query("select radminsuper from $prefix"._authors." where aid='$aid'");
list($radminsuper) = mysql_fetch_row($result);
if ($radminsuper==1) {

   // Default function to display the admin stuff for the Quote Add-on
   function QotdAdmin() {
      global $hlpfile, $admin, $prefix;
      include ("config.php");
      $hlpfile = "manual/$language/downloads.html";
      include ("header.php");
      GraphicAdmin($hlpfile);
      OpenTable();
      echo "</center><font size=4><b>"._ADDQUOTE."</b><br><br>
      <font size=2>
      <form action=admin.php method=post>
      <table border=0 width=100%><tr><td>
      "._QUOTETEXT.": </td><td><textarea class=textbox name=qquote cols=60 rows=5></textarea></td></tr><tr><td>
      "._AUTHOR.": </td><td><input class=textbox type=text name=qauthor size=31 maxlength=128></td></tr><tr><td>
      </td></tr></table>
      <input type=hidden name=op value=QotdAdd>
      <input type=submit value="._ADD.">
      </form><br>
      <a href =\"admin.php?op=QotdDisplay&page=1\">" ._MODQUOTES."</a></font><br><br>
      </td></tr></table></td></tr></table>";
      include("footer.php");
   }

   // function for adding new quotes
   function QotdAdd($qquote, $qauthor) {
        global $prefix;
        $time = date("Y-m-d");
      mysql_query("insert into $prefix"._quotes." (quote, author) values ('$qquote', '$qauthor')");
      Header("Location: admin.php?op=QotdAdmin");
   }
   
   // function for displaying multiple quotes
   function QotdDisplay($page) {
       global $hlpfile, $admin, $keyword, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $prefix;
       include ("config.php");
       $hlpfile = "manual/$language/downloads.html";
       include ("header.php");
       GraphicAdmin($hlpfile);
       OpenTable();
       $keyword2 = ereg_replace(" ", "%", $keyword);
            $whereclause = "where quote like \"%".$keyword2."%\"";
       if ($keyword == "") $whereclause = "";
       $result = mysql_query("SELECT COUNT(*) as help FROM $prefix"._quotes." $whereclause");
       list($numrecords) = mysql_fetch_row($result);
       $entriesperpage = 20;
       $totalpages = ceil($numrecords / $entriesperpage);
       if ($numrecords > 0) {
          echo "</center><font size=4><b>"._MODQUOTES."</b></font><br><br>
      <table><tr><td>
      <form action=admin.php method=post>
      "._SEARCHKEY.": <input class=textbox type=text name=keyword size=31 maxlength=128 value=\"$keyword\">
      <input type=hidden name=page value=1>
      <input type=hidden name=op value=QotdDisplay>
      <input type=submit value="._SEARCH.">
      </form></td><td><form action=admin.php method=post>
      <input type=hidden name=page value=1>
      <input type=hidden name=op value=QotdDisplay>
      <input type=submit value=\""._RESETSEARCH."\">
      </form></td></tr></table>
          <font size=2>
          <table border width=\"100%\">";
          echo "<tr bgcolor=\"$bgcolor4\"><td ><font size=\"3\">" ._QUOTE."</td><td><font size=\"3\">" ._AUTHOR."</td><td><font size=\"3\">" ._ACTION."</td></tr>";
          $start = $entriesperpage * ($page - 1);
      $sql = "SELECT qid, quote, author FROM $prefix"._quotes." $whereclause order by qid limit $start, $entriesperpage";
          $result = mysql_query($sql);
          while(list($qqid, $qquote, $qauthor) = mysql_fetch_array($result)) {
             echo "<tr><td bgcolor=\"$bgcolor4\"><font size=\"2\">".substr($qquote,0,50)."</td><td bgcolor=\"$bgcolor4\"><font size=\"2\">".substr($qauthor,0,50)."</td>";
             echo "<td bgcolor=\"$bgcolor4\"><font size=\"2\"><a href=\"admin.php?op=QotdEdit&qid=$qqid&page=$page\">" ._EDIT."</a> | <a href=\"admin.php?op=QotdDelete&qid=$qqid&page=$page\">" ._DELETE."</a></td>";
             echo "</tr>";
          }
          echo "</table><br>";
          if ($page > 1) {
             $prevpage = $page - 1;
          } else {
             $prevpage = 0;
          }
          if ($page < $totalpages) {
             $nextpage = $page + 1;
          } else {
             $nextpage = 0;
          }
          echo "<table border=0 width=\"100%\"><tr><td align=\"center\" width=\"33%\">";
          if ($prevpage != 0) {
             echo "<a href=\"admin.php?op=QotdDisplay&page=$prevpage&keyword=$keyword\">" ._PREVIOUS."</a>";
          } else {
             echo " ";
          }
          echo "</td><td align=\"center\" width=\"33%\">";
          echo "<a href=\"admin.php?op=QotdAdmin\">" ._GOBACK2."</a>";
          echo "</td><td align=\"center\" width=\"33%\">";
          if ($nextpage !=0) {
             echo "<a href=\"admin.php?op=QotdDisplay&page=$nextpage&keyword=$keyword\">" ._NEXT."</a>";
          } else {
             echo " ";
          }
          echo "</td></tr></table>";
       } else {
          echo ""._NOQUOTES."";
       }
       echo "</td></tr></table></td></tr></table>";
       include("footer.php");
   }
   
   // function for deletion of quotes
   function QotdDelete($qid,$page) {
      global $hlpfile, $admin, $prefix;
      include ("config.php");
      $hlpfile = "manual/$language/downloads.html";
      include ("header.php");
      GraphicAdmin($hlpfile);
      OpenTable();
      echo "</center><font size=4><b>" ._DELETEQUOTE."</b><br><br>";
      echo "<center>";
      echo "<font size=3 color=Red>";
      echo "<b>"._QUOTEWARNING."</b><br><br><font color=Black>";
      echo "[ <a href=admin.php?op=QotdDeleteOk&qid=$qid&page=$page>"._YES."</a> | <a href=admin.php?op=QotdDisplay&page=$page>"._NO."</a> ]<br><br>";
      echo "</td></tr></table></td></tr></table>";
      include("footer.php");
   }
      
   // function for confirmation for deletion of quotes
   function QotdDeleteOk($qid,$page) {
        global $prefix;
       mysql_query("DELETE FROM $prefix"._quotes." where qid='$qid'");
       header("Location: admin.php?op=QotdDisplay&page=$page");
   }
   
   // function for editing of quotes
   function QotdEdit($qid,$page) {
      global $hlpfile, $admin, $prefix;
      include ("config.php");
      $hlpfile = "manual/$language/downloads.html";
      include ("header.php");
      GraphicAdmin($hlpfile);
      $result = mysql_query("SELECT quote, author FROM $prefix"._quotes." WHERE qid = '$qid'");
      list($quote,$author) = mysql_fetch_row($result);
      OpenTable();
      echo "</center><font size=4><b>" ._EDITQUOTE."</b><br><br>
      <font size=2>
      <form action=admin.php?op=QotdAdmin method=post>
      <table border=0 width=100%><tr><td>
      " ._QUOTETEXT." </td><td><textarea class=\"textbox\" name=\"qquote\" cols=\"60\" rows=\"5\">$quote</textarea></td></tr><tr><td>
      " ._AUTHOR.": </td><td><input class=\"textbox\" type=\"text\" name=\"qauthor\" size=\"31\" maxlength=\"128\" value=\"$author\"></td></tr><tr><td>
      </td></tr></table>
      <input type=hidden name=op value=QotdSave>
      <input type=hidden name=page value=$page>
      <input type=hidden name=qqid value=$qid>
      <input type=submit value=" ._SAVECHANGES.">
      </form>
      </td></tr></table></td></tr></table>";
      include("footer.php");
       }
      
   // function for saving modified quotes
   function QotdSave($qqid,$qquote,$qauthor,$page) {
        global $prefix;
       mysql_query("UPDATE $prefix"._quotes." set quote='$qquote', author='$qauthor' WHERE qid='$qqid'");
       Header("Location: admin.php?op=QotdDisplay&page=$page");
   }

   // These are the various options when we've included this file
   switch($op) {
      case "QotdAdmin":
         QotdAdmin();
         break;

      case "QotdAdd":
         QotdAdd($qquote, $qauthor);
         break;

      case "QotdSave":
         QotdSave($qqid,$qquote,$qauthor,$page);
         break;

      case "QotdDeleteOk":   
         QotdDeleteOk($qid,$page);
         break;

      case "QotdDelete":   
         QotdDelete($qid,$page);
         break;

      case "QotdDisplay":   
         QotdDisplay($page);
         break;

      case "QotdEdit":   
         QotdEdit($qid,$page);
         break;
   }

} else {

    // message when user is not authorized
    echo "Access Denied";
}

// end of file
?>


Any help is appreciated. All I am getting is the "No quotes found" showing in my block.
 
View user's profile Send private message Visit poster's website ICQ Number
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sun Apr 17, 2005 11:11 pm Reply with quote

Are there any quotes in the database? This is the admin module that you posted here. But, the block is where the message is.
 
View user's profile Send private message
Donovan







PostPosted: Mon Apr 18, 2005 7:42 am Reply with quote

Yes I have about 10 or so quotes there.
 
Raven







PostPosted: Mon Apr 18, 2005 8:49 am Reply with quote

Please post the block code.
 
Donovan







PostPosted: Mon Apr 18, 2005 8:53 am Reply with quote

Code:
<?

// qotd (Quote of the day) function for phpnuke, based on
// software originally by Joe Stump of miester.org.
//
// adapted for phpnuke 4.x and 5.x by Erik Sooff (erik@slooff.com)
//
// 22-5-2001
//////////////////////////////////////////////////////////////////////
// 16-08-2001
// Converted to the new PHP-Nuke 5.1 Blocks System by Thiago Campos
// You can contact me at mrhemp@amigoz.org
/////////////////////////////////////////////////////////////////////

global $prefix, $currentlang;

if(file_exists("language/qotd/qotd-$currentlang.php")) {
   include("language/qotd/qotd-$currentlang.php");
}
else {
   include("language/qotd/qotd-english.php");
}

   // initiate some vars
   $content = '';

   // Create the random id for the quote
   $result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."");
   $quote_count = mysql_fetch_array($result);
   $quote_count = $quote_count[0];

   // only proceed if we have quotes in the database
   if ($quote_count > 0) {
      if ($quote_count == 1) {
         $random = 0;
      } else {
         srand((double)microtime()*1000000);
         $random = rand(0,$quote_count - 1);
      }

      // Now that we have the random number we can pull out the record
      $result = mysql_query("SELECT * FROM $prefix"._quotes." LIMIT $random,1");
      $myrow = mysql_fetch_row($result);

      // this is the start of the content for the qotd block
        $content = '<center><font class=tiny><i>';

      // add the quote text and remove whitespaces at begin or end
      $content .= trim($myrow[1]);
      $content .= '</i><br>';

      // add the author and then close everything
      $content .= '-- '.stripslashes($myrow[2]).'</font></center>';
   } else {

      // this is what we say when the quotes database is empty
      $content = ''._NOQUOTES.'';
   }


?>
 
Raven







PostPosted: Mon Apr 18, 2005 9:27 am Reply with quote

Change these lines
Code:
   // Create the random id for the quote

   $result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."");
   $quote_count = mysql_fetch_array($result);
   $quote_count = $quote_count[0];
to
Code:
   // Create the random id for the quote

   $result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."");
   $quote_count = mysql_fetch_array($result);
echo 'qc = '.$quote_count.'<br />';
   $quote_count = $quote_count[0];
echo 'qc = '.$quote_count.'<br />';
die();

and post back the result. This will kill your page after that block. Just remove the lines after you get the initial results.
 
Donovan







PostPosted: Mon Apr 18, 2005 10:09 am Reply with quote

qc =
qc =
 
Raven







PostPosted: Mon Apr 18, 2005 12:41 pm Reply with quote

Well, that's your problem. $quote_count is empty. Try adding $dbi to the global line
Code:
global $prefix, $currentlang, $dbi;

and then change
Code:
$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."");
to
Code:
$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."",$dbi);
 
Donovan







PostPosted: Mon Apr 18, 2005 2:17 pm Reply with quote

Still shows "No quotes found"

Here is what I have so far.

Code:
global $prefix, $currentlang, $dbi;


if(file_exists("language/qotd/qotd-$currentlang.php")) {
   include("language/qotd/qotd-$currentlang.php");
}
else {
   include("language/qotd/qotd-english.php");
}

   // initiate some vars
   $content = '';

   // Create the random id for the quote
   $result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."",$dbi);
   $quote_count = mysql_fetch_array($result);
   $quote_count = $quote_count[0];

   // only proceed if we have quotes in the database
   if ($quote_count > 0) {
      if ($quote_count == 1) {
         $random = 0;
      } else {
         srand((double)microtime()*1000000);
         $random = rand(0,$quote_count - 1);
      }

      // Now that we have the random number we can pull out the record
      $result = mysql_query("SELECT * FROM $prefix"._quotes." LIMIT $random,1",$dbi);
      $myrow = mysql_fetch_row($result);

      // this is the start of the content for the qotd block
        $content = '<center><font class=tiny><i>';

      // add the quote text and remove whitespaces at begin or end
      $content .= trim($myrow[1]);
      $content .= '</i><br>';

      // add the author and then close everything
      $content .= '-- '.stripslashes($myrow[2]).'</font></center>';
   } else {

      // this is what we say when the quotes database is empty
      $content = ''._NOQUOTES.'';
   }


?>
 
Raven







PostPosted: Mon Apr 18, 2005 4:20 pm Reply with quote

Replace these 2 lines
$quote_count = mysql_fetch_array($result);
$quote_count = $quote_count[0];

with
$quote_count = mysql_num_rows($result);
 
Donovan







PostPosted: Mon Apr 18, 2005 6:26 pm Reply with quote

*sigh* Same results.

"No quotes found"

Here is a dump of the table.


Code:
-- Host: localhost

-- Generation Time: Apr 18, 2005 at 07:25 PM
-- Server version: 4.0.24
-- PHP Version: 4.3.11
--
-- Database: `xxxxxxx`
--

-- --------------------------------------------------------

--
-- Table structure for table `nuke_quotes`
--

CREATE TABLE `nuke_quotes` (
  `qid` int(10) unsigned NOT NULL auto_increment,
  `quote` text,
  `author` varchar(150) NOT NULL default '',
  PRIMARY KEY  (`qid`),
  KEY `qid` (`qid`)
) TYPE=MyISAM AUTO_INCREMENT=20 ;

--
-- Dumping data for table `nuke_quotes`
--

INSERT INTO `nuke_quotes` VALUES (1, 'A real leader faces the music, even if he doesn''t like the tune.', 'Anonymous');
INSERT INTO `nuke_quotes` VALUES (2, '"Come on, you sons of bitches-do you want to live forever?" \r\n', 'Gunnery Sergeant Dan Daly, USMC, Belleau Wood, June 1918');
INSERT INTO `nuke_quotes` VALUES (3, '"Casualties many; Percentage of dead not known; Combat efficiency; we \r\nare winning." ', 'Colonel David M. Shoup, USMC, Tarawa, 21 November 1943');
INSERT INTO `nuke_quotes` VALUES (4, '"I want you boys to hurry up and ! whip these Germans so we can get out to \r\nthe Pacific to kick the s* *t out of the purple-pissing Japanese, before \r\nthe Godda**ed MARINES get all the credit!" ', 'Lt General George Patton, US Army 1945');
INSERT INTO `nuke_quotes` VALUES (5, '"Goddam it, you''ll never get the Purple Heart hiding in a foxhole! \r\nFollow me!" ', 'Captain Henry P. "Jim" Crowe, USMC, Guadalcanal, 13 January 1943');
INSERT INTO `nuke_quotes` VALUES (6, '"In the absence of orders, go find something and kill it."', 'Field Marshal Erwin Rommel');
INSERT INTO `nuke_quotes` VALUES (7, '"History does not long entrust the care of freedom to the weak or the timid."', 'General Dwight D. Eisenhower');
INSERT INTO `nuke_quotes` VALUES (8, '"The price of freedom is eternal vigilance."', 'Thomas Jefferson');
INSERT INTO `nuke_quotes` VALUES (9, '"I feel that retired generals should never miss an opportunity to remain \r\nsilent concerning matters for which they are no longer responsible."', 'General H. Norman Schwarzkopf');
INSERT INTO `nuke_quotes` VALUES (10, '"Cry ''Havoc'' and let slip the dogs of War."', 'William Shakespeare ("Julius Caesar")');
INSERT INTO `nuke_quotes` VALUES (11, '"Artillerymen believe the world consist of two types of people; other Artillerymen and targets."', 'Unknown');
 
Raven







PostPosted: Mon Apr 18, 2005 6:48 pm Reply with quote

Change
Code:
global $prefix, $currentlang, $dbi;


if(file_exists("language/qotd/qotd-$currentlang.php")) {
   include("language/qotd/qotd-$currentlang.php");
}
else {
   include("language/qotd/qotd-english.php");
}

   // initiate some vars
   $content = '';

   // Create the random id for the quote
   $result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."",$dbi);

to
Code:
global $prefix, $currentlang, $dbi;

$content = '';
if(file_exists("language/qotd/qotd-$currentlang.php")) {
   include("language/qotd/qotd-$currentlang.php");
$contents .= '1<br />';
}
else {
   include("language/qotd/qotd-english.php");
$contents .= '2<br />';
}

   // initiate some vars
//   $content = '';

   // Create the random id for the quote
   $result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."",$dbi) or die('MySQL said '.mysql_error());
 
Donovan







PostPosted: Mon Apr 18, 2005 8:08 pm Reply with quote

This is really strange. Now where the block should be says the following

MySQL said Table 'thirdadm_finance.nuke_quotes' doesn't exist

That is where I have my Nuke Treasury. Why is this script pointing to the wrong database?
 
Raven







PostPosted: Mon Apr 18, 2005 8:16 pm Reply with quote

My guess is that your NT script is stepping on the $prefix variable. Is the QOTD block right beneath your Treasury block?
 
Donovan







PostPosted: Mon Apr 18, 2005 8:39 pm Reply with quote

There are 3 blocks in between on the right side.
 
Donovan







PostPosted: Mon Apr 18, 2005 8:40 pm Reply with quote

I moved it to the left side and it came back but it still says "No quotes found"

Thanks for your help in this by the way.
 
Raven







PostPosted: Mon Apr 18, 2005 11:35 pm Reply with quote

Add this line back again:
$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."",$dbi) or die('MySQL said '.mysql_error());

If it still points to the wrong data base, right after the global line add this:
$prefix = 'nuke'; or whatever your $prefix is supposed to be.
 
Donovan







PostPosted: Tue Apr 19, 2005 7:36 am Reply with quote

I never took the first line out. I moved it back to the right side of the page with the $prefix='nuke'; and the error came back

MySQL said Table 'thirdadm_finance.nuke_quotes' doesn't exist

This is bizzare.
 
Donovan







PostPosted: Fri Sep 23, 2005 2:49 pm Reply with quote

Never did get this working. Anybody have another random quotes block to use?
 
spasticdonkey
RavenNuke(tm) Development Team



Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA

PostPosted: Thu Jan 11, 2007 8:38 pm Reply with quote

Is it just me or do the long quotes appear more often than the shorter ones?
 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©