gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r4160 - in i18nHTML/src: admin examples i18nHTML


From: grothoff
Subject: [GNUnet-SVN] r4160 - in i18nHTML/src: admin examples i18nHTML
Date: Mon, 1 Jan 2007 21:35:38 -0800 (PST)

Author: grothoff
Date: 2007-01-01 21:35:32 -0800 (Mon, 01 Jan 2007)
New Revision: 4160

Added:
   i18nHTML/src/admin/index.php
   i18nHTML/src/admin/login.php
   i18nHTML/src/admin/signup.php
   i18nHTML/src/admin/signup_form.php
   i18nHTML/src/admin/tables.php
Removed:
   i18nHTML/src/admin/signup_form.html
Modified:
   i18nHTML/src/admin/login_form.html
   i18nHTML/src/examples/example.php
   i18nHTML/src/examples/example2.php
   i18nHTML/src/examples/start.php
   i18nHTML/src/i18nHTML/i18nhtml.php
Log:
stuff

Added: i18nHTML/src/admin/index.php
===================================================================
--- i18nHTML/src/admin/index.php        2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/admin/index.php        2007-01-02 05:35:32 UTC (rev 4160)
@@ -0,0 +1,48 @@
+<?php
+/*
+     (C) 2006, 2007 Christian Grothoff
+
+     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.
+
+     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("i18nHTML/i18nhtml.php");
+include("login.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>";
+TITLE("WWW translation: Administration");
+echo "</head><body>";
+W("This is the i18nHTML administrative interface.");
+echo "<ul>\n";
+LILI("status.php", "Display statistics");
+LILI("editor.php", "Go to mass translation");
+LILI("tables.php", "Initialize tables");
+
+// search for suspicious translations
+// LILI("dig.php", "Search for suspicious translations");
+
+// allow admins to delete translations of lower-level
+// accounts
+// LILI("delete.php", "Administer translations");
+
+// allow admins to delete accounts (& all translations)
+// of lower-level or to grant administrative priviledges
+// LILI("accounts.php", "Manage acconts");
+
+// have a table with legal languages (for signing up)
+// LILI("languages.php", "Setup languages");
+
+echo "</ul>\n";
+generateFooter();
+echo "</body></html>";
\ No newline at end of file

Added: i18nHTML/src/admin/login.php
===================================================================
--- i18nHTML/src/admin/login.php        2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/admin/login.php        2007-01-02 05:35:32 UTC (rev 4160)
@@ -0,0 +1,53 @@
+<?php
+/*
+     (C) 2006 Christian Grothoff
+
+     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.
+
+     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.
+*/
+  // login management
+
+session_start();
+if (isset($_POST['username']))
+  $_SESSION['username'] = $_POST['username'];
+if (isset($_POST['password']))
+  $_SESSION['password'] = $_POST['password'];
+$uid = -1;
+if ( (isset($_SESSION['username'])) &&
+     (isset($_SESSION['password'])) ) {
+  $username = $_SESSION['username'];
+  $password = crypt($_SESSION['password']);  
+  $query = "SELECT allowed,uid FROM " . $i18nHTMLsqlPrefix . "accounts WHERE 
username=\"$username\" AND password=\"$password\"";
+  $result = mysql_query($query, $connection);
+  $num = 0;
+  if ($result)
+    $num = mysql_numrows($result);
+  $count = 0;
+  while ($num > 0) {
+    $row = mysql_fetch_array($result);
+    $allowed = $row["allowed"];
+    if ($allowed == $xlang) {
+      $uid = $row["uid"];
+      break;
+    }
+    $num--;
+  }  
+}
+if ($uid == -1) {
+  include("login_form.html");
+  exit();
+}
+
+?>
\ No newline at end of file

Modified: i18nHTML/src/admin/login_form.html
===================================================================
--- i18nHTML/src/admin/login_form.html  2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/admin/login_form.html  2007-01-02 05:35:32 UTC (rev 4160)
@@ -13,6 +13,9 @@
 <table class="width50" cellspacing="1">
 <tr>
        <td class="form-title">Login</td>
+       <td class="center">
+               <a href="signup_form.php">Request new account</a>
+       </td>
 </tr>
 <tr class="row-1">
        <td class="category" width="25%">Username</td>
@@ -29,20 +32,18 @@
        </td>
 </tr>
 <tr>
-       <td class="center" colspan="2">
+       <td class="center" colspan=2>
                <input type="submit" class="button" value="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: Sat Dec 30 21:58:14 MST 2006
+Last modified: Mon Jan  1 22:34:39 MST 2007
 <!-- hhmts end -->
   </body>
 </html>

Added: i18nHTML/src/admin/signup.php
===================================================================
--- i18nHTML/src/admin/signup.php       2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/admin/signup.php       2007-01-02 05:35:32 UTC (rev 4160)
@@ -0,0 +1,61 @@
+<?php
+/*
+     (C) 2006 Christian Grothoff
+
+     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.
+
+     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("i18nHTML/i18nhtml.php");
+
+function mkpass($length = 8) {
+  $password = "";
+  $possible = "0123456789abcdefghijkmnopqrstuvwxyz"; 
+  $i = 0; 
+  while ($i < $length) { 
+    $password .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
+    $i++;
+  }
+  return $password;
+}
+
+session_start();
+if (isset($_POST['username']))
+  $_SESSION['username'] = $_POST['username'];
+if (isset($_POST['email']))
+  $_SESSION['email'] = $_POST['email'];
+if (isset($_POST['language']))
+  $_SESSION['language'] = $_POST['language'];
+if ( (isset($_SESSION['username'])) &&
+     (isset($_SESSION['language'])) &&
+     (isset($_SESSION['email'])) ) {
+  $username = $_SESSION['username'];
+  $language = $_SESSION['language'];
+  $email    = $_SESSION['email'];
+  $password = mkpass();
+  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 = crypt($password);
+    $query = "INSERT INTO " . $i18nHTMLsqlPrefix . "accounts 
VALUES(\"$username\",\"$password\",\"$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";
+}
+?>
\ No newline at end of file

Deleted: i18nHTML/src/admin/signup_form.html
===================================================================
--- i18nHTML/src/admin/signup_form.html 2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/admin/signup_form.html 2007-01-02 05:35:32 UTC (rev 4160)
@@ -1,56 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-  <head>
-    <title>i18nHTML: signup</title>
-  </head>
-
-  <body>
-    <h1>i18nHTML: signup</h1>
-
-  <div align="center">
-
-<form name="login_form" method="post" action="signup.php">
-<table class="width50" cellspacing="1">
-<tr>
-       <td class="form-title">Login</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>
-<tr class="row-2">
-       <td class="category">
-
-               Email   </td>
-       <td>
-               <input type="email" name="email" size="32" maxlength="128" />
-       </td>
-</tr>
-<tr class="row-3">
-       <td class="category">
-
-               Target translation language</td>
-       <td>
-               <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>
-</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>
-</html>

Added: i18nHTML/src/admin/signup_form.php
===================================================================
--- i18nHTML/src/admin/signup_form.php  2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/admin/signup_form.php  2007-01-02 05:35:32 UTC (rev 4160)
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <title>i18nHTML: signup</title>
+  </head>
+
+  <body>
+    <h1>i18nHTML: signup</h1>
+
+  <div align="center">
+
+<form name="login_form" method="post" action="signup.php">
+<table class="width50" cellspacing="1">
+<tr>
+       <td class="form-title">Login</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>
+<tr class="row-2">
+       <td class="category">
+
+               Email   </td>
+       <td>
+               <input type="email" name="email" size="32" maxlength="128" />
+       </td>
+</tr>
+<tr class="row-3">
+       <td class="category">
+
+               Target translation language</td>
+       <td>
+               <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>
+</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>
+</html>

Added: i18nHTML/src/admin/tables.php
===================================================================
--- i18nHTML/src/admin/tables.php       2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/admin/tables.php       2007-01-02 05:35:32 UTC (rev 4160)
@@ -0,0 +1,48 @@
+<?php
+/*
+     (C) 2006 Christian Grothoff
+
+     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.
+
+     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("i18nHTML/i18nhtml.php");
+// ensure the mapping and pending tables exist, creating them if not
+$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);
+if (!$result) {
+  die('Unable to initialize map table.  Invalid query: ' . mysql_error());
+}
+
+$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);
+if (!$result) {
+  die('Unable to initialize pending table.  Invalid query: ' . mysql_error());
+}
+
+$query="CREATE TABLE IF NOT EXISTS " . $i18nHTMLsqlPrefix . "accounts" .
+       " (username TINYBLOB, password BLOB, allowed BLOB, level INT, uid 
BIGINT NOT NULL AUTO_INCREMENT, " .
+       "INDEX(username(10)), PRIMARY KEY(uid))";
+$result = mysql_query($query, $connection);
+if (!$result) {
+  die('Unable to initialize accounts table.  Invalid query: ' . mysql_error());
+}
+
+echo "Tables created.\n";
+
+echo "</body></html>";
\ No newline at end of file

Modified: i18nHTML/src/examples/example.php
===================================================================
--- i18nHTML/src/examples/example.php   2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/examples/example.php   2007-01-02 05:35:32 UTC (rev 4160)
@@ -1,5 +1,5 @@
 <?php
-include("i18nhtml.inc.php");
+include("i18nHTML/i18nhtml.php");
 DOCTYPE("HTML");
 echo "<html><head>";
 TITLE("Example page");

Modified: i18nHTML/src/examples/example2.php
===================================================================
--- i18nHTML/src/examples/example2.php  2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/examples/example2.php  2007-01-02 05:35:32 UTC (rev 4160)
@@ -1,5 +1,5 @@
 <?php
-include("i18nhtml.inc.php");  // do this 1st, add translation support
+include("i18nHTML/i18nhtml.php");  // do this 1st, add translation support
 DOCTYPE("HTML","Transitional");         // tell the user agent document format
 setTranslateLinkMarker("***");          // make translation marker more visible
 editOnlyUntranslatedText();             // restrict translations to 
untranslated strings

Modified: i18nHTML/src/examples/start.php
===================================================================
--- i18nHTML/src/examples/start.php     2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/examples/start.php     2007-01-02 05:35:32 UTC (rev 4160)
@@ -1,5 +1,5 @@
 <?php
-include("i18nhtml.inc.php");
+include("i18nHTML/i18nhtml.php");
 DOCTYPE("HTML", "Transitional");
 echo "<html><head>\n";
 TITLE("Documentation");

Modified: i18nHTML/src/i18nHTML/i18nhtml.php
===================================================================
--- i18nHTML/src/i18nHTML/i18nhtml.php  2007-01-02 03:25:53 UTC (rev 4159)
+++ i18nHTML/src/i18nHTML/i18nhtml.php  2007-01-02 05:35:32 UTC (rev 4160)
@@ -1,6 +1,6 @@
 <?php
 /*
-     (C) 2003, 2004, 2005, 2006 Christian Grothoff and other contributing 
authors.
+     (C) 2003, 2004, 2005, 2006, 2007 Christian Grothoff and other 
contributing authors.
 
      This code is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -38,15 +38,12 @@
 include("i18nhtml_config.php");
 header("Content-type: text/html; charset=utf-8");
 
-// if (get_magic_quotes_gpc())
-//   die('PHP misconfigured.  Disable get_magic_quotes.');
-
 // establish default connection to database server
-$connection = mysql_connect($i18nHTMLsqlServer,
-                           $i18nHTMLsqlUser,
-                           $i18nHTMLsqlPass);
+$connection = @mysql_connect($i18nHTMLsqlServer,
+                            $i18nHTMLsqlUser,
+                            $i18nHTMLsqlPass);
 if (!$connection) {
-   die ('Failure connecting to ' . $i18nHTMLsqlServer . ' : ' . mysql_error());
+   die ('Failure connecting to ' . $i18nHTMLsqlServer . ': ' . mysql_error());
 }
 
 // and select database on server that holds translations
@@ -798,7 +795,7 @@
   global $i18nHTMLsrcLang;
 
   P();
-  echo "Translation engine based on <a 
href=\"http://gnunet.org/i18nHTML/\";>i18nHTML</a> (C) 2003, 2004, 2005, 2006 <a 
href=\"http://grothoff.org/christian/\";>Christian Grothoff</a>.<br />\n";
+  echo "Translation engine based on <a 
href=\"http://gnunet.org/i18nHTML/\";>i18nHTML</a> (C) 2003, 2004, 2005, 2006, 
2007 <a href=\"http://grothoff.org/christian/\";>Christian Grothoff</a>.<br 
/>\n";
   if ( ($xlang) && ($xlang != $i18nHTMLsrcLang) ) {
     $protocol = "http";
     if ($HTTP_SERVER_VARS["HTTPS"] == "on") {





reply via email to

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