Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 3b179f69

Přidáno uživatelem Petr Lukašík před více než 5 roky(ů)

Re #7580 vyhledávání slovníků

Zobrazit rozdíly:

old/html/multidic/app/webroot/classes/db.php
12 12
  var $Host     = "Filek.cz";
13 13
  var $Database = "aswi-dictionary";
14 14
  var $User     = "dbowner";
15
  var $Password = "db486ex12";
15
  var $Password = "";
16 16

  
17 17
  /** @var mysqli_result  */
18 18
  var $result = null;
......
117 117
  }
118 118

  
119 119
  function num_rows() {
120
    return $this->result->num_rows;
120
    if ($this->result) {
121
      return $this->result->num_rows;
122
    }else{
123
      return 0;
124
    }
121 125
  }
122 126

  
123 127
  function num_fields() {
124
    return $this->result->field_count;
128
    if ($this->result) {
129
      return $this->result->field_count;
130
    }else{
131
      return 0;
132
    }
125 133
  }
126 134

  
127 135
  function f($Name) {
old/html/multidic/app/webroot/functions/dictionary.php
1
<?php  
1
<?php
2 2
mb_internal_encoding('UTF-8');
3 3
session_start();
4 4

  
5
  require_once("./classes/db.php");
6
  require_once "./functions/new_hebrew_format.php";
5
require_once("./classes/db.php");
6
require_once "./functions/new_hebrew_format.php";
7 7

  
8 8

  
9
  define('CESTA_SLOV', "voices/word/");
10
  define('PRIPONA', ".mp3");
11
  define('CESTA_CLANKU', "voices/article/");
12
  define('CESTA_KONTEXTU', "voices/context/");
13
  define('MAX_ODEZVA', 60 * 60 * 60);
9
define('CESTA_SLOV', "voices/word/");
10
define('PRIPONA', ".mp3");
11
define('CESTA_CLANKU', "voices/article/");
12
define('CESTA_KONTEXTU', "voices/context/");
13
define('MAX_ODEZVA', 60 * 60 * 60);
14 14
/*
15 15
function register_globals($order = 'egpcs')
16 16
{
......
42 42
}
43 43
  
44 44
*/
45
  
46
  function prihlasit($jmeno, $heslo) {
47
  global $_SESSION;
48
  if (!Empty($jmeno) && !Empty($heslo)) {
49
    $DB = new DB_Sql();
50
    $result = $DB->query( "select * " .
51
    		"from user " .
52
    		"where nick = '".$DB->escape_string($jmeno)."' " .
53
    				"and pass = '".$DB->escape_string($heslo)."'");//, array($jmeno, $heslo) );
54
    if ($DB->num_rows() != 1)
55
      return false;
56
    session_regenerate_id();
57
    $_SESSION['ses_nick'] = $DB->Record['nick'];
58
    $_SESSION['ses_IDuser'] = $DB->Record['IDuser'];
59
    $_SESSION['ses_date_last_visit'] = time();
60
    $_SESSION['ses_level'] = $DB->Record['privileges'];
61
    $_SESSION['ses_name'] = $DB->Record['name'];
62
    $_SESSION['ses_surname'] = $DB->Record['surname'];
63

  
64
	pr($_SESSION);
65 45

  
66
    $number_of_usage = $DB->Record["number_of_usage"];
67
	$number_of_usage++;
68

  
69
    $dotaz = "UPDATE \"user\" SET date_last_visit = now(),
46
function prihlasit($jmeno, $heslo)
47
{
48
    global $_SESSION;
49
    if (!Empty($jmeno) && !Empty($heslo)) {
50
        $DB = new DB_Sql();
51
        $result = $DB->query("select * " .
52
            "from user " .
53
            "where nick = '" . $DB->escape_string($jmeno) . "' " .
54
            "and pass = '" . $DB->escape_string($heslo) . "'");//, array($jmeno, $heslo) );
55
        if ($DB->num_rows() != 1)
56
            return false;
57
        session_regenerate_id();
58
        $_SESSION['ses_nick'] = $DB->Record['nick'];
59
        $_SESSION['ses_IDuser'] = $DB->Record['IDuser'];
60
        $_SESSION['ses_date_last_visit'] = time();
61
        $_SESSION['ses_level'] = $DB->Record['privileges'];
62
        $_SESSION['ses_name'] = $DB->Record['name'];
63
        $_SESSION['ses_surname'] = $DB->Record['surname'];
64

  
65
        pr($_SESSION);
66

  
67
        $number_of_usage = $DB->Record["number_of_usage"];
68
        $number_of_usage++;
69

  
70
        $dotaz = "UPDATE \"user\" SET date_last_visit = now(),
70 71
                            number_of_usage = '$number_of_usage'
71
                            WHERE \"IDuser\" = ".$_SESSION["ses_IDuser"];
72
    $DB->query($dotaz);
73
	clean_old_examinations($_SESSION["ses_IDuser"]);
72
                            WHERE \"IDuser\" = " . $_SESSION["ses_IDuser"];
73
        $DB->query($dotaz);
74
        clean_old_examinations($_SESSION["ses_IDuser"]);
74 75

  
75
    return true;
76
  }
77
  return false;
76
        return true;
77
    }
78
    return false;
78 79
}
79 80

  
80
function kontrola_pristupu($level = 0) {
81
  global $_SESSION;
82
  //pr($_SESSION);
83
  if(Empty($_SESSION['ses_nick'])) return false;
84
  if(Empty($_SESSION['ses_date_last_visit'])) return false;
85
  if ($_SESSION['ses_date_last_visit']+MAX_ODEZVA < time()) return false;
86
  if ($_SESSION['ses_level'] < $level) return false;
87
  $_SESSION['ses_date_last_visit'] = time();
88
  return true;
81
function kontrola_pristupu($level = 0)
82
{
83
    global $_SESSION;
84
    //pr($_SESSION);
85
    if (Empty($_SESSION['ses_nick'])) return false;
86
    if (Empty($_SESSION['ses_date_last_visit'])) return false;
87
    if ($_SESSION['ses_date_last_visit'] + MAX_ODEZVA < time()) return false;
88
    if ($_SESSION['ses_level'] < $level) return false;
89
    $_SESSION['ses_date_last_visit'] = time();
90
    return true;
89 91
}
90 92

  
91
function odhlasit() {
92
  global $_SESSION;
93
  session_regenerate_id();
94
  //p_g($_SESSION);
93
function odhlasit()
94
{
95
    global $_SESSION;
96
    session_regenerate_id();
97
    //p_g($_SESSION);
95 98
}
96 99

  
97
function pr($neco) {
98
	p_g($neco);
100
function pr($neco)
101
{
102
    p_g($neco);
99 103
}
100 104

  
101
function p_g($neco) {
102
	echo "<pre>";
103
	print_r($neco);
104
	echo "</pre>";
105
function p_g($neco)
106
{
107
    echo "<pre>";
108
    print_r($neco);
109
    echo "</pre>";
105 110
} // END function p_g
106 111

  
107
function CzStrToLower($str) {
112
function CzStrToLower($str)
113
{
108 114

  
109
  /*$str = StrTr($str,
110
           "ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉĚÍÓÚŮÝŠČŘŽŇŤĎ",
111
           "abcdefghijlkmnopqrstuvwxyzáéěíóúůýščřžňťď");
112
  */
113
  $str = mb_strtolower($str, "UTF-8");
114
  //echo "str = $str<br />";
115
  return $str;
115
    /*$str = StrTr($str,
116
             "ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉĚÍÓÚŮÝŠČŘŽŇŤĎ",
117
             "abcdefghijlkmnopqrstuvwxyzáéěíóúůýščřžňťď");
118
    */
119
    $str = mb_strtolower($str, "UTF-8");
120
    //echo "str = $str<br />";
121
    return $str;
116 122
}
117 123

  
118 124

  
119
function lang($idf) {
120
  if (!isset($_SESSION["LaId"])) {
121
    $_SESSION["LaId"] = "cz";
122
  }
125
function lang($idf)
126
{
127
    if (!isset($_SESSION["LaId"])) {
128
        $_SESSION["LaId"] = "cz";
129
    }
123 130
    $LaId = $_SESSION["LaId"];
124 131

  
125
  static $translations;
126
  if (!isset($translations)) {
127
    $spojeni = new DB_Sql();
128
    $dotaz = "SELECT idf, translation FROM translation WHERE language = '$LaId'";
129
    $spojeni->query($dotaz);
130
    while ($spojeni->next_record()) {
131
      $translations[$spojeni->row[0]] = $spojeni->row[1];
132
    static $translations;
133
    if (!isset($translations)) {
134
        $spojeni = new DB_Sql();
135
        $dotaz = "SELECT idf, translation FROM translation WHERE language = '$LaId'";
136
        $spojeni->query($dotaz);
137
        while ($spojeni->next_record()) {
138
            $translations[$spojeni->row[0]] = $spojeni->row[1];
139
        }
132 140
    }
133
  }
134
  return (isset($translations[$idf]) ? $translations[$idf] : $idf);
141
    return (isset($translations[$idf]) ? $translations[$idf] : $idf);
135 142
}
136 143

  
137 144
//pouzivat bud lang() nebo lang_cist_cele_najednou()
138 145
//nakonec vybrat podle rychlosti
139 146

  
140 147

  
141
function lang_cist_cele_najednou($idf) {
142
  global $LaId; // nastaveno na základě části URL
143
  if (!IsSet($LaId))
144
    $LaId = "cz";
145
  static $translations;
148
function lang_cist_cele_najednou($idf)
149
{
150
    global $LaId; // nastaveno na základě části URL
151
    if (!IsSet($LaId))
152
        $LaId = "cz";
153
    static $translations;
146 154

  
147
  require_once("./classes/db.php");
148
  $spojeni = new DB_Sql();
149
  $dotaz = "SELECT translation FROM translation WHERE idf = '" . addslashes($idf) . "' AND language = '$LaId'";
150
  $row = $spojeni->query($dotaz);
151
  // při neexistujícím překladu je vrácen identifikátor
152
  if ($spojeni->num_rows() != 0) {
153
    $spojeni->next_record();
154
    return $spojeni->Record[0];
155
  }
156
  else {
157
    return $idf;
158
  }
155
    require_once("./classes/db.php");
156
    $spojeni = new DB_Sql();
157
    $dotaz = "SELECT translation FROM translation WHERE idf = '" . addslashes($idf) . "' AND language = '$LaId'";
158
    $row = $spojeni->query($dotaz);
159
    // při neexistujícím překladu je vrácen identifikátor
160
    if ($spojeni->num_rows() != 0) {
161
        $spojeni->next_record();
162
        return $spojeni->Record[0];
163
    } else {
164
        return $idf;
165
    }
159 166
}
160 167

  
161 168

  
162
function clean_old_examinations($ses_IDuser) {
163
  require_once("./classes/db.php");
164
  $spojeni = new DB_Sql();
165
  $dotaz = "SELECT e.*,
169
function clean_old_examinations($ses_IDuser)
170
{
171
    require_once("./classes/db.php");
172
    $spojeni = new DB_Sql();
173
    $dotaz = "SELECT e.*,
166 174
                   (now() - 3 * INTERVAL '1 month') as before_three_month
167 175
            FROM examing e
168 176
            WHERE e.date < (now() - 3 * INTERVAL '1 month')
169
              AND e.\"user\" = ".$_SESSION['ses_IDuser']."
177
              AND e.\"user\" = " . $_SESSION['ses_IDuser'] . "
170 178
            ORDER BY e.date;";
171
  $radky = $spojeni->query($dotaz);
172
  while ($spojeni->next_record()) {
173
    $id = $spojeni->Record["IDexaming"];
174
    $dotaz = "DELETE FROM exam WHERE examing = $id";
175
    $spojeni->query($dotaz);
176
    $dotaz = "DELETE FROM examing WHERE \"IDexaming\" = $id";
177
    $spojeni->query($dotaz);
178
  }
179
    $radky = $spojeni->query($dotaz);
180
    while ($spojeni->next_record()) {
181
        $id = $spojeni->Record["IDexaming"];
182
        $dotaz = "DELETE FROM exam WHERE examing = $id";
183
        $spojeni->query($dotaz);
184
        $dotaz = "DELETE FROM examing WHERE \"IDexaming\" = $id";
185
        $spojeni->query($dotaz);
186
    }
179 187
}
180 188

  
181
function translation_chooser() {
182
  require_once("./classes/db.php");
183
  $spojeni = new DB_Sql();
184
  $dotaz = "SELECT code FROM translation_lang WHERE visible <> 0";
185
  $radky = $spojeni->query($dotaz);
186
  foreach ($radky as $radka) {
187
      echo '<a href="?set_lang=' . $radka['code'] . '">' . $radka['code'] . '</a>&nbsp;';
188
	}
189
function translation_chooser()
190
{
191
    require_once("./classes/db.php");
192
    $spojeni = new DB_Sql();
193
    $dotaz = "SELECT code FROM translation_lang WHERE visible <> 0";
194
    $radky = $spojeni->query($dotaz);
195
    foreach ($radky as $radka) {
196
        echo '<a href="?set_lang=' . $radka['code'] . '">' . $radka['code'] . '</a>&nbsp;';
197
    }
189 198
}
190 199

  
191
function copyright() {
192
  //global $LaId;
193
  //echo ('<div class="copyright"><a href="http://www.e-beda.cz" class="active">created by e-beda.cz</a></div>');
194
  //echo ("\$LaId = $LaId");
200
function copyright()
201
{
202
    //global $LaId;
203
    //echo ('<div class="copyright"><a href="http://www.e-beda.cz" class="active">created by e-beda.cz</a></div>');
204
    //echo ("\$LaId = $LaId");
195 205
}
196 206

  
197
function insert_picture( $class = "obrazek" ) {
198
  require_once("./classes/db.php");
199
  $spojeni = new DB_Sql();
200
  $dotaz = "SELECT * FROM pictures ORDER BY RAND() LIMIT 1";
201
  $radky = $spojeni->query($dotaz);
202

  
203
  if(!$radky){
204
      echo "Chyba pri vyberu obrazku...";
205
      return false;
206
  }
207
function insert_picture($class = "obrazek")
208
{
209
    require_once("./classes/db.php");
210
    $spojeni = new DB_Sql();
211
    $dotaz = "SELECT * FROM pictures ORDER BY RAND() LIMIT 1";
212
    $radky = $spojeni->query($dotaz);
207 213

  
208
  $obrazek = mysqli_fetch_assoc($radky);
209
  if (empty($obrazek)) {
210
    echo "Chyba pri vyberu obrazku...";
211
    return false;
212
  }
213
  else {
214
    $nazev_souboru = $obrazek["name_of_picture"];
215
    $cesky = $obrazek["czech"];
216
    $anglicky = $obrazek["english"];
217
    $arabsky = $obrazek["orig"];
214
    if (!$radky) {
215
        echo "Chyba pri vyberu obrazku...";
216
        return false;
217
    }
218 218

  
219
  $navrat .= "
219
    $obrazek = mysqli_fetch_assoc($radky);
220
    if (empty($obrazek)) {
221
        echo "Chyba pri vyberu obrazku...";
222
        return false;
223
    } else {
224
        $nazev_souboru = $obrazek["name_of_picture"];
225
        $cesky = $obrazek["czech"];
226
        $anglicky = $obrazek["english"];
227
        $arabsky = $obrazek["orig"];
228

  
229
        $navrat .= "
220 230
<div id=\"$class\">
221 231
  <table>
222 232
    <tr>
......
234 244
</div>";
235 245

  
236 246

  
237
    echo $navrat;
238
  }
247
        echo $navrat;
248
    }
239 249
}
240 250

  
241 251

  
242
function print_context_chooser($source_id) {
243
  require_once("./classes/db.php");
244
  $spojeni = new DB_Sql();
245
  $dotaz = "SELECT * FROM context WHERE source LIKE '$source_id'";
246
  $radky = $spojeni->query($dotaz);
247
  if ($spojeni->num_rows() == 0) {
248
    echo "Bohužel u tohoto zdroje zatím nejsou žádné kontexty,
252
function print_context_chooser($source_id)
253
{
254
    require_once("./classes/db.php");
255
    $spojeni = new DB_Sql();
256
    $dotaz = "SELECT * FROM context WHERE source LIKE '$source_id'";
257
    $radky = $spojeni->query($dotaz);
258
    if ($spojeni->num_rows() == 0) {
259
        echo "Bohužel u tohoto zdroje zatím nejsou žádné kontexty,
249 260
               můžete je přidat ze slovníku, zvolením položky kontext->přidej";
250
    return false;
251
  }
252
  else {
253
    $navrat = "<select name=\"context\" size=\"6\">";
254
    while ($spojeni->next_record()) {
255
      $navrat .= "  <option value=\"".$spojeni->Record["IDcontext"]."\">  ".
256
                  $spojeni->Record[cz_context]." - ".
257
                  $spojeni->Record[en_context]." - ".
258
                  $spojeni->Record[orig_context].
259
                  "  </option>\n";
261
        return false;
262
    } else {
263
        $navrat = "<select name=\"context\" size=\"6\">";
264
        while ($spojeni->next_record()) {
265
            $navrat .= "  <option value=\"" . $spojeni->Record["IDcontext"] . "\">  " .
266
                $spojeni->Record[cz_context] . " - " .
267
                $spojeni->Record[en_context] . " - " .
268
                $spojeni->Record[orig_context] .
269
                "  </option>\n";
270
        }
271
        $navrat .= '</select>';
260 272
    }
261
    $navrat .= '</select>';
262
  }
263
  echo $navrat;
264
  return true;
273
    echo $navrat;
274
    return true;
265 275
}
266 276

  
267 277

  
268
function get_translation_chooser() {
269
  require_once("./classes/db.php");
270
  $spojeni = new DB_Sql();
271
  $dotaz = "SELECT * FROM translation_lang";
272
  $spojeni->query($dotaz);
273
  $navrat = "<select name=\"translation_lang_id\" size=\"4\">";
274
  while ($spojeni->next_record()) {
275
    $navrat .= "  <option value=\"".$spojeni->Record["code"]."\">  ".$spojeni->Record["name"]."  </option>";
276
  }
277
  $navrat .= '</select>';
278
  return $navrat;
278
function get_translation_chooser()
279
{
280
    require_once("./classes/db.php");
281
    $spojeni = new DB_Sql();
282
    $dotaz = "SELECT * FROM translation_lang";
283
    $spojeni->query($dotaz);
284
    $navrat = "<select name=\"translation_lang_id\" size=\"4\">";
285
    while ($spojeni->next_record()) {
286
        $navrat .= "  <option value=\"" . $spojeni->Record["code"] . "\">  " . $spojeni->Record["name"] . "  </option>";
287
    }
288
    $navrat .= '</select>';
289
    return $navrat;
279 290
}
280 291

  
281
function get_field_chooser() {
282
  require_once("./classes/db.php");
283
  $spojeni = new DB_Sql();
284
  $dotaz = "SELECT * FROM field";
285
  $radky = $spojeni->query($dotaz);
286
  $navrat = "<select name=\"field\" size=\"1\">";
287
  while ($spojeni->next_record()) {
288
    $navrat .= "  <option value=\"".$spojeni->Record[0]."\">  ".$spojeni->Record[1]."  </option>";
289
  }
290
  $navrat .= '</select>';
291
  return $navrat;
292
function get_field_chooser()
293
{
294
    require_once("./classes/db.php");
295
    $spojeni = new DB_Sql();
296
    $dotaz = "SELECT * FROM field";
297
    $radky = $spojeni->query($dotaz);
298
    $navrat = "<select name=\"field\" size=\"1\">";
299
    while ($spojeni->next_record()) {
300
        $navrat .= "  <option value=\"" . $spojeni->Record[0] . "\">  " . $spojeni->Record[1] . "  </option>";
301
    }
302
    $navrat .= '</select>';
303
    return $navrat;
292 304
}
305

  
293 306
/*
294 307
function getTree($table, $id, $parent_id, $parent, $level) { 
295 308
  require_once("./classes/db.php");
......
333 346
  return $navrat;
334 347
}
335 348
*/
336
function get_author_chooser() {
337
  require_once("./classes/db.php");
338
  $spojeni = new DB_Sql();
339
  $dotaz = "SELECT * FROM author";
340
  $radky = $spojeni->query($dotaz);
341
  $navrat = "<select name=\"author_id\" size=\"1\">\n";
342
  while ($spojeni->next_record()) {
343
    $navrat .= "  <option value=\"".$spojeni->Record[0]."\">  ".
344
                         $spojeni->Record[1]." ".$spojeni->Record[2]."  </option>\n";
345
  }
346
  $navrat .= "</select>\n";
347
  return $navrat;
349
function get_author_chooser()
350
{
351
    require_once("./classes/db.php");
352
    $spojeni = new DB_Sql();
353
    $dotaz = "SELECT * FROM author";
354
    $radky = $spojeni->query($dotaz);
355
    $navrat = "<select name=\"author_id\" size=\"1\">\n";
356
    while ($spojeni->next_record()) {
357
        $navrat .= "  <option value=\"" . $spojeni->Record[0] . "\">  " .
358
            $spojeni->Record[1] . " " . $spojeni->Record[2] . "  </option>\n";
359
    }
360
    $navrat .= "</select>\n";
361
    return $navrat;
348 362
}
349 363

  
350 364

  
351
function insert_language_chooser() {
352
  echo get_language_chooser();
365
function insert_language_chooser()
366
{
367
    echo get_language_chooser();
353 368
}
354 369

  
355
function get_language_chooser($size = 1) {
356
  require_once("./classes/db.php");
357
  $spojeni = new DB_Sql();
358
  $dotaz = "SELECT * FROM \"language\"";
359
  $radky = $spojeni->query($dotaz);
360
  $navrat = "<select name=\"language\" size=\"$size\">";
361
  while ($spojeni->next_record()) {
362
    $navrat .= "  <option value=\"".$spojeni->Record[0]."\">  ".$spojeni->Record[1]."  </option>";
363
  }
364
  $navrat .= '</select>';
365
  return $navrat;
370
function get_language_chooser($size = 1)
371
{
372
    require_once("./classes/db.php");
373
    $spojeni = new DB_Sql();
374
    $dotaz = "SELECT * FROM \"language\"";
375
    $radky = $spojeni->query($dotaz);
376
    $navrat = "<select name=\"language\" size=\"$size\">";
377
    while ($spojeni->next_record()) {
378
        $navrat .= "  <option value=\"" . $spojeni->Record[0] . "\">  " . $spojeni->Record[1] . "  </option>";
379
    }
380
    $navrat .= '</select>';
381
    return $navrat;
366 382
}
367 383

  
368
function get_source_chooser($language, $nazev = "source") {
369
  require_once("./classes/db.php");
370
  $spojeni = new DB_Sql();
371
  $dotaz = "SELECT * FROM source";
372
  if (!Empty($language))
373
   $dotaz .= " WHERE \"language\" = '$language'";
374
  $radky = $spojeni->query($dotaz);
375
  $navrat = "<select name=\"$nazev\" size=\"1\">";
376
  while ($spojeni->next_record()) {
377
    $navrat .= "  <option value=\"".$spojeni->Record[0]."\">  ".$spojeni->Record[1]." - ".$spojeni->Record[2]."  </option>";
378
  }
379
  $navrat .= '</select>';
380
  return $navrat;
384
function get_source_chooser($language, $nazev = "source")
385
{
386
    require_once("./classes/db.php");
387
    $spojeni = new DB_Sql();
388
    $dotaz = "SELECT * FROM source";
389
    if (!Empty($language))
390
        $dotaz .= " WHERE \"language\" = '$language'";
391
    $radky = $spojeni->query($dotaz);
392
    $navrat = "<select name=\"$nazev\" size=\"1\">";
393
    while ($spojeni->next_record()) {
394
        $navrat .= "  <option value=\"" . $spojeni->Record[0] . "\">  " . $spojeni->Record[1] . " - " . $spojeni->Record[2] . "  </option>";
395
    }
396
    $navrat .= '</select>';
397
    return $navrat;
381 398
}
382 399

  
383
function get_lection_chooser($source, $size = 1, $nazev = "lection") {
384
  require_once("./classes/db.php");
385
  $spojeni = new DB_Sql();
386
  $dotaz  = "SELECT lection FROM dict WHERE source = '$source' GROUP BY lection ORDER BY lection ";
387
  $radky = $spojeni->query($dotaz);
388
  $navrat = "<select name=\"$nazev\" size=\"$size\">";
389
  $i = 0;
390
  while ($spojeni->next_record()) {
391
    $cisla[$i] = 0 + ($spojeni->Record["lection"]);
392
    $hodnoty[$i] = $spojeni->Record["lection"];
393
    $i++;
394
  }
395
  if (count($cisla) <= 0) {
396
  	return "prazdne";
397
  }
398
  asort($cisla);
399
  foreach ($cisla as $klic => $cislo) {
400
    $navrat .= "  <option value=\"".$hodnoty[$klic]."\"> ".lang("lekce")." ".$hodnoty[$klic]."  </option>";
401
  }
402
  $navrat .= '</select>';
403
  return $navrat;
400
function get_lection_chooser($source, $size = 1, $nazev = "lection")
401
{
402
    require_once("./classes/db.php");
403
    $spojeni = new DB_Sql();
404
    $dotaz = "SELECT lection FROM dict WHERE source = '$source' GROUP BY lection ORDER BY lection ";
405
    $radky = $spojeni->query($dotaz);
406
    $navrat = "<select name=\"$nazev\" size=\"$size\">";
407
    $i = 0;
408
    while ($spojeni->next_record()) {
409
        $cisla[$i] = 0 + ($spojeni->Record["lection"]);
410
        $hodnoty[$i] = $spojeni->Record["lection"];
411
        $i++;
412
    }
413
    if (count($cisla) <= 0) {
414
        return "prazdne";
415
    }
416
    asort($cisla);
417
    foreach ($cisla as $klic => $cislo) {
418
        $navrat .= "  <option value=\"" . $hodnoty[$klic] . "\"> " . lang("lekce") . " " . $hodnoty[$klic] . "  </option>";
419
    }
420
    $navrat .= '</select>';
421
    return $navrat;
404 422
}
405 423

  
406
function get_lection_chooser_article($source, $size = 1, $nazev = "lection") {
407
  require_once("./classes/db.php");
408
  $spojeni = new DB_Sql();
409
  $dotaz  = "SELECT lection FROM article WHERE source = '$source' GROUP BY lection ORDER BY lection ";
410
  $radky = $spojeni->query($dotaz);
411
  $navrat = "<select name=\"$nazev\" size=\"$size\">";
412
  $i = 0;
413
  while ($spojeni->next_record()) {
414
    $cisla[$i] = 0 + ($spojeni->Record["lection"]);
415
    $hodnoty[$i] = $spojeni->Record["lection"];
416
    $i++;
417
  }
418
  if (count($cisla) <= 0) {
419
  	return "prazdne";
420
  }
421
  asort($cisla);
422
  foreach ($cisla as $klic => $cislo) {
423
    $navrat .= "  <option value=\"".$hodnoty[$klic]."\"> ".lang("lekce")." ".$hodnoty[$klic]."  </option>";
424
  }
425
  $navrat .= '</select>';
426
  return $navrat;
424
function get_lection_chooser_article($source, $size = 1, $nazev = "lection")
425
{
426
    require_once("./classes/db.php");
427
    $spojeni = new DB_Sql();
428
    $dotaz = "SELECT lection FROM article WHERE source = '$source' GROUP BY lection ORDER BY lection ";
429
    $radky = $spojeni->query($dotaz);
430
    $navrat = "<select name=\"$nazev\" size=\"$size\">";
431
    $i = 0;
432
    while ($spojeni->next_record()) {
433
        $cisla[$i] = 0 + ($spojeni->Record["lection"]);
434
        $hodnoty[$i] = $spojeni->Record["lection"];
435
        $i++;
436
    }
437
    if (count($cisla) <= 0) {
438
        return "prazdne";
439
    }
440
    asort($cisla);
441
    foreach ($cisla as $klic => $cislo) {
442
        $navrat .= "  <option value=\"" . $hodnoty[$klic] . "\"> " . lang("lekce") . " " . $hodnoty[$klic] . "  </option>";
443
    }
444
    $navrat .= '</select>';
445
    return $navrat;
427 446
}
428 447

  
429
function get_lection_chooser_test($source, $size = 1, $nazev = "lection") {
430
  require_once("./classes/db.php");
431
  $spojeni = new DB_Sql();
432
  $dotaz  = "SELECT lection FROM test WHERE source = '$source' GROUP BY lection ORDER BY lection ";
433
  $radky = $spojeni->query($dotaz);
434
  $navrat = "<select name=\"$nazev\" size=\"$size\">";
435
  $i = 0;
436
  while ($spojeni->next_record()) {
437
    $cisla[$i] = 0 + ($spojeni->Record["lection"]);
438
    $hodnoty[$i] = $spojeni->Record["lection"];
439
    $i++;
440
  }
441
  if (count($cisla) <= 0) {
442
  	return "prazdne";
443
  }
444
  asort($cisla);
445
  foreach ($cisla as $klic => $cislo) {
446
    $navrat .= "  <option value=\"".$hodnoty[$klic]."\"> ".lang("lekce")." ".$hodnoty[$klic]."  </option>";
447
  }
448
  $navrat .= '</select>';
449
  return $navrat;
448
function get_lection_chooser_test($source, $size = 1, $nazev = "lection")
449
{
450
    require_once("./classes/db.php");
451
    $spojeni = new DB_Sql();
452
    $dotaz = "SELECT lection FROM test WHERE source = '$source' GROUP BY lection ORDER BY lection ";
453
    $radky = $spojeni->query($dotaz);
454
    $navrat = "<select name=\"$nazev\" size=\"$size\">";
455
    $i = 0;
456
    while ($spojeni->next_record()) {
457
        $cisla[$i] = 0 + ($spojeni->Record["lection"]);
458
        $hodnoty[$i] = $spojeni->Record["lection"];
459
        $i++;
460
    }
461
    if (count($cisla) <= 0) {
462
        return "prazdne";
463
    }
464
    asort($cisla);
465
    foreach ($cisla as $klic => $cislo) {
466
        $navrat .= "  <option value=\"" . $hodnoty[$klic] . "\"> " . lang("lekce") . " " . $hodnoty[$klic] . "  </option>";
467
    }
468
    $navrat .= '</select>';
469
    return $navrat;
450 470
}
451 471

  
452
function get_count_chooser($source, $lection, $size = 1) {
453
  require_once("./classes/db.php");
454
  $spojeni = new DB_Sql();
455
  $dotaz  = "SELECT czech FROM dict WHERE source = '$source' AND lection = '$lection' ";
456
  $radky = $spojeni->query($dotaz);
457
  $max = $spojeni->num_rows();
458
  $navrat = lang("V této lekci je ").$max.lang(" slovíček ")." <br /> <br />\n";
459
  $navrat .= lang("Počet slovíček ke zkoušení: \n");
460
  $navrat .= "<select name=\"count\" size=\"$size\">";
461
  for ($count = 10; $count < $max; $count += 10) {
462
    $navrat .= "  <option value=\"".$count."\">  ".$count."  </option>";
463
  }
464
  $navrat .= "  <option value=\"".$spojeni->num_rows()."\">  ".$max."  </option>";
465
  $navrat .= '</select>';
466
  return $navrat;
472
function get_count_chooser($source, $lection, $size = 1)
473
{
474
    require_once("./classes/db.php");
475
    $spojeni = new DB_Sql();
476
    $dotaz = "SELECT czech FROM dict WHERE source = '$source' AND lection = '$lection' ";
477
    $radky = $spojeni->query($dotaz);
478
    $max = $spojeni->num_rows();
479
    $navrat = lang("V této lekci je ") . $max . lang(" slovíček ") . " <br /> <br />\n";
480
    $navrat .= lang("Počet slovíček ke zkoušení: \n");
481
    $navrat .= "<select name=\"count\" size=\"$size\">";
482
    for ($count = 10; $count < $max; $count += 10) {
483
        $navrat .= "  <option value=\"" . $count . "\">  " . $count . "  </option>";
484
    }
485
    $navrat .= "  <option value=\"" . $spojeni->num_rows() . "\">  " . $max . "  </option>";
486
    $navrat .= '</select>';
487
    return $navrat;
467 488
}
468 489

  
469 490

  
470
function print_hlasku($text) {
471
  echo "<h4 class=\"nadpis3\">".$text."</h4> \n";
491
function print_hlasku($text)
492
{
493
    echo "<h4 class=\"nadpis3\">" . $text . "</h4> \n";
472 494
}
473 495

  
474
function is_in_dictionary_past($past, $source, $lection) {
475
  if (Empty($past) || (Trim($past) == "")) return false;
476
  require_once("./classes/db.php");
477
  $spojeni = new DB_Sql();
478
  $dotaz = "SELECT past FROM dict WHERE past LIKE '$past' AND source = $source AND lection LIKE '$lection'";
479
  $spojeni->query($dotaz);
480
  if ($spojeni->Errno != 0) {
481
    print_hlasku($spojeni->Error);
482
    return false;
483
  }
484
  //echo $spojeni->num_rows();
485
  if ($spojeni->num_rows() > 0)
486
    return true;
496
function is_in_dictionary_past($past, $source, $lection)
497
{
498
    if (Empty($past) || (Trim($past) == "")) return false;
499
    require_once("./classes/db.php");
500
    $spojeni = new DB_Sql();
501
    $dotaz = "SELECT past FROM dict WHERE past LIKE '$past' AND source = $source AND lection LIKE '$lection'";
502
    $spojeni->query($dotaz);
503
    if ($spojeni->Errno != 0) {
504
        print_hlasku($spojeni->Error);
505
        return false;
506
    }
507
    //echo $spojeni->num_rows();
508
    if ($spojeni->num_rows() > 0)
509
        return true;
487 510

  
488
  return false;
511
    return false;
489 512
}
490 513

  
491 514
/**
......
494 517
 *
495 518
 *  TODO: UPRAVIT OSTATNI DATA VKLADANA DO DB (DATA, USER, ATD...)
496 519
 *        DODELAT UPLOAD ZVUKOVEHO SOUBORU
497
 *  @return true   kdyz se to povede
498
 *  @return false  naopak
520
 * @return true   kdyz se to povede
521
 * @return false  naopak
499 522
 */
500
function insert_word($czech,$english,$word_category,$verbal_class,$present,$past,$valence,$root,
501
                     $field,$language,$user,$source,$lection, $future, $infinitive, $gender, $vocalized, $nonvocalized,
523
function insert_word($czech, $english, $word_category, $verbal_class, $present, $past, $valence, $root,
524
                     $field, $language, $user, $source, $lection, $future, $infinitive, $gender, $vocalized, $nonvocalized,
502 525
                     $word_category_foreign, $status_constructus_single, $status_constructus_plural, $single_adj_female,
503
                      $plural_adj_female, $conjugation, $imperative, $prefix, $status_constructus_single_female,
504
		      $status_constructus_plural_female,
505
		      $czech_female, $single_female, $plural_female, 
506
                      $status_constructus_single_noun_female, $status_constructus_plural_noun_female,
507
		      $nonvocalized_female, $nonvocalized_alternative, $vocalized_alternative) {
526
                     $plural_adj_female, $conjugation, $imperative, $prefix, $status_constructus_single_female,
527
                     $status_constructus_plural_female,
528
                     $czech_female, $single_female, $plural_female,
529
                     $status_constructus_single_noun_female, $status_constructus_plural_noun_female,
530
                     $nonvocalized_female, $nonvocalized_alternative, $vocalized_alternative)
531
{
508 532

  
509
  require_once("./classes/db.php");
510
  $spojeni = new DB_Sql();
511
  /*
512
  //pokud uz je ve slovniku nebude se znovu vkladat
513
  if (is_in_dictionary_past($past, $source, $lection)) {
514
    print_hlasku ("Slovíčko '$past - $czech - $english' nebylo přidáno, již je ve slovníku...");
515
    return false;
516
  }
517
  */
533
    require_once("./classes/db.php");
534
    $spojeni = new DB_Sql();
535
    /*
536
    //pokud uz je ve slovniku nebude se znovu vkladat
537
    if (is_in_dictionary_past($past, $source, $lection)) {
538
      print_hlasku ("Slovíčko '$past - $czech - $english' nebylo přidáno, již je ve slovníku...");
539
      return false;
540
    }
541
    */
518 542

  
519
  //$NOW = Date("YmdHis");
520
   $dotaz = "INSERT INTO dict (czech,
543
    //$NOW = Date("YmdHis");
544
    $dotaz = "INSERT INTO dict (czech,
521 545
                            english,
522 546
                            word_category,
523 547
                            verbal_class,
......
557 581
			    nonvocalized_alternative,
558 582
			    vocalized_alternative
559 583
)
560
                    VALUES ('".AddSlashes($czech)."',
561
                            '".AddSlashes($english)."',
562
                            '".AddSlashes($word_category)."',
563
                            '".AddSlashes($verbal_class)."',
564
                            '".AddSlashes($present)."',
565
                            '".AddSlashes($past)."',
566
                            '".AddSlashes($future)."',
567
                            '".AddSlashes($infinitive)."',
568
                            '".AddSlashes($valence)."',
569
                            '".AddSlashes($vocalized)."',
570
                            '".AddSlashes($nonvocalized)."',
571
                            '".AddSlashes($root)."',
572
                            '".AddSlashes($gender)."',
573
                            '".AddSlashes($field)."',
574
                            '".AddSlashes($source)."',
575
                            '".AddSlashes($lection)."',
576
                            '".AddSlashes($language)."',
577
                            '".AddSlashes($user)."',
584
                    VALUES ('" . AddSlashes($czech) . "',
585
                            '" . AddSlashes($english) . "',
586
                            '" . AddSlashes($word_category) . "',
587
                            '" . AddSlashes($verbal_class) . "',
588
                            '" . AddSlashes($present) . "',
589
                            '" . AddSlashes($past) . "',
590
                            '" . AddSlashes($future) . "',
591
                            '" . AddSlashes($infinitive) . "',
592
                            '" . AddSlashes($valence) . "',
593
                            '" . AddSlashes($vocalized) . "',
594
                            '" . AddSlashes($nonvocalized) . "',
595
                            '" . AddSlashes($root) . "',
596
                            '" . AddSlashes($gender) . "',
597
                            '" . AddSlashes($field) . "',
598
                            '" . AddSlashes($source) . "',
599
                            '" . AddSlashes($lection) . "',
600
                            '" . AddSlashes($language) . "',
601
                            '" . AddSlashes($user) . "',
578 602
                            'NOW',
579 603
                            '0',
580 604
                            '0',
581
                            '".AddSlashes($word_category_foreign)."', 
582
                            '".AddSlashes($status_constructus_single)."', 
583
                            '".AddSlashes($status_constructus_plural)."',
584
                            '".AddSlashes($single_adj_female)."',
585
                            '".AddSlashes($plural_adj_female)."', 
586
                            '".AddSlashes($conjugation)."', 
587
                            '".AddSlashes($imperative)."',
588
			    '".AddSlashes($prefix)."',
589
			    '".AddSlashes($status_constructus_single_female)."',
590
			    '".AddSlashes($status_constructus_plural_female)."',
591
			    '".AddSlashes($czech_female)."', 
592
			    '".AddSlashes($single_female)."', 
593
			    '".AddSlashes($plural_female)."', 
594
			    '".AddSlashes($status_constructus_single_noun_female)."', 
595
			    '".AddSlashes($status_constructus_plural_noun_female)."',
596
			    '".AddSlashes($nonvocalized_female)."',
597
			    '".AddSlashes($nonvocalized_alternative)."',
598
			    '".AddSlashes($vocalized_alternative)."'
605
                            '" . AddSlashes($word_category_foreign) . "', 
606
                            '" . AddSlashes($status_constructus_single) . "', 
607
                            '" . AddSlashes($status_constructus_plural) . "',
608
                            '" . AddSlashes($single_adj_female) . "',
609
                            '" . AddSlashes($plural_adj_female) . "', 
610
                            '" . AddSlashes($conjugation) . "', 
611
                            '" . AddSlashes($imperative) . "',
612
			    '" . AddSlashes($prefix) . "',
613
			    '" . AddSlashes($status_constructus_single_female) . "',
614
			    '" . AddSlashes($status_constructus_plural_female) . "',
615
			    '" . AddSlashes($czech_female) . "', 
616
			    '" . AddSlashes($single_female) . "', 
617
			    '" . AddSlashes($plural_female) . "', 
618
			    '" . AddSlashes($status_constructus_single_noun_female) . "', 
619
			    '" . AddSlashes($status_constructus_plural_noun_female) . "',
620
			    '" . AddSlashes($nonvocalized_female) . "',
621
			    '" . AddSlashes($nonvocalized_alternative) . "',
622
			    '" . AddSlashes($vocalized_alternative) . "'
599 623
)";
600
  $spojeni->query($dotaz);
601
  if ($spojeni->Errno != 0) {
602
    print_hlasku($spojeni->$Error);
603
    return false;
604
  }
605
  return true;
624
    $spojeni->query($dotaz);
625
    if ($spojeni->Errno != 0) {
626
        print_hlasku($spojeni->$Error);
627
        return false;
628
    }
629
    return true;
606 630
}
607 631

  
608 632

  
609
function save_to_not_found($direction, $word) {
610
  require_once("./classes/db.php");
611
  $spojeni = new DB_Sql();
612
  $dotaz = "SELECT * FROM not_found_$direction WHERE not_found LIKE '$word'";
613
  $radky = $spojeni->query($dotaz);
614
  if ($spojeni->num_rows() == 0)  {
615
    $dotaz = "INSERT INTO not_found_$direction (not_found,
633
function save_to_not_found($direction, $word)
634
{
635
    require_once("./classes/db.php");
636
    $spojeni = new DB_Sql();
637
    $dotaz = "SELECT * FROM not_found_$direction WHERE not_found LIKE '$word'";
638
    $radky = $spojeni->query($dotaz);
639
    if ($spojeni->num_rows() == 0) {
640
        $dotaz = "INSERT INTO not_found_$direction (not_found,
616 641
                          date,
617 642
                          count)
618 643
                  VALUES ('$word', 'NOW', 1)";
619
  }
620
  else {
621
    $spojeni->next_record();
622
    $pocet = $spojeni->Record["count"];
623
    $pocet++;
624
    $identifikator = $spojeni->Record["IDnot_found_$direction"];
625
    $dotaz = "UPDATE not_found_$direction
644
    } else {
645
        $spojeni->next_record();
646
        $pocet = $spojeni->Record["count"];
647
        $pocet++;
648
        $identifikator = $spojeni->Record["IDnot_found_$direction"];
649
        $dotaz = "UPDATE not_found_$direction
626 650
              SET count = $pocet
627 651
              WHERE \"IDnot_found_$direction\" = $identifikator";
628
  }
629
  $spojeni->query($dotaz);
652
    }
653
    $spojeni->query($dotaz);
630 654
}
631 655

  
632 656

  
657
function __get_word_in_card_format($Record)
658
{
659
    //global CESTA_KONTEXTU, PRIPONA, CESTA_SLOV;
660
    require_once("./administration/context.php");
633 661

  
634
function __get_word_in_card_format($Record) {
635
  //global CESTA_KONTEXTU, PRIPONA, CESTA_SLOV;
636
  require_once("./administration/context.php");
662
    $navrat = "<div class=\"card\">\n<br />";
663
    $navrat .= " \n     ";
637 664

  
638
  $navrat = "<div class=\"card\">\n<br />";
639
  $navrat .= " \n     ";
665
    $navrat .= $Record["czech"];
666
    $navrat .= "&nbsp;  - \n";
667
    $navrat .= $Record["english"];
668
    $navrat .= "&nbsp;   \n";
640 669

  
641
  $navrat .= $Record["czech"];
642
  $navrat .= "&nbsp;  - \n";
643
  $navrat .= $Record["english"];
644
  $navrat .= "&nbsp;   \n";
645
 
646
  //if(!empty($Record["gender"])) 
647
  //		$navrat .= " (".$Record["gender"].".) "; 
648
  $navrat .= "<div lang=\"he\" dir=\"rtl\">";
649
  
650
  $navrat .= "<span class=\"big arabic\">";
651
  $navrat .= (!empty($Record["past"]))? $Record["past"] : $Record["present"] ;
652
  $navrat .= "</span>";
653
  
654
  $Record["gender"] = trim($Record["gender"]);
655
  if(!empty( $Record["gender"] )) 
656
  		$navrat .= "<span style=\"font-size:200%\"  dir=\"ltr\"> (".$Record["gender"].") </span>";
657
  		
658
  $navrat .= "&nbsp;</div>\n";
659
  $navrat .= " \n  ";
660
  
661
  if (!Empty($Record["context"])) {
662
  	$navrat .= "\n<br />";//.lang("Kontext:");
663
    $context = get_context($Record["context"]);
664
    $navrat .= $context["cz_context"]." - ".$context["en_context"]." -
665
              <div class=\"arabic\">".$context["orig_context"]."</div>";
666
  }
667
  if (!Empty($Record["context_voice"])) {
668
  	$navrat .= '<a href="'.CESTA_KONTEXTU.$Record["IDdict"].PRIPONA.'"> '.lang("přehrát zvuk").' </a>';
669
  }
670
    //if(!empty($Record["gender"]))
671
    //		$navrat .= " (".$Record["gender"].".) ";
672
    $navrat .= "<div lang=\"he\" dir=\"rtl\">";
673

  
674
    $navrat .= "<span class=\"big arabic\">";
675
    $navrat .= (!empty($Record["past"])) ? $Record["past"] : $Record["present"];
676
    $navrat .= "</span>";
677

  
678
    $Record["gender"] = trim($Record["gender"]);
679
    if (!empty($Record["gender"]))
680
        $navrat .= "<span style=\"font-size:200%\"  dir=\"ltr\"> (" . $Record["gender"] . ") </span>";
681

  
682
    $navrat .= "&nbsp;</div>\n";
683
    $navrat .= " \n  ";
684

  
685
    if (!Empty($Record["context"])) {
686
        $navrat .= "\n<br />";//.lang("Kontext:");
687
        $context = get_context($Record["context"]);
688
        $navrat .= $context["cz_context"] . " - " . $context["en_context"] . " -
689
              <div class=\"arabic\">" . $context["orig_context"] . "</div>";
690
    }
691
    if (!Empty($Record["context_voice"])) {
692
        $navrat .= '<a href="' . CESTA_KONTEXTU . $Record["IDdict"] . PRIPONA . '"> ' . lang("přehrát zvuk") . ' </a>';
693
    }
670 694
//  else {
671 695
//    $navrat .= lang("není");
672 696
//  }
673
  
674
  if (!Empty($Record["word_voice"])) {
675
  	$navrat .= "\n<br />".lang("Zvuk:");
676
    $navrat .= '<a href="'.CESTA_SLOV.$Record["IDdict"].PRIPONA.'"> '.lang("přehrát zvuk").' </a>';
677
  }
697

  
698
    if (!Empty($Record["word_voice"])) {
699
        $navrat .= "\n<br />" . lang("Zvuk:");
700
        $navrat .= '<a href="' . CESTA_SLOV . $Record["IDdict"] . PRIPONA . '"> ' . lang("přehrát zvuk") . ' </a>';
701
    }
678 702
//  else
679 703
//    $navrat .= lang("není");
680
  $navrat .= "\n<br />\n<br />\n</div>";
704
    $navrat .= "\n<br />\n<br />\n</div>";
681 705

  
682
  return $navrat;
706
    return $navrat;
683 707
}
684 708

  
685 709
/**
......
688 712
 * Tzn. bude se hledat token zacínající na "mal"
689 713
 * Tokeny jsou samostatna slova, nebo slova oddelena
690 714
 * lomitkem nebo sekvenci znaku carkaMezera.
691
 * 
715
 *
692 716
 * @param string $token
693 717
 * @return string
694 718
 */
695
function get_token_regexp($token) {
696
	return "^".$token.'[ ]?$|'.
697
	       "/".$token.'[ ]?$|'.
698
	       ",[ ]?".$token.'[ ]?$|'.
699
	       ";[ ]?".$token.'[ ]?$|'.
700
	       "^".$token.";|".
701
	       "^[ ]?".$token.",|".
702
	       ",[ ]?".$token.",|".
703
	       "^".$token." [(]";
719
function get_token_regexp($token)
720
{
721
    return "^" . $token . '[ ]?$|' .
722
        "/" . $token . '[ ]?$|' .
723
        ",[ ]?" . $token . '[ ]?$|' .
724
        ";[ ]?" . $token . '[ ]?$|' .
725
        "^" . $token . ";|" .
726
        "^[ ]?" . $token . ",|" .
727
        ",[ ]?" . $token . ",|" .
728
        "^" . $token . " [(]";
704 729
}
705 730

  
706
function hebrew_add_vowel($string) {
707
	$ret = '';
708
	$mez = mb_strlen($string)-1;
709
	for($i = 0; $i < $mez; $i++) {
710
		$ret .= mb_substr($string, $i, 1). "[ְֱֲֳִֵֶַָֹֻֻּֽֿׁ]*";//"[][⌈⌉?!><]?";
711
	}
712
	return $ret.mb_substr($string, $mez, 1);
731
function hebrew_add_vowel($string)
732
{
733
    $ret = '';
734
    $mez = mb_strlen($string) - 1;
735
    for ($i = 0; $i < $mez; $i++) {
736
        $ret .= mb_substr($string, $i, 1) . "[ְֱֲֳִֵֶַָֹֻֻּֽֿׁ]*";//"[][⌈⌉?!><]?";
737
    }
738
    return $ret . mb_substr($string, $mez, 1);
713 739
}
714 740

  
715
function arabic_add_vowel($string) {
716
	$ret = '';
717
	$mez = mb_strlen($string)-1;
718
	for($i = 0; $i < $mez; $i++) {
719
		$ret .= mb_substr($string, $i, 1). "[ٌَ]*";//"[][⌈⌉?!><]?";
720
	}
721
	return $ret.mb_substr($string, $mez, 1);
741
function arabic_add_vowel($string)
742
{
743
    $ret = '';
744
    $mez = mb_strlen($string) - 1;
745
    for ($i = 0; $i < $mez; $i++) {
746
        $ret .= mb_substr($string, $i, 1) . "[ٌَ]*";//"[][⌈⌉?!><]?";
747
    }
748
    return $ret . mb_substr($string, $mez, 1);
722 749
}
723 750

  
724 751
/**
725 752
 *  Funkce vytiskne preklad slova z parametru
726 753
 *
727
 *  @param $word slovo urcene k prekladu
728
 *  @param $language jazyk
754
 * @param $word slovo urcene k prekladu
755
 * @param $language jazyk
729 756
 *
730 757
 */
731
function print_translation($word, $direction, $language = 1) {
732
  require_once("./classes/db.php");
733
  $spojeni = new DB_Sql();
734
  $text = "\n       ";
758
function print_translation($word, $direction, $language = 1)
759
{
760
    require_once("./classes/db.php");
761
    $spojeni = new DB_Sql();
762
    $text = "\n       ";
735 763

  
736
  //$po = mb_strtolower($word, "UTF-8");
737
  //echo $word."\n<br />".$po;
764
    //$po = mb_strtolower($word, "UTF-8");
765
    //echo $word."\n<br />".$po;
738 766

  
739
  if (empty($word)) {
740
    $text .= lang("Musíte zadat nějaké slovo.");
741
  }
742
  else {
743
    $navrat = "";
744
    //pr($direction);
745
    switch ($direction) {
746
      case("en"):
747
        $word = mb_strtolower($word, "UTF-8");
748
        $word = get_token_regexp($word);
749
        
750
        $dotaz = "SELECT * FROM dict 
767
    if (empty($word)) {
768
        $text .= lang("Musíte zadat nějaké slovo.");
769
    } else {
770
        $navrat = "";
771
        //pr($direction);
772
        switch ($direction) {
773
            case("en"):
774
                $word = mb_strtolower($word, "UTF-8");
775

  
776
                $dotaz = "SELECT * FROM dict 
751 777
        		WHERE language = $language 
752
        		  AND lower(english) ~ '$word' 
778
        		  AND lower(english) = '$word' 
753 779
        		  ORDER BY english LIMIT 30";
754
      break;
755
      case("he"):
756
        $word_strict = $word;
757
        //$word = hebrew_add_vowel($word);
758
	
759
	$word_token = get_token_regexp($word);
780
                break;
781
            case("he"):
782
                $word_strict = $word;
783
                //$word = hebrew_add_vowel($word);
760 784

  
761
	$word_token = pg_escape_string($word_token);
785
                $word_token = $spojeni->escape_string($word);
762 786

  
763
	$dotaz = "SELECT * FROM dict
787
                $dotaz = "SELECT * FROM dict
764 788
            WHERE language = $language AND
765 789
                  (
766
                   (past    ~ ('$word_token')) 
790
                   (past    = ('$word_token')) 
767 791
                   OR
768
                   (nonvocalized ~ ('$word_token'))
792
                   (nonvocalized = ('$word_token'))
769 793
		   OR
770
                   (nonvocalized_female ~ ('$word_token'))
794
                   (nonvocalized_female = ('$word_token'))
771 795
		   OR
772
                   (single_female ~ ('$word_token'))
796
                   (single_female = ('$word_token'))
773 797
		   OR
774
                   (nonvocalized_alternative ~ ('$word_token'))
798
                   (nonvocalized_alternative = ('$word_token'))
775 799
		   OR
776
                   (vocalized_alternative ~ ('$word_token'))
800
                   (vocalized_alternative = ('$word_token'))
777 801
                  ) 
778 802
		  AND 
779 803
                  (
780 804
                   czech NOT LIKE '' OR czech IS NOT NULL
781 805
                  )
782
               ORDER BY length(nonvocalized) LIMIT 30";
806
               ORDER BY nonvocalized LIMIT 30";
783 807

  
784 808
//	    echo $dotaz;
785 809

  
786
/*
787
	$dotaz = "SELECT * FROM dict
788
            WHERE language = $language AND
789
                  (
790
                   (past    ~ ('$word')) 
791
                   OR
792
                   (nonvocalized ~ ('$word_strict'))
793
                  ) 
794
               ORDER BY english LIMIT 30";
795
*/
796
	/*
797
      	$dotaz = "SELECT * FROM dict
798
            WHERE language = $language AND
799
                  (
800
                   (present ~ ('$word')) 
801
                   OR
802
                   (past    ~ ('$word')) 
803
                   OR
804
                   (valence ~ ('$word')) 
805
                   OR
806
                   (nonvocalized ~ ('$word_strict'))
807
                  ) 
808
               ORDER BY english LIMIT 30";
809
	       */
810
      break;
811
      case("ar"):
812
        $word = arabic_add_vowel($word);
813
        //pr($word);
814
        $dotaz = "SELECT * FROM dict
810
                /*
811
                    $dotaz = "SELECT * FROM dict
812
                            WHERE language = $language AND
813
                                  (
814
                                   (past    ~ ('$word'))
815
                                   OR
816
                                   (nonvocalized ~ ('$word_strict'))
817
                                  )
818
                               ORDER BY english LIMIT 30";
819
                */
820
                /*
821
                      $dotaz = "SELECT * FROM dict
822
                        WHERE language = $language AND
823
                              (
824
                               (present ~ ('$word'))
825
                               OR
826
                               (past    ~ ('$word'))
827
                               OR
828
                               (valence ~ ('$word'))
829
                               OR
830
                               (nonvocalized ~ ('$word_strict'))
831
                              )
832
                           ORDER BY english LIMIT 30";
833
                       */
834
                break;
835
            case("ar"):
836
                $word = arabic_add_vowel($word); //kdyžtak zakomentuj?
837
                //pr($word);
838
                $dotaz = "SELECT * FROM dict
815 839
            WHERE language = $language AND
816 840
                  ((present = '$word') OR
817 841
                   (past    = '$word') OR
818 842
                   (valence = '$word') OR
819 843
                   (root    = '$word')) 
820 844
              ORDER BY english LIMIT 30";
821
        //pr($dotaz);
822
      break;
823
      case("cz"):
824
      	$word = mb_strtolower($word, "UTF-8");
825
        $word = get_token_regexp($word); 
826
        $dotaz = "SELECT * FROM dict 
845
                //pr($dotaz);
846
                break;
847
            case("cz"):
848
                $word = mb_strtolower($word, "UTF-8");
849
                $dotaz = "SELECT * FROM dict 
827 850
                 WHERE language = $language 
828
                   AND lower(czech) ~ '$word' 
851
                   AND lower(czech) = '$word' 
829 852
                   ORDER BY english LIMIT 30";
830
    }
831
    //$dotaz .= " ORDER BY context DESC, word_voice";
832
    //echo "sql = $dotaz\n<br />";
853
        }
854
        //$dotaz .= " ORDER BY context DESC, word_voice";
855
        //echo "sql = $dotaz\n<br />";
833 856

  
834
    $radky = $spojeni->query($dotaz);
835
    if ($spojeni->num_rows() == 0)  {
836
      $text .= "<br />Slovo nebylo nalezeno";
857
        $radky = $spojeni->query($dotaz);
858
        if ($spojeni->num_rows() == 0) {
859
            $text .= "<br />Slovo nebylo nalezeno";
837 860
////////save_to_not_found($direction, $word);//vratit zpatky a opravit
861
        } else {
862
            foreach ($radky as $radka) {
863
                if ($language == 2 && $radka['autorized']) //hebrew
864
                {
865
                    $text .= __get_word_in_new_hebrew_format($radka);
866
                } else {
867
                    //dle zadani vybereme jen prvni slovo - tj. s contextem a zvukem
868
                    $text .= __get_word_in_card_format($radka);
869
                }
870
            }
871
        }
838 872
    }
839
    else {
840
      while($spojeni->next_record()) {
841
	  if($language == 2 && $spojeni->Record['autorized']) //hebrew
842
	  {
843
	    $text .= __get_word_in_new_hebrew_format($spojeni->Record);
844
	  }
845
	  else {
846
	      //dle zadani vybereme jen prvni slovo - tj. s contextem a zvukem
847
	    $text .= __get_word_in_card_format($spojeni->Record);
848
	  }
849
      }
850
    }
851
  }
852
  $text .= "\n   \n";
853
  echo $text;
873
    $text .= "\n   \n";
874
    echo $text;
854 875
}
855 876

  
856 877
/**
857 878
 *  Funkce pro preklad z cestiny, vyhleda ve slovniku
858 879
 *  vsechna slova odpovidajici parametru
859 880
 *
860
 *  @param $word slovo urcene k prekladu
861
 *  @return do tabulky zformatovany preklad
881
 * @param $word slovo urcene k prekladu
882
 * @return do tabulky zformatovany preklad
862 883
 */
863
function translate_from_cz($word) {
864
  $navrat = "";
865
  require_once("./classes/db.php");
866
  $spojeni = new DB_Sql();
867
  $dotaz = "SELECT * FROM dict WHERE lower(czech) LIKE lower('$word') ;";
868
  $radky = $spojeni->query($dotaz);
869
  $spojeni->next_record();
870
  return $spojeni->Record;
884
function translate_from_cz($word)
885
{
886
    $navrat = "";
887
    require_once("./classes/db.php");
888
    $spojeni = new DB_Sql();
889
    $dotaz = "SELECT * FROM dict WHERE lower(czech) LIKE lower('$word') ;";
890
    $radky = $spojeni->query($dotaz);
891
    $spojeni->next_record();
892
    return $spojeni->Record;
871 893
}
872 894

  
873 895
/**
874 896
 *  Funkce pro preklad z anglictiny, vyhleda ve slovniku
875 897
 *  vsechna slova odpovidajici parametru
876 898
 *
877
 *  @param $word slovo urcene k prekladu
878
 *  @return do tabulky zformatovany preklad
899
 * @param $word slovo urcene k prekladu
900
 * @return do tabulky zformatovany preklad
879 901
 */
880
function translate_from_en($word) {
881
  $navrat = "";
882
  require_once("./classes/db.php");
883
  $spojeni = new DB_Sql();
884
  $dotaz = "SELECT * FROM dict WHERE lower(english) LIKE lower('$word') ;";
885
  $radky = $spojeni->query($dotaz);
886
  $spojeni->next_record();
887
  return $spojeni->Record;
902
function translate_from_en($word)
903
{
904
    $navrat = "";
905
    require_once("./classes/db.php");
906
    $spojeni = new DB_Sql();
907
    $dotaz = "SELECT * FROM dict WHERE lower(english) LIKE lower('$word') ;";
908
    $radky = $spojeni->query($dotaz);
909
    $spojeni->next_record();
910
    return $spojeni->Record;
888 911
}
889 912

  
890 913
/**
891 914
 *  Funkce pro preklad z "tretiho" jazyka, vyhleda ve slovniku
892 915
 *  vsechna slova odpovidajici parametru
893 916
 *
894
 *  @param $word slovo urcene k prekladu
895
 *  @return do tabulky zformatovany preklad
917
 * @param $word slovo urcene k prekladu
918
 * @return do tabulky zformatovany preklad
896 919
 */
897
function translate_from_ar($word) {
898
  $navrat = "";
899
  require_once("./classes/db.php");
900
  $spojeni = new DB_Sql();
901
  $dotaz = "SELECT * FROM dict
920
function translate_from_ar($word)
921
{
922
    $navrat = "";
923
    require_once("./classes/db.php");
924
    $spojeni = new DB_Sql();
925
    $dotaz = "SELECT * FROM dict
902 926
            WHERE language = 1 AND
903 927
                  ((present LIKE '$word') OR
904 928
                   (past LIKE '$word') OR
905 929
                   (valence LIKE '$word') OR
906 930
                   (root LIKE '$word'))";
907
  $radky = $spojeni->query($dotaz);
908
  $spojeni->next_record();
909
  return $spojeni->Record;
931
    $radky = $spojeni->query($dotaz);
932
    $spojeni->next_record();
933
    return $spojeni->Record;
910 934
}
911 935

  
912 936
/**
......
917 941
 *  TODO: UPRAVIT OSTATNI DATA VKLADANA DO DB (DATA, USER, ATD...)
918 942
 *
919 943
 *
920
 *  @param $file - cesta k csv souboru
921
 *  @return true   kdyz se to povede
922
 *  @return false  naopak
944
 * @param $file - cesta k csv souboru
945
 * @return true   kdyz se to povede
946
 * @return false  naopak
923 947
 */
924
function dump_csv_file($file) {
948
function dump_csv_file($file)
949
{
925 950

  
926
  if (!file_exists($file)) {
927
    echo ("Chyba!!! Zadany soubor: $file neexistuje!!!");
928
    return false;
929
  }
930
  require_once("./classes/db.php");
951
    if (!file_exists($file)) {
952
        echo("Chyba!!! Zadany soubor: $file neexistuje!!!");
953
        return false;
954
    }
955
    require_once("./classes/db.php");
931 956

  
932
  $spojeni = new DB_Sql();
957
    $spojeni = new DB_Sql();
933 958

  
934
  $radky = file($file);
935
  echo "<table border=\"1\">\n";
936

  
937
  $pocitadlo = 0;
938

  
939
  $NOW = Date("YmdHis");
940
  for($i=0;$i<Count($radky);$i++) {
941
    if (!strpos($radky[$i], ";"))  continue;
942
    $radek = explode(';', $radky[$i]);
943
    insert_word(AddSlashes($radek[0]),//czech
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff