Beispiel #1
0
function AESDecrypt($ciphertext, $key, $IV)
{
    $aes = new Crypt_AES(CRYPT_MODE_ECB);
    $aes->setKey(characet($key));
    $aes->setIV(characet($IV));
    return $aes->decrypt(hex2bin($ciphertext));
}
Beispiel #2
0
function writeLog($text)
{
    // $text=iconv("GBK", "UTF-8//IGNORE", $text);
    $text = characet($text);
    //file_put_contents ( dirname ( __FILE__ ) . "/log/log.txt", date ( "Y-m-d H:i:s" ) . "  " . $text . "\r\n", FILE_APPEND );
    file_put_contents("./Wxin_V10C_150513/Doc/log/alipay.txt", date("Y-m-d H:i:s") . "  " . $text . "\r\n", FILE_APPEND);
}
Beispiel #3
0
/**
 * 插入数据库
 * @param  [type] $data [description]
 * @return [type] $inser_num [返回成功插入的数量]
 */
function insert_db($data)
{
    echo "开始写入数据库\n";
    $insert_num = 0;
    //成功插入的数量
    $con = new mysqli("localhost", "root", "", "collection");
    if (!$con) {
        die('连接数据库失败:' . $con->error() . "\n\n");
    }
    $con->query('SET NAMES UTF8');
    foreach ($data as $v) {
        $sql = 'INSERT INTO hejian (skuId, name, url, price, martPrice, category_1, category_2) VALUES ("' . $v['skuId'] . '", "' . characet($v['name']) . '", "' . $v['url'] . '", "' . $v['price'] . '", "' . $v['martPrice'] . '", "' . characet($v['category_1']) . '", "' . characet($v['category_2']) . '")';
        $res = $con->query($sql);
        if (!$res) {
            echo "插入失败!商品地址:" . $v[1] . "\n";
            echo iconv("UTF-8", "gb2312", $sql) . "\n";
        } else {
            echo ".";
            $insert_num++;
        }
    }
    echo "\n";
    echo "成功插入" . $insert_num . "条数据\n\n";
    $con->close();
    return $insert_num;
}
Beispiel #4
0
<?php

$page = 1;
//当前页码;
$totalPage = 0;
//总页码;
do {
    $s = ($page - 1) * 95;
    $url = "http://list.taobao.com/itemlist/market/nongye1.htm?_input_charset=utf-8&json=on&s=" . $s . "&atype=b&cat=50107919&style=list&at=4673%2C11138&as=0&viewIndex=1&spm=a2106.2206569.0.0.klNaSh&same_info=1&isnew=2&pSize=95&_ksTS=1405255051526_27";
    //获取json数据
    $json = HttpGet($url);
    //处理编码问题
    $utf8_json = characet($json);
    //json解析为数组
    $arr = json_decode($utf8_json, true);
    //获取页码
    $page = $arr['page']['currentPage'];
    //获取总页码
    $totalPage = $arr['page']['totalPage'];
    //获取商品列表
    $lists = $arr['itemList'];
    //计算总共商品数
    $count = count($lists);
    //向终端输出信息
    echo "获取....第" . $page . "页,共" . $count . "条信息\n";
    //开始插入数据库
    $insert_num = insert_db($lists);
    //向终端输出信息
    echo "\n";
    echo "成功" . $insert_num . "条 失败" . ($count - $insert_num) . "条\n\n";
    $page++;
Beispiel #5
0
// | Author: 百家威信 <http://bbs.baijiacms.com>
// +----------------------------------------------------------------------
defined('SYSTEM_IN') or exit('Access Denied');
$alipaythirdlogin = mysqld_select("SELECT * FROM " . table('thirdlogin') . " WHERE enabled=1 and `code`='alipay'");
if (!empty($alipaythirdlogin) && !empty($alipaythirdlogin['id'])) {
    require_once WEB_ROOT . '/includes/lib/alipaySDK/config.php';
    require_once WEB_ROOT . '/includes/lib/alipaySDK/AopSdk.php';
    if (!empty($_GP["auth_code"])) {
        $auth_code = $_GP["auth_code"];
        require_once WEB_ROOT . '/includes/lib/alipaySDK/UserInfo.php';
        $userinfo = new UserInfo();
        $alipay_user = $userinfo->getUserInfo($auth_code);
        if (!empty($alipay_user)) {
            $alipay_openid = $user_info_resp->user_id;
            if (!empty($alipay_openid) && (!empty($_SESSION[MOBILE_ALIPAY_OPENID]) && $_SESSION[MOBILE_ALIPAY_OPENID] != $alipay_openid) || empty($_SESSION[MOBILE_ALIPAY_OPENID])) {
                $nickname = characet($user_info_resp->deliver_fullname);
                $follow = 1;
                $avatar = $user_info_resp->avatar;
                $gender = $user_info_resp->gender;
                $gender = $gender == 'F' ? 2 : ($gender == 'M' ? 1 : 0);
                $fans = mysqld_select("SELECT * FROM " . table('alipay_alifans') . " WHERE alipay_openid=:alipay_openid ", array(':alipay_openid' => $alipay_openid));
                if (empty($fans['alipay_openid'])) {
                    $row = array('nickname' => $nickname, 'follow' => $follow, 'gender' => intval($gender), 'alipay_openid' => $alipay_openid, 'avatar' => '', 'createtime' => TIMESTAMP);
                    mysqld_insert('alipay_alifans', $row);
                    if (!empty($avatar)) {
                        mysqld_update('alipay_alifans', array('avatar' => $avatar), array('alipay_openid' => $alipay_openid));
                    }
                } else {
                    $row = array('nickname' => $nickname, 'follow' => $follow, 'gender' => intval($gender), 'avatar' => '');
                    mysqld_update('alipay_alifans', $row, array('alipay_openid' => $alipay_openid));
                    if (!empty($avatar)) {
Beispiel #6
0
 public function getUserInfo($auth_code)
 {
     $token = $this->requestToken($auth_code);
     // echo "token: " .var_export($token);
     // print_r($token);
     if (isset($token->alipay_system_oauth_token_response)) {
         // 成功返回
         // 示例:array(
         // 'access_token' => 'publicpBfd7aa055c4c34120949e287f84eee84a',
         // 'expires_in' => 500,
         // 're_expires_in' => 300,
         // 'refresh_token' => 'publicpB343643c1f58b415ab9add66c0ea91fd3',
         // )
         $token_str = $token->alipay_system_oauth_token_response->access_token;
         // echo $token_str;
         $user_info = $this->requestUserInfo($token_str);
         // var_dump ( $user_info );
         if (isset($user_info->alipay_user_userinfo_share_response)) {
             $user_info_resp = $user_info->alipay_user_userinfo_share_response;
             // 以下每个字段都需要申请权限,才会返回。
             // 支付宝返回的是GBK编码,所以中文会有乱码
             // 'phone' => '',
             // 'deliver_fullname' => '濞村嘲',
             // 'user_type_value' => '2',
             // 'is_mobile_auth' => 'T',
             // 'user_id' => 'BM7PjM8f8-v6VFqeTlFUqo97w0QKRHRl-OmymTOxsGHnKDWiwQekMHiEi06tEbjgbb',
             // 'gender' => 'm',
             // 'zip' => '',
             // 'cert_type_value' => '0',
             // 'is_licence_auth' => 'F',
             // 'deliver_province' => '瀹?,
             // 'deliver_city' => '钘?,
             // 'is_certified' => 'T',
             // 'deliver_area' => '濮濇笟',
             // 'is_bank_auth' => 'T',
             // 'deliver_mobile' => '1234',
             // 'email' => '*****@*****.**',
             // 'address' => '娑撶痪鐠?99宄般亯鎼存潪娴犺泛D4B鎼?F',
             // 'user_status' => 'T',
             // 'cert_no' => '32142134',
             // 'real_name' => '濞村嘲',
             // 'is_id_auth' => 'T',
             // 'deliver_address_list' =>
             $user_id = $user_info_resp->user_id;
             // $deliver_fullname = iconv("GBK", "UTF-8//IGNORE", $user_info_resp->deliver_fullname);
             $deliver_fullname = characet($user_info_resp->deliver_fullname);
             $deliver_mobile = $user_info_resp->deliver_mobile;
             echo $deliver_fullname;
             writeLog($deliver_fullname);
             return $user_info_resp;
         }
         // print_r($user_info);
         writeLog("user_info" . var_export($user_info, true));
     } elseif (isset($token->error_response)) {
         // 返回了错误信息
         // 如:[code] => 40002
         // [msg] => Invalid Arguments
         // [sub_code] => isv.code-invalid
         // [sub_msg] => 授权码code无效
         // 记录错误返回信息
         writeLog($token->error_response->sub_msg);
     }
     writeLog(var_export($token, true));
 }
Beispiel #7
0
/**
 * 插入数据库
 * @param  [type] $data [description]
 * @return [type] $inser_num [返回成功插入的数量]
 */
function insert_db($data, $category)
{
    echo "开始写入数据库\n";
    $insert_num = 0;
    //成功插入的数量
    $con = new mysqli("localhost", "root", "", "collection");
    if (!$con) {
        die('连接数据库失败:' . $con->error() . "\n\n");
    }
    $con->query('SET NAMES UTF8');
    foreach ($data as $v) {
        $sql = 'INSERT INTO yiyao_2 (skuId, title, url, price, one_price, category_1, category_2) VALUES ("' . $v['3'] . '", "' . characet($v['2']) . '", "' . $v['1'] . '", "' . $v['price'] . '", "' . $v['one_price'] . '", "' . characet($category['name_1']) . '", "' . characet($category['name_2']) . '")';
        $res = $con->query($sql);
        //echo iconv("UTF-8","gb2312",$sql)."\n";
        if (!$res) {
            echo "插入失败!商品地址:" . $v[1] . "\n";
            echo iconv("UTF-8", "gb2312", $sql) . "\n";
        } else {
            echo ".";
            $insert_num++;
        }
    }
    echo "\n";
    $con->close();
    return $insert_num;
}
Beispiel #8
0
 protected function checkLog($text)
 {
     // $text=iconv("GBK", "UTF-8//IGNORE", $text);
     $text = characet($text);
     file_put_contents("./Wxin_V10C_150513/Doc/log/log.txt", date("Y-m-d H:i:s") . "  " . $text . "\r\n", FILE_APPEND);
 }
Beispiel #9
0
                die('api num use end\\n');
            }
            $product_base = $data['jingdong_ware_baseproduct_get_responce']['product_base'];
            $brand_name = $product_base[0]['brand_name'];
            $name = $product_base[0]['name'];
            $value_weight = $product_base[0]['value_weight'];
            if (empty($product_base[0]['product_area'])) {
                $product_area = '';
                print_r("skuId: " . $value['skuId'] . "dont't have 'product_area'\n");
                //				print_r($product_base);
                //				die;
            } else {
                $product_area = $product_base[0]['product_area'];
            }
            //组装数组
            $datas = array('skuId' => $value['skuId'], 'name' => $name, 'adword' => $adword, 'jdPrice' => $jdPrice, 'marketPrice' => $marketPrice, 'good' => $good, 'good_num' => $good_num, 'url' => 'http://item.jd.com/' . $value['skuId'] . '.html', 'category_1' => characet('营养保健'), 'category_2' => $category[$cids[$i]]['name_2'], 'category_3' => $category[$cids[$i]]['name_3'], 'brand_name' => $brand_name, 'sale_time' => $sale_time, 'value_weight' => $value_weight, 'product_area' => $product_area);
            //插入数据库
            insert_db($datas);
        }
        $panduan = $wareCount - $page * 100;
        echo "{$panduan} = " . $panduan . "\n";
    } while ($panduan >= 0);
}
function select_db()
{
    $con = new mysqli("localhost", "root", "", "collection");
    if (!$con) {
        die('连接数据库失败:' . $con->error() . "\n\n");
    }
    $con->query('SET NAMES UTF8');
    $sql = "SELECT skuId FROM jd GROUP BY skuId";