Пример #1
0
                    exit;
                } else {
                    show_message('绑定出错!');
                }
            }
        }
    }
}
//是否生成过二维码
if (is_erweima($user_id) == 0) {
    require 'weixin/wechat.class.php';
    $config = $GLOBALS['db']->getRow("SELECT * FROM " . $GLOBALS['ecs']->table('weixin_config') . " WHERE `id` = 1");
    $weixin = new core_lib_wechat($config);
    $scene_id = $db->getOne("select id from " . $GLOBALS['ecs']->table('weixin_qcode') . " order by id desc");
    $scene_id = $scene_id ? $scene_id + 1 : 1;
    $qcode = $weixin->getQRCode($scene_id, 1, $user_id);
    $GLOBALS['db']->query("insert into " . $GLOBALS['ecs']->table('weixin_qcode') . " (`id`,`type`,`content`,`qcode`) value ({$scene_id},4,'{$user_id}','{$qcode['ticket']}')");
}
if (!$smarty->is_cached('v_user_haibao.dwt', $cache_id)) {
    assign_template();
    $position = assign_ur_here();
    $smarty->assign('page_title', $position['title']);
    // 页面标题
    $smarty->assign('ur_here', $position['ur_here']);
    // 当前位置
    /* meta information */
    $smarty->assign('keywords', htmlspecialchars($_CFG['shop_keywords']));
    $smarty->assign('description', htmlspecialchars($_CFG['shop_desc']));
    $smarty->assign('user_info', get_user_info_by_user_id($user_id));
    $smarty->assign('erweima', get_erweima_by_user_id($user_id));
    $smarty->assign('user_id', $user_id);
Пример #2
0
 if ($_POST) {
     $type = intval($_POST['type']);
     if ($type == 3) {
         $content = getstr($_POST['content']);
     } else {
         $content = intval($_POST['content']);
     }
     if ($content) {
         if (!$id) {
             $link[] = array('href' => 'weixin.php?act=addqcode', 'text' => '生成二维码');
             require '../weixin/wechat.class.php';
             $config = $GLOBALS['db']->getRow("SELECT * FROM " . $GLOBALS['ecs']->table('weixin_config') . " WHERE `id` = 1");
             $weixin = new core_lib_wechat($config);
             $scene_id = $db->getOne("select id from " . $GLOBALS['ecs']->table('weixin_qcode') . " order by id desc");
             $scene_id = $scene_id ? $scene_id + 1 : 1;
             $qcode = $weixin->getQRCode($scene_id, 1);
             $ret = $db->query("insert into " . $GLOBALS['ecs']->table('weixin_qcode') . " (`id`,`type`,`content`,`qcode`) value ({$scene_id},{$type},'{$content}','{$qcode['ticket']}')");
         } else {
             $ret = $db->query("update " . $GLOBALS['ecs']->table('weixin_qcode') . " set `type`='{$type}',`content`='{$content}' where id={$id}");
             $link[] = array('href' => 'weixin.php?act=qcode', 'text' => '二维码列表');
         }
     }
     if ($ret) {
         sys_msg('操作成功', 0, $link);
     } else {
         sys_msg('操作失败,请重试', 0, $link);
     }
 } else {
     $smarty->assign('action_link', array('text' => "管理二维码", 'href' => 'weixin.php?act=qcode'));
     $ret = $db->getRow("select * from " . $GLOBALS['ecs']->table('weixin_qcode') . " where id={$id}");
     $smarty->assign('ur_here', "生成二维码");
Пример #3
0
            $state = 0;
        }
        if ($_GET['ajax'] == 1) {
            echo json_encode(array('state' => $state, 'url' => "../user.php"));
        } else {
            echo "<script>function myrefresh(){ {$str} }\n\t\tsetTimeout('myrefresh()',1000);</script>";
        }
        exit;
    }
} else {
    //print_r($_SESSION);
    //生成登录二维码代码 开始
    if ($_SESSION['login_value'] && $_SESSION['_outtime'] > time()) {
        $token = $GLOBALS['db']->getOne("SELECT token FROM " . $GLOBALS['ecs']->table('weixin_login') . " WHERE `value` = '{$_SESSION['login_value']}'");
    } else {
        $weixinconfig = $GLOBALS['db']->getRow("SELECT * FROM " . $GLOBALS['ecs']->table('weixin_config') . " WHERE `id` = 1");
        $weixin = new core_lib_wechat($weixinconfig);
        $scene_id = $t . rand(1000, 9999);
        $scene_id = substr($scene_id, 5);
        $token = $weixin->getQRCode($scene_id, 0, 600);
        $token = $token['ticket'];
        $ip = real_ip();
        $GLOBALS['db']->query("INSERT INTO " . $GLOBALS['ecs']->table('weixin_login') . " (`createtime`,`token`,`ip`,`value`) value\n\t\t ('{$t}','{$token}','{$ip}','{$scene_id}')");
        $_SESSION['login_value'] = $scene_id;
        $_SESSION['_outtime'] = $t + 600;
    }
    //生成登录二维码代码 结束
    echo "<h1>请使用微信扫描下面的二维码进行登陆。二维码有效期10分钟。过期请刷新页面重新获取。</h1>";
    echo "<p><img src='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={$token}' height='300px'></p>";
    echo "<iframe src='login.php?act=check' style='display:none'></iframe>";
}