function amr_remove_array_level($compprop) { $newcompprop = array(); foreach ($compprop as $g => $v) { // remove one level $newcompprop = array_merge($newcompprop, $v); } $newcompprop = amr_sort_by_two_cols_asc('Column', 'Order', $newcompprop); return $newcompprop; }
function amr_ical_validate_list_options($i) { global $amr_options; if (isset($_POST['general'])) { if (is_array($_POST['general'][$i])) { foreach ($_POST['general'][$i] as $c => $v) { if (!empty($_POST['general'][$i][$c])) { switch ($c) { case 'Default Event URL': if (!filter_var($_POST['general'][$i][$c], FILTER_VALIDATE_URL)) { amr_invalid_url(); } else { $url = filter_var($_POST['general'][$i][$c], FILTER_SANITIZE_URL); $sticky_url = amr_make_sticky_url($url); if (!$sticky_url) { $amr_options['listtypes'][$i]['general'][$c] = $url; } else { $amr_options['listtypes'][$i]['general'][$c] = $sticky_url; } } break; case 'customHTMLstylefile': $custom_htmlstyle_file = esc_attr($_POST['general'][$i]['customHTMLstylefile']); if (!($custom_htmlstyle_file[0] === '/')) { $custom_htmlstyle_file = '/' . $custom_htmlstyle_file; } $uploads = wp_upload_dir(); if (!file_exists($uploads['basedir'] . $custom_htmlstyle_file)) { amr_invalid_file(); $amr_options['listtypes'][$i]['general']['customHTMLstylefile'] = ' '; } else { $amr_options['listtypes'][$i]['general']['customHTMLstylefile'] = $custom_htmlstyle_file; } break; default: $amr_options['listtypes'][$i]['general'][$c] = filter_var($_POST['general'][$i][$c], FILTER_SANITIZE_STRING); } } else { $amr_options['listtypes'][$i]['general'][$c] = ''; } } } else { echo 'Error in form - general array not found'; } } if (isset($_POST['limit'])) { if (is_array($_POST['limit'][$i])) { foreach ($_POST['limit'][$i] as $c => $v) { $amr_options['listtypes'][$i]['limit'][$c] = isset($_POST['limit'][$i][$c]) ? $_POST['limit'][$i][$c] : 11; } } else { echo 'Error in form - limit array not found'; } } if (isset($_POST['format'])) { if (is_array($_POST['format'][$i])) { foreach ($_POST['format'][$i] as $c => $v) { /* amr - how should we validate this ? accepting any input for now */ $amr_options['listtypes'][$i]['format'][$c] = isset($_POST['format'][$i][$c]) ? stripslashes_deep($_POST['format'][$i][$c]) : ''; } } else { echo 'Error in form - format array not found'; } } foreach ($amr_options['listtypes'][$i]['component'] as $k => $c) { if (isset($_POST['component'][$i][$k])) { $amr_options['listtypes'][$i]['component'][$k] = true; } else { $amr_options['listtypes'][$i]['component'][$k] = false; } } unset($amr_options['listtypes'][$i]['grouping']); if (isset($_POST['level'][1])) { $k = esc_attr($_POST['level']['1']); if (!($k === 'none')) { $amr_options['listtypes'][$i]['grouping'][$k] = '1'; } } if (isset($_POST['level'][2])) { $k = esc_attr($_POST['level']['2']); if (!($k === 'none')) { $amr_options['listtypes'][$i]['grouping'][$k] = '2'; } } if (isset($_POST['ColH'])) { if (is_array($_POST['ColH'][$i])) { foreach ($_POST['ColH'][$i] as $c => $v) { $amr_options['listtypes'][$i]['heading'][$c] = $v; } } // else echo 'Error in form - grouping array not found'; /* May not want any groupings ? } if (isset($_POST['CalP'])) { if (is_array($_POST['CalP'][$i])) { foreach ($_POST['CalP'][$i] as $c => $v) { if (is_array($v)) { foreach ($v as $p => $pv) { /*need to validate these */ switch ($p) { case 'Column': if (function_exists('filter_var')) { if (filter_var($pv, FILTER_VALIDATE_INT, array("options" => array("min_range" => 0, "max_range" => 20)))) { $amr_options['listtypes'][$i]['calprop'][$c][$p] = $pv; } else { $amr_options['listtypes'][$i]['calprop'][$c][$p] = 0; } } else { $amr_options['listtypes'][$i]['calprop'][$c][$p] = $pv; } break; case 'Order': if (function_exists('filter_var')) { if (filter_var($pv, FILTER_VALIDATE_INT, array("options" => array("min_range" => 0, "max_range" => 99)))) { $amr_options['listtypes'][$i]['calprop'][$c][$p] = $pv; } break; } else { $amr_options['listtypes'][$i]['calprop'][$c][$p] = $pv; } break; case 'Before': $amr_options['listtypes'][$i]['calprop'][$c][$p] = wp_kses($pv, amr_allowed_html()); break; case 'After': $amr_options['listtypes'][$i]['calprop'][$c][$p] = wp_kses($pv, amr_allowed_html()); break; } } } } } else { _e('Error in form - calprop array not found', 'amr-ical-events-list'); } } if (isset($_POST['ComP'])) { if (is_array($_POST['ComP'])) { foreach ($_POST['ComP'] as $c => $v) { /* eg c= summary */ if (is_array($v)) { foreach ($v as $p => $pv) { /*need to validate these */ switch ($p) { case 'Column': if (function_exists('filter_var')) { if (filter_var($pv, FILTER_VALIDATE_INT, array("options" => array("min_range" => 0, "max_range" => 20)))) { $amr_options['listtypes'][$i]['compprop'][$c][$p] = $pv; } else { $amr_options['listtypes'][$i]['compprop'][$c][$p] = 0; } break; } else { $amr_options['listtypes'][$i]['compprop'][$c][$p] = $pv; } break; case 'Order': if (function_exists('filter_var')) { if (filter_var($pv, FILTER_VALIDATE_INT, array("options" => array("min_range" => 0, "max_range" => 99)))) { $amr_options['listtypes'][$i]['compprop'][$c][$p] = $pv; } else { $amr_options['listtypes'][$i]['compprop'][$c][$p] = 0; } break; } else { $amr_options['listtypes'][$i]['compprop'][$c][$p] = $pv; } break; case 'Before': $bef = wp_kses($pv, amr_allowed_html()); $bef = wp_kses_stripslashes($bef); //if (stripos($bef, '\\"')) echo 'YES still there'; $bef = str_replace('\\"', '"', $bef); $amr_options['listtypes'][$i]['compprop'][$c][$p] = $bef; //if ($c == 'URL') echo 'TEST:'. $bef.' else '.$amr_options['listtypes'][$i]['compprop'][$c][$p]; break; case 'After': $amr_options['listtypes'][$i]['compprop'][$c][$p] = wp_kses_stripslashes(wp_kses($pv, amr_allowed_html())); break; } } } } $amr_options['listtypes'][$i]['compprop'] = amr_sort_by_two_cols_asc('Column', 'Order', $amr_options['listtypes'][$i]['compprop']); } else { echo 'Error in form - compprop array not found'; } } $result = update_option('amr-ical-events-list', $amr_options); return $result; }