commit
						aff50d785d
					
				@ -1,4 +1,20 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Patch for when using nginx instead of apache, source: http://php.net/manual/en/function.getallheaders.php#84262
 | 
				
			||||||
 | 
					if (!function_exists('getallheaders')) { 
 | 
				
			||||||
 | 
					    function getallheaders() { 
 | 
				
			||||||
 | 
					        $headers = ''; 
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        foreach ($_SERVER as $name => $value) { 
 | 
				
			||||||
 | 
					            if (substr($name, 0, 5) == 'HTTP_') { 
 | 
				
			||||||
 | 
					                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; 
 | 
				
			||||||
 | 
					            } 
 | 
				
			||||||
 | 
					        } 
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return $headers; 
 | 
				
			||||||
 | 
					    } 
 | 
				
			||||||
 | 
					} 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Log an action. If $itemId is set, it is an item action.
 | 
					// Log an action. If $itemId is set, it is an item action.
 | 
				
			||||||
function logAction($comment, $oldValue, $newValue, $itemId=null) {
 | 
					function logAction($comment, $oldValue, $newValue, $itemId=null) {
 | 
				
			||||||
    $activity = R::dispense('activity');
 | 
					    $activity = R::dispense('activity');
 | 
				
			||||||
@ -27,8 +43,8 @@ function setUserToken($user, $expires) {
 | 
				
			|||||||
function getUser() {
 | 
					function getUser() {
 | 
				
			||||||
    global $jsonResponse;
 | 
					    global $jsonResponse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (isset(apache_request_headers()['Authorization'])) {
 | 
					    if (isset(getallheaders()['Authorization'])) {
 | 
				
			||||||
        $hash = apache_request_headers()['Authorization'];
 | 
					        $hash = getallheaders()['Authorization'];
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            $payload = JWT::decode($hash, getJwtKey());
 | 
					            $payload = JWT::decode($hash, getJwtKey());
 | 
				
			||||||
            $user = R::load('user', $payload->uid);
 | 
					            $user = R::load('user', $payload->uid);
 | 
				
			||||||
@ -46,7 +62,7 @@ function getUser() {
 | 
				
			|||||||
// Get all users.
 | 
					// Get all users.
 | 
				
			||||||
function getUsers($sanitize = true) {
 | 
					function getUsers($sanitize = true) {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        $hash = apache_request_headers()['Authorization'];
 | 
					        $hash = getallheaders()['Authorization'];
 | 
				
			||||||
        $payload = JWT::decode($hash, getJwtKey());
 | 
					        $payload = JWT::decode($hash, getJwtKey());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $users = R::findAll('user');
 | 
					        $users = R::findAll('user');
 | 
				
			||||||
@ -246,8 +262,8 @@ function validateToken($requireAdmin = false) {
 | 
				
			|||||||
function checkDbToken() {
 | 
					function checkDbToken() {
 | 
				
			||||||
    $user = getUser();
 | 
					    $user = getUser();
 | 
				
			||||||
    if (null != $user) {
 | 
					    if (null != $user) {
 | 
				
			||||||
        if (isset(apache_request_headers()['Authorization'])) {
 | 
					        if (isset(getallheaders()['Authorization'])) {
 | 
				
			||||||
            $hash = apache_request_headers()['Authorization'];
 | 
					            $hash = getallheaders()['Authorization'];
 | 
				
			||||||
            return $hash == $user->token;
 | 
					            return $hash == $user->token;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -259,7 +275,7 @@ function clearDbToken() {
 | 
				
			|||||||
    $payload = null;
 | 
					    $payload = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        $payload = JWT::decode(apache_request_headers()['Authorization'], getJwtKey());
 | 
					        $payload = JWT::decode(getallheaders()['Authorization'], getJwtKey());
 | 
				
			||||||
    } catch (Exception $e) {}
 | 
					    } catch (Exception $e) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (null != $payload) {
 | 
					    if (null != $payload) {
 | 
				
			||||||
@ -358,3 +374,5 @@ function updateItemFromAction(&$item, $action) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    R::store($item);
 | 
					    R::store($item);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										22
									
								
								build/Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								build/Dockerfile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					# Dockerfile for Taskboard with nginx and sqlite.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					FROM ubuntu:trusty
 | 
				
			||||||
 | 
					MAINTAINER Alex van den Hoogen <alex.van.den.hoogen@geodan.nl>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RUN apt-get update && \
 | 
				
			||||||
 | 
					    apt-get install -yq --no-install-recommends git wget nginx php5-fpm php5-sqlite sqlite3 ca-certificates pwgen && \
 | 
				
			||||||
 | 
					    apt-get clean && \
 | 
				
			||||||
 | 
					    rm -rf /var/lib/apt/lists/*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RUN echo "cgi.fix_pathinfo = 0;" >> /etc/php5/fpm/php.ini && \
 | 
				
			||||||
 | 
					    echo "daemon off;" >> /etc/nginx/nginx.conf && \
 | 
				
			||||||
 | 
					    mkdir -p /var/www
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RUN git clone https://github.com/kiswa/TaskBoard.git /var/www && \
 | 
				
			||||||
 | 
					    chmod 777 $(find /var/www -type d)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ADD nginx.conf /etc/nginx/sites-available/default
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EXPOSE 80
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CMD service php5-fpm start && nginx
 | 
				
			||||||
							
								
								
									
										0
									
								
								build/build-all
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								build/build-all
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								build/clean
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								build/clean
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								build/minify-app
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								build/minify-app
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										0
									
								
								build/minify-libs
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								build/minify-libs
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
		Reference in New Issue
	
	Block a user