zero-perfoliate
zero-perfoliate

Author Topic: Unknown php code  (Read 178 times)

Offline gordon2

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Unknown php code
« on: May 23, 2010, 12:17:01 AM »
Please, assist with a small piece of PHP code, which I don't understand
Code: [Select]
echo $text.=<<<post
//here goes PHP code
post;


Below the whole code.  Can that piece be replaced with something more understandable.
Basically it wokrs on WAMP, but on my live server after pressing button Send it redirects to a blank page, though messages are sent and delivered.

Code: [Select]
<?php
    set_time_limit 
(1200);
    
$mail1="&#1042;&#1072;&#1096;&#1077; &#1080;&#1084;&#1103; 1 <your1@email.com>";
    
$mail2="&#1042;&#1072;&#1096;&#1077; &#1080;&#1084;&#1103; 2 <your2@email.com>";
    
$mail3="&#1042;&#1072;&#1096;&#1077; &#1080;&#1084;&#1103; 3 <your3@email.com>";

    
$tmail1=htmlspecialchars($mail1);
    
$tmail2=htmlspecialchars($mail2);
    
$tmail3=htmlspecialchars($mail3);

    if (!empty(
$_POST) && !isset($sent)) {

    
$emailer_subj $_POST['emailer_subj'];
    
$emailer_mails $_POST['emailer_mails'];
    
$emailer_text $_POST['emailer_text'];
    
$emailer_yourmail $_POST['emailer_yourmail'];

    if (empty(
$emailer_subj) || $emailer_subj=="&#1058;&#1077;&#1084;&#1072; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;") {
    
$mail_msg='<b>&#1042;&#1099; &#1085;&#1077; &#1074;&#1074;&#1077;&#1083;&#1080; &#1090;&#1077;&#1084;&#1091; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;</b>';
  } elseif (empty(
$emailer_mails) || $emailer_mails=="&#1055;&#1086;&#1095;&#1090;&#1086;&#1074;&#1099;&#1077; &#1072;&#1076;&#1088;&#1089;&#1077;") {
    
$mail_msg='<b>&#1053;&#1077; &#1091;&#1082;&#1072;&#1079;&#1072;&#1085;&#1086; &#1072;&#1076;&#1088;&#1077;&#1089;&#1072; &#1087;&#1086;&#1083;&#1091;&#1095;&#1072;&#1090;&#1077;&#1083;&#1077;&#1081;</b>';
  } elseif (empty(
$emailer_text) || $emailer_text=="&#1058;&#1077;&#1082;&#1089;&#1090; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;") {
    
$mail_msg='<b>&#1042;&#1099; &#1085;&#1077; &#1074;&#1074;&#1077;&#1083;&#1080; &#1090;&#1077;&#1082;&#1089;&#1090; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;</b>';
  } else {
    
$mail_msg='&#1042;&#1072;&#1096;&#1077; &#1089;&#1086;&#1086;&#1073;&#1097;&#1077;&#1085;&#1080;&#1077; &#1086;&#1090;&#1087;&#1088;&#1072;&#1074;&#1083;&#1077;&#1085;&#1086;.<br>&#1053;&#1072;&#1078;&#1084;&#1080;&#1090;&#1077; <a href="'.$_SERVER['REQUEST_URI'].'">&#1079;&#1076;&#1077;&#1089;&#1100;</a>, &#1077;&#1089;&#1083;&#1080; &#1074;&#1072;&#1096; &#1073;&#1088;&#1072;&#1091;&#1079;&#1077;&#1088; &#1085;&#1077; &#1087;&#1086;&#1076;&#1076;&#1077;&#1088;&#1078;&#1080;&#1074;&#1072;&#1077;&#1090; &#1087;&#1077;&#1088;&#1077;&#1085;&#1072;&#1087;&#1088;&#1072;&#1074;&#1083;&#1077;&#1085;&#1080;&#1077;.';
    
$headers="MIME-Version: 1.0\r\n";
    
$headers.="Content-type: text/html; charset=utf-8\r\n";
    
$headers.="From: $emailer_yourmail";

    
$emailer_text=preg_replace("/ +/"," ",$emailer_text);
    
$emailer_text=preg_replace("/(\r\n){3,}/","\r\n\r\n",$emailer_text);
    
$emailer_text=str_replace("\r\n","<br>",$emailer_text);

    
$emails=explode(","$emailer_mails);
    
$count_emails count($emails);
    for (
$i=0$i<=$count_emails-1$i++)
    {
    
$email=trim($emails[$i]);
    if(
$emails[$i]!="") {
    if(
mail($email,$emailer_subj,$emailer_text,$headers)) $report.="<li><span style=\"color:green;\">&#1054;&#1090;&#1087;&#1088;&#1072;&#1074;&#1083;&#1077;&#1085;&#1086;: ".$emails[$i]."</span></li>"; else $report.="<li><span style=\"color:red;\">&#1053;&#1077; &#1086;&#1090;&#1087;&#1088;&#1072;&#1074;&#1083;&#1077;&#1085;&#1086;: ".$emails[$i]."<span></li>";
    
sleep(5);
    }
    }

    
$log=fopen("log.txt","w");
    
fwrite($log,$report);
    
fclose($log);
    
$sent=1;
  }
} else {
  
$mail_msg='&#1042;&#1089;&#1077; &#1087;&#1086;&#1083;&#1103; &#1086;&#1073;&#1103;&#1079;&#1072;&#1090;&#1077;&#1083;&#1100;&#1085;&#1099; &#1076;&#1083;&#1103; &#1079;&#1072;&#1087;&#1086;&#1083;&#1085;&#1077;&#1085;&#1080;&#1103;.';
  
$emailer_text=$emailer_subj=$emailer_mails=$emailer_yourmail='';
}

    if (!isset(
$sent)) {
    if(isset(
$_GET['messent']))
    {echo 
$text.="<b style=\"text-align:center;margin-top:200px;display:block;\">&#1042;&#1089;&#1105; &#1086;&#1082;&#1077;&#1081;. &#1057;&#1086;&#1086;&#1073;&#1097;&#1077;&#1085;&#1080;&#1077; &#1086;&#1090;&#1087;&#1088;&#1072;&#1074;&#1083;&#1077;&#1085;&#1086;. <a href=\"emailer.php\">&#1045;&#1097;&#1105;?</a><br><br><u>&#1054;&#1090;&#1095;&#1105;&#1090;:</u></b> <ol style=\"display:block;width:300px;margin:10px auto;\">";
    
readfile("log.txt");
    echo
"</ol>";}
    else {
    echo 
$text.=<<<post
    <script type="text/javascript">
    function form_validator(form) {
    if (form.emailer_subj.value=='' || form.emailer_subj.value=='&#1058;&#1077;&#1084;&#1072; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;') { alert('&#1059;&#1082;&#1072;&#1078;&#1080;&#1090;&#1077; &#1090;&#1077;&#1084;&#1091; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;.'); form.emailer_subj.focus(); return false; }
    if (form.emailer_mails.value=='' || form.emailer_mails.value=='&#1055;&#1086;&#1095;&#1090;&#1086;&#1074;&#1099;&#1077; &#1072;&#1076;&#1088;&#1077;&#1089;&#1072;') { alert('&#1059;&#1082;&#1072;&#1078;&#1080;&#1090;&#1077; &#1072;&#1076;&#1088;&#1077;&#1089;&#1072; &#1087;&#1086;&#1083;&#1091;&#1095;&#1072;&#1090;&#1072;&#1083;&#1077;&#1081;.'); form.emailer_mails.focus(); return false; }
    if (form.emailer_text.value=='' || form.emailer_text.value=='&#1058;&#1077;&#1082;&#1089;&#1090; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;') { alert('&#1042;&#1099; &#1085;&#1077; &#1079;&#1072;&#1087;&#1086;&#1083;&#1085;&#1080;&#1083;&#1080; &#1087;&#1086;&#1083;&#1077; &#1089;&#1086;&#1086;&#1073;&#1097;&#1077;&#1085;&#1080;&#1103;.'); form.emailer_text.focus(); return false; }
    return true;
    }
    </script>
    <style type="text/css">
    form {display:block;margin:20px auto;width:500px;}
    textarea, input, select {width:100%; margin:5px 0;}
    textarea {height:200px;}
    .red {color:#a00;}
    </style>
    <form method="post" onsubmit="return form_validator(this);">
    <p class="red">$mail_msg</p>
    <input type="text" name="emailer_subj" id="emailer_subj" value="&#1058;&#1077;&#1084;&#1072; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;" title="&#1055;&#1086; &#1082;&#1072;&#1082;&#1086;&#1084;&#1091; &#1087;&#1086;&#1074;&#1086;&#1076;&#1091; &#1087;&#1080;&#1096;&#1077;&#1084;?" onfocus="if (this.value=='&#1058;&#1077;&#1084;&#1072; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;') this.value='';" onblur="if (this.value=='') this.value='&#1058;&#1077;&#1084;&#1072; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;';">
    <textarea name="emailer_mails" id="emailer_mails" title="&#1050;&#1090;&#1086; &#1087;&#1086;&#1083;&#1091;&#1095;&#1072;&#1090;&#1077;&#1083;&#1080;?" onfocus="if (this.value=='&#1055;&#1086;&#1095;&#1090;&#1086;&#1074;&#1099;&#1077; &#1072;&#1076;&#1088;&#1077;&#1089;&#1072;') this.value='';" onblur="if (this.value=='') this.value='&#1055;&#1086;&#1095;&#1090;&#1086;&#1074;&#1099;&#1077; &#1072;&#1076;&#1088;&#1077;&#1089;&#1072;';">&#1055;&#1086;&#1095;&#1090;&#1086;&#1074;&#1099;&#1077; &#1072;&#1076;&#1088;&#1077;&#1089;&#1072;</textarea>
    <textarea name="emailer_text" id="emailer_text" title="&#1063;&#1090;&#1086; &#1087;&#1080;&#1096;&#1077;&#1084;?" onfocus="if (this.value=='&#1058;&#1077;&#1082;&#1089;&#1090; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;') this.value='';" onblur="if (this.value=='') this.value='&#1058;&#1077;&#1082;&#1089;&#1090; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;';">&#1058;&#1077;&#1082;&#1089;&#1090; &#1087;&#1080;&#1089;&#1100;&#1084;&#1072;</textarea>
    <select name="emailer_yourmail">
    <option value="$mail1">$tmail1</option>
    <option value="$mail2">$tmail2</option>
    <option value="$mail3">$tmail3</option>
    </select>
    <input type="submit" value="&#1054;&#1090;&#1087;&#1088;&#1072;&#1074;&#1080;&#1090;&#1100;" title="&#1054;&#1090;&#1087;&#1088;&#1072;&#1074;&#1080;&#1090;&#1100; &#1084;&#1099;&#1083;">
    </form>
post;
}
}
else { 
  
$ret_uri=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
  
header("Refresh: 0; URL=http://".$ret_uri."?messent");
  exit;
}

?>

 

zero-perfoliate