Warcraft II Forum
Warcraft II => Mods & Development => Topic started by: USA~Archer on April 13, 2015, 04:10:07 PM
-
iL / mouse,
I am trying to install PHP PvPGN utilities on my PvPGN server, is this what RU server uses for ladder stats?
Is some of your PHP custom coded like "oldgames.php"?
If so, once I get it working on my test server, then I can experiment with writing PHP code to contribute for things like this:
Would it be a lot of work to display how many times was a certain map hosted? for example from the last month?
Extended report statistics is in plans.
To clearly parse the reports and collect all data.
Any help with php-coding for this task is appreciated.
I'm having some issues with PHP Utils install:
OS: CentOS 7
DB: MySQL
PvPGN: ver 1.99
Now I am trying to install PHP Utilities
http://sourceforge.net/projects/pvpgn-phputils/ (http://sourceforge.net/projects/pvpgn-phputils/)
The index page works, but when i go to War2 Ladder stats, it shows
Connection Error to Mysql Server
But I have the MySQL server configured correctly in the config file, I'm pretty sure
CONFIG FILE of PHP UTILS FOR PVPGN
<?php
// ----------------------------------------------------------------------
// Player -vs- Player Gaming Network Statistics System
// http://pvpgn.spfree.net/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Author from 2.4.4: Pelish (pelish@gmail.com)
// Original author: jfro (imeepmeep@hotmail.com)
// Author from 2.3.20: Snaiperx (http://www.rino.com.co/)
// Author from 2.3.16: STORM (http://www.stormzone.ru/)
// Tanzania theme author: Tanzania (tanzania@gmx.net)
// ----------------------------------------------------------------------
// ---------------------------------------------------------------------------------
// Database & System Config settings - Key
//
// db_type: Database type (mysql, pgsql, etc.)
// db_host: SQL Server Hostname or IP address
// db_port: SQL Server port
// db_database: SQL Database Name
// db_user: SQL Username
// db_pass: SQL Password
// db_prefix SQL Database Prefix
// db_record: Name of the table with player records in yourSQL DB
// db_bnet: Name of the table with player info`s in your SQL DB
// db_profile: Name of the table with player profile in your SQL DB
// db_teams: Name of the table with team records in your SQL DB
// db_friend: Name of the table with friends records in your SQL DB
// db_counters: Name of the table with counter records in your SQL DB
// db_d2: Name of the table with d2ladder records in your SQL DB
//
// *NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*
// *NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*
// (Provided my Gambit)
// For better support for everyone, I have added a central location to assign links for
// all PHP and HTML pages. Now you don't have to scour HTML code for links/URL's to wrong domains.
// Assighn the values below to correct all links and refrences to your webpage.
//
// (DO NOT UNCOMMENT, CHANGE BELOW UNDER "// System Config settings")
// homepage Full URL to your websites Home Page
// ladderroot Full URL to main stats page
// (DO NOT UNCOMMENT, CHANGE BELOW UNDER "// System Config settings")
//
// *NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*
// *NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*NEW*
// System Config settings
$site_name = "PvPGN server";
$db_type = "mysql";
$db_host = "127.0.0.1";
$db_port = 3306; /* 3306 is the most common MySQL port */
$db_database = "my-mysql-user";
$db_user = "my-user";
$db_pass = "my-mysql-password";
$db_prefix = "pvpgn_";
$db_record = $db_prefix."Record";
$db_bnet = $db_prefix."BNET";
$db_profile = $db_prefix."profile";
$db_teams = $db_prefix."team";
$db_friend = $db_prefix."friend";
$db_counters = $db_prefix."counters";
$db_d2 = $db_prefix."d2ladder";
$homepage = "http://10.1.1.126/";
$ladderroot = "http://10.1.1.126/"; /* can also be something like "http://www.myserver.net/ladder/" */
$theme = "bnet";
$use_php_xslt = true; // only change this if you know you have xsltproc installed and not php-xslt
$xslt_command = "xsltproc"; // for when you don't have php4-xslt but have the xsltproc command or sabcmd
// set pvpgn_dir to where you pvpgn directory is, include trailing slash
$pvpgn_dir = "/usr/local/pvpgn/";
$ladders_dir = $pvpgn_dir."var/pvpgn/ladders/";
$w3ladder_xsl_file = getcwd()."/themes/$theme/w3ladder.xsl";
$d2ladder_xml_file = $ladders_dir."d2ladder.xml";
$d2ladder_xsl_file = getcwd()."/themes/$theme/d2ladder.xsl";
// ---------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------
// PvPGN variables settings
//
// icon_levelx: Wins required for TFT icon
//
// ---------------------------------------------------------------------------------
$icon_level1 = 25;
$icon_level2 = 50;
$icon_level3 = 100;
$icon_level4 = 200;
$icon_level5 = 500;
// ---------------------------------------------------------------------------------
// Page settings
//
// site_theme: Theme you want to run
// page_max: How many players you want to display on one page
// default_game: Defines stats for which game user will see on entering
// default_type: Defines which type of game user will see on entering
// date_format: Defines PHP date format used in stats displaying
// d2ladder_file: Path on your system which shows ladder.D2DV location
// d2update_time: Time to update your D2 DB (in seconds), 0 is off
// stats_version: Don't change, just for easier version display
//
// ---------------------------------------------------------------------------------
$site_theme = "bnet";
$page_max = "50";
$default_game = "W2BE";
$default_type = "solo";
$date_format = " F j - G:i";
$d2ladder_file = "/usr/local/pvpgn/var/pvpgn/ladders/ladder.D2DV";
$d2update_time = "3600";
$stats_version = "2.4.5";
// ---------------------------------------------------------------------------------
// Administration Interface settings
//
// max_rank: Maximum rank number allowed on your server
// default_sort_by: Can be auth_lock, auth_admin, uid or acct_username
// default_sort_dir: Can be DESC or ASC
//
// ---------------------------------------------------------------------------------
$max_rank = "1000";
$default_sort_by = "auth_admin";
$default_sort_dir = "DESC";
// ---------------------------------------------------------------------------------
// Optional User file settings (unfinished, doesn`t work)
//
// pvpgn_users: Path on your system which shows user dir location
// use_files: Defines whether we use files or database
//
// ---------------------------------------------------------------------------------
$pvpgn_users = "/usr/local/pvpgn/var/pvpgn/users";
$use_files = false;
// ---------------------------------------------------------------------------------
// END of conf file.
?>
-
I got it working, its very strange, it looks like i found a bug in the PHP PvPGN Utility:
after looking at /var/log/httpd/error_log
it had a PHP Warning, at mysql_handler.php line 35
So I go look at the mysql_handler php code, and see its trying to connect to "$db_hostname" but the variable used should actually be $db_host
Changed it to $dbhost and now it works.
<?php
// ----------------------------------------------------------------------
// Player -vs- Player Gaming Network Statistics System
// http://pvpgn.spfree.net/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Author from 2.4.4: Pelish (pelish@gmail.com)
// Original author: jfro (imeepmeep@hotmail.com)
// Author from 2.3.20: Snaiperx (http://www.rino.com.co/)
// Author from 2.3.16: STORM (http://www.stormzone.ru/)
// Tanzania theme author: Tanzania (tanzania@gmx.net)
// ----------------------------------------------------------------------
class sql_handle {
var $db_connection;
// ----------------------------------------------------------------------------------------------
// This is how we connect to DB
// ----------------------------------------------------------------------------------------------
function db_connect([size=14pt][b]$db_hostname,[/b][/size] $db_username, $db_password, $db)
{ global $db_port;
$this->db_connection=mysql_connect($db_hostname.":".$db_port, $db_username, $db_password)
OR die ("Connection Error to Mysql Server");
mysql_select_db($db)
OR die("Connection Error to Database");
return $this->db_connection;
}
-
So I can see by looking at this, it looks exactly like war2.me's ladder, but doesnt look anything like ladder.war2.ru
So are you guys using different utilities or is ladder.war.2ru just themed differently?
-
Blid made ladder.war2.ru
-
Yeah I used this along time ago. But i dont remember having that issue.... did you download from the original source?
-
Yeah, from the sourceforge link there
Ive run into tons of little glitches like that trying to set this thing up. Just finally got ladder rank fully working, it involved having to manually add several mysql tables and columns that the PHP utils program was trying to use but hadnt created for itself
At one point i deleted the wrong table on accident, luckily i had a snapshot of my pvpgn VM, had to revert back, dump mysql, go back and import the db and try again
Hope blid will share the PHP code for the current ladder and oldgames.php so i can run on my sever, experiment, and come up with some new features, then give back to RU
For example, i was on RUs oldgames.php today and manually searching for games by using CTRL F, so that i could find tournament games and record them for the bracket at my site
The "games today" and "yesterday" works fine but when you try to dump "games this week" the page crawls and sometimes crashes the browser
I would like to make a search feature so i can search for "pball" or "60men" and get all the games within a specified time period.
Maybe even set up to send me an email when someone makes a pball game
Also the feature request that started this discussion: making a PHP script that figured out the most popular maps this week, month, etc
Sent from my iPhone using Tapatalk
-
Ive run into tons of little glitches like that trying to set this thing up. Just finally got ladder rank fully working, it involved having to manually add several mysql tables and columns that the PHP utils program was trying to use but hadnt created for itself
Yeah, I remember having to do that too. I think this script is more geared towards D2/W3 isn't it? But yeah, afaik ru doesn't use this or any of the other open source pvpgn scripts. Custom ladder, custom server status, etc.
oldgames.php is also some custom thing, I don't know who created it. All views of it are slow as hell for me, especially when you initially visit the page. It works by parsing the game reports pvpgn generates in /var/reports/ but it's so inefficient since the reports just pile up in that directory and are never purged I think? I haven't look at it too closely. The whole thing should probably be scrapped and rewritten, which I was thinking about messing with in the future.
I also don't really see a problem with making some of this stuff open source and letting you & others contribute to it, but that's not a decision I'm going to make on my own, especially given that the code we're discussing right now isn't even my work. You may want to contact iL directly about that and see what he says. If he supports it then I will too.
-
iL, Blid, lets work together to code some new game data tools
As long as RU is top result on google for Warcraft 2, its going to continue to be the only War2 server in the world (that matters). No ones going to try make their own server, split this tiny community, just so they can have the burden of supporting it themselves 24/7
Let me know if you want to share your game data PHP codes so we can all rework it and improve RU
Sent from my iPhone using Tapatalk
-
iL, Blid, lets work together to code some new game data tools
Sure, welcome to our team!
Are you experienced in php-programming or w/e?
Ive run into tons of little glitches like that trying to set this thing up
I didn't try PHP PvPGN utilities because i don't think that's really what we need.
For example, i was on RUs oldgames.php today and manually searching for games by using CTRL F, so that i could find tournament games and record them for the bracket at my site
The "games today" and "yesterday" works fine but when you try to dump "games this week" the page crawls and sometimes crashes the browser
oldgames.php is a small separate script have been made by one of old russian players, he doens't play last 5-6 years.
That script is far from perfect and should be refactored i think.
"games this week" makes the server highload and i'm happy to keep it separately from bnet-server hosting.
I plan to rewrite oldgames.php as a part of new extended reports statistics.
I would like to make a search feature so i can search for "pball" or "60men" and get all the games within a specified time period.
Maybe even set up to send me an email when someone makes a pball game
Also the feature request that started this discussion: making a PHP script that figured out the most popular maps this week, month, etc
Yes, i think the best way is to move the reports to the database totally.
Then you will be able to easily add 1 more sql-request with 1 more page to receive as complicated request as you wish.
Let me know if you want to share your game data PHP codes so we can all rework it and improve RU
Sure, i think we can share oldgames.php and probably ladder.war2.ru (if Blid agrees) to you if that help. But existing scripts are ugly, i'd say it's much easier to make new code than to change the existing one.
The first task i see on this project is to make the report parser for reports here: http://reportb.war2.ru/ (http://reportb.war2.ru/)
To parse about 200 000 reports for the start and continual parsing every several minutes. That will be a directory, need to check which reports should be parsed.
Also to make the database table structure to keep all the report data and to let us make any reports we want.
-
Cool,
I'm a Network + VoIP Engineer, also making websites has always been a hobby.
Ive always wanted to learn how to write a useful program, but i never got far in studying because i have always been studying network and VoIP.
But now I have been studying PHP and having fun with it so hope i can contribute some good code.
Also, i always have security in mind when writing code because I have studied network, voip, and application security. So i will make sure to sanitize user input and test against sql injection before contributing anything
Sent from my iPhone using Tapatalk
-
Bravo archer rock that shit.
-
So, is anything being done about this?
-
I think the first thing that needs to be done is to have PvPGN store the game data in the database instead of text files
Once the data is stored in a database, we can work on writing PHP to talk to the db and display game data more efficiently
So far I dont know how to do either of those things however...
Sent from my iPhone using Tapatalk
-
Pvpgn asks in the config how to save the files and where... let me double check lol
Edit yea super easy to do.
-
Ok cool! i will setup my pvpgn server to write game data to db and start working on the php side then
Sent from my iPhone using Tapatalk
-
Tupac,
I dont see it in bnetd.conf
The storage option section is only for storing accounts in db, which i have set to store in mysql but reports doesnt have a db option
Sent from my iPhone using Tapatalk
-
hmm yteah i wrote the ladder without ever learning how to program. frostbitten made the stylesheet. il came in and cleaned up the ladder code to a degree. there was a player recently that asked to see the script and i said sure and mousetopher sent it to him, he was planning to see if he could add in a skill rating. havent heard anything about it. usa~archer is talking about wanting to look at our custom ladder? or about some sort of pvpgn ladder?
-
Your custom ladder, the pvpgn ladder i installed on my own server to play with it but it isnt what we need.
iL said its best to rewrite oldgames.php from start so thats what were working on but still curious to see your code
How did u write it without knowing how to? Code generator of some kind?
Sent from my iPhone using Tapatalk
-
Maybe that he never sat down and formally "learned" any programming language? It's not really necessary, I only really know the PHP & SQL I've picked up from working with WP and was still able to figure out War2TV and some other crap. Programming languages all basically do the same thing, the important part is figuring out the necessary logic to make something work, then it's just a matter of Googling the syntax to make it happen.
So, if pvpgn can be configured to output reports directly to mysql then that's the way to go for sure. Writing the script to retrieve them from the db based on date or whatever would be sooper easy.
Tupac,
I dont see it in bnetd.conf
The storage option section is only for storing accounts in db, which i have set to store in mysql but reports doesnt have a db option
I think this is right though. Even so, it'd also be sooper easy to process the report files and put them into a db. The two main concerns are 1) making it efficient (iL said there's like 200k old report files to deal with?) and 2) making it secure. But even factoring that in, I don't think it'd be hard.
-
So instead of reworking pvpgn to save gr's to db, you think it would be easier to make some kind of script that reads past, current, and future gr's, and imports them to db?
Im taking some classes at teamtreehouse.com right now on PHP + MySQL
Sent from my iPhone using Tapatalk
-
If pvpgn doesn't already support exporting reports to db, then yes. (coming from someone who knows nothing about C but a little about PHP). I have no idea how you expect to write a script that reads reports for games that haven't happened yet though. :D
-
Ok makes sense.
Lol @ future games
Sent from my iPhone using Tapatalk
-
Edit the pvpgn source I looking into this now I have more time.
-
Cool
Sent from my iPhone using Tapatalk
-
Your custom ladder, the pvpgn ladder i installed on my own server to play with it but it isnt what we need.
iL said its best to rewrite oldgames.php from start so thats what were working on but still curious to see your code
How did u write it without knowing how to? Code generator of some kind?
learned php as i went along. as a result the code worked but wasn't very clean or efficient but il might have fixed that stuff. ive forgotten all php since then.
-
the code i wrote uses entirely publicly available info, it literally does not use a single thing you need admin access for. goes to somewhere like this: http://reportb.war2.ru/ (http://reportb.war2.ru/), and opens all the unchecked reports, parses them, and adds them to its own db.
if pvpgn just outputs game results direct to a db the coding couldve been a lot easier heh
-
I think the first thing that needs to be done is to have PvPGN store the game data in the database instead of text files
Once the data is stored in a database, we can work on writing PHP to talk to the db and display game data more efficiently
So far I dont know how to do either of those things however...
AFAIK PvPGN have no option to store it's log in DB. So we should make a report parser ourselves.
To parse the report and upload it's data to DB.
the code i wrote uses entirely publicly available info, it literally does not use a single thing you need admin access for. goes to somewhere like this: [url]http://reportb.war2.ru/,[/url] ([url]http://reportb.war2.ru/,[/url]) and opens all the unchecked reports, parses them, and adds them to its own db.
Yes, exactly, this reportb should be used with parser.
Also note that these reports should contain different languages depend on war2-client language: english (usual), german (for some clients), russian (for russian combat), spanish (for spanish build) and maybe several more.
I think the 1-st thing we need is parser function.
Proper function should return one of 3 values:
- success, when the game parsed and result is inside the DB
- broken report, when game parsed but script detected an error in the report
- parse error, when game has not been parsed but not sure if it's error script or not. A reason to check and debug the script.
Also, it should parse all the games: were people have been dropped, used different languages and played 1v1, 2v5, 4v4 or any others.
That is how i see this.
Also, i dislike current database format and prefer to refactor it also.
I think about 2 main tables:
- games with all game parameters (name, id, type, option, 3 dates, map, mapauth, mapsize, tile, joins, maxplayers, minutes).
- players - the table contains each player in each game (game_id, player_order, name, race, WIN_LOSS_DISC, map, play_time, language, score, units, structures, resources, etc...)
I mean everyting except maybe normal/ladder/iron records as not related to the game.
Maybe several more tables needed to improve performance and size: player_name2id, map_name2id, etc.
Any your offers about DB structure are welcomed also.
iL said its best to rewrite oldgames.php from start so thats what were working on but still curious to see your code
Yes, i mean oldgames and ladder stats have common part for report parsing, that part is non-trival, so looks reasonable to use the same code for both projects.
Also would be much easier to read oldgames from DB when we upload data to it.
-
In addition to previous:
good idea for parsing based on templates and scanf. I'd go that way for the game parsing:
https://code.google.com/p/hwstats/
hwstats_2.35f-sc.zip
Check scripts/parse_reports.php:
function LoadReport($filename, $template)
{
$template = file_get_contents($template);
$content = file_get_contents($filename);
....
$ri = sscanf( $content, $template ); // report info
...
$info=array(
//game info
"GameName" => $ri[0],
"GameID" => $ri[1],
"ClientTag" => $ri[2],
"GameType" => GetGameOption($ri[3]),
...
there's for 2 players only, we need up to 8.