functions.php 2.4 KB

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