3v4l.org

run code in 300+ PHP versions simultaneously
<?php # Инициализация переменных : $aResult = array(); # результирующий массив # Загрузка страницы : $sResponse = $this->curl( 'user/eggs/activate/content/form.action', array( 'code' => $sCode ) ); # Преобразование ответа в массив : $aResponse = json_decode( $sResponse, true ); # Загрузка страницы : $sResponse = $this->curl( 'user/eggs/activate/content/form.action', array( 'code' => $sCode, 'token' => $aResponse['data']['token'] ) ); # Если зачисления не произошло : if( mb_substr_count( $sResponse, $sCode ) != 2 ) { if( count( $aExplode = explode( '<p>', $sResponse ) ) < 3 ) throw new Exception( 'undefined error' ); $aExplode = explode( '</', $aExplode[2] ); throw new Exception( trim( strip_tags( $aExplode[0] ) ) ); } # Парсинг суммы : if( count( $aExplode = explode( 'на сумму', $sResponse ) ) < 2 ) throw new Exception( 'error parse amount' ); $aExplode = explode( 'руб', $aExplode[1] ); $aResult['dAmount'] = preg_replace( '/[^0-9\.]+/', '', str_replace( ',', '.', trim( $aExplode[0] ) ) ) - 0; # Парсинг примечания : if( count( $aExplode = explode( 'Комментарий к переводу', $sResponse ) ) < 2 ) throw new Exception( 'error parse comment' ); $aExplode = explode( '</p>', $aExplode[1] ); $aResult['sComment'] = trim( strip_tags( $aExplode[0] ) ); # Подтверждение : $aResponse = json_decode( $this->curl( 'user/eggs/activate/content/activate.action', array( 'code' => $sCode ) ), true ); # Проверка подтверждения : if( !isset( $aResponse['code'] ) || !isset( $aResponse['code']['value'] ) || !isset( $aResponse['code']['_name'] ) || $aResponse['code']['value'] != '0' || $aResponse['code']['_name'] != 'NORMAL' ) throw new Exception( 'bad server answer: '.var_export( $aResponse, true ) ); return $aResult; } # Метод : запрос на смену пароля. # Возвращает : идентификатор запроса. public function requestChangePassword() { # Загружаем страницу : $this->curl( 'options/password.action' ); # Загружаем страницу : $aResponse = json_decode( $this->curl( 'user/person/change/password.action' ), true ); # Инициализация переменных : $iIdentifier = isset( $aResponse['identifier'] ) ? $aResponse['identifier'] - 0 : 0; # Если поле <= 0 : if( $iIdentifier <= 0 ) throw new Exception( 'field identifier not found' ); # Загружаем страницу : $this->curl( 'user/confirmation/form.action', array( 'identifier' => $iIdentifier, 'type' => 'PASSWORD_CHANGE' ) ); return $iIdentifier; } # Метод : подтверждение смены пароля. # Принимает : идентификатор запроса, старый пароль, новый пароль, код с sms. public function progressChangePassword( $iIdentifier, $sOldPassword, $sNewPassword, $iCode ) { # Загружаем страницу : $aResponse = json_decode( $this->curl( 'user/confirmation/confirm.action', array( 'code' => $iCode, "data['newPassword']" => $sNewPassword, "data['oldPassword']" => $sOldPassword, "data['period']" => 4, 'identifier' => $iIdentifier, 'type' => 'PASSWORD_CHANGE' ) ), true ); # Проверка на наличие ошибок : if( !isset( $aResponse['code'] ) || !isset( $aResponse['code']['value'] ) || $aResponse['code']['value'] != 0 ) throw new Exception( isset( $aResponse['message'] ) ? $aResponse['message'] : json_encode( $aResponse ) ); } # Метод : запрос на отключение SMS подтверждения операций. # Принимает : требуется отключить? # Возвращает : идентификатор подтверждения. public function requestConfirmPayments( $bOff = true ) { # Загрузка страницы : $this->curl( 'settings/options/security.action' ); # Загрузка страницы : $aResponse = json_decode( $this->curl( 'user/person/change/security.action', array( 'type' => 'SMS_CONFIRMATION', 'value' => $bOff ? 'false' : 'true' ) ), true ); # Проверка ответа : if( !isset( $aResponse['code'] ) || !isset( $aResponse['code']['value'] ) || $aResponse['code']['value'] != 7 || !isset( $aResponse['data'] ) || !isset( $aResponse['data']['token'] ) ) throw new Exception( json_encode( $aResponse ) ); # Инициализация переменных : $sToken = $aResponse['data']['token']; # Загрузка страницы : $aResponse = json_decode( $this->curl( 'user/person/change/security.action', array( 'token' => $sToken, 'type' => 'SMS_CONFIRMATION', 'value' => $bOff ? 'false' : 'true' ) ), true ); # Проверка ответа : if( isset( $aResponse['code'] ) && isset( $aResponse['code']['value'] ) && $aResponse['code']['value'] == 0 ) return true; # Проверка ответа : if( !isset( $aResponse['code'] ) || !isset( $aResponse['code']['value'] ) || $aResponse['code']['value'] != 4 || !isset( $aResponse['identifier'] ) || $aResponse['identifier'] <= 0 ) throw new Exception( json_encode( $aResponse ) ); # Инициализация переменных : $iIdentifier = $aResponse['identifier']; # Загрузка страницы : $this->curl( 'user/confirmation/form.action', array( 'identifier' => $iIdentifier, 'token' => $sToken, 'type' => 'SMS_CONFIRMATION', 'value' => $bOff ? 'false' : 'true' ) ); return $iIdentifier; } # Метод : подтверждение отключения SMS подтверждения операций. # Принимает : идентификатор запроса, код с sms. public function progressConfirmPayments( $iIdentifier, $iCode ) { # Загрузка страницы : $aResponse = json_decode( $this->curl( 'user/confirmation/confirm.action', array( 'code' => $iCode, 'identifier' => $iIdentifier, 'type' => 'SMS_CONFIRMATION' ) ), true ); # Проверка на наличие ошибок : if( !isset( $aResponse['code'] ) || !isset( $aResponse['code']['value'] ) || $aResponse['code']['value'] != 0 ) throw new Exception( isset( $aResponse['message'] ) ? $aResponse['message'] : json_encode( $aResponse ) ); } # Метод : SMS подтверждение операции. public function paymentSMSConfirm( $iCode ) { # Загрузка страницы : $aResponse = json_decode( $this->curl( 'user/payment/form/state.action', array( 'confirmationCode' => $iCode, 'protected' => 'true', 'state' => 'PAY' ) ), true ); # Загрузка страницы : $sResponse = $this->curl( 'user/payment/form/state.action', array( 'confirmationCode' => $iCode, 'protected' => 'true', 'state' => 'PAY', 'token' => $aResponse['data']['token'] ) ); # Если платеж был не успешен : if( mb_strpos( $sResponse, 'transaction":"' ) === false ) { if( mb_strpos( $sResponse, 'class="errorElement"' ) !== false ) { $aExplode = explode( 'class="errorElement">', $sResponse ); $aExplode = explode( '</', $aExplode[1] ); throw new Exception( trim( $aExplode[0] ) ); } if( count( $sMessage = explode( '<p>', $sResponse ) ) < 2 ) throw new Exception( 'unknown error' ); $sMessage = explode( '</p>', $sMessage[1] ); throw new Exception( $sMessage[0] ); } # Если это яйцо : if( count( $aExplode = explode( 'Код ваучера:', $sResponse ) ) > 1 ) { $aExplode = explode( '<', $aExplode[1] ); return trim( $aExplode[0] ); } # Парсинг № транзакции : $aExplode = explode( 'transaction":"', $sResponse ); $aExplode = explode( '"', $aExplode[1] ); return $aExplode[0]; } # Метод : очистка cookie. public function clearCookie() { # Очистка содержимого файла : file_put_contents( $this->sCookieFile, '' ); } }
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.15
Parse error: syntax error, unexpected '}' in /in/rSfNr on line 44
Process exited with code 255.

preferences:
176.15 ms | 1395 KiB | 22 Q