This repository was archived by the owner on Dec 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.php
More file actions
585 lines (567 loc) · 21.6 KB
/
Copy pathfunctions.php
File metadata and controls
585 lines (567 loc) · 21.6 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
<?php
/**
* Fix $_SERVER variables for various set-ups.
*
*/
function fix_server_vars() {
global $PHP_SELF;
$default_server_values = array(
'SERVER_SOFTWARE' => '',
'REQUEST_URI' => '',
);
$_SERVER = array_merge( $default_server_values, $_SERVER );
/* Fix for IIS when running with PHP ISAPI */
if ( empty( $_SERVER['REQUEST_URI'] ) || ( php_sapi_name() != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
/* IIS Mod-Rewrite */
if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
} elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
/* IIS Isapi_Rewrite */
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
} else {
/* Use ORIG_PATH_INFO if there is no PATH_INFO */
if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
if ( isset( $_SERVER['PATH_INFO'] ) ) {
if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
else
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
}
// Append the query string if it exists and isn't null
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
}
}
}
// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) )
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
// Fix for Dreamhost and other PHP as CGI hosts
if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false )
unset( $_SERVER['PATH_INFO'] );
// Fix empty PHP_SELF
$PHP_SELF = $_SERVER['PHP_SELF'];
if ( empty( $PHP_SELF ) )
$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] );
}
/**
* Check for the required PHP version, and the MySQL extension or a database drop-in.
*
* Dies if requirements are not met.
*
*/
function ws_check_php_mysql_versions() {
global $required_php_version;
$php_version = phpversion();
if (version_compare($required_php_version, $php_version, '>')) {
die('Your server is running PHP version $php_version but WebStats $version requires at least $required_php_version.');
}
if (!extension_loaded( 'mysql' )) {
die('Your PHP installation appears to be missing the MySQL extension which is required by WebStats.');
}
}
/**
* Sets the current page url
*/
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
else
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
return $pageURL;
}
/**
* Sets the current page url
*
* From the admin page.
*
*/
function adminPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]."/admin";
else
$pageURL .= $_SERVER["SERVER_NAME"]."/admin";
return $pageURL;
}
/**
*
* Sets a database connection
*
*/
class DBConfig {
var $host; var $user; var $pass; var $db; var $db_link; var $conn = false; var $persistant = false; public $error = false;
public function config(){
$this->error = true; $this->persistant = true;
}
function conn($host, $user, $pass, $db, $createdb){
$this->host = $host;
$this->user = $user;
$this->pass = $pass;
$this->db = $db;
/* Establish the connection. */
if ($this->persistant)
$this->db_link = mysqli_connect('p:'.$this->host, $this->user, $this->pass);
else
$this->db_link = mysqli_connect($this->host, $this->user, $this->pass);
if (!$this->db_link) {
if ($this->error) {
$this->error($type=1);
}
return false;
} else {
if (empty($db)) {
if ($this->error) {
$this->error($type=2);
}
} else {
$db = mysqli_select_db($this->db_link, $this->db); /* select db */
if ((!$db) && ($createdb !== true)) {
if ($this->error) {
$this->error($type=2);
}
return false;
}
if((!$db) && ($createdb === true)) {
if(mysqli_query($this->db_link, "CREATE DATABASE IF NOT EXISTS `".$this->db."`")){
echo "Database created :) <br />";
mysqli_select_db($this->db_link, $this->db);
} else {
if ($this->error){
$this->error($type=5);
}
}
}
$this -> conn = true;
}
return $this->db_link;
}
}
function close() { /* close connection */
if ($this -> conn) { /* check connection */
if ($this->persistant) {
$this -> conn = false;
} else {
mysqli_close($this->db_link);
$this -> conn = false;
}
} else {
if ($this->error) {
return $this->error($type=4);
}
}
}
public function error($type='') { /* Choose error type */
if (empty($type)) {
return false;
} else {
if ($type==1) {
echo "<strong>Database could not connect</strong> " . "<br />";
} else if ($type==2) {
echo "<strong>mysql error</strong> " . mysqli_error($this->db_link) . "<br />";
} else if ($type==3) {
echo "<strong>error </strong>, Proses has been stopped" . "<br />";
} else if ($type==4) {
echo "<span style='color: red;'>There was an error while connnecting to the MySQL database. Please contact the webmaster (user, password or host incorrect).</span>" . "<br />";
} else if ($type==5) {
echo "<span style='color: red;'>There was an error while selecting the database. Please contact the webmaster (database name incorrect).</span>";
} else {
echo "Error creating database: " . mysqli_error($this->db_link) . "<br />";
}
}
}
}
/**
* Sets The Date.
*
* @since 3.0
*
* @param integer $stamp Time in seconds since 1969.
*/
function get_date($stamp) {
setlocale(LC_TIME, "usa");
$datum = date ("d. M 'y", $stamp);
return $datum;
}
/**
* Sets Output Format.
*
* @since 3.2
*
* @param integer $time Time in seconds since 1969.
*/
function get_played($time) {
$hour = $time / 3600;
$hour_2 = floor($hour);
$minute_hour = $hour_2 * 60;
$minute = $time / 60;
$minute_2 = $minute - $minute_hour;
$minute_3 = floor($minute_2);
$day = $hour_2 / 24;
$day_2 = floor($day);
$hour_3 = $hour_2 - ($day_2 * 24) ;
$dayholder = 0;
if ($minute_3 <= 9){$minute_3 = '0'.$minute_3;};
if ($day_2 <= 9){$day_2 = ''.$day_2;};
if ($hour_3 <= 9){$hour_3 = '0'.$hour_3;};
if ($hour_2 < 10 && $minute_3 >= 0) {
$played = "0".$hour_2."<span class='timefont'>h</span> ".$minute_3."<span class='timefont'>m</span>";
}
if ($hour_2 >= 10) {
$played = "".$hour_2."<span class='timefont'>h</span> ".$minute_3."<span class='timefont'>m</span>";
}
if (WS_CONFIG_PLAYTIME === true) {
if ($hour_2 >= 24) {
$played = "".$day_2."<span class='timefont'>d</span> ".$hour_3."<span class='timefont'>h</span> ".$minute_3."<span class='timefont'>m</span>";
}
}
return $played;
}
/**
* Sets the page numbers.
*
* @since 3.0
*
* @param integer $numbers Amount of items.
* @param string $mode Page viewed from to set href links.
* @param string $sort Optional viewing control behavior to keep the way of sort.
*/
function get_pages($numbers, $mode, $sort) {
$setamount = WS_CONFIG_PAGENUM;
$numberofpages = array(25, 35, 45, 50, 75, 100);
for($i=0; $i <= sizeof($numberofpages)-1; $i++){
if($_GET["NPP"] == $numberofpages[$i]) {
$dropdownselected = ("<option value='".$numberofpages[$i]."' SELECTED>".$numberofpages[$i]."</option>");
} else
$dropdown .= "<option value='".$numberofpages[$i]."'>".$numberofpages[$i]."</option>";
}
if(!isset($_GET["page"])){$_GET["page"] = 1;}
$output = '<div style="margin:auto;" align="center"><form class="custom">';
if(isset($_GET["mode"])){$inputmode = $_GET["mode"];} else {$inputmode = WS_CONFIG_MODULE;}
$output .= '<input name="mode" type="hidden" value="'.$inputmode.'"/>';
if(isset($_GET["sort"])){$inputsort = $_GET["sort"];} else {$inputsort = 'player';}
$output .= '<input name="sort" type="hidden" value="'.$inputsort.'"/>';
if(isset($_GET["NPP"])) {
$numbers = ceil($numbers / $_GET["NPP"]);
} else {
if(isset($setamount)) {
$_GET["NPP"] = $setamount;
$numbers = ceil($numbers / $setamount);
} else {
$numbers = ceil($numbers / 25);
}
}
$output .= '<table class="pagination"><tbody><tr valign="top">';
$output .= '<td><span data-tooltip aria-haspopup="true" class="has-tip" title="Number of items per page"><select onchange="this.form.submit();" id="customDropdown" class="select2" name="NPP">
'.$dropdownselected.$dropdown.'
</select></span></td>';
//Tests if page number is set.
if(isset($_GET["page"])) {
if(1 == $numbers) {
$pages = '<td class="arrow unavailable">«</td>';
$pages .= '<td style="background: #f5f5f5;" class="current"><a>1</a></td>';
$pages .='<td class="arrow unavailable">»</td>';
} elseif($_GET["page"] <= 6 and $_GET["page"] != $numbers) {
//If the number of pages is less than or equal to 6, and the current page is not the last page.
//If/else beginning of list set-up.
if($_GET["page"]==1) {
$pages = '<td class="arrow unavailable">«</td>';
$pages .= '<td style="background: #f5f5f5;" class="current"><a>1</a></td>';
} else {
$pages = '<td class="arrow"><a class="ajax-link" href="?mode='.$mode.'&page='.($_GET["page"]-1).'&sort='.$sort.'&NPP='.$_GET["NPP"].'">«</a></td>';
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page=1&sort='.$sort.'&NPP='.$_GET["NPP"].'">1</a></td>';
}
//If the number of pages is larger than or equal to 10.
if($numbers >= 10) {
for($i=1; $i < 10; $i++) {
$page = $i + 1;
if($_GET["page"]==$page) {
$pages .= '<td style="background: #f5f5f5;" class="current"><a class="ajax-link" href="#">'.$page.'</a></td>';
} else {
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$page.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.$page.'</a></td>';
}
}
$pages .= '<td class="unavailable">…</td>';
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$numbers.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.floor($numbers).'</a></td>';
} else {
for($i=2; $i <= $numbers; $i++) {
if($_GET["page"]==$i) {
$pages .= '<td style="background: #f5f5f5;" class="current"><a>'.$i.'</a></td>';
} else {
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$i.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.$i.'</a></td>';
}
}
}
if($_GET["page"] < $numbers) {
$pages .='<td class="arrow"><a class="ajax-link" href="?mode='.$mode.'&page='.($_GET["page"] + 1).'&sort='.$sort.'&NPP='.$_GET["NPP"].'">»</a></td>';
} else {
$pages .='<td class="arrow unavailable">»</td>';
}
} elseif($_GET["page"] >= 7 and $_GET["page"] <= ($numbers-6)) {
//If the number of pages is greater than or equal to 7, and the current page is not within 5 pages from the end.
$pages = '<td class="arrow"><a class="ajax-link" href="?mode='.$mode.'&page='.($_GET["page"]-1).'&sort='.$sort.'&NPP='.$_GET["NPP"].'">«</a></td>';
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page=1&sort='.$sort.'&NPP='.$_GET["NPP"].'">1</a></td>';
$pages .= '<td class="unavailable">…</td>';
for($i=($_GET["page"]-5); $i < ($_GET["page"]+4); $i++) {
$page = $i + 1;
if($_GET["page"]==$page) {
$pages .= '<td style="background: #f5f5f5;" class="current"><a>'.$page.'</a></td>';
} else {
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$page.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.$page.'</a></td>';
}
}
$pages .= '<td class="unavailable">…</td>';
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$numbers.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.floor($numbers).'</a></td>';
$pages .='<td class="arrow"><a class="ajax-link" href="?mode='.$mode.'&page='.($_GET["page"] + 1).'&sort='.$sort.'&NPP='.$_GET["NPP"].'">»</a></td>';
} elseif($_GET["page"] < $numbers and $_GET["page"] >= ($numbers-5)) {
//If the current page is less than the number of pages, and the current page is not within 5 pages from the end.
$pages = '<td class="arrow"><a>«</a></td>';
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page=1&sort='.$sort.'&NPP='.$_GET["NPP"].'">1</a></td>';
$pages .= '<td class="unavailable">…</td>';
for($i=($_GET["page"]-5); $i < $numbers; $i++) {
$page = $i + 1;
if($_GET["page"]==$page){
$pages .= '<td style="background: #f5f5f5;" class="current"><a>'.$page.'</a></td>';
} else {
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$page.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.$page.'</a></td>';
}
}
$pages .='<td class="arrow"><a>»</a></td>';
} elseif($_GET["page"] > $numbers) {
//If the current page is greater than the number of pages.
if (($_GET["page"]-5) == 1) {
$pages = '<td class="arrow unavailable">«</td>';
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page=1&sort='.$sort.'&NPP='.$_GET["NPP"].'">1</a></td>';
} else {
$pages = '<td class="arrow unavailable"><a class="ajax-link" href="?mode='.$mode.'&page='.($_GET["page"]-1).'&sort='.$sort.'&NPP='.$_GET["NPP"].'">«</a></td>';
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page=1&sort='.$sort.'&NPP='.$_GET["NPP"].'">1</a></td>';
$pages .= '<td class="unavailable">…</td>';
for($i=$size; $i < $numbers; $i++) {
if($_GET["page"]==$i) {
$pages .= '<td style="background: #f5f5f5;" class="current"><a>'.$i.'</a></td>';
} else {
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$i.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.$i.'</a></td>';
}
}
}
for($i=5;$i >= 2; $i--) {
if((($_GET["page"]-$i) >= 1)){$size = $_GET["page"]-$i; break 1;}
}
$pages .='<td class="arrow unavailable">»</td>';
} elseif(($_GET["page"] == $numbers) && ($numbers <= 9)) {
$pages = '<td class="arrow"><a class="ajax-link" href="?mode='.$mode.'&page='.($_GET["page"]-1).'&sort='.$sort.'&NPP='.$_GET["NPP"].'">«</a></td>';
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page=1&sort='.$sort.'&NPP='.$_GET["NPP"].'">1</a></td>';
for($i=2; $i <= $numbers; $i++) {
if($_GET["page"]==$i) {
$pages .= '<td style="background: #f5f5f5;" class="current"><a>'.$i.'</a></td>';
} else {
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$i.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.$i.'</a></td>';
}
}
$pages .='<td class="arrow unavailable">»</td>';
} elseif(($_GET["page"] == $numbers) && ($numbers > 9)) {
$pages = '<td class="arrow"><a>«</a></td>';
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page=1&sort='.$sort.'&NPP='.$_GET["NPP"].'">1</a></td>';
$pages .= '<td class="unavailable">…</td>';
for($i=($_GET["page"]-7); $i < $numbers; $i++) {
$page = $i + 1;
if($_GET["page"]==$page){
$pages .= '<td style="background: #f5f5f5;" class="current"><a>'.$page.'</a></td>';
} else {
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$page.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.$page.'</a></td>';
}
}
$pages .='<td class="arrow unavailable">»</td>';
}
} else {
//If page number is not set. It must be page 1.
$pages = '<td class="arrow unavailable">«</td>';
$pages .= '<td style="background: #f5f5f5;" class="current"><a>1</a></td>';
//If the number of pages is more than or equal to 10.
if($numbers >= 10) {
for($i=1; $i <= 10; $i++) {
if($i==$_GET["page"]){
$pages .= '<td style="background: #f5f5f5;" class="current"><a>'.$i.'</a></td>';
} else {
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$i.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.$i.'</a></td>';
}
}
$pages .='<td class="arrow"><a class="ajax-link" href="?mode='.$mode.'&page=2&sort='.$sort.'&NPP='.$_GET["NPP"].'">»</a></td>';
} else {
//Else the number of pages must be 9 or less.
for($i=2; $i <= $numbers; $i++) {
$pages .= '<td><a class="ajax-link" href="?mode='.$mode.'&page='.$i.'&sort='.$sort.'&NPP='.$_GET["NPP"].'">'.$i.'</a></td>';
}
$pages .='<td class="arrow unavailable">»</td>';
}
}
if(isset($_GET["page"])){$inputpage = $_GET["page"];} else {$inputpage = 1;}
$pages .='<td class="input"><input style="margin:0 0 0 0; width: 40px;" maxlength="20" name="page" type="text" value="'.$inputpage.'"/></td>';
$output .= $pages.'</tr></tbody></table></form></div>';
return $output;
}
function get_tag($tag,$xml) {
preg_match_all('/<'.$tag.'>(.*)<\/'.$tag.'>$/imU',$xml,$match);
return $match[1];
}
/**
* This function will check whether the visitor is a search engine robot.
*
* @since 3.0
*
*/
function is_bot() {
$botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
"looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
"Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
"crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp",
"msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
"Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
"Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
"Butterfly","Twitturls","Me.dium","Twiceler");
foreach($botlist as $bot) {
if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
return true; // Is a bot
}
return false; // Not a bot
}
/**
* Kill WebStats execution and display HTML message with error message.
*
* This function complements the die() PHP function. The difference is that
* HTML will be displayed to the user. It is recommended to use this function
* only, when the execution should not continue any further. It is not
* recommended to call this function very often and try to handle as many errors
* as possible silently.
*
* @since 3.0
*
* @param string $message Error message.
* @param string $title Error title.
* @param string|array $args Optional arguments to control behavior.
*/
function ws_die($message = '', $title = '', $args = array()) {
$function ='_default_ws_die_handler';
call_user_func( $function, $message, $title, $args );
}
/**
* Kill WebStats execution and display HTML message with error message.
*
* This is the default handler for ws_die if you want a custom one for your
* site then you can overload using the wp_die_handler filter in wp_die
*
* @since 3.0
* @access private
*
* @param string $message Error message.
* @param string $title Error title.
* @param string|array $args Optional arguments to control behavior.
*/
function _default_ws_die_handler($message, $title = '', $args = array()) {
$defaults = array( 'response' => 500 );
$message = "<p>$message</p>";
$back_text = ('« Back');
$message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";
header( 'Content-Type: text/html; charset=utf-8' );
if(empty($title)) {$title = 'Web Stats › Error';}
echo <<<END
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>$title</title>
<link rel="stylesheet" href="../css/foundation-icons.css" />
<style type="text/css">
body {
background: #fff;
color: #333;
font-family: sans-serif;
margin: 2em auto;
padding: 1em 2em;
-webkit-border-radius: 3px;
border-radius: 3px;
border: 1px solid #dfdfdf;
max-width: 700px;
}
h1 {
border-bottom: 1px solid #dadada;
clear: both;
color: #666;
font: 24px Georgia, "Times New Roman", Times, serif;
margin: 30px 0 0 0;
padding: 0;
padding-bottom: 7px;
}
#error-page {
margin-top: 50px;
}
#error-page p {
font-size: 14px;
line-height: 1.5;
margin: 25px 0 20px;
}
#error-page code {
font-family: Consolas, Monaco, monospace;
}
ul li {
margin-bottom: 10px;
font-size: 14px ;
}
a {
color: #21759B;
text-decoration: none;
}
a:hover {
color: #D54E21;
}
.button {
font-family: sans-serif;
text-decoration: none;
font-size: 14px !important;
line-height: 16px;
padding: 6px 12px;
cursor: pointer;
border: 1px solid #bbb;
color: #464646;
-webkit-border-radius: 15px;
border-radius: 15px;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
background-color: #f5f5f5;
background-image: -ms-linear-gradient(top, #ffffff, #f2f2f2);
background-image: -moz-linear-gradient(top, #ffffff, #f2f2f2);
background-image: -o-linear-gradient(top, #ffffff, #f2f2f2);
background-image: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#f2f2f2));
background-image: -webkit-linear-gradient(top, #ffffff, #f2f2f2);
background-image: linear-gradient(top, #ffffff, #f2f2f2);
}
.button:hover {
color: #000;
border-color: #666;
}
.button:active {
background-image: -ms-linear-gradient(top, #f2f2f2, #ffffff);
background-image: -moz-linear-gradient(top, #f2f2f2, #ffffff);
background-image: -o-linear-gradient(top, #f2f2f2, #ffffff);
background-image: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#ffffff));
background-image: -webkit-linear-gradient(top, #f2f2f2, #ffffff);
background-image: linear-gradient(top, #f2f2f2, #ffffff);
}
</style>
</head>
<body id="error-page">
$message
</body>
</html>
END;
die();
}
?>