commit a6aad1bace880a8fe59e091992f09401127b2b07 Author: Kubwa Date: Sat Nov 28 09:19:59 2020 +0100 Initial import diff --git a/Banned.jpg b/Banned.jpg new file mode 100644 index 0000000..e92aea2 Binary files /dev/null and b/Banned.jpg differ diff --git a/Boards.iar b/Boards.iar new file mode 100644 index 0000000..9173843 Binary files /dev/null and b/Boards.iar differ diff --git a/Config.php b/Config.php new file mode 100644 index 0000000..8d222a1 --- /dev/null +++ b/Config.php @@ -0,0 +1,20 @@ + array( + "server" => "127.0.0.1", + "user" => "root", + "pass" => "***", + "db" => "visitorboard" + ) + ); + +?> \ No newline at end of file diff --git a/Database.sql b/Database.sql new file mode 100644 index 0000000..f99bf4c --- /dev/null +++ b/Database.sql @@ -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'; \ No newline at end of file diff --git a/Fonts/BRSANRT0.TTF b/Fonts/BRSANRT0.TTF new file mode 100644 index 0000000..ed72a76 Binary files /dev/null and b/Fonts/BRSANRT0.TTF differ diff --git a/Fonts/BlackOpsOne-Regular.ttf b/Fonts/BlackOpsOne-Regular.ttf new file mode 100644 index 0000000..46a14f2 Binary files /dev/null and b/Fonts/BlackOpsOne-Regular.ttf differ diff --git a/Fonts/DJB Chalk It Up.ttf b/Fonts/DJB Chalk It Up.ttf new file mode 100644 index 0000000..f4def70 Binary files /dev/null and b/Fonts/DJB Chalk It Up.ttf differ diff --git a/Img/Blackboard.jpg b/Img/Blackboard.jpg new file mode 100644 index 0000000..b6e3399 Binary files /dev/null and b/Img/Blackboard.jpg differ diff --git a/Img/ChalkBorder.png b/Img/ChalkBorder.png new file mode 100644 index 0000000..fbf1d76 Binary files /dev/null and b/Img/ChalkBorder.png differ diff --git a/Language/lang.txt b/Language/lang.txt new file mode 100644 index 0000000..806ff6b --- /dev/null +++ b/Language/lang.txt @@ -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 \ No newline at end of file diff --git a/NoImage.jpg b/NoImage.jpg new file mode 100644 index 0000000..2f29a63 Binary files /dev/null and b/NoImage.jpg differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Update.jpg b/Update.jpg new file mode 100644 index 0000000..6dca56f Binary files /dev/null and b/Update.jpg differ diff --git a/UserImage/00000000-0000-0000-0000-000000000000.jpg b/UserImage/00000000-0000-0000-0000-000000000000.jpg new file mode 100644 index 0000000..2f29a63 Binary files /dev/null and b/UserImage/00000000-0000-0000-0000-000000000000.jpg differ diff --git a/UserImage/00000000-0000-0000-0000-000000000001.jpg b/UserImage/00000000-0000-0000-0000-000000000001.jpg new file mode 100644 index 0000000..e92aea2 Binary files /dev/null and b/UserImage/00000000-0000-0000-0000-000000000001.jpg differ diff --git a/UserImage/00000000-0000-0000-0000-000000000002.jpg b/UserImage/00000000-0000-0000-0000-000000000002.jpg new file mode 100644 index 0000000..6dca56f Binary files /dev/null and b/UserImage/00000000-0000-0000-0000-000000000002.jpg differ diff --git a/UserImage/bb7c4d4e-ff01-4b76-84f0-c218601bb15b.jpg b/UserImage/bb7c4d4e-ff01-4b76-84f0-c218601bb15b.jpg new file mode 100644 index 0000000..c740d16 Binary files /dev/null and b/UserImage/bb7c4d4e-ff01-4b76-84f0-c218601bb15b.jpg differ diff --git a/binary_helper/magick b/binary_helper/magick new file mode 100644 index 0000000..912f92d Binary files /dev/null and b/binary_helper/magick differ diff --git a/binary_helper/magick.exe b/binary_helper/magick.exe new file mode 100644 index 0000000..e358e6d Binary files /dev/null and b/binary_helper/magick.exe differ diff --git a/classes/Framework.MySql.Class.php b/classes/Framework.MySql.Class.php new file mode 100644 index 0000000..d1a6558 --- /dev/null +++ b/classes/Framework.MySql.Class.php @@ -0,0 +1,120 @@ +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);} + } +?> \ No newline at end of file diff --git a/classes/GridUserInfo.php b/classes/GridUserInfo.php new file mode 100644 index 0000000..97e1d37 --- /dev/null +++ b/classes/GridUserInfo.php @@ -0,0 +1,366 @@ +Uuid = $Uuid; + $this->HomeUri = $HomeUri; + $this->WorkingPath = realpath(dirname(__FILE__)); + $this->ImagesPath = $ImagesPath; + $this->MySql = new MySql($GLOBALS["CONFIG"]["mysql"]["user"], $GLOBALS["CONFIG"]["mysql"]["pass"], $GLOBALS["CONFIG"]["mysql"]["db"], $GLOBALS["CONFIG"]["mysql"]["server"]); + + //Process OpenSim header fields + foreach ($_SERVER as $k => $v) + { + if (substr($k, 5, 13) == "X_SECONDLIFE_") + {$this->OSHeaders[substr($k, 18)] = $v;} + } + + //Remove cached profile images after 60 days but process this cleanup every 5 days only + if ($this->HelpValue("IMAGE.LAST.CLEANTIME") + 86400 * 5 < time()) + { + $this->HelpValue("IMAGE.LAST.CLEANTIME", time()); + $Files = glob($this->ImagesPath."/UserImage/*.jpg"); + foreach ($Files as $File) + { + if (is_file($File) && time() - filemtime($File) >= 86400 * 60) + {unlink($File);} + } + //Also delete the cached metadata + $this->MySql->query("DELETE FROM userdata WHERE lastreq < {0}", array(time() - 86400 * 60)); + } + + //Process pre defined images + if (!file_exists($this->ImagesPath."/UserImage/00000000-0000-0000-0000-000000000000.jpg")) + {file_put_contents($this->ImagesPath."/UserImage/00000000-0000-0000-0000-000000000000.jpg", base64_decode($this->ErrorImage));} + if (!file_exists($this->ImagesPath."/UserImage/00000000-0000-0000-0000-000000000001.jpg")) + {file_put_contents($this->ImagesPath."/UserImage/00000000-0000-0000-0000-000000000001.jpg", base64_decode($this->BlockedImage));} + if (!file_exists($this->ImagesPath."/UserImage/00000000-0000-0000-0000-000000000002.jpg")) + {file_put_contents($this->ImagesPath."/UserImage/00000000-0000-0000-0000-000000000002.jpg", base64_decode($this->UpdateImage));} + + //Do the magic + $this->LastRequest = time(); + if ($this->ExistsInCache()) //User exists in cache? + { + $this->GetFromCache(); //Load everything from cache + if ($this->LastUpdate + 3600 * 4 < time()) + { + $this->GetFromInternet(); //Get all the data from the users grid + if ($this->HomeGrid == "Unknown" && + $this->FirstName == "Unknown" && + $this->LastName == "User") + {$this->GetFromCache();} + } + } + else + {$this->GetFromInternet();} + } + + //The user might be unwanted in our system. See mysql table "bans" + private function IsUnwanted($CheckList) + { + $AllBans = $this->MySql->query("SELECT * FROM bans"); + while ($Ban = $AllBans->fetch()) + { + for ($i = 0; $i < count($CheckList); ++$i) + { + if (stripos($CheckList[$i], $Ban["banvalue"]) !== false) + { + $this->MySql->query("UPDATE bans SET nums = {1}, lastseen = {2} WHERE banvalue = {0} LIMIT 1", array($Ban["banvalue"], $Ban["nums"] + 1, $this->OSHeaders["OBJECT_KEY"])); + return true; + } + } + } + return false; + } + + private function ExistsInCache() + { + $InCache = $this->MySql->query("SELECT * FROM userdata WHERE id = {0} LIMIT 1", array($this->Uuid))->fetch(); + return !empty($InCache["id"]); + } + + private function GetFromCache() + { + $Cache = $this->MySql->query("SELECT * FROM userdata WHERE id = {0} LIMIT 1", array($this->Uuid))->fetch(); + $this->FromJson($Cache["userdata"]); + $this->LastUpdate = $Cache["lastreq"]; + if (file_exists($this->ImagesPath."/UserImage/".$this->Uuid.".jpg")) + {$this->ProfileImageBlob = file_get_contents($this->ImagesPath."/UserImage/".$this->Uuid.".jpg");} + } + + //Magic function + private function GetFromInternet() + { + //First of all, we need to find out what uris the gridservices are having for this user (might be different for each user) + $this->ServiceUris = $this->RequestUserSeviceUris(); + if ($this->ServiceUris !== false) + { + //IF this was successfull, we are requesting all required user info from the services + $UserInfo = $this->RequestUserInfo(); + if ($UserInfo !== false) + { + $this->FirstName = $UserInfo["user_firstname"]; + $this->LastName = $UserInfo["user_lastname"]; + + /* Ungewollte User in der Auflistung ausschließen */ + if ($this->IsUnwanted(array($this->Uuid, $this->HomeUri, $this->FirstName." ".$this->LastName))) + { + $this->BirthUnix = 0; + $this->UserTitle = "Blacklisted"; + $this->HomeGrid = "Somewhere"; + $this->ProfileImageUuid = "00000000-0000-0000-0000-000000000001"; + $this->ProfileAbout = ""; + $this->HomeRegionUuid = "00000000-0000-0000-0000-000000000000"; + $this->HomeRegionName = ""; + $this->HomeRegionUri = ""; + $this->HomeRegionPos = ""; + $this->HomeRegionUuid = "00000000-0000-0000-0000-000000000000"; + $this->HomeRegionName = "Unknown"; + $this->HomeRegionUri = ""; + $this->HomeRegionPos = "<0, 0, 0>"; + $this->ProfileImageBlob = base64_decode($this->BlockedImage); + $this->AddToCache(); + return; + } + + //We can do more magic: Request the entire user profile, its image and all other cool stuff + $ProfileData = $this->RequestUserProfile(); + $GridInfo = $this->RequestHomeGrid(); + $this->BirthUnix = $UserInfo["user_created"]; + $this->UserTitle = $UserInfo["user_title"]; + if (empty($this->UserTitle)) + {$this->UserTitle = "Unknown";} + $this->HomeGrid = $GridInfo["gridname"]; + $this->ProfileImageUuid = $ProfileData["result"]["ImageId"]; + $this->ProfileAbout = $ProfileData["result"]["AboutText"]; + $HomeRegion = $this->RequestHomeRegion(); + $this->HomeRegionUuid = $HomeRegion["uuid"]; + $this->HomeRegionName = $HomeRegion["region_name"]; + $this->HomeRegionUri = $HomeRegion["server_uri"]; + $this->HomeRegionPos = $HomeRegion["position"]; + $this->ProfileImageBlob = $this->RequestUserImageBlob(); + $this->AddToCache(); + return; + } + } + $this->FirstName = "Unknown"; + $this->LastName = "User"; + $this->BirthUnix = 0; + $this->UserTitle = "Wrong configured grid"; + $this->HomeGrid = "Unknown"; + $this->ProfileImageUuid = "00000000-0000-0000-0000-000000000000"; + $this->ProfileAbout = ""; + $this->HomeRegionUuid = "00000000-0000-0000-0000-000000000000"; + $this->HomeRegionName = ""; + $this->HomeRegionUri = ""; + $this->HomeRegionPos = ""; + $this->HomeRegionUuid = "00000000-0000-0000-0000-000000000000"; + $this->HomeRegionName = "Unknown"; + $this->HomeRegionUri = ""; + $this->HomeRegionPos = "<0, 0, 0>"; + if (file_exists($this->ImagesPath."/UserImage/".$this->Uuid.".jpg")) + {$this->ProfileImageBlob = file_get_contents($this->ImagesPath."/UserImage/".$this->Uuid.".jpg");} + else + {$this->ProfileImageBlob = base64_decode($this->ErrorImage);} + } + + private function RequestUserSeviceUris() + { + $Res = HttpRequest($this->HomeUri, "get_server_urlsuserID".$this->Uuid."", "", 3, "application/xml"); + if (strlen($Res) < 200) + {return false;} + $ServiceURLs = ParseXml($Res); + $ServiceURLList = array(); + for ($i = 0; $i < count($ServiceURLs["params"]["param"]["value"]["struct"]["member"]); ++$i) + { + $ServiceURL = $ServiceURLs["params"]["param"]["value"]["struct"]["member"][$i]; + $ServiceURLList[$ServiceURL["name"]] = $ServiceURL["value"]["string"]; + } + if (count($ServiceURLList) < 7) + {return false;} + return $ServiceURLList; + } + + private function RequestUserProfile() + {return json_decode(HttpRequest($this->ServiceUris["SRV_ProfileServerURI"], "{\"jsonrpc\":\"2.0\",\"id\":\"00000000-0000-0000-0000-000000000000\",\"method\":\"avatar_properties_request\",\"params\":{\"UserId\":\"".$this->Uuid."\"}}", "", 3, "application/json-rpc"), true);} + + private function RequestUserInfo() + { + $UserInfos = ParseXml(HttpRequest($this->HomeUri, "get_user_infouserID".$this->Uuid."", "", 3, "application/xml")); + $UserInfosList = array(); + for ($i = 0; $i < count($UserInfos["params"]["param"]["value"]["struct"]["member"]); ++$i) + { + $UserInfo = $UserInfos["params"]["param"]["value"]["struct"]["member"][$i]; + $UserInfosList[$UserInfo["name"]] = $UserInfo["value"]["string"]?$UserInfo["value"]["string"]:$UserInfo["value"]["i4"]; + } + if (count($UserInfosList) < 6) + {return false;} + return $UserInfosList; + } + + private function RequestHomeGrid() + {return ParseXml(HttpRequest($this->HomeUri.((substr($this->HomeUri, -1, 1) == "/")?"":"/")."get_grid_info", "", "", 3), true);} + + private function RequestHomeRegion() + { + $HomeInfos = ParseXml(HttpRequest($this->HomeUri, "get_home_regionuserID".$this->Uuid."", "", 3, "application/xml")); + $HomeInfosList = array(); + for ($i = 0; $i < count($HomeInfos["params"]["param"]["value"]["struct"]["member"]); ++$i) + { + $HomeInfo = $HomeInfos["params"]["param"]["value"]["struct"]["member"][$i]; + $HomeInfosList[$HomeInfo["name"]] = $HomeInfo["value"]["string"]; + } + if (count($HomeInfosList) < 13) + {return false;} + return $HomeInfosList; + } + + private function RequestUserImageBlob() + { + if (!empty($this->ProfileImageUuid) && $this->ProfileImageUuid != "00000000-0000-0000-0000-000000000000") + { + $AssetURI = $this->ServiceUris["SRV_AssetServerURI"].((substr($this->ServiceUris["SRV_AssetServerURI"], -1, 1) == "/")?"":"/")."assets/".$this->ProfileImageUuid."/data"; + $AssetImageData = HttpRequest($AssetURI, "", "", 3); + $TempName = $this->MySql->id(8); + file_put_contents("binary_helper/".$TempName.".jp2", $AssetImageData); + //Should be the same for Windows and Unix... If not, only God can help you... or Google (which is the same) + shell_exec("binary_helper".DIRECTORY_SEPARATOR."magick convert binary_helper/".$TempName.".jp2 binary_helper/".$TempName.".jpg"); + $AssetImageData = file_get_contents("binary_helper/".$TempName.".jpg"); + @unlink("binary_helper/".$TempName.".jp2"); + @unlink("binary_helper/".$TempName.".jpg"); + if (strlen($AssetImageData) < 512) + {return base64_decode($this->ErrorImage);} + $SrcImg = imagecreatefromstring($AssetImageData); + $DstImg = ImageCreateTrueColor(200, 200); + imagecopyresampled($DstImg, $SrcImg, 0, 0, 0, 0, 200, 200, imageSX($SrcImg), imageSY($SrcImg)); + ob_start(); + imagejpeg($DstImg, null, 90); + $Res = ob_get_contents(); + ob_end_clean(); + } + else + {$Res = base64_decode($this->ErrorImage);} + return $Res; + } + + private function AddToCache() + { + $this->MySql->query("REPLACE INTO userdata(id, userdata, lastreq)VALUES({0}, {1}, {2})", array($this->Uuid, $this->ToJson(), $this->LastRequest)); + file_put_contents($this->ImagesPath."/UserImage/".$this->Uuid.".jpg", $this->ProfileImageBlob); + } + + public function ToArray() + { + if (!empty($this->FirstName)) + { + return array("uuid" => $this->Uuid, + "firstname" => $this->FirstName, + "lastname" => $this->LastName, + "homegrid" => $this->HomeGrid, + "birthunix" => $this->BirthUnix, + "profileimage" => $this->ProfileImageUuid, + "about" => $this->ProfileAbout, + "title" => $this->UserTitle, + "home" => $this->HomeRegionName, + "homelocation" => $this->HomeRegionPos, + "homeuri" => $this->HomeRegionUri); + } + else + {return false;} + } + + public function ToJson() + { + if (!empty($this->FirstName)) + {return json_encode($this->ToArray());} + else + {return false;} + } + + public function FromJson($Json) + { + $Json = json_decode($Json, true); + $this->Uuid = $Json["uuid"]; + $this->FirstName = $Json["firstname"]; + $this->LastName = $Json["lastname"]; + $this->HomeGrid = $Json["homegrid"]; + $this->BirthUnix = $Json["birthunix"]; + $this->ProfileImageUuid = $Json["profileimage"]; + $this->ProfileAbout = $Json["about"]; + $this->UserTitle = $Json["title"]; + $this->HomeRegionName = $Json["home"]; + $this->HomeRegionPos = $Json["homelocation"]; + $this->HomeRegionUri = $Json["homeuri"]; + } + + public function ToLsl($Glue) + { + if (!empty($this->FirstName)) + { + return implode($Glue, array($this->Uuid, + $this->FirstName, + $this->LastName, + ($this->HomeGrid==null)?"Unknown":$this->HomeGrid, + ($this->BirthUnix==null)?"0":$this->BirthUnix, + ($this->ProfileImageUuid==null)?"00000000-0000-0000-0000-000000000000":$this->ProfileImageUuid, + base64_encode($this->ProfileAbout), + ($this->UserTitle==null)?"":(is_array($this->UserTitle)?"":$this->UserTitle), + ($this->HomeRegionName==null)?"":$this->HomeRegionName, + ($this->HomeRegionPos==null)?"<0, 0, 0>":$this->HomeRegionPos, + ($this->HomeRegionUri==null)?"":$this->HomeRegionUri)); + } + else + {return false;} + } + + private function HelpValue($Name, $Value = null) + { + if ($Value === null) + { + $Res = $this->MySql->query("SELECT * FROM helpvals WHERE name = {0} LIMIT 1", array($Name))->fetch(); + return $Res["val"]; + } + else + {$this->MySql->query("REPLACE INTO helpvals (name, val)VALUES({0}, {1})", array($Name, $Value));} + } + } +?> \ No newline at end of file diff --git a/classes/Http.php b/classes/Http.php new file mode 100644 index 0000000..185f57d --- /dev/null +++ b/classes/Http.php @@ -0,0 +1,84 @@ + 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; + } + } +?> \ No newline at end of file diff --git a/classes/Xml.php b/classes/Xml.php new file mode 100644 index 0000000..a192f17 --- /dev/null +++ b/classes/Xml.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..5110361 --- /dev/null +++ b/index.php @@ -0,0 +1,265 @@ +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]); + } + } + } + } + } +?> \ No newline at end of file diff --git a/iptrace.php b/iptrace.php new file mode 100644 index 0000000..c35aa78 --- /dev/null +++ b/iptrace.php @@ -0,0 +1,52 @@ +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"]))); +?> \ No newline at end of file