Exemplo n.º 1
0
 /**
  * All in one method
  *
  * @param   int|array  $duration  Array of time segments or a number of seconds
  * @return  string
  */
 function toString($duration, $periods = null)
 {
     if (!is_array($duration)) {
         $duration = Duration::int2array($duration, $periods);
     }
     return Duration::array2string($duration);
 }
Exemplo n.º 2
0
 /**
  * Convert a FormalDate to a string
  * @return string
  */
 public function __toString()
 {
     $result = array();
     if ($this->isRecurring) {
         $result[] = "R";
         if ($this->numRepetitions !== null) {
             $result[] = $this->numRepetitions;
         }
         $result[] = "/";
     } elseif ($this->isApproximate) {
         $result[] = "A";
     }
     if ($this->start !== null) {
         $result[] = $this->start->__toString();
     }
     if ($this->isRange) {
         $result[] = "/";
     }
     if ($this->end !== null) {
         $result[] = $this->end->__toString();
     } elseif ($this->duration !== null) {
         $result[] = $this->duration->__toString();
     }
     return implode("", $result);
 }
Exemplo n.º 3
0
 /**
  * Returns the total elapsed time.
  *
  * This includes the times between previous start() and stop() calls if any,
  * as well as the time since the stopwatch was last started if it is running.
  *
  * @return Duration
  */
 public function getElapsedTime()
 {
     if ($this->startTime === null) {
         return $this->duration;
     }
     return $this->duration->plus(Duration::between($this->startTime, Instant::now()));
 }
Exemplo n.º 4
0
 /**
  * Test some leap years.
  * 
  */
 function test_end()
 {
     $datA = DateAndTime::withYearDay(2005, 125);
     $datB = DateAndTime::withYearDay(2006, 125);
     $timespan = Schedule::startingDuration(DateAndTime::withYearDay(2005, 125), Duration::withDays(365));
     $this->assertEqual($timespan->startYear(), 2005);
     $this->assertEqual($timespan->dayOfYear(), 125);
     $duration = $timespan->duration();
     $this->assertTrue($duration->isEqualTo(Duration::withDays(365)));
     $end = $timespan->end();
     $this->assertEqual($end->julianDayNumber(), 2453860);
     $this->assertEqual($end->julianDayNumber() - $datA->julianDayNumber(), 364);
     $this->assertEqual($end->year(), 2006);
     $this->assertEqual($end->dayOfYear(), 124);
     $this->assertTrue($end->isEqualTo(DateAndTime::withYearDayHourMinuteSecond(2006, 124, 23, 59, 59)));
 }
Exemplo n.º 5
0
 /**
  * Compare
  * Both pace objects must have the same unit and the unit must be comparable.
  * @param \Runalyze\Activity\Pace $other
  * @param boolean $raw [optional]
  * @throws \InvalidArgumentException
  * @return string
  */
 public function compareTo(Pace $other, $raw = false)
 {
     if ($this->Unit != $other->unit()) {
         throw new \InvalidArgumentException('Pace objects must have the same unit.');
     }
     if ($this->secondsPerKm() == 0 || $other->secondsPerKm() == 0) {
         return '';
     }
     switch ($this->Unit) {
         case self::MIN_PER_KM:
         case self::MIN_PER_100M:
         case self::MIN_PER_500M:
             $first = new Duration($this->value());
             $second = new Duration($other->value());
             $string = Duration::format(abs($first->seconds() - $second->seconds()));
             return $this->formatComparison($string, $first->seconds() <= $second->seconds(), $raw);
         case self::KM_PER_H:
         case self::M_PER_S:
             $value = abs((double) str_replace(',', '.', $this->value()) - (double) str_replace(',', '.', $other->value()));
             $string = number_format($value, 1, ',', '.');
             return $this->formatComparison($string, $other->secondsPerKm() >= $this->secondsPerKm(), $raw);
     }
     throw new \InvalidArgumentException('Pace unit ' . $this->Unit . ' cannot be compared.');
 }
Exemplo n.º 6
0
 /**
  * Answer a TimeStamp which is anInteger seconds after the receiver.
  * 
  * @param integer $anInteger
  * @return object TimeStamp
  * @access public
  * @since 5/13/05
  */
 function plusSeconds($anInteger)
 {
     $obj = $this->plus(Duration::withSeconds($anInteger));
     return $obj;
 }
Exemplo n.º 7
0
 /**
  * Test durations that generate seconds larger than 2^32 seconds.
  * This may or may not work on some systems.
  * (32-bit) integers can be up to ~2billion. 
  * This corresponds to ~100 years (36500 days).
  * The system may or may not support going over this limit.
  * The system this was developed on, 
  *
  *		Linux version 2.4.18-14 (bhcompile@stripples.devel.redhat.com) 
  *			(gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)) #1 
  *			Wed Sep 4 13:35:50 EDT 2002
  *
  *		PHP 4.3.2
  *			'./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' 
  *			'--enable-safe-mode' '--with-openssl' '--with-gd' 
  *			'--enable-gd-native-ttf' '--with-jpeg-dir=/usr/lib' 
  *			'--with-png-dir=/usr/lib' '--with-xpm-dir=/usr/lib' 
  *			'--with-ttf=/usr/lib' '--with-t1lib=/usr/lib' '--with-ldap' 
  *			'--with-mysql' '--with-pdflib' '--with-zlib-dir=/usr/lib' 
  *			'--with-gettext' '--with-xml' '--with-pgsql=/usr' 
  *			'--with-java=/usr/java' '--with-iconv=/usr/local/lib' '--with-dom'
  *
  * supports the following tests.
  */
 function test_big_durations()
 {
     // 50 years (18250 days)
     $duration = Duration::withDays(18250);
     $this->assertEqual($duration->days(), 18250);
     $this->assertEqual($duration->hours(), 0);
     $this->assertEqual($duration->minutes(), 0);
     $this->assertEqual($duration->seconds(), 0);
     $this->assertEqual($duration->asSeconds(), 86400 * 18250);
     $this->assertEqual($duration->asSeconds(), 1576800000);
     // 100 years (36500 days)
     $duration = Duration::withDays(36500);
     $this->assertEqual($duration->days(), 36500);
     $this->assertEqual($duration->hours(), 0);
     $this->assertEqual($duration->minutes(), 0);
     $this->assertEqual($duration->seconds(), 0);
     $this->assertEqual($duration->asSeconds(), 86400 * 36500);
     $this->assertEqual($duration->asSeconds(), 3153600000);
     // 500 years (182500 days)
     $duration = Duration::withDays(182500);
     $this->assertEqual($duration->days(), 182500);
     $this->assertEqual($duration->hours(), 0);
     $this->assertEqual($duration->minutes(), 0);
     $this->assertEqual($duration->seconds(), 0);
     $this->assertEqual($duration->asSeconds(), 86400 * 182500);
     $this->assertEqual($duration->asSeconds(), 15768000000);
     // 5000 years (1825000 days)
     $duration = Duration::withDays(1825000);
     $this->assertEqual($duration->days(), 1825000);
     $this->assertEqual($duration->hours(), 0);
     $this->assertEqual($duration->minutes(), 0);
     $this->assertEqual($duration->seconds(), 0);
     $this->assertEqual($duration->asSeconds(), 86400 * 1825000);
     $this->assertEqual($duration->asSeconds(), 157680000000);
     // 5000 years (1825000 days)
     // minus 500 years (182500 days)
     // should equal 4500 years (1642500 days)
     $duration = Duration::withDays(1825000);
     $result = $duration->minus(Duration::withDays(182500));
     $this->assertEqual($result->days(), 1642500);
     $this->assertEqual($result->hours(), 0);
     $this->assertEqual($result->minutes(), 0);
     $this->assertEqual($duration->seconds(), 0);
     $this->assertEqual($result->asSeconds(), 86400 * 1642500);
     $this->assertEqual($result->asSeconds(), 141912000000);
     // 500,000,000 years (182500000000 days)
     // minus 500 years (182500 days)
     // should equal 499,999,500 years (182481750000 days)
     $duration = Duration::withDays(182500000000);
     $result = $duration->minus(Duration::withDays(182500));
     $this->assertEqual($result->days(), 182499817500);
     $this->assertEqual($result->hours(), 0);
     $this->assertEqual($result->minutes(), 0);
     $this->assertEqual($duration->seconds(), 0);
     $this->assertEqual($result->asSeconds(), 86400 * 182499817500);
     $this->assertEqual($result->asSeconds(), hexdec('3804e5eaf8ea00'));
     // 50,000,000,000 years (18250000000000 days)
     // minus 500 years (182500 days)
     // should equal 49,999,999,500 years (18249999817500 days)
     $duration = Duration::withDays(18250000000000);
     $result = $duration->minus(Duration::withDays(182500));
     $this->assertEqual($result->days(), 18249999817500);
     $this->assertEqual($result->hours(), 0);
     $this->assertEqual($result->minutes(), 0);
     $this->assertEqual($duration->seconds(), 0);
     $this->assertEqual($result->asSeconds(), 86400 * 18249999817500);
     $this->assertEqual($result->asSeconds(), hexdec('15e1eb3b3dfd6a00'));
     // Beyond negative 4 billion years, the precision drops from
     // second precision to hour precision.
     // 4,000,000,000 years (1460000000000 days)
     $duration = Duration::withDaysHoursMinutesSeconds(1460000000000, 2, 23, 12);
     $this->assertEqual($duration->days(), 1460000000000);
     $this->assertEqual($duration->hours(), 2);
     $this->assertEqual($duration->minutes(), 23);
     $this->assertEqual($duration->seconds(), 12);
     // 50,000,000,000 years (18250000000000 days)
     $duration = Duration::withDaysHoursMinutesSeconds(18250000000000, 2, 23, 12);
     $this->assertEqual($duration->days(), 18250000000000);
     $this->assertEqual($duration->hours(), 2);
     // 		$this->assertEqual($duration->minutes(), 23);
     // 		$this->assertEqual($duration->seconds(), 12);
 }
Exemplo n.º 8
0
 /**
  * Create a new object starting from midnight
  * 
  * @param object DateAndTime $aDateAndTime
  * @param object Duration $aDuration
  * @param optional string $class DO NOT USE OUTSIDE OF PACKAGE.
  *		This parameter is used to get around the limitations of not being
  *		able to find the class of the object that recieved the initial 
  *		method call.
  * @return object Year
  * @access public
  * @since 5/5/05
  * @static
  */
 static function startingDuration($aDateAndTime, $aDuration, $class = 'Year')
 {
     // Validate our passed class name.
     if (!(strtolower($class) == strtolower('Year') || is_subclass_of(new $class(), 'Year'))) {
         die("Class, '{$class}', is not a subclass of 'Year'.");
     }
     $asDateAndTime = $aDateAndTime->asDateAndTime();
     $midnight = $asDateAndTime->atMidnight();
     $year = new $class();
     $year->setStart($midnight);
     $year->setDuration(Duration::withDays(Year::getDaysInYear($midnight->year())));
     return $year;
 }
Exemplo n.º 9
0
 /**
  * Answer a Duration that represents this object, the duration since
  * midnight.
  * 
  * @return object Duration
  * @access public
  * @since 5/4/05
  */
 function asDuration()
 {
     $obj = Duration::withSeconds($this->seconds);
     return $obj;
 }
Exemplo n.º 10
0
 public function test_offset_ClockDuration_nullClock()
 {
     TestHelper::assertNullException($this, function () {
         Clock::offset(null, Duration::ZERO());
     });
 }
Exemplo n.º 11
0
 /**
  * Answer a DateAndTime equivalent to the reciever, but at UTC (offset = 0)
  * 
  * @return object DateAndTime
  * @access public
  * @since 5/4/05
  */
 function asUTC()
 {
     $obj = $this->utcOffset(Duration::withHours(0));
     return $obj;
 }
Exemplo n.º 12
0
 /**
  * Test converting methods
  * 
  */
 function test_converting()
 {
     $time = Time::withHourMinuteSecond(15, 25, 10);
     // asDate ()
     $temp = $time->asDate();
     $this->assertTrue($temp->isEqualTo(Date::today()));
     $this->assertEqual(strtolower(get_class($temp)), 'date');
     // asDateAndTime ()
     $temp = $time->asDateAndTime();
     $comparison = DateAndTime::midnight();
     $comparison = $comparison->plus(Duration::withSeconds(55510));
     $this->assertTrue($temp->isEqualTo($comparison));
     $this->assertEqual(strtolower(get_class($temp)), 'dateandtime');
     // asDuration ()
     $temp = $time->asDuration();
     $this->assertTrue($temp->isEqualTo(Duration::withSeconds(55510)));
     $this->assertEqual(strtolower(get_class($temp)), 'duration');
     // asMonth ()
     $temp = $time->asMonth();
     $this->assertTrue($temp->isEqualTo(Month::starting(Date::today())));
     $this->assertEqual(strtolower(get_class($temp)), 'month');
     // asSeconds ()
     $this->assertEqual($time->asSeconds(), 55510);
     // asTime ()
     $temp = $time->asTime();
     $this->assertTrue($temp->isEqualTo($time));
     $this->assertEqual(strtolower(get_class($temp)), 'time');
     // asTimeStamp ()
     $temp = $time->asTimeStamp();
     $comparison = TimeStamp::midnight();
     $comparison = $comparison->plus(Duration::withSeconds(55510));
     $this->assertTrue($temp->isEqualTo($comparison));
     $this->assertEqual(strtolower(get_class($temp)), 'timestamp');
     // asWeek ()
     $temp = $time->asWeek();
     $this->assertTrue($temp->isEqualTo(Week::starting(Date::today())));
     $this->assertEqual(strtolower(get_class($temp)), 'week');
     // asYear ()
     $temp = $time->asYear();
     $this->assertTrue($temp->isEqualTo(Year::starting(Date::today())));
     $this->assertEqual(strtolower(get_class($temp)), 'year');
     // to ()
     $today = DateAndTime::today();
     $tomorrow = DateAndTime::tomorrow();
     $result = $time->to($tomorrow);
     $this->assertEqual(strtolower(get_class($result)), 'timespan');
     $this->assertTrue($result->isEqualTo(Timespan::startingDuration($today->plus(Duration::withSeconds(55510)), Duration::withDaysHoursMinutesSeconds(0, 8, 34, 50))));
     $result = $time->to(Time::withHourMinuteSecond(23, 25, 10));
     $this->assertEqual(strtolower(get_class($result)), 'timespan');
     $this->assertTrue($result->isEqualTo(Timespan::startingDuration($today->plus(Duration::withSeconds(55510)), Duration::withDaysHoursMinutesSeconds(0, 8, 0, 0))));
 }
Exemplo n.º 13
0
 public function testHourFormat()
 {
     $Time = new Duration();
     $this->assertEquals('24:00:00', $Time->fromSeconds(24 * 3600)->string(Duration::FORMAT_WITH_HOURS));
     $this->assertEquals('27:13:08', $Time->fromSeconds(27 * 3600 + 13 * 60 + 8)->string(Duration::FORMAT_WITH_HOURS));
 }
Exemplo n.º 14
0
function age($params, &$smarty)
{
    $d = new Duration();
    $d->short();
    $d->terse();
    $a = $d->AgeAsArray(ceil($d->Diff(time(), $params["time"])));
    if (isset($params['steps'])) {
        return join(' ', array_slice($a, 0, $params['steps']));
    }
    return join(' ', $a);
}
Exemplo n.º 15
0
 /**
  * Answer a string version of this time zone
  * 
  * @return string
  * @access public
  * @since 10/15/08
  */
 public function printableString()
 {
     if ($this->offset->isLessThan(Duration::withSeconds(0))) {
         $string = '-';
     } else {
         $string = '+';
     }
     $string .= str_pad(abs($this->offset->hours()), 2, '0', STR_PAD_LEFT);
     $string .= ':' . str_pad(abs($this->offset->minutes()), 2, '0', STR_PAD_LEFT);
     return $string;
 }
Exemplo n.º 16
0
 /**
  * Create a new object starting now, with a given duration. 
  * Override - as each Week has a defined duration
  * 
  * @param object DateAndTime $aDateAndTime
  * @param object Duration $aDuration
  * @param optional string $class DO NOT USE OUTSIDE OF PACKAGE.
  *		This parameter is used to get around the limitations of not being
  *		able to find the class of the object that recieved the initial 
  *		method call.
  * @return object Week
  * @access public
  * @since 5/5/05
  * @static
  */
 static function startingDuration($aDateAndTime, $aDuration, $class = 'Week')
 {
     // Validate our passed class name.
     if (!(strtolower($class) == strtolower('Week') || is_subclass_of(new $class(), 'Week'))) {
         die("Class, '{$class}', is not a subclass of 'Week'.");
     }
     $asDateAndTime = $aDateAndTime->asDateAndTime();
     $midnight = $asDateAndTime->atMidnight();
     $dayNames = ChronologyConstants::DayNames();
     $temp = $midnight->dayOfWeek() + 7 - array_search(Week::startDay(), $dayNames);
     $delta = abs($temp - intval($temp / 7) * 7);
     $adjusted = $midnight->minus(Duration::withDays($delta));
     $obj = parent::startingDuration($adjusted, Duration::withWeeks(1), $class);
     return $obj;
 }
Exemplo n.º 17
0
 public function minus(Duration $duration)
 {
     $date = $this->toDateTime();
     $date->sub($duration->asPHPDateInterval());
     return $this->fromDateTime($date);
 }
Exemplo n.º 18
0
        }
    }
    $a[$i] = array($r['day'], $r['count']);
}
for ($i = 0; $i < 12; $i++) {
    print '<tr>';
    print '<th>' . $a[$i][0] . ':</th><td>' . number_format($a[$i][1], 0) . ' ' . _('posts') . ' ' . sprintf("(%0.1f%%)", $a[$i][1] / $totalposts * 100) . '</td>';
    print '<th>' . $a[$i + 12][0] . ':</th><td>' . number_format($a[$i + 12][1], 0) . ' ' . _('posts') . ' ' . sprintf("(%0.1f%%)", $a[$i + 12][1] / $totalposts * 100) . '</td>';
    print '</tr>';
}
print '</table></td><td style="text-align:right"><img src="/stat-img-hour.php" width="400" height="250" /></td></tr></table>';
$cache1 = new Memcache();
$cache1->pconnect('localhost', '11211');
$cache2 = new Memcache();
$cache2->pconnect('localhost', '11212');
$dur = new Duration();
$cs1 = $cache1->getStats();
$cs2 = $cache2->getStats();
makeSection(_('cache statistics'));
print '<table style="text-align:left"><tr><th>Statistic</th><th>Cache 1</th><th>Cache 2</th>';
print '<tr><th>Uptime</th><td>' . $dur->AgeAsString($cs1['uptime']) . '</td><td>' . $dur->AgeAsString($cs2['uptime']) . '</td></tr>';
print '<tr><th>Item Count</th><td>' . number_format($cs1['curr_items'], 0) . '</td><td>' . number_format($cs2['curr_items'], 0) . '</td></tr>';
print '<tr><th>Utilization</th><td>' . sprintf("%0.01f", $cs1['bytes'] / $cs1['limit_maxbytes'] * 100.0) . '%</td><td>' . sprintf("%0.01f", $cs2['bytes'] / $cs2['limit_maxbytes'] * 100.0) . '%</td></tr>';
print '<tr><th>Hit Efficiency</th><td>' . sprintf("%0.01f", $cs1['get_hits'] / $cs1['get_misses']) . " to 1 (" . sprintf("%0.02f", ($cs1['cmd_get'] + $cs1['cmd_set']) / $cs1['uptime']) . " req/s)</td><td>" . sprintf("%0.01f", $cs2['get_hits'] / $cs2['get_misses']) . ' to 1 (' . sprintf("%0.02f", ($cs2['cmd_get'] + $cs2['cmd_set']) / $cs2['uptime']) . ' req/s)</td></tr>';
print '<tr><th>Byte Efficiency</th><td>' . sprintf("%0.01f", $cs1['bytes_written'] / $cs1['bytes_read']) . " to 1</td><td>" . sprintf("%0.01f", $cs2['bytes_written'] / $cs2['bytes_read']) . ' to 1</td></tr>';
print '<tr><th>Average Object Size</th><td>' . number_format($cs1['bytes'] / $cs1['curr_items'], 0) . ' bytes</td><td>' . number_format($cs2['bytes'] / $cs2['curr_items'], 0) . ' bytes</td></tr>';
print '</table>';
$res = cache_pg_Exec($db, "SELECT COUNT(*) AS count,MAX(period) AS max_period,AVG(period) AS avg_period,SUM(hits) AS hits,MAX(hits) AS max_hits FROM spammers", 60);
$res = $res[0];
makeSection(_('spammer statistics'));
print '<table style="text-align:left">';
Exemplo n.º 19
0
function handle_service($buffer)
{
    global $hlist;
    global $services_ok;
    global $services_warning;
    global $services_pending;
    global $services_critical;
    global $services_unknown;
    global $services_ack;
    $nothing = strtok($buffer, "\n");
    $host_name = substr(strtok("\n"), 11);
    $description = substr(strtok("\n"), 21);
    $modified_attributes = substr(strtok("\n"), 21);
    $check_command = substr(strtok("\n"), 15);
    $check_period = substr(strtok("\n"), 13);
    $notification_period = substr(strtok("\n"), 20);
    $check_interval = substr(strtok("\n"), 15);
    $retry_interval = substr(strtok("\n"), 15);
    $event_handler = substr(strtok("\n"), 15);
    $has_been_checked = substr(strtok("\n"), 18);
    $should_be_scheduled = substr(strtok("\n"), 21);
    $execution_time = substr(strtok("\n"), 22);
    $latency = substr(strtok("\n"), 15);
    $check_type = substr(strtok("\n"), 12);
    $status = substr(strtok("\n"), 15);
    $last_hard_state = substr(strtok("\n"), 17);
    $last_event_id = substr(strtok("\n"), 14);
    $current_event_id = substr(strtok("\n"), 18);
    $current_problem_id = substr(strtok("\n"), 20);
    $last_problem_id = substr(strtok("\n"), 17);
    $current_attempt = substr(strtok("\n"), 17);
    $max_attempts = substr(strtok("\n"), 14);
    # If you have a slightly older version of Nagios you'll need to uncomment these. They were in the file twice in older versions.
    #		$last_event_id = substr(strtok("\n"),14);
    #		$current_event_id = substr(strtok("\n"),18);
    $state_type = substr(strtok("\n"), 12);
    $last_state_change = substr(strtok("\n"), 19);
    $last_hard_state_change = substr(strtok("\n"), 24);
    $time_ok = substr(strtok("\n"), 14);
    $time_warning = substr(strtok("\n"), 19);
    $time_unknown = substr(strtok("\n"), 19);
    $time_critical = substr(strtok("\n"), 20);
    $plugin_output = substr(strtok("\n"), 15);
    $long_plugin_output = substr(strtok("\n"), 20);
    $performance_data = substr(strtok("\n"), 18);
    $last_check = strftime("%b %d %Y %H:%M:%S", substr(strtok("\n"), 12));
    $next_check = substr(strtok("\n"), 12);
    $check_options = substr(strtok("\n"), 15);
    $current_notification_number = substr(strtok("\n"), 29);
    $current_notification_id = substr(strtok("\n"), 24);
    $last_notification = strftime("%b %d %Y %H:%M:%S", substr(strtok("\n"), 19));
    $next_notification = substr(strtok("\n"), 19);
    $no_more_notifications = substr(strtok("\n"), 23);
    $notifications_enabled = substr(strtok("\n"), 23);
    $checks_enabled = substr(strtok("\n"), 23);
    $accept_passive_service_checks = substr(strtok("\n"), 24);
    $event_handler_enabled = substr(strtok("\n"), 23);
    $problem_has_been_acknowledged = substr(strtok("\n"), 31);
    $acknowledgement_type = substr(strtok("\n"), 22);
    $flap_detection_enabled = substr(strtok("\n"), 24);
    $failure_prediction_enabled = substr(strtok("\n"), 28);
    $process_performance_data = substr(strtok("\n"), 26);
    $obsess_over_service = substr(strtok("\n"), 21);
    $last_update = strftime("%b %d %Y %H:%M:%S", substr(strtok("\n"), 13));
    $is_flapping = substr(strtok("\n"), 13);
    $percent_state_change = substr(strtok("\n"), 22);
    $scheduled_downtime_depth = substr(strtok("\n"), 26);
    $real_dur = time(0) - $last_state_change;
    $duration = Duration::toString($real_dur);
    $last_state_change = strftime("%b %d %Y %H:%M:%S", $last_state_change);
    // Populate the wonderful array with all the details about this service. Also, increment the counters for the service status.
    if ($status == "0") {
        $status = "OK";
        $services_ok++;
    } else {
        if ($status == "1") {
            $services_warning++;
            $status = "WARNING";
        } else {
            if ($status == "4") {
                $services_pending++;
            } else {
                if ($status == "2") {
                    //the table status thing ignores critial for critical hosts, so why does the counter?
                    //it doesn't anymore!
                    if ($hlist[$host_name]["host"]["status"] != "1") {
                        if ($problem_has_been_acknowledged != "1" && $notifications_enabled == "1") {
                            $services_critical++;
                        } else {
                            $services_ack++;
                        }
                    }
                    $status = "CRITICAL";
                } else {
                    if ($status == "3") {
                        $services_unknown++;
                        $status = "Unknown";
                    } else {
                        $services_unknown++;
                        $status = "Unknown";
                    }
                }
            }
        }
    }
    if ($status != "OK" && $status != "PENDING") {
        // Don't store the lengthy details for the OK or Pending services because that seems unneccesary
        $hlist[$host_name]["service"][$description]["last_update"] = $last_update;
        $hlist[$host_name]["service"][$description]["host_name"] = $host_name;
        $hlist[$host_name]["service"][$description]["description"] = $description;
        $hlist[$host_name]["service"][$description]["status"] = $status;
        $hlist[$host_name]["service"][$description]["current_attempt"] = $current_attempt;
        $hlist[$host_name]["service"][$description]["max_attempts"] = $max_attempts;
        $hlist[$host_name]["service"][$description]["state_type"] = $state_type;
        $hlist[$host_name]["service"][$description]["last_check"] = $last_check;
        $hlist[$host_name]["service"][$description]["next_check"] = $next_check;
        $hlist[$host_name]["service"][$description]["check_type"] = $check_type;
        $hlist[$host_name]["service"][$description]["checks_enabled"] = $checks_enabled;
        $hlist[$host_name]["service"][$description]["accept_passive_service_checks"] = $accept_passive_service_checks;
        $hlist[$host_name]["service"][$description]["event_handler_enabled"] = $event_handler_enabled;
        $hlist[$host_name]["service"][$description]["last_state_change"] = $last_state_change;
        $hlist[$host_name]["service"][$description]["problem_has_been_acknowledged"] = $problem_has_been_acknowledged;
        $hlist[$host_name]["service"][$description]["last_hard_state"] = $last_hard_state;
        $hlist[$host_name]["service"][$description]["time_ok"] = $time_ok;
        $hlist[$host_name]["service"][$description]["time_unknown"] = $time_unknown;
        $hlist[$host_name]["service"][$description]["time_warning"] = $time_warning;
        $hlist[$host_name]["service"][$description]["time_critical"] = $time_critical;
        $hlist[$host_name]["service"][$description]["last_notification"] = $last_notification;
        $hlist[$host_name]["service"][$description]["current_notification_number"] = $current_notification_number;
        $hlist[$host_name]["service"][$description]["notifications_enabled"] = $notifications_enabled;
        $hlist[$host_name]["service"][$description]["latency"] = $latency;
        $hlist[$host_name]["service"][$description]["execution_time"] = $execution_time;
        $hlist[$host_name]["service"][$description]["flap_detection_enabled"] = $flap_detection_enabled;
        $hlist[$host_name]["service"][$description]["is_flapping"] = $is_flapping;
        $hlist[$host_name]["service"][$description]["percent_state_change"] = $percent_state_change;
        $hlist[$host_name]["service"][$description]["scheduled_downtime_depth"] = $scheduled_downtime_depth;
        $hlist[$host_name]["service"][$description]["failure_prediction_enabled"] = $failure_prediction_enabled;
        $hlist[$host_name]["service"][$description]["process_performance_data"] = $process_performance_data;
        $hlist[$host_name]["service"][$description]["obsess_over_service"] = $obsess_over_service;
        $hlist[$host_name]["service"][$description]["plugin_output"] = $plugin_output;
        $hlist[$host_name]["service"][$description]["duration"] = $duration;
        $hlist[$host_name]["service"][$description]["duration_in_secs"] = $real_dur;
    }
}
 /**
  * Test conversion to the PHP built-in DateTime
  * 
  * @return void
  * @access public
  * @since 11/21/08
  */
 public function test_php_datetime()
 {
     print "<h3>conversion to PHP DateTime</h3>";
     $ref = new ReflectionClass('DateTimeZone');
     printpre($ref->getMethods());
     $dateAndTime = DateAndTime::withYearMonthDayHourMinuteSecondOffset(2005, 6, 4, 15, 25, 10, Duration::withHours(-5));
     $this->checkEquality($dateAndTime, $dateAndTime->asDateTime());
     $dateAndTime = DateAndTime::withYearMonthDayHourMinuteSecondOffset(2005, 2, 4, 15, 25, 10, Duration::withHours(-4));
     $this->checkEquality($dateAndTime, $dateAndTime->asDateTime());
     $dateAndTime = DateAndTime::withYearMonthDayHourMinuteSecondOffset(1423, 2, 4, 15, 25, 10, Duration::withHours(0));
     $this->checkEquality($dateAndTime, $dateAndTime->asDateTime());
     $dateAndTime = DateAndTime::withYearMonthDayHourMinuteSecondOffset(732, 6, 3, 8, 0, 0, Duration::withHours(0));
     $this->checkEquality($dateAndTime, $dateAndTime->asDateTime());
     $dateAndTime = DateAndTime::withYearMonthDayHourMinuteSecondOffset(2, 6, 3, 8, 0, 0, Duration::withHours(0));
     $this->checkEquality($dateAndTime, $dateAndTime->asDateTime());
     $dateAndTime = DateAndTime::withYearMonthDayHourMinuteSecondOffset(0, 6, 3, 8, 0, 0, Duration::withHours(0));
     $this->checkEquality($dateAndTime, $dateAndTime->asDateTime());
     $dateAndTime = DateAndTime::withYearMonthDayHourMinuteSecondOffset(-460, 6, 3, 8, 0, 0, Duration::withHours(0));
     $this->checkEquality($dateAndTime, $dateAndTime->asDateTime());
     $dateAndTime = DateAndTime::withYearMonthDayHourMinuteSecondOffset(-8460, 6, 3, 8, 0, 0, Duration::withHours(0));
     $this->checkEquality($dateAndTime, $dateAndTime->asDateTime());
     $dateAndTime = DateAndTime::now();
     $this->checkEquality($dateAndTime, $dateAndTime->asDateTime());
 }
Exemplo n.º 21
0
 /**
  * Update the modification date and set the creation date if needed.
  *
  * WARNING: NOT IN OSID
  * 
  * @return void
  * @access public
  * @since 5/4/06
  */
 function updateModificationDate()
 {
     // Only update our modification time if we will be adding more than a
     // minute (to save on many repeated updates while changing lots of values
     // at once).
     if (isset($this->_modifyDate) && is_object($this->_modifyDate)) {
         $now = DateAndTime::now();
         $minute = Duration::withSeconds(60);
         if ($minute->isGreaterThan($now->minus($this->_modifyDate))) {
             return;
         }
     }
     $this->_loadDates();
     $this->_storeDates();
 }
Exemplo n.º 22
0
 /**
  * Test Converting Methods
  * 
  */
 function test_converting()
 {
     // Converting
     $timespan = Year::startingDuration(DateAndTime::withYearMonthDayHourMinuteSecondOffset(2005, 5, 4, 15, 25, 10, Duration::withHours(-4)), Duration::withDays(10));
     // asDate()
     $temp = $timespan->asDate();
     $this->assertTrue($temp->isEqualTo(Date::withYearMonthDay(2005, 5, 4)));
     // asDateAndTime()
     $temp = $timespan->asDateAndTime();
     $this->assertTrue($temp->isEqualTo(DateAndTime::withYearMonthDayHourMinuteSecond(2005, 5, 4, 00, 00, 00)));
     // asDuration()
     $temp = $timespan->asDuration();
     $this->assertTrue($temp->isEqualTo(Duration::withDays(365)));
     // asMonth()
     $temp = $timespan->asMonth();
     $this->assertTrue($temp->isEqualTo(Month::withMonthYear(5, 2005)));
     // asTime()
     $temp = $timespan->asTime();
     $dateAndTime = DateAndTime::withYearMonthDayHourMinuteSecond(2005, 5, 4, 0, 0, 0);
     $this->assertTrue($temp->isEqualTo($dateAndTime->asTime()));
     // asTimeStamp()
     $temp = $timespan->asTimeStamp();
     $this->assertTrue($temp->isEqualTo(TimeStamp::withYearMonthDayHourMinuteSecond(2005, 5, 4, 0, 0, 0)));
     // asWeek()
     $temp = $timespan->asWeek();
     $this->assertTrue($temp->isEqualTo(Week::starting(Date::withYearMonthDay(2005, 5, 1))));
     // asYear()
     $temp = $timespan->asYear();
     $this->assertTrue($temp->isEqualTo(Year::starting(Date::withYearMonthDay(2005, 5, 4))));
     // to()
     $temp = $timespan->to(Date::withYearMonthDay(2005, 10, 1));
     $comparison = Timespan::startingEnding(DateAndTime::withYearMonthDayHourMinuteSecond(2005, 5, 4, 0, 0, 0), Date::withYearMonthDay(2005, 10, 1));
     $this->assertTrue($temp->isEqualTo($comparison));
 }
Exemplo n.º 23
0
 /**
  * Save an XML string to the feed cache
  * 
  * @param string $url
  * @param string $feedXml
  * @return void
  * @access protected
  * @since 7/8/08
  */
 protected function cacheXmlString($url, $feedXml)
 {
     $dbc = Services::getService("DatabaseManager");
     $query = new DeleteQuery();
     $query->setTable('segue_plugins_rssfeed_cache');
     $query->addWhereEqual('url', $url);
     $query->addWhereRawLessThan('cache_time', $dbc->toDBDate(DateAndTime::now()->minus(Duration::withSeconds(600)), IMPORTER_CONNECTION), _OR);
     try {
         $result = $dbc->query($query, IMPORTER_CONNECTION);
     } catch (NoSuchTableDatabaseException $e) {
         $this->createCacheTable();
     }
     $query = new InsertQuery();
     $query->setTable('segue_plugins_rssfeed_cache');
     $query->addValue('url', $url);
     $query->addValue('feed_data', $feedXml);
     $dbc->query($query, IMPORTER_CONNECTION);
 }
Exemplo n.º 24
0
 /**
  * Creates individual Entry objects of the appropriate type and
  * stores them in the $_entry array based upon DOM data.
  *
  * @param DOMNode $child The DOMNode to process
  */
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('media') . ':' . 'content':
             $content = new MediaContent();
             $content->transferFromDOM($child);
             $this->_content[] = $content;
             break;
         case $this->lookupNamespace('media') . ':' . 'rating':
             $mediarating = new MediaRating();
             $mediarating->transferFromDOM($child);
             $this->_mediarating = $mediarating;
             break;
         case $this->lookupNamespace('media') . ':' . 'credit':
             $mediacredit = new MediaCredit();
             $mediacredit->transferFromDOM($child);
             $this->_mediacredit = $mediacredit;
             break;
         case $this->lookupNamespace('yt') . ':' . 'duration':
             $duration = new Duration();
             $duration->transferFromDOM($child);
             $this->_duration = $duration;
             break;
         case $this->lookupNamespace('yt') . ':' . 'private':
             $private = new PrivateExtension();
             $private->transferFromDOM($child);
             $this->_private = $private;
             break;
         case $this->lookupNamespace('yt') . ':' . 'videoid':
             $videoid = new VideoId();
             $videoid->transferFromDOM($child);
             $this->_videoid = $videoid;
             break;
         case $this->lookupNamespace('yt') . ':' . 'uploaded':
             $uploaded = new Uploaded();
             $uploaded->transferFromDOM($child);
             $this->_uploaded = $uploaded;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }
Exemplo n.º 25
0
 /**
  * Answer the number of seconds the receiver represents.
  * 
  * @return integer
  * @access public
  * @since 5/3/05
  */
 function seconds()
 {
     // Above 2^31 seconds, (amost exactly 100 years), PHP converts the
     // variable from an integer to a float to allow it to grow larger.
     // While addition and subraction work fine with floats, float modulos
     // and divisions loose precision. This precision loss does not affect
     // the proper value of days up to the maximum duration tested, 50billion
     // years.
     if (abs($this->seconds) > pow(2, 31)) {
         $remainderDuration = $this->minus(Duration::withDays($this->days()));
         return $remainderDuration->seconds();
     } else {
         if ($this->isPositive()) {
             return floor($this->seconds % ChronologyConstants::SecondsInMinute());
         } else {
             return 0 - floor(abs($this->seconds) % ChronologyConstants::SecondsInMinute());
         }
     }
 }
 /**
  * Answer the delay (in seconds) that the modification time should be cached without
  * checking the source again. 
  * 
  * @return object Duration
  * @access public
  * @since 5/13/08
  */
 public function getCacheDuration()
 {
     // A default of 1 minute is used. Override this method to add longer
     // or shorter times.
     return Duration::withMinutes(1);
 }
Exemplo n.º 27
0
 /**
  * Initialize this cache for an authorization manager
  * 
  * @param object AuthorizationManager $manager
  * @return void
  * @access private
  * @since 4/22/08
  */
 private function initialize(AuthorizationManager $manager)
 {
     // Initialize our paremeters
     $this->_queue = array();
     $this->_agentIdStrings = array();
     $this->loadSingleAz_stmts = array();
     // get our configuration
     $this->authorizationManager = $manager;
     $this->_configuration = $manager->_configuration;
     $this->_authorizationManagerObjectCache = $manager->_cache;
     // [Re]set up our cache if it doesn't exist or if we have a new user.
     if (!isset($_SESSION['__isAuthorizedCache'])) {
         $_SESSION['__isAuthorizedCache'] = array();
     }
     // If we have been operating for more than the configured cache expiry time,
     // reset our cache so that authorization revokation can take effect.
     if (!isset($_SESSION['__isAuthorizedCacheInitTime'])) {
         $_SESSION['__isAuthorizedCacheInitTime'] = DateAndTime::now();
     }
     if (DateAndTime::now()->isGreaterThan($_SESSION['__isAuthorizedCacheInitTime']->plus(Duration::withMinutes(10)))) {
         $_SESSION['__isAuthorizedCache'] = array();
         $_SESSION['__isAuthorizedCacheInitTime'] = DateAndTime::now();
     }
     if (!isset($_SESSION['__isAuthorizedCacheUnknownIds'])) {
         $_SESSION['__isAuthorizedCacheUnknownIds'] = array();
     }
     if (!isset($_SESSION['__isAuthorizedCache']['USER']) || !isset($_SESSION['__isAuthorizedCacheAgents']['USER']) || !isset($_SESSION['__isAuthorizedCacheTime']['USER']) || $_SESSION['__isAuthorizedCacheAgents']['USER'] != implode(", ", $this->getAgentIdStringArray('USER'))) {
         $_SESSION['__isAuthorizedCacheAgents']['USER'] = implode(", ", $this->getAgentIdStringArray('USER'));
         $_SESSION['__isAuthorizedCache']['USER'] = array();
         $_SESSION['__isAuthorizedCacheTime']['USER'] = DateAndTime::now();
     }
     // Unload any expired Node AZs
     $this->_synchronizeCache();
 }
Exemplo n.º 28
0
function duration($dur)
{
    return Duration::toSeconds('! ' . $dur);
}
Exemplo n.º 29
0
 /**
  * Create a new object starting now, with a given duration. 
  * Override - as each month has a defined duration
  * 
  * @param object DateAndTime $aDateAndTime
  * @param object Duration $aDuration
  * @param optional string $class DO NOT USE OUTSIDE OF PACKAGE.
  *		This parameter is used to get around the limitations of not being
  *		able to find the class of the object that recieved the initial 
  *		method call.
  * @return object Month
  * @access public
  * @since 5/5/05
  * @static
  */
 static function startingDuration($aDateAndTime, $aDuration, $class = 'Month')
 {
     // Validate our passed class name.
     if (!(strtolower($class) == strtolower('Month') || is_subclass_of(new $class(), 'Month'))) {
         die("Class, '{$class}', is not a subclass of 'Month'.");
     }
     $start = $aDateAndTime->asDateAndTime();
     $adjusted = DateAndTime::withYearMonthDay($start->year(), $start->month(), 1);
     $days = Month::daysInMonthForYear($adjusted->month(), $adjusted->year());
     $month = new $class();
     $month->setStart($adjusted);
     $month->setDuration(Duration::withDays($days));
     return $month;
 }
Exemplo n.º 30
0
function RSSReader_activate()
{
    ini_set('error_reporting', E_ALL);
    ini_set('display_errors', 1);
    require_once "{$GLOBALS['PROJECT_BASEDIR']}/libs/TempStore.php";
    // abstracts data storage
    // returns MySQL valid timestamp
    function mysql_time($t)
    {
        return date('Y-m-d H:i:s', $t);
    }
    // prints out fetched key=>val pairs
    function printarr($arr)
    {
        foreach ($arr as $k => $v) {
            if (is_array($v)) {
                printarr($v);
            } else {
                echo "<tr>\n\t<td>&laquo;{$k}&raquo;</td>\n\t<td>&laquo;" . htmlspecialchars($v, ENT_COMPAT, 'UTF-8') . "&raquo;</td>\n</tr>\n";
            }
        }
    }
    // CONSTANTS AND HANDLES
    $shortwait = 10;
    // time in seconds between each check for new content on well reporting servers (10*60 is a good value here)
    $longwait = 30;
    // time in seconds between each redownload of content on servers not reporting content information (30*60 is a good value here)
    $sql =& new DBXStore($GLOBALS['DB_HOST'], $GLOBALS['DB_USERNAME'], $GLOBALS['DB_PASSWORD'], $GLOBALS['DB_DATABASE']);
    // data storage handle
    $feeds = $sql->read('feeds', array('id', 'url', 'timer', 'lastmodified', 'etag', 'reports'));
    // cache of all relevant information from data storage
    $ett = null;
    // I have to get the ETag we got from the server to the data writing bit somehow...
    $lmm = null;
    // I have to get the Last-Modified timestamp we got from the server to the data writing bit somehow...
    $update = false;
    // This also needs a default value to avoid notices--I don't want ANY errors. ;)
    //________________________________________________________________
    //================================================================
    //
    //      MAIN LOOP
    //________________________________________________________________
    //================================================================
    foreach ($feeds->data as $feed) {
        // Check to see if it's time to update this feed
        $checkhead = false;
        $ett = null;
        // clear out old ETag availability value
        $lmm = null;
        // clear out old Last-Modified availability value
        if ($feed['reports'] == 'complete' || $feed['reports'] == 'etagonly' || $feed['reports'] == 'lmonly') {
            // Server reports some usable information, we can make HEAD requests after a short wait time
            if ($feed['timer'] == 0 || empty($feed['timer']) || $feed['timer'] == null || strtotime($feed['timer']) + $shortwait < time()) {
                // Time since last update longer than required short wait time, or not set timestamp
                $checkhead = true;
            }
        } else {
            // Either reports 'none' (bad server!) or not tested, only check after long wait time has passed
            if ($feed['timer'] == 0 || empty($feed['timer']) || $feed['timer'] == null || strtotime($feed['timer']) + $longwait < time()) {
                // Time since last update longer than required long wait time, or not set timestamp
                $checkhead = true;
            }
        }
        if ($checkhead == true) {
            // about time to make a new HEAD request
            if ($feed['reports'] == 'complete' || $feed['reports'] == 'etagonly') {
                // etag checking here
                $resp = SimpleHEAD::HEADrequest($feed['url']);
                if (!isset($feed['etag']) || empty($feed['etag']) || $feed['etag'] == null || !isset($resp['et']) || empty($resp['et']) || $resp['et'] == null) {
                    echo "Got no ETag to compare with; proceeding with download.\n";
                    $update = true;
                } elseif (isset($feed['etag']) && isset($resp['et']) && !empty($resp['et']) && $resp['et'] != null && $feed['etag'] == $resp['et']) {
                    echo "Cool, these ETags are equal! No need to update.\n";
                    $update = false;
                    // we can't check ALL the time!
                    $sql->write('feeds', array('timer' => mysql_time(time())), $feed['id']);
                    $ett = $resp['et'];
                    // I have to get this to the data writing bit somehow...
                } elseif (isset($feed['etag']) && isset($resp['et']) && !empty($resp['et']) && $feed['etag'] != null && $feed['etag'] != $resp['et']) {
                    echo "These ETags are different; proceeding with download.\n";
                    echo $feed['etag'] . '   -   ' . $resp['et'] . "\n";
                    $update = true;
                    $ett = $resp['et'];
                    // I have to get this to the data writing bit somehow...
                } else {
                    // Something I failed to think about?
                    die("This sure is an interesting error. (Check the ETag code of " . __FILE__ . " at " . __LINE__ . ".\n");
                }
                if ($feed['reports'] == 'complete') {
                    $lmm = $resp['lm'];
                    // don't forget to store this if we have it
                }
            } elseif ($feed['reports'] == 'lmonly') {
                // lm checking here
                $resp = SimpleHEAD::HEADrequest($feed['url']);
                if (isset($resp['lm']) && !empty($resp['lm'])) {
                    $lmm = strtotime($resp['lm']);
                }
                if (!isset($feed['lastmodified']) || strtotime($feed['lastmodified']) == 0 || !isset($resp['lm']) || empty($resp['lm'])) {
                    echo "Got no Last-Modified timestamp to compare with; proceeding with download.\n";
                    $update = true;
                } elseif (isset($feed['lastmodified']) && $lmm != 0 && strtotime($feed['lastmodified']) == $lmm) {
                    echo "Cool, these Last-Modified timestamps are equal! No need to update.\n";
                    $update = false;
                    // we can't check ALL the time!
                    $sql->write('feeds', array('timer' => mysql_time(time())), $feed['id']);
                } elseif (isset($feed['lastmodified']) && $lmm != 0 && strtotime($feed['lastmodified']) != $lmm) {
                    echo "These timestamps are different; proceeding with download.\n";
                    echo strtotime($feed['lastmodified']) . '   -   ' . $lmm . "\n";
                    $update = true;
                } else {
                    // Something I failed to think about?
                    die("This sure is an interesting error. (Check the Last-Modified code of " . __FILE__ . " at " . __LINE__ . ".\n");
                }
            } elseif ($feed['reports'] == 'none' || $feed['reports'] == null) {
                if ($feed['reports'] == null) {
                    ServerTestPackage::ServerReportingTest($feed['url'], $feed['id'], $sql);
                }
                $ett = null;
                // reset these before writing
                $lmm = null;
                // reset these before writing
                // no way to check if anything's new... we'll just have to download the whole thing
                $update = true;
            } else {
                // ambiguous database value for 'reports'
                die("Ambiguous database value for 'reports': feed['reports'] = {$feed['reports']}.\n");
            }
        } else {
            // from if($checkhead)
            // too soon to update, we'll just give out a little notice
            if ($feed['reports'] == 'complete' || $feed['reports'] == 'etagonly' || $feed['reports'] == 'lmonly') {
                // short wait time
                echo "LOL! Too soon d00d.\n" . Duration::toString(time() - strtotime($feed['timer'])) . " since last update. You just gotta wait " . Duration::toString(strtotime($feed['timer']) + $shortwait - time()) . " more.\n";
            } else {
                // long wait time
                echo "OMG! Too soon d00d.\n" . Duration::toString(time() - strtotime($feed['timer'])) . " since last update. You just gotta wait " . Duration::toString(strtotime($feed['timer']) + $longwait - time()) . " more.\n";
            }
        }
        // end if($checkhead)
        if ($update) {
            $rss =& new XML_RSS($feed['url']);
            $rss->parse();
            echo '<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset="utf-8" />
		<title>Test</title>
	</head>
	<body>
		<table>';
            printarr($rss->getChannelInfo());
            echo '		</table>
	</body>
</html>			
';
            // we've updated, now write a new timestamp
            if (isset($ett) && !empty($ett) && isset($lmm) && !empty($lmm)) {
                // Got both ETag and Last-Modified from server (bravo!)
                // write the current time, the ETag we got, and the Last-Modified timestamp we got
                $sql->write('feeds', array('timer' => mysql_time(time()), 'etag' => $ett, 'lastmodified' => mysql_time($lmm)), $feed['id']);
            } elseif (isset($ett) && !empty($ett)) {
                // Only got ETag from server
                // write the current time and the ETag we got
                $sql->write('feeds', array('timer' => mysql_time(time()), 'etag' => $ett), $feed['id']);
            } elseif (isset($lmm) && !empty($lmm)) {
                // Only got Last-Modified from server
                // write the current time and the Last-Modified timestamp we got
                $sql->write('feeds', array('timer' => mysql_time(time()), 'lastmodified' => mysql_time($lmm)), $feed['id']);
            } else {
                // Got no content information from server (bad server!)
                // just write the current time
                $sql->write('feeds', array('timer' => mysql_time(time())), $feed['id']);
            }
        }
    }
    // end main loop
}