Merge branch 'bug-602' into release
[cacert-devel.git] / www / wot.php
index 61fbc1b..551e485 100644 (file)
@@ -16,6 +16,9 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */ ?>
 <?
+require_once("../includes/loggedin.php");
+require_once("../includes/lib/l10n.php");
+
 
 function show_page($target,$message,$error)
 {
@@ -83,43 +86,36 @@ function show_page($target,$message,$error)
 function send_reminder()
 {
        $body = "";
-       if($_POST['reminder-lang'] != "" && $_POST['reminder-lang'] != "en_AU")
-        {
-               $userlang = $_POST['reminder-lang'];
-               $_SESSION['_config']['reminder-lang'] = $_POST['reminder-lang'];
-               putenv("LANG=".$userlang);
-               setlocale(LC_ALL, $userlang);
-
-               $body .= $_SESSION['_config']['translations'][$userlang].":\n\n";
-               $body .= sprintf(_("This is a short reminder that you filled out forms to become trusted with CAcert.org, and %s has attempted to issue you points. Please create your account at %s as soon as possible and then notify %s so that the points can be issued."), $_SESSION['profile']['fname']." (".$_SESSION['profile']['email'].")", "http://www.cacert.org", $_SESSION['profile']['fname'])."\n\n";
-               $body .= _("Best regards")."\n";
-               $body .= _("CAcert Support Team");
+       $my_translation = L10n::get_translation();
+
+       $_SESSION['_config']['reminder-lang'] = $_POST['reminder-lang'];
 
-               $body .= "\n\nEnglish:\n\n";
+       $reminder_translations[] = $_POST['reminder-lang'];
+       if ( !in_array("en", $reminder_translations, $strict=true) ) {
+               $reminder_translations[] = "en";
        }
 
-       $body .= sprintf("This is a short reminder that you filled out forms to become trusted with CAcert.org, and %s has attempted to issue you points. Please create your account at %s as soon as possible and then notify %s so that the points can be issued.", $_SESSION['profile']['fname']." (".$_SESSION['profile']['email'].")", "http://www.cacert.org", $_SESSION['profile']['fname'])."\n\n";
-       $body .= "Best regards"."\n";
-       $body .= "CAcert Support Team";
+       foreach ($reminder_translations as $translation) {
+               L10n::set_translation($translation);
 
+               $body .= L10n::$translations[$translation].":\n\n";
+               $body .= sprintf(_("This is a short reminder that you filled out forms to become trusted with CAcert.org, and %s has attempted to issue you points. Please create your account at %s as soon as possible and then notify %s so that the points can be issued."), $_SESSION['profile']['fname']." (".$_SESSION['profile']['email'].")", "http://www.cacert.org", $_SESSION['profile']['fname'])."\n\n";
+               $body .= _("Best regards")."\n";
+               $body .= _("CAcert Support Team")."\n\n";
+       }
+
+       L10n::set_translation($reminder_translations[0]); // for the subject
        sendmail($_POST['email'], "[CAcert.org] "._("Reminder Notice"), $body, $_SESSION['profile']['email'], "", "", $_SESSION['profile']['fname']);
 
-       if($_POST['reminder-lang'] != "" && $_POST['reminder-lang'] != "en_AU")
-       {
-               $userlang = $_SESSION['profile']['language'];
-               putenv("LANG=".$userlang);
-               setlocale(LC_ALL, $userlang);
-       }
+       L10n::set_translation($my_translation);
 
        $_SESSION['_config']['remindersent'] = 1;
+       $_SESSION['_config']['error'] = _("A reminder notice has been sent.");
 }
 
 
 
 
-
-       require_once("../includes/loggedin.php");
-
        loadem("account");
        if(array_key_exists('date',$_POST) && $_POST['date'] != "")
                $_SESSION['_config']['date'] = $_POST['date'];
@@ -127,13 +123,47 @@ function send_reminder()
        if(array_key_exists('location',$_POST) && $_POST['location'] != "")
                $_SESSION['_config']['location'] = $_POST['location'];
 
-       $oldid=array_key_exists('oldid',$_REQUEST)?intval($_REQUEST['oldid']):0;        
+       $oldid=array_key_exists('oldid',$_REQUEST)?intval($_REQUEST['oldid']):0;
 
        if($oldid == 12)
                $id = $oldid;
+               
+       if($oldid == 4)
+       {
+               if ($_POST['ttp']!='') {
+                       //This mail does not need to be translated
+                       $body = "Hi TTP adminstrators,\n\n";
+                       $body .= "User ".$_SESSION['profile']['fname']." ".
+                       $_SESSION['profile']['lname']." with email address '".
+                       $_SESSION['profile']['email']."' is requesting a TTP assurances for ".
+                       mysql_escape_string(stripslashes($_POST['country'])).".\n\n";
+                       if ($_POST['ttptopup']=='1') {
+                               $body .= "The user is also requesting TTP TOPUP.\n\n";
+                       }else{
+                               $body .= "The user is NOT requesting TTP TOPUP.\n\n";
+                       }
+                       $body .= "The user received ".intval($_SESSION['profile']['points'])." assurance points up to today.\n\n";
+                       $body .= "Please start the TTP assurance process.";
+                       sendmail("support@cacert.org", "[CAcert.org] TTP request.", $body, "support@cacert.org", "", "", "CAcert Website");
+
+                       //This mail needs to be translated
+                       $body  =_("You are receiving this email because you asked for TTP assurance.")."\n\n";
+                       if ($_POST['ttptopup']=='1') {
+                               $body .=_("You are requesting TTP TOPUP.")."\n\n";
+                       }else{
+                               $body .=_("You are NOT requesting TTP TOPUP.")."\n\n";
+                       }
+                       $body .= _("Best regards")."\n";
+                       $body .= _("CAcert Support Team");
+
+                       sendmail($_SESSION['profile']['email'], "[CAcert.org] "._("You requested TTP assurances"), $body, "support@cacert.org", "", "", "CAcert Support");
+
+               }
+
+       }
 
        if(($id == 5 || $oldid == 5 || $id == 6 || $oldid == 6))
-               if (!is_assurer($_SESSION['profile']['id'])) 
+               if (!is_assurer($_SESSION['profile']['id']))
                        {
                                show_page ("Exit","",get_assurer_reason($_SESSION['profile']['id']));
                                exit;
@@ -160,7 +190,7 @@ function send_reminder()
                        $_SESSION['_config']['noemailfound'] = 1;
                        show_page("EnterEmail","",_("I'm sorry, there was no email matching what you entered in the system. Please double check your information."));
                        exit;
-               } else 
+               } else
                {
                        $_SESSION['_config']['noemailfound'] = 0;
                        $_SESSION['_config']['notarise'] = mysql_fetch_assoc($res);
@@ -170,6 +200,14 @@ function send_reminder()
                                exit;
                        }
                }
+               $query = "select * from `users` where `email`='".mysql_escape_string(stripslashes($_POST['email']))."' and `locked`=1";
+               $res = mysql_query($query);
+               if(mysql_num_rows($res) >= 1)
+               {
+                       $_SESSION['_config']['noemailfound'] = 0;
+                       show_page("EnterEmail","",_("This account is locked and can not be assured. For more information ask support@cacert.org."));
+                       exit;
+               }
        }
 
        if($oldid == 5 || $oldid == 6)
@@ -200,12 +238,19 @@ function send_reminder()
        if($oldid == 6)
        {
 $iecho= "c";
-               if(!array_key_exists('assertion',$_POST) || $_POST['assertion'] != 1 || !array_key_exists('rules',$_POST) || $_POST['rules'] != 1)
+               if(!array_key_exists('assertion',$_POST) || $_POST['assertion'] != 1)
                {
                        show_page("VerifyData","",_("You failed to check all boxes to validate your adherence to the rules and policies of CAcert"));
                        exit;
                }
 
+/*             if(!array_key_exists('rules',$_POST) || $_POST['rules'] != 1)
+               {
+                       show_page("VerifyData","",_("You failed to check all boxes to validate your adherence to the rules and policies of CAcert"));
+                       exit;
+               }
+*/
+
                if((!array_key_exists('certify',$_POST) || $_POST['certify'] != 1 )  && $_SESSION['profile']['ttpadmin'] != 1)
                {
                        show_page("VerifyData","",_("You failed to check all boxes to validate your adherence to the rules and policies of CAcert"));
@@ -245,7 +290,7 @@ $iecho= "c";
                        $newpoints = $awarded = $max;
                if($newpoints < 0)
                        $newpoints = $awarded = 0;
-               
+
                $query = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['_config']['notarise']['id']."' group by `to`";
                $res = mysql_query($query);
                $drow = mysql_fetch_assoc($res);
@@ -258,13 +303,13 @@ $iecho= "c";
                        $newpoints = $max - $drow['total'];
                if($newpoints < 0)
                        $newpoints = 0;
-               
+
                if(mysql_escape_string(stripslashes($_POST['date'])) == "")
                        $_POST['date'] = date("Y-m-d H:i:s");
 
                $query = "select * from `notary` where `from`='".$_SESSION['profile']['id']."' AND
                                                `to`='".$_SESSION['_config']['notarise']['id']."' AND
-                                               `awarded`='$awarded' AND 
+                                               `awarded`='$awarded' AND
                                                `location`='".mysql_escape_string(stripslashes($_POST['location']))."' AND
                                                `date`='".mysql_escape_string(stripslashes($_POST['date']))."'";
                $res = mysql_query($query);
@@ -290,12 +335,12 @@ $iecho= "c";
                        $query .= ",\n`sponsor`='".intval($_POST['sponsor'])."'";
                } else if($_SESSION['profile']['board'] == 1) {
                        $query .= ",\n`method`='".mysql_escape_string(stripslashes($_POST['method']))."'";
-               } else if($_SESSION['profile']['ttpadmin'] == 1 && ($_POST['method'] == 'Trusted 3rd Parties' || $_POST['method'] == 'Trusted third Parties')) {
-                       $query .= ",\n`method`='Trusted Third Parties'";
+               } else if($_SESSION['profile']['ttpadmin'] == 1 && ($_POST['method'] == 'Trusted 3rd Parties' || $_POST['method'] == 'Trusted Third Parties')) {
+                       $query .= ",\n`method`='TTP-Assisted'";
                }
                mysql_query($query);
                fix_assurer_flag($_SESSION['_config']['notarise']['id']);
-               
+
                if($_SESSION['profile']['points'] < 150)
                {
                        $addpoints = 0;
@@ -315,12 +360,8 @@ $iecho= "c";
                        $_SESSION['profile']['points'] += $addpoints;
                }
 
-               if($_SESSION['_config']['notarise']['language'] != "")
-               {
-                       $userlang = $_SESSION['_config']['notarise']['language'];
-                       putenv("LANG=".$userlang);
-                       setlocale(LC_ALL, $userlang);
-               }
+               $my_translation = L10n::get_translation();
+               L10n::set_translation($_SESSION['_config']['notarise']['language']);
 
                $body  = sprintf(_("You are receiving this email because you have been assured by %s %s (%s)."), $_SESSION['profile']['fname'], $_SESSION['profile']['lname'], $_SESSION['profile']['email'])."\n\n";
                if($_POST['points'] != $newpoints)
@@ -335,12 +376,10 @@ $iecho= "c";
 
                if(($drow['total'] + $newpoints) >= 100 && $newpoints > 0)
                {
-//                     $body .= _("You now have over 100 points and can start assuring others.")."\n\n";
-                       $body .= _("You have at least 100 Assurance Points, if you want to become an assurer try the")." ";
-                       $body .= _("Assurer Challenge")." ( https://cats.cacert.org )\n\n";
-                       $body .= _("To make it easier for others in your area to find you, it's helpful to list yourself as an assurer (this is voluntary), as well as a physical location where you live or work the most. You can flag your account to be listed, and add a comment to the display by going to:")."\n\n";
+                       $body .= _("You have at least 100 Assurance Points, if you want to become an assurer try the Assurer Challenge")." ( https://cats.cacert.org )\n\n";
+                       $body .= _("To make it easier for others in your area to find you, it's helpful to list yourself as an assurer (this is voluntary), as well as a physical location where you live or work the most. You can flag your account to be listed, and add a comment to the display by going to:")."\n";
                        $body .= "https://www.cacert.org/wot.php?id=8\n\n";
-                       $body .= _("You can list your location by going to:")."\n\n";
+                       $body .= _("You can list your location by going to:")."\n";
                        $body .= "https://www.cacert.org/wot.php?id=13\n\n";
                }
 
@@ -352,8 +391,7 @@ $iecho= "c";
 
                sendmail($_SESSION['_config']['notarise']['email'], "[CAcert.org] "._("You've been Assured."), $body, "support@cacert.org", "", "", "CAcert Website");
 
-               putenv("LANG=".$_SESSION['profile']['language']);
-               setlocale(LC_ALL, $_SESSION['profile']['language']);
+               L10n::set_translation($my_translation);
 
                $body  = sprintf(_("You are receiving this email because you have assured %s %s (%s)."), $_SESSION['_config']['notarise']['fname'], $_SESSION['_config']['notarise']['lname'], $_SESSION['_config']['notarise']['email'])."\n\n";
                if($_POST['points'] != $newpoints)
@@ -445,18 +483,53 @@ $iecho= "c";
                                                where `to`='".$user['id']."' group by `to` HAVING SUM(`points`) > 0"));
                        if($points > 0)
                        {
-                               sendmail($user['email'], "[CAcert.org] ".$_REQUEST['subject'], $_REQUEST['message'],
-                                       $_SESSION['profile']['email'], "", "", $_SESSION['profile']['fname']." ".$_SESSION['profile']['lname']);
-                               show_page("ContactAssurer",_("Your email has been sent to")." ".$user['fname'].".<br />[ <a href='javascript:history.go(-2)'>"._("Go Back")."</a> ]","");
+                               $my_translation = L10n::get_translation();
+                               L10n::set_translation($user['language']);
+
+                               $subject = "[CAcert.org] ".sprintf(_("Message from %s"),
+                                               $_SESSION['profile']['fname']);
+
+                               $body  = sprintf(_("Hi %s,"), $user['fname'])."\n\n";
+                               $body .= sprintf(_("%s %s has sent you a message via the ".
+                                               "contact an Assurer form on CAcert.org."),
+                                               $_SESSION['profile']['fname'],
+                                               $_SESSION['profile']['lname'])."\n\n";
+                               $body .= sprintf(_("Subject: %s"), $_REQUEST['subject'])."\n";
+                               $body .= _("Message:")."\n";
+                               $body .= $_REQUEST['message']."\n\n";
+                               $body .= "------------------------------------------------\n\n";
+                               $body .= _("Please note, that this is NOT a message on behalf ".
+                                               "of CAcert but another CAcert community member. If ".
+                                               "you suspect that the contact form might have been ".
+                                               "abused, please write to support@cacert.org")."\n\n";
+                               $body .= _("Best regards")."\n";
+                               $body .= _("Your CAcert Community");
+
+                               sendmail($user['email'], $subject, $body,
+                                               $_SESSION['profile']['email'], //from
+                                               "", //replyto
+                                               "", //toname
+                                               $_SESSION['profile']['fname']." ".
+                                                       $_SESSION['profile']['lname']); //fromname
+
+                               L10n::set_translation($my_translation);
+
+                               showheader(_("My CAcert.org Account!"));?>
+                               <p>
+                                       <? printf(_("Your email has been sent to %s."), $user['fname']); ?>
+                               </p>
+                               <p>[ <a href='javascript:history.go(-2)'><?= _("Go Back") ?></a> ]</p>
+                               <?
+                               showfooter();
                                exit;
                        } else {
                                show_page(0,"",_("Sorry, I was unable to locate that user."));
                                exit;
                        }
-               
+
                }
-       } 
-       if($oldid == 9) 
+       }
+       if($oldid == 9)
        {
                $oldid=0;
                $id = 9;