Initial import

master
Kubwa 2020-11-28 09:19:59 +01:00
commit a6aad1bace
25 changed files with 1280 additions and 0 deletions

BIN
Banned.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
Boards.iar Normal file

Binary file not shown.

20
Config.php Normal file
View File

@ -0,0 +1,20 @@
<?php
/***********************************************************************
* Script (c) Kubwa (https://kubwa.de)
*
* This script was release under BSD license.
* You are free to use, share or change this code as you wish. This
* header must be kept intact.
***********************************************************************/
$GLOBALS["CONFIG"] = array(
//Config for mysql server
"mysql" => array(
"server" => "127.0.0.1",
"user" => "root",
"pass" => "***",
"db" => "visitorboard"
)
);
?>

299
Database.sql Normal file
View File

@ -0,0 +1,299 @@
CREATE TABLE IF NOT EXISTS `bans` (
`banvalue` varchar(128) NOT NULL,
`nums` bigint(6) NOT NULL DEFAULT 0,
`comment` mediumtext NOT NULL DEFAULT '',
`lastseen` varchar(36) NOT NULL DEFAULT '',
PRIMARY KEY (`banvalue`),
KEY `nums` (`nums`),
KEY `Idx_lastseen` (`lastseen`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Gebante und aus dem System ausgeschlossene Avatare für Besucherboards';
CREATE TABLE IF NOT EXISTS `countries_lang` (
`country` varchar(2) NOT NULL,
`name` varchar(64) NOT NULL,
`lang` varchar(2) NOT NULL,
PRIMARY KEY (`country`),
KEY `lang` (`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Sprachzuordnung zu Ländern für Besucherboards';
INSERT INTO `countries_lang` (`country`, `name`, `lang`) VALUES
('ad', 'Andorra', 'ca'),
('ae', 'United Arab Emirates', 'ar'),
('af', 'Afghanistan', 'fa'),
('ag', 'Antigua and Barbuda', 'en'),
('ai', 'Anguilla', 'en'),
('al', 'Albania', 'sq'),
('am', 'Armenia', 'hy'),
('an', 'Netherlands Antilles', 'nl'),
('ao', 'Angola', 'pt'),
('ar', 'Argentina', 'es'),
('as', 'American Samoa', 'en'),
('at', 'Austria', 'de'),
('au', 'Australia', 'en'),
('aw', 'Aruba', 'nl'),
('ax', 'Aland Islands', 'sv'),
('az', 'Azerbaijan', 'az'),
('ba', 'Bosnia and Herzegovina', 'bs'),
('bb', 'Barbados', 'en'),
('bd', 'Bangladesh', 'bn'),
('be', 'Belgium', 'nl'),
('bf', 'Burkina Faso', 'fr'),
('bg', 'Bulgaria', 'bg'),
('bh', 'Bahrain', 'ar'),
('bi', 'Burundi', 'fr'),
('bj', 'Benin', 'fr'),
('bl', 'Saint Barthelemy', 'fr'),
('bm', 'Bermuda', 'en'),
('bn', 'Brunei', 'ms'),
('bo', 'Bolivia', 'es'),
('bq', 'Bonaire Saint Eustatius and Saba ', 'nl'),
('br', 'Brazil', 'pt'),
('bs', 'Bahamas', 'en'),
('bt', 'Bhutan', 'dz'),
('bw', 'Botswana', 'en'),
('by', 'Belarus', 'be'),
('bz', 'Belize', 'en'),
('ca', 'Canada', 'en'),
('cc', 'Cocos Islands', 'ms'),
('cd', 'Democratic Republic of the Congo', 'fr'),
('cf', 'Central African Republic', 'fr'),
('cg', 'Republic of the Congo', 'fr'),
('ch', 'Switzerland', 'de'),
('ci', 'Ivory Coast', 'fr'),
('ck', 'Cook Islands', 'en'),
('cl', 'Chile', 'es'),
('cm', 'Cameroon', 'en'),
('cn', 'China', 'zh'),
('co', 'Colombia', 'es'),
('cr', 'Costa Rica', 'es'),
('cs', 'Serbia and Montenegro', 'cu'),
('cu', 'Cuba', 'es'),
('cv', 'Cabo Verde', 'pt'),
('cw', 'Curacao', 'nl'),
('cx', 'Christmas Island', 'en'),
('cy', 'Cyprus', 'el'),
('cz', 'Czechia', 'cs'),
('de', 'Germany', 'de'),
('dj', 'Djibouti', 'fr'),
('dk', 'Denmark', 'da'),
('dm', 'Dominica', 'en'),
('do', 'Dominican Republic', 'es'),
('dz', 'Algeria', 'ar'),
('ec', 'Ecuador', 'es'),
('ee', 'Estonia', 'et'),
('eg', 'Egypt', 'ar'),
('eh', 'Western Sahara', 'ar'),
('er', 'Eritrea', 'aa'),
('es', 'Spain', 'es'),
('et', 'Ethiopia', 'am'),
('fi', 'Finland', 'fi'),
('fj', 'Fiji', 'en'),
('fk', 'Falkland Islands', 'en'),
('fm', 'Micronesia', 'en'),
('fo', 'Faroe Islands', 'fo'),
('fr', 'France', 'fr'),
('ga', 'Gabon', 'fr'),
('gb', 'United Kingdom', 'en'),
('gd', 'Grenada', 'en'),
('ge', 'Georgia', 'ka'),
('gf', 'French Guiana', 'fr'),
('gg', 'Guernsey', 'en'),
('gh', 'Ghana', 'en'),
('gi', 'Gibraltar', 'en'),
('gl', 'Greenland', 'kl'),
('gm', 'Gambia', 'en'),
('gn', 'Guinea', 'fr'),
('gp', 'Guadeloupe', 'fr'),
('gq', 'Equatorial Guinea', 'es'),
('gr', 'Greece', 'el'),
('gs', 'South Georgia and the South Sandwich Islands', 'en'),
('gt', 'Guatemala', 'es'),
('gu', 'Guam', 'en'),
('gw', 'Guinea-Bissau', 'pt'),
('gy', 'Guyana', 'en'),
('hk', 'Hong Kong', 'zh'),
('hn', 'Honduras', 'es'),
('hr', 'Croatia', 'hr'),
('ht', 'Haiti', 'ht'),
('hu', 'Hungary', 'hu'),
('id', 'Indonesia', 'id'),
('ie', 'Ireland', 'en'),
('il', 'Israel', 'he'),
('im', 'Isle of Man', 'en'),
('in', 'India', 'en'),
('io', 'British Indian Ocean Territory', 'en'),
('iq', 'Iraq', 'ar'),
('ir', 'Iran', 'fa'),
('is', 'Iceland', 'is'),
('it', 'Italy', 'it'),
('je', 'Jersey', 'en'),
('jm', 'Jamaica', 'en'),
('jo', 'Jordan', 'ar'),
('jp', 'Japan', 'ja'),
('ke', 'Kenya', 'en'),
('kg', 'Kyrgyzstan', 'ky'),
('kh', 'Cambodia', 'km'),
('ki', 'Kiribati', 'en'),
('km', 'Comoros', 'ar'),
('kn', 'Saint Kitts and Nevis', 'en'),
('kp', 'North Korea', 'ko'),
('kr', 'South Korea', 'ko'),
('kw', 'Kuwait', 'ar'),
('ky', 'Cayman Islands', 'en'),
('kz', 'Kazakhstan', 'kk'),
('la', 'Laos', 'lo'),
('lb', 'Lebanon', 'ar'),
('lc', 'Saint Lucia', 'en'),
('li', 'Liechtenstein', 'de'),
('lk', 'Sri Lanka', 'si'),
('lr', 'Liberia', 'en'),
('ls', 'Lesotho', 'en'),
('lt', 'Lithuania', 'lt'),
('lu', 'Luxembourg', 'lb'),
('lv', 'Latvia', 'lv'),
('ly', 'Libya', 'ar'),
('ma', 'Morocco', 'ar'),
('mc', 'Monaco', 'fr'),
('md', 'Moldova', 'ro'),
('me', 'Montenegro', 'sr'),
('mf', 'Saint Martin', 'fr'),
('mg', 'Madagascar', 'fr'),
('mh', 'Marshall Islands', 'mh'),
('mk', 'North Macedonia', 'mk'),
('ml', 'Mali', 'fr'),
('mm', 'Myanmar', 'my'),
('mn', 'Mongolia', 'mn'),
('mo', 'Macao', 'zh'),
('mp', 'Northern Mariana Islands', 'fi'),
('mq', 'Martinique', 'fr'),
('mr', 'Mauritania', 'ar'),
('ms', 'Montserrat', 'en'),
('mt', 'Malta', 'mt'),
('mu', 'Mauritius', 'en'),
('mv', 'Maldives', 'dv'),
('mw', 'Malawi', 'ny'),
('mx', 'Mexico', 'es'),
('my', 'Malaysia', 'ms'),
('mz', 'Mozambique', 'pt'),
('na', 'Namibia', 'en'),
('nc', 'New Caledonia', 'fr'),
('ne', 'Niger', 'fr'),
('nf', 'Norfolk Island', 'en'),
('ng', 'Nigeria', 'en'),
('ni', 'Nicaragua', 'es'),
('nl', 'Netherlands', 'nl'),
('no', 'Norway', 'no'),
('np', 'Nepal', 'ne'),
('nr', 'Nauru', 'na'),
('nu', 'Niue', 'ni'),
('nz', 'New Zealand', 'en'),
('om', 'Oman', 'ar'),
('pa', 'Panama', 'es'),
('pe', 'Peru', 'es'),
('pf', 'French Polynesia', 'fr'),
('pg', 'Papua New Guinea', 'en'),
('ph', 'Philippines', 'tl'),
('pk', 'Pakistan', 'ur'),
('pl', 'Poland', 'pl'),
('pm', 'Saint Pierre and Miquelon', 'fr'),
('pn', 'Pitcairn', 'en'),
('pr', 'Puerto Rico', 'en'),
('ps', 'Palestinian Territory', 'ar'),
('pt', 'Portugal', 'pt'),
('pw', 'Palau', 'pa'),
('py', 'Paraguay', 'es'),
('qa', 'Qatar', 'ar'),
('re', 'Reunion', 'fr'),
('ro', 'Romania', 'ro'),
('rs', 'Serbia', 'sr'),
('ru', 'Russia', 'ru'),
('rw', 'Rwanda', 'rw'),
('sa', 'Saudi Arabia', 'ar'),
('sb', 'Solomon Islands', 'en'),
('sc', 'Seychelles', 'en'),
('sd', 'Sudan', 'ar'),
('se', 'Sweden', 'sv'),
('sg', 'Singapore', 'cm'),
('sh', 'Saint Helena', 'en'),
('si', 'Slovenia', 'sl'),
('sj', 'Svalbard and Jan Mayen', 'no'),
('sk', 'Slovakia', 'sk'),
('sl', 'Sierra Leone', 'en'),
('sm', 'San Marino', 'it'),
('sn', 'Senegal', 'fr'),
('so', 'Somalia', 'so'),
('sr', 'Suriname', 'nl'),
('ss', 'South Sudan', 'en'),
('st', 'Sao Tome and Principe', 'pt'),
('sv', 'El Salvador', 'es'),
('sx', 'Sint Maarten', 'nl'),
('sy', 'Syria', 'ar'),
('sz', 'Eswatini', 'en'),
('tc', 'Turks and Caicos Islands', 'en'),
('td', 'Chad', 'fr'),
('tf', 'French Southern Territories', 'fr'),
('tg', 'Togo', 'fr'),
('th', 'Thailand', 'th'),
('tj', 'Tajikistan', 'tg'),
('tk', 'Tokelau', 'tk'),
('tl', 'Timor Leste', 'te'),
('tm', 'Turkmenistan', 'tk'),
('tn', 'Tunisia', 'ar'),
('to', 'Tonga', 'to'),
('tr', 'Turkey', 'tr'),
('tt', 'Trinidad and Tobago', 'en'),
('tv', 'Tuvalu', 'tv'),
('tw', 'Taiwan', 'zh'),
('tz', 'Tanzania', 'sw'),
('ua', 'Ukraine', 'uk'),
('ug', 'Uganda', 'en'),
('um', 'United States Minor Outlying Islands', 'en'),
('us', 'United States', 'en'),
('uy', 'Uruguay', 'es'),
('uz', 'Uzbekistan', 'uz'),
('va', 'Vatican', 'la'),
('vc', 'Saint Vincent and the Grenadines', 'en'),
('ve', 'Venezuela', 'es'),
('vg', 'British Virgin Islands', 'en'),
('vi', 'U.S. Virgin Islands', 'en'),
('vn', 'Vietnam', 'vi'),
('vu', 'Vanuatu', 'bi'),
('wf', 'Wallis and Futuna', 'wl'),
('ws', 'Samoa', 'sm'),
('xk', 'Kosovo', 'sq'),
('ye', 'Yemen', 'ar'),
('yt', 'Mayotte', 'fr'),
('za', 'South Africa', 'zu'),
('zm', 'Zambia', 'en'),
('zw', 'Zimbabwe', 'en');
CREATE TABLE IF NOT EXISTS `helpvals` (
`name` varchar(64) NOT NULL,
`val` varchar(8192) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Hilfsdaten für Besucherboards';
CREATE TABLE IF NOT EXISTS `ip_timezones` (
`ip` varchar(32) NOT NULL,
`timezone` varchar(64) NOT NULL,
`country` varchar(4) NOT NULL,
`unix` bigint(255) NOT NULL,
PRIMARY KEY (`ip`),
KEY `unix` (`unix`),
KEY `country_unix` (`country`,`unix`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Gecachte Zeitzonen und Landinfos zu IPs (gehashed) für Besucherboards';
CREATE TABLE IF NOT EXISTS `userdata` (
`id` varchar(36) NOT NULL DEFAULT '',
`userdata` varchar(8192) NOT NULL,
`lastreq` bigint(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `lastreq` (`lastreq`),
KEY `Idx_id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Userdaten Cache für Besucherboards';
CREATE TABLE IF NOT EXISTS `_datastore` (
`id` varchar(64) NOT NULL,
`data` mediumtext DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Arbeitsdatensätze';

BIN
Fonts/BRSANRT0.TTF Normal file

Binary file not shown.

Binary file not shown.

BIN
Fonts/DJB Chalk It Up.ttf Normal file

Binary file not shown.

BIN
Img/Blackboard.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

BIN
Img/ChalkBorder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

62
Language/lang.txt Normal file
View File

@ -0,0 +1,62 @@
[de]
title_1=Letzte Besucher
title_2=Frühere Besucher
title_name=Name
title_from=Kommt aus
title_time=Zeit
[en]
title_1=Latest visitors
title_2=Earlier visitors
title_name=Name
title_from=From
title_time=Time
[ru]
title_1=posledniy posetitel' (Latest visitors)
title_2=Raneye posetiteli (Earlier visitors)
title_name=Familiya (Name)
title_from=Proiskhodit iz (From)
title_time=vremya (Time)
[fr]
title_1=Dernier visiteur
title_2=Anciens visiteurs
title_name=Nom de famille
title_from=Vient de
title_time=Temps
[es]
title_1=Últimos visitantes
title_2=Visitantes anteriores
title_name=Nombre
title_from=Desde
title_time=Hora
[pl]
title_1=Ostatni odwiedzający
title_2=Wcześniejsi goście
title_name=Imię
title_from=Od
title_time=Czas
[pt]
title_1=Últimos visitantes
title_2=Visitantes anteriores
title_name=Nome
title_from=De
title_time=Tempo
[cn]
title_1=Zuìxīn fǎngkè
title_2=Jiào zǎo de fǎngkè
title_name=Míngchēng
title_from=Cóng
title_time=Shíjiān
[it]
title_1=Ultimi visitatori
title_2=Visitatori precedenti
title_name=Nome
title_from=A partire dal
title_time=Tempo

BIN
NoImage.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

0
README.md Normal file
View File

BIN
Update.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
binary_helper/magick Normal file

Binary file not shown.

BIN
binary_helper/magick.exe Normal file

Binary file not shown.

View File

@ -0,0 +1,120 @@
<?php
/***********************************************************************
* Script (c) Kubwa (https://kubwa.de)
*
* This script was release under BSD license.
* You are free to use, share or change this code as you wish. This
* header must be kept intact.
***********************************************************************/
class MySql
{
private $Connection;
public function __construct($User, $Pass, $Database = null, $Server = "127.0.0.1")
{
$this->Connection = mysqli_connect($Server, $User, $Pass);
if ($Database != null)
{mysqli_select_db($Database, $this->Connection);}
$this->query("CREATE TABLE IF NOT EXISTS _datastore (id VARCHAR(64) PRIMARY KEY, data TEXT)");
}
public function id($Len = 36)
{
$Chars = str_shuffle("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
$Res = "";
for ($i = 0; $i < $Len; ++$i) {$Res = $Res.substr($Chars, rand(0, strlen($Chars) - 1), 1);}
return $Res;
}
public function close()
{mysql_close($this->Connection);}
public function ping()
{return mysqli_ping($this->Connection);}
public function query($Query, $Values = array())
{
$Whitespaces = array(" ", "\t", "\n", "\r", "\0", "\x0B");
$ReplaceData = array(array(), array());
$StartOffset = 1;
if (stripos($Query, "{0}") !== false) {$StartOffset = 0;}
foreach($Values as $Key => $Value)
{
if (is_numeric($Key)) {$Key = $Key + $StartOffset;}
$InQueryPos = stripos($Query, "{".$Key."}");
if ($InQueryPos !== false)
{
$LeadingChr = "";
for ($u = $InQueryPos - 1; $u > -1; $u = $u - 1)
{
if (!in_array(substr($Query, $u, 1), $Whitespaces))
{
if (substr($Query, $u, 1) != "'") {$LeadingChr = "'";}
break;
}
}
$FollowingChr = "";
for ($u = $InQueryPos + strlen("{".$Key."}"); $u < strlen($Query); $u = $u + 1)
{
if (!in_array(substr($Query, $u, 1), $Whitespaces))
{
if (substr($Query, $u, 1) != "'") {$FollowingChr = "'";}
break;
}
}
if ($InQueryPos + strlen("{".$Key."}") >= strlen($Query)) {$FollowingChr = "'";}
$ReplaceData[0][] = "{".$Key."}";
$ReplaceData[1][] = $LeadingChr.mysqli_real_escape_string($Value, $this->Connection).$FollowingChr;
}
}
$Query = str_ireplace($ReplaceData[0], $ReplaceData[1], $Query);
$MysqlRes = new MySqlResult(mysqli_query($Query, $this->Connection), $Query);
return $MysqlRes;
}
public function setting($Name, $Value = null)
{
$Name = strtoupper($Name);
if (!isset($Value))
{
$Res = $this->query("SELECT * FROM _datastore WHERE id = '{0}' LIMIT 1", array($Name));
if ($Res->error() == "")
{
$DataRes = $Res->fetch();
if (isset($DataRes)) {return $DataRes[data];}
return false;
}
return null;
}
else
{$this->query("REPLACE INTO _datastore (id, data)VALUES('{0}', '{1}')", array($Name, $Value));}
}
}
class MySqlResult
{
private $MySqlRes;
private $Error;
private $QueryString;
public function __construct($QueryRes, $QueryStr)
{
$this->MySqlRes = $QueryRes;
$this->Error = mysqli_error($this->Connection);
$this->QueryString = $QueryStr;
}
public function fetch()
{return mysqli_fetch_array($this->MySqlRes);}
public function error()
{return $this->Error;}
public function querystring()
{return $this->QueryString;}
public function numrows()
{return mysqli_num_rows($this->MySqlRes);}
}
?>

366
classes/GridUserInfo.php Normal file

File diff suppressed because one or more lines are too long

84
classes/Http.php Normal file
View File

@ -0,0 +1,84 @@
<?php
/***********************************************************************
* Script (c) Kubwa (https://kubwa.de)
*
* This script was release under BSD license.
* You are free to use, share or change this code as you wish. This
* header must be kept intact.
***********************************************************************/
function HttpRequest($Host, $PostData = "", $Auth = "", $Timeout = 60, $ContentType = "application/x-www-form-urlencoded")
{
$Res = "";
try
{
if (function_exists("curl_init"))
{
$Handler = curl_init();
curl_setopt($Handler, CURLOPT_URL, $Host);
curl_setopt($Handler, CURLOPT_TIMEOUT, $Timeout);
curl_setopt($Handler, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($Handler, CURLOPT_SSL_VERIFYPEER, false);
$Headers = array();
$Headers[] = "Connection: Close";
$Headers[] = "User-Agent: Kubwa Framework HTTP-Request";
if (!empty($Auth))
{$Headers[] = "Authorization: Basic ".base64_encode($Auth);}
if (!empty($PostData))
{
$Headers[] = "Content-type: ".$ContentType;
$Headers[] = "Content-Length: ".strlen($PostData);
curl_setopt($Handler, CURLOPT_POST, true);
curl_setopt($Handler, CURLOPT_POSTFIELDS, $PostData);
}
curl_setopt($Handler, CURLOPT_HTTPHEADER, $Headers);
curl_setopt($Handler, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($Handler, CURLOPT_HEADER, false);
curl_setopt($Handler, CURLOPT_RETURNTRANSFER, true);
$Res = curl_exec($Handler);
curl_close($Handler);
}
else
{
$Headers = array();
$Headers[] = "Connection: Close";
$Headers[] = "User-Agent: Kubwa Framework HTTP-Request";
if (!empty($Auth))
{$Headers[] = "Authorization: Basic ".base64_encode($Auth);}
if (!empty($PostData))
{
$Headers[] = "Content-type: ".$ContentType;
$Headers[] = "Content-Length: ".strlen($PostData);
$Options = array('http' => array( 'header' => $Headers,
'method' => 'POST',
'timeout' => $Timeout,
'content' => $PostData
),
'ssl' => array( 'verify_peer' => false,
'allow_self_signed' => true
)
);
}
else
{
$Options = array('http' => array( 'header' => $Headers,
'method' => 'GET',
'timeout' => $Timeout
),
'ssl' => array( 'verify_peer' => false,
'allow_self_signed' => true
)
);
}
$Res = file_get_contents($Host, false, stream_context_create($Options));
}
return $Res;
}
catch (HttpException $ex)
{
return $ex;
}
}
?>

12
classes/Xml.php Normal file
View File

@ -0,0 +1,12 @@
<?php
/***********************************************************************
* Script (c) Kubwa (https://kubwa.de)
*
* This script was release under BSD license.
* You are free to use, share or change this code as you wish. This
* header must be kept intact.
***********************************************************************/
function ParseXml($Xml)
{return json_decode(json_encode(simplexml_load_string($Xml, "SimpleXMLElement", LIBXML_NOCDATA)), true);}
?>

265
index.php Normal file
View File

@ -0,0 +1,265 @@
<?php
/***********************************************************************
* Script (c) Kubwa (https://kubwa.de)
*
* This script was release under BSD license.
* You are free to use, share or change this code as you wish. This
* header must be kept intact.
***********************************************************************/
require_once("classes/Framework.MySql.Class.php");
require_once("classes/GridUserInfo.php");
require_once("classes/Http.php");
require_once("classes/Xml.php");
require_once("Config.php");
/*
This is the new visitorboard code.
It will generate a nice looking png image that is being shown on the visitorboard inworld.
*/
//Database
$MySql = new MySql($GLOBALS["CONFIG"]["mysql"]["user"], $GLOBALS["CONFIG"]["mysql"]["pass"], $GLOBALS["CONFIG"]["mysql"]["db"], $GLOBALS["CONFIG"]["mysql"]["server"]);
//Handle languagefile
LoadLanguages();
$SelLang = strtolower($_GET["l"]);
if (!isset($GLOBALS["LanguageData"][$SelLang])) {$SelLang = "en";}
//Look up timezone, country and the (hopefulle) correct language for the region that requests this image
$ListOfTimezones = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
$MySql->query("DELETE FROM ip_timezones WHERE unix < {0} OR (unix < {1} AND country = '')", array(time() - 86400 * 60, time() - 86400));
$Exists = $MySql->query("SELECT * FROM ip_timezones WHERE ip = md5({0}) LIMIT 1", array($_SERVER["REMOTE_ADDR"]))->fetch();
$TimeZone = "Europe/Berlin";
$Country = "DE";
if (empty($Exists["ip"]))
{
//We can also use another service to trace the ip, if you wish so, change this code
$TraceRequest = json_decode(HttpRequest("http://ip-api.com/json/".$_SERVER["REMOTE_ADDR"], "", 3), true);
if ($TraceRequest["status"] == "success")
{
$TimeZone = $TraceRequest["timezone"];
$Country = $TraceRequest["countryCode"];
}
//To have a minimum of dataprotection, we are hashing the cached ip addresses
$MySql->query("INSERT INTO ip_timezones (ip, timezone, country, unix)VALUES(md5({0}), {1}, {2}, {3})", array($_SERVER["REMOTE_ADDR"], $TimeZone, $Country, time()));
}
else
{
$TimeZone = $Exists["timezone"];
$Country = $Exists["country"];
}
if (in_array(strtolower($TimeZone), $ListOfTimezones))
{date_default_timezone_set($TimeZone);}
//So, now lets start with requesting all required information from the visitors grids
$UserMem = array();
$AllUsers = explode(";", $_GET["u"]);
for ($i = 0; $i < count($AllUsers); ++$i)
{
$SingleUser = explode(",", $AllUsers[$i]);
for ($z = 0; $z < count($SingleUser); ++$z)
{$SingleUser[$z] = trim($SingleUser[$z]);}
if (!empty($SingleUser[0]) && !empty($SingleUser[1]))
{
//The magic is done here
$UserInfo = new GridUser($SingleUser[0], $SingleUser[1], realpath(dirname(__FILE__)));
$Info = $UserInfo->ToArray();
if ($Info !== false)
{
$UserMem[] = array("uuid" => $Info["uuid"],
"name" => $Info["firstname"]." ".$Info["lastname"],
"grid" => $Info["homegrid"],
"title" => $Info["title"],
"unix" => date("d.m.Y H:i", (int)$SingleUser[2]));
}
}
}
$UserMem = array_reverse($UserMem);
//Now we are starting to render the image
$Image = imagecreatetruecolor(1024, 512);
$Colors["white"] = imagecolorallocate($Image, 255, 255, 255);
$Colors["red"] = imagecolorallocate($Image, 140, 0, 0);
$Colors["blue"] = imagecolorallocate($Image, 0, 0, 140);
$Colors["green"] = imagecolorallocate($Image, 0, 60, 0);
$Colors["whitealpha"] = imagecolorallocatealpha($Image, 255, 255, 255, 96);
$Background = imagecreatefromjpeg("Img/Blackboard.jpg");
imagecopyresampled($Image, $Background, 0, 0, 0, 0, 1024, 512, imagesx($Background), imagesy($Background));
$Size = imageftbbox(26, 0, "Fonts/DJB Chalk It Up.ttf", $GLOBALS["LanguageData"][$SelLang]["title_1"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 26, 0, 20, 20 + $Size[1], $Colors["white"], "Fonts/DJB Chalk It Up.ttf", $GLOBALS["LanguageData"][$SelLang]["title_1"]);
$Size = imageftbbox(24, 0, "Fonts/DJB Chalk It Up.ttf", $GLOBALS["LanguageData"][$SelLang]["title_2"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 24, 0, 20, 240 + $Size[1], $Colors["white"], "Fonts/DJB Chalk It Up.ttf", $GLOBALS["LanguageData"][$SelLang]["title_2"]);
$x = 20;
$y = 65;
for ($i = 0; $i < count($UserMem); ++$i)
{
if ($i < 2)
{$ImgSize = 160;}
else
{$ImgSize = 92;}
if ($i > 0)
{
if ($i < 2)
{$x = $x + 512;}
else
{
$x = $x + 1024 / 3;
if ($i == 2)
{
$x = 20;
$y = 280;
}
if ($x >= 1024)
{
$x = 20;
$y = $y + 120;
}
}
}
$UserImage = MakeBorderOnImage(imagecreatefromjpeg("UserImage/".$UserMem[$i]["uuid"].".jpg"), "ChalkBorder");
imagecopyresampled($Image, $UserImage, $x, $y, 0, 0, $ImgSize, $ImgSize, imagesx($UserImage), imagesy($UserImage));
if ($i < 2)
{
$LocalY = $y;
$Size = imageftbbox(12, 0, "Fonts/DJB Chalk It Up.ttf", $GLOBALS["LanguageData"][$SelLang]["title_name"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 12, 0, $x + $ImgSize + 10, $LocalY + $Size[1], $Colors["white"], "Fonts/DJB Chalk It Up.ttf", $GLOBALS["LanguageData"][$SelLang]["title_name"]);
$LocalY = $LocalY + $Size[1] + 5;
$Size = imageftbbox(18, 0, "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["name"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 18, 0, $x + $ImgSize + 10 + 10, $LocalY + $Size[1], $Colors["red"], "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["name"]);
$LocalY = $LocalY + $Size[1] + 2;
$Size = imageftbbox(11, 0, "Fonts/DJB Chalk It Up.ttf", "» ".$UserMem[$i]["title"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 11, 0, $x + $ImgSize + 10 + 10, $LocalY + $Size[1], $Colors["green"], "Fonts/DJB Chalk It Up.ttf", "» ".$UserMem[$i]["title"]);
$LocalY = $LocalY + $Size[1] + 10;
$Size = imageftbbox(12, 0, "Fonts/DJB Chalk It Up.ttf", $GLOBALS["LanguageData"][$SelLang]["title_from"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 12, 0, $x + $ImgSize + 10, $LocalY + $Size[1], $Colors["white"], "Fonts/DJB Chalk It Up.ttf", $GLOBALS["LanguageData"][$SelLang]["title_from"]);
$LocalY = $LocalY + $Size[1] + 5;
$Size = imageftbbox(18, 0, "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["grid"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 18, 0, $x + $ImgSize + 10 + 10, $LocalY + $Size[1], $Colors["blue"], "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["grid"]);
$LocalY = $LocalY + $Size[1] + 10;
$Size = imageftbbox(12, 0, "Fonts/DJB Chalk It Up.ttf", $GLOBALS["LanguageData"][$SelLang]["title_time"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 12, 0, $x + $ImgSize + 10, $LocalY + $Size[1], $Colors["white"], "Fonts/DJB Chalk It Up.ttf", $GLOBALS["LanguageData"][$SelLang]["title_time"]);
$LocalY = $LocalY + $Size[1] + 5;
$Size = imageftbbox(18, 0, "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["unix"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 18, 0, $x + $ImgSize + 10 + 10, $LocalY + $Size[1], $Colors["white"], "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["unix"]);
$LocalY = $LocalY + $Size[1] + 10;
}
else
{
$LocalY = $y;
$Size = imageftbbox(14, 0, "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["name"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 14, 0, $x + $ImgSize + 10, $LocalY + $Size[1], $Colors["red"], "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["name"]);
$LocalY = $LocalY + $Size[1] + 2;
$Size = imageftbbox(9, 0, "Fonts/DJB Chalk It Up.ttf", "» ".$UserMem[$i]["title"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 9, 0, $x + $ImgSize + 10, $LocalY + $Size[1], $Colors["green"], "Fonts/DJB Chalk It Up.ttf", "» ".$UserMem[$i]["title"]);
$LocalY = $LocalY + $Size[1] + 10;
$Size = imageftbbox(14, 0, "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["grid"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 14, 0, $x + $ImgSize + 10, $LocalY + $Size[1], $Colors["blue"], "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["grid"]);
$LocalY = $LocalY + $Size[1] + 10;
$Size = imageftbbox(14, 0, "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["unix"]);
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 14, 0, $x + $ImgSize + 10, $LocalY + $Size[1], $Colors["white"], "Fonts/DJB Chalk It Up.ttf", $UserMem[$i]["unix"]);
$LocalY = $LocalY + $Size[1] + 10;
}
}
$Size = imageftbbox(10, 0, "Fonts/BlackOpsOne-Regular.ttf", "KUBWA");
$Size = array(abs($Size[0]) + abs($Size[2]), abs($Size[1]) + abs($Size[5]));
imagefttext($Image, 10, 0, 1024 - $Size[0] - 15, 512 - $Size[1], $Colors["whitealpha"], "Fonts/BlackOpsOne-Regular.ttf", "KUBWA");
header("content-type: image/png");
imagepng($Image);
//A little helper function which puts a nice frame around a users image
function MakeBorderOnImage($Image, $Border)
{
imagealphablending($Image, false);
imagesavealpha($Image, true);
$Border = imagecreatefrompng("Img/".$Border.".png");
$ScaledBorder = imagecreatetruecolor(imagesx($Image), imagesy($Image));
imagecopyresampled($ScaledBorder, $Border, 0, 0, 0, 0, imagesx($Image), imagesy($Image), imagesx($Border), imagesy($Border));
if (round(rand(0, 3)) == 1) {imageflip($ScaledBorder, IMG_FLIP_HORIZONTAL);}
if (round(rand(0, 3)) == 2) {imageflip($ScaledBorder, IMG_FLIP_VERTICAL);}
if (round(rand(0, 3)) == 3) {imageflip($ScaledBorder, IMG_FLIP_BOTH);}
$ScaledBorder = imagerotate($ScaledBorder, 3 - rand(0, 6), imagecolorallocate($ScaledBorder, 76, 255, 0), true);
$Transparent = imagecolorallocatealpha ($Image, 255, 255, 255, 127);
for ($y = 0; $y < imagesy($ScaledBorder); ++$y)
{
for ($x = 0; $x < imagesx($ScaledBorder); ++$x)
{
$rgb = imagecolorsforindex($ScaledBorder, imagecolorat($ScaledBorder, $x, $y));
if ($rgb["green"] >= 250 && $rgb["red"] < 100 && $rgb["blue"] < 100)
{imagesetpixel($Image, $x, $y, $Transparent);}
else
{
if ($rgb["red"] > 0 && $rgb["green"] > 0 && $rgb["blue"] > 0 && rand(0, 1000) > 100)
{imagesetpixel($Image, $x, $y, imagecolorallocatealpha($Image, 255, 255, 255, $rgb["alpha"]));}
}
}
}
return $Image;
}
//Language variable handling (kind of shitty)
$GLOBALS["LanguageData"] = array();
function LoadLanguages()
{
$Temp = file_get_contents("Language/lang.txt");
$Temp = explode("\n", str_replace("\r", "", $Temp));
$CurLng = "";
for ($i = 0; $i < count($Temp); ++$i)
{
$Line = trim(explode("#", $Temp[$i])[0]);
if (!empty($Line))
{
if (substr($Line, 0, 1) == "[")
{
$CurLng = substr($Line, 1, -1);
$GLOBALS["LanguageData"][strtolower($CurLng)] = array();
}
else
{
if (!empty($CurLng))
{
$KeyPair = explode("=", $Line, 2);
$GLOBALS["LanguageData"][strtolower($CurLng)][strtolower(trim($KeyPair[0]))] = trim($KeyPair[1]);
}
}
}
}
}
?>

52
iptrace.php Normal file
View File

@ -0,0 +1,52 @@
<?php
/***********************************************************************
* Script (c) Kubwa (https://kubwa.de)
*
* This script was release under BSD license.
* You are free to use, share or change this code as you wish. This
* header must be kept intact.
***********************************************************************/
require_once("classes/Framework.MySql.Class.php");
require_once("classes/GridUserInfo.php");
require_once("classes/Http.php");
require_once("classes/Xml.php");
require_once("Config.php");
/*
This little script is looking up country, language and timezone for a ip address and caches it.
To have a minimum of dataprotection, we are hashing the ip addresses we are looking up.
*/
if (empty($_GET["ip"]) || !filter_var($_GET["ip"], FILTER_VALIDATE_IP))
{die("NOPE");}
$MySql = new MySql($GLOBALS["CONFIG"]["mysql"]["user"], $GLOBALS["CONFIG"]["mysql"]["pass"], $GLOBALS["CONFIG"]["mysql"]["db"], $GLOBALS["CONFIG"]["mysql"]["server"]);
$MySql->query("DELETE FROM ip_timezones WHERE unix < {0} OR (unix < {1} AND country = '')", array(time() - 86400 * 60, time() - 86400));
$Exists = $MySql->query("SELECT * FROM ip_timezones WHERE ip = md5({0}) LIMIT 1", array($_GET["ip"]))->fetch();
$TimeZone = "Europe/Berlin";
$Country = "DE";
if (empty($Exists["ip"]))
{
//We can also use another service to trace the ip, if you wish so, change this code
$TraceRequest = json_decode(HttpRequest("http://ip-api.com/json/".$_GET["ip"], "", 3), true);
if ($TraceRequest["status"] == "success")
{
$TimeZone = $TraceRequest["timezone"];
$Country = $TraceRequest["countryCode"];
}
$MySql->query("INSERT INTO ip_timezones (ip, timezone, country, unix)VALUES(md5({0}), {1}, {2}, {3})", array($_GET["ip"], $TimeZone, $Country, time()));
}
else
{
$TimeZone = $Exists["timezone"];
$Country = $Exists["country"];
}
$Language = "DE";
$Exists = $MySql->query("SELECT * FROM countries_lang WHERE country = {0} LIMIT 1", array(strtolower($Country)))->fetch();
if (!empty($Exists["lang"]))
{$Language = strtoupper($Exists["lang"]);}
die(implode(",", array("OK", $Country, $TimeZone, $Language, $_GET["payload"])));
?>