本文整理汇总了PHP中SJB_Request::getProtocol方法的典型用法代码示例。如果您正苦于以下问题:PHP SJB_Request::getProtocol方法的具体用法?PHP SJB_Request::getProtocol怎么用?PHP SJB_Request::getProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SJB_Request
的用法示例。
在下文中一共展示了SJB_Request::getProtocol方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHTML
public static function getHTML($service)
{
if ($service->getPublicKey() === null) {
/** @see Zend_Service_ReCaptcha_Exception */
require_once 'Zend/Service/ReCaptcha/Exception.php';
throw new Zend_Service_ReCaptcha_Exception('Missing public key');
}
$host = Zend_Service_ReCaptcha::API_SERVER;
$params = $service->getParams();
if ((bool) $params['ssl'] === true) {
$host = Zend_Service_ReCaptcha::API_SECURE_SERVER;
}
$htmlBreak = '<br>';
$htmlInputClosing = '>';
if ((bool) $params['xhtml'] === true) {
$htmlBreak = '<br />';
$htmlInputClosing = '/>';
}
$errorPart = '';
if (!empty($params['error'])) {
$errorPart = '&error=' . urlencode($params['error']);
}
$options = $service->getOptions();
$return = '';
if (!empty($options)) {
$encoded = Zend_Json::encode($options);
$encoded = substr($encoded, 1, -1) . ",callback: Recaptcha.focus_response_field";
$host = SJB_Request::getProtocol() . '://www.google.com/recaptcha/api';
$return = <<<SCRIPT
<script type="text/javascript" src="{$host}/js/recaptcha_ajax.js"></script>
<script type="text/javascript">
\tfunction showRecaptcha() {
\t\tif (\$("#recaptcha_div").html() === "") {
\t\t\tRecaptcha.create("{$service->getPublicKey()}", "recaptcha_div", {{$encoded}});
\t\t\twindow.setTimeout(showRecaptcha, 3000);
\t\t}
\t}
\twindow.setTimeout(showRecaptcha, 900);
</script>
SCRIPT;
$return .= <<<HTML
<div id="recaptcha_div"></div>
HTML;
}
return $return;
}
示例2: getListingsFromSimplyHired
public static function getListingsFromSimplyHired($params)
{
$listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($params->listing_type_sid);
if ($listingTypeID == 'Job' && $GLOBALS['uri'] == '/search-results-jobs/' || $GLOBALS['uri'] == '/ajax/') {
$publisherID = SJB_Settings::getSettingByName('simplyHiredPublisherID');
$limit = SJB_Settings::getSettingByName('countSimplyHiredListings');
$ip = $_SERVER['REMOTE_ADDR'];
$userAgent = urlencode(SJB_Request::getUserAgent());
$start = $limit * ($params->listing_search_structure['current_page'] - 1) + 1;
$stateIndexes = array('AL' => 'Alabama', 'AK' => 'Alaska', 'AZ' => 'Arizona', 'AR' => 'Arkansas', 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', 'WI' => 'Wisconsin', 'WY' => 'Wyoming', 'DC' => 'District of Columbia', 'AS' => 'American Samoa', 'GU' => 'Guam', 'MP' => 'Northern Mariana Islands', 'PR' => 'Puerto Rico', 'UM' => "United's Minor Outlying Islands", 'VI' => 'Virgin Islands');
$countryCodes = array('United States' => 'us', 'Australia' => 'au', 'Austria' => 'at', 'Belgium' => 'be', 'Brazil' => 'br', 'Canada' => 'ca', 'France' => 'fr', 'Germany' => 'de', 'India' => 'in', 'Ireland' => 'ie', 'Italy' => 'it', 'Mexico' => 'mx', 'Netherlands' => 'nl', 'Spain' => 'es', 'Switzerland' => 'ch', 'United Kingdom' => 'gb');
// SET PARAMS FOR REQUEST
$keywords = '';
$criteria = $params->criteria_saver->criteria;
$fieldSID = SJB_ListingFieldManager::getListingFieldSIDByID('JobCategory');
$fieldInfo = SJB_ListingFieldDBManager::getListValuesBySID($fieldSID);
$fieldList = array();
foreach ($fieldInfo as $val) {
$fieldList[$val['id']] = $val['caption'];
}
$categoryCriteria = isset($criteria['JobCategory']['multi_like']) ? $criteria['JobCategory']['multi_like'] : '';
if (!empty($categoryCriteria)) {
foreach ($categoryCriteria as $category) {
if (!empty($fieldList[$category])) {
$keywords .= empty($keywords) ? $fieldList[$category] : ' OR ' . $fieldList[$category];
}
}
if (!empty($keywords)) {
$keywords = "({$keywords})";
}
}
foreach ($criteria as $field) {
if (is_array($field)) {
foreach ($field as $fieldType => $values) {
if ($fieldType == 'multi_like_and') {
foreach ($values as $val) {
$keywords .= empty($keywords) ? $val : ' ' . $val;
}
}
}
}
}
if (isset($criteria['keywords']) && !empty($criteria['keywords'])) {
foreach ($criteria['keywords'] as $key => $item) {
if (in_array($key, array('exact_phrase', 'any_words', 'all_words', 'like'))) {
$keywords .= $item;
}
}
}
$systemKeywords = trim(SJB_Settings::getSettingByName('simplyHiredKeyword'));
$keywords = $systemKeywords ? '(' . $systemKeywords . ')' . ($keywords ? ' OR (' . $keywords . ')' : '') : $keywords;
$keywords = preg_replace('/\\s+/', ' ', $keywords);
$keywords = str_replace(',', '', $keywords);
$keywords = urlencode(trim($keywords));
$location = self::getLocation($criteria, 'simplyHiredLocation');
$radius = SJB_Settings::getSettingByName('simplyHiredMiles');
if (isset($criteria['Location_ZipCode']['geo']['radius']) && !empty($criteria['Location_ZipCode']['geo']['radius'])) {
$radius = $criteria['Location_ZipCode']['geo']['radius'];
if ($radius == 'any') {
$radius = '';
}
}
$sortBy = SJB_Settings::getSettingByName('simplyHiredSortBy');
$siteUrl = SJB_Settings::getSettingByName('simplyHiredSiteUrl');
$jobAMaticDomain = SJB_Settings::getSettingByName('jobAMaticDomain', false);
if (!empty($jobAMaticDomain) && $siteUrl == 'simplyhired.com') {
$jobAMaticDomain = str_replace('http://', '', $jobAMaticDomain);
$jobAMaticDomain = str_replace('/', '', $jobAMaticDomain);
$jobAMaticDomain = "&jbd={$jobAMaticDomain}";
} else {
$jobAMaticDomain = '';
}
if ($siteUrl == 'simplyhired.com') {
$ssty = 2;
} else {
$ssty = 3;
}
$url = "http://api.{$siteUrl}/a/jobs-api/xml-v2/q-{$keywords}/l-{$location}/mi-{$radius}/ws-{$limit}/pn-{$params->listing_search_structure['current_page']}/sb-{$sortBy}?pshid={$publisherID}&ssty={$ssty}&cflg=r{$jobAMaticDomain}&clip={$ip}";
$sxml = new simplexml();
$xmlString = SJB_HelperFunctions::getUrlContentByCurl($url);
$simplyhiredListings = array();
if ($xmlString === false) {
// throw new Exception("simplyHiredPlugin: Failed to read XML from url - {$url}");
SJB_Logger::error("simplyHiredPlugin: Failed to read XML from url - {$url}");
} else {
//$tree = $sxml->xml_load_file($url, 'array');
$tree = $sxml->xml_load_file($xmlString, 'array');
$totalResults = 0;
if ($tree !== false) {
$results = isset($tree['rs']) ? $tree['rs'] : array();
$outputCountry = array_flip($countryCodes);
foreach ($results as $node) {
if ($tree['rq']['rpd'] == 1) {
$node = array($node);
}
foreach ($node as $key => $result) {
$state = (string) $result['loc']['@attributes']['st'];
$country = (string) $result['loc']['@attributes']['country'];
$simplyhiredListings[$key] = array('Title' => (string) $result['jt'], 'CompanyName' => (string) isset($result['cn']['@content']) ? $result['cn']['@content'] : '', 'JobDescription' => (string) $result['e'], 'Location' => array('Country' => empty($country) ? '' : (isset($outputCountry[strtolower($country)]) ? $outputCountry[strtolower($country)] : ''), 'State' => empty($location[1]) ? '' : (isset($stateIndexes[strtoupper($state)]) ? $stateIndexes[strtoupper($state)] : ''), 'State_Code' => empty($state) ? '' : strtoupper($state), 'City' => (string) $result['loc']['@attributes']['cty']), 'activation_date' => (string) $result['dp'], 'url' => (string) $result['src']['@attributes']['url'], 'api' => 'simplyHired', 'onmousedown' => ' onMouseDown="xml_sclk(this);" ', 'target' => ' target="_blank"', 'onclick' => 'onclick="addStatisticsForSimplyHired();" ', 'code' => '<span style="font-size:10px; position:relative; top:-5px; font-family:Arial,sans-serif;color: #333;"><a style="color: #333; text-decoration:none" href="' . SJB_Request::getProtocol() . '://www.simplyhired.com/">Jobs</a> by</span> <a STYLE="text-decoration:none" href="' . SJB_Request::getProtocol() . '://www.simplyhired.com/"><img src="' . SJB_Request::getProtocol() . '://www.jobamatic.com/c/jbb/images/simplyhired.png" alt="Simply Hired"></a>');
}
//.........这里部分代码省略.........
示例3: getListingsFromIndeed
//.........这里部分代码省略.........
}
foreach ($criteria as $fieldName => $field) {
if (is_array($field)) {
foreach ($field as $fieldType => $values) {
if ($fieldType === 'multi_like_and') {
foreach ($values as $val) {
if ($keywords != '') {
$keywords .= " and ";
}
$keywords .= $val;
}
}
}
}
}
if (isset($criteria['keywords']) && !empty($criteria['keywords'])) {
foreach ($criteria['keywords'] as $key => $item) {
if (in_array($key, array('exact_phrase', 'any_words', 'all_words'))) {
if (!empty($keywords)) {
$keywords .= ' or ';
}
$keywords .= $item;
}
}
}
if (substr($keywords, -4) == ' or ') {
$keywords = substr($keywords, 0, strlen($keywords) - 4);
}
$keywords = trim($keywords);
$keywords = urlencode($keywords);
$location = self::getLocation($criteria);
if (isset($criteria['Location']['location']['radius']) && !empty($criteria['Location']['location']['radius'])) {
if ($criteria['Location']['location']['radius'] == 'any') {
$radius = '';
} else {
$radius = $criteria['Location']['location']['radius'];
}
} else {
$radius = 0;
}
$indeedCountry = SJB_Settings::getSettingByName('IndeedCountry');
$country = !empty($criteria['Location_Country']['multi_like'][0]) ? $criteria['Location_Country']['multi_like'][0] : $indeedCountry;
$codes = array_values($countryCodes);
if (!in_array($country, $codes)) {
// ok. Country value - not correct Indeed value. Lets try convert it.
if (is_numeric($country)) {
$countryInfo = SJB_CountriesManager::getCountryInfoBySID($country);
$country = !empty($countryInfo['country_code']) ? $countryInfo['country_code'] : '';
}
}
$jobType = SJB_Settings::getSettingByName('IndeedJobType');
$siteType = SJB_Settings::getSettingByName('IndeedSiteType');
$sort = SJB_Settings::getSettingByName('IndeedSort');
$highlight = SJB_Settings::getSettingByName('IndeedHighlightKeywords');
$url = "http://api.indeed.com/ads/apisearch?publisher={$publisherID}&q={$keywords}&l={$location}&sort={$sort}&radius={$radius}&st={$siteType}&jt={$jobType}&start={$start}&limit={$limit}&fromage=&filter=&latlong=1&co={$country}&highlight={$highlight}&chnl=&userip={$ip}&useragent={$userAgent}&v=2";
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// grab URL and pass it to the browser
$xml = curl_exec($ch);
curl_close($ch);
$indeedListings = array();
if ($xml !== false) {
$doc = new DOMDocument();
try {
$doc->loadXML($xml, LIBXML_NOERROR);
$results = $doc->getElementsByTagName('results');
if ($results instanceof DOMNodeList) {
$outputCountry = array_flip($countryCodes);
$totalResults = $doc->getElementsByTagName('totalresults')->item(0)->nodeValue;
$totalPages = ceil((int) $totalResults / $limit);
$pageNumber = $doc->getElementsByTagName('pageNumber')->item(0)->nodeValue;
$indeedDomain = !empty($indeedCountry) && isset($countryDomains[$indeedCountry]) ? $countryDomains[$indeedCountry] : $countryDomains['us'];
if (strpos($indeedDomain, '.') !== 2) {
$indeedDomain = 'www.' . $indeedDomain;
}
foreach ($results as $node) {
foreach ($node->getElementsByTagName('result') as $result) {
$resultXML = simplexml_import_dom($result);
$jobKey = (string) $resultXML->jobkey;
$state = (string) $resultXML->state;
$country = (string) $resultXML->country;
$indeedListings[$jobKey] = array('Title' => (string) $resultXML->jobtitle, 'CompanyName' => (string) $resultXML->company, 'JobDescription' => (string) $resultXML->snippet, 'Location' => array('Country' => empty($country) ? '' : $outputCountry[strtolower($country)], 'State' => empty($state) ? '' : isset($stateIndexes[strtoupper($state)]) ? $stateIndexes[strtoupper($state)] : $state, 'State_Code' => empty($state) ? '' : strtoupper($state), 'City' => (string) $resultXML->city), 'url' => (string) $resultXML->url, 'onmousedown' => ' onMouseDown="' . (string) $resultXML->onmousedown . '" ', 'target' => ' target="_blank" ', 'jobkey' => $jobKey, 'activation_date' => (string) $resultXML->date, 'api' => 'indeed', 'code' => '<span id="indeed_at"><a href="' . SJB_Request::getProtocol() . '://' . $indeedDomain . '/">jobs</a> by <a href="' . SJB_Request::getProtocol() . '://' . $indeedDomain . '/" title="Job Search"><img src="' . SJB_Request::getProtocol() . '://www.indeed.com/p/jobsearch.gif" style="border: 0; vertical-align: middle;" alt="Indeed job search"></a></span>', 'pageNumber' => $pageNumber, 'totalPages' => $totalPages);
}
}
} else {
SJB_Logger::error('CANT GET INDEED XML RESULTS');
}
} catch (ErrorException $e) {
SJB_Logger::error($e->getMessage());
}
} else {
SJB_Logger::error('NOT VALID RESPONSE FROM INDEED');
}
self::$indeedListings = $indeedListings;
}
return $params;
}