Skip to content
Snippets Groups Projects
Commit fd350db4 authored by Ubbo Veentjer's avatar Ubbo Veentjer
Browse files

fix some php warnings, add mail-reply adress and utf8-mail-encoding

git-svn-id: https://textgridlab.org/svn/textgrid/trunk/middleware/tgauth@13678 7c539038-3410-0410-b1ec-0f2a7bf1c452
parent a3950c50
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ include 'webinit.inc.php';
if($_POST['mail']){
$mail = $_POST['mail'];
$imap->mail($mail['reciever'], $mail['subject'], $mail['body']);
$imap->mail($mail['reciever'], $mail['subject'], $mail['body'], true);
$status='Mail an '.$mail['reciever'].' wurde versendet';
}
......
......@@ -21,6 +21,7 @@ $conf['ldap']['debug'] = false;
// mail (imap)
$conf['mail']['sender'] = $ini['mailSender'];
$conf['mail']['reply'] = $ini['mailReply'];
$conf['mail']['cc'] = $ini['mailCC'];
$conf['mail']['smtpHost'] = $ini['smtpHost'];
$conf['mail']['smtpUser'] = $ini['smtpUser'];
......
......@@ -8,11 +8,13 @@ class tgImap {
var $conf;
var $sender;
var $cc;
var $reply;
function __construct( $conf) {
$this->conf = $conf;
$this->sender = $conf['mail']['sender'];
$this->cc = $conf['mail']['cc'];
$this->reply = $conf['mail']['reply'];
$params['host'] = $conf['mail']['smtpHost'];
$params['username'] = $conf['mail']['smtpUser'];
......@@ -45,12 +47,13 @@ class tgImap {
$html = '<html><body>'.nl2br($body).'</body></html>';
$crlf = "\n";
$mime = new Mail_mime(array('eol' => $crlf));
$mime = new Mail_mime(array('eol' => $crlf, 'html_charset' => 'UTF-8', 'text-charset' => 'UTF-8'));
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$headers['From'] = $this->sender;
$headers['To'] = $to;
$headers['Reply-To'] = $this->reply;
$headers['Subject'] = $subject;
if($cc) {
......
......@@ -30,7 +30,7 @@ class tgSqliteDB {
$where .= "WHERE at_status=0";
break;
case "my":
$where .= "WHERE at_assignee='".$this->conf[login][user]."'";
$where .= "WHERE at_assignee='".$this->conf['login']['user']."'";
break;
case "closed":
$where .= "WHERE at_status=1 OR at_status = 2";
......@@ -64,13 +64,13 @@ class tgSqliteDB {
}
$query = "INSERT INTO user_request (name, surname, pref_uid, email, institution, newsletter, lang, ldap_uid, at_status, at_assignee)
VALUES ('".$data[name]."','".$data[surname]."','".$data[userid]."','"
.$data[email]."','".$data[institution]."','".$data[newsletter]."', '".$data[lang]."', '', '0', '')";
VALUES ('".$data['name']."','".$data['surname']."','".$data['userid']."','"
.$data['email']."','".$data['institution']."','".$data['newsletter']."', '".$data['lang']."', '', '0', '')";
$this->query($query);
}
function assignRequest($id) {
$query = "UPDATE user_request SET at_assignee = '" . $this->conf[login][user] . "', at_status = 3 WHERE id=".$id;
$query = "UPDATE user_request SET at_assignee = '" . $this->conf['login']['user'] . "', at_status = 3 WHERE id=".$id;
$this->query($query);
}
......
......@@ -13,7 +13,8 @@ managerdn = "cn=Manager,dc=textgrid,dc=de"
managerpassword =
[mail]
mailSender = register@textgridlab.org
mailSender = no-reply@textgridlab.org
mailReply = register@textgrid.de
mailCC = TEXTGRID-REGISTER@D-GRID.DE
smtpHost = localhost
smtpUser = register@textgridlab.org
......
......@@ -15,23 +15,22 @@ $imap = new tgImap($conf);
// work around magic_quotes_gpc
if (get_magic_quotes_gpc()) {
$data = stripslashes($_POST[data]);
$data = stripslashes($_POST['data']);
} else {
$data = $_POST[data];
$data = $_POST['data'];
}
/**
* Validation
*/
//print_r($_POST);
//echo $data;
$in = json_decode($data, TRUE);
$out['status'] = 'validating';
//print_r($in);
//echo $in['email'];
// if no language selected default to english
if(!isset($in['lang'])) {
$in['lang'] = 'en';
}
// email already used? -> query ldap
if($ldap->emailExists($in['email'])) {
$out['error']['email'] = "registered";
......@@ -42,8 +41,11 @@ if($ldap->uidExists($in['userid'])) {
$out['error']['userid'] = "userid_used";
}
if(empty($in['email']) ) {
$out['error']['email'] = "empty";
}
if($out['error']) {
if(isset($out['error'])) {
echo json_encode($out);
return;
}
......@@ -51,9 +53,6 @@ if($out['error']) {
/**
* validation done, request -> db, mail to user and ...
*/
//print_r($db->getUserRequests());
$db->insertUserRequest($in);
// send email
......@@ -87,7 +86,7 @@ function sendMails($conf, $imap, $db, $data) {
}
$body .= "\nLink zum Backend : " . $conf['url'] . "\n";
$imap->mail($conf['imap']['cc'], 'New Request', $body);
$imap->mail($conf['mail']['cc'], 'New Request', $body);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment