Skip to content

Commit

Permalink
🤡 Merge recent changes to live (#196)
Browse files Browse the repository at this point in the history
* Improve .htaccess rewrite rules

- strip www. from www.steamlug.org
- redirect to https, if it's not /feed/cast/mp3 or /feed/cast.php?t=mp3
  looks like this is solved best through THE_REQUEST instead of RewriteConds matching REQUEST_URI/QUERY_STRING and logical operations between them
- RewriteRules in .htaccess files are only parsing the remote uri part (without a / in the beginning), so substitutions don't need a /
- added comments for better readability

* Fix credit font and spacing

* Sign In Through Steam button/logged in avatar as right ending of navbar

using steamLogin class instead of inline style to position icon correctly
moved about menu to the right

leave about always there and admin (without another about) shows only when admin is logged in

* Windward support for gameQ (#193)

* Added TNet/windward protocol support for gameQ
* Update Windward protocol comments

* fixed new youtube rss link pattern
  • Loading branch information
johndrinkwater committed May 22, 2016
2 parents 33d6583 + f38ebfa commit f2ffdb3
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 25 deletions.
33 changes: 21 additions & 12 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,33 @@ ServerSignature Off

RewriteBase /
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ https://%1/$1 [L,R=301]

# Strip www. from www.steamlug.org
# shall not match any other subdomains (staging, archive, ...)
RewriteCond %{HTTP_HOST} ^www\.steamlug\.org$
RewriteRule ^(.*)$ steamlug.org/$1 [R=301,L]

# Redirect every non https request to https, except feed/cast/mp3 or feed/cast.php?t=mp3 (for itunes)
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !^GET\ /feed/cast(/mp3|\.php\?t=mp3)\ HTTP/ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

# if remote uri refers to a valid directory, stop
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^(.*)$ - [L]

RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^((.*/)*[^./]+)/*$ $1.php [L]

RewriteRule ^cast/s(\d+)e(\d+)$ /cast.php?s=$1&e=$2 [NC,L]
RewriteRule ^feed/cast/(\w+)$ /feed/cast.php?t=$1 [NC,L]
RewriteRule ^youtubethumb/s(\d+)e(\d+)$ /youtubethumb/?s=$1&e=$2 [NC,L]
RewriteRule ^youtubedescription/s(\d+)e(\d+)$ /youtubedescription/?s=$1&e=$2 [NC,L]
RewriteRule ^app/(\d+)$ /app.php?appid=$1 [NC,L]
RewriteRule ^events/(\w+)$ /events.php?eventid=$1 [NC,L]
RewriteRule ^polls/(\d+)$ /polls.php?pollid=$1 [NC,L]
RewriteRule ^member/(\w+)$ /member.php?uid=$1 [NC,L]
RewriteRule ^clan/(\w+)$ /clan.php?clanid=$1 [NC,L]
RewriteRule ^cast/s(\d+)e(\d+)$ cast.php?s=$1&e=$2 [NC,L]
RewriteRule ^feed/cast/(\w+)$ feed/cast.php?t=$1 [NC,L]
RewriteRule ^youtubethumb/s(\d+)e(\d+)$ youtubethumb/?s=$1&e=$2 [NC,L]
RewriteRule ^youtubedescription/s(\d+)e(\d+)$ youtubedescription/?s=$1&e=$2 [NC,L]
RewriteRule ^app/(\d+)$ app.php?appid=$1 [NC,L]
RewriteRule ^events/(\w+)$ events.php?eventid=$1 [NC,L]
RewriteRule ^polls/(\d+)$ polls.php?pollid=$1 [NC,L]
RewriteRule ^member/(\w+)$ member.php?uid=$1 [NC,L]
RewriteRule ^clan/(\w+)$ clan.php?clanid=$1 [NC,L]

RewriteRule ^apple-touch-icon(.*).png$ mobile-favicon.png [L]

Expand All @@ -47,4 +57,3 @@ RewriteRule ^apple-touch-icon(.*).png$ mobile-favicon.png [L]
<ifmodule mod_mime.c>
AddType application/x-font-ttf .ttf
</ifmodule>

3 changes: 2 additions & 1 deletion css/bootstrap.steamlug.css
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ p a.group-join{font-size:100%}
@keyframes showpolls{
from{width:0}
}
.navbar-nav>li.steamLogin{right:0}
.navbar-nav>li.steamLogin{right:0;padding-right:11px}
.navbar-nav>li.steamLogin>a{display:block;border:0;padding:3px 5px 4px 3px}
.navbar-nav>li.navbar-avatar>a{padding:6px}
#navbar{position:relative}
Expand Down Expand Up @@ -1124,3 +1124,4 @@ article.twit label.control-label{text-align:left;border:3px solid transparent;pa
.dynamiclink img{float:left;margin-right:14px;max-height:88px}
img.warning { box-shadow: 0 0 8px orange }
img.replace { box-shadow: 0 0 8px red; border: 1px dashed red }
.credit{padding:20px 0 10px 0}
4 changes: 2 additions & 2 deletions css/bootstrap.steamlug.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions includes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
</ul>
</div>
</div>
<p class="muted credit text-center">This site is not affiliated with or endorsed by Valve, Steam, or any of their partners.<br />
<p class="text-muted credit text-center">This site is not affiliated with or endorsed by Valve, Steam, or any of their partners.<br />
All registered trademarks or copyrights are property of their respective owners.</p>
<?php
if ( $weareadmin ) {
print '<p class="muted credit text-center">Memory: ' . memory_get_usage( ) . '</p>';
print '<p class="text-muted credit text-center">Memory: ' . memory_get_usage( ) . '</p>';
}
?>
</div>
Expand Down
135 changes: 135 additions & 0 deletions includes/gameq/protocols/windward.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?php
/**
* This file is part of GameQ.
*
* GameQ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GameQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Windward Protocol Class
*
* Result from this call should be a text over HTTP
*
* @author Jason Rivers <jason@jasonrivers.co.uk>
*/
class GameQ_Protocols_Windward extends GameQ_Protocols_Http
{
/**
* Array of packets we want to look up.
* Each key should correspond to a defined method in this or a parent class
*
* @var array
*/
protected $packets = array(
self::PACKET_STATUS => "GET / HTTP/1.0\r\nAccept: */*\r\n\r\n",
);

/**
* Methods to be run when processing the response(s)
*
* @var array
*/
protected $process_methods = array(
"process_status",
);

/**
* The protocol being used
*
* @var string
*/
protected $protocol = 'tnet';

/**
* String name of this protocol class
*
* @var string
*/
protected $name = 'windward';

/**
* Longer string name of this protocol class
*
* @var string
*/
protected $name_long = "Windward";

/*
* Internal methods
*/
protected function preProcess_status($packets=array())
{
// Split on newline
$m = explode("\n", $packets[0]);

return $m;
}

protected function process_status()
{
// Make sure we have a valid response
if(!$this->hasValidResponse(self::PACKET_STATUS))
{
return array();
}
$res = ($this->preProcess_status($this->packets_response[self::PACKET_STATUS]));


// Loop through the array to get the server name and the number of players.
$playerCount=0;
foreach ($res as $i => $v) {

if (strstr($v, "Name")) {
$server_name_index=$i;
$server_name=str_replace("Name: ", "", $v);
}

// Server always shows clients even when there's no player connected.
// So we only do this after we've found the "Clients:" line
if (isset($hasClients) && $hasClients > 0) {
if ($v != "") {
$playerCount++;
}
}

if (strstr($v, "Clients:")) {
$hasClients = str_replace("Clients: ", "", $v);
}

}



// Set the result to a new result instance
$result = new GameQ_Result();

// Server is always dedicated
$result->add('dedicated', TRUE);

// No mods, as of yet
$result->add('mod', FALSE);

$result->add('hostname', $server_name);
$result->add('numplayers', $playerCount);
// Server doesn't give use this maxplayers, Here is the Dev's wording on the matter:
// Challenge 99. Max loot is 100, max challenge is 99. I've had my dev server up to ~25 players at one point.
// 0.2% CPU usage (of a single core out of 12), 96 MB RAM usage.
$result->add('maxplayers', 99);
$result->add('steamappid', 326410);
// Server doesn't report the map that it has generated, so we don't have a blank on the page we're going for "world"
$result->add('map', "world");

return $result->fetch();
}
}
14 changes: 7 additions & 7 deletions includes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@
</ul>
</li>
<li<?= $serversPage; ?>><a href="/servers">Servers</a></li>
<li<?= $aboutPage; ?>><a href="/about">About</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<?php
if ($weareadmin) {
?>
Expand All @@ -251,17 +254,14 @@
<li<?= $adminAdminPage; ?>><a href="/admins">Admins</a></li>
<li><a target="_blank" href="/transcriberer">Transcriberer</a></li>
<li><a target="_blank" href="//data.steamlug.org/updatesteamlug.php">Update events</a></li>
<li<?= $aboutPage; ?>><a href="/about">About</a></li>
</ul>
</li>
<?php
} else {
<?php
}
?>
<li<?= $aboutPage; ?>><a href="/about">About</a></li>
<?php } ?>
<?= $logIn; ?>
</ul>
</div>
</ul>
</div>
</div>
</nav>
<div class="container">
2 changes: 1 addition & 1 deletion news.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
</p><div class="dynamiclink"><img src="{$t['url']}" alt="A thumbnail of the video for {$v['title']}"/><h4><a href="https://youtu.be/{$vid[1]}">{$v['title']}</a></h4><p>$d</p></div><p>
YOUTUBE;
$url = preg_quote($vid[0], '/');
$pattern = "/<a target=\"_blank\" href=\"https:\/\/" . $url . "\" id=\"dynamiclink_[0-9]\">https:\/\/" . $url . "<\/a>/";
$pattern = "/<a href=\"https:\/\/" . $url . "\" target=\"_blank\" rel=\"noreferrer\" id=\"dynamiclink_[0-9]\">https:\/\/" . $url . "<\/a>/";
$item['description'] = preg_replace( $pattern, $embed, $item['description'] );
}
}
Expand Down

0 comments on commit f2ffdb3

Please sign in to comment.