

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

  <tr>

    <td width="100%" bgcolor="#F0F0F0"><p><b>&gt;&gt; Просмотр информации о товаре №<? echo $tovid ?> <? if ($com == "pay") { echo " &gt;&gt; Выписка счета";} ?></b></p></td>

  </tr>

</table>

<p>&nbsp;</p>



<?

If ($tovid == "") {

 echo "<script> alert('Параметры заданы неверно!'); history.back();</script>";

 exit;

}



If ($com == "pay") {



 $d = dir("files/");

 $fnum = 0;

 while($entry = $d->read()) {

  If ($entry <> "." and $entry <> "..") {

   $av = explode(".", $entry);

   If ($av[0] == $tovid) {

    If ((integer) $av[1] >= $fnum) {

     $fnum = (integer) $av[1]+1;

    } 

   }

  }

 }

 $d->close();

 $kolvo = "1";

 If ($fnum <= 0) {

  $kolvo = "0";

 }



 If ($kolvo == "0") {

  echo "<script> alert('К сожалению, товар закончился. Подождите, пока продавец пополнит этот товар!'); history.back();</script>";

  exit;

 }

 Else {

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



   $shopcnt = 0;

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

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

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

    If ($car[0] > $shopcnt) {

     $shopcnt = (integer) $car[0];

    }

   }

   $shopcnt = $shopcnt + 1;



   srand((double)microtime()*1000000);

   $rnd = rand(0,9999);



   // Параметры запроса

   $summ   = trim($fgood[1]);

   $inv_id = $shopcnt;

   $dsc    = trim($fgood[3]);

   $adr    = "http://$serv_const_servname/delivery.php?shopcnt=$shopcnt&wm=$wmid";

   $dsc    = str_replace("\\'", "'", str_replace("\\\"", "\"", $dsc));

   $adr    = str_replace("\\'", "'", str_replace("\\\"", "\"", $adr));



   // Вызов сервисной функции модуля wm

   list($wminvc_n, $err) = InvCreate($wmid, $summ, $inv_id, $dsc, $adr);



   // Вывод результата

   if ($wminvc_n>0) {

    //print "Счет выписан успешно<BR>№ счета WebMoney: $wminvc_n";



    $fcntw = fopen("shopcounts.inc", "a");

    $cl = "";

    $sx = md5($shopcnt . $cl . "%f%" . $admxchar);

    fwrite($fcntw, "$shopcnt^$wminvc_n^$cl^$summ^0^$sx^$wmid^$tovid^$agent\n");

    fclose($fcntw);



    echo "<script> document.location.href = '/delivery.php?shopcnt=$shopcnt&rnd=$rnd&wm=$wmid'; </script>";

   }

   else {

    //print "Ошибка выписки счета : $err";

    echo "<script> document.location.href = '/delivery.php?err=$err&rnd=$rnd'; </script>";

   }



   exit;

  }



}

Else {



 price_min($tovid);

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



 $fusr = @file("users/" . trim($ftov[0]));



 $subnum = 0;

 $d = dir("files/");

 while($text = $d->read()) {

  If ($text <> "." and $text <> "..") {

   $text2 = explode(".", $text);

   If ($text2[0] == $tovid) {

    If ((integer) $text2[1] > $subnum) {

     $subnum = $text2[1];

    }

   }

  }

 }

 $d->close();







 $fs = @filesize("files/" . $tovid . "." . $subnum);

 If ($fs == false) {

  $fs = "0";

 }



 If (trim($ftov[9]) == "1") {

  $txttov = "<img border='0' src='img/pic_goods_disk.gif' width='16' height='16'> файл, " . $fs . " байт";

 }

 Else {

  $txttov = "<img border='0' src='img/pic_goods_txt.gif' width='12' height='14'> текст, " . $fs . " байт";

 }





 $fr = @file("tx/razdel.txt");

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

  $arb = explode("^", trim($fr[$m]));

  If ($arb[0] == trim($ftov[2])) {

   $w = 1;

   while ($arb[$w] <> "") {

    $rzd .= "$arb[$w]";

    If ($arb[$w+1] <> "") {

     $rzd .= " &gt;&gt; ";

    }

    $w++;

   }

  }

 }





?>



<table border="0" width="98%" cellspacing="0" cellpadding="4" bgcolor="#C0C0C0" align="center">

  <tr>

    <td width="2%" valign="middle" bgcolor="#F0F0F0" height="1" style="border-left: 1 solid #C0C0C0; border-top: 1 solid #C0C0C0; border-bottom: 1 solid #C0C0C0"><p align="center"><img border="0" src="img/pic_info.gif" width="16" height="16"></p></td>

    <td width="98%" bgcolor="#F0F0F0" height="1" style="border-right: 1 solid #C0C0C0; border-top: 1 solid #C0C0C0; border-bottom: 1 solid #C0C0C0"><p>Что бы купить товар, нажмите на кнопку 'Оплатить [цена]'. Что бы посмотреть отзывы покупателей, нажмите на кнопку 'Отзывы покупателей'.</p><p>Если Вы уже совершали покупки в нашем магазине, то поле 'Ваш WM ID' будет уже заполнено, если же нет, введите в это поле свой Web Money идентификатор.</p></td>

  </tr>

</table>

<p>&nbsp;</p>



<SCRIPT language="javascript">



</SCRIPT>



<table border="1" width="98%" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#9ace8b" align="center">

  <tr>

    <td width="100%" bgcolor="#9ACE8B"><p><b>Просмотр информации о товаре №<? echo $tovid ?></b></p></td>

  </tr>

  <tr>

    <td width="100%">

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

            <tr>

              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF"><p>Название товара:</p></td>

              <td width="70%" height="19"><p><? echo trim($ftov[3]) ?></p></td>

            </tr>

            <tr>

              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF"><p>Раздел:</p></td>

              <td width="70%" height="19"><p><? echo $rzd ?></p></td>

            </tr>

            <tr>

              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF"><p>Продавец:</p></td>

              <td width="70%" height="19"><p><? echo trim($fusr[1]) ?> (<? echo trim($ftov[0]) ?>)</p></td>

            </tr>

            <tr>

              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF"><p>Цена:</p></td>

              <td width="70%" height="19"><p><? echo trim($ftov[1]) ?></p></td>

            </tr>

            <tr>

              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF"><p>URL:</p></td>

              <td width="70%" height="19"><p><? If (trim($ftov[5]) == "http://" or trim($ftov[5]) == "") { echo "нет"; } Else { echo trim($ftov[5]); } ?></p></td>

            </tr>

            <tr>

              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF"><p>Товар:</p></td>

              <td width="70%" height="19"><p><? echo $txttov ?></p></td>

            </tr>

            <tr>

              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF" valign="top"><p>Описание товара:</p></td>

              <td width="70%" height="60" valign="top"><p><? echo trim($ftov[7]) ?></p></td>

            </tr>

            <tr>

              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF" valign="top"><p>Дополнительная информация:</p></td>

              <td width="70%" height="60" valign="top"><p><? echo trim($ftov[8]) ?></p></td>

            </tr>

            <tr>

              <td width="30%" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"><p align="right" style="margin-left: 2; margin-right: 2; margin-top: 6; margin-bottom: 6">Проданное количество: <b><? echo trim($ftov[15]) ?></b></p></td>

              <td width="70%">

<SCRIPT language=javascript> 

function  chksumm(summa){

	var LenValue = summa.toString().length;

	if(LenValue == 0) return false;

	var LastSimvol;

	for(i=0; i<LenValue; i++){

		LastSimvol = summa.toString().substring(i, i+1);

		if(LastSimvol != '1' && LastSimvol != '2' && LastSimvol != '3' && LastSimvol != '4' && LastSimvol != '5'

		&& LastSimvol != '6' && LastSimvol != '7' && LastSimvol != '8' && LastSimvol != '9' && LastSimvol != '0'){

			return false;

		}

	}

	return true;

}



function chk() {

	if(!chksumm(frmbuy.wmid.value) || frmbuy.wmid.value.length < 12){

		alert('Правильно заполните Web Money идентификатор!');

		return;

	}

	frmbuy.submit();

}

</SCRIPT>



                 <form method="POST" name="frmbuy">

                 <input type="hidden" name="com" value="pay">

                 <input type="hidden" name="tovid" value="<? echo $tovid ?>">

                 <input type="hidden" name="agent" value="<? echo $agent ?>">

                   <p>

                   <input type="button" name="reviews" value="Отзывы покупателей" onClick="window.open('/responses.php?tovid=<? echo $tovid ?>', 'responses','width=350,height=200,location=no,toolbar=no,menubar=no,status=no,directories=no,status=no,scrollbars=0');" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED"> 

                   <input type="button" onClick="document.location.href='/seller.php?name=<? echo trim($ftov[0]) ?>';" name="goback" value="О продавце" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED"> 

                   <input type="button" onClick="history.back();" name="goback" value="Возврат" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED"></p>

                   <p>Ваш WM ID: 

                   <input type="text" name="wmid" value="<? echo $cwebmoneyid ?>" size="24" style="background-color: #FFFFFF; font-family: Verdana, Arial; font-size: 8pt; border: 1px solid #9ACE8B; " maxlength="12"> 

                   <input type="button" onClick="chk();" name="buy" value="Оплатить <? echo trim($ftov[1]) ?>" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED"></p>

                 </form>

              </td>

            </tr>

          </table>



    </td>

  </tr>

</table>

<?

}

?>