| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * plugins/fortune/setup.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2003 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * Original code contributed by paulm@spider.org |
| 10 | * |
| 11 | * Simple SquirrelMail WebMail Plugin that displays the output of |
| 12 | * fortune above the message listing. |
| 13 | * |
| 14 | * $Id$ |
| 15 | */ |
| 16 | |
| 17 | function squirrelmail_plugin_init_fortune() { |
| 18 | global $squirrelmail_plugin_hooks; |
| 19 | |
| 20 | $squirrelmail_plugin_hooks['mailbox_index_before']['fortune'] = 'fortune'; |
| 21 | $squirrelmail_plugin_hooks['options_display_inside']['fortune'] = 'fortune_options'; |
| 22 | $squirrelmail_plugin_hooks['options_display_save']['fortune'] = 'fortune_save'; |
| 23 | $squirrelmail_plugin_hooks['loading_prefs']['fortune'] = 'fortune_load'; |
| 24 | } |
| 25 | |
| 26 | function fortune() { |
| 27 | global $fortune_visible, $color; |
| 28 | |
| 29 | if (!$fortune_visible) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | $fortune_location = '/usr/games/fortune'; |
| 34 | $exist = file_exists($fortune_location); |
| 35 | echo "<center><table cellpadding=0 cellspacing=0 border=0 bgcolor=$color[10]><tr><td><table width=100% cellpadding=2 cellspacing=1 border=0 bgcolor=\"$color[5]\"><tr><td align=center>"; |
| 36 | echo '<TABLE><TR><TD>'; |
| 37 | if (!$exist) { |
| 38 | echo "$fortune_location" . _(" not found."); |
| 39 | } else { |
| 40 | echo "<CENTER><FONT=3><EM>" . _("Today's Fortune") . "</EM><BR></FONT></CENTER><pre>"; |
| 41 | system($fortune_location); |
| 42 | } |
| 43 | |
| 44 | echo '</pre></TD></TR></TABLE></td></tr></table></td></tr></table></center>'; |
| 45 | } |
| 46 | |
| 47 | function fortune_load() { |
| 48 | global $username, $data_dir, $fortune_visible; |
| 49 | |
| 50 | $fortune_visible = getPref($data_dir, $username, 'fortune_visible'); |
| 51 | } |
| 52 | |
| 53 | function fortune_options() { |
| 54 | global $fortune_visible; |
| 55 | |
| 56 | echo "<tr><td align=right nowrap>" . _("Fortunes:") . "</td>\n"; |
| 57 | echo '<td><input name="fortune_fortune_visible" type=CHECKBOX'; |
| 58 | if ($fortune_visible) |
| 59 | echo ' CHECKED'; |
| 60 | echo "> " . _("Show fortunes at top of mailbox") . "</td></tr>\n"; |
| 61 | } |
| 62 | |
| 63 | function fortune_save() { |
| 64 | global $username,$data_dir; |
| 65 | |
| 66 | if (isset($_POST['fortune_fortune_visible'])) { |
| 67 | setPref($data_dir, $username, 'fortune_visible', '1'); |
| 68 | } else { |
| 69 | setPref($data_dir, $username, 'fortune_visible', ''); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | ?> |