本文整理汇总了PHP中SJB_Request::getUserAgent方法的典型用法代码示例。如果您正苦于以下问题:PHP SJB_Request::getUserAgent方法的具体用法?PHP SJB_Request::getUserAgent怎么用?PHP SJB_Request::getUserAgent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SJB_Request
的用法示例。
在下文中一共展示了SJB_Request::getUserAgent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logout
public static function logout()
{
$blogPath = SJB_Settings::getSettingByName('blog_path');
if (empty($blogPath)) {
return;
}
$url = SJB_System::getSystemSettings('SITE_URL') . $blogPath . '/';
$client = new Zend_Http_Client($url, array('useragent' => SJB_Request::getUserAgent(), 'maxredirects' => 0));
if (isset($_SESSION['wp_cookie_jar'])) {
$client->setCookieJar(@unserialize($_SESSION['wp_cookie_jar']));
}
try {
$response = $client->request();
$matches = array();
if (preg_match('/_wpnonce=([\\w\\d]+)"/', $response->getBody(), $matches)) {
$wpnonce = $matches[1];
$url = $url . 'wp-login.php?action=logout&_wpnonce=' . $wpnonce . '&noSJB=1';
$client->setUri($url);
$response = $client->request();
foreach ($response->getHeaders() as $key => $header) {
if ('set-cookie' == strtolower($key)) {
if (is_array($header)) {
foreach ($header as $val) {
header("Set-Cookie: " . $val, false);
}
} else {
header("Set-Cookie: " . $header, false);
}
}
}
}
} catch (Exception $ex) {
}
}
示例2: logout
static function logout()
{
SessionStorage::destroy(SJB_Session::getSessionId());
$forumPath = SJB_Settings::getSettingByName('forum_path');
if (empty($forumPath)) {
return;
}
$url = SJB_System::getSystemSettings('SITE_URL') . $forumPath . '/';
$client = new Zend_Http_Client($url, array('useragent' => SJB_Request::getUserAgent()));
$client->setCookie($_COOKIE);
$client->setCookieJar();
try {
$response = $client->request();
$matches = array();
if (preg_match('/\\.\\/ucp.php\\?mode=logout\\&sid=([\\w\\d]+)"/', $response->getBody(), $matches)) {
$sid = $matches[1];
$client->setUri($url . 'ucp.php?mode=logout&sid=' . $sid);
$response = $client->request();
foreach ($response->getHeaders() as $key => $header) {
if ('set-cookie' == strtolower($key)) {
if (is_array($header)) {
foreach ($header as $val) {
header("Set-Cookie: " . $val, false);
}
} else {
header("Set-Cookie: " . $header, false);
}
}
}
}
} catch (Exception $ex) {
}
}
示例3: getListingsFromJuju
/**
* @param $params
* @return mixed
*/
public static function getListingsFromJuju($params)
{
$listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($params->listing_type_sid);
if ($listingTypeID == 'Job' && $GLOBALS['uri'] == '/search-results-jobs/' || $GLOBALS['uri'] == '/ajax/') {
$criteria = $params->criteria_saver->criteria;
$keywords = self::getKeywords(isset($criteria['keywords']) ? $criteria['keywords'] : array());
$category = self::getCategory(isset($criteria['JobCategory']['multi_like']) ? $criteria['JobCategory']['multi_like'] : array());
if (!empty($category)) {
$keywords .= '+' . $category;
}
$location = self::getLocation($criteria, 'JujuLocation');
$radius = self::getRadius(isset($criteria['Location']['location']['radius']) ? $criteria['Location']['location']['radius'] : null);
$countListings = self::getCountListings();
$page = self::getPage();
$publisherID = SJB_Settings::getSettingByName('JujuID');
$ip = SJB_Request::getVar('REMOTE_ADDR', '', 'SERVER');
$userAgent = urlencode(SJB_Request::getUserAgent());
$url = "http://api.juju.com/jobs?partnerid={$publisherID}&k={$keywords}&l={$location}&r={$radius}&useragent={$userAgent}&ipaddress={$ip}&jpp={$countListings}&page={$page}&highlight=0";
self::setListingsUsingUrl($url);
}
return $params;
}
示例4: 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>');
}
//.........这里部分代码省略.........
示例5: getListingsFromIndeed
public static function getListingsFromIndeed($params)
{
$listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($params->listing_type_sid);
if ($listingTypeID == 'Job' && $GLOBALS['uri'] == '/search-results-jobs/' || $GLOBALS['uri'] == '/ajax/') {
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : $params->listing_search_structure['current_page'];
$publisherID = SJB_Settings::getSettingByName('IndeedPublisherID');
$limit = SJB_Settings::getSettingByName('countIndeedListings');
$ip = $_SERVER['REMOTE_ADDR'];
$userAgent = urlencode(SJB_Request::getUserAgent());
$start = $limit * ($page - 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', 'Argentina' => 'ar', 'Australia' => 'au', 'Austria' => 'at', 'Bahrain' => 'bh', 'Belgium' => 'be', 'Brazil' => 'br', 'Canada' => 'ca', 'Chile' => 'cl', 'China' => 'cn', 'Colombia' => 'co', 'Czech Republic' => 'cz', 'Denmark' => 'dk', 'Finland' => 'fi', 'France' => 'fr', 'Germany' => 'de', 'Greece' => 'gr', 'Hong Kong' => 'hk', 'Hungary' => 'hu', 'India' => 'in', 'Indonesia' => 'id', 'Ireland' => 'ie', 'Israel' => 'il', 'Italy' => 'it', 'Japan' => 'jp', 'Korea' => 'kr', 'Kuwait' => 'kw', 'Luxembourg' => 'lu', 'Malaysia' => 'my', 'Mexico' => 'mx', 'Netherlands' => 'nl', 'New Zealand' => 'nz', 'Norway' => 'no', 'Oman' => 'om', 'Pakistan' => 'pk', 'Peru' => 'pe', 'Philippines' => 'ph', 'Poland' => 'pl', 'Portugal' => 'pt', 'Qatar' => 'qa', 'Romania' => 'ro', 'Russia' => 'ru', 'Russian Federation' => 'ru', 'Saudi Arabia' => 'sa', 'Singapore' => 'sg', 'South Africa' => 'za', 'Spain' => 'es', 'Sweden' => 'se', 'Switzerland' => 'ch', 'Taiwan' => 'tw', 'Turkey' => 'tr', 'United Arab Emirates' => 'ae', 'United Kingdom' => 'gb', 'Venezuela' => 've');
$countryDomains = array('us' => 'indeed.com', 'ar' => 'ar.indeed.com', 'au' => 'au.indeed.com', 'at' => 'at.indeed.com', 'bh' => 'bh.indeed.com', 'be' => 'be.indeed.com', 'br' => 'indeed.com.br', 'ca' => 'ca.indeed.com', 'cl' => 'indeed.cl', 'cn' => 'cn.indeed.com', 'co' => 'co.indeed.com', 'cz' => 'cz.indeed.com', 'dk' => 'dk.indeed.com', 'fi' => 'indeed.fi', 'fr' => 'indeed.fr', 'de' => 'de.indeed.com', 'gr' => 'gr.indeed.com', 'hk' => 'indeed.hk', 'hu' => 'hu.indeed.com', 'in' => 'indeed.co.in', 'id' => 'id.indeed.com', 'ie' => 'ie.indeed.com', 'il' => 'il.indeed.com', 'it' => 'it.indeed.com', 'jp' => 'jp.indeed.com', 'kr' => 'kr.indeed.com', 'kw' => 'kw.indeed.com', 'lu' => 'indeed.lu', 'my' => 'indeed.com.my', 'mx' => 'indeed.com.mx', 'nl' => 'indeed.nl', 'nz' => 'nz.indeed.com', 'no' => 'no.indeed.com', 'om' => 'om.indeed.com', 'pk' => 'indeed.com.pk', 'pe' => 'indeed.com.pe', 'ph' => 'indeed.com.ph', 'pl' => 'pl.indeed.com', 'pt' => 'indeed.pt', 'qa' => 'qa.indeed.com', 'ro' => 'ro.indeed.com', 'ru' => 'ru.indeed.com', 'sa' => 'sa.indeed.com', 'sg' => 'indeed.com.sg', 'za' => 'indeed.co.za', 'es' => 'indeed.es', 'se' => 'se.indeed.com', 'ch' => 'indeed.ch', 'tw' => 'tw.indeed.com', 'tr' => 'tr.indeed.com', 'ae' => 'indeed.ae', 'gb' => 'indeed.co.uk', 've' => 've.indeed.com');
// 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)) {
if (!empty($keywords)) {
$keywords .= ' or ';
}
foreach ($categoryCriteria as $category) {
if (!empty($category) && !empty($fieldList[$category])) {
$keywords .= $fieldList[$category] . ' or ';
}
}
$keywords = substr($keywords, 0, strlen($keywords) - 4);
}
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 {
//.........这里部分代码省略.........