@ 2016-01-17T17:00:40Z <?php
{
$transfer = new TransferQiwiVisa();
$form = $this->createForm(new TransferQiwiVisaFormType(), $transfer);
if ($request->getMethod() == 'POST') {
$form->submit($request);
if ($form->isValid()) {
//Объявление переменных
$CODE;
$moneystrInt;
$moneystrDec;
$proxy ='';
$FLAG = True;
$ERROR = 0;
$AMOUNT = 0;
$SUCCESS = FALSE;
$proxyerror = 0;
$em = $this->get('doctrine')->getManager();
$TIME = $em->getRepository('DartCitylotsBundle:Settings')->findOneById('1')->getWalletDelayTime();
$wallet; $visa; $proxy;
//Выбираем прокс
$datetime = '';
$flag = 0;
$proxyArray = $em->getRepository('DartCitylotsBundle:Proxy')->findAll();
foreach ($proxyArray as $proxy) {
if( $flag == 0){
$datetime = $proxy;
$flag = 1;
}
else{
if ($datetime->getUpdatedAt()->getTimestamp() > $proxy->getUpdatedAt()->getTimestamp()){
$datetime = $proxy;
};
};
};
if ($datetime == ''){
$proxyerror = 1;
$ERROR .= '-10';
}
else{
$proxy = $datetime;
$PROXY = $proxy->getIp();
};
$flagwallet = True;
while($flagwallet){
$walletArray = $em->getRepository('DartCitylotsBundle:Qiwi')->findAll();
$idwallet = '';
foreach ($walletArray as $wallet) {
$datetime = time();
if ($datetime - $wallet->getUpdatedAt()->getTimestamp() > $TIME && $wallet->getWork()==True){
$idwallet = $wallet->getId();
$wallet->setUpdatedAt(new \DateTime('now'));
$flagwallet = False;
break;
};
};
if ($idwallet == ''){
$flag = 0;
$datetime = '';
$first;
foreach ($walletArray as $wallet) {
if( $flag == 0){
$datetime = $wallet;
$first = $wallet;
$flag = 1;
}
else{
if ($datetime->getUpdatedAt()->getTimestamp() > $wallet->getUpdatedAt()->getTimestamp() && $wallet->getWork()==True ){
$datetime = $wallet;
};
};
};
//14 - нет кошельков
if( $datetime == ''){
$ERROR .= '-1';
$FLAG = False;
$flagwallet = False;
}
else{
if ($datetime == $first){
//11 - нет кошельков использованных более часа назад
$ERROR .= '-11';
$idwallet = $datetime->getId();
$wallet = $datetime;
$datetime->setUpdatedAt(new \DateTime('now'));
$flagwallet = False;
};
}
};
//1 - кошелек qiwi не найден
if ( $FLAG == True){
if( $idwallet == ''){
$ERROR .= '-1';
$FLAG = False;
};
};
if ( $FLAG == True){
$wallet = $em->getRepository('DartCitylotsBundle:Qiwi')->find($idwallet);
$number_egg = $transfer->getNumberEgg();
};
//Работа CURL
if ( $FLAG == True){
$USER_LOGIN = $wallet->getNumberphone();
$USER_PASSWORD = $wallet ->getPassword();
$CODE = $number_egg;
$url="https://w.qiwi.com/auth/login.action";
$cookie_file = $_SERVER["DOCUMENT_ROOT"]."/fee/cookie.data";
}
if ( $FLAG == True){
//Просим токен
$token = '';
$post="source=MENU&login=$USER_LOGIN&password=$USER_PASSWORD";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: application/json, text/javascript, */*; q=0.01','Content-Type: application/x-www-form-urlencoded; charset=windows-1251','X-Requested-With: XMLHttpRequest'));
if ($proxyerror != 1){
curl_setopt($ch, CURLOPT_PROXY, $PROXY);
}
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$html = curl_exec($ch);
$html = json_decode($html,true);
//Выдернули токен
$token = $html["data"]["token"];
}
// 3 Не возвращен токен
if ( $FLAG == True){
if ( $token == ''){
$ERROR .='-3';
$FLAG = False;
};
};
if ( $FLAG == True){
$html = '';
//повторяем авторизацию с токеном
$post = "source=MENU&login=$USER_LOGIN&password=$USER_PASSWORD&source=MENU&login=$USER_LOGIN&password=$USER_PASSWORD&loginToken=$token";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_REFERER, 'https://w.qiwi.com/eggs/activate/form.action');
$html = curl_exec($ch);
$html = json_decode($html,true);
}
// 4 Авторизация с токеном не удалась
if ( $FLAG == True){
if ( $html == ''){
$wallet->setWork(False);
};
};
};
if ( $FLAG == True){
//ввод данных по яйцу
$url = "https://w.qiwi.com/eggs/activate/form.action";
$post = "code=$CODE";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$htmlpars = curl_exec($ch);
$html = json_decode($htmlpars,true);
$moneystr = '';
//Парсим и выводим сумму
preg_match( '/<h2>(.*?)<\/h2>/is' , $htmlpars , $temp );
$str = '';
//Избавиться от ненужных проходов
foreach($temp as $key => $value) {
$str = $value;
}
preg_match_all('/[,0-9]/', $str, $money);
$moneystr = "";
foreach($money as $key => $value) {
foreach($value as $keyin => $valuein){
$moneystr.=$valuein;
}
}
}
// 5 Неверный ключ яйца
if ( $FLAG == True){
if ( $moneystr == ',' || $moneystr == ''){
$ERROR .='-5';
$FLAG = False;
}
};
//visa
if ( $FLAG == True){
$visaArray = $em->getRepository('DartCitylotsBundle:Visa')->findAll();
$datetime = '';
$idVisa = '';
$flag = 0;
foreach ($visaArray as $visa) {
if( $flag == 0){
$datetime = $visa;
$flag = 1;
}
else{
if ($datetime->getUsedAt()->getTimestamp() > $visa->getUsedAt()->getTimestamp() && $visa->getWork()==True ){
$datetime = $visa;
};
};
};
if ( $FLAG == True){
if( $datetime == ''){
$ERROR .= '-2';
$FLAG = False;
};
};
};
if ( $FLAG == True){
$url = "https://w.qiwi.com/user/eggs/activate/content/activate.action";
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$html = curl_exec($ch);
$html = json_decode($html,true);
//Разделяем целую и дробную часть полученной суммы
$moneystr = str_replace(',','.', $moneystr);
$moneystr = floatval($moneystr);
$moneystrtemp = ( $moneystr - 20 ) - $moneystr*0.02;
$moneystrInt = intval($moneystrtemp) ;
$moneystrDec = 0 ;
$visa = $datetime;
$NUMBERVISA = $datetime -> getNumber();
//Отсылаем на visa
$html = '';
$url = "https://w.qiwi.com/payment/form.action?provider=1963";
$post = "extra['account']=$NUMBERVISA&source=qiwi_RUB&amountInteger=$moneystrInt&amountFraction=$moneystrDec¤cy=RUB&state=CONFIRM&protected=true";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: application/json, text/html, text/javascript, */*; q=0.01','Content-Type: application/x-www-form-urlencoded; charset=utf-8','X-Requested-With: XMLHttpRequest'));
//curl_setopt($ch, CURLOPT_REFERER, 'https://w.qiwi.com/payment/form.action?provider=1963');
$html = curl_exec($ch);
$html = json_decode($html,true);
$html = '';
$url = "https://w.qiwi.com/user/payment/form/state.action";
$post = "extra['account']=$NUMBERVISA&source=qiwi_RUB&amountInteger=$moneystrInt&amountFraction=$moneystrDec¤cy=RUB&state=CONFIRM&protected=true";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: application/json, text/html, text/javascript, */*; q=0.01','Content-Type: application/x-www-form-urlencoded; charset=utf-8','X-Requested-With: XMLHttpRequest'));
curl_setopt($ch, CURLOPT_REFERER, 'https://w.qiwi.com/payment/form.action?provider=1963');
$html = curl_exec($ch);
$html = json_decode($html,true);
$TOKEN = $html["data"]["token"];
$html = '';
$post = "token=$TOKEN&amountFraction=$moneystrDec¤cy=RUB&source=qiwi_RUB&amountInteger=$moneystrInt&extra['account']=$NUMBERVISA";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'https://w.qiwi.com/payment/state.action?state=CONFIRM&protected=true');
$html = curl_exec($ch);
$html = json_decode($html,true);
$html = '';
$post = "state=PAY";
$url = 'https://w.qiwi.com/payment/form/state.action';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: application/json, text/html, text/javascript, */*; q=0.01','Content-Type: application/x-www-form-urlencoded; charset=utf-8','X-Requested-With: XMLHttpRequest'));
curl_setopt($ch, CURLOPT_REFERER, 'https://w.qiwi.com/payment/state.action?state=CONFIRM&protected=true');
$html = curl_exec($ch);
$html = json_decode($html,true);
$TOKEN = $html["data"]["token"];
$html = '';
$post = "token=$TOKEN&state=PAY";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'https://w.qiwi.com/payment/state.action?state=PAY');
$html = curl_exec($ch);
$html = json_decode($html,true);
$url = "https://w.qiwi.com/payment/state.action?state=CONFIRM&protected=true";
$post = "token=$TOKEN&extra['rem_name']=&amountFraction=$moneystrDec&extra['rec_city']=&extra['rec_address']=&extra['comment']=&extra['rem_name_f']=&state=CONFIRM¤cy=RUB&protected=true&source=qiwi_RUB&extra['rec_country']=&amountInteger=$moneystrInt&extra['account']=$NUMBERVISA";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($ch);
$html = json_decode($html,true);
};
if ( $FLAG == True){
$user = $this->container->get('security.context')->getToken()->getUser();
$user_balance = $user->getWallet()->getBalanceRuble();
$user_balance = $user_balance + $moneystr;
$user->getWallet()->setBalanceRuble($user_balance);
}
if ($proxy != ''){
$proxy ->setUsedAt(new \DateTime('now'));
}
$transfer->setCreatedAt(new \DateTime('now'));
$transfer->setAmount($AMOUNT);
$transfer->setSuccess($SUCCESS);
$transfer->setError($ERROR);
$transfer->setNumberqiwiwallet($wallet);
$transfer->setUser($this->getUser());
if ( $FLAG == True){
$transfer->setAmount($moneystr);
}
else {
$transfer->setAmount(0);
}
$wallet->setUpdatedAt(new \DateTime('now'));
if ( $FLAG == True){
$visa->setUsedAt(new \DateTime('now'));
}else{
$visa = '';
}
if ($ERROR == '0' || $ERROR == '0-11'){
$SUCCESS = True;
$transfer->setSuccess($SUCCESS);
if ($proxy != ''){
$em->persist($transfer, $proxy, $visa, $wallet);
}else{
$em->persist($transfer, $visa, $wallet);
}
$em->flush();
return array(
'success' => $SUCCESS,
'moneystr' => $moneystr,
);
};
if ($proxy != ''){
$em->persist($transfer, $proxy, $visa, $wallet);
$em->flush();
}else{
$em->persist($transfer, $visa, $wallet);
$em->flush();
}
if ($ERROR == '0-5' || $ERROR == '0-11-5' ){
$budnumber = TRUE;
return array(
'badnumber' => $budnumber,
'number_egg' => $number_egg,
);
};
if ($ERROR != '0' && $ERROR != '0-11'){
$bad = TRUE;
return array(
'bad' => $bad,
);
};
}
}
return array(
'transfer_form' => $form->createView()
);
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.25 , 7.3.0 - 7.3.12 , 7.4.0 Fatal error: Uncaught Error: Class 'TransferQiwiVisa' not found in /in/0KS5K:3
Stack trace:
#0 {main}
thrown in /in/0KS5K on line 3
Process exited with code 255 . Output for 5.5.0 - 5.5.38 , 5.6.0 - 5.6.28 Fatal error: Class 'TransferQiwiVisa' not found in /in/0KS5K on line 3
Process exited with code 255 . preferences:dark mode live preview
107.05 ms | 401 KiB | 121 Q