Location: PHPKode > scripts > Live - Calendar > option.php
<?php
function live_calendar_options(){
  global $wpdb;
  if (isset($_POST['enable_categories'])){
  		$display_upcoming_days = mysql_escape_string($_POST['display_upcoming_days']);

      if (mysql_escape_string($_POST['display_todays']) == 'on'){
          $disp_todays = 'true';
      }else{
          $disp_todays = 'false';
      }
      
      if (mysql_escape_string($_POST['display_upcoming']) == 'on'){
          $disp_upcoming = 'true';
      }else{
          $disp_upcoming = 'false';
      }
      
      if (mysql_escape_string($_POST['enable_categories']) == 'on'){
          $enable_categories = 'true';
      } else{
	    		$enable_categories = 'false';
	    }
	    if (mysql_escape_string($_POST['default_city']) == ''){
          $default_city = 'ShenZhen';
      } else{
	    		$default_city = mysql_escape_string($_POST['default_city']);
	    } 
	    if (mysql_escape_string($_POST['default_link']) == ''){
          $default_link = '#';
      } else{
	    		$default_link = mysql_escape_string($_POST['default_link']);
	    } 
	    if (mysql_escape_string($_POST['sidebar_list_num']) == ''){
          $sidebar_list_num = 10;
      } else{
	    		$sidebar_list_num = mysql_escape_string($_POST['sidebar_list_num']);
	    }
	    if (mysql_escape_string($_POST['event_title_width']) == ''){
          $event_title_width = 30;
      } else{
	    		$event_title_width = mysql_escape_string($_POST['event_title_width']);
	    }
	    if (mysql_escape_string($_POST['event_title_truncate']) == ''){
          $event_title_truncate = 30;
      } else{
	    		$event_title_truncate = mysql_escape_string($_POST['event_title_truncate']);
	    }
	    if (mysql_escape_string($_POST['sidebar_calendar_color']) == ''){
          $sidebar_calendar_color = '#666666';
      } else{
	    		$sidebar_calendar_color = mysql_escape_string($_POST['sidebar_calendar_color']);
	    }
	    if (mysql_escape_string($_POST['sidebar_calendar_fontcolor']) == ''){
          $sidebar_calendar_fontcolor = '#000000';
      } else{
	    		$sidebar_calendar_fontcolor = mysql_escape_string($_POST['sidebar_calendar_fontcolor']);
	    }
      
      $wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$default_city."' WHERE config_item='default_city'");
      $wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$default_link."' WHERE config_item='default_link'");
      $wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$disp_todays."' WHERE config_item='display_todays'");
      $wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$disp_upcoming."' WHERE config_item='display_upcoming'");
      $wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$display_upcoming_days."' WHERE config_item='display_upcoming_days'");
  		$wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$enable_categories."' WHERE config_item='enable_categories'");
  		$wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$sidebar_list_num."' WHERE config_item='sidebar_list_num'");
  		$wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$event_title_width."' WHERE config_item='event_title_width'");
  		$wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$event_title_truncate."' WHERE config_item='event_title_truncate'");
  		$wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$sidebar_calendar_color."' WHERE config_item='sidebar_calendar_color'");
  		$wpdb->get_results("UPDATE " . WP_LIVE_CALENDAR_CONFIG_TABLE . " SET config_value = '".$sidebar_calendar_fontcolor."' WHERE config_item='sidebar_calendar_fontcolor'");

  		echo "<div class=\"updated\"><p><strong>".__('Settings saved','live-calendar').".</strong></p></div>";
	}

  	 $default_city =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='default_city'"));
  	 $default_link =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='default_link'"));
  	 $display_todays =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_todays'"));
  	 $display_upcoming =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_upcoming'"));
  	 $display_upcoming_days =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_upcoming_days'"));
  	 $enable_categories =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='enable_categories'"));
  	 $sidebar_list_num =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='sidebar_list_num'"));
  	 $event_title_width =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='event_title_width'"));
		 $event_title_truncate =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='event_title_truncate'"));
		 $sidebar_calendar_color =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='sidebar_calendar_color'"));
   	 $sidebar_calendar_fontcolor =  $wpdb->get_var($wpdb->prepare("SELECT config_value FROM " . WP_LIVE_CALENDAR_CONFIG_TABLE . " WHERE config_item='sidebar_calendar_fontcolor'"));

     if ($display_todays == 'true'){
         $yes_disp_todays = 'selected="selected"';
     }else{
         $no_disp_todays = 'selected="selected"';
     }
     if ($display_upcoming == 'true'){
         $yes_disp_upcoming = 'selected="selected"';
     }else{
         $no_disp_upcoming = 'selected="selected"';
     }
  
     if ($enable_categories == 'true'){
         $yes_enable_categories = 'selected="selected"';
     }else{
         $no_enable_categories = 'selected="selected"';
     }
 
?>
<div class="wrap">
  <h2><?php _e('Calendar Options','live-calendar'); ?></h2>
  <form name="quoteform" id="quoteform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=live-calendar-options">
       <div id="linkadvanceddiv" class="postbox">
            <div style="float: left; width: 98%; clear: both;" class="inside">
                <table cellpadding="5" cellspacing="5">
                	<tr>
											<td><legend><?php _e('Default City','live-calendar'); ?>:</legend></td>
                      <td><input type="text" name="default_city" class="input" size="30" maxlength="30" value="<?php echo $default_city; ?>" /></td>
									</tr>
									<tr>
											<td><legend><?php _e('Default Link','live-calendar'); ?>:</legend></td>
                      <td><input type="text" name="default_link" class="input" size="60" maxlength="60" value="<?php echo $default_link; ?>" /></td>
									</tr>
                  <tr>
											<td><legend><?php _e('Display todays events?','live-calendar'); ?></legend></td>
                      <td><select name="display_todays">
															<option value="on" <?php echo $yes_disp_todays ?>><?php _e('Yes','live-calendar') ?></option>
															<option value="off" <?php echo $no_disp_todays ?>><?php _e('No','live-calendar') ?></option>
                            </select>
                      </td>
                  </tr>
                  <tr>
											<td><legend><?php _e('Display upcoming events?','live-calendar'); ?></legend></td>
                     	<td><select name="display_upcoming">
															<option value="on" <?php echo $yes_disp_upcoming ?>><?php _e('Yes','live-calendar') ?></option>
															<option value="off" <?php echo $no_disp_upcoming ?>><?php _e('No','live-calendar') ?></option>
                            </select>
				    								<?php _e('for','live-calendar'); ?> <input type="text" name="display_upcoming_days" value="<?php echo $display_upcoming_days ?>" size="1" maxlength="3" /> <?php _e('days into the future','live-calendar'); ?>
                       </td>
                  </tr>
                  <tr>
											<td><legend><?php _e('Show event categories?','live-calendar'); ?></legend></td>
                      <td><select name="enable_categories">
				                			<option value="on" <?php echo $yes_enable_categories ?>><?php _e('Yes','live-calendar') ?></option>
															<option value="off" <?php echo $no_enable_categories ?>><?php _e('No','live-calendar') ?></option>
                          </select>
                      </td>
                  </tr>
                  <tr>
											<td><legend><?php _e('Number of Recent events list?','live-calendar'); ?></legend></td>
                      <td><input type="text" name="sidebar_list_num" class="input" size="10" maxlength="10" value="<?php echo $sidebar_list_num; ?>" /></td>
                  </tr>
                  <tr>
											<td><legend><?php _e('Max characters of event title?','live-calendar'); ?></legend></td>
                      <td><input type="text" name="event_title_width" class="input" size="10" maxlength="10" value="<?php echo $event_title_width; ?>" /></td>
                  </tr>
                  <tr>
											<td><legend><?php _e('Max characters to truncate?','live-calendar'); ?></legend></td>
                      <td><input type="text" name="event_title_truncate" class="input" size="10" maxlength="10" value="<?php echo $event_title_truncate; ?>" /></td>
                  </tr>
                  <tr>
											<td><legend><?php _e('Background color of sidebar calendar?','live-calendar'); ?></legend></td>
                      <td><input type="text" name="sidebar_calendar_color" class="input" size="10" maxlength="10" value="<?php echo $sidebar_calendar_color; ?>" /></td>
                  </tr>
                  <tr>
											<td><legend><?php _e('Font color of sidebar calendar?','live-calendar'); ?></legend></td>
                      <td><input type="text" name="sidebar_calendar_fontcolor" class="input" size="10" maxlength="10" value="<?php echo $sidebar_calendar_fontcolor; ?>" /></td>
                  </tr>
                </table>
						</div>
            <div style="clear:both; height:1px;">&nbsp;</div>
	        </div>
          <input type="submit" name="save" class="button bold" value="<?php _e('Save','live-calendar'); ?> &raquo;" />
  </form>
  </div>
<?php
}
?>
Return current item: Live - Calendar