Skip to content

Commit

Permalink
added the validation code from plasticfantastic.com
Browse files Browse the repository at this point in the history
  • Loading branch information
prgsmall committed Sep 26, 2011
1 parent 8b54730 commit 78dd231
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
4 changes: 4 additions & 0 deletions validation/nodejs/db.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$con=mysql_connect("localhost","USERNAME","PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("plast19_nodejs");
?>
24 changes: 24 additions & 0 deletions validation/nodejs/scrCreateServer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
include "db.php";

$externalIP=$_SERVER['REMOTE_ADDR'];
$internalIP=$_GET['ip'];
$port=$_GET['port'];

$sql=mysql_query("
DELETE FROM servers
WHERE externalIP='$externalIP'
");

$sql=mysql_query("
INSERT INTO servers
(externalIP,internalIP,port)
VALUES
('$externalIP','$internalIP','$port')
");

if(!$sql){echo "0"; exit();}

echo "1";

?>
15 changes: 15 additions & 0 deletions validation/nodejs/scrJoinServer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

include "db.php";

$externalIP=$_SERVER['REMOTE_ADDR'];

$sql=mysql_query("SELECT internalIP,port FROM servers WHERE externalIP='$externalIP'");

if(mysql_num_rows($sql)==0){echo "0"; exit();}

$row=mysql_fetch_array($sql);

echo $row[internalIP] . "," . $row[port];

?>
37 changes: 37 additions & 0 deletions validation/servers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
-- phpMyAdmin SQL Dump
-- version 3.4.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Sep 21, 2011 at 09:12 AM
-- Server version: 5.1.54
-- PHP Version: 5.2.6

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `plast19_nodejs`
--

-- --------------------------------------------------------

--
-- Table structure for table `servers`
--

CREATE TABLE IF NOT EXISTS `servers` (
`externalIP` varchar(15) NOT NULL,
`internalIP` varchar(15) NOT NULL,
`port` int(5) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

0 comments on commit 78dd231

Please sign in to comment.