diff options
author | gumi <git@gumi.ca> | 2019-06-29 17:04:09 +0000 |
---|---|---|
committer | root <root@dezilaromed.themanaworld.org> | 2019-06-29 17:04:09 +0000 |
commit | a4f747c5de3b831ba3c1d387817fdc75be25e1cc (patch) | |
tree | 5cd1a7ef84885fcd3efcdddef923d1864de5f610 /includes | |
parent | e41baa4c3aeb5f2b05fb928c1bf13e6a9bb130a7 (diff) | |
download | website-a4f747c5de3b831ba3c1d387817fdc75be25e1cc.tar.gz website-a4f747c5de3b831ba3c1d387817fdc75be25e1cc.tar.bz2 website-a4f747c5de3b831ba3c1d387817fdc75be25e1cc.tar.xz website-a4f747c5de3b831ba3c1d387817fdc75be25e1cc.zip |
move away from PHP, use static pages with the api
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.php | 40 | ||||
-rw-r--r-- | includes/conf/mysql.conf.php.example | 8 | ||||
-rw-r--r-- | includes/email.php | 63 | ||||
-rwxr-xr-x | includes/fetch-news.sh | 8 | ||||
-rw-r--r-- | includes/libs/libmysql.php | 89 | ||||
-rw-r--r-- | includes/models/account.php | 114 | ||||
-rw-r--r-- | includes/news.php | 1 |
7 files changed, 30 insertions, 293 deletions
diff --git a/includes/common.php b/includes/common.php index ea8a63f..d1eec1e 100644 --- a/includes/common.php +++ b/includes/common.php @@ -13,6 +13,13 @@ function placeHeader($page_title) "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> +<!-- Google Tag Manager --> +<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': +new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], +j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= +'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); +})(window,document,'script','dataLayer','GTM-5KTWGJ');</script> +<!-- End Google Tag Manager --> <title>The Mana World - <?php echo $page_title; ?></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="Content-Style-Type" content="text/css"/> @@ -54,11 +61,10 @@ function placeHeader($page_title) <li><a href="downloads.php">Downloads</a></li> <li><a href="news-feed.php">News</a></li> <li><a href="about.php">About</a></li> - <li><a href="https://webchat.freenode.net/?channels=#themanaworld">Support (IRC)</a></li> + <li><a href="/recover">Account Recovery</a></li> <li><a href="https://wiki.themanaworld.org/">Wiki</a></li> <li><a href="https://forums.themanaworld.org/">Forums</a></li> <li><a href="https://wiki.themanaworld.org/index.php/FAQ">FAQ</a></li> - <li><a href="https://wiki.themanaworld.org/index.php/Servers">Servers</a></li> </ul> </div> </div> @@ -71,7 +77,26 @@ function placeHeader($page_title) <div class="section_bottomright"> <div class="section banners"> Server status - <iframe src="https://server.themanaworld.org/status.php" width="130" height="30" frameborder="0" scrolling="no"></iframe> + <a class="tmwa-status" href="https://server.themanaworld.org" target="_blank">Online</a> + <script> + (() => { + const status_node = document.querySelector(".tmwa-status"); + const tmwa_poll = () => + fetch("/api/tmwa/server") + .then(data => data.json()) + .then(data => { + if (data.serverStatus === "Online") { + status_node.innerText = `${data.serverStatus}: (${data.playersOnline} players)`; + status_node.classList.remove("offline"); + } else { + status_node.innerText = "Offline"; + status_node.classList.add("offline"); + } + setTimeout(tmwa_poll, 8000); + }); + tmwa_poll(); + })(); + </script> </div> </div> </div> @@ -153,16 +178,9 @@ function placeFooter() </div> </div> <!-- /page --> </div> -<!-- Google Tag Manager --> + </body> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-5KTWGJ" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> -<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': -new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], -j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= -'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); -})(window,document,'script','dataLayer','GTM-5KTWGJ');</script> -<!-- End Google Tag Manager --> - </body> </html> <?php } diff --git a/includes/conf/mysql.conf.php.example b/includes/conf/mysql.conf.php.example deleted file mode 100644 index d0122d5..0000000 --- a/includes/conf/mysql.conf.php.example +++ /dev/null @@ -1,8 +0,0 @@ -<?php - - $conf['mysql_hostname'] = "localhost"; - $conf['mysql_database'] = "test"; - $conf['mysql_username'] = "test"; - $conf['mysql_password'] = "test123"; - -?>
\ No newline at end of file diff --git a/includes/email.php b/includes/email.php deleted file mode 100644 index 6184d56..0000000 --- a/includes/email.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -// Email Template Header -// Image Mapped for Html Email -// Base/Default Links -function getEmailTemplate($emailText) { - $boundary = uniqid('np'); - $headers .= "MIME-Version: 1.0\r\nContent-type: multipart/alternative;boundary=".$boundary."\r\n"; - $data = "This is a MIME encoded message."; - - $data .= "\r\n\r\n--" . $boundary . "\r\n"; - $data .= "Content-type: text/plain;charset=utf-8\r\n\r\n"; - $data .= "###############################################################\n"; - $data .= "# ___________.__ _____ #\n"; - $data .= "# \__ ___/| |__ ____ / \ ____ ____ ____ #\n"; - $data .= "# | | | | \_/ __ \ / \ / \ \__ \ / __ \ \__ \ #\n"; - $data .= "# | | | Y \ ___/ / Y \/ __ \| | \ \/ __ \_ #\n"; - $data .= "# |____| |___|__/\____> \____|____(______/__| \(______/ #\n"; - $data .= "# __ __ .__ .___ #\n"; - $data .= "# / \ / \___________| | __| _/ #\n"; - $data .= "# \ \/\/ / _ \_ __ \ | / __ | #\n"; - $data .= "# \ ( <_> ) | \/ |__/ /_/ | #\n"; - $data .= "# \__/\ / \____/|__| |____/\____ | #\n"; - $data .= "# \/ \/ #\n"; - $data .= "# #\n"; - $data .= "###############################################################\n"; - $data .= $emailText; - - $data .= "\r\n\r\n--" . $boundary . "\r\n"; - $data .= "Content-type: text/html;charset=utf-8\r\n\r\n"; - - $data .= '<html><body> -<img id="Image-Maps-Com-image-maps-2014-05-22-121954" src="https://www.themanaworld.org/images/TMW-email-temaplate-mailer.png" border="0" width="640" height="272" orgWidth="640" orgHeight="272" usemap="#image-maps-2014-05-22-121954" alt="" /> -<map name="image-maps-2014-05-22-121954" id="ImageMapsCom-image-maps-2014-05-22-121954"> -<area alt="Home Page" title="The Mana World" href="https://www.themanaworld.org/" shape="rect" coords="0,0,197,201" style="outline:none;" target="_self" /> -<area alt="Home Page" title="The Mana World" href="https://www.themanaworld.org/" shape="rect" coords="197,0,465,168" style="outline:none;" target="_self" /> -<area alt="Official Client Mana Plus" title="Official Client Mana Plus" href="http://manaplus.org" shape="rect" coords="465,0,640,168" style="outline:none;" target="_self" /> -<area alt="The Mana World News" title="The Mana World News" href="https://www.themanaworld.org/index.php" shape="rect" coords="196,168,275,201" style="outline:none;" target="_self" /> -<area alt="The Mana World Wiki" title="The Mana World Wiki" href="https://wiki.themanaworld.org/index.php/Main_Page" shape="rect" coords="274,168,375,201" style="outline:none;" target="_self" /> -<area alt="The Mana World Forums" title="The Mana World Forums" href="https://forums.themanaworld.org/" shape="rect" coords="372,168,490,201" style="outline:none;" target="_self" /> -<area alt="The Mana World Support (IRC)" title="The Mana World Support (IRC)" href="https://webchat.freenode.net/?channels=#themanaworld" shape="rect" coords="488,168,640,201" style="outline:none;" target="_self" /> -<area alt="About The Mana World" title="About The Mana World" href="https://www.themanaworld.org/about.php" shape="rect" coords="0,201,84,272" style="outline:none;" target="_self" /> -<area alt="Creative Commons" title="Creative Commons" href="http://creativecommons.org/" shape="rect" coords="84,201,121,272" style="outline:none;" target="_self" /> -<area alt="GNU General Public License" title="GNU General Public License " href="http://www.gnu.org/copyleft/gpl.html" shape="rect" coords="121,201,155,272" style="outline:none;" target="_self" /> -<area alt="Open Source Initiative" title="Open Source Initiative" href="http://opensource.org/" shape="rect" coords="155,202,189,272" style="outline:none;" target="_self" /> -<area alt="The Mana World on Facebook" title="The Mana World on Facebook" href="https://www.facebook.com/themanaworld" shape="rect" coords="191,204,308,272" style="outline:none;" target="_self" /> -<area alt="The Mana World on G+" title="The Mana World on G+" href="https://plus.google.com/+TheManaWorldOrg" shape="rect" coords="310,204,344,272" style="outline:none;" target="_self" /> -<area alt="The Mana World on Youtube" title="The Mana World on Youtube" href="https://www.youtube.com/user/TheManaWorld" shape="rect" coords="345,203,379,271" style="outline:none;" target="_self" /> -<area alt="Official Client Mana Plus" title="Official Client Mana Plus" href="http://manaplus.org" shape="rect" coords="382,203,501,272" style="outline:none;" target="_self" /> -<area alt="Mac OS Downloads" title="Mac OS Downloads" href="http://download.evolonline.org/manaplus/macosx/" shape="rect" coords="502,203,537,272" style="outline:none;" target="_self" /> -<area alt="Windows Installer" title="Windows Installer" href="http://manaplus.org/windowsinstaller" shape="rect" coords="537.8000001907349,202.8000030517578,572.8000001907349,271.8000030517578" style="outline:none;" target="_self" /> -<area alt="Linux Versions" title="Linux Versions" href="http://manaplus.org/" shape="rect" coords="575,203,640,272" style="outline:none;" target="_self" /> -<area shape="rect" coords="638,270,640,272" alt="Image Map" style="outline:none;" title="Image Map" href="http://www.image-maps.com/index.php?aff=mapped_users_0" /> -</map> -'.nl2br($emailText).' -<div style="font-size:10px;"> - © 2004-2014 The Mana World -</div> -</body> -</html>'; - $data .= "\r\n\r\n--" . $boundary . "--"; - return array($headers,$data); -} -?> diff --git a/includes/fetch-news.sh b/includes/fetch-news.sh deleted file mode 100755 index 5cc9ea5..0000000 --- a/includes/fetch-news.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# Fetches project news and saves it for local use. -# - -/usr/bin/wget -q -O /home/tmw/public_html/www/includes/rss2_projnews.tmp 'http://sourceforge.net/export/rss2_projnews.php?group_id=106790&rss_fulltext=1' > /dev/null -/bin/mv -f /home/tmw/public_html/www/includes/rss2_projnews.tmp \ - /home/tmw/public_html/www/includes/rss2_projnews.cache diff --git a/includes/libs/libmysql.php b/includes/libs/libmysql.php deleted file mode 100644 index 5a3a06c..0000000 --- a/includes/libs/libmysql.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php - -require_once "includes/conf/mysql.conf.php"; - -class Database -{ - // implement singleton pattern - static private $instance = null; - - private $conn; - - static public function getInstance() - { - if (null === self::$instance) - { - self::$instance = new self; - } - return self::$instance; - } - - // ctor - private function __construct() - { - global $conf; - $this->conn = mysql_connect( $conf['mysql_hostname'], - $conf['mysql_username'], - $conf['mysql_password'] ) - or die ("Connection to database failed!" . mysql_error()); - - mysql_select_db( $conf['mysql_database'], $this->conn ) - or die ("Selection of database failed! " . mysql_error()); - } - - private function checkConnect() - { - if (!isset($this->conn)) - { - die("Not connected to database"); - } - } - - // returns the value in the first row and column - public function getValue( $sql ) - { - $this->checkConnect(); - - $res = mysql_query( $sql, $this->conn ); - if (!$res) - { - die('Error while calling database: ' . mysql_error()); - } - $vals = mysql_fetch_row( $res ); - mysql_free_result( $res ); - return $vals[0]; - } - - // executes some sql and returns affected rows - public function exec( $sql ) - { - $this->checkConnect(); - - $res = mysql_query( $sql, $this->conn ); - if (!$res) - { - die('Error while calling database: ' . mysql_error()); - } - $numrows = mysql_affected_rows( $this->conn ); - return $numrows; - } - - public function escape( $string ) - { - $this->checkConnect(); - - return mysql_real_escape_string( $string, $this->conn ); - } - - public function disconnect() - { - if ( mysql_ping( $this->conn ) ) - { - mysql_close( $this->conn ); - } - } - -} - - -?>
\ No newline at end of file diff --git a/includes/models/account.php b/includes/models/account.php deleted file mode 100644 index ef253c6..0000000 --- a/includes/models/account.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php - -require_once "includes/libs/libstrutils.php"; - -class TMWAccount -{ - const ACCOUNT_TBL = "tmw_accounts"; - - const GENDER_MALE = 1; - const GENDER_FEMALE = 2; - - const STATE_PENDING = 0; - const STATE_CREATED = 0; - const STATE_FAILED = 0; - - private $id; - private $username; - private $password; - private $email; - private $gender; - private $state; - private $registration; - - public static function getAccountCount() - { - $db = Database::getInstance(); - $sql = "SELECT COUNT(*) FROM " . TMWAccount::ACCOUNT_TBL; - return $db->getValue( $sql ); - } - - public static function existsUsername($str) - { - $db = Database::getInstance(); - $sql = sprintf("SELECT COUNT(*) FROM " . TMWAccount::ACCOUNT_TBL . - " WHERE USERNAME = '%s'", $db->escape($str)); - return ($db->getValue($sql) == 1); - } - - public function setUsername($name){ $this->username = $name; } - public function setPassword($pwd){ $this->password = $pwd; } - public function setEMail($email){ $this->email = $email; } - public function setGender($gender){ $this->gender = $gender; } - - public function validate() - { - $errors = array(); - - // check here for correct values.. - if (strlen($this->username) < 4) - $errors[] = "Username is too short"; - - if (strlen($this->username) >= 24) - $errors[] = "Username is too long"; - - if (strlen($this->password) < 4) - $errors[] = "Password is too short"; - - if (strlen($this->password) >= 24) - $errors[] = "Password is too long"; - - if (strlen($this->email) < 4) - $errors[] = "EMail is too short"; - - if (strlen($this->email) >= 40) - $errors[] = "EMail is too long"; - - if (!check_chars($this->username)) - $errors[] = 'Username contains invalid characters. ' . BAD_STRING_DESC; - - if (!check_chars($this->password)) - $errors[] = 'Password contains invalid characters. ' . BAD_STRING_DESC; - - if ($this->gender != TMWAccount::GENDER_MALE && - $this->gender != TMWAccount::GENDER_FEMALE ) - { - $errors[] = 'Gender has to be Male or Female!'; - } - - if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) - { - $errors[] = 'EMail has wrong format.'; - } - - - // returns true if everything is fine ( test with === true) - if (count($errors) == 0) - { - return true; - } - else - { - return $errors; - } - } - - - - public function storeAccount() - { - $db = Database::getInstance(); - $sql = sprintf( "INSERT INTO " . TMWAccount::ACCOUNT_TBL . - " (USERNAME, PASSWORD, EMAIL, GENDER) " . - "VALUES ('%s', '%s', '%s', %d) ", - $db->escape($this->username), - $db->escape($this->password), - $db->escape($this->email), - $this->gender); - - $rows = $db->exec( $sql ); - return ( $rows == 1 ); - } -} - -?> diff --git a/includes/news.php b/includes/news.php index 791e3c4..21e7f27 100644 --- a/includes/news.php +++ b/includes/news.php @@ -11,6 +11,7 @@ function printNews($num='all') { $content .= $buffer; if (preg_match('/<\/div>/',$buffer)) { $count++; + $content .= "<br>"; } if ($count == $num && $num != 'all') { $content .= '<div class="read-more"><a class="more" href="/news-feed.php">More News >></a></div>'; |