How to stop the major error....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jclarkkent2003
Forum Contributor
Posts: 123
Joined: Sat Dec 04, 2004 9:14 pm

How to stop the major error....

Post by jclarkkent2003 »

Hi again,
I'm really busting my butt lately writing php scripts the past week, and keep getting problems.

Sometimes I run a script that takes hours and doesn't output anything at all, and just displays "Cannot display page" error.

I tried adding this:

set_time_limit(9999999999);
ignore_user_abort(1);

but that didn't work either.

Another part of the script has set_time_limit(0);//this may take awhile. so I am hoping that means unlimited and not time out zero seconds.

How can I prevent this script from timing out or breaking? It loops through doing LOTS and LOTS of permutations from a very large file.
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

Some code would help, maybe you have a never-ending loop somewhere.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

another point worth raising - is PHP the correct solution for your problem?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your time limit is an out of bounds integer, fyi. Use 0 instead.
jclarkkent2003
Forum Contributor
Posts: 123
Joined: Sat Dec 04, 2004 9:14 pm

Post by jclarkkent2003 »

php is correct, and i changed set_time_limit to 0.

I'm running this on windows xp pro sp2 with xampp, which lasts way longer than it does on my server.

Does anyone know of a php 2 c (or c++) converter? I get the feeling if I ran this in shell it would work alot better, cuz php always gives me these kinds of problems.

It's a script that will take list.txt and do permutations for each line in the list, and my list is at 1,000 lines, I want it to do permutations for all 1,000 lines and it breaks before it does anything.

What is a way to go about this? I want this as AUTOMATED as possible, so that means, I do NOT want to break the list.txt into 10 files of 100 each (cuz I really see no use for that). It's gotta take one single input list.txt and do permutations until the pc runs out of DISK space, lol........

I'd like to be able to increase the list.txt to 10,000 lines or 20,000 lines would be lovely.

Any ideas?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

When I asked is PHP the right solution for your problem, I was hinting that you might want to look into other possibilites such as C# or Perl.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

post your code, we may be able to recommend changes or a different language to write this in..
jclarkkent2003
Forum Contributor
Posts: 123
Joined: Sat Dec 04, 2004 9:14 pm

Post by jclarkkent2003 »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Here is the script, i modified it a little bit here and there, changed some words and names.

I believe I fixed the error about it timing out, or at least I pray I did. It's been running for two hours and still seems to be loading which is good, I just had to have it display something every 10 seconds or the browser would eventually time out.

Any ideas on how to easily convert this to C or Perl (perferably c)?

I can give a few snippets (edited variable names of course)

Code: Select all

class MYFUNCTION
{
	var $PROXY_LIST=false;
	var $CURRENT_PROXY=false;
	var $useProxies=false;
	var $proxyPath = 'proxies.txt';
	
	var $max_out = 100000;
	var $time_delay = 1;
	var $extra_bar=0;//0= no limit
	
	var $named_list=null;
	var $stopat=null;
		
	var $fileName ="whatisthefilename.txt";	
	var $fileMode ="w";
	
	var $numRequests=0;
	
	function GoForIt()
	{
		set_time_limit(0);//this may take awhile.
		$totalsize=9;
		$i=0;
		$d=0;
		while($i < $totalsize && $d <= $this->depth)
		{
    		if($this->useProxies)
    			$this->GetNextProxy();
        	$this->ANOTHERFUNCTIONHERE($this->named_list[$i]);
	        $totalsize = count($this->named_list);
	        if($max_out >= $this->extra_bar)
	        	break;
	        if($this->depth>0)
	        	$d++;
	        $i++;
	        
        	sleep($this->time_delay);
    	}
    	$this->SaveToFile();
	}
	
	/********************************************************************
	* Get the next anonymous proxy from the proxies.txt file
	* When the last proxy is reached it goes back to the first
	* proxies should be just the proxy ip and port and a new line
	*********************************************************************/
	function GetNextProxy()
	{
		// if the current_proxy is false, then load the proxy file
		if(!$this->CURRENT_PROXY)
		{
			$handle = fopen($this->proxyPath, "rb");
			if($handle == false)
			{
				echo "Please upload a proxy list. or untick the proxy list, moron!";
				exit;
			}
			elseif ($handle == true)
			{
				$this->PROXY_LIST = fread($handle, filesize('proxies/proxies.txt'));
				fclose($handle);
				$this->PROXY_LIST = explode("\n", $this->PROXY_LIST);
				$this->CURRENT_PROXY = current($this->PROXY_LIST);
	   		}
		}
		else
		{
			//get the next proxy from the array
			$this->CURRENT_PROXY = next($this->PROXY_LIST);
			//if used all proxies then get the first proxy
			if(!$this->CURRENT_PROXY)
				$this->CURRENT_PROXY = reset($this->PROXY_LIST);
		}
	}
	function  BLAHBLAHBLAH($result)
	{
		if(is_array($result))
		foreach($result as $value)
		{
			$value = strip_tags($value);
			$value = trim($value);
	        if (!in_array($value,$this->named_list))
	        {
	           	if($this->stopat!=null && $this->stopat($value))
		                $this->named_list[] = $value;
	           	else 
	           		$this->named_list[] = $value;
	        }
	    }
	}
ETC..... It goes on and on, it's not a short script. How could one easily convert it into perl or most preferably c / c++, lol, or even visual c++ (not going to right now but maybe in a few months/years) , the goal would be a c script i could compile and run in linux shell (i've done simple things before), or maybe even windows dos prompt.

Thanks in advance

EDIT: there are a few more php functions is uses, preg_match_all, strpos, return and break (not really php heh), $ch = curl_init(); $data = curl_exec($ch) fopen, fwrite, and fclose , so it uses some curl as well. I don't and never really cared for perl but if that's better for this , ok then, but I most prefer to translate into c to run on linux shell enviroment. thanks again so much`


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I think it'd help to understand what your script is supposed to do, both high-level concept and fairly detailed.. C has libraries available to do everything you have asked about, however there may be a solution already available or one that's nearly there...
Post Reply