Browse Source

Start image upload, finish usertypes, minor polishing

master
OliverParoczai 4 years ago
parent
commit
4f2d4fe2b5
  1. 3
      .gitignore
  2. 22
      API/request.php
  3. 136
      admin/dataupload.php
  4. 1
      css/style.css
  5. 71
      header.php
  6. 0
      images/defaultuser.png
  7. 0
      images/logo.png
  8. 5
      login.php
  9. 2
      school.php

3
.gitignore vendored

@ -1 +1,4 @@
creds.php creds.php
images/company
images/school
images/user

22
API/request.php

@ -59,13 +59,22 @@ if($type == null){
include "../images/default.png"; include "../images/default.png";
} }
break; break;
case "company":
header('Content-Type: image/png');
$file = "../images/company/".$_GET["id"].".png";
if(file_exists($file)){
include $file;
}else{
include "../images/default.png";
}
break;
case "user": case "user":
header('Content-Type: image/png'); header('Content-Type: image/png');
$file = "../images/user/".$_GET["id"].".png"; $file = "../images/user/".$_GET["id"].".png";
if(file_exists($file)){ if(file_exists($file)){
include $file; include $file;
}else{ }else{
include "../images/user/default.png"; include "../images/defaultuser.png";
} }
break; break;
default: default:
@ -96,6 +105,17 @@ if($type == null){
$result->close(); $result->close();
$conn->close(); $conn->close();
break; break;
case "company":
$list = array();
if ($result = $conn->query("SELECT * FROM `schooltypes`")) {
while($row = $result->fetch_assoc()) {
$list[] = $row;
}
echo json_encode($list);
}
$result->close();
$conn->close();
break;
case "user": case "user":
$list = array(); $list = array();
if ($result = $conn->query("SELECT * FROM `acctypes`")) { if ($result = $conn->query("SELECT * FROM `acctypes`")) {

136
admin/dataupload.php

@ -12,13 +12,20 @@
</div> </div>
<!-- Input Group --> <!-- Input Group -->
<div class="row clearfix"> <div class="row clearfix">
<form class="col-lg-12 col-md-12 col-sm-12 col-xs-12" method="POST" action="#"> <form class="col-lg-12 col-md-12 col-sm-12 col-xs-12" method="POST" action="#" enctype="multipart/form-data">
<div class="card"> <div class="card">
<div class="header"> <div class="header">
<?php <?php
if(isset($_GET["uploaded"]) || isset($_GET["addedfaculty"])){
if(isset($_GET["uploaded"])){ if(isset($_GET["uploaded"])){
if($_GET["uploaded"] == 0){ echo '<div id="uploadsuccess" class="alert alert-danger text-center"><strong>Sikertelen feltöltés.</strong> Kérjük <a href="mailto:admin@paredu.hu" style="color: white;">vegye fel a kapcsolatot az adminisztrátorokkal</a>.</div>'; if($_GET["uploaded"] == 0){ echo '<div id="uploadsuccess" class="alert alert-danger text-center"><strong>Sikertelen feltöltés.</strong> Kérjük <a href="mailto:admin@paredu.hu" style="color: white;">vegye fel a kapcsolatot az adminisztrátorokkal</a>.</div>';
}elseif($_GET["uploaded"] == 1){ echo '<div id="uploadsuccess" class="alert alert-success text-center">Sikeres feltöltés</div>';} }elseif($_GET["uploaded"] == 1){ echo '<div id="uploadsuccess" class="alert alert-success text-center">Sikeres feltöltés</div>';
}
}else{
if($_GET["addedfaculty"] == 0){ echo '<div id="uploadsuccess" class="alert alert-danger text-center">A <strong>kar hozzáadása sikertelen.</strong> Kérjük <a href="mailto:admin@paredu.hu" style="color: white;">vegye fel a kapcsolatot az adminisztrátorokkal</a>.</div>';
}elseif($_GET["addedfaculty"] == 1){ echo '<div id="uploadsuccess" class="alert alert-success text-center">Az új kar <strong>sikeresen hozzáadva</strong> az intézményhez</div>';
}
}
?> ?>
<script> <script>
setTimeout(function(){ setTimeout(function(){
@ -28,7 +35,7 @@
</script> </script>
<?php } ?> <?php } ?>
<h2> <h2>
INTÉZMÉNY ADATAI <?php if($type == 2){ echo "VÁLLALAT"; } else { echo "INTÉZMÉNY"; } ?> ADATAI
</h2> </h2>
<ul class="header-dropdown m-r--5"> <ul class="header-dropdown m-r--5">
<li class="dropdown"> <li class="dropdown">
@ -58,27 +65,32 @@
</div> </div>
</div> </div>
<div class="col-md-7"> <div class="col-md-7">
<b>Intézmény Neve</b> <b><?php if($type == 2){ echo "Vállalat"; } else { echo "Intézmény"; } ?> Neve</b>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
<i class="material-icons">edit</i> <i class="material-icons">edit</i>
</span> </span>
<div class="form-line"> <div class="form-line">
<input type="text" class="form-control" name="schoolname" placeholder="Név" value="<?php echo $selschvals["name"]; ?>"> <input type="text" class="form-control" name="formname" placeholder="Név" value="<?php echo $selschvals["name"]; ?>">
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<b>Intézmény Típusa</b> <b><?php if($type == 2){ echo "Vállalat"; } else { echo "Intézmény"; } ?> Típusa</b>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
<i class="material-icons">school</i> <i class="material-icons">school</i>
</span> </span>
<div class="form-line"> <div class="form-line">
<select class="form-control show-tick" name="schooltype"> <select class="form-control show-tick" name="formtype">
<?php if($type == 2){ ?>
<option value="vallalat" <?php if($selschvals["type"] == "vallalat"){ echo "selected"; } ?>>Vállalat</option>
<option value="nonprofit" <?php if($selschvals["type"] == "nonprofit"){ echo "selected"; } ?>>Non-profit</option>
<?php }else{ ?>
<option value="high" <?php if($selschvals["type"] == "high"){ echo "selected"; } ?>>Középiskola</option> <option value="high" <?php if($selschvals["type"] == "high"){ echo "selected"; } ?>>Középiskola</option>
<option value="uni" <?php if($selschvals["type"] == "uni"){ echo "selected"; } ?>>Egyetem</option> <option value="uni" <?php if($selschvals["type"] == "uni"){ echo "selected"; } ?>>Egyetem</option>
<option value="college" <?php if($selschvals["type"] == "college"){ echo "selected"; } ?>>Főiskola</option> <option value="college" <?php if($selschvals["type"] == "college"){ echo "selected"; } ?>>Főiskola</option>
<?php } ?>
</select> </select>
</div> </div>
</div> </div>
@ -86,14 +98,15 @@
</div> </div>
<div class="row clearfix"> <div class="row clearfix">
<div class="col-md-2"> <div class="col-md-2">
<b>Intézmény fotója</b> <b><?php if($type == 2){ echo "Vállalat"; } else { echo "Intézmény"; } ?> fotója</b>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
<img class="squircle" src="<?php echo $curdir; ?>API/request.php?type=image&subtype=school&id=<?php echo $selschvals["id"]; ?>" height="100px" width="100px"> <img class="squircle" id="formimageout" src="<?php echo $curdir; ?>API/request.php?type=image&subtype=<?php if($type == 2){ echo "company"; }else{ echo "school"; } ?>&id=<?php echo $selschvals["id"]; ?>" height="100px" width="100px">
</span> </span>
<div> <div>
<button type="button" class="btn bg-indigo waves-effect"> <input type="file" name="formfile" id="formfile" style="display: none;">
<i class="material-icons">replay</i> <button type="button" class="btn bg-indigo waves-effect" onclick="document.getElementById('formfile').click();" style="vertical-align: text-top;">
<i class="material-icons">upload</i>
</button> </button>
<button type="button" class="btn bg-green waves-effect" style="vertical-align: text-top;"> <button type="button" class="btn bg-green waves-effect" style="vertical-align: text-top;">
<i class="material-icons">download</i> <i class="material-icons">download</i>
@ -101,6 +114,7 @@
</div> </div>
</div> </div>
</div> </div>
<?php if($type != 2){ ?>
<div class="col-md-10"> <div class="col-md-10">
<b>Intézmény által oktatott szakok</b> <b>Intézmény által oktatott szakok</b>
<div class="input-group"> <div class="input-group">
@ -112,8 +126,9 @@
</div> </div>
</div> </div>
</div> </div>
<?php } ?>
<div class="col-md-3"> <div class="col-md-3">
<b>Intézmény telefonszáma</b> <b><?php if($type == 2){ echo "Vállalat"; } else { echo "Intézmény"; } ?> telefonszáma</b>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
<i class="material-icons">phone</i> <i class="material-icons">phone</i>
@ -124,7 +139,7 @@
</div> </div>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<b>Intézmény e-mail címe</b> <b><?php if($type == 2){ echo "Vállalat"; } else { echo "Intézmény"; } ?> e-mail címe</b>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
<i class="material-icons">email</i> <i class="material-icons">email</i>
@ -181,8 +196,101 @@
if ($result == TRUE) { if ($result == TRUE) {
if (!empty($result) && $result->num_rows > 0) { if (!empty($result) && $result->num_rows > 0) {
for($i = 0; $i < $result->num_rows; $i++){ for($i = 0; $i < $result->num_rows; $i++){
echo '<h2 class="card-inside-title">Kar '.($i+1).'</h2>';
$facvals = $result->fetch_assoc(); $facvals = $result->fetch_assoc();
echo "<div>s".$facvals["facultyid"]."</div>"; //echo "<div>s".$facvals["facultyid"]."</div>";
?>
<div class="row clearfix">
<div class="col-md-2">
<b>Egyedi Azonosító (ID)</b>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">fact_check</i>
</span>
<div class="form-line">
<input type="text" class="form-control text-center" name="facultyid_<?php echo $facvals["facultyid"]; ?>" value="#<?php echo $facvals["facultyid"]; ?>" readOnly>
</div>
</div>
</div>
<div class="col-md-10">
<b>Kar Neve</b>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">edit</i>
</span>
<div class="form-line">
<input type="text" class="form-control" name="facultyname_<?php echo $facvals["facultyid"]; ?>" placeholder="Név" value="<?php echo $facvals["facultyname"]; ?>">
</div>
</div>
</div>
<div class="col-md-12">
<b>Kar által oktatott szakok</b>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">assignment</i>
</span>
<div class="form-line">
<input type="text" class="form-control" data-role="tagsinput" value="<?php echo $facvals["facultyspec"]; ?>" name="facultyspec_<?php echo $facvals["facultyid"]; ?>">
</div>
</div>
</div>
<div class="col-md-3">
<b>Kar telefonszáma</b>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">phone</i>
</span>
<div class="form-line masked-input">
<input type="text" class="form-control phone-number" name="facultyphnnum_<?php echo $facvals["facultyphonenumber"]; ?>" placeholder="Pl.: +36 00/000-0000" value="<?php echo $facvals["facultyphonenumber"]; ?>">
</div>
</div>
</div>
<div class="col-md-3">
<b>Kar e-mail címe</b>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">email</i>
</span>
<div class="form-line">
<input type="text" class="form-control" name="facultyemail_<?php echo $facvals["facultyid"]; ?>" placeholder="Pl.: kar@intezmeny.hu" value="<?php echo $facvals["facultyemail"]; ?>">
</div>
</div>
</div>
<div class="col-md-2">
<b>Irányítószám</b>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">local_post_office</i>
</span>
<div class="form-line masked-input">
<input type="text" class="form-control postal-code" name="postcode" placeholder="Pl.: 1011" value="<?php echo $selschvals["postalcode"]; ?>">
</div>
</div>
</div>
<div class="col-md-4">
<b>Város</b>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">location_city</i>
</span>
<div class="form-line">
<input type="text" class="form-control" name="loc" placeholder="Pl.: Budapest" value="<?php echo $selschvals["location"]; ?>">
</div>
</div>
</div>
<div class="col-md-5">
<b>Utca, házszám</b>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">label</i>
</span>
<div class="form-line">
<input type="text" class="form-control" name="locspec" placeholder="Pl.: Egyetem tér 1-3" value="<?php echo $selschvals["locationspec"]; ?>">
</div>
</div>
</div>
</div>
<?php
} }
}else{ }else{
echo "Még nincsennek karok hozzáadva."; echo "Még nincsennek karok hozzáadva.";

1
css/style.css

@ -7582,7 +7582,6 @@ fieldset[disabled] .form-control {
white-space: nowrap; white-space: nowrap;
position: relative; position: relative;
border-bottom: 1px solid #e9e9e9; border-bottom: 1px solid #e9e9e9;
background: url("../images/user-img-background.jpg") no-repeat no-repeat;
height: 155px; } height: 155px; }
.sidebar .user-info .image { .sidebar .user-info .image {
margin-right: 12px; margin-right: 12px;

71
header.php

@ -1,6 +1,6 @@
<?php <?php
//error_reporting(E_ALL); error_reporting(E_ALL);
//ini_set('display_errors', 1); 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();
@ -38,7 +38,7 @@ if(isset($_POST["selectedcompany"]) && $loggedin){
$_SESSION["selectedschool"] = $_POST["selectedschool"]; $_SESSION["selectedschool"] = $_POST["selectedschool"];
} }
if(!isset($liteload) && !$loggedin && $isadmin && ($type == 1 || $type == 2)){ if(!isset($liteload) && $loggedin == false && $isadmin && $type != 1 && $type != 2 && $type != 3){
header("Location: ".$curdir."login.php"); header("Location: ".$curdir."login.php");
die(); die();
}else{ }else{
@ -53,11 +53,24 @@ if(!isset($liteload) && !$loggedin && $isadmin && ($type == 1 || $type == 2)){
$type = $sqlvals["type"]; $type = $sqlvals["type"];
if($type == 2){ if($type == 2){
$connctdcmps = explode(",", $sqlvals["connectedcompanyids"]); $connctdcmps = explode(",", $sqlvals["connectedcompanyids"]);
}elseif($type == 1){
$connctdschids = array();
$viewsql = "SELECT * FROM `schools`";
$result2 = $conn->query($viewsql);
for($i = 0; $i < $result2->num_rows; $i++){
if ($result2 == TRUE) {
if (!empty($result2) && $result2->num_rows > 0) {
$vals = $result2->fetch_assoc();
$connctdschids[$i] = $vals["id"];
}
}
}
mysqli_free_result($result2);
}else{ }else{
$connctdschids = explode(",", $sqlvals["connectedschoolids"]); $connctdschids = explode(",", $sqlvals["connectedschoolids"]);
} }
$sql = "SELECT * FROM `acctypes` WHERE `id` = '".$type."'";
mysqli_free_result($result); mysqli_free_result($result);
$sql = "SELECT * FROM `acctypes` WHERE `id` = '".$type."'";
$result = $conn->query($sql); $result = $conn->query($sql);
$sqlvals = $result->fetch_assoc(); $sqlvals = $result->fetch_assoc();
$fulltype = $sqlvals["name_hun"]; $fulltype = $sqlvals["name_hun"];
@ -66,19 +79,57 @@ if(!isset($liteload) && !$loggedin && $isadmin && ($type == 1 || $type == 2)){
mysqli_free_result($result); mysqli_free_result($result);
if(isset($data_upload)){ if(isset($data_upload)){
ini_set("file_uploads", 1);
if(isset($_POST["submit"])){ if(isset($_POST["submit"])){
$modsql = "UPDATE `schools` SET `name` = '".$conn->real_escape_string($_POST['schoolname'])."', `type` = '".$conn->real_escape_string($_POST['schooltype'])."', `postalcode` = '".$conn->real_escape_string($_POST['postcode'])."', `spec` = '".str_replace(', ', ',', preg_replace('/\s+/', ' ', trim($conn->real_escape_string($_POST['spec']))))."', `location` = '".$conn->real_escape_string($_POST['loc'])."', `locationspec` = '".$conn->real_escape_string($_POST['locspec'])."', `phonenumber` = '".$conn->real_escape_string($_POST['phnnum'])."', `emailaddress` = '".$conn->real_escape_string($_POST['email'])."' WHERE `schools`.`id` = ".substr($_SESSION["selectedschool"], 1); if($type == 2){
$modsql = "UPDATE `companies` SET `name` = '".$conn->real_escape_string($_POST['formname'])."', `type` = '".$conn->real_escape_string($_POST['formtype'])."', `postalcode` = '".$conn->real_escape_string($_POST['postcode'])."', `spec` = '".str_replace(', ', ',', preg_replace('/\s+/', ' ', trim($conn->real_escape_string($_POST['spec']))))."', `location` = '".$conn->real_escape_string($_POST['loc'])."', `locationspec` = '".$conn->real_escape_string($_POST['locspec'])."', `phonenumber` = '".$conn->real_escape_string($_POST['phnnum'])."', `emailaddress` = '".$conn->real_escape_string($_POST['email'])."' WHERE `companies`.`id` = ".substr($_SESSION["selectedcompany"], 1);
$filepath = $curdir."images/company/".substr($_SESSION["selectedcompany"], 1).".png";
}else{
$modsql = "UPDATE `schools` SET `name` = '".$conn->real_escape_string($_POST['formname'])."', `type` = '".$conn->real_escape_string($_POST['formtype'])."', `postalcode` = '".$conn->real_escape_string($_POST['postcode'])."', `spec` = '".str_replace(', ', ',', preg_replace('/\s+/', ' ', trim($conn->real_escape_string($_POST['spec']))))."', `location` = '".$conn->real_escape_string($_POST['loc'])."', `locationspec` = '".$conn->real_escape_string($_POST['locspec'])."', `phonenumber` = '".$conn->real_escape_string($_POST['phnnum'])."', `emailaddress` = '".$conn->real_escape_string($_POST['email'])."' WHERE `schools`.`id` = ".substr($_SESSION["selectedschool"], 1);
$filepath = $curdir."images/school/".substr($_SESSION["selectedschool"], 1).".png";
}
if(isset($_FILES["formfile"]) && $_FILES["formfile"]['error'] != UPLOAD_ERR_NO_FILE){
$check = getimagesize($_FILES["formfile"]["tmp_name"]);
if($check !== false) {
$filetype = $_FILES["formfile"]["type"];
if($filetype != "image/jpg" && $filetype != "image/png" && $filetype != "image/jpeg" && $filetype != "image/gif" ) {
$uploadProblem = 0;
}else{
if ($_FILES["formfile"]["size"] > 900000) {
$uploadProblem = 1;
}else{
//move_uploaded_file($_FILES["formfile"]["tmp_name"], $filepath);
copy($_FILES["formfile"]["tmp_name"], $filepath);
}
}
if(isset($uploadProblem)){
header("Location: dataupload.php?imageuploaded=".$uploadProblem);
die();
}else{
header("Location: dataupload.php?imageuploaded=2");
die();
}
}
}else{
if ($conn->query($modsql) === TRUE) { if ($conn->query($modsql) === TRUE) {
header("Location: dataupload.php?uploaded=1"); header("Location: dataupload.php?uploaded=1");
} else { } else {
//echo "Error: " . $modsql . "<br>" . $conn->error; //echo "Error: " . $modsql . "<br>" . $conn->error;
//header("Location: dataupload.php?uploaded=0&error=".$conn->error);
header("Location: dataupload.php?uploaded=0"); header("Location: dataupload.php?uploaded=0");
} }
die(); die();
}elseif(isset($_POST["addfaculty"]) && $_POST['schooltype'] == "uni"){ }
$modsql = "INSERT INTO `faculties` (`schoolid`, `facultyname`, `facultyspec`) VALUES ('".substr($_SESSION["selectedschool"], 1)."', '', '')"; }elseif(isset($_POST["addfaculty"]) && $_POST['formtype'] == "uni"){
$modsql = "INSERT INTO `faculties` (`schoolid`, `facultyname`, `facultyspec`, `facultyphonenumber`, `facultyemail`) VALUES ('".substr($_SESSION["selectedschool"], 1)."', '', '', '', '')";
$conn->query($modsql); $conn->query($modsql);
header("Location: dataupload.php"); if ($conn->query($modsql) === TRUE) {
header("Location: dataupload.php?addedfaculty=1");
} else {
//echo "Error: " . $modsql . "<br>" . $conn->error;
//header("Location: dataupload.php?uploaded=0&error=".$conn->error);
header("Location: dataupload.php?addedfaculty=0");
}
die(); die();
} }
} }
@ -119,7 +170,7 @@ if(!isset($liteload) && !$loggedin && $isadmin && ($type == 1 || $type == 2)){
$result = $conn->query($viewsql); $result = $conn->query($viewsql);
if ($result == TRUE) { if ($result == TRUE) {
if (!empty($result) && $result->num_rows > 0) { if (!empty($result) && $result->num_rows > 0) {
$selcomvals = $result->fetch_assoc(); $selschvals = $result->fetch_assoc();
} }
//else{ //else{
//$modsql = "INSERT INTO `schools` (`id`, `name`, `type`, `spec`, `postalcode`, `location`, `locationspec`, `phonenumber`) VALUES ('".substr($_SESSION["selectedschool"], 1)."', '', '', '', '', '', '', '')"; //$modsql = "INSERT INTO `schools` (`id`, `name`, `type`, `spec`, `postalcode`, `location`, `locationspec`, `phonenumber`) VALUES ('".substr($_SESSION["selectedschool"], 1)."', '', '', '', '', '', '', '')";
@ -427,7 +478,7 @@ if(!isset($liteload) && !$loggedin && $isadmin && ($type == 1 || $type == 2)){
<div class="menu"> <div class="menu">
<ul class="list"> <ul class="list">
<?php if(!$isadmin){ <?php if(!$isadmin){
if($type == 1 || $type == 2){ #School admin and partner ?> if($type == 1 || $type == 2 || $type == 3){ #School admin and partner ?>
<li class="header">ADMINISZTRÁTOR</li> <li class="header">ADMINISZTRÁTOR</li>
<li> <li>
<a href="admin"> <a href="admin">

0
images/user/default.png → images/defaultuser.png

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

0
images/logo.png

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

5
login.php

@ -1,13 +1,10 @@
<?php <?php
if(isset($_GET["logout"])){ if(isset($_GET["logout"])){
//session_cache_limiter('private');session_cache_expire(0);
session_start(); session_start();
unset($_SESSION["login"]); unset($_SESSION["login"]);
session_unset(); session_unset();
session_destroy(); session_destroy();
//session_write_close();
//$_SESSION=array();
//session_cache_limiter('private');session_cache_expire(0);
session_start(); session_start();
session_regenerate_id(true); session_regenerate_id(true);
header('Clear-Site-Data: "cache"'); header('Clear-Site-Data: "cache"');

2
school.php

@ -55,7 +55,7 @@ $json[$schoolid]["type"]
<div class="col-md-6 col-sm-12" style="padding-right: 0;"> <div class="col-md-6 col-sm-12" style="padding-right: 0;">
<div id="map"></div> <div id="map"></div>
</div> </div>
<button class="btn btn-primary btn-lg waves-effect btn-block">FOLLOW</button> <a href="schools.php"><button class="btn bg-indigo btn-lg waves-effect btn-block"><i class="material-icons left">keyboard_backspace</i><span>VISSZA</span></button></a>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save