@ 2015-11-09T22:16:46Z <?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.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.2.6 0.007 0.010 16.74 7.2.0 0.004 0.008 19.25 7.1.20 0.007 0.010 15.59 7.1.10 0.006 0.006 17.74 7.1.7 0.007 0.007 17.05 7.1.6 0.018 0.007 19.48 7.1.5 0.004 0.008 16.66 7.1.0 0.010 0.067 22.57 7.0.20 0.039 0.003 14.91 7.0.10 0.030 0.087 20.20 7.0.9 0.043 0.090 20.19 7.0.8 0.043 0.077 20.19 7.0.7 0.050 0.077 20.18 7.0.6 0.040 0.080 20.11 7.0.5 0.053 0.077 20.58 7.0.4 0.010 0.083 20.13 7.0.3 0.010 0.070 20.08 7.0.2 0.013 0.080 19.92 7.0.1 0.017 0.070 20.05 7.0.0 0.000 0.073 20.07 5.6.28 0.007 0.067 21.34 5.6.25 0.010 0.037 21.00 5.6.24 0.023 0.067 20.70 5.6.23 0.010 0.077 20.86 5.6.22 0.013 0.060 20.76 5.6.21 0.010 0.080 20.75 5.6.20 0.007 0.043 21.27 5.6.19 0.010 0.077 21.21 5.6.18 0.007 0.063 21.14 5.6.17 0.017 0.083 21.21 5.6.16 0.003 0.080 21.23 5.6.15 0.010 0.087 21.22 5.6.14 0.023 0.063 21.20 5.6.13 0.000 0.057 21.26 5.6.12 0.003 0.087 21.21 5.6.11 0.007 0.087 21.24 5.6.10 0.007 0.090 21.18 5.6.9 0.010 0.083 21.20 5.6.8 0.013 0.067 20.64 5.6.7 0.007 0.057 20.61 5.6.6 0.000 0.087 20.63 5.6.5 0.013 0.067 20.59 5.6.4 0.007 0.063 20.55 5.6.3 0.000 0.073 20.48 5.6.2 0.007 0.070 20.59 5.6.1 0.007 0.040 20.62 5.6.0 0.000 0.080 20.61 5.5.38 0.007 0.063 20.61 5.5.37 0.003 0.077 20.55 5.5.36 0.013 0.037 20.60 5.5.35 0.007 0.087 20.63 5.5.34 0.023 0.073 20.93 5.5.33 0.010 0.077 21.12 5.5.32 0.010 0.080 21.11 5.5.31 0.013 0.077 20.94 5.5.30 0.007 0.060 21.03 5.5.29 0.013 0.073 20.96 5.5.28 0.007 0.057 20.96 5.5.27 0.007 0.077 21.04 5.5.26 0.007 0.087 21.10 5.5.25 0.007 0.080 20.83 5.5.24 0.013 0.073 20.39 5.5.23 0.013 0.063 20.36 5.5.22 0.010 0.073 20.32 5.5.21 0.017 0.043 20.34 5.5.20 0.007 0.067 20.32 5.5.19 0.007 0.083 20.34 5.5.18 0.010 0.080 20.43 5.5.16 0.007 0.077 20.44 5.5.15 0.013 0.070 20.30 5.5.14 0.013 0.073 20.38 5.5.13 0.010 0.070 20.34 5.5.12 0.017 0.057 20.40 5.5.11 0.000 0.083 20.42 5.5.10 0.000 0.087 20.35 5.5.9 0.010 0.073 20.30 5.5.8 0.003 0.057 20.17 5.5.7 0.013 0.067 20.16 5.5.6 0.007 0.047 20.23 5.5.5 0.003 0.040 20.28 5.5.4 0.007 0.080 20.14 5.5.3 0.003 0.087 20.34 5.5.2 0.013 0.073 20.33 5.5.1 0.000 0.053 20.24 5.5.0 0.003 0.087 20.28
preferences:dark mode live preview
35.59 ms | 401 KiB | 5 Q