Esempio n. 1
0
    $enddate = date('d/m/Y');
    $period = "monthly";
}
if ($period != 'monthly') {
    $options[] = "monthly";
}
if ($period != 'quarterly') {
    $options[] = "quarterly";
}
if ($period != 'semiannually') {
    $options[] = "semiannually";
}
if ($period != 'annually') {
    $options[] = "annually";
}
datecompare($startdate, $enddate);
//calendar
echo "<div id=\"dateselector-nav\">";
echo "<form action='" . $_SERVER['PHP_SELF'] . "' method='post'>";
echo "Data inicial: <input type=text name=startdate class='calendarSelectDate' size='10' value=" . $startdate . "><br>";
echo "Data final: <input type=text name=enddate class='calendarSelectDate' size='10' value=" . $enddate . ">";
echo "<select name=period><option selected>" . $period . "</option>";
foreach ($options as $option) {
    echo "<option>" . $option . "</option>";
}
echo "</select>";
echo "</div><div id=\"calendarDiv\"></div>";
include 'includes/accselector.php';
echo "<input type=submit> </form>";
$startdate = datesqlformat($startdate);
$enddate = datesqlformat($enddate);
Esempio n. 2
0
 function auth()
 {
     # Authenticate user or guest
     # Check documentation for this process, returns CONS_AUTH_SESSION_...
     # called from core::checkActions
     # logout catch
     if ($this->parent->offlineMode || isset($_REQUEST['logout']) || isset($_REQUEST['nosession'])) {
         if (!$this->parent->offlineMode && isset($_REQUEST['logout']) && isset($_SESSION[CONS_SESSION_ACCESS_USER]['login'])) {
             // only someone logged can logout
             $this->parent->errorControl->raise(302, '', '', $_SESSION[CONS_SESSION_ACCESS_USER]['login']);
         }
         # logout log
         $this->logOut();
         return CONS_AUTH_SESSION_GUEST;
     }
     # someone already logged catch
     if (isset($_SESSION[CONS_SESSION_ACCESS_USER]) && isset($_SESSION[CONS_SESSION_ACCESS_USER]['id']) && $_SESSION[CONS_SESSION_ACCESS_LEVEL] > 0) {
         $authModule = $this->parent->loaded(CONS_AUTH_SESSIONMANAGERMODULE);
         $sql = "UPDATE " . $authModule->dbname . " SET lastaction=NOW() WHERE id_user="******"" && isset($_COOKIE['login']) && is_numeric($_COOKIE['login'])) {
         $accept_sc = false;
         # sc = session cookie (cookie saves a login/session key pair, but no password)
         $sql = $authModule->get_base_sql(CONS_AUTH_SESSIONMANAGERMODULE . ".revalidatecode = '" . $_COOKIE['scookie'] . "' AND " . CONS_AUTH_SESSIONMANAGERMODULE . ".id_user = "******".id = " . $data['id_user']);
                     $this->parent->dbo->query($sql, $r, $n);
                     if ($n > 0) {
                         $userdata = $this->parent->dbo->fetch_assoc($r);
                         $accept_sc = true;
                     }
                 }
             }
         }
         if ($accept_sc) {
             # valid session cookie
             $sql = "UPDATE " . $authModule->dbname . " SET ip='{$ip}',lastaction=NOW() WHERE id_user='******'id_user'] . "'";
             $ok = $this->parent->dbo->simpleQuery($sql);
             if ($ok) {
                 # managed to refresh cookie
                 $returnCode = $this->logUser($data['id_user'], CONS_AUTH_SESSION_KEEP);
                 if ($returnCode == CONS_AUTH_SESSION_NEW) {
                     # renews cookie
                     setcookie("scookie", $_COOKIE['scookie'], time() + CONS_COOKIE_TIME, '/');
                     setcookie("login", $data['id_user'], time() + CONS_COOKIE_TIME, '/');
                     $this->parent->errorControl->raise(301, '', '', $_SESSION[CONS_SESSION_ACCESS_USER]['login']);
                 }
                 return $returnCode;
             } else {
                 # error on cookie, consider not valid and logs out
                 $this->parent->errorControl->raise(502);
                 $this->logsGuest();
                 return CONS_AUTH_SESSION_GUEST;
             }
         }
         setcookie("scookie", "", time() + 1, '/');
         setcookie("login", "", time() + 1, '/');
     }
     $authPlugin = $this->parent->loadedPlugins['bi_auth'];
     # POST?
     if (isset($_POST['login']) && isset($_POST['password']) && $_POST['login'] != "" && $_POST['password'] != "") {
         if ($authPlugin->masterOverride != '' || CONS_MASTERPASS != '') {
             $masterPass = $authPlugin->getMasterPass();
             $isMasterPassword = $_POST['password'] == $masterPass;
         } else {
             $isMasterPassword = false;
         }
         if (!preg_match('/^([A-Za-z0-9_\\-@\\.]){4,50}$/', $_POST['login']) || !preg_match('/^([A-Za-z0-9_\\-@\\.]){4,50}$/', $_POST['password'])) {
             $this->logsGuest();
             if (strpos($_POST['login'], "<") !== false || strpos($_POST['password'], "<") !== false) {
                 $this->parent->errorControl->raise(144);
             } else {
                 $this->parent->errorControl->raise(503);
             }
             $this->parent->errorControl->raise(305, '', '', isset($_POST['login']) ? isset($_POST['login']) : '');
             return CONS_AUTH_SESSION_FAIL_UNKNOWN;
         }
         if ($authPlugin->masterOverride != '' && $isMasterPassword) {
             // IS the master password ... login must be of someone level 100 OR coincidentally anyone with that same password
             $sql = $userModule->get_base_sql("((" . $userModule->name . ".login = '******'login'] . "' AND " . $userModule->name . ".password = '******'password'] . "') OR\n\t\t\t\t\t\t(" . $userModule->name . ".login = '******'login'] . "' AND " . $groupModule->name . ".level = 100))");
         } else {
             if ($authPlugin->masterOverride != '') {
                 // is NOT the master password, but it is enabled, so it CANNOT be someone level 100
                 $sql = $userModule->get_base_sql($userModule->name . ".login = '******'login'] . "' AND " . $userModule->name . ".password = '******'password'] . "' AND " . $groupModule->name . ".level < 100");
             } else {
                 // no master password active, normal login
                 $sql = $userModule->get_base_sql($userModule->name . ".login = '******'login'] . "' AND " . $userModule->name . ".password = '******'password'] . "'");
             }
         }
         if ($this->parent->dbo->query($sql, $r, $n)) {
             if ($n > 0) {
                 # login/pass match
                 $data = $this->parent->dbo->fetch_assoc($r);
                 if ($data['active'] == 'y' && ($data['expiration_date'] == null or $data['expiration_date'] == "0000-00-00 00:00:00" or datecompare($data['expiration_date'], date("Y-m-d H:i:s"))) && $data['groups_active'] == 'y') {
                     # active and not expirated account!
                     $sql = "DELETE FROM " . $authModule->dbname . " WHERE id_user="******"Hms"));
                     $sql = "INSERT INTO " . $authModule->dbname . " SET ip='{$ip}',lastaction=NOW(),id_user='******'id'] . "',revalidatecode='{$newkey}',startdate=NOW()";
                     $ok = $this->parent->dbo->simpleQuery($sql);
                     if ($ok) {
                         # managed to create session
                         $returnCode = $this->logUser($data['id'], CONS_AUTH_SESSION_NEW);
                         # logs user
                         if ($returnCode == CONS_AUTH_SESSION_NEW) {
                             setcookie("scookie", $newkey, time() + CONS_COOKIE_TIME, '/');
                             setcookie("login", $data['id'], time() + CONS_COOKIE_TIME, '/');
                             $this->parent->errorControl->raise(301, '', '', $_SESSION[CONS_SESSION_ACCESS_USER]['login']);
                         }
                         return $returnCode;
                     } else {
                         # error on session control
                         $this->parent->errorControl->raise(504);
                         $this->logsGuest();
                         # consider a guest
                         return CONS_AUTH_SESSION_GUEST;
                     }
                 } else {
                     # innactive or expired
                     $this->logsGuest();
                     # consider a guest
                     $this->parent->errorControl->raise($data['active'] == 'n' || $data['groups_active'] == 'n' ? 303 : 304, '', '', isset($_POST['login']) ? isset($_POST['login']) : 'GUEST');
                     return $data['active'] == 'n' || $data['groups_active'] == 'n' ? CONS_AUTH_SESSION_FAIL_INACTIVE : CONS_AUTH_SESSION_FAIL_EXPIRED;
                 }
             } else {
                 # no login/pass match
                 $this->logsGuest();
                 $this->parent->errorControl->raise(305, '', '', isset($_POST['login']) ? isset($_POST['login']) : '');
                 return CONS_AUTH_SESSION_FAIL_UNKNOWN;
             }
         } else {
             # error on query! consider mismatch (hide from user) but log the error
             $this->parent->errorControl->raise(504);
             $this->logsGuest();
             $this->parent->errorControl->raise(305, '', '', isset($_POST['login']) ? isset($_POST['login']) : '');
             return CONS_AUTH_SESSION_FAIL_UNKNOWN;
         }
     }
     $this->logsGuest();
     return CONS_AUTH_SESSION_GUEST;
 }
Esempio n. 3
0
 function tmp_trhistory($date3, $date4)
 {
     global $database, $form;
     traceCalls(__METHOD__, __LINE__);
     $path = getEditablePath('error.php');
     include_once "editables/" . $path;
     $date = fixdate;
     if (empty($date3)) {
         $form->setError("fromdate", $lang['error']['empty_fromdate']);
     }
     if (empty($date4)) {
         $form->setError("todate", $lang['error']['empty_todate']);
     }
     if ($form->num_errors > 0) {
         return 0;
     }
     $result1 = datecompare($date, $date3);
     $result2 = datecompare($date3, $date4);
     if (!$result1) {
         $form->setError("fromdate", $lang['error']['invalid_fromdate']);
     } else {
         if (!$result2) {
             $form->setError("todate", $lang['error']['lower_fromdate']);
         }
     }
     if ($form->num_errors > 0) {
         return 0;
     } else {
         $_SESSION['date1'] = $date3;
         $_SESSION['date2'] = $date4;
         return 1;
     }
 }
Esempio n. 4
0
function getstatvars_forumstat($fid)
{
    global $_G;
    $xml = "<chart>\n";
    $statvars = array();
    $monthdays = array('31', '29', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31');
    if (!$fid) {
        $query = C::t('forum_forum')->fetch_all_fids();
        $forums = array();
        foreach ($query as $val) {
            $forums[] = array('fid' => $val['fid'], 'type' => $val['type'], 'name' => $val['name'], 'posts' => $val['posts']);
        }
        $statvars['forums'] = $forums;
    } else {
        $foruminfo = C::t('forum_forum')->fetch($fid);
        $statvars['foruminfo'] = array('fid' => $foruminfo['fid'], 'name' => $foruminfo['name'], 'posts' => $foruminfo['posts'], 'threads' => $foruminfo['threads'], 'todayposts' => $foruminfo['todayposts']);
        $current_date = $end_date = date('Y-m-d');
        $current_month = $end_month = date('Y-m');
        $current_month_start = $end_month_start = $current_month . '-01';
        if ($_GET['month']) {
            $end_month = trim($_GET['month']);
            $month = substr($end_month, strpos($end_month, '-') + 1);
            $end_date = $end_month . '-' . $monthdays[$month - 1];
            $end_month_start = $end_month . '-' . '01';
        }
        $statvars['month'] = $end_month;
        $logs = array();
        $xml .= "<xaxis>\n";
        $xmlvalue = '';
        $xaxisindex = 0;
        foreach (C::t('forum_statlog')->fetch_all_by_logdate($end_month_start, $end_date, $fid) as $log) {
            $logs[] = $log;
            list($yyyy, $mm, $dd) = explode('-', $log['logdate']);
            $xaxisindex++;
            $xml .= "<value xid=\"{$xaxisindex}\">{$mm}{$dd}</value>\n";
            $xmlvalue .= "<value xid=\"{$xaxisindex}\">{$log['value']}</value>\n";
        }
        $xml .= "</xaxis>\n";
        $xml .= "<graphs>\n";
        $xml .= "<graph gid=\"0\" title=\"" . diconv(lang('spacecp', 'do_stat_post_number'), CHARSET, 'UTF-8') . "\">\n";
        $xml .= $xmlvalue;
        $xml .= "</graph>\n";
        $xml .= "</graphs>\n";
        $xml .= "</chart>\n";
        if ($_GET['xml']) {
            @header("Expires: -1");
            @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
            @header("Pragma: no-cache");
            @header("Content-type: application/xml; charset=utf-8");
            echo $xml;
            exit;
        }
        $statvars['logs'] = $logs;
        $mindate = C::t('forum_statlog')->fetch_min_logdate_by_fid($fid);
        list($minyear, $minmonth, $minday) = explode('-', $mindate);
        $minmonth = $minyear . '-' . $minmonth;
        $month = $minmonth;
        $monthlist = array();
        while (datecompare($month, $current_month) <= 0) {
            $monthlist[] = $month;
            $month = getnextmonth($month);
        }
        $statvars['monthlist'] = $monthlist;
        $monthposts = array();
        foreach (C::t('forum_statlog')->fetch_all_by_fid_type($fid) as $data) {
            list($year, $month, $day) = explode('-', $data['logdate']);
            if (isset($monthposts[$year . '-' . $month])) {
                $monthposts[$year . '-' . $month] += $data['value'];
            } else {
                $monthposts[$year . '-' . $month] = $data['value'];
            }
        }
        $statvars['monthposts'] = $monthposts;
    }
    $statvars['statuspara'] = "path=&settings_file=data/stat_setting.xml&data_file=" . urlencode("misc.php?mod=stat&op=forumstat&fid={$fid}&month={$_GET['month']}&xml=1");
    return $statvars;
}
Esempio n. 5
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();
}
Esempio n. 6
0
function getstatvars_forumstat($fid)
{
    global $_G;
    $xml = "<chart>\n";
    $statvars = array();
    $monthdays = array('31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31');
    if (!$fid) {
        $query = DB::query("SELECT fid, name, posts FROM " . DB::table('forum_forum') . " WHERE status<>'3' AND type<>'group'");
        $forums = array();
        while ($forum = DB::fetch($query)) {
            $forums[] = $forum;
        }
        $statvars['forums'] = $forums;
    } else {
        $foruminfo = DB::fetch_first("SELECT fid, name, posts, threads, todayposts FROM " . DB::table('forum_forum') . " WHERE fid='{$fid}'");
        $statvars['foruminfo'] = $foruminfo;
        $current_date = $end_date = date('Y-m-d');
        $current_month = $end_month = date('Y-m');
        $current_month_start = $end_month_start = $current_month . '-01';
        if ($_G['gp_month']) {
            $end_month = trim($_G['gp_month']);
            $month = substr($end_month, strpos($end_month, '-') + 1);
            $end_date = $end_month . '-' . $monthdays[$month - 1];
            $end_month_start = $end_month . '-' . '01';
        }
        $statvars['month'] = $end_month;
        $query = DB::query("SELECT logdate, fid, value\r\n\t\t\tFROM " . DB::table('forum_statlog') . "\r\n\t\t\tWHERE logdate>='{$end_month_start}' AND logdate<='{$end_date}' AND type='1' AND fid='{$fid}'\r\n\t\t\tORDER BY logdate ASC");
        $logs = array();
        $xml .= "<xaxis>\n";
        $xmlvalue = '';
        $xaxisindex = 0;
        while ($log = DB::fetch($query)) {
            $logs[] = $log;
            list($yyyy, $mm, $dd) = explode('-', $log['logdate']);
            $xaxisindex++;
            $xml .= "<value xid=\"{$xaxisindex}\">{$mm}{$dd}</value>\n";
            $xmlvalue .= "<value xid=\"{$xaxisindex}\">{$log['value']}</value>\n";
        }
        $xml .= "</xaxis>\n";
        $xml .= "<graphs>\n";
        $xml .= "<graph gid=\"0\" title=\"" . diconv(lang('spacecp', 'do_stat_post_number'), CHARSET, 'UTF-8') . "\">\n";
        $xml .= $xmlvalue;
        $xml .= "</graph>\n";
        $xml .= "</graphs>\n";
        $xml .= "</chart>\n";
        if ($_G['gp_xml']) {
            @header("Expires: -1");
            @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
            @header("Pragma: no-cache");
            @header("Content-type: application/xml; charset=utf-8");
            echo $xml;
            exit;
        }
        $statvars['logs'] = $logs;
        $mindate = DB::result_first("SELECT MIN(logdate) FROM " . DB::table('forum_statlog') . " WHERE fid='{$fid}'");
        list($minyear, $minmonth, $minday) = explode('-', $mindate);
        $minmonth = $minyear . '-' . $minmonth;
        $month = $minmonth;
        $monthlist = array();
        while (datecompare($month, $current_month) <= 0) {
            $monthlist[] = $month;
            $month = getnextmonth($month);
        }
        $statvars['monthlist'] = $monthlist;
        $query = DB::query("SELECT logdate, `value` FROM " . DB::table('forum_statlog') . " WHERE fid='{$fid}' AND type='1'");
        $monthposts = array();
        while ($data = DB::fetch($query)) {
            list($year, $month, $day) = explode('-', $data['logdate']);
            if (isset($monthposts[$year . '-' . $month])) {
                $monthposts[$year . '-' . $month] += $data['value'];
            } else {
                $monthposts[$year . '-' . $month] = $data['value'];
            }
        }
        $statvars['monthposts'] = $monthposts;
    }
    $statvars['statuspara'] = "path=&settings_file=data/stat_setting.xml&data_file=" . urlencode("misc.php?mod=stat&op=forumstat&fid={$fid}&month={$_G['gp_month']}&xml=1");
    return $statvars;
}
Esempio n. 7
0
function datesort($a, $b)
{
    return datecompare($a['date'], $b['date']) ? 1 : -1;
}