Stunden ende, einiges fertig, fehlt nicht mehr viel

Took 2 hours 31 minutes
This commit is contained in:
Tobias Hopp 2020-10-02 10:41:09 +02:00
parent 1fd648bc4a
commit c37ad92dbc
51 changed files with 26430 additions and 17 deletions

0
.idea/codeStyles/codeStyleConfig.xml generated Normal file → Executable file
View File

6
.idea/jsLibraryMappings.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="PROJECT" libraries="{bootstrap, jquery-3.3.1.slim, popper.js}" />
</component>
</project>

0
.idea/modules.xml generated Normal file → Executable file
View File

3
.idea/online-faq.iml generated Normal file → Executable file
View File

@ -4,5 +4,8 @@
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="bootstrap" level="application" />
<orderEntry type="library" name="jquery-3.3.1.slim" level="application" />
<orderEntry type="library" name="popper.js" level="application" />
</component>
</module>

4
.idea/php.xml generated Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpProjectSharedConfiguration" php_language_level="7" />
</project>

0
.idea/vcs.xml generated Normal file → Executable file
View File

177
.idea/workspace.xml generated Executable file
View File

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BranchesTreeState">
<expand>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
</path>
</expand>
<select />
</component>
<component name="ChangeListManager">
<list default="true" id="fc13552d-b118-4828-b78f-fc8714e0cfdc" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.idea/jsLibraryMappings.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/php.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/classes/Api.class.inc.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/config.inc.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/controller/FaqController.class.inc.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/model/FaqModel.class.inc.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/templates/faq.tmpl.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/templates/start.tmpl.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap-grid.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap-grid.css.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap-grid.min.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap-grid.min.css.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap-reboot.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap-reboot.css.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap-reboot.min.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap-reboot.min.css.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap.css.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap.min.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/bootstrap.min.css.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/default.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/css/sticky-footer-navbar.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/js/bootstrap.bundle.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/js/bootstrap.bundle.js.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/js/bootstrap.bundle.min.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/js/bootstrap.bundle.min.js.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/js/bootstrap.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/js/bootstrap.js.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/js/bootstrap.min.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/js/bootstrap.min.js.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/js/jquery-3.5.1.min.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/vendor/js/start.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/views/Apitemplate.class.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/codeStyles/codeStyleConfig.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/codeStyles/codeStyleConfig.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/online-faq.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/online-faq.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/LICENSE" beforeDir="false" afterPath="$PROJECT_DIR$/LICENSE" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/SECURITY.md" beforeDir="false" afterPath="$PROJECT_DIR$/SECURITY.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/classes/Autoloader.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/classes/Autoloader.class.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/classes/Database.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/classes/Database.class.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/classes/Factory.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/classes/Factory.class.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/classes/Request.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/classes/Request.class.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/controller/DefaultController.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/controller/DefaultController.class.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/index.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/main.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/model/DefaultModel.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/model/DefaultModel.class.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/test.tmpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/test.tmpl.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/views/Template.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/views/Template.class.inc.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings">
<execution />
</component>
<component name="DarkyenusTimeTracker">
<option name="totalTimeSeconds" value="8993" />
<option name="gitIntegration" value="true" />
<option name="naggedAbout" value="1" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="HTML File" />
<option value="CSS File" />
<option value="JavaScript File" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1iJGpr9KuWzqJPbaXgGvBoTSNb4" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/templates" />
<property name="list.type.of.created.stylesheet" value="CSS" />
<property name="vue.rearranger.settings.migration" value="true" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/templates" />
</key>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="fc13552d-b118-4828-b78f-fc8714e0cfdc" name="Default Changelist" comment="" />
<created>1601618466935</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1601618466935</updated>
<workItem from="1601618467981" duration="9245000" />
</task>
<task id="LOCAL-00001" summary="Initial commit">
<created>1601618764031</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1601618764031</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Initial commit" />
<option name="LAST_COMMIT_MESSAGE" value="Initial commit" />
</component>
<component name="WindowStateProjectService">
<state x="1066" y="308" width="499" height="596" key="NewPhpClassDialog" timestamp="1601624640212">
<screen x="0" y="34" width="1920" height="1046" />
</state>
<state x="1066" y="308" width="499" height="596" key="NewPhpClassDialog/0.34.1920.1046@0.34.1920.1046" timestamp="1601624640212" />
<state x="755" y="479" width="399" height="161" key="NewPhpFileDialog" timestamp="1601618925778">
<screen x="0" y="34" width="1920" height="1046" />
</state>
<state x="755" y="479" width="399" height="161" key="NewPhpFileDialog/0.34.1920.1046@0.34.1920.1046" timestamp="1601618925778" />
<state x="555" y="292" width="800" height="535" key="Vcs.Push.Dialog.v2" timestamp="1601618765171">
<screen x="0" y="34" width="1920" height="1046" />
</state>
<state x="555" y="292" width="800" height="535" key="Vcs.Push.Dialog.v2/0.34.1920.1046@0.34.1920.1046" timestamp="1601618765171" />
<state x="739" y="469" width="432" height="182" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1601624836751">
<screen x="0" y="34" width="1920" height="1046" />
</state>
<state x="739" y="469" width="432" height="182" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/0.34.1920.1046@0.34.1920.1046" timestamp="1601624836751" />
<state x="623" y="264" width="672" height="678" key="search.everywhere.popup" timestamp="1601628017554">
<screen x="0" y="34" width="1920" height="1046" />
</state>
<state x="623" y="264" width="672" height="678" key="search.everywhere.popup/0.34.1920.1046@0.34.1920.1046" timestamp="1601628017554" />
</component>
</project>

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
SECURITY.md Normal file → Executable file
View File

27
classes/Api.class.inc.php Normal file
View File

@ -0,0 +1,27 @@
<?php
class Api
{
public static $request;
/**
* @return bool
* @throws Exception
*/
public static function getRequest()
{
self::$request = json_decode( file_get_contents('php://input') );
return true;
}
public static function getVar( $a_index )
{
if( !isset( self::$request[$a_index] ) )
{
return false;
}
return self::$request[$a_index];
}
}

0
classes/Autoloader.class.inc.php Normal file → Executable file
View File

0
classes/Database.class.inc.php Normal file → Executable file
View File

4
classes/Factory.class.inc.php Normal file → Executable file
View File

@ -16,7 +16,7 @@ class Factory
public static function getController( Request $a_request )
{
# Prepare name of controller
$controller_name = mb_strtolower( $a_request->getVar( 'controller' ) );
$controller_name = mb_strtolower( $a_request->getVar( 'c' ) );
$controller_name = ucfirst( $controller_name );
$controller_name .= 'Controller';
@ -49,7 +49,7 @@ class Factory
public static function getAction( $a_controller, Request $a_request )
{
# Prepare name of the action
$action_name = mb_strtolower( $a_request->getVar('action') );
$action_name = mb_strtolower( $a_request->getVar('a') );
$action_name = str_ireplace( 'action', '', $action_name );
$action_name .= 'Action';

0
classes/Request.class.inc.php Normal file → Executable file
View File

7
config.inc.php Normal file
View File

@ -0,0 +1,7 @@
<?php
define( 'MYSQL_HOST', 'localhost' );
define( 'MYSQL_USER', 'online-faq' );
define( 'MYSQL_PASS', 'RnKVJHcUBIIu1XM2' );
define( 'MYSQL_DB', 'online-faq' );

66
controller/DefaultController.class.inc.php Normal file → Executable file
View File

@ -13,17 +13,71 @@ class DefaultController
*/
public function indexAction()
{
$view = new Template( 'test' );
$DefaultModel = new DefaultModel();
$value = $DefaultModel->getTestMessage();
$view->set_placeholder( 'test', $value );
$view = new Template( 'start' );
// Return the HTML Code to the index.php
return $view->getHtml();
} # function indexAction()
/**
* @return string
* @throws Exception
*/
public function joinFAQAction()
{
$view = new Template( 'start' );
$DefaultModel = new DefaultModel();
$Request = new Request();
$room_code = $Request->getVar( 'code', null, 'GET' );
if( empty( $room_code ) && !isset( $room_code ) )
{
$view->set_placeholder( 'error', 'Room-Code is invalid!' );
return $view->getHtml();
}
if( ( $room_id = $DefaultModel->checkCode( $room_code ) ) === false )
{
$view->set_placeholder( 'error', 'Room-Code is invalid!' );
return $view->getHtml();
}
if( !$DefaultModel->joinRoom( $room_id ) )
{
$view->set_placeholder( 'error', 'An error occured, please try again later!' );
return $view->getHtml();
}
return $view->getHtml();
}
/**
* @return string
* @throws Exception
*/
public function createFAQAction()
{
$view = new Template( 'start' );
$DefaultModel = new DefaultModel();
$Request = new Request();
$room_name = $Request->getVar( 'room-name' );
if( !$DefaultModel->createRoom( $room_name ) )
{
$view->set_placeholder( 'error', 'An error occured, please try again later!' );
return $view->getHtml();
}
return $view->getHtml();
}
} # class

View File

@ -0,0 +1,81 @@
<?php
class FaqController extends DefaultController
{
public function indexAction()
{
$view = new Template( 'faq' );
$FAQModel = new FaqModel();
$room = $FAQModel->getRoom();
$view->set_placeholder( 'room_name', $room['name'] );
return $view->getHtml();
}
public function getQuestionsAction()
{
$view = new Apitemplate();
$FAQModel = new FaqModel();
$room = $FAQModel->getRoom();
$questions = $FAQModel->getQuestions( $room['id'] );
$view->setResponse( array( 'questions' => $questions ) );
return $view->getResponse();
}
public function addQuestionAction()
{
$view = new Apitemplate();
$FAQModel = new FaqModel();
$room = $FAQModel->getRoom();
$question = Api::getVar( 'question' );
try {
$FAQModel->addQuestion( $room, $question );
} catch( Exception $e )
{
$view->setSuccess( false );
$view->setHeaderCode( 901 );
return $view->getResponse();
}
$view->setSuccess( true );
return $view->getResponse();
}
public function addAnswerAction()
{
$view = new Apitemplate();
$FAQModel = new FaqModel();
$room = $FAQModel->getRoom();
$question_id = Api::getVar( 'question_id' );
$answer = Api::getVar( 'answer' );
if( !$FAQModel->checkUserIsRoomOwner( $room ) )
{
$view->setSuccess( false );
$view->setHeaderCode( 905 );
return $view->getResponse();
}
try {
$FAQModel->addAnswer( $question_id, $answer );
} catch( Exception $e )
{
$view->setSuccess( false );
$view->setHeaderCode( 902 );
return $view->getResponse();
}
$view->setSuccess( true );
return $view->getResponse();
}
}

0
index.php Normal file → Executable file
View File

8
main.inc.php Normal file → Executable file
View File

@ -11,6 +11,7 @@ Autoloader::register();
try
{
session_start();
$host = MYSQL_HOST;
$dbname = MYSQL_DB;
@ -19,6 +20,13 @@ try
# Set DB connection
Database::setConnection( $pdo );
try {
Api::getRequest();
} catch( Exception $e )
{
# exception ignored
}
}

40
model/DefaultModel.class.inc.php Normal file → Executable file
View File

@ -3,8 +3,44 @@
class DefaultModel
{
public function getTestMessage()
public function redirectToStart($string)
{
return "Rabbits can't fly without Red Bull.";
header( "Location: ?c=default&a=index&rsn=$string" );
exit();
}
public function checkCode($room_code)
{
$stmnt = Database::getConnection()->prepare( 'SELECT id FROM rooms WHERE code = :code' );
$stmnt->execute( array( 'code' => $room_code ) );
$result = $stmnt->fetch( PDO::FETCH_ASSOC );
if( $result === false || empty( $result ) )
{
return false;
}
return $result['id'];
}
public function joinRoom($room_id)
{
$_SESSION['room'] = $room_id;
header( 'Location: ?c=faq' );
return true;
}
public function createRoom(string $room_name)
{
$room_owner = session_id();
$stmnt = Database::getConnection()->prepare( 'INSERT INTO rooms ( name, owner, code ) VALUES ( :name, :owner, :code )' );
$stmnt->execute( array( 'name' => $room_name, 'owner' => $room_owner, 'code' => $this->generateRandomStr() ) );
}
public function generateRandomStr( $length = 4 )
{
return 'U2HA';
}
}

View File

@ -0,0 +1,90 @@
<?php
class FaqModel
{
public function redirectToStart($string)
{
header( "Location: ?c=default&a=index&rsn=$string" );
exit();
}
public function getRoom( )
{
if( !isset( $_SESSION['room'] ) )
{
$this->redirectToStart( 'no-code' );
}
if( ( $id = $this->checkID( $_SESSION['room'] ) ) === false )
{
$this->redirectToStart( 'invalid' );
}
$stmnt = Database::getConnection()->prepare( 'SELECT * FROM rooms WHERE id = :id' );
$stmnt->execute( array( 'id' => $id ) );
return $stmnt->fetch( PDO::FETCH_ASSOC );
}
public function getQuestions( $room_id )
{
$stmnt = Database::getConnection()->prepare( 'SELECT * FROM questions WHERE room_id = :id' );
$stmnt->execute( array( 'id' => $room_id ) );
$result = $stmnt->fetchAll( PDO::FETCH_ASSOC );
if( $result === false || empty( $result ) )
{
return false;
}
return $result;
}
private function checkID($room_id)
{
$stmnt = Database::getConnection()->prepare( 'SELECT id FROM rooms WHERE id = :id' );
$stmnt->execute( array( 'id' => $room_id ) );
$result = $stmnt->fetch( PDO::FETCH_ASSOC );
if( $result === false || empty( $result ) )
{
return false;
}
return $result['id'];
}
public function addQuestion(int $room_id, bool $question)
{
$stmnt = Database::getConnection()->prepare( 'INSERT INTO questions ( room_id, question, created_by ) VALUES ( :room_id, :question, :created_by )' );
$stmnt->execute( array( 'room_id' => $room_id, $question, 'Anonymous' ) );
}
public function addAnswer(int $question_id, bool $answer)
{
$stmnt = Database::getConnection()->prepare( 'UPDATE questions SET answer = :answer WHERE id = :id' );
$stmnt->execute( array( 'answer' => $answer, 'id' => $question_id ) );
}
public function checkUserIsRoomOwner( array $a_room )
{
$stmnt = Database::getConnection()->prepare( 'SELECT owner_sid FROM rooms WHERE id = :id' );
$stmnt->execute( array( 'id' => $a_room['id'] ) );
$result = $stmnt->fetchAll( PDO::FETCH_ASSOC );
if( $result === false || empty( $result ) )
{
return false;
}
if( $result['owner_sid'] === session_id() )
{
return true;
}
return false;
}
}

80
templates/faq.tmpl.html Executable file
View File

@ -0,0 +1,80 @@
<!doctype html>
<html lang="en" class="h-100">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Jekyll v3.8.5">
<title>Online-FAQ | Room [[ROOM_NAME]]</title>
<!-- Bootstrap core CSS -->
<link href="vendor/css/bootstrap.min.css" rel="stylesheet"">
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
<!-- Custom styles for this template -->
<link href="vendor/css/sticky-footer-navbar.css" rel="stylesheet">
</head>
<body class="d-flex flex-column h-100">
<header>
<!-- Fixed navbar -->
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="#">Online-FAQ</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="?c=default">Start</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">This FAQ</a>
</li>
</ul>
<form class="form-inline mt-2 mt-md-0">
<input class="form-control mr-sm-2" type="text" placeholder="FAQ-Code" aria-label="Join">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Join FAQ</button>
</form>
</div>
</nav>
</header>
<!-- Begin page content -->
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">Online-FAQ</h1>
<p class="lead">Room [[ROOM_NAME]]</p>
<br>
</div>
<div id="questions">
</div>
</main>
<footer class="footer mt-auto py-3">
<div class="container">
<span class="text-muted">Online-FAQ<br>Programmed by Tobias Hopp</span>
</div>
</footer>
<script src="vendor/js/jquery-3.5.1.min.js"></script>
<script src="vendor/js/bootstrap.bundle.min.js"></script>
<script src="vendor/js/faq.js"></script>
</body>
</html>

121
templates/start.tmpl.html Normal file
View File

@ -0,0 +1,121 @@
<!doctype html>
<html lang="en" class="h-100">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Jekyll v3.8.5">
<title>Online-FAQ | Start</title>
<!-- Bootstrap core CSS -->
<link href="vendor/css/bootstrap.min.css" rel="stylesheet"">
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
<!-- Custom styles for this template -->
<link href="vendor/css/sticky-footer-navbar.css" rel="stylesheet">
</head>
<body class="d-flex flex-column h-100">
<header>
<!-- Fixed navbar -->
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="#">Online-FAQ</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="?c=default">Start <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" data-toggle="modal" data-target="#createFAQModal">Create new FAQ</a>
</li>
</ul>
<form class="form-inline mt-2 mt-md-0" action="?c=default&a=JoinFAQ" method="get">
<input class="form-control mr-sm-2" type="text" name="code" placeholder="FAQ-Code" aria-label="Join">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Join FAQ</button>
</form>
</div>
</nav>
</header>
<div class="modal fade" id="createFAQModal" tabindex="-1" role="dialog" aria-labelledby="createFAQModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="createFAQModalLabel">Create a FAQ</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="room-name" class="col-form-label">Custom Room-Name:</label>
<input type="text" class="form-control" id="room-name">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Create</button>
</div>
</div>
</div>
</div>
<!-- Begin page content -->
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">Online-FAQ</h1>
<p class="lead">Collect your database of questions and have them answered directly by your teacher.</p>
<div class="container">
<div class="row">
<div class="col-lg">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#createFAQModal">Create an FAQ</button>
</div>
<div class="col-lg">
<form class="form-inline mt-2 mt-md-0" action="?c=default&a=JoinFAQ" method="get">
<input class="form-control mr-sm-2" type="text" name="code" placeholder="FAQ-Code" aria-label="Join">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Join FAQ</button>
</form>
</div>
</div>
</div>
<br><br>
</div>
</main>
<footer class="footer mt-auto py-3">
<div class="container">
<span class="text-muted">Online-FAQ<br>Programmed by Tobias Hopp</span>
</div>
</footer>
<script src="vendor/js/jquery-3.5.1.min.js"></script>
<script src="vendor/js/bootstrap.bundle.min.js"></script>
<script src="vendor/js/start.js"></script>
</body>
</html>

80
templates/test.tmpl.html Normal file → Executable file
View File

@ -1,10 +1,76 @@
<!DOCTYPE html>
<html lang="de">
<!doctype html>
<html lang="en" class="h-100">
<head>
<meta charset="UTF-8">
<title>Test</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Jekyll v3.8.5">
<title>Sticky Footer Navbar Template · Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="vendor/css/bootstrap.min.css" rel="stylesheet"">
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
<!-- Custom styles for this template -->
<link href="vendor/css/sticky-footer-navbar.css" rel="stylesheet">
</head>
<body>
[[TEST]]
<body class="d-flex flex-column h-100">
<header>
<!-- Fixed navbar -->
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="#">Online-FAQ</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Create new FAQ</a>
</li>
</ul>
<form class="form-inline mt-2 mt-md-0">
<input class="form-control mr-sm-2" type="text" placeholder="FAQ-Code" aria-label="Join">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Join FAQ</button>
</form>
</div>
</nav>
</header>
<!-- Begin page content -->
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">Online-FAQ</h1>
<p class="lead">Collect your database of questions and have them answered directly by your teacher.</p>
</div>
</main>
<footer class="footer mt-auto py-3">
<div class="container">
<span class="text-muted">Online-FAQ<br>Programmed by Tobias Hopp</span>
</div>
</footer>
<script src="vendor/js/jquery-slim.min.js"></script>
<script src="vendor/js/bootstrap.bundle.min.js"></script>
</body>
</html>
</html>

3719
vendor/css/bootstrap-grid.css vendored Normal file

File diff suppressed because it is too large Load Diff

1
vendor/css/bootstrap-grid.css.map vendored Normal file

File diff suppressed because one or more lines are too long

7
vendor/css/bootstrap-grid.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1
vendor/css/bootstrap-grid.min.css.map vendored Normal file

File diff suppressed because one or more lines are too long

331
vendor/css/bootstrap-reboot.css vendored Normal file
View File

@ -0,0 +1,331 @@
/*!
* Bootstrap Reboot v4.3.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
article, aside, figcaption, figure, footer, header, hgroup, main, nav, section {
display: block;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
}
[tabindex="-1"]:focus {
outline: 0 !important;
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-original-title] {
text-decoration: underline;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
border-bottom: 0;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: .5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 80%;
}
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -.25em;
}
sup {
top: -.5em;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
}
a:hover {
color: #0056b3;
text-decoration: underline;
}
a:not([href]):not([tabindex]) {
color: inherit;
text-decoration: none;
}
a:not([href]):not([tabindex]):hover, a:not([href]):not([tabindex]):focus {
color: inherit;
text-decoration: none;
}
a:not([href]):not([tabindex]):focus {
outline: 0;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
}
pre {
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
}
figure {
margin: 0 0 1rem;
}
img {
vertical-align: middle;
border-style: none;
}
svg {
overflow: hidden;
vertical-align: middle;
}
table {
border-collapse: collapse;
}
caption {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
color: #6c757d;
text-align: left;
caption-side: bottom;
}
th {
text-align: inherit;
}
label {
display: inline-block;
margin-bottom: 0.5rem;
}
button {
border-radius: 0;
}
button:focus {
outline: 1px dotted;
outline: 5px auto -webkit-focus-ring-color;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
select {
word-wrap: normal;
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
button:not(:disabled),
[type="button"]:not(:disabled),
[type="reset"]:not(:disabled),
[type="submit"]:not(:disabled) {
cursor: pointer;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
padding: 0;
border-style: none;
}
input[type="radio"],
input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
-webkit-appearance: listbox;
}
textarea {
overflow: auto;
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
display: block;
width: 100%;
max-width: 100%;
padding: 0;
margin-bottom: .5rem;
font-size: 1.5rem;
line-height: inherit;
color: inherit;
white-space: normal;
}
progress {
vertical-align: baseline;
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
[type="search"] {
outline-offset: -2px;
-webkit-appearance: none;
}
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
summary {
display: list-item;
cursor: pointer;
}
template {
display: none;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */

1
vendor/css/bootstrap-reboot.css.map vendored Normal file

File diff suppressed because one or more lines are too long

8
vendor/css/bootstrap-reboot.min.css vendored Normal file
View File

@ -0,0 +1,8 @@
/*!
* Bootstrap Reboot v4.3.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.min.css.map */

File diff suppressed because one or more lines are too long

10038
vendor/css/bootstrap.css vendored Normal file

File diff suppressed because it is too large Load Diff

1
vendor/css/bootstrap.css.map vendored Normal file

File diff suppressed because one or more lines are too long

7
vendor/css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1
vendor/css/bootstrap.min.css.map vendored Normal file

File diff suppressed because one or more lines are too long

5
vendor/css/default.css vendored Normal file
View File

@ -0,0 +1,5 @@
body {
text-align: center;
}

20
vendor/css/sticky-footer-navbar.css vendored Normal file
View File

@ -0,0 +1,20 @@
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
main > .container {
padding: 60px 15px 0;
}
.footer {
background-color: #f5f5f5;
}
.footer > .container {
padding-right: 15px;
padding-left: 15px;
}
code {
font-size: 80%;
}

7013
vendor/js/bootstrap.bundle.js vendored Normal file

File diff suppressed because it is too large Load Diff

1
vendor/js/bootstrap.bundle.js.map vendored Normal file

File diff suppressed because one or more lines are too long

7
vendor/js/bootstrap.bundle.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
vendor/js/bootstrap.bundle.min.js.map vendored Normal file

File diff suppressed because one or more lines are too long

4435
vendor/js/bootstrap.js vendored Normal file

File diff suppressed because it is too large Load Diff

1
vendor/js/bootstrap.js.map vendored Normal file

File diff suppressed because one or more lines are too long

7
vendor/js/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
vendor/js/bootstrap.min.js.map vendored Normal file

File diff suppressed because one or more lines are too long

2
vendor/js/jquery-3.5.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

3
vendor/js/start.js vendored Normal file
View File

@ -0,0 +1,3 @@
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').trigger('focus')
})

View File

@ -0,0 +1,41 @@
<?php
class Apitemplate
{
/**
* @var array
*/
private $response = array(
'api-name' => 'faq-online',
'api-version' => 1.0,
'data' => array(),
'success' => false
);
/**
* @param array $a_response
*/
public function setResponse( array $a_response )
{
$this->response['data'] = $a_response;
}
public function getResponse()
{
return json_encode( $this->response );
}
public function setHeaderCode( $a_code )
{
header("HTTP/1.1 $a_code" );
}
public function setSuccess( bool $a_success )
{
$this->response['success'] = $a_success;
}
}

0
views/Template.class.inc.php Normal file → Executable file
View File