root/trunk/redirectors/showip.php

Revision 291, 3.7 kB (checked in by hannes, 3 years ago)

establishing a global warnings array to store and display (choke) warnings

Line 
1 <?php
2
3 /**
4  * Package: Spam Board 5
5  * File: redirectors/showip.php
6  * Description: Show the IP of a user (can be called from every single post)
7  *
8  * Copyright (C) 2007, 2009 Hannes Schueller
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as
12  * published by the Free Software Foundation, version 3 of the
13  * License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program (see LICENCE). If not,
22  * see <http://www.gnu.org/licenses/>.
23  **/
24
25 // called independently from index
26 require_once('../includes/config/settings.php');
27
28 // load classes on demand
29 function __autoload($class) {
30     global $SETTINGS;
31     if (is_file($SETTINGS['fspath'] . 'classes/pages/' . $class . '.php')) {
32         require_once($SETTINGS['fspath'] . 'classes/pages/' . $class . '.php');
33     } elseif (is_file($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php')) {
34         require_once($SETTINGS['fspath'] . 'classes/misc/' . $class . '.php');
35     } else { die('Class ' . $class . ' not found.'); }
36 }
37
38 // initialize global warnings array
39 $WARNINGS = Array();
40
41 // import version number
42 require_once($SETTINGS['fspath'] . 'includes/config/version.php');
43 // bots definition
44 require_once($SETTINGS['fspath'] . 'includes/config/bots.php');
45 // formatting object
46 $F = new Format();
47 require($SETTINGS['fspath'] . 'includes/lang/' . $SETTINGS['language'] . '.php');
48 // open database connection
49 $C = new Connection();
50 Member::session();
51 if (isset($_SESSION['lang']) && $_SESSION['lang'] != '') {
52     include($SETTINGS['fspath'] . 'includes/lang/' . $_SESSION['lang'] . '.php');
53 }
54 // translate passed variables to local identifiers
55 require($SETTINGS['fspath'] . 'includes/input.php');
56
57 // page start
58 $_pref = '../';
59 $html = Page::start();
60
61 // check if user has permission; required: read; dependent on id
62 if (Member::checkRights('Showip', 'r', $INPUT['id'])) {
63     // permission granted
64     // get IP form database
65     $q = $C->prepare('SELECT ip FROM '.$SETTINGS['dbtableprefix'].'posts WHERE postid=:id');
66     $q->bindParam(':id', $INPUT['id'], PDO::PARAM_INT, 12);
67     $q->execute();
68     $_ip = $q->fetchColumn();
69     $q = NULL;
70     // output
71     $html->body->addChild('h2', $LANG['IP']);
72     $div = $html->body->addChild('div', $_ip);
73     $div->addAttribute('class', 'message');
74     $div = $html->body->addChild('div');
75     $div->addAttribute('align', 'center');
76     $a = $div->addChild('a', $LANG['Close_Window']);
77     $a->addAttribute('href', 'javascript:self.close()');
78 } else {
79     $div = $html->body->addChild('div', $LANG['error_permission_denied']);
80     $div->addAttribute('class', 'message');
81 }
82
83 /* figure out which MIME type to send the document with (depending on browser capabilities)
84  * set text/html as default (for deprecated legacy browsers) */
85 $mime = 'text/html';
86 if(stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml')) {
87     if(preg_match('/application\/xhtml\+xml;q=([01]|0\.\d{1,3}|1\.0)/i', $_SERVER['HTTP_ACCEPT'], $matches)) {
88         // priority of XHTML
89         $xhtml_q = $matches[1];
90         if(preg_match('/text\/html;q=q=([01]|0\.\d{1,3}|1\.0)/i', $_SERVER['HTTP_ACCEPT'], $matches)) {
91             // priority of HTML
92             $html_q = $matches[1];
93             if((float)$xhtml_q >= (float)$html_q) {
94                 // browser prefers XHTML over HTML, so send the document as such; this guarantees faster and more reliable rendering
95                 $mime = 'application/xhtml+xml';
96             }
97         }
98     } else {
99         // browser accepts XHTML, but script can't figure out which one it prefers; send as XHTML
100         $mime = 'application/xhtml+xml';
101     }
102 }
103
104 // page output
105 Page::send($html);
106
107 ?>
Note: See TracBrowser for help on using the browser.