PageRenderTime 54ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/WebCalendar-1.2.5/includes/init.php.orig

#
Unknown | 491 lines | 459 code | 32 blank | 0 comment | 0 complexity | f28cfc04d5ad27b3f379be1309a57e95 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /* Does various initialization tasks and includes all needed files.
  3. *
  4. * This page is included by most WebCalendar pages as the only include file.
  5. * This greatly simplifies the other PHP pages since they don't need to worry
  6. * about what files it includes.
  7. *
  8. * <b>Comments:</b>
  9. * The following scripts do not use this file:
  10. * - login.php
  11. * - week_ssi.php
  12. * - upcoming.php
  13. * - tools/send_reminders.php
  14. *
  15. * How to use:
  16. * 1. call include_once 'includes/init.php'; at the top of your script.
  17. * 2. call any other functions or includes not in this file that you need
  18. * 3. call the print_header function with proper arguments
  19. *
  20. * What gets called:
  21. * - include_once 'includes/translate.php';
  22. * - require_once 'includes/classes/WebCalendar.class';
  23. * - require_once 'includes/classes/Event.class';
  24. * - require_once 'includes/classes/RptEvent.class';
  25. * - include_once 'includes/assert.php';
  26. * - include_once 'includes/config.php';
  27. * - include_once 'includes/dbi4php.php';
  28. * - include_once 'includes/formvars.php';
  29. * - include_once 'includes/functions.php';
  30. * - include_once "includes/$user_inc";
  31. * - include_once 'includes/validate.php';
  32. * - include_once 'includes/site_extras.php';
  33. * - include_once 'includes/access.php';
  34. *
  35. * Also, for month.php, day.php, week.php, week_details.php:
  36. * - {@link send_no_cache_header ()};
  37. *
  38. * @author Craig Knudsen <cknudsen@cknudsen.com>
  39. * @copyright Craig Knudsen, <cknudsen@cknudsen.com>, http://www.k5n.us/cknudsen
  40. * @license http://www.gnu.org/licenses/gpl.html GNU GPL
  41. * @version $Id: init.php,v 1.130.2.15 2011/08/09 03:27:56 cknudsen Exp $
  42. * @package WebCalendar
  43. */
  44. if ( empty ( $_SERVER['PHP_SELF'] ) ||
  45. ( ! empty ( $_SERVER['PHP_SELF'] ) &&
  46. preg_match ( "/\/includes\//", $_SERVER['PHP_SELF'] ) ) )
  47. die ( 'You cannot access this file directly!' );
  48. include_once 'includes/translate.php';
  49. require_once 'includes/classes/WebCalendar.class';
  50. require_once 'includes/classes/Event.class';
  51. require_once 'includes/classes/RptEvent.class';
  52. $WebCalendar = new WebCalendar ( __FILE__ );
  53. include_once 'includes/assert.php';
  54. include_once 'includes/config.php';
  55. include_once 'includes/dbi4php.php';
  56. include_once 'includes/formvars.php';
  57. include_once 'includes/functions.php';
  58. $WebCalendar->initializeFirstPhase ();
  59. include_once 'includes/' . $user_inc;
  60. include_once 'includes/validate.php';
  61. include_once 'includes/site_extras.php';
  62. include_once 'includes/access.php';
  63. include_once 'includes/gradient.php';
  64. $WebCalendar->initializeSecondPhase ();
  65. /* Prints the HTML header and opening HTML body tag.
  66. *
  67. * @param array $includes Array of additional files to include referenced
  68. * from the includes directory
  69. * @param string $HeadX Data to be printed inside the head tag (meta,
  70. * script, etc)
  71. * @param string $BodyX Data to be printed inside the Body tag (onload
  72. * for example)
  73. * @param bool $disbleCustom Do not include custom header? (useful for small
  74. * popup windows, such as color selection)
  75. * @param bool $disableStyle Do not include the standard css?
  76. * @param bool $disableRSS Do not include the RSS link
  77. * @param bool $disableAJAX Do not include the prototype.js link
  78. */
  79. function print_header ( $includes = '', $HeadX = '', $BodyX = '',
  80. $disableCustom = false, $disableStyle = false, $disableRSS = false,
  81. $disableAJAX = false, $disableUTIL = false ) {
  82. global $BGCOLOR, $browser, $charset, $CUSTOM_HEADER, $CUSTOM_SCRIPT,
  83. $DISABLE_POPUPS, $DISPLAY_TASKS, $DISPLAY_WEEKENDS, $FONTS, $friendly,
  84. $LANGUAGE, $login, $MENU_ENABLED, $MENU_THEME, $OTHERMONTHBG,
  85. $POPUP_FG, $REQUEST_URI, $self, $TABLECELLFG, $TEXTCOLOR,
  86. $THBG, $THFG, $TODAYCELLBG, $WEEKENDBG, $SCRIPT, $PUBLIC_ACCESS_FULLNAME,
  87. $PUBLIC_ACCESS, $is_admin;
  88. $lang = $ret = '';
  89. // Remember this view if the file is a view_x.php script.
  90. if ( ! strstr ( $REQUEST_URI, 'view_entry' ) )
  91. remember_this_view ( true );
  92. // Check the CSS version for cache clearing if needed.
  93. if ( ! $disableStyle ) {
  94. if ( isset ( $_COOKIE['webcalendar_csscache'] ) )
  95. $webcalendar_csscache = $_COOKIE['webcalendar_csscache'];
  96. else {
  97. $webcalendar_csscache = 1;
  98. SetCookie ( 'webcalendar_csscache', $webcalendar_csscache );
  99. }
  100. }
  101. // Menu control.
  102. if ( ! empty ( $friendly ) || $disableCustom )
  103. $MENU_ENABLED = 'N';
  104. $appStr = generate_application_name ( true );
  105. $ret .= send_doctype ( $appStr );
  106. $ret .= ( ! $disableAJAX ? '
  107. <script type="text/javascript" src="includes/js/prototype.js"></script>'
  108. : '' );
  109. // Includes needed for the top menu.
  110. if ( $MENU_ENABLED == 'Y' ) {
  111. $MENU_THEME = ( ! empty ( $MENU_THEME ) && $MENU_THEME != 'none'
  112. ? $MENU_THEME : 'default' );
  113. $menu_theme = ( $SCRIPT == 'admin.php' && ! empty ( $GLOBALS['sys_MENU_THEME'] )
  114. ? $GLOBALS['sys_MENU_THEME'] :
  115. $MENU_THEME );
  116. $ret .= '
  117. <script type="text/javascript" src="/JSCookMenu/JSCookMenu.js"></script>
  118. <link rel="stylesheet" type="text/css" href="includes/menu/themes/'
  119. . $menu_theme . '/theme.css" />
  120. <script type="text/javascript" src="includes/menu/themes/' . $menu_theme
  121. . '/theme.js"></script>';
  122. }
  123. $ret .= ( ! $disableUTIL ? '
  124. <script type="text/javascript" src="includes/js/util.js"></script>' : '' );
  125. // Any other includes?
  126. if ( is_array ( $includes ) ) {
  127. foreach ( $includes as $inc ) {
  128. if ( substr ( $inc, 0, 13 ) == 'js/popups.php' && !
  129. empty ( $DISABLE_POPUPS ) && $DISABLE_POPUPS == 'Y' ) {
  130. // Don't load popups.php javascript if DISABLE_POPUPS.
  131. } else
  132. $ret .= '
  133. <script type="text/javascript" src="js_cacher.php?inc='
  134. . $inc . '"></script>';
  135. }
  136. }
  137. // Do we need anything else inside the header tag?
  138. if ( $HeadX )
  139. $ret .= '
  140. ' . $HeadX;
  141. if ( $MENU_ENABLED == 'Y' ) {
  142. include_once 'includes/menu/index.php';
  143. }
  144. // Add RSS feed for unapproved events if approvals are required
  145. if ( $GLOBALS['REQUIRE_APPROVALS'] == 'Y' && $login != '__public__' && $is_admin ) {
  146. // Prh .. fix theme change for auth_http which does not set webcal*login
  147. // variables.
  148. //
  149. // Pass the logged in user id as login=<whatever> on the URL
  150. // Add css_cache=<cookie setting> to change the URL signature
  151. // to force a fetch from the server rather than from the
  152. // browser cache when the style changes.
  153. // Note: we could do all the queries to add the RSS feed for every user
  154. // the current user has permissions to approve for, but I'm thinking
  155. // that's too many db requests to repeat on every page.
  156. $ret .= '<link rel="alternate" type="application/rss+xml" title="' . $appStr
  157. . ' - Unapproved Events - ' . $login . '" href="rss_unapproved.php"/>';
  158. if ( $is_admin && $PUBLIC_ACCESS == 'Y' )
  159. $ret .= '<link rel="alternate" type="application/rss+xml" title="' .
  160. $appStr . ' - Unapproved Events - ' .
  161. translate ( $PUBLIC_ACCESS_FULLNAME ) .
  162. '" href="rss_unapproved.php?user=public"/>';
  163. }
  164. if ( $is_admin ) {
  165. $ret .= '<link rel="alternate" type="application/rss+xml" title="' . $appStr
  166. . ' - ' . translate('Activity Log') . '" href="rss_activity_log.php"/>';
  167. }
  168. // If loading admin.php, we will not use an exrternal file because we need to
  169. // override the global colors and this is impossible if loading external file.
  170. // We will still increment the webcalendar_csscache cookie though.
  171. echo $ret . ( $disableStyle ? '' : '
  172. <link rel="stylesheet" type="text/css" href="css_cacher.php?login='
  173. . ( empty ( $_SESSION['webcal_tmp_login'] )
  174. ? $login : $_SESSION['webcal_tmp_login'] )
  175. . '&amp;css_cache=' . $webcalendar_csscache
  176. . '" />' )
  177. // Add custom script/stylesheet if enabled.
  178. . ( $CUSTOM_SCRIPT == 'Y' && ! $disableCustom
  179. ? load_template ( $login, 'S' ) : '' )
  180. // Include includes/print_styles.css as a media="print" stylesheet. When the
  181. // user clicks on the "Printer Friendly" link, $friendly will be non-empty,
  182. // including this as a normal stylesheet so they can see how it will look
  183. // when printed. This maintains backwards-compatibility for browsers that
  184. // don't support media="print" stylesheets
  185. . ( empty ( $friendly ) ? '' : '
  186. <link rel="stylesheet" type="text/css"'
  187. . ( empty ( $friendly ) ? ' media="print"' : '' )
  188. . ' href="includes/print_styles.css" />' )
  189. // Add RSS feed if publishing is enabled.
  190. . ( ! empty ( $GLOBALS['RSS_ENABLED'] ) && $GLOBALS['RSS_ENABLED'] == 'Y' &&
  191. $login == '__public__' || ( ! empty ( $GLOBALS['USER_RSS_ENABLED'] ) &&
  192. $GLOBALS['USER_RSS_ENABLED'] == 'Y' ) && ! $disableRSS ? '
  193. <link rel="alternate" type="application/rss+xml" title="' . $appStr
  194. . ' [RSS 2.0]" href="rss.php'
  195. /* TODO: single-user mode, etc. */
  196. . ( $login != '__public__' ? '?user=' . $login : '' ) . '" />' : '' ) . '
  197. <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />'
  198. . ( $MENU_ENABLED == 'Y' ? $menuScript : '' ) . '
  199. </head>
  200. <body'
  201. // Determine the page direction (left-to-right or right-to-left).
  202. . ( translate ( 'direction' ) == 'rtl' ? ' dir="rtl"' : '' )
  203. /* Add <body> id. */ . ' id="' . preg_replace ( '/(_|.php)/', '',
  204. substr ( $self, strrpos ( $self, '/' ) + 1 ) ) . '"'
  205. // Add any extra parts to the <body> tag.
  206. . ( empty ( $BodyX ) ? '' : " $BodyX" ) . '>' . "\n"
  207. // If menu is enabled, place menu above custom header if desired.
  208. . ( $MENU_ENABLED == 'Y' && $menuConfig['Above Custom Header']
  209. ? $menuHtml : '' )
  210. // Add custom header if enabled.
  211. . ( $CUSTOM_HEADER == 'Y' && ! $disableCustom
  212. ? load_template ( $login, 'H' ) : '' )
  213. // Add the top menu if enabled.
  214. . ( $MENU_ENABLED == 'Y' && ! $menuConfig['Above Custom Header']
  215. ? $menuHtml : '' );
  216. // TODO convert this to return value.
  217. }
  218. /* Prints the common trailer.
  219. *
  220. * @param bool $include_nav_links Should the standard navigation links be
  221. * included in the trailer?
  222. * @param bool $closeDb Close the database connection when finished?
  223. * @param bool $disableCustom Disable the custom trailer the administrator
  224. * has setup? (This is useful for small popup
  225. * windows and pages being used in an iframe.)
  226. */
  227. function print_trailer ( $include_nav_links = true, $closeDb = true,
  228. $disableCustom = false ) {
  229. global $ALLOW_VIEW_OTHER, $c, $cat_id, $CATEGORIES_ENABLED, $CUSTOM_TRAILER,
  230. $DATE_FORMAT_MD, $DATE_FORMAT_MY, $DEMO_MODE, $DISPLAY_TASKS, $friendly,
  231. $DISPLAY_TASKS_IN_GRID, $fullname, $GROUPS_ENABLED, $has_boss, $is_admin,
  232. $is_nonuser, $is_nonuser_admin, $LAYER_STATUS, $login, $login_return_path,
  233. $MENU_DATE_TOP, $MENU_ENABLED, $NONUSER_ENABLED, $PUBLIC_ACCESS,
  234. $PUBLIC_ACCESS_CAN_ADD, $PUBLIC_ACCESS_FULLNAME, $PUBLIC_ACCESS_OTHERS,
  235. $readonly, $REPORTS_ENABLED, $REQUIRE_APPROVALS, $single_user, $STARTVIEW,
  236. $thisday, $thismonth, $thisyear, $use_http_auth, $user, $views, $WEEK_START;
  237. $ret = '';
  238. if ( $include_nav_links && ! $friendly ) {
  239. if ( $MENU_ENABLED == 'N' || $MENU_DATE_TOP == 'N' )
  240. $ret .= '<div id="dateselector">' . print_menu_dates () . '</div>';
  241. if ( $MENU_ENABLED == 'N' )
  242. include_once 'includes/trailer.php';
  243. }
  244. $ret .= ( empty ( $tret ) ? '' : $tret ) // Data from trailer.
  245. // Add custom trailer if enabled.
  246. . ( $CUSTOM_TRAILER == 'Y' && ! $disableCustom && isset ( $c )
  247. ? load_template ( $login, 'T' ) : '' );
  248. if ( $closeDb ) {
  249. if ( isset ( $c ) )
  250. dbi_close ( $c );
  251. unset ( $c );
  252. }
  253. // Only include version info if user is admin. No need to publicize
  254. // version to would-be hackers.
  255. return $ret .
  256. ( $is_admin ?
  257. "<!-- " . $GLOBALS['PROGRAM_NAME'] . " "
  258. . $GLOBALS['PROGRAM_URL'] . " -->\n" : '' )
  259. // Adds an easy link to validate the pages.
  260. . ( $DEMO_MODE == 'Y' ? '
  261. <p><a href="http://validator.w3.org/check?uri=referer">'
  262. . '<img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" '
  263. . 'class="valid" /></a></p>' : '' )/* Close HTML page properly. */ . '
  264. </body>
  265. </html>
  266. ';
  267. }
  268. function print_menu_dates ( $menu = false ) {
  269. global $cat_id, $CATEGORIES_ENABLED, $custom_view, $DATE_FORMAT_MD,
  270. $DATE_FORMAT_MY, $DISPLAY_WEEKENDS, $id, $login, $SCRIPT, $thisday,
  271. $thismonth, $thisyear, $user, $WEEK_START;
  272. $goStr = translate ( 'Go' );
  273. $ret = $urlArgs = $include_id = '';
  274. // TODO add this to admin and pref.
  275. // Change this value to 'Y' to enable staying in custom views.
  276. $STAY_IN_VIEW = 'N';
  277. $selected = ' selected="selected"';
  278. if ( $STAY_IN_VIEW == 'Y' && ! empty ( $custom_view ) ) {
  279. $include_id = true;
  280. $monthUrl = $SCRIPT;
  281. } else
  282. if ( access_can_view_page ( 'month.php' ) )
  283. $monthUrl = 'month.php';
  284. else {
  285. $monthUrl = $GLOBALS['STARTVIEW'];
  286. if ( preg_match ( '/[?&](\S+)=(\S+)/', $monthUrl, $match ) ) {
  287. $monthUrl = $match[0];
  288. $urlArgs = '
  289. <input type="hidden" name="'
  290. . $match[1] . '" value="' . $match[2] . '" />';
  291. }
  292. }
  293. if ( access_can_access_function ( ACCESS_MONTH ) ) {
  294. $ret .= '
  295. <form action="' . $monthUrl
  296. . '" method="get" name="SelectMonth" id="month'
  297. . ( $menu ? 'menu' : 'form' ) . '"> ' . $urlArgs
  298. . ( ! empty ( $user ) && $user != $login ? '
  299. <input type="hidden" name="user" value="' . $user . '" />' : '' )
  300. . ( ! empty ( $id ) && $include_id ? '
  301. <input type="hidden" name="id" value="' . $id . '" />' : '' )
  302. . ( ! empty ( $cat_id ) && $CATEGORIES_ENABLED == 'Y' &&
  303. ( ! $user || $user == $login ) ? '
  304. <input type="hidden" name="cat_id" value="'
  305. . $cat_id . '" />' : '' ) . '
  306. <label for="monthselect"><a '
  307. . 'href="javascript:document.SelectMonth.submit()">'
  308. . translate ( 'Month' ) . '</a>:&nbsp;</label>
  309. <select name="date" id="monthselect" '
  310. . 'onchange="document.SelectMonth.submit()">';
  311. if ( ! empty ( $thisyear ) && ! empty ( $thismonth ) ) {
  312. $m = $thismonth;
  313. $y = $thisyear;
  314. } else {
  315. $m = date ( 'm' );
  316. $y = date ( 'Y' );
  317. }
  318. $d_time = mktime ( 0, 0, 0, $m, 1, $y );
  319. $thisdate = date ( 'Ymd', $d_time );
  320. // $y--;
  321. $m -= 7;
  322. for ( $i = 0; $i < 25; $i++ ) {
  323. $m++;
  324. if ( $m > 12 ) {
  325. $m = 1;
  326. $y++;
  327. }
  328. if ( $y >= 1970 && $y < 2038 ) {
  329. $d = mktime ( 0, 0, 0, $m, 1, $y );
  330. $dateYmd = date ( 'Ymd', $d );
  331. $ret .= '
  332. <option value="' . $dateYmd . '"'
  333. . ( $dateYmd == $thisdate ? $selected : '' ) . '>'
  334. . date_to_str ( $dateYmd, $DATE_FORMAT_MY, false, true, 0 ) . '</option>';
  335. }
  336. }
  337. }
  338. if ( access_can_access_function ( ACCESS_WEEK ) ) {
  339. $ret .= '
  340. </select>' . ( $menu ? '' : '
  341. <input type="submit" value="' . $goStr . '" />' ) . '
  342. </form>' . ( $menu ? '
  343. </td>
  344. <td class="ThemeMenubackgr ThemeMenu">' : '' );
  345. if ( $STAY_IN_VIEW == 'Y' && ! empty ( $custom_view ) )
  346. $weekUrl = $SCRIPT;
  347. else
  348. if ( access_can_view_page ( 'week.php' ) ) {
  349. $urlArgs = '';
  350. $weekUrl = 'week.php';
  351. } else {
  352. $weekUrl = $GLOBALS['STARTVIEW'];
  353. if ( preg_match ( '/[?&](\S+)=(\S+)/', $weekUrl, $match ) ) {
  354. $weekUrl = $match[0];
  355. $urlArgs = '
  356. <input type="hidden" name="'
  357. . $match[1] . '" value="' . $match[2] . '" />';
  358. }
  359. }
  360. $ret .= '
  361. <form action="' . $weekUrl
  362. . '" method="get" name="SelectWeek" id="week'
  363. . ( $menu ? 'menu' : 'form' ) . '">' . $urlArgs
  364. . ( ! empty ( $user ) && $user != $login ? '
  365. <input type="hidden" name="user" value="' . $user . '" />' : '' )
  366. . ( ! empty ( $id ) && $include_id ? '
  367. <input type="hidden" name="id" value="' . $id . '" />' : '' )
  368. . ( ! empty ( $cat_id ) && $CATEGORIES_ENABLED == 'Y' &&
  369. ( ! $user || $user == $login ) ? '
  370. <input type="hidden" name="cat_id" value="'
  371. . $cat_id . '" />' : '' ) . '
  372. <label for="weekselect"><a '
  373. . 'href="javascript:document.SelectWeek.submit()">'
  374. . translate ( 'Week' ) . '</a>:&nbsp;</label>
  375. <select name="date" id="weekselect" '
  376. . 'onchange="document.SelectWeek.submit()">';
  377. if ( ! empty ( $thisyear ) && ! empty ( $thismonth ) ) {
  378. $m = $thismonth;
  379. $y = $thisyear;
  380. } else {
  381. $m = date ( 'm' );
  382. $y = date ( 'Y' );
  383. }
  384. $d = ( empty ( $thisday ) ? date ( 'd' ) : $thisday );
  385. $d_time = mktime ( 0, 0, 0, $m, $d, $y );
  386. $thisweek = date ( 'W', $d_time );
  387. $wkstart = get_weekday_before ( $y, $m, $d );
  388. $lastDay = ( $DISPLAY_WEEKENDS == 'N' ? 4 : 6 );
  389. for ( $i = -5; $i <= 9; $i++ ) {
  390. $twkstart = $wkstart + ( 604800 * $i );
  391. $twkend = $twkstart + ( 86400 * $lastDay );
  392. $dateSYmd = date ( 'Ymd', $twkstart );
  393. $dateEYmd = date ( 'Ymd', $twkend );
  394. $dateW = date ( 'W', $twkstart + 86400 );
  395. if ( $twkstart > 0 && $twkend < 2146021200 )
  396. $ret .= '
  397. <option value="' . $dateSYmd . '"'
  398. . ( $dateW == $thisweek ? $selected : '' ) . '>'
  399. . ( ! empty ( $GLOBALS['PULLDOWN_WEEKNUMBER'] ) &&
  400. ( $GLOBALS['PULLDOWN_WEEKNUMBER'] == 'Y' )
  401. ? '( ' . $dateW . ' )&nbsp;&nbsp;' : '' ) . sprintf ( "%s - %s",
  402. date_to_str ( $dateSYmd, $DATE_FORMAT_MD, false, true, 0 ),
  403. date_to_str ( $dateEYmd, $DATE_FORMAT_MD, false, true, 0 ) )
  404. . '</option>';
  405. }
  406. }
  407. if ( access_can_access_function ( ACCESS_YEAR ) ) {
  408. $ret .= '
  409. </select>' . ( $menu ? '' : '
  410. <input type="submit" value="' . $goStr . '" />' ) . '
  411. </form>' . ( $menu ? '
  412. </td>
  413. <td class="ThemeMenubackgr ThemeMenu" align="right">' : '' );
  414. if ( $STAY_IN_VIEW == 'Y' && ! empty ( $custom_view ) )
  415. $yearUrl = $SCRIPT;
  416. else
  417. if ( access_can_view_page ( 'year.php' ) ) {
  418. $urlArgs = '';
  419. $yearUrl = 'year.php';
  420. } else {
  421. $yearUrl = $GLOBALS['STARTVIEW'];
  422. if ( preg_match ( '/[?&](\S+)=(\S+)/', $yearUrl, $match ) ) {
  423. $yearUrl = $match[0];
  424. $urlArgs = '
  425. <input type="hidden" name="'
  426. . $match[1] . '" value="' . $match[2] . '" />';
  427. }
  428. }
  429. $ret .= '
  430. <form action="' . $yearUrl . '" method="get" name="SelectYear" id="year'
  431. . ( $menu ? 'menu' : 'form' ) . '">' . $urlArgs
  432. . ( ! empty ( $user ) && $user != $login ? '
  433. <input type="hidden" name="user" value="' . $user . '" />' : '' )
  434. . ( ! empty ( $id ) && $include_id ? '
  435. <input type="hidden" name="id" value="' . $id . '" />' : '' )
  436. . ( ! empty ( $cat_id ) && $CATEGORIES_ENABLED == 'Y' &&
  437. ( ! $user || $user == $login ) ? '
  438. <input type="hidden" name="cat_id" value="'
  439. . $cat_id . '" />' : '' ) . '
  440. <label for="yearselect"><a '
  441. . 'href="javascript:document.SelectYear.submit()">'
  442. . translate ( 'Year' ) . '</a>:&nbsp;</label>
  443. <select name="year" id="yearselect" '
  444. . 'onchange="document.SelectYear.submit()">';
  445. $y = ( empty ( $thisyear ) ? date ( 'Y' ) : $thisyear );
  446. for ( $i = $y - 2; $i < $y + 6; $i++ ) {
  447. if ( $i >= 1970 && $i < 2038 )
  448. $ret .= '
  449. <option value="' . $i . '"'
  450. . ( $i == $y ? $selected : '' ) . ">$i" . '</option>';
  451. }
  452. $ret .= '
  453. </select>' . ( $menu ? '' : '
  454. <input type="submit" value="' . $goStr . '" />' ) . '
  455. </form>';
  456. }
  457. return $ret;
  458. }
  459. ?>