# HG changeset patch
# User mortenp
# Date 1236197309 -39600
# Node ID 9d5846a45086506c0fdd0575e7b2a59dbb6c0752
# Parent 9b32890a008ecb0ec582c11b0193a7498cd21372
Added contrib/web/php-moderation (Thomas Goirand)
diff -r 9b32890a008e -r 9d5846a45086 ChangeLog
--- a/ChangeLog Thu Mar 05 07:05:19 2009 +1100
+++ b/ChangeLog Thu Mar 05 07:08:29 2009 +1100
@@ -1,3 +1,4 @@
+ o Added contrib/web/php-moderation (Thomas Goirand)
1.2.16
o Fixed injection in contrib/web/perl-user (Gerd von Egidy)
1.2.16-RC1
diff -r 9b32890a008e -r 9d5846a45086 contrib/web/php-moderation/build-translations.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/web/php-moderation/build-translations.sh Thu Mar 05 07:08:29 2009 +1100
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# Build script for generating the MLMMJ moderation web interface locales
+#
+
+set -e
+
+LOCALE_TRANS=fr_FR
+WEB_SCRIPT_FILES=mlmmj-moderation.php
+
+if [ ! -d translations ]; then
+ echo "Wrong working directory." >&2
+ exit 1
+fi
+
+echo "===> Managing internationalizations and localizations"
+
+echo "=> Extracting strings from sources"
+xgettext $WEB_SCRIPT_FILES -o translations/templates.pot
+
+echo "=> Merging in every language .po file:"
+for i in $LOCALE_TRANS; do
+ echo -n "$i "
+ msgmerge -s -U "translations/$i.po" translations/templates.pot
+done
+
+echo "=> Creating l10n folders"
+for i in $LOCALE_TRANS; do
+ mkdir -p "translations/locale/$i/LC_MESSAGES"
+done
+
+echo "=> Creating binary formats of language files:"
+for i in $LOCALE_TRANS; do
+ echo -n $i" "
+ msgfmt -c -v -o "translations/locale/$i/LC_MESSAGES/messages.mo" \
+ "translations/$i.po"
+done
diff -r 9b32890a008e -r 9d5846a45086 contrib/web/php-moderation/mlmmj-moderation.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/web/php-moderation/mlmmj-moderation.php Thu Mar 05 07:08:29 2009 +1100
@@ -0,0 +1,277 @@
+
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+// These are the configuration variables for your list
+$mod_dir = "/some/path/to/your/listname/moderation";
+$list_name = "listname";
+$list_domain = "example.com";
+$delimiter = "+";
+$from_addr = "user@example.com";
+
+// Manage accepted language and cookies
+$txt_default_lang = "en";
+session_register("lang");
+if(isset($_SESSION["lang"]) && !is_string($_SESSION["lang"])){
+ unset($lang);
+}
+if(isset($_SESSION["lang"])){
+ $lang = $_SESSION["lang"];
+}
+
+// TODO: Add some web stuffs to change the language manually on the web interface...
+// ...HERE...
+//
+
+// $lang = "fr_FR";
+
+// The following code keeps the lang in sessions, so it can be changed manually above with lang=XX
+// and if there's nothing in session yet, then it will parse the language set in the browser
+if(isset($lang)){
+ $_SESSION["lang"] = $lang;
+}
+if (!isset($lang)){
+ if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && $_SERVER["HTTP_ACCEPT_LANGUAGE"]) {
+ $all_languages = strtok($_SERVER["HTTP_ACCEPT_LANGUAGE"],";");
+ $langaccept = explode(",", $all_languages);
+ for ($i = 0; $i < sizeof($langaccept); $i++) {
+ $tmplang = trim($langaccept[$i]);
+ $tmplang2 = substr($tmplang,0,2);
+ if (!isset($lang) && isset($txt_langname[$tmplang]) && $txt_langname[$tmplang]) {
+ $lang = $tmplang;
+ }elseif (!isset($lang) && isset($txt_langname[$tmplang2])) {
+ $lang = $tmplang2;
+ }
+ }
+ }
+ if (!isset($lang)) {
+ $lang = $txt_default_lang;
+ }
+ $_SESSION["lang"] = $lang;
+}
+header("Content-type: text/html; charset=UTF-8");
+switch($lang){
+case "fr_FR":
+case "fr":
+ $gettext_lang = "fr_FR.UTF-8";
+ break;
+default:
+ $gettext_lang = "en_US.UTF-8";
+ break;
+}
+if(FALSE === putenv("LC_ALL=$gettext_lang")){
+ echo "Failed to putenv LC_ALL=$gettext_lang
";
+}
+if(FALSE === putenv("LANG=$gettext_lang")){
+ echo "Failed to putenv LANG=$gettext_lang
";
+}
+if(FALSE === setlocale(LC_ALL, $gettext_lang)){
+ echo "Failed to setlocale(LC_ALL,$gettext_lang)
";
+}
+$pathname = bindtextdomain("messages", dirname(__FILE__) ."/translations/locale");
+$message_domain = textdomain("messages");
+
+// This comes from the Mail_Mime PEAR package, under Debian, you need
+// the php-mail-mime package to have this script work.
+require_once 'Mail/mimeDecode.php';
+
+// Email header parsing
+function decodeEmail($input){
+ $params['include_bodies'] = true;
+ $params['decode_bodies'] = true;
+ $params['decode_headers'] = true;
+
+ $decoder = new Mail_mimeDecode($input);
+ $structure = $decoder->decode($params);
+ return $structure;
+}
+
+// Reading of all the messages from the moderation folder
+function getMessageList(){
+ global $mod_dir;
+ $all_msg = array();
+ // Read all files from the directory.
+ if (is_dir($mod_dir)) {
+ if ($dh = opendir($mod_dir)) {
+ while (($file = readdir($dh)) !== false) {
+ $full_path = $mod_dir . "/" . $file;
+ if(filetype($full_path) == "file"){
+ if(FALSE === ($input = file_get_contents($full_path))){
+ echo ""._("Warning: could not read")." $full_path
";
+ }else{
+ $struct = decodeEmail($input);
+ $my_msg = array();
+ $my_msg["headers"] = $struct->headers;
+ $my_msg["body"] = $struct->body;
+ $my_msg["filename"] = $file;
+ $all_msg[] = $my_msg;
+ }
+ }
+ }
+ closedir($dh);
+ }
+ }
+ return $all_msg;
+}
+
+// Printing of the list of messages to be displayed (the big table)
+function printAllMessages($all_msg){
+ $n = sizeof($all_msg);
+ $out = "
"._("Date")." | "._("Subject")." | "._("From")." |
---|