本文整理汇总了PHP中getDomain函数的典型用法代码示例。如果您正苦于以下问题:PHP getDomain函数的具体用法?PHP getDomain怎么用?PHP getDomain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDomain函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
if ($this->isPost()) {
$params = $this->input->post();
$return_url = $params['return_url'];
unset($params['return_url']);
$ret = $this->user_model->checkLogin($params);
if ($ret) {
if ($return_url) {
$result = array_for_result(true, 'login success', array(), $return_url);
} else {
$result = array_for_result(true, 'login success', array(), '/index.php/tips/index');
}
$cookie_d['u_id'] = $ret;
$cookie_d['sso_key'] = encrypt_string_by_time();
$cookie_data = json_encode($cookie_d);
setcookie('admin_permit', $cookie_data, time() + 3600, '/', getDomain($_SERVER['HTTP_HOST']));
} else {
$result = array_for_result(false, 'login failed');
}
$this->renderJsonp($result, $params);
} else {
$params = $this->input->get();
$return_url = isset($params['returnurl']) ? $params['returnurl'] : '';
$data['title'] = 'Login';
$data['return_url'] = $return_url;
$this->render('login/index', $data);
}
}
示例2: createData
/**
* Формирование данных доступных в шаблоне.
*/
function createData()
{
if ($this->params['sort'] != 2) {
$this->supportCached();
}
switch ($this->params['sort']) {
default:
case 1:
$sort = "sort";
break;
case 2:
$sort = "RAND()";
break;
}
$where = "i.idsec={$this->section_id}";
if ($this->params['idalb'] > 0) {
$where .= " AND i.iditem=" . (int) $this->params['idalb'];
} elseif ($this->params['idcat'] > 0) {
if ($idalbs = A::$DB->getCol("SELECT id FROM {$this->section}_albums WHERE idcat=" . (int) $this->params['idcat'])) {
$where .= " AND (i.iditem=" . implode(" OR i.iditem=", $idalbs) . ")";
}
}
$images = array();
A::$DB->query("\r\r\n\tSELECT i.* FROM " . getDomain($this->section) . "_images AS i\r\r\n\tLEFT JOIN {$this->section}_albums AS a ON a.id=i.iditem\r\r\n\tWHERE {$where} AND a.active='Y' ORDER BY {$sort}" . (!empty($this->params['rows']) ? " LIMIT 0," . (int) $this->params['rows'] : ""));
while ($row = A::$DB->fetchRow()) {
if (isset($links[$row['iditem']])) {
$row['link'] = $links[$row['iditem']];
} else {
$row['link'] = $links[$row['iditem']] = gallery_createItemLink($row['iditem'], $this->section);
}
$images[] = $row;
}
$this->Assign("images", $images);
}
示例3: getUri
/**
* This helper function can be used to get a valid uri from an url and return it.
*
* @param string $url
*
* @return mixed
*/
function getUri($url)
{
if (!empty($url)) {
// Sanitize URL first by removing unwanted chars
$url = preg_replace("/[\n\r]/", '', $url);
// Sanitize URL accourding to RFC1738 (perhaps use RFC3986?)
$entities = [' '];
$replacements = ['%20'];
$url = str_replace($entities, $replacements, $url);
// Check weither the domain is actually valid
if (getDomain($url) == false) {
return false;
}
$pslManager = new Pdp\PublicSuffixListManager();
$urlParser = new Pdp\Parser($pslManager->getList());
$urlData = $urlParser->parseUrl($url)->toArray();
$path = $urlData['path'] . (!empty($urlData['query']) ? '?' . $urlData['query'] : '');
// Set the path to root if empty (default)
if (empty($path)) {
$path = '/';
}
// Sanitize PATH accourding to RFC1738 (perhaps use RFC3986?)
$entities = [' '];
$replacements = ['%20'];
$path = str_replace($entities, $replacements, $path);
return $path;
} else {
return false;
}
}
示例4: check_permission
public function check_permission()
{
$WebSiteID = $this->session->userdata('WebSiteID');
$GroupID = $this->session->userdata('GroupID');
$AccID = $this->session->userdata('AccID');
$PreWebSiteID = $this->session->userdata('WebSiteID');
$url = trim($this->uri->uri_string());
$routestring = explode('/', $url);
$controller = @$routestring[0];
$method = @$routestring[1];
$WebID = $WebSiteID;
$curr_class = @$controller;
$curr_method = @$method;
if (trim($curr_class) == '') {
$curr_class = "redirect";
}
if (trim($curr_method) == '') {
$curr_method = "index";
}
$controllerfile = 'application/controllers/' . $WebID . '/' . $curr_class . '.php';
if (!file_exists($controllerfile)) {
if ($curr_class == 'ajax') {
$controllerfile = 'application/controllers/ajax.php';
} else {
$controllerfile = 'application/controllers/common/' . $curr_class . '.php';
if (!file_exists($controllerfile)) {
$curr_class = "redirect";
$curr_method = "index";
}
}
}
$sql = "SELECT WebSiteID, Suspend FROM tbl_websites WITH (NOLOCK) WHERE Domain='" . mssql_real_escape_string(getDomain()) . "' AND Activate=1 AND StartTime< GETDATE() AND GETDATE()< ExpireTime";
$query = $this->db->query($sql);
$rowcount = $query->num_rows();
if ($rowcount > 0) {
$row = $query->row();
if ($row->Suspend) {
//show suspend page
echo "suspend";
show_404();
} else {
$WebSiteID = $row->WebSiteID;
$this->session->set_userdata('WebSiteID', $row->WebSiteID);
}
} else {
show_404();
}
if ($GroupID == '' || $GroupID === false) {
$GroupID = 'public';
$this->session->set_userdata('GroupID', $GroupID);
}
$sql = "SELECT count(*) total FROM tbl_websites_accounts_groups_models WITH (NOLOCK) WHERE Activate=1 AND GroupID='" . mssql_real_escape_string($GroupID) . "' AND ModelID='" . mssql_real_escape_string($curr_class) . "' AND (AccID='" . mssql_real_escape_string($AccID) . "' OR AccID='') AND (WebSiteID='" . mssql_real_escape_string($WebSiteID) . "' OR WebSiteID='')";
$query = $this->db->query($sql);
$row = $query->row();
$total = $row->total;
if ($total <= 0) {
show_404();
}
}
示例5: getSocialUser
function getSocialUser()
{
global $twitterFollowers;
global $facebookFriends;
global $relationshipStatus;
global $politicalViews;
global $logFileHandle;
$thisUser = getUserBasics();
$yob = substr($thisUser["birthday"], 0, 4);
$age = date("Y") - $yob;
$userValues["domain"] = getDomain();
fwrite($logFileHandle, "<p>The domain is " . $userValues["domain"]);
$userValues["identifier"] = getIdentifier($userValues["domain"]);
/******************* Facebook ************************/
if ($userValues["domain"] == "facebook.com") {
if ($age > 18 && rand(1, 100) > 20) {
$userValues["profile"]["relationshipStatus"] = getRelationshipStatus($age);
}
// if (!empty($relStatus)) { $userValues["profile"]["relationshipStatus"] = $relStatus; }
// get political views
if ($thisUser["primaryAddress"]["country"] == "United States") {
if (rand(1, 100) > 61) {
$polViews = getRandomValue($politicalViews);
$userValues["profile"]["politicalViews"] = skewPoliticalViews($polViews, $age, $thisUser["gender"], $thisUser["primaryAddress"]["stateAbbreviation"]);
}
}
$range = getRandomValue($facebookFriends);
$numberOfFBfriends = rand($range["min"], $range["max"]);
fwrite($logFileHandle, "<p>The number of friends is: " . $numberOfFBfriends);
$userValues["friends"] = getFriendsOrFollowersArray($numberOfFBfriends, $userValues["domain"]);
//*************** Interests, Movies, Books, Music **************/
// parameters: &attribute_name=profiles%23181683&uuid=ea1bc321-4320-4fbb-8f07-fb939b90cf46&value={"profile":{"interests":[{"interest":"scrapbooking"},{"interest":"cats"},{"interest":"dogs"}],"movies":[{"movie":"Platoon"},{"movie":"Star+Trek+Into+Darkness"}],"books":[{"book":"Call+It+Sleep"},{"book":"The+Death+of+the+Heart"},{"book":"The+French+Lieutenant%27s+Woman"}],"music":[{"music":"Britney+Spears"}]}}
$psychInfoTypes = array("interests" => "interest", "movies" => "movie", "books" => "book", "music" => "music");
foreach ($psychInfoTypes as $categoryName => $itemName) {
$numberOfItems = getNumberOfItems($itemName);
$itemString = $itemName . "s";
if ($itemName == "music") {
$itemString = $itemName . " artists";
}
fwrite($logFileHandle, "<p>The number of {$itemString} is: " . $numberOfItems);
if ($numberOfItems > 0) {
$userValues["profile"][$categoryName] = getItems($itemName, $numberOfItems);
}
}
}
/********************* Twitter ***********************/
if ($userValues["domain"] == "twitter.com") {
$range = getRandomValue($twitterFollowers);
$numberOfTWfollowers = rand($range["min"], $range["max"]);
fwrite($logFileHandle, "<p>The number of followers is: " . $numberOfTWfollowers);
$userValues["followers"] = getFriendsOrFollowersArray($numberOfTWfollowers, $userValues["domain"]);
}
$thisUser["profiles"] = array();
$thisUser["profiles"][] = $userValues;
return $thisUser;
}
示例6: createData
/**
* Формирование данных доступных в шаблоне.
*/
function createData()
{
if ($this->params['sort'] != 5) {
$this->supportCached();
}
$this->params['idcat'] = (int) $this->params['idcat'];
$this->params['rows'] = (int) $this->params['rows'];
if ($this->params['idcat']) {
$catrow = A::$DB->getRowById($this->params['idcat'], "{$this->section}_categories");
$catrow['link'] = gallery_createCategoryLink($this->params['idcat'], $this->section);
$this->Assign("category", $catrow);
}
switch ($this->params['sort']) {
default:
case 1:
$sort = "date DESC";
break;
case 2:
$sort = "date";
break;
case 3:
$sort = "name";
break;
case 4:
$sort = "sort";
break;
case 5:
$sort = "RAND()";
break;
}
$sql = "\r\r\n\tSELECT *,svote/cvote AS vote FROM {$this->section}_albums\r\r\n\tWHERE active='Y'" . ($this->params['idcat'] ? " AND idcat={$this->params['idcat']}" : "") . (!empty($this->params['filter']) ? " AND {$this->params['filter']}" : "") . "\r\r\n\tORDER BY {$sort}";
if ($this->params['rows']) {
A::$DB->queryLimit($sql, 0, $this->params['rows']);
} else {
A::$DB->query($sql);
}
$albums = array();
while ($row = A::$DB->fetchRow()) {
$row['category'] = getTreePath($this->section . "_categories", $row['idcat']);
$row['link'] = gallery_createItemLink($row['id'], $this->section);
$row['vote'] = round($row['vote'], 2);
$row['images'] = A::$DB->getAll("\r\r\n\t SELECT * FROM " . getDomain($this->section) . "_images\r\r\n\t WHERE idsec=? AND iditem=? ORDER BY sort", array($this->section_id, $row['id']));
if ($this->options['usetags']) {
$row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']);
}
prepareValues($this->section, $row);
$row = A::$OBSERVER->Modifier('gallery_prepareValues', $this->section, $row);
$albums[] = $row;
}
A::$DB->free();
$this->Assign("albums", $albums);
}
示例7: parse
/**
* Parse attachments
* @return array Returns array with failed or success data
* (See parser-common/src/Parser.php) for more info.
*/
public function parse()
{
$reports = [];
if ($this->parsedMail->getHeader('subject') == "[SpamCop] summary report") {
$this->feedName = 'summary';
$reports = $this->parseSummaryReport();
} elseif ($this->parsedMail->getHeader('subject') == "[SpamCop] Alert") {
$this->feedName = 'alert';
$reports = $this->parseAlerts();
} elseif (strpos($this->parsedMail->getHeader('from'), "@reports.spamcop.net") !== false && $this->arfMail !== false) {
$this->feedName = 'spamreport';
$reports = $this->parseSpamReportArf();
} elseif (strpos($this->parsedMail->getHeader('from'), "@reports.spamcop.net") !== false && strpos($this->parsedMail->getMessageBody(), '[ Offending message ]')) {
$this->feedName = 'spamreport';
$reports = $this->parseSpamReportCustom();
} else {
$this->warningCount++;
}
foreach ($reports as $report) {
// If feed is known and enabled, validate data and save report
if ($this->isKnownFeed() && $this->isEnabledFeed()) {
// Sanity check
if ($this->hasRequiredFields($report) === true) {
// incident has all requirements met, filter and add!
$report = $this->applyFilters($report);
if (!empty($report['Spam-URL'])) {
$url = $report['Spam-URL'];
}
if (!empty($report['Reported-URI'])) {
$url = $report['Reported-URI'];
}
if (!empty($url)) {
$urlData = getUrldata($url);
if (!empty($urlData['host']) && !empty($urlData['path'])) {
$this->feedName = 'spamvertizedreport';
}
}
$incident = new Incident();
$incident->source = config("{$this->configBase}.parser.name");
$incident->source_id = false;
$incident->ip = $report['Source-IP'];
$incident->domain = empty($url) ? false : getDomain($url);
$incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
$incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
$incident->timestamp = strtotime($report['Received-Date']);
$incident->information = json_encode($report);
$this->incidents[] = $incident;
}
}
}
return $this->success();
}
示例8: archive_createSection
/**
* Обработчик события "Создание раздела".
*
* @param string $section Полный строковой идентификатор раздела.
* @param array $params Параметры события.
*/
function archive_createSection($section, $params)
{
if ($params['module'] == 'archive') {
$ids = A::$DB->getCol("\r\r\n SELECT id FROM " . getDomain($section) . "_sections\r\r\n\tWHERE module='catalog' AND (lang='" . A::$LANG . "' OR lang='all')");
setOption($section, 'sections', serialize($ids));
} elseif ($params['module'] == 'catalog') {
if ($archive = getSectionByModule('archive')) {
$ids = getOption($archive, 'sections');
$ids = !empty($ids) ? unserialize($ids) : array();
$ids[] = $params['id'];
setOption($archive, 'sections', serialize($ids));
}
}
}
示例9: sitemap_createSection
/**
* Обработчик события "Создание раздела".
*
* @param string $section Полный строковой идентификатор раздела.
* @param array $params Параметры события.
*/
function sitemap_createSection($section, $params)
{
if ($params['module'] == 'sitemap') {
$ids = A::$DB->getCol("SELECT id FROM " . getDomain($section) . "_sections WHERE lang='" . A::$LANG . "' OR lang='all'");
setTextOption($section, 'sections', serialize($ids));
} elseif ($sitemap = getSectionByModule('sitemap')) {
$ids = getTextOption($sitemap, 'sections');
$ids = !empty($ids) ? unserialize($ids) : array();
if (!$ids) {
$ids = array();
}
$ids[] = $params['id'];
setTextOption($sitemap, 'sections', serialize($ids));
}
}
示例10: termSearchByUrl
public function termSearchByUrl(Request $request)
{
$url = $request['url'];
$connection = getSiteName(getDomain($url));
$path_alias = getUri($url);
if (empty($connection) || empty($path_alias)) {
return AJAX::argumentError();
}
$termModule = new TermModule($connection);
$result = $termModule->getTermInfo(array('path_alias' => $path_alias));
if (count($result) > 0) {
return AJAX::success(array('info' => $result));
} else {
return AJAX::notExist();
}
}
示例11: productSearchByURL
public function productSearchByURL(Request $request)
{
$url = $request['url'];
$connection = getSiteName(getDomain($url));
$sn = getSn($url);
if (empty($connection) || empty($sn)) {
return AJAX::argumentError();
}
$termModule = new ProductModule($connection);
$result = $termModule->getProductInfo(array('sn' => $sn));
if (count($result) > 0) {
return AJAX::success(array('info' => $result));
} else {
return AJAX::notExist();
}
}
示例12: parse
/**
* Parse attachments
* @return array Returns array with failed or success data
* (See parser-common/src/Parser.php) for more info.
*/
public function parse()
{
$xml = simplexml_load_string($this->parsedMail->getMessageBody());
$timestamp = strtotime($xml->attributes()->date);
foreach ($xml->list as $reports) {
$this->feedName = (string) $reports->attributes()->type;
// If feed is known and enabled, validate data and save report
if ($this->isKnownFeed() && $this->isEnabledFeed()) {
foreach ($reports->url_info as $url_info) {
$url = (string) $url_info->attributes()->url;
$ip = (string) $url_info->attributes()->ip;
$urlData = getUrlData($url);
if (filter_var($ip, FILTER_VALIDATE_IP) === false) {
// No IP supplied by Google
if (!empty($urlData['host']) && !filter_var($urlData['host'], FILTER_VALIDATE_IP) === false) {
// Hostname is an IP address
$ip = $urlData['host'];
} else {
// We have no IP address, try to get the IP address by resolving the domain
$ip = @gethostbyname($urlData['host']);
// If it fails, set to localhost
$ip = $ip == $urlData['host'] ? '127.0.0.1' : $ip;
}
}
$report = ['domain' => getDomain($url), 'uri' => getUri($url), 'category' => config("{$this->configBase}.feeds.{$this->feedName}.category")];
// Sanity check
if ($this->hasRequiredFields($report) === true) {
// incident has all requirements met, filter and add!
$report = $this->applyFilters($report);
$incident = new Incident();
$incident->source = config("{$this->configBase}.parser.name");
$incident->source_id = false;
$incident->ip = $ip;
$incident->domain = $report['domain'];
$incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
$incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
$incident->timestamp = $timestamp;
$incident->information = json_encode(array_merge($urlData, $report));
$this->incidents[] = $incident;
}
}
}
}
return $this->success();
}
示例13: BuildCleanURL
/**
* Builds a Clean URL. Domain name is pulled from getDomain
*
* @param string $c the controller object to invoke
* @param string $m the method of the controller to call
* @param int $id (optional) the id of the record being updated
* @param array $qs (optional) array/assoc array/model of query string variables and values
* @return string a clean URL
*
*/
public function BuildCleanURL($c, $m, $id = null, $qs = null)
{
$idStr = "";
$qsStr = "";
if (is_object($qs)) {
$qs2 = array();
foreach ($qs as $k => $v) {
$qs2[] = "{$k}={$v}";
}
$qsStr = "/?" . implode("&", $qs2);
} elseif (_isArray($qs)) {
$qsStr = $this->BuildQSFromArray($qs);
}
if ($id != null) {
$idStr = "/" . (string) $id;
}
$dir = $this->state == "live" ? "" : "Public/";
return str_replace(array("~d~", "~dir~", "~c~", "~m~", "~id~", "~qs~"), array(getDomain(), $dir, $c, $m, $idStr, $qsStr), $this->cleanURLTemplate);
}
示例14: parse
/**
* Parse attachments
* @return array Returns array with failed or success data
* (See parser-common/src/Parser.php) for more info.
*/
public function parse()
{
foreach ($this->parsedMail->getAttachments() as $attachment) {
if (strpos($attachment->filename, '-report.txt') === false) {
continue;
}
// Handle aliasses first
foreach (config("{$this->configBase}.parser.aliases") as $alias => $real) {
if ($attachment->filename == "{$alias}-report.txt") {
$this->feedName = $real;
break;
}
}
if ($this->isKnownFeed() && $this->isEnabledFeed()) {
// Sanity check
$report = str_replace("\r", "", $attachment->getContent());
if (preg_match_all('/([\\w\\-]+): (.*)[ ]*\\r?\\n/', $report, $matches)) {
$report = array_combine($matches[1], $matches[2]);
if ($this->hasRequiredFields($report) === true) {
// incident has all requirements met, filter and add!
$report = $this->applyFilters($report);
$incident = new Incident();
$incident->source = config("{$this->configBase}.parser.name");
$incident->source_id = false;
$incident->ip = $report['ip'];
$incident->domain = empty($report['uri']) ? false : getDomain($report['uri']);
$incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
$incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
$incident->timestamp = strtotime($report['last_seen']);
$incident->information = json_encode($report);
$this->incidents[] = $incident;
}
} else {
// Unable to build report
$this->warningCount++;
}
}
}
return $this->success();
}
示例15: parse
/**
* Parse attachments
* @return array Returns array with failed or success data
* (See parser-common/src/Parser.php) for more info.
*/
public function parse()
{
if ($this->arfMail !== true) {
$this->feedName = 'default';
// If feed is known and enabled, validate data and save report
if ($this->isKnownFeed() && $this->isEnabledFeed()) {
// To get some more consitency, remove "\r" from the report.
$this->arfMail['report'] = str_replace("\r", "", $this->arfMail['report']);
// Build up the report
preg_match_all("/([\\w\\-]+): (.*)[ ]*\n/m", $this->arfMail['report'], $matches);
$report = array_combine($matches[1], $matches[2]);
// Sanity check
if ($this->hasRequiredFields($report) === true) {
// Grap the domain and user from the authentication results for contact lookup (byDomain)
preg_match("/smtp.auth=(?<user>.*)@(?<domain>.*)/m", $report['Authentication-Results'], $matches);
if (!empty($matches) && is_array($matches) && !empty($matches[0])) {
$report['Source-User'] = $matches['user'];
$report['Source-Domain'] = $matches['domain'];
}
ksort($report);
// incident has all requirements met, filter and add!
$report = $this->applyFilters($report);
$incident = new Incident();
$incident->source = config("{$this->configBase}.parser.name");
$incident->source_id = false;
$incident->ip = $report['Source-IP'];
$incident->domain = empty($report['Source-Domain']) ? false : getDomain($report['Source-Domain']);
$incident->class = config("{$this->configBase}.feeds.{$this->feedName}.class");
$incident->type = config("{$this->configBase}.feeds.{$this->feedName}.type");
$incident->timestamp = strtotime($report['Arrival-Date']);
$incident->information = json_encode($report);
$this->incidents[] = $incident;
}
}
}
return $this->success();
}