@ 2015-11-09T21:50:37Z <?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, '' );
}
}
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) 5.6.15 0.003 0.067 18.15 5.6.14 0.017 0.067 18.24 5.6.13 0.007 0.057 18.29 5.6.12 0.000 0.047 20.99 5.6.11 0.017 0.073 21.05 5.6.10 0.003 0.070 21.02 5.6.9 0.013 0.070 21.02 5.6.8 0.017 0.070 20.39 5.5.30 0.007 0.037 17.95 5.5.29 0.003 0.050 18.01 5.5.28 0.003 0.040 20.86 5.5.27 0.007 0.080 20.81 5.5.26 0.017 0.050 20.89 5.5.25 0.007 0.077 20.72 5.5.24 0.023 0.070 20.18
preferences:dark mode live preview
140.77 ms | 1394 KiB | 7 Q