コード例 #1
0
ファイル: template.php プロジェクト: jbogota/blog-king
 function draw_admin()
 {
     global $template, $getdate, $cal, $master_array, $is_loged_in;
     if ($is_loged_in == TRUE) {
         // Print Calendar Checkboxes
         $COLUMNS_TO_PRINT = 3;
         $column = 1;
         $filelist = availableCalendars('', '', '', true);
         foreach ($filelist as $file) {
             if ($column > $COLUMNS_TO_PRINT) {
                 $delete_table .= '</tr>';
                 $column = 1;
             }
             if ($column == 1) {
                 $delete_table .= '<tr>';
             }
             $cal_filename_tmp = getCalendarName($file);
             $cal_tmp = urlencode($file);
             $cal_displayname_tmp = str_replace("32", " ", $cal_filename_tmp);
             $delete_table .= '<td align="left"><input name="delete_calendar[]" value="' . $cal_tmp . '" type="checkbox" />' . $cal_displayname_tmp . '</td>';
             $column++;
         }
         // Print remaining empty columns if necessary
         $number_of_columns = count($filelist);
         while (gettype($number_of_columns / $COLUMNS_TO_PRINT) != "integer") {
             $delete_table .= '<td>&nbsp;</td>';
             $number_of_columns++;
         }
         $this->page = str_replace('{DELETE_TABLE}', $delete_table, $this->page);
     } else {
         $this->page = preg_replace('!<\\!-- switch logged_in on -->(.*)<\\!-- switch logged_in off -->!is', '', $this->page);
         $this->page = preg_replace('!<\\!-- switch logged_in2 on -->(.*)<\\!-- switch logged_in2 off -->!is', '', $this->page);
     }
 }
コード例 #2
0
    // Pull the display name off the URL.
    #	$cal_displaynames[] = substr(str_replace('32', ' ', basename($web_cal)), 0, -4);
    $cal_displaynames[] = substr(basename($web_cal), 0, -4);
    if (in_array($web_cal, $list_webcals)) {
        $web_cal = md5($phpiCal_config->salt . $web_cal);
    }
    $cals[] = urlencode($web_cal);
    $subscribe_path = $cal_webcalPrefix;
    // Add the webcal to the available calendars.
    $cal_filelist[] = $cal_httpPrefix;
}
// Process the local calendars.
if (count($local_cals) > 0) {
    $local_cals = availableCalendars($username, $password, $local_cals);
    foreach ($local_cals as $local_cal) {
        $cal_displaynames[] = str_replace('32', ' ', getCalendarName($local_cal));
    }
    $cal_filelist = array_merge($cal_filelist, $local_cals);
    $cals = array_merge($cals, array_map("urlencode", array_map("getCalendarName", $local_cals)));
    // Set the download and subscribe paths from the config, if there is
    // only one calendar being displayed and those paths are defined.
    if (count($local_cals) == 1) {
        $filename = $local_cals[0];
        $add_cpath = '';
        if (isset($cpath) && $cpath != '') {
            $add_cpath = "{$cpath}/";
        }
        if ($phpiCal_config->download_uri == '' && preg_match('/(^\\/|\\.\\.\\/)/', $filename) == 0) {
            $subscribe_path = 'webcal://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/' . $filename;
            $download_filename = $filename;
        } elseif ($phpiCal_config->download_uri != '') {
コード例 #3
0
            }
        }
    }
    if ($parse_file == true) {
        // We need to re-parse at least one calendar, so unset master_array
        unset($master_array);
    }
}
if ($parse_file) {
    $overlap_array = array();
    $uid_counter = 0;
}
$calnumber = 1;
foreach ($cal_filelist as $cal_key => $filename) {
    // Find the real name of the calendar.
    $actual_calname = getCalendarName($filename);
    if ($parse_file) {
        // Let's see if we're doing a webcal
        if (substr($filename, 0, 7) == 'http://' || substr($filename, 0, 8) == 'https://' || substr($filename, 0, 9) == 'webcal://') {
            $cal_webcalPrefix = str_replace(array('http://', 'https://'), 'webcal://', $filename);
            $cal_httpPrefix = str_replace(array('webcal://', 'https://'), 'http://', $filename);
            $cal_httpsPrefix = str_replace(array('http://', 'webcal://'), 'https://', $filename);
            $master_array['-4'][$calnumber]['webcal'] = 'yes';
            $actual_mtime = remote_filemtime($cal_httpPrefix);
            /*
             * We want to copy the remote calendar to a local temporary file,
             * because the current parser will read it twice:
             * - Once to get the timezone information
             * - And again to collect the remaining data
             * See: http://phpicalendar.net/forums/viewtopic.php?f=45&t=4140#p14451
             */
コード例 #4
0
function display_ical_list($cals, $pick = FALSE)
{
    global $cal, $ALL_CALENDARS_COMBINED, $current_view, $getdate, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames;
    // Print each calendar option.
    foreach ($cals as $cal_tmp) {
        // Format the calendar path for display.
        //
        // Only display the calendar name, replace all instances of "32" with " ",
        // and remove the .ics suffix.
        $cal_displayname_tmp = getCalendarName($cal_tmp);
        $cal_displayname_tmp = str_replace("32", " ", $cal_displayname_tmp);
        #overwrite the display name if we already have a real name
        if (is_numeric(array_search($cal_tmp, $cal_filelist))) {
            $cal_displayname_tmp = $cal_displaynames[array_search($cal_tmp, $cal_filelist)];
        } else {
            # pull the name from the $cal_tmp file
            $ifile = @fopen($cal_tmp, "r");
            if ($ifile == FALSE) {
                exit(error($lang['l_error_cantopen'], $cal_tmp));
            }
            while (!feof($ifile)) {
                $line = fgets($ifile, 1024);
                $line = trim($line);
                if (ereg("([^:]+):(.*)", $line, $regs)) {
                    $field = $regs[1];
                    $data = $regs[2];
                    $property = $field;
                    $prop_pos = strpos($property, ';');
                    if ($prop_pos !== false) {
                        $property = substr($property, 0, $prop_pos);
                    }
                    $property = strtoupper($property);
                    if ($property == "X-WR-CALNAME") {
                        $cal_displayname_tmp = $data;
                        break;
                    }
                }
                #stop reading if we find an event or timezone before there's a name
                if ($line == "BEGIN:VTIMEZONE" || $line == "BEGIN:VEVENT") {
                    break;
                }
            }
            echo "</pre>";
        }
        // If this is a webcal, add 'Webcal' to the display name.
        if (preg_match("/^(https?|webcal):\\/\\//i", $cal_tmp)) {
            $cal_displayname_tmp .= " Webcal";
        } else {
            // Strip path and .ics suffix.
            $cal_tmp = getCalendarName($cal_tmp);
            // Add calendar label.
            $cal_displayname_tmp .= " {$calendar_lang}";
        }
        // Encode the calendar path.
        $cal_encoded_tmp = urlencode($cal_tmp);
        // Display the option.
        //
        // The submitted calendar will be encoded, and always use http://
        // if it is a webcal. So that is how we perform the comparison when
        // trying to figure out if this is the selected calendar.
        if ($pick) {
            if (in_array($cal_encoded_tmp, explode(",", $cal)) || count($cals) == count(explode(",", $cal))) {
                $return .= "<option value=\"{$cal_encoded_tmp}\" selected=\"selected\">{$cal_displayname_tmp}</option>\n";
            } else {
                $return .= "<option value=\"{$cal_encoded_tmp}\">{$cal_displayname_tmp}</option>\n";
            }
        } else {
            $cal_httpPrefix_tmp = str_replace('webcal://', 'http://', $cal_tmp);
            if ($cal_httpPrefix_tmp == urldecode($cal)) {
                $return .= "<option value=\"{$current_view}.php?cal={$cal_encoded_tmp}&amp;getdate={$getdate}\" selected=\"selected\">{$cal_displayname_tmp}</option>";
            } else {
                $return .= "<option value=\"{$current_view}.php?cal={$cal_encoded_tmp}&amp;getdate={$getdate}\">{$cal_displayname_tmp}</option>";
            }
        }
    }
    // option to open all (non-web) calenders together
    if (!$pick) {
        if ($cal == $ALL_CALENDARS_COMBINED) {
            $return .= "<option value=\"{$current_view}.php?cal={$ALL_CALENDARS_COMBINED}&amp;getdate={$getdate}\" selected=\"selected\">{$all_cal_comb_lang}</option>";
        } else {
            $return .= "<option value=\"{$current_view}.php?cal={$ALL_CALENDARS_COMBINED}&amp;getdate={$getdate}\">{$all_cal_comb_lang}</option>";
        }
    }
    return $return;
}
コード例 #5
0
function display_ical_list($cals, $pick = FALSE)
{
    global $cal, $current_view, $getdate, $lang, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames, $list_webcals, $phpiCal_config, $master_array;
    // Print each calendar option.
    $return = '';
    $all_cals = false;
    if (count($cals) > 1) {
        $all_cals = true;
    }
    foreach ($cals as $name => $cal_tmp) {
        // Format the calendar path for display.
        //
        $cal_displayname_tmp = '';
        $search_idx = array_search($cal_tmp, $cal_filelist);
        $override_name = false;
        if (!is_numeric($name)) {
            $cal_displayname_tmp = $name;
            $override_name = true;
        } else {
            if (is_numeric($search_idx)) {
                $cal_displayname_tmp = $cal_displaynames[$search_idx];
            } else {
                if (substr($cal_tmp, 0, 7) == 'http://' || substr($cal_tmp, 0, 8) == 'https://' || substr($cal_tmp, 0, 9) == 'webcal://') {
                    $cal_tmp2 = str_replace('webcal://', 'http://', $cal_tmp);
                    $cal_tmp2 = str_replace('https://', 'http://', $cal_tmp2);
                    $num = 1;
                    foreach ($master_array[-4] as $master_cal) {
                        if ($master_cal['filename'] == $cal_tmp2) {
                            $cal_displayname_tmp = $master_array[-3][$num];
                            break;
                        }
                        $num++;
                    }
                } else {
                    # pull the name from the $cal_tmp file
                    $ifile = @fopen($cal_tmp, 'r');
                    if ($ifile == FALSE) {
                        exit(error($lang['l_error_cantopen'], $cal_tmp));
                    }
                    while (!feof($ifile)) {
                        $line = fgets($ifile, 1024);
                        $line = trim($line);
                        if (ereg("([^:]+):(.*)", $line, $regs)) {
                            $field = $regs[1];
                            $data = $regs[2];
                            $property = $field;
                            $prop_pos = strpos($property, ';');
                            if ($prop_pos !== false) {
                                $property = substr($property, 0, $prop_pos);
                            }
                            $property = strtoupper($property);
                            if ($property == "X-WR-CALNAME") {
                                $cal_displayname_tmp = stripslashes($data);
                                break;
                            }
                        }
                        #stop reading if we find an event or timezone before there's a name
                        if ($line == "BEGIN:VTIMEZONE" || $line == "BEGIN:VEVENT") {
                            break;
                        }
                    }
                    @fclose($ifile);
                }
            }
        }
        if (empty($cal_displayname_tmp)) {
            // Only display the calendar name, replace all instances of "32" with " ",
            // and remove the .ics suffix.
            $cal_displayname_tmp = getCalendarName($cal_tmp);
            #$cal_displayname_tmp = str_replace('32', ' ', $cal_displayname_tmp);
        }
        if (!$override_name) {
            // If this is a webcal, add 'Webcal' to the display name.
            if (preg_match("/^(https?|webcal):\\/\\//i", $cal_tmp)) {
                $cal_displayname_tmp .= " Webcal";
            } else {
                // Strip path and .ics suffix.
                $cal_tmp = getCalendarName($cal_tmp);
                // Add calendar label.
                $cal_displayname_tmp .= " {$calendar_lang}";
            }
        }
        // Encode the calendar path.
        $cal_encoded_tmp = urlencode($cal_tmp);
        if (in_array($cal_tmp, $list_webcals)) {
            $cal_encoded_tmp = md5($phpiCal_config->salt . $cal_tmp);
        }
        // Try to detect unselected calendars
        if (!in_array($cal_encoded_tmp, explode(",", $cal))) {
            $all_cals = false;
        }
        // Display the option.
        //
        // The submitted calendar will be encoded, and always use http://
        // if it is a webcal. So that is how we perform the comparison when
        // trying to figure out if this is the selected calendar.
        if ($pick) {
            if (in_array($cal_encoded_tmp, explode(",", $cal)) || count($cals) == count(explode(",", $cal))) {
                $return .= "<option value=\"{$cal_encoded_tmp}\" selected=\"selected\">{$cal_displayname_tmp}</option>\n";
            } else {
                $return .= "<option value=\"{$cal_encoded_tmp}\">{$cal_displayname_tmp}</option>\n";
            }
        } else {
            if ($cal_encoded_tmp == $cal || $cal_encoded_tmp == urldecode($cal)) {
                $return .= "<option value=\"{$current_view}.php?cal={$cal_encoded_tmp}&amp;getdate={$getdate}\" selected=\"selected\">{$cal_displayname_tmp}</option>";
            } else {
                $return .= "<option value=\"{$current_view}.php?cal={$cal_encoded_tmp}&amp;getdate={$getdate}\">{$cal_displayname_tmp}</option>";
            }
        }
    }
    // option to open all (non-web) calenders together
    if (!$pick) {
        if ($all_cals || $cal == $phpiCal_config->ALL_CALENDARS_COMBINED) {
            $return .= "<option value=\"{$current_view}.php?cal={$phpiCal_config->ALL_CALENDARS_COMBINED}&amp;getdate={$getdate}\" selected=\"selected\">{$all_cal_comb_lang}</option>";
        } else {
            $return .= "<option value=\"{$current_view}.php?cal={$phpiCal_config->ALL_CALENDARS_COMBINED}&amp;getdate={$getdate}\">{$all_cal_comb_lang}</option>";
        }
    }
    return $return;
}