Replacing deprecated HTML "center" element (second try).
[squirrelmail.git] / plugins / fortune / functions.php
1 <?php
2
3 /**
4 * Fortune plugin functions
5 *
6 * @copyright &copy; 2004-2006 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
9 * @package plugins
10 * @subpackage fortune
11 */
12
13 /**
14 * Declare configuration globals
15 */
16 global $fortune_location, $fortune_options;
17
18 /**
19 * Load default config
20 */
21 include_once(SM_PATH . 'plugins/fortune/config_default.php');
22
23 /**
24 * Load site config
25 */
26 if (file_exists(SM_PATH . 'config/fortune_config.php')) {
27 include_once(SM_PATH . 'config/fortune_config.php');
28 } elseif (file_exists(SM_PATH . 'plugins/fortune/config.php')) {
29 include_once(SM_PATH . 'plugins/fortune/config.php');
30 }
31
32 /**
33 * Show fortune
34 * @access private
35 * @since 1.5.1
36 */
37 function fortune_function() {
38 global $fortune_visible, $color, $fortune_location, $fortune_options;
39
40 if (!$fortune_visible) {
41 return;
42 }
43
44 $exist = file_exists($fortune_location);
45
46 if ($fortune_options!='') {
47 $fortune_command=$fortune_location . ' ' . $fortune_options;
48 } else {
49 $fortune_command=$fortune_location;
50 }
51
52 echo "<div style=\"text-align: center;\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"$color[10]\">\n".
53 "<tr><td><table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\" bgcolor=\"$color[5]\">\n".
54 "<tr><td align=\"center\">\n";
55 echo '<table><tr><td>';
56 if (!$exist) {
57 printf(_("%s is not found."),$fortune_location);
58 } else {
59 echo "<div style=\"text-align: center;\"><em>" . _("Today's Fortune") . "</em></div><pre>\n" .
60 htmlspecialchars(shell_exec($fortune_command)) .
61 "</pre>\n";
62 }
63
64 echo '</td></tr></table></td></tr></table></td></tr></table></div>';
65 }
66
67 /**
68 * Add fortune options
69 * @access private
70 * @since 1.5.1
71 */
72 function fortune_function_options() {
73 global $optpage_data;
74
75 $optpage_data['grps']['fortune'] = _("Fortunes:");
76 $optionValues = array();
77 $optionValues[] = array('name' => 'fortune_visible',
78 'caption' => _("Show fortunes at top of mailbox"),
79 'type' => SMOPT_TYPE_BOOLEAN,
80 'initial_value' => false );
81 $optpage_data['vals']['fortune'] = $optionValues;
82 }
83
84 /**
85 * Get fortune prefs
86 * @access private
87 * @since 1.5.1
88 */
89 function fortune_function_load() {
90 global $username, $data_dir, $fortune_visible;
91
92 $fortune_visible = getPref($data_dir, $username, 'fortune_visible');
93 }
94 ?>