prefix . "wpgmza"; $wpgmza_tblname_maps = $wpdb->prefix . "wpgmza_maps"; $wpgmza_tblname_poly = $wpdb->prefix . "wpgmza_polygon"; $wpgmza_tblname_polylines = $wpdb->prefix . "wpgmza_polylines"; $wpgmza_version = "5.14"; $wpgmza_p_version = "5.14"; $wpgmza_t = "basic"; add_action('admin_head', 'wpgmaps_head'); add_action('admin_footer', 'wpgmaps_reload_map_on_post'); register_activation_hook( __FILE__, 'wpgmaps_activate' ); register_deactivation_hook( __FILE__, 'wpgmaps_deactivate' ); add_action('init', 'wpgmaps_init'); add_action('admin_menu', 'wpgmaps_admin_menu'); add_filter('widget_text', 'do_shortcode'); $debug_start = (float) array_sum(explode(' ',microtime())); function wpgmaps_activate() { global $wpdb; global $wpgmza_version; $table_name = $wpdb->prefix . "wpgmza"; $table_name_maps = $wpdb->prefix . "wpgmza_maps"; delete_option("WPGMZA"); wpgmaps_handle_db(); $wpgmza_data = get_option("WPGMZA"); if (!$wpgmza_data) { // load first map as an example map (i.e. if the user has not installed this plugin before, this must run $res_maps = $wpdb->get_results("SELECT * FROM $table_name_maps"); $wpdb->show_errors(); if (!$res_maps) { $rows_affected = $wpdb->insert( $table_name_maps, array( "map_title" => "My first map", "map_start_lat" => "51.5081290", "map_start_lng" => "-0.1280050", "map_width" => "600", "map_height" => "400", "map_width_type" => "px", "map_height_type" => "px", "map_start_location" => "51.5081290,-0.1280050", "map_start_zoom" => "1", "directions_enabled" => '1', "default_marker" => "0", "alignment" => "0", "styling_enabled" => "0", "styling_json" => "", "active" => "0", "type" => "1", "kml" => "", "fusion" => "", "bicycle" => "2", "traffic" => "2", "dbox" => "1", "dbox_width" => "250", "listmarkers" => "0", "listmarkers_advanced" => "0", "order_markers_by" => "1", "order_markers_choice" => "2", "show_user_location" => "0", "ugm_enabled" => "0", "ugm_access" => "0", "mass_marker_support" => "1") ); } } else { $rows_affected = $wpdb->insert( $table_name_maps, array( "map_start_lat" => "".$wpgmza_data['map_start_lat']."", "map_start_lng" => "".$wpgmza_data['map_start_lng']."", "map_title" => "My Map", "map_width" => "".$wpgmza_data['map_width']."", "map_height" => "".$wpgmza_data['map_height']."", "map_width_type" => "".$wpgmza_data['map_width_type']."", "map_height_type" => "".$wpgmza_data['map_height_type']."", "map_start_location" => "".$wpgmza_data['map_start_lat'].",".$wpgmza_data['map_start_lng']."", "map_start_zoom" => "".$wpgmza_data['map_start_zoom']."", "default_marker" => "".$wpgmza_data['map_default_marker']."", "type" => "".$wpgmza_data['map_type']."", "alignment" => "".$wpgmza_data['map_align']."", "styling_enabled" => "0", "styling_json" => "", "active" => "0", "kml" => "", "fusion" => "", "directions_enabled" => "".$wpgmza_data['directions_enabled']."", "bicycle" => "".$wpgmza_data['bicycle']."", "traffic" => "".$wpgmza_data['traffic']."", "dbox" => "".$wpgmza_data['dbox']."", "dbox_width" => "".$wpgmza_data['dbox_width']."", "listmarkers" => "".$wpgmza_data['listmarkers']."", "listmarkers_advanced" => "".$wpgmza_data['listmarkers_advanced']."", "order_markers_by" => "".$wpgmza_data['order_markers_by']."", "order_markers_choice" => "".$wpgmza_data['order_markers_choice']."", "show_user_location" => "".$wpgmza_data['show_user_location']."", "ugm_enabled" => "".$wpgmza_data['ugm_enabled']."", "ugm_access" => "".$wpgmza_data['ugm_access']."", "mass_marker_support" => "1" ) ); delete_option("WPGMZA"); } // load first marker as an example marker $results = $wpdb->get_results("SELECT * FROM $table_name WHERE `map_id` = '1'"); if (!$results) { $rows_affected = $wpdb->insert( $table_name, array( 'map_id' => '1', 'address' => 'London', 'lat' => '51.5081290', 'lng' => '-0.1280050', 'pic' => '', 'link' => '', 'icon' => '', 'anim' => '', 'title' => '', 'infoopen' => '', 'description' => '') ); } //wpgmza_cURL_response("activate"); //check to see if you have write permissions to the plugin folder (version 2.2) if (!wpgmaps_check_permissions()) { wpgmaps_permission_warning(); } else { wpgmaps_update_all_xml_file(); } } function wpgmaps_deactivate() { /* wpgmza_cURL_response("deactivate"); */ } function wpgmaps_init() { wp_enqueue_script("jquery"); $plugin_dir = basename(dirname(__FILE__))."/languages/"; load_plugin_textdomain( 'wp-google-maps', false, $plugin_dir ); } function wpgmaps_reload_map_on_post() { if (isset($_POST['wpgmza_savemap'])){ $res = wpgmza_get_map_data($_GET['map_id']); $wpgmza_lat = $res->map_start_lat; $wpgmza_lng = $res->map_start_lng; $wpgmza_width = $res->map_width; $wpgmza_height = $res->map_height; $wpgmza_width_type = $res->map_width_type; $wpgmza_height_type = $res->map_height_type; $wpgmza_map_type = $res->type; if (!$wpgmza_map_type || $wpgmza_map_type == "" || $wpgmza_map_type == "1") { $wpgmza_map_type = "ROADMAP"; } else if ($wpgmza_map_type == "2") { $wpgmza_map_type = "SATELLITE"; } else if ($wpgmza_map_type == "3") { $wpgmza_map_type = "HYBRID"; } else if ($wpgmza_map_type == "4") { $wpgmza_map_type = "TERRAIN"; } else { $wpgmza_map_type = "ROADMAP"; } $start_zoom = $res->map_start_zoom; if ($start_zoom < 1 || !$start_zoom) { $start_zoom = 5; } if (!$wpgmza_lat || !$wpgmza_lng) { $wpgmza_lat = "51.5081290"; $wpgmza_lng = "-0.1280050"; } ?> lat; $wpgmza_lng = $res->lng; $wpgmza_map_type = "ROADMAP"; $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); ?> map_start_lat; $wpgmza_lng = $res->map_start_lng; $wpgmza_width = $res->map_width; $wpgmza_height = $res->map_height; $wpgmza_width_type = $res->map_width_type; $wpgmza_height_type = $res->map_height_type; $wpgmza_map_type = $res->type; if (!$wpgmza_map_type || $wpgmza_map_type == "" || $wpgmza_map_type == "1") { $wpgmza_map_type = "ROADMAP"; } else if ($wpgmza_map_type == "2") { $wpgmza_map_type = "SATELLITE"; } else if ($wpgmza_map_type == "3") { $wpgmza_map_type = "HYBRID"; } else if ($wpgmza_map_type == "4") { $wpgmza_map_type = "TERRAIN"; } else { $wpgmza_map_type = "ROADMAP"; } $start_zoom = $res->map_start_zoom; if ($start_zoom < 1 || !$start_zoom) { $start_zoom = 5; } if (!$wpgmza_lat || !$wpgmza_lng) { $wpgmza_lat = "51.5081290"; $wpgmza_lng = "-0.1280050"; } ?> map_start_lat; $wpgmza_lng = $res->map_start_lng; $wpgmza_width = $res->map_width; $wpgmza_height = $res->map_height; $wpgmza_width_type = $res->map_width_type; $wpgmza_height_type = $res->map_height_type; $wpgmza_map_type = $res->type; if (!$wpgmza_map_type || $wpgmza_map_type == "" || $wpgmza_map_type == "1") { $wpgmza_map_type = "ROADMAP"; } else if ($wpgmza_map_type == "2") { $wpgmza_map_type = "SATELLITE"; } else if ($wpgmza_map_type == "3") { $wpgmza_map_type = "HYBRID"; } else if ($wpgmza_map_type == "4") { $wpgmza_map_type = "TERRAIN"; } else { $wpgmza_map_type = "ROADMAP"; } $start_zoom = $res->map_start_zoom; if ($start_zoom < 1 || !$start_zoom) { $start_zoom = 5; } if (!$wpgmza_lat || !$wpgmza_lng) { $wpgmza_lat = "51.5081290"; $wpgmza_lng = "-0.1280050"; } ?> formatOutput = true; $channel_main = $dom->createElement('markers'); $channel = $dom->appendChild($channel_main); $table_name = $wpdb->prefix . "wpgmza"; // PREVIOUS VERSION HANDLING if (function_exists('wpgmza_register_pro_version')) { $prov = get_option("WPGMZA_PRO"); $wpgmza_pro_version = $prov['version']; $results = $wpdb->get_results( " SELECT * FROM $table_name WHERE `map_id` = '$mapid' " ); } else { $results = $wpdb->get_results( " SELECT * FROM $table_name WHERE `map_id` = '$mapid' " ); } foreach ( $results as $result ) { $id = $result->id; $address = stripslashes($result->address); $description = stripslashes($result->description); $pic = $result->pic; if (!$pic) { $pic = ""; } $icon = $result->icon; if (!$icon) { $icon = ""; } $link_url = $result->link; if ($link_url) { } else { $link_url = ""; } $lat = $result->lat; $lng = $result->lng; $anim = $result->anim; $infoopen = $result->infoopen; $mtitle = stripslashes($result->title); $map_id = $result->map_id; $channel = $channel_main->appendChild($dom->createElement('marker')); $title = $channel->appendChild($dom->createElement('marker_id')); $title->appendChild($dom->CreateTextNode($id)); $title = $channel->appendChild($dom->createElement('map_id')); $title->appendChild($dom->CreateTextNode($map_id)); $title = $channel->appendChild($dom->createElement('title')); $title->appendChild($dom->CreateTextNode($mtitle)); $title = $channel->appendChild($dom->createElement('address')); $title->appendChild($dom->CreateTextNode($address)); $desc = $channel->appendChild($dom->createElement('desc')); $desc->appendChild($dom->CreateTextNode($description)); $desc = $channel->appendChild($dom->createElement('pic')); $desc->appendChild($dom->CreateTextNode($pic)); $desc = $channel->appendChild($dom->createElement('icon')); $desc->appendChild($dom->CreateTextNode($icon)); $desc = $channel->appendChild($dom->createElement('linkd')); $desc->appendChild($dom->CreateTextNode($link_url)); $bd = $channel->appendChild($dom->createElement('lat')); $bd->appendChild($dom->CreateTextNode($lat)); $bd = $channel->appendChild($dom->createElement('lng')); $bd->appendChild($dom->CreateTextNode($lng)); $bd = $channel->appendChild($dom->createElement('anim')); $bd->appendChild($dom->CreateTextNode($anim)); $bd = $channel->appendChild($dom->createElement('infoopen')); $bd->appendChild($dom->CreateTextNode($infoopen)); } if (is_multisite()) { global $blog_id; @$dom->save(WP_PLUGIN_DIR.'/'.plugin_basename(dirname(__FILE__)).'/'.$blog_id.'-'.$mapid.'markers.xml'); } else { // PREVIOUS VERSION HANDLING if (function_exists('wpgmza_register_pro_version')) { $prov = get_option("WPGMZA_PRO"); $wpgmza_pro_version = $prov['version']; @$dom->save(WP_PLUGIN_DIR.'/'.plugin_basename(dirname(__FILE__)).'/'.$mapid.'markers.xml'); } else { @$dom->save(WP_PLUGIN_DIR.'/'.plugin_basename(dirname(__FILE__)).'/'.$mapid.'markers.xml'); } } } function wpgmaps_update_all_xml_file() { global $wpdb; $table_name = $wpdb->prefix . "wpgmza_maps"; $results = $wpdb->get_results("SELECT `id` FROM $table_name WHERE `active` = 0"); foreach ( $results as $result ) { $map_id = $result->id; wpgmaps_update_xml_file($map_id); } } function wpgmaps_action_callback_basic() { global $wpdb; global $wpgmza_tblname; global $wpgmza_p; $check = check_ajax_referer( 'wpgmza', 'security' ); $table_name = $wpdb->prefix . "wpgmza"; if ($check == 1) { if ($_POST['action'] == "add_marker") { $rows_affected = $wpdb->insert( $table_name, array( 'map_id' => $_POST['map_id'], 'address' => $_POST['address'], 'lat' => $_POST['lat'], 'lng' => $_POST['lng'], 'infoopen' => '', 'description' => '', 'title' => '', 'anim' => '', 'link' => '', 'icon' => '', 'pic' => '' ) ); //exit( var_dump( $wpdb->last_query ) ); wpgmaps_update_xml_file($_POST['map_id']); echo wpgmza_return_marker_list($_POST['map_id']); } if ($_POST['action'] == "edit_marker") { $cur_id = $_POST['edit_id']; $rows_affected = $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET address = %s, lat = %f, lng = %f WHERE id = %d", $_POST['address'], $_POST['lat'], $_POST['lng'], $cur_id) ); wpgmaps_update_xml_file($_POST['map_id']); echo wpgmza_return_marker_list($_POST['map_id']); } if ($_POST['action'] == "delete_marker") { $marker_id = $_POST['marker_id']; $wpdb->query( " DELETE FROM $wpgmza_tblname WHERE `id` = '$marker_id' LIMIT 1 " ); wpgmaps_update_xml_file($_POST['map_id']); echo wpgmza_return_marker_list($_POST['map_id']); } } die(); // this is required to return a proper result } function wpgmaps_load_maps_api() { wp_enqueue_script('google-maps' , 'http://maps.google.com/maps/api/js?sensor=true' , false , '3'); } function wpgmaps_tag_basic( $atts ) { global $wpgmza_current_map_id; extract( shortcode_atts( array( 'id' => '1' ), $atts ) ); global $short_code_active; $wpgmza_current_map_id = $atts['id']; $res = wpgmza_get_map_data($atts['id']); $short_code_active = true; //$wpgmza_data = get_option('WPGMZA'); $map_align = $res->alignment; $map_width_type = $res->map_width_type; $map_height_type = $res->map_height_type; if (!isset($map_width_type)) { $map_width_type == "px"; } if (!isset($map_height_type)) { $map_height_type == "px"; } if ($map_width_type == "%" && intval($res->map_width) > 100) { $res->map_width = 100; } if ($map_height_type == "%" && intval($res->map_height) > 100) { $res->map_height = 100; } if (!$map_align || $map_align == "" || $map_align == "1") { $map_align = "float:left;"; } else if ($map_align == "2") { $map_align = "margin-left:auto !important; margin-right:auto; !important; align:center;"; } else if ($map_align == "3") { $map_align = "float:right;"; } else if ($map_align == "4") { $map_align = ""; } $map_style = "style=\"display:block; overflow:auto; width:".$res->map_width."".$map_width_type."; height:".$res->map_height."".$map_height_type."; $map_align\""; $ret_msg .= "
 
"; return $ret_msg; } function wpgmaps_get_plugin_url() { if ( !function_exists('plugins_url') ) return get_option('siteurl') . '/wp-content/plugins/' . plugin_basename(dirname(__FILE__)); return plugins_url(plugin_basename(dirname(__FILE__))); } function wpgmaps_head() { global $wpgmza_tblname_maps; if (isset($_POST['wpgmza_savemap'])){ global $wpdb; //var_dump($_POST); $map_id = attribute_escape($_POST['wpgmza_id']); $map_title = attribute_escape($_POST['wpgmza_title']); $map_height = attribute_escape($_POST['wpgmza_height']); $map_width = attribute_escape($_POST['wpgmza_width']); $map_width_type = attribute_escape($_POST['wpgmza_map_width_type']); $map_height_type = attribute_escape($_POST['wpgmza_map_height_type']); $map_start_location = attribute_escape($_POST['wpgmza_start_location']); $map_start_zoom = intval($_POST['wpgmza_start_zoom']); $type = intval($_POST['wpgmza_map_type']); $alignment = intval($_POST['wpgmza_map_align']); $order_markers_by = intval($_POST['wpgmza_order_markers_by']); $order_markers_choice = intval($_POST['wpgmza_order_markers_choice']); $show_user_location = intval($_POST['wpgmza_show_user_location']); $directions_enabled = intval($_POST['wpgmza_directions']); $bicycle_enabled = intval($_POST['wpgmza_bicycle']); $traffic_enabled = intval($_POST['wpgmza_traffic']); $dbox = intval($_POST['wpgmza_dbox']); $dbox_width = attribute_escape($_POST['wpgmza_dbox_width']); $listmarkers = intval($_POST['wpgmza_listmarkers']); $listmarkers_advanced = intval($_POST['wpgmza_listmarkers_advanced']); $gps = explode(",",$map_start_location); $map_start_lat = $gps[0]; $map_start_lng = $gps[1]; $map_default_marker = $_POST['upload_default_marker']; $kml = attribute_escape($_POST['wpgmza_kml']); $fusion = attribute_escape($_POST['wpgmza_fusion']); $data['map_default_starting_lat'] = $map_start_lat; $data['map_default_starting_lng'] = $map_start_lng; $data['map_default_height'] = $map_height; $data['map_default_width'] = $map_width; $data['map_default_zoom'] = $map_start_zoom; $data['map_default_type'] = $type; $data['map_default_alignment'] = $alignment; $data['map_default_order_markers_by'] = $order_markers_by; $data['map_default_order_markers_choice'] = $order_markers_choice; $data['map_default_show_user_location'] = $show_user_location; $data['map_default_directions'] = $directions_enabled; $data['map_default_bicycle'] = $bicycle_enabled; $data['map_default_traffic'] = $traffic_enabled; $data['map_default_dbox'] = $dbox; $data['map_default_dbox_width'] = $dbox_width; $data['map_default_listmarkers'] = $listmarkers; $data['map_default_listmarkers_advanced'] = $listmarkers_advanced; $data['map_default_marker'] = $map_default_marker; $data['map_default_width_type'] = $map_width_type; $data['map_default_height_type'] = $map_height_type; $rows_affected = $wpdb->query( $wpdb->prepare( "UPDATE $wpgmza_tblname_maps SET map_title = %s, map_width = %s, map_height = %s, map_start_lat = %f, map_start_lng = %f, map_start_location = %s, map_start_zoom = %d, default_marker = %s, type = %d, alignment = %d, order_markers_by = %d, order_markers_choice = %d, show_user_location = %d, directions_enabled = %d, kml = %s, bicycle = %d, traffic = %d, dbox = %d, dbox_width = %s, listmarkers = %d, listmarkers_advanced = %d, fusion = %s, map_width_type = %s, map_height_type = %s WHERE id = %d", $map_title, $map_width, $map_height, $map_start_lat, $map_start_lng, $map_start_location, $map_start_zoom, $map_default_marker, $type, $alignment, $order_markers_by, $order_markers_choice, $show_user_location, $directions_enabled, $kml, $bicycle_enabled, $traffic_enabled, $dbox, $dbox_width, $listmarkers, $listmarkers_advanced, $fusion, $map_width_type, $map_height_type, $map_id) ); //echo $wpdb->print_error(); update_option('WPGMZA_SETTINGS', $data); echo "
"; _e("Your settings have been saved.","wp-google-maps"); echo "
"; } else if (isset($_POST['wpgmza_save_maker_location'])){ global $wpdb; global $wpgmza_tblname; $mid = attribute_escape($_POST['wpgmaps_marker_id']); $wpgmaps_marker_lat = attribute_escape($_POST['wpgmaps_marker_lat']); $wpgmaps_marker_lng = attribute_escape($_POST['wpgmaps_marker_lng']); $rows_affected = $wpdb->query( $wpdb->prepare( "UPDATE $wpgmza_tblname SET lat = %s, lng = %s WHERE id = %d", $wpgmaps_marker_lat, $wpgmaps_marker_lng, $mid) ); //update_option('WPGMZA', $data); echo "
"; _e("Your marker location has been saved.","wp-google-maps"); echo "
"; } else if (isset($_POST['wpgmza_save_poly'])){ global $wpdb; global $wpgmza_tblname_poly; $mid = attribute_escape($_POST['wpgmaps_map_id']); $wpgmaps_polydata = attribute_escape($_POST['wpgmza_polygon']); $linecolor = attribute_escape($_POST['poly_line']); $fillcolor = attribute_escape($_POST['poly_fill']); $opacity = attribute_escape($_POST['poly_opacity']); $rows_affected = $wpdb->query( $wpdb->prepare( "INSERT INTO $wpgmza_tblname_poly SET map_id = %d, polydata = %s, linecolor = %s, fillcolor = %s, opacity = %s ", $mid, $wpgmaps_polydata, $linecolor, $fillcolor, $opacity ) ); echo "
"; _e("Your polygon has been created.","wp-google-maps"); echo "
"; } else if (isset($_POST['wpgmza_edit_poly'])){ global $wpdb; global $wpgmza_tblname_poly; $mid = attribute_escape($_POST['wpgmaps_map_id']); $pid = attribute_escape($_POST['wpgmaps_poly_id']); $wpgmaps_polydata = attribute_escape($_POST['wpgmza_polygon']); $linecolor = attribute_escape($_POST['poly_line']); $fillcolor = attribute_escape($_POST['poly_fill']); $opacity = attribute_escape($_POST['poly_opacity']); $rows_affected = $wpdb->query( $wpdb->prepare( "UPDATE $wpgmza_tblname_poly SET polydata = %s, linecolor = %s, fillcolor = %s, opacity = %s WHERE `id` = %d" , $wpgmaps_polydata, $linecolor, $fillcolor, $opacity, $pid ) ); echo "
"; _e("Your polygon has been saved.","wp-google-maps"); echo "
"; } else if (isset($_POST['wpgmza_save_polyline'])){ global $wpdb; global $wpgmza_tblname_polylines; $mid = attribute_escape($_POST['wpgmaps_map_id']); $wpgmaps_polydata = attribute_escape($_POST['wpgmza_polyline']); $linecolor = attribute_escape($_POST['poly_line']); $linethickness = attribute_escape($_POST['poly_thickness']); $opacity = attribute_escape($_POST['poly_opacity']); $rows_affected = $wpdb->query( $wpdb->prepare( "INSERT INTO $wpgmza_tblname_polylines SET map_id = %d, polydata = %s, linecolor = %s, linethickness = %s, opacity = %s ", $mid, $wpgmaps_polydata, $linecolor, $linethickness, $opacity ) ); echo "
"; _e("Your polyline has been created.","wp-google-maps"); echo "
"; } else if (isset($_POST['wpgmza_edit_polyline'])){ global $wpdb; global $wpgmza_tblname_polylines; $mid = attribute_escape($_POST['wpgmaps_map_id']); $pid = attribute_escape($_POST['wpgmaps_poly_id']); $wpgmaps_polydata = attribute_escape($_POST['wpgmza_polyline']); $linecolor = attribute_escape($_POST['poly_line']); $linethickness = attribute_escape($_POST['poly_thickness']); $opacity = attribute_escape($_POST['poly_opacity']); $rows_affected = $wpdb->query( $wpdb->prepare( "UPDATE $wpgmza_tblname_polylines SET polydata = %s, linecolor = %s, linethickness = %s, opacity = %s WHERE `id` = %d" , $wpgmaps_polydata, $linecolor, $linethickness, $opacity, $pid ) ); echo "
"; _e("Your polyline has been saved.","wp-google-maps"); echo "
"; } else if (isset($_POST['wpgmza_save_settings'])){ global $wpdb; $wpgmza_data['wpgmza_settings_image_width'] = attribute_escape($_POST['wpgmza_settings_image_width']); $wpgmza_data['wpgmza_settings_image_height'] = attribute_escape($_POST['wpgmza_settings_image_height']); $wpgmza_data['wpgmza_settings_use_timthumb'] = attribute_escape($_POST['wpgmza_settings_use_timthumb']); $wpgmza_data['wpgmza_settings_infowindow_width'] = attribute_escape($_POST['wpgmza_settings_infowindow_width']); $wpgmza_data['wpgmza_settings_infowindow_links'] = attribute_escape($_POST['wpgmza_settings_infowindow_links']); $wpgmza_data['wpgmza_settings_infowindow_address'] = attribute_escape($_POST['wpgmza_settings_infowindow_address']); $wpgmza_data['wpgmza_settings_map_streetview'] = attribute_escape($_POST['wpgmza_settings_map_streetview']); $wpgmza_data['wpgmza_settings_map_zoom'] = attribute_escape($_POST['wpgmza_settings_map_zoom']); $wpgmza_data['wpgmza_settings_map_pan'] = attribute_escape($_POST['wpgmza_settings_map_pan']); $wpgmza_data['wpgmza_settings_map_type'] = attribute_escape($_POST['wpgmza_settings_map_type']); $wpgmza_data['wpgmza_settings_map_scroll'] = attribute_escape($_POST['wpgmza_settings_map_scroll']); $wpgmza_data['wpgmza_settings_map_draggable'] = attribute_escape($_POST['wpgmza_settings_map_draggable']); $wpgmza_data['wpgmza_settings_map_clickzoom'] = attribute_escape($_POST['wpgmza_settings_map_clickzoom']); $wpgmza_data['wpgmza_settings_ugm_striptags'] = attribute_escape($_POST['wpgmza_settings_map_striptags']); $wpgmza_data['wpgmza_settings_force_jquery'] = attribute_escape($_POST['wpgmza_settings_force_jquery']); update_option('WPGMZA_OTHER_SETTINGS', $wpgmza_data); echo "
"; _e("Your settings have been saved.","wp-google-maps"); echo "
"; } } function wpgmaps_admin_menu() { add_menu_page('WPGoogle Maps', __('Maps','wp-google-maps'), 'manage_options', 'wp-google-maps-menu', 'wpgmaps_menu_layout', wpgmaps_get_plugin_url()."/images/map_app_small.png"); //add_submenu_page('wp-google-maps-menu', 'WP Google Maps - Markers', __('Markers','wp-google-maps'), 'manage_options' , 'wp-google-maps-menu-markers', 'wpgmaps_menu_marker_layout'); if (function_exists('wpgmza_pro_advanced_menu')) { add_submenu_page('wp-google-maps-menu', 'WP Google Maps - Advanced Options', __('Advanced','wp-google-maps'), 'manage_options' , 'wp-google-maps-menu-advanced', 'wpgmaps_menu_advanced_layout'); } add_submenu_page('wp-google-maps-menu', 'WP Google Maps - Settings', __('Settings','wp-google-maps'), 'manage_options' , 'wp-google-maps-menu-settings', 'wpgmaps_menu_settings_layout'); // add_options_page('WP Google Maps', 'WP Google Maps', 'manage_options', 'wp-google-maps-menu', 'wpgmaps_menu_layout'); } function wpgmaps_menu_layout() { //check to see if we have write permissions to the plugin folder // // if (!$_GET['action']) { wpgmza_map_page(); } else { echo"
".__("Experiencing problems with the plugin?","wp-google-maps")."
".__("See the troubleshooting manual.","wp-google-maps")."
"; if ($_GET['action'] == "trash" && isset($_GET['map_id'])) { if ($_GET['s'] == "1") { if (wpgmaps_trash_map($_GET['map_id'])) { //wp_redirect( admin_url('admin.php?page=wp-google-maps-menu') ); echo ""; } else { _e("There was a problem deleting the map.");; } } else { $res = wpgmza_get_map_data($_GET['map_id']); echo "

".__("Delete your map","wp-google-maps")."

".__("Are you sure you want to delete the map","wp-google-maps")." \"".$res->map_title."?\"
".__("Yes","wp-google-maps")." | ".__("No","wp-google-maps")."

"; } } else if ($_GET['action'] == "edit_marker" && isset($_GET['id'])) { wpgmza_edit_marker($_GET['id']); } else if ($_GET['action'] == "add_poly" && isset($_GET['map_id'])) { wpgmza_pro_add_poly($_GET['map_id']); } else if ($_GET['action'] == "edit_poly" && isset($_GET['map_id'])) { wpgmza_pro_edit_poly($_GET['map_id']); } else if ($_GET['action'] == "add_polyline" && isset($_GET['map_id'])) { wpgmza_pro_add_polyline($_GET['map_id']); } else if ($_GET['action'] == "edit_polyline" && isset($_GET['map_id'])) { wpgmza_pro_edit_polyline($_GET['map_id']); } else { if (function_exists('wpgmza_register_pro_version')) { $prov = get_option("WPGMZA_PRO"); $wpgmza_pro_version = $prov['version']; if (floatval($wpgmza_pro_version) < 4.01 || $wpgmza_pro_version == null) { wpgmaps_upgrade_notice(); wpgmza_pro_menu(); } else { wpgmza_pro_menu(); } } else { wpgmza_basic_menu(); } } } } function wpgmaps_menu_marker_layout() { if (!$_GET['action']) { wpgmza_marker_page(); } else { echo"
".__("Experiencing problems with the plugin?","wp-google-maps")."
".__("See the troubleshooting manual.","wp-google-maps")."
"; if ($_GET['action'] == "trash" && isset($_GET['marker_id'])) { if ($_GET['s'] == "1") { if (wpgmaps_trash_marker($_GET['marker_id'])) { //wp_redirect( admin_url('admin.php?page=wp-google-maps-menu') ); echo ""; } else { _e("There was a problem deleting the marker.");; } } else { $res = wpgmza_get_marker_data($_GET['map_id']); echo "

".__("Delete Marker","wp-google-maps")."

".__("Are you sure you want to delete this marker:","wp-google-maps")." \"".$res->address."?\"
".__("Yes","wp-google-maps")." | ".__("No","wp-google-maps")."

"; } } } } function wpgmaps_menu_settings_layout() { if (function_exists('wpgmza_register_pro_version')) { if (function_exists('wpgmaps_settings_page_pro')) { wpgmaps_settings_page_pro(); } } else { wpgmaps_settings_page_basic(); } } function wpgmaps_settings_page_basic() { echo"

".__("WP Google Map Settings","wp-google-maps")."

"; $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); $wpgmza_settings_map_streetview = $wpgmza_settings['wpgmza_settings_map_streetview']; $wpgmza_settings_map_zoom = $wpgmza_settings['wpgmza_settings_map_zoom']; $wpgmza_settings_map_pan = $wpgmza_settings['wpgmza_settings_map_pan']; $wpgmza_settings_map_type = $wpgmza_settings['wpgmza_settings_map_type']; $wpgmza_force_jquery = $wpgmza_settings['wpgmza_settings_force_jquery']; if ($wpgmza_settings_map_streetview == "yes") { $wpgmza_streetview_checked = "checked='checked'"; } if ($wpgmza_settings_map_zoom == "yes") { $wpgmza_zoom_checked = "checked='checked'"; } if ($wpgmza_settings_map_pan == "yes") { $wpgmza_pan_checked = "checked='checked'"; } if ($wpgmza_settings_map_type == "yes") { $wpgmza_type_checked = "checked='checked'"; } if ($wpgmza_force_jquery == "yes") { $wpgmza_force_jquery_checked = "checked='checked'"; } if (function_exists('wpgmza_register_pro_version')) { $pro_settings1 = wpgmaps_settings_page_sub('infowindow'); $prov = get_option("WPGMZA_PRO"); $wpgmza_pro_version = $prov['version']; if (floatval($wpgmza_pro_version) < 3.9) { $prov_msg = "

Please note that these settings will only work with the Pro Addon version 3.9 and above. Your current version is $wpgmza_pro_version. To download the latest version, please email nick@wpgmaps.com

"; } } echo "

$prov_msg

$pro_settings1

".__("Map Settings")."

".__("General Map Settings","wp-google-maps").": ".__("Disable StreetView")."
".__("Disable Zoom Controls")."
".__("Disable Pan Controls")."
".__("Disable Map Type Controls")."
".__("Troubleshooting Options","wp-google-maps").": ".__("Over-ride current jQuery with version 1.8.3 (Tick this box if you are receiving jQuery related errors)")."

"; echo "
"; } function wpgmaps_menu_advanced_layout() { if (function_exists('wpgmza_register_pro_version')) { wpgmza_pro_advanced_menu(); } } function wpgmza_map_page() { if (function_exists('wpgmza_register_pro_version')) { echo"

".__("My Maps","wp-google-maps")." ".__("Add New","wp-google-maps")."

"; wpgmaps_check_versions(); wpgmaps_list_maps(); } else { echo"

".__("My Maps","wp-google-maps")."

"; echo"

".__("Create unlimited maps","wp-google-maps")." ".__("with the","wp-google-maps")." ".__("Pro Version","wp-google-maps")." ".__("of WP Google Maps for only","wp-google-maps")." $14.99!

"; wpgmaps_list_maps(); } echo "
"; echo"
".__("Problems with the plugin? See the troubleshooting manual.","wp-google-maps")."
"; } function wpgmaps_list_maps() { global $wpdb; global $wpgmza_tblname_maps; if ($wpgmza_tblname_maps) { $table_name = $wpgmza_tblname_maps; } else { $table_name = $wpdb->prefix . "wpgmza_maps"; } $results = $wpdb->get_results( " SELECT * FROM $table_name WHERE `active` = 0 ORDER BY `id` DESC " ); echo " "; foreach ( $results as $result ) { if ($result->type == "1") { $map_type = __("Roadmap","wp-google-maps"); } else if ($result->type == "2") { $map_type = __("Satellite","wp-google-maps"); } else if ($result->type == "3") { $map_type = __("Hybrid","wp-google-maps"); } else if ($result->type == "4") { $map_type = __("Terrain","wp-google-maps"); } if (function_exists('wpgmza_register_pro_version')) { $trashlink = "| id."\" title=\"Trash\">".__("Trash","wp-google-maps").""; } echo "id."\">"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
".__("ID","wp-google-maps")." ".__("Title","wp-google-maps")." ".__("Width","wp-google-maps")." ".__("Height","wp-google-maps")." ".__("Type","wp-google-maps")."
".$result->id."id."\" title=\"".__("Edit","wp-google-maps")."\">".$result->map_title."
id."\" title=\"".__("Edit","wp-google-maps")."\">".__("Edit","wp-google-maps")." $trashlink
".$result->map_width."".$result->map_height."".$map_type."
"; } function wpgmza_marker_page() { echo"

".__("My Markers","wp-google-maps")." ".__("Add New","wp-google-maps")."

"; wpgmaps_list_markers(); echo "
"; echo"
".__("Problems with the plugin? See the troubleshooting manual.","wp-google-maps")."
"; } function wpgmaps_list_markers() { global $wpdb; global $wpgmza_tblname; $results = $wpdb->get_results( " SELECT * FROM $wpgmza_tblname ORDER BY `address` DESC " ); echo " "; foreach ( $results as $result ) { echo "id."\">"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
".__("ID","wp-google-maps")." ".__("Icon","wp-google-maps")." ".__("Linked to","wp-google-maps")." ".__("Title","wp-google-maps")." ".__("Address","wp-google-maps")." ".__("GPS","wp-google-maps")." ".__("Pic","wp-google-maps")." ".__("Link","wp-google-maps")."
".$result->id."".$result->icon."".$result->map_id."".$result->title."".$result->address."".$result->lat.",".$result->lng."".$result->pic."".$result->link."
"; } function wpgmaps_check_versions() { $prov = get_option("WPGMZA_PRO"); $wpgmza_pro_version = $prov['version']; if (floatval($wpgmza_pro_version) < 4.06 || $wpgmza_pro_version == null) { wpgmaps_upgrade_notice(); } } function wpgmza_basic_menu() { global $wpgmza_tblname_maps; global $wpdb; if (!wpgmaps_check_permissions()) { wpgmaps_permission_warning(); } if ($_GET['action'] == "edit" && isset($_GET['map_id'])) { $res = wpgmza_get_map_data($_GET['map_id']); if ($res->map_start_zoom) { $wpgmza_zoom[intval($res->map_start_zoom)] = "SELECTED"; } else { $wpgmza_zoom[8] = "SELECTED"; } if ($res->type) { $wpgmza_map_type[intval($res->type)] = "SELECTED"; } else { $wpgmza_map_type[1] = "SELECTED"; } if ($res->alignment) { $wpgmza_map_align[intval($res->alignment)] = "SELECTED"; } else { $wpgmza_map_align[1] = "SELECTED"; } if ($res->map_width_type == "%") { $wpgmza_map_width_type_percentage = "SELECTED"; } else { $wpgmza_map_width_type_px = "SELECTED"; } if ($res->map_height_type == "%") { $wpgmza_map_height_type_percentage = "SELECTED"; } else { $wpgmza_map_height_type_px = "SELECTED"; } $wpgmza_act = "disabled readonly"; $wpgmza_act_msg = "".__("Add custom icons, titles, descriptions, pictures and links to your markers with the","wp-google-maps")." \"".__("Pro Edition","wp-google-maps")."\" ".__("of this plugin for just","wp-google-maps")." $14.99"; $wpgmza_csv = "

".__("Purchase the Pro Edition","wp-google-maps")." ".__("of WP Google Maps and save your markers to a CSV file!","wp-google-maps")."

"; } echo "

WP Google Maps

".__("Map Settings","wp-google-maps")."

".__("Short code","wp-google-maps").": ".__("copy this into your post or page to display the map","wp-google-maps")."
".__("Map Name","wp-google-maps").":
".__("Width","wp-google-maps").":
".__("Height","wp-google-maps").":
".__("Map Alignment","wp-google-maps").":
".__("Map type","wp-google-maps").":
".__("Get all of these advanced features with the Pro version for only $14.99 once off. Support and updates included forever.","wp-google-maps")."
".__("Default Marker Image","wp-google-maps").": $display_marker -reset-
".__("List all Markers","wp-google-maps").": ".__("List all markers below the map","wp-google-maps")."
".__("Select this for the advanced listing functionality","wp-google-maps")."
".__("Order markers by","wp-google-maps").":
".__("Show User's Location?","wp-google-maps").":
".__("Enable Directions?","wp-google-maps").":         ".__("Directions Box Open by Default?","wp-google-maps").":         ".__("Directions Box Width","wp-google-maps").": px
".__("Enable Bicycle Layer?","wp-google-maps").":         ".__("Enable Traffic Layer?","wp-google-maps").":
".__("KML/GeoRSS URL","wp-google-maps").": ".__("The KML/GeoRSS layer will over-ride most of your map settings","wp-google-maps")."
".__("Fusion table ID","wp-google-maps").": ".__("Read data directly from your Fusion Table.","wp-google-maps")."
".__("Remember to save your map!","wp-google-maps")."

".__("Tip: Use your mouse to change the layout of your map. When you have positioned the map to your desired location, press \"Save Map\" to keep your settings.","wp-google-maps")."

 

".__("Remember to save your map!","wp-google-maps")."

".__("Add a marker","wp-google-maps")."

".__("Title","wp-google-maps").":  
".__("Address/GPS","wp-google-maps").":  
".__("Description","wp-google-maps").":  
".__("Pic URL","wp-google-maps").":
".__("Link URL","wp-google-maps").":
".__("Custom Marker","wp-google-maps").":  
".__("Animation","wp-google-maps").":
".__("Adding","wp-google-maps")."... ".__("Saving","wp-google-maps")."...

$wpgmza_act_msg

".__("Your Markers","wp-google-maps")."

".wpgmza_return_marker_list($_GET['map_id'])."


$wpgmza_csv

".__("Add a Polygon","wp-google-maps")."

\"".__("Add

".__("Add Polygons to your maps for only","wp-google-maps")." $14.99. ".__("Click","wp-google-maps")." ".__("here","wp-google-maps")."

".__("Add a Polyline","wp-google-maps")."

\"".__("Add

".__("Add Polyline and routes to your maps for only","wp-google-maps")." $14.99. ".__("Click","wp-google-maps")." ".__("here","wp-google-maps")."
\"".__("Add

".__("Add detailed information to your markers for only","wp-google-maps")." $14.99. ".__("Click","wp-google-maps")." ".__("here","wp-google-maps")."
\"".__("Add

".__("Add different marker icons, or your own icons to make your map really stand out!","wp-google-maps")."
\"".__("Add

".__("Allow your visitors to get directions to your markers!","wp-google-maps")." ".__("Click","wp-google-maps")." ".__("here","wp-google-maps")."



".__("WP Google Maps encourages you to make use of the amazing icons created by Nicolas Mollet's Maps Icons Collection","wp-google-maps")." http://mapicons.nicolasmollet.com/ ".__("and to credit him when doing so.","wp-google-maps")."

"; } function wpgmza_edit_marker($mid) { global $wpgmza_tblname_maps; global $wpdb; if ($_GET['action'] == "edit_marker" && isset($mid)) { $res = wpgmza_get_marker_data($mid); echo "

WP Google Maps

".__("Edit Marker Location","wp-google-maps")." ".__("ID","wp-google-maps")."#$mid

".__("Marker Latitude","wp-google-maps").":
".__("Marker Longitude","wp-google-maps").":

".__("Tip: Use your mouse to change the location of the marker. Simply click and drag it to your desired location.","wp-google-maps")."

 

$wpgmza_act_msg

"; } } function wpgmaps_admin_scripts() { wp_enqueue_script('media-upload'); //wp_enqueue_script('thickbox'); wp_enqueue_media(); wp_register_script('my-wpgmaps-upload', plugins_url('js/media.js', __FILE__), array('jquery'), '1.0', true); wp_enqueue_script('my-wpgmaps-upload'); if ($_GET['action'] == "add_poly" || $_GET['action'] == "edit_poly" || $_GET['action'] == "add_polyline" || $_GET['action'] == "edit_polyline") { wp_register_script('my-wpgmaps-color', plugins_url('js/jscolor.js',__FILE__), false, '1.4.1', false); wp_enqueue_script('my-wpgmaps-color'); } if ($_GET['page'] == "wp-google-maps-menu" && $_GET['action'] == "edit") { wp_enqueue_script( 'jquery-ui-tabs'); wp_register_script('my-wpgmaps-tabs', plugins_url('js/wpgmaps_tabs.js',__FILE__), array('jquery-ui-core'), '1.0.1', true); wp_enqueue_script('my-wpgmaps-tabs'); } } function wpgmaps_user_styles() { wp_register_style( 'wpgmaps-style', plugins_url('css/wpgmza_style.css', __FILE__) ); wp_enqueue_style( 'wpgmaps-style' ); } function wpgmaps_admin_styles() { //wp_enqueue_style('thickbox'); } if (isset($_GET['page']) && $_GET['page'] == 'wp-google-maps-menu') { add_action('admin_print_scripts', 'wpgmaps_admin_scripts'); add_action('admin_print_styles', 'wpgmaps_admin_styles'); } add_action('wp_print_styles', 'wpgmaps_user_styles'); function wpgmza_return_marker_list($map_id,$admin = true,$width = "100%") { global $wpdb; global $wpgmza_tblname; $marker_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpgmza_tblname WHERE `map_id` = '$map_id';" ) ); if ($marker_count > 2000) { return __("There are too many markers to make use of the live edit function. The maximum amount for this functionality is 2000 markers. Anything more than that number would crash your browser. In order to edit your markers, you would need to download the table in CSV format, edit it and re-upload it.","wp-google-maps"); } else { $results = $wpdb->get_results(" SELECT * FROM $wpgmza_tblname WHERE `map_id` = '$map_id' ORDER BY `id` DESC "); if ($admin) { $wpgmza_tmp .= " "; } else { $wpgmza_tmp .= "
".__("ID","wp-google-maps")." ".__("Icon","wp-google-maps")." ".__("Title","wp-google-maps")." ".__("Address","wp-google-maps")." ".__("Description","wp-google-maps")." ".__("Image","wp-google-maps")." ".__("Link","wp-google-maps")." ".__("Action","wp-google-maps")."
"; } $res = wpgmza_get_map_data($map_id); $default_marker = ""; //$wpgmza_data = get_option('WPGMZA'); //if ($wpgmza_data['map_default_marker']) { $default_icon = ""; } else { $default_icon = ""; } foreach ( $results as $result ) { $img = $result->pic; $link = $result->link; $icon = $result->icon; if (!$img) { $pic = ""; } else { $pic = "pic."\" width=\"40\" />"; } if (!$icon) { $icon = $default_marker; } else { $icon = ""; } if (!$link) { $linktd = ""; } else { $linktd = "link."\" target=\"_BLANK\" title=\"".__("View this link","wp-google-maps")."\">>>"; } if ($admin) { $wpgmza_tmp .= " id."\"> "; } else { $wpgmza_tmp .= " id."\" mid=\"".$result->id."\" mapid=\"".$result->map_id."\" class=\"wpgmaps_mlist_row\"> "; } } if ($admin) { $wpgmza_tmp .= "
".__("Title","wp-google-maps")." ".__("Address","wp-google-maps")." ".__("Description","wp-google-maps")."
".$result->id." ".$icon."id."\" value=\"".$result->icon."\" />id."\" value=\"".$result->anim."\" />id."\" value=\"".$result->infoopen."\" /> ".$result->title."id."\" value=\"".$result->title."\" /> ".$result->address."id."\" value=\"".$result->address."\" /> ".$result->description."id."\" value=\"".$result->description."\" /> $picid."\" value=\"".$result->pic."\" /> $linktdid."\" value=\"".$result->link."\" /> id."\">".__("Edit","wp-google-maps")." | id."\" title=\"".__("Edit this marker","wp-google-maps")."\" class=\"wpgmza_edit_btn\" id=\"".$result->id."\">".__("Edit Location","wp-google-maps")." | id."\">".__("Delete","wp-google-maps")."
".sprintf('%02d', $result->id)." ".$icon." ".$result->title." ".$result->address." ".$result->description."
"; } else { $wpgmza_tmp .= "
"; } return $wpgmza_tmp; } } function wpgmaps_chmodr($path, $filemode) { if (!is_dir($path)) return chmod($path, $filemode); $dh = opendir($path); while (($file = readdir($dh)) !== false) { if($file != '.' && $file != '..') { $fullpath = $path.'/'.$file; if(is_link($fullpath)) return FALSE; elseif(!is_dir($fullpath) && !chmod($fullpath, $filemode)) return FALSE; elseif(!wpgmaps_chmodr($fullpath, $filemode)) return FALSE; } } closedir($dh); if(chmod($path, $filemode)) return TRUE; else return FALSE; } if (function_exists('wpgmza_register_pro_version')) { add_action('wp_ajax_add_marker', 'wpgmaps_action_callback_pro'); add_action('wp_ajax_delete_marker', 'wpgmaps_action_callback_pro'); add_action('wp_ajax_edit_marker', 'wpgmaps_action_callback_pro'); add_action('wp_ajax_delete_poly', 'wpgmaps_action_callback_pro'); add_action('template_redirect','wpgmaps_check_shortcode'); if (function_exists('wpgmza_register_gold_version')) { add_action('wp_footer', 'wpgmaps_user_javascript_gold'); add_action('admin_head', 'wpgmaps_admin_javascript_gold'); } else { add_action('wp_footer', 'wpgmaps_user_javascript_pro'); add_action('admin_head', 'wpgmaps_admin_javascript_pro'); } if (function_exists('wpgmza_register_ugm_version')) { } add_shortcode( 'wpgmza', 'wpgmaps_tag_pro' ); } else { add_action('admin_head', 'wpgmaps_admin_javascript_basic'); add_action('wp_ajax_add_marker', 'wpgmaps_action_callback_basic'); add_action('wp_ajax_delete_marker', 'wpgmaps_action_callback_basic'); add_action('wp_ajax_edit_marker', 'wpgmaps_action_callback_basic'); add_action('template_redirect','wpgmaps_check_shortcode'); add_action('wp_footer', 'wpgmaps_user_javascript_basic'); add_shortcode( 'wpgmza', 'wpgmaps_tag_basic' ); } function wpgmaps_check_shortcode() { global $posts; global $short_code_active; $short_code_active = false; $pattern = get_shortcode_regex(); foreach ($posts as $wpgmpost) { preg_match_all('/'.$pattern.'/s', $wpgmpost->post_content, $matches); foreach ($matches as $match) { if (is_array($match)) { foreach($match as $key => $val) { $pos = strpos($val, "wpgmza"); if ($pos === false) { } else { $short_code_active = true; } } } } } } function wpgmaps_check_permissions() { $filename = dirname( __FILE__ ).'/wpgmaps.tmp'; $testcontent = "Permission Check\n"; $handle = @fopen($filename, 'w'); if (@fwrite($handle, $testcontent) === FALSE) { @fclose($handle); add_option("wpgmza_permission","n"); return false; } else { @fclose($handle); add_option("wpgmza_permission","y"); return true; } } function wpgmaps_permission_warning() { echo "
"; _e("The plugin directory does not have 'write' permissions. Please enable 'write' permissions (755) for "); echo "\"".dirname( __FILE__ )."\" "; _e("in order for this plugin to work! Please see "); echo ""; _e("this page"); echo " "; _e("for help on how to do it."); echo "
"; } // handle database check upon upgrade function wpgmaps_update_db_check() { global $wpgmza_version; if (get_option('wpgmza_db_version') != $wpgmza_version) { wpgmaps_handle_db(); } // create all XML files wpgmaps_update_all_xml_file(); } add_action('plugins_loaded', 'wpgmaps_update_db_check'); function wpgmaps_handle_db() { global $wpdb; global $wpgmza_version; global $wpgmza_tblname_poly; global $wpgmza_tblname_polylines; global $wpgmza_tblname; $table_name = $wpdb->prefix . "wpgmza"; // check for previous versions containing 'desc' instead of 'description' $results = $wpdb->get_results("DESC $wpgmza_tblname"); foreach ($results as $row ) { if ($row->Field == "desc") { $founded++; } } if ($founded>0) { $wpdb->query( " ALTER TABLE $wpgmza_tblname CHANGE `desc` `description` MEDIUMTEXT " ); } // end check $sql = " CREATE TABLE `".$table_name."` ( `id` int(11) NOT NULL AUTO_INCREMENT, `map_id` int(11) NOT NULL, `address` varchar(700) NOT NULL, `description` mediumtext NOT NULL, `pic` varchar(700) NOT NULL, `link` varchar(700) NOT NULL, `icon` varchar(700) NOT NULL, `lat` varchar(100) NOT NULL, `lng` varchar(100) NOT NULL, `anim` varchar(3) NOT NULL, `title` varchar(700) NOT NULL, `infoopen` varchar(3) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; "; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); $sql = " CREATE TABLE `".$wpgmza_tblname_poly."` ( `id` int(11) NOT NULL AUTO_INCREMENT, `map_id` int(11) NOT NULL, `polydata` LONGTEXT NOT NULL, `linecolor` VARCHAR(7) NOT NULL, `fillcolor` VARCHAR(7) NOT NULL, `opacity` VARCHAR(3) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; "; dbDelta($sql); $sql = " CREATE TABLE `".$wpgmza_tblname_polylines."` ( `id` int(11) NOT NULL AUTO_INCREMENT, `map_id` int(11) NOT NULL, `polydata` LONGTEXT NOT NULL, `linecolor` VARCHAR(7) NOT NULL, `linethickness` VARCHAR(3) NOT NULL, `opacity` VARCHAR(3) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; "; dbDelta($sql); $table_name = $wpdb->prefix . "wpgmza_maps"; $sql = " CREATE TABLE `".$table_name."` ( `id` int(11) NOT NULL AUTO_INCREMENT, `map_title` varchar(50) NOT NULL, `map_width` varchar(6) NOT NULL, `map_height` varchar(6) NOT NULL, `map_start_lat` varchar(700) NOT NULL, `map_start_lng` varchar(700) NOT NULL, `map_start_location` varchar(700) NOT NULL, `map_start_zoom` INT(10) NOT NULL, `default_marker` varchar(700) NOT NULL, `type` INT(10) NOT NULL, `alignment` INT(10) NOT NULL, `directions_enabled` INT(10) NOT NULL, `styling_enabled` INT(10) NOT NULL, `styling_json` mediumtext NOT NULL, `active` INT(1) NOT NULL, `kml` VARCHAR(700) NOT NULL, `bicycle` INT(10) NOT NULL, `traffic` INT(10) NOT NULL, `dbox` INT(10) NOT NULL, `dbox_width` varchar(10) NOT NULL, `listmarkers` INT(10) NOT NULL, `listmarkers_advanced` INT(10) NOT NULL, `ugm_enabled` INT(10) NOT NULL, `fusion` VARCHAR(100) NOT NULL, `map_width_type` VARCHAR(3) NOT NULL, `map_height_type` VARCHAR(3) NOT NULL, `mass_marker_support` INT(10) NOT NULL, `ugm_access` INT(10) NOT NULL, `order_markers_by` INT(10) NOT NULL, `order_markers_choice` INT(10) NOT NULL, `show_user_location` INT(3) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; "; dbDelta($sql); add_option("wpgmza_db_version", $wpgmza_version); update_option("wpgmza_db_version",$wpgmza_version); } function wpgmza_get_map_data($map_id) { global $wpdb; global $wpgmza_tblname_maps; $result = $wpdb->get_results(" SELECT * FROM $wpgmza_tblname_maps WHERE `id` = '".$map_id."' LIMIT 1 "); $res = $result[0]; return $result[0]; } function wpgmza_get_marker_data($mid) { global $wpdb; global $wpgmza_tblname; $result = $wpdb->get_results(" SELECT * FROM $wpgmza_tblname WHERE `id` = '".$mid."' LIMIT 1 "); $res = $result[0]; return $res; } function wpgmaps_upgrade_notice() { global $wpgmza_pro_version; echo "

Dear Pro User

We have recently added new functionality to the Pro version of this plugin. You are currently using the latest Basic version which needs the latest Pro version for all functionality to work. Your current Pro version is $wpgmza_pro_version - The latest Pro version is 4.06

To download your latest copy of the Pro version, please use this form and your download link will be emailed to your immediately. Get your latest version by clicking here.

Installation Instructions:

  • - Once downloaded, please deactivate and delete your old Pro plugin (your marker and map information wont be affected at all).
  • - Upload the new plugin ZIP file.

If you experience any bugs, please let me know so that I can get it sorted out ASAP.

Kind regards,
WP Google Maps

"; } function wpgmaps_trash_map($map_id) { global $wpdb; global $wpgmza_tblname_maps; if (isset($map_id)) { $rows_affected = $wpdb->query( $wpdb->prepare( "UPDATE $wpgmza_tblname_maps SET active = %d WHERE id = %d", 1, $map_id) ); return true; } else { return false; } } function wpgmaps_filter(&$array) { $clean = array(); foreach($array as $key => &$value ) { if( is_array($value) ) { wpgmaps_filter($value); } else { //$value = trim(strip_tags($value)); if (get_magic_quotes_gpc()) { $data = stripslashes($value); } $data = mysql_real_escape_string($value); } } } function wpgmaps_debugger($section) { global $debug; global $debug_start; global $debug_step; if ($debug) { $end = (float) array_sum(explode(' ',microtime())); echo ""; } } function wpgmaps_load_jquery() { if (!is_admin()) { $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); if ($wpgmza_settings['wpgmza_settings_force_jquery'] == "yes") { wp_deregister_script('jquery'); wp_register_script('jquery', plugins_url("js/jquery.min.js",__FILE__), false, "1.8.3"); } wp_enqueue_script('jquery'); } } add_action('wp_enqueue_scripts', 'wpgmaps_load_jquery', 9999);