Browse Source

Update chat design, fix header, actually use AJAX

master
OliverParoczai 3 years ago
parent
commit
0462a3def1
  1. 29
      SQL/paredu_chat.sql
  2. 16
      admin/eventupload.php
  3. 34
      chat/chat_script.js
  4. 14
      chat/index.php
  5. 54
      chat/php/model.php
  6. 37
      chat/script.js
  7. 47
      css/chat.css
  8. 9
      css/style.css
  9. 8
      event.php
  10. 6
      events.php
  11. 40
      header.php
  12. 8
      school.php
  13. 6
      schools.php
  14. 30
      setup.php

29
SQL/paredu_chat.sql

@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/ -- https://www.phpmyadmin.net/
-- --
-- Host: localhost -- Host: localhost
-- Generation Time: Apr 10, 2021 at 01:57 PM -- Generation Time: Apr 15, 2021 at 01:55 PM
-- Server version: 10.3.27-MariaDB-0+deb10u1 -- Server version: 10.3.27-MariaDB-0+deb10u1
-- PHP Version: 7.3.27-1~deb10u1 -- PHP Version: 7.3.27-1~deb10u1
@ -32,7 +32,7 @@ CREATE TABLE `chats` (
`chat_id` int(4) NOT NULL, `chat_id` int(4) NOT NULL,
`chat_user_id` int(3) NOT NULL, `chat_user_id` int(3) NOT NULL,
`chat_user2_id` int(3) NOT NULL, `chat_user2_id` int(3) NOT NULL,
`chat_message` text NOT NULL, `chat_message` text CHARACTER SET utf8 COLLATE utf8_hungarian_ci NOT NULL,
`chat_sent_by` int(1) NOT NULL, `chat_sent_by` int(1) NOT NULL,
`chat_date` datetime NOT NULL `chat_date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
@ -69,6 +69,19 @@ CREATE TABLE `chats_to` (
-- -------------------------------------------------------- -- --------------------------------------------------------
--
-- Table structure for table `notifications`
--
CREATE TABLE `notifications` (
`id` int(20) NOT NULL,
`userid` bigint(20) NOT NULL,
`fromuserid` bigint(20) NOT NULL,
`unread` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
-- --
-- Table structure for table `users` -- Table structure for table `users`
-- --
@ -103,6 +116,12 @@ ALTER TABLE `chats_from`
ALTER TABLE `chats_to` ALTER TABLE `chats_to`
ADD PRIMARY KEY (`chat_id`); ADD PRIMARY KEY (`chat_id`);
--
-- Indexes for table `notifications`
--
ALTER TABLE `notifications`
ADD PRIMARY KEY (`id`);
-- --
-- Indexes for table `users` -- Indexes for table `users`
-- --
@ -131,6 +150,12 @@ ALTER TABLE `chats_from`
ALTER TABLE `chats_to` ALTER TABLE `chats_to`
MODIFY `chat_id` int(4) NOT NULL AUTO_INCREMENT; MODIFY `chat_id` int(4) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `notifications`
--
ALTER TABLE `notifications`
MODIFY `id` int(20) NOT NULL AUTO_INCREMENT;
-- --
-- AUTO_INCREMENT for table `users` -- AUTO_INCREMENT for table `users`
-- --

16
admin/eventupload.php

@ -14,28 +14,28 @@
if($type == 2){ if($type == 2){
$ownertype = 2; $ownertype = 2;
$ownerid = substr($_SESSION["selectedcompany"], 1); $ownerid = substr($_SESSION["selectedcompany"], 1);
$schjson = json_decode(file_get_contents($url."/API/request.php?type=companies&id=".$ownerid), true); $schjson = json_decode(file_get_contents($siteurl."/API/request.php?type=companies&id=".$ownerid), true);
}else{ }else{
$ownertype = 1; $ownertype = 1;
$ownerid = substr($_SESSION["selectedschool"], 1); $ownerid = substr($_SESSION["selectedschool"], 1);
$schjson = json_decode(file_get_contents($url."/API/request.php?type=schools&id=".$ownerid), true); $schjson = json_decode(file_get_contents($siteurl."/API/request.php?type=schools&id=".$ownerid), true);
} }
$json = json_decode(file_get_contents($url."/API/request.php?type=events&ownertype=".$ownertype."&ownerid=".$ownerid), true); $json = json_decode(file_get_contents($siteurl."/API/request.php?type=events&ownertype=".$ownertype."&ownerid=".$ownerid), true);
$userjson = json_decode(file_get_contents($url."/API/request.php?type=user&id=".$userid), true); $userjson = json_decode(file_get_contents($siteurl."/API/request.php?type=user&id=".$userid), true);
if(!isset($json["response"])){ if(!isset($json["response"])){
echo "<div class='list-group'>"; echo "<div class='list-group'>";
for($i = count($json)-1; $i>=0; $i--) { for($i = count($json)-1; $i>=0; $i--) {
if($json[$i]["title"] != ""){ if($json[$i]["title"] != ""){
#echo '<a class="listitem list-group-item waves-effect"><img class="smallimg listitemimg squircle" src="'.$url.'/API/request.php?type=image&subtype=eventcategory&category='.$json[$i]["category"].'"><b>'.$json[$i]["title"].'</b><br>'.$json[$i]["description"].'</a>'; #echo '<a class="listitem list-group-item waves-effect"><img class="smallimg listitemimg squircle" src="'.$siteurl.'/API/request.php?type=image&subtype=eventcategory&category='.$json[$i]["category"].'"><b>'.$json[$i]["title"].'</b><br>'.$json[$i]["description"].'</a>';
//echo '<a class="listitem list-group-item waves-effect" href="'.$curdir.'event.php?id='.$json[$i]["eventid"].'"><table><td><img class="smallimg listitemimg squircle" src="'.$url.'/API/request.php?type=image&subtype=eventcategory&category='.$json[$i]["category"].'"><td><td><b>'.$json[$i]["title"].'</b><br>'.$selschvals["name"].'<br>'.$json[$i]["description"].'</b><td></table></a>'; //echo '<a class="listitem list-group-item waves-effect" href="'.$curdir.'event.php?id='.$json[$i]["eventid"].'"><table><td><img class="smallimg listitemimg squircle" src="'.$siteurl.'/API/request.php?type=image&subtype=eventcategory&category='.$json[$i]["category"].'"><td><td><b>'.$json[$i]["title"].'</b><br>'.$selschvals["name"].'<br>'.$json[$i]["description"].'</b><td></table></a>';
echo ' echo '
<div class="panel panel-default panel-post"> <div class="panel panel-default panel-post">
<div class="panel-heading"> <div class="panel-heading">
<div class="media"> <div class="media">
<div class="media-left"> <div class="media-left">
<a href="#">'; <a href="#">';
if($json[$i]["uploadedas_userid"] != ""){ echo '<img class="fixsizeimg42" src="'.$url.'/API/request.php?type=image&subtype=user&id='.$userid.'">'; if($json[$i]["uploadedas_userid"] != ""){ echo '<img class="fixsizeimg42" src="'.$siteurl.'/API/request.php?type=image&subtype=user&id='.$userid.'">';
}else{ echo '<img class="fixsizeimg42" src="'.$url.'/API/request.php?type=image&subtype=school&id='.$ownerid.'">'; } }else{ echo '<img class="fixsizeimg42" src="'.$siteurl.'/API/request.php?type=image&subtype=school&id='.$ownerid.'">'; }
echo'</a> echo'</a>
</div> </div>
<div class="media-body"> <div class="media-body">

34
chat/chat_script.js

@ -21,7 +21,7 @@ $(document).ready(function (){
}); });
let loadMessages= function(user1_id, user2_id){ let loadMessages= function(user1_id, user2_id){
chat_history.empty(); //chat_history.empty();
$.ajax({ url:'php/get_messages.php', $.ajax({ url:'php/get_messages.php',
method: 'POST', method: 'POST',
dataType:'json', dataType:'json',
@ -31,14 +31,15 @@ $(document).ready(function (){
}, },
dataType: 'json', dataType: 'json',
success: function(result){ success: function(result){
chat_history.empty();
if(result != ''){ if(result != ''){
for(let i=0; i<result.length; i++){ for(let i=0; i<result.length; i++){
$(".chat_history_none").remove(); $(".chat_history_none").remove();
if(result[i].chat_sent_by == user1_id){ if(result[i].chat_sent_by == user1_id){
let item='<div class="chat_history_chat_sent"><h4>'+result[i].chat_message+'</h4></div>'; let item='<div class="chat_history_chat_sent"><small>'+result[i].chat_date+'</small><h4>'+result[i].chat_message+'</h4></div>';
chat_history.append(item); chat_history.append(item);
} else { } else {
let item='<div class="chat_history_chat_received"><h4>'+result[i].chat_message+'</h4></div>'; let item='<div class="chat_history_chat_received"><small>'+result[i].chat_date+'</small><h4>'+result[i].chat_message+'</h4></div>';
chat_history.append(item); chat_history.append(item);
} }
} }
@ -64,7 +65,7 @@ $(document).ready(function (){
success: function(result){ success: function(result){
let parsed= jQuery.parseJSON(result); let parsed= jQuery.parseJSON(result);
$(".chat_history_none").remove(); $(".chat_history_none").remove();
let item='<div class="chat_history_chat_sent"><h4>'+parsed.message+'</h4></div>'; let item='<div class="chat_history_chat_sent"><small>'+parsed.time+'</small><h4>'+parsed.message+'</h4></div>';
chat_history.append(item); chat_history.append(item);
}, },
@ -75,7 +76,7 @@ $(document).ready(function (){
}); });
message.val(''); message.val('');
} }
let getUsers= function(){ let getUsers= function(option){
$.ajax({url:'php/get_users.php', $.ajax({url:'php/get_users.php',
method:'POST', method:'POST',
dataType: 'json', dataType: 'json',
@ -84,13 +85,28 @@ $(document).ready(function (){
}, },
success: function(data){ success: function(data){
for(let i=0; i<data.length; i++) { for(let i=0; i<data.length; i++) {
let item= '<div class="users_user listitem list-group-item waves-effect" id="'+data[i].id+'"><span class="users_user_pic"><img src="'+data[i].userimg+'" class="listitemimg circle"></span><span class="users_user_info">'+data[i].name+'</span><span class="users_user_id">'+data[i].id+'</span></div>'; if(data[i].unread > 0){
if(option === 1){
let item = '<span class="users_user_info" id="user'+data[i].id+'"><b>'+data[i].name+' ('+data[i].unread+' új)</b></span>';
$('#user'+data[i].id).replaceWith(item);
}else{
let item = '<div class="users_user listitem list-group-item waves-effect" id="'+data[i].id+'" onClick="scrollDown();"><span class="users_user_pic"><img src="'+data[i].userimg+'" class="listitemimg circle"></span><span class="users_user_info" id="user'+data[i].id+'"><b>'+data[i].name+' ('+data[i].unread+' új)</b></span><span class="users_user_id">'+data[i].id+'</span></div>';
users.append(item);
}
}else{
if(option === 1){
let item = '<span class="users_user_info" id="user'+data[i].id+'">'+data[i].name+'</span>';
$('#user'+data[i].id).replaceWith(item);
}else{
let item = '<div class="users_user listitem list-group-item waves-effect" id="'+data[i].id+'" onClick="scrollDown();"><span class="users_user_pic"><img src="'+data[i].userimg+'" class="listitemimg circle"></span><span class="users_user_info" id="user'+data[i].id+'">'+data[i].name+'</span><span class="users_user_id">'+data[i].id+'</span></div>';
users.append(item); users.append(item);
} }
}
}
let single_user= $('.users_user'); let single_user= $('.users_user');
for(let i=0; i<single_user.length; i++){ for(let i=0; i<single_user.length; i++){
$(single_user[i]).click(function(e){ $(single_user[i]).click(function(e){
message.prop('disabled', false); message.prop('disabled', false);
let pic= e.target.firstChild.firstChild.src; let pic= e.target.firstChild.firstChild.src;
let id = e.target.id; let id = e.target.id;
@ -107,6 +123,10 @@ $(document).ready(function (){
}); });
} }
getUsers(); getUsers();
setInterval(function() {
getUsers(1);
loadMessages(user_id.html(), document.getElementsByClassName("chat_history_user_id")[0].innerHTML);
}, 3000);
send.click(function(e){ send.click(function(e){
e.preventDefault(); e.preventDefault();
sendMessage(user_id.html(),chat_id.html()); sendMessage(user_id.html(),chat_id.html());

14
chat/index.php

@ -15,9 +15,9 @@
<div class="chat_history_user_id">0</div> <div class="chat_history_user_id">0</div>
</div> </div>
<div class="chat_history_chat"> <div class="chat_history_chat">
<div align="center"> <div class="text-center">
<h4>ParEdu Hírek</h4> <h4>Chat</h4>
<p>Még tesztelés alatt vagyunk, a befejezéséig a hírek az git oldalon találhatóak</p> <p>A beszélgetés megkezdéséhez kattintson az adott felhasználóra</p>
</div> </div>
</div> </div>
</div> </div>
@ -28,7 +28,7 @@
<textarea class="form-control no-resize message auto-growth" id="new_message" disabled=true rows="1" placeholder="Üzenet" style="background-color: rgba(0,0,0,0.0);"></textarea> <textarea class="form-control no-resize message auto-growth" id="new_message" disabled=true rows="1" placeholder="Üzenet" style="background-color: rgba(0,0,0,0.0);"></textarea>
</div> </div>
</div> </div>
<button type="submit" id="btn-send" class="btn bg-teal waves-effect" disabled=true><i class="material-icons">send</i></button> <button type="submit" id="btn-send" onClick="scrollDown();" class="btn bg-teal waves-effect" disabled=true><i class="material-icons">send</i></button>
</form> </form>
</div> </div>
</div> </div>
@ -39,5 +39,11 @@
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
autosize($('textarea.auto-growth')); autosize($('textarea.auto-growth'));
}); });
function scrollDown(){
setTimeout(function(){
document.querySelectorAll(".chat_history_chat")[0].scrollTop=document.querySelectorAll(".chat_history_chat")[0].scrollHeight;
}, 300);
}
</script> </script>
<?php include "../footer.php"; ?> <?php include "../footer.php"; ?>

54
chat/php/model.php

@ -20,10 +20,10 @@ class Connection {
class Model extends Connection { class Model extends Connection {
public function getUsers($id){ public function getUsers($id){
include "../../creds.php";
//$sql="SELECT * FROM users WHERE user_id != ?"; //$sql="SELECT * FROM users WHERE user_id != ?";
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://".$_SERVER['HTTP_HOST']."/paredu";
$pdo = $this->connect(); $pdo = $this->connect();
$pdo->exec('USE paredu'); $pdo->exec('USE '.$dbname);
$sql = "SELECT * FROM `auth` WHERE `id` != ?"; $sql = "SELECT * FROM `auth` WHERE `id` != ?";
$stmt=$pdo->prepare($sql); $stmt=$pdo->prepare($sql);
$stmt->execute([$id]); $stmt->execute([$id]);
@ -33,20 +33,51 @@ class Model extends Connection {
for($i = 0; $i<count($fetch); $i++){ for($i = 0; $i<count($fetch); $i++){
$sndarray = array(); $sndarray = array();
$sndarray["id"] = $fetch[$i]["id"]; $sndarray["id"] = $fetch[$i]["id"];
if($fetch[$i]["fullname"] != 0){ if($fetch[$i]["fullname"] != ""){
$sndarray["name"] = $fetch[$i]["fullname"]; $sndarray["name"] = $fetch[$i]["fullname"];
}else{ }else{
$sndarray["name"] = $fetch[$i]["username"]; $sndarray["name"] = $fetch[$i]["username"];
} }
$sndarray["userimg"] = $url."/API/request.php?type=image&subtype=user&id=".$fetch[$i]["id"]; $sndarray["userimg"] = $siteurl."/API/request.php?type=image&subtype=user&id=".$fetch[$i]["id"];
$pdo->exec('USE '.$dbname."_chat");
$sql = "SELECT * FROM notifications WHERE userid = ? AND fromuserid = ?; ";
$stmtcheck=$pdo->prepare($sql);
$stmtcheck->execute([$id, $fetch[$i]["id"]]);
$resultcheck = $stmtcheck->fetchAll();
if($stmtcheck && $stmtcheck->rowCount() > 0){
$sndarray["unread"] = $resultcheck[0]["unread"];
}else{
$sndarray["unread"] = 0;
}
$result[$i] = $sndarray; $result[$i] = $sndarray;
} }
return $result; return $result;
} }
public function insertChat($id,$user2_id, $message, $time){ public function insertChat($id,$user2_id, $message, $time){
$conn = $this->connect();
$sql = "SELECT * FROM notifications WHERE userid = ? AND fromuserid = ?; ";
$stmtcheck=$conn->prepare($sql);
$stmtcheck->execute([$user2_id, $id]);
$result = $stmtcheck->fetchAll();
if($stmtcheck && $stmtcheck->rowCount() > 0){
$unread = $result[0]["unread"];
}
if(isset($unread)){
$sql = "UPDATE notifications SET unread = ? WHERE userid = ? AND fromuserid = ?;";
$stmtinsert=$conn->prepare($sql);
$stmtinsert->execute([($unread+1), $user2_id, $id]);
}else{
$sql="INSERT INTO notifications (userid, fromuserid, unread) VALUES (?, ?, 1);";
$stmtinsert=$conn->prepare($sql);
$stmtinsert->execute([$user2_id, $id]);
}
$sql="INSERT INTO chats (chat_user_id, chat_user2_id, chat_message, chat_sent_by, chat_date) VALUES(?,?,?,?,?)"; $sql="INSERT INTO chats (chat_user_id, chat_user2_id, chat_message, chat_sent_by, chat_date) VALUES(?,?,?,?,?)";
$stmt=$this->connect()->prepare($sql); $stmt=$conn->prepare($sql);
$stmt->execute([$id,$user2_id, $message, $id, $time]); $stmt->execute([$id,$user2_id, $message, $id, $time]);
$result= $stmt->fetchAll(); $result= $stmt->fetchAll();
return $result; return $result;
@ -61,8 +92,19 @@ class Model extends Connection {
} }
public function getChats($id1, $id2){ public function getChats($id1, $id2){
$conn = $this->connect();
$sql = "SELECT * FROM notifications WHERE userid = ? AND fromuserid = ?";
$stmtcheck=$conn->prepare($sql);
$stmtcheck->execute([$id1, $id2]);
$result = $stmtcheck->fetchAll();
if($stmtcheck->rowCount() > 0){
$sql = "DELETE FROM notifications WHERE userid = ? AND fromuserid = ?";
$stmtinsert=$conn->prepare($sql);
$stmtinsert->execute([$id1, $id2]);
}
$sql="SELECT * FROM chats WHERE chat_user_id = ? and chat_user2_id=? OR chat_user_id=? and chat_user2_id=?"; $sql="SELECT * FROM chats WHERE chat_user_id = ? and chat_user2_id=? OR chat_user_id=? and chat_user2_id=?";
$stmt=$this->connect()->prepare($sql); $stmt=$conn->prepare($sql);
$stmt->execute([$id1, $id2, $id2, $id1]); $stmt->execute([$id1, $id2, $id2, $id1]);
$result=$stmt->fetchAll(); $result=$stmt->fetchAll();
return $result; return $result;

37
chat/script.js

@ -1,37 +0,0 @@
$(document).ready( function(){
let username_login= $('#user_name');
let pass_login= $('#pass');
let login= $('#btn-login');
let login_message= $('#login_message');
let users_id_checked;
login.click(function(e){
e.preventDefault();
$.ajax({ url:"php/get_this_user.php",
dataType: 'json',
data: {
name: username_login.val(),
pass: pass_login.val()
},
method: 'POST',
success: function(result){
if(result =='Please enter a valid info') {
login_message.html(result);
login_message.css({'color': 'red', 'border': '1px solid', 'border-color': 'black', 'background-color': 'black'});
}
else {
window.location.href= 'chat.php';
}
},
error: function(result){
console.log(result);
}
})
})
});

47
css/chat.css

@ -1,11 +1,16 @@
html, body {
margin: 0;
}
.chat-container { .chat-container {
width: 100%; width: 100%;
height: 500px; } height: calc(100vh - 70px);
margin: 0; }
.chat-container .user_id { .chat-container .user_id {
display: none; } display: none; }
.chat-container .users { .chat-container .users {
height: 100%; max-height: 100%;
padding-right: 0; padding-right: 0;
margin: 0 0 0 0;
} }
.chat-container .users .users_user { .chat-container .users .users_user {
justify-content: space-between; justify-content: space-between;
@ -16,7 +21,7 @@
visibility: hidden; visibility: hidden;
pointer-events: none; } pointer-events: none; }
.chat-container .users .users_user .users_user_pic { .chat-container .users .users_user .users_user_pic {
height: 100; height: 100%;
width: 20%; width: 20%;
pointer-events: none; } pointer-events: none; }
@ -29,10 +34,13 @@
background-color: lime; } background-color: lime; }
.chat-container .users .users_user:hover { .chat-container .users .users_user:hover {
background-color: #a2c6eb; } background-color: #a2c6eb; }
.chat-container .users .users_userold {
display: none;
}
.chat-container .chat { .chat-container .chat {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 500px; } height: 100%; }
.chat-container .chat .chat_history { .chat-container .chat .chat_history {
width: 100%; width: 100%;
height: 80%; height: 80%;
@ -46,8 +54,8 @@
color: blue; } color: blue; }
.chat-container .chat .chat_history .chat_history_user { .chat-container .chat .chat_history .chat_history_user {
width: 100%; width: 100%;
height: 70px; height: 67px;
background-color: #455a64; background-color: #3949ab;
display: flex; display: flex;
justify-content: space-between; } justify-content: space-between; }
.chat-container .chat .chat_history .chat_history_user .chat_history_user_pic { .chat-container .chat .chat_history .chat_history_user .chat_history_user_pic {
@ -57,22 +65,24 @@
-webkit-background-size: cover; -webkit-background-size: cover;
-moz-background-size: cover; -moz-background-size: cover;
-o-background-size: cover; -o-background-size: cover;
height:100%; height:70px;
width: 70px; width: 70px;
margin-left: 15px; } margin: 0;
scale: 0.7; }
.chat-container .chat .chat_history .chat_history_user .chat_history_user_info { .chat-container .chat .chat_history .chat_history_user .chat_history_user_info {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
color: white; color: white;
font-weight: bold; } font-weight: bold;
margin-right: 70px; }
.chat-container .chat .chat_history .chat_history_user .chat_history_user_id { .chat-container .chat .chat_history .chat_history_user .chat_history_user_id {
visibility: hidden; } visibility: hidden; }
.chat-container .chat .chat_history .chat_history_chat { .chat-container .chat .chat_history .chat_history_chat {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
height: 80%; height: 100%;
overflow-y: scroll; overflow-y: scroll;
background-color: #fafafa; } background-color: #fafafa; }
.chat-container .chat .chat_history .chat_history_chat .chat_history_chat_sent { .chat-container .chat .chat_history .chat_history_chat .chat_history_chat_sent {
@ -80,28 +90,31 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-self: flex-end; align-self: flex-end;
background-color: #26a69a; background-color: #00ff99;
border-radius: 10px; border-radius: 4px;
padding: 5px; padding: 5px;
margin-top: 5px; margin-top: 5px;
margin-right: 15px;} margin-right: 15px;
word-wrap: break-word; }
.chat-container .chat .chat_history .chat_history_chat .chat_history_chat_received { .chat-container .chat .chat_history .chat_history_chat .chat_history_chat_received {
width: 45%; width: 45%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-self: flex-start; align-self: flex-start;
background-color: #26c6da; background-color: #56b0ff;
border-radius: 10px; border-radius: 4px;
padding: 5px; padding: 5px;
margin-top: 5px; margin-top: 5px;
margin-left: 15px; } margin-left: 15px;
word-wrap: break-word; }
.chat-container .chat .chat_box { .chat-container .chat .chat_box {
width: 100%; width: 100%;
height: 20%; height: 20%;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background-color: #fafafa; } background-color: #fafafa;
border-top: 1px grey solid; }
.chat-container .chat .chat_box form { .chat-container .chat .chat_box form {
display: flex; display: flex;
align-items: center; align-items: center;

9
css/style.css

@ -33,17 +33,18 @@
} }
section.fullscreencontent { section.fullscreencontent {
margin: 50px 0px 0 315px; margin: 50px 0px 0 300px;
margin-left: 315px; margin-left: 300px;
-moz-transition: 0.5s; -moz-transition: 0.5s;
-o-transition: 0.5s; -o-transition: 0.5s;
-webkit-transition: 0.5s; -webkit-transition: 0.5s;
transition: 0.5s; transition: 0.5s;
display: flex;
flex: 1;
} }
.ls-closed section.fullscreencontent { .ls-closed section.fullscreencontent {
margin-left: 15px; margin-left: 0px; }
}
.fixsizeimg42 { .fixsizeimg42 {
height: 42px; height: 42px;

8
event.php

@ -2,8 +2,8 @@
ini_set("allow_url_fopen", 1); ini_set("allow_url_fopen", 1);
$sqldependent = true; $sqldependent = true;
include "header.php"; include "header.php";
$json = json_decode(file_get_contents($url."/API/request.php?type=events"), true); $json = json_decode(file_get_contents($siteurl."/API/request.php?type=events"), true);
$jsonlang = json_decode(file_get_contents($url."/API/request.php?type=string&subtype=school"), true); $jsonlang = json_decode(file_get_contents($siteurl."/API/request.php?type=string&subtype=school"), true);
for($eventid = 0; $eventid<count($json); $eventid++) { for($eventid = 0; $eventid<count($json); $eventid++) {
if($json[$eventid]["eventid"] == $_GET["id"]){ if($json[$eventid]["eventid"] == $_GET["id"]){
break; break;
@ -12,10 +12,10 @@ for($eventid = 0; $eventid<count($json); $eventid++) {
if($json[$eventid]["ownertype"] == 2){ if($json[$eventid]["ownertype"] == 2){
$iscompany = true; $iscompany = true;
$viewsql = "SELECT * FROM `companies` WHERE `id` = ".$json[$eventid]["ownerid"]; $viewsql = "SELECT * FROM `companies` WHERE `id` = ".$json[$eventid]["ownerid"];
$profimg = $url."/API/request.php?type=image&subtype=company&id=".$json[$eventid]["ownerid"]; $profimg = $siteurl."/API/request.php?type=image&subtype=company&id=".$json[$eventid]["ownerid"];
}else{ }else{
$viewsql = "SELECT * FROM `schools` WHERE `id` = ".$json[$eventid]["ownerid"]; $viewsql = "SELECT * FROM `schools` WHERE `id` = ".$json[$eventid]["ownerid"];
$profimg = $url."/API/request.php?type=image&subtype=school&id=".$json[$eventid]["ownerid"]; $profimg = $siteurl."/API/request.php?type=image&subtype=school&id=".$json[$eventid]["ownerid"];
} }
$result = $conn->query($viewsql); $result = $conn->query($viewsql);
if ($result == TRUE) { if ($result == TRUE) {

6
events.php

@ -8,7 +8,7 @@
<div class="row clearfix"> <div class="row clearfix">
<div class="list-group"> <div class="list-group">
<?php <?php
$json = json_decode(file_get_contents($url."/API/request.php?type=events"), true); $json = json_decode(file_get_contents($siteurl."/API/request.php?type=events"), true);
if(!isset($json["response"])){ if(!isset($json["response"])){
for($i = count($json)-1; $i>=0; $i--) { for($i = count($json)-1; $i>=0; $i--) {
if($json[$i]["title"] != ""){ if($json[$i]["title"] != ""){
@ -22,7 +22,7 @@
if (!empty($result) && $result->num_rows > 0) { if (!empty($result) && $result->num_rows > 0) {
$vals = $result->fetch_assoc(); $vals = $result->fetch_assoc();
if($json[$i]["uploadedas_userid"] != ""){ if($json[$i]["uploadedas_userid"] != ""){
$userjson = json_decode(file_get_contents($url."/API/request.php?type=user&id=".$json[$i]["ownerid"]), true); $userjson = json_decode(file_get_contents($siteurl."/API/request.php?type=user&id=".$json[$i]["ownerid"]), true);
$ownername = $userjson["name"]; $ownername = $userjson["name"];
}else{ }else{
$ownername = $vals["name"]; $ownername = $vals["name"];
@ -33,7 +33,7 @@
} }
echo '<a class="listitem list-group-item waves-effect" href="'.$curdir.'event.php?id='.$json[$i]["eventid"].'"> echo '<a class="listitem list-group-item waves-effect" href="'.$curdir.'event.php?id='.$json[$i]["eventid"].'">
<table> <table>
<td><img class="smallimg listitemimg squircle" src="'.$url.'/API/request.php?type=image&subtype=eventcategory&category='.$json[$i]["category"].'"><td> <td><img class="smallimg listitemimg squircle" src="'.$siteurl.'/API/request.php?type=image&subtype=eventcategory&category='.$json[$i]["category"].'"><td>
<td style="white-space: pre-line;"><b>'.$json[$i]["title"].'</b><br>'.$ownername.'<br>'.$json[$i]["description"].'</b><td> <td style="white-space: pre-line;"><b>'.$json[$i]["title"].'</b><br>'.$ownername.'<br>'.$json[$i]["description"].'</b><td>
</table> </table>
</a>'; </a>';

40
header.php

@ -1,6 +1,9 @@
<?php <?php
//error_reporting(E_ALL); $maintenance = true;
//ini_set('display_errors', 1); if($maintenance) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
}
//session_cache_limiter('private');session_cache_expire(0); //session_cache_limiter('private');session_cache_expire(0);
session_start(); session_start();
@ -28,13 +31,17 @@ if((isset($isadmin) && $isadmin == true) || (isset($ischat) && $ischat == true))
$ischat = false; $ischat = false;
} }
$openpage = basename($_SERVER['PHP_SELF']); $openpage = basename($_SERVER['PHP_SELF']);
//$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://".$_SERVER['HTTP_HOST']."/paredu";
include "creds.php"; if(!file_exists($curdir."creds.php")){
echo "A setup.php fájl nincs lefuttatva. <a href='".$curdir."setup.php'>Futtatás</a>";
die();
}else{
include "creds.php";
}
// Create connection // Create connection
$conn = new mysqli($sqlserver, $sqluser, $sqlpass, $dbname); $conn = new mysqli($sqlserver, $sqluser, $sqlpass, $dbname);
$conn->set_charset("utf8");
// Check connection // Check connection
if ($conn->connect_error) { if ($conn->connect_error) {
@ -235,6 +242,25 @@ if((!isset($liteload) && $loggedin == false && $isadmin && $type != 1 && $type !
} }
} }
mysqli_free_result($result); mysqli_free_result($result);
$conn->close();
$conn = new mysqli($sqlserver, $sqluser, $sqlpass, $dbname."_chat");
$conn->set_charset("utf8");
$viewsql = "SELECT * FROM notifications WHERE userid = ".$userid;
$result = $conn->query($viewsql);
$unreadchatmessages = 0;
if ($result == TRUE) {
if (!empty($result) && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()){
$unreadchatmessages += $row["unread"];
}
}else{
$unreadchatmessages = 0;
}
}
mysqli_free_result($result);
$conn->close();
$conn = new mysqli($sqlserver, $sqluser, $sqlpass, $dbname);
$conn->set_charset("utf8");
}else{ }else{
$username = "Vendég"; $username = "Vendég";
$type = "0"; $type = "0";
@ -579,9 +605,10 @@ if((!isset($liteload) && $loggedin == false && $isadmin && $type != 1 && $type !
</li> </li>
<?php }else{ #end of login button ?> <?php }else{ #end of login button ?>
<li <?php if($ischat){ echo 'class="active"'; }?>> <li <?php if($ischat){ echo 'class="active"'; }?>>
<a href="<?php echo $curdir; ?>chat/"> <a href="<?php echo $curdir; ?>chat/index.php">
<i class="material-icons">chat</i> <i class="material-icons">chat</i>
<span>Chat</span> <span>Chat</span>
<?php if($unreadchatmessages > 0){ echo '<span class="badge bg-teal float-right" style="color: #333; ">'.$unreadchatmessages.' új</span>'; }?>
</a> </a>
</li> </li>
<?php } }else{ ?> <?php } }else{ ?>
@ -601,6 +628,7 @@ if((!isset($liteload) && $loggedin == false && $isadmin && $type != 1 && $type !
<a href="<?php echo $curdir; ?>chat/index.php?fromadmin"> <a href="<?php echo $curdir; ?>chat/index.php?fromadmin">
<i class="material-icons">chat</i> <i class="material-icons">chat</i>
<span>Chat</span> <span>Chat</span>
<?php if($unreadchatmessages > 0){ echo '<span class="badge bg-teal float-right" style="color: #333; ">'.$unreadchatmessages.' új</span>'; }?>
</a> </a>
</li> </li>
<li class="header">MŰVELETEK</li> <li class="header">MŰVELETEK</li>

8
school.php

@ -4,13 +4,13 @@ $load_leaflet = true;
if(!isset($borderless)){ $load_school = true; include "header.php"; $inputid = $_GET["id"]; } if(!isset($borderless)){ $load_school = true; include "header.php"; $inputid = $_GET["id"]; }
if(isset($iscompany)){ if(isset($iscompany)){
$mjson = json_decode(file_get_contents($url."/API/request.php?type=companies"), true); $mjson = json_decode(file_get_contents($siteurl."/API/request.php?type=companies"), true);
$ownerimgtype = "company"; $ownerimgtype = "company";
}else{ }else{
$mjson = json_decode(file_get_contents($url."/API/request.php?type=schools"), true); $mjson = json_decode(file_get_contents($siteurl."/API/request.php?type=schools"), true);
$ownerimgtype = "school"; $ownerimgtype = "school";
} }
$mjsonlang = json_decode(file_get_contents($url."/API/request.php?type=string&subtype=school"), true); $mjsonlang = json_decode(file_get_contents($siteurl."/API/request.php?type=string&subtype=school"), true);
for($mid = 0; $mid<count($mjson); $mid++) { for($mid = 0; $mid<count($mjson); $mid++) {
if($mjson[$mid]["id"] == $inputid){ if($mjson[$mid]["id"] == $inputid){
break; break;
@ -25,7 +25,7 @@ for($mid = 0; $mid<count($mjson); $mid++) {
<div class="col-xs-12"> <div class="col-xs-12">
<?php } ?> <?php } ?>
<div class="card profile-card"> <div class="card profile-card">
<div class="profile-header" style="background: url('<?php echo $url; ?>/API/request.php?type=image&subtype=<?php echo $ownerimgtype; ?>&id=<?php echo $mjson[$mid]["id"]; ?>') center center; width: 100%; height: <?php if(!isset($borderless)){ echo '200px'; }else{ echo '150px'; } ?>; background-repeat: no-repeat; background-size: cover;"></div> <div class="profile-header" style="background: url('<?php echo $siteurl; ?>/API/request.php?type=image&subtype=<?php echo $ownerimgtype; ?>&id=<?php echo $mjson[$mid]["id"]; ?>') center center; width: 100%; height: <?php if(!isset($borderless)){ echo '200px'; }else{ echo '150px'; } ?>; background-repeat: no-repeat; background-size: cover;"></div>
<div class="profile-body"> <div class="profile-body">
<div style="text-align: left; padding-left: 15px; padding-right: 15px;"> <div style="text-align: left; padding-left: 15px; padding-right: 15px;">
<?php if(!isset($borderless)){ echo "<h3>".$mjson[$mid]["name"]."</h3>"; }else{ echo "<h4>".$mjson[$mid]["name"]."</h4>"; }?> <?php if(!isset($borderless)){ echo "<h3>".$mjson[$mid]["name"]."</h3>"; }else{ echo "<h4>".$mjson[$mid]["name"]."</h4>"; }?>

6
schools.php

@ -1,4 +1,4 @@
<?php ini_set("allow_url_fopen", 1); include "header.php"; $jsonlang = json_decode(file_get_contents($url."/API/request.php?type=string&subtype=school"), true); ?> <?php ini_set("allow_url_fopen", 1); include "header.php"; $jsonlang = json_decode(file_get_contents($siteurl."/API/request.php?type=string&subtype=school"), true); ?>
<section class="content"> <section class="content">
<div class="container-fluid"> <div class="container-fluid">
@ -9,7 +9,7 @@
<div class="alert alert-warning text-center"><span class="font-bold" style="color: rgb(57, 57, 57);">Az itt található adatok az intézmények beleegyezése nélkül lettek feltöltve, tesztelés céljából.</span></div> <div class="alert alert-warning text-center"><span class="font-bold" style="color: rgb(57, 57, 57);">Az itt található adatok az intézmények beleegyezése nélkül lettek feltöltve, tesztelés céljából.</span></div>
<div class="list-group"> <div class="list-group">
<?php <?php
$json = json_decode(file_get_contents($url."/API/request.php?type=schools"), true); $json = json_decode(file_get_contents($siteurl."/API/request.php?type=schools"), true);
for($i = 0; $i<count($json); $i++) { for($i = 0; $i<count($json); $i++) {
if($json[$i]["name"] != ""){ if($json[$i]["name"] != ""){
for($j = 0; $j<count($jsonlang); $j++) { for($j = 0; $j<count($jsonlang); $j++) {
@ -21,7 +21,7 @@
echo ' echo '
<a class="listitem list-group-item waves-effect" href="'.$curdir.'school.php?id='.$json[$i]["id"].'"> <a class="listitem list-group-item waves-effect" href="'.$curdir.'school.php?id='.$json[$i]["id"].'">
<table> <table>
<td><img class="listitemimg squircle" src="'.$url.'/API/request.php?type=image&subtype=school&id='.$json[$i]["id"].'"></td> <td><img class="listitemimg squircle" src="'.$siteurl.'/API/request.php?type=image&subtype=school&id='.$json[$i]["id"].'"></td>
<td style="white-space: pre-line;"><b>'.$json[$i]["name"].'</b><br>'.$json[$i]["location"].'<br>'.$fulltype.'</b></td> <td style="white-space: pre-line;"><b>'.$json[$i]["name"].'</b><br>'.$json[$i]["location"].'<br>'.$fulltype.'</b></td>
</table> </table>
</a>'; </a>';

30
setup.php

@ -1,37 +1,53 @@
<?php <?php
if(!file_exists("creds.php")){
#Setup for first start #Setup for first start
$error = 0; $error = 0;
if(!file_exists("images/company")){ if (is_dir("images") && is_writable("images")){
if(!file_exists("images/company")){
if(mkdir("images/company", 0777) && $error != 1){ if(mkdir("images/company", 0777) && $error != 1){
echo "Vállalati fotó könyvtár létrehozva<br>"; echo "Vállalati fotó könyvtár létrehozva<br>";
}else{ }else{
$error = 1; $error = 1;
} }
} }
if(!file_exists("images/user")){ if(!file_exists("images/user")){
if(mkdir("images/user", 0777) && $error != 1){ if(mkdir("images/user", 0777) && $error != 1){
echo "Felhasználói fotó könyvtár létrehozva<br>"; echo "Felhasználói fotó könyvtár létrehozva<br>";
}else{ }else{
$error = 1; $error = 1;
} }
} }
if(!file_exists("images/school")){ if(!file_exists("images/school")){
if(mkdir("images/school", 0777) && $error != 1){ if(mkdir("images/school", 0777) && $error != 1){
echo "Intézményi fotó könyvtár létrehozva<br>"; echo "Intézményi fotó könyvtár létrehozva<br>";
}else{ }else{
$error = 1; $error = 1;
} }
}
}else{
echo "Az 'images' könyvtár vagy nem létezik, vagy nincs írhatónak beállítva.";
} }
if(!file_exists("creds.php")){
if(file_put_contents("creds.php", '<?php $sqlserver = "localhost"; $sqluser = "root"; $sqlpass = "dbpass"; $dbname = "paredu"; ?>') && $error != 1){ if (is_writable(__DIR__)){
if(!file_exists("creds.php")){
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . '://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
if(file_put_contents("creds.php", '<?php $sqlserver = "localhost"; $sqluser = "root"; $sqlpass = "dbpass"; $dbname = "paredu"; $siteurl = "'.$url.'"; ?>') && $error != 1){
echo "Adatbázis konfiguráció létrehozva (creds.php)<br>"; echo "Adatbázis konfiguráció létrehozva (creds.php)<br>";
}else{ }else{
$error = 1; $error = 1;
} }
}
}else{
echo "Az gyökérkönyvtár nincs írhatónak beállítva.";
} }
if($error == 1){ if($error == 1){
echo "Nincsennek a jogok megfelelően beállítva. A gyökérmappa (".basename(__DIR__) .") legyen 777 jogosultságú."; echo "Nincsennek a jogok megfelelően beállítva. A gyökérmappa (".basename(__DIR__) .") legyen 777 jogosultságú.";
} }
echo "<br><a href='index.php'>Visszatérés a kezdőlapra</a>";
}else{
echo "Már kész a telepítés. Az azonosító adatokat a creds.php fájlban lehet módosítani.";
}
?> ?>
Loading…
Cancel
Save