function wpgmaps_update_xml_file($mapid = false) { $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); if (isset($wpgmza_settings['wpgmza_settings_marker_pull']) && $wpgmza_settings['wpgmza_settings_marker_pull'] == '0') { /* using db method, do nothing */ return; } if (!$mapid) { $mapid = $_POST['map_id']; } if (!$mapid) { $mapid = sanitize_text_field($_GET['map_id']); } global $wpdb; /* added in 6.0.30 */ if (!class_exists("DOMDocument")) { return new WP_Error('db_query_error', __('DOMDocument is not enabled'), "Please contact your host and ask them to enable the DOMDocument class. WP Google Maps uses this class to create the marker data files."); } $dom = new DOMDocument('1.0'); $dom->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']; $sql = "SELECT * FROM {$table_name} WHERE `map_id` = '{$mapid}' AND `approved` = 1"; $results = $wpdb->get_results($sql); } else { $results = $wpdb->get_results("\r\n SELECT *\r\n FROM {$table_name}\r\n WHERE `map_id` = '{$mapid}'\r\n AND `approved` = 1\r\n\r\n "); } 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; $retina = $result->retina; $category = $result->category; if ($icon == "") { if (function_exists('wpgmza_get_category_data')) { $category_data = wpgmza_get_category_data($category); if (isset($category_data->category_icon) && isset($category_data->category_icon) != "") { $icon = $category_data->category_icon; } else { $icon = ""; } if (isset($category_data->retina)) { $retina = $category_data->retina; } } } $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('retina')); $bd->appendChild($dom->CreateTextNode($retina)); $bd = $channel->appendChild($dom->createElement('category')); $bd->appendChild($dom->CreateTextNode($category)); $bd = $channel->appendChild($dom->createElement('infoopen')); $bd->appendChild($dom->CreateTextNode($infoopen)); } $upload_dir = wp_upload_dir(); wpgmaps_handle_directory(); $xml_marker_location = wpgmza_return_marker_path(); if (is_multisite()) { global $blog_id; if ($dom->save($xml_marker_location . $blog_id . '-' . $mapid . 'markers.xml') == FALSE) { return new WP_Error('db_query_error', __('Could not save XML file'), "Could not save marker XML file (" . $xml_marker_location . $blog_id . "-" . $mapid . "markers.xml) for Map ID {$mapid}"); } } else { // PREVIOUS VERSION HANDLING if (function_exists('wpgmza_register_pro_version')) { $prov = get_option("WPGMZA_PRO"); $wpgmza_pro_version = $prov['version']; if ($dom->save($xml_marker_location . $mapid . 'markers.xml') == FALSE) { return new WP_Error('db_query_error', __('Could not save XML file'), "Could not save marker XML file (" . $xml_marker_location . $mapid . "markers.xml) for Map ID {$mapid}"); } } else { if ($dom->save($xml_marker_location . $mapid . 'markers.xml') == FALSE) { return new WP_Error('db_query_error', __('Could not save XML file'), "Could not save marker XML file (" . $xml_marker_location . $mapid . "markers.xml) for Map ID {$mapid}"); } } } return true; }
function wpgmaps_update_xml_file($mapid = false) { if (!$mapid) { $mapid = $_POST['map_id']; } if (!$mapid) { $mapid = sanitize_text_field($_GET['map_id']); } global $wpdb; $dom = new DOMDocument('1.0'); $dom->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("\n SELECT *\n FROM {$table_name}\n WHERE `map_id` = '{$mapid}'\n AND `approved` = 1\n\n "); } else { $results = $wpdb->get_results("\n SELECT *\n FROM {$table_name}\n WHERE `map_id` = '{$mapid}'\n AND `approved` = 1\n\n "); } 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; $category = $result->category; if (function_exists('wpgmza_get_category_icon')) { $category_icon = wpgmza_get_category_icon($category); if ($category_icon) { $icon = $category_icon; } } $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('category')); $bd->appendChild($dom->CreateTextNode($category)); $bd = $channel->appendChild($dom->createElement('infoopen')); $bd->appendChild($dom->CreateTextNode($infoopen)); } $upload_dir = wp_upload_dir(); wpgmaps_handle_directory(); $xml_marker_location = wpgmza_return_marker_path(); if (is_multisite()) { global $blog_id; if ($dom->save($xml_marker_location . $blog_id . '-' . $mapid . 'markers.xml') == FALSE) { return new WP_Error('db_query_error', __('Could not save XML file'), "Could not save marker XML file (" . $xml_marker_location . $blog_id . "-" . $mapid . "markers.xml) for Map ID {$mapid}"); } } else { // PREVIOUS VERSION HANDLING if (function_exists('wpgmza_register_pro_version')) { $prov = get_option("WPGMZA_PRO"); $wpgmza_pro_version = $prov['version']; if ($dom->save($xml_marker_location . $mapid . 'markers.xml') == FALSE) { return new WP_Error('db_query_error', __('Could not save XML file'), "Could not save marker XML file (" . $xml_marker_location . $mapid . "markers.xml) for Map ID {$mapid}"); } } else { if ($dom->save($xml_marker_location . $mapid . 'markers.xml') == FALSE) { return new WP_Error('db_query_error', __('Could not save XML file'), "Could not save marker XML file (" . $xml_marker_location . $mapid . "markers.xml) for Map ID {$mapid}"); } } } return true; }
geocoder.geocode( { 'address': wpgm_address }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { wpgm_gps = String(results[0].geometry.location); var latlng1 = wpgm_gps.replace("(",""); var latlng2 = latlng1.replace(")",""); var latlngStr = latlng2.split(",",2); var wpgm_lat = parseFloat(latlngStr[0]); var wpgm_lng = parseFloat(latlngStr[1]); var data = { action: 'add_marker', security: '<?php echo $ajax_nonce; ?> ', map_id: wpgm_map_id, address: wpgm_address, lat: wpgm_lat, lng: wpgm_lng }; jQuery.post(ajaxurl, data, function(response) { wpgmza_InitMap(); jQuery("#wpgmza_marker_holder").html(response); jQuery("#wpgmza_addmarker").show(); jQuery("#wpgmza_addmarker_loading").hide(); wpgmza_reinitialisetbl(); var myLatLng = new google.maps.LatLng(wpgm_lat,wpgm_lng); MYMAP.map.setCenter(myLatLng); }); } else { alert("Geocode was not successful for the following reason: " + status); } }); }); jQuery("#wpgmza_editmarker").click(function(){ jQuery("#wpgmza_editmarker_div").hide(); jQuery("#wpgmza_editmarker_loading").show(); var wpgm_edit_id; wpgm_edit_id = parseInt(jQuery("#wpgmza_edit_id").val()); var wpgm_address = "0"; var wpgm_map_id = "0"; var wpgm_gps = "0"; if (document.getElementsByName("wpgmza_add_address").length > 0) { wpgm_address = jQuery("#wpgmza_add_address").val(); } if (document.getElementsByName("wpgmza_id").length > 0) { wpgm_map_id = jQuery("#wpgmza_id").val(); } geocoder.geocode( { 'address': wpgm_address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { wpgm_gps = String(results[0].geometry.location); var latlng1 = wpgm_gps.replace("(",""); var latlng2 = latlng1.replace(")",""); var latlngStr = latlng2.split(",",2); var wpgm_lat = parseFloat(latlngStr[0]); var wpgm_lng = parseFloat(latlngStr[1]); var data = { action: 'edit_marker', security: '<?php echo $ajax_nonce; ?> ', map_id: wpgm_map_id, edit_id: wpgm_edit_id, address: wpgm_address, lat: wpgm_lat, lng: wpgm_lng }; jQuery.post(ajaxurl, data, function(response) { wpgmza_InitMap(); jQuery("#wpgmza_add_address").val(""); jQuery("#wpgmza_add_title").val(""); jQuery("#wpgmza_marker_holder").html(response); jQuery("#wpgmza_addmarker_div").show(); jQuery("#wpgmza_editmarker_loading").hide(); jQuery("#wpgmza_edit_id").val(""); wpgmza_reinitialisetbl();
<?php $songs = json_decode($_POST['jsonstr'], true); $dom = new DOMDocument(); $dom->load("default.pli"); $songlist = $dom->getElementsByTagName("songList")->item(0); foreach ($songs as $id => $name) { $songnode = $dom->CreateElement("song"); $songid = $dom->CreateElement("id"); $songname = $dom->CreateElement("name"); $songid->appendChild($dom->CreateTextNode($id)); $songname->appendChild($dom->CreateTextNode($name)); $songnode->appendChild($songid); $songnode->appendChild($songname); $songlist->appendChild($songnode); } $dom->save("default.pli"); if (count($songs) == 1) { echo "Add {$name} Successfully"; } else { echo "Add Songs Successfully"; }
<?php $url = "http://www.google.cn/music/artist?id=" . $_POST['id']; $pagedata = file_get_contents($url); // // $reg = "/player_iframe%3Fid%3D(\\w+).*?\">([^<].*?)</"; preg_match_all($reg, $pagedata, $hotsongs, PREG_SET_ORDER); $dom = new DOMDocument('1.0', 'utf-8'); $playlistNode = $dom->CreateElement("playlist"); $dom->appendChild($playlistNode); $listnameNode = $dom->CreateElement("listname"); $listnameNode->appendChild($dom->CreateTextNode("temp")); $playlistNode->appendChild($listnameNode); $songListNode = $dom->CreateElement("songList"); $playlistNode->appendChild($songListNode); foreach ($hotsongs as $song) { $name = html_entity_decode($song[2], ENT_COMPAT, "utf-8"); $songNode = $dom->CreateElement("song"); $songid = $dom->CreateElement("id"); $songname = $dom->CreateElement("name"); $songid->appendChild($dom->CreateTextNode($song[1])); $songname->appendChild($dom->CreateTextNode($name)); $songNode->appendChild($songid); $songNode->appendChild($songname); $songListNode->appendChild($songNode); } $dom->save("ownlist/temp.pli"); // // preg_match("/(?<=width=\"100%\" align=\"left\">)[^<]+/", $pagedata, $artistname);
/** * Convert img tag to object tag. * * @param \DOMDocument $DOMdoc */ protected function imgToObject($DOMdoc) { $tagsImg = $DOMdoc->getElementsByTagName('img'); foreach ($tagsImg as $img) { $src = $img->getAttribute('src'); $file = $this->getFile($src); if ($file) { $object = $DOMdoc->CreateElement('object'); //Copy the image in the archiv $object->setAttribute('data', $file->getResourceNode()->getName()); $objecttxt = $DOMdoc->CreateTextNode($file->getResourceNode()->getName()); $object->appendChild($objecttxt); $object->setAttribute('type', $file->getResourceNode()->getMimeType()); //Creating one table to replace the tags $elements[] = [$object, $img]; } } //Replaces image tag by the object tag if (!empty($elements)) { foreach ($elements as $el) { $el[1]->parentNode->replaceChild($el[0], $el[1]); } } }