This repository has been archived by the owner on Apr 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.php
139 lines (95 loc) · 3.39 KB
/
config.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
include('psm_config.php');
//$psm_actionlogging = true; //if true, every user action (logging in/out, changing an event, etc) will be recorded in the file action.log
//$psm_deftimezone = 'America/New_York'; //name of timezone to be displayed to user. a list of valid values can be found at http://php.net/manual/en/timezones.php
/*$linksi = startmysql();
$sqlsi = "SELECT * FROM `" . $sql_pref . "siteinfo`";
$resultsi = mysql_query($sqlsi) or die("Query failed:\n" . mysql_error());
$rowsi = mysql_fetch_row($resultsi);
$sitetitle = $rowsi[0];
$rowsi = mysql_fetch_row($resultsi);
$sitedescription = $rowsi[0];
$rowsi = mysql_fetch_row($resultsi);
$companyname = $rowsi[0];
mysql_free_result($resultsi);
mysql_close($linksi);*/
///////////////////////////////////////////////
// ignore everything below here except mysql //
///////////////////////////////////////////////
date_default_timezone_set("UTC");
session_start();
$siteaddr = $siteprotocol . $sitedomain . $sitesubdir;
$br = "\n";
$date = getdate();
$psm_deftimezone_obj = timezone_open($psm_deftimezone);
//$usingmysql = false; //gets automatically set when a mysql query is made
$halfassadmincheck = false;
function startmysql() {
global $sql_addr, $sql_user, $sql_pass, $sql_db;
//$usingmysql=true;//commented because I decided not to attempt to dynamically close MySQL results
$link = mysql_connect($sql_addr, $sql_user, $sql_pass) or die("ERROR: Could not connect to database: \n" . mysql_error());
mysql_select_db($sql_db) or die("ERROR: Could not select database: \n" . mysql_error());
return $link;
}
function action_log($logmsg) {
global $psm_actionlogging;
if ($psm_actionlogging) {
error_log("\n" . date("Y-m-d H:i:s") . " [" . $_SERVER['REMOTE_ADDR'] . "] " . $logmsg, 3, $rootdir."action.log");
}
}
function mustBeLoggedIn() {
global $halfassadmincheck;
if (!isset($_SESSION['user']) || ($halfassadmincheck && intval($_SESSION['permission'])<1)) {
$_SESSION['errcode']="106";
header("Location: " . $siteaddr . "/login.php");
die("You must be logged in to do that.");
}
}
function getThemeColors() {
global $backcolor, $forecolor, $forehcolor;
global $def_backcolor, $def_forecolor, $def_forehcolor;
$backcolor = $def_backcolor;
$forecolor = $def_forecolor;
$forehcolor = $def_forehcolor;
/*if (isset($_SESSION['theme'])) {
$themearr = explode(",", $_SESSION['theme']);
$backcolor = $themearr[0];
$forecolor = $themearr[1];
$forehcolor = $themearr[2];
}*/
if (isset($_SESSION['backcolor'])) {
$backcolor = $_SESSION['backcolor'];
}
if (isset($_SESSION['forecolor'])) {
$forecolor = $_SESSION['forecolor'];
}
if (isset($_SESSION['forehcolor'])) {
$forehcolor = $_SESSION['forehcolor'];
}
}
/**
* From http://stackoverflow.com/a/2542531/992504
*/
function getRanges( $nums )
{
$ranges = array();
for ( $i = 0, $len = count($nums); $i < $len; $i++ )
{
$rStart = $nums[$i];
$rEnd = $rStart;
while ( isset($nums[$i+1]) && $nums[$i+1]-$nums[$i] == 1 )
$rEnd = $nums[++$i];
$ranges[] = $rStart == $rEnd ? $rStart : $rStart.'-'.$rEnd;
}
return $ranges;
}
/**
* Modified from http://stackoverflow.com/q/6191503/992504
*/
function prepareTextIcal($text)
{
$search = array('\\', ';', ',', "\r\n", "\n", "\r");
$replace = array('\\\\', '\;', '\,', '\n', '\n', '\n');
return strip_tags(str_replace($search, $replace, $text));
}
?>