Viewing file: global.php (4.68 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
// // taken from functions/plugin.php on 2006/09/07 // since 1.5.2 // if (!function_exists('check_plugin_version')) { function check_plugin_version($plugin_name, $a = 0, $b = 0, $c = 0, $force_inclusion = FALSE) {
$info_function = $plugin_name . '_info'; $version_function = $plugin_name . '_version'; $plugin_info = array(); $plugin_version = FALSE;
// first attempt to find the plugin info function, wherein // the plugin version should be available // if (function_exists($info_function)) $plugin_info = $info_function(); else if ($force_inclusion && file_exists(SM_PATH . 'plugins/' . $plugin_name . '/setup.php')) { include_once(SM_PATH . 'plugins/' . $plugin_name . '/setup.php'); if (function_exists($info_function)) $plugin_info = $info_function(); } if (!empty($plugin_info['version'])) $plugin_version = $plugin_info['version'];
// otherwise, look for older version function // if (!$plugin_version && function_exists($version_function)) $plugin_version = $version_function();
if (!$plugin_version) return FALSE;
// now massage version number into something we understand // $plugin_version = trim(preg_replace(array('/[^0-9.]+.*$/', '/[^0-9.]/'), '', $plugin_version), '.'); $plugin_version = explode('.', $plugin_version); if (!isset($plugin_version[0])) $plugin_version[0] = 0; if (!isset($plugin_version[1])) $plugin_version[1] = 0; if (!isset($plugin_version[2])) $plugin_version[2] = 0; // sm_print_r($plugin_version);
// now test the version number // if ($plugin_version[0] < $a || ($plugin_version[0] == $a && $plugin_version[1] < $b) || ($plugin_version[0] == $a && $plugin_version[1] == $b && $plugin_version[2] < $c)) return FALSE;
return TRUE;
} }
// // taken from functions/plugin.php on 2006/09/21 // since 1.5.2 // if (!function_exists('sqm_array_merge')) { function sqm_array_merge($a, $b, $concat_strings=true) {
$ret = array();
if (is_array($a)) { $ret = $a; } else { if (is_string($a) && is_string($b) && $concat_strings) { return $a . $b; } $ret[] = $a; }
if (is_array($b)) { foreach ($b as $key => $value) { if (isset($ret[$key])) { $ret[$key] = sqm_array_merge($ret[$key], $value, $concat_strings); } else { $ret[$key] = $value; } } } else { $ret[] = $b; }
return $ret;
} }
// // taken from functions/global.php on 2007/01/14 // since 1.5.2 // if (!function_exists('sqGetGlobalVarMultiple')) { function sqGetGlobalVarMultiple($name, &$value, $indicator_field, $search = SQ_INORDER, $fallback_no_suffix=TRUE, $default=NULL, $typecast=FALSE) {
// Set arbitrary max limit -- should be much lower except on the // search results page, if there are many (50 or more?) mailboxes // shown, this may not be high enough. Is there some way we should // automate this value? // $max_form_search = 100;
for ($i = 1; $i <= $max_form_search; $i++) { if (sqGetGlobalVar($indicator_field . '_' . $i, $temp, $search)) { return sqGetGlobalVar($name . '_' . $i, $value, $search, $default, $typecast); } }
// no indicator field found; just try without suffix if allowed // if ($fallback_no_suffix) { return sqGetGlobalVar($name, $value, $search, $default, $typecast); }
// no dice, set default and return FALSE // if (!is_null($default)) { $value = $default; } return FALSE;
} }
// // taken from functions/global.php on 2007/01/14 // since 1.5.2 // if (!function_exists('sq_htmlspecialchars')) { function sq_htmlspecialchars($value, $quote_style=ENT_QUOTES) {
if ($quote_style === FALSE) $quote_style = ENT_QUOTES;
// array? go recursive... // if (is_array($value)) { $return_array = array(); foreach ($value as $key => $val) { $return_array[sq_htmlspecialchars($key, $quote_style)] = sq_htmlspecialchars($val, $quote_style); } return $return_array;
// sanitize strings only // } else if (is_string($value)) { if ($quote_style === TRUE) return str_replace(array('\'', '"'), array(''', '"'), $value); else return htmlspecialchars($value, $quote_style); }
// anything else gets returned with no changes // return $value;
} }
|