예제 #1
0
<P>
<A CLASS="navlinks" HREF="week.php?<?php 
    echo $u_url;
    if ($thisyear) {
        echo "year={$thisyear}&month={$thismonth}&day={$thisday}";
    }
    echo $caturl . "&";
    ?>
friendly=1" TARGET="cal_printer_friendly"
onMouseOver="window.status = '<?php 
    etranslate("Generate printer-friendly version");
    ?>
'">[<?php 
    etranslate("Printer Friendly");
    ?>
]</A>

<?php 
    include "includes/trailer.php";
    ?>

<?php 
} else {
    dbi_close($c);
}
?>

</BODY>
</HTML>
예제 #2
0
/**
 * Prints the common trailer.
 *
 * @param bool $include_nav_links Should the standard navigation links be
 *                               included in the trailer?
 * @param bool $closeDb           Close the database connection when finished?
 * @param bool $disableCustom     Disable the custom trailer the administrator
 *                                has setup?  (This is useful for small popup
 *                                windows and pages being used in an iframe.)
 */
function print_trailer($include_nav_links = true, $closeDb = true, $disableCustom = false)
{
    global $CUSTOM_TRAILER, $c, $STARTVIEW;
    global $login, $user, $cat_id, $categories_enabled, $thisyear, $thismonth, $thisday, $DATE_FORMAT_MY, $WEEK_START, $DATE_FORMAT_MD, $readonly, $is_admin, $public_access, $public_access_can_add, $single_user, $use_http_auth, $login_return_path, $require_approvals, $is_nonuser_admin, $public_access_others, $allow_view_other, $views, $reports_enabled, $LAYER_STATUS, $nonuser_enabled, $groups_enabled, $fullname, $has_boss;
    if ($include_nav_links) {
        include_once "includes/trailer.php";
    }
    // Add custom trailer if enabled
    if ($CUSTOM_TRAILER == 'Y' && !$disableCustom && isset($c)) {
        $res = dbi_query("SELECT cal_template_text FROM webcal_report_template " . "WHERE cal_template_type = 'T' and cal_report_id = 0");
        if ($res) {
            if ($row = dbi_fetch_row($res)) {
                echo $row[0];
            }
            dbi_free_result($res);
        }
    }
    if ($closeDb) {
        if (isset($c)) {
            dbi_close($c);
        }
        unset($c);
    }
}
예제 #3
0
function do_redirect($url)
{
    global $SERVER_SOFTWARE, $_SERVER, $c;
    if (empty($SERVER_SOFTWARE)) {
        $SERVER_SOFTWARE = $_SERVER["SERVER_SOFTWARE"];
    }
    //echo "SERVER_SOFTWARE = $SERVER_SOFTWARE <br />\n"; exit;
    if (substr($SERVER_SOFTWARE, 0, 5) == "Micro") {
        echo "<?xml version=\"1.0\" encoding=\"utf8\"?>\n<!DOCTYPE html\n    PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n    \"DTD/xhtml1-transitional.dtd\">\n\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n<title>Redirect</title>\n" . "<meta http-equiv=\"refresh\" content=\"0; url={$url}\" />\n</head>\n<body>\n" . "Redirecting to.. <a href=\"" . $url . "\">here</a>.</body>\n</html>";
    } else {
        Header("Location: {$url}");
        echo "<?xml version=\"1.0\" encoding=\"utf8\"?>\n<!DOCTYPE html\n    PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n    \"DTD/xhtml1-transitional.dtd\">\n\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n\n<head>\n<title>Redirect</title>\n</head>\n<body>\n" . "Redirecting to ... <a href=\"" . $url . "\">here</a>.</body>\n</html>";
    }
    dbi_close($c);
    exit;
}
function do_redirect($url)
{
    global $_SERVER, $c, $SERVER_SOFTWARE, $SERVER_URL;
    // Replace any '&amp;' with '&' since we don't want that in the HTTP header.
    $url = str_replace('&amp;', '&', $url);
    if (empty($SERVER_SOFTWARE)) {
        $SERVER_SOFTWARE = $_SERVER['SERVER_SOFTWARE'];
    }
    // $SERVER_URL should end in '/', but we may not have it yet if we are
    // redirecting to the login.  If not, then pull it from the database.
    if (empty($SERVER_URL) && !empty($c)) {
        $res = dbi_query("SELECT cal_value FROM webcal_config " . "WHERE cal_setting = 'SERVER_URL'");
        if ($res) {
            if ($row = dbi_fetch_row($res)) {
                $SERVER_URL = $row[0];
            }
        }
        dbi_free_result($res);
    }
    // If we have the server URL, then use a full URL, which is technically
    // required (but all browsers accept relative URLs here).
    // BUT, only do this if our URL does not start with '/' because then
    // we could end up with a URL like:
    //   http://www.k5n.us/webcalendar/webcalendar/month.php
    if (!empty($SERVER_URL) && substr($url, 0, 1) != '/') {
        $url = $SERVER_URL . $url;
    }
    //echo "<pre>"; print_r ( debug_backtrace() ); echo "\n</pre>\n";
    //echo "URL: $url <br>"; exit;
    $meta = '';
    if (substr($SERVER_SOFTWARE, 0, 5) == 'Micro' || substr($SERVER_SOFTWARE, 0, 3) == 'WN/') {
        $meta = '
    <meta http-equiv="refresh" content="0; url=' . $url . '" />';
    } else {
        header('Location: ' . $url);
    }
    echo send_doctype('Redirect') . $meta . '
  </head>
  <body>
    Redirecting to.. <a href="' . $url . '">here</a>.
  </body>
</html>';
    dbi_close($c);
    exit;
}
예제 #5
0
function do_config($fileLoc)
{
    global $db_database, $db_host, $db_login, $db_password, $db_persistent, $db_type, $NONUSER_PREFIX, $phpdbiVerbose, $PROGRAM_DATE, $PROGRAM_NAME, $PROGRAM_URL, $PROGRAM_VERSION, $readonly, $run_mode, $settings, $single_user, $single_user_login, $TROUBLE_URL, $use_http_auth, $user_inc;
    $PROGRAM_VERSION = 'v1.2.7';
    $PROGRAM_DATE = '22 Feb 2013';
    $PROGRAM_NAME = 'WebCalendar ' . "{$PROGRAM_VERSION} ({$PROGRAM_DATE})";
    $PROGRAM_URL = 'http://www.k5n.us/webcalendar.php';
    $TROUBLE_URL = 'docs/WebCalendar-SysAdmin.html#trouble';
    // Open settings file to read.
    $settings = array();
    if (file_exists($fileLoc)) {
        $fd = @fopen($fileLoc, 'rb', true);
    }
    if (empty($fd) && defined('__WC_INCLUDEDIR')) {
        $fd = @fopen(__WC_INCLUDEDIR . '/settings.php', 'rb', true);
        if ($fd) {
            $fileLoc = __WC_INCLUDEDIR . '/settings.php';
        }
    }
    // If still empty.... use __FILE__.
    if (empty($fd)) {
        $testName = get_full_include_path("settings.php");
        $fd = @fopen($fileLoc, 'rb', true);
        if ($fd) {
            $fileLoc = $testName;
        }
    }
    if (empty($fd) || filesize($fileLoc) == 0) {
        // There is no settings.php file.
        // Redirect user to install page if it exists.
        if (file_exists('install/index.php')) {
            header('Location: install/index.php');
            exit;
        } else {
            die_miserable_death(translate('Could not find settings.php file...'));
        }
    }
    // We don't use fgets () since it seems to have problems with Mac-formatted
    // text files. Instead, we read in the entire file, and split the lines manually.
    $data = '';
    while (!feof($fd)) {
        $data .= fgets($fd, 4096);
    }
    fclose($fd);
    // Replace any combination of carriage return (\r) and new line (\n)
    // with a single new line.
    $data = preg_replace("/[\r\n]+/", "\n", $data);
    // Split the data into lines.
    $configLines = explode("\n", $data);
    for ($n = 0, $cnt = count($configLines); $n < $cnt; $n++) {
        $buffer = trim($configLines[$n], "\r\n ");
        if (preg_match('/^#|\\/\\*/', $buffer) || preg_match('/^<\\?/', $buffer) || preg_match('/^\\?>/', $buffer)) {
            // end PHP code
            continue;
        }
        if (preg_match('/(\\S+):\\s*(\\S+)/', $buffer, $matches)) {
            $settings[$matches[1]] = $matches[2];
        }
        // echo "settings $matches[1] => $matches[2]<br />";
    }
    $configLines = $data = '';
    // Extract db settings into global vars.
    $db_database = $settings['db_database'];
    $db_host = $settings['db_host'];
    $db_login = $settings['db_login'];
    $db_password = $settings['db_password'];
    $db_persistent = preg_match('/(1|yes|true|on)/i', $settings['db_persistent']) ? '1' : '0';
    $db_type = $settings['db_type'];
    // If no db settings, then user has likely started install but not yet
    // completed.  So, send them back to the install script.
    if (empty($db_type)) {
        if (file_exists('install/index.php')) {
            header('Location: install/index.php');
            exit;
        } else {
            die_miserable_death(translate('Incomplete settings.php file...'));
        }
    }
    // Use 'db_cachedir' if found, otherwise look for 'cachedir'.
    if (!empty($settings['db_cachedir'])) {
        dbi_init_cache($settings['db_cachedir']);
    } else {
        if (!empty($settings['cachedir'])) {
            dbi_init_cache($settings['cachedir']);
        }
    }
    if (!empty($settings['db_debug']) && preg_match('/(1|true|yes|enable|on)/i', $settings['db_debug'])) {
        dbi_set_debug(true);
    }
    foreach (array('db_type', 'db_host', 'db_login', 'db_password') as $s) {
        if (empty($settings[$s])) {
            die_miserable_death(str_replace('XXX', $s, translate('Could not find XXX defined in...')));
        }
    }
    // Allow special settings of 'none' in some settings[] values.
    // This can be used for db servers not using TCP port for connection.
    $db_host = $db_host == 'none' ? '' : $db_host;
    $db_password = $db_password == 'none' ? '' : $db_password;
    $readonly = preg_match('/(1|yes|true|on)/i', $settings['readonly']) ? 'Y' : 'N';
    if (empty($settings['mode'])) {
        $settings['mode'] = 'prod';
    }
    $run_mode = preg_match('/(dev)/i', $settings['mode']) ? 'dev' : 'prod';
    $phpdbiVerbose = $run_mode == 'dev';
    $single_user = preg_match('/(1|yes|true|on)/i', $settings['single_user']) ? 'Y' : 'N';
    if ($single_user == 'Y') {
        $single_user_login = $settings['single_user_login'];
    }
    if ($single_user == 'Y' && empty($single_user_login)) {
        die_miserable_death(str_replace('XXX', 'single_user_login', translate('You must define XXX in')));
    }
    $use_http_auth = preg_match('/(1|yes|true|on)/i', $settings['use_http_auth']) ? true : false;
    // Type of user authentication.
    $user_inc = $settings['user_inc'];
    // If sqlite, the db file is in the include directory
    if ($db_type == 'sqlite') {
        $db_database = get_full_include_path($db_database);
    }
    // Check the current installation version.
    // Redirect user to install page if it is different from stored value.
    // This will prevent running WebCalendar until UPGRADING.html has been
    // read and required upgrade actions completed.
    $c = @dbi_connect($db_host, $db_login, $db_password, $db_database, false);
    if ($c) {
        $rows = dbi_get_cached_rows('SELECT cal_value FROM webcal_config
       WHERE cal_setting = \'WEBCAL_PROGRAM_VERSION\'');
        if (!$rows) {
            // &amp; does not work here...leave it as &.
            header('Location: install/index.php?action=mismatch&version=UNKNOWN');
            exit;
        } else {
            $row = $rows[0];
            if (empty($row) || $row[0] != $PROGRAM_VERSION) {
                // &amp; does not work here...leave it as &.
                header('Location: install/index.php?action=mismatch&version=' . (empty($row) ? 'UNKNOWN' : $row[0]));
                exit;
            }
        }
        dbi_close($c);
    } else {
        // Must mean we don't have a settings.php file.
        // NOTE: if we get a connect error when running send_reminders.php,
        // we may want to show that error message here.
        // &amp; does not work here...leave it as &.
        header('Location: install/index.php?action=mismatch&version=UNKNOWN');
        exit;
    }
    // We can add extra 'nonuser' calendars such as a holiday, corporate,
    // departmental, etc. We need a unique prefix for these calendars
    // so we don't get them mixed up with real logins. This prefix should be
    // a maximum of 5 characters and should NOT change once set!
    $NONUSER_PREFIX = '_NUC_';
    if ($single_user != 'Y') {
        $single_user_login = '';
    }
}
예제 #6
0
function print_trailer($include_nav_links = true, $closeDb = true, $disableCustom = false)
{
    global $ALLOW_VIEW_OTHER, $c, $cat_id, $CATEGORIES_ENABLED, $CUSTOM_TRAILER, $DATE_FORMAT_MD, $DATE_FORMAT_MY, $DEMO_MODE, $DISPLAY_TASKS, $friendly, $DISPLAY_TASKS_IN_GRID, $fullname, $GROUPS_ENABLED, $has_boss, $is_admin, $is_nonuser, $is_nonuser_admin, $LAYER_STATUS, $login, $login_return_path, $MENU_DATE_TOP, $MENU_ENABLED, $NONUSER_ENABLED, $PUBLIC_ACCESS, $PUBLIC_ACCESS_CAN_ADD, $PUBLIC_ACCESS_FULLNAME, $PUBLIC_ACCESS_OTHERS, $readonly, $REPORTS_ENABLED, $REQUIRE_APPROVALS, $single_user, $STARTVIEW, $thisday, $thismonth, $thisyear, $use_http_auth, $user, $views, $WEEK_START;
    $ret = '';
    if ($include_nav_links && !$friendly) {
        if ($MENU_ENABLED == 'N' || $MENU_DATE_TOP == 'N') {
            $ret .= '<div id="dateselector">' . print_menu_dates() . '</div>';
        }
        if ($MENU_ENABLED == 'N') {
            include_once 'includes/trailer.php';
        }
    }
    $ret .= (empty($tret) ? '' : $tret) . ($CUSTOM_TRAILER == 'Y' && !$disableCustom && isset($c) ? load_template($login, 'T') : '');
    if ($closeDb) {
        if (isset($c)) {
            dbi_close($c);
        }
        unset($c);
    }
    // Only include version info if user is admin.  No need to publicize
    // version to would-be hackers.
    return $ret . ($is_admin ? "<!-- " . $GLOBALS['PROGRAM_NAME'] . "     " . $GLOBALS['PROGRAM_URL'] . " -->\n" : '') . ($DEMO_MODE == 'Y' ? '
    <p><a href="http://validator.w3.org/check?uri=referer">' . '<img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" ' . 'class="valid" /></a></p>' : '') . '
  </body>
</html>
';
}
예제 #7
0
/** Sends a redirect to the specified page.
 *
 * The database connection is closed and execution terminates in this function.
 *
 * <b>Note:</b> MS IIS/PWS has a bug in which it does not allow us to send a
 * cookie and a redirect in the same HTTP header.  When we detect that the web
 * server is IIS, we accomplish the redirect using meta-refresh.  See the
 * following for more info on the IIS bug:
 *
 * {@link http://www.faqts.com/knowledge_base/view.phtml/aid/9316/fid/4}
 *
 * @param string $url The page to redirect to.  In theory, this should be an
 *                    absolute URL, but all browsers accept relative URLs (like
 *                    "month.php").
 *
 * @global string   Type of webserver
 * @global array    Server variables
 * @global resource Database connection
 */
function do_redirect($url)
{
    global $SERVER_SOFTWARE, $_SERVER, $c;
    // Replace any '&amp;' with '&' since we don't want that in the HTTP
    // header.
    $url = str_replace('&amp;', '&', $url);
    if (empty($SERVER_SOFTWARE)) {
        $SERVER_SOFTWARE = $_SERVER["SERVER_SOFTWARE"];
    }
    //echo "SERVER_SOFTWARE = $SERVER_SOFTWARE <br />\n"; exit;
    if (substr($SERVER_SOFTWARE, 0, 5) == "Micro" || substr($SERVER_SOFTWARE, 0, 3) == "WN/") {
        echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html\n    PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n    \"DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n<head>\n<title>Redirect</title>\n" . "<meta http-equiv=\"refresh\" content=\"0; url={$url}\" />\n</head>\n<body>\n" . "Redirecting to.. <a href=\"" . $url . "\">here</a>.</body>\n</html>";
    } else {
        Header("Location: {$url}");
        //print "<javascript>window.location.href='index.php';</script>" ;
        echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html\n    PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n    \"DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n<head>\n<title>Redirect</title>\n</head>\n<body>\n" . "Redirecting to aa... <a href=\"" . $url . "\">here</a>.</body>\n</html>";
    }
    dbi_close($c);
    exit;
}