igor@142: <?
igor@142: $wgExtensionFunctions[] = "wfLiLaLoExtension";
igor@142: 
igor@142: function wfLiLaLoExtension() {
igor@142:     global $wgParser;
igor@142:     $wgParser->setHook( "lilalo", "renderLiLaLoPRE" );
igor@142: }
igor@142: 
igor@142: function renderLiLaLoPRE( $input ) {
igor@143:     preg_match('/[^\n]*l3: local_session_id=([0-9-]*)[^\n]*[\n]/', $input, $matches);
igor@143:     $session_id=$matches[1];
igor@143:     preg_match('/([0-9]*)-([0-9]*)/', $session_id, $matches);
igor@143:     $session_start_time = intval($matches[2]);
igor@143:     $hour=intval(date('G', $session_start_time));
igor@143:     $min=intval(date('i', $session_start_time));
igor@143:     $sec=intval(date('s', $session_start_time));
igor@143:     $input = preg_replace('/[^\n]*l3: local_session_id=([0-9-]*)[^\n]*[\n]/', '', $input);
igor@143:     $input = preg_replace('/((..):(..):(...)(#[^\n]*))/e', 
igor@143:                           '\'$2:$3:$4<b><a href="http://xgu.ru/l3?page='.$session_id.'&id='
igor@143:                              .'\'.strval($session_start_time+3600*(intval("$2")-$hour)+60*(intval("$3")-$min)+1*(intval("$4")-$sec)).\''
igor@143:                              .'">$5</a></b>\'', 
igor@143:                           $input);
igor@143: #                             .strval($session_start_time+3600*(intval($2)-$hour)+60*(intval($3)-$min)+(intval($4)-$sec))
igor@143:     return "<pre>$hour:$min:$sec $input</pre>";
igor@142: }
igor@142: 
igor@142: ?>