Forums | Chat | News | Contact Us | Register | PSU Social |
PSU: Got cat?
Forums | Chat | News | Contact Us | Register | PSU Social |
Home | Forum | Chat | Wiki | Social | AGN | PS2 Stats |
|
|
|
Thread Tools | Search this Thread | Display Modes |
2013-04-08, 03:34 PM | [Ignore Me] #1 | ||
Corporal
|
Greetings all,
This is my take on a split roster using the CSV export of found on your outfit page on PSU. There are 3 entries to edit at the top
Local files required:
Code is otherwise copy paste, but you can edit it, in any way you wish. See example here. Limited support can be given in this thread. Hope it can come to some use to anyone. Source Code:
<?php // Edit this for the CSV Export found at your outfit page on PSU $csv = "http://www.planetside-universe.com/outfit.php?stats=37509488620613138&csv=export"; // Edit this for the secondary rank to split, like recruits. $rnksplit = "Recruit/Inactive"; // Time to Cache in seconds $cache = "3600"; // one hour function formatSeconds($mins) { $mins = (int)$mins; if ( $mins === 0 ) { return "<font color='#666666'>No data</font>"; } // variables for holding values $hours = 0; $days = 0; $weeks = 0; // calculations if ( $mins >= 60 ) { $hours = (int)($mins / 60); $mins = $mins % 60; } if ( $hours >= 24 ) { $days = (int)($hours / 24); $hours = $hours % 24; } // format result $result = ''; if ( $days ) { $result .= "{$days}d "; } if ( $hours ) { $result .= "{$hours}h "; } if ( $mins ) { $result .= "{$mins}m"; } $result = rtrim($result); return $result; } $timer = file("rostertimer.txt"); $offset = time() - $cache; $timerraw = (time() - $timer[0]) / 60; $newtime = explode(".", $timerraw); if($newtime[0] == 1 || $newtime[0] == 0){ $s = ""; } else { $s = "s"; } if($newtime[0] == 0) { $newtime[0] = "<1"; } if($timer[0] < $offset) { // This bit puts the file file_put_contents("roster.csv", file_get_contents($csv)); $timer = fopen("rostertimer.txt","w"); file_put_contents("rostertimer.txt", time()); fclose($timer); $datasave = "This is live data."; } else { $datasave = "Data saved ". $newtime[0] ." minute". $s ." ago."; } $row = 1; if (($handle = fopen("roster.csv", "r")) !== FALSE) { echo "<br /><font size='3'>Members</font> <font size='1' color='#666666'>". $datasave ."</font>"; echo "<table class='roster' cellpadding=5 cellspacing=0 border=0 width='100%'><tr bgcolor='#111111'><td><font color='#ffffff'><b>BR</b></font></td><td><font color='#ffffff'><b>Name</b></font></td><td><div align='center'><font color='#ffffff'><b>Rank</b></font></div></td><td><div align='center'><font color='#ffffff'><b>Kills/Assists</b></font></div></td><td><div align='center'><font color='#ffffff'><b>Score/Min</b></font></div></td><td><div align='center'><font color='#ffffff'><b>Time Played</b></font></div></td><td><div align='center'><font color='#ffffff'><b>Facilities C/D*</b></font></div></td><td><div align='center'><font color='#ffffff'><b>Member since</b></font></div></td><td><div align='right'><font color='#ffffff'><b>Last Login</b></font></div></td></tr>"; while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if($data[3] == $rnksplit) { $recruits[] = array($data[15], $data[1], $data[3], $data[18], $data[21], $data[4], $data[12], $data[10], $data[11], $data[22], $data[23]); $row++; } else { if($trcng == 0) { $trcolor = "#dedede"; $trcng = 1; } else { $trcolor = "#cdcdcd"; $trcng = 0; } $num = count($data); // echo "<p> $num fields in line $row: <br /></p>\n"; if($data[1] == "name_first") { // do nothing } else { echo "<tr bgcolor='". $trcolor ."'>"; echo "<td class='border'>". $data[15] ."</td>"; echo "<td class='border'>". $data[1] ."</td>"; echo "<td class='border'><div align='center'>". $data[3] ."</div></td>"; echo "<td class='border'><div align='center'>". $data[18] ."/"; echo "". $data[21] ."</td></div>"; echo "<td class='border'><div align='center'>". number_format($data[11], 2, '.', '') ."</div></td>"; echo "<td class='border'><div align='center'>". formatSeconds($data[10]) ."</div></td>"; echo "<td class='border'><div align='center'>". $data[22] ."/"; echo "". $data[23] ."</div></td>"; echo "<td class='border'><div align='center'>". date("jS M. 'y", $data[4]) ."</div></td>"; echo "<td class='border'><div align='right'>". date("g:ia jS M. 'y", $data[12]) ."</div></td>"; /* if($data[24] == "0") { echo "<td><font color='#bbbbbb'>Offline</font>"; echo "</td>"; } else { echo "<td><font color='#00FF00'>Online</font>"; echo "</td>"; } */ echo "</tr>"; } $row++; } } echo "</table>"; echo "* Facilities that has been <b>C</b>aptured and <b>D</b>efended<br />"; fclose($handle); } echo "<br /><font size='3'>Recruits / Inactive</font> <font size='1' color='#666666'>". $datasave ."</font>"; echo "<table class='roster' cellpadding=5 cellspacing=0 border=0 width='100%'><tr bgcolor='#111111'><td><font color='#ffffff'><b>BR</b></font></td><td><font color='#ffffff'><b>Name</b></font></td><td><div align='center'><font color='#ffffff'><b>Rank</b></font></div></td><td><div align='center'><font color='#ffffff'><b>Kills/Assists</b></font></div></td><td><div align='center'><font color='#ffffff'><b>Score/Min</b></font></div></td><td><div align='center'><font color='#ffffff'><b>Time Played</b></font></div></td><td><div align='center'><font color='#ffffff'><b>Facilities C/D*</b></font></div></td><td><div align='center'><font color='#ffffff'><b>Member since</b></font></div></td><td><div align='right'><font color='#ffffff'><b>Last Login</b></font></div></td></tr>"; for($i=0; $i<count($recruits); ++$i) { if($trcng == 0) { $trcolor = "#dedede"; $trcng = 1; } else { $trcolor = "#cdcdcd"; $trcng = 0; } $num = count($data); // echo "<p> $num fields in line $row: <br /></p>\n"; if($data[1] == "name_first") { // do nothing } else { echo "<tr bgcolor='". $trcolor ."'>"; echo "<td class='border'>". $recruits[$i][0] ."</td>"; echo "<td class='border'>". $recruits[$i][1] ."</td>"; echo "<td class='border'><div align='center'>". $recruits[$i][2] ."</div></td>"; echo "<td class='border'><div align='center'>". $recruits[$i][3] ."/"; echo "". $recruits[$i][4] ."</td></div>"; echo "<td class='border'><div align='center'>". number_format($recruits[$i][8], 2, '.', '') ."</div></td>"; echo "<td class='border'><div align='center'>". formatSeconds($recruits[$i][7]) ."</div></td>"; echo "<td class='border'><div align='center'>". $recruits[$i][9] ."/"; echo "". $recruits[$i][10] ."</div></td>"; echo "<td class='border'><div align='center'>". date("jS M. 'y", $recruits[$i][5]) ."</div></td>"; echo "<td class='border'><div align='right'>". date("g:ia jS M. 'y", $recruits[$i][6]) ."</div></td>"; echo "</tr>"; } } echo "</table>"; echo "* Facilities that has been <b>C</b>aptured and <b>D</b>efended<br />"; echo "Roster imported from <a href='http://www.planetside-universe.com/'>PSU</a>"; ?>
__________________
Get this or an empire themed dynamic sig with your name on it at http://ps2.gilsweb.com/ Belonging to Long Forgotten Soldiers outfit on Miller, Technology IS Might Last edited by Elahhez; 2013-04-08 at 03:46 PM. |
||
|
|
Bookmarks |
|
|