function getbodygraph($object, $hitgroups, $disparmor = '', $headers = 1, $dec = 0) { $positions = array('HITGROUP_HEAD' => '78,22', 'HITGROUP_CHEST' => '78,86', 'HITGROUP_STOMACH' => '78,136', 'HITGROUP_LEFTARM' => '122,122', 'HITGROUP_RIGHTARM' => '32,122', 'HITGROUP_LEFTLEG' => '56,222', 'HITGROUP_RIGHTLEG' => '94,222'); global $armors, $range; $graph = ''; $header = ''; if (!is_array($disparmor)) { $disparmor = array($disparmor); } foreach ($disparmor as $armor) { $graph .= "<td><div class='bodygraph'>"; $armordata = array(); foreach ($positions as $key => $val) { $armordata[$key] = isset($armors[$armor][$key]) ? round($armors[$armor][$key], 2) : 1; } $dist = dist($GLOBALS['range'], 'IN'); $header .= "<th>{$armor} @ {$dist}</th>"; foreach ($armordata as $key => $val) { $eq = ''; if (isset($object["Damage"])) { $basedmg = damageatrange($object['Damage'], $range); $result = $basedmg * $armors['No Armor'][$key]; $eq .= "base damage: {$basedmg}\nbase hitgroup: * {$armors['No Armor'][$key]}\n"; if ($hitgroups[$key]) { $result *= $hitgroups[$key]; $eq .= "ammo hitgroup: * {$hitgroups[$key]}\n"; } if ($armor != 'No Armor') { $eq .= "armor hitgroup: * {$val}\n"; $result *= $val; } if ($object['bulletcount'] > 1) { $eq .= "bullet count: * {$object['bulletcount']}\n"; $result *= $object['bulletcount']; } $eq .= "total: {$result}\n"; } else { $result = $val * $armordata[$key] * $hitgroups[$key]; } $result = round($result, $dec); $coords = explode(',', $positions[$key]); $graph .= "<div title='{$eq}' style='position: absolute; left: {$coords[0]}px; top: {$coords[1]}px; width: 100px; text-align: center; transform: translate(-50%, -50%);'>{$result}</div>"; } $graph .= "</div></td>"; } if ($headers) { $retval = "<table><tr>{$header}</tr><tr>{$graph}</tr></table>"; } else { $retval = "<table><tr>{$graph}</tr></table>"; } return $retval; }
/** * Assigns points to one of the centroids * @param array $data the data points to cluster * @param array $centroids The array of centroids * @param int $k The number of clusters */ function assign_points($data, $centroids, $k) { foreach ($data as $datum_index => $datum) { foreach ($centroids as $centroid) { $distances[$datum_index][] = dist($datum, $centroid); } } foreach ($distances as $distance_index => $distance) { $which_cluster = min_key($distance); $tentative_clusters[$which_cluster][] = $distance_index; $distances_from_clusters = array("{$distance_index}" => $distance); } //in case there's not enough clusters, take the farthest element from any of the cluster's centres //and make it a cluster. if (count($tentative_clusters) < $k) { $point_as_cluster = max_key($distances_from_clusters); foreach ($tentative_clusters as $tentative_index => $tentative_cluster) { foreach ($tentative_cluster as $tentative_element) { if ($tentative_element == $point_as_cluster) { $clusters[$k + 1][] = $tentative_element; } else { $clusters[$tentative_index][] = $tentative_element; } } } } else { $clusters = $tentative_clusters; } return $clusters; }
//For some reason, stuff is running infinitely. Lets also pause when a certain number of iterations are over. $flag = 0; $iterations = $numberofpoints * $numberofpoints; do { $flag = 0; $iterations = $iterations - 1; //For each point, calculate its distance from the k means and assign a color to each point for ($i = 0; $i < $numberofpoints; $i++) { $mindistance = 1000000; $whichcolor = -1; $tempx = $points[$i]['x']; $tempy = $points[$i]['y']; $originalcolor = $points[$i]['color']; //This loop iterates through all k means for ($j = 0; $j < $k; $j++) { $tempdistance = dist($means[$j]->x, $means[$j]->y, $tempx, $tempy); if ($tempdistance < $mindistance) { $mindistance = $tempdistance; $whichcolor = $j; } } //Now assign whichcolor to the point i $points[$i]['color'] = $whichcolor; if ($originalcolor != $points[$i]['color']) { $flag = 1; } } //Calculate new value of means based on the points allocated to each mean //This loop goes through each color and calculates a mean for it for ($i = 0; $i < $k; $i++) { $n = 0;
} } } $flag = 0; $emp = !empty($S); $i = -1; while ($emp == 1 && $flag == 0) { //while($S[++$i]==""){$P = $S[$i];} $P = $S[current(array_keys($S))]; $PC = mysql_query("select * from clus" . $P . " LIMIT 1"); $pc = mysql_fetch_array($PC); $em = !empty($U); $j = 0; while ($em == 1 && !is_null($pc['id'])) { //select Q CLOSEST to P array_multisort(dist($pc, $U), $U); $Q = $U[0]; $CQ = mysql_query("select COUNT(*) as numQ from clus" . $Q); $cQ = mysql_fetch_assoc($CQ); // var_dump($CQ); $CP = mysql_query("select COUNT(*) as numP from clus" . $P); $cP = mysql_fetch_assoc($CP); // var_dump($CP); if ($k - $cQ['numQ'] > $cP['numP']) { mysql_query("insert into clus" . $Q . " select * from clus" . $P . " LIMIT " . $cP['numP']); } else { mysql_query("insert into clus" . $Q . " select * from clus" . $P . " LIMIT " . $k - $cQ['numQ']); unset($U[$j]); $j++; $V[$c['numC']++] = $Q; mysql_query("delete from clus" . $P . " where id in (select id from clus" . $P . " LIMIT" . $k - $cQ['numQ'] . ")");
<?php class Car { public $color; public $type; } $myCar = new Car(); $myCar->color = 'red'; $myCar->type = 'sedan'; $yourCar = new Car(); $yourCar->color = 'blue'; $yourCar->type = 'suv'; $cars = array($myCar, $yourCar); $a = "abc"; $b = 3; $a = $b; //echo $a; function dist($x1, $y1, $x2, $y2) { $temp = ($x1 - $x2) * ($x1 - $x2) + ($y1 - $y2) * ($y1 - $y2); return sqrt($temp); } echo dist(3, 3, 4, 4);
function closest4bot($bx, $by, $bside) { //global $stat,$max1,$link; global $stat, $max1; $t_sys = array(1, 1, 100, ''); // первые 2 значения отвечают за координаты и последняя - расстояние $do_SQL = 'SELECT `participants`.`x`,`participants`.`y`,`players`.`user`,`battles`.`x` as `bx`,`battles`.`y` as `by` FROM `participants`,`players`,`battles` WHERE `participants`.`time`=' . $stat['battle'] . ' AND `participants`.`side`=' . (1 - $bside) . ' AND `participants`.`hp`>0 AND `players`.`id`=`participants`.`id` AND `battles`.`id`=' . ($max1['id'] + 1) . ' AND `battles`.`offer`=' . $stat['battle'] . ' AND `battles`.`attacker`=`players`.`user` and players.hp_now>0'; $get = mysql_query($do_SQL); while ($cords = mysql_fetch_array($get)) { if (is_numeric($cords['bx']) && is_numeric($cords['by'])) { $tdist = dist($bx, $by, $cords['bx'], $cords['by']); } else { $tdist = dist($bx, $by, $cords['x'], $cords['y']); } //echo 'Дистанция между ботом и целью: '.$tdist.'<br>'; if ($tdist < $t_sys[2]) { $t_sys[0] = $cords['x']; $t_sys[1] = $cords['y']; $t_sys[2] = $tdist; $t_sys[3] = $cords['user']; //echo 'success!!<br>'; } } return $t_sys; }
$js_tid = $command['left_id'][$i]; $js_tname = $command['left'][$i]; $js_tx = is_numeric($jjjs['x']) && $jjjs['type'] == 0 ? $jjjs['x'] : $command['left_x'][$i]; $js_ty = is_numeric($jjjs['y']) && $jjjs['type'] == 0 ? $jjjs['y'] : $command['left_y'][$i]; } // $type = mysql_fetch_array(mysql_query("SELECT `type` FROM battles WHERE attacker='".$command['left'][$i]."'")); echo "<a href=\"javascript:top.to('" . $command['left'][$i] . "')\" oncontextmenu=\"top.pp('" . $command['left'][$i] . "'); return false;\"><font color='blue'>" . $command['left'][$i] . "</font></a> <SMALL>[ " . $command['left_hp'][$i] . " ]</SMALL>"; if ($i + 1 < count($command['left'])) { echo ", "; } $js_info .= ($command['left'][$i] != $stat['user'] ? "create" : "my") . "per(" . (is_numeric($jjjs['x']) && $jjjs['type'] == 0 ? $jjjs['x'] : $command['left_x'][$i]) . "," . (is_numeric($jjjs['y']) && $jjjs['type'] == 0 ? $jjjs['y'] : $command['left_y'][$i]) . ",'" . $command['left'][$i] . "'," . $command['left_id'][$i] . ",'1'," . $jjjs['type'] . ",{$command['left_fr'][$i]});"; } echo " <b>против</b> "; for ($i = 0; $i < count($command['right']); $i++) { if ($participant['side'] == 0 && dist($participant['x'], $participant['y'], $command['right_x'][$i], $command['right_y'][$i]) < $js_dist) { $js_dist = dist($participant['x'], $participant['y'], $command['right_x'][$i], $command['right_y'][$i]); $js_tid = $command['right_id'][$i]; $js_tname = $command['right'][$i]; $js_tx = is_numeric($jjjs['x']) && $jjjs['type'] == 0 ? $jjjs['x'] : $command['right_x'][$i]; $js_ty = is_numeric($jjjs['y']) && $jjjs['type'] == 0 ? $jjjs['y'] : $command['right_y'][$i]; } echo "<a href=\"javascript:top.to('" . $command['right'][$i] . "')\" oncontextmenu=\"top.pp('" . $command['right'][$i] . "'); return false;\"><font color='red'>" . $command['right'][$i] . "</font></a> <SMALL>[ " . $command['right_hp'][$i] . " ]</SMALL>"; if ($i + 1 < count($command['right'])) { echo ", "; } $sql_right = mysql_query("SELECT `type`,`x`,`y` FROM battles WHERE attacker='" . $command['right'][$i] . "' AND offer=" . $stat['battle'] . " ORDER by `time` DESC LIMIT 1"); $jjjs = mysql_fetch_array($sql_right); if (mysql_num_rows($sql_right) == 0) { $jjjs = array('type' => 1); } $js_info .= ($command['right'][$i] != $stat['user'] ? "create" : "my") . "per(" . (is_numeric($jjjs['x']) && $jjjs['type'] == 0 ? $jjjs['x'] : $command['right_x'][$i]) . "," . (is_numeric($jjjs['y']) && $jjjs['type'] == 0 ? $jjjs['y'] : $command['right_y'][$i]) . ",'" . $command['right'][$i] . "'," . $command['right_id'][$i] . ",'2'," . $jjjs['type'] . ",{$command['right_fr'][$i]});";
function GenerateStatTable() { global $stats_tables, $theater, $upgrades, $armors, $range; $armors = array('No Armor' => $theater['player_settings']['damage']['DamageHitgroups']); foreach ($theater["player_gear"] as $gearname => $data) { $gear = getobject("player_gear", $gearname); $img = getvgui($gearname, 'css'); $thisitem = array(); $thisitem['Img'] = $img; $thisitem['Name'] = getlookup($gear['print_name']); $thisitem['Team'] = printval($gear, "team_access"); $thisitem['Slot'] = printval($gear, "gear_slot"); $thisitem['Cost'] = printval($gear, "gear_cost"); $thisitem['Weight'] = printval($gear, "gear_weight"); $thisitem['Ammo'] = printval($gear, "extra_ammo"); if (isset($gear["DamageHitgroups"])) { $thisitem['DamageHitgroups'] = getbodygraph($gear, $gear["DamageHitgroups"], '', 0, 2); } $stats_tables['Gear']['items'][$gearname] = $thisitem; if ($data["gear_slot"] == 'armor') { $armors[$thisitem['Name']] = $gear["DamageHitgroups"]; } } foreach ($theater["weapons"] as $wpnname => $data) { if (isset($data["IsBase"])) { continue; } $thisitem = array(); $item = getobject("weapons", $wpnname); $pn = getlookup($item["print_name"]); $img = getvgui($wpnname, 'css'); $thisitem['Img'] = $img; $thisitem['Name'] = getlookup($item["print_name"]); $thisitem['Class'] = printval($item, "weapon_class"); $thisitem['CR'] = printval($item, "class_restricted") ? printval($item, "class_restricted") : 0; $thisitem['Length'] = dist($item["barrel_length"], 'IN'); $thisitem['Cost'] = printval($item, "weapon_cost"); $thisitem['Slot'] = printval($item, "weapon_slot"); $thisitem['Weight'] = printval($item, "weapon_weight"); $thisitem['RPM'] = printval($item, "rounds_per_minute"); $thisitem['Sway'] = printval($item, "sway"); $thisitem['Damage'] = 0; if (isset($item["ballistics"])) { $thisitem['Fire Modes'] = printval($item["ballistics"], "FireModes"); } else { $thisitem['Fire Modes'] = 'single'; } if (isset($item["explosives"])) { $thisitem['Ammo'] = printval($item["explosives"], "entity", 1); $expammo = getobject("ammo", $item["ammo_clip"]["ammo_type"]); $thisitem['Carry'] = printval($expammo, "carry"); $thisitem['Carry Max'] = printval($expammo, "carry"); } elseif (isset($item["ammo_clip"])) { $ammo = getobject("ammo", $item["ammo_clip"]["ammo_type"]); $dmg = damageatrange($ammo['Damage'], $range); $thisitem['Damage'] = $dmg; if ($ammo['bulletcount'] > 1) { $thisitem['Damage'] = $dmg * $ammo['bulletcount'] . " max ({$ammo['bulletcount']} pellets)"; } $thisitem['DamageChart'] = printval($ammo, "Damage"); $thisitem['Spread'] = getspreadgraph($item["ballistics"]['spread']) . "<br>{$item["ballistics"]['spread']}"; $thisitem['Recoil'] = getrecoilgraph($item['recoil']); $thisitem['Ammo'] = printval($item["ammo_clip"], "ammo_type", 1); if ($item["ammo_clip"]["clip_max_rounds"] > 1 && !$item["ballistics"]["singleReload"]) { $thisitem['Magazine'] = printval($item["ammo_clip"], "clip_max_rounds"); $thisitem['Carry'] = printval($item["ammo_clip"], "clip_default") . " (" . $item["ammo_clip"]["clip_max_rounds"] * $item["ammo_clip"]["clip_default"] . ")\n"; $thisitem['Carry Max'] = printval($item["ammo_clip"], "clip_max") . " (" . $item["ammo_clip"]["clip_max_rounds"] * $item["ammo_clip"]["clip_max"] . ")\n"; } else { $thisitem['Magazine'] = printval($item["ammo_clip"], "clip_max_rounds"); $thisitem['Carry'] = printval($item["ammo_clip"], "clip_default"); $thisitem['Carry Max'] = printval($item["ammo_clip"], "clip_max"); } } elseif (isset($item["melee"])) { $thisitem['Damage'] = printval($item["melee"], "MeleeDamage"); } $stats_tables['Weapons']['items'][$wpnname] = $thisitem; } foreach ($theater["weapon_upgrades"] as $upname => $data) { if (isset($data["IsBase"])) { continue; } // if ((substr($upname,0,5) == "base_") || (substr($upname,-5,5) == "_base")) { // continue; // } $upgrade = getobject("weapon_upgrades", $upname, 1); $img = getvgui($upname, 'css'); $thisitem = array(); if (isset($upgrade['attach_weapon'])) { if (isset($stats_tables['Weapons']['items'][$upgrade['attach_weapon']])) { $stats_tables['Weapons']['items'][$upgrade['attach_weapon']]['Img'] = $img; } } if (substr($upname, 0, 5) == "ammo_") { $link = "<br><a href='#{$upgrade['ammo_type_override']}'>{$upgrade['ammo_type_override']} [{$upgrade['upgrade_cost']}]</a>"; $fn = 'Ammo'; } else { $link = "<a href='#{$upname}'>" . getlookup($upgrade['print_name']) . " [{$upgrade['upgrade_cost']}]</a><br>"; $fn = 'Upgrades'; } // Add ammo and upgrade links to weapon items if (isset($upgrade['allowed_weapons']['weapon'])) { $tmp = $upgrade['allowed_weapons']['weapon']; $upgrade['allowed_weapons'] = is_array($tmp) ? $tmp : array($tmp); } $aw = array(); if (isset($upgrade['allowed_weapons'])) { foreach ($upgrade['allowed_weapons'] as $order => $witem) { $aw[] = "<a href='#{$witem}'>{$stats_tables['Weapons']['items'][$witem]['Name']}</a>"; $stats_tables['Weapons']['items'][$witem][$fn] .= $link; } } $thisitem['Img'] = $img; $thisitem['Name'] = getlookup($upgrade['print_name']); $thisitem['Slot'] = printval($upgrade, "upgrade_slot"); $thisitem['CR'] = printval($upgrade, "class_restricted"); $thisitem['Cost'] = printval($upgrade, "upgrade_cost"); $thisitem['Ammo Type'] = printval($upgrade, "ammo_type_override", 1); $thisitem['Abilities'] = printval($upgrade, "weapon_abilities"); $thisitem['Weapons'] = implode("<br>", $aw); $stats_tables['Upgrades']['items'][$upname] = $thisitem; } foreach ($theater["ammo"] as $ammoname => $data) { // Hide rockets and grenades (so we can link to them in #explosives), and other items we don't want to see at all if (substr($ammoname, 0, 7) == "rocket_" || substr($ammoname, 0, 8) == "grenade_" || $ammoname == 'default' || $ammoname == 'no_carry') { continue; } $ammo = getobject("ammo", $ammoname); if (!isset($ammo['carry'])) { continue; } $thisitem = array(); $thisitem['Name'] = "<a id='{$ammoname}'>{$ammoname}</a>"; $thisitem['Carry'] = printval($ammo, "carry"); $thisitem['Mag'] = printval($ammo, "magsize"); $dmg = damageatrange($ammo['Damage'], $range); if ($ammo['bulletcount'] > 1) { $dmg = $dmg * $ammo['bulletcount'] . " max ({$ammo['bulletcount']} pellets)"; } $thisitem['Damage'] = $dmg; $thisitem['DamageGraph'] = printval($ammo, "Damage"); $thisitem['PenetrationPower'] = damageatrange($ammo["PenetrationPower"], $range); $thisitem['PenetrationGraph'] = printval($ammo, "PenetrationPower"); $thisitem['Tracer'] = "Type: {$ammo["tracer_type"]}<br>Frequency: {$ammo["tracer_frequency"]}<br>Low Ammo: {$ammo["tracer_lowammo"]}"; $thisitem['Suppression'] = printval($ammo, "SuppressionIncrement"); $thisitem['DamageHitgroups'] = getbodygraph($ammo, $ammo["DamageHitgroups"], array_keys($armors)); $stats_tables['Ammo']['items'][$ammoname] = $thisitem; } foreach ($theater["explosives"] as $explosivename => $data) { if (isset($data["IsBase"])) { continue; } $explosive = getobject("explosives", $explosivename); $thisitem = array(); $thisitem['Name'] = "<a id='{$explosivename}'>{$explosivename}</a>"; $thisitem['Class'] = printval($explosive, "entity_class"); $thisitem['FuseTime'] = printval($explosive, "FuseTime"); if (isset($explosive["Cookable"])) { $thisitem['Cookable'] = printval($explosive, "Cookable"); } else { $thisitem['Cookable'] = 1; } if (isset($explosive["RocketStartSpeed"])) { $speeds = array($explosive["RocketStartSpeed"]); if (isset($explosive["RocketTopSpeed"])) { if (isset($explosive["RocketAcceleration"])) { for ($i = $explosive["RocketStartSpeed"] + $explosive["RocketAcceleration"]; $i < $explosive["RocketTopSpeed"]; $i += $explosive["RocketAcceleration"]) { $speeds[] = $i; } } $speeds[] = $explosive["RocketTopSpeed"]; } } if (count($speeds) > 1) { $thisitem['Speed'] = getgraph($speeds, 'Speed', 'Time'); } else { $thisitem['Speed'] = dist($explosive["RocketStartSpeed"], 'IN') . "/s"; } $dmg = $range < $explosive["DetonateDamageRadius"] ? round($explosive["DetonateDamage"] * ($explosive["DetonateDamageRadius"] / ($explosive["DetonateDamageRadius"] - $range)), 2) : 0; $thisitem['Damage'] = $dmg; if (isset($explosive["AreaDamageAmount"])) { $thisitem['DamageGraph'] = "AreaDamageTime: {$explosive["AreaDamageTime"]}<br>AreaDamageFrequency: {$explosive["AreaDamageFrequency"]}<br>AreaDamageMinRadius: " . dist($explosive["AreaDamageMinRadius"], 'IN') . "<br>AreaDamageMaxRadius: " . dist($explosive["AreaDamageMaxRadius"], 'IN') . "<br>AreaDamageGrowSpeed: {$explosive["AreaDamageGrowSpeed"]}<br>AreaDamageAmount: {$explosive["AreaDamageAmount"]}<br>DamageType: {$explosive["DamageType"]}"; } else { $thisitem['DamageGraph'] = getcirclegraph($explosive) . "<br>DetonateDamage: {$explosive["DetonateDamage"]}<br>DetonatePenetrationRadius: " . dist($explosive["DetonatePenetrationRadius"], 'IN') . "<br>DetonateDamageRadius: " . dist($explosive["DetonateDamageRadius"], 'IN'); if (isset($explosive["DetonateFlashDuration"])) { $thisitem['DamageGraph'] .= "<br>DetonateFlashDuration: {$explosive["DetonateFlashDuration"]}"; } } $stats_tables['Explosives']['items'][$explosivename] = $thisitem; } foreach ($theater['player_templates'] as $classname => $classdata) { $thisitem = array(); $thisitem['Name'] = getlookup($classdata['print_name']); $thisitem['Team'] = printval($classdata, "team"); $thisitem['Models'] = printval($classdata, "models"); if (isset($classdata["buy_order"])) { foreach ($classdata["buy_order"] as $order => $buyitem) { foreach ($buyitem as $type => $item) { $thisitem['Buy order'] .= "<a href='#{$item}'>{$item}</a><br>"; } } } if (isset($classdata["allowed_items"])) { foreach ($classdata["allowed_items"] as $order => $aitem) { foreach ($aitem as $type => $item) { if (is_array($item)) { foreach ($item as $it => $in) { $thisitem['Allowed Items'] .= "<a href='#{$in}'>[{$type}] {$in}</a><br>"; } } else { $thisitem['Allowed Items'] .= "<a href='#{$item}'>{$item}</a><br>"; } } } } $stats_tables['Classes']['items'][$classname] = $thisitem; } // Teams are goofy because of display method foreach ($theater['teams'] as $teamname => $teamdata) { $thisitem = '<table>'; $tn = getlookup($teamdata['name']); $stats_tables['Teams']['fields'][$tn] = 1; if (isset($teamdata['logo'])) { $thisitem .= "<div style='text-align: center;'><img src='data/materials/vgui/{$teamdata['logo']}.png' style='width: 64px; height: 64px;'></div>\n"; } if (isset($teamdata['squads'])) { foreach ($teamdata['squads'] as $squad => $squaddata) { $sn = getlookup($squad); $thisitem .= "<tr><td><h3>{$sn}</h3></td></tr><tr><td>\n"; foreach ($squaddata as $order => $slot) { foreach ($slot as $title => $role) { $label = getlookup($title); $thisitem .= "<a href='#{$role}'>{$label}<br>\n"; } } $thisitem .= "</td></tr>\n"; } } $thisitem .= "</table>\n"; $stats_tables['Teams']['items'][0][$tn] = $thisitem; } // Do cleanup and make links between items here foreach (array_keys($stats_tables) as $sectionname) { ksort($stats_tables[$sectionname]['items']); } }
$mineral = $_POST['mineral']; $query = "SELECT * FROM rokka WHERE mineral='{$mineral}' OR district='{$district}' ORDER by OGR_FID "; $result = mysqli_query($connect, $query); return $result; } function type() { include "conf.php"; $district = $_POST['district']; $mineral = $_POST['mineral']; $query = "SELECT * FROM rokka ORDER by OGR_FID "; $result = mysqli_query($connect, $query); return $result; } if ($district != "" and $mineral != "") { $result = dist(); } elseif ($district != "" or $mineral != "") { $result = mineral(); } else { $result = type(); } if ($result->num_rows > 0) { echo '<table class="TFtable table-striped table-border: 1px solid black; table-hover">'; echo "<TR><TD width='40' border: 1px solid black;><h3>Zone<h3></TD><TD width='40'><h3>District<h3></TD><TD width='50'><h3>Location<h3></TD><TD><h3>Mineral<h3></TD><TD Width='80' border=5px><h3>Area<h3></TD><TD><h3>X <h3></TD><TD><h3>XX <h3></TD><TD><h3>Y <h3></TD><TD><h3>YY <h3></TD><TD width='40'><h3>TopoSheet<h3></TD><TD width='40'><h3>Remarks<h3></TD><TD width='40'><h3>Map<h3></TD></TR>"; while ($row = $result->fetch_assoc()) { $x = $row["x"]; $xx = $row["xx"]; $y = $row["y"]; $yy = $row["yy"]; echo "<tr><td width = '40' border: 1px solid black;>"; echo $row["zone"];
function displayHomePage($string) { ?> <fieldset> <center><img src="boston.png" /><br/> <form method="post"> <input type="submit" name="add" value="Add Attraction" /><br/> </form> <form method="get"> <input type="submit" name="op" value="Clear" id="Clear" /><br/> </form> <form method="get"> Search for a string:<br/> <input type="text" name="entsearch" placeholder="Enter Search" /> <input type="submit" name="search" value="Search" /> <br/><br/> Compute distances:<br/> <input type="text" name="entaddr" placeholder="Enter Address" /> <input type="submit" name="searchaddr" value="Search" /> </form> </center> </fieldset><br/><br/> <?php echo "<fieldset class=reviews>"; //Number of attractions $query = "SELECT attraction_id FROM `bestofbc`"; $dbc = connectToDB(); $result = performQuery($dbc, $query); $rows = mysqli_num_rows($result); echo "There are {$rows} attractions<br/><br/><br/>"; ?> <?php //DISPLAYS ALL ATTRACTIONS OR SEARCH ATTRACTIONS IF ENTERED SEARCH $string = $_GET['entsearch']; $string2 = $_GET['entaddr']; //If nothing in search, display all attractions if (empty($string) && empty($string2)) { $query = "select * from `bestofbc` where attraction_id NOT IN ({$_COOKIE['omitstring']})"; $dbc = connectToDB(); $result = performQuery($dbc, $query); //$row = mysqli_fetch_array($result, MYSQLI_ASSOC); ?> <table> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { ?> <?php $names = $row['name']; $category = $row['category']; $address = $row['address']; $phone = $row['phone']; $url = $row['url']; $stars = $row['stars']; $price_range = $row['price_range']; $id = $row['attraction_id']; echo "<th>Attraction</th><th>Comment</th><tr><td>"; echo "{$names} <br/> {$category} <br/> {$address} <br/> {$phone} <br/> {$url} <br/> {$stars} <br/> {$price_range} <br/><br/>"; echo "<form method=get>"; echo "<input type=submit name=\"op\" id=\"omitstring\" value=\"Hide Attraction\"/>"; echo "<input type=hidden name=\"id\" value=\"{$id}\"/>"; echo "</form>"; echo "</td>"; $comment = $row['comment']; $user = $row['entered_by']; $date = $row['insertion_date']; echo "<td>"; echo "{$comment} <br/> {$user} <i>{$date}</i> <br/><br/>"; echo "</td></tr>"; } ?> </table> <?php echo "</fieldset>"; } else { //Else, search for attraction if (isset($_GET['search'])) { $string = $_GET['entsearch']; $query = "select entered_by, name, category, address, phone, url, stars, price_range, comment from `bestofbc` where entered_by LIKE '%{$string}%' OR name LIKE '%{$string}%'"; $dbc = connectToDB(); $result = performQuery($dbc, $query); ?> <table> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { ?> <?php $names = $row['name']; $category = $row['category']; $address = $row['address']; $phone = $row['phone']; $url = $row['url']; $stars = $row['stars']; $price_range = $row['price_range']; $id = $row['attraction_id']; echo "<th>Attraction</th><th>Comment</th><tr><td>"; echo "{$names} <br/> {$category} <br/> {$address} <br/> {$phone} <br/> {$url} <br/> {$stars} <br/> {$price_range} <br/><br/>"; //echo "<input type=submit name='hide' value='Hide Attraction' />"; echo "<form method=get>"; echo "<input type=submit name=\"op\" id=\"hideattr\" value=\"Hide Attraction\"/>"; echo "<input type=hidden name=\"id\" value=\"{$id}\"/>"; echo "</form>"; echo "</td>"; $comment = $row['comment']; $user = $row['entered_by']; $date = $row['insertion_date']; echo "<td>"; echo "{$comment} <br/> {$user} <i>{$date}</i> <br/><br/>"; echo "</td></tr>"; } ?> </table> <?php echo "</fieldset>"; } if (isset($_GET['searchaddr'])) { $addr = $_GET['entaddr']; //echo "$addr <br/>"; $loc2 = makeLocArrayTwo(); $lat2 = $loc2['latitude']; $long2 = $loc2['longitude']; //echo "Lat is $lat2 and long is $long2<br/>"; $query = "select entered_by, name, category, address, phone, url, stars, price_range, comment, latitude, longitude from `bestofbc` where entered_by LIKE '%{$string}%' OR name LIKE '%{$string}%'"; $dbc = connectToDB(); $result = performQuery($dbc, $query); ?> <table> <?php while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { ?> <?php $names = $row['name']; $category = $row['category']; $address = $row['address']; $phone = $row['phone']; $url = $row['url']; $stars = $row['stars']; $price_range = $row['price_range']; echo "<th>Attraction</th><th>Comment</th><th>Distance</th><tr><td>"; echo "{$names} <br/> {$category} <br/> {$address} <br/> {$phone} <br/> {$url} <br/> {$stars} <br/> {$price_range} <br/><br/>"; echo "<input type=submit name='hide' value='Hide Attraction' />"; echo "</td>"; $comment = $row['comment']; $user = $row['entered_by']; $date = $row['insertion_date']; echo "<td>"; echo "{$comment} <br/> {$user} <i>{$date}</i> <br/><br/>"; echo "</td>"; $lat1 = $row['latitude']; $long1 = $row['longitude']; $loc1 = array("latitude" => $lat1, "longitude" => $long1); echo "<td>"; echo dist($loc1, $loc2); echo "</td></tr>"; } ?> </table> <?php echo "</fieldset>"; } } }
} //END version // BEGIN range // Units of measurement $range_units = array('U' => 'Game Units', 'M' => 'Meters', 'FT' => 'Feet', 'YD' => 'Yards', 'IN' => 'Inches'); // Set range unit, override if valid unit is requested. $range_unit = 'M'; if (isset($_REQUEST['range_unit'])) { if (array_key_exists($_REQUEST['range_unit'], $range_units)) { $range_unit = $_REQUEST['range_unit']; } } // Set range $range = 10; if (isset($_REQUEST['range'])) { $_REQUEST['range'] = dist($_REQUEST['range'], $range_unit, 'IN', 0); if ($_REQUEST['range'] >= 0 && $_REQUEST['range'] <= 20000) { $range = $_REQUEST['range']; } } // END range // BEGIN theater // Populate $theaters array with all the theater files in the selected version $files = glob("{$datapath}/mods/{$mod}/{$version}/scripts/theaters/*.theater"); foreach ($files as $file) { if (substr(basename($file), 0, 5) == "base_" || substr(basename($file), -5, 5) == "_base") { continue; } $theaters[] = basename($file, ".theater"); } // Add all custom theaters to the list, these do NOT depend on version, they will always be added
function _makeArcs($image, $fg, $mX, $mY, $nX, $nY, $r1, $r2, $begin, $end, &$float1, &$float2) { $theta = 0; $omega = 0; $d = dist($mX, $mY, $nX, $nY); $theta = acos((pow($r1, 2) - pow($r2, 2) + pow($d, 2)) / (2 * $d * $r1)); if ($nX - $mX < 0) { $omega = atan_wrapper($mY - $nY, $mX - $nX); } else { if ($nX - $mX > 0) { $omega = PI + atan_wrapper($mY - $nY, $mX - $nX); } else { if ($nX - $mX == 0) { if ($nY > $mY) { $omega = 3 * PI / 2; } else { $omega = PI / 2; } } } } if ($omega + $theta - $end > 0) { imagearc_radians($image, $nX, $nY, $r1 * 2, $r1 * 2, $omega + $theta, $end + TWO_PI, $fg); imagearc_radians($image, $nX, $nY, $r1 * 2, $r1 * 2, $begin + TWO_PI, $omega - $theta, $fg); } else { imagearc_radians($image, $nX, $nY, $r1 * 2, $r1 * 2, $omega + $theta, $end, $fg); imagearc_radians($image, $nX, $nY, $r1 * 2, $r1 * 2, $begin + TWO_PI, $omega - $theta + TWO_PI, $fg); } if ($omega + $theta < $end || $omega - $theta > $begin) { //strokeCap(SQUARE); //stroke($bg); //imagesetthickness($image, 4); // imagearc_radians($image, $nX, $nY, $r1*2, $r1*2, $omega-$theta,$omega+$theta, $fg); //imagesetthickness($image, 2); //stroke($fg); //strokeCap(ROUND); } $theta = PI - acos((pow($r2, 2) - pow($r1, 2) + pow($d, 2)) / (2 * $d * $r2)); if ($nX - $mX < 0) { $omega = atan_wrapper($mY - $nY, $mX - $nX); } else { if ($nX - $mX > 0) { $omega = PI + atan_wrapper($mY - $nY, $mX - $nX); } else { if ($nX - $mX == 0) { if ($nY > $mY) { $omega = 3 * PI / 2; } else { $omega = PI / 2; } } } } imagearc_radians($image, $mX, $mY, $r2 * 2, $r2 * 2, $omega + $theta, $omega - $theta + TWO_PI, $fg); //imagefilledellipse($image, $mX, $mY, $r2*2, $r2*2, $fg); //noFill() $float1 = $omega + $theta; $float2 = $omega - $theta + TWO_PI; }
function printarray($object, $index, $link = 0, $nulldisp = ' ', $prefix = '') { $data = ''; if ($prefix != '') { $prefix .= '->'; } global $range; $graph = in_array($index, array('Damage', 'PenetrationPower', 'PhysicsImpulse', 'PenetrationDamage')) ? 1 : 0; if ($graph) { if (!isset($object[$index][$range])) { $object[$index][$range] = damageatrange($object[$index], $range); } ksort($object[$index]); } $arr = array(); $dmg = array(); foreach ($object[$index] as $rangedist => $rangedmg) { if (is_array($rangedmg)) { $arr[] = printarray($object[$index], $rangedist, $link, $nulldisp, $prefix . $rangedist); } else { $disprange = $graph ? dist($rangedist, 'IN') : $rangedist; $dmg[$rangedist] = $rangedmg; if ($index == 'Damage' && (isset($object['bulletcount']) && $object['bulletcount'] > 1)) { $totaldmg = $rangedmg * $object['bulletcount']; $dmg[$rangedist] = $totaldmg; $arr[] = "{$prefix}{$disprange}: {$totaldmg}"; } else { if ($index == 'DamageHitgroups' && $object['Damage']) { $basedmg = array_shift(array_values($object['Damage'])); if ($object['bulletcount'] > 1) { $basedmg = $basedmg * $object['bulletcount']; } $arr[] = "{$prefix}{$disprange}: {$rangedmg} (" . $rangedmg * $basedmg . " dmg)"; } else { $arr[] = "{$prefix}{$disprange}: {$rangedmg}"; } } } } if ($graph) { $data = getgraph($dmg, $index) . "<br>\n"; } return $data . implode('<br>', $arr); }
function sort_ip_by_xydist($i, $x, $y) { foreach ($i as &$j) { $j[6] = dist($x, $y, $j[4], $j[5]); } usort($i, "cmp_distsort"); return $i; }
echo 'Creating cluster' . $i . '<br/>'; } //select K records randomly and remove it from the table for ($i = 1; $i <= $K; $i++) { //Allot each record to a P ds mysql_query("insert into clus" . $i . " select * from table1 order by RAND() limit 1"); $set_r = mysql_query("select id from clus" . $i); $pk = mysql_fetch_array($set_r); mysql_query("delete from table1 where sl=" . $pk['id']); } do { //retrieve record r $set = mysql_query("select * from table1 LIMIT 1"); $r = mysql_fetch_array($set); //order Ps accdn to distance from r array_multisort(dist($r, $p), $p); $j = 0; $i = $p[$j]; $flag = 0; while ($i < $K && $flag == 0) { $ar = array(); $new = array(); //allot distinct senstive values of Pi to s(Pi) $sP = mysql_query("select Disease from clus" . $i); while ($SP = mysql_fetch_array($sP)) { $ar[] = $SP; } foreach ($ar as $x) { array_push($new, $x["Disease"]); } // allot senstive values of r to s(r)
if ($originalcolor != intval($points[$i]['color'])) { $stop = 0; } } for ($j = 0; $j < $k; $j++) { $x = 0; $y = 0; $N = 0; for ($i = 0; $i < $n; $i++) { if (intval($points[$i]['color']) == $j) { $x = $x + floatval($points[$i]['x']); $y = $y + floatval($points[$i]['y']); $N = $N + 1; } } if ($N != 0) { $x = $x / $N; $y = $y / $N; $means[$j]->x = $x; $means[$j]->y = $y; } } } while ($stop == 0); $currenterror = 0; for ($i = 0; $i < $n; $i++) { $j = $points[$i]['color']; $currenterror = $currenterror + dist($means[$j]->x, $means[$j]->y, floatval($points[$i]['x']), floatval($points[$i]['y'])); } $points['n'] = $n; $points['k'] = $k; echo json_encode($points);