-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution.php
More file actions
70 lines (55 loc) · 1.32 KB
/
solution.php
File metadata and controls
70 lines (55 loc) · 1.32 KB
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
<?php
include 'common/dbconnect.php';
include 'common/functions.php';
sec_session_start();
// Set current user name in variable so header.php works properly
$curuser = "";
if(login_check($mysqli) == true) {
if(isset($_SESSION['username'])) {
$curuser = $_SESSION['username'];
}
}
// Test for errors
if(mysqli_connect_errno()){
echo mysqli_connect_error();
}
$get_id = strip_tags($_GET[id]);
$query = "SELECT * FROM solutions WHERE id = '$get_id'";
$result = $mysqli->query($query);
if($result){
// Cycle through results
while ($row = $result->fetch_assoc()) {
$id = $row['id'];
$name = $row['name'];
$description = $row['description'];
$company = $row['company'];
$timestamp = date('F j, Y ',$row['timestamp']);
$creator = $row['creator'];
$category = $row['category'];
$image = $row['image'];
$urlexists = false;
if(strlen($image) > 0) {
if(urlExists($image)) {
$urlexists = true;
$info = getimagesize("$image");
$max = 400;
$info[0];
$info[1];
$biggest = $info[0];
if($info[1] > $info[0]) {
$biggest = $info[1];
}
$ratio = ($max / $biggest);
$width = $info[0]*$ratio;
$height = $info[1]*$ratio;
}
}
}
// Free result set
$result->free();
include 'views/solution.php';
}
if(!$result) {
header('Location: index.php');
}
?>