Browse code

Created repository.

DoubleBastionAdmin authored on 26/01/2022 20:32:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,39 @@
1
+<?php
2
+/**
3
+ *  Copyright (C) 2021  Double Bastion LLC
4
+ *
5
+ *  This file is part of Roundpin, which is licensed under the
6
+ *  GNU Affero General Public License Version 3.0. The license terms
7
+ *  are detailed in the "LICENSE.txt" file located in the root directory.
8
+ */
9
+
10
+session_start();
11
+
12
+if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access'])) {
13
+
14
+ define('ACCESSCONST', TRUE);
15
+
16
+ require('db-connect.php');
17
+
18
+    $username = $_POST['username'];
19
+    $contactName = $_POST['contact_name'];
20
+    $profilePicture = $_POST['profile_picture_c'];
21
+
22
+    // Get the id of the user for which we want to insert the contact data
23
+    $query1 = $mysqli->query("SELECT id, username, enabled FROM app_users WHERE BINARY username = '$username' AND enabled = 1");
24
+    $queryres = $query1->fetch_array();
25
+    $userID = $queryres[0];
26
+
27
+    // Update the contact profile picture
28
+    $query2 = $mysqli->prepare("UPDATE contacts SET profile_picture_c=? WHERE user_id=? AND contact_name=?");
29
+    $query2->bind_param("sis", $profilePicture, $userID, $contactName);
30
+    if ($query2->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'failure'; }
31
+
32
+    $response = array('result' => $messagetosend);
33
+    echo json_encode($response);
34
+
35
+} else {
36
+    header("Location: roundpin-login.php");
37
+}
38
+
39
+?>