Unstoppable Domains

How to improve this?

Spaceship Spaceship
Watch

newsiness

VIP Member
Impact
49
I have a script to pull particular content from a webpage to display on your site.
http://newsiness.com/testing/script.txt

The hosting provider always complaint that the script consume a lot of cpu resource when a lot of visitors executing this script. What's wrong with the script and how to improve this?

Thanks
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
0
•••
Untested,
PHP:
<?php

$theLocation = '';
$startingpoint = ''; 
$endingpoint = '';

$theDomain = @parse_url($theLocation);
$theDomain = "http://$theDomain[host]";

if (extension_loaded('curl'))
{
	$ch = curl_init($theLocation);

	if (!$ch)
	{
		die('The specified server is currently unable to handle the request due to a temporary overloading.');
	}

	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
	$value = curl_exec($ch);
	curl_close();
}
else
{
	$value = file_get_contents($theLocation);
}

$start = strpos($value, $startingpoint);
$finish = strpos($value, $endingpoint);
$length = $finish - $start;
$value = substr($value, $start, $length);

$FinalOutput = preg_replace("/(href=\"?)(\/[^\"\/]+)/", '\\1' . $theDomain . '\\2', $value);

if (strlen($FinalOutput) == 0)
{
	echo 'The specified server is currently unable to handle the request due to a temporary overloading.';
}
else
{	
	echo $FinalOutput;
	ob_flush();
	flush();
}

?>
 
0
•••
Thanks DomainManDave for the note.

Eric, the script is working fine. Thanks a lot! :)

Hopefully, no more cpu usage issue from them.
 
0
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back