Пример #1
0
 function onCron($isDay = false)
 {
     # cron Triggered, isDay or isHour
     ###### -> Construct should add this module to the onCron array
     if ($isDay) {
         // delete week old entries (select data, detect files, delete files, delete data)
         $core =& $this->parent;
         $undoModule = $this->parent->loaded($this->moduleRelation);
         $sql = "SELECT id, files FROM " . $undoModule->dbname . " WHERE files<>'' AND data<NOW() - INTERVAL 1 WEEK";
         $core->dbo->query($sql, $r, $n);
         if ($n > 0) {
             for ($c = 0; $c < $n; $c++) {
                 list($id, $files) = $core->dbo->fetch_row($r);
                 $files = @unserialize($files);
                 if ($files) {
                     foreach ($files as $file) {
                         if (is_file(CONS_FMANAGER . "_undodata/" . $file)) {
                             @unlink(CONS_FMANAGER . "_undodata/" . $file);
                         }
                     }
                 }
             }
         }
         $core->dbo->simpleQuery("DELETE FROM " . $undoModule->dbname . " WHERE data<NOW() - INTERVAL 1 WEEK");
         # Find orphan files and delete them
         $lastWeek = date("Y-m-d") . " 00:00:00";
         $lastWeek = datecalc($lastWeek, 0, 0, -7);
         $lastWeek = tomktime($lastWeek);
         $files = listFiles(CONS_FMANAGER . "_undodata/", '@^(.*)$@', true);
         foreach ($files as $file) {
             $ft = filemtime(CONS_FMANAGER . "_undodata/" . $file);
             if ($ft < $lastWeek) {
                 @unlink(CONS_FMANAGER . "_undodata/" . $file);
             } else {
                 break;
             }
             // the list is ordered by date, so the first not to match means none will
         }
     }
 }
Пример #2
0
        continue;
    }
    $sql = $module->get_base_sql('', '', $itemsPerModule);
    $hasCategory = $hasCategory || isset($category[$rssId]) && $category[$rssId] != "";
    $this->dbo->query($sql, $r, $n);
    $dateField = "";
    foreach ($module->fields as $fname => &$field) {
        if ($field[CONS_XML_TIPO] == CONS_TIPO_DATETIME && isset($field[CONS_XML_TIMESTAMP])) {
            $dateField = $fname;
        }
    }
    $ppage = new CKTemplate($this->template);
    $ppage->tbreak($ilt[$rssId]);
    for ($c = 0; $c < $n; $c++) {
        $dados = $this->dbo->fetch_assoc($r);
        $rssItem = array("title" => $dados[$it[$rssId]], "description" => $dados[$idesc[$rssId]], "date" => $dateField != "" ? gmdate("D, d M Y H:i:s", tomktime($dados[$dateField])) . " GMT" : $NOWdate, "link" => $ppage->techo($dados));
        if (!isset($category[$rssId]) || $category[$rssId] != "") {
            if ($hasCategory) {
                $rssItem['category'] = $dados[$category[$rssId]];
            }
        }
        $mylist[] = $rssItem;
    }
    $rssId++;
}
function datesort($a, $b)
{
    return datecompare($a['date'], $b['date']) ? 1 : -1;
}
uksort($mylist, "datesort");
$obj = $rssTemplate->get("_itens");
Пример #3
0
function echoCalendar(&$containerTP, $width = 0, $month = 0, $year = 0, $highlights = array(), $dayborder = 0, $prevquery = "", $nextquery = "", $divname = "inlinecalendar")
{
    /*
      width should be divisible by 7
      highlights is an array, each with the following:
     	'day' => # day
     	'title' => title on the cell (if nothing, will use the day #)
     	'link' => link if click on the cell (if nothing, no link)
     	'class' => (optional) class for the cell
      dayborder is the number in pixels of border (+margin +padding) you will use on each cell
    */
    $tp = new CKTemplate($containerTP);
    if (!is_file(CONS_PATH_SETTINGS . "defaults/calendar.html")) {
        return "echoCalendar: File not found";
    }
    $tp->fetch(CONS_PATH_SETTINGS . "defaults/calendar.html");
    if ($month == 0) {
        $month = date("m");
    }
    if ($year == 0) {
        $year = date("Y");
    }
    $width = 7 * floor($width / 7);
    $widthDay = floor($width / 7) - 2 * $dayborder;
    $month = (int) $month;
    $year = (int) $year;
    if ($year < 100) {
        $year += 2000;
    }
    if ($month < 10) {
        $month = "0" . $month;
    }
    $initDay = $year . "-" . $month . "-01";
    $endDate = datecalc($initDay, 0, 1);
    $monthLine = $tp->get("_line");
    $dayTp = $tp->get("_day");
    $temp = "";
    // <-- main
    $tempL = "";
    // <-- a line
    $column = date("w", tomktime($initDay));
    // where this month starts
    $today = date("Y-m-d");
    $daysOnPreviousMonth = $column;
    while ($daysOnPreviousMonth > 0) {
        $tempL .= $dayTp->techo(array('class' => 'calendarDayEmpty', "title" => "&nbsp;", "widthday" => $widthDay));
        $daysOnPreviousMonth--;
    }
    while (datecompare($endDate, $initDay)) {
        // while we are within the month (loop will increase initDay)
        $isWeekend = $column == 0 || $column == 6;
        $isToday = $initDay == $today;
        $day = substr($initDay, 8, 2);
        // the following line will put the appropriate class on the day depending on start/end of the project, weekend or deadline
        $output = array("class" => $isToday ? "calendarDayToday" : ($isWeekend ? "calendarDayWeekend" : "calendarDayNormal"), "title" => (int) $day, "widthday" => $widthDay);
        // now we check if we have a highlight
        foreach ($highlights as $high) {
            if ($high['day'] == $day) {
                $output['class'] = isset($high['class']) && $high['class'] != '' ? $high['class'] : "calendarDayHighlight";
                $output['title'] = isset($high['title']) ? $high['title'] : (int) $day;
                if (isset($high['link']) && $high['link'] != '') {
                    $output['title'] = "<a href=\"" . $high['link'] . "\">" . $output['title'] . "</a>";
                }
            }
        }
        $tempL .= $dayTp->techo($output);
        if ($column == 6) {
            // end of a line
            $temp .= $monthLine->techo(array("_day" => $tempL));
            // <-- echo line
            $tempL = "";
        }
        $column++;
        if ($column >= 7) {
            $column = 0;
        }
        $initDay = datecalc($initDay, 0, 0, 1);
    }
    if ($column != 0) {
        // we might not have finished the last line ... check it:
        for ($column = $column; $column < 7; $column++) {
            $tempL .= $dayTp->techo(array('class' => 'calendarDayEmpty', "title" => "", "widthday" => $widthDay));
        }
        $temp .= $monthLine->techo(array("_day" => $tempL));
        // <-- echo line
        $tempL = "";
    }
    $tp->assign("width", $width);
    $tp->assign("month", $month);
    $tp->assign("year", $year);
    $tp->assign("widthday", $widthDay);
    $tp->assign("_line", $temp);
    $tp->assign("calendar", $divname);
    if ($prevquery != '' && $nextquery != '') {
        $tp->assign("ajaxcommandprev", $prevquery);
        $tp->assign("ajaxcommandnext", $nextquery);
    } else {
        $tp->assign("_prevnext");
    }
    return $tp->techo();
}
Пример #4
0
function fd($date, $mask = "d/m/Y")
{
    # Simple interface to format datetimes with ADOdb.
    if (strlen($date) > 0 && $date != "0000-00-00" && $date != "0000-00-00 00:00:00") {
        return adodb_date($mask, tomktime($date));
    }
    return "";
}