Электронные книги

<?php
   $lot="http://electrobook.ru/shop/tovar_001.html"; # урл лота в шопе http://www.electrobook.ru/shop/ - как он видится там по умолчанию, а НЕ то, как выглядит Ваш партнерский линк!!!
   $partner="orzu"; # здесь впишите ваш логин партнера-дилера
   $sh=array(
      array("<input type='hidden' name='USER_AFFILIATE' value='none'>"," партнёр none'>","<p>"),
      array("<input type='hidden' name='USER_AFFILIATE' value='$partner'>"," партнёр $partner'>","<p class=p>")
    );
   $ft=array(
      array("<!-- code lot start -->","<!-- code lot end -->"),
      array("<!-- code wm start -->","<!-- code wm end -->"),
      array("<!-- code rupay start -->","<!-- code rupay end -->"),
      array("<!-- code alternative start -->","<!-- code alternative end -->"),
      array("<!-- code dolli start -->","<!-- code dolli end -->"),
      array("<!-- code zpayment start -->","<!-- code zpayment end -->"),
      array("<!-- code robokassa start -->","<!-- code robokassa end -->"),
   );
   $out=import_price($lot,$sh,$ft);
# Небольшой парсер странички лота.
# Меняет оформление.
# Понимает разные версии шопов:
   $out[1]=preg_replace("'<script[^>]*?>.*?</script>'si","",$out[1]);
   $m=preg_match_all("/<form(.*)<\/form>/Uis",$out[1],$arr);
   for ($j=0; $j < $m; $j++) {
      $arr[1][$j]=str_replace("\"","'",$arr[1][$j]);
      $n=preg_match_all("/'LMI_PAYMENT_AMOUNT' value='(.+)'>.*<input type=submit value='(.+)'/Uis",$arr[1][$j],$tmp);
      for ($k=0; $k < $n; $k++) {
         list ($arg,$wm)=array($tmp[1][$k],$tmp[2][$k]);
         $to=(stristr($wm,"WM") and !stristr($wm,$arg)) ? $arg." ".$wm: $wm;
         $to="   <td width=101><input type=submit value='".strtoupper($to)."' class=wm></td>";
         $from="'<td[^>]*?><input type=submit value=\'$wm\' class=wmi></td>'si";
         $arr[1][$j]=preg_replace($from,$to,$arr[1][$j]);
      }
   }
# Для гарантии убивем импортированный скрипт проверки емайла,
# и учреждаем собственный:
   $out[1]="
      <script>
         function rupau() {
            if (document.wmr) dp=document.wmr.USER_PAY.value;
            else if (document.rupay) dp=document.rupay.sum_pol.value;
            else if (document.robokassa) dp=document.robokassa.sum.value;
            else if (document.zpayment) dp=document.zpayment.USER_PAY.value;
            else dp=0;
            if (dp < 1.00) {
               alert('Платежи менее рубля данным сервисом не обрабатываются');
               return false;
            } else return email_on_air();
         }
         function email_on_air() {
            if (document.wmr.USER_EMAIL.value=='') {
               alert('Вы должны указать свой email !!! При нажатии кнопки курсор будет помещён в форму ввода email');
               document.subscribe.email.focus();
               return false;
            } else return true;
         }
         function check() {
            if (!document.wmz) document.subscribe.email.value='магазин выключен...';
            else if (subscribe.email.value.match(/^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,4}$/i)) {
               if (document.zpayment) document.zpayment.CLIENT_MAIL.value=document.subscribe.email.value;
               if (document.zpayment) document.zpayment.USER_EMAIL.value=document.subscribe.email.value;
               if (document.robokassa) document.robokassa.email.value=document.subscribe.email.value;
               if (document.wmz) document.wmz.USER_EMAIL.value=document.subscribe.email.value;
               if (document.wmr) document.wmr.USER_EMAIL.value=document.subscribe.email.value;
               if (document.cbz) document.cbz.USER_EMAIL.value=document.subscribe.email.value;
               if (document.cbr) document.cbr.USER_EMAIL.value=document.subscribe.email.value;
               if (document.rupay) document.rupay.email.value=document.subscribe.email.value;
               if (document.other) document.other.email.value=document.subscribe.email.value;
               document.subscribe.email.value='ok, email принят';
            } else document.subscribe.email.value='некорректный email';
            return false;
         }
      </script>";
   for ($j=0; $j < count($arr[1]); $j=$j+2) {
      if (empty($arr[1][$j]) or empty($arr[1][$j+1])) continue;
      $merchant=(stristr($arr[1][$j],"payment.asp") and stristr($arr[1][$j+1],"payment.asp")) ?
         "▪ Оплата через WebMoney происходит в браузере при запущенной программе WM Keeper. Получение ссылок для скачивания книг - автоматически, сразу же после получения оплаты":
         "Выполнить операцию внутри кипера:";
      $out[1].=
         "\n<table width=100% border=0 cellspacing=0 cellpadding=0 class=wmbuttons>".
         "\n<tr><td><p>$merchant</p></td>\n     <form id=wm ".$arr[1][$j]."</form>\n      <form ".$arr[1][$j+1]."</form></tr>\n</table>";
   }
   $out[2]=preg_replace("'<table[^>]*?>'si","<table width=100% border=0 cellspacing=0 cellpadding=0 class=wmbuttons>",$out[2]);
   $out[2]=str_replace("<form ","<form id=rupay ",$out[2]);
   $out[2]=preg_replace("'<td width=[^>]*?>'si","<td width=101>",$out[2]);
   $out[2]=preg_replace("'<input type=submit[^>]*?>'si","<input type=submit value='RBC money' class=wm>",$out[2]);
   $out[3]=str_replace("<form ","<form id=other ",$out[3]);
   $out[3]=preg_replace("'<select name=varianto[^>]*?>'si","<select name='varianto' class=select>",$out[3]);
   $out[3]=preg_replace("'<input type=submit[^>]*?>'si","<input type=submit value='оформить заказ' class=submit>",$out[3]);
   $echo=<<<EOF
<!-- Оформление элементов формы: -->
<style>
.lotbody td {border:1px lavender solid;padding:1px;margin:0;font-family:verdana,arial,sans-serif;color:black;font-size:11px;font-weight:normal;}
.wmbuttons td {border:0px;padding:1px;margin:0;}
.wm {width:100px;}
#useremail .email {width:240px;}
#useremail .submit {width:120px;}
#other .select {width:244px;}
#other .submit {width:120px;}
p {text-indent:0em;margin:2px 0;}
</style>
  
<table align="center" border="1" width="650" cellspacing="1" cellpadding="1" class="lotbody">
<tr height="21">
   <form onSubmit='return check();' name="subscribe" id="useremail">
      <td valign="top" width="115">
            <font color="red">Внимание !!!</font>
            <br><img width="115" height="1" border="0"></td>
      <td valign="top">
            <p>Введите свой е-mail.<br>Адрес Вашей электронной почты будет задействован при получении ссылок для скачивания книг, идентификации Вас как покупателя и получения ключей к купленным книгам:</p>
            <div><img width="500" height="1" border="0"></div>
            <center>
            <input name="email" type="text" size="30" value="Укажите свой email:" maxlength="50" onfocus=document.subscribe.email.value=''; class="email">
            <input name="eml" type="submit" size="30" value="Запомнить email" class="submit">
            </center>
            </td>
   </form>
</tr>
EOF;
   $echo.=$out[4]."
<tr height=\"21\">
      <td valign=\"top\" width=\"115\">ОПЛАТА ЧЕРЕЗ WEBMONEY:<br><img width=\"115\" height=\"1\" border=\"0\"></td></td>
      <td valign=\"top\">
         <div><img width=\"100%\" height=\"1\" border=\"0\"></div>
         $out[1]
         </td>
</tr>";
   if (isset($out[5]) and $out[5]!="") $echo.="
<tr height=\"21\">
      <td valign=\"top\" width=\"115\">ОПЛАТА ЧЕРЕЗ<br>Z-PAYMENT:</td>
      <td valign=\"top\">$out[5]</td>
</tr>";
   if (isset($out[6]) and $out[6]!="") $echo.="
<tr height=\"21\">
      <td valign=\"top\" width=\"115\">ОПЛАТА ЧЕРЕЗ RoboKassa:</td>
      <td valign=\"top\">$out[6]</td>
</tr>";
   if (isset($out[2]) and $out[2]!="") $echo.="
<tr height=\"21\">
      <td valign=\"top\" width=\"115\">ОПЛАТА ЧЕРЕЗ RBC Money:</td>
      <td valign=\"top\">$out[2]</td>
</tr>";
   if (isset($out[3]) and $out[3]!="") $echo.=$out[3];
   $echo.="</td></tr></table><br>";     
function import_price($file,$sh,$ft) {
   $out=array_fill(0,10,"");
   $ic=@file($file);
   $se=array();
   for ($i=0; $i < count($ic); $i++) {
      if (strlen($ic[$i]) > 3) $se[]=$ic[$i];
   }
   for ($k=0; $k < count($ft); $k++) {
      for ($i=0; $i < sizeof($se); $i++) {
         if (ereg($ft[$k][0],$se[$i])) {
            $ya=array();
            $end=false;
            for ($j=1; $j < sizeof($se)-$i; $j++) {
               if (ereg($ft[$k][1],$se[$i+$j])) $end=true;
               if (!$end) $ya[]=$se[$i+$j];
            }
            for ($j=0; $j < sizeof($ya); $j++) {
               if (ereg("index.php",$ya[$j])) $out[$k].=$ya[$j]; else $out[$k].=str_replace($sh[0],$sh[1],$ya[$j]);
            }
         }
      }
   }
   return $out;
}
# Тут сидит получившийся код платёжной формы.
# Отдаём его на экран:
    echo $echo;
  
?>

Поиск: 

Новости

26.03.10
бонусы




Всего визитов: 27492
Сегодня посетителей:
Сегодня визитов: 1

место для счетчиков