9b5edd1d |
1 | <?php |
2 | |
3 | /** |
4 | * plugins/fortune/setup.php |
5 | * |
9b5edd1d |
6 | * Original code contributed by paulm@spider.org |
7 | * |
8 | * Simple SquirrelMail WebMail Plugin that displays the output of |
9 | * fortune above the message listing. |
10 | * |
0fe5da50 |
11 | * @copyright (c) 1999-2004 The SquirrelMail Project Team |
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
13 | * @version $Id$ |
ea5f4b8e |
14 | * @package plugins |
15 | * @subpackage fortune |
9b5edd1d |
16 | */ |
17 | |
ea5f4b8e |
18 | /** |
0fe5da50 |
19 | * Init plugin |
20 | * @access private |
21 | */ |
9b5edd1d |
22 | function squirrelmail_plugin_init_fortune() { |
23 | global $squirrelmail_plugin_hooks; |
24 | |
25 | $squirrelmail_plugin_hooks['mailbox_index_before']['fortune'] = 'fortune'; |
26 | $squirrelmail_plugin_hooks['options_display_inside']['fortune'] = 'fortune_options'; |
27 | $squirrelmail_plugin_hooks['options_display_save']['fortune'] = 'fortune_save'; |
28 | $squirrelmail_plugin_hooks['loading_prefs']['fortune'] = 'fortune_load'; |
29 | } |
30 | |
0fe5da50 |
31 | /** |
32 | * Show fortune |
33 | * @access private |
34 | */ |
9b5edd1d |
35 | function fortune() { |
36 | global $fortune_visible, $color; |
37 | |
38 | if (!$fortune_visible) { |
39 | return; |
40 | } |
41 | |
42 | $fortune_location = '/usr/games/fortune'; |
ecaf45ec |
43 | $exist = file_exists($fortune_location); |
a9e1e670 |
44 | echo "<center><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"$color[10]\">\n". |
45 | "<tr><td><table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\" bgcolor=\"$color[5]\">\n". |
46 | "<tr><td align=\"center\">\n"; |
47 | echo '<table><tr><td>'; |
9b5edd1d |
48 | if (!$exist) { |
75d3419e |
49 | echo "$fortune_location" . _(" not found."); |
9b5edd1d |
50 | } else { |
a9e1e670 |
51 | echo "<center><em>" . _("Today's Fortune") . "</em><br></font></center><pre>"; |
52 | htmlspecialchars(system($fortune_location)); |
9b5edd1d |
53 | } |
54 | |
a9e1e670 |
55 | echo '</pre></td></tr></table></td></tr></table></td></tr></table></center>'; |
9b5edd1d |
56 | } |
57 | |
0fe5da50 |
58 | /** |
59 | * Get fortune prefs |
60 | * @access private |
61 | */ |
9b5edd1d |
62 | function fortune_load() { |
63 | global $username, $data_dir, $fortune_visible; |
64 | |
65 | $fortune_visible = getPref($data_dir, $username, 'fortune_visible'); |
66 | } |
67 | |
0fe5da50 |
68 | /** |
69 | * Add fortune options |
70 | * @access private |
71 | */ |
9b5edd1d |
72 | function fortune_options() { |
73 | global $fortune_visible; |
74 | |
a75e70b1 |
75 | echo "<tr>" . html_tag('td',_("Fortunes:"),'right','','nowrap') . "\n"; |
9b5edd1d |
76 | echo '<td><input name="fortune_fortune_visible" type=CHECKBOX'; |
77 | if ($fortune_visible) |
78 | echo ' CHECKED'; |
0fe5da50 |
79 | echo " /> " . _("Show fortunes at top of mailbox") . "</td></tr>\n"; |
9b5edd1d |
80 | } |
81 | |
0fe5da50 |
82 | /** |
83 | * Save fortune prefs |
84 | * @access private |
85 | */ |
9b5edd1d |
86 | function fortune_save() { |
87 | global $username,$data_dir; |
9b5edd1d |
88 | |
a8a3b441 |
89 | if (sqgetGlobalVar('fortune_fortune_visible',$fortune_fortune_visible,SQ_POST)) { |
9b5edd1d |
90 | setPref($data_dir, $username, 'fortune_visible', '1'); |
91 | } else { |
92 | setPref($data_dir, $username, 'fortune_visible', ''); |
93 | } |
94 | } |
95 | |
a9e1e670 |
96 | ?> |