setWorld(); $this->connect("localhost","","", ""); include('sources/world_speeds.php'); $this->unit['spear']['wood'] = 50; $this->unit['spear']['clay'] = 30; $this->unit['spear']['iron'] = 10; $this->unit['sword']['wood'] = 30; $this->unit['sword']['clay'] = 30; $this->unit['sword']['iron'] = 70; $this->unit['axe']['wood'] = 60; $this->unit['axe']['clay'] = 30; $this->unit['axe']['iron'] = 40; $this->unit['archer']['wood'] = 100; $this->unit['archer']['clay'] = 30; $this->unit['archer']['iron'] = 60; $this->unit['scout']['wood'] = 50; $this->unit['scout']['clay'] = 50; $this->unit['scout']['iron'] = 20; $this->unit['light_cal']['wood'] = 125; $this->unit['light_cal']['clay'] = 100; $this->unit['light_cal']['iron'] = 250; $this->unit['mt_arch']['wood'] = 250; $this->unit['mt_arch']['clay'] = 100; $this->unit['mt_arch']['iron'] = 150; $this->unit['heavy_cal']['wood'] = 200; $this->unit['heavy_cal']['clay'] = 150; $this->unit['heavy_cal']['iron'] = 600; $this->unit['ram']['wood'] = 300; $this->unit['ram']['clay'] = 200; $this->unit['ram']['iron'] = 200; $this->unit['cat']['wood'] = 320; $this->unit['cat']['clay'] = 400; $this->unit['cat']['iron'] = 100; } function connect($db_location, $db_username, $db_password, $db_name){ //EX::::: mysql_connect("localhost","",""); $connection = mysql_connect($db_location, $db_username, $db_password); $this->check_query($connection, $db_location, "connect", $db_username." == ".$db_password); $db_select = mysql_select_db($db_name); $this->check_query($db_select, $db_name, "select", "1"); } function insert($db_name, $fields, $values){ $explode = explode(',', $values); $ex_count = count($explode); $store_value = ""; for($x=0;$x<$ex_count;$x++){ if($x != 0){ $store_value .= ",'".$explode[$x]."'"; } else { $store_value .= "'".$explode[$x]."'"; } } $query = mysql_query("INSERT INTO ".$db_name." (".$fields.") values(".$store_value.")"); //mysql_query("INSERT INTO noblelist (username, x,y,name) values('$name','$village_x','$village_y','$village_player')"); $this->check_query($query, $db_name); } //$claimer->check_query($query, $db_name, $type="query", $other=""); function check_query($query, $db_name, $type="query", $other=""){ if($type == "query"){ if(!$query){ // die("Could Not insert('".$db_name."'):
". mysql_error()); $this->error("Could Not insert('".$db_name."'):
". mysql_error()); } } if($type == "select"){ if(!$query){ $this->error("Could not select the database('".$db_name."'):
". mysql_error()."
".$other); } } if($type == "connect"){ if(!$query){ $this->error("Could not connect('".$db_name."')-(info:'".$other."'):
". mysql_error()); } } if($type == "delete"){ if(!$query){ $this->error("Could not delete(item:'".$other."') from ('".$db_name."'):
". mysql_error()); } } } function delete(){ // } function error($msg, $title="Error"){ //$this->tribal_msg("Steven10172", "Error For Claimer", $msg); mail("admin@twclaimer.com", $title, $msg); //echo "

".$msg."

"; return true; } function tribal_msg($to, $subject, $msg){ // The parameters must be URL encoded $to = urlencode($to); $subject = urlencode($subject); $message = urlencode($msg); $password = "df0349ce110b69f03b4def8012ae4970"; $base_url = "http://en10.tribalwars.net/send_mail.php?from_id=922062&password=".$password;; // go to URL $handle = fopen($base_url . "&to=".$to."&subject=".$subject."&message=".$message, 'r'); fgets($handle); // Display message fclose($handle); } /* function new_user($username, $db_name="info"){ $query_line = "INSERT INTO ".$db_name." (".$fields.") values(".$store_value.")"; $query = mysql_query($query_line); $this->check_query($query, $db_name, $type="query", $query_line); //SEND PASSWORD VIA TRIBALWARS } function change_pass(){ // } function login($username, $password, $info_db_name="info"){ $username = mysql_escape_string($username); $username = md5($password); $query = "SELECT * FROM ".$info_db_name." WHERE username='".$username."'"; $query = mysql_query($query); $this->check_query($query, $info_db_name); while($row = mysql_fetch_array($query)){ if($row['username'] == $username && $row['password'] == $password){ //User Is Loged in return true; } else { //Wrong Username or Password return false; } } } function delete_user($username, $info_db_name="info", $delete_db_name="deleted"){ $username = mysql_escape_string($username); $query = "SELECT * FROM ".$table." WHERE username='".$username."'"; $query = mysql_query($query); $this->check_query($query, $delete_db_name); while($row = mysql_fetch_array($query)){ $this->insert($db_name, "username", $row['username']); } $query = "DELETE FROM ".$info_db_name." WHERE username='".$username."'"; $query = mysql_query($query); $this->check_query($query, $info_db_name, $type="delete", $username); } function password_gen(){ $word = ""; for($x=0;$x<8;$x++){ if(rand(1,2) == 1){ $word .= chr(rand(65,90)); } else { $word .= rand(0,9); } } return $word; } */ function add_claim($x, $y, $player, $tribe_id, $db_name="claimer"){ $claimed = $this->check_claim($x, $y, $tribe_id); if($this->num_claims($player) < 15){ if($claimed == "no"){ $query = mysql_query("SELECT * FROM info_".$this->current_world." WHERE tribe_id='".$tribe_id."'"); $this->check_query($query, "info_".$this->current_world, "select", "2"); while($data = mysql_fetch_array($query)){ $length = $data['expire_length']; } $expired = "no"; $deleted = "no"; if($length == ""){ $length = "10:0:0:0"; } list($d, $h, $m, $s) = explode(':', $length); $length = $this->expire_time_conv($d, $h, $m, $s); $date = time() + $length; $query = mysql_query("INSERT INTO ".$db_name."_".$this->current_world." (username,x,y,date,tribe,expired,deleted) values('$player','$x','$y','$date','$tribe_id','$expired','$deleted')"); $this->check_query($query, $db_name, "query", "((--INSERT INTO ".$db_name." (username,x,y,date,expired,deleted) values('$player','$x','$y','$date','$expired','$deleted')--))"); return "yes"; } else { return "no"; } } else { return "max"; } } function who_claimed($x, $y, $tribe_id){ $query = "SELECT * FROM claimer_".$this->current_world." WHERE tribe='".$tribe_id."' AND x='".$x."' AND y='".$y."' AND deleted='no' AND expired='no'"; $query = mysql_query($query); $this->check_query($query, $db_name, "select", "6"); $username = ""; while($row = mysql_fetch_array($query)){ $username = $row['username']; } return $username; } function num_claims($user){ $query = mysql_query("SELECT * FROM claimer_".$this->current_world." WHERE username='".$user."' AND expired='no' AND deleted='no'"); $this->check_query($query, "claimer".$this->current_world, "select"); $num = mysql_num_rows($query); return $num; } function delete_claim($claim_id, $db_name="claimer"){ //$query = "DELETE FROM ".$db_name."_".$this->current_world." WHERE id='".$claim_id."'"; $query = "UPDATE ".$db_name."_".$this->current_world." SET deleted='yes' WHERE id='".$claim_id."'"; //$query = "UPDATE players_".$current_world."_growth SET day=".$nxt_day." WHERE day=".$day; $query = mysql_query($query); $this->check_query($query, $db_name."_".$this->current_world, "delete", "- ID: ".$claim_id." -"); return true; } function expire_time($exp_date, $claim_id){ $expired = $this->is_expired($exp_date); //3 Days,0 Hours,0 Mins if($expired == "yes"){ $query = mysql_query("UPDATE claimer_".$this->current_world." SET expired='yes' WHERE id='".$claim_id."'"); $output = "This Claim has Expired"; } else { $exp_date = $exp_date - time(); $time_left = array('days'=>null,'hours'=>null,'minutes'=>null,'seconds'=>null); $time_left['days'] = floor($exp_date / 86400); $left = $exp_date - (86400 * $time_left['days']); $time_left['hours'] = floor($left / 3600); $left = $left - (3600 * $time_left['hours']); $time_left['minutes'] = floor($left / 60); $left = $left - (60 * $time_left['minutes']); $time_left['seconds'] = $left; if($time_left['days'] < 0) { $error_time = "ERROR"; } if($time_left['hours'] < 0) { $error_time = "ERROR"; } if($time_left['minutes'] < 0) { $error_time = "ERROR"; } if($time_left['seconds'] < 0) { $error_time = "ERROR"; } $display_time = $time_left['days'].":".$time_left['hours'].":".$time_left['minutes'].":".$time_left['seconds']; if($error_time == "ERROR" && $expired == "NO"){ $output = "ERROR "; } else { //$output = " "; $output = "".$time_left['days']." Days ".$time_left['hours']." Hrs. ".$time_left['minutes']." Mins cancel"; } } if($output == "- Days - Hrs. - Mins"){ $output = "This Claim has Expired"; } return $output; } function is_expired($input_time){ if($input_time <= time()){ return "yes"; } else { return "no"; } } function show_claim($username, $tribe_id, $show="user", $show2="only_tribe", $db_name="claimer", $style="b"){ //$query = "SELECT * FROM claimer WHERE username='steven10172' AND tribe in ('123','2343','3454')"; if($show != "user"){ //$query = "SELECT * FROM claimer_".$this->current_world." WHERE tribe in (".$tribe_id.")"; $fam_tribe_id = $tribe_id.","; $query = mysql_query("SELECT * FROM links_".$this->current_world." WHERE creator_tribe_id='".$tribe_id."'"); while($row = mysql_fetch_array($query)){ $fam_tribe_id .= $row['tribe_id'].","; } $query = mysql_query("SELECT * FROM links_".$this->current_world." WHERE tribe_id='".$tribe_id."'"); while($row = mysql_fetch_array($query)){ $fam_tribe_id .= $row['creator_tribe_id'].","; } if($show2 == "only_tribe"){ $fam_tribe_id = $tribe_id.","; } $family_ids = explode(",", $fam_tribe_id); foreach($family_ids as $family_id) { $query = mysql_query("SELECT * FROM tribes_".$this->current_world." WHERE id='".$family_id."'"); while($row = mysql_fetch_array($query)){ $fam_tag = $row['tag']; } $query = "SELECT * FROM claimer_".$this->current_world." WHERE tribe='".$family_id."' ORDER BY id DESC"; $query = mysql_query($query); $this->check_query($query, $db_name, "select", "3"); while($row = mysql_fetch_array($query)){ $deleted = $row['deleted']; $expired = $row['expired']; if($deleted == "yes" || $expired == "yes"){ //nothing } else { $username = $row['username']; $date = $row['date']; $x = $row['x']; $y = $row['y']; $village_k = $this->village_k($x, $y); $claim_id = $row['id']; $query2 = "SELECT * FROM villages_".$this->current_world." WHERE x='".$x."' AND y='".$y."'"; $query2 = mysql_query($query2); while($row2 = mysql_fetch_array($query2)){ $village_name = $row2['name']; $village_pts = $row2['points']; $player_id = $row2['owner']; $village_id = $row2['id']; } $query3 = "SELECT * FROM players_".$this->current_world." WHERE id='".$player_id."'"; $query3 = mysql_query($query3); while($row3 = mysql_fetch_array($query3)){ $village_owner = $row3['name']; $tribe_id_show = $row3['ally']; } $query4 = "SELECT * FROM tribes_".$this->current_world." WHERE id='".$tribe_id_show."'"; $query4 = mysql_query($query4); while($row4 = mysql_fetch_array($query4)){ $tribe_tag = $row4['tag']; } $query5 = "SELECT * FROM players_".$this->current_world." WHERE name='".$username."'"; $query5 = mysql_query($query5); while($row5 = mysql_fetch_array($query5)){ $claimer_name_id = $row5['id']; } if($style == "a"){ $style = "b"; } else { $style = "a"; } $display .= ' '.$username.' ('.urldecode($fam_tag).') '.$village_name.' ('.$x.'|'.$y.')'.$village_k.' - '.$village_pts.' pts '.$village_owner.' '.urldecode($tribe_tag).' '.$this->expire_time($date, $claim_id).' '; } unset($player_id, $village_name, $village_owner, $player_id, $tribe_tag, $tribe_id_show); } } } else { $query = "SELECT * FROM claimer_".$this->current_world." WHERE username='".$username."' AND tribe='".$tribe_id."' ORDER BY id DESC"; $query = mysql_query($query); $this->check_query($query, $db_name."_".$this->current_world, "select", "4"); while($row = mysql_fetch_array($query)){ $deleted = $row['deleted']; $expired = $row['expired']; if($deleted == "yes" || $expired == "yes"){ //nothing } else { $username = $row['username']; $date = $row['date']; $username = $row['username']; $x = $row['x']; $y = $row['y']; $village_k = $this->village_k($x, $y); $claim_id = $row['id']; $query2 = "SELECT * FROM villages_".$this->current_world." WHERE x='".$x."' AND y='".$y."'"; $query2 = mysql_query($query2); while($row2 = mysql_fetch_array($query2)){ $village_name = $row2['name']; $village_pts = $row2['points']; $player_id = $row2['owner']; $village_id = $row2['id']; } $query3 = "SELECT * FROM players_".$this->current_world." WHERE id='".$player_id."'"; $query3 = mysql_query($query3); while($row3 = mysql_fetch_array($query3)){ $village_owner = $row3['name']; $tribe_id_show = $row3['ally']; } $query4 = "SELECT * FROM tribes_".$this->current_world." WHERE id='".$tribe_id_show."'"; $query4 = mysql_query($query4); while($row4 = mysql_fetch_array($query4)){ $tribe_tag = $row4['tag']; } if($style == "a"){ $style = "b"; } else { $style = "a"; } $display .= ' '.$username.' '.$village_name.' ('.$x.'|'.$y.')'.$village_k.' - '.$village_pts.' pts '.$village_owner.' '.urldecode($tribe_tag).' '.$this->expire_time($date, $claim_id).' '; } unset($village_id,$village_name,$x,$y,$village_k,$village_pts,$player_id,$village_owner,$tribe_id_show,$tribe_tag,$date,$row,$claim_id); } } return $display; } function tribe_list($tribe_id, $user_id){ $display = (' Name Rank Points Villages '); $query = "SELECT * FROM players_".$this->current_world." WHERE ally='".$tribe_id."' ORDER BY rank"; $query = mysql_query($query); $x = 0; while($row = mysql_fetch_array($query)){ $x++; $player_id = $row['id']; $name = $row['name']; $rank = $row['rank']; $points = $row['points']; $villages = $row['villages']; if($player_id == $user_id){ $class_style = ' class="lit"'; } else { $class_style = ""; } $display .= (' '.$x.' '.$name.' '.number_format($rank).' '.number_format($points).' '.number_format($villages).' '); } return $display; } function village_k($x, $y="y"){ if($y == "y" && strpos($x, "|") !== false){ $ex = explode("|", $x); $x = $ex[0]; $y = $ex[1]; } $k = "K"; if($y<100){ $k .= ""; } else { $k .= $y[0]; } if($x<100){ $k .= "0"; } else { $k .= $x[0]; } return $k; } function check_claim($x, $y, $tribe_id){ $fam_tribe_id = $tribe_id.","; $query = mysql_query("SELECT * FROM links_".$this->current_world." WHERE creator_tribe_id='".$tribe_id."'"); while($row = mysql_fetch_array($query)){ $fam_tribe_id .= $row['tribe_id'].","; } $query = mysql_query("SELECT * FROM links_".$this->current_world." WHERE tribe_id='".$tribe_id."'"); while($row = mysql_fetch_array($query)){ $fam_tribe_id .= $row['creator_tribe_id'].","; } $family_ids = explode(",", $fam_tribe_id); foreach($family_ids as $family_id) { $query = "SELECT * FROM claimer_".$this->current_world." WHERE tribe='".$family_id."' AND x='".$x."' AND y='".$y."' AND deleted='no' AND expired='no'"; $query = mysql_query($query); $this->check_query($query, $db_name, "select", "6"); /* while($row = mysql_fetch_array($query)){ $stored_x = $row['x']; $stored_y = $row['y']; $expired = $row['expired']; if($stored_x == $x && $stored_y == $y && $expired == "no"){ $claimed = "yes"; } } */ if(mysql_num_rows($query) > 0){ $claimed = "yes"; } } if($claimed != "yes"){ $claimed = "no"; } return $claimed; } function report_show($tribe){ // } function report_add($tribe, $coord, $in_village, $out_village){ $coords = explode("|", $coord); $x = $coords[0]; $y = $coords[1]; $in_village = explode(",", $in_village); $out_village = explode(",", $out_village); } function report_search($term, $type="player"){ //$type = player //$type = tribe //$type = coord } function report_exists($coord){ $coords = explode("|", $coord); $x = $coords[0]; $y = $coords[1]; } function bbcode($input){ preg_match_all('/\d{1,3}\|\d{1,3}/', $input, $matches); //preg_match_all('/\d\d\d\|\d\d\d/', $input, $matches); return $matches[0]; } function distance($coord1, $coord2){ $coord1 = explode("|", $coord1); $x1 = $coord1[0]; $y1 = $coord1[1]; $coord2 = explode("|", $coord2); $x2 = $coord2[0]; $y2 = $coord2[1]; $x = pow($x2 - $x1,2); $y = pow($y2 - $y1,2); $distance = sqrt($x + $y); return $distance; } function time($time){ $hr = floor($time/3600); $time = $time - ($hr*3600); $min = floor($time/60); $time = $time - ($min*60); $sec = floor($time); $time = $this->add_zero($hr).":".$this->add_zero($min).":".$this->add_zero($sec); return $time; } function unit($unit, $coord1, $coord2){ $distance = $this->distance($coord1, $coord2); $trav_time = $this->unit[str_replace('en', '', $this->current_world)][$unit] * $distance * 60; $time = $this->time(round($trav_time)); return $time; } function add_zero($var){ if($var < 10){ $var = "0".$var; } return $var; } function unit_price($unit, $amount){ $wood = $amount * $this->unit[$unit]['wood']; $clay = $amount * $this->unit[$unit]['clay']; $iron = $amount * $this->unit[$unit]['iron']; $total = $wood.":".$clay.":".$iron; return $total; } function world_show($org_address){ $world_pre = "en"; $world_num = 1; $world_list = ""; $num_worlds = 37; while($world_num <= $num_worlds){ $address= $org_address; $world = $world_pre."".$world_num; $address = $address."/".$world."/index.php"; $world_list .= '
  • World '.$world.'
  • '; $world_num++; } return $world_list; } function tribe_link($admin, $action, $tribe_id_org, $add_info=""){ $action = strtolower($action); $display = ""; $request = ""; $style= "a"; $tribe_id = $tribe_id_org; if($action == "show"){ //Show Current Tribe Links $query = mysql_query("SELECT * FROM links_".$this->current_world." WHERE creator_tribe_id='".$tribe_id_org."'"); $this->check_query($query, "links_".$this->current_world, "select", "7"); while($row = mysql_fetch_array($query)){ unset($link_id, $status, $start_time, $creator_id, $creator_name, $tribe_id); $link_id = $row['id']; $status = $row['status']; $start_time = $row['start_time']; $creator_id = $row['creator_id']; $creator_name = $row['creator_name']; $tribe_id = $row['tribe_id']; if(strtolower($status) != "deleted"){ $query2 = mysql_query("SELECT * FROM tribes_".$this->current_world." WHERE id='".$tribe_id."' LIMIT 1"); $this->check_query($query, "tribes_".$this->current_world, "select", "8"); while($row2 = mysql_fetch_array($query2)){ $tribe_name = $row2['tag']; } $days = floor((time()-$start_time)/86400); if($style == "a"){ $style = "b"; } else { $style = "a"; } if(strtolower($status) == "linked"){ $color = "green"; } if(strtolower($status) == "denied"){ $color = "red"; } if(strtolower($status) == "pending"){ $color = "orange"; if($admin == "yes"){ $request .= ''.$status.''.$tribe_name.''.date("d/n/Y",$start_time).''.$days.''.$creator_name.'Remove Request'; } else { $request .= ''.$status.''.$tribe_name.''.date("d/n/Y",$start_time).''.$days.''.$creator_name.''; } } else { if($admin == "yes"){ $display .= ''.$status.''.$tribe_name.''.date("d/n/Y",$start_time).''.$days.''.$creator_name.'Delete Link'; } else { $display .= ''.$status.''.$tribe_name.''.date("d/n/Y",$start_time).''.$days.''.$creator_name.''; } } unset($days); unset($start_time); } } $query = mysql_query("SELECT * FROM links_".$this->current_world." WHERE tribe_id='".$tribe_id_org."'"); $this->check_query($query, "links_".$this->current_world, "select", "9"); while($row = mysql_fetch_array($query)){ unset($link_id, $status, $start_time, $creator_id, $creator_name, $tribe_id); $link_id = $row['id']; $status = $row['status']; $start_time = $row['start_time']; $creator_id = $row['creator_id']; $creator_name = $row['creator_name']; $tribe_id = $row['creator_tribe_id']; if(strtolower($status) != "deleted"){ $query2 = mysql_query("SELECT * FROM tribes_".$this->current_world." WHERE id='".$tribe_id."' LIMIT 1"); $this->check_query($query, "tribes_".$this->current_world, "select", "10"); while($row2 = mysql_fetch_array($query2)){ $tribe_name = $row2['tag']; } $days = floor((time()-$start_time)/86400); if($style == "a"){ $style = "b"; } else { $style = "a"; } if(strtolower($status) == "linked"){ $color = "green"; } if(strtolower($status) == "denied"){ $color = "red"; } if(strtolower($status) == "pending"){ $color = "orange"; if($admin == "yes"){ $request .= 'Accept Request -- Deny Request'.$tribe_name.''.date("d/n/Y",$start_time).''.$days.''.$creator_name.''; } else { $request .= 'Pending'.$tribe_name.''.date("d/n/Y",$start_time).''.$days.''.$creator_name.''; } } else { if($admin == "yes"){ $display .= ''.$status.''.$tribe_name.''.date("d/n/Y",$start_time).''.$days.''.$creator_name.'Delete Link'; } else { $display .= ''.$status.''.$tribe_name.''.date("d/n/Y",$start_time).''.$days.''.$creator_name.''; } } } } return $display.":::::request:::::".$request; } if($action == "add" && $admin == "yes"){ //Add a tribe link list($creator_id, $creator_name, $tribe_id_add) = explode(',', trim($add_info)); $status = "Pending"; $start_time = time(); $query = mysql_query("INSERT INTO links_".$this->current_world." (status,start_time,creator_id,creator_name,creator_tribe_id,tribe_id) values('$status','$start_time','$creator_id','$creator_name','$tribe_id','$tribe_id_add')"); $this->check_query($query, "links_".$this->current_world, "insert"); $query = mysql_query("SELECT * FROM tribes_".$this->current_world." WHERE id='".$tribe_id_add."' LIMIT 1"); $this->check_query($query, "tribes_".$this->current_world, "select", "11"); while($row = mysql_fetch_array($query)){ $tribe_name = $row['tag']; } $display = "

    A request has been sent to ".$tribe_name."

    "; return $display; } } function growth($username){ $username = mysql_real_escape_string($username); } function safe($var){ $var = urldecode($var); $var = addslashes($var); mysql_real_escape_string(); stripslashes(); strip_tags(); return $var; } function duke_vote($user_id, $tribe_id, $vote){ $vote = mysql_real_escape_string(trim(strtolower($vote))); $query = mysql_query("SELECT * FROM vote_".$this->current_world." WHERE tribe_id='".$tribe_id."' AND id='".$user_id."'"); $this->check_query($query, "vote_".$this->current_world, "select", "12"); if(mysql_num_rows($query) > 0){ $result = "You already voted"; //already voted } else { $query = mysql_query("INSERT INTO vote_".$this->current_world." SET tribe_id='".$tribe_id."', id='".$user_id."', vote='".$vote."'"); $this->check_query($query, "vote_".$this->current_world, "insert"); $result = "Your vote on ".$vote." has been counted.


    Please click here to go to the home page.
    "; } return $result; } function number_members($tribe_id){ $query = mysql_query("SELECT members FROM tribes_".$this->current_world." WHERE id='".$tribe_id."'"); $this->check_query($query, "tribes_".$this->current_world, "select", "13"); while($row = mysql_fetch_array($query)){ $members = $row['members']; } return $members; } function check_duke($tribe_id){ $query = mysql_query("SELECT * FROM vote_".$this->current_world." WHERE tribe_id='".$tribe_id."'"); $this->check_query($query, "vote_".$this->current_world, "select", "14"); $x = 0; $vote = array(); while($row = mysql_fetch_array($query)){ $vote[$x] = strtolower(trim($row['vote'])); $x++; } $array = $this->most_used($vote, "array"); $player = $array['word']; $num_times = $array['count']; $query = mysql_query("SELECT * FROM tribes_".$this->current_world." WHERE id='".$tribe_id."'"); $this->check_query($query, "tribes_".$this->current_world, "select", "15"); while($row = mysql_fetch_array($query)){ $members = $row['members']; $tag = $row['tag']; } if(($members*0.3) <= $num_times){ $query = mysql_query("SELECT * FROM players_".$this->current_world." WHERE name='".$player."'"); $this->check_query($query, "players_".$this->current_world, "select", "16"); while($row = mysql_fetch_array($query)){ $player_id = $row['id']; } $query = mysql_query("SELECT * FROM info_".$this->current_world." WHERE tribe_id='".$tribe_id."'"); $this->check_query($query, "info_".$this->current_world, "select", "17"); while($row = mysql_fetch_array($query)){ $done = "done"; } if($done == "done"){ $query = mysql_query("UPDATE info_".$this->current_world." SET admin_ids='".$player_id."'"); $this->check_query($query, "info_".$this->current_world, "update"); } else { $query = mysql_query("INSERT INTO info_".$this->current_world." SET tribe_id='".$tribe_id."', expire_length='10:00:00:00', admin_ids=',".$player_id.",', tribe_chan='".$this->tribe_chan($tag)."'"); $this->check_query($query, "info_".$this->current_world, "update"); } $query = mysql_query("DELETE FROM vote_".$this->current_world." WHERE tribe_id='".$tribe_id."'"); $this->check_query($query, "vote_".$this->current_world, "delete"); } elseif(count($vote) == $members){ //EVERYONE HAS VOTED AND NO ONE HAD OVER 30% OF THE VOTES } } function array_depth($array) { $max_depth = 1; foreach ($array as $value) { if (is_array($value)) { $depth = array_depth($value) + 1; if ($depth > $max_depth) { $max_depth = $depth; } } } return $max_depth; } function most_used($array, $result="array"){ if(is_array($array)){ $count = Array(); $most = null; foreach($array as $word) { $count[$word]['count']++; $count[$word]['word'] = $word; } sort($count); $most = end($count); if($result == "array" || $result == "both"){ $return = $most; } if($result == "number"){ $return = $most['count']; } if($result == "word"){ $return = $most['word']; } if($result != "both" && $result != "array" && $result != "number" && $result != "word"){ $return = $most; } } else { $this->error("Not Array"); $return = "Error"; } return $return; } function tribe_chan($input){ $output = str_replace(" ", "_", $input); return $output; } function expire_time_conv($d, $h, $m, $s){ $total = $d * 24; $total = ($total + $h) * 60; $total = ($total + $m) * 60; $total = $total + $s; //$length = "864000"; $length = $total; return $length; } function setWorld(){ $this->current_world = $_GET['world']; } function admin_access($tribe_id, $do="show", $user_id="", $type=""){ if($do == "show"){ //Show Admins $query = mysql_query("SELECT * FROM info_".$this->current_world." WHERE tribe_id='".$tribe_id."'"); $this->check_query($query, "info_".$this->current_world, "select"); while($row = mysql_fetch_array($query)){ $admin_ids = explode(",", $row['admin_ids']); } if(is_array($admin_ids)){ foreach($admin_ids as $admin_id){ $results .= "".$this->get_username($admin_id).""; } } } if($do == "delete"){ //Delete Admin } if($do == "add"){ //Add Admin } return $results; } function get_username($user_id){ $query = mysql_query("SELECT * FROM players_".$this->current_world." WHERE id='".$user_id."'"); $this->check_query($query, "players_".$this->current_world, "select"); while($row = mysql_fetch_array($query)){ $name = $row['name']; } return $name; } function get_userid($username){ $query = mysql_query("SELECT * FROM players_".$this->current_world." WHERE name='".$username."'"); $this->check_query($query, "players_".$this->current_world, "select"); while($row = mysql_fetch_array($query)){ $id = $row['id']; } return $id; } function access_list($tribe_id){ //for($x=0;$x<10;$x++){ echo ''; $query = mysql_query("SELECT * FROM info_".$this->current_world." WHERE tribe_id='".$tribe_id."'"); $this->check_query($query, "info_".$this->current_world, "select"); while($row = mysql_fetch_array($query)){ $admin_ids = explode(",", $row['admin_ids']); } $query = "SELECT * FROM players_".$this->current_world." WHERE ally='".$tribe_id."' ORDER BY rank"; $query = mysql_query($query); while($row = mysql_fetch_array($query)){ $name = $row['name']; $player_id = $row['id']; if(in_array($player_id, $admin_ids)){ $checked = 'checked="checked"'; } $display .= (''); unset($name, $player_id, $checked); } return $display; } } $claimer = new Claimer(); ?>