Update of /cvsroot/phpicalendar/phpicalendar/functions/init In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11887/functions/init Added Files: configs.php cpaths.php date_range.php sanitize.php set_error_reporting.php Log Message: add new files --- NEW FILE: configs.php --- <?php // Pull in the configuration and some functions. include_once(BASE.'default_config.php'); if (is_file(BASE.'config.inc.php')){ include_once(BASE.'config.inc.php'); foreach($configs as $key=>$value) $phpiCal_config->setProperty($key, $value); } // Set the cookie URI. if ($phpiCal_config->cookie_uri == '') { $phpiCal_config->setProperty('cookie_uri', $_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'], '/') ).'phpicalendar' ); } if (isset($_COOKIE[$phpiCal_config->cookie_uri]) && !isset($_POST['unset'])) { $phpicalendar = unserialize(stripslashes($_COOKIE[$cookie_name])); if (isset($phpicalendar['cookie_language'])) $phpiCal_config->setProperty('language', $phpicalendar['cookie_language']); if (isset($phpicalendar['cookie_calendar'])) $phpiCal_config->setProperty('default_cal_check', $phpicalendar['cookie_calendar']); if (isset($phpicalendar['cookie_cpath'])) $phpiCal_config->setProperty('default_cpath_check', $phpicalendar['cookie_cpath']); if (isset($phpicalendar['cookie_view'])) $phpiCal_config->setProperty('default_view', $phpicalendar['cookie_view']); if (isset($phpicalendar['cookie_style']) && is_dir(BASE.'templates/'.$phpicalendar['cookie_style'].'/')){ $phpiCal_config->setProperty('template', $phpicalendar['cookie_style']); } if (isset($phpicalendar['cookie_startday'])) $phpiCal_config->setProperty('week_start_day', $phpicalendar['cookie_startday']); if (isset($phpicalendar['cookie_time'])) $phpiCal_config->setProperty('day_start', $phpicalendar['cookie_time']); } # language support # default to english and overwrite other strings as available unset($lang); include_once(BASE.'languages/english.inc.php'); $language = strtolower($phpiCal_config->language); $lang_file = BASE.'languages/'.$language.'.inc.php'; if (is_file($lang_file)) { include_once($lang_file); } $template = $phpiCal_config->template; $fillTime = $phpiCal_config->day_start; $day_array = array (); while ($fillTime < $phpiCal_config->day_end) { array_push ($day_array, $fillTime); preg_match ('/([0-9]{2})([0-9]{2})/', $fillTime, $dTime); $fill_h = $dTime[1]; $fill_min = $dTime[2]; $fill_min = sprintf('%02d', $fill_min + $phpiCal_config->gridLength); if ($fill_min == 60) { $fill_h = sprintf('%02d', ($fill_h + 1)); $fill_min = '00'; } $fillTime = $fill_h . $fill_min; } /* echo "<pre>xx"; print_r($configs); print_r($phpiCal_config); echo "</pre>"; #die; */ --- NEW FILE: cpaths.php --- <?php #cpath modifies the calendar path based on the url or cookie values. This allows you to run multiple calendar subsets from a single phpicalendar installation. Operations on cpath are largely hidden from the end user. if ($phpiCal_config->calendar_path == '') { $calendar_path = BASE.'calendars'; }else $calendar_path = $phpiCal_config->calendar_path; $cpath = ''; #initialize cpath to prevent later undef warnings. if(isset($_REQUEST['cpath'])&& $_REQUEST['cpath'] !=''){ $cpath = str_replace('..','',$_REQUEST['cpath']); $calendar_path .= "/$cpath"; # $tmp_dir .= "/$cpath"; }elseif(isset($phpiCal_config->default_cpath_check) && $phpiCal_config->default_cpath_check !='' ){ $cpath = str_replace('..','',$default_cpath_check); $calendar_path .= "/$cpath"; # $tmp_dir .= "/$cpath"; } #these need cpath to be set #set up specific template folder for a particular cpath if (isset($user_template["$cpath"])){ $template = $user_template["$cpath"]; } #set up specific webcals for a particular cpath if (isset($phpiCal_config->more_webcals) && is_array($phpiCal_config->more_webcals[$cpath])){ $list_webcals = array_merge($phpiCal_config->list_webcals, $phpiCal_config->more_webcals["$cpath"]); } --- NEW FILE: date_range.php --- <?php if (!isset($getdate)) { if (isset($_GET['getdate']) && ($_GET['getdate'] !== '')) { $getdate = $_GET['getdate']; } else { $getdate = date('Ymd', time() + $second_offset); } } preg_match ("/([0-9]{4})([0-9]{2})([0-9]{2})/", $getdate, $day_array2); $this_day = $day_array2[3]; $this_month = $day_array2[2]; $this_year = $day_array2[1]; # set bounds on master_array # mktime int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] ) $start_month = $this_month - 1; $start_year = $this_year; $end_month = $this_month + 1; $end_year = $this_year; if ($this_month == 1){ $start_month = 12; $start_year--; } if ($this_month == 12){ $end_month = 1; $end_year++; } switch ($current_view){ case 'month': case 'week': case 'day': $mArray_begin = mktime (0,0,0,$start_month,21,($start_year)); $mArray_end = mktime (0,0,0,$end_month,12,($end_year)); break; default: $mArray_begin = mktime (0,0,0,12,21,($this_year - 1)); $mArray_end = mktime (0,0,0,1,12,($this_year + 1)); } --- NEW FILE: sanitize.php --- <?php /** * Sanitizes variables and arrays in a recursive manner * * This method was created as a result of strip_tags() happening on an array * would destroy the contents of the array. Thus, in order to avoid this from * happening we need checks to see if something is an array and to process * it as such. * * The only sanitizing this method provides is stripping non-allowed tags. * * @author Christopher Weldon <cw...@ta...> * @param mixed $value Value to be sanitized * @return mixed */ function recursiveSanitize($value) { if (is_array($value)) { $valmod = array(); foreach ($value as $key => $subval) { if (is_array($subval)) { $subval = recursiveSanitize($subval); } else { $subval = strip_tags($subval); } $valmod[$key] = $subval; } $value = $valmod; } else { $value = strip_tags($value); } return $value; } if (!isset($_SERVER) && isset($HTTP_SERVER_VARS)) { $_SERVER = &$HTTP_SERVER_VARS; } foreach ($_REQUEST as $key=>$val){ switch ($key){ case 'event_data': # modify this to allow or disallow different HTML tags in event popups $allowed = "<p><br><b><i><em><a><img><div><span><ul><ol><li><h1><h2><h3><h4><h5><h6><hr><em><strong><small><table><tr><td><th>"; $val = strip_tags($val,$allowed); break; default: # cpath $val = recursiveSanitize($val); } $_REQUEST[$key] = $val; } foreach ($_POST as $key=>$val){ switch ($key){ case 'action': $actions = array('login','logout','addupdate','delete'); if (!in_array($val,$actions)) $val = ''; break; case 'date': case 'time': if (!is_numeric($val)) $val = ''; break; default: $val = recursiveSanitize($val); } $_POST[$key] = $val; } foreach ($_GET as $key=>$val){ switch ($key){ case 'cal': if (!is_array($val)){ $val = strip_tags($val); $_GET['cal'] = strip_tags($val); }else{ unset ($_GET['cal']); foreach($val as $cal){ $_GET['cal'][]= strip_tags($cal); } } break; case 'getdate': if (!is_numeric($val)) $val = ''; break; default: $val = recursiveSanitize($val); } if ($key != 'cal') $_GET[$key] = $val; } foreach ($_COOKIE as $key=>$val){ switch ($key){ case 'time': if (!is_numeric($val)) $val = ''; break; default: $val = recursiveSanitize($val); } $_COOKIE[$key] = $val; } ?> --- NEW FILE: set_error_reporting.php --- <?php /* set error reporting config boolean $verbose_errors = false by default */ // uncomment when developing, comment for shipping version error_reporting (E_ERROR | E_WARNING | E_PARSE); #error_reporting(0); // Older versions of PHP do not define $_SERVER. Define it here instead. |