-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenbrugshallerne.php
119 lines (92 loc) · 3.42 KB
/
Genbrugshallerne.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* Plugin Name: Standopsætning og fremvisning
*/
$connect = new wpdb('idathoet_com','fxHBp2mG6Ezk','idathoet_com_db_genbrugshallerne','mysql32.unoeuro.com');
function getAllStande(){
global $connect;
$sql = "SELECT stand.*, stand_pictures.link
FROM stand, stand_pictures
WHERE stand_pictures.standID = stand.ID";
$result = $connect->get_results($sql);
foreach($result as $key => $row) {
$stand .= '<a href="/stand-'.$row->ID.'" class="stand-link">
<img src="/wp-content/uploads/user-uploads/'.$row->link.'" alt="" class="stand-thumb">
<div class="stand-link-wrap">
<h2 class="stand-name">'.$row->title.'</h2>
<span class="tag"></span>
</div>
</a>';
}
return $stand;
}
add_shortcode('fremvis_stande', 'getAllStande');
function getStand($id){
global $connect;
$sql = "SELECT stand.*, stand_pictures.link, pictures.link
FROM stand, stand_pictures, pictures
WHERE pictures.standID = stand.ID AND stand_pictures.standID = stand.ID AND stand.ID = $id";
$result = $connect->get_results($sql);
$row = $result->fetch_object();
return $result;
}
add_shortcode('get_stand', 'getStand');
function getTags(){
global $connect;
$sql = "SELECT * FROM tags";
$result = $connect->get_results($sql);
return $result;
}
function login($username, $password){
global $connect;
$sql= "SELECT ID, username, password FROM users WHERE username='".$username."'";
$result = $connect->query($sql);
$row = $result->fetch_object();
if (isset($_POST['login'])){
if ($username == $row->Username && $password == $row->Password){
$_SESSION['UserID'] = $row->UserID;
header('location:../home.php');
} else {
header('location:../login.php');
}
}
}
function uploadPicture(){
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$allowedExts = array("jpg", "jpeg", "gif", "png", "heic", "bmp");
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/heic")
|| ($_FILES["file"]["type"] == "image/bmp"))
&& ($_FILES["file"]["size"] < 36000000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
} else {
// Verifikation:
// echo "Upload: " . $_FILES["file"]["name"] . "<br />";
// echo "Type: " . $_FILES["file"]["type"] . "<br />";
// echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
// echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("../../uploads/user-uploads/" . $_FILES["file"]["name"])){
echo $_FILES["file"]["name"] . " already exists. ";
} else {
move_uploaded_file($_FILES["file"]["tmp_name"],
"../../uploads/user-uploads/" . $_FILES["file"]["name"]);
// echo "Stored in: " . "../media/" . $_FILES["file"]["name"];
header("Location:../upload-done.php");
}
}
} else {
echo "Return Code: " . $_FILES["file"]["name"] . "<br />";
echo "Invalid file";
print_r($_FILES);
}
}
?>