<commit_before><?php

 /**
   * Summary of getCommonDomain
   * @param mixed $url1
   * @param mixed $url2
   * @return string the common domain part of the given urls
   */
function glpi_getCommonDomain($url1, $url2) {
   $domain = '';
   try {
      $glpi = explode( "/", $url1) ;
      $glpi = explode( ".", $glpi[2] );
      $pm = explode( "/", $url2) ;
      $pm = explode( ".", $pm[2] );
      $cglpi = array_pop( $glpi ) ;
      $cpm = array_pop( $pm) ;
      while( $cglpi && $cpm && $cglpi == $cpm ) {
         $domain = $cglpi.($domain==''?'':'.'.$domain) ;
         $cglpi = array_pop( $glpi ) ;
         $cpm = array_pop( $pm ) ;
      }
      if( $domain != '' ) {
         return $domain ;
      }
   } catch(Exception $e) {}
   return '';
}

/**
 * Summary of glpi_isHTML
 * @return boolean true if content-type is HTML
 */
function glpi_isHTML( ) {
   $needle = 'content-type' ;
   $type = 'text/html' ;
   foreach( headers_list() as $val ) {
      $parts = explode( ":", $val);<commit_msg>Fixed an issue with document.domain when PM (or GLPI) URL was using a port<commit_after><?php

 /**
   * Summary of getCommonDomain
   * @param mixed $url1
   * @param mixed $url2
   * @return string the common domain part of the given urls
   */
function glpi_getCommonDomain($url1, $url2) {
   $domain = '';
   try {
      $glpi = explode( "/", $url1) ;
      $glpi = explode( ".", $glpi[2] );
      $pm = explode( "/", $url2) ;
      $pm = explode( ".", $pm[2] );
      $cglpi = array_shift(explode(":", array_pop( $glpi ))) ;
      $cpm = array_shift(explode(":", array_pop( $pm))) ;
      while( $cglpi && $cpm && $cglpi == $cpm ) {
         $domain = $cglpi.($domain==''?'':'.'.$domain) ;
         $cglpi = array_pop( $glpi ) ;
         $cpm = array_pop( $pm ) ;
      }
      if( $domain != '' ) {
         return $domain ;
      }
   } catch(Exception $e) {}
   return '';
}

/**
 * Summary of glpi_isHTML
 * @return boolean true if content-type is HTML
 */
function glpi_isHTML( ) {
   $needle = 'content-type' ;
   $type = 'text/html' ;
   foreach( headers_list() as $val ) {
      $parts = explode( ":", $val);
{'fraction_non_alphanumeric': 0.1922896097790315, 'fraction_numerical': 0.007522331922896097, 'mean_word_length': 2.3617693522906795, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '107476', 'n_tokens_mistral': 778, 'n_tokens_neox': 777, 'n_words': 186}