first commit
This commit is contained in:
parent
735274944f
commit
32f3e0c785
43 changed files with 10512 additions and 0 deletions
79
includes/chatLoad.php
Normal file
79
includes/chatLoad.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
// $timestamp = DateTime::createFromFormat('U.u', microtime(true));
|
||||
// echo $timestamp->format("m-d-Y H:i:s.u");
|
||||
$micro_date = microtime();
|
||||
$date_array = explode(" ",$micro_date);
|
||||
$date = date("Y-m-d H:i:s",$date_array[1]);
|
||||
$timestamp = "$date:" . $date_array[0];
|
||||
file_put_contents('lastTimecode.txt', $timestamp);
|
||||
// echo "$timestamp";
|
||||
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
// $date = date('m/d/Y h:i:s a', time());
|
||||
$date = date('d.m.Y - H:i', time());
|
||||
|
||||
// PUT A W IN PLACE OF THE A TO OVERRIDE FILE INSTEAD OF ADDING AT THE END !!
|
||||
$chatFile = fopen("chatContent.php", "a") or die("Unable to open file!");
|
||||
|
||||
$message = $_POST['message'];
|
||||
$chatName = $_POST['chatName'];
|
||||
|
||||
$colors = array("antiquewhite","aqua","aquamarine","azure","beige","bisque","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","crimson","cyan","darkcyan","darkgoldenrod","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkturquoise","darkviolet","deeppink","deepskyblue","dodgerblue","firebrick","forestgreen","fuchsia","gainsboro","gold","goldenrod","green","hotpink","indianred","khaki","lawngreen","lightcoral","lightcyan");
|
||||
|
||||
$rand_colorIndex = array_rand($colors, 1);
|
||||
|
||||
$rand_color = $colors[$rand_colorIndex];
|
||||
|
||||
|
||||
|
||||
$knownNames = array("leo");
|
||||
$personalColor = array("leo" => "green");
|
||||
|
||||
$knownNames = json_decode(file_get_contents('knownNames.txt'), true);
|
||||
|
||||
$personalColor = json_decode(file_get_contents('personalColors.txt'), true);
|
||||
|
||||
|
||||
|
||||
if ($chatName == ""){
|
||||
$chatName = "anonym";
|
||||
$name_color = "grey";
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
if (in_array($chatName, $knownNames)) {
|
||||
$name_color = $personalColor[$chatName];
|
||||
}
|
||||
|
||||
else {
|
||||
$name_color = $rand_color;
|
||||
array_push($knownNames, $chatName);
|
||||
$personalColor += [$chatName => $name_color];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$insert = "<div class='message'><span class='chatName' style='color: $name_color !important'>$chatName</span><span class='mesTime'> | $date</span><br>". $message ."</div><br> \n";
|
||||
fwrite($chatFile, $insert);
|
||||
fclose($chatFile);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
file_put_contents('knownNames.txt', json_encode($knownNames));
|
||||
|
||||
file_put_contents('personalColors.txt', json_encode($personalColor));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue