commit c31f418f1850127c841506a00e42dda93ee516e2
Author: hard456 <janpalcut@seznam.cz>
Date:   Mon Jun 10 18:26:24 2019 +0200

    Re #7580 správa zdrojů

diff --git a/old/html/multidic/app/webroot/administration/add_source.php b/old/html/multidic/app/webroot/administration/add_source.php
index 8c1e16b..bf89986 100644
--- a/old/html/multidic/app/webroot/administration/add_source.php
+++ b/old/html/multidic/app/webroot/administration/add_source.php
@@ -1,22 +1,22 @@
 <?php
 require_once("./functions/dictionary.php");
 
-if (!Empty($action) && $action == "insert_new_source") {
+if(isset($_REQUEST['submit_btn'])){
   require_once("./administration/source.php");
   
   $zobrazit_znovu = true;
   
-  if (Empty($title)) {
+  if (Empty(@$_REQUEST['title'])) {
     print_hlasku("Název musíte vyplnit");
   }
-  else if (Empty($from_page)) {
+  else if (Empty(@$_REQUEST['from_page'])) {
     print_hlasku("Od stránky musíte vyplnit");
   }
-  else if (Empty($to_page)) {
+  else if (Empty(@$_REQUEST['to_page'])) {
     print_hlasku("Do stránky musíte vyplnit");
   }
   else {
-    insert_source($title, $subtitle, $place, $publication, $publication_no, $from_page, $to_page, $language, $year);
+    insert_source(@$_REQUEST['title'], @$_REQUEST['subtitle'], @$_REQUEST['place'], @$_REQUEST['publication'], @$_REQUEST['publication_no'], @$_REQUEST['from_page'], @$_REQUEST['to_page'], @$_REQUEST['language'], @$_REQUEST['year']);
     $zobrazit_znovu = false;
   }
 }
@@ -28,33 +28,7 @@ function znova($string) {
 }
 
 ?>
-<script language="JavaScript">
-	function setFocus(object)
-	{
-	   	object.focus();
-	   	object.select();
-	}
 
-  function validate_new_source_form(form) {
-    new_source_form = form;
-    if (new_source_form.title.value == "") {
-      alert("Položku musite vyplnit.");
-      setFocus(new_source_form.title);
-      return false;
-    }
-    if (new_source_form.from_page.value == "") {
-      alert("Položku musite vyplnit.");
-      setFocus(new_source_form.from_page);
-      return false;
-    }
-    if (new_source_form.to_page.value == "") {
-      alert("Položku musite vyplnit.");
-      setFocus(new_source_form.to_page);
-      return false;
-    }
-    return true;
-  }
-</script>
 <table>
     <thead align="center"> <h3 class="nadpis2">Vlož nový zdroj</h3> </thead>
     <tbody>
@@ -62,31 +36,31 @@ function znova($string) {
       <table border="0">
       <tr class="akt">
         <td>titul*</td>
-        <td><input type="text" name="title"  size="50" maxlength="100"<?php znova($title)?>/></td>
+        <td><input type="text" name="title"  size="50" maxlength="100"<?php znova(@$_REQUEST['title'])?>/></td>
       </tr>
       <tr class="akt">
         <td>podtitul</td>
-        <td><input type="text" name="subtitle"  size="50" maxlength="100"<?php znova($subtitle)?>/></td>
+        <td><input type="text" name="subtitle"  size="50" maxlength="100"<?php znova(@$_REQUEST['subtitle'])?>/></td>
       </tr>
       <tr class="akt">
         <td>místo</td>
-        <td><input type="text" name="place"  size="50" maxlength="100"<?php znova($place)?>/></td>
+        <td><input type="text" name="place"  size="50" maxlength="100"<?php znova(@$_REQUEST['place'])?>/></td>
       </tr>
       <tr class="akt">
         <td>publikace</td>
-        <td><input type="text" name="publication"  size="50" maxlength="100"<?php znova($publication)?>/></td>
+        <td><input type="text" name="publication"  size="50" maxlength="100"<?php znova(@$_REQUEST['publication'])?>/></td>
       </tr>
       <tr class="akt">
         <td>publikační číslo</td>
-        <td><input type="text" name="publication_no"  size="50" maxlength="30"<?php znova($publication_no)?>/></td>
+        <td><input type="text" name="publication_no"  size="50" maxlength="30"<?php znova(@$_REQUEST['publication_no'])?>/></td>
       </tr>
       <tr class="akt">
         <td>od strany*</td>
-        <td><input type="text" name="from_page"  size="50" maxlength="100"<?php znova($from_page)?>/></td>
+        <td><input type="text" name="from_page"  size="50" maxlength="100"<?php znova(@$_REQUEST['from_page'])?>/></td>
       </tr>
       <tr class="akt">
         <td>do strany*</td>
-        <td><input type="text" name="to_page"  size="50" maxlength="100"<?php znova($to_page)?>/></td>
+        <td><input type="text" name="to_page"  size="50" maxlength="100"<?php znova(@$_REQUEST['to_page'])?>/></td>
       </tr>
       <tr class="akt">
         <td>jazyk</td>
@@ -94,22 +68,15 @@ function znova($string) {
       </tr>
       <tr class="akt">
         <td>rok</td>
-        <td><input type="text" name="year"  size="50" maxlength="4"<?php znova($year)?>/></td>
+        <td><input type="text" name="year"  size="50" maxlength="4"<?php znova(@$_REQUEST['year'])?>/></td>
       </tr>
       <tr class="nadpis_sekce">
         <td>
-          <input type="hidden" name="action" value="insert_new_source">
         </td>
-        <td><input type="submit" value="Vlož"></td>
+        <td><input type="submit" value="Vlož" name="submit_btn"></td>
       </tr>
     </form>
     </tbody>
   </table>
-  
-  <script language="javascript">
-				<!--
-					var focus = document.new_source_form.title;
-  				focus.focus();
-				-->
-  </script>
+
 
diff --git a/old/html/multidic/app/webroot/administration/delete_author_of_source.php b/old/html/multidic/app/webroot/administration/delete_author_of_source.php
index 0b4f2aa..087364d 100644
--- a/old/html/multidic/app/webroot/administration/delete_author_of_source.php
+++ b/old/html/multidic/app/webroot/administration/delete_author_of_source.php
@@ -4,12 +4,14 @@
   require_once("./classes/db.php");
   
   $spojeni = new DB_Sql();
-  $dotaz = "DELETE FROM author_of_source WHERE \"IDsource\" = $source_id AND \"IDauthor\" = $author_id";
+  $dotaz = "DELETE FROM author_of_source WHERE IDsource = $source_id AND IDauthor = $author_id";
   $spojeni->query($dotaz);
   if ($spojeni->connection->errno != 0) {
     print_hlasku("Autora se nepodařilo odebrat");
   }
-  print_hlasku("Autor odebrán");
+  else{
+    print_hlasku("Autor odebrán");
+  }
   echo_zpet_do_zdroju();
   
 ?>
diff --git a/old/html/multidic/app/webroot/administration/edit_source.php b/old/html/multidic/app/webroot/administration/edit_source.php
index 221abf4..d22487a 100644
--- a/old/html/multidic/app/webroot/administration/edit_source.php
+++ b/old/html/multidic/app/webroot/administration/edit_source.php
@@ -3,70 +3,44 @@
 
 $vypis_edit = true;
 
-if (!Empty($action) && $action == "edit_source") {
+if(isset($_REQUEST['submit_btn'])){
   
-  if (Empty($title)) {
+  if (Empty(@$_REQUEST['title'])) {
     print_hlasku("Název musíte vyplnit");
   }
-  else if (Empty($from_page)) {
+  else if (Empty(@$_REQUEST['from_page'])) {
     print_hlasku("Od stránky musíte vyplnit");
   }
-  else if (Empty($to_page)) {
+  else if (Empty(@$_REQUEST['to_page'])) {
     print_hlasku("Do stránky musíte vyplnit");
   }
   else {
-    update_source($title, $subtitle, $place, $publication, $publication_no, 
-                  $from_page, $to_page, $language, $year, $source_id);
+    update_source(@$_REQUEST['title'], @$_REQUEST['subtitle'], @$_REQUEST['place'], @$_REQUEST['publication'], @$_REQUEST['publication_no'],
+        @$_REQUEST['from_page'], @$_REQUEST['to_page'], @$_REQUEST['language'], @$_REQUEST['year'], @$_REQUEST['source_id']);
     //print_table_of_source();
     $vypis_edit = false;
   }
 }
-if($vypis_edit){
-  
-  $Record          = get_source($source_id);
-  $title           = $Record[1];
-  $subtitle        = $Record[2];
-  $place           = $Record[3];
-  $publication     = $Record[4];
-  $publication_no  = $Record[5];
-  $from_page       = $Record[6];
-  $to_page         = $Record[7];
-  $language        = $Record[8];
-  $year            = $Record[9];
-
+if($vypis_edit)
+{
+    $Record = get_source(@$_REQUEST['source_id']);
+    $title = $Record[1];
+    $subtitle = $Record[2];
+    $place = $Record[3];
+    $publication = $Record[4];
+    $publication_no = $Record[5];
+    $from_page = $Record[6];
+    $to_page = $Record[7];
+    $language = $Record[8];
+    $year = $Record[9];
 
+}
 ?>
-<script language="JavaScript">
-	function setFocus(object)
-	{
-	   	object.focus();
-	   	object.select();
-	}
 
-  function validate_edit_source_form(form) {
-    new_source_form = form;
-    if (new_source_form.title.value == "") {
-      alert("Položku musite vyplnit.");
-      setFocus(new_source_form.title);
-      return false;
-    }
-    if (new_source_form.from_page.value == "") {
-      alert("Položku musite vyplnit.");
-      setFocus(new_source_form.from_page);
-      return false;
-    }
-    if (new_source_form.to_page.value == "") {
-      alert("Položku musite vyplnit.");
-      setFocus(new_source_form.to_page);
-      return false;
-    }
-    return true;
-  }
-</script>
 <table>
     <thead align="center"> <h3 class="nadpis2">Uprav zdroj</h3> </thead>
     <tbody>
-    <form action="" method="POST" name="edit_source_form" onSubmit="return validate_edit_source_form(this)">
+    <form action="" method="POST">
       <table border="0">
       <tr class="akt">
         <td>titul*</td>
@@ -106,21 +80,11 @@ if($vypis_edit){
       </tr>
       <tr class="nadpis_sekce">
         <td>
-          <input type="hidden" name="action" value="edit_source">
-          <input type="hidden" name="source_id" value="<?php echo $source_id?>">
+          <input type="hidden" name="source_id" value="<?php echo @$_REQUEST['source_id']?>">
         </td>
-        <td><input type="submit" value="Uprav"></td>
+        <td><input type="submit" value="Uprav" name="submit_btn"></td>
       </tr>
     </form>
     </tbody>
   </table>
-  
-  <script language="javascript">
-				<!--
-					var focus = document.edit_source_form.title;
-  				focus.focus();
-				-->
-  </script>
-<?php
-  }//end of else
-?>
+
diff --git a/old/html/multidic/app/webroot/administration/edit_user.php b/old/html/multidic/app/webroot/administration/edit_user.php
index 79330e3..8540e11 100644
--- a/old/html/multidic/app/webroot/administration/edit_user.php
+++ b/old/html/multidic/app/webroot/administration/edit_user.php
@@ -49,7 +49,7 @@ if($vypis_edit)
 <table>
     <thead align="center"> <h3 class="nadpis2">Uprav uživatele</h3> </thead>
     <tbody>
-    <form action="" method="POST" name="edit_user_form">
+    <form action="" method="POST">
       <table border="0">
       <tr class="akt">
         <td>jméno*</td>
diff --git a/old/html/multidic/app/webroot/administration/list_source.php b/old/html/multidic/app/webroot/administration/list_source.php
index 4ba7845..9524958 100644
--- a/old/html/multidic/app/webroot/administration/list_source.php
+++ b/old/html/multidic/app/webroot/administration/list_source.php
@@ -2,12 +2,12 @@
 
 require_once("./administration/source.php");
 
-if (!Empty($action) && $action == "delete_source") {
+if(isset($_REQUEST['delete-btn'])){
   $coun_true = 0;
   $coun_false = 0;
-  if (Is_Array($smaz)) {
-    for (Reset($smaz); Current($smaz); Next($smaz)) {
-      if (delete_source(Key($smaz))) $coun_true++;
+  if (Is_Array($_REQUEST['smaz'])) {
+    for (Reset($_REQUEST['smaz']); Current($_REQUEST['smaz']); Next($_REQUEST['smaz'])) {
+      if (delete_source(Key($_REQUEST['smaz']))) $coun_true++;
       else $coun_false++;
     }
   }
@@ -18,8 +18,8 @@ if (!Empty($action) && $action == "delete_source") {
 }
 
 
-if (!Empty($serad)) {
-  print_table_of_source($order, $od, $limit);
+if (!Empty($_REQUEST['serad'])) {
+  print_table_of_source(@$_REQUEST['order'], @$_REQUEST['od'], @$_REQUEST['limit']);
 }
 else {
   print_table_of_source();
diff --git a/old/html/multidic/app/webroot/administration/list_user.php b/old/html/multidic/app/webroot/administration/list_user.php
index e783ffc..620652c 100644
--- a/old/html/multidic/app/webroot/administration/list_user.php
+++ b/old/html/multidic/app/webroot/administration/list_user.php
@@ -2,11 +2,8 @@
 
 require_once("./administration/user.php");
 
-
-
 if(isset($_REQUEST['delete-btn'])){
 
-
   $coun_true = 0;
   $coun_false = 0;
   if (Is_Array($_REQUEST['smaz'])) {
diff --git a/old/html/multidic/app/webroot/administration/source.php b/old/html/multidic/app/webroot/administration/source.php
index 1ab8745..379cc4c 100644
--- a/old/html/multidic/app/webroot/administration/source.php
+++ b/old/html/multidic/app/webroot/administration/source.php
@@ -27,10 +27,10 @@ function get_row_of_table($Record, $od = 1, $do = 2) {
 function get_authors_of_source($IDsource) {
   require_once("./classes/db.php");
   $spojeni = new DB_Sql();
-  $dotaz = "SELECT a.name, a.surname, a.\"IDauthor\"
+  $dotaz = "SELECT a.name, a.surname, a.IDauthor
             FROM author_of_source f, author a 
-            WHERE f.\"IDsource\" = '$IDsource'
-              AND f.\"IDauthor\" = a.\"IDauthor\"";
+            WHERE f.IDsource= $IDsource
+              AND f.IDauthor = a.IDauthor";
   $spojeni->query($dotaz);
   $navrat = "";
   while ($spojeni->next_record()) {
@@ -44,7 +44,7 @@ function get_authors_of_source($IDsource) {
 function get_pocet_zdroju() {
   require_once("./classes/db.php");
   $spojeni = new DB_Sql();
-  $dotaz = "SELECT \"IDsource\" FROM source ";
+  $dotaz = "SELECT IDsource FROM source";
   $spojeni->query($dotaz);
   return $spojeni->num_rows();
 }
@@ -118,28 +118,27 @@ return "<tr class=\"nadpis_sekce\">
 }
 
 function get_foot_of_table() {
-  return '<tr class="nadpis_sekce"><td> <input type="submit" name="delete" value="Smaž"></td>
+  return '<tr class="nadpis_sekce"><td> <input type="submit" name="delete-btn" value="Smaž"></td>
   <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>';
 }
 
 function print_table_of_source($order = "IDsource", $od = 0, $limit = 30) {
   require_once("./classes/db.php");
   $spojeni = new DB_Sql();
-  $dotaz = "SELECT * FROM source ORDER BY \"$order\" OFFSET $od LIMIT $limit";
+  $dotaz = "SELECT * FROM source ORDER BY $order LIMIT $od, $limit";
   $radky = $spojeni->query($dotaz);
   $navrat = "<h3 class=\"nadpis2\">Výpis zdrojů</h3>";
   $navrat .= get_razeni($order, $od, $limit);
   $navrat .= "<table><form action=\"\" method=\"post\">";
   $navrat .= get_header_of_table();
+
   while ($spojeni->next_record()) {
-    $navrat .= get_row_of_table($spojeni->Record, 1, 10);
+    $navrat .= get_row_of_table($radky->fetch_array(), 1, 10);
   }
   $navrat .= get_foot_of_table();
-  $navrat .= '<input type="hidden" name="action" value="delete_source">';
+  $navrat .= '<input type="hidden" name="action" value="delete-btn">';
   $navrat .= "</form></table>";
   echo $navrat;
-
-  
 }
 
 
@@ -147,15 +146,15 @@ function insert_source($title,$subtitle,$place,$publication,$publication_no,$fro
   require_once("./classes/db.php");
   $spojeni = new DB_Sql();
   
-  $dotaz = "INSERT INTO source (\"title\", 
-                                \"subtitle\", 
-                                \"place\",
-                                \"publication\",
-                                \"publication_no\", 
-                                \"from_page\",
-                                \"to_page\",
-                                \"language\",
-                                \"year\") 
+  $dotaz = "INSERT INTO source (title, 
+                                subtitle, 
+                                place,
+                                publication,
+                                publication_no, 
+                                from_page,
+                                to_page,
+                                language,
+                                year) 
                        VALUES ('$title',
                                '$subtitle',
                                '$place',
@@ -180,7 +179,7 @@ function possible_to_delete_source($source_id) {
 
   require_once("./classes/db.php");
   $spojeni = new DB_Sql();
-  $dotaz = "SELECT * FROM author_of_source WHERE \"IDsource\" = '$source_id'";
+  $dotaz = "SELECT * FROM author_of_source WHERE IDsource = $source_id";
   $spojeni->query($dotaz);
   if ($spojeni->connection->errno != 0) {
     print_hlasku($spojeni->Error);
@@ -189,7 +188,7 @@ function possible_to_delete_source($source_id) {
   if ($spojeni->num_rows() == 0)
     $jedna = true;
     
-  $dotaz = "SELECT * FROM dict WHERE source = '$source_id'";
+  $dotaz = "SELECT * FROM dict WHERE source = $source_id";
   $spojeni->query($dotaz);
   if ($spojeni->connection->errno != 0) {
     print_hlasku($spojeni->Error);
@@ -208,12 +207,12 @@ function delete_source($ID) {
   }
   require_once("./classes/db.php");
   $spojeni = new DB_Sql();
-  $dotaz = "DELETE FROM source WHERE \"IDsource\" = $ID";
+  $dotaz = "DELETE FROM source WHERE IDsource = $ID";
   $spojeni->query($dotaz);
   if ($spojeni->connection->errno != 0) {
     return false;
   }
-  $dotaz = "DELETE FROM author_of_source WHERE \"IDsource\" = $ID";
+  $dotaz = "DELETE FROM author_of_source WHERE Dsource = $ID";
   $spojeni->query($dotaz);
   if ($spojeni->connection->errno != 0) {
     return false;
@@ -235,7 +234,7 @@ function update_source($title, $subtitle, $place, $publication, $publication_no,
                             to_page = '$to_page',
                             language = '$language',
                             year = '$year'
-                            WHERE \"IDsource\" = $source_id";
+                            WHERE IDsource = $source_id";
   $spojeni->query($dotaz);
   if ($spojeni->connection->errno != 0) {
     print_hlasku("Zdroj se nepodařilo upravit.");
@@ -251,12 +250,9 @@ function update_source($title, $subtitle, $place, $publication, $publication_no,
 function get_source($source_id) {
   require_once("./classes/db.php");
   $spojeni = new DB_Sql();
-  $dotaz = "SELECT * FROM source WHERE \"IDsource\" LIKE '$source_id'";
+  $dotaz = "SELECT * FROM source WHERE IDsource LIKE $source_id";
   $radky = $spojeni->query($dotaz);
-
-  $spojeni->next_record();
-  
-  return $spojeni->Record;
+  return $spojeni->next_record();
 }
 
 
