Request.php 1.78 KB
<?php

/**
 * 请求数据
 * User: ziy
 * Date: 14-7-8
 * Time: 下午6:07
 */
class YOHOPay_Package_Request
{

    /**
     * 订单号
     * @var string
     */
    public $orderCode;

    /**
     * 编码后的订单号
     * @var string
     */
    public $orderCodeString;

    /**
     * 订单名称
     * @var string
     */
    public $orderName;

    /**
     * 商品名称
     * @var string
     */
    public $goodsName;

    /**
     * 用户UID
     * @var integer
     */
    public $userID;

    /**
     * 用户
     * @var string
     */
    public $userName = '';

    /**
     * 订单创建时间
     * @var int
     */
    public $createTime = 0;

    /**
     * 付款总金额
     * @var int
     */
    public $feeTotal = 0;

    /**
     * 客户IP
     * @var string
     */
    public $clientIP = '0.0.0.0';

    /**
     * 订单过期时间
     * @var int
     */
    public $orderExpireTime = 0;

    public function __construct()
    {
        $this->clientIP = $this->getClientIp();
    }

    /**
     * 获取客户端ip
     * @return String
     */
    public function getClientIp()
    {
        if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) {
            $ip = getenv("HTTP_CLIENT_IP");
        } elseif (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) {
            $ip = getenv("HTTP_X_FORWARDED_FOR");
        } elseif (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) {
            $ip = getenv("REMOTE_ADDR");
        } elseif (isset ($_SERVER ["REMOTE_ADDR"]) && $_SERVER ["REMOTE_ADDR"] && strcasecmp($_SERVER ['REMOTE_ADDR'], "unknown")) {
            $ip = $_SERVER ["REMOTE_ADDR"];
        } else {
            $ip = "0.0.0.0";
        }
        return $ip;
    }
}