当前位置: 首页>>代码示例>>PHP>>正文


PHP utils::IsConnectionSecure方法代码示例

本文整理汇总了PHP中utils::IsConnectionSecure方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::IsConnectionSecure方法的具体用法?PHP utils::IsConnectionSecure怎么用?PHP utils::IsConnectionSecure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils的用法示例。


在下文中一共展示了utils::IsConnectionSecure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dirname

//
//   iTop is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU Affero General Public License for more details.
//
//   You should have received a copy of the GNU Affero General Public License
//   along with iTop. If not, see <http://www.gnu.org/licenses/>
/**
 * Shows a usage of the SOAP queries 
 *
 * @copyright   Copyright (C) 2010-2012 Combodo SARL
 * @license     http://opensource.org/licenses/AGPL-3.0
 */
require_once 'itopsoaptypes.class.inc.php';
$sItopRoot = 'http' . (utils::IsConnectionSecure() ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . dirname($_SERVER['SCRIPT_NAME']) . '/..';
$sWsdlUri = $sItopRoot . '/webservices/itop.wsdl.php';
//$sWsdlUri .= '?service_category=';
$aSOAPMapping = SOAPMapping::GetMapping();
ini_set("soap.wsdl_cache_enabled", "0");
$oSoapClient = new SoapClient($sWsdlUri, array('trace' => 1, 'classmap' => $aSOAPMapping));
try {
    // The most simple service, returning a string
    //
    $sServerVersion = $oSoapClient->GetVersion();
    echo "<p>GetVersion() returned <em>{$sServerVersion}</em></p>";
    // More complex ones, returning a SOAPResult structure
    // (run the page to know more about the returned data)
    //
    $oRes = $oSoapClient->CreateIncidentTicket('admin', 'admin', 'Email server down', 'HW found shutdown', null, new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'NW Management'))), new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Troubleshooting'))), '', new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'NW support'))), array(new SOAPLinkCreationSpec('Device', array(new SOAPSearchCondition('name', 'switch01')), array()), new SOAPLinkCreationSpec('Server', array(new SOAPSearchCondition('name', 'dbserver1.demo.com')), array())), '1', '1');
    echo "<p>CreateIncidentTicket() returned:\n";
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:31,代码来源:itopsoap.examples.php

示例2: foreach

    }
} else {
    $oSoapServer->setClass('BasicServices', null);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    CMDBObject::SetTrackOrigin('webservice-soap');
    $oSoapServer->handle();
} else {
    echo "This SOAP server can handle the following functions: ";
    $aFunctions = $oSoapServer->getFunctions();
    echo "<ul>\n";
    foreach ($aFunctions as $sFunc) {
        if ($sFunc == 'GetWSDLContents') {
            continue;
        }
        echo "<li>{$sFunc}</li>\n";
    }
    echo "</ul>\n";
    echo "<p>Here the <a href=\"{$sWsdlUri}\">WSDL file</a><p>";
    echo "You may also want to try the following service categories: ";
    echo "<ul>\n";
    foreach (get_declared_classes() as $sPHPClass) {
        if (is_subclass_of($sPHPClass, 'WebServicesBase')) {
            $sServiceCategory = $sPHPClass;
            $sSoapServerUri = 'http' . (utils::IsConnectionSecure() ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . dirname($_SERVER['SCRIPT_NAME']) . '/../webservices/soapserver.php';
            $sSoapServerUri .= "?service_category={$sServiceCategory}";
            echo "<li><a href=\"{$sSoapServerUri}\">{$sServiceCategory}</a></li>\n";
        }
    }
    echo "</ul>\n";
}
开发者ID:kira8565,项目名称:ITOP203-ZHCN,代码行数:31,代码来源:soapserver.php

示例3: Login

 /**
  * Attempt a login
  * 	 	
  * @param int iOnExit What action to take if the user is not logged on (one of the class constants EXIT_...)
  * @return int One of the class constants EXIT_CODE_...
  */
 protected static function Login($iOnExit)
 {
     if (self::SecureConnectionRequired() && !utils::IsConnectionSecure()) {
         // Non secured URL... request for a secure connection
         throw new Exception('Secure connection required!');
     }
     $aAllowedLoginTypes = MetaModel::GetConfig()->GetAllowedLoginTypes();
     if (isset($_SESSION['auth_user'])) {
         //echo "User: ".$_SESSION['auth_user']."\n";
         // Already authentified
         UserRights::Login($_SESSION['auth_user']);
         // Login & set the user's language
         return self::EXIT_CODE_OK;
     } else {
         $index = 0;
         $sLoginMode = '';
         $sAuthentication = 'internal';
         while ($sLoginMode == '' && $index < count($aAllowedLoginTypes)) {
             $sLoginType = $aAllowedLoginTypes[$index];
             switch ($sLoginType) {
                 case 'cas':
                     utils::InitCASClient();
                     // check CAS authentication
                     if (phpCAS::isAuthenticated()) {
                         $sAuthUser = phpCAS::getUser();
                         $sAuthPwd = '';
                         $sLoginMode = 'cas';
                         $sAuthentication = 'external';
                     }
                     break;
                 case 'form':
                     // iTop standard mode: form based authentication
                     $sAuthUser = utils::ReadPostedParam('auth_user', '', false, 'raw_data');
                     $sAuthPwd = utils::ReadPostedParam('auth_pwd', null, false, 'raw_data');
                     if ($sAuthUser != '' && $sAuthPwd !== null) {
                         $sLoginMode = 'form';
                     }
                     break;
                 case 'basic':
                     // Standard PHP authentication method, works with Apache...
                     // Case 1) Apache running in CGI mode + rewrite rules in .htaccess
                     if (isset($_SERVER['HTTP_AUTHORIZATION']) && !empty($_SERVER['HTTP_AUTHORIZATION'])) {
                         list($sAuthUser, $sAuthPwd) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
                         $sLoginMode = 'basic';
                     } else {
                         if (isset($_SERVER['PHP_AUTH_USER'])) {
                             $sAuthUser = $_SERVER['PHP_AUTH_USER'];
                             // Unfortunately, the RFC is not clear about the encoding...
                             // IE and FF supply the user and password encoded in ISO-8859-1 whereas Chrome provides them encoded in UTF-8
                             // So let's try to guess if it's an UTF-8 string or not... fortunately all encodings share the same ASCII base
                             if (!self::LooksLikeUTF8($sAuthUser)) {
                                 // Does not look like and UTF-8 string, try to convert it from iso-8859-1 to UTF-8
                                 // Supposed to be harmless in case of a plain ASCII string...
                                 $sAuthUser = iconv('iso-8859-1', 'utf-8', $sAuthUser);
                             }
                             $sAuthPwd = $_SERVER['PHP_AUTH_PW'];
                             if (!self::LooksLikeUTF8($sAuthPwd)) {
                                 // Does not look like and UTF-8 string, try to convert it from iso-8859-1 to UTF-8
                                 // Supposed to be harmless in case of a plain ASCII string...
                                 $sAuthPwd = iconv('iso-8859-1', 'utf-8', $sAuthPwd);
                             }
                             $sLoginMode = 'basic';
                         }
                     }
                     break;
                 case 'external':
                     // Web server supplied authentication
                     $bExternalAuth = false;
                     $sExtAuthVar = MetaModel::GetConfig()->GetExternalAuthenticationVariable();
                     // In which variable is the info passed ?
                     eval('$sAuthUser = isset(' . $sExtAuthVar . ') ? ' . $sExtAuthVar . ' : false;');
                     // Retrieve the value
                     if ($sAuthUser && strlen($sAuthUser) > 0) {
                         $sAuthPwd = '';
                         // No password in this case the web server already authentified the user...
                         $sLoginMode = 'external';
                         $sAuthentication = 'external';
                     }
                     break;
                 case 'url':
                     // Credentials passed directly in the url
                     $sAuthUser = utils::ReadParam('auth_user', '', false, 'raw_data');
                     $sAuthPwd = utils::ReadParam('auth_pwd', null, false, 'raw_data');
                     if ($sAuthUser != '' && $sAuthPwd !== null) {
                         $sLoginMode = 'url';
                     }
                     break;
             }
             $index++;
         }
         //echo "\nsLoginMode: $sLoginMode (user: $sAuthUser / pwd: $sAuthPwd\n)";
         if ($sLoginMode == '') {
             // First connection
             $sDesiredLoginMode = utils::ReadParam('login_mode');
//.........这里部分代码省略.........
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:101,代码来源:loginwebpage.class.inc.php

示例4: DoExecute

 protected function DoExecute()
 {
     echo "<p>Note: You may also want to try the sample SOAP client <a href=\"../webservices/itopsoap.examples.php\">itopsoap.examples.php</a></p>\n";
     $aSOAPMapping = SOAPMapping::GetMapping();
     // this file is generated dynamically with location = here
     $sWsdlUri = 'http' . (utils::IsConnectionSecure() ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . dirname($_SERVER['SCRIPT_NAME']) . '/../webservices/itop.wsdl.php';
     ini_set("soap.wsdl_cache_enabled", "0");
     foreach ($this->m_aTestSpecs as $iPos => $aWebService) {
         echo "<h2>SOAP call #{$iPos} - {$aWebService['verb']}</h2>\n";
         echo "<p>Using WSDL: {$sWsdlUriForService}</p>\n";
         echo "<p>{$aWebService['explain result']}</p>\n";
         $sWsdlUriForService = $sWsdlUri . '?service_category=' . $aWebService['service_category'];
         $this->m_SoapClient = new SoapClient($sWsdlUriForService, array('classmap' => $aSOAPMapping, 'trace' => 1));
         if (false) {
             self::DumpVariable($this->m_SoapClient->__getTypes());
         }
         try {
             $oRes = call_user_func_array(array($this->m_SoapClient, $aWebService['verb']), $aWebService['args']);
         } catch (SoapFault $e) {
             print "<pre>\n";
             print "Request: \n" . htmlspecialchars($this->m_SoapClient->__getLastRequest()) . "\n";
             print "Response: \n" . htmlspecialchars($this->m_SoapClient->__getLastResponse()) . "\n";
             print "</pre>";
             print "Response in HTML: <p>" . $this->m_SoapClient->__getLastResponse() . "</p>";
             throw $e;
         }
         self::DumpVariable($oRes);
         print "<pre>\n";
         print "Request: \n" . htmlspecialchars($this->m_SoapClient->__getLastRequest()) . "\n";
         print "Response: \n" . htmlspecialchars($this->m_SoapClient->__getLastResponse()) . "\n";
         print "</pre>";
         if ($oRes instanceof SOAPResult) {
             $res = $oRes->status;
         } elseif ($oRes instanceof SOAPSimpleResult) {
             $res = $oRes->status;
         } else {
             $res = $oRes;
         }
         if ($res != $aWebService['expected result']) {
             echo "Expecting:<br/>\n";
             var_dump($aWebService['expected result']);
             echo "Obtained:<br/>\n";
             var_dump($res);
             throw new UnitTestException("Expecting result '{$aWebService['expected result']}', but got '{$res}'");
         }
     }
 }
开发者ID:besmirzanaj,项目名称:itop-code,代码行数:47,代码来源:testlist.inc.php


注:本文中的utils::IsConnectionSecure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。