• Prime Mover (unregistered)

    'im frist!'

  • 516052 (unregistered) in reply to Prime Mover

    1 != 4

    Comment rejected.

  • (nodebb)

    The real wtf is still php

  • Álvaro González (github) in reply to DocMonster

    Absolutely! This same algorithm written in Python would have been flawless.

  • (nodebb)

    Oh my God, how did I not think of this approach before. For example, if you need to perform a certain action N times, the solution would be to get a random number K between N-X and N+X and repeat the action K times. Over the life of the software, it'll average out to N!!

  • Anonymous') OR 1=1; DROP TABLE wtf; -- (unregistered)

    Maybe this developer also used the rand() implementation from https://xkcd.com/221/ , in which case this script will exit every time.

  • NoLand (unregistered)

    I guess we may even solve the P-NP problem by lavishly sprinkling extits all over the code – at least, statistically.

  • (nodebb) in reply to Anonymous') OR 1=1; DROP TABLE wtf; --

    Or perhaps the programmer started their career in Dilbert's accounting department https://dilbert.com/strip/2001-10-25

  • (nodebb) in reply to Álvaro González

    Anything written in Python would be flawless

    Kek

  • ooOOooGa (unregistered)

    I'm almost afraid to ask what the purpose of setting a value in $_GET is meant to do.

  • (nodebb) in reply to DocMonster

    Are we still allowed to say Kek with the Activision Blizzard scandal happening?

  • (nodebb) in reply to Anonymous') OR 1=1; DROP TABLE wtf; --

    https://www.php.net/manual/en/function.srand.php#117966

    If your webserver is using a forked model (e.g. Apache pre-fork model with mod_php), and the random number generator was already seeded, you do get the same random number out of all of them.

    rand() in PHP is just as bad as you can imagine.

  • ZZartin (unregistered)

    I don't see how using git would have made the situation any better.

  • witchdoctor (unregistered) in reply to ZZartin

    I don't see how using git would have made the situation any better.

    You'd get a helpful commit message like "fixed it" with the person who is to blame and a date and time attached. So, minimally better. You could then search the email archive or the bugtracker by date (though I'm betting email only in this case) for the problem description and kind of archeologically work backwards to find out what's going on.

  • Álvaro González (github) in reply to ooOOooGa

    I'm almost afraid to ask what the purpose of setting a value in $_GET is meant to do.

    The only possible way to run a local script using cron is to invoke it through a web server with wget, everybody knows that.

  • tbo (unregistered) in reply to Ext3h

    Are you telling me that seeding the random number generator seeds the random number generator?

  • Random Task Scheduling (unregistered)

    I kind of like it; it has some interesting use-cases. It could be used in a situation where an inspection or action needs to happen regularly, but what's being inspected or acted upon adapts to a pattern of inspection/action. To do the inspection all the time is too costly, but to do it randomly tends to enforce compliance in the meantime.

  • (nodebb)

    Code comments are why you are doing something.

  • Sole Purpose Of Visit (unregistered) in reply to Álvaro González

    And here we enter the realm of Bayesian Priors.

    Knowing nothing about the quality of PHP as a language, and knowing nothing about the quality of PHP programmers, and knowing nothing about the community of programmers whose chosen language is PHP, or perhaps programmers who have learned PHP as their first language and (presumably with a laugh and a song) happily transferred to, say BrainF*ck, we can definitely assert that it is equally likely that any given programmer is likely to write this self-same garbage either in PHP or in Python or in (language of choice).

    Unfortunately, the priors are that (a) this nitwit is a PHP programmer (b) this nitwit is statistically certain to have learned programming via PHP and (c) this nitwit is programming PHP in a way that his employer find eminently cromulent, given the choice of PHP programmers out there.

    Given the priors, I would hypothesise that PHP (the language) is indeed a very, very, large part of the problem.

  • Edd (unregistered)

    So it's run on request or on a cron?

  • (nodebb) in reply to NoLand

    Sounds more like a solution to the halting problem.

  • I'm not a robot (unregistered) in reply to Ext3h

    I hate to defend PHP, but...

    That comment isn't talking about a web server that forks, it's talking about manually forking within the script using pcntl_fork - in which case it's entirely expected that the RNG state, along with everything else, would be copied to the child. I don't know why they claim it isn't possible to manually reseed in the child - perhaps there was a bug at the time the comment was written that would cause that, or maybe they just screwed up, but it worked fine when I tested it.

  • rk (unregistered) in reply to Álvaro González

    Not true. But maybe you are being sarcastic.

Leave a comment on “A Graceful Exit”

Log In or post as a guest

Replying to comment #531474:

« Return to Article