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