[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4257 - in i18nHTML: . src/admin src/i18nHTML
From: |
grothoff |
Subject: |
[GNUnet-SVN] r4257 - in i18nHTML: . src/admin src/i18nHTML |
Date: |
Sun, 7 Jan 2007 22:54:20 -0800 (PST) |
Author: grothoff
Date: 2007-01-07 22:54:15 -0800 (Sun, 07 Jan 2007)
New Revision: 4257
Added:
i18nHTML/src/admin/by_user.php
Modified:
i18nHTML/ChangeLog
i18nHTML/debianize.sh
i18nHTML/src/admin/Makefile.am
i18nHTML/src/admin/accounts.php
i18nHTML/src/admin/delete.php
i18nHTML/src/admin/dig.php
i18nHTML/src/admin/index.php
i18nHTML/src/admin/status.php
i18nHTML/src/i18nHTML/i18nhtml.php
i18nHTML/todo
Log:
adding a few more features
Modified: i18nHTML/ChangeLog
===================================================================
--- i18nHTML/ChangeLog 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/ChangeLog 2007-01-08 06:54:15 UTC (rev 4257)
@@ -1,3 +1,7 @@
+Sun Jan 7 23:14:13 MST 2007
+ Added per-translator statistics.
+ Added capability to edit / delete translations by translator.
+
Sat Jan 6 17:35:36 MST 2007
Releasing i18nHTML 0.3.0.
Modified: i18nHTML/debianize.sh
===================================================================
--- i18nHTML/debianize.sh 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/debianize.sh 2007-01-08 06:54:15 UTC (rev 4257)
@@ -1,2 +1,3 @@
#!/bin/sh
-debuild -us -uc
+dpkg-buildpackage -rfakeroot
+
Modified: i18nHTML/src/admin/Makefile.am
===================================================================
--- i18nHTML/src/admin/Makefile.am 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/src/admin/Makefile.am 2007-01-08 06:54:15 UTC (rev 4257)
@@ -1,6 +1,7 @@
pkgdata_DATA = \
accounts.php \
add_language.php \
+ by_user.php \
cleanup.php \
commitMassTranslation.php \
commitTranslation.php \
Modified: i18nHTML/src/admin/accounts.php
===================================================================
--- i18nHTML/src/admin/accounts.php 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/src/admin/accounts.php 2007-01-08 06:54:15 UTC (rev 4257)
@@ -31,7 +31,7 @@
die();
}
-$query = "SELECT username,realname,level,uid FROM ${i18nHTMLsqlPrefix}accounts
WHERE level < $level";
+$query = "SELECT username,realname,level,uid,allowed FROM
${i18nHTMLsqlPrefix}accounts WHERE level < $level";
if ($uid != 1)
$query = $query + " AND allowed=$xlang";
$result = mysql_query($query, $connection);
@@ -43,14 +43,15 @@
die();
}
echo "<table border=2>";
-echo "<tr><th>Login</th><th>Real
name</th><th>Level</th><th>Actions</th></tr>\n";
+echo "<tr><th>Login</th><th>Real
name</th><th>Language</th><th>Level</th><th>Actions</th></tr>\n";
while ($num-- > 0) {
$row = mysql_fetch_array($result);
$log = $row['username'];
$rn = $row['realname'];
$lev = $row['level'];
+ $allowed = $row['allowed'];
$cid = $row['uid'];
- echo "<tr><td>$log</td><td>$rn</td><td>$lev</td>";
+ echo "<tr><td>$log</td><td>$rn</td><td>$allowed</td><td>$lev</td>";
echo "<td>";
if ($log != "legacy") {
echo "<a href=\"manage_account.php?cid=$cid&action=delete\">delete</a>,";
@@ -58,11 +59,21 @@
echo "<a href=\"manage_account.php?cid=$cid&action=promote\">promote</a>,";
echo "<a href=\"manage_account.php?cid=$cid&action=demote\">demote</a>";
} else {
- echo "none";
+ W("No actions apply");
}
echo "</td></tr>\n";
}
echo "</table>";
+BP();
+W("Delete will delete the account.");
+BR();
+W("Kill will delete the account and all translations added by the respective
user.");
+BR();
+W("Promote will grant the user the ability to administer accounts of lower
level, increasing his level by one.");
+BR();
+W("Demote will reduce the user's ability to administer accounts of lower
level, decreasing his level by one.");
+EP();
+HR();
generateFooter();
echo "</body></html>\n";
?>
\ No newline at end of file
Added: i18nHTML/src/admin/by_user.php
===================================================================
--- i18nHTML/src/admin/by_user.php 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/src/admin/by_user.php 2007-01-08 06:54:15 UTC (rev 4257)
@@ -0,0 +1,98 @@
+<?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_once("login.php");
+DOCTYPE("HTML", "Transitional");
+echo "<html><head>\n";
+TITLE("i18nHTML administration: edit translations (by user)");
+echo "</head><body>";
+$truid = $_REQUEST['truid'];
+if (! is_numeric($truid)) {
+ W("Invalid access.");
+ generateFooter();
+ echo "</body></html>";
+ die();
+ }
+$query2 = "SELECT level FROM ${i18nHTMLsqlPrefix}accounts WHERE uid=${truid}";
+$result2 = mysql_query($query2, $connection);
+$ok = 1;
+if ($result2) {
+ $num = mysql_numrows($result2);
+ if ($num == 1) {
+ $row = mysql_fetch_array($result2);
+ $trlevel = $row["level"];
+ if ( ($level <= $trlevel) &&
+ ($truid != $uid) )
+ $ok = 0; // insufficient level!
+ }
+ }
+if ($ok == 0) {
+ W("This page requires higher-level access priviledges.");
+ generateFooter();
+ echo "</body></html>";
+ die();
+ }
+
+$data = ARRAY();
+$query = "SELECT name,ip,translation,tid FROM ${i18nHTMLsqlPrefix}map WHERE
uid=$truid AND lang=\"${lang}\" ORDER BY ip";
+$result = mysql_query($query, $connection);
+$perfect = 0;
+$num = 0;
+$alpha = 1;
+if ($result)
+ $num = mysql_numrows($result);
+
+H2("Translations by ${truid}");
+echo "<form name=\"dig_form\" method=\"post\"
action=\"delete.php?xlang=${lang}\">\n";
+echo "<table border='5'>\n";
+echo "<tr>";
+TH("Original and Translation");
+TH("IP");
+TH("Delete");
+echo "</tr>\n";
+
+
+while ($num-- > 0) {
+ $row = mysql_fetch_array($result);
+ if (! $row)
+ continue; // oops!?
+ $text = htmlentities(stripslashes($row["name"]));
+ $translation = stripslashes($row["translation"]);
+ $tid = $row["tid"];
+ $ipaddr = $row["ip"];
+ if (! is_numeric($tid))
+ continue; // oops!?
+
+
+ echo "<tr><td><table border=0><tr><td>"$text"</td></tr>\n" .
+ "<tr><td><input type=\"text\" name=\"eid${tid}\" value=\"$translation\"
maxlength=4000 size=80 /></td></tr></table></td>\n" .
+ "<td>$ipaddr</td>\n" .
+ "<td><input type=\"checkbox\" name=\"tid${tid}\" value=\"1\"
/></td></tr>";
+}
+echo "</table>\n";
+BR();
+echo "<input type=\"submit\" class=\"button\" value=\"";
+TRANSLATE("Update translations");
+echo "\"/>";
+echo "</form>\n";
+HR();
+generateFooter();
+echo "</body></html>";
+?>
\ No newline at end of file
Modified: i18nHTML/src/admin/delete.php
===================================================================
--- i18nHTML/src/admin/delete.php 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/src/admin/delete.php 2007-01-08 06:54:15 UTC (rev 4257)
@@ -26,57 +26,98 @@
session_start();
$success = 0;
+$updated = 0;
$total = 0;
+$utotal = 0;
foreach ($_POST as $postval => $selected) {
- if ($selected != 1)
- continue;
- if (strstr($postval, "tid") != $postval)
- continue;
- $total++;
- $tid = substr($postval, 3);
- if (! is_numeric($tid)) {
- echo "se: '$tid' - $postval";
- continue;
- }
- $query = "SELECT uid FROM ${i18nHTMLsqlPrefix}map WHERE tid=${tid}";
- $result = mysql_query($query, $connection);
- if (! $result) {
- echo "not found";
- continue;
- }
- $num = mysql_numrows($result);
- if ($num != 1) {
- echo "not found - $num";
- continue; // oops! Primary key not unique!?
- }
- $row = mysql_fetch_array($result);
- $truid = $row["uid"];
- $query = "SELECT level FROM ${i18nHTMLsqlPrefix}accounts WHERE uid=${truid}";
- $result = mysql_query($query, $connection);
- $ok = 1;
- if ($result) {
+ if ( ($selected == 1) &&
+ (strstr($postval, "tid") == $postval) ) {
+ $total++;
+ $tid = substr($postval, 3);
+ if (! is_numeric($tid))
+ continue;
+ $query = "SELECT uid FROM ${i18nHTMLsqlPrefix}map WHERE tid=${tid}";
+ $result = mysql_query($query, $connection);
+ if (! $result)
+ continue;
$num = mysql_numrows($result);
- if ($num == 1) {
- $row = mysql_fetch_array($result);
- $trlevel = $row["level"];
- if ($level <= $trlevel)
- $ok = 0; // insufficient level!
+ if ($num != 1)
+ continue; // oops! Primary key not unique!?
+ $row = mysql_fetch_array($result);
+ $truid = $row["uid"];
+ $query = "SELECT level FROM ${i18nHTMLsqlPrefix}accounts WHERE
uid=${truid}";
+ $result = mysql_query($query, $connection);
+ $ok = 1;
+ if ($result) {
+ $num = mysql_numrows($result);
+ if ($num == 1) {
+ $row = mysql_fetch_array($result);
+ $trlevel = $row["level"];
+ if ( ($level <= $trlevel) &&
+ ($uid != $truid) )
+ $ok = 0; // insufficient level!
+ }
}
- }
- if (! $ok) {
- echo "access";
- continue; // refuse!
- }
- $query = "DELETE FROM ${i18nHTMLsqlPrefix}map WHERE tid=${tid}";
- mysql_query($query, $connection);
- $success++;
- }
+ if (! $ok)
+ continue; // refuse!
+ $query = "DELETE FROM ${i18nHTMLsqlPrefix}map WHERE tid=${tid}";
+ mysql_query($query, $connection);
+ $success++;
+ } // if delete operation
+
+
+
+ if (strstr($postval, "eid") == $postval) {
+ $tid = substr($postval, 3);
+ if (! is_numeric($tid))
+ continue;
+ $query = "SELECT uid,translation FROM ${i18nHTMLsqlPrefix}map WHERE
tid=${tid}";
+ $result = mysql_query($query, $connection);
+ if (! $result)
+ continue;
+ $num = mysql_numrows($result);
+ if ($num != 1)
+ continue; // oops! Primary key not unique!?
+ $row = mysql_fetch_array($result);
+ $truid = $row["uid"];
+ $oldtrans = $row["translation"];
+ $etran = fix(to_unicode($selected));
+ if ($etran == $oldtrans)
+ continue;
+ $utotal++;
+
+ $etran = mysql_real_escape_string($etran);
+ $query = "SELECT level FROM ${i18nHTMLsqlPrefix}accounts WHERE
uid=${truid}";
+ $result = mysql_query($query, $connection);
+ $ok = 1;
+ if ($result) {
+ $num = mysql_numrows($result);
+ if ($num == 1) {
+ $row = mysql_fetch_array($result);
+ $trlevel = $row["level"];
+ if ( ($level <= $trlevel) &&
+ ($uid != $truid) )
+ $ok = 0; // insufficient level!
+ }
+ }
+ if (! $ok)
+ continue; // refuse!
+ $query = "UPDATE ${i18nHTMLsqlPrefix}map SET translation=\"${etran}\"
WHERE tid=${tid}";
+ // mysql_query($query, $connection);
+ $updated++;
+ } // if update operation
+
+} // for all POSTs
BP();
W("Successfully deleted %s translations.",
$success);
if ($success != $total)
W("Note that some deletions failed.");
+W("Successfully updated %s translations.",
+ $updated);
+if ($updated != $utotal)
+ W("Note that some updates failed.");
EP();
generateFooter();
echo "</body></html>\n";
Modified: i18nHTML/src/admin/dig.php
===================================================================
--- i18nHTML/src/admin/dig.php 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/src/admin/dig.php 2007-01-08 06:54:15 UTC (rev 4257)
@@ -17,12 +17,6 @@
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
- /*
- Ideas for additional diggers:
- - punctuation mismatch (especially ".!?#")
- - translation count of UID
- */
-
include_once("i18nHTML/i18nhtml.php");
include_once("login.php");
$mode = $_REQUEST['mode'];
@@ -39,11 +33,11 @@
BP();
W("Using heuristic %s.", $mode);
BR();
-W("The worst offenders (acccording to the selected heuristic) are shown
towards the end of the table.");
+W("The worst offenders (acccording to the selected heuristic) are shown
towards the beginning of the table.");
EP();
$data = ARRAY();
-$query = "SELECT name,translation,uid,tid FROM ${i18nHTMLsqlPrefix}map WHERE
lang=\"${lang}\" ORDER BY name";
+$query = "SELECT name,ip,translation,uid,tid FROM ${i18nHTMLsqlPrefix}map
WHERE lang=\"${lang}\" ORDER BY name";
$result = mysql_query($query, $connection);
$hidden = 0;
$perfect = 0;
@@ -59,6 +53,7 @@
$translation = stripslashes($row["translation"]);
$truid = $row["uid"];
$tid = $row["tid"];
+ $ipaddr = $row["ip"];
if (! is_numeric($tid))
continue; // oops!?
@@ -70,7 +65,8 @@
if ($num == 1) {
$row = mysql_fetch_array($result2);
$trlevel = $row["level"];
- if ($level <= $trlevel)
+ if ( ($level <= $trlevel) &&
+ ($uid != $truid) )
$ok = 0; // insufficient level!
}
}
@@ -140,6 +136,31 @@
}
$score = $total;
}
+ case "punc": // punctuation mismatch counts
+ if ( ($text == "") || ($translation == "") ) {
+ $score = 999999;
+ } else {
+ $cc1 = count_chars($text, 0);
+ $cc2 = count_chars($translation, 0);
+ $total = 0;
+ foreach (".,!?;\"'`:-=+-()*" as $punct) {
+ $t1 = $cc1[$punct];
+ $t2 = $cc2[$punct];
+ $del = $t1 - $t2;
+ $total += $del * $del;
+ }
+ $score = $total;
+ }
+ case "totc": // total number of contributed translations
+ $query2 = "SELECT trd FROM ${i18nHTMLsqlPrefix}map WHERE ";
+ if ($truid == 2)
+ $query2 = $query2 . "ip=$ipaddr";
+ else
+ $query2 = $query2 . "uid=$truid";
+ $result2 = mysql_query($query2, $connection);
+ $score = 1;
+ if ($result)
+ $score += mysql_numrows($result2);
break;
case "alpha":
default:
@@ -148,9 +169,9 @@
}
$entry = "<tr><td><table border=0><tr><td>"$text"</td></tr>\n" .
"<tr><td>"$translation"</td></tr></table></td>\n" .
- "<td>$truid</td>\n" . // todo: add link to delete account / etc
- "<td>$score</td>\n" . // todo: add link to delete account / etc
- "<td><input type=\"checkbox\" name=\"tid${tid}\" value=\"1\"
/></td></tr>"; // todo: add checkbox in form to delete translation
+ "<td>$truid/$ipaddr</td>\n" . // todo: add link to delete account /
etc
+ "<td>$score</td>\n" .
+ "<td><input type=\"checkbox\" name=\"tid${tid}\" value=\"1\"
/></td></tr>";
if (isset($data[$score]))
$entries = $data[$score];
else
@@ -161,7 +182,16 @@
else
$perfect++;
}
-ksort($data);
+// sort results
+switch($mode) {
+ case "alpha":
+ case "totc":
+ ksort($data);
+ break;
+ default:
+ krsort($data);
+ break;
+ }
H2("Translations to ${lang}");
echo "<form name=\"dig_form\" method=\"post\"
action=\"delete.php?xlang=${lang}\">\n";
echo "<table border='5'>\n";
Modified: i18nHTML/src/admin/index.php
===================================================================
--- i18nHTML/src/admin/index.php 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/src/admin/index.php 2007-01-08 06:54:15 UTC (rev 4257)
@@ -41,6 +41,10 @@
"Search for suspicious translations using weighted word-length
distance");
LILI("dig.php?mode=psmc&xlang=$lang&f=",
"Search for suspicious translations using percent sign mismatch
counts");
+ LILI("dig.php?mode=punc&xlang=$lang&f=",
+ "Search for suspicious translations using punctuation mismatch counts");
+ LILI("dig.php?mode=totc&xlang=$lang&f=",
+ "Search for suspicious translations using number of contributed
translations");
LILI("dig.php?mode=alpha&xlang=$lang&f=",
"Search for suspicious translations using alphabetical ordering");
}
Modified: i18nHTML/src/admin/status.php
===================================================================
--- i18nHTML/src/admin/status.php 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/src/admin/status.php 2007-01-08 06:54:15 UTC (rev 4257)
@@ -31,6 +31,7 @@
echo "<html><head>\n";
TITLE("Translation: status");
echo "</head><body>";
+H1("i18nHTML statistics");
BP();
W("Language setting is %s.",
$lang);
@@ -51,7 +52,6 @@
$num = 0;
if ($result)
$num = mysql_numrows($result);
-echo "<center>[<a href=\"?xlang=${i18nHTMLsrcLang}\">" . W_($i18nHTMLsrcLang)
. "</a>";
while ($num-- > 0) {
$row = mysql_fetch_array($result);
if (! $row)
@@ -70,6 +70,7 @@
W("%s translated sentences in database.", $total);
EP();
+H2("Translations by language");
echo "<center><table border=5>\n";
echo "<tr>";
TH("Language");
@@ -79,6 +80,55 @@
printf("<tr><td>%s</td><td>%s</td></tr>\n", $a, $b);
}
echo "</table></center>\n";
+
+
+H2("Translations by translator");
+$query = "SELECT username,realname,uid,allowed FROM
${i18nHTMLsqlPrefix}accounts";
+$result = mysql_query($query, $connection);
+$num = 0;
+if ($result)
+ $num = mysql_numrows($result);
+echo "<center><table border=2>\n";
+echo "<tr><th>Login</th><th>Real
name</th><th>Translations</th><th>Language</th>\n";
+while ($num-- > 0) {
+ $row = mysql_fetch_array($result);
+ $log = $row['username'];
+ $rn = $row['realname'];
+ $allowed = $row['allowed'];
+ $tuid = $row['uid'];
+
+ $query2 = "SELECT tid FROM ${i18nHTMLsqlPrefix}map WHERE uid=$tuid";
+ $result2 = mysql_query($query2, $connection);
+ $num2 = 0;
+ if ($result2)
+ $num2 = mysql_numrows($result2);
+ echo "<tr><td><a
href=\"by_user.php?xlang=${lang}&truid=${tuid}\">$log</a></td><td>$rn</td><td
align=\"right\">$num2</td><td>$allowed</td></tr>\n";
+ }
+echo "</table></center>\n";
+
+/* -- far too expensive
+H2("Translations by IP");
+$query = "SELECT DISTINCT ip FROM ${i18nHTMLsqlPrefix}map ORDER BY ip";
+$result = mysql_query($query, $connection);
+$num = 0;
+if ($result)
+ $num = mysql_numrows($result);
+echo "<center><table border=2>\n";
+echo "<tr><th>IP</th><th>Translations</th>\n";
+while ($num-- > 0) {
+ $row = mysql_fetch_array($result);
+ $ip = $row['ip'];
+
+ $query2 = "SELECT tid FROM ${i18nHTMLsqlPrefix}map WHERE ip=\"$ip\"";
+ $result2 = mysql_query($query2, $connection);
+ $num2 = 0;
+ if ($result2)
+ $num2 = mysql_numrows($result2);
+ echo "<tr><td>$ip</td><td align=\"right\">$num2</td></tr>\n";
+ }
+echo "</table></center>\n";
+*/
+
HR();
generateFooter();
echo "</body></html>";
Modified: i18nHTML/src/i18nHTML/i18nhtml.php
===================================================================
--- i18nHTML/src/i18nHTML/i18nhtml.php 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/src/i18nHTML/i18nhtml.php 2007-01-08 06:54:15 UTC (rev 4257)
@@ -94,16 +94,6 @@
$tok = strtok(";");
}
}
-// If no language is specified, use english.
-if ( (! $lang) || ($lang=="") )
- $lang = $i18nHTMLsrcLang;
-$xlang = $_REQUEST['xlang'];
-if ($xlang)
- $lang = $xlang;
-$lang = ucfirst(strtolower($lang));
-$lang = quote_smart($lang);
-$editor = $_REQUEST['editor'];
-$i18nHTMLhasTranslation = 0; // set by last call to translation_query()
/**
* Replace certain HTML named special characters with their
@@ -119,8 +109,7 @@
// Quote variable to make safe from
// http://fr.php.net/manual/en/function.mysql-real-escape-string.php
-function quote_smart($value)
-{
+function quote_smart($value) {
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
@@ -129,6 +118,18 @@
return $value;
}
+// If no language is specified, use default
+if ( (! $lang) || ($lang=="") )
+ $lang = $i18nHTMLsrcLang;
+$xlang = $_REQUEST['xlang'];
+if ($xlang)
+ $lang = $xlang;
+$lang = ucfirst(strtolower($lang));
+$lang = quote_smart($lang);
+$editor = $_REQUEST['editor'];
+$i18nHTMLhasTranslation = 0; // set by last call to translation_query()
+
+
// *************************************************
// i18nHTML configuration API functions
// *************************************************
Modified: i18nHTML/todo
===================================================================
--- i18nHTML/todo 2007-01-07 20:47:38 UTC (rev 4256)
+++ i18nHTML/todo 2007-01-08 06:54:15 UTC (rev 4257)
@@ -1,11 +1,7 @@
Ideas for future development:
-Users:
-* enable users to view & edit their own translations
-
Administration:
* enable default translation feature
-* provide summary of translator's performance (totals, view translations)
Installation:
* finish debian package:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4257 - in i18nHTML: . src/admin src/i18nHTML,
grothoff <=