Keeping it simple:
SeanPHP Code:while ( 1 == 1 ) {
echo "How long can I run for?";
}
![]()
| SitePoint Sponsor |
Keeping it simple:
SeanPHP Code:while ( 1 == 1 ) {
echo "How long can I run for?";
}
![]()
Harry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature




I'll make sure I only try that on Tripod about 20 billion times.![]()
![]()
They probably have PHP setup to timeout after a very short period
Sean![]()
Harry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
Why not just use
a little less coding, works the same thoughPHP Code:while (true) {}
![]()
- the lid is off the maple syrup again!
"True" you could do it that way, but I like 1 == 1!
Sean![]()
Harry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature

Hmmm...![]()
What's needed is 2 scripts like Shauns which also pretend to be browsers;
PHP Code:/* beavis.php */
function sendToHost($host,$method,$path,$data,$useragent=0) {
// Supply a default method of GET if the one passed was empty
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host,80, $errno, $errstr, 30);
if ( !$fp ) {
$buf = $errstr . " (" . $errno . ")<br>\n";
}
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
if ($useragent)
fputs($fp, "User-Agent: phpMyPal v1.0 [url]http://www.phpmypal.com\n[/url]");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;
}
while ( 1 == 1 ) {
sendToHost ( $_SERVER['SERVER_NAME'], "", $_SERVER, "", $_SERVER['DOCUMENT_ROOT'] . "butthead.php", "uhuhuh=uhuhuh" );
}
Enough already.PHP Code:/* butthead.php */
function sendToHost($host,$method,$path,$data,$useragent=0) {
// Supply a default method of GET if the one passed was empty
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host,80, $errno, $errstr, 30);
if ( !$fp ) {
$buf = $errstr . " (" . $errno . ")<br>\n";
}
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
if ($useragent)
fputs($fp, "User-Agent: phpMyPal v1.0 [url]http://www.phpmypal.com\n[/url]");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;
}
while ( 1 == 1 ) {
sendToHost ( $_SERVER['SERVER_NAME'], "", $_SERVER, "", $_SERVER['DOCUMENT_ROOT'] . "beavis.php", "huhuhu=huhuhu" );
}
Did you try that out before you posted?
Sean![]()
Harry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature

I'm not brave enough. Instead I posted it at Hotscripts under "Server Maintenance" to see what the feedback is.


He he hehehe...this is like opening a can of worms (never really got that expression)....
HarryF: I tried that locally last night and it crashed my apache (though it was running on windoze so i'm not surprised), my browser (microsoft again) and the machine basically just stopped responding.....not entirely sure what happened and/or why it did it...will try it on our internal development server here at work later today and see what happens on a linux box.
Guess you gotta burn your fingers before you learn ???
* Due to the last tax raise our prices has risen
* - answers w/o thought $1 - answers w/ thought $3
* - correct answers $10
* - Dumb stares are still free


Here is a little piece of uselessness...
(My first ever PHP script, I thought it was soooo hard back then... even though I made it by looking at Kevin's count-to-10 script, but writing in my stuff, so it's half not mine...)
PHP Code:<html>
<head>
<center>
<title> Counting to whatever you like</title>
</head>
<body>
<link rel="stylesheet" type="text/css" href="style.css" />
<?
if ($num >= 10001) {
die("I thought i told you not to do anything above 10000!");
} else {
if (!isset($num)): ?>
<form action="<?=$PHP_SELF?>" method="Post">
Count to (1 - 10000 only please): <input type="text" name="num"><br>
<input type="Submit" value="Submit">
</form>
<?
else:
$count = 1;
while ($count <= $num) {
echo( "$count " );
$count++;
}
$count--;
?> <br> <?
echo "Counted to $count successfully!";
endif;
}
?>
</center>
</body>
</html>


Hey,
don't knock that...it's a learning curve...might be the next step up from
but it still has it's place in history..he hehehePHP Code:<? echo "Hello World!"; ?>
not entirely sure why you made that script, except just learn loops better. I call that genuine "Uselessness"..![]()
* Due to the last tax raise our prices has risen
* - answers w/o thought $1 - answers w/ thought $3
* - correct answers $10
* - Dumb stares are still free


no ; needed on 1-line scripts...Originally posted by EvilDoppler
Hey,
don't knock that...it's a learning curve...might be the next step up from
but it still has it's place in history..he hehehePHP Code:<? echo "Hello World!"; ?>
not entirely sure why you made that script, except just learn loops better. I call that genuine "Uselessness"..![]()


geee...sorry...i guess i should consider quitting my job nowno ; needed on 1-line scripts...![]()
but thanks for letting me knowhe heehe
* Due to the last tax raise our prices has risen
* - answers w/o thought $1 - answers w/ thought $3
* - correct answers $10
* - Dumb stares are still free


na, it doesn't hurt to put a ;...


aaahhh phew...maybe i should keep the job then..
* Due to the last tax raise our prices has risen
* - answers w/o thought $1 - answers w/ thought $3
* - correct answers $10
* - Dumb stares are still free

MHWUAHAHAAHAHAmy browser (microsoft again) and the machine basically just stopped responding...
Just had another idea for the send to host function;
What makes PHP scripts safe is their execution time limit. But with that send to host function, you "envoke" another script exactly the same way as if you had viewed it with your webpage. So it basically keeps restarting the script.PHP Code:function sendToHost($host,$method,$path,$data,$useragent=0) {
// Supply a default method of GET if the one passed was empty
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host,80, $errno, $errstr, 30);
if ( !$fp ) {
$buf = $errstr . " (" . $errno . ")<br>\n";
}
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
if ($useragent)
fputs($fp, "User-Agent: phpMyPal v1.0 <a href="http://www.phpmypal.com\n" target="_blank">[url]http://www.phpmypal.com\n[/url]</a>");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;
}
echo ( "<p>" . sendToHost ( $_SERVER['SERVER_NAME'], "", $_SERVER, "", $_SERVER['PHP_SELF', "mirrormirror=whoisthefairest" ) );
$fairest = array (
"You are",
"Snow White is"
);
shuffle $fairest;
if ( $_GET['mirrormirror'] == "whoisthefairest" ) {
echo ( "<p>" . $fairest[0] . " the fairest of them all");
}
?>
You are evilwill try it on our internal development server here at work later today and see what happens on a linux box.Don't think it stands a chance. As they say: the bigger the processor, the faster it crashes.


okay!!!
the development server took just about half as long as my home machine before crashing...t'was ok i've now learned my lesson and will probably not attempt your modification in the near future.
he hehehehehe....we can only learn from our mistakes so what matters more than screwing things up now and again ?? he hehehehe
cheers and on with it!
* Due to the last tax raise our prices has risen
* - answers w/o thought $1 - answers w/ thought $3
* - correct answers $10
* - Dumb stares are still free


wasn't that just one brilliant excuse ?? heh ehehe
After it smacked my home machine to pieces i wasn't really putting any money on the dev. server standing a chance on it either. It wasn't the machine itself that crashed this time though, only apache and/or php. Not sure which, my sys admin wasn't too keen on my little experiement and wouldn't allow me to go near it again so i could play with the log file. darn it!!
* Due to the last tax raise our prices has risen
* - answers w/o thought $1 - answers w/ thought $3
* - correct answers $10
* - Dumb stares are still free


The thread is dropping out of the front page..been a hype of new threads posted overnight..can't have that..
* Due to the last tax raise our prices has risen
* - answers w/o thought $1 - answers w/ thought $3
* - correct answers $10
* - Dumb stares are still free
Originally posted by notepad_coder
Why not just use
a little less coding, works the same thoughPHP Code:while (true) {}
is much better. it makes it so much more cryptic. Of course it isn't always true:PHP Code:while (1 != 2) {}
http://www.ehumorcentral.com/Directory/Jokes/929.html
Or how about
OwenPHP Code:while (0.11111111111111111/0.11111111111111112 == 1) {}


Hola folks!!
Eventhough it's great to see soo many...uhmmm...fresh ideas coming in, we're actually not really seeing anything which could be used for something (other than the last 10 posts about running an "in-definite" loop)..
Can't we get some more of the scripts which actually has a use somewhere (other than attempting to time-out the server) ?
Cheers folks - sorry to sound like an old man!![]()
* Due to the last tax raise our prices has risen
* - answers w/o thought $1 - answers w/ thought $3
* - correct answers $10
* - Dumb stares are still free
Heres a little script I made when I first started PHP, I thought it was so cool. After about a week of using it I decided it was pretty dumb and havn't used it since.
Just a simple math thing.PHP Code:<?
if ($_POST) {
$n1 = $_POST['numb1'];
$n2 = $_POST['numb2'];
$a = $n1 + $n1;
echo $a. "<br>";
$a = $n1 - $n2;
echo $a. "<br>";
$a = $n1 * $n2;
echo $a. "<br>";
$a = $n1 / $n2;
echo $a;
} else {
?>
<form action="<? echo $PHP_SELF; ?>" method="post">
<input type="text" name="numb1"> + - * / <input type="text" name="numb2"><br><br>
<input type="submit" value="Do The Math">
</form>
<?
}
?>
- the lid is off the maple syrup again!


He ehehehe...
well it's not bad for a first script...I had to tackle a forum/messageboard which at that time was "really" complicated for a youngun....
don't even think i'd ever do another though...too boring...
* Due to the last tax raise our prices has risen
* - answers w/o thought $1 - answers w/ thought $3
* - correct answers $10
* - Dumb stares are still free
Hehe. I am very bored so I just did a page that I will probably never use again and I thought I should post it here. It's a calculator that uses JavaScript and PHP. I must say it is pretty good, for me doing it it is
You can test it out here http://www.nathantech.com/calc.html
That could probably be used for something good but for now it is useless to me.PHP Code:<html>
<head>
<script language="JavaScript">
<!--
function addNum(num) {
if (document.calc.way.value == "") {
document.calc.num1.value += num;
document.calc.num1.focus();
} else {
document.calc.num2.value += num;
document.calc.num2.focus();
}
}
function c(w) {
document.calc.way.value = " " + w;
}
-->
</script>
</head>
<body>
<form name="calc" action="calc.html" method="post">
<table cellpadding=0 cellspacing=0>
<tr>
<td colspan=2><input type="text" name="num1" style="width:50px" readonly></td>
<td><input type="text" name="way" style="width:25px"></td>
<td colspan=2><input type="text" name="num2" style="width:50px"></td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr>
<td><input type="button" value=" 1 " style="width:25px;height:25px;" onClick="addNum(1)"></td>
<td><input type="button" value=" 2 " style="width:25px;height:25px;" onClick="addNum(2)"></td>
<td><input type="button" value=" 3 " style="width:25px;height:25px;" onClick="addNum(3)"></td>
<td rowspan=2><input type="button" value=" + " style="width:25px;height:50px;" onClick="c('+')"></td>
<td rowspan=2><input type="button" value=" * " style="width:25px;height:50px;" onClick="c('*')"></td>
</tr>
<tr>
<td><input type="button" value=" 4 " style="width:25px;height:25px;" onClick="addNum(4)"></td>
<td><input type="button" value=" 5 " style="width:25px;height:25px;" onClick="addNum(5)"></td>
<td><input type="button" value=" 6 " style="width:25px;height:25px;" onClick="addNum(6)"></td>
</tr>
<tr>
<td><input type="button" value=" 7 " style="width:25px;height:25px;" onClick="addNum(7)"></td>
<td><input type="button" value=" 8 " style="width:25px;height:25px;" onClick="addNum(8)"></td>
<td><input type="button" value=" 9 " style="width:25px;height:25px;" onClick="addNum(9)"></td>
<td rowspan=2><input type="button" value=" - " style="width:25px;height:50px;" onClick="c('-')"></td>
<td rowspan=2><input type="button" value=" / " style="width:25px;height:50px;" onClick="c('/')"></td>
</tr>
<tr>
<td colspan=2><input type="button" value=" 0 " style="width:50px;height:25px;" onClick="addNum(0)"></td>
<td><input type="button" value=" . " style="width:25px;height:25px;" onClick="addNum('.')"></td>
</tr>
<tr>
<td colspan=5><input type="submit" value=" Calculate " style="width:125px;height:25px;"></td>
</tr>
<?
if ($_POST) {
echo str_repeat("<tr></tr>", 6);
echo "<tr><td colspan=5 align=\"center\">";
if (trim($_POST['way']) == "+") {
echo $_POST['num1'] + $_POST['num2'];
} elseif (trim($_POST['way']) == "-") {
echo $_POST['num1'] - $_POST['num2'];
} elseif (trim($_POST['way']) == "*") {
echo $_POST['num1'] * $_POST['num2'];
} elseif (trim($_POST['way']) == "/") {
echo $_POST['num1'] / $_POST['num2'];
}
echo "</td></tr>";
}
?>
</table>
</form>
</body>
</html>
Last edited by notepad_coder; Jun 20, 2002 at 20:31.


HEY FOLKS!!
it seems like we're back in business again. neato..
and note, nice script...i'll try to do something useless again soon...can't have you be the only one submitting useless stuff...
cheers n' ears
* Due to the last tax raise our prices has risen
* - answers w/o thought $1 - answers w/ thought $3
* - correct answers $10
* - Dumb stares are still free
Bookmarks