[PLUGIN] rFacts: Random Fact System

brsy

nah mang
May 12, 2011
1,530
272
Here is rFacts 1.0, which displays random facts. The facts are edited within the database, and once you follow the instructions below, just read the first fact and it will show you the final step. I MIGHT create a backend plugin so you can edit it within the housekeeping. This can be used on a RevCMS hotel, and it is mostly used on the Habbo themes. Do not re-release on any forum without valid permissions.

Installation Instructions
- Open up class.core.php within the RevCMS app folder. Insert this code above the first class.
PHP:
    public function rFacts() {
        $getFacts = mysql_query("SELECT facts FROM r_facts ORDER by RAND() LIMIT 10");
            return mysql_result($getFacts);
    }

- Next, open app-->class.template.php and within the Init() function, put the following code.
PHP:
$this->setParams('rFacts', $core->rFacts());

- Then, go to where ever you want the facts to be and type {rFacts}

- Finally, run the following query in the database.
PHP:
CREATE TABLE IF NOT EXISTS `r_facts` (
  `facts` varchar(999) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
--
-- Dumping data for table `r_facts`
--
 
INSERT INTO `r_facts` (`facts`) VALUES
('These messages can be edited from within the r_facts table :)');

You are done!

Credits:

ChrizPHP - Creating & coding the release (90%)
Fresh Hotel - Giving me the idea (10%)
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
Erm..
1) Why is the rFacts method in the core class? It should be in the Users class, organization is key.
2) The rFacts method does not return anything, so the setParam shouldn't work?
3) #2 makes me think - did you test this?
 

brsy

nah mang
May 12, 2011
1,530
272
Erm..
1) Why is the rFacts method in the core class? It should be in the Users class, organization is key.
2) The rFacts method does not return anything, so the setParam shouldn't work?
3) #2 makes me think - did you test this?
I'm so sorry, I edit the function just now. I put it into the core, because I felt it wouldn't really matter. I should put a return infront of the mysql result. @#3 I implemented it onto Habpro Hotel.

can you pin this to the plugins node?
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,199
3,934
Or you could do this:

PHP:
<?php
  
$FACT['1'] = "Obbo Hotel opened on the 30th March 2012";
$FACT['2'] = "Obbo Hotel was created by Craig, Luis and Mcd!";
$FACT['3'] = "Obbo Staff releases a new rare every week! ";
$FACT['4'] = "Obbo Staff creates their own rare values to make it easier for you!"; 
$FACT['5'] = "Obbo Staff will always update you on what is happening with Obbo!!"; 
$FACT['6'] = "The most users online was.. 120!";
$FACT['7'] = "Obbo Staff backup the database EVERY 24 hours, somtimes twice a day!";
$FACT['8'] = "You will always see the catalogue update, if not everyday!!";
$FACT['9'] = "We create our own badges and give them to you!";
$FACT['10'] = "Every record in usercount online we break, we give out a badge!";
$FACT['11'] = "There is over 11.70 GB worth of data in back ups already!";
$FACT['12'] = "We have over 6,546 users registered!";
$FACT['13'] = "There is over 10,642 rooms made in the hotel!";
$FACT['14'] = "Over 1329794 thousand pieces of furniture have been bought!";
 
echo "<b>FACT:</b>&nbsp;". $FACT[rand(1,14)];

But nice release.
 

brsy

nah mang
May 12, 2011
1,530
272
Or you could do this:

PHP:
<?php
 
$FACT['1'] = "Obbo Hotel opened on the 30th March 2012";
$FACT['2'] = "Obbo Hotel was created by Craig, Luis and Mcd!";
$FACT['3'] = "Obbo Staff releases a new rare every week! ";
$FACT['4'] = "Obbo Staff creates their own rare values to make it easier for you!";
$FACT['5'] = "Obbo Staff will always update you on what is happening with Obbo!!";
$FACT['6'] = "The most users online was.. 120!";
$FACT['7'] = "Obbo Staff backup the database EVERY 24 hours, somtimes twice a day!";
$FACT['8'] = "You will always see the catalogue update, if not everyday!!";
$FACT['9'] = "We create our own badges and give them to you!";
$FACT['10'] = "Every record in usercount online we break, we give out a badge!";
$FACT['11'] = "There is over 11.70 GB worth of data in back ups already!";
$FACT['12'] = "We have over 6,546 users registered!";
$FACT['13'] = "There is over 10,642 rooms made in the hotel!";
$FACT['14'] = "Over 1329794 thousand pieces of furniture have been bought!";
 
echo "<b>FACT:</b>&nbsp;". $FACT[rand(1,14)];

But nice release.
I'd rather it being done using MySQL because you can implement it into the housekeeping, making adding/editing an ease.
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,199
3,934
I'd rather it being done using MySQL because you can implement it into the housekeeping, making adding/editing an ease.

Or you can simply add a new line and not run a query that isn't needed each time :D?!
 

Quackster

a devbest user says what
Aug 22, 2010
1,765
1,245
The function tries to select c_facts yet the table SQL name is r_facts?!?! dafuq is diz? fukn conspiracy
 

brsy

nah mang
May 12, 2011
1,530
272
The function tries to select c_facts yet the table SQL name is r_facts?!?! dafuq is diz? fukn conspiracy
I guess you are such a troll that you forgot how to read. I edited the function a lot... especially since I didn't want to take it directly from my CMS...
 

Mee

Member
May 4, 2012
232
28
Another way of doing it is using Rantex;

rantex.php
Code:
<?php
$settings['text_from_file'] = '';

$settings['quotes'] = array(
'Text here 1',
'Text here 2',
);

$settings['display_type'] = 1;

$settings['allow_otf'] = 1;

if ($settings['allow_otf'] && isset($_GET['type']))
{
$type = intval($_GET['type']);
}
else
{
$type = $settings['display_type'];
}

if ($settings['text_from_file'])
{
$settings['quotes'] = file($settings['text_from_file']);
}

if (count($settings['quotes']))
{
$txt = $settings['quotes'][array_rand($settings['quotes'])];
}
else
{
$txr = 'No text to choose from';
}

if ($type)
{

$txt = nl2br(trim($txt));
$txt = str_replace(array("\n","\r"),'',$txt);
echo 'document.write(\''.addslashes($txt).'\')';
}
else
{
echo $txt;
}
?>

Display line
Code:
<script type="text/javascript" src="rantex.php"></script>
 

Gajeel

Well-Known Member
Oct 4, 2011
2,411
413
I used Javascript before, which was something alike to @Sledmore's script but his were on PHP and the site takes like few seconds to load just because of the script so he suggested me to use it and bam the site loads faster (since I did a lot of facts at the Javascript code).
 

Users who are viewing this thread

Top