Online Server List

Arrange meetings with other people to play MP, announce your servers.
Zinal
Inserter
Inserter
Posts: 28
Joined: Mon Sep 01, 2014 5:42 pm
Contact:

Online Server List

Post by Zinal »

So.. I was searched the forum for an online server list since I don't trust third-party application without open-source.
I couldn't find any so I made one myself!
It can be found here: http://factorio.zinals.nu/FactorioServerList/index.php.

The site features a simple list of servers with a name, host, port and a description.
A single person can add up to 10 servers on the list (If you want to add more, contact me and we can sort it out). I limited it to 10 servers/person as a precaution (Since everyone can add servers as they like)
More features will be added on request.

If you have any requests or suggestions, don't hesitate to tell me! :)
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Online Server List

Post by ssilk »

I knew, that sooner or later someone would come up with such a thing. Good idea!

But when you don't trust third party, why should the others? In other words: Where is your code? :)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
User avatar
HeilTec
Filter Inserter
Filter Inserter
Posts: 258
Joined: Tue Jul 08, 2014 1:14 pm
Contact:

Re: Online Server List

Post by HeilTec »

There are no servers as such - only gamers playing p2p.

I don't trust your site. Show some code.
Google is my friend. Searching the forum and the wiki is always a first.
Zinal
Inserter
Inserter
Posts: 28
Joined: Mon Sep 01, 2014 5:42 pm
Contact:

Re: Online Server List

Post by Zinal »

Wow, people are even more suspicious of a web-application than a standalone program? :O

Anyway, I'm running a PHP server with the framework CodeIgniter. I have a Controller, A model and several views.
Adding a server or updating the list is made through Javascript and AJAX (to communicate with the backend PHP server).
The only information I collect, other than the name,host,port and description, is the user's IP-Address. I collect the IP for a single reason: Spam-Protection.

Controller:

Code: Select all

class Main extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->library("template_manager");
        $this->load->model("server_model");
        $this->tm = $this->template_manager;
    }
    
    public function index()
    {
        $this->server_model->remove_old_servers();
        $data = new stdClass();
        
        $data->servers = $this->load->view("servers_list", array("servers" => $this->server_model->get_list()), true);
        
        $this->tm->load_content("main_view", $data);
        $this->tm->show();
    }
    
    public function update_list()
    {
        $this->server_model->remove_old_servers();
        exit($this->load->view("servers_list", array("servers" => $this->server_model->get_list()), true));
    }
    
    public function add_server()
    {
        if(!IS_AJAX)
            exit("No direct access allowed!");
        
        $name = post("name", true);
        $host = post("host", true);
        $port = post("port", true);
        $description = post("description", true);
        $ip = $this->input->ip_address();
        
        if(strlen($name) < 5)
            exit(json_encode(array("error" => "The name of the server has to be atleast 5 characters long")));
        
        if(!$this->input->valid_ip($host))
            exit(json_encode(array("error" => "The host you provided is not an valid IP address")));
            
        if($port === false || !is_numeric($port))
            exit(json_encode(array("error" => "The port you provided is not an valid number")));
        
        $server = $this->server_model->get_from_host($host, $port);
        if($server != null)
            exit(json_encode(array("error" => "There is already a server with that host/ip: {$server->name}")));
        
        if(count($this->server_model->get_servers_from_ip($ip)) > 10)
            exit(json_encode(array("error" => "You have already added 10 servers to the list. Contact Zinal if you want to add more")));
        
        $id = $this->server_model->add_server($name, $host, $port, $description, $ip);
        $server = $this->server_model->get($id);
        exit(json_encode(array("result" => "The server {$server->name} has been added to the list")));
    }

    public function update_last_played()
    {
        if(!IS_AJAX)
            exit("No direct access allowed!");
        
        $id = post("id", true);
        
        $this->server_model->update_last_played($id);
        $this->update_list();
    }
    
}
 
Model:

Code: Select all

class Server_Model extends CI_Model
{
    private $server_table = "servers";
    
    public function __construct()
    {
        parent::__construct();
    }
    
    public function get($id)
    {
        return $this->db->where("id", $id)->get($this->server_table)->row();
    }
    
    public function get_list()
    {
        return $this->db->where("removed", null)->get($this->server_table)->result();
    }
    
    public function get_from_host($host, $port)
    {
        return $this->db->where("host", $host)->where("port", $port)->get($this->server_table)->row();
    }
    
    public function add_server($name, $host, $port, $description, $ip)
    {
        $this->db->insert($this->server_table, array(
            "name" => $name,
            "host" => $host,
            "port" => $port,
            "description" => $description,
            "from_ip" => $ip,
            "inserted" => date("Y-m-d H:i:s"),
            "last_played" => date("Y-m-d H:i:s")
        ));
        
        return $this->db->insert_id();
    }
    
    public function remove_old_servers()
    {
        $remove = array();
        $servers = $this->get_list();
        $today = new DateTime();
        
        foreach($servers as $server)
        {
            $last_played = new DateTime($server->last_played);
            $diff = $today->diff($last_played, true);
            
            if($diff->days > 5)
                $remove[] = $server->id;
        }
        
        if(count($remove) > 0)
        {
            $this->db->where_in("id", $remove)->update($this->server_table, array("removed" => date("Y-m-d H:i:s")));
            return $this->db->affected_rows();
        }
        
        return 0;
    }
    
    public function get_servers_from_ip($ip)
    {
        return $this->db->where("from_ip", $ip)->get($this->server_table)->result();
    }
    
    public function update_last_played($id)
    {
        $this->db->where("id", $id)->update($this->server_table, array("last_played" => date("Y-m-d H:i:s")));
        return $this->db->affected_rows();
    }
    
}
I will not post the views, since there are several and only consist of HTML data with PHP echo tags.
Anything else you wanna know?

(EDIT: Just realized that the code here was not the latest upload, it was missing the functions for removing old servers)
Alkalyne
Inserter
Inserter
Posts: 25
Joined: Sun Jun 15, 2014 11:39 pm
Contact:

Re: Online Server List

Post by Alkalyne »

Code: Select all

Wow, people are even more suspicious of a web-application than a standalone program? :O
It's weird... I don't know why people are suspicious, it's just a list of server
Zinal
Inserter
Inserter
Posts: 28
Joined: Mon Sep 01, 2014 5:42 pm
Contact:

Re: Online Server List

Post by Zinal »

Well, I can relate somewhat..
In my work as a programmer I've seen several pages that collected all the information it can from users that enter it.. It's not much, mostly just the IP of the user, the useragent and small stuff like that, but still, I can guarantee that my page does nothing of that (except for saving the user's IP when creating a server). It doesn't use cookies nor sessions!
User avatar
SHiRKiT
Filter Inserter
Filter Inserter
Posts: 706
Joined: Mon Jul 14, 2014 11:52 pm
Contact:

Re: Online Server List

Post by SHiRKiT »

Congrats for the intention, thanks for creating it!
Zinal
Inserter
Inserter
Posts: 28
Joined: Mon Sep 01, 2014 5:42 pm
Contact:

Re: Online Server List

Post by Zinal »

Added a button to remove a server from the list.
This can however only been seen by the user that created the server.

Also changed the ordering of the list. The server that was last played on (by clicking the button) will appear at the top of the list. (This means that inactive servers will be pushed down the list).

Edit: Just realized that I didn't implement the search function (not like it's needed right now, with only 3 test servers on the list), but now it works and you can search for a server name there.

I might add a registration/login system to add/remove servers (meaning that you have to login to add a server). This will increase the security of the list.. What do you guys think?
Alkalyne
Inserter
Inserter
Posts: 25
Joined: Sun Jun 15, 2014 11:39 pm
Contact:

Re: Online Server List

Post by Alkalyne »

I found a bug : When you delete a server you cannot add it again (a server with this ip already exist)
Zinal
Inserter
Inserter
Posts: 28
Joined: Mon Sep 01, 2014 5:42 pm
Contact:

Re: Online Server List

Post by Zinal »

Alkalyne wrote:I found a bug : When you delete a server you cannot add it again (a server with this ip already exist)
Fixed it, forgot to remove the server from a temporary list.
n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: Online Server List

Post by n9103 »

Code: Select all

A Database Error Occurred

Error Number: 1054

Unknown column 'deleted' in 'where clause'

SELECT * FROM (`servers`) WHERE `deleted` IS NULL AND `host` = '108.115.33.109' AND `port` = '34197'

Filename: G:\Programs\Apache\htdocs\FactorioServerList\system\database\DB_driver.php

Line Number: 330
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.
Zinal
Inserter
Inserter
Posts: 28
Joined: Mon Sep 01, 2014 5:42 pm
Contact:

Re: Online Server List

Post by Zinal »

n9103 wrote:

Code: Select all

A Database Error Occurred

Error Number: 1054

Unknown column 'deleted' in 'where clause'

SELECT * FROM (`servers`) WHERE `deleted` IS NULL AND `host` = '108.115.33.109' AND `port` = '34197'

Filename: G:\Programs\Apache\htdocs\FactorioServerList\system\database\DB_driver.php

Line Number: 330
Oops, my mistake. Should be removed instead of deleted.. It's fixed now, so try again please :)
User avatar
HeilTec
Filter Inserter
Filter Inserter
Posts: 258
Joined: Tue Jul 08, 2014 1:14 pm
Contact:

Re: Online Server List

Post by HeilTec »

OK - so you can publish an IP on the site. I dont think I'll use that.
I have no public IP so I need to go on some kind of VPN NAT puncher. Evolve seems to do the trick and includes voice chat and groups to find players.
Google is my friend. Searching the forum and the wiki is always a first.
Zinal
Inserter
Inserter
Posts: 28
Joined: Mon Sep 01, 2014 5:42 pm
Contact:

Re: Online Server List

Post by Zinal »

Indeed, Evolve is a great program and all, but it doesn't work for everyone. That's why I made another list. (Well, I really made it since I wanted to.. I was bored xD)
User avatar
HeilTec
Filter Inserter
Filter Inserter
Posts: 258
Joined: Tue Jul 08, 2014 1:14 pm
Contact:

Re: Online Server List

Post by HeilTec »

Zinal wrote:Indeed, Evolve is a great program and all, but it doesn't work for everyone. That's why I made another list. (Well, I really made it since I wanted to.. I was bored xD)
OK - you do get constructive results avoiding boredom.
Google is my friend. Searching the forum and the wiki is always a first.
User avatar
cpy
Filter Inserter
Filter Inserter
Posts: 839
Joined: Thu Jul 31, 2014 5:34 am
Contact:

Re: Online Server List

Post by cpy »

Not trusting websites? Unless you have, noscripts, do not track, adblock, no flash, no cookies (not being on AT&T) you are stupid for saying that.

Because there's nothing you can do about it, he can post anything he wants, what's the god damn point of him posting web site code? Are you some kind of monkeys that see others ask for executable code so now you ask for a damn web site code? Will you run your own web server to test that code?

What makes you think he can't post different code to that which he uses on his web? It's not source code from application that you can compile on your own. Even then if compiled code does not work, I won't trust that guy. You can't just verify web by asking for code.

I run noscript, do not track and adblock myself, because i don't trust web sites. Now I can visit sites like his without problem.
Last edited by cpy on Wed Nov 19, 2014 1:41 pm, edited 4 times in total.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Online Server List

Post by ssilk »

I cannot speak for the others, but for me it was just THIS, that it doesn't make sense to do everything yourself, because you don't trust others... I was just trying to see, how far this will go. :twisted:

But till now, this goes quite well, I think this is a good project. :)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: Online Server List

Post by n9103 »

Descriptions longer than the test one aren't displayed properly after submission. See current list.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.
Zinal
Inserter
Inserter
Posts: 28
Joined: Mon Sep 01, 2014 5:42 pm
Contact:

Re: Online Server List

Post by Zinal »

n9103 wrote:Descriptions longer than the test one aren't displayed properly after submission. See current list.
Sorry about that.. Forgot to replace ' and " characters.. They mess up the HTML page.. That's why it looked like that. Fixed.
User avatar
HeilTec
Filter Inserter
Filter Inserter
Posts: 258
Joined: Tue Jul 08, 2014 1:14 pm
Contact:

Re: Online Server List

Post by HeilTec »

Look at this post from kovarex -
https://forums.factorio.com/forum/vie ... 83&p=49335
As long as this stands it will not work simply publishing an IP. The players need a chat lobby to coordinate joining. Perhaps at some future date a project like this may become useful.
Google is my friend. Searching the forum and the wiki is always a first.
Post Reply

Return to “Multiplayer”