-
Notifications
You must be signed in to change notification settings - Fork 2
/
signup.php
94 lines (75 loc) · 2.62 KB
/
signup.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
<?php
header('Access-Control-Allow-Origin: *');
include_once "config.php";
include_once "sheets.php";
include_once "drive.php";
if (!isset($_POST['product']) ||
!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['phone']) ||
!isset($_POST['education']) ||
!isset($_FILES['cv']) ||
!isset($_POST['g-recaptcha-response'])){
$output = json_encode(array('type' => 'fail', 'text' => "Incomplete form"));
die($output);
}
if (!isset($_POST['entity'])){
$_POST['entity'] = "Others";
}
if (!isset($_POST['track'])){
$_POST['track'] = "";
}
if (!isset($_POST['institute_text'])){
$_POST['institute_text'] = "";
}
$product = $_POST['product'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$education = $_POST['education'];
if ($_FILES['cv']['tmp_name'] != ""){
$cv = file_get_contents($_FILES['cv']['tmp_name']);
}
$entity = $_POST['entity'];
$track = $_POST['track'];
$institute = $_POST['institute_text'];
$gcaptcha = $_POST['g-recaptcha-response'];
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array(
'secret' => $gcaptcha_private,
'response' => $gcaptcha,
'remoteip' => $_SERVER['REMOTE_ADDR']
);
$curlConfig = array(
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $data
);
$ch = curl_init();
curl_setopt_array($ch, $curlConfig);
$response = curl_exec($ch);
curl_close($ch);
$jsonResponse = json_decode($response);
/*
if (!$jsonResponse || !$jsonResponse->success === true) {
$output = json_encode(array('type' => 'fail', 'text' => "Captcha invalid"));
die($output);
}
*/
$date = new DateTime("now", new DateTimeZone('Asia/Colombo') );
$timestamp = $date->format('Y-m-d H:i:s');
$url = "Not provided";
if (isset($cv)){
$url = upload($cv, $first_name, $last_name, $entity, $timestamp);
}
$res = append([[$timestamp, $product, $first_name, $last_name, $email, $phone, $institute, $education, $url, $track]], $entity);
if ($res == "success") {
$output = json_encode(array('type' => 'success', 'text' => "Details successfully submitted."));
die($output);
} else{
$output = json_encode(array('type' => 'fail', 'text' => "An unknown error occurred."));
die($output);
}