[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4174 - in i18nHTML/src: . admin i18nHTML
From: |
grothoff |
Subject: |
[GNUnet-SVN] r4174 - in i18nHTML/src: . admin i18nHTML |
Date: |
Tue, 2 Jan 2007 23:40:37 -0800 (PST) |
Author: grothoff
Date: 2007-01-02 23:40:32 -0800 (Tue, 02 Jan 2007)
New Revision: 4174
Added:
i18nHTML/src/admin/accounts.php
i18nHTML/src/admin/add_language.php
i18nHTML/src/admin/languages.php
i18nHTML/src/admin/manage_account.php
Modified:
i18nHTML/src/admin/index.php
i18nHTML/src/admin/login.php
i18nHTML/src/admin/login_form.php
i18nHTML/src/admin/signup.php
i18nHTML/src/admin/tables.php
i18nHTML/src/i18nHTML/i18nhtml.php
i18nHTML/src/update0_3_0.php
Log:
added account managment -- untested
Added: i18nHTML/src/admin/accounts.php
===================================================================
--- i18nHTML/src/admin/accounts.php 2007-01-03 05:11:39 UTC (rev 4173)
+++ i18nHTML/src/admin/accounts.php 2007-01-03 07:40:32 UTC (rev 4174)
@@ -0,0 +1,64 @@
+<?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_once("i18nHTML/i18nhtml.php");
+include("login.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>";
+TITLE("i18nHTML account administration");
+echo "</head><body>";
+generateLanguageBar();
+H2("i18nHTML account administration");
+
+if ( (uid <= 0) || ($level <= 0) ) {
+ W("Only authorized users can administer accounts.");
+ die();
+ }
+
+$query = "SELECT username,realname,level,uid FROM ${i18nHTMLsqlPrefix}accounts
WHERE level < $level";
+if ($uid != 1)
+ $query = $query + " AND allowed=$xlang";
+$result = mysql_query($query, $connection);
+$num = 0;
+if ($result)
+ $num = mysql_numrows($result);
+if ($num == 0) {
+ W("There are no accounts that you are authorized to administer at this
time.");
+ die();
+ }
+echo "<table border=2>";
+echo "<tr><th>Login</th><th>Real
name</th><th>Level</th><th>Actions</th></tr>\n";
+while ($num-- > 0) {
+ $row = mysql_fetch_array($row);
+ $log = $row['login'];
+ $rn = $row['realname'];
+ $lev = $row['level'];
+ $cid = $row['uid'];
+ echo "<tr><td>$log</td><td>$rn</td><td>$lev</td>";
+ echo "<td>";
+ echo "<a href=\"manage_account.php?cid=$cid&action=delete\">delete</a>,";
+ echo "<a href=\"manage_account.php?cid=$cid&action=kill\">kill</a>,";
+ echo "<a href=\"manage_account.php?cid=$cid&action=promote\">promote</a>,";
+ echo "<a href=\"manage_account.php?cid=$cid&action=demote\">demote</a>";
+ echo "</td></tr>\n";
+ }
+echo "</table>";
+generateFooter();
+echo "</body></html>\n";
+?>
\ No newline at end of file
Added: i18nHTML/src/admin/add_language.php
===================================================================
--- i18nHTML/src/admin/add_language.php 2007-01-03 05:11:39 UTC (rev 4173)
+++ i18nHTML/src/admin/add_language.php 2007-01-03 07:40:32 UTC (rev 4174)
@@ -0,0 +1,57 @@
+<?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_once("i18nHTML/i18nhtml.php");
+include("login.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>";
+TITLE("i18nHTML language addition");
+echo "</head><body>";
+generateLanguageBar();
+if ($uid != 1) {
+ W("Only the administrator can add new languages.");
+ die();
+ }
+session_start();
+if (! isset($_POST['newlang'])) {
+ W("No language specified!");
+ die();
+ }
+$newlang = mysql_real_escape_string($_POST['newlang']);
+
+$query = "SELECT lang FROM ${i18nHTMLsqlPrefix}languages WHERE
lang=\"$newlang\";";
+$result = mysql_query($query, $connection);
+$num = 0;
+if ($result)
+ $num = mysql_numrows($result);
+if ($num != 0) {
+ W("This language already exists.");
+ die();
+ }
+$doesdef = $_POST['def'];
+if ($doesdef != "1")
+ $doesdef = "0";
+$query = "INSERT INTO ${i18nHTMLsqlPrefix}languages VALUES (\"$newlang\",
$doesdef)";
+mysql_query($query, $connection);
+
+W("Language %s added.",
+ $newlang);
+generateFooter();
+echo "</body></html>\n";
+?>
\ No newline at end of file
Modified: i18nHTML/src/admin/index.php
===================================================================
--- i18nHTML/src/admin/index.php 2007-01-03 05:11:39 UTC (rev 4173)
+++ i18nHTML/src/admin/index.php 2007-01-03 07:40:32 UTC (rev 4174)
@@ -42,10 +42,10 @@
echo "<ul>\n";
// allow admins to delete accounts (& all translations)
// of lower-level or to grant administrative priviledges
-// LILI("accounts.php", "Manage acconts");
+LILI("accounts.php", "Manage acconts");
// have a table with legal languages (for signing up)
-// LILI("languages.php", "Setup languages");
+LILI("languages.php", "Setup languages");
echo "</ul>\n";
Added: i18nHTML/src/admin/languages.php
===================================================================
--- i18nHTML/src/admin/languages.php 2007-01-03 05:11:39 UTC (rev 4173)
+++ i18nHTML/src/admin/languages.php 2007-01-03 07:40:32 UTC (rev 4174)
@@ -0,0 +1,51 @@
+<?php
+/*
+ (C) 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_once("i18nHTML/i18nhtml.php");
+include("login.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>";
+TITLE("i18nHTML: setup languages");
+echo "</head><body>";
+generateLanguageBar();
+H2("Add language");
+?>
+<div align=center>
+<form name="lang_form" method="post" action="add_language.php">
+<table cellspacing="1">
+<tr>
+<td width="25%"><?php W("New language");?></td>
+<td width="75%"><input type="text" name="newlang" size="32" maxlength="32"
/></td>
+</tr>
+<tr>
+<td width="25%"><?php W("Default translations apply");?></td>
+<td width="75%"><input type="checkbox" name="def" value="1" /></td>
+</tr>
+<tr>
+<td colspan="2"><input type="submit" class="button" value="<?php
W("Submit");?>"/></td>
+</tr>
+</table>
+</form>
+</div>
+<hr>
+<?php
+generateFooter();
+?>
+</body>
+</html>
Modified: i18nHTML/src/admin/login.php
===================================================================
--- i18nHTML/src/admin/login.php 2007-01-03 05:11:39 UTC (rev 4173)
+++ i18nHTML/src/admin/login.php 2007-01-03 07:40:32 UTC (rev 4174)
@@ -18,17 +18,19 @@
Boston, MA 02111-1307, USA.
*/
// login management
+include_once("i18nHTML/i18nhtml.php");
session_start();
if (isset($_POST['username']))
$_SESSION['username'] = $_POST['username'];
if (isset($_POST['password']))
$_SESSION['password'] = $_POST['password'];
$uid = -1;
+$level = -1;
if ( (isset($_SESSION['username'])) &&
(isset($_SESSION['password'])) ) {
$username = mysql_real_escape_string($_SESSION['username']);
$password = mysql_real_escape_string(crypt($_SESSION['password']));
- $query = "SELECT allowed,uid FROM " . $i18nHTMLsqlPrefix .
+ $query = "SELECT allowed,uid,level FROM " . $i18nHTMLsqlPrefix .
"accounts WHERE username=\"$username\" AND password=\"$password\"";
$result = mysql_query($query, $connection);
$num = 0;
@@ -40,11 +42,16 @@
$allowed = $row["allowed"];
if ($allowed == $xlang) {
$uid = $row["uid"];
+ $level = $row["level"];
break;
}
$num--;
}
-}
+ if ($uid == -1)
+ $error_message = W_("Invalid login `%s` or password `%s`!",
+ ARRAY($username,
+ $password));
+ }
if ($uid == -1) {
include("login_form.php");
exit();
Modified: i18nHTML/src/admin/login_form.php
===================================================================
--- i18nHTML/src/admin/login_form.php 2007-01-03 05:11:39 UTC (rev 4173)
+++ i18nHTML/src/admin/login_form.php 2007-01-03 07:40:32 UTC (rev 4174)
@@ -24,6 +24,8 @@
echo "</head><body>";
generateLanguageBar();
H2("i18nHTML login");
+if (isset($error_message))
+ echo $error_message;
?>
<div align=center>
<form name="login_form" method="post" action="login.php">
Added: i18nHTML/src/admin/manage_account.php
===================================================================
--- i18nHTML/src/admin/manage_account.php 2007-01-03 05:11:39 UTC (rev
4173)
+++ i18nHTML/src/admin/manage_account.php 2007-01-03 07:40:32 UTC (rev
4174)
@@ -0,0 +1,86 @@
+<?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_once("i18nHTML/i18nhtml.php");
+include("login.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>";
+TITLE("i18nHTML account administration");
+echo "</head><body>";
+generateLanguageBar();
+H2("i18nHTML account administration");
+
+if ( (uid <= 0) || ($level <= 0) ) {
+ W("Only authorized users can administer accounts.");
+ die();
+ }
+if (! isset($_REQUEST['cid'])) {
+ W("Invalid invocation.");
+ die();
+ }
+$cid = $_REQUEST['cid'];
+if (! isset($_REQUEST['action'])) {
+ W("Invalid invocation.");
+ die();
+ }
+$action = $_REQUEST['action'];
+
+$query = "SELECT level FROM ${i18nHTMLsqlPrefix}accounts WHERE level < $level
AND uid=$cid";
+if ($uid != 1)
+ $query = $query + " AND allowed=$xlang";
+$result = mysql_query($query, $connection);
+$num = 0;
+if ($result)
+ $num = mysql_numrows($result);
+if ($num == 0) {
+ W("You did not select an account that you are authorized to administer at
this time.");
+ die();
+ }
+if ($action == "delete") {
+ $query = "DELETE FROM ${i18nHTMLsqlPrefix}accounts WHERE uid=$cid";
+ mysql_query($query, $connection);
+ W("Account deleted.");
+ die();
+ }
+if ($action == "kill") {
+ $query = "DELETE FROM ${i18nHTMLsqlPrefix}map WHERE uid=$cid";
+ mysql_query($query, $connection);
+ W("All translations added by this account deleted.");
+ $query = "DELETE FROM ${i18nHTMLsqlPrefix}accounts WHERE uid=$cid";
+ mysql_query($query, $connection);
+ W("Account deleted.");
+ die();
+ }
+$row = mysql_fetch_array($row);
+$nlevel = $row['level'];
+if ($action == "promote")
+ $nlevel++;
+ else if ($action == "demote")
+ $nlevel--;
+if ($nlevel != $row['level']) {
+ $query = "UPDATE TABLE ${i18nHTMLsqlPrefix}accounts SET level=$nlevel WHERE
uid=$cid";
+ mysql_query($query, $connection);
+ W("Account ${action}d to level $nlevel.");
+ } else {
+ W("Specified action '%s' unknown.",
+ $action);
+ }
+generateFooter();
+echo "</body></html>\n";
+?>
\ No newline at end of file
Modified: i18nHTML/src/admin/signup.php
===================================================================
--- i18nHTML/src/admin/signup.php 2007-01-03 05:11:39 UTC (rev 4173)
+++ i18nHTML/src/admin/signup.php 2007-01-03 07:40:32 UTC (rev 4174)
@@ -17,7 +17,6 @@
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-include("i18nHTML/i18nhtml.php");
include_once("i18nHTML/i18nhtml.php");
DOCTYPE("HTML", "Transitional");
echo "<html><head>";
Modified: i18nHTML/src/admin/tables.php
===================================================================
--- i18nHTML/src/admin/tables.php 2007-01-03 05:11:39 UTC (rev 4173)
+++ i18nHTML/src/admin/tables.php 2007-01-03 07:40:32 UTC (rev 4174)
@@ -1,6 +1,6 @@
<?php
/*
- (C) 2006 Christian Grothoff
+ (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
@@ -44,18 +44,26 @@
}
// setup root account
-$query="INSERT INTO ${i18nHTMLsqlPrefix}accounts VALUES(\"root\", \"" .
mysql_real_escape_string(crypt($i18nHTMLsqlAdminPass)) . "\",
\"Administrator\", \"$i18nHTMLsrcLang\", 9999, 0)";
+$query="INSERT INTO ${i18nHTMLsqlPrefix}accounts VALUES (\"root\", \"" .
mysql_real_escape_string(crypt($i18nHTMLsqlAdminPass)) . "\",
\"Administrator\", \"$i18nHTMLsrcLang\", 9999, 1)";
"INDEX(c(10)), INDEX(lang(4)), INDEX(count))";
+echo $query;
mysql_query($query, $connection);
+// setup legacy account
+$query="INSERT INTO ${i18nHTMLsqlPrefix}accounts VALUES (\"legacy\",
\"nologin\", \"Legacy\", \"$i18nHTMLsrcLang\", 0, 2)";
+ "INDEX(c(10)), INDEX(lang(4)), INDEX(count))";
+echo $query;
+mysql_query($query, $connection);
+
$query="CREATE TABLE IF NOT EXISTS ${i18nHTMLsqlPrefix}languages" .
- " (lang TINYBLOB, dodef INT, INDEX(lang(10)))";
+ " (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";
+W("Tables created.");
-echo "</body></html>";
\ No newline at end of file
+echo "</body></html>";
+?>
\ No newline at end of file
Modified: i18nHTML/src/i18nHTML/i18nhtml.php
===================================================================
--- i18nHTML/src/i18nHTML/i18nhtml.php 2007-01-03 05:11:39 UTC (rev 4173)
+++ i18nHTML/src/i18nHTML/i18nhtml.php 2007-01-03 07:40:32 UTC (rev 4174)
@@ -168,7 +168,7 @@
$protocol = "https"; // switch to https
}
$back = $protocol . "://" . $HTTP_SERVER_VARS["HTTP_HOST"] .
$HTTP_SERVER_VARS["REQUEST_URI"];
- return "<a href=\"" . $i18nHTMLbase . "translate.php?xlang="
+ return "<a href=\"${i18nHTMLbase}translate.php?xlang="
. $lang
. "&text=" . urlencode(fix($a))
. "&back=" . urlencode($back)
@@ -555,7 +555,8 @@
global $connection;
global $lang;
global $i18nHTMLrecordMode;
- global $i18nHTMLhasTranslation, $i18nHTMLsqlPrefix;
+ global $i18nHTMLhasTranslation;
+ global $i18nHTMLsqlPrefix;
global $i18nHTMLsrcLang;
$i18nHTMLhasTranslation = 1; // assume translation until failure
@@ -575,21 +576,20 @@
if ($i18nHTMLrecordMode == 2) {
// if not already in pending table (and recordMode set to allow us)
// then insert this string into it
- $query = "SELECT count FROM ".$i18nHTMLsqlPrefix."pending WHERE
c=\"$a_sql\" AND lang=\"$lang\"";
+ $query = "SELECT count FROM ${i18nHTMLsqlPrefix}pending WHERE
c=\"$a_sql\" AND lang=\"$lang\"";
$result = mysql_query($query, $connection);
$num = 0;
if ($result)
$num = mysql_num_rows($result);
if (0 == $num) {
- $query = "INSERT INTO ".$i18nHTMLsqlPrefix."pending VALUES(\"$a_sql\",
\"$lang\", 0)";
+ $query = "INSERT INTO ${i18nHTMLsqlPrefix}pending VALUES(\"$a_sql\",
\"$lang\", 0)";
mysql_query($query, $connection);
}
}
return $a;
}
// attempt to get translations, ranked for best
- $query = "SELECT translation FROM " . $i18nHTMLsqlPrefix .
- "map WHERE name=\"$a_sql\" AND lang=\"$lang\" ORDER BY ranking
DESC";
+ $query = "SELECT translation FROM ${i18nHTMLsqlPrefix}map WHERE
name=\"$a_sql\" AND lang=\"$lang\" ORDER BY ranking DESC";
$result = mysql_query($query, $connection);
$num = 0;
if ($result)
@@ -599,8 +599,7 @@
// either insert untranslated item into pending table or update
// referenced count; count is used to display more used strings
// during mass translation before less common ones.
- $query = "SELECT count FROM " . $i18nHTMLsqlPrefix .
- "pending WHERE c=\"$a_sql\" AND lang=\"$lang\"";
+ $query = "SELECT count FROM ${i18nHTMLsqlPrefix}pending WHERE
c=\"$a_sql\" AND lang=\"$lang\"";
$result = mysql_query($query, $connection);
$num = 0;
if ($result)
@@ -612,8 +611,7 @@
$query = "UPDATE " . $i18nHTMLsqlPrefix .
"pending SET count=$count WHERE c=\"$a_sql\" AND
lang=\"$lang\"";
} else {
- $query = "INSERT INTO " . $i18nHTMLsqlPrefix .
- "pending VALUES(\"$a_sql\", \"$lang\", 1)";
+ $query = "INSERT INTO ${i18nHTMLsqlPrefix}pending VALUES(\"$a_sql\",
\"$lang\", 1)";
}
mysql_query($query, $connection);
@@ -665,7 +663,7 @@
function intlink_($a, $b) {
global $lang;
- $ret = "<a href=\"" . $a . "?xlang=" . $lang . "\">" . TRANSLATE_($b) .
"</a>";
+ $ret = "<a href=\"${a}?xlang=" . $lang . "\">" . TRANSLATE_($b) . "</a>";
$ret = $ret . translateLink_($b);
return $ret;
}
@@ -679,7 +677,7 @@
// create internationalized, external link to
// $a with description $b
function extlink_($a, $b) {
- $ret = "<a href=\"" . $a . "\">" . TRANSLATE_($b) . "</a>" .
translateLink_($b);
+ $ret = "<a href=\"${a}\">" . TRANSLATE_($b) . "</a>" . translateLink_($b);
return $ret;
}
@@ -692,7 +690,7 @@
// create internationalized, external link to
// $a with description $b and title $c
function extlink_title_($a, $b, $c) {
- $ret = "<a href=\"" . $a . "\" title=\"" . TRANSLATE_($c) . "\">" .
TRANSLATE_($b) . "</a>" . translateLink_($b) . translateLink_($c);
+ $ret = "<a href=\"${a}\" title=\"" . TRANSLATE_($c) . "\">" . TRANSLATE_($b)
. "</a>" . translateLink_($b) . translateLink_($c);
return $ret;
}
Modified: i18nHTML/src/update0_3_0.php
===================================================================
--- i18nHTML/src/update0_3_0.php 2007-01-03 05:11:39 UTC (rev 4173)
+++ i18nHTML/src/update0_3_0.php 2007-01-03 07:40:32 UTC (rev 4174)
@@ -1,33 +1,13 @@
<?php
include("i18nHTML/i18nhtml.php");
-/* run this script to update your existing i18nHTML 0.2.0 database to a 0.3.0
db */
-$query="CREATE TABLE IF NOT EXISTS " . $i18nHTMLsqlPrefix . "accounts" .
- " (username TINYBLOB, password BLOB, allowed BLOB, level INT, uid INT
NOT NULL AUTO_INCREMENT" .
- "INDEX(username(10)));";
-$result = mysql_query($query, $connection);
-if (!$result) {
- die('Unable to initialize accounts table. Invalid query: ' . mysql_error());
-}
+/* run this script *after* accessing tables.php in order to update
+ your existing i18nHTML 0.2.0 database to a 0.3.0 db */
-// create administrator account
-$query="INSERT INTO " . $i18nHTMLsqlPrefix . "accounts VALUES(\"root\",\"" .
crypt("password") . "\", \"admin\", 99, 0);";
+# UID 2 == legacy
+$query="ALTER TABLE ${i18nHTMLsqlPrefix}map ADD uid DEFAULT 2 INT AFTER ip;";
$result = mysql_query($query, $connection);
if (!$result) {
- die('Unable to create root account. Invalid query: ' . mysql_error());
-}
-
-// we will assign all "old" translations to the legacy account
-$query="INSERT INTO " . $i18nHTMLsqlPrefix . "accounts
VALUES(\"legacy\",\"no-hash\", \"none\", 0, 1);";
-$result = mysql_query($query, $connection);
-if (!$result) {
- die('Unable to create root account. Invalid query: ' . mysql_error());
-}
-
-
-$query="ALTER TABLE " . $i18nHTMLsqlPrefix . "map" . " ADD uid DEFAULT 1 INT
AFTER ip;";
-$result = mysql_query($query, $connection);
-if (!$result) {
die('Unable to initialize map table. Invalid query: ' . mysql_error());
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4174 - in i18nHTML/src: . admin i18nHTML,
grothoff <=