source: dictionary.php@ 4

Last change on this file since 4 was 4, checked in by george, 17 years ago

Opraveno: Staré odkazy na předchozí adresu projektu.
Opraveno: Mnoho překlepů, špatných slovních spojení a gramatických chyb.

  • Property svn:executable set to *
File size: 4.2 KB
Line 
1<?php
2
3session_start();
4include('includes/config.php');
5include('includes/databaseconection.php');
6
7//pøipojení do databáze
8$Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password']);
9$Database->SQLCommand('SET NAMES '.$Config['Database']['Charset']);
10$Database->SelectDatabase($Config['Database']['Database']);
11
12
13 function Licence($Licence)
14 { // BEGIN function Licence
15 global $Database;
16 if (isset($_SESSION['User']) and $_SESSION['User'] <> '') {
17 $User = $_SESSION['User'];
18 $Pass = $_SESSION['Pass'];
19
20 $Line = mysql_fetch_array($Database->SQLCommand("SELECT * FROM user WHERE LOWER(user) = LOWER('$User')"));
21 if (!$Line) {
22 return false;
23 } else {
24 if ($Licence == 1) {
25 if ($Line['gm'] == 1) {
26 return true;
27 } else return false;
28 }
29 If ($Line['pass'] == $Pass) {
30
31 // zapsání poslení použité IP
32 // $Addres = $_SERVER['REMOTE_ADDR'];
33 // $Database->SQLCommand("UPDATE user SET LastLogin = now(), LastIP = '$Addres' WHERE user = '$User'");
34
35 return True;
36 } else { return False;
37 // die('Nemáte zde pøístup, pøihla‘te se: <a href="'.$Config['Web']['BaseURL'].'">zde</a>');
38 }
39 }
40 } else { return False;
41 // die('Nemáte zde pøístup, pøihla‘te se: <a href="'.$Config['Web']['BaseURL'].'">zde</a>');
42 }
43
44 } // END function Licence
45
46
47
48
49echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
50<HTML>
51<HEAD>
52 <META http-equiv="Content-Language" content="cs">
53 <META http-equiv="Content-Type" content="text/html; charset='.$Config['Web']['Charset'].'">
54 <META HTTP-EQUIV="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT">
55 <link rel="SHORTCUT ICON" href="/images/favicon.ico">
56 <TITLE>Projekt pøekládání textù do WoW</TITLE>
57</HEAD>
58 <body>
59
60 ';
61
62 if (array_key_exists('insert', $_GET)) {
63 echo '<form action="dictionary.php" method="post">
64 <input type="text" name="AJWord"> Anglické slovo<br>
65 <input type="text" name="CZWord"> Èeské slovo<br>
66 <input type="text" name="description"> Popis<br>
67 <input type="submit" value="Ulo¾it">
68 </form>
69 ';
70 $WinWidth = 230;
71 } else {
72 $WinWidth = 345;
73 if (array_key_exists('AJWord', $_POST)) {
74 $AJWord = $_POST['AJWord'];
75 $CZWord = $_POST['CZWord'];
76 $description = $_POST['description'];
77 $user = @$_SESSION['UserID'];
78 $Database->SQLCommand("INSERT INTO `dictionary` ( `AJWord` , `CZWord` , `description` , `user` )
79 VALUES ('$AJWord', '$CZWord', '$description', '$user');");
80 echo 'Záznam byl ulo¾en!';
81 $WinWidth = 325;
82 }
83 }
84
85
86 echo '<table border="1" width="100%">';
87
88 if (array_key_exists('search', $_GET)) {
89 $Search = $_GET['search'];
90 } else {
91 $Search = '';
92 }
93
94
95 echo '<tr><td><form action="dictionary.php" method="get">
96 <input type="text" value="'.$Search.'" name="search" size="30">
97 <input type="submit" value="Vyhledat">';
98 if (Licence(0))
99 echo ' <a href="dictionary.php?insert">Vlo¾it slovo</a>';
100
101 echo '</form></td></tr>';
102 echo '<tr><td>
103 <p style=" overflow: auto; width: 100%; height: '.$WinWidth.'px;">';
104 //todo select
105 if ($Search <> '') {
106 $sql = "SELECT * FROM `dictionary` WHERE LOWER(AJWord) LIKE LOWER('%$Search%') OR LOWER(CZWord) LIKE LOWER('%$Search%') OR LOWER(description) LIKE LOWER('%$Search%')";
107 } else {
108 $sql = "SELECT * FROM `dictionary`";
109 }
110 echo '<table border="1" cellpadding="2" cellspacing="0" width="100%">
111 <tr><th>Eng</th>
112 <th>Cze</th>
113 <th> Popis</th></tr>';
114 $ID = $Database->SQLCommand($sql);
115 while ($Line = mysql_fetch_array($ID)) {
116 echo '<tr>
117 <td>'.$Line['AJWord'].'</td>
118 <th>'.$Line['CZWord'].'</th>
119 <td>'.$Line['description'].'</td></tr>';
120 }
121 echo '</table>';
122
123 echo '</td></tr>';
124
125 echo '</table>
126 </body>';
127?>
Note: See TracBrowser for help on using the repository browser.