function actionModify() { $id = (int) $this->_context->get('id'); $rs = Account::find('user_id = ?', $id)->getOne(); if (!$rs->id()) { return $this->msg($tip = '参数错误', url('manage::account')); } $form = Form_Common::createForm('', 'manage/profile'); if ($this->_context->isPOST() && $form->validate($_POST)) { $post = $form->values(); $user_mail = $post['user_mail']; $user_pass = $post['user_pass']; $is_locked = $post['is_locked'] ? '1' : '0'; #dump($post); if ($user_pass) { $user_pass = sha1(md5('sike' . $post['user_pass'] . Q::ini('appini/secret_key'))); $rs->user_pass; } $rs->user_mail = $user_mail; $rs->is_locked = $is_locked; $rs->save(); return $this->msg($tip = '修改成功', url('manage::account/modify', array('id' => $id))); } $form->import($rs->toArray()); $form->element('user_pass')->value = ''; $form->element('is_locked')->checked = $rs->is_locked; #dump($form->element('is_locked')); $this->_view['form'] = $form; $this->_view['rs'] = $rs; $order = Order::find('user_id = ?', $id)->order('created DESC')->getAll(); $this->_view['order'] = $order; $this->_view['_UDI'] = 'manage::account/index'; }
function login() { $this->admin_security->check_no_admin_login(); // Process the inputs if form is posted if ($_POST) { // To avoid mysql injection $this->admin_security->avoid_mysql_injection(); // Setting validation rules $this->form_validation->set_rules($this->admin_rules->login()); $this->form_validation->set_error_delimiters('<div class="er">', '</div>'); //provide div to show message // Continue authentication if form is valid if ($this->form_validation->run() == FALSE) { $this->data['error'] = 1; } else { // make sessions and redirect to home page if admin is authenticated if ($admin_id = $this->admin_security->authenticate_admin($_POST['username'], md5($_POST['password']))) { // Set session data $this->session->set_userdata('admin_id', $admin_id); redirect(base_url() . 'admin/dashboard'); } else { // Assign error message $this->data['err_msg_invalid'] = 'Invalid username or password.'; } } } // Load login page $this->load->view('admin/login', $this->data); }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $m = $this->getConfig('methods'); if (@count($m) == 1) { $a = new Am_Paysystem_Action_Form(self::URL . $m[0] . '/event/'); } else { $a = new Am_Paysystem_Action_HtmlTemplate_Micropayment($this->getDir(), 'micropayment-confirm.phtml'); $methods = array(); if (@count($m)) { $a->url = self::URL . $m[0] . '/event/'; foreach ($m as $title) { $methods[self::URL . $title . '/event/'] = $this->getConfig($title . '.title'); } } else { foreach ($this->getConfig() as $k => $v) { if (is_array($v) && !empty($v['title'])) { $methods[self::URL . $k . '/event/'] = $v['title']; } } $a->url = array_shift(array_keys($methods)); } $a->methods = $methods; } $a->project = $this->getConfig('project'); $a->amount = $invoice->first_total * 100; $a->freepaymentid = $invoice->public_id; $a->seal = md5("project={$a->project}&amount={$a->amount}&freepaymentid={$a->freepaymentid}" . $this->getConfig('key')); $result->setAction($a); }
/** * * @ORM\PrePersist */ public function generateSecurekey() { $generator = new SecureRandom(); $random = $generator->nextBytes(150); $securekey = md5($random . time()); $this->setSecurekey($securekey); }
function wpcom_static_url($file) { $i = hexdec(substr(md5($file), -1)) % 2; $http = is_ssl() ? 'https' : 'http'; $url = $http . '://s' . $i . '.wp.com' . $file; return $url; }
public function getkey($actionUrl = null, $mktime = null) { $actionUrl = $this->_getActionUrl($actionUrl); if ($mktime == null) { $lifetime = Centurion_Config_Manager::get('ticket.lifetime'); list($lifetimeValue, $lifetimeUnit) = sscanf($lifetime, '%d%s'); $mktime = new Zend_Date(); switch ($lifetimeUnit) { case 'j': case 'd': $mktime->setHour(0); case 'h': $mktime->setMinute(0); case 'm': default: $mktime->setSecond(0); } } if ($mktime instanceof Zend_Date) { $date = $mktime->toString('YYYYMMdd-HH:mm'); } else { $date = date('Ymd-H:i', $mktime); } $salt = Centurion_Config_Manager::get('ticket.salt'); $ticket = md5($salt . $actionUrl . $date); return $ticket; }
function get_token_from_guids($guids) { $guids = array_unique($guids); sort($guids); $string = implode(',', $guids); return md5($string); }
function verifyTiezi_send($uid, $tid, $pid, $water = 'StusGame Tieba Cloud Sign Plugin "verifyTiezi"', $device = 4) { if (empty($uid) || empty($tid) || empty($pid)) { return array('status' => '1', 'msg' => ''); } $ck = misc::GetCookie($pid); $xs = verifyTiezi_gettie($tid, $ck); $x = array('BDUSS' => $ck, '_client_id' => 'wappc_136' . rand_int(10) . '_' . rand_int(3), '_client_type' => $device, '_client_version' => '5.0.0', '_phone_imei' => md5(rand_int(16)), 'anonymous' => '0', 'content' => $water, 'fid' => $xs['fid'], 'kw' => $xs['word'], 'net_type' => '3', 'tbs' => $xs['tbs'], 'tid' => $tid, 'title' => ''); $y = ''; foreach ($x as $key => $value) { $y .= $key . '=' . $value; } $x['sign'] = strtoupper(md5($y . 'tiebaclient!!!')); $c = new wcurl('http://c.tieba.baidu.com/c/c/post/add', array('Content-Type: application/x-www-form-urlencoded')); /* //Note:普通的 $x = verifyTiezi_gettie($tid,$ck); $c = new wcurl('http://tieba.baidu.com'.$x['__formurl']); unset($x['__formurl']); $x['co'] = $water; */ $c->addcookie('BDUSS=' . $ck); $return = json_decode($c->post($x), true); $c->close(); if (!empty($return['error_code']) && $return['error_code'] != '1') { return array('status' => $return['error_code'], 'msg' => $return['error_msg']); } else { return array('status' => '1', 'msg' => ''); } }
/** * Initialize session. * @param boolean $keepopen keep session open? The default is * to close the session after $_SESSION has been populated. * @uses $_SESSION */ function session_init($keepopen = false) { $settings = new phpVBoxConfigClass(); // Sessions provided by auth module? if (@$settings->auth->capabilities['sessionStart']) { call_user_func(array($settings->auth, $settings->auth->capabilities['sessionStart']), $keepopen); return; } // No session support? No login... if (@$settings->noAuth || !function_exists('session_start')) { global $_SESSION; $_SESSION['valid'] = true; $_SESSION['authCheckHeartbeat'] = time(); $_SESSION['admin'] = true; return; } // start session session_start(); // Session is auto-started by PHP? if (!ini_get('session.auto_start')) { ini_set('session.use_trans_sid', 0); ini_set('session.use_only_cookies', 1); // Session path if (isset($settings->sessionSavePath)) { session_save_path($settings->sessionSavePath); } session_name(isset($settings->session_name) ? $settings->session_name : md5('phpvbx' . $_SERVER['DOCUMENT_ROOT'] . $_SERVER['HTTP_USER_AGENT'])); session_start(); } if (!$keepopen) { session_write_close(); } }
/** * Encrypts password with salt and entered password * Stucture => saltedHash:salt * @param $pass * @return string * */ function encrypt($pass) { $password = $pass; $salt = 'LSAS213saddEASDRAs2135SDA'; $password = md5($salt . $password) . ":" . $salt; return $password; }
public static function generatePassword($request, $seed) { $context = $request['context']; $username = $request['username']; $pass = convBase(md5($context . $username . $seed), '0123456789abcdef', "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNIOPQRSTUVWXYZ()-_!\$%&=@#"); return $pass; }
function getSQLValue() { if (is_array($this->property_info['value'])) { return md5($this->property_info['value']['original']); } return md5($this->property_info['value']); }
/** * @package iCMS * @copyright 2007-2010, iDreamSoft * @license http://www.idreamsoft.com iDreamSoft * @author coolmoo <*****@*****.**> */ function iCMS_link($vars) { $limit = isset($vars['row']) ? (int) $vars['row'] : "100"; $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1; switch ($vars['type']) { case "text": $sql[] = " `logo`='' "; break; case "logo": $sql[] = " `logo`!='' "; break; } isset($vars['cid']) && ($sql[] = " cid='" . $vars['cid'] . "'"); $sql && ($where = 'WHERE ' . implode(' AND ', $sql)); $iscache = true; if ($vars['cache'] == false || isset($vars['page'])) { $iscache = false; $rs = ''; } else { $cacheName = 'links/' . md5($sql); $rs = iCache::get($cacheName); } if (empty($rs)) { $rs = iDB::all("SELECT * FROM `#iCMS@__links`{$where} ORDER BY ordernum ASC,id ASC LIMIT 0 , {$limit}"); $iscache && iCache::set($cacheName, $rs, $cache_time); } return $rs; }
public static function is_auth($cookie) { $request = APF::get_instance()->get_request(); if ($cookie) { $is_flash = @$request->get_parameter("is_flash"); if ($is_flash) { $browser = $request->get_parameter("user_agent"); } else { $browser = $_SERVER['HTTP_USER_AGENT']; } $iBugsecques = APF::get_instance()->get_config('iBugSecques'); $cookieStr = Util_AuthorCrypt::decrypt($cookie, md5($browser . $iBugsecques)); if (empty($cookieStr)) { return false; } $cookieArr = explode("\t", $cookieStr); @(list($user_id, $username, $cookietime) = $cookieArr); if (empty($user_id) || empty($username)) { return false; } $request->set_user_id($user_id); $request->set_username($username); return true; } else { return false; } }
public function addUser($add = array()) { if (empty($add['staff_name']) and empty($add['username']) and empty($add['password'])) { return TRUE; } $this->db->where('staff_email', strtolower($add['site_email'])); $this->db->delete('staffs'); $this->db->set('staff_email', strtolower($add['site_email'])); $this->db->set('staff_name', $add['staff_name']); $this->db->set('staff_group_id', '11'); $this->db->set('staff_location_id', '0'); $this->db->set('language_id', '11'); $this->db->set('timezone', '0'); $this->db->set('staff_status', '1'); $this->db->set('date_added', mdate('%Y-%m-%d', time())); $query = $this->db->insert('staffs'); if ($this->db->affected_rows() > 0 and $query === TRUE) { $staff_id = $this->db->insert_id(); $this->db->where('username', $add['username']); $this->db->delete('users'); $this->db->set('username', $add['username']); $this->db->set('staff_id', $staff_id); $this->db->set('salt', $salt = substr(md5(uniqid(rand(), TRUE)), 0, 9)); $this->db->set('password', sha1($salt . sha1($salt . sha1($add['password'])))); $query = $this->db->insert('users'); } return $query; }
public function testRegularUser() { $originalUser = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'); $user = new UserWrapped($originalUser, $this->apiUser); $this->assertTrue($user->isEnabled()); $this->assertTrue($user->isAccountNonExpired()); $this->assertTrue($user->isAccountNonLocked()); $this->assertTrue($user->isCredentialsNonExpired()); $this->assertTrue($user->isEqualTo($this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'))); $originalUser->expects($this->once())->method('eraseCredentials'); $user->eraseCredentials(); $username = '******'; $password = '******'; $roles = array('ROLE_USER', 'ROLE_TEST'); $salt = md5(microtime(true)); $originalUser->expects($this->exactly(2))->method('getUsername')->will($this->returnValue($username)); $originalUser->expects($this->once())->method('getPassword')->will($this->returnValue($password)); $originalUser->expects($this->once())->method('getRoles')->will($this->returnValue($roles)); $originalUser->expects($this->once())->method('getSalt')->will($this->returnValue($salt)); $this->assertSame($username, $user->getUsername()); $this->assertSame($username, (string) $user); $this->assertSame($password, $user->getPassword()); $this->assertSame($roles, $user->getRoles()); $this->assertSame($salt, $user->getSalt()); $this->assertSame($originalUser, $user->getWrappedUser()); }
function onadd() { $this->load('misc'); $appid = intval($this->input('appid')); $icon = $this->input('icon'); $uid = intval($this->input('uid')); $username = $this->input('username'); $body_data = $_ENV['misc']->array2string($this->input('body_data')); $title_data = $_ENV['misc']->array2string($this->input('title_data')); $title_template = $this->_parsetemplate($this->input('title_template')); $body_template = $this->_parsetemplate($this->input('body_template')); $body_general = $this->input('body_general'); $target_ids = $this->input('target_ids'); $image_1 = $this->input('image_1'); $image_1_link = $this->input('image_1_link'); $image_2 = $this->input('image_2'); $image_2_link = $this->input('image_2_link'); $image_3 = $this->input('image_3'); $image_3_link = $this->input('image_3_link'); $image_4 = $this->input('image_4'); $image_4_link = $this->input('image_4_link'); $hash_template = md5($title_template . $body_template); $hash_data = md5($title_template . $title_data . $body_template . $body_data); $dateline = $this->time; $this->db->query("INSERT INTO " . UC_DBTABLEPRE . "feeds SET appid='{$appid}', icon='{$icon}', uid='{$uid}', username='******',\r\n\t\t\ttitle_template='{$title_template}', title_data='{$title_data}', body_template='{$body_template}', body_data='{$body_data}', body_general='{$body_general}',\r\n\t\t\timage_1='{$image_1}', image_1_link='{$image_1_link}', image_2='{$image_2}', image_2_link='{$image_2_link}',\r\n\t\t\timage_3='{$image_3}', image_3_link='{$image_3_link}', image_4='{$image_4}', image_4_link='{$image_4_link}',\r\n\t\t\thash_template='{$hash_template}', hash_data='{$hash_data}', target_ids='{$target_ids}', dateline='{$dateline}'"); return $this->db->insert_id(); }
public function actionToken($state) { // only poeple on the list should be generating new tokens if (!$this->context->token->checkAccess($_SERVER['REMOTE_ADDR'])) { echo "Oh sorry man, this is a private party!"; mail($this->context->token->getEmail(), 'Notice', 'The token is maybe invalid!'); $this->terminate(); } // facebook example code... $stoken = $this->session->getSection('token'); if (!isset($_GET['code'])) { $stoken->state = md5(uniqid(rand(), TRUE)); //CSRF protection $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" . $this->context->token->getAppId() . "&redirect_uri=" . urlencode($this->link('//Crawler:token')) . "&scope=" . $this->context->token->getAppPermissions() . "&state=" . $stoken->state; echo "<script> top.location.href='" . $dialog_url . "'</script>"; $this->terminate(); } if (isset($stoken->state) && $stoken->state === $_GET['state']) { $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $this->context->token->getAppId() . "&redirect_uri=" . urlencode($this->link('//Crawler:token')) . "&client_secret=" . $this->context->token->getAppSecret() . "&code=" . $_GET['code']; $response = file_get_contents($token_url); $params = null; parse_str($response, $params); $date = new DateTime(); $date->add(new DateInterval('PT' . $params["expires"] . 'S')); $this->context->token->saveToken($params['access_token'], $date); echo "Thanks for your token :)"; } else { echo "The state does not match. You may be a victim of CSRF."; } $this->terminate(); }
protected function _authenticateValidateResult($resultIdentity) { $hash = new Application_Plugin_Phpass(); $check = false; // auto-login if ($this->_credentialTreatment == 'autologin') { $check = true; } // again, try with md5 if (is_string($this->_credential) && md5($this->_credential) == $resultIdentity['password']) { $check = true; } // Check that hash value is correct if (is_string($this->_credential) && $hash->CheckPassword($this->_credential, $resultIdentity['password'])) { $check = true; } if (!$check) { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID; $this->_authenticateResultInfo['messages'][] = 'Supplied credential is invalid.'; return $this->_authenticateCreateAuthResult(); } $this->_resultRow = $resultIdentity; $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS; $this->_authenticateResultInfo['messages'][] = 'Authentication successful.'; return $this->_authenticateCreateAuthResult(); }
function callback($in, &$paymentId, &$money, &$message) { $digest = trim(md5($in['OrderMessage'])); $info = explode('|', $in['OrderMessage']); $paymentId = $info[1]; $money = $info[2]; if ($in['Digest'] == $digest) { switch ($info[22]) { case 0: $message = '未支付'; return PAY_CANCEL; break; case 2: return PAY_SUCCESS; break; case 3: $message = '交易失败'; return PAY_FAILED; break; default: $message = '交易出现错误'; return PAY_ERROR; break; } } else { $message = '交易出现错误'; return PAY_ERROR; } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $mcid * @return \Illuminate\Http\Response */ public function update(Request $request, $mcid_id) { $this->validate($request, ['file' => 'required']); $mcid = MCID::findOrFail($mcid_id); $file = $_FILES['file']; $fileName = md5($mcid_id . $file['name'] . time()); $path = str_finish($this->skin_path, '/') . $fileName; $content = File::get($file['tmp_name']); if (is_image($file['type']) && $file['size'] <= 150 * 1000) { list($img_w, $img_h) = getimagesize($file['tmp_name']); if ($img_w > 64 || $img_h > 64) { $error = "皮肤文件 '{$fileName}' 尺寸不正确."; } else { $result = $this->manager->saveFile($path, $content); if ($result === true) { $skin = Skin::where('mcid_id', $mcid->id)->first(); if ($skin == null) { $skin = new Skin(); } $skin->mcid_id = $mcid->id; $skin->url = $path; $skin->save(); return redirect()->back()->withSuccess("皮肤文件 '{$fileName}' 上传成功."); } else { $error = $result ?: "皮肤文件 '{$fileName}' 上传失败."; } } } else { $error = "皮肤文件 '{$fileName}' 格式或大小不正确."; } return redirect()->back()->withErrors([$error]); }
function chapchallengeresponse($challenge, $password) { // Generates a response for a challenge response CHAP Auth $hexChallenge = pack("H32", $challenge); $response = md5("" . $password . $hexChallenge); return $response; }
public function index() { if (isset($_POST['name'])) { if ($this->_session('verify') != md5($this->_post('proving'))) { $this->error('验证码错误!'); exit; } $User = D("Admin"); // 实例化User对象 $condition['name'] = $this->_post('name'); $condition['password'] = $User->adminMd5($this->_post('passw')); $list = $User->where($condition)->find(); if ($list) { session('admin_name', $list['username']); //设置session session('admin_uid', $list['id']); session('verify', null); //删除验证码 //session(null); //清空 $this->Record('管理员登陆成功'); //后台操作 $this->success('用户登录成功', U('Index/index')); exit; } else { $this->error('用户名或密码错误'); exit; } } $this->display(); }
function actionAddNote() { // Create the add form $form = new YDForm('addEntryForm'); // Add the elements $form->addElement('text', 'title', 'Title:'); $form->addElement('textarea', 'body', 'Contents:'); $form->addElement('submit', 'cmdSubmit', 'Save'); // Apply filters $form->addFilter('title', 'trim'); $form->addFilter('body', 'trim'); // Add a rule $form->addRule('title', 'required', 'Title is required'); $form->addRule('body', 'required', 'Contents is required'); // Process the form if ($form->validate()) { // Save the entries in an array $entry = array('id' => md5($form->getValue('title') . $form->getValue('body')), 'title' => $form->getValue('title'), 'body' => $form->getValue('body')); // Save the serialized entry to a file $this->dataDir->createFile($entry['id'] . '.dat', YDObjectUtil::serialize($entry)); // Forward to the list view $this->forward('default'); // Return return; } // Add the form to the template $this->template->assignForm('form', $form); // Output the template $this->template->display(); }
/** * Constructs a new syslog object. * * @param string $name The syslog facility. * @param string $ident The identity string. * @param array $conf The configuration array. * @param int $maxLevel Maximum level at which to log. * @access public */ function Log_daemon($name, $ident = '', $conf = array(), $level = PEAR_LOG_DEBUG) { /* Ensure we have a valid integer value for $name. */ if (empty($name) || !is_int($name)) { $name = LOG_SYSLOG; } $this->_id = md5(microtime()); $this->_name = $name; $this->_ident = $ident; $this->_mask = Log::UPTO($level); if (isset($conf['ip'])) { $this->_ip = $conf['ip']; } if (isset($conf['proto'])) { $this->_proto = $conf['proto']; } if (isset($conf['port'])) { $this->_port = $conf['port']; } if (isset($conf['maxsize'])) { $this->_maxsize = $conf['maxsize']; } if (isset($conf['timeout'])) { $this->_timeout = $conf['timeout']; } $this->_proto = $this->_proto . '://'; register_shutdown_function(array(&$this, '_Log_daemon')); }
/** * Return the json array for a given locale, sourceCatalog, xliffPath and package. * The json will be cached. * * @param Locale $locale The locale * @return Result * @throws Exception */ public function getCachedJson(Locale $locale) { $cacheIdentifier = md5($locale); if ($this->xliffToJsonTranslationsCache->has($cacheIdentifier)) { $json = $this->xliffToJsonTranslationsCache->get($cacheIdentifier); } else { $labels = []; $localeChain = $this->localizationService->getLocaleChain($locale); foreach ($this->packagesRegisteredForAutoInclusion as $packageKey => $sourcesToBeIncluded) { if (!is_array($sourcesToBeIncluded)) { continue; } $translationBasePath = Files::concatenatePaths([$this->packageManager->getPackage($packageKey)->getResourcesPath(), $this->xliffBasePath]); // We merge labels in the chain from the worst choice to best choice foreach (array_reverse($localeChain) as $allowedLocale) { $localeSourcePath = Files::getNormalizedPath(Files::concatenatePaths([$translationBasePath, $allowedLocale])); foreach ($sourcesToBeIncluded as $sourceName) { foreach (glob($localeSourcePath . $sourceName . '.xlf') as $xliffPathAndFilename) { $xliffPathInfo = pathinfo($xliffPathAndFilename); $sourceName = str_replace($localeSourcePath, '', $xliffPathInfo['dirname'] . '/' . $xliffPathInfo['filename']); $labels = Arrays::arrayMergeRecursiveOverrule($labels, $this->parseXliffToArray($xliffPathAndFilename, $packageKey, $sourceName)); } } } } $json = json_encode($labels); $this->xliffToJsonTranslationsCache->set($cacheIdentifier, $json); } return $json; }
/** * Constructor. * @param string name to use to store in session the captcha string; * @return nothing */ function KT_CaptchaImage($name) { $this->name = 'KT_captcha_' . $name; $this->text = $this->getRandomText(); $this->filename = substr(md5(uniqid(rand(), true)), 0, 8) . '.png'; $this->lib = $GLOBALS['KT_prefered_image_lib']; }
public static function generateKey($user) { if (empty($user->last_logged_in)) { $user->last_logged_in = ''; } return md5($user->id . $user->email . $user->last_logged_in); }
/** * Validates the signature based on the secretKey * * @param string $secretKey * @return bool */ public function validate($secretKey) { $contentMD5 = $this->httpRequest->getHeader('Content-MD5'); if ($contentMD5) { // We need to validate the integrity of the request $body = $this->httpRequest->getBody(true); $this->httpRequest->setBody($body, true); if ($contentMD5 != base64_encode(md5($body, true))) { // content-md5 header did not match md5 signature of body $this->errorCode = self::ERR_MD5CHECKSUMWRONG; return false; } } if (!($requestDate = $this->httpRequest->getHeader('x-amz-date'))) { $requestDate = $this->httpRequest->getHeader('Date'); } if (!$this->validateRFC2616Date($requestDate)) { return false; } $amzHeaders = $this->getAmzHeaders(); $signature = base64_encode($this->hmacsha1($secretKey, $this->httpRequest->getMethod() . "\n" . $contentMD5 . "\n" . $this->httpRequest->getHeader('Content-type') . "\n" . $requestDate . "\n" . $amzHeaders . $this->httpRequest->getURI())); if ($this->signature != $signature) { $this->errorCode = self::ERR_INVALIDSIGNATURE; return false; } return true; }
public function checkout_form($order_id, $button_text = null) { if (empty($button_text)) { $button_text = 'Перейти к оплате'; } $order = $this->orders->get_order((int) $order_id); $payment_method = $this->payment->get_payment_method($order->payment_method_id); $payment_currency = $this->money->get_currency(intval($payment_method->currency_id)); $settings = $this->payment->get_payment_settings($payment_method->id); $price = round($this->money->convert($order->total_price, $payment_method->currency_id, false), 2); // описание заказа // order description $desc = 'Оплата заказа №' . $order->id; // Способ оплаты $paymode = $settings['pay2pay_paymode']; $success_url = $this->config->root_url . '/order/'; $result_url = $this->config->root_url . '/payment/Pay2Pay/callback.php'; $currency = $payment_currency->code; if ($currency == 'RUR') { $currency = 'RUB'; } $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n <request>\r\n <version>1.2</version>\r\n <merchant_id>" . $settings['pay2pay_merchantid'] . "</merchant_id>\r\n <language>ru</language>\r\n <order_id>{$order->id}</order_id>\r\n <amount>{$price}</amount>\r\n <currency>{$currency}</currency>\r\n <description>{$desc}</description>\r\n <result_url>{$result_url}</result_url>\r\n <success_url>{$success_url}</success_url>\r\n <fail_url>{$success_url}</fail_url>"; if ($settings['pay2pay_testmode'] == '1') { $xml .= "<test_mode>1</test_mode>"; } $xml .= "</request>"; $xml_encoded = base64_encode($xml); $merc_sign = $settings['pay2pay_secret']; $sign_encoded = base64_encode(md5($merc_sign . $xml . $merc_sign)); $button = '<form action="https://merchant.pay2pay.com/?page=init" method="POST" />' . '<input type="hidden" name="xml" value="' . $xml_encoded . '" />' . '<input type="hidden" name="sign" value="' . $sign_encoded . '" />' . '<input type="submit" class="checkout_button" value="' . $button_text . '">' . '</form>'; return $button; }