本文整理汇总了PHP中JFile::append方法的典型用法代码示例。如果您正苦于以下问题:PHP JFile::append方法的具体用法?PHP JFile::append怎么用?PHP JFile::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFile
的用法示例。
在下文中一共展示了JFile::append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addEntry
/**
* Method to add an entry to the log.
*
* @param JLogEntry $entry The log entry object to add to the log.
*
* @return boolean True on success.
*
* @since 11.1
* @throws RuntimeException
*/
public function addEntry(JLogEntry $entry)
{
// Initialise the file if not already done.
$this->initFile();
// Set some default field values if not already set.
if (!isset($entry->clientIP)) {
// Check for proxies as well.
if (isset($_SERVER['REMOTE_ADDR'])) {
$entry->clientIP = $_SERVER['REMOTE_ADDR'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$entry->clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
$entry->clientIP = $_SERVER['HTTP_CLIENT_IP'];
}
}
// If the time field is missing or the date field isn't only the date we need to rework it.
if (strlen($entry->date) != 10 || !isset($entry->time)) {
// Get the date and time strings in GMT.
$entry->datetime = $entry->date->toISO8601();
$entry->time = $entry->date->format('H:i:s', false);
$entry->date = $entry->date->format('Y-m-d', false);
}
// Get a list of all the entry keys and make sure they are upper case.
$tmp = array_change_key_case(get_object_vars($entry), CASE_UPPER);
// Decode the entry priority into an English string.
$tmp['PRIORITY'] = $this->priorities[$entry->priority];
// Fill in field data for the line.
$line = $this->format;
foreach ($this->fields as $field) {
$line = str_replace('{' . $field . '}', isset($tmp[$field]) ? $tmp[$field] : '-', $line);
}
// Write the new entry to the file.
$line .= "\n";
if (!JFile::append($this->path, $line)) {
throw new RuntimeException('Cannot write to log file.');
}
}