This repository has been archived by the owner on Oct 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
50 lines (48 loc) · 1.51 KB
/
index.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
<?php
session_start();
require_once('./class/google.php');
require_once('./class/hook.php');
require_once('./class/user.php');
require_once('./class/jotform.php');
require_once('./views/engine.php');
$view = new Views('main/header');
$view->set('title', 'hello again');
$view->render();
$view->loadAndRender('main/body');
if (isset($_SESSION['token'])) {
if($_SESSION['lt'] + 3600 < time()) {
session_destroy();
session_start();
header('Location: index.php');
}
$g = new Google('', 'reauth', $_SESSION['token']);
$gid = $g->getGID();
$u = new User();
$uid = $u->getUIDfromGID($gid);
$view->loadFile('user/welcome');
$view->set('name', $g->getName());
$view->render();
$jf_token = $u->getJotFormToken($gid);
$j = new JotForm_Webhook();
if ($jf_token == null || !$j->setKey($jf_token) || !($j->testWrite())) {
if (isset($_POST['jf_api'])) {
$jf_api = $_POST['jf_api'];
$u->setJotFormToken($gid, $jf_api);
$j->setKey($jf_api);
if (!$j->isKeyValid() || !$j->testWrite()) {
$view->loadAndRender('jotform/token_invalid');
} else {
header('Location: index.php');
}
}
$view->loadAndRender('jotform/connect');
} else {
$h = new Hook($uid);
$_SESSION['jf'] = true;
$view->loadAndRender('main/webhooks');
$h->printWebhooks();
}
} else {
$view->loadAndRender('user/login');
}
$view->loadAndRender('main/footer');