Esempio n. 1
0
function dispatch()
{
    // generate a dictionary of arguments
    $query = formArgstoDict();
    // create consumer and handler objects
    $consumer = new SimpleConsumer();
    $handler = new SimpleActionHandler($query, $consumer);
    // extract identity url from arguments.  Will be null if absent from query.
    $identity_url = isset($query['identity_url']) ? $query['identity_url'] : null;
    if ($identity_url) {
        $ret = $consumer->find_identity_info($identity_url);
        if (!$ret) {
            setAlert(sprintf('Unable to find openid server for identity url %s', $identity_url));
        } else {
            // found identity server info
            list($identity_url, $server_id, $server_url) = $ret;
            // build trust root - this examines the script env and builds
            // based on your running location.  In practice this may be static.
            // You will likely want it to be your entire website, not just
            // this script.
            $trust_root = isset($_SERVER['SCRIPT_URI']) ? $_SERVER['SCRIPT_URI'] : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
            // build url to application for use in creating return_to
            $app_url = isset($_SERVER['SCRIPT_URI']) ? $_SERVER['SCRIPT_URI'] : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
            // create return_to url from app_url
            $return_to = $handler->createReturnTo($app_url, $identity_url);
            // handle the request
            $redirect_url = $consumer->handle_request($server_id, $server_url, $return_to, $trust_root);
            // redirect the user-agent to the server
            my_redirect($redirect_url);
        }
    } else {
        if (isset($query['openid.mode']) || isset($query['openid_mode'])) {
            // got a request from the server.  build a Request object and pass
            // it off to the consumer object.  OpendIDActionHandler handles
            // the various end cases (see above).
            $openid = $handler->getOpenID();
            $req = new ConsumerRequest($openid, $query, 'GET');
            $response = $consumer->handle_response($req);
            // let our SimpleActionHandler do the work
            $response->doAction($handler);
        }
    }
}
Esempio n. 2
0
    //数据合法性判断
    if (empty($username) || empty($username)) {
        //跳转
        my_redirect('privilege.php?act=login', '用户名或密码不能为空!', '正在为您重新跳转到登陆页面');
    }
    //合理性判断
    if (!Captcha::checkCaptcha($captcha)) {
        my_redirect('privilege.php?act=login', '验证码错误!', '正在为您重新跳转到登陆页面');
    }
    $user = new User();
    if ($users = $user->getUserByUsername($username)) {
        //用户名存在
        if (md5('yimai' . $password) === $users['u_password']) {
            //密码正确
            //将用户信息写入session
            @session_start();
            $_SESSION['user_id'] = $users['id'];
            if (!isset($_SESSION['uri'])) {
                my_redirect('index.php?act=view&id=2', '登陆成功!', '正在为您重新跳转到首页!', 1000);
            } else {
                my_redirect("{$_SESSION['uri']}", '登陆成功!', '正在为您重新跳转到易买网!', 1000);
            }
        } else {
            //密码错误
            my_redirect('privilege.php?act=login', '密码错误!', '正在为您重新跳转到登陆页面!');
        }
    } else {
        //用户名不存在
        my_redirect('privilege.php?act=login', '该用户名不存在!', '正在为您重新跳转到登陆页面!');
    }
}
Esempio n. 3
0
        $order_goods = new OrderGoods();
        $_goods['o_id'] = $order_id;
        $_goods['g_id'] = $_SESSION['orderGoods']['g_id'];
        $_goods['g_code'] = $_SESSION['orderGoods']['g_code'];
        $_goods['o_name'] = $_SESSION['orderGoods']['c_name'];
        $_goods['o_price'] = $_SESSION['orderGoods']['c_price'];
        $_goods['o_number'] = $_SESSION['orderGoods']['c_number'];
        //往订单商品表添加商品
        if ($order_goods->insertOrderGoods($_goods)) {
            $_SESSION['totalPrice'] = $totals;
            $_SESSION['orderNumber'] = $orderNumber;
            $_SESSION['orderId'] = $order_id;
            my_redirect("order.php?act=pay&orderId={$order_id}", '生成订单成功!', '正在为您跳转到支付页面!');
        }
    } else {
        my_redirect('order.php', '生成订单失败!', '正在为您跳转到订单页面!');
    }
} elseif ($act == 'pay') {
    //$orderId = $_GET['orderId'];
    //加载支付模板
    include_once YIMAI_TEMP . 'pay.html';
} elseif ($act == 'success') {
    //将订单里面的商品从购物车里面删除
    $orderGoods = new OrderGoods();
    $goods_id = $orderGoods->getOrderGoodsIdByOrderId($_SESSION['orderId']);
    foreach ($goods_id as $id) {
        $cart = new Cart();
        $cart->deleteCartGoodsByUserIdAndGoodsId($id['g_id']);
    }
    $orderGoods->updateOrderGoodsByOrderId($_SESSION['orderId']);
    //加载成功模板
Esempio n. 4
0
    include_once YIMAI_TEMP . 'shopping.html';
} elseif ($act == 'replace') {
    //将商品加入购物车
    //判断是否登陆
    if (!isset($_SESSION['user_id'])) {
        //未登陆
        my_redirect('privilege.php', '请先登陆!', '正在为您跳转到登陆页面!');
    }
    $goods_id = $_GET['id'];
    $user_id = $_SESSION['user_id'];
    $cart = new Cart();
    $cart->replaceGoodsToCart($goods_id);
    if (!($cartList = $cart->getCartGoodsByUserId())) {
        my_redirect('index.php', '获取购物车商品失败', '请重新获取!');
    }
    //获取商品详情
    $goods = new Goods();
    $oneGoods = $goods->getGoodsById($goods_id);
    //加载购物车模板
    include_once YIMAI_TEMP . 'goods_view.html';
} elseif ($act == 'delete') {
    $goods_id = $_GET['goods_id'];
    $cart = new Cart();
    if ($cart->deleteCartGoodsByUserIdAndGoodsId($goods_id)) {
        //删除成功
        my_redirect('cart.php', '删除购物车商品成功!', '正在为您重新加载购物车!', 1000);
    } else {
        //删除失败
        my_redirect('cart.php', '删除购物车商品失败!', '请在购物车里重新删除!');
    }
}
Esempio n. 5
0
    //获取所有留言
    $guestbook = new Guestbook();
    $pagecount = $config['guestbook_page'];
    //分页数据获取
    $list = $guestbook->getAllMessage($pagecount, $page);
    //获取当前总留言数量
    $counts = $guestbook->getCounts();
    //计算当前显示留言数
    $pages = ceil($counts / $config['guestbook_page']);
    //获取分页字符串
    $page_str = Page::getPageString('guestbooks.php', 'list', $counts, $page, $pagecount);
    //加载前台留言界面
    include_once YIMAI_TEMP . 'guestbook.html';
} elseif ($act == 'insert') {
    //留言入库
    $g_name = $_REQUEST['guestName'];
    $g_send_message = $_REQUEST['guestTitle'];
    $g_send_text = $_REQUEST['guestContent'];
    //var_dump($g_send_message,$g_send_text);exit;
    if (empty($g_send_message) || empty($g_send_text)) {
        my_redirect('guestbooks.php', '留言标题或内容不能为空!', '正在为您跳转到留言板');
    }
    $guestbook = new Guestbook();
    if ($guestbook->insertMessage($g_name, $g_send_message, $g_send_text)) {
        //留言成功
        my_redirect('guestbooks.php', '留言成功!', '正在为您跳转到留言板', 1000);
    } else {
        //留言失败
        my_redirect('guestbooks.php', '留言失败!', '正在为您跳转到留言板');
    }
}