CMD: Completely Malicious Data

by Mark Bowytz in Error'd on 2014-10-30

What? Friday already!? Not quite, but close! We have something really good coming up tomorrow for Halloween, so here's your weekly dose of Error'd a day early. Enjoy!

--------

36 Comments - Last Comment @ 2014-10-31

Advanced Time Management

by Mark Bowytz in Representative Line on 2014-10-28

Whenever a computer wants to sync its internal clock, usually right around reboot, it'll check in with a time server. This is built-in functionality that spans across every modern OS.

Now, in some cases you might have a reason to disable the time check - and that's fine.

31 Comments - Last Comment @ 12:04

Undefined Favorites

by Mark Bowytz in Error'd on 2014-10-24

"It's great I can ship my favorites to Europe, I just wish I knew what they were," writes Nick.

84 Comments - Last Comment @ 2014-10-29

The Beginning of the Zend

by Remy Porter in CodeSOD on 2014-10-23

Karol found a program that needs to look at a timestamp, and determine if that timestamp is before or after an expiration date. The code that was handling this looked like this:

public function _isSmsCodeExpired($id)
    {

        $genDateStr = $this->db()->query('SELECT date FROM table')->fetchColumn();

        if (empty($genDateStr))
        {
            return true;
        }
        
        $expireDateArr = array();
        $intervalSec = 120;

        $genDataTmp = explode(' ', $genDateStr);
        $genDataArr = explode('-', $genDataTmp[0]);

        $expireDateArr['year'] = $genDataArr[0];
        $expireDateArr['month'] = $genDataArr[1];
        $expireDateArr['day'] = $genDataArr[2];

        $genDataArr = explode(':', $genDataTmp[1]);

        $expireDateArr['hour'] = $genDataArr[0];
        $expireDateArr['minute'] = $genDataArr[1];
        $expireDateArr['second'] = substr($genDataArr[2], 0, 2);

        $intervalMin = (int) $intervalSec / 60;
        $intervalSec = (int) $intervalSec - ( $intervalMin * 60 );

        $expireDateArr['second'] += $intervalSec;
        $expireDateArr['minute'] += $intervalMin;

        $expireDateArr['second'] += $intervalSec;
        if ($expireDateArr['second'] > 60)
        {
            $expireDateArr['minute'] += 1;
            $expireDateArr['second'] = $expireDateArr['second'] - 60;
        }

        if ($expireDateArr['minute'] > 60)
        {
            $expireDateArr['hour'] += 1;
            $expireDateArr['minute'] = $expireDateArr['minute'] - 60;
        }

        if ($expireDateArr['hour'] > 24)
        {
            $expireDateArr['day'] += 1;
            $expireDateArr['hour'] = $expireDateArr['hour'] - 24;
        }

        $daysInMonth = date("t", strtotime($expireDateArr['year'] . "-" . $expireDateArr['month'] . "-01"));

        if ($expireDateArr['day'] > $daysInMonth)
        {
            $expireDateArr['month'] += 1;
            $expireDateArr['day'] = $expireDateArr['day'] - $daysInMonth;
        }

        if ($expireDateArr['month'] > 12)
        {
            $expireDateArr['year'] += 1;
        }


        $expireDate = new Zend_Date($expireDateArr);
        $now = new Zend_Date();

        if ($now->isEarlier($expireDate))
            return false;
        else
            return true;
    }

80 Comments - Last Comment @ 2014-10-28
View Article Archives »