本文整理汇总了PHP中Profile::getIp方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::getIp方法的具体用法?PHP Profile::getIp怎么用?PHP Profile::getIp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile::getIp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* {@inheritdoc}
*/
public function write(Profile $profile)
{
$this->cleanup();
$record = array('_id' => $profile->getToken(), 'parent' => $profile->getParentToken(), 'data' => base64_encode(serialize($profile->getCollectors())), 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), 'time' => $profile->getTime());
return $this->getMongo()->update(array('_id' => $profile->getToken()), array_filter($record, function ($v) {
return !empty($v);
}), array('upsert' => true));
}
示例2: write
/**
* Write data associated with the given token.
*
* @param Profile $profile A Profile instance
*
* @return Boolean Write operation successful
*/
public function write(Profile $profile)
{
$this->cleanup();
$record = array('_id' => $profile->getToken(), 'parent' => $profile->getParent() ? $profile->getParent()->getToken() : null, 'data' => serialize($profile->getCollectors()), 'ip' => $profile->getIp(), 'url' => $profile->getUrl(), 'time' => $profile->getTime());
return $this->getMongo()->insert(array_filter($record, function ($v) {
return !empty($v);
}));
}
示例3: write
/**
* {@inheritdoc}
*/
public function write(Profile $profile)
{
$db = $this->initDb();
$args = array(':token' => $profile->getToken(), ':parent' => $profile->getParentToken(), ':data' => base64_encode(serialize($profile->getCollectors())), ':ip' => $profile->getIp(), ':method' => $profile->getMethod(), ':url' => $profile->getUrl(), ':time' => $profile->getTime(), ':created_at' => time());
try {
if ($this->has($profile->getToken())) {
$this->exec($db, 'UPDATE sf_profiler_data SET parent = :parent, data = :data, ip = :ip, method = :method, url = :url, time = :time, created_at = :created_at WHERE token = :token', $args);
} else {
$this->exec($db, 'INSERT INTO sf_profiler_data (token, parent, data, ip, method, url, time, created_at) VALUES (:token, :parent, :data, :ip, :method, :url, :time, :created_at)', $args);
}
$this->cleanup();
$status = true;
} catch (\Exception $e) {
$status = false;
}
$this->close($db);
return $status;
}
示例4: write
/**
* {@inheritdoc}
*/
public function write(Profile $profile)
{
$file = $this->getFilename($profile->getToken());
$profileIndexed = is_file($file);
if (!$profileIndexed) {
// Create directory
$dir = dirname($file);
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
}
}
// Store profile
$data = array('token' => $profile->getToken(), 'parent' => $profile->getParentToken(), 'children' => array_map(function ($p) {
return $p->getToken();
}, $profile->getChildren()), 'data' => $profile->getCollectors(), 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), 'time' => $profile->getTime());
if (false === file_put_contents($file, serialize($data))) {
return false;
}
if (!$profileIndexed) {
// Add to index
if (false === ($file = fopen($this->getIndexFilename(), 'a'))) {
return false;
}
fputcsv($file, array($profile->getToken(), $profile->getIp(), $profile->getMethod(), $profile->getUrl(), $profile->getTime(), $profile->getParentToken()));
fclose($file);
}
return true;
}
示例5: write
/**
* {@inheritdoc}
*/
public function write(Profile $profile)
{
$data = array('token' => $profile->getToken(), 'parent' => $profile->getParentToken(), 'children' => array_map(function ($p) {
return $p->getToken();
}, $profile->getChildren()), 'data' => $profile->getCollectors(), 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), 'time' => $profile->getTime());
$profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken()));
if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime)) {
if (!$profileIndexed) {
// Add to index
$indexName = $this->getIndexName();
$indexRow = implode("\t", array($profile->getToken(), $profile->getIp(), $profile->getMethod(), $profile->getUrl(), $profile->getTime(), $profile->getParentToken(), $profile->getStatusCode())) . "\n";
return $this->appendValue($indexName, $indexRow, $this->lifetime);
}
return true;
}
return false;
}
示例6: write
/**
* Write data associated with the given token.
*
* @param Profile $profile A Profile instance
*
* @return Boolean Write operation successful
*/
public function write(Profile $profile)
{
return $this->getMongo()->insert(array('token' => $profile->getToken(), 'ip' => $profile->getIp(), 'url' => $profile->getUrl() === null ? '' : $profile->getUrl(), 'profile' => serialize($profile)));
}