init.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <?php
  2. /**
  3. * init.php -- initialisation file
  4. *
  5. * File should be loaded in every file in src/ or plugins that occupate an entire frame
  6. *
  7. * @copyright &copy; 2006 The SquirrelMail Project Team
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @version $Id$
  10. * @package squirrelmail
  11. */
  12. /**
  13. * This is a development version so in order to track programmer mistakes we
  14. * set the error reporting to E_ALL
  15. */
  16. error_reporting(E_ALL);
  17. /**
  18. * Make sure we have a page name
  19. *
  20. */
  21. if ( !defined('PAGE_NAME') ) define('PAGE_NAME', NULL);
  22. /**
  23. * If register_globals are on, unregister globals.
  24. * Second test covers boolean set as string (php_value register_globals off).
  25. */
  26. if ((bool) ini_get('register_globals') &&
  27. strtolower(ini_get('register_globals'))!='off') {
  28. /**
  29. * Remove all globals that are not reserved by PHP
  30. * 'value' and 'key' are used by foreach. Don't unset them inside foreach.
  31. */
  32. foreach ($GLOBALS as $key => $value) {
  33. switch($key) {
  34. case 'HTTP_POST_VARS':
  35. case '_POST':
  36. case 'HTTP_GET_VARS':
  37. case '_GET':
  38. case 'HTTP_COOKIE_VARS':
  39. case '_COOKIE':
  40. case 'HTTP_SERVER_VARS':
  41. case '_SERVER':
  42. case 'HTTP_ENV_VARS':
  43. case '_ENV':
  44. case 'HTTP_POST_FILES':
  45. case '_FILES':
  46. case '_REQUEST':
  47. case 'HTTP_SESSION_VARS':
  48. case '_SESSION':
  49. case 'GLOBALS':
  50. case 'key':
  51. case 'value':
  52. break;
  53. default:
  54. unset($GLOBALS[$key]);
  55. }
  56. }
  57. // Unset variables used in foreach
  58. unset($GLOBALS['key']);
  59. unset($GLOBALS['value']);
  60. }
  61. /**
  62. * Used as a dummy value, e.g., for passing as an empty
  63. * hook argument (where the value is passed by reference,
  64. * and therefore NULL itself is not acceptable).
  65. */
  66. global $null;
  67. $null = NULL;
  68. /**
  69. * [#1518885] session.use_cookies = off breaks SquirrelMail
  70. *
  71. * When session cookies are not used, all http redirects, meta refreshes,
  72. * src/download.php and javascript URLs are broken. Setting must be set
  73. * before session is started.
  74. */
  75. if (!(bool)ini_get('session.use_cookies') ||
  76. ini_get('session.use_cookies') == 'off') {
  77. ini_set('session.use_cookies','1');
  78. }
  79. /**
  80. * calculate SM_PATH and calculate the base_uri
  81. * assumptions made: init.php is only called from plugins or from the src dir.
  82. * files in the plugin directory may not be part of a subdirectory called "src"
  83. *
  84. */
  85. if (isset($_SERVER['SCRIPT_NAME'])) {
  86. $a = explode('/', $_SERVER['SCRIPT_NAME']);
  87. } elseif (isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) {
  88. $a = explode('/', $HTTP_SERVER_VARS['SCRIPT_NAME']);
  89. } else {
  90. $error = 'Unable to detect script environment. Please test your PHP '
  91. . 'settings and send your PHP core configuration, $_SERVER and '
  92. . '$HTTP_SERVER_VARS contents to the SquirrelMail developers.';
  93. die($error);
  94. }
  95. $sSM_PATH = '';
  96. for($i = count($a) -2; $i > -1; --$i) {
  97. $sSM_PATH .= '../';
  98. if ($a[$i] === 'src' || $a[$i] === 'plugins') {
  99. break;
  100. }
  101. }
  102. $base_uri = implode('/', array_slice($a, 0, $i)). '/';
  103. define('SM_PATH',$sSM_PATH);
  104. define('SM_BASE_URI', $base_uri);
  105. /**
  106. * global var $bInit is used to check if initialisation took place.
  107. * At this moment it's a workarounf for the include of addrbook_search_html
  108. * inside compose.php. If we found a better way then remove this. Do only use
  109. * this var if you know for sure a page can be called stand alone and be included
  110. * in another file.
  111. */
  112. $bInit = true;
  113. /**
  114. * This theme as a failsafe if no themes were found, or if we error
  115. * out before anything could be initialised.
  116. */
  117. $color = array();
  118. $color[0] = '#DCDCDC'; /* light gray TitleBar */
  119. $color[1] = '#800000'; /* red */
  120. $color[2] = '#CC0000'; /* light red Warning/Error Messages */
  121. $color[3] = '#A0B8C8'; /* green-blue Left Bar Background */
  122. $color[4] = '#FFFFFF'; /* white Normal Background */
  123. $color[5] = '#FFFFCC'; /* light yellow Table Headers */
  124. $color[6] = '#000000'; /* black Text on left bar */
  125. $color[7] = '#0000CC'; /* blue Links */
  126. $color[8] = '#000000'; /* black Normal text */
  127. $color[9] = '#ABABAB'; /* mid-gray Darker version of #0 */
  128. $color[10] = '#666666'; /* dark gray Darker version of #9 */
  129. $color[11] = '#770000'; /* dark red Special Folders color */
  130. $color[12] = '#EDEDED';
  131. $color[13] = '#800000'; /* (dark red) Color for quoted text -- > 1 quote */
  132. $color[14] = '#ff0000'; /* (red) Color for quoted text -- >> 2 or more */
  133. $color[15] = '#002266'; /* (dark blue) Unselectable folders */
  134. $color[16] = '#ff9933'; /* (orange) Highlight color */
  135. require(SM_PATH . 'functions/global.php');
  136. require(SM_PATH . 'functions/strings.php');
  137. require(SM_PATH . 'functions/arrays.php');
  138. /* load default configuration */
  139. require(SM_PATH . 'config/config_default.php');
  140. /* reset arrays in default configuration */
  141. $ldap_server = array();
  142. $plugins = array();
  143. $fontsets = array();
  144. $aTemplateSet = array();
  145. $aTemplateSet[0]['ID'] = 'default';
  146. $aTemplateSet[0]['NAME'] = 'Default';
  147. /* load site configuration */
  148. require(SM_PATH . 'config/config.php');
  149. /* load local configuration overrides */
  150. if (file_exists(SM_PATH . 'config/config_local.php')) {
  151. require(SM_PATH . 'config/config_local.php');
  152. }
  153. require(SM_PATH . 'functions/plugin.php');
  154. require(SM_PATH . 'include/constants.php');
  155. require(SM_PATH . 'include/languages.php');
  156. require(SM_PATH . 'class/template/Template.class.php');
  157. require(SM_PATH . 'class/error.class.php');
  158. /**
  159. * If magic_quotes_runtime is on, SquirrelMail breaks in new and creative ways.
  160. * Force magic_quotes_runtime off.
  161. * tassium@squirrelmail.org - I put it here in the hopes that all SM code includes this.
  162. * If there's a better place, please let me know.
  163. */
  164. ini_set('magic_quotes_runtime','0');
  165. /* if running with magic_quotes_gpc then strip the slashes
  166. from POST and GET global arrays */
  167. if (get_magic_quotes_gpc()) {
  168. sqstripslashes($_GET);
  169. sqstripslashes($_POST);
  170. }
  171. /* strip any tags added to the url from PHP_SELF.
  172. This fixes hand crafted url XXS expoits for any
  173. page that uses PHP_SELF as the FORM action */
  174. $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
  175. $PHP_SELF = php_self();
  176. /**
  177. * Initialize the session
  178. */
  179. /** set the name of the session cookie */
  180. if (!isset($session_name) || !$session_name) {
  181. $session_name = 'SQMSESSID';
  182. }
  183. /**
  184. * When session.auto_start is On we want to destroy/close the session
  185. */
  186. $sSessionAutostartName = session_name();
  187. $sCookiePath = null;
  188. if (isset($sSessionAutostartName) && $sSessionAutostartName !== $session_name) {
  189. $sCookiePath = ini_get('session.cookie_path');
  190. $sCookieDomain = ini_get('session.cookie_domain');
  191. // reset the cookie
  192. setcookie($sSessionAutostartName,'',time() - 604800,$sCookiePath,$sCookieDomain);
  193. @session_destroy();
  194. session_write_close();
  195. }
  196. /**
  197. * includes from classes stored in the session
  198. */
  199. require(SM_PATH . 'class/mime.class.php');
  200. ini_set('session.name' , $session_name);
  201. session_set_cookie_params (0, $base_uri);
  202. sqsession_is_active();
  203. /**
  204. * When on login page, have to reset the user session, making
  205. * sure to save session restore data first
  206. */
  207. if (PAGE_NAME == 'login') {
  208. if (!sqGetGlobalVar('session_expired_post', $sep, SQ_SESSION))
  209. $sep = '';
  210. if (!sqGetGlobalVar('session_expired_location', $sel, SQ_SESSION))
  211. $sel = '';
  212. sqsession_destroy();
  213. session_write_close();
  214. /**
  215. * in some rare instances, the session seems to stick
  216. * around even after destroying it (!!), so if it does,
  217. * we'll manually flatten the $_SESSION data
  218. */
  219. if (!empty($_SESSION))
  220. $_SESSION = array();
  221. sqsession_is_active();
  222. session_regenerate_id();
  223. // put session restore data back into session if necessary
  224. if (!empty($sel)) {
  225. sqsession_register($sel, 'session_expired_location');
  226. if (!empty($sep))
  227. sqsession_register($sep, 'session_expired_post');
  228. }
  229. }
  230. /**
  231. * SquirrelMail internal version number -- DO NOT CHANGE
  232. * $sm_internal_version = array (release, major, minor)
  233. */
  234. $SQM_INTERNAL_VERSION = explode('.', SM_VERSION, 3);
  235. $SQM_INTERNAL_VERSION[2] = intval($SQM_INTERNAL_VERSION[2]);
  236. /* load prefs system; even when user not logged in, should be OK to do this here */
  237. require(SM_PATH . 'functions/prefs.php');
  238. $prefs_backend = do_hook('prefs_backend', $null);
  239. if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) {
  240. require(SM_PATH . $prefs_backend);
  241. } elseif (isset($prefs_dsn) && !empty($prefs_dsn)) {
  242. require(SM_PATH . 'functions/db_prefs.php');
  243. } else {
  244. require(SM_PATH . 'functions/file_prefs.php');
  245. }
  246. /* if plugins are disabled only for one user and
  247. * the current user is NOT that user, turn them
  248. * back on
  249. */
  250. sqgetGlobalVar('username',$username,SQ_SESSION);
  251. if ($disable_plugins && !empty($disable_plugins_user)
  252. && $username != $disable_plugins_user) {
  253. $disable_plugins = false;
  254. }
  255. /* remove all plugins if they are disabled */
  256. if ($disable_plugins) {
  257. $plugins = array();
  258. }
  259. /**
  260. * Include Compatibility plugin if available.
  261. */
  262. if (!$disable_plugins && file_exists(SM_PATH . 'plugins/compatibility/functions.php'))
  263. include_once(SM_PATH . 'plugins/compatibility/functions.php');
  264. /**
  265. * MAIN PLUGIN LOADING CODE HERE
  266. * On init, we no longer need to load all plugin setup files.
  267. * Now, we load the statically generated hook registrations here
  268. * and let the hook calls include only the plugins needed.
  269. */
  270. $squirrelmail_plugin_hooks = array();
  271. if (!$disable_plugins && file_exists(SM_PATH . 'config/plugin_hooks.php')) {
  272. require(SM_PATH . 'config/plugin_hooks.php');
  273. }
  274. /**
  275. * allow plugins to override main configuration; hook is placed
  276. * here to allow plugins to use session information to do their work
  277. */
  278. do_hook('config_override', $null);
  279. /**
  280. * DISABLED.
  281. * Remove globalized session data in rg=on setups
  282. *
  283. * Code can be utilized when session is started, but data is not loaded.
  284. * We have already loaded configuration and other important vars. Can't
  285. * clean session globals here.
  286. if ((bool) @ini_get('register_globals') &&
  287. strtolower(ini_get('register_globals'))!='off') {
  288. foreach ($_SESSION as $key => $value) {
  289. unset($GLOBALS[$key]);
  290. }
  291. }
  292. */
  293. sqsession_register(SM_BASE_URI,'base_uri');
  294. /**
  295. * Retrieve the language cookie
  296. */
  297. if (! sqgetGlobalVar('squirrelmail_language',$squirrelmail_language,SQ_COOKIE)) {
  298. $squirrelmail_language = '';
  299. }
  300. /**
  301. * Do something special for some pages. This is based on the PAGE_NAME constand
  302. * set at the top of every page.
  303. */
  304. switch (PAGE_NAME) {
  305. case 'style':
  306. // need to get the right template set up
  307. //
  308. sqGetGlobalVar('templateid', $templateid, SQ_GET);
  309. // sanitize just in case...
  310. //
  311. $templateid = preg_replace('/(\.\.\/){1,}/', '', $templateid);
  312. // make sure given template actually is available
  313. //
  314. $found_templateset = false;
  315. for ($i = 0; $i < count($aTemplateSet); ++$i) {
  316. if ($aTemplateSet[$i]['ID'] == $templateid) {
  317. $found_templateset = true;
  318. break;
  319. }
  320. }
  321. // FIXME: do we need/want to check here for actual (physical) presence of template sets?
  322. // selected template not available, fall back to default template
  323. //
  324. if (!$found_templateset) {
  325. $sTemplateID = Template::get_default_template_set();
  326. } else {
  327. $sTemplateID = $templateid;
  328. }
  329. session_write_close();
  330. break;
  331. case 'redirect':
  332. require(SM_PATH . 'functions/auth.php');
  333. //nobreak;
  334. case 'login':
  335. require(SM_PATH . 'functions/display_messages.php' );
  336. require(SM_PATH . 'functions/page_header.php');
  337. require(SM_PATH . 'functions/html.php');
  338. // reset template file cache
  339. //
  340. $sTemplateID = Template::get_default_template_set();
  341. Template::cache_template_file_hierarchy(TRUE);
  342. /**
  343. * Make sure icon variables are setup for the login page.
  344. */
  345. $icon_theme = $icon_themes[$icon_theme_def]['PATH'];
  346. /*
  347. * NOTE: The $icon_theme_path var should contain the path to the icon
  348. * theme to use. If the admin has disabled icons, or the user has
  349. * set the icon theme to "None," no icons will be used.
  350. */
  351. $icon_theme_path = (!$use_icons || $icon_theme=='none') ? NULL : ($icon_theme == 'template' ? SM_PATH . Template::calculate_template_images_directory($sTemplateID) : $icon_theme);
  352. /**
  353. * cleanup old cookies with a cookie path the same as the standard php.ini
  354. * cookie path. All previous SquirrelMail version used the standard php.ini
  355. * cookie path for storing the session name. That behaviour changed.
  356. */
  357. if ($sCookiePath !== SM_BASE_URI) {
  358. /**
  359. * do not delete the standard sessions with session.name is i.e. PHPSESSID
  360. * because they probably belong to other php apps
  361. */
  362. if (ini_get('session.name') !== $sSessionAutostartName) {
  363. // This does not work. Sometimes the cookie with SQSESSID=deleted and path /
  364. // is picked up in webmail.php => login will fail
  365. //sqsetcookie(ini_get('session.name'),'',0,$sCookiePath);
  366. }
  367. }
  368. break;
  369. default:
  370. require(SM_PATH . 'functions/display_messages.php' );
  371. require(SM_PATH . 'functions/page_header.php');
  372. require(SM_PATH . 'functions/html.php');
  373. /**
  374. * Check if we are logged in
  375. */
  376. require(SM_PATH . 'functions/auth.php');
  377. if ( !sqsession_is_registered('user_is_logged_in') ) {
  378. // use $message to indicate what logout text the user
  379. // will see... if 0, typical "You must be logged in"
  380. // if 1, information that the user session was saved
  381. // and will be resumed after (re)login
  382. //
  383. $message = 0;
  384. // First we store some information in the new session to prevent
  385. // information-loss.
  386. //
  387. $session_expired_post = $_POST;
  388. $session_expired_location = PAGE_NAME;
  389. if (!sqsession_is_registered('session_expired_post')) {
  390. sqsession_register($session_expired_post,'session_expired_post');
  391. }
  392. if (!sqsession_is_registered('session_expired_location')) {
  393. sqsession_register($session_expired_location,'session_expired_location');
  394. if ($session_expired_location == 'compose')
  395. $message = 1;
  396. }
  397. // signout page will deal with users who aren't logged
  398. // in on its own; don't show error here
  399. //
  400. if ( PAGE_NAME == 'signout' ) {
  401. return;
  402. }
  403. /**
  404. * Initialize the template object (logout_error uses it)
  405. */
  406. /*
  407. * $sTemplateID is not initialized when a user is not logged in, so we
  408. * will use the config file defaults here. If the neccesary variables
  409. * are net set, force a default value.
  410. */
  411. $sTemplateID = Template::get_default_template_set();
  412. $oTemplate = Template::construct_template($sTemplateID);
  413. set_up_language($squirrelmail_language, true);
  414. if (!$message)
  415. logout_error( _("You must be logged in to access this page.") );
  416. else
  417. logout_error( _("Your session has expired, but will be resumed after logging in again.") );
  418. exit;
  419. }
  420. //FIXME: remove next line if the placement of the copy of this line above does not prove to be problematic
  421. sqgetGlobalVar('username',$username,SQ_SESSION);
  422. sqgetGlobalVar('authz',$authz,SQ_SESSION);
  423. /**
  424. * Setting the prefs backend
  425. */
  426. sqgetGlobalVar('prefs_cache', $prefs_cache, SQ_SESSION );
  427. sqgetGlobalVar('prefs_are_cached', $prefs_are_cached, SQ_SESSION );
  428. if ( !sqsession_is_registered('prefs_are_cached') ||
  429. !isset( $prefs_cache) ||
  430. !is_array( $prefs_cache)) {
  431. $prefs_are_cached = false;
  432. $prefs_cache = false; //array();
  433. }
  434. /**
  435. * initializing user settings
  436. */
  437. require(SM_PATH . 'include/load_prefs.php');
  438. // i do not understand the frames language cookie story
  439. /**
  440. * We'll need this to later have a noframes version
  441. *
  442. * Check if the user has a language preference, but no cookie.
  443. * Send him a cookie with his language preference, if there is
  444. * such discrepancy.
  445. */
  446. $my_language = getPref($data_dir, $username, 'language');
  447. if ($my_language != $squirrelmail_language) {
  448. sqsetcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
  449. }
  450. // /dont understand
  451. /**
  452. * Set up the language.
  453. */
  454. $err=set_up_language(getPref($data_dir, $username, 'language'));
  455. // Japanese translation used without mbstring support
  456. if ($err==2) {
  457. $sError =
  458. "<p>You need to have PHP installed with the multibyte string function \n".
  459. "enabled (using configure option --enable-mbstring).</p>\n".
  460. "<p>System assumed that you accidently switched to Japanese translation \n".
  461. "and reverted your language preference to English.</p>\n".
  462. "<p>Please refresh this page in order to use webmail.</p>\n";
  463. error_box($sError);
  464. }
  465. $timeZone = getPref($data_dir, $username, 'timezone');
  466. /* Check to see if we are allowed to set the TZ environment variable.
  467. * We are able to do this if ...
  468. * safe_mode is disabled OR
  469. * safe_mode_allowed_env_vars is empty (you are allowed to set any) OR
  470. * safe_mode_allowed_env_vars contains TZ
  471. */
  472. $tzChangeAllowed = (!ini_get('safe_mode')) ||
  473. !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
  474. preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars'));
  475. if ( $timeZone != SMPREF_NONE && ($timeZone != "")
  476. && $tzChangeAllowed ) {
  477. // get time zone key, if strict or custom strict timezones are used
  478. if (isset($time_zone_type) &&
  479. ($time_zone_type == 1 || $time_zone_type == 3)) {
  480. /* load time zone functions */
  481. require(SM_PATH . 'include/timezones.php');
  482. $realTimeZone = sq_get_tz_key($timeZone);
  483. } else {
  484. $realTimeZone = $timeZone;
  485. }
  486. // set time zone
  487. if ($realTimeZone) {
  488. putenv("TZ=".$realTimeZone);
  489. }
  490. }
  491. /**
  492. * php 5.1.0 added time zone functions. Set time zone with them in order
  493. * to prevent E_STRICT notices and allow time zone modifications in safe_mode.
  494. */
  495. if (function_exists('date_default_timezone_set')) {
  496. if ($timeZone != SMPREF_NONE && $timeZone != "") {
  497. date_default_timezone_set($timeZone);
  498. } else {
  499. // interface runs on server's time zone. Remove php E_STRICT complains
  500. $default_timezone = @date_default_timezone_get();
  501. date_default_timezone_set($default_timezone);
  502. }
  503. }
  504. break;
  505. }
  506. /*
  507. * $sTemplateID is not initialized when a user is not logged in, so we
  508. * will use the config file defaults here. If the neccesary variables
  509. * are not set, force a default value.
  510. *
  511. * If the user is logged in, $sTemplateID will be set in load_prefs.php,
  512. * so we shouldn't change it here.
  513. */
  514. if (!isset($sTemplateID)) {
  515. $sTemplateID = Template::get_default_template_set();
  516. $icon_theme_path = !$use_icons ? NULL : Template::calculate_template_images_directory($sTemplateID);
  517. }
  518. // template object may have already been constructed in load_prefs.php
  519. //
  520. if (empty($oTemplate)) {
  521. $oTemplate = Template::construct_template($sTemplateID);
  522. }
  523. // We want some variables to always be available to the template
  524. $oTemplate->assign('javascript_on',
  525. (sqGetGlobalVar('user_is_logged_in', $user_is_logged_in, SQ_SESSION)
  526. ? checkForJavascript() : 0));
  527. $oTemplate->assign('base_uri', sqm_baseuri());
  528. $always_include = array('sTemplateID', 'icon_theme_path');
  529. foreach ($always_include as $var) {
  530. $oTemplate->assign($var, (isset($$var) ? $$var : NULL));
  531. }
  532. /**
  533. * Initialize our custom error handler object
  534. */
  535. $oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl');
  536. /**
  537. * Activate custom error handling
  538. */
  539. if (version_compare(PHP_VERSION, "4.3.0", ">=")) {
  540. $oldErrorHandler = set_error_handler(array($oErrorHandler, 'SquirrelMailErrorhandler'));
  541. } else {
  542. $oldErrorHandler = set_error_handler('SquirrelMailErrorhandler');
  543. }
  544. /**
  545. * Javascript support detection function
  546. * @param boolean $reset recheck javascript support if set to true.
  547. * @return integer SMPREF_JS_ON or SMPREF_JS_OFF ({@see include/constants.php})
  548. * @since 1.5.1
  549. */
  550. function checkForJavascript($reset = FALSE) {
  551. global $data_dir, $username, $javascript_on, $javascript_setting;
  552. if ( !$reset && sqGetGlobalVar('javascript_on', $javascript_on, SQ_SESSION) )
  553. return $javascript_on;
  554. $user_is_logged_in = FALSE;
  555. if ( $reset || !isset($javascript_setting) )
  556. $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
  557. if ( !sqGetGlobalVar('new_js_autodetect_results', $js_autodetect_results) &&
  558. !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results) )
  559. $js_autodetect_results = SMPREF_JS_OFF;
  560. if ( $javascript_setting == SMPREF_JS_AUTODETECT )
  561. $javascript_on = $js_autodetect_results;
  562. else
  563. $javascript_on = $javascript_setting;
  564. sqsession_register($javascript_on, 'javascript_on');
  565. return $javascript_on;
  566. }
  567. function sqm_baseuri() {
  568. global $base_uri;
  569. return $base_uri;
  570. }