/** * $params['isScript'] * $params['groupId'] * $params['time'] */ function logUser($params) { if (!$params['isScript']) { $uid = 0; $uid = user_getid(); $request = HTTPRequest::instance(); $cookie_manager = new CookieManager(); $userLogManager = new UserLogManager(); $userLogManager->logAccess($params['time'], $params['groupId'], $uid, $cookie_manager->getCookie('session_hash'), $request->getFromServer('HTTP_USER_AGENT'), $request->getFromServer('REQUEST_METHOD'), $request->getFromServer('REQUEST_URI'), HTTPRequest::getIPAddress(), $request->getFromServer('HTTP_REFERER')); } }
public function __construct(PFUser $user, Git_HTTP_Command $command) { parent::__construct(); $gitolite_user_info = posix_getpwnam('gitolite'); $this->gitolite_home = $gitolite_user_info['dir']; $this->env['SHELL'] = '/bin/sh'; $this->env['REMOTE_USER'] = $user->getUnixName(); $this->env['GIT_HTTP_BACKEND'] = $command->getCommand(); $this->env['HOME'] = $this->gitolite_home; $this->env['REMOTE_ADDR'] = HTTPRequest::getIPAddress(); $this->appendToEnv('REQUEST_URI'); $this->appendToEnv('REMOTE_PORT'); $this->appendToEnv('SERVER_ADDR'); $this->appendToEnv('SERVER_PORT'); }
/** * call the viewvc.cgi and echo the parsed output */ function viewvc_utils_passcommand() { $parse = viewvc_utils_display_header(); $request_uri = getStringFromServer('REQUEST_URI'); //this is very important ... if (getStringFromServer('PATH_INFO') == "") { $path = "/"; //echo "no path<br>\n"; } else { $path = getStringFromServer('PATH_INFO'); // hack: path must always end with / if (strrpos($path, "/") != strlen($path) - 1) { $path .= "/"; } //echo "path=$path<br>\n"; } // "view=auto" is not well supported in wrapped mode. See SR 341 on Partners. $query_string = str_replace("view=auto", "view=markup", viewvc_utils_escape_string_from_server('QUERY_STRING')); $command = 'HTTP_COOKIE=' . viewvc_utils_escape_string_from_server('HTTP_COOKIE') . ' ' . 'HTTP_USER_AGENT=' . viewvc_utils_escape_string_from_server('HTTP_USER_AGENT') . ' ' . 'REMOTE_ADDR=' . escapeshellarg(HTTPRequest::getIPAddress()) . ' ' . 'QUERY_STRING=' . $query_string . ' ' . 'SERVER_SOFTWARE=' . viewvc_utils_escape_string_from_server('SERVER_SOFTWARE') . ' ' . 'SCRIPT_NAME=' . viewvc_utils_escape_string_from_server('SCRIPT_NAME') . ' ' . 'HTTP_ACCEPT_ENCODING=' . viewvc_utils_escape_string_from_server('HTTP_ACCEPT_ENCODING') . ' ' . 'HTTP_ACCEPT_LANGUAGE=' . viewvc_utils_escape_string_from_server('HTTP_ACCEPT_LANGUAGE') . ' ' . 'PATH_INFO=' . viewvc_utils_wrap_utf8_file_name($path) . ' ' . 'PATH=' . viewvc_utils_escape_string_from_server('PATH') . ' ' . 'HTTP_HOST=' . viewvc_utils_escape_string_from_server('HTTP_HOST') . ' ' . 'DOCUMENT_ROOT=' . viewvc_utils_escape_string_from_server('DOCUMENT_ROOT') . ' ' . 'CODENDI_LOCAL_INC=' . viewvc_utils_escape_string_from_server('CODENDI_LOCAL_INC') . ' ' . '/var/www/cgi-bin/viewvc.cgi 2>&1'; $content = viewvc_utils_wrap_utf8_exec($command); list($headers, $body) = http_split_header_body($content); // Set content type header from the value set by ViewVC // No other headers are generated by ViewVC because generate_etags // is set to 0 in the ViewVC config file $found = false; $line = strtok($content, "\n\t\r\v"); $pathInfo = pathinfo($path); while ($line && !$found) { if (preg_match('/^Content-Type:(.*)$/', $line, $matches)) { //Until Apache will support the office 2007 mime types by default //We should keep test on extension for IE to set the right Mime Type. $officeEtensions = array('docm' => 'application/vnd.ms-word.document.macroEnabled.12', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'); if (array_key_exists('extension', $pathInfo) && array_key_exists($pathInfo['extension'], $officeEtensions)) { $viewvc_content_type = $officeEtensions[$pathInfo['extension']]; } else { $viewvc_content_type = $matches[1]; } $found = true; } $line = strtok("\n\t\r\v"); } $content = substr($content, strpos($content, $line)); // Now look for 'Location:' header line (e.g. generated by 'view=redirect_pathrev' // parameter, used when browsing a directory at a certain revision number) $found = false; $line = strtok($content, "\n\t\r\v"); $viewvc_location = false; while ($line && !$found && strlen($line) > 1) { if (preg_match('/^Location:(.*)$/', $line, $matches)) { $viewvc_location = $matches[1]; $found = true; } $line = strtok("\n\t\r\v"); } if ($found) { $content = substr($content, strpos($content, $line)); } if ($parse) { //parse the html doc that we get from viewvc. //remove the http header part as well as the html header and //html body tags $begin_body = strpos($content, "<body"); if ($begin_body === false) { $begin_body = strpos($content, "<BODY"); $begin_doc = strpos($content, ">", $begin_body) + 1; } else { $begin_doc = strpos($content, ">", $begin_body) + 1; } $length = strpos($content, "</body>\n</html>") - $begin_doc; // Now insert references, and display echo util_make_reference_links(substr($content, $begin_doc, $length), $GLOBALS['group_id']); } else { if ($viewvc_location) { header('Location: ' . $viewvc_location); exit(1); } header('Content-Type:' . $viewvc_content_type . '; charset=utf-8'); echo $body; } }
/** * @return string the new session_hash */ function createSession($user_id, $time) { // generate a token from a PRNG // continue until unique token is generated (SHOULD only be once) $number_generator = new RandomNumberGenerator(); do { $token = $number_generator->getNumber(); $sql = "SELECT 1\n FROM session\n WHERE session_hash = " . $this->da->quoteSmart($token); $dar = $this->retrieve($sql); } while ($dar && $dar->rowCount() == 1); $sql = sprintf("INSERT INTO session (session_hash, ip_addr, time,user_id) VALUES (%s, %s, %d, %d)", $this->da->quoteSmart($token), $this->da->quoteSmart(HTTPRequest::getIPAddress()), $time, $user_id); if ($this->update($sql)) { $this->storeLoginSuccess($user_id, $time); } else { $token = false; } return $token; }