public function test_date_check() { $this->assertTrue(date_check('2015-06-22')); $this->assertFalse(date_check('2015-06-21')); $this->assertTrue(date_check('2015-08-01')); $this->assertTrue(date_check('2015-07')); $this->assertFalse(date_check('2015-07-abc')); $this->assertFalse(date_check('')); $this->assertFalse(date_check('123')); $this->assertFalse(date_check(123)); }
<?php // constants require_once "includes/common.php"; // connect to database mysql_connect(DB_SERVER, DB_USER, DB_PASS); // select database mysql_select_db(DB_NAME); // prepare an array for the lookup dates $datesarray = array(); // ensure each parameter is in lat,lng format if (!date_check($_GET["datein"]) || !date_check($_GET["dateout"])) { header("Content-type: text/plain"); print json_encode($dates); exit; } // check for good inputs and make variables $datein = mysql_real_escape_string($_GET["datein"]); $dateout = mysql_real_escape_string($_GET["dateout"]); // make sure date in is before date out if (strtotime($dateout) < strtotime($datein)) { header("Content-type: text/plain"); print json_encode($dates); exit; } // figure out the size of the array needed $numDays = date('d', strtotime("{$dateout}") - strtotime("{$datein}")); // prepare an array to encapsulate the new dates $dates = array(); $dates[] = $numDays; // put the dates in the array
function pop3_session($tools, $user, $pass, $port, $host, $ssl, $starttls, $keep, $destination, $acct_id, $uid_map) { $pop3 = hm_new('pop3'); $pop3->server = $host; $pop3->port = $port; $pop3->starttls = $starttls; $pop3->ssl = $ssl; $msg_count = 0; $read_size = 0; $seen = false; $msg_list = array(); if ($pop3->connect()) { if ($pop3->auth($user, $pass)) { $msg_list = $pop3->mlist(); $uid_list = $pop3->uidl(); foreach ($msg_list as $id => $size) { $headers = true; if ($keep) { if (isset($uid_map[$acct_id][$uid_list[$id]])) { continue; } $uid_map[$acct_id][$uid_list[$id]] = false; } $msg_count++; if ($pop3->retr_start($id)) { if ($tools->imap_append_start($destination, $size, false)) { $continue = true; while ($continue) { list($line, $continue) = $pop3->retr_feed(); $read_size += strlen($line); if ($keep && $headers) { $dt = date_check($line); if ($dt) { $uid_map[$acct_id][$uid_list[$id]] = $dt; } } if (!trim($line)) { $headers = false; } if ($continue && strlen($line)) { $tools->imap_append_feed($line, true); } else { $tools->imap_append_feed("\r\n", true); $tools->imap_append_end(); break; } } } } if (!$keep) { $pop3->dele($id); } } if ($keep) { $new_uid_map = array(); foreach ($msg_list as $id => $size) { if (isset($uid_map[$acct_id][$uid_list[$id]])) { $new_uid_map[$uid_list[$id]] = $uid_map[$acct_id][$uid_list[$id]]; } else { $new_uid_map[$uid_list[$id]] = false; } } $uid_map[$acct_id] = $new_uid_map; } $pop3->quit(); } } return array($msg_count, $uid_map); }