//maps any absolute url from this drupal site to nid if applicable. //can also be used to check whether an absolute path is in the site and points to a node (e.g. node/1) function _pingback_url_to_nid($url) { //first check if the url is really in our site, as well as getting the non-base-url part if (preg_match($a = '#^'. preg_quote($GLOBALS['base_url'], '#') .'/(.+)$#', $url, $matches)) { //dpm($matches[1]); //dpm(drupal_get_normal_path($matches[1])); if (!variable_get('clean_url', 0)) { // Clean URLs not enabled. Strip '?q=' from URL. $matches[1] = str_replace('?q=', '', $matches[1]); } if ( variable_get('language_count', 1) > 1 && variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE) != LANGUAGE_NEGOTIATION_NONE ) { // Check if we have a language prefix and strip it $alias = explode('/', $matches[1]); $alias_lang = language_default('language'); $__langs = language_list(); foreach (array_keys($__langs) as $lang) { if ($lang == $alias[0]) { $alias_lang = $lang; array_shift($alias); break; } } $matches[1] = implode('/', $alias); $path = drupal_get_normal_path($matches[1], $alias_lang); } else { $path = drupal_get_normal_path($matches[1]); } if (preg_match($b = '#^node/([0-9]+)$#', $path, $matches2)) { return $matches2[1]; } //else dpm($b); } //dpm($a); return FALSE; }