gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r4167 - in i18nHTML/src: admin i18nHTML


From: grothoff
Subject: [GNUnet-SVN] r4167 - in i18nHTML/src: admin i18nHTML
Date: Tue, 2 Jan 2007 20:29:40 -0800 (PST)

Author: grothoff
Date: 2007-01-02 20:29:36 -0800 (Tue, 02 Jan 2007)
New Revision: 4167

Modified:
   i18nHTML/src/admin/editor.php
   i18nHTML/src/admin/login.php
   i18nHTML/src/admin/login_form.php
   i18nHTML/src/admin/signup.php
   i18nHTML/src/admin/signup_form.php
   i18nHTML/src/admin/tables.php
   i18nHTML/src/admin/translate.php
   i18nHTML/src/i18nHTML/i18nhtml.php
   i18nHTML/src/i18nHTML/i18nhtml_config.php
Log:
log

Modified: i18nHTML/src/admin/editor.php
===================================================================
--- i18nHTML/src/admin/editor.php       2007-01-03 01:24:52 UTC (rev 4166)
+++ i18nHTML/src/admin/editor.php       2007-01-03 04:29:36 UTC (rev 4167)
@@ -17,7 +17,8 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-include("i18nHTML/i18nhtml.php");
+include_once("i18nHTML/i18nhtml.php");
+include("login.php");
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();

Modified: i18nHTML/src/admin/login.php
===================================================================
--- i18nHTML/src/admin/login.php        2007-01-03 01:24:52 UTC (rev 4166)
+++ i18nHTML/src/admin/login.php        2007-01-03 04:29:36 UTC (rev 4167)
@@ -17,8 +17,7 @@
      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
 */
-  // login management
-
+// login management
 session_start();
 if (isset($_POST['username']))
   $_SESSION['username'] = $_POST['username'];
@@ -28,7 +27,7 @@
 if ( (isset($_SESSION['username'])) &&
      (isset($_SESSION['password'])) ) {
   $username =  mysql_real_escape_string($_SESSION['username']);
-  $password =  mysql_real_escape_string(crypt($_SESSION['password']));  
+  $password =  mysql_real_escape_string(crypt($_SESSION['password']));
   $query = "SELECT allowed,uid FROM " . $i18nHTMLsqlPrefix . 
            "accounts WHERE username=\"$username\" AND password=\"$password\"";
   $result = mysql_query($query, $connection);

Modified: i18nHTML/src/admin/login_form.php
===================================================================
--- i18nHTML/src/admin/login_form.php   2007-01-03 01:24:52 UTC (rev 4166)
+++ i18nHTML/src/admin/login_form.php   2007-01-03 04:29:36 UTC (rev 4167)
@@ -1,49 +1,54 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-  <head>
-    <title>i18nHTML: login</title>
-  </head>
+<?php
+/*
+     (C) 2007 Christian Grothoff
 
-  <body>
-    <h1>i18nHTML: login</h1>
+     This code is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
 
-  <div align="center">
+     The code is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
 
+     You should have received a copy of the GNU General Public License
+     along with the code; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+include_once("i18nHTML/i18nhtml.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>";
+TITLE("i18nHTML: signup");
+echo "</head><body>";
+generateLanguageBar();
+H2("i18nHTML login");
+?>
+<div align=center>
 <form name="login_form" method="post" action="login.php">
-<table class="width50" cellspacing="1">
+<table cellspacing="1">
 <tr>
-       <td class="form-title">Login</td>
-       <td class="center">
-               <a href="signup_form.php">Request new account</a>
-       </td>
+<td width="25%"><?php W("Login");?></td>
+<td width="75%"><input type="text" name="username" size="32" maxlength="32" 
/></td>
 </tr>
-<tr class="row-1">
-       <td class="category" width="25%">Username</td>
-       <td width="75%">
-               <input type="text" name="username" size="32" maxlength="32" />
-       </td>
+<tr>
+<td><?php W("Password");?></td>
+<td><input type="password" name="password" size="32" maxlength="128" /></td>
 </tr>
-<tr class="row-2">
-       <td class="category">
-
-               Password        </td>
-       <td>
-               <input type="password" name="password" size="16" maxlength="32" 
/>
-       </td>
-</tr>
 <tr>
-       <td class="center" colspan=2>
-               <input type="submit" class="button" value="Login" />
-       </td>
+<td colspan=2><input type="submit" class="button" value="<?php W("Login");?>" 
/></td>
 </tr>
 </table>
 </form>
 </div>
-    <hr>
-    <address><a href="mailto:address@hidden";>Christian Grothoff</a></address>
-<!-- Created: Sat Dec 30 21:55:28 MST 2006 -->
-<!-- hhmts start -->
-Last modified: Mon Jan  1 22:34:39 MST 2007
-<!-- hhmts end -->
-  </body>
+<?php
+BP();
+W("Signup for accounts %s.",
+  extlink_("signup_form.php", "here"));
+EP();
+HR();
+generateFooter();
+?>
+</body>
 </html>

Modified: i18nHTML/src/admin/signup.php
===================================================================
--- i18nHTML/src/admin/signup.php       2007-01-03 01:24:52 UTC (rev 4166)
+++ i18nHTML/src/admin/signup.php       2007-01-03 04:29:36 UTC (rev 4167)
@@ -18,6 +18,13 @@
      Boston, MA 02111-1307, USA.
 */
 include("i18nHTML/i18nhtml.php");
+include_once("i18nHTML/i18nhtml.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>";
+TITLE("i18nHTML account creation");
+echo "</head><body>";
+generateLanguageBar();
+H2("i18nHTML account creation");
 
 function mkpass($length = 8) {
   $password = "";
@@ -42,30 +49,50 @@
 if ( (isset($_SESSION['username'])) &&
      (isset($_SESSION['language'])) &&
      (isset($_SESSION['email'])) ) {
-  $username =  mysql_real_escape_string($_SESSION['username']);
+  $login    =  mysql_real_escape_string($_SESSION['username']);
   $language =  mysql_real_escape_string($_SESSION['language']);
   $email    =  mysql_real_escape_string($_SESSION['email']);
   $realname =  mysql_real_escape_string($_SESSION['realname']);
   $password =  mkpass();
 
-  // FIXME: check account does not yet exist!
-  $query = "SELECT language FROM " . $i18nHTMLsqlPrefix . "accounts WHERE 
username=\"$username\";";
-  mysql_query($query, $connection);     
-  // ...
-
-  if (mail($email, 
-           "Your i18nHTML password", 
-           "Somebody, possibly you, requested an i18nHTML account.\n" .
-           "If this was not you, ignore this e-mail.\n" .
-           "Your password is '$password'.")) {
-    $password = mysql_real_escape_string($password);
-    $password = crypt($password);
-    $query = "INSERT INTO " . $i18nHTMLsqlPrefix . "accounts 
VALUES(\"$username\",\"$password\",\"$realname\",\"$language\",0);";
-    mysql_query($query, $connection);     
-    echo "E-mail with password sent.\n";
-  } else
-    echo "Failed to sent E-mail with password.\n";
-} else {
-  echo "Invalid inputs.\n";
-}
+  $query = "SELECT lang FROM ${i18nHTMLsqlPrefix}languages WHERE 
lang=\"$language\";";
+  $result = mysql_query($query, $connection);     
+  $num = 0;
+  if ($result)
+    $num = mysql_numrows($result);
+  if ($num == 0) {
+    W("This language is not legal for this system.");
+    W("You may want to ask the operator to add it to the set of legal 
languages.");
+  } else {
+    $query = "SELECT realname FROM ${i18nHTMLsqlPrefix}accounts WHERE 
username=\"$login\";";
+    $result = mysql_query($query, $connection);     
+    $num = 0;
+    if ($result)
+      $num = mysql_numrows($result);
+    if ($num > 0) {
+      $row = mysql_fetch_array($row);
+      W("Somebody with the name '%s' is already using this login.  Please try 
another login.\n",
+       $row['realname']);
+    } else {
+      if (mail($email, 
+              "Your i18nHTML password", 
+              "Somebody, possibly you, requested an i18nHTML account.\n" .
+              "If this was not you, ignore this e-mail.\n" .
+              "Otherwise, your password is '$password'.")) {
+       $password = mysql_real_escape_string($password);
+       $password = crypt($password);
+       $query = "INSERT INTO " . $i18nHTMLsqlPrefix . "accounts 
VALUES(\"$username\",\"$password\",\"$realname\",\"$language\",0);";
+       mysql_query($query, $connection);     
+       W("E-mail with password sent, login %s.\n",
+         extlink_("login.php", "here"));
+      } else {
+       W("Failed to sent E-mail with password.\n");
+      }
+    }
+  } else {
+    W("Invalid inputs.\n");
+  }
+ }
+generateFooter();
+echo "</body></html>\n";
 ?>
\ No newline at end of file

Modified: i18nHTML/src/admin/signup_form.php
===================================================================
--- i18nHTML/src/admin/signup_form.php  2007-01-03 01:24:52 UTC (rev 4166)
+++ i18nHTML/src/admin/signup_form.php  2007-01-03 04:29:36 UTC (rev 4167)
@@ -1,63 +1,71 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-  <head>
-    <title>i18nHTML: signup</title>
-  </head>
+<?php
+/*
+     (C) 2007 Christian Grothoff
 
-  <body>
-    <h1>i18nHTML: signup</h1>
+     This code is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
 
-  <div align="center">
+     The code is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
 
+     You should have received a copy of the GNU General Public License
+     along with the code; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+include_once("i18nHTML/i18nhtml.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>";
+TITLE("i18nHTML: signup");
+echo "</head><body>";
+generateLanguageBar();
+H2("Sign up for a new i18nHTML account");
+?>
+<div align=center>
 <form name="login_form" method="post" action="signup.php">
-<table class="width50" cellspacing="1">
+<table cellspacing="1">
 <tr>
-       <td class="form-title">Create new account</td>
+<td width="25%"><?php W("Desired login");?></td>
+<td width="75%"><input type="text" name="username" size="32" maxlength="32" 
/></td>
 </tr>
-<tr class="row-1">
-        <td class="category" width="25%">Desired login</td>
-       <td width="75%">
-               <input type="text" name="username" size="32" maxlength="32" />
-       </td>
+<tr>
+<td width="25%"><?php W("Real name");?></td>
+<td width="75%"><input type="text" name="realname" size="32" maxlength="32" 
/></td>
 </tr>
-<tr class="row-2">
-        <td class="category" width="25%">Real name</td>
-       <td width="75%">
-               <input type="text" name="realname" size="32" maxlength="32" />
-       </td>
+<tr>
+<td><?php W("Email");?></td>
+<td><input type="email" name="email" size="32" maxlength="128" /></td>
 </tr>
-<tr class="row-3">
-       <td class="category">
-
-               Email   </td>
-       <td>
-               <input type="email" name="email" size="32" maxlength="128" />
-       </td>
+<tr>
+<td><?php W("Language");?></td>
+<td>
+<?php
+    $query = "SELECT lang FROM ${i18nHTMLsqlPrefix}languages ORDER BY lang";
+    $result = mysql_query($query, $connection);
+    $num = 0;
+    if ($result)
+      $num = mysql_numrows($result);
+    while ($num-- > 0) {
+      $row = mysql_fetch_array($result);
+      $dblang = $row['lang'];
+      echo "<input type=\"radio\" name=\"language\" value=\"$dblang\">$dblang 
/>";
+    }
+?>
+</td>
 </tr>
-<tr class="row-4">
-       <td class="category">
-
-               Target translation language</td>
-       <td>
-    <!-- FIXME: provide list of valid languages in the system! -->
-               <input type="language" name="language" size="32" maxlength="32" 
/>
-       </td>
-</tr>
 <tr>
-       <td class="center" colspan="2">
-               <input type="submit" class="button" value="Signup" />
-       </td>
+<td colspan="2"><input type="submit" class="button" value="<?php 
W("Signup");?>"/></td>
 </tr>
 </table>
 </form>
 </div>
-
-
-    <hr>
-    <address><a href="mailto:address@hidden";>Christian Grothoff</a></address>
-<!-- Created: Sat Dec 30 21:55:28 MST 2006 -->
-<!-- hhmts start -->
-Last modified: Sat Dec 30 21:58:14 MST 2006
-<!-- hhmts end -->
-  </body>
+<hr>
+<?php
+generateFooter();
+?>
+</body>
 </html>

Modified: i18nHTML/src/admin/tables.php
===================================================================
--- i18nHTML/src/admin/tables.php       2007-01-03 01:24:52 UTC (rev 4166)
+++ i18nHTML/src/admin/tables.php       2007-01-03 04:29:36 UTC (rev 4167)
@@ -19,7 +19,7 @@
 */
 include("i18nHTML/i18nhtml.php");
 // ensure the mapping and pending tables exist, creating them if not
-$query="CREATE TABLE IF NOT EXISTS " . $i18nHTMLsqlPrefix . "map" .
+$query="CREATE TABLE IF NOT EXISTS ${i18nHTMLsqlPrefix}map" .
        " (name BLOB, lang TINYBLOB, translation BLOB, ranking INT, ip 
TINYTEXT, uid INT, " .
        "INDEX(name(10)), INDEX(lang(4)), INDEX(ranking), 
INDEX(translation(10)))";
 $result = mysql_query($query, $connection);
@@ -27,7 +27,7 @@
   die('Unable to initialize map table.  Invalid query: ' . mysql_error());
 }
 
-$query="CREATE TABLE IF NOT EXISTS " . $i18nHTMLsqlPrefix . "pending" .
+$query="CREATE TABLE IF NOT EXISTS ${i18nHTMLsqlPrefix}pending" .
        " (c BLOB, lang TINYBLOB, count INT, " .
        "INDEX(c(10)), INDEX(lang(4)), INDEX(count))";
 $result = mysql_query($query, $connection);
@@ -35,7 +35,7 @@
   die('Unable to initialize pending table.  Invalid query: ' . mysql_error());
 }
 
-$query="CREATE TABLE IF NOT EXISTS " . $i18nHTMLsqlPrefix . "accounts" .
+$query="CREATE TABLE IF NOT EXISTS ${i18nHTMLsqlPrefix}accounts" .
        " (username TINYBLOB, password BLOB, realname BLOB, allowed BLOB, level 
INT, uid BIGINT NOT NULL AUTO_INCREMENT, " .
        "INDEX(username(10)), PRIMARY KEY(uid))";
 $result = mysql_query($query, $connection);
@@ -43,6 +43,19 @@
   die('Unable to initialize accounts table.  Invalid query: ' . mysql_error());
 }
 
+// setup root account
+$query="INSERT INTO ${i18nHTMLsqlPrefix}accounts VALUES(\"root\", \"" . 
mysql_real_escape_string(crypt($i18nHTMLsqlAdminPass)) . "\", 
\"Administrator\", \"$i18nHTMLsrcLang\", 9999, 0)";
+       "INDEX(c(10)), INDEX(lang(4)), INDEX(count))";
+mysql_query($query, $connection);
+
+
+$query="CREATE TABLE IF NOT EXISTS ${i18nHTMLsqlPrefix}languages" .
+       " (lang TINYBLOB, dodef INT, INDEX(lang(10)))";
+$result = mysql_query($query, $connection);
+if (!$result) {
+  die('Unable to initialize languages table.  Invalid query: ' . 
mysql_error());
+}
+
 echo "Tables created.\n";
 
 echo "</body></html>";
\ No newline at end of file

Modified: i18nHTML/src/admin/translate.php
===================================================================
--- i18nHTML/src/admin/translate.php    2007-01-03 01:24:52 UTC (rev 4166)
+++ i18nHTML/src/admin/translate.php    2007-01-03 04:29:36 UTC (rev 4167)
@@ -18,6 +18,7 @@
      Boston, MA 02111-1307, USA.
 */
 include("i18nHTML/i18nhtml.php");
+include("login.php");
 if (!$connection) {
   echo "Database is down. Cannot edit translations.";
   die();

Modified: i18nHTML/src/i18nHTML/i18nhtml.php
===================================================================
--- i18nHTML/src/i18nHTML/i18nhtml.php  2007-01-03 01:24:52 UTC (rev 4166)
+++ i18nHTML/src/i18nHTML/i18nhtml.php  2007-01-03 04:29:36 UTC (rev 4167)
@@ -760,25 +760,18 @@
   global $i18nHTMLsrcLang;
 
   if ($connection) {
-    echo "<center>[";
-    $query = "SELECT DISTINCT lang FROM ".$i18nHTMLsqlPrefix."map ORDER BY 
lang";
-//     die($query);
+    $query = "SELECT lang FROM ${i18nHTMLsqlPrefix}languages ORDER BY lang";
     $result = mysql_query($query, $connection);
     $num = 0;
     if ($result)
       $num = mysql_numrows($result);
-    echo "<a href=\"?xlang=" . $i18nHTMLsrcLang . "\">";
-    W($i18nHTMLsrcLang);
-    echo "</a>";
-    $last = $i18nHTMLsrcLang;
-    for ($i=0;$i<$num;$i++) {
+    echo "<center>[<a href=\"?xlang=${i18nHTMLsrcLang}\">" . 
W_($i18nHTMLsrcLang) . "</a>";
+    while ($num-- > 0) {
       $row = mysql_fetch_array($result);
       $next = $row["lang"];
-      if ($next == $last)
-        continue;
-      echo " | ";
-      echo "<a href=\"?xlang=$next\">" . W_($next) . "</a>";
-      $last = $next;
+      if ($next == $i18nHTMLsrcLang)
+       continue;
+      echo " | <a href=\"?xlang=$next\">" . W_($next) . "</a>";
     }
     echo "]</center>";
   }

Modified: i18nHTML/src/i18nHTML/i18nhtml_config.php
===================================================================
--- i18nHTML/src/i18nHTML/i18nhtml_config.php   2007-01-03 01:24:52 UTC (rev 
4166)
+++ i18nHTML/src/i18nHTML/i18nhtml_config.php   2007-01-03 04:29:36 UTC (rev 
4167)
@@ -46,6 +46,11 @@
 $i18nHTMLsqlPass = "pass";
 
 /**
+ * Password for i18nHTML web admin access.
+ */
+$i18nHTMLsqlAdminPass = "pass";
+
+/**
  * Prefix to all SQL table names used by i18nHTML.
  */
 $i18nHTMLsqlPrefix = ""; 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]