Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- include("header.php");
- if(strlen($_GET['pre'])>1)
- {include($_GET['pre'].".php");}
- else{include("presets.php");}
- date_default_timezone_set('Australia/Brisbane'); // set timezone to hobowars time
- if(isset($_POST['id_list']))
- {
- $id_list_str = $_POST['id_list'];
- $_POST['id_list'] = explode(',',preg_replace('/\s+/','',$_POST['id_list']));
- }
- function csvtoarray($csvdata) // create a function to put csv file into an array
- {
- $rows = explode("\n", trim($csvdata)); // use the newline as a delimiter to separate rows
- $temp_array[0] = explode(',', preg_replace('/\s+/','',$rows[0])); // get headers, types of stats. remove whitespace from stat names
- for($i = 1; $i < count($rows); $i++) // run a loop for each row
- {
- $temp = explode(', ', $rows[$i]); //exploding each row at commas
- for($i2 = 0; $i2 < count($temp); $i2++) //run a loop for each stat in the row
- {
- $temp_array[$temp[1]][$temp_array[0][$i2]]=($temp[$i2]); //for each member, make an array key with the ID as value, then a sub-key with the stat name as key, and stat vaule as value
- }
- }
- return $temp_array; // returning the results of the function
- }
- function ex_range($ez,$v)
- {
- $ez=explode('-',$ez);
- if($v>=$ez[0] AND $v<=$ez[1])
- {return true;}
- else
- {return false;}
- }
- function array_orderby()
- {
- $args = func_get_args();
- $data = array_shift($args);
- foreach ($args as $n => $field) {
- if (is_string($field)) {
- $tmp = array();
- foreach ($data as $key => $row)
- $tmp[$key] = $row[$field];
- $args[$n] = $tmp;
- }
- }
- $args[] = &$data;
- call_user_func_array('array_multisort', $args);
- return array_pop($args);
- }
- if($_POST['colored_names'] == 'y')
- {
- if($_POST['startcolor']=="rr")
- {
- $rr_colors=array('cc0000','ff9900','66cc00','339966','0099cc','3366ff','3300cc');
- for($lc=0; $lc < ($_POST['top_num']); $lc++)
- {
- $color['r'][$lc]=hexdec(substr($rr_colors[($lc % count($rr_colors))],0,2));
- $color['g'][$lc]=hexdec(substr($rr_colors[($lc % count($rr_colors))],2,2));
- $color['b'][$lc]=hexdec(substr($rr_colors[($lc % count($rr_colors))],4,2));
- }
- }
- elseif($_POST['startcolor']=="hw")
- {
- $rr_colors=array('FA8202','000000','E67700','66411A');
- for($lc=0; $lc < ($_POST['top_num']); $lc++)
- {
- $color['r'][$lc]=hexdec(substr($rr_colors[($lc % count($rr_colors))],0,2));
- $color['g'][$lc]=hexdec(substr($rr_colors[($lc % count($rr_colors))],2,2));
- $color['b'][$lc]=hexdec(substr($rr_colors[($lc % count($rr_colors))],4,2));
- }
- }
- else
- {
- $color['r'][0]=hexdec(substr($_POST['startcolor'],0,2));
- $color['g'][0]=hexdec(substr($_POST['startcolor'],2,2));
- $color['b'][0]=hexdec(substr($_POST['startcolor'],4,2));
- for($lc=1; $lc < $_POST['top_num']; $lc++)
- {
- $color['r'][$lc]=$color['r'][0]-(floor($color['r'][0]/$_POST['top_num'])*$lc);
- $color['g'][$lc]=$color['g'][0]-(floor($color['g'][0]/$_POST['top_num'])*$lc);
- $color['b'][$lc]=$color['b'][0]-(floor($color['b'][0]/$_POST['top_num'])*$lc);
- }
- }
- }
- $old_stats=csvtoarray($_POST['data_old_view']); // make old data array
- $new_stats=csvtoarray($_POST['data_new_view']); // make new data array
- $old_time_epoch=strtotime($_POST['old_time']); // convert old time from plain text to unix epoch
- $new_time_epoch=strtotime($_POST['new_time']); // convert new time from plain text to unix epoch
- $mc=0;
- foreach ($new_stats as $value)
- { // for each member
- if($value['ID'] > 0)
- { // if ID is greather than zero
- $lc=0; // setting the loop count to zero
- foreach ($value as $value2)
- { // for each stat
- if(in_array($new_stats[0][$lc],array('Name','ID','Age','LastActive','Chamber'))){$difference[$mc][$new_stats[0][$lc]]=$value2;} // if current loop is calulating items in array, set gains array to current (new data) value
- elseif(($old_stats[$value['ID']][$new_stats[0][$lc]]=='' OR $value2=='') AND !in_array($new_stats[0][$lc],array('Exp','BegIncome','Cash','Points','Tokens','DPs'))){$difference[$mc][$new_stats[0][$lc]]=0;
- $old_stats[$value['ID']][$new_stats[0][$lc]]=$value2;}
- elseif($value2 < $old_stats[$value['ID']][$new_stats[0][$lc]] AND in_array($new_stats[0][$lc],array('Exp','BegIncome')))
- {$difference[$mc][$new_stats[0][$lc]]=$value2;}
- else{$difference[$mc][$new_stats[0][$lc]]=$value2-$old_stats[$value['ID']][$new_stats[0][$lc]];} // if none of the above, subtract old stat from new stat, and set that for gains array
- $lc++; // increment the loop counter
- } // for each stat
- } // if ID greater than zero
- $mc++;
- } // for each member
- include("formula.php");
- include("datastore.php");
- echo'<form action="" method="get">
- <input type="button" value="Highlight All Output" onClick="javascript:this.form.output.focus();this.form.output.select();">
- (Push Ctrl-C to copy, or right click and select copy after highlighting)<br />';
- echo '<textarea name="textarea" id="output" wrap="off" cols="85" rows="48">';
- echo"Gains from [b]".$_POST['old_time']."[/b] to [b]".$_POST['new_time']."[/b] ";
- echo "(".round((strtotime($_POST['new_time'])-strtotime($_POST['old_time']))/86400,2)." Days)\n";
- if($_POST['bold_gains']=='y'){echo"[b]";}
- echo"\n";
- if(isset($_POST['gain_type']))
- {
- foreach($_POST['gain_type'] as $stat_type)
- { // for each stat type to show
- $type_total=0;
- $type_show_count=0;
- if($_POST['bold_gains']<>'y'){echo "[b]";}
- if(strlen($_POST['formula_alt']) > 1 AND $stat_type=='Formula'){echo "***".$_POST['formula_alt']."***";}
- else
- {
- echo "***".$stat_type;
- if($stat_type<>'Formula'){echo " Difference";}
- echo "***";
- }
- if($_POST['bold_gains']<>'y'){echo "[/b]";}
- echo"\n";
- $sorted2 = array_orderby($difference, $stat_type, SORT_DESC);
- //$sorted2 = $difference;
- //eval("$_POST['id_list']=array(".$_POST['id_list'].");";
- /*if(isset($_POST['id_list']))
- {
- $_POST['id_list'] = explode(',',preg_replace('/\s+/','',$_POST['id_list']));
- }
- */
- foreach($sorted2 as $member)
- { // for each gang member
- if(
- ($member[$stat_type] > 0 AND $_POST['ex_pos'] == 'y') OR
- ($member[$stat_type] == 0 AND $_POST['ex_zer'] == 'y') OR
- ($member[$stat_type] < 0 AND $_POST['ex_neg'] == 'y') OR
- ex_range($_POST['ex_range'],$member[$stat_type]) OR
- ($_POST['id_list_type']=='blk' AND in_array($member['ID'],$_POST['id_list'])) OR
- ($_POST['id_list_type']=='wht' AND !in_array($member['ID'],$_POST['id_list']))
- )
- {$noshow='';} //if exculded due to direction of or lack of gain
- else{ //if not excluded
- $type_total=$type_total+$member[$stat_type];
- if($_POST['colored_names'] == 'y' AND $type_show_count < $_POST['top_num'])
- {
- echo "[hex=".
- str_pad(dechex($color['r'][$type_show_count]), 2, "0", STR_PAD_LEFT).
- str_pad(dechex($color['g'][$type_show_count]), 2, "0", STR_PAD_LEFT).
- str_pad(dechex($color['b'][$type_show_count]), 2, "0", STR_PAD_LEFT).
- "]";
- }
- if($_POST['comma_gains']=='y'){echo number_format($member[$stat_type])." - ";}else{echo $member[$stat_type]." - ";}
- if($_POST['hoboname']=='y'){echo "[hoboname=".$member['ID']."]";}
- else{
- echo $member['Name']." (";
- if($_POST['link_names']=='y'){echo"[hobo=".$member['ID']."]";}
- echo $member['ID'];
- if($_POST['link_names']=='y'){echo"[/hobo]";}
- echo ")";
- }
- if($_POST['colored_names'] == 'y' AND $type_show_count < $_POST['top_num']){echo"[/hex]";}
- echo "\n";
- $type_show_count++;
- } // if not excluded
- } // for each gang member
- echo "\nTotal: ".number_format($type_total)."\n";
- echo "\n\n";
- } // for each stat type to show
- }
- if($_POST['bold_gains']=='y'){echo "[/b]";}
- echo "</textarea>";
- echo"</form>";
- ?>
- </td>
- </tr>
- </table>
- <?
- include("footer.php");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement