A Digital Age Deserves A Digital Leader

Code request Thread

Re: Code request Thread

Postby c0ldfyr3 » Tue Oct 06, 2009 12:40 pm

well hopefully i can get some help on this new little project...

heres the break down:
    1:grab users IP address
    2:connect to the dB for verification
    3:test if the user knows an IP in the allowed dB
    4:verify the IP they supplied is their IP, Since the Allowed IP's are static only check the node# or 4th set of digits
    5:function to wirte the users IP to file if they are not in the Allowed dB
    6:checking if the user is in the Allowed dB if not send it to functio ban()
    7:if the user is in the Allowed dB
    8:process the for said page
here is the said code:
Code: Select all
session_start()
//grab users IP address
$myIP = $_SERVER['REMOTE_ADDR'];
//connect to the dB for verifacation
@mysql_connect("$host", "$user", "$password")or die ('Error connecting to mysql');
@mysql_select_db("myAllowedIPnodes");
//test if the user knows an IP in the allowed dB
echo "whats your IP?<form method='post'><input type='text' size='12' name='iVerifiedIP' /> </form>";
$iPHostNumb = $_POST['iVerifiedIP'];
$iCheckIP = mysql_query("SELECT * FROM provoca1_myAllowedIPnodes.iIP WHERE Allowed LIKE '$myIP' LIMIT 0, 1");
$ipAllowed = mysql_numrows($iCheckIP);
//verify the IP they supplied is their IP, Since the Allowed IP's are static only check the node# or 4th set of digits
$iVerifyIP4thSec = explode(".", $iCheckIP);
$iVerifyIP4thSec = $iVerifyIP4thSec[3];
//function to wirte the users IP to file if they are not in the Allowed dB
Function ban()
{
$file = fopen(IPs.txt,"w");
echo fwrite($file,"$myIP\n");
fclose($file);
}
//checking if the user is in the Allowed dB if not send it to functio ban()
   if($iPHostNumb != $iCheckIP)
   {
   ban("$myIP");
   }
//if the user is in the Allowed dB
ELSE if($iPHostNumb == (base64_decode($_SERVER['REMOTE_ADDR']))

{
  @require("Includes/Content/Header.php");
  @require("Includes/Content/$iPage.php");
  @require("Includes/Content/Footer.php");

}



my issue is when its checking the database its returning 1 for every one that connects where as i want only the users IP's that are in the database to be allowed to connect, there fore if said user A connects and is not in the Allowed dB they should return 0, not 1.

however i am also wanting to test if the user knowns an IP in the allowed dB, if so return 1; and if not return 0.

originally i have the server check against a base64 encoded IP address with an encoded variable it looked like so:
Code: Select all
if(base64_decode($_SERVER['REMOTE_ADDR']) == "NzYuNzkuMjI5LiRpUEhvc3ROdW1i")


however i am unsure if encoding and decoding it will cause room for error as its an allowed server IP with the nodes as a variable as such
Code: Select all
if(base64_decode($_SERVER['REMOTE_ADDR']) == "192.168.0.$iPHostNumb")
Image
PRO Level 15
User avatar
Posts: 1346
Joined: Sun May 02, 2004 8:49 pm
Location: 127.0.0.1

Re: Code request Thread

Postby NT50 » Tue Oct 06, 2009 7:24 pm

fireraisr wrote:Hello, I'm new here. I think this is the right place for my problem. I have a batch file that I wrote for my company that copies sales reports from a directory, zips and emails them to a gmail account. This works great for customer accounts that are less than 4 years old but for those that are over that the zip file becomes too large to mail. I can split up the zip through the batch process but I still need the files automatically emailed.

I want to write the directory that the zip's are in to a text file and then use that file to retrieve the path info and then input it into the target of the email script. I know how to output to a text file but can't figure out how to retrieve the data line by line and execute the script for each line.

Any help is would be much appreciated.

Thanks in advance.



Have you tried Cobian Backup it is free..........
Dogs Have Owners; Cats Have Staff
PROfessional Member
User avatar
Posts: 8220
Joined: Sat Jun 19, 2004 4:46 pm
Location: Jackson, TN USA
Real Name: Jeff Replogle

Re: Code request Thread

Postby Thomas52 » Tue Jul 13, 2010 8:22 am

I set up a page for my wife's "Barn Camera" at http://www.adkins9.net/barn and it worked GREAT (for about 5 minutes, ) but since then, all I get is the "missing image" icon on the page. Can anyone get me a clue to what I am doing wrong, or better yet, how to do it right? Many thanks for any input.

Code: Select all
<HTML> 
<HEAD>
<TITLE>Barn Cam</TITLE>
<meta name="description" content="Pilgrim &amp; Lakota" />
<meta name="keywords"
content="barn cam" />
 
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
     var refresh = 5;
    var seconds = refresh;
      function webcamRefresh()
    {
      document.form.counter.value = --seconds;
      if (seconds <= 0)
      {
         var now = new Date();
         var imageURL = "http://173.20.56.33/cgi/jpg/image.cgi" + "?" + now.getTime();
         document.webcam.src = imageURL;
         seconds = refresh;
      }
      refreshTimer = setTimeout("webcamRefresh()", 1000);
    }
 
// -->
</SCRIPT>
</HEAD>
<IMG NAME="webcam" SRC="http://173.20.56.33/cgi/jpg/image.cgi" border=1 width=600 height=450>
-->
</style>
</HTML>
"He either fears his fate too much, Or his desserts are small, Who dares not put it to the touch, To win or lose it all!" - James Graham, 5th Earl of Montrose (1612 to 1650)
PROfessional Member
User avatar
Posts: 136
Joined: Sat Dec 14, 2002 5:03 am
Location: The foothills of the beautiful Blue Ridge Mountains of Western North Carolina
Real Name: Thomas Adkins

Re: Code request Thread

Postby NT50 » Tue Jul 13, 2010 12:27 pm

It says it is doenloading the image but never does. Hopefully John or somebody here will see this and help you. (I'm not a web programmer, just wanted to let you know that it has been seen)
Dogs Have Owners; Cats Have Staff
PROfessional Member
User avatar
Posts: 8220
Joined: Sat Jun 19, 2004 4:46 pm
Location: Jackson, TN USA
Real Name: Jeff Replogle

Re: Code request Thread

Postby Thomas52 » Tue Jul 13, 2010 8:00 pm

Thank you, NT50.
I did forget to mention, I have another (proprietory) page set up for the same image at http://www.adkins9.net/go2/barn - you may need the username/password user/user. But I would like to figure out what I'm doing wrong on my "new" page.
All ideas & suggestions appreciated.
"He either fears his fate too much, Or his desserts are small, Who dares not put it to the touch, To win or lose it all!" - James Graham, 5th Earl of Montrose (1612 to 1650)
PROfessional Member
User avatar
Posts: 136
Joined: Sat Dec 14, 2002 5:03 am
Location: The foothills of the beautiful Blue Ridge Mountains of Western North Carolina
Real Name: Thomas Adkins

Re: Code request Thread

Postby NT50 » Tue Jul 13, 2010 9:32 pm

I sent John a PM, he is the coder of this site.
Dogs Have Owners; Cats Have Staff
PROfessional Member
User avatar
Posts: 8220
Joined: Sat Jun 19, 2004 4:46 pm
Location: Jackson, TN USA
Real Name: Jeff Replogle

Re: Code request Thread

Postby kanaloa » Tue Jul 13, 2010 10:04 pm

The problem must be with the javascript. Unfortunately I'm not fluent in JS or CGI so I can't offer much help as to how to get it working. But I get the same error in all browsers I tried. Where did you get the code from you're using?
"Greatness is not a function of circumstance. Greatness, it turns out, is largely a matter of conscious choice, and discipline." - Jim Collins
President
User avatar
Posts: 11795
Joined: Sun Mar 10, 2002 1:18 am
Location: Columbia, SC
Real Name: John Derrick

Re: Code request Thread

Postby Thomas52 » Wed Jul 14, 2010 2:39 am

"He either fears his fate too much, Or his desserts are small, Who dares not put it to the touch, To win or lose it all!" - James Graham, 5th Earl of Montrose (1612 to 1650)
PROfessional Member
User avatar
Posts: 136
Joined: Sat Dec 14, 2002 5:03 am
Location: The foothills of the beautiful Blue Ridge Mountains of Western North Carolina
Real Name: Thomas Adkins

Previous

Return to HTML, CSS, and Scripts

Who is online

Users browsing this forum: No registered users and 1 guest