<?

include("const.php");

?>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">

<meta http-equiv="Content-Language" content="ru">

<title>Отзывы покупателей</title>

<link rel="stylesheet" href="/antsoft.css" type="text/css">

</head>

<body topmargin="0" leftmargin="0" link="#0000FF" vlink="#0000FF" alink="#FF0000">



<?

If ($shopcnt <> "" and $wm <> "") {



 $fcnt = @file("shopcounts.inc");

 for ($i = 0; $i < count($fcnt); $i++) {

  $ar = explode("^", trim($fcnt[$i]));

  If ($ar[0] == $shopcnt) {

   $fid = $i;

   break;

  }

 }



 $tovid = $ar[7];

 $fr = @file("responses/$tovid");



 If ($fid >= 0 and $ar[6] == $wm and $ar[4] == "1") {

  $presp = -1;

  for ($t = 0; $t < count($fr); $t++) {

   $ee = explode("^", $fr[$t]);

   If ($ee[3] == $shopcnt) {

    $presp = $t;

    break;

   }

  }



  If ($presp == -1) {

   $presp = count($fr);

   $fr[0] = "";

   $ee = "";

  }



  If ($send == "ok") {

   $fg = @file("goods/$tovid");

   $fm = @file("moneyback/" . trim($fg[0]));

   If (trim($fm[1]) == "") { $fm[0] = ""; }

   $wepos = count($fm);

   for ($r = 0; $r < count($fm); $r++) {

    $we = explode("^", trim($fm[$r]));



    If ($we[0] == $shopcnt) {

     $wepos = $r;

     break;

    }

   }

   $fm[$wepos] = "$shopcnt^$r1^" . trim($fg[1]) . "^$wm^$wmz";



   $fmw = fopen("moneyback/" . trim($fg[0]), "w");

   for ($h = 0; $h < count($fm); $h++) {

    fwrite($fmw, trim($fm[$h]) . "\n");

   }

   fclose($fmw);



   $msg = str_replace("\n","<br>",htmlspecialchars(stripslashes($msg)));

   $msg = str_replace("^","_",$msg);



   $fr[$presp] = "$r1^" . date("d.m.Y") . "^{$msg}^{$shopcnt}^{$ww[4]}\n";

   $ee[2] = $msg;



   $ff = fopen("responses/$tovid", "w");

   for ($i = 0; $i < count($fr); $i++) {

    fwrite($ff, trim($fr[$i]) . "\n");

   }

   fclose($ff);

   echo "<script> alert('Сохранено!'); </script>";

   $ee[0] = $r1;

  }

 }

 Else {

  echo "<script> alert('Неоплаченному товару отзыв добавлять нельзя!'); history.back(); </script>";

 }

 $msg = $ee[2];



 If ($ee[0] == "1") {

  $rbad = "checked";

 }

 Else {

  $rgood = "checked";

 }

 ?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">

  <tr>

    <td width="100%" bgcolor="#9ACE8B"><img border="0" src="/pic_delivery.gif" width="247" height="38"></td>

  </tr>

  <tr>

    <td width="100%">

      <table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#F1FFED" style="border-collapse: collapse" bordercolor="#111111">

        <tr>

          <td width="100%" height="138" valign="top">

<form method="POST">

<input type="hidden" name="send" value="ok">

<p>Ваш отзыв: <input type="radio" value="0" name="r1" <? echo $rgood ?>>хорошо <input type="radio" value="1" name="r1" <? echo $rbad ?>>плохо</p>

<p align="center">

<textarea rows="6" name="msg" cols="52" style="font-family: Verdana, Arial; font-size: 8pt; border: 1px solid #9ACE8B; "><? echo str_replace("<br>", "\n", $msg); ?></textarea></p>

<?

If ($send == "") {

 ?>

<p>Ваш WMZ кошелек:

<input type="text" name="wmz" <? echo $arwmz[4] ?>size="20" style="border: 1px solid #9ACE8B" size="15" maxlength="13" style="font-family: Verdana, Arial; font-size: 8pt; border: 1 solid #7F9DB9"></p>

 <?

}

?>

          </td>

        </tr>

      </table>

    </td>

  </tr>

</table>

<p align="center">

<input type="submit" name="B1" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED" value="Сохранить">

<input type="button" onClick="document.location.href='/check.php?shopcnt=<? echo $shopcnt ?>&wm=<? echo $wm ?>'" name="B2" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED" value="Возврат"></p>

</form>

 <?

}

Else {

 If ($com == "bad") {

  $b1 = "";

  $b2 = "";

  $b3 = "<b>";

  $b4 = "</b>";

 }

 Else {

  $b1 = "<b>";

  $b2 = "</b>";

  $b3 = "";

  $b4 = "";

 }

?>



<table border="0" width="100%" height="176" cellspacing="0" cellpadding="0">

  <tr>

    <td width="100%" height="19" bgcolor="#9ACE8B">

      <p align="center"><? echo $b1 ?><a href="/responses.php?tovid=<? echo $tovid ?>" class="cap2">положительные</a>

      <? echo $b2 ?> |&nbsp; <? echo $b3 ?><a href="/responses.php?com=bad&tovid=<? echo $tovid ?>" class="cap2">отрицательные</a><? echo $b4 ?></td>

  </tr>

  <tr>

    <td width="100%" valign="top" bgcolor="#F1FFED">

    <div style="overflow-y:scroll;height:100%;width:100%;border: 1px solid #9ace8b;">

    <table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#F1FFED" style="border-collapse: collapse" bordercolor="#111111">



<?

If ($com == "bad") {

 $sravno = "1";

}

Else {

 $sravno = "0";

}



$fre = @file("responses/$tovid");



$none = true;

for ($i = 1; $i < count($fre); $i++) {

 $ar = explode("^", trim($fre[$i]));

 If ($ar[0] == $sravno) {

  If ($ar[4] <> "") {

   $otvet = "<p><b>ответ продавца:</b></p><p>$ar[4]</p>";

  }

  echo "

      <tr>

        <td width='30%' style='border-bottom: 1 solid #9ace8b' valign='top'><p><b>$ar[1]</b></p></td>

        <td width='70%' style='border-bottom: 1 solid #9ace8b'><p>$ar[2]</p>$otvet</td>

      </tr>

  ";

   $none = false;

 }

 Else {

  $none = true;

 }

}

If ($none == true) {

 echo "

      <tr>

        <td width='100%' height='150' valign='center'><p align='center'><b>Отзывов не найдено!</b></p></td>

      </tr>";

}

?>



    </table>

    </div>

    </td>

  </tr>

</table>

<p align="center">

<input type="button" onClick="window.close()" name="closewindow" value="Закрыть окно" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED"></p>



<?

}

?>



</body>

</html>