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>
9 use Friendica\Core\Addon;
10 use Friendica\Util\Network;
12 // IMPORTANT: SET THIS to your fortunate server
14 define('FORTUNATE_SERVER', 'hostname.com');
16 function fortunate_install()
18 Addon::registerHook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
19 if (FORTUNATE_SERVER == 'hostname.com' && is_site_admin()) {
20 notice('Fortunate addon requires configuration. See README');
24 function fortunate_uninstall()
26 Addon::unregisterHook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
30 function fortunate_fetch(&$a, &$b)
32 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
33 . $a->get_baseurl() . '/addon/fortunate/fortunate.css' . '" media="all" />' . "\r\n";
35 if (FORTUNATE_SERVER != 'hostname.com') {
36 $s = Network::fetchUrl('http://' . FORTUNATE_SERVER . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand());
37 $b .= '<div class="fortunate">' . $s . '</div>';