<?

$serv_const_servname = "shopwm.ru";

$serv_const_commission = 0.03;

$serv_const_reklamcommission = 0.03;

$serv_const_nchar = "!@#$%^&*()/|\~`=+?:;№<>йцукенгшщзхъфывапролджэячсмитьбю.,{}";

$serv_const_names = "administrator^support^1^2^3^100^wmshop^wm^webmoneyshop^anton^admin^server^najel^";

$serv_const_lstcount = 40;

$serv_const_shopwmz = "Z750121392533";

$serv_const_shopwmid = "554707490608";

$admxchar = "ZayzEmzyVrakrup19:ertkiweruijnjfgtert";

$wmconst__shop_wmpurse = $serv_const_shopwmz;	// Кошелек магазина, используемого для расчетов

$wmconst__shop_wmid    = $serv_const_shopwmid;	// WMидентификатор магазина

$wmconst__invc_protect = '0';			// Срок протекции выписываемых счетов

$wmconst__invc_active  = '3';			// Срок действия  выписываемых счетов

$wmconst__trans_prtime = '0';			// Срок протекции сделки для переводов с протекцией



include("wm.inc");





//функции

function wm_send_msg($tx_wmid, $tx_msg) {

 $wmid   = $tx_wmid;

 $msg    = str_replace("\\'", "'", str_replace("\\\"", "\"", $tx_msg));



 $res = SendMsg($wmid, $msg);



 if (strlen($res) <= 0) {

  return true;

 }

 else {

  return $res;

 }

}



function history($usrlogin, $prihod, $rashod, $comis, $syscomis, $from, $to, $text) {

 global $serv_const_servname;

 $text = str_replace("^","_",htmlspecialchars(stripslashes($text)));



 $fh = fopen("history/$usrlogin", "a");

 $fu = file("users/$usrlogin");

 $ostatok = trim($fu[9]);

 fwrite($fh, date("d.m.Y H:i:s") . "^$prihod^$rashod^$comis^$syscomis^$ostatok^$from^$to^$text\n");

 fclose($fh);



 return true;

}



function wm_send_money($tx_summ, $tx_usr, $tx_mdpwd, $tx_to, $tx_mb, $tx_hmsg) {

 global $serv_const_shopwmz;



 echo "<script> alert('$tx_summ, $tx_usr, $tx_mdpwd, $tx_to, $tx_mb, $tx_hmsg'); </script>";



 $fu = file("users/$tx_usr");

 $tx_summ = ceil($tx_summ*100)/100;

 $wmcomis = ceil($tx_summ*0.008*100)/100;



 If ($tx_mb == "moneyback") {

  If (trim($fu[11]) == "0" or trim($fu[11]) == "3") {

   $fu[11] = "1";

  }

 }



 If ((double) trim($fu[9]) >= $tx_summ+$wmcomis and trim($fu[11]) <> "0" and trim($fu[11]) <> "3") {

  If (md5(getenv("REMOTE_ADDR") . trim($fu[0])) == $tx_mdpwd) {



   //wm перевод

   $fcnr = file("tx/count.txt");

   $fcn_pos = (integer) trim($fcnr[0]);

   $fcn_pos = $fcn_pos + 1;

   $fcn = fopen("tx/count.txt", "w");

   fwrite($fcn, $fcn_pos);

   fclose($fcn);



   $trn_id  = $fcn_pos;

   $wmpurse = $tx_to;

   $summ    = $tx_summ;

   $dsc     = $tx_hmsg;

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



   list($wmtrn_n, $err) = TransCreate($wmpurse, $summ, $trn_id, $dsc);



   //wm перевод end



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

   if ($wmtrn_n>0) {

    //удаляем срадства с кошелька юзера begin

    $fg = fopen("users/$tx_usr", "w");

    fwrite($fg, trim($fu[0]) . "\n");

    fwrite($fg, trim($fu[1]) . "\n");

    fwrite($fg, trim($fu[2]) . "\n");

    fwrite($fg, trim($fu[3]) . "\n");

    fwrite($fg, trim($fu[4]) . "\n");

    fwrite($fg, trim($fu[5]) . "\n");

    fwrite($fg, trim($fu[6]) . "\n");

    fwrite($fg, trim($fu[7]) . "\n");

    fwrite($fg, trim($fu[8]) . "\n");

    fwrite($fg, (double) trim($fu[9]) - ($tx_summ+$wmcomis) . "\n");

    for ($rf = 10; $rf < count($fu); $rf++) {

     fwrite($fg, trim($fu[$rf]) . "\n");

    }

    fclose($fg);

    //удаляем срадства с кошелька юзера end

    history($tx_usr, "0", $tx_summ, $wmcomis, "0", $serv_const_shopwmz, $tx_to, $tx_hmsg);



    return true;

   }

   else {

    return $err;

   }

   $GLOBALS["ft"] = @file("users/$tx_usr");



  }

 }

 Else {

  return "На вашем счету не хватает денег либо Вы блокированы!";

 }

}



function serv_send_money($tx_summ, $tx_usr, $tx_mdpwd, $textmsg) {

 global $serv_const_shopwmz;



 $fu = file("users/$tx_usr");

 $tx_summ = ceil($tx_summ*100)/100;

 If ((double) trim($fu[9]) >= $tx_summ and trim($fu[11]) <> "0" and trim($fu[11]) <> "3") {

  If (md5(getenv("REMOTE_ADDR") . trim($fu[0])) == $tx_mdpwd) {



   //удаляем срадства с кошелька юзера begin

   $fg = fopen("users/$tx_usr", "w");

   fwrite($fg, trim($fu[0]) . "\n");

   fwrite($fg, trim($fu[1]) . "\n");

   fwrite($fg, trim($fu[2]) . "\n");

   fwrite($fg, trim($fu[3]) . "\n");

   fwrite($fg, trim($fu[4]) . "\n");

   fwrite($fg, trim($fu[5]) . "\n");

   fwrite($fg, trim($fu[6]) . "\n");

   fwrite($fg, trim($fu[7]) . "\n");

   fwrite($fg, trim($fu[8]) . "\n");

   fwrite($fg, (double) trim($fu[9]) - $tx_summ . "\n");

   for ($rf = 10; $rf < count($fu); $rf++) {

    fwrite($fg, trim($fu[$rf]) . "\n");

   }

   fclose($fg);

   //удаляем срадства с кошелька юзера end





   //перечисляем срадства на счет admin begin

   $fa = file("users/admin");

   $fg = fopen("users/admin", "w");

   fwrite($fg, trim($fa[0]) . "\n");

   fwrite($fg, trim($fa[1]) . "\n");

   fwrite($fg, trim($fa[2]) . "\n");

   fwrite($fg, trim($fa[3]) . "\n");

   fwrite($fg, trim($fa[4]) . "\n");

   fwrite($fg, trim($fa[5]) . "\n");

   fwrite($fg, trim($fa[6]) . "\n");

   fwrite($fg, trim($fa[7]) . "\n");

   fwrite($fg, trim($fa[8]) . "\n");

   fwrite($fg, (double) trim($fa[9]) + $tx_summ . "\n");

   for ($rf = 10; $rf < count($fu); $rf++) {

    fwrite($fg, trim($fa[$rf]) . "\n");

   }

   fclose($fg);

   //перечисляем срадства на счет admin end





   history($tx_usr, "0", $tx_summ, "0", "0", $serv_const_shopwmz, $serv_const_shopwmz, $textmsg);

   history("admin", $tx_summ, "0", "0", "0", $serv_const_shopwmz, $serv_const_shopwmz, $textmsg . " От пользователя $tx_usr");



   $GLOBALS["ft"] = @file("users/$tx_usr");

   return true;

  }

 }

 Else {

  return "На вашем счету не хватает денег либо Вы блокированы!";

 }

}







////////////////////////////////////////////////////////////// ПОНИЖЕНИЕ ЦЕН!

function price_min($tov) {

   $fgoods = @file("goods/" . $tov);



   If (trim($fgoods[11]) == "on") {

    $ardate = explode(".", trim($fgoods[17]));



    If ((double) $ardate[0] < (double) date("z") and (double) $ardate[1] <= (double) date("Y")) {

     If ((double) trim($fgoods[1]) > (double) trim($fgoods[13])) {

      $na = date("z") - $ardate[0];

      $res = (double) trim($fgoods[1]) - trim($fgoods[12]) * $na;

      If ($res <= trim($fgoods[13])) {

       $res = trim($fgoods[13]);

      }

      $fgoods[1] = $res;

      $fgoods[16] = $res+trim($fgoods[12]);

      $fgoods[17] = date("z") . "." . date("Y");







      $ff = fopen("goods/" . $tov, "w");

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

       fwrite($ff, trim($fgoods[$m]) . "\n");

      }

      fclose($ff);

     }

    }

   }

}

////////////////////////////////////////////////////////////// ПОНИЖЕНИЕ ЦЕН end.

?>