Index: xmlsitemap/xmlsitemap.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/xmlsitemap/xmlsitemap.install,v retrieving revision 1.4 diff -u -r1.4 xmlsitemap.install --- xmlsitemap/xmlsitemap.install 11 Dec 2007 22:57:45 -0000 1.4 +++ xmlsitemap/xmlsitemap.install 12 Feb 2008 10:48:55 -0000 @@ -56,11 +56,24 @@ */ function xmlsitemap_disable() { $path = file_directory_path() .'/xmlsitemap'; + xmlsitemap_rmdir_recursive($path); +} + +/** + * Recursively delete a directory's contents + */ +function xmlsitemap_rmdir_recursive($path) { if ($dir = @opendir($path)) { while (($file = readdir($dir)) !== FALSE) { - if ($file != '.' && $file != '..') { - unlink("$path/$file"); + if ($file == '.' || $file == '..') { + continue; + } + $fullpath = "$path/$file"; + if(is_dir($fullpath)) { + xmlsitemap_rmdir_recursive($fullpath); + continue; } + unlink($fullpath); } closedir($dir); rmdir($path); Index: xmlsitemap/xmlsitemap.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/xmlsitemap/xmlsitemap.module,v retrieving revision 1.16 diff -u -r1.16 xmlsitemap.module --- xmlsitemap/xmlsitemap.module 18 Dec 2007 22:54:51 -0000 1.16 +++ xmlsitemap/xmlsitemap.module 12 Feb 2008 10:48:59 -0000 @@ -12,7 +12,7 @@ switch ($section) { case 'admin/settings/xmlsitemap': case 'admin/settings/xmlsitemap/settings': - return t('Configure the site map. Your site map is at !url.', array('!url' => ''. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE) .'')); + return t('Configure the site map. Your site map is at !url.', array('!url' => ''. _xmlsitemap_url_basic() .'')); case 'admin/settings/xmlsitemap/engines': return t('Configure behavior for search engines.'); case 'admin/settings/xmlsitemap/additional': @@ -61,7 +61,7 @@ 'weight' => 1, ); $items[] = array( - 'path' => 'sitemap.xml', + 'path' => _xmlsitemap_get_basic_path(), 'title' => t('Site map index'), 'callback' => '_xmlsitemap_output', 'type' => MENU_CALLBACK, @@ -72,7 +72,7 @@ $chunk_count = variable_get('xmlsitemap_chunk_count', 0); for ($chunk = 0; $chunk < $chunk_count; ++$chunk) { $items[] = array( - 'path' => "sitemap$chunk.xml", + 'path' => _xmlsitemap_get_basic_path(0, $chunk), 'title' => t('Site map !number', array('!number' => $chunk)), 'callback' => '_xmlsitemap_output', 'callback arguments' => array($chunk), @@ -317,7 +317,7 @@ * Implementation of hook_robotstxt(). */ function xmlsitemap_robotstxt() { - return array("Sitemap: ". xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE)); + return array("Sitemap: ". _xmlsitemap_url_basic()); } /** @@ -331,13 +331,13 @@ drupal_set_header('Content-type: text/xml; charset=utf-8'); global $user; $dest = file_directory_path() .'/xmlsitemap'; - file_check_directory($dest, FILE_CREATE_DIRECTORY); + _xmlsitemap_ensure_folder($dest); if (isset($chunk)) { - $dest .= "/sitemap$chunk.xml.gz"; + $dest .= '/' . _xmlsitemap_get_basic_path(1, $chunk) . '.gz'; $type = t('Site map @chunk', array('@chunk' => $chunk)); } else { - $dest .= '/sitemap.xml.gz'; + $dest .= '/' . _xmlsitemap_get_basic_path(1) . '.gz'; $link_count = _xmlsitemap_link_count(); $chunk_size = variable_get('xmlsitemap_chunk_size', 50000); $type = $link_count > $chunk_size ? t('Site map index') : t('Site map'); @@ -389,9 +389,9 @@ $current_user = $user; $user = user_load(array('uid' => 0)); $path = file_directory_path() .'/xmlsitemap'; - file_check_directory($path, FILE_CREATE_DIRECTORY); + _xmlsitemap_ensure_folder($path); $node_count = db_result(db_query("SELECT COUNT(*) FROM {node}")); - $dest = $path .'/sitemap.xml.gz'; + $dest = $path .'/' . _xmlsitemap_get_basic_path(1) . '.gz'; $link_count = _xmlsitemap_link_count(); $chunk_size = variable_get('xmlsitemap_chunk_size', 50000); $status = TRUE; @@ -401,7 +401,7 @@ $status = FALSE; } for ($chunk = 0; $chunk < $link_count / $chunk_size; ++$chunk) { - $dest = $path ."/sitemap$chunk.xml.gz"; + $dest = $path . '/' . _xmlsitemap_get_basic_path(1, $chunk) . '.gz'; $data = gzencode(_xmlsitemap_output_chunk($chunk)); if (file_save_data($data, $dest, FILE_EXISTS_REPLACE) === 0 && ($page == $chunk || !isset($page))) { $status = FALSE; @@ -440,7 +440,7 @@ $output .= ''."\n"; $chunk_size = variable_get('xmlsitemap_chunk_size', 50000); for ($chunk = 0; $chunk < $link_count / $chunk_size; ++$chunk) { - $output .= ''. xmlsitemap_url("sitemap$chunk.xml", NULL, NULL, NULL, TRUE) .''; + $output .= ''. xmlsitemap_url(_xmlsitemap_get_basic_path(1, $chunk), NULL, NULL, NULL, TRUE) .''; $previous = $chunk * $chunk_size; $links = array_slice(_xmlsitemap_links(), $previous, $chunk_size); $output .= ''. gmdate('Y-m-d\TH:i:s+00:00', array_reduce($links, '_xmlsitemap_chunk_last_change')) .''; @@ -737,6 +737,39 @@ } /** + * Gets the basic URL, including the sitemap path + */ +function _xmlsitemap_url_basic() { + $path = _xmlsitemap_get_basic_path(); + $alias = drupal_lookup_path('alias', $path); + return xmlsitemap_url($path, ($alias ? $alias : NULL), NULL, NULL, TRUE); +} + +/** + * Gets the basic path for the sitemap file + * @param $domain: A boolean indicating whether we want the domain inserted into the path. Defaults to 0. + * @param $chunk: The chunk. Defaults to ''. + * @returns The path to the sitemap. + */ +function _xmlsitemap_get_basic_path($domain = 0, $chunk = '') { + $thispath = "sitemap$chunk.xml"; + if($domain) { + $thispath = getenv('HTTP_HOST') . "/$thispath"; + } + return($thispath); +} + +/** + * Ensures that the folder exists, and contains a folder with the name + * @param $path: The path to the folder + */ +function _xmlsitemap_ensure_folder($path) { + $host = getenv('HTTP_HOST'); + file_check_directory($path, FILE_CREATE_DIRECTORY); + file_check_directory(($fullpath = $path . '/' . $host), FILE_CREATE_DIRECTORY); +} + +/** * Modified version of drupal_get_path_alias() for xmlsitemap_url(). * @param $path: An internal Drupal path * @param $alias: The URL alias. Default is NULL. Index: xmlsitemap/docs/xmlsitemap.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/xmlsitemap/docs/xmlsitemap.php,v retrieving revision 1.4 diff -u -r1.4 xmlsitemap.php --- xmlsitemap/docs/xmlsitemap.php 6 Dec 2007 17:41:14 -0000 1.4 +++ xmlsitemap/docs/xmlsitemap.php 12 Feb 2008 10:49:00 -0000 @@ -159,7 +159,7 @@ $form['google']['xmlsitemap_engines_google_url'] = array( '#type' => 'textfield', '#title' => t('Submission URL'), - '#default_value' => variable_get('xmlsitemap_engines_google_url', 'http://www.google.com/webmasters/tools/ping?sitemap='. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE)), + '#default_value' => variable_get('xmlsitemap_engines_google_url', 'http://www.google.com/webmasters/tools/ping?sitemap='. xmlsitemap_url_basic()), '#description' => t('The URL to submit the site map to.'), ); $form['google']['xmlsitemap_engines_google_verify'] = array( @@ -171,7 +171,7 @@ return $form; case 'ping': if (variable_get('xmlsitemap_engines_google_submit', TRUE)) { - $result = drupal_http_request(variable_get('xmlsitemap_engines_google_url', 'http://www.google.com/webmasters/tools/ping?sitemap='. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE))); + $result = drupal_http_request(variable_get('xmlsitemap_engines_google_url', 'http://www.google.com/webmasters/tools/ping?sitemap='. xmlsitemap_url_basic())); if ($result->code == 200) { watchdog('xmlsitemap', t('Sitemap successfully submitted to Google.')); } Index: xmlsitemap/xmlsitemap_engines/xmlsitemap_engines.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/xmlsitemap/xmlsitemap_engines/xmlsitemap_engines.module,v retrieving revision 1.4 diff -u -r1.4 xmlsitemap_engines.module --- xmlsitemap/xmlsitemap_engines/xmlsitemap_engines.module 13 Dec 2007 02:48:02 -0000 1.4 +++ xmlsitemap/xmlsitemap_engines/xmlsitemap_engines.module 12 Feb 2008 10:49:02 -0000 @@ -50,7 +50,7 @@ $form['google']['xmlsitemap_engines_google_url'] = array( '#type' => 'textfield', '#title' => t('Submission URL'), - '#default_value' => variable_get('xmlsitemap_engines_google_url', 'http://www.google.com/webmasters/tools/ping?sitemap='. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE)), + '#default_value' => variable_get('xmlsitemap_engines_google_url', 'http://www.google.com/webmasters/tools/ping?sitemap='. xmlsitemap_url_basic()), '#description' => t('The URL to submit the site map to.'), ); $form['google']['xmlsitemap_engines_google_verify'] = array( @@ -62,7 +62,7 @@ return $form; case 'ping': if (variable_get('xmlsitemap_engines_google_submit', FALSE)) { - $result = drupal_http_request(variable_get('xmlsitemap_engines_google_url', 'http://www.google.com/webmasters/tools/ping?sitemap='. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE))); + $result = drupal_http_request(variable_get('xmlsitemap_engines_google_url', 'http://www.google.com/webmasters/tools/ping?sitemap='. xmlsitemap_url_basic())); if ($result->code == 200) { watchdog('xmlsitemap', t('Sitemap successfully submitted to Google.')); } @@ -96,7 +96,7 @@ $form['yahoo']['xmlsitemap_engines_yahoo_url'] = array( '#type' => 'textfield', '#title' => t('Submission URL'), - '#default_value' => variable_get('xmlsitemap_engines_yahoo_url', 'http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap='. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE)), + '#default_value' => variable_get('xmlsitemap_engines_yahoo_url', 'http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap='. xmlsitemap_url_basic()), '#description' => t('The URL to submit the site map to.'), ); $form['yahoo']['xmlsitemap_engines_yahoo_verify'] = array( @@ -114,7 +114,7 @@ return $form; case 'ping': if (variable_get('xmlsitemap_engines_yahoo_submit', FALSE)) { - $result = drupal_http_request(variable_get('xmlsitemap_engines_yahoo_url', 'http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap='. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE))); + $result = drupal_http_request(variable_get('xmlsitemap_engines_yahoo_url', 'http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap='. xmlsitemap_url_basic())); if ($result->code == 200) { watchdog('xmlsitemap', t('Site map successfully submitted to Yahoo!.')); } @@ -146,13 +146,13 @@ $form['ask']['xmlsitemap_engines_ask_url'] = array( '#type' => 'textfield', '#title' => t('Submission URL'), - '#default_value' => variable_get('xmlsitemap_engines_ask_url', 'http://submissions.ask.com/ping?sitemap='. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE)), + '#default_value' => variable_get('xmlsitemap_engines_ask_url', 'http://submissions.ask.com/ping?sitemap='. xmlsitemap_url_basic()), '#description' => t('The URL to submit the site map to.'), ); return $form; case 'ping': if (variable_get('xmlsitemap_engines_ask_submit', FALSE)) { - $result = drupal_http_request(variable_get('xmlsitemap_engines_ask_url', 'http://submissions.ask.com/ping?sitemap='. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE))); + $result = drupal_http_request(variable_get('xmlsitemap_engines_ask_url', 'http://submissions.ask.com/ping?sitemap='. xmlsitemap_url_basic())); if ($result->code == 200) { watchdog('xmlsitemap', t('Site map successfully submitted to Ask.com.')); } @@ -184,7 +184,7 @@ $form['live']['xmlsitemap_engines_live_url'] = array( '#type' => 'textfield', '#title' => t('Submission URL'), - '#default_value' => variable_get('xmlsitemap_engines_live_url', 'http://webmaster.live.com/ping.aspx?siteMap='. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE)), + '#default_value' => variable_get('xmlsitemap_engines_live_url', 'http://webmaster.live.com/ping.aspx?siteMap='. xmlsitemap_url_basic()), '#description' => t('The URL to submit the site map to.'), ); $form['live']['xmlsitemap_engines_live_verify'] = array( @@ -202,7 +202,7 @@ return $form; case 'ping': if (variable_get('xmlsitemap_engines_live_submit', FALSE)) { - $result = drupal_http_request(variable_get('xmlsitemap_engines_live_url', 'http://webmaster.live.com/ping.aspx?siteMap='. xmlsitemap_url('sitemap.xml', drupal_lookup_path('alias', 'sitemap.xml') ? drupal_lookup_path('alias', 'sitemap.xml') : NULL, NULL, NULL, TRUE))); + $result = drupal_http_request(variable_get('xmlsitemap_engines_live_url', 'http://webmaster.live.com/ping.aspx?siteMap='. xmlsitemap_url_basic())); if ($result->code == 200) { watchdog('xmlsitemap', t('Site map successfully submitted to Windows Live.')); }