Changeset 49 for trunk/dictionary.php
- Timestamp:
- Jan 30, 2009, 10:33:08 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:ignore
set to
SqlTranslate.zip
-
Property svn:ignore
set to
-
trunk/dictionary.php
r43 r49 2 2 3 3 session_start(); 4 5 // SQL injection hack protection 6 foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($_POST[$Index]); 7 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]); 8 4 9 include('includes/config.php'); 5 10 include('includes/databaseconection.php'); … … 10 15 $Database->SelectDatabase($Config['Database']['Database']); 11 16 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']; 17 function Licence($Licence) 18 { 19 global $Database; 20 21 if (isset($_SESSION['User']) and $_SESSION['User'] <> '') 22 { 23 $User = $_SESSION['User']; 24 $Pass = $_SESSION['Pass']; 19 25 20 26 $Line = mysql_fetch_array($Database->SQLCommand("SELECT * FROM user WHERE LOWER(user) = LOWER('$User')")); 21 if (!$Line) { 27 if (!$Line) 28 { 22 29 return false; 23 30 } else { … … 41 48 // die('Nemáte zde přístup, přihlate se: <a href="'.$Config['Web']['BaseURL'].'">zde</a>'); 42 49 } 43 44 } // END function Licence 50 } 45 51 46 47 48 49 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 52 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 50 53 <HTML> 51 54 <HEAD> … … 56 59 <TITLE>Projekt překládání textů do WoW</TITLE> 57 60 </HEAD> 58 <body> 61 <body>'); 59 62 60 '; 61 62 if (array_key_exists('insert', $_GET)) { 63 echo '<form action="dictionary.php" method="post"> 63 if(array_key_exists('insert', $_GET)) 64 { 65 echo('<form action="dictionary.php" method="post"> 64 66 <input type="text" name="AJWord"> Anglické slovo<br> 65 67 <input type="text" name="CZWord"> České slovo<br> 66 68 <input type="text" name="description"> Popis<br> 67 69 <input type="submit" value="Uložit"> 68 </form> 69 ';70 $WinWidth = 230; 71 } else{72 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 80 echo 'Záznam byl uložen!';81 82 83 70 </form>'); 71 $WinWidth = 230; 72 } else 73 { 74 $WinWidth = 345; 75 if (array_key_exists('AJWord', $_POST)) 76 { 77 $AJWord = $_POST['AJWord']; 78 $CZWord = $_POST['CZWord']; 79 $description = $_POST['description']; 80 $user = @$_SESSION['UserID']; 81 $Database->SQLCommand("INSERT INTO `dictionary` ( `AJWord` , `CZWord` , `description` , `user` ) VALUES ('$AJWord', '$CZWord', '$description', '$user');"); 82 echo('Záznam byl uložen!'); 83 $WinWidth = 325; 84 } 85 } 84 86 87 echo('<table border="1" width="100%">'); 88 89 if(array_key_exists('search', $_GET)) 90 { 91 $Search = $_GET['search']; 92 } else 93 { 94 $Search = ''; 95 } 96 97 echo('<tr><td><form action="dictionary.php" method="get"> 98 <input type="text" value="'.$Search.'" name="search" size="30"> 99 <input type="submit" value="Vyhledat">'); 100 if(Licence(0)) 101 echo(' <a href="dictionary.php?insert">Vložit slovo</a>'); 102 103 echo('</form></td></tr>'); 104 echo('<tr><td> 105 <p style=" overflow: auto; width: 100%; height: '.$WinWidth.'px;">'); 106 //todo select 107 if($Search <> '') 108 { 109 $sql = "SELECT * FROM `dictionary` WHERE LOWER(AJWord) LIKE LOWER('%$Search%') OR LOWER(CZWord) LIKE LOWER('%$Search%') OR LOWER(description) LIKE LOWER('%$Search%')"; 110 } else 111 { 112 $sql = "SELECT * FROM `dictionary`"; 113 } 114 echo('<table border="1" cellpadding="2" cellspacing="0" width="100%"> 115 <tr><th>Eng</th> 116 <th>Cze</th> 117 <th> Popis</th></tr>'); 118 $ID = $Database->SQLCommand($sql); 119 while ($Line = mysql_fetch_array($ID)) 120 { 121 echo('<tr> 122 <td>'.$Line['AJWord'].'</td> 123 <th>'.$Line['CZWord'].'</th> 124 <td>'.$Line['description'].'</td></tr>'); 125 } 126 echo('</table>'); 85 127 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>'; 128 echo('</td></tr>'); 122 129 123 echo '</td></tr>'; 124 125 echo '</table> 126 </body>'; 130 echo('</table></body>'); 131 127 132 ?>
Note:
See TracChangeset
for help on using the changeset viewer.