-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathheader.php
124 lines (95 loc) · 4.64 KB
/
header.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
* @author Piyush
* @copyright 2011
*/
error_reporting(E_ALL);
ini_set("display_errors", "On");
//Include core php extensions
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/constants.php';
require_once __DIR__ . '/functions.php';
require_once __DIR__ . '/template/template.php';
require_once __DIR__ . '/db/db.php';
require_once __DIR__ . '/vanshavali/vanshavali.php';
//If config file exists then include it else leave it
if (file_exists(__DIR__ . "/config.php")) {
if (is_readable(__DIR__ . "/config.php")) {
require_once(__DIR__ . "/config.php");
}
}
//Initialize them
global $db, $template;
$template = new template();
$db = new db();
//Select the default database
if (isset($config['database']) and ! empty($config['database'])) {
$db->select_db($config['database']);
}
//Check if Wordpress is enabled or not
if (!(empty($config['consumer_key']) && empty($config['consumer_key_secret']))) {
vanshavali::$wp_login = true;
}
//Assign the Email Address of admin in the App
vanshavali::$admin_email = $config['admin_email'];
vanshavali::$hostname = $config['hostname'];
//If config is not initialized, don't go further
if (!isset($config))
{
return;
}
global $user;
//Include FamilyTree modules
require_once __DIR__ . '/user/user.php';
require_once __DIR__ . '/suggest/suggest_handler.php';
//Initialize supporting Familytree modules
$user = new user();
$suggest_handler = new suggest_handler();
if (vanshavali::$wp_login) {
$user->setConsumerToken($config['consumer_key'], $config['consumer_key_secret'], $config['end_point'], $config['namespace']);
$user->oauth->setUrl($config['auth_end_point'], $config['access_end_point']);
}
//Register the basic suggests
$suggest_handler->register_handler(ADDMEMBER, "suggest.add.tpl", array("suggested_by", "suggested_to", "newvalue", "sod", "oldvalue"), ADD);
$suggest_handler->register_handler(NAME, "suggest.edit.name.tpl", array("suggested_by", "suggested_to", "oldvalue", "newvalue", "sod"), MODIFY);
$suggest_handler->register_handler(DOB, "suggest.edit.dob.tpl", array("suggested_by", "suggested_to", "oldvalue", "newvalue", "sod"), MODIFY);
$suggest_handler->register_handler(GAON, "suggest.edit.gaon.tpl", array("suggested_by", "suggested_to", "oldvalue", "newvalue", "sod"), MODIFY);
$suggest_handler->register_handler(RELATIONSHIP, "suggest.edit.relationship.tpl", array("suggested_by", "suggested_to", "oldvalue", "newvalue", "sod"), MODIFY);
$suggest_handler->register_handler(ALIVE, "suggest.edit.alive.tpl", array("suggested_by", "suggested_to", "oldvalue", "newvalue", "sod"), MODIFY);
$suggest_handler->register_handler(GENDER, "suggest.edit.gender.tpl", array("suggested_by", "suggested_to", "oldvalue", "newvalue", "sod"), MODIFY);
$suggest_handler->register_handler(DELMEMBER, "suggest.del.tpl", array("suggested_by", "suggested_to", "newvalue", "oldvalue", "sod"), DEL);
$suggest_handler->register_handler(ADDSPOUSE, "suggest.add.spouse.tpl", array("suggested_by", "suggested_to", "newvalue", "oldvalue", "sod"), ADD);
$suggest_handler->register_handler(ADDPARENTS, "suggest.add.parents.tpl", array("suggested_by", "suggested_to", "newvalue", "oldvalue"), ADD);
$suggest_handler->register_handler(REMOVEPARENTS, "suggest.remove.parent.tpl", array("suggested_by", "suggested_to", "newvalue", "oldvalue"), DEL);
$suggest_handler->register_handler(REMOVESPOUSE, "suggest.remove.spouse.tpl", array("suggested_by", "suggested_to", "newvalue", "oldvalue"), DEL);
//Initialize custom error handler
function vanshavali_error($level, $message, $file, $line, $context) {
global $template;
switch ($level) {
case E_USER_ERROR:
case E_USER_WARNING:
$template->assign("message", $message);
$template->assign("lineno", $line);
$template->assign("file", $file);
$template->assign("context", $context);
$template->header();
$template->display("error_high.tpl");
exit(); //exit the file as error level is high
break;
case E_USER_NOTICE:
//If request is AJAX then
if (@$_SERVER['HTTP_X_REQUESTED_WITH']) {
//Prepare the array
$errorarray = array("success" => 0, "message" => $message);
echo json_encode($errorarray);
} else {
$template->assign("message", $message);
$template->assign("lineno", $line);
$template->assign("file", $file);
$template->assign("context", $context);
$template->display("error_low.tpl");
}
}
}
set_error_handler("vanshavali_error"); //Set the custom error handler
?>