Exemple #1
0
 /**
  * Binds variables to the template and prints it
  * The following values are always assigned: userId, trans
  * @param $arguments an array with arguments in $templateVar => $content
  * @param $template the name of the template
  * @param $safeParams template parameters which should not be escaped
  * @param $fullPage if true, it will render a full page, otherwise only a part
  *                  defaults to true
  */
 protected function render($template, $arguments = array(), $safeParams = array(), $fullPage = true)
 {
     if ($fullPage) {
         $template = new \OCP\Template('news', $template, 'user');
     } else {
         $template = new \OCP\Template('news', $template);
     }
     foreach ($arguments as $key => $value) {
         if (array_key_exists($key, $safeParams)) {
             $template->assign($key, $value, false);
         } else {
             $template->assign($key, $value);
         }
     }
     $template->assign('userId', $this->userId);
     $template->assign('trans', $this->trans);
     $template->printPage();
 }
Exemple #2
0
 /**
  * @brief serve opds feed for given directory
  *
  * @param string $dir full path to directory
  * @param int $id requested id
  */
 public static function serveFeed($dir, $id)
 {
     if (isset($_SERVER['HTTP_ACCEPT']) && stristr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
         header('Content-Type: application/atom+xml');
     } else {
         header('Content-Type: text/xml; charset=UTF-8');
     }
     $sortAttribute = 'name';
     $sortDirection = false;
     $defaults = new \OC_Defaults();
     $tmpl = new \OCP\Template('files_opds', 'feed');
     $tmpl->assign('files', Files::formatFileInfos(Files::getFiles($dir, $sortAttribute, $sortDirection)));
     $tmpl->assign('bookshelf', Files::formatFileInfos(Bookshelf::get()));
     $tmpl->assign('bookshelf-count', Bookshelf::count());
     $tmpl->assign('feed_id', self::getFeedId());
     $tmpl->assign('id', $id);
     $tmpl->assign('dir', $dir);
     $tmpl->assign('user', \OCP\User::getDisplayName());
     $tmpl->assign('feed_title', Config::get('feed_title', \OCP\User::getDisplayName() . "'s Library"));
     $tmpl->assign('feed_subtitle', Config::getApp('feed_subtitle', $defaults->getName() . " OPDS catalog"));
     $tmpl->assign('feed_updated', time());
     $tmpl->printPage();
 }
\OCP\App::checkAppEnabled('collaboration');
OCP\App::setActiveNavigationEntry('collaboration');
OCP\Util::addScript('collaboration', 'update_task');
OCP\Util::addScript('collaboration/3rdparty', 'jquery-ui-sliderAccess');
OCP\Util::addScript('collaboration/3rdparty', 'jquery-ui-timepicker-addon');
OCP\Util::addScript('collaboration/3rdparty', 'jquery-te');
OCP\Util::addStyle('collaboration/3rdparty', 'jquery-te');
OCP\Util::addStyle('collaboration/3rdparty', 'jquery-ui-timepicker-addon');
OCP\Util::addStyle('collaboration', 'content_header');
OCP\Util::addStyle('collaboration', 'tabs');
OCP\Util::addStyle('collaboration', 'update_task');
$l = OC_L10N::get('collaboration');
$tpl = new OCP\Template('collaboration', 'update_task', 'user');
$bol = OC_Collaboration_Project::isAdmin();
if ($bol == true) {
    if (isset($_POST['tid'])) {
        $tpl->assign('title', $l->t('Update Task'));
        $tpl->assign('submit_btn_name', $l->t('Update'));
        $tpl->assign('tid', $_POST['tid']);
        $tpl->assign('task_details', OC_Collaboration_Task::readTask($_POST['tid']));
    } else {
        $tpl->assign('title', $l->t('Create Task'));
        $tpl->assign('submit_btn_name', $l->t('Create'));
        $tpl->assign('projects', OC_Collaboration_Project::getProjects(OC_User::getUser()));
    }
    $tpl->printPage();
} else {
    header('Location: ' . \OCP\Util::linkToRoute('collaboration_route', array('rel_path' => 'dashboard')));
    \OCP\Util::writeLog('collaboration', 'Permission denied for ' . OC_User::getUser() . ' to create task.', \OCP\Util::WARN);
    exit;
}
Exemple #4
0
	public static function init() {
		// register autoloader
		$loaderStart = microtime(true);
		require_once __DIR__ . '/autoloader.php';
		self::$loader = new \OC\Autoloader();
		spl_autoload_register(array(self::$loader, 'load'));
		$loaderEnd = microtime(true);

		self::initPaths();

		// setup 3rdparty autoloader
		$vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php';
		if (file_exists($vendorAutoLoad)) {
			require_once $vendorAutoLoad;
		} else {
			OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
			// we can't use the template error page here, because this needs the
			// DI container which isn't available yet
			print('Composer autoloader not found, unable to continue. Check the folder "3rdparty".');
			exit();
		}

		// setup the basic server
		self::$server = new \OC\Server(\OC::$WEBROOT);
		\OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd);
		\OC::$server->getEventLogger()->start('boot', 'Initialize');

		// set some stuff
		//ob_start();
		error_reporting(E_ALL | E_STRICT);
		if (defined('DEBUG') && DEBUG) {
			ini_set('display_errors', 1);
		}
		self::$CLI = (php_sapi_name() == 'cli');

		date_default_timezone_set('UTC');
		ini_set('arg_separator.output', '&');

		//try to configure php to enable big file uploads.
		//this doesn´t work always depending on the webserver and php configuration.
		//Let´s try to overwrite some defaults anyways

		//try to set the maximum execution time to 60min
		@set_time_limit(3600);
		@ini_set('max_execution_time', 3600);
		@ini_set('max_input_time', 3600);

		//try to set the maximum filesize to 10G
		@ini_set('upload_max_filesize', '10G');
		@ini_set('post_max_size', '10G');
		@ini_set('file_uploads', '50');

		self::handleAuthHeaders();
		self::registerAutoloaderCache();

		// initialize intl fallback is necessary
		\Patchwork\Utf8\Bootup::initIntl();
		OC_Util::isSetLocaleWorking();

		if (!defined('PHPUNIT_RUN')) {
			OC\Log\ErrorHandler::setLogger(OC_Log::$object);
			if (defined('DEBUG') and DEBUG) {
				OC\Log\ErrorHandler::register(true);
				set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
			} else {
				OC\Log\ErrorHandler::register();
			}
		}

		// register the stream wrappers
		stream_wrapper_register('fakedir', 'OC\Files\Stream\Dir');
		stream_wrapper_register('static', 'OC\Files\Stream\StaticStream');
		stream_wrapper_register('close', 'OC\Files\Stream\Close');
		stream_wrapper_register('quota', 'OC\Files\Stream\Quota');
		stream_wrapper_register('oc', 'OC\Files\Stream\OC');

		\OC::$server->getEventLogger()->start('init_session', 'Initialize session');
		OC_App::loadApps(array('session'));
		if (!self::$CLI) {
			self::initSession();
		}
		\OC::$server->getEventLogger()->end('init_session');
		self::initTemplateEngine();
		self::checkConfig();
		self::checkInstalled();
		self::checkSSL();
		OC_Response::addSecurityHeaders();

		$errors = OC_Util::checkServer(\OC::$server->getConfig());
		if (count($errors) > 0) {
			if (self::$CLI) {
				foreach ($errors as $error) {
					echo $error['error'] . "\n";
					echo $error['hint'] . "\n\n";
				}
			} else {
				OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
				OC_Template::printGuestPage('', 'error', array('errors' => $errors));
			}
			exit;
		}

		//try to set the session lifetime
		$sessionLifeTime = self::getSessionLifeTime();
		@ini_set('gc_maxlifetime', (string)$sessionLifeTime);

		$systemConfig = \OC::$server->getSystemConfig();

		// User and Groups
		if (!$systemConfig->getValue("installed", false)) {
			self::$server->getSession()->set('user_id', '');
		}

		OC_User::useBackend(new OC_User_Database());
		OC_Group::useBackend(new OC_Group_Database());

		//setup extra user backends
		if (!self::checkUpgrade(false)) {
			OC_User::setupBackends();
		}

		self::registerCacheHooks();
		self::registerFilesystemHooks();
		self::registerPreviewHooks();
		self::registerShareHooks();
		self::registerLogRotate();
		self::registerLocalAddressBook();

		//make sure temporary files are cleaned up
		$tmpManager = \OC::$server->getTempManager();
		register_shutdown_function(array($tmpManager, 'clean'));

		if ($systemConfig->getValue('installed', false) && !self::checkUpgrade(false)) {
			if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
				OC_Util::addScript('backgroundjobs');
			}
		}

		// Check whether the sample configuration has been copied
		if($systemConfig->getValue('copied_sample_config', false)) {
			$l = \OC::$server->getL10N('lib');
			header('HTTP/1.1 503 Service Temporarily Unavailable');
			header('Status: 503 Service Temporarily Unavailable');
			OC_Template::printErrorPage(
				$l->t('Sample configuration detected'),
				$l->t('It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php')
			);
			return;
		}

		$host = OC_Request::insecureServerHost();
		// if the host passed in headers isn't trusted
		if (!OC::$CLI
			// overwritehost is always trusted
			&& OC_Request::getOverwriteHost() === null
			&& !OC_Request::isTrustedDomain($host)
		) {
			header('HTTP/1.1 400 Bad Request');
			header('Status: 400 Bad Request');

			$tmpl = new OCP\Template('core', 'untrustedDomain', 'guest');
			$tmpl->assign('domain', $_SERVER['SERVER_NAME']);
			$tmpl->printPage();

			exit();
		}
		\OC::$server->getEventLogger()->end('boot');
	}
Exemple #5
0
	public static function init() {
		// register autoloader
		require_once __DIR__ . '/autoloader.php';
		self::$loader = new \OC\Autoloader();
		self::$loader->registerPrefix('Doctrine\\Common', 'doctrine/common/lib');
		self::$loader->registerPrefix('Doctrine\\DBAL', 'doctrine/dbal/lib');
		self::$loader->registerPrefix('Symfony\\Component\\Routing', 'symfony/routing');
		self::$loader->registerPrefix('Symfony\\Component\\Console', 'symfony/console');
		self::$loader->registerPrefix('Patchwork', '3rdparty');
		self::$loader->registerPrefix('Pimple', '3rdparty/Pimple');
		spl_autoload_register(array(self::$loader, 'load'));

		// make a dummy session available as early as possible since error pages need it
		self::$session = new \OC\Session\Memory('');

		// set some stuff
		//ob_start();
		error_reporting(E_ALL | E_STRICT);
		if (defined('DEBUG') && DEBUG) {
			ini_set('display_errors', 1);
		}
		self::$CLI = (php_sapi_name() == 'cli');

		date_default_timezone_set('UTC');
		ini_set('arg_separator.output', '&');

		// try to switch magic quotes off.
		if (get_magic_quotes_gpc() == 1) {
			ini_set('magic_quotes_runtime', 0);
		}

		//try to configure php to enable big file uploads.
		//this doesn´t work always depending on the webserver and php configuration.
		//Let´s try to overwrite some defaults anyways

		//try to set the maximum execution time to 60min
		@set_time_limit(3600);
		@ini_set('max_execution_time', 3600);
		@ini_set('max_input_time', 3600);

		//try to set the maximum filesize to 10G
		@ini_set('upload_max_filesize', '10G');
		@ini_set('post_max_size', '10G');
		@ini_set('file_uploads', '50');

		self::handleAuthHeaders();
		self::initPaths();
		self::registerAutoloaderCache();

		OC_Util::isSetLocaleWorking();

		// setup 3rdparty autoloader
		$vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php';
		if (file_exists($vendorAutoLoad)) {
			require_once $vendorAutoLoad;
		}

		if (!defined('PHPUNIT_RUN')) {
			OC\Log\ErrorHandler::setLogger(OC_Log::$object);
			if (defined('DEBUG') and DEBUG) {
				OC\Log\ErrorHandler::register(true);
				set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
			} else {
				OC\Log\ErrorHandler::register();
			}
		}

		// register the stream wrappers
		stream_wrapper_register('fakedir', 'OC\Files\Stream\Dir');
		stream_wrapper_register('static', 'OC\Files\Stream\StaticStream');
		stream_wrapper_register('close', 'OC\Files\Stream\Close');
		stream_wrapper_register('quota', 'OC\Files\Stream\Quota');
		stream_wrapper_register('oc', 'OC\Files\Stream\OC');

		// setup the basic server
		self::$server = new \OC\Server();

		self::initTemplateEngine();
		OC_App::loadApps(array('session'));
		if (!self::$CLI) {
			self::initSession();
		} else {
			self::$session = new \OC\Session\Memory('');
		}
		self::checkConfig();
		self::checkInstalled();
		self::checkSSL();
		OC_Response::addSecurityHeaders();

		$errors = OC_Util::checkServer(\OC::$server->getConfig());
		if (count($errors) > 0) {
			if (self::$CLI) {
				foreach ($errors as $error) {
					echo $error['error'] . "\n";
					echo $error['hint'] . "\n\n";
				}
			} else {
				OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
				OC_Template::printGuestPage('', 'error', array('errors' => $errors));
			}
			exit;
		}

		//try to set the session lifetime
		$sessionLifeTime = self::getSessionLifeTime();
		@ini_set('gc_maxlifetime', (string)$sessionLifeTime);

		// User and Groups
		if (!OC_Config::getValue("installed", false)) {
			self::$session->set('user_id', '');
		}

		OC_User::useBackend(new OC_User_Database());
		OC_Group::useBackend(new OC_Group_Database());

		//setup extra user backends
		if (!self::checkUpgrade(false)) {
			OC_User::setupBackends();
		}

		self::registerCacheHooks();
		self::registerFilesystemHooks();
		self::registerPreviewHooks();
		self::registerShareHooks();
		self::registerLogRotate();
		self::registerLocalAddressBook();

		//make sure temporary files are cleaned up
		register_shutdown_function(array('OC_Helper', 'cleanTmp'));

		if (OC_Config::getValue('installed', false) && !self::checkUpgrade(false)) {
			if (OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
				OC_Util::addScript('backgroundjobs');
			}
		}

		$host = OC_Request::insecureServerHost();
		// if the host passed in headers isn't trusted
		if (!OC::$CLI
			// overwritehost is always trusted
			&& OC_Request::getOverwriteHost() === null
			&& !OC_Request::isTrustedDomain($host)
		) {
			header('HTTP/1.1 400 Bad Request');
			header('Status: 400 Bad Request');

			$tmpl = new OCP\Template('core', 'untrustedDomain', 'guest');
			$tmpl->assign('domain', $_SERVER['SERVER_NAME']);
			$tmpl->printPage();

			exit();
		}
	}
Exemple #6
0
 *                                                *
 * (c) Copyright 2011 Bart Visscher               *
 * This file is licensed under the Affero General *
 * Public License version 3 or later.             *
 * See the COPYING-README file.                   *
 *************************************************/
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('tasks');
if (!OCP\App::isEnabled('calendar')) {
    OCP\Template::printUserPage('tasks', 'no-calendar-app');
    exit;
}
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
if (count($calendars) == 0) {
    header('Location: ' . OCP\Util::linkTo('calendar', 'index.php'));
    exit;
}
OCP\Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addScript('tasks', 'tasks');
OCP\Util::addStyle('tasks', 'style');
OCP\Util::addScript('contacts', 'jquery.multi-autocomplete');
OCP\Util::addScript('', 'oc-vcategories');
OCP\App::setActiveNavigationEntry('tasks_index');
$categories = OC_Calendar_App::getCategoryOptions();
$priority_options = OC_Task_App::getPriorityOptions();
$output = new OCP\Template('tasks', 'tasks', 'user');
$output->assign('priority_options', $priority_options);
$output->assign('categories', $categories, false);
$output->printPage();
Exemple #7
0
		,"ico":"img/FiR.jpg"
		,"title":"Traditionally played with Go pieces (black and white stones) on a go board with 19\u00d719 intersections.<br>User plays first, then players alternate in placing a mark of their own on an empty place. The winner is the first player to get an unbroken row of five marks horizontally, vertically, or diagonally."
	},{"id":"theTotalIsRight"
		,"js":"g/theTotalIsRight/ttir.html"
		,"caption":"The total is right"
		,"ico":"img/ttir.jpg"
		,"title":"A random three-digit target is generated, then six numbers are randomly chosen. You have thirty seconds to get as near to the target as possible by combining the six numbers, and using addition, subtraction, multiplication and division."
	},{"id":"jsSudoku"
		,"js":"g/duSouk/jsSudoku.html"
		,"caption":"Number Place"
		,"ico":"img/jsSudoku.jpg"
		,"title":"Howard Garns (1905-1989) is the creator of Number Place - aka Sudoku.<br>The objective is to fill a 9\u00d79 grid with digits so that each column, each row, and each of the nine 3\u00d73 sub-grids that compose the grid contains all of the digits from 1 to 9. The puzzle is a grid partially completed with \"givens\", and must have a unique solution."
	},{"id":"sokogo"
		,"js":"g/sokogo/sokogo.html"
		,"caption":"Sokogo"
		,"ico":"img/sokogo.jpg"
		,"title":"Sokoban ('warehouse keeper' in japanese) was created in 1981 by Hiroyuki Imabayashi. This is a type of transport puzzle, in which the player pushes (but never pulls - except in reverse mode) one box or crate at a time, around in a warehouse, trying to get them to storage locations."
	}
]
EOJ;

$myArr = json_decode($myJSON);
if ( $myArr ) {
//	Display the list of games
	$myTemplate = new \OCP\Template(K_APP_NAME, 'listGames.tpl', 'user');
	$myTemplate->assign('mainList', $myArr);
} else {
	$myTemplate = new \OCP\Template(K_APP_NAME, 'Err0201.tpl', 'user');
}
$myTemplate->printPage();
?>
            $tid = OC_Collaboration_Task::createTask($_POST['title'], $_POST['description'], OC_User::getUser(), $_POST['pid'], $_POST['priority'], $_POST['deadline_time'], 'Unassigned', NULL);
        }
        if ($tid != false && isset($_POST['send_mail'])) {
            OC_Collaboration_Mail::sendTaskCreationMail($_POST['title'], $_POST['description'], $_POST['pid'], $_POST['member'], $_POST['deadline_time']);
        }
        $eve->assign('title', $l->t('Loading...'));
        $eve->assign('permission_granted', 'true');
        $eve->assign('task', $tid);
        $eve->printPage();
    } else {
        if (!isset($_POST['status'])) {
            $_POST['status'] = NULL;
        }
        if (!isset($_POST['member'])) {
            $_POST['member'] = NULL;
        }
        if (!isset($_POST['reason'])) {
            $_POST['reason'] = NULL;
        }
        $status = OC_Collaboration_Task::updateTask($_POST['tid'], $_POST['title'], $_POST['description'], OC_User::getUser(), $_POST['pid'], $_POST['priority'], $_POST['deadline_time'], $_POST['status'], $_POST['member'], $_POST['reason']);
        if ($status != false && isset($_POST['send_mail'])) {
            OC_Collaboration_Mail::sendTaskCreationMail($_POST['title'], $_POST['description'], $_POST['pid'], $_POST['member'], $_POST['deadline_time']);
        }
        $eve = new OCP\Template('collaboration', 'event_edit_form', 'user');
        $eve->assign('title', $l->t('Loading...'));
        $eve->assign('permission_granted', 'true');
        $eve->assign('task', $_POST['tid']);
        $eve->printPage();
        //		print_unescaped('<META HTTP-EQUIV="Refresh" Content="0; URL=' . \OCP\Util::linkToRoute('collaboration_route', array('rel_path' => 'submit_change_task')) . '?task=' . $_POST['tid'] . '&title=' . $_POST['title'] . '">');
    }
}
 /**
  *
  * @PublicPage
  * @NoAdminRequired
  * @NoCSRFRequired
  *
  * @param $share
  * @return TemplateResponse
  */
 public function publicChart($share)
 {
     $project = $this->connect->project()->getShare($share);
     $params = ['template' => 'guest', 'protected' => false, 'wrongpw' => false, 'requesttoken' => false];
     if ($project['open'] == 1 && $project['is_share'] == 1) {
         // static requesttoken
         $params['requesttoken'] = md5($project['share_password'] . md5($project['share_link']));
         // share time is over
         if ($project['share_is_expire'] == '1' && strtotime($project['share_expire_time']) < time()) {
             $params['protected'] = true;
             $params['template'] = 'guest';
         } else {
             //
             $session_publickey = Helper::session('publickey');
             if (!empty($session_publickey) && $session_publickey == $params['requesttoken']) {
                 $params['template'] = 'project';
             } else {
                 if ($project['share_is_protected'] == 1) {
                     $post_requesttoken = Helper::get('requesttoken');
                     $post_password = Helper::get('password');
                     $params['protected'] = true;
                     $params['template'] = 'authenticate';
                     if ($post_requesttoken == $params['requesttoken'] && md5($post_password) == $project['share_password']) {
                         Helper::session('publickey', $params['requesttoken']);
                         $params['template'] = 'project';
                     } else {
                         if (!empty($post_password)) {
                             $params['wrongpw'] = true;
                         }
                     }
                 } else {
                     $params['template'] = 'project';
                 }
             }
         }
     }
     if ($params['template'] == 'guest') {
         $template = new \OCP\Template('', '404', 'guest');
         $template->printPage();
         exit;
     }
     if ($params['template'] == 'authenticate') {
         return new TemplateResponse($this->appName, 'authenticate', ['wrongpw' => $params['wrongpw'], 'requesttoken' => $params['requesttoken']], 'guest');
     }
     if ($params['template'] == 'project') {
         unset($project['is_share']);
         unset($project['share_link']);
         unset($project['share_is_protected']);
         unset($project['share_password']);
         unset($project['share_is_expire']);
         unset($project['share_expire_time']);
         $jsonData = ['project' => $project, 'tasks' => $this->connect->task()->get(), 'links' => $this->connect->link()->get()];
         $params = ['current_user' => null];
         return new TemplateResponse($this->appName, 'main', $params);
     }
 }
Exemple #10
0
	/**
	 * Handle the request
	 */
	public static function handleRequest() {
		$l = \OC_L10N::get('lib');
		// load all the classpaths from the enabled apps so they are available
		// in the routing files of each app
		OC::loadAppClassPaths();

		// Check if ownCloud is installed or in maintenance (update) mode
		if (!OC_Config::getValue('installed', false)) {
			$controller = new OC\Core\Setup\Controller();
			$controller->run($_POST);
			exit();
		}

		$host = OC_Request::insecureServerHost();
		// if the host passed in headers isn't trusted
		if (!OC::$CLI
			// overwritehost is always trusted
			&& OC_Request::getOverwriteHost() === null
			&& !OC_Request::isTrustedDomain($host)) {

			header('HTTP/1.1 400 Bad Request');
			header('Status: 400 Bad Request');
			$tmpl = new OCP\Template('core', 'untrustedDomain', 'guest');
			$tmpl->assign('domain', $_SERVER['SERVER_NAME']);
			$tmpl->printPage();
			return;
		}

		$request = OC_Request::getPathInfo();
		if (substr($request, -3) !== '.js') { // we need these files during the upgrade
			self::checkMaintenanceMode();
			self::checkUpgrade();
		}

		if (!OC_User::isLoggedIn()) {
			// Test it the user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
			if (!OC_Config::getValue('maintenance', false) && !self::checkUpgrade(false)) {
				OC_App::loadApps(array('authentication'));
			}
			OC::tryBasicAuthLogin();
		}


		if (!self::$CLI and (!isset($_GET["logout"]) or ($_GET["logout"] !== 'true'))) {
			try {
				if (!OC_Config::getValue('maintenance', false) && !\OCP\Util::needUpgrade()) {
					OC_App::loadApps(array('authentication'));
					OC_App::loadApps(array('filesystem', 'logging'));
					OC_App::loadApps();
				}
				self::checkSingleUserMode();
				OC::$server->getRouter()->match(OC_Request::getRawPathInfo());
				return;
			} catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
				//header('HTTP/1.0 404 Not Found');
			} catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) {
				OC_Response::setStatus(405);
				return;
			}
		}

		// Load minimum set of apps
		if (!self::checkUpgrade(false)) {
			// For logged-in users: Load everything
			if(OC_User::isLoggedIn()) {
				OC_App::loadApps();
			} else {
				// For guests: Load only authentication, filesystem and logging
				OC_App::loadApps(array('authentication'));
				OC_App::loadApps(array('filesystem', 'logging'));
			}
		}

		// Handle redirect URL for logged in users
		if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) {
			$location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url']));

			// Deny the redirect if the URL contains a @
			// This prevents unvalidated redirects like ?redirect_url=:user@domain.com
			if (strpos($location, '@') === false) {
				header('Location: ' . $location);
				return;
			}
		}
		// Handle WebDAV
		if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') {
			// not allowed any more to prevent people
			// mounting this root directly.
			// Users need to mount remote.php/webdav instead.
			header('HTTP/1.1 405 Method Not Allowed');
			header('Status: 405 Method Not Allowed');
			return;
		}

		// Redirect to index if the logout link is accessed without valid session
		// this is needed to prevent "Token expired" messages while login if a session is expired
		// @see https://github.com/owncloud/core/pull/8443#issuecomment-42425583
		if(isset($_GET['logout']) && !OC_User::isLoggedIn()) {
			header("Location: " . OC::$WEBROOT.(empty(OC::$WEBROOT) ? '/' : ''));
			return;
		}

		// Someone is logged in
		if (OC_User::isLoggedIn()) {
			OC_App::loadApps();
			OC_User::setupBackends();
			if (isset($_GET["logout"]) and ($_GET["logout"])) {
				OC_JSON::callCheck();
				if (isset($_COOKIE['oc_token'])) {
					OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
				}
				if (isset($_SERVER['PHP_AUTH_USER'])) {
					if (isset($_COOKIE['oc_ignore_php_auth_user'])) {
						// Ignore HTTP Authentication for 5 more mintues.
						setcookie('oc_ignore_php_auth_user', $_SERVER['PHP_AUTH_USER'], time() + 300, OC::$WEBROOT.(empty(OC::$WEBROOT) ? '/' : ''));
					} elseif ($_SERVER['PHP_AUTH_USER'] === self::$session->get('loginname')) {
						// Ignore HTTP Authentication to allow a different user to log in.
						setcookie('oc_ignore_php_auth_user', $_SERVER['PHP_AUTH_USER'], 0, OC::$WEBROOT.(empty(OC::$WEBROOT) ? '/' : ''));
					}
				}
				OC_User::logout();
				// redirect to webroot and add slash if webroot is empty
				header("Location: " . OC::$WEBROOT.(empty(OC::$WEBROOT) ? '/' : ''));
			} else {
				// Redirect to default application
				OC_Util::redirectToDefaultPage();
			}
		} else {
			// Not handled and not logged in
			self::handleLogin();
		}
	}
Exemple #11
0
<?php

OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('files_pdfviewer');
$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
$file = isset($_GET['file']) ? $_GET['file'] : '';
// TODO: add mime type detection and load the template
$mime = "application/pdf";
$page = new OCP\Template('files_pdfviewer', 'pdf');
$page->assign('dir', $dir);
$page->assign('file', $file);
$page->printPage();
 /**
  *@PublicPage
  * @NoCSRFRequired
  * @UseSession
  */
 public function index($token)
 {
     if ($token) {
         $linkItem = Share::getShareByToken($token, false);
         if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
             $type = $linkItem['item_type'];
             $itemSource = CalendarApp::validateItemSource($linkItem['item_source'], CalendarApp::SHARETODOPREFIX);
             $shareOwner = $linkItem['uid_owner'];
             $calendarName = $linkItem['item_target'];
             $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
             // stupid copy and paste job
             if (isset($linkItem['share_with'])) {
                 // Authenticate share_with
                 $password = $this->params('password');
                 if (isset($password)) {
                     if ($linkItem['share_type'] === \OCP\Share::SHARE_TYPE_LINK) {
                         // Check Password
                         $newHash = '';
                         if (\OC::$server->getHasher()->verify($password, $linkItem['share_with'], $newHash)) {
                             $this->session->set('public_link_authenticated', $linkItem['id']);
                             if (!empty($newHash)) {
                             }
                         } else {
                             \OCP\Util::addStyle('files_sharing', 'authenticate');
                             $params = array('wrongpw' => true);
                             return new TemplateResponse('files_sharing', 'authenticate', $params, 'guest');
                         }
                     } else {
                         \OCP\Util::writeLog('share', 'Unknown share type ' . $linkItem['share_type'] . ' for share id ' . $linkItem['id'], \OCP\Util::ERROR);
                         return false;
                     }
                 } else {
                     // Check if item id is set in session
                     if (!$this->session->exists('public_link_authenticated') || $this->session->get('public_link_authenticated') !== $linkItem['id']) {
                         // Prompt for password
                         \OCP\Util::addStyle('files_sharing', 'authenticate');
                         $params = array();
                         return new TemplateResponse('files_sharing', 'authenticate', $params, 'guest');
                     }
                 }
             }
             \OCP\Util::addStyle(CalendarApp::$appname, '3rdparty/fontello/css/animation');
             \OCP\Util::addStyle(CalendarApp::$appname, '3rdparty/fontello/css/fontello');
             \OCP\Util::addStyle($this->appName, 'style');
             \OCP\Util::addStyle($this->appName, 'share');
             \OCP\Util::addScript($this->appName, 'share');
             $data = TasksApp::getEventObject($itemSource, false, false);
             $l = \OC::$server->getL10N($this->appName);
             $object = VObject::parse($data['calendardata']);
             $vTodo = $object->VTODO;
             $id = $data['id'];
             $object = Object::cleanByAccessClass($id, $object);
             $accessclass = $vTodo->getAsString('CLASS');
             $permissions = TasksApp::getPermissions($id, TasksApp::TODO, $accessclass);
             if ($accessclass === 'PRIVATE') {
                 header('HTTP/1.0 404 Not Found');
                 $response = new TemplateResponse('core', '404', '', 'guest');
                 return $response;
             }
             $categories = $vTodo->getAsArray('CATEGORIES');
             $summary = strtr($vTodo->getAsString('SUMMARY'), array('\\,' => ',', '\\;' => ';'));
             $location = strtr($vTodo->getAsString('LOCATION'), array('\\,' => ',', '\\;' => ';'));
             $description = strtr($vTodo->getAsString('DESCRIPTION'), array('\\,' => ',', '\\;' => ';'));
             $priorityOptionsArray = TasksApp::getPriorityOptionsFilterd();
             //$priorityOptions=$priorityOptionsArray[(string)$vTodo->priority];
             $priorityOptions = 0;
             $link = strtr($vTodo->getAsString('URL'), array('\\,' => ',', '\\;' => ';'));
             $TaskDate = '';
             $TaskTime = '';
             if ($vTodo->DUE) {
                 $dateDueType = $vTodo->DUE->getValueType();
                 if ($dateDueType == 'DATE') {
                     $TaskDate = $vTodo->DUE->getDateTime()->format('d.m.Y');
                     $TaskTime = '';
                 }
                 if ($dateDueType == 'DATE-TIME') {
                     $TaskDate = $vTodo->DUE->getDateTime()->format('d.m.Y');
                     $TaskTime = $vTodo->DUE->getDateTime()->format('H:i');
                 }
             }
             $TaskStartTime = '';
             $TaskStartDate = '';
             if ($vTodo->DTSTART) {
                 $dateStartType = $vTodo->DTSTART->getValueType();
                 if ($dateStartType === 'DATE') {
                     $TaskStartDate = $vTodo->DTSTART->getDateTime()->format('d.m.Y');
                     $TaskStartTime = '';
                 }
                 if ($dateStartType === 'DATE-TIME') {
                     $TaskStartDate = $vTodo->DTSTART->getDateTime()->format('d.m.Y');
                     $TaskStartTime = $vTodo->DTSTART->getDateTime()->format('H:i');
                 }
             }
             //PERCENT-COMPLETE
             $cptlStatus = (string) $this->l10n->t('needs action');
             $percentComplete = 0;
             if ($vTodo->{'PERCENT-COMPLETE'}) {
                 $percentComplete = $vTodo->{'PERCENT-COMPLETE'};
                 //$cptlStatus = (string)$this->l10n->t('in procress');
                 if ($percentComplete === '0') {
                     $cptlStatus = (string) $this->l10n->t('needs action');
                 }
                 if ($percentComplete > '0' && $percentComplete < '100') {
                     $cptlStatus = (string) $this->l10n->t('in procress');
                 }
             }
             if ($vTodo->{'COMPLETED'}) {
                 $cptlStatus = (string) $this->l10n->t('completed');
             }
             $timezone = \OC::$server->getSession()->get('public_link_timezone');
             $sCat = '';
             if (is_array($categories) && count($categories) > 0) {
                 $sCat = $categories;
             }
             $params = ['eventid' => $itemSource, 'permissions' => $permissions, 'priorityOptions' => $priorityOptions, 'percentComplete' => $percentComplete, 'cptlStatus' => $cptlStatus, 'TaskDate' => isset($TaskDate) ? $TaskDate : '', 'TaskTime' => isset($TaskTime) ? $TaskTime : '', 'TaskStartDate' => isset($TaskStartDate) ? $TaskStartDate : '', 'TaskStartTime' => isset($TaskStartTime) ? $TaskStartTime : '', 'title' => $summary, 'accessclass' => $accessclass, 'location' => $location, 'categories' => $sCat, 'calendar' => $data['calendarid'], 'aCalendar' => CalendarApp::getCalendar($data['calendarid'], false, false), 'calAppName' => CalendarApp::$appname, 'description' => $description, 'repeat_rules' => '', 'link' => $link, 'timezone' => $timezone, 'uidOwner' => $shareOwner, 'displayName' => \OCP\User::getDisplayName($shareOwner), 'sharingToken' => $token, 'token' => $token];
             $response = new TemplateResponse($this->appName, 'publicevent', $params, 'base');
             return $response;
         }
         //end isset
     }
     //end token
     $tmpl = new \OCP\Template('', '404', 'guest');
     $tmpl->printPage();
 }
Exemple #13
0
 /**
  * Send 404 Response
  */
 protected function sendNotFound()
 {
     header("HTTP/1.0 404 Not Found");
     $tmpl = new \OCP\Template('', '404', 'guest');
     $tmpl->assign('file', $this->filepath);
     $tmpl->printPage();
     exit;
 }
Exemple #14
0
 public static function init()
 {
     // calculate the root directories
     OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4));
     // register autoloader
     $loaderStart = microtime(true);
     require_once __DIR__ . '/autoloader.php';
     self::$loader = new \OC\Autoloader([OC::$SERVERROOT . '/lib', OC::$SERVERROOT . '/core', OC::$SERVERROOT . '/settings', OC::$SERVERROOT . '/ocs', OC::$SERVERROOT . '/ocs-provider', OC::$SERVERROOT . '/3rdparty']);
     spl_autoload_register(array(self::$loader, 'load'));
     $loaderEnd = microtime(true);
     self::$CLI = php_sapi_name() == 'cli';
     try {
         self::initPaths();
         // setup 3rdparty autoloader
         $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php';
         if (!file_exists($vendorAutoLoad)) {
             throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".');
         }
         require_once $vendorAutoLoad;
     } catch (\RuntimeException $e) {
         OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
         // we can't use the template error page here, because this needs the
         // DI container which isn't available yet
         print $e->getMessage();
         exit;
     }
     foreach (OC::$APPSROOTS as $appRoot) {
         self::$loader->addValidRoot($appRoot['path']);
     }
     // setup the basic server
     self::$server = new \OC\Server(\OC::$WEBROOT);
     \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd);
     \OC::$server->getEventLogger()->start('boot', 'Initialize');
     // Don't display errors and log them
     error_reporting(E_ALL | E_STRICT);
     @ini_set('display_errors', 0);
     @ini_set('log_errors', 1);
     date_default_timezone_set('UTC');
     //try to configure php to enable big file uploads.
     //this doesn´t work always depending on the webserver and php configuration.
     //Let´s try to overwrite some defaults anyways
     //try to set the maximum execution time to 60min
     @set_time_limit(3600);
     @ini_set('max_execution_time', 3600);
     @ini_set('max_input_time', 3600);
     //try to set the maximum filesize to 10G
     @ini_set('upload_max_filesize', '10G');
     @ini_set('post_max_size', '10G');
     @ini_set('file_uploads', '50');
     self::setRequiredIniValues();
     self::handleAuthHeaders();
     self::registerAutoloaderCache();
     // initialize intl fallback is necessary
     \Patchwork\Utf8\Bootup::initIntl();
     OC_Util::isSetLocaleWorking();
     if (!defined('PHPUNIT_RUN')) {
         $logger = \OC::$server->getLogger();
         OC\Log\ErrorHandler::setLogger($logger);
         if (\OC::$server->getConfig()->getSystemValue('debug', false)) {
             OC\Log\ErrorHandler::register(true);
             set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
         } else {
             OC\Log\ErrorHandler::register();
         }
     }
     // register the stream wrappers
     stream_wrapper_register('fakedir', 'OC\\Files\\Stream\\Dir');
     stream_wrapper_register('static', 'OC\\Files\\Stream\\StaticStream');
     stream_wrapper_register('close', 'OC\\Files\\Stream\\Close');
     stream_wrapper_register('quota', 'OC\\Files\\Stream\\Quota');
     stream_wrapper_register('oc', 'OC\\Files\\Stream\\OC');
     \OC::$server->getEventLogger()->start('init_session', 'Initialize session');
     OC_App::loadApps(array('session'));
     if (!self::$CLI) {
         self::initSession();
     }
     \OC::$server->getEventLogger()->end('init_session');
     self::initTemplateEngine();
     self::checkConfig();
     self::checkInstalled();
     OC_Response::addSecurityHeaders();
     if (self::$server->getRequest()->getServerProtocol() === 'https') {
         ini_set('session.cookie_secure', true);
     }
     if (!defined('OC_CONSOLE')) {
         $errors = OC_Util::checkServer(\OC::$server->getConfig());
         if (count($errors) > 0) {
             if (self::$CLI) {
                 // Convert l10n string into regular string for usage in database
                 $staticErrors = [];
                 foreach ($errors as $error) {
                     echo $error['error'] . "\n";
                     echo $error['hint'] . "\n\n";
                     $staticErrors[] = ['error' => (string) $error['error'], 'hint' => (string) $error['hint']];
                 }
                 try {
                     \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors));
                 } catch (\Exception $e) {
                     echo 'Writing to database failed';
                 }
                 exit(1);
             } else {
                 OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
                 OC_Template::printGuestPage('', 'error', array('errors' => $errors));
                 exit;
             }
         } elseif (self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) {
             \OC::$server->getConfig()->deleteAppValue('core', 'cronErrors');
         }
     }
     //try to set the session lifetime
     $sessionLifeTime = self::getSessionLifeTime();
     @ini_set('gc_maxlifetime', (string) $sessionLifeTime);
     $systemConfig = \OC::$server->getSystemConfig();
     // User and Groups
     if (!$systemConfig->getValue("installed", false)) {
         self::$server->getSession()->set('user_id', '');
     }
     OC_User::useBackend(new OC_User_Database());
     OC_Group::useBackend(new OC_Group_Database());
     //setup extra user backends
     if (!self::checkUpgrade(false)) {
         OC_User::setupBackends();
     }
     self::registerCacheHooks();
     self::registerFilesystemHooks();
     if (\OC::$server->getSystemConfig()->getValue('enable_previews', true)) {
         self::registerPreviewHooks();
     }
     self::registerShareHooks();
     self::registerLogRotate();
     self::registerLocalAddressBook();
     self::registerEncryptionWrapper();
     self::registerEncryptionHooks();
     //make sure temporary files are cleaned up
     $tmpManager = \OC::$server->getTempManager();
     register_shutdown_function(array($tmpManager, 'clean'));
     $lockProvider = \OC::$server->getLockingProvider();
     register_shutdown_function(array($lockProvider, 'releaseAll'));
     if ($systemConfig->getValue('installed', false) && !self::checkUpgrade(false)) {
         if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
             OC_Util::addScript('backgroundjobs');
         }
     }
     // Check whether the sample configuration has been copied
     if ($systemConfig->getValue('copied_sample_config', false)) {
         $l = \OC::$server->getL10N('lib');
         header('HTTP/1.1 503 Service Temporarily Unavailable');
         header('Status: 503 Service Temporarily Unavailable');
         OC_Template::printErrorPage($l->t('Sample configuration detected'), $l->t('It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php'));
         return;
     }
     $request = \OC::$server->getRequest();
     $host = $request->getInsecureServerHost();
     /**
      * if the host passed in headers isn't trusted
      * FIXME: Should not be in here at all :see_no_evil:
      */
     if (!OC::$CLI && self::$server->getConfig()->getSystemValue('overwritehost') === '' && !\OC::$server->getTrustedDomainHelper()->isTrustedDomain($host) && self::$server->getConfig()->getSystemValue('installed', false)) {
         header('HTTP/1.1 400 Bad Request');
         header('Status: 400 Bad Request');
         $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest');
         $tmpl->assign('domain', $request->server['SERVER_NAME']);
         $tmpl->printPage();
         exit;
     }
     \OC::$server->getEventLogger()->end('boot');
 }
/**
 * The default information screen
 * @global array $profile
 */
function no_mode()
{
    global $USERNAME, $profile;
    $tmpl = new OCP\Template('user_openid', 'nomode', 'guest');
    if (substr($profile['req_url'], -1, 1) !== '/') {
        //the identity should always end with a /
        $profile['req_url'] .= '/';
    }
    $tmpl->addHeader('link', array('rel' => 'openid.server', 'href' => $profile['req_url']));
    $tmpl->addHeader('link', array('rel' => 'openid.delegate', 'href' => $profile['idp_url']));
    $tmpl->assign('user', $USERNAME);
    $tmpl->printPage();
}
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either 
* version 3 of the License, or any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*  
* You should have received a copy of the GNU Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
// Check if we are a user
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('media');
require_once OC::$APPSROOT . '/apps/media/lib_collection.php';
require_once OC::$APPSROOT . '/apps/media/lib_scanner.php';
OCP\Util::addscript('media', 'player');
OCP\Util::addscript('media', 'music');
OCP\Util::addscript('media', 'playlist');
OCP\Util::addscript('media', 'collection');
OCP\Util::addscript('media', 'scanner');
OCP\Util::addscript('media', 'jquery.jplayer.min');
OCP\Util::addStyle('media', 'music');
OCP\App::setActiveNavigationEntry('media_index');
$tmpl = new OCP\Template('media', 'music', 'user');
$tmpl->printPage();
?>
 
	/**
	* @method OC_Shorty_HttpException::__construct
	* @brief: Constructs an exception based on a phrase and a set of parameters
	* @param integer status: Http status code
	* @access public
	* @author Christian Reiner
	*/
	public function __construct ( $status )
	{
		if (   is_numeric($status)
			&& array_key_exists($status,OC_Shorty_Type::$HTTPCODE) )
		{
			$status = intval($status);
			$phrase = OC_Shorty_Type::$HTTPCODE[$status];
		}
		else
		{
			$status = 400;
			$phrase = OC_Shorty_Type::$HTTPCODE[400]; // "Bad Request"
		} // else

		// return http status code to client (browser)
		if ( ! headers_sent() )
		{
			header ( sprintf("HTTP/1.0 %s %s",$status,$phrase) );
		}
		$tmpl = new OCP\Template("shorty", "tmpl_http_status", "guest");
		$tmpl->assign("explanation", OC_Shorty_L10n::t($phrase));
		$tmpl->printPage();
		exit;
  } // function __construct