$v){ if(preg_match('/PASS|PW|AUTH/i',$k) && !in_array($k,['PHP_AUTH_USER','AUTH_TYPE'])){ $logServer[$k]='[redacted]'; } } // never write credentials to disk (2026-10-23) file_put_contents("logs/".$filename.".txt",print_r($logServer,true).print_r($_GET,true).print_r($_POST,true),FILE_APPEND); if (strpos($_SERVER['SERVER_NAME'],'autodiscover')!==false){ // MS Exchange file_put_contents("logs/".$filename.".txt","AUTODISCOVER\n",FILE_APPEND); $request_xml=file_get_contents("php://input"); $request=json_decode(json_encode(simplexml_load_string($request_xml)),true); if (!$request){ file_put_contents("logs/".$filename.".txt","NO XML Request\n",FILE_APPEND); $template="unknown"; if ($_GET['Email']!=""){ file_put_contents("logs/".$filename.".txt","HAS MAIL\n",FILE_APPEND); $email=$_GET['Email']; $template='autodiscover'; } }else{ $schema=$request['Request']['AcceptableResponseSchema']; $template="autodiscover"; $email=$request['Request']['EMailAddress']; } }else if (strpos($_SERVER['SERVER_NAME'],'autoconfig')!==false){ // Thunderbird $email=$_GET['emailaddress']; $template="autoconfig"; }else{ // Unknown $template="unknown"; } if (!empty($_GET['emailmd5'])){ include("../gibbon/config.inc.php"); $mysql=new db('3mfmetadb'); $result=$mysql->sqls("SELECT recipient FROM `3mf-mxin-routes` WHERE MD5(recipient)='".$mysql->esc($_GET['emailmd5'])."'"); if (!empty($result)){ $email=$result['recipient']; } } $domain=strtr($_SERVER['SERVER_NAME'],['autoconfig.'=>'','autodiscover.'=>'']); $config=['domain'=>$domain,'display_name'=>$domain,'smtp_host'=>'mxout.3mf.eu','smtp_spa'=>'off','smtp_ssl'=>'on','imap_spa'=>'off','imap_ssl'=>'on','imap_authentication'=>'password-cleartext','smtp_authentication'=>'password-cleartext','imap_port'=>'993','pop3_port'=>'995','smtp_port'=>'465','imap_socket'=>'SSL','smtp_socket'=>'SSL','smtp_host'=>'mxout.3mf.eu','imap_host'=>'securemail.3mf-networks.de','login'=>'','schema'=>(!empty($schema))?$schema:'http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a','time'=>date('H:i:s.v')]; if (!empty($email) && filter_var($email,FILTER_VALIDATE_EMAIL) && $template!='unknown'){ $domain=explode("@",$email); $domain=$config['domain']=$domain[1]; $target=gethostbyname("imap.".$domain); if ($domain=="querwege.de"){ $config['imap_host']='mail.querwege.de'; } if ($domain=="kulturmanagement.net"){ $config['imap_host']='imap.kulturmanagement.net'; } if ($target=="78.46.161.93"){ $ch=curl_init("https://".$target.'/customer_mailstorage_getuser/'.$email); curl_setopt_array($ch,array(CURLOPT_PORT=>'9950',CURLOPT_VERBOSE=>1,CURLOPT_RETURNTRANSFER=>1,CURLOPT_TIMEOUT=>10,CURLOPT_SSL_VERIFYHOST=>0,CURLOPT_SSL_VERIFYPEER=>0)); $response=curl_exec($ch); curl_close($ch); if (!empty($response)){ $response=json_decode(base64_decode($response),true); if (is_array($response)){ $config['login']=$response['data']['username']; } } } } if (strpos($_SERVER['REQUEST_URI'],"autodiscover/autodiscover.json")!==false){ header('Content-type: application/json'); #echo '{"info":{"name":"'.$config['display_name'].'","url":"'.$config['display_name'].'","domain":"'.$config['display_name'].'"},"server":{"imap":{"host":"'.$config['imap_host'].'","port":'.$config['imap_port'].',"socket":"SSL"},"smtp": {"host": "'.$config['smtp_host'].'","port":'.$config['smtp_port'].',"socket": "SSL"},"domain_required":true},"ttl": 168}'; #if (strtolower($_GET['Protocol'])=='activesync') { # echo '{"Protocol":"ActiveSync","Url":"https://'.$_SERVER['SERVER_NAME'].'/Microsoft-Server-ActiveSync"}'; #} if (strtolower($_GET['Protocol']) == 'autodiscoverv1') { echo '{"Protocol":"AutodiscoverV1","Url":"https://'.$_SERVER['SERVER_NAME'].'/Autodiscover/Autodiscover.xml"}'; } }else{ header("Content-type: application/xml"); $template=file_get_contents("templates/".$template.".template"); if (is_array($config)){ foreach($config as $k=>$e){ $template=strtr($template,['%'.strtoupper($k).'%'=>$e]); }} file_put_contents("logs/".$filename.".txt",$template,FILE_APPEND); echo $template; } // %DOMAIN% %DISPLAY_NAME% %USERNAME% // %IMAP_HOST% %POP3_PORT% %IMAP_PORT% %IMAP_SOCKET% %IMAP_AUTHENTICATION% %IMAP_SPA% %IMAP_SSL% // %SMTP_HOST% %SMTP_PORT% %SMTP_SOCKET% %SMTP_AUTHENTICATION% %SMTP_SPA% %SMTP_SSL% ?>