Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Eudemons Online > EO PServer Hosting
You last visited: Today at 19:02

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



certain php code request

Discussion on certain php code request within the EO PServer Hosting forum part of the Eudemons Online category.

Reply
 
Old   #1

 
PowerChaos's Avatar
 
elite*gold: 90
Join Date: Feb 2008
Posts: 1,112
Received Thanks: 642
certain php code request

Dear noobs and pro's

i know that this post has not mutch to do with eo
but it is still used for eo ( my online checker script) as i want to get powerchaos.info back online so it can be used
but before i put it back online i need to have a good script that does his work instead a messy script (you will see what is changed as soon it is ready to go live)

i like to know who are the scripters here because i got a small request for them

i am searching for a way to block invalid ip's that get submitted with a form

to give a example

ip 258.12.20.14 is invalid

invalid is 192.168.1.1 (private lan network)

i got already a way to block hamachi ip's
i got in meantime a way to block all invalid ip's but for 1 of other reason it allows a few to get true


would some1 be nice to point me to the error or fix the error for me ?

a own code that does the same would be nice to

demo of below code can be found at
PHP Code:
                    $validipcheck1 "^([1-9]{1,1})+\.([0-9]{1,3})+\.([0-9]{1,3})+\.([0-9]{1,3})$";
                    
$validipcheck2 "^([1-2]{1,1})+([0-9]{1,2})+\.([0-9]{1,3})+\.([0-9]{1,3})+\.([0-9]{1,3})$";
                    
$hamachiip "^([5]{1,1})+\.([0-9]{1,3})+\.([0-9]{1,3})+\.([0-9]{1,3})$";
                    
$local1 "^([1]{1,1})+([9]{1,1})+([2]{1,1})+\.([1]{1,1})+([6]{1,1})+([8]{1,1})+\.([0-9]{1,3})+\.([0-9]{1,3})$";
                    
$local2 "^([1]{1,1})+([0]{1,1})+\.([0-9]{1,3})+\.([0-9]{1,3})+\.([0-9]{1,3})$";
                    
$range1 "^([1]{1,1})+([7]{1,1})+([2]{1,1})+\.([1-2]{1,1})+([6-9]{1,1})+\.([0-9]{1,3})+\.([0-9]{1,3})$";
                    
$range2 "^([1]{1,1})+([7]{1,1})+([2]{1,1})+\.([3]{1,1})+([0-2]{1,1})+\.([0-9]{1,3})+\.([0-9]{1,3})$";
                    
$subcheck1 "^([2-9]{1,1})+([5-9]{1,1})+([5-9]{1,1})+\.([0-9]{1,3})+\.([0-9]{1,3})+\.([0-9]{1,3})$";
                    
$subcheck2 "^([0-9]{1,3})+\.([2-9]{1,1})+([5-9]{1,1})+([5-9]{1,1})+\.([0-9]{1,3})+\.([0-9]{1,3})$";
                    
$subcheck3 "^([0-9]{1,3})+\.([0-9]{1,3})+\.([2-9]{1,1})+([5-9]{1,1})+([5-9]{1,1})+\.([0-9]{1,3})$";
                    
$subcheck4 "^([0-9]{1,3})+\.([0-9]{1,3})+\.([0-9]{1,3})+\.([2-9]{1,1})+([5-9]{1,1})+([5-9]{1,1})$";
                    if ((
eregi($subcheck1$ip)) OR (eregi($subcheck2$ip)) OR (eregi($subcheck3$ip)) OR (eregi($subcheck4$ip)) OR (eregi($local1$ip)) OR (eregi($local2$ip)) OR (eregi($range1$ip)) OR (eregi($range2$ip)))
                            {
                            
$sub == 1;
                            }
                            
                            if  ((!
eregi($validipcheck1$ip)) OR (!eregi($validipcheck2$ip)) OR ( $sub == ))
                            {
                            
$proceed 0;
                            
$end 1;
                                echo 
"<blockquote>
                                                      <p>
                                                          “Server ip adress is Not Allowed , Please fill in a differend ip adress.”
                                                      </p>
                                                  </blockquote>"
;
                            }
                            else if ((
eregi($validipcheck1$ip)) OR (eregi($validipcheck2$ip)))
                            {
                            
$proceed 0;
                            
$end 1;
                                echo 
"<blockquote>
                                                      <p>
                                                          “Valid ip match.”
                                                      </p>
                                                  </blockquote>"
;
                            } 
the user who can fix this and can show that it works get free Lifetime Premium hosting from me :P

to point it in small what need to be done
  • block private lan adresses
    192.168.0.0 – 192.168.255.255
    172.16.0.0 – 172.31.255.255
    10.0.0.0 – 10.255.255.255
    5.0.0.0 - 5.255.255.255
  • block invalid ip adresses ( like 256 or higher in any block )
  • check for 3 dots (valid ip adress )
this is what the script still failt to do
  • block invalid ip adresses ( 256.25.21.20 = working )
  • allow short ip adresses ( 1.1.1.1 = fail )
  • allow some valid ip adresses ( 205.25.25.25 = fail )

enjoy the fun
Greetings From PowerChaos
PowerChaos is offline  
Thanks
1 User
Old 10/26/2011, 02:31   #2
 
~*Kronic*~'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 219
Received Thanks: 110
If you would explain what it is intended to do a little more I would be happy to help. You are just trying to block any ips that are local and hamachi?
~*Kronic*~ is offline  
Old 10/26/2011, 02:37   #3

 
PowerChaos's Avatar
 
elite*gold: 90
Join Date: Feb 2008
Posts: 1,112
Received Thanks: 642
indeed
my form submits the server ip ( game server)
and because i know that there are a lot of people ( including bots) that submit wrong ip's
so i like to prevent wrong submision

a wrong ip gives me a lot of server load as my script checks every ip on the provided port to know if it is open or not ( status checking script for private games)

<-- thats what it shows after submision so far

hopely by looking at the above link you got a better idea of what it going be and why i definaly need that ip security

the ip security get used to to prevent local submisions (as best thing ever i saw was 192.168.1.1 as submision ip )

Greetings From PowerChaos

ps: form get submitted and posted into a database and then included in my ip checking script to see if ports are open , thats all it does
PowerChaos is offline  
Old 10/26/2011, 02:55   #4
 
~*Kronic*~'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 219
Received Thanks: 110
All I have to say at the moment is that eregi is a very bad function to use as it is slow and outdated (using str functions is better)... but I fear this topic will be closed and/or locked. If not I will be happy to help tomorrow

EDIT: The echo statements are also not correct formatting, that may be where your problem lies?
~*Kronic*~ is offline  
Old 10/26/2011, 03:10   #5

 
PowerChaos's Avatar
 
elite*gold: 90
Join Date: Feb 2008
Posts: 1,112
Received Thanks: 642
Quote:
Originally Posted by ~*Kronic*~ View Post
EDIT: The echo statements are also not correct formatting, that may be where your problem lies?
if i want to write it like this
PHP Code:
echo "
t
h
e
s
t
"

then it still shows like this
Code:
test
so that echo output does not mather :P

it goes realy only about the checks , but i included the 2 echo's on it to know what it give or should give ( not true/false , but a value if equal )

the script itself got even a email script build in on the same "messy" way as that echo ^^

Greetings From PowerChaos
PowerChaos is offline  
Old 10/26/2011, 06:07   #6
 
hio77's Avatar
 
elite*gold: 20
Join Date: Jun 2006
Posts: 1,759
Received Thanks: 827
tbh that code is pretty clean, clean and short are two very different things.. ill have a look over it if i get a chance for you.. allthough im not the best on eregs..
hio77 is offline  
Old 10/26/2011, 12:14   #7

 
PowerChaos's Avatar
 
elite*gold: 90
Join Date: Feb 2008
Posts: 1,112
Received Thanks: 642
Quote:
Originally Posted by hio77 View Post
tbh that code is pretty clean, clean and short are two very different things.. ill have a look over it if i get a chance for you.. allthough im not the best on eregs..
it does not neeed to be in eregs

it can be kinda the same way or a other way

the only thing that counts for me is that it works and does what it need to do

so it blocks unwanted ip's and invalid ips (like explained above)

Greetings From PowerChaos
PowerChaos is offline  
Old 10/26/2011, 18:23   #8
 
idlemonkey's Avatar
 
elite*gold: 540
Join Date: May 2009
Posts: 1,593
Received Thanks: 591
Smile hope this might be of some use

Im no master scripter but maybe you can make some good use of this ...
Attached Files
File Type: zip Php-AGTC-IPban.ZIP (4.4 KB, 2 views)
idlemonkey is offline  
Old 10/26/2011, 18:23   #9
 
Eurion's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 1,208
Received Thanks: 926
Here's a fast write up, I did. I tested it on a few of the IP's you provided and it seems to be working fine.



Here's the PHP Code:
Code:
<?php
$host = "YourHost"; //Server Host
$db_user = "YourDbUser"; //Database User
$db_pass = "YourDbPass"; //Db Password
$connect = mysql_connect($host, $db_user, $db_pass) OR DIE(mysql_error());
$db_name = "YourDatabase"; //Db Name
//Invalid Ip Checker
function check_ip($IP1) 
{ 
global $connect;
mysql_select_db($db_name);
$IP1 = $IP1; 
$result = mysql_query("SELECT * FROM invalid_ip WHERE active='1'") OR DIE(mysql_error()); 
while($row = mysql_fetch_array($result)) 
{ 
$StartIP = $row['start']; 
$EndIP   = $row['end']; 
if ($IP1 >= $StartIP && $IP1 <= $EndIP) 
{ 
$IP1 = "0";
} 
} 
return $IP1; 
}        
?>

<form action="" method="POST">
<table>
<tr><td>Ip:</td><td><input type="text" name="ip"></td></tr>
<tr><td></td><td><input type="submit" name="check" value=" Check IP "></td></tr>
</table>
</form>
<br />
<br />
<?php
If(ISSET($_POST['check']))
{
global $connect; //Makes the connection variable Global   
$ip = mysql_real_escape_string($_POST['ip']); //Grab the Entered IP
$valid_ip = (check_ip($ip) == '0' ? "No" : "Yes"); //Ternary Check of Invalid Ips. Runs off of the function
$ip_nums = explode('.', $ip);  //Seperates the $ip variable so it can count the blocks
$periods = count($ip_nums) - 1; // Takes the seperate IP blocks, and counts them, then minus's by 1 to get true value.

//Check to make sure each ip block isnt greater than 255
If($ip_nums[0] > 255 || $ip_nums[1] > 255 || $ip_nums[2] > 255 || $ip_nums[3] > 255)
{
 echo 'Sorry Ips can not be larger than 255';    
}
ElseIf($periods != 3) //Check Periods to make sure there are only 3 periods.
{
 echo "Sorry you don't have enough periods in your IP.";   
}
ElseIf($valid_ip == "No")//Runs the Ip check to see if the entered IP is in the invalid list.
{
 echo "Sorry the IP you entered is invalid.";   
}
Else
{
 echo "It worked!!!!";   
} 
}    
?>

Here's the Mysql Table for the invalid IP checker
Code:
DROP TABLE IF EXISTS `invalid_ip`;
CREATE TABLE `invalid_ip` (
  `id` int(15) NOT NULL auto_increment,
  `start` varchar(20) NOT NULL default '',
  `end` varchar(20) NOT NULL default '',
  `active` enum('0','1') NOT NULL default '0',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;

/* Insert Invalid Ip Ranges that we know of */
INSERT INTO `invalid_ip` VALUES 
('1', '192.168.0.0', '192.168.1.255.255', '1'),
('2', '172.16.0.0', '172.31.255.255', '1'),
('3', '10.0.0.0', '10.255.255.255', '1'),
('4', '5.0.0.0', '5.255.255.255', '1');

I had it set up to a form on my test page. But by following the comments, you should be-able to tell what each section does.
Eurion is offline  
Thanks
2 Users
Old 10/26/2011, 21:06   #10
 
Thorlon's Avatar
 
elite*gold: 100
Join Date: Mar 2011
Posts: 620
Received Thanks: 409
Nice job Eurion, im sure Powerchaos will be very grateful.
Thorlon is offline  
Old 10/26/2011, 23:58   #11

 
PowerChaos's Avatar
 
elite*gold: 90
Join Date: Feb 2008
Posts: 1,112
Received Thanks: 642
Quote:
Originally Posted by idlemonkey View Post
Im no master scripter but maybe you can make some good use of this ...
it is a nice script
but the checks are failing
i can not add every single ip range to a txt file to lookup the check

the 3 dot check is missing , the 255+ is missing and the ip range check is missing

but for the rest it is a nice script


Quote:
Originally Posted by Eurion View Post
Here's a fast write up, I did. I tested it on a few of the IP's you provided and it seems to be working fine.

Here's the Mysql Table for the invalid IP checker
Code:
('1', '192.168.0.0', '192.168.1.255.255', '1'),
I had it set up to a form on my test page. But by following the comments, you should be-able to tell what each section does.
Thank you for the code
but you messed up a little part ( the part i quoted :P )

if it works then i let you know , i still need to edit a lot from it as my script got a own database already
but atleast the function/check part is what i need and then i can implent it into my script

Thank you
Greetings From PowerChaos

Thank you Eurion,
i can confirm that this code works like it need to be
i can even block proxy's from submitting and can do a lot more now with the example you provided to me

it is a bit differend code then i was thinking , but atleast it works perfect like it need to be ( easy to add new blocks and to add other security to it )

please send me a pm for the coupon code of the lifetime hosting (so i know if you realy want it ^^ )

Greetings From PowerChaos
PowerChaos is offline  
Old 10/27/2011, 02:39   #12
 
Eurion's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 1,208
Received Thanks: 926
Thanks for the offer PowerChaos, but I'm in no need for a membership Perhaps you can give it to someone else who is in need of it.
Eurion is offline  
Old 10/27/2011, 05:03   #13

 
PowerChaos's Avatar
 
elite*gold: 90
Join Date: Feb 2008
Posts: 1,112
Received Thanks: 642
The site is live now

i made a new topic so users can request what need to be added or what they like to have added

your code is realy nice and easy
exactly what i needed
in meantime i was finishing the script as the submit script is the most work ( it need a lot of checks :P )


Thank you
Greetings From PowerChaos
PowerChaos is offline  
Old 10/27/2011, 05:08   #14
 
Thorlon's Avatar
 
elite*gold: 100
Join Date: Mar 2011
Posts: 620
Received Thanks: 409
I don't want to be pushy but if you are willing to give away the vps i would be very interested
Thorlon is offline  
Old 10/27/2011, 05:11   #15

 
PowerChaos's Avatar
 
elite*gold: 90
Join Date: Feb 2008
Posts: 1,112
Received Thanks: 642
Quote:
Originally Posted by Thorlon View Post
I don't want to be pushy but if you are willing to give away the vps i would be very interested
who is talking about a vps ??

Quote:
the user who can fix this and can show that it works get free Lifetime Premium hosting from me :P
premium hosting = 10GB space , 300GB traffic ... and so on (its a hosting package from me with a value of 3€ per month )

anyway , i leave the desision totaly up to eurion or i can give it away as a other reward when needed :P

Greetings From PowerChaos
PowerChaos is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[REQUEST] CODE please...
07/17/2011 - Facebook - 0 Replies
pa share naman po ng mga code.. pa pm po sa code!! TY in ADVANCE..
[Request] code
10/26/2009 - AutoIt - 5 Replies
can someone help me with a code..for silkroad i want to be a keypresser 1~5 very faster...but just for SRO ( controlsend funciton) i dont know how to make it..please help me !
[Request]Pharmacist Items Code So I Code Buy the Scroll
05/30/2009 - CO2 Private Server - 1 Replies
could you please teach me how to code Pharmacist Items so i could buy them all especially the scrolls.
request/help with a code
10/24/2008 - CO2 Private Server - 1 Replies
well i kinda need a lil bit of help on how to start a code that will check if i'm the only one who's on the map O.O thx
[Request]C++ Bot Source Code/Example Code
07/19/2008 - Silkroad Online - 2 Replies
Please someone direct me to anywhere that might have any sort of information and resources on the construction of a bot, preferably in C++. Looking for any Reverse engineering information(finding the Base addr for say player) and locating the offsets ptrs for Cur health etc. I would also love to see a simple example source in C++ of putting those addresses and offsets into action. I'm sure I have the basic idea down on how to do this but I'm not 100% sure how to get it setup correctly. ...



All times are GMT +1. The time now is 19:02.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.