function withLocale($locale, $func, $params) { $curLocale = $GLOBALS['locale']; if (!$locale) { $locale = $GLOBALS['defLocale']; } if ($curLocale == $locale) { call_user_func_array($func, $params); } else { switchLocale($locale); call_user_func_array($func, $params); switchLocale($curLocale); } }
<?php // initialize session _and_ locale require_once "sess.php"; $locale =& $_SESSION["locale"]; $locale = detectLocale($_SESSION['locale']); switchLocale($locale);
} // contents $left = $size; fseek($fd, $range[1]); while ($left) { $data = fread($fd, 16384); $left -= strlen($data); print $data; flush(); } fclose($fd); if ($last && !connection_aborted()) { ++$DATA["downloads"]; reconnectDB(); // set default locale for notifications switchLocale($defLocale); // trigger download hooks onTicketDownload($DATA); // check for validity after download if (isTicketExpired($DATA)) { ticketPurge($DATA); } else { // update download count $now = time(); $sql = "UPDATE ticket SET last_stamp = {$now}" . ", downloads = downloads + 1 WHERE id = " . $db->quote($id); $db->exec($sql); } // kill the session ASAP if ($auth === false) { session_destroy(); }