Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
LadySyren
Regular
Regular



Joined: Sep 03, 2004
Posts: 56
Location: Iowa

PostPosted: Sun Dec 26, 2004 12:16 am Reply with quote

I wasn't sure where to post this, so if its in the wrong area I apologize. I was just wondering if someone would be able to tell me if there is anything wrong with this ...

<?php
/************************************************************************************/
/* /*
/* QOTM Block for PHP-Nuke 6.5-7.6 /*
/* v1.0 /*
/* /*
/* Copyright © 2004 by: JRSweets (JRSweets@gmail.com) /*
/* [ Only registered users can see links on this board! Get registered or login! ] /*
/* /*
/* 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. /*
/* /*
/************************************************************************************/

if(stristr($_SERVER['SCRIPT_NAME'],"block-QOTM.php")) {
Header("Location: index.php");
die();
}

global $prefix;

$quote_count = 0;
$sql = "SELECT COUNT(*) FROM $prefix"._bbqotm;
$quote_count = $db->sql_query($sql);

if ($quote_count > 0)
{
$sql ="SELECT * FROM $prefix"._qotm." ORDERY BY rand()";
$row = $db->sql_fetchrow($db->sql_query($sql));

$content = '<center><font class=tiny><i>';
$content .= trim($row[quote_text]);
$content .= '</i><br>';
$content .= '- '.stripslashes($row[quote_author]).'</font></center>';
}
else
{
$content = 'No Quotes in Database';
}




?>

I did as instructed and it kept telling me this odd error. Something about a non member function (or something like that) on line 25 in the coding.
 
View user's profile Send private message Send e-mail Visit poster's website AIM Address
PHrEEkie
Subject Matter Expert



Joined: Feb 23, 2004
Posts: 358

PostPosted: Sun Dec 26, 2004 12:22 am Reply with quote

Add $db to the global line

global $db, $prefix;

PHrEEk

_________________
PHP - Breaking your legacy scripts one build at a time. 
View user's profile Send private message
LadySyren







PostPosted: Sun Dec 26, 2004 12:40 am Reply with quote

Thanks, I did that and it seems to be working now. There's just one problem. It appears that there isn't a way for someone to add or submit a quote.
 
PHrEEkie







PostPosted: Sun Dec 26, 2004 12:57 am Reply with quote

You'd have to add a form to it, and depending on how complicated you wanted to get with the form, you might need to create a module for Quote submissions. Anytime you want to allow user submissions, you are then getting into an area of security concern. I can't imagine there isn't already a random quote module with block available anywhere? Have you had a look around, or has everything left you wanting to create a custom one? It's a lot of work, because not only do you have to create the submission form, you also have to have a receiving script to process the submission, check it for security issues, and add it to the database.

PHrEEk
 
LadySyren







PostPosted: Sun Dec 26, 2004 8:13 am Reply with quote

Well, according to the information about this quote of the moment block I downloaded, everythings suppose to be there already to allow users to submit a quote, let admins review it and either accept or deny it, etc. Only things I see are the block itself, no quotes, no way for users to submit them. I also see the quote of the moment control/admin area in the forums admin control panel but that only has config, review, and management. There's nothing even for an admin to enter a quote. I'd love to find a quote of the moment or quote of the day block that will allow users to submit their own quotes but so far this is the only one I've found and it's not usable.
 
JRSweets
Worker
Worker



Joined: Aug 06, 2004
Posts: 192

PostPosted: Mon Dec 27, 2004 10:12 am Reply with quote

It works and will do everything you want it to. I just noticed this post, (thanks to Raven sending a PM Wink)

To submit a quote goto the forums main page and you will see this above you forums.

Click "Add a Quote" and you and your users can add them from there.

Depending on your settings, both the words are also links. One links to [ Only registered users can see links on this board! Get registered or login! ] to display a full listing of all the quotes, the other [ Only registered users can see links on this board! Get registered or login! ] also for adding of quotes.

The admin can always add quotes, however users will only see the add quote link if you give users the ability to add quotes.

As for the block, I had placed to wrong one in the package.

You can get the updated block [ Only registered users can see links on this board! Get registered or login! ] as there is still a typo in the one above.


Last edited by JRSweets on Mon Mar 07, 2005 2:00 pm; edited 1 time in total 
View user's profile Send private message
LadySyren







PostPosted: Mon Dec 27, 2004 11:33 am Reply with quote

Oh peachy Smile Thanks a bunch. I've downloaded the one you said to and again, did everything as instructed. I tried to submit a quote to test it out and I get this error message:

Failed to insert quote into table

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Syren', '', '2', '63.186.1.4', '1104168701')' at line 1

INSERT INTO nuke_bbqotm (quote_text, quote_author, quote_enabled, quote_user_id, quote_ipaddress, quote_date) VALUES ('\If love is so blind, why is lingerie so popular?\', 'Syren', '', '2', '63.186.1.4', '1104168701')

Line : 128
File : /home/xxxxx/public_html/xxxxx/modules/Forums/qotm_user.php
 
LadySyren







PostPosted: Mon Dec 27, 2004 11:48 am Reply with quote

Actually, I figured out why I got that error so I fixed it Smile Thanks a bunch for all the help, guys!!

Happy Holidays!
 
JRSweets







PostPosted: Mon Dec 27, 2004 12:02 pm Reply with quote

Why did you get the error? Post it here, it may help someone else.
 
LadySyren







PostPosted: Mon Dec 27, 2004 3:29 pm Reply with quote

Well, that error showed up because when I submitted a quote, I had included " "'s in with the text. IE: "If love is so blind, why is lingerie so popular?" When people submit their own quotes, they have to just submit the text without the " "'s . Make sense?
 
JRSweets







PostPosted: Mon Dec 27, 2004 6:03 pm Reply with quote

If you find these lines in quote_user.php
Code:
                        //Lets do some security checking of the submitted data

                        $quote = str_replace("\'","''",$HTTP_POST_VARS['quote_text']);
                        $quote = preg_replace(array('#&(?!(\#[0-9]+;))#', '#<#', '#>#'), array('&amp;', '&lt;', '&gt;'),$quote);
                        //Remove quotes if there
                        $quote = str_replace("\"","",$quote);


Replace with this:
Code:
                        //Remove quotes if there

                        $quote = str_replace("\"","",$HTTP_POST_VARS['quote_text']);

                        //Lets do some security checking of the submitted data
                        $quote = str_replace("\'","''",$quote);
                        $quote = preg_replace(array('#&(?!(\#[0-9]+;))#', '#<#', '#>#'), array('&amp;', '&lt;', '&gt;'),$quote);


It won't matter if the user submits the quote surrounded by quotation marks or not. (That was what I was trying to do in the first place)
 
LadySyren







PostPosted: Tue Dec 28, 2004 9:19 am Reply with quote

Oh wonderful! Thanks so much!
 
Deseroka
Client



Joined: Apr 15, 2003
Posts: 466
Location: FL

PostPosted: Tue Jan 04, 2005 6:08 am Reply with quote

Has anyone successfully made this work with a theme like Chronicles? I guess the images interfere, it shows up in a theme like 3DFantasy, but not Chronicles.
 
View user's profile Send private message
JRSweets







PostPosted: Fri Jan 07, 2005 1:30 pm Reply with quote

I have never had this problem.

Side note: If anyone wants to add the number of waiting quotes to the admin waiting content block...

(If using nuke older than 7.6 the replace ".$admin_file." with "admin".)

Open mainfile.php and find:
Code:
$content .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"".$admin_file.".php?op=DownloadsListBrokenDownloads\">"._BROKENDOWN."</a>: $brokend<br></font>"; 


Add add:
Code:
$qotmreqd = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_bbqotm WHERE quote_enabled='0'"));

$content .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"".$admin_file.".php?op=forums\">Waiting Quotes</a>: $qotmreqd<br></font>";


Last edited by JRSweets on Fri Jan 07, 2005 1:39 pm; edited 2 times in total 
Deseroka







PostPosted: Fri Jan 07, 2005 1:35 pm Reply with quote

Thank you, but I am sorry. I got impatient and ended up removing the application and just adding them into my header. Very nice mod tho, and I love that members were able to submit.
 
JRSweets







PostPosted: Fri Jan 07, 2005 1:39 pm Reply with quote

Deseroka wrote:
Has anyone successfully made this work with a theme like Chronicles? I guess the images interfere, it shows up in a theme like 3DFantasy, but not Chronicles.


Code:
<?php

/************************************************************************************/
/*                                                                                  */
/* QOTM Block for PHP-Nuke 6.5-7.6                                                  */
/* v1.0                                                                             */
/*                                                                                  */
/* Copyright © 2004 by: JRSweets (JRSweets@gmail.com)                               */
/* http://www.jeffrusso.net                                                         */
/*                                                                                  */
/* 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.                   */
/*                                                                                  */
/************************************************************************************/

if(stristr($_SERVER['SCRIPT_NAME'], "block-Quote_of_the_Moment.php")) {
    Header("Location: index.php");
    die();
}

global $db, $prefix;

        $quote_count = 0;
        $sql = "SELECT COUNT(*) FROM $prefix"._bbqotm;
        $quote_count = $db->sql_query($sql);

        if ($quote_count > 0)
        {
                $sql  ="SELECT quote_text, quote_author FROM $prefix"._bbqotm." WHERE quote_enabled = 1 ORDER BY rand()";
                $row = $db->sql_fetchrow($db->sql_query($sql));

                $content = '<center><font class=tiny><i>';
                $content .= trim($row['quote_text']);
                $content .= '</i><br>';
                $content .= '- '.stripslashes($row['quote_author']).'</font></center>';
        }
        else
        {
                $content = 'No Quotes in Database';
        }


?>


This is the whole updated block, it should intefere with anything. No images or anything are called. I have it working with 5 different themes on my site.

Hmm.... Strange
 
Deseroka







PostPosted: Fri Jan 07, 2005 2:19 pm Reply with quote

It worked in 3d fantasy, elektro, all of the others, but could not get it to work in Chronicles. I know this theme also interferes with the public message so....I dunno. You know much more than me Embarassed
 
JRSweets







PostPosted: Fri Jan 07, 2005 3:38 pm Reply with quote

If you ever try to install it again, send me a pm and I will see if I can get it working.
 
Deseroka







PostPosted: Fri Jan 07, 2005 3:57 pm Reply with quote

Thank you!
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

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 ©