Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
lib/
js/ext/
public/lib/
public/js/ext/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ php_errors.log
update_cache.lock
node_modules
.vscode
vendor/
2 changes: 2 additions & 0 deletions .setup/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ RUN mkdir -pv /local/logs
COPY etc/ /etc/
COPY local/ /local/

COPY --from=composer /usr/bin/composer /usr/bin/composer

VOLUME /var/lib/mysql
VOLUME /home/git
VOLUME /local/codeisok
Expand Down
2 changes: 1 addition & 1 deletion .setup/etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server {
# Make site accessible from http://localhost/
server_name localhost;

root /local/codeisok/;
root /local/codeisok/public;
index index.php;

error_log /local/logs/codeisok.error.log error;
Expand Down
4 changes: 3 additions & 1 deletion .setup/local/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ localhost=$(head -n 1 /etc/hosts | awk '{print $2}')
echo "127.0.0.1 $localhost $localhost.localdomain $hostname $hostname.localdomain" >> /etc/hosts
service sendmail start

composer install -d /local/codeisok

if [ -t 1 ]; then
# Interactive mode, stdout is terminal
service nginx start
bash
else
nginx -g 'daemon off;'
fi
fi
37 changes: 9 additions & 28 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
<?php
define('GITPHP_BASEDIR', dirname(__FILE__) . '/');
define('GITPHP_CONFIGDIR', GITPHP_BASEDIR . '.config/');
define('GITPHP_INCLUDEDIR', GITPHP_BASEDIR . '.include/');
define('GITPHP_GITOBJECTDIR', GITPHP_INCLUDEDIR . 'git/');
define('GITPHP_CONTROLLERDIR', GITPHP_INCLUDEDIR . 'controller/');
define('GITPHP_CACHEDIR', GITPHP_INCLUDEDIR . 'cache/');
define('GITPHP_LOCALEDIR', GITPHP_BASEDIR . '.locale/');
define('GITPHP_TEMPLATESDIR', GITPHP_BASEDIR . '.templates/');
define('GITPHP_CSSDIR', GITPHP_BASEDIR . 'css/');
define('GITPHP_JSDIR', GITPHP_BASEDIR . 'js/');
define('GITPHP_LIBDIR', GITPHP_BASEDIR . 'lib/');
require_once __DIR__ . '/vendor/autoload.php';

define('GITPHP_BASE_NS', 'GitPHP');

spl_autoload_register(
function($class) {
// psr4 autoload
$namespaces = explode('\\', $class);
if (count($namespaces) > 1 && $namespaces[0] == GITPHP_BASE_NS) {
$file_name = array_pop($namespaces) . ".php";
unset($namespaces[0]);

$file_name = GITPHP_INCLUDEDIR . join(DIRECTORY_SEPARATOR, array_map('strtolower', $namespaces)) . DIRECTORY_SEPARATOR . $file_name;
if (file_exists($file_name)) {
require_once $file_name;
}
}
}
);
const GITPHP_BASEDIR = __DIR__ . '/';
const GITPHP_CONFIGDIR = GITPHP_BASEDIR . '.config/';
const GITPHP_LOCALEDIR = GITPHP_BASEDIR . 'resources/locale/';
const GITPHP_TEMPLATESDIR = GITPHP_BASEDIR . 'resources/templates/';
const GITPHP_TEMPLATESCACHEDIR = GITPHP_BASEDIR . 'templates_c/';
const GITPHP_CSSDIR = GITPHP_BASEDIR . 'public/css/';
const GITPHP_JSDIR = GITPHP_BASEDIR . 'public/js/';
const GITPHP_LIBDIR = GITPHP_BASEDIR . 'public/lib/';

class CountClass
{
Expand Down
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "badoo/codeisok",
"description": "Git code browsing and code review tool",
"type": "project",
"license": "GPL-3.0",
"autoload": {
"psr-4": {
"GitPHP\\": "src/"
},
"files": [
"lib/memcache_cache_handler.php",
"lib/php-gettext/streams.php",
"lib/php-gettext/gettext.php"
]
},
"minimum-stability": "dev",
"require": {}
}
18 changes: 18 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Cache key for the cache contents / age map array
*/
define('MEMCACHE_OBJECT_MAP', 'memcache_objectmap');
const MEMCACHE_OBJECT_MAP = 'memcache_objectmap';

/**
* memcache cache handler function
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "Git code browsing and code review tool",
"directories": {
"lib": "lib"
"lib": "public/lib"
},
"scripts": {
"lint": "eslint .",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 1 addition & 3 deletions index.php → public/index.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
define('GITPHP_START_TIME', microtime(true));
define('GITPHP_START_MEM', memory_get_usage());

require_once __DIR__ . '/bootstrap.php';

define('DO_NOT_USE_ERROR_HANDLER', 1);
require_once __DIR__ . '/../bootstrap.php';

$Application = new \GitPHP\Application();

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions .include/Application.php → src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ protected function getOldController($action)
case 'atom':
case 'rss':
$controller = new \GitPHP\Controller\Feed();
if ($action == 'rss') $controller->SetParam('format', GITPHP_FEED_FORMAT_RSS);
else if ($action == 'atom') $controller->SetParam('format', GITPHP_FEED_FORMAT_ATOM);
if ($action == 'rss') $controller->SetParam('format', \GitPHP\Controller\Feed::GITPHP_FEED_FORMAT_RSS);
else if ($action == 'atom') $controller->SetParam('format', \GitPHP\Controller\Feed::GITPHP_FEED_FORMAT_ATOM);
break;

case 'commit':
Expand Down
3 changes: 1 addition & 2 deletions .include/cache/Cache.php → src/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,15 @@ private function CreateSmarty()

$this->tpl = new \Smarty;
$this->tpl->template_dir = GITPHP_TEMPLATESDIR;
$this->tpl->compile_dir = GITPHP_TEMPLATESCACHEDIR;

$this->tpl->caching = 2;

$this->tpl->cache_lifetime = \GitPHP\Config::GetInstance()->GetValue('objectcachelifetime', 86400);

$servers = \GitPHP\Config::GetInstance()->GetValue('memcache', null);
if (isset($servers) && is_array($servers) && (count($servers) > 0)) {
require_once(GITPHP_CACHEDIR . 'Memcache.php');
\GitPHP\Cache\Memcache::GetInstance()->AddServers($servers);
require_once(GITPHP_CACHEDIR . 'memcache_cache_handler.php');
$this->tpl->cache_handler_func = 'memcache_cache_handler';
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions .include/controller/Base.php → src/Controller/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ abstract class Base implements ControllerInterface
public function __construct($project = null)
{
\GitPHP\Log::GetInstance()->timerStart();
require_once(\GitPHP\Util::AddSlash(\GitPHP\Config::GetInstance()->GetValue('smarty_prefix', 'lib/smarty/libs/')) . 'Smarty.class.php');
require_once(\GitPHP\Util::AddSlash(\GitPHP\Config::GetInstance()->GetValue('smarty_prefix', GITPHP_BASEDIR . 'lib/smarty/libs/')) . 'Smarty.class.php');
\GitPHP\Log::GetInstance()->timerStop('require Smarty.class.php');
$this->tpl = new \Smarty;
$this->tpl->plugins_dir[] = GITPHP_INCLUDEDIR . 'smartyplugins';
$this->tpl->plugins_dir[] = GITPHP_BASEDIR . 'lib/smartyplugins';
$this->tpl->template_dir = GITPHP_TEMPLATESDIR;
$this->tpl->compile_dir = GITPHP_TEMPLATESCACHEDIR;

if (\GitPHP\Config::GetInstance()->GetValue('debug', false)) {
$this->tpl->error_reporting = E_ALL;
Expand All @@ -74,9 +75,7 @@ public function __construct($project = null)

$servers = \GitPHP\Config::GetInstance()->GetValue('memcache', null);
if (isset($servers) && is_array($servers) && (count($servers) > 0)) {
require_once(GITPHP_CACHEDIR . 'Memcache.php');
\GitPHP\Cache\Memcache::GetInstance()->AddServers($servers);
require_once(GITPHP_CACHEDIR . 'memcache_cache_handler.php');
$this->tpl->cache_handler_func = 'memcache_cache_handler';
}
}
Expand Down
2 changes: 1 addition & 1 deletion .include/controller/Blame.php → src/Controller/Blame.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected function LoadData()
$this->tpl->assign('tree', $commit->GetTree());

if (\GitPHP\Config::GetInstance()->GetValue('geshi', true)) {
include_once(\GitPHP\Util::AddSlash(\GitPHP\Config::GetInstance()->GetValue('geshiroot', 'lib/geshi/')) . "geshi.php");
include_once(\GitPHP\Util::AddSlash(\GitPHP\Config::GetInstance()->GetValue('geshiroot', GITPHP_BASEDIR . 'lib/geshi/')) . "geshi.php");
if (class_exists('GeSHi')) {
$geshi = new \GeSHi("", 'php');
if ($geshi) {
Expand Down
4 changes: 2 additions & 2 deletions .include/controller/Blob.php → src/Controller/Blob.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected function checkGeshi()
{
$result = false;
if (\GitPHP\Config::GetInstance()->GetValue('geshi', true)) {
include_once(\GitPHP\Util::AddSlash(\GitPHP\Config::GetInstance()->GetValue('geshiroot', 'lib/geshi/')) . "geshi.php");
include_once(\GitPHP\Util::AddSlash(\GitPHP\Config::GetInstance()->GetValue('geshiroot', GITPHP_BASEDIR . 'lib/geshi/')) . "geshi.php");
if (class_exists('GeSHi')) {
$result = true;
}
Expand Down Expand Up @@ -240,7 +240,7 @@ protected function LoadData()

switch ($this->params['hi']) {
case 'sexy':
include_once('lib/syntaxhighlighter/syntaxhighlighter.php');
include_once(GITPHP_BASEDIR . 'lib/syntaxhighlighter/syntaxhighlighter.php');
$SH = new \SyntaxHighlighter($blob->GetName());
$this->tpl->assign('sexy', 1);
$this->tpl->assign('extracss_files', $SH->getCssList());
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function LoadData()
}

if (empty($this->params['sidebyside'])) {
include_once(\GitPHP\Util::AddSlash('lib/syntaxhighlighter') . "syntaxhighlighter.php");
include_once(\GitPHP\Util::AddSlash(GITPHP_BASEDIR . 'lib/syntaxhighlighter') . "syntaxhighlighter.php");
$this->tpl->assign('sexy', 1);
$this->tpl->assign('highlighter_no_ruler', 1);
$this->tpl->assign('highlighter_diff_enabled', 1);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function LoadData()
$this->loadReviewsLinks($co, implode('', $co->GetComment()));

if (empty($this->params['sidebyside'])) {
include_once(\GitPHP\Util::AddSlash('lib/syntaxhighlighter') . "syntaxhighlighter.php");
include_once(\GitPHP\Util::AddSlash(GITPHP_BASEDIR . 'lib/syntaxhighlighter') . "syntaxhighlighter.php");
$this->tpl->assign('sexy', 1);
$this->tpl->assign('highlighter_no_ruler', 1);
$this->tpl->assign('highlighter_diff_enabled', 1);
Expand Down
63 changes: 31 additions & 32 deletions .include/controller/DiffBase.php → src/Controller/DiffBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,6 @@
* @subpackage Controller
*/


/**
* Constants for diff modes
*/
define('GITPHP_DIFF_UNIFIED', '1');
define('GITPHP_DIFF_SIDEBYSIDE', '2');

/**
* Constant of the diff mode cookie in the user's browser
*/
define('GITPHP_DIFF_MODE_COOKIE', 'GitPHPDiffMode');
define('GITPHP_TREEDIFF_ENABLED_COOKIE', 'GitPHPTreeDiffEnabled');

/**
* Diff mode cookie lifetime
*/
define('GITPHP_DIFF_MODE_COOKIE_LIFETIME', 60 * 60 * 24 * 365); // 1 year
define('GITPHP_TREEDIFF_ENABLED_COOKIE_LIFETIME', 60 * 60 * 24 * 365); // 1 year

/**
* DiffBase controller class
*
Expand All @@ -39,6 +20,24 @@
*/
abstract class DiffBase extends Base
{
/**
* Constants for diff modes
*/
const GITPHP_DIFF_UNIFIED = '1';
const GITPHP_DIFF_SIDEBYSIDE = '2';

/**
* Constant of the diff mode cookie in the user's browser
*/
const GITPHP_DIFF_MODE_COOKIE = 'GitPHPDiffMode';
const GITPHP_TREEDIFF_ENABLED_COOKIE = 'GitPHPTreeDiffEnabled';

/**
* Diff mode cookie lifetime
*/
const GITPHP_DIFF_MODE_COOKIE_LIFETIME = 60 * 60 * 24 * 365; // 1 year
const GITPHP_TREEDIFF_ENABLED_COOKIE_LIFETIME = 60 * 60 * 24 * 365; // 1 year

/**
* ReadQuery
*
Expand All @@ -51,7 +50,7 @@ protected function ReadQuery()
if (!isset($this->params['plain']) || $this->params['plain'] != true) {
$diffcookie = $this->DiffMode(isset($_GET['o']) ? $_GET['o'] : '');

if ($diffcookie === GITPHP_DIFF_SIDEBYSIDE) {
if ($diffcookie === self::GITPHP_DIFF_SIDEBYSIDE) {
$this->params['sidebyside'] = true;
} else {
$this->params['unified'] = true;
Expand All @@ -77,18 +76,18 @@ protected function TreeDiffEnabled($overrideMode = null) {
/*
* Check cookie
*/
if (!empty($_COOKIE[GITPHP_TREEDIFF_ENABLED_COOKIE])) {
$enabled = $_COOKIE[GITPHP_TREEDIFF_ENABLED_COOKIE] === '1';
if (!empty($_COOKIE[self::GITPHP_TREEDIFF_ENABLED_COOKIE])) {
$enabled = $_COOKIE[self::GITPHP_TREEDIFF_ENABLED_COOKIE] === '1';
} else {
/*
* Create cookie to prevent browser delay
*/
setcookie(GITPHP_TREEDIFF_ENABLED_COOKIE, $enabled ? '1' : '0', time() + GITPHP_TREEDIFF_ENABLED_COOKIE_LIFETIME);
setcookie(self::GITPHP_TREEDIFF_ENABLED_COOKIE, $enabled ? '1' : '0', time() + self::GITPHP_TREEDIFF_ENABLED_COOKIE_LIFETIME);
}

if ($overrideMode !== null) {
$enabled = $overrideMode === '1';
setcookie(GITPHP_TREEDIFF_ENABLED_COOKIE, $overrideMode, time() + GITPHP_TREEDIFF_ENABLED_COOKIE_LIFETIME);
setcookie(self::GITPHP_TREEDIFF_ENABLED_COOKIE, $overrideMode, time() + self::GITPHP_TREEDIFF_ENABLED_COOKIE_LIFETIME);
}

return $enabled;
Expand All @@ -105,30 +104,30 @@ protected function TreeDiffEnabled($overrideMode = null) {
*/
protected function DiffMode($overrideMode = '')
{
$mode = GITPHP_DIFF_UNIFIED; // default
$mode = self::GITPHP_DIFF_UNIFIED; // default

/*
* Check cookie
*/
if (!empty($_COOKIE[GITPHP_DIFF_MODE_COOKIE])) {
$mode = $_COOKIE[GITPHP_DIFF_MODE_COOKIE];
if (!empty($_COOKIE[self::GITPHP_DIFF_MODE_COOKIE])) {
$mode = $_COOKIE[self::GITPHP_DIFF_MODE_COOKIE];
} else {
/*
* Create cookie to prevent browser delay
*/
setcookie(GITPHP_DIFF_MODE_COOKIE, $mode, time() + GITPHP_DIFF_MODE_COOKIE_LIFETIME);
setcookie(self::GITPHP_DIFF_MODE_COOKIE, $mode, time() + self::GITPHP_DIFF_MODE_COOKIE_LIFETIME);
}

if (!empty($overrideMode)) {
/*
* User is choosing a new mode
*/
if ($overrideMode == 'sidebyside') {
$mode = GITPHP_DIFF_SIDEBYSIDE;
setcookie(GITPHP_DIFF_MODE_COOKIE, GITPHP_DIFF_SIDEBYSIDE, time() + GITPHP_DIFF_MODE_COOKIE_LIFETIME);
$mode = self::GITPHP_DIFF_SIDEBYSIDE;
setcookie(self::GITPHP_DIFF_MODE_COOKIE, self::GITPHP_DIFF_SIDEBYSIDE, time() + self::GITPHP_DIFF_MODE_COOKIE_LIFETIME);
} else {
$mode = GITPHP_DIFF_UNIFIED;
setcookie(GITPHP_DIFF_MODE_COOKIE, GITPHP_DIFF_UNIFIED, time() + GITPHP_DIFF_MODE_COOKIE_LIFETIME);
$mode = self::GITPHP_DIFF_UNIFIED;
setcookie(self::GITPHP_DIFF_MODE_COOKIE, self::GITPHP_DIFF_UNIFIED, time() + self::GITPHP_DIFF_MODE_COOKIE_LIFETIME);
}
}

Expand Down
Loading