本文整理汇总了PHP中Provider::normalizeHostName方法的典型用法代码示例。如果您正苦于以下问题:PHP Provider::normalizeHostName方法的具体用法?PHP Provider::normalizeHostName怎么用?PHP Provider::normalizeHostName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Provider
的用法示例。
在下文中一共展示了Provider::normalizeHostName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: regAction
public function regAction()
{
var_dump(Provider::normalizeHostName('80.misp.ru'));
}
示例2: processRequest
/**
* Process the request
* @param string $os 'Android','iOS' or 'Windows'
*
* TODO: This logic shouldn't be in the model
*/
public static function processRequest($os)
{
if (!isset($_POST['PACKAGE_NAME'])) {
Log::warning('Package name is not set! UAS=' . Request::userAgent() . ' POST=' . Json::encode($_POST));
}
$time = time();
$ip = $_SERVER['REMOTE_ADDR'];
$host = gethostbyaddr($ip);
$country = null;
$provider = null;
if ($host != $ip && strpos($host, '.') !== false) {
$country = strtolower(substr($host, strrpos($host, '.') + 1));
if (strlen($country) != 2) {
$country = null;
}
$provider = \Provider::normalizeHostName($host);
}
Log::notice("Got request time={$time} host={$host} country={$country}");
$values = array('created_at', 'package_name', 'app_version_code', 'app_version_name', 'brand', 'phone_model', 'product', 'stack_trace', 'android_version', 'file_path', 'total_mem_size', 'available_mem_size', 'user_comment', 'user_app_start_date', 'user_crash_date', 'installation_id', 'report_id', 'user_email');
$data = array();
$vals = $_POST;
foreach ($values as $key) {
$key = strtoupper($key);
if (isset($vals[$key])) {
$data[$key] = trim($vals[$key]);
unset($vals[$key]);
}
}
if (isset($data['user_email']) && ($data['user_email'] == 'N/A' || trim($data['user_email']) == '')) {
$data['user_email'] = null;
}
$data['created_at'] = gmdate('Y-m-d H:i:s');
$data['country'] = $country;
$data['provider'] = $provider;
$data['os'] = $os;
$secureCount = 0;
do {
$submit = static::create($data);
if ($submit === false) {
Db::getAdapter()->close();
Log::info("Failed to insert crash submit report for time={$time}, waiting 5 seconds");
set_time_limit(60);
sleep(5);
Db::getAdapter()->reconnect();
Log::info("Retry {$secureCount} insert crash submit report for time={$time}");
}
} while ($submit === false && $secureCount++ < 3);
if ($submit !== false) {
foreach ($vals as $metaName => $metaValue) {
if ($metaValue !== null) {
$metaValue = trim($metaValue);
if (strlen($metaValue) > 0) {
$secureCount = 0;
do {
$dbMeta = $submit->insertMeta(strtolower($metaName), trim($metaValue));
if ($dbMeta === false) {
Db::getAdapter()->close();
Log::info("Failed to insert submit meta for meta={$metaName} time={$time}, waiting 5 seconds");
set_time_limit(60);
sleep(5);
Db::getAdapter()->reconnect();
Log::info("Retry {$secureCount} meta insert for meta={$metaName} time={$time}");
}
} while ($dbMeta === false && $secureCount++ < 2);
}
}
}
}
\Email\Trigger::processRequest($_POST);
Log::notice("Done request time={$time}");
}