<?php if (!defined('main')) {die("no direct access");} $clanid = 8324; //Clanid Bei aaotracker $onlinetime = 60; //Zeit die man auf der Seite für online angezeigt wird $cachelifetime = 60; //Sekunden nach der der Cache vom aaotracker erneuert wird $curl = false; //Curl für "Fernzugriff" nutzen if (!function_exists('file_put_contents')) { function file_put_contents($filename, $data) { $f = @fopen($filename, 'w'); if (!$f) { return false; } else { $bytes = fwrite($f, $data); fclose($f); return $bytes; } } } function createCache($clanid){ $players = array(); //XML besorgen if ($curl) { $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, 'http://aaotracker.com/livefeed/xml_clanprofile.php?clanid='.$clanid); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $xml = curl_exec($ch); curl_close($ch); } else { $xml = file_get_contents('http://aaotracker.com/livefeed/xml_clanprofile.php?clanid='.$clanid); } //Onlinestatus auslesen $p = xml_parser_create(); xml_parse_into_struct($p, $xml, $data, $index); xml_parser_free($p); foreach ($index['PLAYERID'] as $key => $id){ $players[$data[$id]['value']] = $data[$index['PLAYERSTATUS'][$key]]['value']; } $cache = '<?php $players = '.var_export($players, true).' ?>'; file_put_contents('include/caches/aaonline.php', $cache); return $players; } if (file_exists('include/caches/aaonline.php')) { if ((time() - filemtime('include/caches/aaonline.php')) > $cachelifetime) { $players = createCache($clanid); } else { include 'include/caches/aaonline.php'; } } else { $players = createCache($clanid); } $dif = time() - $onlinetime; $uid = $aauid = array(); $content = ''; $sql = db_query("SELECT u.name, u.trackerid, u.id AS uid, UNIX_TIMESTAMP(o.uptime) AS uptime, u.llogin FROM prefix_user u LEFT JOIN prefix_online o ON o.uid = u.id WHERE u.recht <= -3 ORDER BY o.uptime DESC, u.llogin DESC"); while ($row = db_fetch_object($sql)) { if ($row->uid != 0 and !in_array($row->uid, $uid)) { $tmp = '<tr><td>'; $online = false; if ($row->uptime > $dif) { $tmp .= '<img src="include/images/icons/online.gif" border="0" alt="online" title="online">'; $online = true; } else { $tmp .= '<img src="include/images/icons/offline.gif" border="0" alt="offline" title="zuletzt eingeloggt um '.date('d.m.Y H:i \U\h\r', $row->llogin).'">'; } if ($players[$row->trackerid] == '1') { $tmp .= ' <a href="http://aaotracker.com/usertracker.php?userid='.$row->trackerid.'" target="_blank"><img src="include/images/icons/trackon.gif" border="0" alt="AA online" title="AA online"></a>'; $online = true; } else { $tmp .= ' <a href="http://aaotracker.com/usertracker.php?userid='.$row->trackerid.'" target="_blank"><img src="include/images/icons/trackoff.gif" border="0" alt="AA offline" title="AA offline"></a>'; } $tmp .= '</td><td><a href="index.php?user-details-'.$row->uid.'">'.$row->name.'</a></td></tr>'."\n"; $aauid[] = $row->uid; if ($online) { $uid[] = $row->uid; $content .= $tmp; } } } //normale Onlinebox $dif = date('Y-m-d H:i:s', time() - $onlinetime); $where = (count($uid)>0) ? 'AND o.uid NOT IN ('.implode(', ', $uid).')' : ''; $abf = "SELECT o.uid, u.name FROM `prefix_online` o LEFT JOIN prefix_user u ON o.uid = u.id WHERE o.uptime > '". $dif."' " . $where; $resultID = db_query($abf); $brk=''; $guests = 0; $guestn = $lang['guests']; while ($row = db_fetch_object($resultID)) { if ($row->uid != 0 AND $brk!=$row->uid) { $content.= '<tr><td><img src="include/images/icons/online.gif" border="0" alt="online"></td>'; $content.='<td><a href="index.php?user-details-'.$row->uid.'">'.$row->name.'</a></td></tr>'."\n"; $uid[] = $row->uid; } if ($row->uid == 0) { $guests++; } $brk=$row->uid; } if ($guests == 1) { $guestn = $lang['guest']; } if (empty($content)) { $content.='<tr><td><img src="include/images/icons/offline.gif" border="0" alt="offline"></td><td><font color="#003366">0 User </font></td></tr>'."\n"; } $content.='<tr><td colspan="2"><hr style="height: 0px; border: dashed #9AB1C8 0px; border-top-width: 1px;"></td></tr>'."\n"; $where = (count($uid)>0) ? 'WHERE id NOT IN ('.implode(', ', $uid).')' : ''; $abf2 = 'SELECT * FROM prefix_user '.$where.' ORDER BY llogin DESC LIMIT 0,5'; $erg2 = db_query($abf2); while ($row2 = db_fetch_object($erg2)) { $datum = date('H:i d.m.y',$row2->llogin); $user = $row2->name; $content.='<tr><td><img src="include/images/icons/offline.gif" border="0" alt="offline"></td><td><a href="index.php?user-details-'.$row2->id.'" title="'.$lang['lasttimeonline'].$datum.'">'.$user.'</a></td></tr>'."\n"; } if ($guests == 0) { $content.= '<tr><td colspan="2"><hr style="height: 0px; border: dashed #9AB1C8 0px; border-top-width: 1px";></td></tr>'."\n".' <tr><td><img src="include/images/icons/offline.gif" border="0" alt="offline"></td><td><font size="-1" color="#003366">0 '.$lang['guests'].'</td></tr>'."\n"; } else { $content.= '<tr><td colspan="2"><hr style="height: 0px; border: dashed #9AB1C8 0px; border-top-width: 1px;"></td></tr>'."\n".' <tr><td><img src="include/images/icons/online.gif" border="0" alt="online"></td><td><font size=-1>'.$guests.' '.$guestn.'</font></td></tr>'."\n"; } ?> <table align="center" border="0" cellpadding="0" cellspacing="0" > <?php echo $content; ?> </table>
So sollte es gehen.
Zuletzt modifiziert von Mairu am 17.05.2009 - 15:10:42