-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera.php
106 lines (102 loc) · 3.37 KB
/
camera.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
<?php
ob_start();
require_once("config/pdo.php");
if (!isset($_SESSION)) {
session_start();
}
if (!isset($_SESSION["user_id"]) || !isset($_SESSION['user_uid'])
|| $_SESSION['user_id'] == -1) {?>
<script>
alert('To accees the Editing features, you need to be logged in');
window.location.href='login';
</script>
<?php exit();
} ?>
<!DOCTYPE html>
<html>
<head>
<?php
include_once 'frontend/head.php';
?>
<title>Camera • Camagru</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/camera.css">
</head>
<body>
<?php include_once "frontend/header.php" ?>
<main>
<?php if (!isset($_COOKIE['usage'])) { ?>
<div class='information'>
<div class='info_header'>
<h3>Usage</h1></h3><i id='cross' class="fa-solid fa-xmark"></i>
</div>
<div>
Start your camera by pressing <b>Start Camera</b>. Choose your stickers.<br>
Take picture by pressing <b>Take Picture</b>.
You can retry taking the picture by pressing <b>Cancel</b> or write your caption and press <b>Submit</b>.<br>
By pressing <b>Submit</b> the image will be uploaded to the database and you are ready to go!
</div>
</div>
<?php } ?>
<div class='camera-buttons'>
<button class="start-camera"><i class="ti ti-camera-off"></i> Start Camera</button>
<button class="click-photo" id="disabled" style="display: none;"><i class="ti ti-camera"></i> Take Picture</button>
</div>
<div class='container'>
<div id='stickers'>
<span id="cam_texts">Stickers</span>
<ul>
<?php for ($i = 1; $i <= 7; $i++) { ?>
<li>
<img src="images/stickers/<?=$i?>.png" onclick="add_sticker(<?=$i?>)">
</li>
<?php } ?>
</ul>
</div>
<div id="video-div">
<video id="video" autoplay playsinline></video>
<div id="add_stickers"></div>
</div>
<div id='drafts'>
<span id="cam_texts">Uploaded Images</span>
<ul id='draft_list'>
<?php
$sql = "SELECT `image`, `image_id`
FROM `images`
WHERE `users_id` = ?
ORDER BY `image_id` DESC;";
$statement = $pdo->prepare($sql);
$statement->execute([$_SESSION['user_id']]);
$result = $statement->fetchAll();
foreach ($result as $row) {
$image = base64_encode($row['image']); ?>
<li>
<img src='data:image/jpg;charset=utf8;base64,<?=$image?>'
onclick="window.open('picture/<?=$row['image_id']?>')">
</li>
<?php }?>
</ul>
</div>
</div>
<canvas id="canvas"></canvas>
<form id='image-form' method='post'>
<h1>New Post</h1>
<textarea id='description-field' name='caption' placeholder="Write a caption..." maxlength="280"></textarea><br />
<div id="buttons">
<button type='button' id='cancel-image'>Cancel</button>
<button type='submit' name='submit' value='submit' id='submit-image'>Submit</submit>
</div>
</form>
<div class='upload_image' enctype="multipart/form-data">
<h5>Or upload image...</h5>
<form method="post" id='upload_form'>
<input type="file" name="file" id='file_input' accept="image/png, image/jpeg" required>
</form>
</div>
</main>
<?php include 'frontend/footer.html'; ?>
</body>
<script type="text/javascript" src="js/dragElement.js"></script>
<script type="text/javascript" src="js/camera.js"></script>
<script type="text/javascript" src="js/camera_upload.js"></script>
</html>