@ 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.
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.4.0 0.013 0.007 15.30 7.3.12 0.008 0.008 15.19 7.3.11 0.007 0.011 15.06 7.3.10 0.007 0.003 14.82 7.3.9 0.010 0.007 15.06 7.3.8 0.009 0.006 14.80 7.3.7 0.003 0.013 14.89 7.3.6 0.007 0.011 14.96 7.3.5 0.007 0.010 15.09 7.3.4 0.006 0.006 15.15 7.3.3 0.003 0.009 15.10 7.3.2 0.010 0.003 16.50 7.3.1 0.000 0.011 16.61 7.3.0 0.004 0.007 16.58 7.2.25 0.006 0.012 15.30 7.2.24 0.007 0.013 15.16 7.2.23 0.006 0.009 15.20 7.2.22 0.000 0.019 15.24 7.2.21 0.003 0.010 14.90 7.2.20 0.003 0.008 15.04 7.2.19 0.007 0.007 15.12 7.2.18 0.007 0.007 14.97 7.2.17 0.006 0.006 14.95 7.2.6 0.009 0.006 16.74 7.2.0 0.006 0.012 19.41 7.1.33 0.003 0.011 15.57 7.1.32 0.003 0.007 15.76 7.1.31 0.006 0.009 15.75 7.1.30 0.007 0.010 15.64 7.1.29 0.004 0.007 15.81 7.1.28 0.009 0.003 15.69 7.1.27 0.009 0.004 15.44 7.1.26 0.003 0.010 15.53 7.1.20 0.003 0.012 15.65 7.1.10 0.009 0.006 17.73 7.1.7 0.007 0.000 16.91 7.1.6 0.007 0.017 19.40 7.1.5 0.007 0.013 16.78 7.1.0 0.000 0.080 22.54 7.0.20 0.004 0.007 16.84 7.0.10 0.000 0.057 20.16 7.0.9 0.003 0.050 20.10 7.0.8 0.007 0.067 20.24 7.0.7 0.000 0.053 20.05 7.0.6 0.017 0.073 20.14 7.0.5 0.013 0.050 20.48 7.0.4 0.007 0.080 20.04 7.0.3 0.000 0.047 20.09 7.0.2 0.013 0.050 20.19 7.0.1 0.007 0.073 20.09 7.0.0 0.010 0.073 20.10 5.6.28 0.000 0.073 21.26 5.6.25 0.010 0.077 20.79 5.6.24 0.003 0.063 20.87 5.6.23 0.017 0.077 20.81 5.6.22 0.010 0.063 20.86 5.6.21 0.020 0.060 20.77 5.6.20 0.013 0.070 21.36 5.6.19 0.013 0.077 21.25 5.6.18 0.017 0.073 21.13 5.6.17 0.003 0.043 21.22 5.6.16 0.007 0.087 21.21 5.6.15 0.003 0.087 21.18 5.6.14 0.000 0.063 21.27 5.6.13 0.017 0.077 21.23 5.6.12 0.007 0.077 21.14 5.6.11 0.007 0.047 21.22 5.6.10 0.003 0.063 21.21 5.6.9 0.010 0.060 21.25 5.6.8 0.010 0.043 20.74 5.6.7 0.007 0.083 20.73 5.6.6 0.007 0.080 20.59 5.6.5 0.013 0.057 20.61 5.6.4 0.010 0.060 20.55 5.6.3 0.013 0.083 20.50 5.6.2 0.000 0.053 20.64 5.6.1 0.007 0.043 20.60 5.6.0 0.007 0.067 20.60 5.5.38 0.010 0.073 20.55 5.5.37 0.017 0.043 20.70 5.5.36 0.010 0.083 20.63 5.5.35 0.010 0.077 20.57 5.5.34 0.007 0.073 21.11 5.5.33 0.003 0.050 20.83 5.5.32 0.010 0.070 21.11 5.5.31 0.003 0.090 20.98 5.5.30 0.000 0.077 21.07 5.5.29 0.003 0.060 20.99 5.5.28 0.000 0.053 20.91 5.5.27 0.007 0.047 21.07 5.5.26 0.003 0.043 21.04 5.5.25 0.007 0.047 20.88 5.5.24 0.013 0.070 20.31 5.5.23 0.013 0.077 20.45 5.5.22 0.007 0.070 20.48 5.5.21 0.010 0.067 20.44 5.5.20 0.003 0.047 20.45 5.5.19 0.010 0.077 20.30 5.5.18 0.010 0.087 20.30 5.5.16 0.003 0.067 20.42 5.5.15 0.010 0.040 20.32 5.5.14 0.010 0.047 20.33 5.5.13 0.003 0.050 20.34 5.5.12 0.013 0.040 20.42 5.5.11 0.003 0.040 20.28 5.5.10 0.003 0.040 20.27 5.5.9 0.013 0.037 20.32 5.5.8 0.007 0.040 20.25 5.5.7 0.000 0.043 20.39 5.5.6 0.007 0.043 20.29 5.5.5 0.007 0.037 20.25 5.5.4 0.010 0.067 20.24 5.5.3 0.010 0.037 20.25 5.5.2 0.003 0.040 20.23 5.5.1 0.007 0.037 20.31 5.5.0 0.003 0.047 20.14
preferences:dark mode live preview
38.35 ms | 401 KiB | 5 Q