HSKrustofsky Posted January 30, 2009 Share Posted January 30, 2009 Can't seem to get this to work... <?php $userip = array("123.456.789.10","10.123.456.*"); if (in_array($_SERVER['REMOTE_ADDR'], $userip)) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="keywords" content="Differential Equations, Dynamical Systems, Nonlinear Problems, Engineering, Sciences" /> <meta name="description" content="Journal, Mathematics, Nonlinear Studies" /> <title>ADVANCED NONLINEAR STUDIES - Vol.9 Num.1</title> <link rel="stylesheet" type="text/css" href="Styles/mainstyle.css" /> </head> <body> <div id="link"> <table width="800px" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="2"> </td> </tr> <tr> <td width="128" bgcolor="#015294"> <a href="journalcover.html"><img src="Images/ShairCover_small.jpg" /></a> </td> <td align="center" bgcolor="#015294"> <font color="#FFFFFF" size="+5">ADVANCED NONLINEAR<br />STUDIES</font><br /> <hr size="2" width="500px" color="#COCOCO" noshade="noshade" /> <font color="#FFFFFF">ISSN 1536-1365</font> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td style="font-family:Arial, Helvetica, sans-serif; color:#015294; border-bottom:solid 2px #015294; border-top:solid 2px #015294;" colspan="2" align="center"> <b> <ul id="nav"> <li style="border-right:solid 2px #015294;"><a href="index.html">Home</a></li> <li style="border-right:solid 2px #015294;"><a href="#">Abstracts</a> <ul> <li><a href="#">Vol. 9, Num. 1</a> <ul> <li><a href="Support/Abstracts/venegas.proofread.pdf">Abstract 1</a></li> <li><a href="Support/Abstracts/jleli2.proofread.pdf">Abstract 2</a></li> <li><a href="Support/Abstracts/Carl-Motreanu.proofread.pdf">Abstract 3</a></li> <li><a href="Support/Abstracts/Zhu.proofread.pdf">Abstract 4</a></li> <li><a href="Support/Abstracts/zanolin.proofread.pdf">Abstract 5</a></li> <li><a href="Support/Abstracts/ghimenti.proofread.pdf">Abstract 6</a></li> <li><a href="Support/Abstracts/Veron.proofread.pdf">Abstract 7</a></li> <li><a href="Support/Abstracts/Melian.proofread.pdf">Abstract 8</a></li> <li><a href="Support/Abstracts/cassani.proofread.pdf">Abstract 9</a></li> <li><a href="Support/Abstracts/Bene.proofread.pdf">Abstract 10</a></li> <li><a href="Support/Abstracts/draghici.proofread.pdf">Abstract 11</a></li> </ul> </li> </ul> </li> <li style="border-right:solid 2px #015294;"><a href="../editors.html">Journal Editors</a></li> <li style="border-right:solid 2px #015294;"><a href="#">Articles</a> <ul> <li><a href="#">Volume 9</a> <ul> <li><a href="v9n1.php">Number 1</a></li> </ul> </li> </ul> <li style="border-right:solid 2px #015294;"><a href="format.html">Format Instructions</a></li> <li><a href="subscribe.html">Order Form</a></li> </ul> </b> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" align="center" style="border-bottom:solid 2px #015294;"> <font size="5" face="Arial, Helvetica, sans-serif" color="#015294"> <b>Table of Contents</b> </font> </td> </tr> <tr> <td colspan="2"> <table width="100%" cellpadding="0" cellspacing="0" align="center" style="border-bottom:solid 2px #015294;"> <tr> <td width="266"> <font face="Arial, Helvetica, sans-serif" color="#015294"> <b>Volume 9</b> </font> </td> <td align="center" width="266"> <font face="Arial, Helvetica, sans-serif" color="#015294"> <b>Number 1</b> </font> </td> <td align="right" width="267"> <font face="Arial, Helvetica, sans-serif" color="#015294"> <b>February 2009</b> </font> </td> </tr> </table> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td align="center" colspan="2"> <font face="Arial, Helvetica, sans-serif" style="font-size:12pt">Click on the <img src="Images/pdficon_small.gif" /> icon to view the articles.</font> </td> </tr> <tr> <td colspan="2"> <font face="Arial, Helvetica, sans-serif" style="font-size:12pt"><p><i><a href="Support/Articles/V9N1_pg1-27.pdf"><img src="Images/pdficon_small.gif" /></a>The Porous Medium Equation With Blowing Up<br /> Boundary Data</i> ... 1<br /> <b>Osvaldo Venegas T.</b></p> <p><i><a href="Support/Articles/V9N1_pg29-68.pdf"><img src="Images/pdficon_small.gif" /></a>Moduli Space Theory of Constan Mean<br /> Curvature Hypersurfaces</i> ... 29<br /> <b>Mohamed JLELI</b></p> <p><i><a href="Support/Articles/V9N1_pg69-80.pdf"><img src="Images/pdficon_small.gif" /></a>Comparison Principle For Quaslinear Parabolic<br /> Inclusions with Clarke's Gradient</i> ... 69<br /> <b>Siegfied Carl, Dumitru Motreanu</b></p> <p><i><a href="Support/Articles/V9N1_pg81-94.pdf"><img src="Images/pdficon_small.gif" /></a>A Note on Asymptotically Linear Schrödinger<br /> Equation on R<sup>N</sup></i> ... 81<br /> <b>Hongbo Zhu</b></p> <p><i><a href="Support/Articles/V9N1_pg95-135.pdf"><img src="Images/pdficon_small.gif" /></a>Conected Branches of Initial Points for<br /> Asymptotic BVPs, With Application to<br /> Heteroclinic and Homoclinic Solutions</i> ... 95<br /> <b>Alessandro Margheri, Carlotta Rebelo, Fabio Zanolin</b></p> <p><i><a href="Support/Articles/V9N1_pg137-147.pdf"><img src="Images/pdficon_small.gif" /></a>Semiclassical Limit For the Nonlinear Klein<br /> Gordon Equation in Bounded Domains</i> ... 137<br /> <b>Marco G. Ghimenti, Carlo R. Grisanti</b></p> <p><i><a href="Support/Articles/V9N1_pg149-164.pdf"><img src="Images/pdficon_small.gif" /></a>On Uniqueness of Large Solutions of Nonlinear<br /> Parabolic Equations in Nonsmooth Domains</i> ... 149<br /> <b>Waad Al Sayed, Laurent Véron</b></p> <p><i><a href="Support/Articles/V9N1_pg165-176.pdf"><img src="Images/pdficon_small.gif" /></a>Quasilinear Equations with Boundary Blow-up<br /> and Exponential Reaction</i> ... 165<br /> <b>Jorge García-Melián</b></p> <p><i><a href="Support/Articles/V9N1_pg177-197.pdf"><img src="Images/pdficon_small.gif" /></a>On a Fourth Order Elliptic Problem<br /> with a Singular Nonlinearity</i> ... 177<br /> <b>Daniele Cassani, João Marcos do Ó, Nassif Ghoussoub</b></p> <p><i><a href="Support/Articles/V9N1_pg199-214.pdf"><img src="Images/pdficon_small.gif" /></a>Retarded Functional Differential Equations on<br /> Manifolds and Applications to Motion Problems<br /> for Forced Constrained Systems</i> ... 199<br /> <b>Pierluigi Benevieri, Alessandro Calamai, Massimo Furi, Maria Patrizia Pera</b></p> <p><i><a href="Support/Articles/V9N1_pg215-226.pdf"><img src="Images/pdficon_small.gif" /></a>Uniqueness and Characterization of the<br /> Maximizers of Integral Functionals With<br /> Constraints</i> ... 215<br /> <b>Cristina Draghici, Hichem Hajaiej</b></p></font> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td style="font-family:Arial, Helvetica, sans-serif; font-size:10pt; border-bottom:solid 2px #015294; border-top:solid 2px #015294;" colspan="2" align="center"> <b>Advanced Nonlinear Studies<br /> Managing Editor: Prof. Shair Ahmad<br /> Email: <a href="mailto:shair.ahmad@utsa.edu">shair.ahmad@utsa.edu</a></b> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </div> </body> </html> <?php } else { header("Location:http://".$_SERVER['HTTP_HOST']."/error.html"); } ?> I need it to where you can add whole IP addresses as well as IP ranges. Can someone help me? Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/ Share on other sites More sharing options...
waterssaz Posted January 30, 2009 Share Posted January 30, 2009 Should do the trick: $ip = array(); $ip[] = '10.10.3.*'; $ip[] = '211.109.238.74'; $ip[] = '254.254.254.2'; function testIP($ip){ //testing that correct IP address used in order //to access admin area... for($i=0, $cnt=count($ip); $i<$cnt; $i++) { $ipregex = preg_replace("/./", "\.", $ip[$i]); $ipregex = preg_replace("/*/", ".*", $ipregex); if(preg_match('/'.$ipregex.'/', $_SERVER[REMOTE_ADDR])) return true; } return false; } Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-750632 Share on other sites More sharing options...
waterssaz Posted January 30, 2009 Share Posted January 30, 2009 Sorry think I have made a small syntax error in above: missed out a slash. use this instead for preg_replace $ipregex = preg_replace(”/\./”, “\.”, $ip[$i]); $ipregex = preg_replace(”/\*/”, “.*”, $ipregex); Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-750635 Share on other sites More sharing options...
HSKrustofsky Posted January 30, 2009 Author Share Posted January 30, 2009 First of all, thanks for your help. I am still having difficulties. It seems to be taking me into a blank page instead of the needed page, or error page(if IP doesn't match). Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-750644 Share on other sites More sharing options...
waterssaz Posted January 30, 2009 Share Posted January 30, 2009 do you have error reporting turned on? Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-750646 Share on other sites More sharing options...
printf Posted January 30, 2009 Share Posted January 30, 2009 Also add ^ in the beginning of the preg_match pattern, so you only block who you really want to block. Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-750661 Share on other sites More sharing options...
HSKrustofsky Posted January 30, 2009 Author Share Posted January 30, 2009 I can't seem to find the error reporting. My custome has decided to host with Yahoo, and I don't know if they have, or offer that. Also, printf, where would I add the ^ in the preg_match pattern. I know you said at the beginning, but exactly where? Just right after the quotes? Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-750788 Share on other sites More sharing options...
printf Posted January 30, 2009 Share Posted January 30, 2009 Sorry, I should have explained it better... change this... if(preg_match('/'.$ipregex.'/', $_SERVER[REMOTE_ADDR])) to this... if(preg_match('/^'.$ipregex.'/', $_SERVER[REMOTE_ADDR])) Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-750828 Share on other sites More sharing options...
HSKrustofsky Posted January 31, 2009 Author Share Posted January 31, 2009 Once again thank you for your help, but I am still getting a blank page. I have no idea what's going on. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-751627 Share on other sites More sharing options...
premiso Posted January 31, 2009 Share Posted January 31, 2009 To see the error do this: <?php error_reporting(E_ALL); ini_set("display_errors", 1); $userip = array("123.456.789.10","10.123.456.*"); if (in_array($_SERVER['REMOTE_ADDR'], $userip)) { ?> Report back what it says. Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-751629 Share on other sites More sharing options...
HSKrustofsky Posted January 31, 2009 Author Share Posted January 31, 2009 No errors, just a blank page. It doesn't go to my error page, or nothing. Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-751640 Share on other sites More sharing options...
printf Posted January 31, 2009 Share Posted January 31, 2009 <?php $ip = array(); $ip[] = '10.10.3.*'; $ip[] = '10.10.24*'; $ip[] = '211.109.238.74'; $ip[] = '254.254.254.2'; function testIP ( $ip ) { $ip = str_replace ( '*', '', $ip ); for ( $i = 0; $i < sizeof ( $ip ); $i++ ) { if ( preg_match ( '/^' . preg_quote ( $ip[$i], '/' ) . '/', $_SERVER['REMOTE_ADDR'] ) > 0 ) { return true; } } return false; } if ( testIP ( $ip ) === true ) { header ( 'Location: http://' . $_SERVER['HTTP_HOST'] . '/error.html' ); exit (); } // continue NO match... ?> Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-751643 Share on other sites More sharing options...
HSKrustofsky Posted January 31, 2009 Author Share Posted January 31, 2009 I don't get it. No matter what I do, it gives me a blank page. ??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-751651 Share on other sites More sharing options...
HSKrustofsky Posted February 1, 2009 Author Share Posted February 1, 2009 Finally, I have found something that works... well, sort of. I have it to where it's allowing the IP address, but not the IP ranges. Is there a way of somehow doing the opposite of preg_match, or something? Here is the code I am working with... <?php $ip_list = array('123.456.789.10', '10.789.456.789'); $ip_range = array('10.123.456.*', '10.456.789.*'); $user_ip = $_SERVER['REMOTE_ADDR']; if(!in_array($user_ip, $ip_list)) { header("Location:http://".$_SERVER['HTTP_HOST']."/error.html"); } if(!empty($ip_range)) { foreach($ip_range as $range) { $range = str_replace('*','(.*)', $range); if(preg_match('/'.$range.'/', $user_ip)) { header("Location:http://".$_SERVER['HTTP_HOST']."/error.html"); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="keywords" content="Differential Equations, Dynamical Systems, Nonlinear Problems, Engineering, Sciences" /> <meta name="description" content="Journal, Mathematics, Nonlinear Studies" /> <title>ADVANCED NONLINEAR STUDIES - Vol.9 Num.1</title> <link rel="stylesheet" type="text/css" href="Styles/mainstyle.css" /> </head> <body> <div id="link"> <table width="800px" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="2"> </td> </tr> <tr> <td width="128" bgcolor="#015294"> <a href="journalcover.html"><img src="Images/ShairCover_small.jpg" /></a> </td> <td align="center" bgcolor="#015294"> <font color="#FFFFFF" size="+5">ADVANCED NONLINEAR<br />STUDIES</font><br /> <hr size="2" width="500px" color="#COCOCO" noshade="noshade" /> <font color="#FFFFFF">ISSN 1536-1365</font> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td style="font-family:Arial, Helvetica, sans-serif; color:#015294; border-bottom:solid 2px #015294; border-top:solid 2px #015294;" colspan="2" align="center"> <b> <ul id="nav"> <li style="border-right:solid 2px #015294;"><a href="index.html">Home</a></li> <li style="border-right:solid 2px #015294;"><a href="#">Abstracts</a> <ul> <li><a href="#">Vol. 9, Num. 1</a> <ul> <li><a href="Support/Abstracts/venegas.proofread.pdf">Abstract 1</a></li> <li><a href="Support/Abstracts/jleli2.proofread.pdf">Abstract 2</a></li> <li><a href="Support/Abstracts/Carl-Motreanu.proofread.pdf">Abstract 3</a></li> <li><a href="Support/Abstracts/Zhu.proofread.pdf">Abstract 4</a></li> <li><a href="Support/Abstracts/zanolin.proofread.pdf">Abstract 5</a></li> <li><a href="Support/Abstracts/ghimenti.proofread.pdf">Abstract 6</a></li> <li><a href="Support/Abstracts/Veron.proofread.pdf">Abstract 7</a></li> <li><a href="Support/Abstracts/Melian.proofread.pdf">Abstract 8</a></li> <li><a href="Support/Abstracts/cassani.proofread.pdf">Abstract 9</a></li> <li><a href="Support/Abstracts/Bene.proofread.pdf">Abstract 10</a></li> <li><a href="Support/Abstracts/draghici.proofread.pdf">Abstract 11</a></li> </ul> </li> </ul> </li> <li style="border-right:solid 2px #015294;"><a href="../editors.html">Journal Editors</a></li> <li style="border-right:solid 2px #015294;"><a href="#">Articles</a> <ul> <li><a href="#">Volume 9</a> <ul> <li><a href="v9n1.php">Number 1</a></li> </ul> </li> </ul> <li style="border-right:solid 2px #015294;"><a href="format.html">Format Instructions</a></li> <li><a href="subscribe.html">Order Form</a></li> </ul> </b> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" align="center" style="border-bottom:solid 2px #015294;"> <font size="5" face="Arial, Helvetica, sans-serif" color="#015294"> <b>Table of Contents</b> </font> </td> </tr> <tr> <td colspan="2"> <table width="100%" cellpadding="0" cellspacing="0" align="center" style="border-bottom:solid 2px #015294;"> <tr> <td width="266"> <font face="Arial, Helvetica, sans-serif" color="#015294"> <b>Volume 9</b> </font> </td> <td align="center" width="266"> <font face="Arial, Helvetica, sans-serif" color="#015294"> <b>Number 1</b> </font> </td> <td align="right" width="267"> <font face="Arial, Helvetica, sans-serif" color="#015294"> <b>February 2009</b> </font> </td> </tr> </table> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td align="center" colspan="2"> <font face="Arial, Helvetica, sans-serif" style="font-size:12pt">Click on the <img src="Images/pdficon_small.gif" /> icon to view the articles.</font> </td> </tr> <tr> <td colspan="2"> <font face="Arial, Helvetica, sans-serif" style="font-size:12pt"><p><i><a href="Support/Articles/V9N1_pg1-27.pdf"><img src="Images/pdficon_small.gif" /></a>The Porous Medium Equation With Blowing Up<br /> Boundary Data</i> ... 1<br /> <b>Osvaldo Venegas T.</b></p> <p><i><a href="Support/Articles/V9N1_pg29-68.pdf"><img src="Images/pdficon_small.gif" /></a>Moduli Space Theory of Constan Mean<br /> Curvature Hypersurfaces</i> ... 29<br /> <b>Mohamed JLELI</b></p> <p><i><a href="Support/Articles/V9N1_pg69-80.pdf"><img src="Images/pdficon_small.gif" /></a>Comparison Principle For Quaslinear Parabolic<br /> Inclusions with Clarke's Gradient</i> ... 69<br /> <b>Siegfied Carl, Dumitru Motreanu</b></p> <p><i><a href="Support/Articles/V9N1_pg81-94.pdf"><img src="Images/pdficon_small.gif" /></a>A Note on Asymptotically Linear Schrödinger<br /> Equation on R<sup>N</sup></i> ... 81<br /> <b>Hongbo Zhu</b></p> <p><i><a href="Support/Articles/V9N1_pg95-135.pdf"><img src="Images/pdficon_small.gif" /></a>Conected Branches of Initial Points for<br /> Asymptotic BVPs, With Application to<br /> Heteroclinic and Homoclinic Solutions</i> ... 95<br /> <b>Alessandro Margheri, Carlotta Rebelo, Fabio Zanolin</b></p> <p><i><a href="Support/Articles/V9N1_pg137-147.pdf"><img src="Images/pdficon_small.gif" /></a>Semiclassical Limit For the Nonlinear Klein<br /> Gordon Equation in Bounded Domains</i> ... 137<br /> <b>Marco G. Ghimenti, Carlo R. Grisanti</b></p> <p><i><a href="Support/Articles/V9N1_pg149-164.pdf"><img src="Images/pdficon_small.gif" /></a>On Uniqueness of Large Solutions of Nonlinear<br /> Parabolic Equations in Nonsmooth Domains</i> ... 149<br /> <b>Waad Al Sayed, Laurent Véron</b></p> <p><i><a href="Support/Articles/V9N1_pg165-176.pdf"><img src="Images/pdficon_small.gif" /></a>Quasilinear Equations with Boundary Blow-up<br /> and Exponential Reaction</i> ... 165<br /> <b>Jorge García-Melián</b></p> <p><i><a href="Support/Articles/V9N1_pg177-197.pdf"><img src="Images/pdficon_small.gif" /></a>On a Fourth Order Elliptic Problem<br /> with a Singular Nonlinearity</i> ... 177<br /> <b>Daniele Cassani, João Marcos do Ó, Nassif Ghoussoub</b></p> <p><i><a href="Support/Articles/V9N1_pg199-214.pdf"><img src="Images/pdficon_small.gif" /></a>Retarded Functional Differential Equations on<br /> Manifolds and Applications to Motion Problems<br /> for Forced Constrained Systems</i> ... 199<br /> <b>Pierluigi Benevieri, Alessandro Calamai, Massimo Furi, Maria Patrizia Pera</b></p> <p><i><a href="Support/Articles/V9N1_pg215-226.pdf"><img src="Images/pdficon_small.gif" /></a>Uniqueness and Characterization of the<br /> Maximizers of Integral Functionals With<br /> Constraints</i> ... 215<br /> <b>Cristina Draghici, Hichem Hajaiej</b></p></font> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td style="font-family:Arial, Helvetica, sans-serif; font-size:10pt; border-bottom:solid 2px #015294; border-top:solid 2px #015294;" colspan="2" align="center"> <b>Advanced Nonlinear Studies<br /> Managing Editor: Prof. Shair Ahmad<br /> Email: <a href="mailto:shair.ahmad@utsa.edu">shair.ahmad@utsa.edu</a></b> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </div> </body> </html> I know it's a bit annoying that I keep on posting this, but i am almost there, and would really like to get done with this. Thank you all one again for all your help. Quote Link to comment https://forums.phpfreaks.com/topic/143133-help-allow-access-by-ip-and-ip-range-help/#findComment-751727 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.