4 * Description: Add a random fortune cookie at the bottom of every pages. [Requires manual confguration.]
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
8 use Friendica\Core\Addon;
10 // IMPORTANT: SET THIS to your fortunate server
12 define ('FORTUNATE_SERVER', 'hostname.com');
14 function fortunate_install() {
15 Addon::registerHook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
16 if(FORTUNATE_SERVER == 'hostname.com' && is_site_admin()) {
17 notice('Fortunate addon requires configuration. See README');
21 function fortunate_uninstall() {
22 Addon::unregisterHook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
26 function fortunate_fetch(&$a,&$b) {
28 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
29 . $a->get_baseurl() . '/addon/fortunate/fortunate.css' . '" media="all" />' . "\r\n";
31 if(FORTUNATE_SERVER != 'hostname.com') {
32 $s = fetch_url('http://' . FORTUNATE_SERVER . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand());
33 $b .= '<div class="fortunate">' . $s . '</div>';