-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoreinvites.php
More file actions
119 lines (115 loc) · 4.03 KB
/
moreinvites.php
File metadata and controls
119 lines (115 loc) · 4.03 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
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
session_start();
include "database.php";
include "navbar.php";
if (isset($_POST['submit'])) {
$sql="select * from status where EID='".$_SESSION['eid']."'";
$res=$db->query($sql);
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i", "", $searchq);
$sqlq = "select * from users where Uname like '%" . $searchq . "%' and not Uname='".$_SESSION['Uname']."'";
$result = $db->query($sqlq);
while($r=$res->fetch_assoc()){
//echo"chk";
if ($result->num_rows > 0) {
if($r['Status']!=null || $r['Status']!=""){
global $data;
$data=json_decode($r['Status']);
foreach($data as $name=>$stat){
while ($info = $result->fetch_assoc()) {
//print_r($info);
if($name!==$info['Uname']){
echo "<div class='links'>" . $info['Uname'] . "<br>
<button class='select' id='" . $info['Uname'] . "'onclick=\"select(this.id)\"'>Select</button></div>";
}
}
}
}
}
else {
echo "No users found";
}
}
}
else {
echo "...";
}
if(isset($_POST['done'])){
$n=$_POST['n'];
$i=0;
while($i<count($n)){
$qry="select * from events where Uname='".$_SESSION['Uname']."'";
$row=$db->query($qry);
while($info=$row->fetch_assoc()){
if (isset($n[$i])) {
$stat[$n[$i]] = "false";
$i += 1;
$json = json_encode($stat);
$qry = $db->prepare("insert into status (EID,Ename,Status) values(?,?,?)");
$qry->bind_param("iss", $_SESSION['eid'], $_SESSION['name'], $json);
$chk = $qry->execute();
}
}
}
if($chk){
echo "<div id='ilink'>Done!!<br><button id='Ilink' onclick=\"link()\">Get Link!</button></div>";
}
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="full">
<form method="post" action='<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>'>
<label>Search for users to send invites here:</label><br>
<input type="text" required class="input" name="search"><br>
<button type="submit" name="submit">SEARCH</button>
</form>
<fieldset>
<legend>Selected users:</legend>
<form method="post" id="form" action='<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>'>
</fieldset>
<button name='done'>Send!!</button>
</form>
</div>
</body>
<div id="popup">
<div id="header">Link for the attendee</div>
<span id="close">×</span>
<input type="text" readonly value="http://localhost/party/ainvites.php?ename=<?php echo $_SESSION['name']?>" id="copytxt"><button onclick="copy()">Copy to clipboard</button>
</div>
<script>
function select(name) {
document.getElementById("form").innerHTML +="<input name=\"n[]\" value='"+name+"' readonly></input><br>";
document.getElementById(name).style.display='none';
}
function link() {
var box = document.getElementById('popup');
var close = document.getElementById('close');
var btn = document.getElementById('Ilink');
var full=document.getElementById('full');
btn.onclick = function() {
box.style.display = "block";
full.setAttribute('class','blur');
}
close.onclick = function() {
box.style.display = "none";
full.setAttribute('class',null);
}
window.onclick = function(event) {
if (event.target == box) {
box.style.display = "none";
full.setAttribute('class',null);
}
}
}
function copy() {
var copytxt = document.getElementById("copytxt");
copytxt.select();
document.execCommand("copy");
alert("Copied the link: " + copytxt.value);
}
</script>
</html>