'' ) { $hgmodulepath = str_replace( '/' . $langcode . '/', '/', $hgmodulepath ); } # Non-clean URLs need removing ?q= $hgmodulepath = str_replace( "?q=", "", $hgmodulepath ); if ( $_GET['dtd'] == 1 ) { # Just supply the dtd. #ob_start(); #echo 'http://www.bdeev.com' . $hgmodulepath . '/graphs/GraphXML.dtd'; #echo $hgmodulepath; include $hgmodulepath . 'GraphXML.dtd'; #include 'http://www.bdeev.com/sites/all/modules/hypergraph/graphs/GraphXML.dtd'; #$dtdfile = ob_get_clean(); #echo $dtdfile; exit(); } header("Content-type: text/xml"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); $hgcachexpire = 3600; # Cache expiration time. #global $user; $userId = $user->uid; $hgmenucacheid = 'hg_menu_' . $userId . '_' . $_GET['par']; /* $begxml = ''; */ $begxml = ''; $endxml = ''; /* $fullxml = ''; ' echo $fullxml; exit(); */ #if ( $_SERVER['SERVER_ADDR'] == '64.13.192.90' ) { if ( variable_get('hypergraph_cache', 'd') == 'f' ) { #echo '.....................' . $_SERVER['SERVER_ADDR']; $temp = filecaching_wrapper_hgm(); } else { $temp = caching_wrapper_hgm(); } #echo $hgmenucacheid; /* $tstart = time(); do { sleep(1); # Give MySQL the time to write the data to the cache (if unfinished) $r = db_query( "SELECT * FROM cache WHERE `cid` = '" . $hgmenucacheid . "'" ) or die(mysql_error()); $appletdata = ''; while( $h = db_fetch_object($r) ) { $temp = $h->data; $appletdata = unserialize( $temp ); } } while ( ( ( time() - $tstart ) < 10 ) and $temp == '' ); # Search for the expected cache (there can be delay) but no longer than 60 seconds. */ if ( $temp <> '' ) { echo $temp; } else { echo $begxml; echo ' '; echo $endxml; } exit(); # IMPORTANT - otherwise any process after Hypergraph adds strings and breaks the XML! function filecaching_wrapper_hgm( $reset = FALSE ) { global $hgcachexpire; global $hgmenucacheid; global $begxml; global $endxml; #echo $hgmenucacheid; $cachedfile = file_directory_temp() . '/' . $hgmenucacheid; $lastchanged = filectime( $cachedfile ); if ( $lastchanged === false or ( time() - $lastchanged > ( $hgcachexpire ) ) ) { #echo '. 1.... '; # Cache file does not exist or is too old. $my_data = $begxml . hypergraph_get_menu( NULL ) . $endxml; # Now put $my_data to cache! $fh = fopen( $cachedfile, "w+" ); fwrite( $fh, $my_data ); fclose( $fh ); } else { #echo '. 2.... '; # Cache file exists. $my_data = file_get_contents( $cachedfile ); } return $my_data; } function caching_wrapper_hgm( $reset = FALSE ) { global $hgcachexpire; global $hgmenucacheid; global $begxml; global $endxml; #echo $hgmenucacheid; static $my_data; #echo '0.... '; if ( !isset($my_data) || $reset ) { if (!$reset && ($cache = cache_get($hgmenucacheid)) && !empty($cache->data)) { $my_data = $cache->data; #echo '1.... ';# . $my_data; } else { // Do your expensive calculations here, and populate $my_data // with the correct stuff.. $my_data = $begxml . hypergraph_get_menu( NULL ) . $endxml; cache_set($hgmenucacheid, 'cache', $my_data, time() + $hgcachexpire); } } return $my_data; } function hypergraph_get_menu( $beginfrom ) { ob_start(); $vid = 1; // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from $terms = taxonomy_get_tree($vid); echo ''; foreach ($terms as $list) { $nodeDepth = $list->depth + 1; echo ''; echo ''; echo ''; } $nodeIDList = array(); foreach ($terms as $findRoots) { if ($findRoots->depth < 1) { echo ''; } foreach ($terms as $child) { $parents = $child->parents; foreach ($parents as $parent) { if ($parent == $findRoots->tid) { echo ''; } } } $count = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $findRoots->tid)); if ($count > 0) { $nodeDepth2 = $findRoots->depth + 2; $result = db_query("SELECT * FROM {term_node} WHERE tid = %d", $findRoots->tid); while($zaznam = db_fetch_array($result)) { $node = db_result(db_query("SELECT title FROM {node} WHERE nid=$zaznam[nid]")); $nodeInList = 0; foreach ($nodeIDList as $nodeID) { if ($nodeID == $zaznam[nid]) { $nodeInList++; } } if ($nodeInList < 1) { $nodeIDList[] = $zaznam[nid]; echo ''; echo ''; echo ''; } } $result = db_query("SELECT * FROM {term_node} WHERE tid = %d", $findRoots->tid); while($zaznam = db_fetch_array($result)) { echo ''; } } } $temp = ob_get_clean(); return $temp; } # Some people don't have PHP5 yet... function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } ?>