427d620c20661a2f92ce8507c834f38d95d2b95d
[friendica-addons.git] / fortunate / fortunate.php
1 <?php
2 /**
3  * Name: Fortunate
4  * Description: Add a random fortune cookie at the bottom of every pages. [Requires manual confguration.]
5  * Version: 1.0
6  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
7  */
8
9 // IMPORTANT: SET THIS to your fortunate server
10
11 define ('FORTUNATE_SERVER', 'hostname.com');
12
13 function fortunate_install() {
14         register_hook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
15         if(FORTUNATE_SERVER == 'hostname.com' && is_site_admin()) {
16                 notice('Fortunate plugin requires configuration. See README');
17         }
18 }
19
20 function fortunate_uninstall() {
21         unregister_hook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
22 }
23
24
25 function fortunate_fetch(&$a,&$b) {
26
27         $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' 
28                 . $a->get_baseurl() . '/addon/fortunate/fortunate.css' . '" media="all" />' . "\r\n";
29
30         if(FORTUNATE_SERVER != 'hostname.com') {
31                 $s = fetch_url('http://' . FORTUNATE_SERVER . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand());
32                 $b .= '<div class="fortunate">' . $s . '</div>';
33         }
34 }
35