data = json_decode(get_option('one-hundred-cities-data')); $this->page = $page = add_options_page('100Cities', '100Cities', 'administrator', 'onehundredcities', array($this,'cities_page')); } function is_valid_url($url) { if($this->check_rss_exists($url)){ return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); } else { return false; } } function cities_page() { if ( $_SERVER["REQUEST_METHOD"] == "POST" ){ $div_array = array('float','block'); $data['gmaps'] = $this->just_numbers($_POST['gmaps']); $data['wikipedia'] = $this->just_numbers($_POST['wikipedia']); $data['panoramio'] = $this->just_numbers($_POST['panoramio']); $data['articles'] = $this->just_numbers($_POST['articles']); $data['weather'] = $this->just_numbers($_POST['weather']); $data['css'] = $this->just_numbers($_POST['defaultcss']); //Check for weird javascript POST params, it doesn't go into the database so... the user has to know what it is writing in it if($data['css'] != 1){ $new_css = preg_replace('/]*>(.*?)<\/script>/is', '', str_replace('\\','', $_POST['css'])); $css_url = dirname(__FILE__) . '/assets/100Cities.css'; //rewrites css file $fp = fopen($css_url, 'w'); fwrite($fp, $new_css); fclose($fp); } //Check it is a real feed $data['articles_feed'] = ""; if($this->is_valid_url($_POST['articles_feed'])){ $content = file_get_contents($_POST['articles_feed']); try { $rss = new SimpleXmlElement($content); if(isset($rss->channel->item) && $rss->channel->item->count() > 0){ $data['articles_feed'] = $_POST['articles_feed']; } } catch(Exception $e){ } } //Check the value is in array if(in_array($_POST['div'], $div_array)){ $data['div'] = $_POST['div']; } else { $data['div'] = 'block'; } $data['tags'] = $this->just_numbers($_POST['tags']); $data['categories'] = $this->just_numbers($_POST['categories']); $data['logo'] = $this->just_numbers($_POST['logo']); $data = json_encode($data); update_option('one-hundred-cities-data', $data); $this->data = json_decode(get_option('one-hundred-cities-data')); $updated = true; } ?>


" id="submitbutton" />