$orderByChangesets = ' ORDER BY c_date DESC'; $num = $end - $start + 1; } $limitChangesets = ' LIMIT ' . (int) $start . ', ' . (int) $num; } else { if ($type == 'revisions') { $bListRevisions = true; $nRevisionsFrom = (int) $start; $nRevisionsTo = (int) $end; } } } } $db = new PDO($dbDsn, $dbUser, $dbPass, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::ATTR_PERSISTENT => false)); $stmt = $db->prepare('SELECT commits.* FROM commits' . ' JOIN keywords_commits USING (c_id)' . ' JOIN keywords USING (k_id)' . ' WHERE k_keyword = :keyword' . $orderByChangesets . $limitChangesets); checkDbResult($stmt, $stmt->execute(array(':keyword' => $keyword))); header('Content-Type: application/xml'); $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->setIndentString(' '); $xml->startDocument('1.0', 'UTF-8', 'yes'); $xml->startElement('results'); $xml->writeAttribute('expand', 'changesets'); $xml->startElement('changesets'); while ($arRow = $stmt->fetch(PDO::FETCH_ASSOC)) { //necessary for branch links $branch = $arRow['c_branch'] . ' in ' . $arRow['c_project_name'] . '/' . $arRow['c_repository_name']; $xml->startElement('changeset'); $xml->writeElement('csid', $arRow['c_hash']); $xml->writeElement('date', date('c', strtotime($arRow['c_date'])));
<?php declare (encoding='utf-8'); /** * Search for commits in the klonfisch database. * * PHP version 5 * * @category Tools * @package Klonfisch * @author Christian Weiske <*****@*****.**> * @license AGPLv3 or later * @link https://gitorious.nr/klonfisch */ header('HTTP/1.0 500 Internal Server Error'); require __DIR__ . '/www-header.php'; $db = new PDO($dbDsn, $dbUser, $dbPass, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::ATTR_PERSISTENT => false)); $arResults = null; if (isset($_REQUEST['q'])) { $query = $_REQUEST['q']; $stmt = $db->prepare('SELECT * FROM commits' . ' JOIN keywords_commits USING (c_id)' . ' JOIN keywords USING (k_id)' . ' WHERE' . ' c_hash LIKE :c_hash' . ' OR c_author LIKE :c_author' . ' OR c_message LIKE :c_message' . ' OR k_keyword = :k_keyword' . ' GROUP BY c_id' . ' ORDER BY c_date DESC' . ' LIMIT 0, 20'); checkDbResult($stmt, $stmt->execute(array(':c_hash' => $query . '%', ':c_author' => '%' . $query . '%', ':c_message' => '%' . $query . '%', ':k_keyword' => $query))); $arResults = array(); while ($arRow = $stmt->fetch(PDO::FETCH_ASSOC)) { $arResults[] = $arRow; } } header('HTTP/1.0 200 OK'); require __DIR__ . '/../data/templates/search.php';
<?php /** * Redirects a Fisheye commit link to Gitorious */ require_once __DIR__ . '/../www-header.php'; $db = new PDO($dbDsn, $dbUser, $dbPass, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::ATTR_PERSISTENT => true)); if (!isset($_GET['cs']) || $_GET['cs'] == '') { header('HTTP/1.0 400 Bad Request'); echo "Commit hash parameter \"cs\" is missing\n"; exit(1); } //Commit hash link // /changelog/test?cs=985f39f6d857ac2e1e4e1cab3d235767 $hash = $_GET['cs']; if (strlen($hash) !== 32) { header('HTTP/1.0 400 Bad Request'); echo "Length of commit hash is not 32\n"; exit(1); } $stmt = $db->prepare('SELECT c_url FROM commits' . ' WHERE c_hash = :hash'); checkDbResult($stmt, $stmt->execute(array(':hash' => $hash))); $arRow = $stmt->fetch(PDO::FETCH_ASSOC); if ($arRow === false) { header('HTTP/1.0 404 Not Found'); echo "Commit not found\n"; exit(1); } header('Location: ' . $arRow['c_url']); exit(0);