/** * Log an array of category/message pairs */ public static function logm($categoryMessagePairs) { $scribe = Z_CONFIG::$LOG_TO_SCRIBE; $cli = Z_Core::isCommandLine(); // Scribe and CLI need additional info if ($scribe || $cli) { // Parse timestamp into date and milliseconds $ts = microtime(true); if (strpos($ts, '.') === false) { $ts .= '.'; } list($ts, $msec) = explode('.', $ts); $date = new DateTime(date(DATE_RFC822, $ts)); $date->setTimezone(new DateTimeZone(Z_CONFIG::$LOG_TIMEZONE)); $date = $date->format('Y-m-d H:i:s') . '.' . str_pad($msec, 4, '0'); // Get remote IP address if (!$cli) { $ipAddress = IPAddress::getIP(); } // Get server hostname if ($scribe) { $host = gethostname(); if (strpos($host, '.') !== false) { $host = substr($host, 0, strpos($host, '.')); } } } $messages = array(); foreach ($categoryMessagePairs as $pair) { // Scribe if ($scribe) { $messages[] = array('category' => $pair[0], 'message' => "{$date} [{$ipAddress}] [{$host}] " . $pair[1]); } else { if ($cli) { $messages[] = array('category' => $pair[0], 'message' => $date . " " . $pair[1]); } else { $messages[] = array('category' => $pair[0], 'message' => $pair[1]); } } } if (Z_CONFIG::$LOG_TO_SCRIBE) { self::logToScribe($messages); } else { self::logToErrorLog($messages); } }
if (strpos($className, 'Z_') === 0) { $className = str_replace('Z_', '', $className); require_once $className . '.inc.php'; return; } // Elastica if (strpos($className, 'Elastica\\') === 0) { $className = str_replace('\\', '/', $className); require_once 'Elastica/lib/' . $className . '.php'; return; } } spl_autoload_register('zotero_autoload'); // Read in configuration variables require 'config/config.inc.php'; if (Z_Core::isCommandLine()) { $_SERVER['DOCUMENT_ROOT'] = realpath(dirname(dirname(__FILE__))) . '/'; $_SERVER['SERVER_NAME'] = Z_CONFIG::$SYNC_DOMAIN; $_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME']; $_SERVER['REQUEST_URI'] = "/"; } else { // Allow a URI pattern to reproxy the request via Perlbal if (!empty(Z_CONFIG::$REPROXY_MAP)) { foreach (Z_CONFIG::$REPROXY_MAP as $prefix => $servers) { if (preg_match("'{$prefix}'", $_SERVER['REQUEST_URI'])) { foreach ($servers as &$server) { $server .= $_SERVER['REQUEST_URI']; } header("X-REPROXY-URL: " . implode(" ", $servers)); exit; }