To use this website completely, it is necessary to store cookies on your computer.
 

* Navigator

Expand - Collapse

* Statistic

  • *Total Posts: 14942
  • *Total Topics: 2271
  • *Online Today: 12
  • *Most Online: 292
(2016 November 12, 09:37:31 am)

Ran Quotes + Submit + PW

Started by Demon Slushy, 2008 December 15, 10:33:41 am

previous topic - next topic

0 Members and 0 Guests are viewing this topic.

Demon Slushy

2008 December 15, 10:33:41 am
Description

This is a random quote script for a side block. Displays a random quote with each page refresh.
Bellow the quotes is a button to submit new quotes so you don't have to manually edit the flat file db where the quotes are stored (however you will if you want to remove a quote).  When you click the add quote button a popup window will appear prompting you to add a password which you defined in the addquote.php file. After you add the password you will see a simple form to add your new quote. That's it!

Installation

Installation is simple download the attached file and extract it. In side the folder should be three files:

-addquote.php <---You will need to edit this file with a text editor to define your password and change the background color and font colors for the popup window to suit your site.

-senddatshit.php <--- You won't need to edit this unless you want to change the "Thank you, your quote has been added!" message.

-quotes.txt <--- This is where your actual quotes are stored.

Upload those three files to your severs root. (Just the files not the folder!)

Goto your PortaMX block manager and create a new php block and add the following code:

Code Select

//Configuration

$quotetitle="Random Quote";
$quotefile="quotes.txt";

//directory

$dir=$_SERVER['DOCUMENT_ROOT'];

//No need to change anything below here except your sites url where the addquote.php is located.
if (file_exists($dir."/".$quotefile)) {
  $quote=file($dir."/".$quotefile);
  $rand_key=array_rand($quote, 1);
list($qtext, $qauthor) = explode("|", trim($quote[$rand_key]));

  echo '<div>';
  if (isset($qtext) && $qtext!="") { echo '<p>'.$qtext.'</p>'; }
  if (isset($qauthor) && $qauthor!="") { echo '<p style="color:#707070; font: normal 7pt Arial, Helvetica, sans-serif; margin: 5px 0 0 20px; padding: 0;">'.$qauthor.'</p>'; }
  echo '</div><hr />';
}

echo '<br /><center><form>
<INPUT type="button" value="Add Quote" onClick="window.open('; echo "'http://www.yoursite/addquote.php','mywindow','width=200,height=200')"; echo '">
</form></center>';


and you are done :) You can change the directory where your files are stored just make sure you do so in the above block code.

-EDIT-
Missed something you will need to also change the

Code Select

<INPUT type="button" value="Add Quote" onClick="window.open('; echo "'http://www.yoursite/addquote.php','mywindow','width=200,height=200')"; echo '">

to your url ;p

[attachment deleted by admin]

Gravity

#1
2009 February 22, 07:08:00 pm
EXCELLENT code.  Just what I was looking for!

justdownload.us

#2
2009 April 01, 08:58:41 pm
nice one dude!!!

Keep up the good work!! O0
DOn't BeLiEve tHat yOu kNow EverYthiNg!!

mmarak524

#3
2010 December 20, 07:47:58 am
This is a wonderful coding and I am totally using it.  But is there anyway that we can do this with images and links?

kev

#4
2011 August 19, 10:16:26 pm
Hi

I have just installed this on my site and after submitting a quote i get this message and no quote is visible

QuoteThank You!
Your quote has been added!
Warning: fputs() expects parameter 3 to be long, string given in /MYSITE/senddatshit.php on line 10


any idea what the problem is please, i am using latest version of the portal and the random quote block appears on my site i changed the password and i was able to add a quote but got this message

thanks

kev

#5
2011 August 23, 01:42:56 pm
Anyone for the above post please

feline

#6
2011 August 23, 07:32:56 pm
Seems like a bug in the file .. call the author.
Many are stubborn in relation to the path, a few in relation to the target.

FireDitto

#7
2012 December 30, 02:00:57 am
Quote from: mmarak524 ,  2010 December 20, 07:47:58 am
This is a wonderful coding and I am totally using it.  But is there anyway that we can do this with images and links?


Indeed! I'd love to have another input value to link to the location from which the quote came (on my site, a thread) so that people can go and read it in context.

How would one go about this?