corrade-http-templates – Blame information for rev 73

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 eva 1 <?php
2  
73 office 3 require_once('vendor/was/utilities/src/IO/IO.php');
1 eva 4  
5 ###########################################################################
6 ## Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 ##
7 ###########################################################################
8 function storeAvatarConversation($firstname, $lastname, $message, $chatFile, $lines) {
9 ####
10 # I. Initialize an array to store the chat lines.
11 $data = array();
12  
13 ####
14 # II. If the file exists, trim it to the number of chat lines.
15 switch(file_exists($chatFile)) {
16 case TRUE:
17 # Open the chat log and trim the lines to the configured line size.
18 $data = explode(
19 PHP_EOL,
20 atomized_get_contents(
21 $chatFile
22 )
23 );
24 while(sizeof($data) > $lines)
25 array_shift($data);
26 break;
27 }
28  
29 ####
30 # III. Add the line at the end.
31 array_push(
32 $data,
33 empty($lastname) ?
34 sprintf(
35 "[%s:%s] %s : %s",
36 date("H"),
37 date("i"),
38 $firstname, # Don't normalize the name.
39 $message
40 ) :
41 sprintf(
42 "[%s:%s] %s %s : %s",
43 date("H"),
44 date("i"),
45 ucfirst(
46 strtolower(
47 $firstname
48 )
49 ),
50 ucfirst(
51 strtolower(
52 $lastname
53 )
54 ),
55 $message
56 )
57 );
58  
59 ####
60 # IV. Now dump the array to the file.
61 atomized_put_contents(
62 $chatFile,
63 implode(
64 PHP_EOL,
65 $data
66 )
67 );
68 }