Skip to content
This repository was archived by the owner on Jul 17, 2018. It is now read-only.

Commit 8599a82

Browse files
author
Kasai
authored
Merge pull request #1 from ACS-DDS/develop
Modify the CSS along to the User & the Message model.
2 parents ea88cbe + d04dd85 commit 8599a82

File tree

15 files changed

+846
-120
lines changed

15 files changed

+846
-120
lines changed

.classes/channelmapper.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@ class ChannelMapper{
55
public function __construct(){}
66

77
public function createChannel($name){
8-
if($name != "null" && !empty($name)){
9-
if(!file_exists($this->fichier = __DIR__ . "/../.data/db/channels/" . $name . ".csv")){
10-
touch($this->fichier);
11-
}
12-
}
8+
$n = trim($name);
9+
if($n != "null") :
10+
var_dump($n);
11+
if($n != "") :
12+
var_dump($n);
13+
if(!file_exists($this->fichier = __DIR__ . "/../.data/db/channels/" . $n . ".csv")) :
14+
var_dump($n);
15+
touch($this->fichier);
16+
endif;
17+
endif;
18+
endif;
1319
}
1420

1521
public function deleteChannel($name){
16-
if($name != "null"){
17-
unlink(__DIR__ . "/../.data/db/channels/" . $name . ".csv");
18-
}
22+
if($name != "null") :
23+
if($name != "general") :
24+
unlink(__DIR__ . "/../.data/db/channels/" . $name . ".csv");
25+
endif;
26+
endif;
1927
}
2028
}

.classes/controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public function resetMessages(){
8484
return $this->message_mapper->resetMessages();
8585
}
8686

87-
public function deleteMessage($name){
87+
public function deleteMessage($a,$b){
8888
if(!$this->isRegistered()) return;
8989

90-
return $this->message_mapper->deleteMessage($name);
90+
return $this->message_mapper->deleteMessage($a,$b);
9191
}
9292
}

.classes/messagemapper.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public function __construct($channel = "general"){
1010
$this->fichier_temp = __DIR__ . "/../.data/db/channels/" . $channel . "_temp.csv";
1111

1212
if(!file_exists($this->fichier = __DIR__ . "/../.data/db/channels/" . $channel . ".csv")){
13-
touch($this->fichier);
13+
$this->fichier = __DIR__ . "/../.data/db/channels/general.csv";
1414
}
1515
}
1616

@@ -40,16 +40,15 @@ public function getMessages(){
4040
endif;
4141
}
4242

43-
public function deleteMessage($name){
43+
public function deleteMessage($name,$time){
4444
$table = fopen($this->fichier,"r");
4545
$temp_table = fopen($this->fichier_temp,"w");
4646

4747
while(($data = fgetcsv($table,1000)) !== FALSE){
48-
if($data[1] == $name){ // this is if you need the first column in a row
48+
if($data[1] == $name && $data[2] == $time){
4949
continue;
5050
}
5151

52-
var_dump($data);
5352
fputcsv($temp_table,$data);
5453
}
5554

.classes/user.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
<?php
22
class User{
3-
protected $name;
3+
protected $nom;
4+
protected $prenom;
5+
protected $passw;
6+
protected $mail;
7+
protected $image;
48
protected $pseudo;
9+
protected $status;
510

611
public function __construct($array){
7-
$this->name = $array[0];
8-
$this->pseudo = $array[2];
9-
$this->status = $array[3];
12+
$this->nom = $array[0];
13+
$this->prenom = $array[1];
14+
$this->passw = $array[2];
15+
$this->mail = $array[3];
16+
$this->image = $array[4];
17+
$this->pseudo = $array[5];
18+
$this->status = $array[6];
1019
}
1120

1221
public function toArray(){
13-
return array($this->name,$this->pseudo,$this->status);
22+
return array($this->nom,$this->pseudo,$this->status);
1423
}
1524

1625
public function html(){

.classes/usermapper.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public function login($pseudo){
2020
$file_temp = fopen($this->file_temp,"w");
2121

2222
while(false !== ($data = fgetcsv($file))){
23-
if($data[0] == $pseudo){
24-
$data[3] = "logged";
23+
if($data[0] . " " . $data[1] == $pseudo){
24+
$data[6] = "logged";
2525
}
2626
fputcsv($file_temp,$data);
2727
}
@@ -36,8 +36,8 @@ public function logout($pseudo){
3636
$file_temp = fopen($this->file_temp,"w");
3737

3838
while(false !== ($data = fgetcsv($file))){
39-
if($data[0] == $pseudo){
40-
$data[3] = "logged-out";
39+
if($data[0] . " " . $data[1] == $pseudo){
40+
$data[6] = "logged-out";
4141
}
4242
fputcsv($file_temp,$data);
4343
}
@@ -61,20 +61,19 @@ public function getMembers(){
6161
}
6262

6363
public function deleteUser($name){
64-
$table = fopen($this->fichier,"r");
65-
$temp_table = fopen($this->fichier_temp,"w");
64+
$table = fopen($this->file,"r");
65+
$temp_table = fopen($this->file_temp,"w");
6666

6767
while(($data = fgetcsv($table,1000)) !== FALSE){
68-
if($data[2] == $name){ // this is if you need the first column in a row
68+
if($data[2] == $name){
6969
continue;
7070
}
7171

72-
var_dump($data);
7372
fputcsv($temp_table,$data);
7473
}
7574

7675
fclose($table);
7776
fclose($temp_table);
78-
rename($this->fichier_temp,$this->fichier);
77+
rename($this->file_temp,$this->file);
7978
}
8079
}

.data/db/users.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Corentin,8e0d92e98814d1cba96d8848fe709d36f94499ce,Kasai.,logged
1+
acs,dds,8e0d92e98814d1cba96d8848fe709d36f94499ce,acs@ofp.com,azeaze.jpg,acs-dds,logged-out
2+
PERROT,Corentin,8e0d92e98814d1cba96d8848fe709d36f94499ce,kasaidot@gmail.com,img.png,Kasai.,logged

.data/tpl/message.tpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<p class="author"><?=$this->author;?> <!--(?=$this->pseudo;?)--></p>
55
<p class="content"><?=$this->message;?></p>
66
<p class="time"><?=ucfirst(strftime("%A %e %B %Y à %k:%M:%S",$this->date));?></p>
7-
8-
<input type="button" name="<?=$this->message;?>" id="clear" value="" onclick="deleteMessage(this.name);">
7+
<?php if($_SESSION["username"] == "PERROT Corentin" || $_SESSION["username"] == "acs dds") : ?>
8+
<input type="button" name="<?=$this->message;?>" date="<?=$this->date;?>" id="clear" value="" onclick="deleteMessage(this.name,this.attributes[2].value);">
9+
<?php endif;?>
910
</div>

.data/tpl/users.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<li class="<?=$this->status;?>">
22
<a id="pm-<?=$this->pseudo;?>" href="#"><?=$this->pseudo;?></a>
3-
<?php if($_SESSION["username"] == "Corentin") : ?>
3+
<?php if($_SESSION["username"] == "PERROT Corentin" || $_SESSION["username"] == "acs dds") : ?>
44
<input type="button" id="suppr" name="<?=$this->pseudo;?>" onclick="deleteUser(this.name);" value="">
55
<?php endif;?>
66
</li>

.static/css/login.css

Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
.log1{
2-
background-color: #3A3C3D;
3-
width: 50%;
4-
height: 60%;
5-
margin: auto;
6-
margin-top: 8%;
7-
box-shadow: 3px 3px 3px 3px black;
2+
background-color:#3A3C3D;
3+
width:50%;
4+
height:84%;
5+
margin:auto;
6+
margin-top:4%;
7+
box-shadow:3px 3px 3px 3px black;
88
}
99
#login_erg{
1010
text-align: center;
11-
padding-top: 120px;
11+
padding-top:120px;
1212
}
1313
#nom,
1414
#prenom,
@@ -17,74 +17,85 @@
1717
#pseudo,
1818
#img,
1919
#send{
20-
padding: 1%;
21-
outline: none;
22-
border: 2px solid black;
20+
padding:1%;
21+
outline:none;
22+
border:2px solid black;
2323
}
2424
#send{
25-
padding: 1%;
26-
outline: none;
27-
border: 2px solid black;
28-
background-color: #fff;
25+
padding:1%;
26+
outline:none;
27+
border:2px solid black;
28+
background-color:#fff;
2929
}
3030
#send:hover{
31-
background-color: #272829;
32-
border: 2px solid green;
31+
background-color:#272829;
32+
border:2px solid green;
3333
}
3434
#send:active{
35-
background-color: #181919;
35+
background-color:#181919;
3636
}
3737
#btn_guest{
3838
margin-left:75%;
3939
margin-top:14.7%;
4040
}
4141
#log_guest{
42-
padding: 5%;
43-
margin-top: -60px;
44-
border: 2px solid orange;
45-
background-color: #fff;
46-
font-family: 'PT Sans Caption', sans-serif;
47-
outline: none;
42+
padding:5%;
43+
margin-top:-60px;
44+
border:2px solid orange;
45+
background-color:#fff;
46+
font-family:"PT Sans Caption",sans-serif;
47+
outline:none;
4848
}
4949
#log_guest:hover{
50-
border: 2px solid #fff;
51-
background-color: orange;
52-
color: #fff;
50+
border:2px solid #fff;
51+
background-color:orange;
52+
color:#fff;
5353
}
5454
#log_guest:active{
55-
background-color: #916E00;
55+
background-color:#916E00;
5656
}
57-
h3{
58-
margin-bottom: -60px;
59-
padding-top: 30px;
60-
text-align: center;
61-
font-family: 'PT Sans Caption', sans-serif;
62-
color: #fff;
63-
font-size: 25px;
64-
border-bottom: 2px solid #fff;
65-
}
66-
h4{
67-
padding-top: 20px;
68-
margin-bottom: 60px;
69-
text-align: center;
70-
font-family: 'PT Sans Caption', sans-serif;
71-
color: #fff;
72-
font-size: 25px;
73-
border-bottom: 2px solid #fff;
57+
h2#login{
58+
margin-bottom:-60px;
59+
padding-top:30px;
60+
text-align:center;
61+
font-family:"PT Sans Caption",sans-serif;
62+
color:#fff;
63+
font-size:25px;
64+
border-bottom:2px solid #fff;
65+
}
66+
h2#register{
67+
padding-top:20px;
68+
margin-bottom:60px;
69+
text-align:center;
70+
font-family:"PT Sans Caption",sans-serif;
71+
color:#fff;
72+
font-size:25px;
73+
border-bottom:2px solid #fff;
74+
}
75+
h2#error{
76+
text-align:center;
77+
font-family:"PT Sans Caption",sans-serif;
78+
color:#fff;
79+
font-size:25px;
80+
border-bottom:2px solid #fff;
7481
}
7582
#login_ins{
76-
text-align: center;
83+
text-align:center;
7784
}
7885
#p_user{
79-
margin-top: 90px;
80-
margin-left: 55%;
81-
color: #fff;
82-
font-size: 14px;
83-
font-family: 'PT Sans Caption', sans-serif;
86+
margin-top:90px;
87+
margin-left:55%;
88+
color:#fff;
89+
font-size:14px;
90+
font-family:"PT Sans Caption",sans-serif;
8491
}
8592
#copyright{
8693
position:fixed;
8794
bottom:20px;
8895
left:20px;
8996
font-size:10px;
97+
}
98+
p.errors{
99+
text-align:center;
100+
color:white;
90101
}

.static/css/styles.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ a:focus{
2929
pointer-events: auto;
3030
}
3131
.notif>.succes{
32-
background-color:rgba(3, 201, 169, 0.7);
32+
background-color:rgba(3,201,169,0.7);
3333
}
3434
div#footer {
3535
background: transparent;
@@ -43,7 +43,7 @@ div#footer {
4343
margin-top: 50px;
4444
}
4545
div#header {
46-
background:#8A8579;
46+
background:#09a74e;
4747
position:fixed;
4848
top:0;
4949
right:0;
@@ -62,6 +62,9 @@ div#header>h1{
6262
font-family: 'Overlock', cursive;
6363
position:fixed;
6464
}
65+
div#header>h1#ch-name{
66+
font-family:"Ubuntu",sans-serif;
67+
}
6568
div#header>h1:before{
6669
content:"#";
6770
font-family: 'Overlock', cursive;

0 commit comments

Comments
 (0)