Results 1 to 37 of 37

Thread: How long can a script run for?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135

    How long can a script run for?

    How long can a php script run for? even after the person who requested it closes the browser? and what do i have to include in my script to make the script stay up?

  2. #2
    New Member
    Join Date
    Aug 2002
    Posts
    3
    You cannot makes scripts run forever. Yes, the will stop when the browser is closed.

    There is also a 30 second timeout on loops.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    are you sure?

    i think if these functions are set properly you can .. im trying to figure this out right now..

    set_time_limit()
    ignore_user_abort()

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Why would you want to?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    it would be cool..

  6. #6
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    no it wouldn't. it'd kill resources and eat up bandwidth...

    and I'm sure there's a much more probably way to do whatever you want to do.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    Originally posted by sam0010
    it would be cool..
    then go outside and runn around the block, can you do it forever? no I don't think so. just like a script can't run for ever. if it does then you won't get an ouput and the users browser will crash. if this happends all the time the person owning the server will shut you down for hogging all the resources.

    also when the browser closes the script stops, how do you suppose the script can keep running if nothing is calling it?
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  8. #8
    Member
    Join Date
    Apr 2002
    Posts
    52
    i wonder if a script calls itself recursively? that may do away with the requirement of having the browser open.

    and i think this would be cool too... except i don't program anymore
    Would this do
    to make it allright?
    Once he has taken you
    from out of sight...

    I'll make my getaway...

    search for a better way
    to find my way home to your...
    Smile.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    well first of all.. a script will stay running after the user closes the browser or leaves if you use the function

    ignore_user_abort(true)

    i tested it

    by the way i never said i wanted a script to run forever.. dont assume cuz it will make an ass out of you and .....ummm.. YOU!

    Ok here is what i am trying to do.. i want to make a script for myself where i fill out a form and then the contents will be emailed to everyone in my database.. but the script times out before all the messages are emailed! So now im looking for a way to make the script run longer. any ideas?

  10. #10
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by sam0010
    well first of all.. a script will stay running after the user closes the browser or leaves if you use the function

    ignore_user_abort(true)

    i tested it

    by the way i never said i wanted a script to run forever.. dont assume cuz it will make an ass out of you and .....ummm.. YOU!

    Ok here is what i am trying to do.. i want to make a script for myself where i fill out a form and then the contents will be emailed to everyone in my database.. but the script times out before all the messages are emailed! So now im looking for a way to make the script run longer. any ideas?
    First, shut up. Second, how did you test it? I bet your test was flawed.

    and chord: you mentioned it keep calling itself? once the browser window closes, it'll stop.

    and about "ignore_user_abort()": again I say "why?"

    I see no logical reason to do this.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    I tested it by making the phpscript send data every 5 seconds to a vb program i made when ignore_user_abort() is used and i close the browser i keep reciving data.. tells you something doesnt it?

    And yes you CAN make a script run itself!

    And can you please tell my what the **** you cant understand that i dont want to have a browser window open while my script is sending emails?!

    stupid hobo!

  12. #12
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Calm down lads

    I assume you're using a loop in the mail part...why not just put multiple addresses in the To field?

    See Example 4 here

  13. #13
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by sam0010
    I tested it by making the phpscript send data every 5 seconds to a vb program i made when ignore_user_abort() is used and i close the browser i keep reciving data.. tells you something doesnt it?

    And yes you CAN make a script run itself!

    And can you please tell my what the **** you cant understand that i dont want to have a browser window open while my script is sending emails?!

    stupid hobo!
    I just wanted to see why you would want to do this because I didn't know...

    And when did I say you couldn't make it run itself?
    Last edited by The Hobo; Aug 9th, 2002 at 09:02 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  14. #14
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    And if you already knew the answer, why'd you ask the question?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  15. #15
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    I dont see why you asking your question. you have already answered it with:

    set_time_limit()
    ignore_user_abort()

  16. #16
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    Originally posted by sam0010
    I tested it by making the phpscript send data every 5 seconds to a vb program i made when ignore_user_abort() is used and i close the browser i keep reciving data.. tells you something doesnt it?

    And yes you CAN make a script run itself!

    And can you please tell my what the **** you cant understand that i dont want to have a browser window open while my script is sending emails?!

    stupid hobo!
    well that pretty much sums it up. you say you kept recieving info once the browser was closed becuase you had a VB program getting the info. if you close the browser then where is the info suppose to go, oh wait Cyberspace yeah that is it. I have you figured out.......give me a break.

    and php will not send mass emails as it is not programmed to do such a thing. it deosn't matter what you do and make (forever loops) it will always timeout, proven fact. if you want to mass email then use perl. look at all the emialing programs that send mass emails, 99% of them use perl to send the mail because it runs a lot cleaner.

    if there is nothing to instigate and manipulate the data you CANNOT run a script when the browser is closed, it shuts down the script. if you can run it from the server in a dos window then sure you could, but not from the browser.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  17. #17
    Addicted Member
    Join Date
    Mar 2002
    Posts
    229
    The Hobo: Why would you want to?
    Hobo, why would you care.

    The Hobo: it'd kill resources and eat up bandwidth...
    LOL, an internal script doesn't eat up bandwidth. Also, a script runing constantly wouldn't use up much more than any other script executed by a user. Unless it's some complex file input output, mail bombing, people killing script, it's not gonna use anywhere more than 0.5% cpu power runing constantly.

    Scoutt: also when the browser closes the script stops, how do you suppose the script can keep running if nothing is calling it?
    That's a false statement. ignore_user_abort(true) will allow the script to run and finish execution even if the user has closed the browser before the script is finished.

    The Hobo: Second, how did you test it? I bet your test was flawed. you mentioned it keep calling itself? once the browser window closes, it'll stop. and about "ignore_user_abort()": again I say "why?"
    I see no logical reason to do this.
    Having a script runing for a long time has its advantages. For example, a user inputs data into a form and submits the form, then exits his browser. The script will keep executing untill the job is finished. A script can keep calling itself using sockets. Then again, you prolly don't know that you can use sockets in PHP.

    The Hobo: And when did I say you couldn't make it run itself?
    Why'd you just contradict what you posted before? :S

    Scoutt: well that pretty much sums it up. you say you kept recieving info once the browser was closed becuase you had a VB program getting the info. if you close the browser then where is the info suppose to go, oh wait Cyberspace yeah that is it. I have you figured out.......give me a break.
    Wow...what's wrong with you. Are you high?

    I'm guessing that Sam0010 made a script using the ignore_user_abort(true) function to avoid the script from shutting down after the browser is closed. In this script, he used sockets to connect to a Visual Basic program that was listening for input. Then he used the sleep function inside a never ending loop to wait 5 seconds before sending the time the script has been runing. Am I correct? Well there's prolly more in the script than I mentioned but that's the basics of it, right?

    The thing is, every script will timeout after 30 seconds of execution. Though you could change this default setting using the set_time_limit() function. Unfortunately, all scripts will end after five minutes of execution. You're in luck though because what you can do is have the script call itself after 4 minutes and 50 seconds using sockets. The reason it's 4:50 and not 4:59 is to give it a margin just in case the transfer is slow. Don't worry about usage, if the script does not out put megabytes of data, it won't make much difference if it runs it self once every five minutes. PHP is multithreaded, therefor many scripts can run at the same time, so you do not have to worry about resources. If you think that it will use up alot of CPU power and Ram, It is like saying that this site can not handle more than one visitor at a time. LOL. As long as your script isn't used massively, then there is no worry about runing it infinately, but if it will be executed many times by many users, then I suggest rethinking your strategy.

    BTW, no offense to HOBO or SCOUTT, but you didn't seem to know what you're talking about contradicting what sam0010 has already prooved. No offense was meant when I quoted every thing you stated incorrectly. I might not be an expert at PHP and there are most likely a couple of errors in what I have just said, but it wasn't completely off as what the two of you have said.

  18. #18
    Member
    Join Date
    Apr 2002
    Posts
    52
    Originally posted by INF3RN0666

    Hobo, why would you care.


    LOL, an internal script doesn't eat up bandwidth. Also, a script runing constantly wouldn't use up much more than any other script executed by a user. Unless it's some complex file input output, mail bombing, people killing script, it's not gonna use anywhere more than 0.5% cpu power runing constantly.


    That's a false statement. ignore_user_abort(true) will allow the script to run and finish execution even if the user has closed the browser before the script is finished.


    Having a script runing for a long time has its advantages. For example, a user inputs data into a form and submits the form, then exits his browser. The script will keep executing untill the job is finished. A script can keep calling itself using sockets. Then again, you prolly don't know that you can use sockets in PHP.


    Why'd you just contradict what you posted before? :S


    Wow...what's wrong with you. Are you high?

    I'm guessing that Sam0010 made a script using the ignore_user_abort(true) function to avoid the script from shutting down after the browser is closed. In this script, he used sockets to connect to a Visual Basic program that was listening for input. Then he used the sleep function inside a never ending loop to wait 5 seconds before sending the time the script has been runing. Am I correct? Well there's prolly more in the script than I mentioned but that's the basics of it, right?

    The thing is, every script will timeout after 30 seconds of execution. Though you could change this default setting using the set_time_limit() function. Unfortunately, all scripts will end after five minutes of execution. You're in luck though because what you can do is have the script call itself after 4 minutes and 50 seconds using sockets. The reason it's 4:50 and not 4:59 is to give it a margin just in case the transfer is slow. Don't worry about usage, if the script does not out put megabytes of data, it won't make much difference if it runs it self once every five minutes. PHP is multithreaded, therefor many scripts can run at the same time, so you do not have to worry about resources. If you think that it will use up alot of CPU power and Ram, It is like saying that this site can not handle more than one visitor at a time. LOL. As long as your script isn't used massively, then there is no worry about runing it infinately, but if it will be executed many times by many users, then I suggest rethinking your strategy.

    BTW, no offense to HOBO or SCOUTT, but you didn't seem to know what you're talking about contradicting what sam0010 has already prooved. No offense was meant when I quoted every thing you stated incorrectly. I might not be an expert at PHP and there are most likely a couple of errors in what I have just said, but it wasn't completely off as what the two of you have said.


    You really took it upon yourself to settle this debate, didn't ya? lol
    Would this do
    to make it allright?
    Once he has taken you
    from out of sight...

    I'll make my getaway...

    search for a better way
    to find my way home to your...
    Smile.

  19. #19
    Addicted Member
    Join Date
    Mar 2002
    Posts
    229
    LOL ya, I didn't notice how much I did till I actually posted it.

    Then again, I find my post necessary because if you ask anyone, I think what HOBO and SCOUTT were being annoying. The guy wants to run the script forever, why should they care why. Ok you can try to warn him about bandwidth use and kills resources, but atleast know what you're talkin about when you do so.

    They're just contradicting him for the hell of it, and with WHAT? Incorrect info, that's what? Would you want that to happen to you? It happens to me all the time and then I end up in arguments with people who don't even know what they're talking about and are wasting my time. If I want to kill my server, you can warn me, but don't be rude and offensive about it. Then after you find out that u're wrong, you change your mind and contradict what you said two posts up and then pretend that you never posted that.

    If you ask me, that just bothers me. LOL. No hard feelings bud but you have to know where i'm coming from.

    ANYWAYS...PEACE OUT. Just had to add my 2000 cents.

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    THANK GOD FOR NOT STUPID PEOPLE!! INFERNO GOT IT PERFECT!


    lol.. its good to know some people know something about what their saying in this forum!

    Have a nice day

  21. #21
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    dude you suck, you don't know what you're talking about.

    pull your head out of your ass and listen. it is only common since that a program will crash the OS, no matter what it is.

    tell me, if a user post a form with his info in it and that particular user closed the info, WHERE IN THE HELL DID HIS INFO GO? oh that is right cyberspace. you are ****ing correct. I have never coded in php and never had a job doing it.

    you CANNOT RUN A FUNCTION FOREVER. I don't care what you say, you can't. the server won't let it. so tell me, if you ran a program on your OS and that program failed, does windows crash? well hell yes it does. it will say not responding. your OS will freeze and not work right. what the hell do you think the server will do? run a program while it is doing nothing is a TSR (Terminate Stay Resident) which means it will hog all the memory it can to do to execute itself. when you figure out that I'm right then you can appologize but untuil then I know what I'm talking about. I have had experience in this and I know what I'm talking about.


    and no we are not contradicting him for the hell of it. we know what we are talking about and that is that. you are talking like "ok hacker, take it to me as I know nothing" you are ****ing stupid. we tell him that as you can't do it. we don't contradict him, we just tell him that it can't be done.

    ok sure make a function that last forever, the user will crash and then that user will be pissed at you adn never visit you again. well that user has a mouth and will tell his friends and then you don't get any hits. heck you might even be considered a virus threat. ****, pay attention man, we have done this before.

    so they can run it forever, but once it hit sthe mark it will stop anyway.

    This is possible if you tell PHP to ignore user aborts. PHP will still note the fact that a user may have broken the connection, but the script will keep running. If it then hits the time limit it will be aborted and your shutdown function, if any, will be called.
    right from the manual
    Last edited by scoutt; Aug 10th, 2002 at 08:38 PM.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  22. #22
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    Originally posted by sam0010
    THANK GOD FOR NOT STUPID PEOPLE!! INFERNO GOT IT PERFECT!


    lol.. its good to know some people know something about what their saying in this forum!

    Have a nice day
    we'll remember that the next time you want help.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    Originally posted by scoutt
    dude you suck, you don't know what you're talking about.

    pull your head out of your ass and listen. it is only common since that a program will crash the OS, no matter what it is.

    tell me, if a user post a form with his info in it and that particular user closed the info, WHERE IN THE HELL DID HIS INFO GO? oh that is right cyberspace. you are ****ing correct. I have never coded in php and never had a job doing it.

    you CANNOT RUN A FUNCTION FOREVER. I don't care what you say, you can't. the server won't let it. so tell me, if you ran a program on your OS and that program failed, does windows crash? well hell yes it does. it will say not responding. your OS will freeze and not work right. what the hell do you think the server will do? run a program while it is doing nothing is a TSR (Terminate Stay Resident) which means it will hog all the memory it can to do to execute itself. when you figure out that I'm right then you can appologize but untuil then I know what I'm talking about. I have had experience in this and I know what I'm talking about.


    and no we are not contradicting him for the hell of it. we know what we are talking about and that is that. you are talking like "ok hacker, take it to me as I know nothing" you are ****ing stupid. we tell him that as you can't do it. we don't contradict him, we just tell him that it can't be done.

    ok sure make a function that last forever, the user will crash and then that user will be pissed at you adn never visit you again. well that user has a mouth and will tell his friends and then you don't get any hits. heck you might even be considered a virus threat. ****, pay attention man, we have done this before.

    so they can run it forever, but once it hit sthe mark it will stop anyway.


    right from the manual

    SOMEONE GET THIS GUY A TAMPON.. I THINK ITS THAT TIME OF THE MONTH...

  24. #24
    Addicted Member
    Join Date
    Mar 2002
    Posts
    229
    Ok you little stupid mother ****er *pardon my language*. i can easily prove to you that it's possible you retard. It uses very little resources 2 you reject. And it won't crash the system you idiot. A PHP script is like a C++ program with a few lines of code. It's like saying that a C++ program doesn't end, it doesn't necessarily crash the system or use up alot of resources for that matter. A C++ Program is a constant loop, and that's why it doesn't end. THe only way it ends is by ending the loop. If you implement the same thing in PHP, the same thing will occur. VERY LITTLE RESOURCE USAGE, and NO SYSTEM CRASH. Then again, why do I bother explaining this to a peanut brain. It can easily be done, and I've told sam to prove it to you, and then you're gonna bow down and suck his dick when he does do it. Alright? That's kool!

  25. #25
    Addicted Member
    Join Date
    Mar 2002
    Posts
    229
    LOL BTW..you can change the time limit, and if you read my big ass post, you'd notice that u can call the script from with in itself again and the countdown will start over. Therefore, it's never ending. But then again, you're stupid and you should stick to the english language since you can speak it so well. One day, coding will be pure english, then it'll be your specialty, but untill then, stay in the closet with all the other fags and don't come out till the world is ready to accept you. No offense to hpmpsexual people but u're an exception!

  26. #26
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    There are too many LOL's in this thread. Kindly stop it, or your accounts will be terminated.

    Good day.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  27. #27
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    Originally posted by INF3RN0666
    Ok you little stupid mother ****er *pardon my language*. i can easily prove to you that it's possible you retard. It uses very little resources 2 you reject. And it won't crash the system you idiot. A PHP script is like a C++ program with a few lines of code. It's like saying that a C++ program doesn't end, it doesn't necessarily crash the system or use up alot of resources for that matter. A C++ Program is a constant loop, and that's why it doesn't end. THe only way it ends is by ending the loop. If you implement the same thing in PHP, the same thing will occur. VERY LITTLE RESOURCE USAGE, and NO SYSTEM CRASH. Then again, why do I bother explaining this to a peanut brain. It can easily be done, and I've told sam to prove it to you, and then you're gonna bow down and suck his dick when he does do it. Alright? That's kool!
    I would just like to add abit, about the very little resources. PHP combined with Mysql and apache, can create quite a load of the system. For example, on my server, people with Vbulliten, usually get suspended because they are using to many processes. and Vbulliten is very well coded. This only happens when 30+ on are on at once.

    I can provide links. if you wish.

    edit: sleepy = bad speller

  28. #28
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294

  29. #29
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    There it is! I've been looking for that picture for a while.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  30. #30
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294
    please use it as much as you can, it fits about every situation on these forums.

  31. #31

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    OK this is where the arguing stops.. no more bad mouthing or put downs.. heres the code:

    <?
    $port = "3232" ;

    set_time_limit(300);
    ignore_user_abort(true);

    $socket_thing = fsockopen ("localhost",$port) or die ("Connection error!<br>");

    print("Connected<br>");
    flush();

    $i = 0;

    for ($i=0;$i!=5;$i++)
    {
    sleep(1) ;
    $sendthis = date ("D, F j, Y \r\nh:i:s A") ;
    fputs ($socket_thing, $i . " " . $sendthis ) ;
    echo($i . "<br>" . $sendthis . "<br><br>" ) ;
    flush();
    }

    fclose($socket_thing) or die("could not close socket<br>");

    $socket_thing = fsockopen ("localhost","80") or die ("Connection error!<br>");

    $httpheader="GET /ping.php HTTP/1.0\r\n\r\n";
    fputs ($socket_thing, $httpheader ) ;

    fclose($socket_thing) or die("could not close socket<br>");

    echo("<br><br>the end") ;


    ?>


    i know its not very good code.. i put it together in 5 mins

    heres what it does.. it connects to my computer (localhost) on port 3232 where i have a vb program listening its then goes through the loop sending the vb program the date and time .. the vb program outputs this "data" into a textbox.. when the loop is over (in this case its 5 seconds) it disconnects form my vbprogram(port 3232) and then connects to my webserver(port 80) where it sends a reqest for its self then basicly ends.. by this time the script has been called again. and it goes through the whole proccess again .. you can also forward variables through the get method just add ?var=val to the end of ping.php.. now you can increase the time between calling its self by increasing the condition for the forloop but dont go over 300 seconds(5 mins) cuz it will time out at 300 secs even if you increase the set_time_limit ...

    i have been reciving these "pings" from the server .. for about an hour now.. the script calls its self every 5 secs and reconnected to the vb program (3232) witch can be annoying but you can go around that..

    Now i am sure you can do alot with a never ending php script (if this is a never ending script)..

    now lets call it a day .. no more arguing!

  32. #32
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    Originally posted by INF3RN0666
    LOL BTW..you can change the time limit, and if you read my big ass post, you'd notice that u can call the script from with in itself again and the countdown will start over. Therefore, it's never ending. But then again, you're stupid and you should stick to the english language since you can speak it so well. One day, coding will be pure english, then it'll be your specialty, but untill then, stay in the closet with all the other fags and don't come out till the world is ready to accept you. No offense to hpmpsexual people but u're an exception!
    ok, for one I am like twice your age show shut the **** up. 2. do you understand what a TSR is? tell me what happens when a program sits there and eats all your memory? gee do you have to restart?

    I bet he can run a loop forever, not debating that, what I am debating is that you guys are the reason the world is fighting little **** ass's called hackers and crackers like you. you little punks need to be shot so the rest of the world can get on with their life. sure go ahead and run that little loop and you will find out how fast you get shut down. dude, scripts use resources if you like it or not. when a script is run forever it makes the server slow, hence the restart. a server that gets restarted a lot cost money.
    and you ****ed yourself when you said you are not an expert in php. just shut the **** up if you don't know.

    I am done with this stupid thread. run all the loops you want and shut down all the servers you want. when everybody shuts you down for being stupid, don't come running to me.

    but I must say this, you are a pro and that is why you have so many programs out there that you are also rich. man why aren't you in pictures, because if it was possible to run a scipt forever then the business's that make mass emailers would have figured it out a long time ago.
    Also, a script runing constantly wouldn't use up much more than any other script executed by a user. Unless it's some complex file input output, mail bombing, people killing script, it's not gonna use anywhere more than 0.5% cpu power runing constantly.
    yeah that is right. you don't understand TSR's do you.
    I might not be an expert at PHP and there are most likely a couple of errors in what I have just said
    hmm that sums it up right there. and I wouldn't talk about talking the english language as you have problems yourself.

    later I am out of here.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  33. #33
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    Originally posted by sam0010
    OK this is where the arguing stops.. no more bad mouthing or put downs.. heres the code:

    <?
    $port = "3232" ;

    set_time_limit(300);
    ignore_user_abort(true);

    $socket_thing = fsockopen ("localhost",$port) or die ("Connection error!<br>");

    print("Connected<br>");
    flush();

    $i = 0;

    for ($i=0;$i!=5;$i++)
    {
    sleep(1) ;
    $sendthis = date ("D, F j, Y \r\nh:i:s A") ;
    fputs ($socket_thing, $i . " " . $sendthis ) ;
    echo($i . "<br>" . $sendthis . "<br><br>" ) ;
    flush();
    }

    fclose($socket_thing) or die("could not close socket<br>");

    $socket_thing = fsockopen ("localhost","80") or die ("Connection error!<br>");

    $httpheader="GET /ping.php HTTP/1.0\r\n\r\n";
    fputs ($socket_thing, $httpheader ) ;

    fclose($socket_thing) or die("could not close socket<br>");

    echo("<br><br>the end") ;


    ?>


    i know its not very good code.. i put it together in 5 mins

    heres what it does.. it connects to my computer (localhost) on port 3232 where i have a vb program listening its then goes through the loop sending the vb program the date and time .. the vb program outputs this "data" into a textbox.. when the loop is over (in this case its 5 seconds) it disconnects form my vbprogram(port 3232) and then connects to my webserver(port 80) where it sends a reqest for its self then basicly ends.. by this time the script has been called again. and it goes through the whole proccess again .. you can also forward variables through the get method just add ?var=val to the end of ping.php.. now you can increase the time between calling its self by increasing the condition for the forloop but dont go over 300 seconds(5 mins) cuz it will time out at 300 secs even if you increase the set_time_limit ...

    i have been reciving these "pings" from the server .. for about an hour now.. the script calls its self every 5 secs and reconnected to the vb program (3232) witch can be annoying but you can go around that..

    Now i am sure you can do alot with a never ending php script (if this is a never ending script)..

    now lets call it a day .. no more arguing!
    and if I owned the server you connect to I would shut your ass down. that is called a bad script as it could and will execute bad code. if I owned that server I would also shut down most sockets so you couldn't connect.

    I see no reason in do anything that is listed. waste of code and talent.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  34. #34

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    psssst.. i think scoutt needs more tampax..

  35. #35

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135




    YOU WIN.. lol

  36. #36
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    My evil laugh has a squeak in it.

    kristopherwilson.com

  37. #37
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294


    The picture prevails once again!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width