commit 556ea52a6061ef28e824a00c505f1f04843a7bb7
Author: Jan Šedivý <honza.seeda@gmail.com>
Date:   Mon Jun 10 15:59:15 2019 +0200

    Re #7580 správa testů ve slovníku

diff --git a/old/html/multidic/app/webroot/administration.php b/old/html/multidic/app/webroot/administration.php
index 5415a57..1bce9ea 100644
--- a/old/html/multidic/app/webroot/administration.php
+++ b/old/html/multidic/app/webroot/administration.php
@@ -27,7 +27,7 @@ if (!kontrola_pristupu(2)) {
 
    <div class="nadpis_sekce">
      <i>Přihlášen:</i><br />
-     <?php echo "".$ses_name." ".$ses_surname."\n"?>
+     <?php echo "".@$_REQUEST['ses_name']." ".@$_REQUEST['ses_surname']."\n"?>
      <br />
      <?php if(kontrola_pristupu(3)) echo "Administrátor";
            else echo "Uživatel (smí i zapisovat)";?>
@@ -156,7 +156,7 @@ if (!kontrola_pristupu(2)) {
    
   // pr($_);
    
-  switch($_REQUEST['nav_id']) {
+  switch(@$_REQUEST['nav_id']) {
     case("add_user") :
       require_once($cesta."add_user.php");
     break;
diff --git a/old/html/multidic/app/webroot/administration/add_test.php b/old/html/multidic/app/webroot/administration/add_test.php
index 3509616..741f1d3 100644
--- a/old/html/multidic/app/webroot/administration/add_test.php
+++ b/old/html/multidic/app/webroot/administration/add_test.php
@@ -13,6 +13,8 @@ require_once("./administration/test.php");
       echo $string;
   }
 
+$language = @$_REQUEST['language'];
+$source = @$_REQUEST['source'];
 
 if (Empty($language) || $language == "") {
   $krok = 0;
@@ -77,7 +79,14 @@ switch ($krok) {
 
   case (2):
   
-  $zobrazit_znovu = true;  
+  $zobrazit_znovu = true;
+
+    $action = @$_REQUEST['action'];
+      $lection = @$_REQUEST['lection'];
+      $title = @$_REQUEST['title'];
+      $body = @$_REQUEST['body'];
+      $note = @$_REQUEST['note'];
+      $test_category = @$_REQUEST['test_category'];
 
     if (!Empty($action) && $action == "insert_new_test") {
 
diff --git a/old/html/multidic/app/webroot/administration/edit_test.php b/old/html/multidic/app/webroot/administration/edit_test.php
index e16d0c7..e045c4e 100644
--- a/old/html/multidic/app/webroot/administration/edit_test.php
+++ b/old/html/multidic/app/webroot/administration/edit_test.php
@@ -1,12 +1,26 @@
 <?php 
 require_once("./administration/test.php");
 $vypis_edit = true;
+
+$action = @$_REQUEST['action'];
+$test_id = @$_REQUEST['test_id'];
+
+$language = @$_REQUEST['language'];
+$source = @$_REQUEST['source'];
+
+
 if (!Empty($action) && $action == "edit_test") {
-  
-	if (Empty($lection)) {
+    $lection = @$_REQUEST['lection'];
+
+    if (Empty($lection)) {
       print_hlasku("Lekci musíte vyplnit");
     }
 	else {
+        $title = @$_REQUEST['title'];
+        $body = @$_REQUEST['body'];
+        $note = @$_REQUEST['note'];
+        $test_category = @$_REQUEST['test_category'];
+
 	    update_test($test_id, $title, $body, $note, $lection, $test_category);
 	    //echo_zpet_do_slovniku();
 	    $vypis_edit = false;
diff --git a/old/html/multidic/app/webroot/administration/list_test.php b/old/html/multidic/app/webroot/administration/list_test.php
index 9bb7757..dac3505 100644
--- a/old/html/multidic/app/webroot/administration/list_test.php
+++ b/old/html/multidic/app/webroot/administration/list_test.php
@@ -5,6 +5,14 @@ if ($cesta == "./examination/")
 else
   require_once("./administration/test.php");
 
+$nav_id = @$_REQUEST['nav_id'];
+$pomocna = @$_REQUEST['pomocna'];
+$language = @$_REQUEST['language'];
+$contrains_source = @$_REQUEST['contrains_source'];
+$contrains_lection = @$_REQUEST['contrains_lection'];
+$action = @$_REQUEST['action'];
+$test_id = @$_REQUEST['test_id'];
+
 if (Empty($language)) :
 
 
@@ -81,11 +89,11 @@ if (!Empty($nav_id) && $nav_id == "authorize_test") {
 
 if ($nav_id == "list_test") $pomocna = false;
 else if ($nav_id == "list_nonauthorized_test") $pomocna = true;
-else  $pomocna = ($nonauthorized == true);
+else  $pomocna = (@$_REQUEST['nonauthorized'] == true);
 //pr($nav_id);
 //vypis
-if (!Empty($serad)) {
-    print_table_of_test($language, $contrains_source, $contrains_lection,$pomocna, $order, $od, $limit);
+if (!Empty(@$_REQUEST['serad'])) {
+    print_table_of_test($language, $contrains_source, $contrains_lection,$pomocna, @$_REQUEST['order'], @$_REQUEST['od'], @$_REQUEST['limit']);
 }
 else {
   print_table_of_test($language, $contrains_source, $contrains_lection, $pomocna);
diff --git a/old/html/multidic/app/webroot/administration/test.php b/old/html/multidic/app/webroot/administration/test.php
index 9b3673a..719b175 100644
--- a/old/html/multidic/app/webroot/administration/test.php
+++ b/old/html/multidic/app/webroot/administration/test.php
@@ -6,9 +6,9 @@ function authorize_test($ID) {
   require_once("./classes/db.php");
   $spojeni = new DB_Sql();
   $dotaz = "UPDATE test SET autorized = true
-                        WHERE \"IDtest\" = '$ID'";
-  $spojeni->query($dotaz);
-  if ($spojeni->connection->errno != 0) {
+                        WHERE IDtest = $ID";
+  $result = $spojeni->query($dotaz);
+  if (!$result) {
     return false;
   }
   return true;
@@ -26,16 +26,16 @@ function get_header_of_table() {
 }
 
 function get_row_of_table($Record) {
-  global $language;
-  global $order;
-  global $od;
-  global $limit;
-  global $contrains_source;
-  global $contrains_lection;
+  $language = @$_REQUEST['language'];
+  $order = @$_REQUEST['order'];
+  $od = @$_REQUEST['od'];
+  $limit = @$_REQUEST['limit'];
+  $contrains_source = @$_REQUEST['contrains_source'];
+  $contrains_lection = @$_REQUEST['contrains_lection'];
 
   $nav_str = "language=$language&contrains_source=$contrains_source&contrains_lection=$contrains_lection";
 
-  $navrat .= "  <tr>\n";
+  $navrat = "  <tr>\n";
   $navrat .= '    <td>
                 <a href="?nav_id=list_test&action=delete_test&test_id='.$Record[0].'&'.$nav_str.'">smaž</a>
                   <!--input type="checkbox" name="smaz['.$Record[0].']" /-->';
@@ -229,7 +229,7 @@ function print_table_of_test($language = "all", $contrains_source = "all", $cont
   else $pomocna = " autorized = true";
 
   if ($language != "all")
-    $dotaz .= " WHERE language = '$language' AND $pomocna ";
+    $dotaz .= " WHERE language = $language AND $pomocna ";
   else
     $dotaz .= " WHERE $pomocna ";
 
@@ -239,14 +239,14 @@ function print_table_of_test($language = "all", $contrains_source = "all", $cont
     $dotaz .= "AND lection = '$contrains_lection'";
 
 
-  $dotaz .= " ORDER BY \"$order\" OFFSET $od LIMIT $limit";
-  
+  $dotaz .= " ORDER BY $order LIMIT $od,$limit";
+
   //pr($dotaz);
 
   $radky = $spojeni->query($dotaz);
 
-  while ($spojeni->next_record()) {
-    $navrat .= get_row_of_table($spojeni->Record);
+  while ($record = $spojeni->next_record()) {
+    $navrat .= get_row_of_table($record);
   }
   $navrat .= get_foot_of_table();
   $navrat .= "</table>";
@@ -256,23 +256,23 @@ function print_table_of_test($language = "all", $contrains_source = "all", $cont
 function get_test($id) {
   require_once("./classes/db.php");
   $spojeni = new DB_Sql();
-  $dotaz = "SELECT * FROM test WHERE \"IDtest\" = '$id'";
+  $dotaz = "SELECT * FROM test WHERE IDtest = $id";
   $radky = $spojeni->query($dotaz);
-  $spojeni->next_record();
+  $record = $spojeni->next_record();
 
-  if ($spojeni->connection->errno != 0) {
+  if (!$radky) {
     print_hlasku("Test se nepodařilo načíst.");
   }
 
-  return $spojeni->Record;
+  return $record;
 }
 
 function delete_test($ID) {
   require_once("./classes/db.php");
   $spojeni = new DB_Sql();
-  $dotaz = "DELETE FROM test WHERE \"IDtest\" = '$ID'";
-  $spojeni->query($dotaz);
-  if ($spojeni->connection->errno != 0) {
+  $dotaz = "DELETE FROM test WHERE `IDtest` = $ID";
+  $result = $spojeni->query($dotaz);
+  if (!$result) {
     return false;
   }
   return true;
@@ -287,9 +287,9 @@ function update_test($id, $title, $body, $note, $lection, $test_category) {
                             note = '".AddSlashes($note)."',
                             lection = '".AddSlashes($lection)."',
                             test_category_id = '".AddSlashes($test_category)."'
-                            WHERE \"IDtest\" = '".AddSlashes($id)."'";
-  $spojeni->query($dotaz);
-  if ($spojeni->connection->errno != 0) {
+                            WHERE IDtest = ".AddSlashes($id);
+  $result = $spojeni->query($dotaz);
+  if (!$result) {
     print_hlasku("Test se nepodařilo upravit.");
   }
   print_hlasku("Test změněn.");
@@ -303,14 +303,14 @@ function insert_test($language,$source,$lection,$title,$body,$note,$user,$test_c
   $spojeni = new DB_Sql();
   //$NOW = Date("YmdHis");
 
-  $dotaz = "INSERT INTO test (\"language\",
-                              \"source\",
-                              \"lection\",
-                              \"inserted_by\",
-                              \"title\",
-                              \"body\",
-                              \"note\",
-                              \"test_category_id\")
+  $dotaz = "INSERT INTO test (`language`,
+                              `source`,
+                              `lection`,
+                              `inserted_by`,
+                              `title`,
+                              `body`,
+                              `note`,
+                              `test_category_id`)
                     VALUES ('". AddSlashes($language)."',
                             '". AddSlashes($source)."',
                             '". AddSlashes($lection)."',
@@ -319,8 +319,8 @@ function insert_test($language,$source,$lection,$title,$body,$note,$user,$test_c
                             '". AddSlashes($body)."',
                             '". AddSlashes($note)."',
                             '". AddSlashes($test_category)."')";
-  $spojeni->query($dotaz);
-  if ($spojeni->connection->errno != 0) {
+  $result = $spojeni->query($dotaz);
+  if (!$result) {
     return false;
   }
   return true;
diff --git a/old/html/multidic/app/webroot/examination/test.php b/old/html/multidic/app/webroot/examination/test.php
index 5231339..62e83d1 100644
--- a/old/html/multidic/app/webroot/examination/test.php
+++ b/old/html/multidic/app/webroot/examination/test.php
@@ -16,8 +16,8 @@ class TestParser {
         //$found = ereg ( "^(([^\{]*)\{([^\}]*)\})*([^\{]*)" , $this->text, $tokens);
         $text = $this->text;
         
-        while(ereg('\{', $text)) {
-            $found = ereg ( "^([^\{]*)\{([^\}]*)\}(.*)" , $text, $tokens);
+        while(preg_match('#\{#', $text)) {
+            $found = preg_match( "#^([^\{]*)\{([^\}]*)\}(.*)#" , $text, $tokens);
             $parsed .= $tokens[1];
             $parsed .= $this->buildSelect($tokens[2]);
             $text = $tokens[3];
@@ -29,7 +29,7 @@ class TestParser {
     
     function buildSelect($selectString) {
         $select = '';
-        $pole = split('/', $selectString);
+        $pole = preg_split('#/#', $selectString);
         
         shuffle($pole);//zamichame!!!
         
@@ -104,12 +104,12 @@ function get_test_chooser($source) {
 function get_test($test_id) {
     require_once("./classes/db.php");
   $spojeni = new DB_Sql();
-  $dotaz  = "SELECT * FROM test WHERE \"IDtest\" = '".pg_escape_string($test_id)."' LIMIT 1 ";
+  $dotaz  = "SELECT * FROM test WHERE IDtest = '".intval($test_id)."' LIMIT 1 ";
   $radky = $spojeni->query($dotaz);
   
-  $spojeni->next_record();
+  $record = $spojeni->next_record();
   
-  return $spojeni->Record;
+  return $record;
 }
 
 function get_tests_by_category($category_id) {
diff --git a/old/html/multidic/app/webroot/functions/dictionary.php b/old/html/multidic/app/webroot/functions/dictionary.php
index 20d9545..0d8c4d0 100644
--- a/old/html/multidic/app/webroot/functions/dictionary.php
+++ b/old/html/multidic/app/webroot/functions/dictionary.php
@@ -372,11 +372,11 @@ function get_language_chooser($size = 1)
 {
     require_once("./classes/db.php");
     $spojeni = new DB_Sql();
-    $dotaz = "SELECT * FROM \"language\"";
+    $dotaz = "SELECT * FROM `language`";
     $radky = $spojeni->query($dotaz);
     $navrat = "<select name=\"language\" size=\"$size\">";
-    while ($spojeni->next_record()) {
-        $navrat .= "  <option value=\"" . $spojeni->Record[0] . "\">  " . $spojeni->Record[1] . "  </option>";
+    while ($record = $spojeni->next_record()) {
+        $navrat .= "  <option value=\"" . $record[0] . "\">  " . $record[1] . "  </option>";
     }
     $navrat .= '</select>';
     return $navrat;
@@ -386,14 +386,14 @@ function get_source_chooser($language, $nazev = "source")
 {
     require_once("./classes/db.php");
     $spojeni = new DB_Sql();
-    $dotaz = "SELECT * FROM source";
+    $dotaz = "SELECT * FROM `source`";
     if (!Empty($language))
         $dotaz .= " WHERE language = '$language'";
     $radky = $spojeni->query($dotaz);
 
     $navrat = "<select name=\"$nazev\" size=\"1\">";
-    while ($spojeni->next_record()) {
-        $navrat .= "  <option value=\"" . $spojeni->row['IDsource'] . "\">  " . $spojeni->row['title'] . " - " . $spojeni->row['subtitle'] . "  </option>";
+    while ($record = $spojeni->next_record()) {
+        $navrat .= "  <option value=\"" . $record['IDsource'] . "\">  " . $record['title'] . " - " . $record['subtitle'] . "  </option>";
     }
     $navrat .= '</select>';
     return $navrat;
@@ -453,13 +453,13 @@ function get_lection_chooser_test($source, $size = 1, $nazev = "lection")
 {
     require_once("./classes/db.php");
     $spojeni = new DB_Sql();
-    $dotaz = "SELECT lection FROM test WHERE source = '$source' GROUP BY lection ORDER BY lection ";
+    $dotaz = "SELECT lection FROM test WHERE `source` = '$source' GROUP BY lection ORDER BY lection ";
     $radky = $spojeni->query($dotaz);
     $navrat = "<select name=\"$nazev\" size=\"$size\">";
     $i = 0;
-    while ($spojeni->next_record()) {
-        $cisla[$i] = 0 + ($spojeni->Record["lection"]);
-        $hodnoty[$i] = $spojeni->Record["lection"];
+    while ($record = $spojeni->next_record()) {
+        $cisla[$i] = 0 + ($record["lection"]);
+        $hodnoty[$i] = $record["lection"];
         $i++;
     }
     if (count($cisla) <= 0) {
@@ -477,7 +477,7 @@ function get_count_chooser($source, $lection, $size = 1)
 {
     require_once("./classes/db.php");
     $spojeni = new DB_Sql();
-    $dotaz = "SELECT czech FROM dict WHERE source = '$source' AND lection = '$lection' ";
+    $dotaz = "SELECT czech FROM dict WHERE `source` = '$source' AND lection = '$lection' ";
     $radky = $spojeni->query($dotaz);
     $max = $spojeni->num_rows();
     $navrat = lang("V této lekci je ") . $max . lang(" slovíček ") . " <br /> <br />\n";
@@ -1129,12 +1129,12 @@ function getStrom($initUzel = 0)
 
     $ret = array();
 
-    while ($spojeni->next_record()) {
+    while ($record = $spojeni->next_record()) {
         $ret[] = array(
-            'id' => $spojeni->Record['id'],
-            'name' => $spojeni->Record['name'],
-            'parent_id' => $spojeni->Record['parent_id'],
-            'children' => getStrom($spojeni->Record['id']),
+            'id' => $record['id'],
+            'name' => $record['name'],
+            'parent_id' => $record['parent_id'],
+            'children' => getStrom($record['id']),
         );
     }
 
