Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

PHP date question

Name: NWS 2007-06-18 2:40 ID:PlS1wRw+

Ok I can echo "Hello World!" but the problem is that after 30 minutes it should only echo "Hello you loser!"
How do I do this?

Name: Anonymous 2007-06-18 4:19 ID:pphrzG4n

sleep

Name: Anonymous 2007-06-18 5:46 ID:6ubeVVOx


<?php
if (isset($_COOKIE['time'])) {
      print (time() > ($_COOKIE['time'] + 30 * 60))
                    ? "Hello you loser!" : "Hello World!";
}
else {
    setcookie('time', time());
    print "Hello World!";
}
?>

Name: Anonymous 2007-06-19 1:04 ID:778Msdes

<?php

if( isset( $_COOKIE['time'] ) )
{
    if( time() < ( $_COOKIE['time'] + 30 * 60 ) )
    {
        echo 'Hello, World!';
    }else
    {
        echo 'Hello, you loser!';
        die;
    }
}else
{
    setcookie( 'time', time() );
    echo 'Hello, World!';
}

?>

<meta http-equiv="refresh" content="5;<?=$_SERVER['PHP_SELF'];?>" />

Name: Anonymous 2007-06-19 9:04 ID:RMveU3zV

<?php

for(x=1;x<30*6000;x++) {
echo '<script>alert("hello world")</script>
}

echo "hello, loser";


?>

Easier

Name: Anonymous 2007-06-19 13:29 ID:IyCbW2ST

>>3
>>4
>>5

FAIL. NEEDS MOAR ENTERPRISE

<?xml version='1.0' standalone='yes'?>
   <config>
      <param name="secondsInMinute" value="60"/>
      <param name="minutesUntilChange" value="30"/>
      <param name="string1" value="Hello World!"/>
      <param name="string2" value="Hello you loser!"/>
  </config>

<?php
$parameters = simplexml_load_file("config.xml");

if( isset( $_COOKIE['time'] ) ) {
    if( time() < ( $_COOKIE['time'] + $parameters['secondsInMinute'] * $parameters['minutesUntilChange'] ) ) {
        echo $parameters['string1'];
   }
   else {
        echo $parameters['string2'];
        die;
    }
}
else {
    setcookie( 'time', time() );
}

Name: Anonymous 2007-06-19 13:38 ID:RpSxbeGb

>>6
setcookie???  class CCookie or GTFO.

Name: Anonymous 2007-06-19 16:13 ID:/TFcm5h9

>>6
THAT'S NOT ENTERPRISE ENOUGH.

An EXPERT ENTERPRISE PROGRAMMER should be always ready to implement scalable dynamic solutions for mission-critical business applications.

<?php

  class Message {
    private $message;
    public function __construct($msg = '') {
      $this->message = $msg;
    }
    public function display() {
      echo $this->message;
    }
  }

  class MessageFatal extends Message {
    public function display() {
      parent::display();
      die;
    }
  }

  class MessageFactory {
    static public function produce($msg, $fatal = false) {
      return $fatal ? new MessageFatal($msg)
                    : new Message($msg);
    }
  }

  interface IGenericConfigurationProvider {
    public function getValue($name);
  }

  class XMLConfig implements IGenericConfigurationProvider {
    private $data;
    public function __construct($filename = 'config.xml') {
      $this->data = simplexml_load_file("config.xml");
    }
    public function getValue($name) {
      return $this->data[$name];
    }
  }

  $config = new XMLConfig(); // Todo: OracleDBConfig, of course.
  $messages = array (
    'fine' => MessageFactory::produce($config->getValue('string1'), false),
    'error' => MessageFactory::produce($config->getValue('string2'), true),
  );

  $what = 'fine';
  $messages = array (
    'fine' => MessageFactory::produce($config->getValue('string1'), false),
    'error' => MessageFactory::produce($config->getValue('string2'), true),
  );

  $what = 'fine'; // TODO: use constants.
  if (isset($_COOKIE['time'])) {
    if (time() < ($_COOKIE['time'] + $config->getValue('secondsInMinute') *
                                     $config->getValue('minutesUntilChange'))) {
      $what = 'error';
    }
  } else {
    setcookie('time', time());
  }
  $messages[$what]->display();

?>


But, of course, this should be rewritten in Java.

Name: Anonymous 2007-06-19 17:12 ID:kT1iRFb2

LOL at all the truth, you win gentlemen

Name: Anonymous 2007-06-20 6:25 ID:UoIfxtSX

>>5
>>8

I lol'd

Name: Anonymous 2007-06-20 7:59 ID:4T1yEFcc

>>8
EXPERT PROGRAMMER!

Name: Anonymous 2007-06-20 15:42 ID:EgG9rrK3

>>8
i didn't realize anyone on earth actually bothered to learn OO PHP...

Name: Anonymous 2007-06-20 17:29 ID:3l+9R43S

Honestly, I never looked at PHP that closely -- just enough to determine it was shit. Kind of akin to how you don't have to stare at the sun all day long to determine that it's really goddamn bright.

Name: Anonymous 2007-06-20 18:53 ID:H1w5fzn0

>>8
OO for PHP - weird.

Name: Anonymous 2009-01-14 15:20

gb2/g/

Name: Anonymous 2009-01-14 15:21

>>15
Baaawww!

Name: Anonymous 2009-03-06 7:06

r algebra There is   no reason why   this meme exists   LISP being the   son of a   picture I saw   the security industry   PEOPLE SHOULD BE   only four options   the final option.

Name: Anonymous 2010-12-09 16:28

Name: Anonymous 2011-01-31 20:15

<-- check em dubz

Don't change these.
Name: Email:
Entire Thread Thread List