]> gitweb.morketsmerke.org Git - bugtrack.git/commitdiff
Przesłanie plików z publicznego repozytorium
authorxf0r3m <jakubstasinski@protonmail.com>
Thu, 10 Aug 2023 10:35:10 +0000 (12:35 +0200)
committerxf0r3m <jakubstasinski@protonmail.com>
Thu, 10 Aug 2023 10:35:10 +0000 (12:35 +0200)
59 files changed:
403.php [new file with mode: 0644]
404.php [new file with mode: 0644]
README.md [new file with mode: 0644]
btcli [new file with mode: 0755]
bugs.php [new file with mode: 0644]
changelog.php [new file with mode: 0755]
changelogs/index.php [new file with mode: 0755]
comments.php [new file with mode: 0644]
db_conf.php [new file with mode: 0644]
db_patch_59.sql [new file with mode: 0755]
forms/changelogform.php [new file with mode: 0755]
forms/chbugstate.php [new file with mode: 0644]
forms/chpasswd.php [new file with mode: 0644]
forms/delcomponent.php [new file with mode: 0644]
forms/delproduct.php [new file with mode: 0644]
forms/deluser.php [new file with mode: 0644]
forms/editcomponent.php [new file with mode: 0644]
forms/editproduct.php [new file with mode: 0644]
forms/newclform.php [new file with mode: 0755]
forms/newcomponent.php [new file with mode: 0644]
forms/newdictionary.php [new file with mode: 0755]
forms/newproduct.php [new file with mode: 0644]
forms/newuser.php [new file with mode: 0644]
forms/setpasswd.php [new file with mode: 0644]
forms/slogan.php [new file with mode: 0644]
frontpage.php [new file with mode: 0644]
index.php [new file with mode: 0755]
install.sql [new file with mode: 0644]
library.php [new file with mode: 0644]
listofbugs.php [new file with mode: 0644]
login.php [new file with mode: 0644]
logout.php [new file with mode: 0644]
modules/chbugstate.php [new file with mode: 0644]
modules/chpasswd.php [new file with mode: 0644]
modules/delcomponent.php [new file with mode: 0644]
modules/delproduct.php [new file with mode: 0644]
modules/deluser.php [new file with mode: 0644]
modules/editclform.php [new file with mode: 0755]
modules/editcomponent.php [new file with mode: 0644]
modules/editdictionary.php [new file with mode: 0755]
modules/editproduct.php [new file with mode: 0644]
modules/listclforms.php [new file with mode: 0755]
modules/listcomponents.php [new file with mode: 0644]
modules/listproducts.php [new file with mode: 0644]
modules/listusers.php [new file with mode: 0644]
modules/newclform.php [new file with mode: 0755]
modules/newcomponent.php [new file with mode: 0644]
modules/newdictionary.php [new file with mode: 0755]
modules/newproduct.php [new file with mode: 0644]
modules/newuser.php [new file with mode: 0644]
modules/saveslogan.php [new file with mode: 0644]
modules/setpasswd.php [new file with mode: 0644]
navbar.php [new file with mode: 0755]
passwd.php [new file with mode: 0644]
settings.php [new file with mode: 0644]
siteListProducts.php [new file with mode: 0644]
statistics.php [new file with mode: 0644]
submit.php [new file with mode: 0644]
viewchlog.php [new file with mode: 0755]

diff --git a/403.php b/403.php
new file mode 100644 (file)
index 0000000..9e150ad
--- /dev/null
+++ b/403.php
@@ -0,0 +1,3 @@
+<div class="alert alert-danger" role="alert">
+  403 - Dostęp do zawartości strony zabroniony.
+</div>
diff --git a/404.php b/404.php
new file mode 100644 (file)
index 0000000..0486b02
--- /dev/null
+++ b/404.php
@@ -0,0 +1,3 @@
+<div class="alert alert-danger" role="alert">
+  404 - Nie odnaleziono żądanej strony.
+</div>
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..9f1d2d2
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
+# BugTrack
+
+Chcąc skorzystać z `btcli` należy skopiować plik do katalogu /usr/local/bin.
+Następnie wskazać gdzie znajdują się pliki instancji BugTrack (zmienna `ROOT`
+na samym początku pliku).
diff --git a/btcli b/btcli
new file mode 100755 (executable)
index 0000000..b19fc57
--- /dev/null
+++ b/btcli
@@ -0,0 +1,344 @@
+#!/usr/bin/php -d log_errors=Off
+<?php
+  $ROOT = "/var/www/html";
+  include($ROOT . "/library.php");
+  include($ROOT . "/db_conf.php");
+  $DEFAULT_USER = $_SERVER['USER'];
+  
+  function list_of_bugs($connection, $type_of="all") {
+    $tableName = "bug";
+    $columnScheme = "*";
+    if ( isset($type_of) ) {
+      if ( $type_of == "all" ) {
+        $whereValue = "1=1";
+      } else if ( $type_of == "user" ) {
+        $whereValue = "state < 3";
+      }
+    } 
+    $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( mysqli_num_rows($result) > 0 ) {
+      $n=1;
+      while ( $row = mysqli_fetch_row($result) ) {
+        echo $n . "\t#" . $row[0] . "\t";
+
+        $tableName = "product";
+        $columnScheme = "name";
+        $whereValue = "id = " . $row[1];
+        $result2 = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+        $prodName = getFieldValue($result2);
+        echo $prodName . "\t";
+
+        $tableName  = "component";
+        $columnScheme = "name";
+        $whereValue = "id = " . $row[2];
+        $result3 = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+        $compName = getFieldValue($result3);
+        echo $compName . "\t";
+
+        echo $row[3] . "\t" . $row[4] . "\t" . $row[5] . "\t";
+        $stateTbl = array("Przyjęty", "Potwierdzony", "W trakcie", "Zakończony", "Odrzucony");
+        $index = $row[6];
+        $state=$stateTbl[$index];
+
+        echo $state . "\n\n";
+        $n++;
+      }
+    }
+  }
+
+  function list_of_products($connection) {
+    $tableName = "product";
+    $columnScheme = "name,description";
+    $whereValue = "1=1";
+    $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( mysqli_num_rows($result) > 0 ) {
+      $n=1;
+      while ( $row = mysqli_fetch_row($result) ) {
+        echo $n . "\t" . $row[0] . " (" . $row[1] . ")\n\n";
+        $n++;
+      }
+    }
+  }
+
+  function list_of_components($connection, $prodName) {
+    $tableName = "product";
+    $columnScheme = "id";
+    $whereValue = "name = '" . mysqli_real_escape_string($connection, htmlspecialchars($prodName)) . "'";
+    $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    $prodId = getFieldValue($result);
+    $tableName = "component";
+    $columnScheme = "name,description";
+    $whereValue = "productId = " . intval($prodId);
+    $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( mysqli_num_rows($result) > 0 ) {
+      $n=1;
+      while ( $row = mysqli_fetch_row($result) ) {
+        echo $n . "\t" . $row[0] . " (" . $row[1] . ")\n\n";
+        $n++;
+      }
+    } 
+  }
+  
+  function submit_bug($connection, $product, $component, $typeof, $subject, $desc) {
+    $tableName = "product";
+    $columnScheme = "id,description";
+    $whereValue = "name = '" . mysqli_real_escape_string($connection, $product) . "'";
+    $resultp = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    $productrow = mysqli_fetch_row($resultp);
+    $productId = $productrow[0];
+    $productDesc = $productrow[1];
+  
+    $tableName = "component";
+    $columnScheme = "id,description";
+    $whereValue = "name = '" . mysqli_real_escape_string($connection, $component) . "'";
+    $resultc = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    $componentrow = mysqli_fetch_row($resultc);
+    $componentId = $componentrow[0];
+    $componentDesc = $componentrow[1];
+
+    $tableName = "bug";
+    $columnScheme = "productId,componentId,typeof,subject,description,state";
+    $setValues = $productId . "," . $componentId . ",'" . mysqli_real_escape_string($connection, htmlspecialchars($typeof)) . "','" . mysqli_real_escape_string($connection, htmlspecialchars($subject)) . "','" . mysqli_real_escape_string($connection, htmlspecialchars($desc)) . "',0";
+    $result = dbAdd($connection, $tableName, $columnScheme, $setValues);
+    if ( $result == true ) { 
+      echo "Zgłoszenie zostało przyjęte. Niebawem pojawi się na stronie zgłoszonych problemów\n\n";
+    } else {
+      var_dump($result);
+    }
+
+    $tableName = "bug";
+    $columnScheme = "id";
+    $whereValue = "1=1 ORDER BY id DESC";
+    $resulti = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    $bugId = getFieldValue($resulti);
+  
+    $tableName = "comment";
+    $columnScheme = "bugId,user,date,content";
+    $setValues = $bugId . ",'" . $_SERVER["USER"] . "','" . date("Y-m-d H:i:s") . "','Utworzono zgłoszenie.<br /><br /><strong>Produkt:</strong> " . $product . " (" . $productDesc . ")<br /><strong>Komponent:</strong> " . $component . " (" . $componentDesc . ")<br /><strong>Rodzaj zgłoszenia:</strong> " . mysqli_real_escape_string($connection, htmlspecialchars($typeof)) . "<br /><strong>Temat:</strong> " . mysqli_real_escape_string($connection, htmlspecialchars($subject)) . "<br /><strong>Opis zgłoszenia:</strong> " . mysqli_real_escape_string($connection, htmlspecialchars($desc)) . "'";
+    $resultk = dbAdd($connection, $tableName, $columnScheme, $setValues);
+    if ( $resultk == true ) {
+      echo "Zgłoszenie zostało również zapisane jako pierwszy komentarz\n\n";
+    } else {
+      var_dump($resultk);
+    }
+  }
+
+  function add_component($connection, $product, $name, $desc, $author) {
+    $tableName = "product";
+    $columnScheme = "id";
+    $whereValue = "name = '" . mysqli_real_escape_string($connection, htmlspecialchars($product)) . "'";
+    $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    $productId = getFieldValue($result);
+    
+    $tableName = "component";
+    $columnScheme = "productId,name,author,description";
+    $setValues = $productId . ",'" . mysqli_real_escape_string($connection, htmlspecialchars($name)) . "','" . mysqli_real_escape_string($connection, htmlspecialchars($author)) . "','" . mysqli_real_escape_string($connection, htmlspecialchars($desc)) . "'";
+    $resultc = dbAdd($connection, $tableName, $columnScheme, $setValues);
+    if ( $resultc == true ) {
+      echo "Komponent produktu " . $product . " został dodany.\n\n";
+    } else {
+      var_dump($resultc);
+    } 
+  }
+
+  function add_product($connection, $name, $desc, $author) {
+    $tableName = "product";
+    $columnScheme = "name,author,description";
+    $setValues = "'" . mysqli_real_escape_string($connection, htmlspecialchars($name)) . "','" . mysqli_real_escape_string($connection, htmlspecialchars($author)) . "','" . mysqli_real_escape_string($connection, htmlspecialchars($desc)) . "'";
+    $resultp = dbAdd($connection, $tableName, $columnScheme, $setValues);
+    if ( $resultp == true ) {
+      echo "Dodano produkt " . $name . "\n\n";
+    } else {
+      var_dump($resultp);
+    }
+  }
+
+  function show_states($state="all") {
+    if ( isset($state) ) {
+      $stateTbl = array('Przyjęty', 'Potwierdzony', 'W trakcie', 'Zakończony', 'Odrzucony', 'Do usunięcia');
+      if ( $state == "all" ) {
+        for ( $i=0; $i < count($stateTbl); $i++ ) {
+          echo $i . "\t" . $stateTbl[$i] . "\n\n";
+        }
+      } else {
+        return $stateTbl[$state];
+      }
+    }
+  }
+
+
+  function change_state($connection, $bugId, $newState) {
+    if ( ( $newState < 0 ) || ( $newState > 5 ) ) {
+      return false;
+    } else if ( $newState == 5 ) {
+      $tableName = 'comment';
+      $whereValue = 'bugId = ' . intval($bugId);
+      $resultk = dbDel($connection, $tableName, $whereValue);
+      if ( $resultk == "true" ) {
+        echo "Wszystkie komentarz powiązane ze zgłoszeniem zostały usunięte\n\n";
+      } else {
+        var_dump($resultk);
+      }
+      $tableName = 'bug';
+      $whereValue = 'id = ' . intval($bugId);
+      $result = dbDel($connection, $tableName, $whereValue);
+      if ( $result == true ) { 
+        echo "Zgłoszenie zostało usunięte\n\n";
+      } else {
+        var_dump($result);
+      }
+    } else {
+      $tableName = 'bug';
+      $columnScheme = 'state';
+      $setValue = 'state = ' . intval($newState);
+      $whereValue = 'id = ' . intval($bugId);
+      $results = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+      $oldState = getFieldValue($results);
+      $oldStateTxt = show_states($oldState);
+      $newStateTxt = show_states($newState);
+      $result = dbUpdate($connection, $tableName, $setValue, $whereValue);
+      if ( $result == true ) { 
+        echo "Status zgłoszenia został zmieniony\n\n";
+        $tableName = 'comment';
+        $columnScheme = 'bugId,user,date,content';
+        $setValues = intval($bugId) . ",'" . $_SERVER['USER'] . "','" . date("Y-m-d H:i:s") . "','Status zgłoszenia został zmieniony z <strong>" . $oldStateTxt . "</strong> na <strong>" . $newStateTxt . "</strong>'";
+        $resultk=dbAdd($connection, $tableName, $columnScheme, $setValues);
+        if ( $resultk == true ) {
+               echo "Zmiana status został uwzględniona w komentarzach\n\n";
+        } else {
+          var_dump($resultk);
+        }
+      } else { 
+        var_dump($result);
+      }
+    }
+  }
+
+  function list_of_comments($connection, $bugId) {
+    $tableName = 'comment';
+    $columnScheme = 'user,date,content';
+    $whereValue = "bugId = " . intval($bugId);
+    $result = dbQuery($connection,$tableName,$columnScheme,$whereValue);
+    if ( mysqli_num_rows($result) > 0 ) {
+      while( $row = mysqli_fetch_row($result) ) {
+        echo $row[0] . ", " . $row[1] . " pisze...\n";
+        echo $row[2] . "\n\n";
+      }
+    }
+  }
+
+  function add_comment($connection, $bugId, $content) {
+    $tableName = 'comment';
+    $columnScheme = 'bugId,user,date,content';
+    $setValues = intval($bugId) . ",'" . $_SERVER['USER'] . "','" . date("Y-m-d H:i:s") . "','" . mysqli_real_escape_string($connection,htmlspecialchars($content)) . "'";
+    $result = dbAdd($connection, $tableName, $columnScheme, $setValues);
+    if ( $result == true ) { 
+      echo "Komentarz został dodany.\n\n";
+    } else { 
+      var_dump($result);
+    }
+  }
+
+  function del_component($connection, $prodName, $compName) {
+    $tableName = 'product';
+    $columnScheme = 'id';
+    $whereValue = "name = '" . mysqli_real_escape_string($connection, htmlspecialchars($prodName)) . "'";
+    $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    $prodId = getFieldValue($result);
+    $tableName = 'component';
+    $whereValue = "name = '" . mysqli_real_escape_string($connection,htmlspecialchars($compName)) . "' AND productId = " . intval($prodId);
+    $result = dbDel($connection, $tableName, $whereValue);
+    if ( $result == true ) {
+      echo "Komponent został usunięty\n\n";
+    } else {
+      var_dump($result);
+    }
+  }
+
+  function del_product($connection, $prodName) {
+    $tableName = "product";
+    $columnScheme = "id";
+    $whereValue = "name = '" . mysqli_real_escape_string($connection, htmlspecialchars($prodName)) . "'";
+    $resulti = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    $prodId = getFieldValue($resulti);
+
+    $tableName = "component";
+    $whereValue = "productId = " . intval($prodId);
+    $result = dbDel($connection, $tableName, $whereValue);
+    if ( $result == true ) { 
+      echo "Wszystkie komponenty powiązane z produktem zostały usunięte\n\n";
+      $tableName = 'product';
+      $whereValue = 'id = ' . intval($prodId);
+      $result = dbDel($connection, $tableName, $whereValue);
+      if ( $result == true ) {
+        echo "Produkt został usunięty\n\n";
+      } else {
+        var_dump($result);
+      }
+    } else {
+      var_dump($result);
+    }
+  }
+
+  function change_password($connection, $username, $newPasswd) {
+    $tableName = "user";
+    $setValues = "passwd_hash = '" . password_hash($newPasswd, PASSWORD_DEFAULT) . "'";
+    $whereValue = "username = '" . mysqli_real_escape_string($connection, htmlspecialchars($username)) . "'";
+    $result = dbUpdate($connection, $tableName, $setValues, $whereValue);
+    if ( $result == true ) {
+      echo "Hasło zostało zmienione\n\n";
+    } else {
+      var_dump($result);
+    }
+  }
+  
+  if ( isset($argv[1]) ) {
+    if ( $argv[1] == 'lb-all' ) { list_of_bugs($connection); }
+    if ( $argv[1] == 'lb-user' ) { list_of_bugs($connection, 'user'); }
+    if ( $argv[1] == 'lp' ) { list_of_products($connection); }
+    if ( $argv[1] == 'lc' ) { list_of_components($connection, $argv[2]); }
+    if ( $argv[1] == 'sb' ) { submit_bug($connection, $argv[2], $argv[3], $argv[4], $argv[5], $argv[6]); }
+    if ( $argv[1] == 'ap' ) { 
+      if ( ! isset($argv[4]) ) { add_product($connection, $argv[2], $argv[3], $_SERVER['USER']);
+      } else { add_product($connection, $argv[2], $argv[3], $argv[4]); }
+    }
+    if ( $argv[1] == 'ac' ) {
+      if ( ! isset($argv[5]) ) { add_component($connection, $argv[2], $argv[3], $argv[4], $_SERVER['USER']); 
+      } else { add_component($connection, $argv[2], $argv[3], $argv[4], $argv[5]); }
+    }
+    if ( $argv[1] == 'cs' ) { change_state($connection, $argv[2], $argv[3]); }
+    if ( $argv[1] == 'ss' ) { show_states(); }
+    if ( $argv[1] == 'ks' ) { list_of_comments($connection, $argv[2]); }
+    if ( $argv[1] == 'ka' ) { add_comment($connection, $argv[2], $argv[3]); }
+    if ( $argv[1] == 'dc' ) { del_component($connection, $argv[2], $argv[3]); }
+    if ( $argv[1] == 'dp' ) { del_product($connection, $argv[2]); }
+    if ( $argv[1] == 'cp' ) { change_password($connection, $argv[2], $argv[3]); }
+  } else {
+    if ( isset($_SERVER["SHELL"]) ) {
+      echo "btcli - BugTrack CLI for request management\n";
+      echo "morketsmerke.org @ 2023\n";
+      echo "This script requires running instance of BugTrack\n";
+      echo "Options:\n";
+      echo "\tlb-all - prints all submitted requests\n\n";
+      echo "\tlb-user - prints submitted request except done or rejected tasks\n\n";
+      echo "\tlp - prints all products defined on the platform\n\n";
+      echo "\tlc <product_name> - prints all components related with given product\n\n";
+      echo "\tsb <product_name> <component_name> <type_of> <subject> <description> - submiting bug or \n\tenchancement request\n\n";
+      echo "\tap <product_name> <product_description> [product_author] - adding new product to the \n\tplatform\n\n";
+      echo "\tac <product_name> <component_name> <component_description> [component_author] - adding new \n\tcomponent related with given product (product must exist before you create a component)\n\n";
+      echo "\tcs <bug_id> <new_state> - change request state (bug_id is the second column in \n\tlb-all/lb-user output)\n\n";
+      echo "\tss - numeric state values reference (shows, which number is which state)\n\n";
+      echo "\tks <bug_id> - prints all comments for given request\n\n";
+      echo "\tks <bug_id> <comment> - writes a comment for given request\n\n";
+      echo "\tdc <product_name> <component_name> - removes given component\n\n";
+      echo "\tdp <product_name> - removes give product with all related components\n\n";
+      echo "\tcp <username> <new_password> - setting new password for given user\n\n";
+      echo "Request removing:\n";
+      echo "To remove some request just set them state 5, which means 'To delete'\n";
+      echo "Setting state 5, causing request deletion\n";
+    } else {
+      include($ROOT . '/403.php');
+    }
+  }
+  #var_dump($_SERVER);
+?>
diff --git a/bugs.php b/bugs.php
new file mode 100644 (file)
index 0000000..9cbdef1
--- /dev/null
+++ b/bugs.php
@@ -0,0 +1,23 @@
+<div class="card card-spacer">
+  <div class="card-header">
+    <h4>Zgłoszenia otwarte:</h4>
+  </div>
+  <div class="card-body">
+<?php
+  $cond = "state > 0 AND state < 3 ORDER BY id DESC";
+  presentListBugs($connection, $cond);
+?>
+  </div>
+</div>
+
+<div class="card card-spacer">
+  <div class="card-header">
+    <h4>Zgłoszenia zamknięte:</h4>
+  </div>
+  <div class="card-body">
+<?php
+  $cond = "state >= 3 ORDER BY id DESC";
+  presentListBugs($connection, $cond);
+?>
+  </div>
+</div>
diff --git a/changelog.php b/changelog.php
new file mode 100755 (executable)
index 0000000..2032a44
--- /dev/null
@@ -0,0 +1,286 @@
+<?php
+if ( session_status() != 2 ) {
+  session_start();
+}
+if ( isset($_SESSION['username']) ) {
+
+  if ( ( ! empty($_POST)) && isset($_POST["changelogVersion"])) {
+    $productName = $_POST["changelogProductName"];
+    $version = $_POST["changelogVersion"];
+
+    if ( ! is_dir("changelogs/" . $productName) ) { 
+      mkdir("changelogs/" . $productName);
+      copy("changelogs/index.php", "changelogs/" . $productName . "/index.php");
+    }
+    @ $fTxt = fopen("changelogs/" . $productName . "/" . $version . ".txt", "wb");
+    @ $fMd = fopen("changelogs/" . $productName . "/" . $version . ".md", "wb");
+    @ $fHTML = fopen("changelogs/" . $productName . "/" . $version . ".html", "wb");
+
+    $filePath = "changelogs/" . $productName . "/" . $version;
+
+    $tableName = 'changelog';
+    $columnScheme = '*';
+    $whereValue = "productId = " . $_POST["changelogProductId"] . " AND version = '" . $version . "'";
+    $resultSearchChangelog = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( mysqli_num_rows($resultSearchChangelog) == 0 ) {
+      $tableName = 'changelog';
+      $columnScheme = "productId,version,filepath";
+      $setValues = intval($_POST["changelogProductId"]) . ",'" . $version . "','" . $filePath . "'";
+      $resultAddChangelog = dbAdd($connection, $tableName, $columnScheme, $setValues);
+      if ( $resultAddChangelog == true ) {
+        echo "<div class=\"alert alert-success\" role=\"alert\">Lista zmian dla wersji " . $version . " produktu " . $productName . " została pomyślnie wygenerowana</div>";
+      } else {
+        echo "<div class=\"alert alert-danger\" role=\"alert\">Lista zmian nie została wygenerowana</div>";
+      }
+    } else {
+      echo "<div class=\"alert alert-success\" role=\"alert\">Lista zmian dla wersji " . $version . " produktu " . $productName . " została pomyślnie wygenerowana</div>";
+    }
+
+    #echo $productName . " - wersja: " . $version . "<br />";
+
+    $msgTxt = $productName . " - wersja: " . $version . "\n";
+    $msgMd = "##### " . $productName . " - wersja: *" . $version . "*\n";
+    $msgHtml = "<h5>" . $productName . "</h5> <h6>&nbsp;&nbsp- wersja: <strong>" . $version . "</strong></h6><br />\n";
+
+    fwrite($fTxt, $msgTxt);
+    fwrite($fMd, $msgMd);
+    fwrite($fHTML, $msgHtml);
+    
+    $tableName = 'dictionary';
+    $columnScheme = 'dictionary';
+    $whereValue = 'productId = ' . $_POST['changelogProductId'];
+    $resultDict = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( mysqli_num_rows($resultDict) > 0 ) {
+      $dict=getFieldValue($resultDict);
+      $dictWords = explode(',', $dict);
+    }
+    
+    fwrite($fHTML, "<ol>\n");
+
+    $lp = 1;
+    foreach ( $_POST as $key => $value ) {
+
+      if ( empty($value) ) { continue; } 
+      if ( (preg_match('/changelogBugIdLC\d+/', $key) == 0) && (preg_match('/changelogBugId\d+/', $key) == 0) ) {
+        
+        if ( preg_match('/changelog/', $key) == 0 ) {
+          fwrite($fHTML, "<li>\n");
+          #echo "Sprawdź w słowniku: $key <br />";
+          $name = $key;
+          for ($i=0; $i < count($dictWords); $i++) {
+            if ( preg_match("/". $name . "=>/", $dictWords[$i]) == 1 ) {
+              $dictExpr = explode('=>', $dictWords[$i]);
+              if ( strlen($value) > 1 ) {
+                #echo $lp . ". " . $dictExpr[1] . "<br />&nbsp;&nbsp;" . $value . "<br /><br />";
+
+                $msgTxt = $lp . ". " . $dictExpr[1] . "\n\t" . $value . "\n\n";
+                $msgMd = $lp . ". " . $dictExpr[1] . "\n\t" . $value . "\n\n";
+                $msgHtml = $dictExpr[1] . "<br />&nbsp;&nbsp;" . $value . "<br /><br />\n";
+
+                fwrite($fTxt, $msgTxt);
+                fwrite($fMd, $msgMd);
+                fwrite($fHTML, $msgHtml);
+
+              } else {
+                #echo $lp . ". " . $dictExpr[1] . "<br /><br />";
+                
+                $msgTxt = $lp . ". " . $dictExpr[1] . "\n\n";
+                $msgMd = $lp . ". " . $dictExpr[1] . "\n\n";
+                $msgHtml = $dictExpr[1] . "<br /><br />\n";
+
+                fwrite($fTxt, $msgTxt);
+                fwrite($fMd, $msgMd);
+                fwrite($fHTML, $msgHtml);
+
+              }
+            }
+          }
+          $lp++;
+          fwrite($fHTML, "</li>\n");
+        }
+      }
+      if ( preg_match('/changelogBugId\d+/', $key) == 1 ) {
+        fwrite($fHTML, "<li style=\"text-align: justify\">\n");
+        #echo "Pobranie danych z bazy: $key <br />";
+        $tableName = 'bug';
+        $columnScheme = "id,componentId,subject,description";
+        $whereValue = "id = " . $value;
+        $resultBug = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+        if ( mysqli_num_rows($resultBug) > 0 ) {
+          $rowBug = mysqli_fetch_row($resultBug);
+          $tableName = "component";
+          $columnScheme = "name";
+          $whereValue = "id = " . $rowBug[1];
+          $resultComp = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+          if ( mysqli_num_rows($resultComp) > 0 ) {
+            $compName = getFieldValue($resultComp);
+          }
+          #echo $lp . ". #" . $rowBug[0] . "&nbsp;-&nbsp;" . $compName . "&nbsp;-&nbsp;" . $rowBug[2] . "<br />";
+          
+          if ( ! empty($_SERVER['HTTPS']) ) { $serverProtocol = "https://"; }
+          else { $serverProtocol = "http://"; }
+
+          $msgTxt = $lp . ". #" . $rowBug[0] . " - " . $compName . " - " . $rowBug[2] . "\n";
+          $msgMd = $lp . ". [#" . $rowBug[0] . "](" . $serverProtocol . $_SERVER['SERVER_NAME'] . "/index.php?p=comments&bid=" . $rowBug[0] . ") - " . $compName . " - " . $rowBug[2] . "\n";
+          $msgHtml = "<a href=\"" . $serverProtocol . $_SERVER['SERVER_NAME'] . "/index.php?p=comments&bid=" . $rowBug[0] . "\">#" . $rowBug[0] . "</a>&nbsp;-&nbsp;" . $compName . "&nbsp;-&nbsp;" . $rowBug[2] . "<br />\n";
+
+          fwrite($fTxt, $msgTxt);
+          fwrite($fMd, $msgMd);
+          fwrite($fHTML, $msgHtml);
+
+          $content = array();
+          #$content = formatTo80Cols($rowBug[3], "&nbsp;&nbsp;", "<br />");
+          $content = newFormatTo80Cols($rowBug[3], "&nbsp;&nbsp;", "<br />");
+
+          foreach ( $content as $line ) {
+            #echo $line;
+            $msgHtml = $line . "\n";
+            fwrite($fHTML, $msgHtml); 
+          }
+          $content = newFormatTo80Cols($rowBug[3], "\t", "\n");
+          #$content = formatTo80Cols($rowBug[3], "\t", "\n");
+          foreach ( $content as $line ) {
+            fwrite($fTxt, $line);
+            fwrite($fMd, $line);
+          }
+        }
+        $assembledKey="changelogBugIdLC" . $value;
+        if ( isset($_POST[$assembledKey]) && ( $_POST[$assembledKey] === "1" ) ) {
+
+          #echo "<br />";
+
+          fwrite($fTxt, "\n");
+          fwrite($fMd, "\n");
+          fwrite($fHTML, "<br />");
+
+          $tableName = "comment";
+          $columnScheme = "id,content";
+          $whereValue = "bugId = " . $value . " ORDER BY id DESC";
+          $resultComment = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+          if ( mysqli_num_rows($resultComment) > 0 ) {
+            #mysqli_data_seek($resultComment, 1);
+            $commentRow = mysqli_fetch_row($resultComment);
+            while ( preg_match('/^Status\ zgłoszenia/', $commentRow[1]) == 1 ) {
+              $commentRow = mysqli_fetch_row($resultComment);
+            }
+            #echo $commentRow[1] . "<br />";
+            #$comment = formatTo80Cols($commentRow[1], "&nbsp;&nbsp;", "<br />");
+            $comment = newFormatTo80Cols($commentRow[1], "&nbsp;&nbsp;", "<br />");
+            foreach ( $comment as $commentLine ) {
+              if ( preg_match('/https/', $commentLine) == 1 ) {
+                $htmlSpecialChr = array("&nbsp;&nbsp;", "<br />");
+                $msgHtml = "&nbsp;&nbsp;<a href=\"" . trim(str_replace($htmlSpecialChr,"", $commentLine)) . "\">" .  trim(str_replace($htmlSpecialChr,"", $commentLine)) . "</a><br />\n";
+                #echo $msgHtml;
+              } else {
+                #echo $commentLine;
+                $msgHtml = $commentLine . "\n";
+              }
+              fwrite($fHTML, $msgHtml);
+            }
+            #$comment = formatTo80Cols($commentRow[1], "\t", "\n");
+            $comment = newFormatTo80Cols($commentRow[1], "\t", "\n");
+            foreach ( $comment as $commentLine ) {
+              if ( preg_match('/https/', $commentLine) == 1 ) {
+                $msgMd = "\t[" . trim($commentLine) . "](" . trim($commentLine) . ")\n";
+                fwrite($fMd, $msgMd);
+                $msgTxt = "\t" . trim($commentLine) . "\n";
+                fwrite($fTxt, $msgTxt);
+              } else {
+                fwrite($fMd, $commentLine);
+                fwrite($fTxt, $commentLine);
+
+              }
+            }
+          }
+        #echo "Pobrać ostatni komentarz dla zgłoszenia: #" . $value . "<br />";
+        }
+        $lp++;
+        fwrite($fHTML, "</li>\n");
+        #echo "<br />";
+
+        fwrite($fTxt, "\n");
+        fwrite($fMd, "\n");
+        fwrite($fHTML, "<br />");
+      }
+      
+        
+    }
+    
+    fwrite($fHTML, "</ol>\n");
+  
+    #echo "Uwagi:<br />";
+    if ( ! empty($_POST["changelogComment"]) ) { 
+      $msgTxt = "Uwagi:\n";    
+      $msgHtml = "Uwagi: <br />";
+
+      fwrite($fTxt, $msgTxt);
+      fwrite($fMd, $msgTxt);
+      fwrite($fHTML, $msgHtml);
+
+      $notices = array();
+      #$notices = formatTo80Cols($_POST["changelogComment"], "&nbsp;&nbsp;", "<br />");
+      $notices = newFormatTo80Cols($_POST["changelogComment"], "&nbsp;&nbsp;", "<br />");
+      foreach ( $notices as $line ) {
+        #echo $line;
+        fwrite($fHTML, $line);
+      }
+      #$notices = formatTo80Cols($_POST["changelogComment"], "\t", "\n");
+      $notices = newFormatTo80Cols($_POST["changelogComment"], "\t", "\n");
+      foreach ( $notices as $line ) {
+        fwrite($fTxt, $line);
+        fwrite($fMd, $line);
+      }
+    }
+    #echo $_POST["changelogComment"];
+    fclose($fTxt);
+    fclose($fMd);
+    fclose($fHTML);
+  }
+  $tableName = "product";
+  $columnScheme = "name";
+  $whereValue = "id = " . $_GET["pid"];
+  $resultName = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($resultName) ) {
+    $productName = getFieldValue($resultName);
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Nie znaleziono produktu o takim identyfikatorze</div>";
+    exit;
+  }
+  
+  echo "<div class=\"card card-spacer\">
+  <div class=\"card-header\">
+    <h4>Wygenerowane listy zmian dla: " . $productName . "</h4>
+  </div>
+  <div class=\"card-body\">";
+
+  $tableName = "changelog";
+  $columnScheme = "filepath";
+  $whereValue = "productId = " . $_GET["pid"];
+  $resultChangelogs = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($resultChangelogs) > 0 ) {
+    echo "<table class=\"table\"><thead></thead><tbody>";
+    while ( $rowCh = mysqli_fetch_row($resultChangelogs) ) {
+      echo "<tr>";
+      echo "<td scope=\"row\"><a href=\"?p=viewchlog&path=" . $rowCh[0] . "\">" . basename($rowCh[0]) . "</a></td>";
+      echo "<td><a href=\"" . $rowCh[0] . ".txt\"><button type=\"button\" class=\"btn btn-primary\">.txt</button></a></td>";
+      echo "<td><a href=\"" . $rowCh[0] . ".md\"><button type=\"button\" class=\"btn btn-primary\">.md</button></a></td>";
+      echo "<td><a href=\"" . $rowCh[0] . ".html\"><button type=\"button\" class=\"btn btn-primary\">.html</button></a></td>";
+      echo "</tr>";
+    }
+    echo "</tbody></table>";
+  } else {
+    echo "<div class=\"alert alert-primary\">Nie znaleziono żadnych list zmian pasujących do produktu</div>";
+  }
+  echo "</div>
+</div>
+<div class=\"card card-spacer\">
+  <div class=\"card-header\">
+    <h4>Nowa lista zmian dla: " . $productName . "</h4>
+  </div>
+  <div class=\"card-body\">";
+  include('forms/changelogform.php');
+} else {
+  include("403.php");
+}
+?>
+
diff --git a/changelogs/index.php b/changelogs/index.php
new file mode 100755 (executable)
index 0000000..43e69a1
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+  if ( ! empty($_SERVER['HTTPS']) ) { $serverProtocol = "https://"; }
+  else { $serverProtocol = "http://"; }
+  $uri = str_replace('/', '', $_SERVER['REQUEST_URI']);
+  header("Location: " . $serverProtocol . $_SERVER['SERVER_NAME'] . "?p=" . $uri);
+?>
diff --git a/comments.php b/comments.php
new file mode 100644 (file)
index 0000000..2685005
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+  if ( isset($_POST) &&  isset($_POST["commentsBugId"]) ) {
+    $tableName = 'comment';
+    $columnScheme = "bugId,user,date,content";
+    $setValue = intval($_POST["commentsBugId"]) . ",'" . $_SESSION["username"] . "','" . date("Y-m-d H:i:s") . "','" . mysqli_real_escape_string($connection, htmlspecialchars($_POST["commentsContent"])) . "'";
+    $result = dbAdd($connection, $tableName, $columnScheme, $setValue);
+  }
+  $tableName = 'comment';
+  $columnScheme = 'user,date,content';
+  $whereValue = "bugId = " . intval($_GET["bid"]);
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($result) > 0 ) {
+    while ( $row = mysqli_fetch_row($result) ) {
+      echo "<div class=\"card card-spacer\">";
+      echo "<div class=\"card-header\">";
+      echo "<strong>" . $row[0] . "</strong>, <em class=\"text-muted\">" . $row[1] . "</em> pisze...";
+      echo "</div><div class=\"card-body\">" . nl2br($row[2]) . "</div></div>";
+    }
+  }
+  if ( session_status() != 2 ) { session_start(); }
+  if ( isset($_SESSION["username"]) ) {
+  echo "<div class=\"card card-spacer\">
+<form action=\"?p=comments&bid=" . intval($_GET["bid"]) . "\" method=\"post\">
+  <div class=\"mb-3\">
+    <label for=\"commentContentTextarea\" class=\"form-label\">Komentarz:</label>
+    <input type=\"hidden\" name=\"commentsBugId\" value=\"" . intval($_GET["bid"]) . "\">
+    <textarea class=\"form-control\" id=\"commnetContentTextarea\" rows=\"3\" name=\"commentsContent\"></textarea>
+  </div>
+  <button type=\"submit\" class=\"btn btn-primary\">Dodaj komentarz</button>
+</form>
+</div>";
+  }
+?>
+
diff --git a/db_conf.php b/db_conf.php
new file mode 100644 (file)
index 0000000..5a3f081
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+  $db = 'bugtrack';
+  $db_user = 'bugtrack';
+  $db_passwd = '1234Test1234#@';
+  $db_host = 'localhost';
+
+  $connection = mysqli_connect($db_host, $db_user, $db_passwd, $db);
+
+  if ( ! $connection ) {
+    echo "<script>console.log('Połaczenie nie powiodło się');
+          console.log(\"Nr błędu: " . mysqli_connect_errno() . "\");
+          console.log(\"Błąd: " . mysqli_connect_error() . "\");</script>";
+    exit;
+  } else {
+    if ( ! isset($_SERVER["SHELL"]) ) {
+      echo "<script>console.log('Połączenie powiodło się!');</script>";
+    }
+  }
+
+?>
diff --git a/db_patch_59.sql b/db_patch_59.sql
new file mode 100755 (executable)
index 0000000..64d9dc6
--- /dev/null
@@ -0,0 +1,25 @@
+use bugtrack;
+
+CREATE TABLE changelog (
+  id int AUTO_INCREMENT PRIMARY KEY,
+  productId int,
+  version varchar(30),
+  filepath text,
+  FOREIGN KEY (productId) REFERENCES product(id)
+);  
+
+CREATE TABLE clform (
+  id int AUTO_INCREMENT PRIMARY KEY,
+  productId int,
+  code text,
+  FOREIGN KEY (productId) REFERENCES product(id)
+);  
+
+CREATE TABLE dictionary (
+  id int AUTO_INCREMENT PRIMARY KEY,
+  productId int,
+  clformId int,
+  dictionary text,
+  FOREIGN KEY (productId) REFERENCES product(id),
+  FOREIGN KEY (clformId) REFERENCES clform(id)
+);  
diff --git a/forms/changelogform.php b/forms/changelogform.php
new file mode 100755 (executable)
index 0000000..6697533
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+  $tableName = "product";
+  $columnScheme = "name";
+  $whereValue = "id = " . $_GET['pid'];
+  $resultName = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  $productName = getFieldValue($resultName);
+?>   
+  <form action="?p=changelog&pid=<?php echo $_GET['pid'] ?>" method="post">
+      <div class="mb-3">
+        <input type="hidden" name="changelogProductName" value="<?php echo $productName; ?>" />
+        <input type="hidden" name="changelogProductId" value="<?php echo $_GET['pid']; ?>" />
+        <label for="changelogVersionInput" class="form-label">Wersja produktu:</label>
+        <input type="text" class="form-control" id="changelogVersionInput" name="changelogVersion" placeholder="1.2.3">
+      </div>
+      <?php
+        $tableName = 'clform';
+        $columnScheme = 'code';
+        $whereValue = 'productId = ' . $_GET['pid'];
+        $resultCLForm = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+        if ( mysqli_num_rows($resultCLForm) > 0 ) {
+          $CLForm = getFieldValue($resultCLForm);
+          echo $CLForm;
+        } else {
+          echo "<div class=\"alert alert-primary\">Nie zdefiniowano kodu formularza dla produktu</div>";
+        }
+        echo "<div class=\"mb-3\">";
+        $tableName = 'bug';
+        $columnScheme = 'id,componentId,subject';
+        $whereValue = 'productId = ' . $_GET['pid'] . " AND state = 3";
+        $resultBugs = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+        if ( mysqli_num_rows($resultBugs) > 0 ) {
+          echo "<ul class=\"list-group\">";
+          while ( $rowB = mysqli_fetch_row($resultBugs) ) {
+            echo "<li class=\"list-group-item\">";
+            echo "<span class=\"form-check\"><input class=\"form-check-input\" type=\"checkbox\" name=\"changelogBugId" . $rowB[0] . "\" value=\"" . $rowB[0] . "\" id=\"changelogBugId" . $rowB[0] . "\"><label class=\"form-check-label\" for=\"changelogBugId" . $rowB[0] . "\">";
+            echo "<a href=\"?p=comments&bid=" . $rowB[0] . "\">#" . $rowB[0] . "</a>&nbsp;-&nbsp;";
+            $tableName = 'component';
+            $columnScheme = 'name';
+            $whereValue = 'id = ' .  $rowB[1];
+            $resultComp = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+            if ( mysqli_num_rows($resultComp) > 0 ) {
+              $compName = getFieldValue($resultComp);
+            } else {
+              echo "<div class=\"alert alert-danger\">Nie znaleziono komponentu o podanym identyfikatorze.</div>";
+            }
+            echo "<strong>" . $compName . "</strong>&nbsp;-&nbsp;" . $rowB[2];
+            echo "</label></span>";
+            echo "<span class=\"form-check\"><input class=\"form-check-input\" type=\"checkbox\" name=\"changelogBugIdLC" . $rowB[0] . "\" value=1 id=\"changelogBugIdLC" . $rowB[0] . "\"><label class=\"form-check-label\" for=\"changelogBugIdLC" . $rowB[0] . "\">Dołącz ostatni komentarz ze zgłoszenia</label></span>";
+            echo "</li>";
+          }
+        echo "</ul></div>";
+        }
+      ?>
+      <div class="mb-3">
+        <label for="changelogCommentTextArea" class="form-label">Komentarz</label>
+        <textarea class="form-control" id="changelogCommentTextArea" name="changelogComment" rows="2" placeholder="To jest komentarz listy zmian."></textarea>
+      </div>
+      <button type="submit" class="btn btn-primary">Wygeneruj listę zmian</button>
+    </form>
diff --git a/forms/chbugstate.php b/forms/chbugstate.php
new file mode 100644 (file)
index 0000000..5244cbf
--- /dev/null
@@ -0,0 +1,31 @@
+<form action="index.php" method="post">
+  <input type="hidden" value="<?php echo $row[0]; ?>" name="bugId">
+  <div class="row">
+    <div class="col">
+      <select class="form-select" name="chBugState">
+        <?php
+        $stateTbl = array('Przyjęty', 'Potwierdzony', 'W trakcie', 'Zakończony', 'Odrzucony', 'Do usunięcia');
+        $tableName = 'bug';
+        $columnScheme = "state";
+        $whereValue = "id = " . intval($row[0]);
+        $result4 = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+        if ( mysqli_num_rows($result4) > 0 ) {
+          $row1 = mysqli_fetch_row($result4);
+          $bugState =  $row1[0];
+          for ($i = 0; $i < count($stateTbl); $i++) {
+            if ( $i == $bugState ) {
+              echo "<option value=\"" . $bugState . "\" selected>" . $stateTbl[$bugState] . "</option>";
+              continue;
+            } else {
+              echo "<option value=\"" . $i . "\">" . $stateTbl[$i] . "</option>";
+            }
+          }
+        }
+        ?>
+      </select>
+    </div>
+    <div class="col">
+      <button type="submit" class="btn btn-primary">Zmień status</button>
+    </div>
+  </div>
+</form>
diff --git a/forms/chpasswd.php b/forms/chpasswd.php
new file mode 100644 (file)
index 0000000..632e48b
--- /dev/null
@@ -0,0 +1,28 @@
+<div class="card">
+  <div class="card-header">
+    <h4>Hasło:</h4>
+  </div>
+  <div class="card-body">
+    <form action="?p=settings" method="post">
+      <div class="row mb-3">
+        <label for="oldPassword" class="col-sm-2 col-form-label">Stare hasło:</label>
+        <div class="col-sm-10">
+          <input type="password" class="form-control" id="oldPassword" name="oldPasswd">
+        </div>
+      </div>
+      <div class="row mb-3">
+        <label for="newPassword" class="col-sm-2 col-form-label">Nowe hasło:</label>
+        <div class="col-sm-10">
+          <input type="password" class="form-control" id="newPassword" name="newPasswd">
+        </div>
+      </div>
+      <div class="row mb-3">
+        <label for="conNewPassword" class="col-sm-2 col-form-label">Potwierdź nowe hasło:</label>
+        <div class="col-sm-10">
+          <input type="password" class="form-control" id="conNewPassword" name="conNewPasswd">
+        </div>
+      </div>
+      <button type="submit" class="btn btn-primary">Zmień hasło</button>
+    </form>
+  </div>
+</div>
diff --git a/forms/delcomponent.php b/forms/delcomponent.php
new file mode 100644 (file)
index 0000000..9e72261
--- /dev/null
@@ -0,0 +1,6 @@
+<form class="row g-2" action="?p=settings" method="post">
+  <div class="col-auto">
+    <input type="hidden" name="delCid" value="<?php echo $row[0]; ?>">
+    <button type="submit" class="btn btn-danger mb-3">Usuń komponent</button>
+  </div>
+</form>
diff --git a/forms/delproduct.php b/forms/delproduct.php
new file mode 100644 (file)
index 0000000..15dadba
--- /dev/null
@@ -0,0 +1,6 @@
+<form class="row g-2" action="?p=settings" method="post">
+  <div class="col-auto">
+    <input type="hidden" name="delPid" value="<?php echo $row[0]; ?>">
+    <button type="submit" class="btn btn-danger mb-3">Usuń produkt</button>
+  </div>
+</form>
diff --git a/forms/deluser.php b/forms/deluser.php
new file mode 100644 (file)
index 0000000..1ea3d95
--- /dev/null
@@ -0,0 +1,6 @@
+<form class="row g-2" action="?p=settings" method="post">
+  <div class="col-auto">
+    <input type="hidden" name="delUid" value="<?php echo $row[0]; ?>">
+    <button type="submit" class="btn btn-danger mb-3">Usuń użytkownika</button>
+  </div>
+</form>
diff --git a/forms/editcomponent.php b/forms/editcomponent.php
new file mode 100644 (file)
index 0000000..7da7719
--- /dev/null
@@ -0,0 +1,6 @@
+<form class="row g-2" action="?p=settings" method="post">
+  <div class="col-auto">
+    <input type="hidden" name="editCid" value="<?php echo $row[0]; ?>">
+    <button type="submit" class="btn btn-primary mb-3">Edytuj komponent</button>
+  </div>
+</form>
diff --git a/forms/editproduct.php b/forms/editproduct.php
new file mode 100644 (file)
index 0000000..922bdfa
--- /dev/null
@@ -0,0 +1,6 @@
+<form class="row g-2" action="?p=settings" method="post">
+  <div class="col-auto">
+    <input type="hidden" name="editPid" value="<?php echo $row[0]; ?>">
+    <button type="submit" class="btn btn-primary mb-3">Edytuj produkt</button>
+  </div>
+</form>
diff --git a/forms/newclform.php b/forms/newclform.php
new file mode 100755 (executable)
index 0000000..d6e7232
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+  $tableName = "product";
+  $columnScheme = "id,name";
+  $whereValue = "id=" . $_POST["viewCLFPid"];
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($result) > 0 ) {
+    $row = mysqli_fetch_row($result);
+    $pid = $row[0];
+    $product = $row[1];
+  }
+?>
+
+<div class="card card-spacer">
+  <div class="card-body">
+    <?php if ( isset($product) ): ?>
+      <h5 class="card-title">Nowy formularz dla produktu: <?php echo $product; ?></h5>
+        <form action="?p=settings" method="post">
+          <input type="hidden" name="CLFPid" value="<?php echo $pid; ?>" />
+          <div class="mb-3">
+            <label for="componentDescInput" class="form-label">Kod formlarza</label>
+            <textarea class="form-control" id="CLFormCodeInput" name="CLFormCode" rows="2" placeholder="Kod HTML formlarza. Znaczniki <script> są niedozwolone."></textarea>
+          </div>
+          <button type="submit" class="btn btn-primary">Dodaj formularz</button>
+        </form> 
+      <?php else: ?>
+        <h5 class="card-title">Nowy formularz dla produktu:</h5>
+        <div class="alert alert-primary" role="alert">Nie znaleziono żadnych produktów.</div>
+      <?php endif ?>
+  </div>
+</div>
diff --git a/forms/newcomponent.php b/forms/newcomponent.php
new file mode 100644 (file)
index 0000000..7687575
--- /dev/null
@@ -0,0 +1,48 @@
+<div class="card card-spacer">
+  <div class="card-body">
+    <h5 class="card-title">Nowy komponent:</h5>
+      <?php
+        $tableName = "product";
+        $columnScheme = "id,name";
+        $whereValue = "1=1";
+        $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+        if ( mysqli_num_rows($result) > 0 ) {
+          $thereAreProducts = true;
+        } else {
+          $thereAreProducts = false;
+        }
+      ?>
+      <?php if ( $thereAreProducts == true ): ?>
+        <form action="?p=settings" method="post">
+          <div class="mb-3">
+            <label for="productSelect" class="form-label">Produkt</label>
+            <select class="form-select" aria-label="Product select" id="productSelect" name="productId">
+              <option selected>Wybierz produkt</option>
+              <?php
+                if ( mysqli_num_rows($result) > 0 ) {
+                  while ( $row = mysqli_fetch_row($result) ) {
+                   echo "<option value=" . $row[0] . ">" . $row[1] . "</option>"; 
+                  }
+                }
+              ?>
+            </select>
+          </div>
+          <div class="mb-3">
+            <label for="componentNameInput" class="form-label">Nazwa komponentu</label>
+            <input type="text" class="form-control" id="componentNameInput" name="componentName" placeholder="np. XFCE">
+          </div>
+          <div class="mb-3">
+            <label for="componentAuthorInput" class="form-label">Autor komponentu</label>
+            <input type="text" class="form-control" id="componentAuthorInput" name="componentAuthor" placeholder="np. Red Hat Inc.">
+          </div>
+          <div class="mb-3">
+            <label for="componentDescInput" class="form-label">Opis komponentu</label>
+            <textarea class="form-control" id="componentDescInput" name="componentDesc" rows="2" placeholder="np. Skrypt zarządzania cryptfs"></textarea>
+          </div>
+          <button type="submit" class="btn btn-primary">Dodaj komponent</button>
+        </form> 
+      <?php else: ?>
+        <div class="alert alert-primary" role="alert">Nie znaleziono żadnych produktów.</div>
+      <?php endif ?>
+  </div>
+</div>
diff --git a/forms/newdictionary.php b/forms/newdictionary.php
new file mode 100755 (executable)
index 0000000..c05bad4
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+  $tableName = "product";
+  $columnScheme = "id,name";
+  $whereValue = "id=" . $_POST["viewCLFPid"];
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($result) > 0 ) {
+    $rowP = mysqli_fetch_row($result);
+    $pid = $rowP[0];
+    $product = $rowP[1];
+  }
+?>
+
+<div class="card card-spacer">
+  <div class="card-body">
+    <?php if ( isset($product) ): ?>
+      <h5 class="card-title">Nowy słownik dla produktu: <?php echo $product; ?></h5>
+        <form action="?p=settings" method="post">
+          <input type="hidden" name="dictPid" value="<?php echo $pid; ?>" />
+          <input type="hidden" name="dictCLFid" value="<?php echo $row[0]; ?>" />
+          <div class="mb-3">
+            <label for="dictionaryInput" class="form-label">Słownik:</label>
+            <textarea class="form-control" id="dictionaryInput" name="dictionary" rows="2" placeholder="nazwa_pola1=>wyrażenie1,nazwa_pola2=>wyrażenie2"></textarea>
+          </div>
+          <button type="submit" class="btn btn-primary">Dodaj słownik</button>
+        </form> 
+      <?php else: ?>
+        <h5 class="card-title">Nowy słownik dla produktu:</h5>
+        <div class="alert alert-primary" role="alert">Nie znaleziono żadnych produktów.</div>
+      <?php endif ?>
+  </div>
+</div>
diff --git a/forms/newproduct.php b/forms/newproduct.php
new file mode 100644 (file)
index 0000000..944af4e
--- /dev/null
@@ -0,0 +1,20 @@
+<div class="card card-spacer">
+  <div class="card-body">
+    <h5 class="card-title">Nowy produkt:</h5>
+    <form action="?p=settings" method="post">
+      <div class="mb-3">
+        <label for="productNameInput" class="form-label">Nazwa produktu</label>
+        <input type="text" class="form-control" id="productNameInput" name="productName" placeholder="np. Trusty Tahr">
+      </div>
+      <div class="mb-3">
+        <label for="productAuthorInput" class="form-label">Autor produktu</label>
+        <input type="text" class="form-control" id="productAuthorInput" name="productAuthor" placeholder="np. Debian Project Community">
+      </div>
+      <div class="mb-3">
+        <label for="productDescriptionTextArea" class="form-label">Opis produktu</label>
+        <textarea class="form-control" id="productDescriptionTextArea" name="productDesc" rows="2" placeholder="np. Dystrybucja systemu GNU/Linux"></textarea>
+      </div>
+      <button type="submit" class="btn btn-primary">Dodaj produkt</button>
+    </form>
+  </div>
+</div>
diff --git a/forms/newuser.php b/forms/newuser.php
new file mode 100644 (file)
index 0000000..acabfb4
--- /dev/null
@@ -0,0 +1,28 @@
+<div class="card card-spacer">
+  <div class="card-body">
+    <h5 class="card-title">Nowy użytkownik:</h5> 
+    <form action="?p=settings" method="post">
+      <div class="row mb-3">
+        <label for="nuUsername" class="col-sm-2 col-form-label">Nazwa użytkownika:</label>
+        <div class="col-sm-10">
+          <input type="text" class="form-control" id="nuUsername" name="nuName">
+        </div>
+      </div>
+      <div class="row mb-3">
+        <label for="nuPassword" class="col-sm-2 col-form-label">Hasło:</label>
+        <div class="col-sm-10">
+          <input type="password" class="form-control" id="nuPassword" name="nuPass">
+        </div>
+      </div>
+      <div class="row mb-3">
+        <label for="nuRole" class="col-sm-2 col-form-label">Rola:</label>
+        <div class="col-sm-10">
+          <select class="form-select" aria-label="Default select example" id="nuRole" name="nuRole">
+            <option value="admin">Administrator</option>
+          </select>
+        </div>
+      </div>
+      <button type="submit" class="btn btn-primary">Dodaj użytkownika</button>
+    </form>
+  </div>
+</div>
diff --git a/forms/setpasswd.php b/forms/setpasswd.php
new file mode 100644 (file)
index 0000000..caa63ce
--- /dev/null
@@ -0,0 +1,10 @@
+<form class="row g-2" action="?p=settings" method="post">
+  <div class="col-auto">
+    <label for="setpasswd" class="visually-hidden">Hasło</label>
+    <input type="password" class="form-control" id="setpasswd" name="setUPasswd" placeholder="Hasło">
+    <input type="hidden" name="setUid" value="<?php echo $row[0]; ?>">
+  </div>
+  <div class="col-auto">
+    <button type="submit" class="btn btn-primary mb-3">Ustaw hasło</button>
+  </div>
+</form>
diff --git a/forms/slogan.php b/forms/slogan.php
new file mode 100644 (file)
index 0000000..08bec74
--- /dev/null
@@ -0,0 +1,23 @@
+<div class="card card-spacer">
+  <div class="card-body">
+   <h5 class="card-title">Slogan strony głównej:</h5>
+<?php
+  $tableName = 'site';
+  $columnScheme = 'slogan';
+  $whereValue = "id = 1";
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($result) > 0 ) {
+    $row = mysqli_fetch_row($result);
+    echo "<form action=\"?p=settings\" method=\"post\">";
+    echo "<div class=\"mb-3\">";
+    echo "<label for=\"sloganInput\" class=\"form-label\">Slogan:</label>";
+    echo "<input type=\"text\" class=\"form-control\" id=\"sloganInput\" name=\"siteSlogan\" value=\"" . $row[0] ."\">";
+    echo "</div>";
+    echo "<button type=\"submit\" class=\"btn btn-warning\">Zapisz slogan</button>";
+    echo "</form>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Nie znaleziono sloganu.</div>";
+  }
+?>
+  </div>
+</div>
diff --git a/frontpage.php b/frontpage.php
new file mode 100644 (file)
index 0000000..d26334b
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+  $tableName = 'site';
+  $columnScheme = 'slogan';
+  $whereValue = 'id = 1';
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($result) > 0 ) {
+    $slogan = getFieldValue($result);
+    echo "<h3>" . $slogan . "</h3>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Nie znaleziono sloganu strony</div>";
+  }
+?>
diff --git a/index.php b/index.php
new file mode 100755 (executable)
index 0000000..60ec915
--- /dev/null
+++ b/index.php
@@ -0,0 +1,80 @@
+<?php include('library.php'); ?>
+<?php include('db_conf.php'); ?>
+<?php
+  $tableName = 'site';
+  $columnScheme = 'slogan';
+  $whereValue = "id = 1";
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  $row = mysqli_fetch_row($result);
+?>
+
+<!doctype html>
+<html lang="pl">
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
+       <style>
+               .frontpage-link { 
+      color: #4286f4 !important; 
+      text-decoration: underline;
+      pointer-events: auto; 
+     }
+               .frontpage-card { margin-top: 0.5%; margin-bottom: 0.5%; }
+               .login-form-card { width: 35%; }
+    .navbar-greetings { color: rgba(0,0,0,.9) !important; pointer-events: none; }
+    .card-spacer { margin-top: 0.5%; }
+    .request-desc { word-wrap: normal; width: 25%; }
+       </style>
+        <title>BugTrack - <?php echo $row[0]; ?></title>
+  </head>
+  <body>
+    <?php include('navbar.php'); ?>
+
+         <div class="card frontpage-card">
+      <div class="card-body">
+        <?php
+          if ( isset($_GET["p"]) ) {
+            if ($_GET["p"] == "login") {
+              include('login.php');
+            } else if ($_GET["p"] == "settings") {
+              include('settings.php');
+            } else if ($_GET["p"] == "logout") {
+              include('logout.php');
+            } else if ($_GET["p"] == "siteListProducts") {
+              include('siteListProducts.php');
+            } else if ($_GET["p"] == "submit") {
+              include('submit.php');
+            } else if ($_GET["p"] == "bugs") {
+              include('bugs.php');
+            } else if ($_GET["p"] == "comments") {
+              include('comments.php');
+            } else if ($_GET["p"] == "changelog") {
+              include('changelog.php');
+            } else if ($_GET["p"] == "viewchlog") {
+              include('viewchlog.php');
+            } else {
+              include('404.php');
+            }
+          } else {
+            include('frontpage.php');
+            if ( session_status() != 2 ) { session_start(); }
+            if ( isset($_SESSION["username"]) ) {
+              if ( isset($_POST) && isset($_POST["chBugState"]) ) {
+                include('modules/chbugstate.php');
+              } 
+              include('listofbugs.php');
+            }
+            include('statistics.php'); 
+          }
+        ?>
+      </div>
+    </div>
+         <nav class="navbar navbar-expand-lg navbar-light bg-light">
+           <div class="container-fluid">
+        <a class="navbar-brand active" aria-current="page" href="http://<?php echo $_SERVER["SERVER_NAME"];?>">BugTrack - morketsmerke.org @ 2023</a>
+      </div>
+    </nav>
+    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
+  </body>
+</html>
diff --git a/install.sql b/install.sql
new file mode 100644 (file)
index 0000000..070bfa3
--- /dev/null
@@ -0,0 +1,57 @@
+CREATE USER 'bugtrack'@'localhost' IDENTIFIED BY '1234Test1234#@';
+CREATE DATABASE bugtrack;
+GRANT ALL ON bugtrack.* TO 'bugtrack'@'localhost';
+
+use bugtrack;
+
+CREATE TABLE user (
+       id int AUTO_INCREMENT PRIMARY KEY,
+       username varchar(30),
+       passwd_hash text,
+       role varchar(30)
+);
+
+CREATE TABLE product (
+  id int AUTO_INCREMENT PRIMARY KEY,
+  name varchar(30),
+  author varchar(60),
+  description text
+);
+
+CREATE TABLE component (
+  id int AUTO_INCREMENT PRIMARY KEY,
+  productId int,
+  name varchar(30),
+  author varchar(60),
+  description text,
+  FOREIGN KEY (productId) REFERENCES product(id)
+);
+
+CREATE TABLE site (
+  id int AUTO_INCREMENT PRIMARY KEY,
+  slogan text
+);
+
+CREATE TABLE bug (
+  id int AUTO_INCREMENT PRIMARY KEY,
+  productId int,
+  componentId int,
+  typeof varchar(60),
+  subject varchar(255),
+  description text,
+  state int,
+  FOREIGN KEY (productId) REFERENCES product(id),
+  FOREIGN KEY (componentId) REFERENCES component(id)
+);
+
+CREATE TABLE comment (
+  id int AUTO_INCREMENT PRIMARY KEY,
+  bugId int,
+  user varchar(60),
+  date varchar(60),
+  content text,
+  FOREIGN KEY (bugId) REFERENCES bug(id)
+);
+
+INSERT INTO user (username, passwd_hash, role) VALUES ('xf0r3m', "$2y$10$MlbeMeXc3SCoxNftEiyM9OVcuaQcucHbizX4aI0QOZguBCUkZRO0q", 'admin');
+INSERT INTO site (slogan) VALUES ('Hello, World!');
diff --git a/library.php b/library.php
new file mode 100644 (file)
index 0000000..3df56dc
--- /dev/null
@@ -0,0 +1,145 @@
+<?php
+
+function mysqliResult($connection, $result) {
+  if ( ($result === true) || (mysqli_num_rows($result) > 0) ) {
+    if ( ! isset($_SERVER["SHELL"]) ) {
+      echo "<script>console.log('Zapytanie powiodło się.')</script>";
+    }
+    return true;
+  } else {
+    echo "<script>console.log('Zapytanie nie powiodło się: " . mysqli_error($connection) . "');</script>";
+    return false;
+  }
+}
+
+function dbQuery($connection, $tableName, $columnScheme, $whereValue, $debug=0) {
+  $query = "SELECT " . $columnScheme . " FROM " . $tableName . " WHERE " . $whereValue;
+  if ( $debug == 1 ) { var_dump($query); }
+  $result = mysqli_query($connection, $query);
+  if ( mysqliResult($connection, $result) ) {
+    return $result;
+  } else {
+    echo "<script>console.log('Pobranie danych z bazy jest niemożliwe');</script>";
+  }
+
+}
+
+function getFieldValue($result) {
+  $row = mysqli_fetch_row($result);
+  return $row[0];
+}
+
+function dbUpdate($connection, $tableName, $setValue, $whereValue) {
+  $query = "UPDATE " . $tableName . " SET " . $setValue . " WHERE " . $whereValue;
+  $result = mysqli_query($connection, $query);
+  if ( mysqliResult($connection, $result) ) {
+    return $result;
+  } else {
+    echo "<script>console.log('Zmiana danych w bazie jest niemożliwa');</script>";
+  }
+
+}
+
+function dbAdd($connection, $tableName, $columnScheme, $setValues) {
+  $query = "INSERT INTO " . $tableName . " (" . $columnScheme . ") VALUES (" . $setValues . ");";
+  $result = mysqli_query($connection, $query);
+
+  if ( mysqliResult($connection, $result) ) {
+    return $result;
+  } else {
+    echo "<script>console.log('Dodanie danych do bazy jest niemożliwa');</script>";
+  }
+}
+
+function dbDel($connection, $tableName, $whereValue) {
+  $query = "DELETE FROM " . $tableName . " WHERE " . $whereValue;
+  $result = mysqli_query($connection, $query);
+
+  if ( mysqliResult($connection, $result) ) {
+    return $result;
+  } else {
+    echo "<script>console.log('Usunięcie danych z bazy jest niemożliwa');</script>";
+  }
+}
+
+function siteListProducts($connection, $page) {  
+  echo "<div class=\"card card-spacer\">
+  <div class=\"card-header\">
+    <h4>Lista produktów:</h4>
+  </div>
+  <div class=\"card-body\">";
+  $tableName = "product";
+  $columnScheme = "*";
+  $whereValue = "1=1";
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($result) > 0 ) {
+    echo "<ul class=\"list-group\">";
+    while ( $row = mysqli_fetch_row($result) ) {
+      echo "<li class=\"list-group-item\"><a href=\"?p=" . $page . "&pid=" . $row[0] ."\">";
+      echo $row[1] . "</a> (<em>". $row[2] ."</em>, <span class=\"text-muted\">" . $row[3] . "</span>)</li>";
+    }
+    echo "</ul>";
+  } else {
+    echo "<div class=\"alert alert-primary\" role=\"alert\">Nie znaleziono żadnych produktów</div>";
+  }
+  echo "</div></div>";
+}
+
+function newFormatTo80Cols($long_string, $linePrefix, $eolSign) {
+  $content = array();
+  if ( strlen($long_string) > 80 ) { 
+    $toExplode = wordwrap($long_string, 80, "|", false);
+    $exploded = explode("|", $toExplode);
+    $i=0;
+    foreach ( $exploded as $line ) {
+      $content[$i] = $linePrefix . $line . $eolSign;
+      $i += 1;
+    }
+  } else {
+    $content[0] = $linePrefix . $long_string . $eolSign;
+  }
+  return $content;
+}
+
+function presentListBugs($connection, $cond) {
+  $tableName = 'bug';
+  $columnScheme = "*";
+  $whereValue = $cond;
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($result) > 0 ) {
+    echo "<table class=\"table\">";
+    echo "<thead><tr><th scope=\"col\">#Lp.</th><th scope=\"col\">#id</th><th scope=\"col\">Produkt</th><th scope=\"col\">Komponent</th>";
+    echo "<th scope=\"col\">Rodzaj zgłosz.</th><th scope=\"col\">Temat zgłosz.</th><th scope=\"col\">Opis zgłosz.</th>";
+    echo "<th>Status zgłosz.</th></tr></thead>";
+    echo "<tbody>";
+    $n = 1;
+    while ( $row = mysqli_fetch_row($result) ) {
+      echo "<tr><td>" . $n . "</td><td><a href=\"?p=comments&bid=" . $row[0] . "\">#" . $row[0] . "</a></td><th scope=\"row\">";
+      $tableName = 'product';
+      $columnScheme = 'name';
+      $whereValue = 'id = ' . intval($row[1]);
+      $result2 = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+      echo getFieldValue($result2);
+      echo "</th><th>";
+      $tableName = 'component';
+      $columnScheme = 'name';
+      $whereValue = 'id = ' . intval($row[2]);
+      $result3 = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+      echo getFieldValue($result3);
+      echo "</th><td>" . $row[3] . "</td><td>" . $row[4] . "</td><td>" . nl2br($row[5]) . "</td>";
+      echo "<td>";
+      $stateTbl = array("Przyjęty", "Potwierdzony", "W trakcie", "Zakończony", "Odrzucony");
+      $index = $row[6];
+      echo $stateTbl[$index]; 
+      echo "</td>";
+      ++$n;
+    }
+    echo "</tbody>";
+    echo "</table>";
+  } else {
+    echo "<div class=\"alert alert-primary\" role=\"alert\">Nie znaleziono żadnych zgłoszeń w trakcie realizacji</div>";
+  }
+}
+?>
diff --git a/listofbugs.php b/listofbugs.php
new file mode 100644 (file)
index 0000000..443fa4d
--- /dev/null
@@ -0,0 +1,48 @@
+<div class="card card-spacer">
+  <div class="card-header">
+    <h4>Lista zgłoszeń:</h4>
+  </div>
+  <div class="card-body">
+<?php
+  $tableName = 'bug';
+  $columnScheme = "*";
+  $whereValue = "state < 3";
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($result) > 0 ) {
+    echo "<table class=\"table\">";
+    echo "<thead><tr><th scope=\"col\">#Lp.</th><th scope=\"col\">#id</th><th scope=\"col\">Produkt</th><th scope=\"col\">Komponent</th>";
+    echo "<th scope=\"col\">Rodzaj zgłosz.</th><th scope=\"col\">Temat zgłosz.</th><th scope=\"col\">Opis zgłosz.</th>";
+    echo "<th>Status zgłosz.</th></tr></thead>";
+    echo "<tbody>";
+    $n = 1;
+    while ( $row = mysqli_fetch_row($result) ) {
+      echo "<tr><td>" . $n . "</td><td><a href=\"?p=comments&bid=" . $row[0] . "\">#" . $row[0] . "</a></td><th scope=\"row\">";
+      $tableName = 'product';
+      $columnScheme = 'name';
+      $whereValue = 'id = ' . intval($row[1]);
+      $result2 = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+      #echo getFieldValue($result2);
+      $row2 = mysqli_fetch_row($result2);
+      echo $row2[0];
+      echo "</th><th>";
+      $tableName = 'component';
+      $columnScheme = 'name';
+      $whereValue = 'id = ' . intval($row[2]);
+      $result3 = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+      #echo getFieldValue($result3);
+      $row3 = mysqli_fetch_row($result3);
+      echo $row3[0];
+      echo "</th><td>" . $row[3] . "</td><td>" . $row[4] . "</td><td class=\"request-desc\">" . nl2br($row[5]) . "</td>";
+      echo "<td>";
+      include('forms/chbugstate.php');
+      echo "</td></tr>";
+      ++$n;
+    }
+    echo "</tbody>";
+    echo "</table>";
+  } else {
+    echo "<div class=\"alert alert-primary\" role=\"alert\">Nie znaleziono żadnych zgłoszonych błędów</div>";
+  }
+?>
+  </div>
+</div>
diff --git a/login.php b/login.php
new file mode 100644 (file)
index 0000000..efeb35d
--- /dev/null
+++ b/login.php
@@ -0,0 +1,48 @@
+<?php if (isset($_POST["login"]) && isset($_POST["pass"])): ?>
+<?php
+  $username = mysqli_real_escape_string($connection, $_POST["login"]);
+  $password = $_POST["pass"];
+  $tableName = 'user';
+  $columnScheme = 'passwd_hash';
+  $whereValue = "username = '" . $username . "';";
+       $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  $row = mysqli_fetch_row($result);
+  $passwd_hash = $row[0];
+  #var_dump($passwd_hash);
+  if ( password_verify($password, $passwd_hash) ) {
+    session_start();
+    $_SESSION['username'] = $username;
+    header("Location: index.php");
+  } else {
+    unset($_POST["login"]);
+    unset($_POST["pass"]);
+    header("Location: ?p=login&bad=1");
+  }
+?>
+<?php else: ?>
+  <?php if ( isset($_GET["bad"]) ): ?>
+    <div class="alert alert-danger" role="alert">
+      Błędna nazwa użytkownika lub hasło.
+    </div>
+  <?php endif ?>
+  <h3>Zaloguj się:</h3>
+  <div class="card-body login-form-card">
+    <form class="row" action="?p=login" method="post">
+           <div class="mb-3 row">
+                   <label for="inputLogin" class="col-sm-2 col-form-label">Login</label>
+                   <div class="col-sm-10">
+                     <input type="text" class="form-control" id="inputLogin" name="login">
+                   </div>
+           </div>
+           <div class="mb-3 row">
+             <label for="inputPassword" class="col-sm-2 col-form-label">Hasło</label>
+             <div class="col-sm-10">
+                     <input type="password" class="form-control" id="inputPassword" name="pass">
+             </div>
+           </div>
+           <div class="col-auto">
+             <button type="submit" class="btn btn-primary mb-3">Zaloguj się</button>
+           </div>
+         </form>
+  </div>
+<?php endif ?>
diff --git a/logout.php b/logout.php
new file mode 100644 (file)
index 0000000..ce95b5c
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+
+  if ( session_status() != 2 ) { session_start(); }
+  unset($_SESSION["username"]);
+  session_destroy();
+  header("Location: index.php");
+?>
diff --git a/modules/chbugstate.php b/modules/chbugstate.php
new file mode 100644 (file)
index 0000000..e0f1ba7
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+  $tableName = 'bug';
+  $columnScheme = "state";
+  $whereValue = "id = " . intval($_POST["bugId"]);
+  $newStateId = intval($_POST["chBugState"]);
+  if ( $newStateId == 5 ) {
+    $tableName = 'comment';
+    $whereValue = "bugId = " . intval($_POST["bugId"]);
+    $result = dbDel($connection, $tableName, $whereValue);
+    if ( $result == true ) {
+      echo "<div class=\"alert alert-success\" role=\"alert\">Komentarz powiązane ze zgłoszeniem usunięte</div>";
+    } else {
+      echo "<div class=\"alert alert-danger\" role=\"alert\">Komentarze powiązane ze zgłoszeniem nie zostały usunięte</div>";
+    }
+    $tableName = 'bug';
+    $whereValue = "id = " . intval($_POST["bugId"]);
+    $result = dbDel($connection, $tableName, $whereValue);
+    if ( $result == true ) {
+      echo "<div class=\"alert alert-success\" role=\"alert\">Zgłoszenie zostało usunięte</div>";
+    } else {
+      echo "<div class=\"alert alert-danger\" role=\"alert\">Zgłoszenie nie zostało usunięte</div>";
+    }
+  } else {
+    $bugResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    $bugRow = mysqli_fetch_row($bugResult);
+    $oldStateId = $bugRow[0];
+      
+
+    $setValue = "state = " . $newStateId;
+    $whereValue = 'id = ' . intval($_POST["bugId"]);
+    $result = dbUpdate($connection, $tableName, $setValue, $whereValue);
+    if ( $result == true ) {
+      echo "<div class=\"alert alert-success\" role=\"alert\">Status zgłoszenia został zmieniony</div>";
+    } else {
+      echo "<div class=\"alert alert-danger\" role=\"alert\">Status zgłoszenia nie został zmieniony</div>";
+    }
+
+    $stateTbl = array("Przyjęty", "Potwierdzony", "W trakcie", "Zakończony", "Odrzucony");
+
+    $newState = $stateTbl[$newStateId];
+    $oldState = $stateTbl[$oldStateId]; 
+
+    $tableName = "comment";
+    $columnScheme = "bugId,user,date,content";
+    $setValue = intval($_POST["bugId"]) . ",'" . $_SESSION["username"] . "','" . date("Y-m-d H:i:s") . "','Status zgłoszenia został zmieniony z <strong>" . $oldState . "</strong> na <strong>" . $newState . "</strong>'";
+    $result = dbAdd($connection, $tableName, $columnScheme, $setValue);
+  }
+?>
diff --git a/modules/chpasswd.php b/modules/chpasswd.php
new file mode 100644 (file)
index 0000000..f2a272b
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+  $whereValue="username = '" . $_SESSION["username"] . "';";
+  $result = dbQuery($connection, 'user', 'passwd_hash', $whereValue);
+  $passwd_hash = getFieldValue($result);
+  if ( password_verify($_POST["oldPasswd"],$passwd_hash) ) {
+    if ( $_POST["newPasswd"] == $_POST["conNewPasswd"] ) {
+      $setValue = "passwd_hash = '" . password_hash($_POST['newPasswd'], PASSWORD_DEFAULT) . "'";
+      $whereValue = "username = '" . $_SESSION["username"] . "';";
+      $result = dbUpdate($connection, 'user', $setValue, $whereValue);
+      if ( $result == true ) {
+        echo "<div class=\"alert alert-success\" role=\"alert\">Hasło zostało zmienione.</div>";
+      } else {
+        echo "<div class=\"alert alert-danger\" role=\"alert\">Zmiana hasła nie powiodła się.</div>";
+      }
+    } 
+  }
+?>
diff --git a/modules/delcomponent.php b/modules/delcomponent.php
new file mode 100644 (file)
index 0000000..e95c042
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+  $id = intval($_POST["delCid"]);
+  $tableName = 'component';
+  $whereValue = "id = " . $id;
+  $result = dbDel($connection, $tableName, $whereValue);
+  if ( $result == true ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Komponent został usunięty</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Komponent nie został usunięty</div>";
+  }
+?>
diff --git a/modules/delproduct.php b/modules/delproduct.php
new file mode 100644 (file)
index 0000000..893067d
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+  $id = intval($_POST["delPid"]);
+  $tableName = 'component';
+  $whereValue = "productId = " . $id;
+  $result = dbDel($connection, $tableName, $whereValue);
+  if ( $result == true ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Usunięto wszystkie komponenty produktu</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Komponenty produktu nie zostały usunięte</div>";
+  }
+
+  $tableName = 'product';
+  $whereValue = "id = " . $id;
+  $result = dbDel($connection, $tableName, $whereValue);
+  if ( $result == true ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Produkt został usunięty</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Produkt nie został usunięty</div>";
+  }
+?>
diff --git a/modules/deluser.php b/modules/deluser.php
new file mode 100644 (file)
index 0000000..9b93b72
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+  $tableName = 'user';
+  $whereValue = "id = " . intval($_POST["delUid"]);
+  $result = dbDel($connection, $tableName, $whereValue);
+  if ( $result ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Użytkownik został usunięty.</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Użytkownik nie został usunięty.</div>";
+  }
+?>
diff --git a/modules/editclform.php b/modules/editclform.php
new file mode 100755 (executable)
index 0000000..42f5819
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+  if ( isset($_POST) && isset($_POST["editCLFormCode"]) ) {
+    if ( empty($_POST["editCLFormCode"]) ) {
+      $id = intval($_POST["delCLFid"]);
+      $tableName = 'clform';
+      $whereValue = "id = " . $id;
+      $result = dbDel($connection, $tableName, $whereValue);
+      if ( $result == true ) {
+        echo "<div class=\"alert alert-success\" role=\"alert\">Kod formularza został usunięty</div>";
+      } else {
+        echo "<div class=\"alert alert-danger\" role=\"alert\">Kod formularza nie został usunięty</div>";
+      }
+    } else {
+      $tableName = "clform";
+      $setValues = "code='" . $_POST["editCLFormCode"] . "'";
+      $whereValue = "id = " . $_POST["CLFid"];
+      $result = dbUpdate($connection, $tableName, $setValues, $whereValue);
+      if ( $result == true ) {
+        echo "<div class=\"alert alert-success\" role=\"alert\">Zapisano zmiany w kodzie formularza.</div>";
+      } else {
+        echo "<div class=\"alert alert-danger\" role=\"alert\">Nie udała się zapisać zmian w kodzie formularza.</div>";
+      }
+    }
+  }
+?>
diff --git a/modules/editcomponent.php b/modules/editcomponent.php
new file mode 100644 (file)
index 0000000..55c5969
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+  if ( isset($_POST) && isset($_POST["editCompName"]) ) {
+    $tableName = "component";
+    $setValues = "productId=" . intval($_POST["editCompProductId"]) . ",name='" . $_POST["editCompName"] . "',author='" . $_POST["editCompAuthor"] . "',description='" . $_POST["editCompDesc"] . "'";
+    $whereValue = "id = " . intval($_POST["editCompId"]);
+    $result = dbUpdate($connection, $tableName, $setValues, $whereValue);
+    if ( $result == true ) {
+      echo "<div class=\"alert alert-success\" role=\"alert\">Zapisano zmiany w komponencie.</div>";
+    } else {
+      echo "<div class=\"alert alert-success\" role=\"alert\">Nie udała się zapisać zmian w komponencie.</div>";
+    }
+  } else {
+    $id = intval($_POST["editCid"]);
+    $tableName = "component";
+    $columnScheme = "productId,name,author,description";
+    $whereValue = "id = " . $id;
+    $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( mysqli_num_rows($result) > 0 ) {
+      $row1 = mysqli_fetch_row($result);
+    } else {
+      echo "<div class=\"alert alert-danger\" role=\"alert\">Nie udało się odnleźć wybranego komponentu.</div>"; 
+    }
+  }
+?>
+<?php if ( ! isset($_POST["editCompName"]) ): ?>
+<div class="card card-spacer">
+  <div class="card-body">
+    <h5 class="card-title">Nowy komponent:</h5>
+      <?php
+        $tableName = "product";
+        $columnScheme = "id,name";
+        $whereValue = "1=1";
+        $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+        if ( mysqli_num_rows($result) > 0 ) {
+          $thereAreProducts = true;
+        } else {
+          $thereAreProducts = false;
+        }
+      ?>
+        <form action="?p=settings" method="post">
+          <div class="mb-3">
+            <label for="productSelect" class="form-label">Produkt</label>
+            <select class="form-select" aria-label="Product select" id="productSelect" name="editCompProductId">
+              <option selected>Wybierz produkt</option>
+              <?php
+                if ( mysqli_num_rows($result) > 0 ) {
+                  while ( $row = mysqli_fetch_row($result) ) {
+                    if ( $row1[0] == $row[0] ) {
+                      echo "<option selected value=" . $row[0] . ">" . $row[1] . "</option>"; 
+                      continue;
+                    }
+                   echo "<option value=" . $row[0] . ">" . $row[1] . "</option>"; 
+                  }
+                }
+              ?>
+            </select>
+          </div>
+          <div class="mb-3">
+            <input type="hidden" name="editCompId" value="<?php echo $_POST["editCid"]; ?>">
+            <label for="componentNameInput" class="form-label">Nazwa komponentu</label>
+            <input type="text" class="form-control" id="componentNameInput" name="editCompName" value="<?php echo $row1[1]; ?>">
+          </div>
+          <div class="mb-3">
+            <label for="componentAuthorInput" class="form-label">Autor komponentu</label>
+            <input type="text" class="form-control" id="componentAuthorInput" name="editCompAuthor" value="<?php echo $row1[2]; ?>">
+          </div>
+          <div class="mb-3">
+            <label for="componentDescInput" class="form-label">Opis komponentu</label>
+            <textarea class="form-control" id="componentDescInput" name="editCompDesc" rows="2"><?php echo $row1[3]; ?></textarea>
+          </div>
+          <button type="submit" class="btn btn-warning">Zapisz zamiany</button>
+        </form> 
+  </div>
+</div>
+<?php endif ?>
diff --git a/modules/editdictionary.php b/modules/editdictionary.php
new file mode 100755 (executable)
index 0000000..7d7624f
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+  if ( isset($_POST) && isset($_POST["editDictionary"]) ) {
+    if ( empty($_POST["editDictionary"]) ) {
+      $id = intval($_POST["dictId"]);
+      $tableName = 'dictionary';
+      $whereValue = "id = " . $id;
+      $result = dbDel($connection, $tableName, $whereValue);
+      if ( $result == true ) {
+        echo "<div class=\"alert alert-success\" role=\"alert\">Słownik został usunięty</div>";
+      } else {
+        echo "<div class=\"alert alert-danger\" role=\"alert\">Słownik nie został usunięty</div>";
+      }
+    } else {
+      $tableName = "dictionary";
+      $setValues = "dictionary='" . $_POST["editDictionary"] . "'";
+      $whereValue = "id = " . $_POST["dictId"];
+      $result = dbUpdate($connection, $tableName, $setValues, $whereValue);
+      if ( $result == true ) {
+        echo "<div class=\"alert alert-success\" role=\"alert\">Zapisano zmiany w słowniku.</div>";
+      } else {
+        echo "<div class=\"alert alert-danger\" role=\"alert\">Nie udała się zapisać zmian w słowniku.</div>";
+      }
+    }
+  }
+?>
diff --git a/modules/editproduct.php b/modules/editproduct.php
new file mode 100644 (file)
index 0000000..be4d2af
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+  if ( isset($_POST) && isset($_POST["productId"]) ) {
+    $id = intval($_POST["productId"]);
+    $tableName = 'product';
+    $setValue = "name = '" . $_POST["productName"] . "', author='" . $_POST["productAuthor"] . "', description='" . $_POST["productDesc"] . "'";
+    $whereValue = "id = " . $id;
+    $result = dbUpdate($connection, $tableName, $setValue, $whereValue);
+    if ( $result == true ) {
+      echo "<div class=\"alert alert-success\" role=\"alert\">Zapisano zmiany w produkcie.</div>";
+    } else {
+      echo "<div class=\"alert alert-danger\" role=\"alert\">Nie udało się zapisać zmian w produkcie.</div>";
+    }
+    } else {
+    $id = intval($_POST["editPid"]);
+    $tableName = 'product';
+    $columnScheme = "*";
+    $whereValue = "id = " . $id . ";";
+    $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( $result == true ) {
+      $row = mysqli_fetch_row($result);
+    } else {
+      echo "<div class=\"alert alert-danger\" role=\"alert\">Nie można odnaleźć wybranego produktu</div>";
+    }
+  }
+?>
+<?php if ( ! isset($_POST["productId"]) ): ?>
+<div class="card card-spacer">
+  <div class="card-body">
+    <h5 class="card-title">Nowy produkt:</h5>
+    <form action="?p=settings" method="post">
+      <div class="mb-3">
+        <label for="productNameInput" class="form-label">Nazwa produktu</label>
+        <input type="hidden" name="productId" value="<?php echo $row[0]; ?>">
+        <input type="text" class="form-control" id="productNameInput" name="productName" value="<?php echo $row[1]; ?>">
+      </div>
+      <div class="mb-3">
+        <label for="productAuthorInput" class="form-label">Autor produktu</label>
+        <input type="text" class="form-control" id="productAuthorInput" name="productAuthor" value="<?php echo $row[2]; ?>">
+      </div>
+      <div class="mb-3">
+        <label for="productDescriptionTextArea" class="form-label">Opis produktu</label>
+        <textarea class="form-control" id="productDescriptionTextArea" name="productDesc" rows="2"><?php echo $row[3]; ?></textarea>
+      </div>
+      <button type="submit" class="btn btn-warning">Zapisz zmiany</button>
+    </form>
+  </div>
+</div>
+<?php endif ?>
+<?php unset($_POST); ?>  
diff --git a/modules/listclforms.php b/modules/listclforms.php
new file mode 100755 (executable)
index 0000000..27e4fe2
--- /dev/null
@@ -0,0 +1,95 @@
+<div class="card card-spacer">
+  <div class="card-body">
+    <h5 class="card-title">Formularz list zmian:</h5>
+    <div class="card card-spacer">
+      <div class="card-body">
+        <h6 class="card-title">Wybierz produkt:</h6>
+          <?php
+                $tableName = 'product';
+                $columnScheme = 'id,name';
+                $whereValue = "1=1";
+                $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+          ?>
+          <?php if( mysqli_num_rows($result) > 0): ?>
+            <form action="?p=settings" method="post">
+              <div class="mb-3">
+                <select class="form-select" aria-label="Choose product" name="viewCLFPid">
+                  <?php
+                    while ( $row = mysqli_fetch_row($result) ) {
+                      if ( isset($_POST["viewCLFPid"]) ) {
+                        if ( $_POST["viewCLFPid"] == $row[0] ) {
+                          echo "<option selected value=\"" . $_POST["viewCLFPid"] . "\">" . $row[1] . "</option>";
+                          continue;
+                        }
+                      }
+                      echo "<option value=\"" . $row[0] . "\">" . $row[1] . "</option>";
+                    }
+                  ?>
+                </select>
+              </div>
+              <button type="submit" class="btn btn-primary">Pokaż formularz</button>
+            </form>
+          <?php else: ?>
+            <div class="alert alert-primary" role="alert">Nie znaleziono żadnych produktów</div>
+          <?php endif ?>
+      </div>
+    </div>
+    <?php if ( isset($_POST) && isset($_POST["viewCLFPid"]) ): ?>
+    <?php
+      $tableName = "clform";
+      $columnScheme = "id,code";
+      $whereValue = "productId =" . intval($_POST["viewCLFPid"]);
+      $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    ?>
+      <?php if ( mysqli_num_rows($result) > 0 ): ?>
+        <?php $row = mysqli_fetch_row($result); ?>
+        <div class="card card-spacer">
+          <h6 class="card-title">Podgląd formularza:</h6>
+          <div class="card-body">
+            <?php echo $row[1]; ?>
+          </div>
+        </div>
+        <div class="card card-spacer">
+          <h6 class="card-title">Kod formularza:</h6>
+          <div class="card-body">
+            <form action="?p=settings" method="post">
+              <input type="hidden" name="CLFid" value="<?php echo $row[0]; ?>" />
+              <div class="mb-3">
+                <textarea class="form-control" id="CLFormCodeInput" name="editCLFormCode" rows="2" placeholder="Kod HTML formlarza. Znaczniki <script> są niedozwolone."><?php echo $row[1]; ?></textarea>
+              </div>
+              <button type="submit" class="btn btn-warning">Zapisz zmiany</button>
+            </form>
+          </div>
+        </div>
+        <?php
+          $tableName = "dictionary";
+          $columnScheme = "id,dictionary";
+          $whereValue = "clformId = " . $row[0];
+          $resultDict = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+        ?>
+        <?php if( mysqli_num_rows($resultDict) > 0 ): ?>
+          <?php $rowD = mysqli_fetch_row($resultDict); ?>
+        <div class="card card-spacer">
+          <h6 class="card-title">Słownik:</h6>
+          <div class="card-body">
+           <form action="?p=settings" method="post">
+              <input type="hidden" name="dictId" value="<?php echo $rowD[0]; ?>" />
+              <div class="mb-3">
+                <textarea class="form-control" name="editDict" rows="2" placeholder="nazwa_pola1=>wyrażenie1,nazwa_pola2=>wyrażenie2"><?php echo $rowD[1]; ?></textarea>
+              </div>
+              <button type="submit" class="btn btn-warning">Zapisz zmiany</button>
+            </form>
+          </div>
+        </div>
+        <?php else: ?>
+          <?php include('forms/newdictionary.php'); ?>
+        <?php endif ?>
+      <?php else: ?>
+        <div class="alert alert-primary" role="alert">Nie znaleziono formularza dla wybranego produktu</div>
+        <?php include('forms/newclform.php'); ?>
+      <?php endif ?>
+    <?php else: ?>
+      <div class="alert alert-primary" role="alert">Nie wybrano produktu</div>
+    <?php endif ?>
+  </div>
+</div>
diff --git a/modules/listcomponents.php b/modules/listcomponents.php
new file mode 100644 (file)
index 0000000..eb69065
--- /dev/null
@@ -0,0 +1,79 @@
+<div class="card card-spacer">
+  <div class="card-body">
+    <h5 class="card-title">Lista komponentów:</h5>
+    <div class="card card-spacer">
+      <div class="card-body">
+        <h6 class="card-title">Wybierz produkt:</h6>
+          <?php
+                $tableName = 'product';
+                $columnScheme = 'id,name';
+                $whereValue = "1=1";
+                $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+          ?>
+          <?php if( mysqli_num_rows($result) > 0): ?>
+            <form action="?p=settings" method="post">
+              <div class="mb-3">
+                <select class="form-select" aria-label="Choose product" name="viewCPid">
+                  <?php
+                    while ( $row = mysqli_fetch_row($result) ) {
+                      if ( isset($_POST["viewCPid"]) ) {
+                        if ( $_POST["viewCPid"] == $row[0] ) {
+                          echo "<option selected value=\"" . $_POST["viewCPid"] . "\">" . $row[1] . "</option>";
+                          continue;
+                        }
+                      }
+                      echo "<option value=\"" . $row[0] . "\">" . $row[1] . "</option>";
+                    }
+                  ?>
+                </select>
+              </div>
+              <button type="submit" class="btn btn-primary">Pokaż komponenty</button>
+            </form>
+          <?php else: ?>
+            <div class="alert alert-primary" role="alert">Nie znaleziono żadnych produktów</div>
+          <?php endif ?>
+      </div>
+    </div>
+    <?php if ( isset($_POST) && isset($_POST["viewCPid"]) ): ?>
+    <?php
+      $tableName = "component";
+      $columnScheme = "id,name,author,description";
+      $whereValue = "productId =" . intval($_POST["viewCPid"]);
+      $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    ?>
+      <?php if ( mysqli_num_rows($result) > 0 ): ?>
+        <table class="table">
+          <thead>
+            <tr>
+              <th scope="col">#Lp</th>
+              <th scope="col">Nazwa komponentu</th>
+              <th scope="col">Autor</th>
+              <th scope="col">Opis komponentu</th>
+              <th></th>
+              <th></th>
+            </tr>
+          </thead>
+          <tbody>
+            <?php
+              if ( mysqli_num_rows($result) > 0 ) {
+                $lp=1;
+                while ( $row = mysqli_fetch_row($result) ) {
+                  echo "<tr><td>" . $lp . "</td><th scope=\"row\">" . $row[1] . "</th><td>" . $row[2] . "</td><td>" . $row[3] . "</td><td>";
+                  include("forms/editcomponent.php");
+                  echo "</td><td>";
+                  include("forms/delcomponent.php");
+                  echo "</td></tr>";
+                  $lp = ++$lp;
+                }
+              }
+            ?>
+          </tbody>
+        </table>
+      <?php else: ?>
+        <div class="alert alert-primary" role="alert">Nie znaleziono komponentów dla wybranego produktu</div>
+      <?php endif ?>
+    <?php else: ?>
+      <div class="alert alert-primary" role="alert">Nie wybrano produktu</div>
+    <?php endif ?>
+  </div>
+</div>
diff --git a/modules/listproducts.php b/modules/listproducts.php
new file mode 100644 (file)
index 0000000..4c4467d
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+  echo "<div class=\"card card-spacer\"><div class=\"card-body\">
+  <h5 class=\"card-title\">Lista produktów:</h5>";
+
+  $tableName = 'product';
+  $columnScheme = '*';
+  $whereValue = "1=1";
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($result) > 0 ) {
+    echo "<table class=\"table\"><thead><tr><th scope=\"col\">#id</th>
+<th scope=\"col\">Nazwa produktu</th><th scope=\"col\">Autor</th>
+<th scope=\"col\">Opis produktu</th>
+<th scope=\"col\"></th><th scope=\"col\"></th></tr></thead><tbody>";
+    while ( $row = mysqli_fetch_row($result) ) {
+      echo "<tr><th scope=\"row\">" . $row[0] . "</th><td>" . $row[1] . "</td><td>" . $row[2] . "</td><td>" . $row[3] . "</td><td>";
+      include("forms/editproduct.php");
+      echo "</td><td>";
+      include("forms/delproduct.php");
+      echo "</td></tr>"; 
+    }
+    echo "</tbody></table>";
+  } else {
+    echo "<div class=\"alert alert-primary\" role=\"alert\">Nie znaleziono żadnych produktów.</div>";
+  }
+  echo "</div></div>";
+?>
diff --git a/modules/listusers.php b/modules/listusers.php
new file mode 100644 (file)
index 0000000..0836bde
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+  echo "<div class=\"card card-spacer\"><div class=\"card-body\">
+  <h5 class=\"card-title\">Lista użytkowników</h5>";
+
+  $tableName = 'user';
+  $columnScheme = '*';
+  $whereValue = "1=1";
+  $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+  if ( mysqli_num_rows($result) > 0 ) {
+    echo "<table class=\"table\"><thead><tr><th scope=\"col\">#id</th>
+<th scope=\"col\">Nazwa użytkownika</th><th scope=\"col\">Rola</th>
+<th scope=\"col\">Przypisz hasło</th>
+<th scope=\"col\">Usuń użytkownika</th></tr></thead><tbody>";
+    while ( $row = mysqli_fetch_row($result) ) {
+      echo "<tr><th scope=\"row\">" . $row[0] . "</th><td>" . $row[1] . "</td><td>" . $row[3] . "</td><td>";
+      include("forms/setpasswd.php");
+      echo "</td><td>";
+      include("forms/deluser.php");
+      echo "</td></tr>"; 
+    }
+    echo "</tbody></table>";
+  } else {
+    echo "<div class=\"alert alert-primary\" role=\"alert\">Nie znaleziono użytkowników!</div>";
+  }
+  echo "</div></div>";
+?>
diff --git a/modules/newclform.php b/modules/newclform.php
new file mode 100755 (executable)
index 0000000..caec98e
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+  $tableName = "clform";
+  $columnScheme = "productId,code";
+  $setValues = $_POST["CLFPid"] . ",'" . $_POST["CLFormCode"] . "'";
+  $result = dbAdd($connection, $tableName, $columnScheme, $setValues);
+  if ( $result == true ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Dodano nowy kod formularza listy zmian dla produktu</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Nie udało się dodać nowego kodu formularza</div>";
+  }
+  unset($_POST);
+?>
diff --git a/modules/newcomponent.php b/modules/newcomponent.php
new file mode 100644 (file)
index 0000000..4c48262
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+  $tableName = "component";
+  $columnScheme = "productId,name,author,description";
+  $setValues = $_POST["productId"] . ",'" . $_POST["componentName"] . "','" . $_POST["componentAuthor"] . "','" . $_POST["componentDesc"] . "'";
+  $result = dbAdd($connection, $tableName, $columnScheme, $setValues);
+  if ( $result == true ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Dodano nowy komponent dla produktu</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Nie udało się dodać nowego komponentu dla produktu</div>";
+  }
+  unset($_POST);
+?>
diff --git a/modules/newdictionary.php b/modules/newdictionary.php
new file mode 100755 (executable)
index 0000000..79cad8e
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+  $tableName = "dictionary";
+  $columnScheme = "productId,clformId,dictionary";
+  $setValues = $_POST["dictPid"] . "," . $_POST['dictCLFid'] . ",'" . $_POST["dictionary"] . "'";
+  $result = dbAdd($connection, $tableName, $columnScheme, $setValues);
+  if ( $result == true ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Dodano słownik dla produktu</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Nie udało się dodać nowego słownika</div>";
+  }
+  unset($_POST);
+?>
diff --git a/modules/newproduct.php b/modules/newproduct.php
new file mode 100644 (file)
index 0000000..a328215
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+  $tableName = 'product';
+  $columnScheme = 'name,author,description';
+  $setValues = "'" . $_POST["productName"] . "','" . $_POST["productAuthor"] . "','" . $_POST["productDesc"] . "'";
+  $result = dbAdd($connection, $tableName, $columnScheme, $setValues);
+  if ( $result ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Dodano nowy produkt.</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Nie udało się dodać produktu.</div>";
+  } 
+?>
diff --git a/modules/newuser.php b/modules/newuser.php
new file mode 100644 (file)
index 0000000..4f41fcc
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+  $tableName = 'user';
+  $columnScheme = 'username, passwd_hash, role';
+  $nuPassHash = password_hash($_POST['nuPass'], PASSWORD_DEFAULT);
+  $setValues = "'" . $_POST['nuName'] . "','" . $nuPassHash . "','" . $_POST["nuRole"] . "'";
+  $result = dbAdd($connection, $tableName, $columnScheme, $setValues);
+  if ( $result == true ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Użytkownik " . $_POST["nuName"] . " został pomyśnie utworzony.</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Utworzenie użytkownika niepowiodło się.</div>";
+  } 
+?>
diff --git a/modules/saveslogan.php b/modules/saveslogan.php
new file mode 100644 (file)
index 0000000..84d9732
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+  $tableName = 'site';
+  $setValues = "slogan ='" . mysqli_real_escape_string($connection, $_POST["siteSlogan"]) . "'";
+  $whereValue = "id = 1";
+  $result = dbUpdate($connection, $tableName, $setValues, $whereValue);
+  if ( $result == 'true ' ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Slogan strony głównej został zmieniony</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Slogan nie został zmieniony</div>";
+  }
+?>
diff --git a/modules/setpasswd.php b/modules/setpasswd.php
new file mode 100644 (file)
index 0000000..429ca1d
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+  $tableName = 'user';
+  $passwd_hash = password_hash($_POST["setUPasswd"], PASSWORD_DEFAULT);
+  $setValue = "passwd_hash = '" . $passwd_hash . "'";
+  $whereValue = "id = " . intval($_POST["setUid"]);
+  $result = dbUpdate($connection, $tableName, $setValue, $whereValue);
+  if ( $result ) {
+    echo "<div class=\"alert alert-success\" role=\"alert\">Hasło zostało pomyślnie nadane.</div>";
+  } else {
+    echo "<div class=\"alert alert-danger\" role=\"alert\">Nie udało się ustawić hasła.</div>";
+  }
+?>
diff --git a/navbar.php b/navbar.php
new file mode 100755 (executable)
index 0000000..aaaa95a
--- /dev/null
@@ -0,0 +1,28 @@
+  <nav class="navbar navbar-expand-lg navbar-light bg-light">
+         <div class="container-fluid">
+      <a class="navbar-brand active" aria-current="page" href="http://<?php echo $_SERVER["SERVER_NAME"];?>">BugTrack</a>
+      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
+      <span class="navbar-toggler-icon"></span>
+      </button>
+      <div class="collapse navbar-collapse" id="navbarNav">
+        <ul class="navbar-nav">
+          <li class="nav-item">
+            <a class="nav-link frontpage-link" href="?p=siteListProducts&site=submit">Zgłoś błąd</a>
+          </li>
+                     <li class="nav-item">
+            <a class="nav-link frontpage-link" href="?p=bugs">Zgłoszone błędy</a>
+          </li>
+            <?php
+              session_start();
+              if ( isset($_SESSION["username"]) ) {
+                echo "<li class=\"nav-item\"><a class=\"nav-link frontpage-link\" href=\"?p=siteListProducts&site=changelog\">Lista zmian</a></li>";
+                echo "<li class=\"nav-item\"><a class=\"nav-link frontpage-link\" href=\"?p=settings\">Ustawienia</a></li>";
+                echo "<li class=\"nav-item\"><span class=\"nav-link navbar-greetings\">Witaj, " . $_SESSION["username"] . "! (<a class=\"frontpage-link\" href=\"?p=logout\">Wyloguj się</a>)</span></li>";
+              } else {
+                echo "<li class=\"nav-item\"><a class=\"nav-link frontpage-link\" href=\"?p=login\">Zaloguj się</a></li>";
+              }
+            ?>
+        </ul>
+      </div>
+    </div>
+  </nav>
diff --git a/passwd.php b/passwd.php
new file mode 100644 (file)
index 0000000..855e8a5
--- /dev/null
@@ -0,0 +1,10 @@
+
+<form action="passwd.php" method="post">
+       Password: <input type="password" name="pass" />
+       <input type="submit" value="Get pass hash" />
+</form>
+<?php
+  if (isset($_POST["pass"])) {
+    echo "<h2>" . password_hash($_POST["pass"], PASSWORD_DEFAULT) . "</h2>";
+  }
+?>
diff --git a/settings.php b/settings.php
new file mode 100644 (file)
index 0000000..4053fde
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+  if ( session_status() != 2 ) {
+    session_start();
+  }
+  if ( isset($_SESSION["username"]) ) {
+    if ( isset($_POST) ) {
+      #var_dump($_POST);
+      if ( isset($_POST["oldPasswd"]) ) { include('modules/chpasswd.php'); }
+      if ( isset($_POST["nuName"]) ) { include('modules/newuser.php'); }
+      if ( isset($_POST["setUPasswd"]) ) { include('modules/setpasswd.php'); }
+      if ( isset($_POST["delUid"]) ) { include('modules/deluser.php'); }
+      if ( isset($_POST["componentName"]) ) { include('modules/newcomponent.php'); }
+      if ( isset($_POST["productId"]) ) { include('modules/editproduct.php'); }
+      if ( isset($_POST["productName"]) ) { include('modules/newproduct.php'); }
+      if ( isset($_POST["delPid"]) ) { include('modules/delproduct.php'); }
+      if ( isset($_POST["editCompId"]) ) { include('modules/editcomponent.php'); }
+      if ( isset($_POST["delCid"]) ) { include('modules/delcomponent.php'); }
+      if ( isset($_POST["siteSlogan"]) ) { include('modules/saveslogan.php'); }
+      if ( isset($_POST["CLFormCode"]) ) { include('modules/newclform.php'); }
+      if ( isset($_POST["editCLFormCode"]) ) { include('modules/editclform.php'); }
+      if ( isset($_POST["dictionary"]) ) { include('modules/newdictionary.php'); }
+      if ( isset($_POST["editDictionary"]) ) { include('modules/editdictionary.php'); }
+
+    }
+    $whereValue="username = '" . $_SESSION["username"] . "';";
+    $result = dbQuery($connection, 'user', 'role', $whereValue);
+    $row = mysqli_fetch_row($result);
+    $userRole = $row[0];
+    #var_dump($userRole);
+    include('forms/chpasswd.php');
+    if ( $userRole == "admin" ) {
+      echo "<div class=\"card card-spacer\"><div class=\"card-header\"><h4>Użytkownicy:</h4></div><div class=\"card-body\">";
+      include('forms/newuser.php');
+      include('modules/listusers.php');
+      echo "</div></div>";
+      echo "<div class=\"card card-spacer\"><div class=\"card-header\"><h4>Produkty:</h4></div><div class=\"card-body\">";
+      if ( isset($_POST) && isset($_POST["editPid"]) ) { include('modules/editproduct.php'); }
+      else { include('forms/newproduct.php'); }
+      include('modules/listproducts.php');
+      echo "</div></div>";
+      echo "<div class=\"card card-spacer\"><div class=\"card-header\"><h4>Komponenty:</h4></div><div class=\"card-body\">";
+      if ( isset($_POST) && isset($_POST["editCid"]) ) { include('modules/editcomponent.php'); }
+      else { include('forms/newcomponent.php'); }
+      include('modules/listcomponents.php');
+      echo "</div></div>";
+      echo "<div class=\"card card-spacer\"><div class=\"card-header\"><h4>Formularz listy zmian:</h4></div><div class=\"card-body\">";
+      include('modules/listclforms.php');
+      echo "</div></div>";
+      echo "<div class=\"card card-spacer\"><div class=\"card-header\"><h4>Strona główna:</h4></div><div class=\"card-body\">";
+      include('forms/slogan.php');
+      echo "</div></div>";
+
+    } 
+  } else {
+    include('403.php');
+  }
+?>
diff --git a/siteListProducts.php b/siteListProducts.php
new file mode 100644 (file)
index 0000000..90f98e7
--- /dev/null
@@ -0,0 +1,27 @@
+<!-- <div class="card card-spacer">
+  <div class="card-header">
+    <h4>Lista produktów:</h4>
+  </div>
+  <div class="card-body"> -->
+ <?php
+    siteListProducts($connection, $_GET["site"]);
+    /*
+    $tableName = "product";
+    $columnScheme = "*";
+    $whereValue = "1=1";
+    $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( mysqli_num_rows($result) > 0 ) {
+      echo "<ul class=\"list-group\">";
+      while ( $row = mysqli_fetch_row($result) ) {
+        echo "<li class=\"list-group-item\"><a href=\"?p=submit&pid=" . $row[0] ."\">";
+        echo $row[1] . "</a> (<em>". $row[2] ."</em>, <span class=\"text-muted\">" . $row[3] . "</span>)</li>";
+      }
+      echo "</ul>";
+    } else {
+      echo "<div class=\"alert alert-primary\" role=\"alert\">Nie znaleziono żadnych produktów</div>";
+    }
+    */
+  ?>
+<!--
+  </div>
+</div>-->
diff --git a/statistics.php b/statistics.php
new file mode 100644 (file)
index 0000000..2326232
--- /dev/null
@@ -0,0 +1,54 @@
+<div class="card card-spacer">
+  <div class="card-header">
+    <h4>Statystyka:</h4>
+  </div>
+  <div class="card-body">
+    <h5 class="card-title">W tej instacji BugTrack znajduje się:</h5>
+    <ul>
+      <li>
+        <?php
+          $tableName = "product";
+          $columnScheme = "COUNT(id)";
+          $whereValue = "1=1";
+          $productResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+          echo "Produktów: <strong>" . getFieldValue($productResult) . "</strong>";
+        ?>
+      </li>
+      <li>
+        <?php
+          $tableName = "component";
+          $columnScheme = "COUNT(id)";
+          $whereValue = "1=1";
+          $componentResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+          echo "Komponentów: <strong>" . getFieldValue($componentResult) . "</strong>";
+        ?>
+      </li>
+      <li>
+        <?php
+          $tableName = "bug";
+          $columnScheme = "COUNT(id)";
+          $whereValue = "1=1";
+          $allBugsResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+          echo "Zgłoszeń: <strong>" . getFieldValue($allBugsResult) . "</strong>";
+        ?>
+      </li>
+      <li>
+        <?php
+          $tableName = "bug";
+          $columnScheme = "COUNT(id)";
+          $whereValue = "state > 0 AND state < 3";
+          $openBugsResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+          echo "Zgłoszeń otwartych: <strong>" . getFieldValue($openBugsResult) . "</strong>";
+        ?>
+      </li>
+      <li>
+        <?php
+          $tableName = "bug";
+          $columnScheme = "COUNT(id)";
+          $whereValue = "state >= 3";
+          $closedBugsResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+          echo "Zgłoszeń zamkniętych: <strong>" . getFieldValue($closedBugsResult) . "</strong>";
+        ?>
+      </li>
+  </div>
+</div>
diff --git a/submit.php b/submit.php
new file mode 100644 (file)
index 0000000..4bbcd39
--- /dev/null
@@ -0,0 +1,108 @@
+<?php
+  if ( isset($_POST) && isset($_POST["submitProductId"]) ) {
+    $tableName = 'bug';
+    $columnScheme = "productId,componentId,typeof,subject,description,state";
+    $setValues = intval($_POST["submitProductId"]) . "," . intval($_POST["submitCompId"]) . ",'" . mysqli_real_escape_string($connection, htmlspecialchars($_POST["submitTypeOf"])) . "','" . mysqli_real_escape_string($connection, htmlspecialchars($_POST["submitSubject"])) . "','" . mysqli_real_escape_string($connection, htmlspecialchars($_POST["submitDesc"])) . "',0";
+    $result = dbAdd($connection, $tableName, $columnScheme, $setValues);
+    if ( $result == true ) {
+      echo "<div class=\"alert alert-success\" role=\"alert\">Zgłoszenie zostało przyjęte. Niebawem pojawi się na stronie zgłoszonych problemów</div>";
+    } else {
+      echo "<div class=\"alert alert-danger\" role=\"alert\">Zgłosznie nie zostało przyjęte.</div>";
+    }
+    $tableName = 'bug';
+    $columnScheme = "id";
+    $whereValue = "1=1 ORDER BY id DESC";
+    $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( mysqli_num_rows($result) > 0 ) {
+      $row = mysqli_fetch_row($result);
+      $bugId = $row[0];
+    }
+    
+    $tableName = 'product';
+    $columnScheme = 'name,description';
+    $whereValue = "id = " . intval($_POST["submitProductId"]);
+    $productResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( mysqli_num_rows($productResult) > 0 ) {
+      $productRow = mysqli_fetch_row($productResult);
+    }
+    
+    $tableName = 'component';
+    $columnScheme = 'name,description';
+    $whereValue = "id = " . intval($_POST["submitCompId"]);
+    $componentResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+    if ( mysqli_num_rows($componentResult) > 0 ) {
+      $componentRow = mysqli_fetch_row($componentResult);
+    }
+
+    $tableName = "comment";
+    $columnScheme = 'bugId,user,date,content';
+    if ( session_status() != 2 ) { session_start(); }
+    if ( isset($_SESSION["username"]) ) { $userName = $_SESSION["username"]; }
+    else { $userName = $_SERVER["REMOTE_ADDR"]; }
+    $setValue = intval($bugId) . ",'" . $userName . "','" . date("Y-m-d H:i:s") . "','Utworzono zgłoszenie.<br /><br /><strong>Produkt:</strong> " . $productRow[0] . " (" . $productRow[1] . ")<br /><strong>Komponent:</strong> " . $componentRow[0] . " (" . $componentRow[1] . ")<br /><strong>Rodzaj zgłoszenia:</strong> " . mysqli_real_escape_string($connection, htmlspecialchars($_POST["submitTypeOf"])) . "<br /><strong>Temat: </strong>" . mysqli_real_escape_string($connection, htmlspecialchars($_POST["submitSubject"])) . "<br /><strong>Opis zgłoszenia:</strong><br />" . mysqli_real_escape_string($connection, htmlspecialchars($_POST["submitDesc"])) . "'";
+    $result = dbAdd($connection, $tableName, $columnScheme, $setValue);
+    if ( $result == true ) { 
+      echo "<div class=\"alert alert-success\" role=\"alert\">Zgłoszenie zostało również zapisane jako pierwszy komentarz</div>";
+    } else {
+      echo "<div class=\"alert alert-danger\" role=\"alert\">Zgłoszenie nie zostało zapisane.</div>";
+    }
+  }
+?>
+<div class="card card-spacer">
+  <div class="card-header">
+    <h4>Zgłoś błąd:</h4>
+  </div>
+  <div class="card-body">
+    <form action="?p=submit&pid=<?php echo intval($_GET["pid"]); ?>" method="post">
+      <div class="mb-3">
+        <label for="productReadonlySelect" class="form-label">Produkt:</label>
+        <select class="form-select" id="productReadonlySelect" name="submitProductId" readonly>
+          <?php
+            $productId = intval($_GET["pid"]);
+            $tableName = "product";
+            $columnScheme = "name,description";
+            $whereValue = "id = " . $productId;
+            $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+            if ( mysqli_num_rows($result) > 0 ) {
+              $row = mysqli_fetch_row($result);
+              echo "<option value=\"" . $productId . "\" selected>" .  $row[0] . " (" . $row[1] . ")</option>";
+            }
+          ?>
+        </select>
+      </div>
+      <div class="mb-3">
+        <label for="productComponentsSelect" class="form-label">Komponent:</label>
+        <select class="form-select" id="productComponentSelect" name="submitCompId">
+          <option></option>
+          <?php
+            $tableName = "component";
+            $columnScheme = "id,name,description";
+            $whereValue = "productId = " . $productId;
+            $result = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+            if ( mysqli_num_rows($result) > 0 ) {
+              while ( $row = mysqli_fetch_row($result) ) {
+                echo "<option value=\"" . $row[0] . "\">" . $row[1] . " (" . $row[2] . ")</option>";
+              }
+            }
+          ?>
+        </select>
+      </div>
+      <div class="mb-3">
+        <label for="typeOfSubmitSelect" class="form-label">Rodzaj zgłoszenia:</label>
+        <select class="form-select" id="typeOfSubmitSelect" name="submitTypeOf">
+          <option value="problem">problem</option>
+          <option value="ulepszenie">ulepszenie</option>
+        </select>
+      </div>
+      <div class="mb-3">
+        <label for="submitSubjectInput" class="form-label">Temat zgłoszenia:</label>
+        <input type="text" class="form-control" id="submitSubjectInput" name="submitSubject">
+      </div>
+      <div class="mb-3">
+        <label for="submitDescription" class="form-label">Opis zgłoszenia:</label>
+        <textarea class="form-control" id="submitDescription" name="submitDesc" rows="2"></textarea>
+      </div> 
+      <button type="submit" class="btn btn-primary">Zgłoś</button>
+    </form>
+  </div>
+</div>
diff --git a/viewchlog.php b/viewchlog.php
new file mode 100755 (executable)
index 0000000..c6b0819
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+$pathElements = explode("/", $_GET["path"]);
+$productName = $pathElements[1];
+$version = $pathElements[2];
+?>
+<div class="card card-spacer">
+  <div class="card-header">
+    <h4>Lista zmian dla wersji <?php echo $version ?> produktu <?php echo $productName; ?>:</h4>
+  </div>
+  <div class="card-body">
+    <?php
+      include($_GET["path"] . ".html");
+    ?>
+  </div>
+</div>