public function callback() { include_once APP_PATH . '/BaoyiPay/BaoyiPay.php'; $xml = $_POST['data']; $info = xml2arr($xml); $body = $info['body']; //返回成功 if ($body['state'] == '02') { // 结算成功 $pay = M('DrawcashList')->where(array('bussflowno' => $body['tranSeqId']))->find(); if ($pay['status'] == 0) { //更新提现记录 $drawcashlist = array('id' => $pay['id'], 'real_amount' => $body['amount'], 'submitdate' => $body['submitDate'], 'acctno' => $body['acctNo'], 'acctname' => $body['acctName'], 'state' => $body['state'], 'proctime' => $body['procTime'], 'remark' => $body['remark'], 'update_time' => NOW_TIME, 'status' => '1'); M('CashFlow')->where(array('bussflowno' => $body['tranSeqId']))->save(array('state' => 1)); M('DrawcashList')->save($drawcashlist); } } elseif ($body['state'] == '03') { // 结算失败 //查看交易记录 $pay = M('DrawcashList')->where(array('bussflowno' => $body['tranSeqId']))->find(); if ($pay['status'] == 0) { //更新提现金额 $productinfo = M('Product')->find($pay['pid']); $drawcash_amount = $productinfo['drawcash_amount'] - $body['amount']; $product = array('id' => $pay['pid'], 'drawcash_amount' => $drawcash_amount); M('Product')->save($product); //更新提现记录 $drawcashlist = array('id' => $pay['id'], 'real_amount' => $body['amount'], 'submitdate' => $body['submitDate'], 'acctno' => $body['acctNo'], 'acctname' => $body['acctName'], 'state' => $body['state'], 'proctime' => $body['procTime'], 'remark' => $body['remark'], 'update_time' => NOW_TIME, 'status' => '2'); M('DrawcashList')->save($drawcashlist); } } }
public function pplogin() { if (IS_POST) { $xml = $_POST['xml']; $mac = $_POST['mac']; $key = '62def3a609f535dbc4ba6ac0471942dc'; $create_mac = hash('sha256', $xml . $key); include_once APP_PATH . '/BaoyiPay/BaoyiPay.php'; $data = xml2arr($xml); dump($data); $data['password'] = $this->decrypt($data['password']); dump($data['password']); dump($data); die; if ($create_mac == $mac) { $ret = array('ErrorMessage' => '', 'JsonResult' => '验证通过。', 'State' => '200'); } else { $ret = array('ErrorMessage' => '', 'JsonResult' => '非正常操作', 'State' => '500'); } $this->ajaxReturn($ret); } }
/** * Function: import_chyrp * Chyrp importing. */ public function import_chyrp() { if (empty($_POST)) { redirect("/admin/?action=import"); } if (!Visitor::current()->group->can("add_post")) { show_403(__("Access Denied"), __("You do not have sufficient privileges to import content.")); } if (isset($_FILES['posts_file']) and $_FILES['posts_file']['error'] == 0) { if (!($posts = simplexml_load_file($_FILES['posts_file']['tmp_name'])) or $posts->generator != "Chyrp") { Flash::warning(__("Chyrp Posts export file is invalid."), "/admin/?action=import"); } } if (isset($_FILES['pages_file']) and $_FILES['pages_file']['error'] == 0) { if (!($pages = simplexml_load_file($_FILES['pages_file']['tmp_name'])) or $pages->generator != "Chyrp") { Flash::warning(__("Chyrp Pages export file is invalid."), "/admin/?action=import"); } } if (ini_get("memory_limit") < 20) { ini_set("memory_limit", "20M"); } $trigger = Trigger::current(); $visitor = Visitor::current(); $sql = SQL::current(); function media_url_scan(&$value) { $config = Config::current(); $regexp_url = preg_quote($_POST['media_url'], "/"); if (preg_match_all("/{$regexp_url}([^\\.\\!,\\?;\"\\'<>\\(\\)\\[\\]\\{\\}\\s\t ]+)\\.([a-zA-Z0-9]+)/", $value, $media)) { foreach ($media[0] as $matched_url) { $filename = upload_from_url($matched_url); $value = str_replace($matched_url, $config->url . $config->uploads_path . $filename, $value); } } } if (isset($_FILES['groups_file']) and $_FILES['groups_file']['error'] == 0) { $import = YAML::load($_FILES['groups_file']['tmp_name']); foreach ($import["groups"] as $name => $permissions) { if (!$sql->count("groups", array("name" => $name))) { $trigger->call("import_chyrp_group", Group::add($name, (array) $permissions)); } } foreach ($import["permissions"] as $id => $name) { if (!$sql->count("permissions", array("id" => $id))) { $sql->insert("permissions", array("id" => $id, "name" => $name)); } } } if (isset($_FILES['users_file']) and $_FILES['users_file']['error'] == 0) { $users = YAML::load($_FILES['users_file']['tmp_name']); foreach ($users as $login => $user) { $group_id = $sql->select("groups", "id", array("name" => $user["group"]), "id DESC")->fetchColumn(); $group = $group_id ? $group_id : $config->default_group; if (!$sql->count("users", array("login" => $login))) { $user = User::add($login, $user["password"], $user["email"], $user["full_name"], $user["website"], $group, $user["joined_at"]); } $trigger->call("import_chyrp_user", $user); } } if (isset($_FILES['posts_file']) and $_FILES['posts_file']['error'] == 0) { foreach ($posts->entry as $entry) { $chyrp = $entry->children("http://chyrp.net/export/1.0/"); $login = $entry->author->children("http://chyrp.net/export/1.0/")->login; $user_id = $sql->select("users", "id", array("login" => $login), "id DESC")->fetchColumn(); $data = xml2arr($entry->content); $data["imported_from"] = "chyrp"; if (!empty($_POST['media_url'])) { array_walk_recursive($data, "media_url_scan"); } $post = Post::add($data, $chyrp->clean, Post::check_url($chyrp->url), $chyrp->feather, $user_id ? $user_id : $visitor->id, (bool) (int) $chyrp->pinned, $chyrp->status, datetime($entry->published), $entry->updated == $entry->published ? null : datetime($entry->updated), "", false); $trigger->call("import_chyrp_post", $entry, $post); } } if (isset($_FILES['pages_file']) and $_FILES['pages_file']['error'] == 0) { foreach ($pages->entry as $entry) { $chyrp = $entry->children("http://chyrp.net/export/1.0/"); $attr = $entry->attributes("http://chyrp.net/export/1.0/"); $login = $entry->author->children("http://chyrp.net/export/1.0/")->login; $user_id = $sql->select("users", "id", array("login" => $login), "id DESC")->fetchColumn(); $page = Page::add($entry->title, $entry->content, $user_id ? $user_id : $visitor->id, $attr->parent_id, (bool) (int) $chyrp->show_in_list, $chyrp->list_order, $chyrp->clean, Page::check_url($chyrp->url), datetime($entry->published), $entry->updated == $entry->published ? null : datetime($entry->updated)); $trigger->call("import_chyrp_page", $entry, $page); } } Flash::notice(__("Chyrp content successfully imported!"), "/admin/?action=import"); }
/** * Function: xml2arr * Recursively converts a SimpleXML object (and children) to an array. * * Parameters: * $parse - The SimpleXML object to convert into an array. */ function xml2arr($parse) { if (empty($parse)) { return ""; } $parse = (array) $parse; foreach ($parse as &$val) { if (get_class($val) == "SimpleXMLElement") { $val = xml2arr($val); } } return $parse; }
public function querycard() { if (IS_POST) { $uid = is_login(); $head = $this->inithead('QP0007'); //6228480328608732074 $cardNo = $_POST['cardNo']; $merorderid = $_POST['merOrderId']; $card_id = $this->encrypt($head['clientDate'], $cardNo); $body = array('cardNo' => $card_id); $message = array('head' => $head, 'body' => $body); include_once APP_PATH . '/BaoyiPay/BaoyiPay.php'; $xml = to_xmlstring($message); $mac = md5($xml . $this->config['KEY']); $para = array('xml' => $xml, 'mac' => $mac); D('AccountLog')->record($head, $xml, $mac, 0); $text = getHttpResponsePost($this->config['PAY_URL'], $para); $para = md5Response($text, $this->config['KEY']); if (!$para) { $this->ajaxReturn(array('status' => 0, 'info' => '信息错误')); exit; } $data = xml2arr($para['xml']); $head = $data['head']; $body = $data['body']; D('AccountLog')->record($head, $para['xml'], $para['mac'], 1); if ($head['respCode'] == 'C000000000') { $info = M('ProductPay')->where(array('merorderid' => $merorderid))->find(); // 验证订单是否允许使用信用卡 if ($info['allow_creditcard'] == 0) { if ($body['cardType'] == '0') { $this->error('该订单不允许使用信用卡支付。'); } } $card = M('QuickcardList')->where(array('uid' => $uid, 'cardNo' => $cardNo))->find(); $bankinfo = $data['body']; if (!$card) { //所属银行编号 $bankNo = $body['bankNo']; $bankNm = $body['bankNm']; if ($info['allow_creditcard'] == 0) { $is_quick = M('BankInfo')->where(array('is_quick' => 1, 'bank_code' => $bankNo))->find(); //不存在 if (!$is_quick) { $this->error('快捷支付暂不支持' . $bankNm . '的借记卡。'); } } $storableCardNo = substr($cardNo, 0, 6) . substr($cardNo, strlen($cardNo) - 4); $id = M('QuickcardList')->add(array('uid' => $uid, 'cardNo' => $cardNo, 'bankNo' => $bankinfo['bankNo'], 'cardType' => $bankinfo['cardType'], 'bankNm' => $bankinfo['bankNm'], 'storableCardNo' => $storableCardNo)); $this->success('查询成功!', U('addstep2', array('id' => $id, 'merorderid' => $merorderid))); } else { if ($card['status'] == 1) { $this->error('您已经绑定了该银行卡。'); } else { $this->success('查询成功!', U('addstep2', array('id' => $card['id'], 'merorderid' => $merorderid))); return; } } } else { $this->error($head['respMsg']); } } }
/** * Function: post_xml_to_db * Migrates the XML post attributes to the "post_attributes" table. * * Versions: 2.0rc1 => 2.0rc2 */ function post_xml_to_db() { $sql = SQL::current(); if (!($rows = $sql->query("SELECT id, xml FROM __posts"))) { return; } function insert_attributes($sql, $row, $xml, &$inserts) { foreach ($xml as $name => $value) { if (is_array($value)) { $value = YAML::dump($value); } if (!$sql->insert("post_attributes", array("post_id" => $row["id"], "name" => $name, "value" => $value))) { # Clear successful attribute insertions so the # user can try again without primary key conflicts. foreach ($inserts as $insertion) { $sql->delete("post_attributes", array("post_id" => $insertion["id"], "name" => $insertion["name"])); } return false; } else { $inserts[] = array("id" => $row["id"], "name" => $name); } } return true; } $results = array(); foreach ($rows->fetchAll() as $row) { if (empty($row["xml"])) { continue; } $xml = xml2arr(new SimpleXMLElement($row["xml"])); $inserts = array(); echo _f("Migrating attributes of post #%d...", array($row["id"])) . test($results[] = insert_attributes($sql, $row, $xml, $inserts)); } if (!in_array(false, $results)) { echo __("Removing `xml` column from `posts` table...") . "\n"; echo " - " . __("Backing up `posts` table...") . test($backup = $sql->select("posts")); if (!$backup) { return; } $backups = $backup->fetchAll(); echo " - " . __("Dropping `posts` table...") . test($drop = $sql->query("DROP TABLE __posts")); if (!$drop) { return; } echo " - " . __("Creating `posts` table...") . test($create = $sql->query("CREATE TABLE IF NOT EXISTS __posts (\n id INTEGER PRIMARY KEY AUTO_INCREMENT,\n feather VARCHAR(32) DEFAULT '',\n clean VARCHAR(128) DEFAULT '',\n url VARCHAR(128) DEFAULT '',\n pinned TINYINT(1) DEFAULT 0,\n status VARCHAR(32) DEFAULT 'public',\n user_id INTEGER DEFAULT 0,\n created_at DATETIME DEFAULT '0000-00-00 00:00:00',\n updated_at DATETIME DEFAULT '0000-00-00 00:00:00'\n ) DEFAULT CHARSET=utf8")); if (!$create) { return file_put_contents("./_posts.bak.txt", var_export($backups, true)); } foreach ($backups as $backup) { unset($backup["xml"]); echo " - " . _f("Restoring post #%d...", array($backup["id"])) . test($insert = $sql->insert("posts", $backup)); if (!$insert) { return file_put_contents("./_posts.bak.txt", var_export($backups, true)); } } echo " -" . test(true); } }
private function savecheck($name, $cardid) { $config = C('SAVE_CHECK'); $clientDate = time_format(NOW_TIME, 'YmdHis'); $head = array('version' => '01', 'msgType' => '0001', 'chanId' => '99', 'merchantNo' => $config['MERCHANTID'], 'clientDate' => time_format(NOW_TIME, 'YmdHis'), 'tranFlow' => $config['MERCHANTID'] . $clientDate . rand(10000, 999999), 'tranCode' => 'SC0002', 'respCode' => '', 'respMsg' => ''); $body = array('idName' => $name, 'idNum' => $cardid); include_once APP_PATH . '/BaoyiPay/BaoyiPay.php'; $xml = to_xmlstring(array('head' => $head, 'body' => $body)); $mac = md5($xml . $config['MERKEY']); $this->checklog($xml . '&' . $mac, 1); $para = array('xml' => $xml, 'mac' => $mac); $text = getHttpResponsePost($config['URL'], $para); $this->checklog($text, 2); $para = md5Response($text, $config['MERKEY']); if (!$para) { //$this->ajaxReturn(array('status'=>0, 'info'=>'信息错误')); return array('status' => 0, 'info' => '信息错误'); } $data = xml2arr($para['xml']); if ($data['head']['respCode'] == 'C000000000') { return array('status' => 1, 'info' => ''); } else { return array('status' => 0, 'info' => $data['head']['respMsg']); } }
/** * SimpleXMLでパースしたオブジェクトを配列へ * * @param SimpleXMLElement $xmlobj * @return array */ public static function xml2array(SimpleXMLElement $xmlobj) { $arr = array(); if (is_object($xmlobj)) { $xmlobj = get_object_vars($xmlobj); } else { $xmlobj = $xmlobj; } foreach ($xmlobj as $key => $val) { if (is_object($xmlobj[$key])) { $arr[$key] = xml2arr($val); } else { if (is_array($val)) { foreach ($val as $k => $v) { if (is_object($v) || is_array($v)) { $arr[$key][$k] = xml2arr($v); } else { $arr[$key][$k] = $v; } } } else { $arr[$key] = $val; } } } return $arr; }