如何在Zend Framework中获取HTTP_REFERER

时间:2016-04-05 12:10:07

标签: php http zend-framework http-referer referer

我尝试使用this解决方案,但它对我不起作用。我的$this没有getRequest()方法,而Zend\Http\Request也没有。$request = new \Zend\Http\Request(); $http_referer = $request->getHeader('referer'); 根本没有boolean false方法。

我试过像

这样的东西
function redeployCtrl($scope, utilService, $filter, $location, generalSettings, $uibModalInstance, $uibModal, $timeout,scheme) {
$scope.openStart = openStart;
$scope.isSubmitable = isSubmitable;
$scope.ipCheckbox = ipCheckbox;
$scope.deploy = deploy;
$scope.init = init;
$scope.cancel = cancel;

function init() {
    $scope.scheme = scheme;
    $scope.loading = 'false';
    $scope.envSchemes = [];
    $scope.isPermanent = false;
    $scope.permanent = {};
    $scope.scheme.Scheme.Description = null;
    $scope.scheme.Scheme.ExpTime = null;

    var max = generalSettings.CalendarEndDate;
    $scope.maxDate = new Date();
    $scope.maxDate.setMonth($scope.maxDate.getMonth() + max);
    $scope.minDate = new Date();
    $scope.minDate = $scope.minDate.setDate($scope.minDate.getDate() + generalSettings.MinExpirationDate);
    $scope.dateOptions = {
        'year-format': 'yyyy',
        'starting-day': 1
    };

    utilService.post(generalSettings.serverPath + 'envscheme/ListSupervisors/', { })
      .then(function (data) {
          $scope.supervisors = data;
      }).catch(function (data) {
          utilService.setError(data.ExceptionMessage, "Failed to retrieve data", "img_error");
      });


    utilService.post(generalSettings.serverPath + 'envscheme/ListPermReasons/', { })
    .then(function (data) {
        $scope.permReasons = data;

    }).catch(function (data) {
        utilService.setError(data.ExceptionMessage, "Failed to retrieve data", "img_error");
    });
}

function openStart() {
    $timeout(function () {
        $scope.startOpened = true;
    });
}

function deploy(scheme, isPermanent) {
    if (isPermanent) {
        scheme.Scheme.ExpTime = '01/01/9999';
        scheme.Scheme.ApprovedBy = $scope.permanent.approvedBy;
        if ($scope.permanent.mainReason === 'Other') {
            scheme.Scheme.Reason = $scope.permanent.customReason;
        } else {
            scheme.Scheme.Reason = $scope.permanent.mainReason;
        }
    } else {
        $scope.scheme.Scheme.ExpTime = utilService.getFormattedDate($scope.scheme.Scheme.ExpTime);
    }
    $scope.loading = 'true';

    utilService.post(generalSettings.serverPath + 'envscheme/ReCreateEnv', scheme)
     .then(function (data) {
         if (data.Success) {
             utilService.alertAmpm("Deploy started successfuly", "Info", "img_information");
             $location.path("/MyEnvironments");
         }
         else {
             utilService.alertAmpm(data.Reason, "Failed to Re-Deploy", "img_error");
             $scope.loading = 'false';
         }
         if (data.Reason.indexOf("Session was not found") < -1) {
             sessionStorage.clear();
             $scope.loading = 'false';
         }
     }).catch(function (data) {
         utilService.setError(data.ExceptionMessage, "Failed to Re-Deploy", "img_error");
         $scope.loading = 'false';
     });
}

function isSubmitable(invalid, modules) {
    if (!invalid) {

        for (var i = 0; i < modules.length; i++) {
            if (modules[i].ipchkBox) {
                if (!modules[i].OS.Parameters.IP) {
                    return true;
                }
            }
        }
        return false;
    }
    return true;
}

function ipCheckbox(checkBox, name) {
    if (!checkBox) {
        var name1 = "ipText" + name;
        $('[name=' + name1 + ']').val('');
        $scope.scheme.Scheme.modules[name].OS.Parameters = new Object();
    }
}

function cancel() {
    $uibModalInstance.dismiss('cancel');
}

但它只返回{{1}}。我错过了什么?

1 个答案:

答案 0 :(得分:1)

知道了,我正在使用错误的课程。我们需要使用\Zend\Http\PhpEnvironment\Request()这个是正确的:

$request = new \Zend\Http\PhpEnvironment\Request();
$http_referer = $request->getServer('HTTP_REFERER');