squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

plugin.php
Go to the documentation of this file.
1 <?php
2 
17 require_once(SM_PATH . 'functions/global.php');
18 
21 
27 function use_plugin ($name) {
28  if (file_exists(SM_PATH . "plugins/$name/setup.php")) {
29  include_once(SM_PATH . "plugins/$name/setup.php");
30  $function = "squirrelmail_plugin_init_$name";
31  if (function_exists($function)) {
32  $function();
33  }
34  }
35 }
36 
42 function do_hook ($name) {
44  $data = func_get_args();
45  $ret = '';
46 
47  if (isset($squirrelmail_plugin_hooks[$name])
48  && is_array($squirrelmail_plugin_hooks[$name])) {
49  foreach ($squirrelmail_plugin_hooks[$name] as $function) {
50  /* Add something to set correct gettext domain for plugin. */
51  if (function_exists($function)) {
52  $function($data);
53  }
54  }
55  }
56 
57  /* Variable-length argument lists have a slight problem when */
58  /* passing values by reference. Pity. This is a workaround. */
59  return $data;
60 }
61 
69 function do_hook_function($name,$parm=NULL) {
71  $ret = '';
72 
73  if (isset($squirrelmail_plugin_hooks[$name])
74  && is_array($squirrelmail_plugin_hooks[$name])) {
75  foreach ($squirrelmail_plugin_hooks[$name] as $function) {
76  /* Add something to set correct gettext domain for plugin. */
77  if (function_exists($function)) {
78  $ret = $function($parm);
79  }
80  }
81  }
82 
83  /* Variable-length argument lists have a slight problem when */
84  /* passing values by reference. Pity. This is a workaround. */
85  return $ret;
86 }
87 
96 function concat_hook_function($name,$parm=NULL) {
98  $ret = '';
99 
100  if (isset($squirrelmail_plugin_hooks[$name])
101  && is_array($squirrelmail_plugin_hooks[$name])) {
102  foreach ($squirrelmail_plugin_hooks[$name] as $function) {
103  /* Concatenate results from hook. */
104  if (function_exists($function)) {
105  $ret .= $function($parm);
106  }
107  }
108  }
109 
110  /* Variable-length argument lists have a slight problem when */
111  /* passing values by reference. Pity. This is a workaround. */
112  return $ret;
113 }
114 
128 function boolean_hook_function($name,$parm=NULL,$priority=0,$tie=false) {
130  $yea = 0;
131  $nay = 0;
132  $ret = $tie;
133 
134  if (isset($squirrelmail_plugin_hooks[$name]) &&
135  is_array($squirrelmail_plugin_hooks[$name])) {
136 
137  /* Loop over the plugins that registered the hook */
138  foreach ($squirrelmail_plugin_hooks[$name] as $function) {
139  if (function_exists($function)) {
140  $ret = $function($parm);
141  if ($ret) {
142  $yea++;
143  } else {
144  $nay++;
145  }
146  }
147  }
148 
149  /* Examine the aftermath and assign the return value appropriately */
150  if (($priority > 0) && ($yea)) {
151  $ret = true;
152  } elseif (($priority < 0) && ($nay)) {
153  $ret = false;
154  } elseif ($yea > $nay) {
155  $ret = true;
156  } elseif ($nay > $yea) {
157  $ret = false;
158  } else {
159  // There's a tie, no action needed.
160  }
161  return $ret;
162  }
163  // If the code gets here, there was a problem - no hooks, etc.
164  return NULL;
165 }
166 
176 function soupNazi(){
177 
178  $soup_menu = array('Mozilla/3','Mozilla/2','Mozilla/1', 'Opera 4',
179  'Opera/4', 'OmniWeb', 'Lynx');
180  sqgetGlobalVar('HTTP_USER_AGENT', $user_agent, SQ_SERVER);
181  foreach($soup_menu as $browser) {
182  if(stristr($user_agent, $browser)) {
183  return 1;
184  }
185  }
186  return 0;
187 }
188 /*************************************/
189 /*** MAIN PLUGIN LOADING CODE HERE ***/
190 /*************************************/
191 
192 /* On startup, register all plugins configured for use.
193  $plugins needs to be globalized because this file is
194  sometimes included inside function (non-global) scope,
195  such as for logout_error. */
196 global $plugins;
197 if (isset($plugins) && is_array($plugins)) {
198  // turn on output buffering in order to prevent output of new lines
199  ob_start();
200  foreach ($plugins as $name) {
201  use_plugin($name);
202  }
203  $output = trim(ob_get_contents());
204  ob_end_clean();
205  // if plugins output more than newlines and spacing, stop script execution.
206  if (!empty($output)) {
207  die($output);
208  }
209 }
210 
elseif
if(! sqgetGlobalVar('sound', $sound, SQ_GET)) elseif($sound=='(none)')
Definition: testsound.php:25
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
$ret
$ret
Definition: webmail.php:172
concat_hook_function
concat_hook_function($name, $parm=NULL)
Definition: plugin.php:96
do_hook
do_hook($name)
Definition: plugin.php:42
$plugins
global $plugins
Definition: plugin.php:196
$output
$output
Definition: webmail.php:71
use_plugin
use_plugin($name)
Definition: plugin.php:27
$squirrelmail_plugin_hooks
global $squirrelmail_plugin_hooks
Definition: plugin.php:17
do_hook_function
do_hook_function($name, $parm=NULL)
Definition: plugin.php:69
SQ_SERVER
const SQ_SERVER
Definition: global.php:20
$data
$data
Definition: mailto.php:83
SM_PATH
const SM_PATH
Definition: decrypt_headers.php:16
NULL
if(!defined('PAGE_NAME')) define('PAGE_NAME' NULL
Definition: validate.php:16
boolean_hook_function
boolean_hook_function($name, $parm=NULL, $priority=0, $tie=false)
Definition: plugin.php:128
soupNazi
soupNazi()
Definition: plugin.php:176