1 | <?php |
---|
2 | // current subversion revision |
---|
3 | if (file_exists('cache/svnrev.php')) |
---|
4 | { |
---|
5 | include('cache/svnrev.php'); |
---|
6 | } |
---|
7 | else |
---|
8 | { |
---|
9 | $svn_rev = '463'; |
---|
10 | } |
---|
11 | define('SVN_REV', $svn_rev); |
---|
12 | |
---|
13 | define('LATEST_DB_UPDATE',"011"); |
---|
14 | |
---|
15 | // current version: major.minor.sub |
---|
16 | // unpair numbers for minor = development version |
---|
17 | define('KB_VERSION', '2.0.6'); |
---|
18 | define('KB_RELEASE', '(Apocrypha)'); |
---|
19 | |
---|
20 | // add new corporations here once you've added the logo to img/corps/ |
---|
21 | $corp_npc = array('Guristas', 'Serpentis Corporation', 'Sansha\'s Nation', 'CONCORD', |
---|
22 | 'Mordus Legion', 'Blood Raider', 'Archangels', 'Guardian Angels', 'True Power'); |
---|
23 | |
---|
24 | function shorten($shorten, $by = 22) |
---|
25 | { |
---|
26 | if (strlen($shorten) > $by) |
---|
27 | { |
---|
28 | $s = substr($shorten, 0, $by) . "..."; |
---|
29 | } |
---|
30 | else $s = $shorten; |
---|
31 | |
---|
32 | return $s; |
---|
33 | } |
---|
34 | |
---|
35 | function slashfix($fix) |
---|
36 | { |
---|
37 | return addslashes(stripslashes($fix)); |
---|
38 | } |
---|
39 | |
---|
40 | function roundsec($sec) |
---|
41 | { |
---|
42 | if ($sec <= 0) |
---|
43 | $s = 0.0; |
---|
44 | else |
---|
45 | $s = $sec; |
---|
46 | |
---|
47 | return number_format(round($s, 1), 1); |
---|
48 | } |
---|
49 | //! Check if a version of this template for the igb exists and return that if so. |
---|
50 | function get_tpl($name) |
---|
51 | { |
---|
52 | if (IS_IGB) |
---|
53 | { |
---|
54 | if (file_exists('./templates/igb_'.$name.'.tpl')) |
---|
55 | { |
---|
56 | return 'igb_'.$name.'.tpl'; |
---|
57 | } |
---|
58 | } |
---|
59 | return $name.'.tpl'; |
---|
60 | } |
---|
61 | |
---|
62 | // this is currently only a wrapper but might get |
---|
63 | // timestamp adjustment options in the future |
---|
64 | function kbdate($format, $timestamp = null) |
---|
65 | { |
---|
66 | if ($timestamp === null) |
---|
67 | { |
---|
68 | $timestamp = time(); |
---|
69 | } |
---|
70 | |
---|
71 | if (config::get('date_gmtime')) |
---|
72 | { |
---|
73 | return gmdate($format, $timestamp); |
---|
74 | } |
---|
75 | return date($format, $timestamp); |
---|
76 | } |
---|
77 | |
---|
78 | function getYear() |
---|
79 | { |
---|
80 | $test = kbdate('o'); |
---|
81 | if ($test == 'o') |
---|
82 | { |
---|
83 | $test = kbdate('Y'); |
---|
84 | } |
---|
85 | return $test; |
---|
86 | } |
---|
87 | |
---|
88 | //! Return start date for the given week, month, year or date. |
---|
89 | |
---|
90 | /*! |
---|
91 | * weekno > monthno > startWeek > yearno |
---|
92 | * weekno > monthno > yearno |
---|
93 | * startDate and endDate are used if they restrict the date range further |
---|
94 | * monthno, weekno and startweek are not used if no year is set |
---|
95 | */ |
---|
96 | function makeStartDate($week = 0, $year = 0, $month = 0, $startweek = 0, $startdate = 0) |
---|
97 | { |
---|
98 | $qstartdate=0; |
---|
99 | if(intval($year)>0) |
---|
100 | { |
---|
101 | if($week) |
---|
102 | { |
---|
103 | if ($week == 1) |
---|
104 | {$qstartdate = strtotime($year.'-1-1 00:00 UTC');} |
---|
105 | else |
---|
106 | {$qstartdate = strtotime('last Monday +'.($week-1).' weeks UTC', strtotime($year.'-1-1'));} |
---|
107 | } |
---|
108 | else if($month) |
---|
109 | {$qstartdate = strtotime($year.'-'.$month.'-1 00:00 UTC');} |
---|
110 | else if($startweek) |
---|
111 | { |
---|
112 | if ($startweek == 1) |
---|
113 | {$qstartdate = strtotime($year.'-1-1 00:00 UTC');} |
---|
114 | else |
---|
115 | {$qstartdate = strtotime('last Monday +'.($week-1).' weeks UTC', strtotime($year.'-1-1'));} |
---|
116 | } |
---|
117 | else |
---|
118 | {$qstartdate = strtotime($year.'-1-1 00:00 UTC');} |
---|
119 | } |
---|
120 | //If set use the latest startdate and earliest enddate set. |
---|
121 | if($startdate && $qstartdate < strtotime($startdate." UTC")) $qstartdate = strtotime($startdate." UTC"); |
---|
122 | return $qstartdate; |
---|
123 | } |
---|
124 | |
---|
125 | //! Return end date for the given week, month, year or date. |
---|
126 | |
---|
127 | /*! |
---|
128 | * Priority order of date filters: |
---|
129 | * weekno > monthno > startWeek > yearno |
---|
130 | * weekno > monthno > yearno |
---|
131 | * startDate and endDate are used if they restrict the date range further |
---|
132 | * monthno, weekno and startweek are not used if no year is set |
---|
133 | */ |
---|
134 | function makeEndDate($week = 0, $year = 0, $month = 0, $enddate = 0) |
---|
135 | { |
---|
136 | if($year) |
---|
137 | { |
---|
138 | if($week) |
---|
139 | { |
---|
140 | if ($week == 53) |
---|
141 | $qenddate = strtotime(($year).'-12-31 23:59 UTC'); |
---|
142 | else |
---|
143 | $qenddate = strtotime('last Monday +'.($week).' weeks -1 minute UTC', strtotime($year.'-1-1')); |
---|
144 | } |
---|
145 | else if($month) |
---|
146 | { |
---|
147 | if($month == 12) $qenddate = strtotime(($year).'-12-31 23:59 UTC'); |
---|
148 | else $qenddate = strtotime(($year).'-'.($month + 1).'-1 00:00 - 1 minute UTC'); |
---|
149 | } |
---|
150 | else |
---|
151 | $qenddate = strtotime(($year).'-12-31 23:59 UTC'); |
---|
152 | } |
---|
153 | //If set use the earliest enddate. |
---|
154 | if($enddate && (!$qenddate || ($qenddate && $qenddate > strtotime($enddate." UTC")))) $qenddate = strtotime($enddate." UTC"); |
---|
155 | |
---|
156 | return $qenddate; |
---|
157 | } |
---|
158 | |
---|
159 | if (!function_exists('file_put_contents')) |
---|
160 | { |
---|
161 | function file_put_contents($filename, $data, $flags=null) |
---|
162 | { |
---|
163 | if(!is_null($flags) && $flags == FILE_APPEND) $f = @fopen($filename, 'ab'); |
---|
164 | else $f = @fopen($filename, 'wb'); |
---|
165 | if (!$f) |
---|
166 | { |
---|
167 | return false; |
---|
168 | } else |
---|
169 | { |
---|
170 | $bytes = fwrite($f, $data); |
---|
171 | fclose($f); |
---|
172 | return $bytes; |
---|
173 | } |
---|
174 | } |
---|
175 | } |
---|