View Single Post
Ejziponken
AlliedModders Donor
Join Date: Apr 2008
Old 08-14-2017 , 14:50   Re: CSGO MOTD new redirect method (2017)
Reply With Quote #3

Quote:
Originally Posted by root88 View Post
Hi there. I've seen few bad plugins without sharing full code (I mean php code):
WebLinks - https://forums.alliedmods.net/showthread.php?t=300313
WebLync - https://forums.alliedmods.net/showthread.php?t=298458

Isn't it against alliedmodders forum rules? Well, as moderators are doing nothing about that, I've spent some time testing possible solutions (idk if it's the same method used in above plugins - but probably it is).

So, you will need some php code, example below (redirect.php)
PHP Code:
<?php
if(isset($_GET['url']))
{
    
$url =  $_GET['url'];
}
else
{
    die(
'No redirection url set!');
}
header("Content-Encoding: none");
ob_end_clean();
ignore_user_abort(true);
ob_start();
echo 
"<script type=\"text/javascript\">
window.open('
$url', 'www', false);
</script>
"
;
$size ob_get_length();
header("Content-Length: $size");
header("Connection: close");
ob_end_flush();
ob_flush();
flush();
exit();
?>
Example SourcePawn plugin below (webshortcuts_test.sp)
PHP Code:
#include <sourcemod>
#pragma semicolon 1
#define PLUGIN_VERSION "1.0.0"

public Plugin:myinfo =
{
    
name "CS: GO Webshortcuts",
    
author "root",
    
description "Just simple webshortcuts.",
    
version PLUGIN_VERSION,
    
url "http://uwujka.pl"
}

char sRedirectPHP[] = "http://ADDRESS_TO_YOUR_WEB_PAGE/redirect.php?url=";
char sUrl2[MAXPLAYERS+1][256];

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_www"www);
    
RegConsoleCmd("sm_sail"sail);
}

public 
Action:www(clientargs)
{
    
char sUrl[] = "http://uwujka.pl";
    
Format(sUrl2[client], 256"%s%s"sRedirectPHPsUrl);
    
ShowMOTDPanel(client""sUrlMOTDPANEL_TYPE_URL);
    
CreateTimer(0.5ShowReloadedUrlclient);
    return 
Plugin_Handled;
}

public 
Action:sail(clientargs)
{
    
char sUrl[] = "https://www.youtube.com/watch?v=YS4fXhiVEQM";
    
Format(sUrl2[client], 256"%s%s"sRedirectPHPsUrl);
    
ShowMOTDPanel(client""sUrlMOTDPANEL_TYPE_URL);
    
CreateTimer(0.5ShowReloadedUrlclient);
    return 
Plugin_Handled;
}

public 
Action:ShowReloadedUrl(Handle:timerany:client)
{
    
ShowMOTDPanel(client""sUrl2[client], MOTDPANEL_TYPE_URL);


You can easily adapt code to any web shortcuts plugin. Have fun, but please - give me credits if you use my code. I've made many plugins which I'm not sharing with you because many people just took my code and gave credits to themselves (sadly most of them are from Poland).

WARNING: IT WILL NOT WORK IF YOUR WEB SERVER USES SERVICE LIKE CLOUDFLARE WHICH MODIFICATES HEADERS!

EDIT:
It seems it's not reloading this page now for unknown reason - showing the same page, no mather if I change url. I will look at this...


EDIT2:
Fixed above bug with new plugin code.
Does not seem to work with my other webshortcuts_csgo plugin. Do I have to use youre plugin?

And ESKO who made WebLinks is saying he will release his webfiles. So not sure if you need to put any more effort into this.

But big thanks. <3

Last edited by Ejziponken; 08-14-2017 at 14:53.
Ejziponken is offline