Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2005-12-13, 09:21 PM
Junior Member
 
Join Date: Oct 2005
Posts: 10
akazukin
Default

Code:
	$filename = 'r_login_info.txt';
	$handle = fopen($filename, "r");
	$contents = fread($handle, filesize($filename));
	fclose($handle);
	$login_info = explode(",", $contents);

	$port = 23;
	if ($_POST['ip1'] != '')
	{
 $fp = fsockopen ($login_info[0], $port, $errno, $errstr);

 if (!$fp)
 {
 	$results = "Error: could not open socket connection";
 }
 else
 {
 	fputs ($fp, $login_info[2]."\n"); //Password 1
 	fputs ($fp, "en\n");  	//enable
 	fputs ($fp, $login_info[3]."\n"); //Password 2
 	fputs ($fp, "config t\n");  //Config t command

 	fgets ($fp, 1024);   //ÿûÿûÿýÿý
 	$moredetails .= fgets ($fp, 1024); //Blank
 	$moredetails .= fgets ($fp, 1024); //User System Verification
 	$moredetails .= fgets ($fp, 1024); //Blank
 	$moredetails .= fgets ($fp, 1024); //Password 1
 	$moredetails .= fgets ($fp, 1024); //enable
 	$moredetails .= fgets ($fp, 1024); //Password 2
 	$moredetails .= fgets ($fp, 1024); //Config. t command
 	fgets ($fp, 1024);   //Enter conf one by one
 	if($_POST['ip1'] != "" && $_POST['ip2'] != "" && $_POST['ip3'] != "" && $_POST['ip4'] != "")
 	{
  $login_info[0] = $_POST['ip1'].".".$_POST['ip2'].".".$_POST['ip3'].".".$_POST['ip4'];
  fputs ($fp, "ip address ".$_POST['ip1'].".".$_POST['ip2'].".".$_POST['ip3'].".".$_POST['ip4']." ".$_POST['smask1'].".".$_POST['smask2'].".".$_POST['smask3'].".".$_POST['smask4']."\n");
  $moredetails .= fgets ($fp, 1024);
 	}
//-------------------------------------------------------------------------

 	//fputs ($fp, "end\n");

 	$moredetails .= fgets ($fp, 1024); //this is line 113: Exit from config-if & config
//-------------------------------------------------------------------------


 	$moredetails .= "\n------------------------------------\n\n"; //line
 }
 fclose ($fp);
 $filename = 'r_login_info.txt';
 $content = $login_info[0].",".$login_info[1].",".$login_info[2].",".$login_info[3].",".$login_info[4];

 if (is_writable($filename))
 {
 	/*
 	In our example we are opening $filename in append mode. The file pointer
 	is at the bottom of the file hence that is where $somecontent will go when
 	we fwrite() it.
 	*/
 	if (!$handle = fopen($filename, 'w'))
 	{
   echo "Cannot open file ($filename)";
   exit;
 	}
 	// Write $somecontent to our opened file.
 	if (!fwrite($handle, $content))
 	{
  echo "Cannot write to file ($filename)";
  exit;
 	}
 	fclose($handle);
 }
	}
	$fp = fsockopen ($login_info[0], $port, $errno, $errstr);

	if (!$fp)
	{
 $results = "Error: could not open socket connection";
	}
	else
	{
........................
..........................
	}
	fclose($fp);
Those within "//------------------" is the problem i encountered.

When i commented those 2 lines, the script will be able to change the ip address in the txt file which the ip address is always used for "fsockopen($host...)" . However when I added them into the code. it will prompted me "Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Group\Apache2\htdocs\MultiVendor_2\r_interface.php on line 113".
tat line is added just to exit from the config mode n it will b display on the page to allow user to view how the config is done.

Anyone can help?
Reply With Quote
  #2 (permalink)  
Old 2005-12-13, 09:46 PM
Senior Member
 
Join Date: Dec 2004
Posts: 199
strasm is an unknown quantity at this point
Default

It is hard to tell because your error is saying line 113 of r_interface.php, but this code does not go that high. Either it is another file or you have cut your code short to show us. Usually when the line that you are looking at looks fine check the lines above it. Make sure everything is terminated correctly watch your concatenation.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:53 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.