Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-08-2011, 02:51 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
External Playercount

Ever wanted to have you're servers playercount on your website?
Well now you can!

Attached is a zip folder.
Inside are two files.
update.php : The php file which handles everything and creates the file.
script.txt : The script to upload to your GServer.

Notes:
In both files you will see one of the following:
$password = 'password';
or
&pass=password
Please MODIFY both passwords to whatever you wish.
You mas also want to change
$Filename = "index.html";
From index.html to somethingelse.html if you already have an index.html file.
In the script.txt file you WILL need to change http://graalghetto.99k.org/update.php to your own URL.

If you have read and followed all this correctly it should display the servers rc players and the normal player count and the total.

Parts of cbk1994's script in his post which can be found here were used in my scripts.
Attached Files
File Type: zip Source Code.zip (884 Bytes, 253 views)
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 12-09-2011 at 01:45 AM..
Reply With Quote
  #2  
Old 12-10-2011, 05:35 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
i know this is a basic script but, you could improve this by creating variables on Created, so you don't have to search in the script where to change stuffs, and you should probably create a encrypted password in the script, and maybe the php code aswell, for higher security.

maybe perhaps also tell us how you can use this on, lets say, your homepage (lets say the top corner of the website) without having to copy/paste the code into the index.html (=

there's much to learn about in this area, nice work though, even if it wasn't that hard to make.
e; maybe should have been posted in the code gallery as well?
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #3  
Old 12-10-2011, 06:52 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Deas_Voice View Post
you should probably create a encrypted password in the script, and maybe the php code aswell, for higher security.
That sounds like way overcomplicating it. Why not just mash your keyboard a bit to come up with a random password?
__________________
Reply With Quote
  #4  
Old 12-10-2011, 07:34 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by cbk1994 View Post
That sounds like way overcomplicating it. Why not just mash your keyboard a bit to come up with a random password?
Or use a random password generator of your choice.
Reply With Quote
  #5  
Old 12-10-2011, 08:37 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
I find sitting on my keyboard is best, but other methods are..
  • Putting jelly babies on your keys and licking them up while accidentally hitting the keys with your forehead.
  • Plugging a USB keyboard into your laptop and throwing the device at the wall.
  • Stage a "punch and judy" puppet performance on your keyboard and see where it gets you.
Reply With Quote
  #6  
Old 12-10-2011, 10:48 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Ask someone with a crude humor for a new password idea. I asked Eye of the Beholder for password ideas and his suggestions were very interesting.
__________________
Reply With Quote
  #7  
Old 12-11-2011, 01:22 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Lol, mashing the keyboard with your hand does the trick for me.
Or just make a JavaScript code which generates random characters..
And it's not like anyone can easily modify your information, as the GServer is updating it every 10 seconds. So the person skewing around with the information might change it temporarily but not permanently and that's only if they know what the PHP file is named and the password.

On an unrelated note:
I wonder if it's possible to open a socket and communicate to a GServer or vise versa?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #8  
Old 12-11-2011, 01:22 AM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
humour me all you want,
but think bigger, lets say you used this on your gigantic website with all sorts of stuff on; a sql database, forums, etc etc. i'm not the guy who knows what you can/cant do if you got ahold off the password, but lets say you could inject something into the sql database because you use php to get data from it. now that isnt a very good thing, right?

again; this are just my thoughts, and maybe i dont know everything there is about security, but i would rather be on the safe side then guessing that people can't do bad stuffs with the password i've provided.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #9  
Old 12-11-2011, 01:29 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Deas_Voice View Post
humour me all you want,
but think bigger, lets say you used this on your gigantic website with all sorts of stuff on; a sql database, forums, etc etc. i'm not the guy who knows what you can/cant do if you got ahold off the password, but lets say you could inject something into the sql database because you use php to get data from it. now that isnt a very good thing, right?

again; this are just my thoughts, and maybe i dont know everything there is about security, but i would rather be on the safe side then guessing that people can't do bad stuffs with the password i've provided.
wtf are you even talking about, there's nothing in the code that could lead to any kind of SQL injection. Obviously you don't use the same password for more than one thing.

The very worst that could happen is someone finds the password and sends some playercount data with an XSS attack in it to steal cookies from whoever accesses the site and login as them. This is only possible if the site is using bad security practices anyway (e.g. not httponly cookies).

Arbitrary PHP is not being executed, nor are any SQL queries, so I'm not sure how you get SQL injection from that.
__________________
Reply With Quote
  #10  
Old 12-11-2011, 01:50 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
I'm not sure either lmao.
If only post would work...
Then you wouldn't have to worry about any of this.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #11  
Old 12-11-2011, 02:09 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
It would be better to just write the numbers to a file, and use that in your other code.

PHP Code:
<?php

$password 
$_REQUEST["pass"];
$key "1234567890";
if (
$password == $key) {
  
$file "playercount.txt";
  
$file fopen($file'w');
  
$player_count $_GET['players'];
  
$rc_count $_GET['rcplayers'];
  
fwrite($file"$player_count $rc_count");
  
fclose($file);
  echo 
"1";
} else {
  echo 
"INVALID PASSWORD";
}
?>
then in your other code you can use:

PHP Code:
<?php
  
  $data 
=  file_get_contents("playercount.txt");
  
$toks explode(" "$data);
  echo 
"Playercount: " $toks[0];
  echo 
"RCs: " $toks[1];

?>
Re-writing your index every time is just a huge waste.
__________________
Quote:
Reply With Quote
  #12  
Old 12-11-2011, 05:47 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Hmm, Makes sense to write it to a text file instead of re-writing the HTML file.
I will look into it.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #13  
Old 12-11-2011, 05:55 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Gunderak View Post
I'm not sure either lmao.
If only post would work...
Then you wouldn't have to worry about any of this.
POST works fine with cURL (see my func_http post), but that doesn't solve the XSS problem. All you really need to do is validate the data serverside.
__________________
Reply With Quote
  #14  
Old 12-11-2011, 06:57 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Ah, ok that seems cool
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.