corrade-http-templates – Rev 73
?pathlinks?
<?php
require_once('vendor/was/utilities/src/IO/IO.php');
###########################################################################
## Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 ##
###########################################################################
function storeAvatarConversation($firstname, $lastname, $message, $chatFile, $lines) {
####
# I. Initialize an array to store the chat lines.
$data = array();
####
# II. If the file exists, trim it to the number of chat lines.
switch(file_exists($chatFile)) {
case TRUE:
# Open the chat log and trim the lines to the configured line size.
$data = explode(
PHP_EOL,
atomized_get_contents(
$chatFile
)
);
while(sizeof($data) > $lines)
array_shift($data);
break;
}
####
# III. Add the line at the end.
array_push(
$data,
empty($lastname) ?
sprintf(
"[%s:%s] %s : %s",
date("H"),
date("i"),
$firstname, # Don't normalize the name.
$message
) :
sprintf(
"[%s:%s] %s %s : %s",
date("H"),
date("i"),
ucfirst(
strtolower(
$firstname
)
),
ucfirst(
strtolower(
$lastname
)
),
$message
)
);
####
# IV. Now dump the array to the file.
atomized_put_contents(
$chatFile,
implode(
PHP_EOL,
$data
)
);
}
Generated by GNU Enscript 1.6.5.90.