function domainTable() { $args = array('post_type' => 'domain', 'orderby' => 'ASC'); $domains = get_posts($args); $sortedDomains = []; $key = 0; foreach ($domains as $domain) { $sortedDomains[$key]['post_title'] = $domain->post_title; $sortedDomains[$key]['post_content'] = $domain->post_content; $sortedDomains[$key]['link'] = get_post_meta($domain->ID, 'link', true); $sortedDomains[$key]['order'] = get_post_meta($domain->ID, 'order', true); $key++; } array_sort_by_column($sortedDomains, 'order'); echo '<table id = "domain-table">'; echo '<th colspan = 2>Domenas</th><th colspan = 3>Aprašymas</th><th>Statistika</th>'; foreach ($sortedDomains as $domain) { echo '<tr>'; echo '<td colspan = 2>' . $domain['post_title'] . '</td>'; echo '<td colspan = 3> ' . $domain['post_content'] . '</td>'; echo '<td><a href = "' . $domain['link'] . '">Linkas</a></td>'; echo '</tr>'; } echo '</table>'; }
<table class = "table table-striped" style = "text-align:left" width = 500> <thead><tr><th>Rank</th><th>Username</th><th>Date Joined</th><th>Current Holdings</th><th>Total Trades</th><th>Buying Power</th><th>Invested Funds</th><th>Portfolio Value</th></tr></thead> <?php if (isset($data) && isset($users) && isset($portfolio) && isset($totals)) { for ($i = 0; $i < count($data); $i++) { $data[$i]["value"] = $totals[$data[$i]["id"]]; } array_sort_by_column($data, 'value'); $count = 0; foreach ($data as $row) { printf("<tr>"); $count++; printf("<td>" . $count . "</td>"); printf("<td>" . $row["username"] . "</td>"); printf("<td>" . $row["date"] . "</td>"); printf("<td>" . $row["portfolioCount"] . "</td>"); printf("<td>" . $row["historyCount"] . "</td>"); printf("<td> \$ " . number_format($row["cash"], 2) . "</td>"); printf("<td> \$ " . number_format($row["value"] - $row["cash"], 2) . "</td>"); printf("<td> \$ " . number_format($row["value"], 2) . "</td>"); printf("</tr>"); } } ?> </table>
public static function get_stamina_leaderboard() { // For ease of editing later I'm not going to try to wiggle this into one query $users = User::all(); $return_array = array(); foreach ($users as $user) { $scores = User_score::get_scores_for_user_approved($user->id, "difficulty_score DESC", 'AND ranked_files.stamina_file = 1'); $top_sum = 0; $top_score = 0; foreach ($scores as $score) { $top_score = $score->difficulty_score; break; } $i = 0; $scores_to_use = 1; if ($top_score < 15) { $scores_to_use = 1; } else { if ($top_score < 20) { $scores_to_use = 1; } else { if ($top_score < 24) { $scores_to_use = 2; } else { if ($top_score < 28) { $scores_to_use = 2; } else { if ($top_score < 31) { $scores_to_use = 3; } else { $scores_to_use = 5; } } } } } foreach ($scores as $score) { $top_sum += $score->difficulty_score; $i++; if ($i == $scores_to_use) { break; } } $avg = $top_sum / $scores_to_use; $user_array = array("username" => $user->display_name, "profile_link" => "/profile/view/" . $user->username, "average_score" => $avg); if ($i == $scores_to_use && $avg != 0) { array_push($return_array, $user_array); } } // sort the array using an anonymous function array_sort_by_column($return_array, 'average_score'); return $return_array; }
<th>Action</th> </thead> <tbody> <?php $this->load->helper('html'); function array_sort_by_column(&$array, $column, $direction = SORT_ASC) { $reference_array = array(); foreach ($array as $key => $row) { $reference_array[$key] = strtolower($row[$column]); } array_multisort($reference_array, $direction, $array); } array_sort_by_column($types['type'], 'name'); array_sort_by_column($suppliers['supplier'], 'title'); if (empty($products['product'])) { } else { if (!isset($products['product'][0])) { $temp = $products; $products = array(); $products['product'][0] = $temp['product']; } } for ($x = 0; $x < sizeof($types['type']); $x++) { $retypes[$types['type'][$x]['id']] = $types['type'][$x]; } for ($x = 0; $x < sizeof($industries['industry']); $x++) { $reindustries[$industries['industry'][$x]['id']] = $industries['industry'][$x]; } for ($x = 0; $x < sizeof($suppliers['supplier']); $x++) {
$exerciseArray = explode(",", $_GET["exercises"]); $select_records = mysql_query("select workout_id from fitness_exercise_repetition where exercise_level_id='" . $level . "' and repetitions!=''"); $exercisesArray = array(); while ($getRecords = mysql_fetch_array($select_records)) { $workoutID = $getRecords["workout_id"]; $checkRecord = mysql_query("select master_check from fitness_exercise_general where workout_id='" . $workoutID . "'"); $getChecked = mysql_fetch_row($checkRecord); if ($getChecked[0] == 1) { $selectWorkouts = mysql_query("select workout_id,workout_name from fitness_exercise_general_multilang where workout_id='" . $workoutID . "' and lang_id=1"); $getWorkout[] = mysql_fetch_array($selectWorkouts); } } foreach ($getWorkout as $workouts) { $exercisesArray[] = $workouts; } $exercisesArray = array_sort_by_column($exercisesArray, "workout_name"); foreach ($exercisesArray as $exerciseRow) { if (in_array($exerciseRow["workout_id"], $exerciseArray)) { $checked = "selected"; } else { $checked = ""; } $options .= "<option value='" . $exerciseRow["workout_id"] . "' {$checked}>" . $exerciseRow["workout_name"] . "</option>"; } /*if(in_array($workoutID,$exerciseArray)) { $checked = "selected"; } else { $checked = "";
public static function getZipCodes($code, $distance) { //connect to db server; select database require 'scripts/database.php'; //query for coordinates of provided ZIP Code if (!($rs = $connection->query("SELECT * FROM zipcodes WHERE code = '{$code}'"))) { $GLOBALS['message'] = "Database error."; return false; } else { if (mysqli_num_rows($rs) == 0) { $GLOBALS['message'] = "No zip codes found."; return false; } else { //if found, set variables $row = mysqli_fetch_array($rs); $lat1 = $row['latitude']; $lon1 = $row['longitude']; $d = $distance; $r = 3959; //compute max and min latitudes / longitudes for search square $latN = rad2deg(asin(sin(deg2rad($lat1)) * cos($d / $r) + cos(deg2rad($lat1)) * sin($d / $r) * cos(deg2rad(0)))); $latS = rad2deg(asin(sin(deg2rad($lat1)) * cos($d / $r) + cos(deg2rad($lat1)) * sin($d / $r) * cos(deg2rad(180)))); $lonE = rad2deg(deg2rad($lon1) + atan2(sin(deg2rad(90)) * sin($d / $r) * cos(deg2rad($lat1)), cos($d / $r) - sin(deg2rad($lat1)) * sin(deg2rad($latN)))); $lonW = rad2deg(deg2rad($lon1) + atan2(sin(deg2rad(270)) * sin($d / $r) * cos(deg2rad($lat1)), cos($d / $r) - sin(deg2rad($lat1)) * sin(deg2rad($latN)))); //find all coordinates within the search square's area //exclude the starting point and any empty city values $query = "SELECT * FROM zipcodes WHERE (latitude <= {$latN} AND latitude >= {$latS} AND longitude <= {$lonE} AND longitude >= {$lonW}) AND (latitude != {$lat1} AND longitude != {$lon1}) AND city != '' ORDER BY state, city, latitude, longitude"; if (!($rs = $connection->query($query))) { $GLOBALS['message'] = "Database error while searching for zip codes in area."; return false; } elseif (mysqli_num_rows($rs) == 0) { $GLOBALS['message'] = "No zip codes found within that distance."; return false; } else { //output all matches to array to be used to search for people in the area. $tmp = array(); $i = 0; while ($row = mysqli_fetch_array($rs)) { $distance = round(acos(sin(deg2rad($lat1)) * sin(deg2rad($row['latitude'])) + cos(deg2rad($lat1)) * cos(deg2rad($row['latitude'])) * cos(deg2rad($row['longitude']) - deg2rad($lon1))) * $r); if ($d >= $distance) { $tmp[$i] = $row; $tmp[$i]['distance'] = $distance; $i++; } } //now we can sort the temp array via the function at the top of the page array_sort_by_column($tmp, 'distance'); return $tmp; } } } }
// Do it $data = csvToArray($feed, ','); // Set number of elements (minus 1 because we shift off the first row) $count = count($data) - 1; //Use first row for names $labels = array_shift($data); foreach ($labels as $label) { $keys[] = $label; } // Add Ids, just in case we want them later $keys[] = 'id'; for ($i = 0; $i < $count; $i++) { $data[$i][] = $i; } // Bring it all together for ($j = 0; $j < $count; $j++) { $d = array_combine($keys, $data[$j]); $newArray[$j] = $d; } array_sort_by_column($newArray, 'id'); // print_r($newArray); // Saving file $json_file = '../data_' . $key . '.json'; $fp = fopen($json_file, 'w'); fwrite($fp, '{"feed":'); fwrite($fp, json_encode($newArray)); fwrite($fp, '}'); echo "<pre>"; echo 'Fichier <a href="' . $json_file . '">data_' . $key . '.json</a><br />'; echo "</pre>"; }
function createJson($year = '') { global $wpdb; $ribbonData = array(); $data = array(); $json = array(); $blueList = array(); $redList = array(); $filter = " and year= " . ($year != '' ? $year : date("Y")); $sql = "SELECT entry_id, location, year, ribbonType, numRibbons,project_name,project_photo, post_id, maker_name " . " FROM `wp_mf_ribbons` where entry_id > 0 " . $filter . " " . " ORDER BY ribbonType ASC, numRibbons desc, entry_id"; foreach ($wpdb->get_results($sql, ARRAY_A) as $ribbon) { $entry_id = $ribbon['entry_id']; $link = "/mfarchives/" . $entry_id; $post_id = $ribbon['post_id']; $project_name = $ribbon['project_name']; $project_photo = $ribbon['project_photo']; $project_desc = ''; $maker_name = $ribbon['maker_name']; $location = $ribbon['location']; $year = $ribbon['year']; $ribbonType = $ribbon['ribbonType']; $numRibbons = $ribbon['numRibbons']; //pull the project information - mf_ribbons data takes precedence if ($post_id != 0) { //archived record $makerSQL = "select post.post_content, wp_postmeta.* " . " from wp_posts post " . " right outer join wp_postmeta on " . " post.ID = post_id and " . " ((post_id = {$post_id} and meta_key like '%maker_name%') or " . " (post_id = {$post_id} and meta_key in('project_photo','project_name')) or " . " (post_id = {$post_id} and meta_key like '%project_description%')) " . " where post.ID = {$post_id} ORDER BY `wp_postmeta`.`meta_key` DESC"; foreach ($wpdb->get_results($makerSQL, ARRAY_A) as $projData) { //wpv1 project data is in the post_content field //cs project data is in the meta fields if ($projData['post_content'] != '') { $jsonArray = json_decode($projData['post_content'], true); //if there is an error, try to fix the json if (empty($jsonArray)) { $content = fixWPv1Json($projData['post_content'], $post_id); $jsonArray = json_decode($content, true); } if (!empty($jsonArray)) { if ($jsonArray['form_type'] == 'presenter') { $project_name = $jsonArray['presentation_name']; $project_photo = $jsonArray['presentation_photo']; $maker_name = $jsonArray['presenter_name']; $project_desc = isset($jsonArray['public_description']) ? $jsonArray['public_description'] : ''; } elseif ($jsonArray['form_type'] == 'exhibit') { $project_name = $jsonArray['project_name']; $project_photo = $jsonArray['project_photo']; $maker_name = $jsonArray['maker_name']; $project_desc = isset($jsonArray['public_description']) ? $jsonArray['public_description'] : ''; } elseif ($jsonArray['form_type'] == 'performer') { $project_name = $jsonArray['performer_name']; $project_photo = $jsonArray['performer_photo']; $maker_name = $jsonArray['name']; $project_desc = isset($jsonArray['public_description']) ? $jsonArray['public_description'] : ''; } break; } } $field = $projData['meta_key']; $value = $projData['meta_value']; if ($field == 'project_photo' && $project_photo == '') { if (is_numeric($value)) { $project_photo = wp_get_attachment_url($value); } else { $project_photo = $value; } } if ($field == 'project_name' && $project_name == '') { $project_name = $value; } if (strpos($field, 'maker_name') !== false) { //if maker name has field_ in it, it is not a valid maker name. if (strpos($value, 'field_') === false && $maker_name == '') { $maker_name = $value; } } if ($field == 'project_description' && $project_desc == '') { $project_desc = $value; } } } else { //non archived record $link = "/maker/entry/" . $entry_id; $maker_first_name = $maker_last_name = ''; //check if this is a GF entry $leadSQL = "SELECT wp_rg_lead_detail.field_number,wp_rg_lead_detail.value,wp_rg_lead_detail_long.value as long_value " . " FROM wp_rg_lead_detail " . " left outer join wp_rg_lead_detail_long ON " . " wp_rg_lead_detail.id = wp_rg_lead_detail_long.lead_detail_id " . " WHERE wp_rg_lead_detail.lead_id = " . $entry_id . " order by lead_id, field_number"; foreach ($wpdb->get_results($leadSQL, ARRAY_A) as $projData) { switch ($projData['field_number']) { case '22': $project_photo = $projData['value']; break; case '151': $project_name = $projData['value']; break; case '16': if ($projData['long_value'] != NULL) { $project_desc = $projData['long_value']; } else { $project_desc = $projData['value']; } break; case '160.3': $maker_first_name = $projData['value']; break; case '160.6': $maker_last_name = $projData['value']; break; } $maker_name = $maker_first_name . ' ' . $maker_last_name; } } //do not add to ribbon array if $project_name, $project_photo and $project_desc are blank if ($project_name == '' && $project_photo == '' && $project_desc == '') { //skip } else { //build ribbon data array $currCount = isset($ribbonData[$entry_id]['ribbon'][$ribbonType]['count']) ? $ribbonData[$entry_id]['ribbon'][$ribbonType]['count'] : 0; $ribbonData[$entry_id]['ribbon'][$ribbonType]['count'] = (int) $currCount + (int) $numRibbons; $ribbonData[$entry_id]['fairedata'][] = array('year' => $year, 'faire' => $location, 'ribbonType' => $ribbonType == 0 ? 'blue' : 'red'); $ribbonData[$entry_id]['project_name'] = $project_name; $ribbonData[$entry_id]['project_photo'] = $project_photo; $ribbonData[$entry_id]['project_desc'] = $project_desc; $ribbonData[$entry_id]['maker_name'] = $maker_name; $ribbonData[$entry_id]['link'] = $link; } } foreach ($ribbonData as $entry_id => $data) { $blueCount = isset($data['ribbon'][0]['count']) ? $data['ribbon'][0]['count'] : 0; $redCount = isset($data['ribbon'][1]['count']) ? $data['ribbon'][1]['count'] : 0; $project_photo = $data['project_photo']; $project_photo = legacy_get_fit_remote_image_url($project_photo, 285, 270, 0); $jsondata = array('entryID' => $entry_id, "blueCount" => $blueCount, "redCount" => $redCount, "project_name" => html_entity_decode($data['project_name']), "project_photo" => $project_photo, "maker_name" => $data['maker_name'], "link" => $data['link'], "project_description" => html_entity_decode($data['project_desc']), "faireData" => array_map("unserialize", array_unique(array_map("serialize", $data['fairedata'])))); $json[] = $jsondata; if ($blueCount > 0) { $blueList[$blueCount]['winners'][] = $jsondata; $blueList[$blueCount]['numRibbons'] = $blueCount; } if ($redCount > 0) { $redList[$redCount]['winners'][] = $jsondata; $redList[$redCount]['numRibbons'] = $redCount; } } //blue list is an array of data //$blueList[number of blue ribbons]= array('numRibbons'=>number of blue ribbons // 'winners' =>ribbon data // ) //sort blue list and red list, within each group, alphabetically array_sort_by_column($blueList, 'numRibbons', SORT_DESC); foreach ($blueList as $key => &$value) { if (is_array($value['winners'])) { array_sort_by_column($value['winners'], 'project_name'); } foreach ($value['winners'] as $winnerKey => $winner) { foreach ($winner['faireData'] as $fdKey => $faireData) { if ($faireData['ribbonType'] == 'red') { unset($value['winners'][$winnerKey]['faireData'][$fdKey]); } } } $blueList[$key]['winners'] = $value['winners']; } array_sort_by_column($redList, 'numRibbons', SORT_DESC); foreach ($redList as $key => &$value) { if (is_array($value['winners'])) { array_sort_by_column($value['winners'], 'project_name'); } foreach ($value['winners'] as $winnerKey => $winner) { foreach ($winner['faireData'] as $fdKey => $faireData) { if ($faireData['ribbonType'] == 'blue') { unset($value['winners'][$winnerKey]['faireData'][$fdKey]); } } } $redList[$key]['winners'] = $value['winners']; } $return['json'] = $json; $return['blueList'] = $blueList; $return['redList'] = $redList; return json_encode($return); }
function get_rank($category, $start = false, $qty = false) { //$athletes = new data("athletes","filter:category='$category' and active='1'",false); //SELECT * FROM ".DBIntrd::$table." WHERE ".$filter if ($category == "all") { $athletes = new data("athletes", "custom:\n\t\t\tSELECT athletes.name,athletes.id,athletes.category,athletes.gender FROM athletes WHERE active=1\n\t\t\t", false); } else { $athletes = new data("athletes", "custom:\n\t\t\tSELECT athletes.name,athletes.id,athletes.category,athletes.gender FROM athletes WHERE active=1 and category='{$category}'\n\t\t\t", false); } $total = count((array) $athletes); if ($start > $total) { $start = 0; } //echo $start; /*$count_flash = new data("attempts","custom: SELECT athlete,count(ascent) FROM attempts WHERE ascent=1 GROUP BY athlete ",false); $count_tops = new data("attempts","custom: SELECT athlete,count(ascent) FROM attempts WHERE ascent=0 GROUP BY athlete ",false);*/ foreach ($athletes as $key => $athlete) { //vd($athlete); //die; $athlete_name = $athlete->name; $athlete_id = $athlete->id; $athlete_cat = $athlete->category; $score[$athlete_name]["id"] = $athlete_id; $score[$athlete_name]["category"] = $athlete_cat; $score[$athlete_name]["gender"] = $athlete->gender; //vd($athelete_name); //die; $attempts = new data("attempts", "filter:athlete='{$athlete_name}' and ascent=0", false); $score[$athlete_name]["attempts"] = count((array) $attempts); $ascents = new data("attempts", "filter:athlete='{$athlete_name}' and ascent=1", false); $score[$athlete_name]["tops"] = count((array) $ascents); $sum = 0; foreach ($ascents as $ascent) { $value = get_boulder($ascent->sector, $ascent->boulder)["value_top"]; $sum = $sum + $value; } $score[$athlete_name]["tops_sum"] = $sum; $flashs = new data("attempts", "filter:athlete='{$athlete_name}' and ascent=2", false); $score[$athlete_name]["flashs"] = count((array) $flashs); $sum = 0; foreach ($flashs as $flash) { $value = get_boulder($flash->sector, $flash->boulder)["value_flash"]; $sum = $sum + $value; } $score[$athlete_name]["flashs_sum"] = $sum; $score[$athlete_name]["total"] = $score[$athlete_name]["flashs_sum"] + $score[$athlete_name]["tops_sum"]; } array_sort_by_column($score, "total", SORT_DESC); //vd($score); //die; //} $score = array_slice($score, $start, $qty); return $score; }
while ($row5 = mysql_fetch_array($sel_5)) { //$data2[]=$row2; array_push($news_array, $row5); } while ($row6 = mysql_fetch_array($sel_6)) { array_push($news_array, $row6); } function array_sort_by_column(&$arr, $col, $dir = SORT_ASC) { $sort_col = array(); foreach ($arr as $key => $row) { $sort_col[$key] = $row[$col]; } array_multisort($sort_col, $dir, $arr); } array_sort_by_column($news_array, "sorting"); //project update comment code start if (isset($_POST['submitProjectUpdateComment']) && $_SESSION['userId'] != '') { extract($_POST); $updatecomment_time = time(); $con->insert("INSERT INTO `projectupdatecomment` (`updatecommentId`, `userId`, `projectId`, `updatenumber`, `updateComment`, `updateCommentTime`) VALUES \n\t\t\t\t\t(NULL, '" . $_SESSION['userId'] . "', '" . $project . "', '" . $updatenumber . "', '" . sanitize_string($projectupdate_comment) . "', '{$updatecomment_time}')"); /*if($_SESSION['userId']!=$sel_pro['userId']) { $emailid=""; $artical=""; $artical="<html><head><style>.body{font-family:Arial, Helvetica, sans-serif; font-size:12px; }</style></head>"; $artical.="<body><strong>Hello ".$sel_pro_user['name'].", </strong><br />"; $artical.="<br />Thank you for creating your profile on ".DISPLAYSITENAME.".com.<br /><br />"; $artical.="<table><tr><td colspan='2'><strong>Account Information</strong></td></tr>"; $artical.="<tr><td colspan='2'> </td></tr><tr><td><strong>User Id : </strong></td><td>".$user_comment."</td></tr>"; $artical.="<tr><td><strong>Password : </strong></td><td>".$sel_pro_user['name']."</td></tr>";
$i = 0; while ($row = mysql_fetch_array($result)) { $mobileId = $row['mobileId']; $latitude = $row['latitude']; $longitude = $row['longitude']; $distance = likit_google_map_distance($custLat, $custLong, $latitude, $longitude); $arr_distance[$i]['customerId'] = $customerId; $arr_distance[$i]['mobileId'] = $mobileId; $arr_distance[$i]['distance'] = $distance; $arr_distance[$i]['custLat'] = $custLat; $arr_distance[$i]['custLong'] = $custLong; $arr_distance[$i]['latitude'] = $latitude; $arr_distance[$i]['longitude'] = $longitude; $i++; } array_sort_by_column($arr_distance, 'distance'); //pre($arr_distance); //echo pre($arr_distance[0]); //จุดของลูกค้า $cust_latitude = $custLat; $cust_longitude = $custLong; $car1_lat = $arr_distance[0]['latitude']; $car1_long = $arr_distance[0]['longitude']; $car1_mobile = $arr_distance[0]['mobileId']; $car2_lat = $arr_distance[1]['latitude']; $car2_long = $arr_distance[1]['longitude']; $car2_mobile = $arr_distance[1]['mobileId']; $car3_lat = $arr_distance[2]['latitude']; $car3_long = $arr_distance[2]['longitude']; $car3_mobile = $arr_distance[2]['mobileId']; ?>
function jg_front_end_leaderboard($atts) { if (session_id() == '' || !isset($_SESSION)) { // session isn't started session_start(); } ob_start(); global $current_user; global $wp_roles; global $wpdb; global $error; global $js_shortcode_on_front; extract(shortcode_atts(array('redirectPaid' => 0, 'display' => true, 'template' => '', 'orderby' => '', 'order' => '', 'limit' => 0), $atts)); //get all pages $teams = array(); $wpjg_generalSettings = get_option('jg_general_settings'); include_once JG_PLUGIN_DIR . '/lib/JustGivingClient.php'; $client = new JustGivingClient($wpjg_generalSettings['ApiLocation'], $wpjg_generalSettings['ApiKey'], $wpjg_generalSettings['ApiVersion'], $wpjg_generalSettings['TestUsername'], $wpjg_generalSettings['TestValidPassword']); // get teams for pages $teams = get_transient('justgiving_teams'); if (DEBUG) { $teams = NULL; } $players = 0; if (!$teams) { $results = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}jgteams WHERE `teamshortname`<>'';"); //print_r($results); foreach ($results as $result) { $res = $client->Team->Get($result->teamshortname); //print_R($res); $vars = array(); if ($res) { $vars = array_merge(get_object_vars($res), get_object_vars($result)); $vars['numMembers'] = count($res->teamMembers); $players += count($res->teamMembers); } else { $vars = array_merge(get_object_vars($result)); } $teams[$res->id] = $vars; } } else { foreach ($teams as $team) { $players += $team['numMembers']; } } if (!DEBUG && (!isset($_GET['id']) || intval($_GET['id']) == 0)) { set_transient('justgiving_teams', $teams, 60 * 10); // 1/2 day storage } include_once JG_PLUGIN_DIR . '/lib/functions.php'; $teams = unstrip_array($teams); require_once JG_PLUGIN_DIR . '/lib/Smarty.class.php'; $smarty = new Smarty(); $smarty->template_dir = JG_PLUGIN_DIR . '/smarty/templates/'; $smarty->compile_dir = JG_PLUGIN_DIR . '/smarty/templates_c/'; $smarty->config_dir = JG_PLUGIN_DIR . '/smarty/configs/'; $smarty->cache_dir = JG_PLUGIN_DIR . '/smarty/cache/'; //print_R($teams); if ($orderby != '') { if ($order == 'asc') { array_sort_by_column($teams, $orderby, SORT_ASC); } else { array_sort_by_column($teams, $orderby, SORT_DESC); } } if ($limit != 0) { $teams = array_slice($teams, 0, $limit); } $selteam = array(); if (isset($_REQUEST['selteam']) && $_REQUEST['selteam']) { foreach ($teams as $team) { if ($team['teamshortname'] == $_REQUEST['selteam']) { $selteam = $team; break; } } } if (isset($selteam['dateCreated'])) { $smarty->assign('sel', $selteam); } $smarty->assign('teams', $teams); $smarty->assign('pluginurl', JG_PLUGIN_URL); $smarty->assign('templateurl', get_template_directory_uri()); $smarty->assign('players', $players); $smarty->assign('settings', $wpjg_generalSettings); if ($template != '') { $smarty->display($template); } else { $smarty->display('leaderboard.html'); } $output = ob_get_contents(); ob_end_clean(); return $output; }
} else { //output all matches to screen echo "<table class=\"bordered\" cellspacing=\"0\">\n"; echo "<tr><th>City</th><th>State</th><th>ZIP Code</th><th>Latitude</th><th>Longitude</th><th>Miles, Point A To B</th></tr>\n"; $tmp = array(); $i = 0; while ($row = mysql_fetch_array($rs)) { $distance = round(acos(sin(deg2rad($lat1)) * sin(deg2rad($row['latitude'])) + cos(deg2rad($lat1)) * cos(deg2rad($row['latitude'])) * cos(deg2rad($row['longitude']) - deg2rad($lon1))) * $r); if ($d >= $distance) { $tmp[$i] = $row; $tmp[$i]['distance'] = $distance; $i++; } } //now we can sort the temp array via the function at the top of the page array_sort_by_column($tmp, 'distance'); foreach ($tmp as $data) { echo "<tr><td>{$data['city']}</td><td>{$data['state']}</td><td>{$data['zip_code']}</td><td>{$data['latitude']}</td><td>{$data['longitude']}</td><td>{$data['distance']}</td></tr>\n"; } while ($row = mysql_fetch_array($rs)) { } echo "</table>\n<br />\n"; } } } } } ?> <p><a href="http://www.dougv.com/blog/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/">Getting All ZIP Codes In A Given Radius From A Known Point / ZIP Code Via PHP And MySQL</a></p> </body> </html>
function array_sort_by_column(&$arr, $col, $dir = SORT_DESC) { $sort_col = array(); foreach ($arr as $key => $row) { $sort_col[$key] = $row[$col]; } array_multisort($sort_col, $dir, $arr); } $links = array(); $i = 0; foreach ($html->find('tr.gai,tr.tum') as $a) { $i = $i + 1; $linkname = $a->children(1)->children(1)->getAttribute('innertext'); $leechers = strip_tags($a->last_child()->children(0)); $leechers = preg_replace("/&#?[a-z0-9]+;/i", "", $leechers); // removing nbsp and other html trash $url = 'http://www.rutor.org' . $a->children(1)->children(1)->href; // print $url.PHP_EOL; $links[$i]['leechers'] = $leechers; $links[$i]['name'] = $linkname; $links[$i]['url'] = $url; // print($i.' >> '. $leechers.' >> '. $linkname .PHP_EOL); } array_sort_by_column($links, 'leechers'); // Sort this shit! for ($i = 0; $i < $results; $i++) { if (strlen($links[$i]['name']) > 5) { // А вдруг, зачем нам это недоразумение. echo $links[$i]['leechers'] . ' ' . mb_strimwidth($links[$i]['name'], 0, 50, "") . PHP_EOL; } }
private static function get_regional_inheritance($generations, $region) { // returns 2 arrays: 'current' and 'inherited' // v6.49 // v6.53 $custom_array = array('current' => array(), 'inherited' => array()); foreach ($generations as $aboveness => $generation) { // v3.84 $c_or_i = $aboveness == 0 ? 'current' : 'inherited'; // v6.66 $custom_values = get_post_custom($generation); foreach ($custom_values as $cv_key => $cv_value) { $cv_key_array = explode('-', $cv_key); if ($cv_key_array[0] == $region) { $qstring = qscode($cv_value[0]); // qscode makes it into a querystring $c = count($cv_key_array); if ($c == 3) { // an order is specified $rank = $cv_key_array[1]; // eg: "2" } else { $rank = "0"; } $custom_array[$c_or_i][] = array('widget_type' => $cv_key_array[$c - 1], 'qstring' => $qstring, 'rank' => $rank, 'aboveness' => $aboveness); // v6.66 } elseif ($cv_key == $region . "_cancel" && $cv_value[0] == '1') { // whether current or inherited: this has to be the only entry for this level $custom_array[$c_or_i][] = array('widget_type' => 'cancel', 'qstring' => '', 'rank' => '0', 'aboveness' => $aboveness); } } // foreach ($custom_values if (count($custom_array['inherited']) > 0) { // v4.12 we only need the nearest inheritance break; // jumps out of foreach ($generations } } // foreach ($generations array_sort_by_column($custom_array['current'], 'rank'); array_sort_by_column($custom_array['inherited'], 'rank'); return $custom_array; }
private function col($row, $data) { $sort_order = array_flip($this->set['cols']); foreach ($row as $k => $v) { $v['val'] = $v[0]; // unset($v[0]); $v['order'] = $sort_order[$k]; $cols[$k] = $v; switch ($v['type']) { case 'lnk': $cols[$k]['href'] = self::set_lnk($v['href'], $data); break; } if (isset($v['custom'])) { $cols[$k]['custom'] = self::set_custom($v['custom'], $data); } } array_sort_by_column($cols, 'order'); return $cols; }
function poolsTable($pools) { // class="success" error warning info $poolID = 0; $table = ""; array_sort_by_column($pools, 'Priority'); foreach ($pools as $pool) { if ($pool['Status'] != "Alive") { $rowclass = 'error'; } else { $rowclass = 'success'; } $poolURL = explode(":", str_replace("/", "", $pool['URL'])); $table = $table . "\n <tr class='" . $rowclass . "'>\n\t<td>"; if ($poolID != 0) { $table = $table . "<form name='spool' action='/' method='post'><input type='hidden' name='url' value='" . $pool['URL'] . "' /><input type='image' src='/img/up.png' name='image'></form>"; } $table = $table . "\n <td class='text-left'>" . $poolURL[1] . "</td>\n <td class='text-left ellipsis'>" . $pool['User'] . "</td>\n <td class='text-left'>" . $pool['Status'] . "</td>\n <td>" . $pool['Priority'] . "</td>\n <td>" . $pool['Getworks'] . "</td>\n <td>" . $pool['Accepted'] . "</td>\n <td>" . $pool['Rejected'] . "</td>\n <td>" . $pool['Discarded'] . "</td>\n <td>" . date('H:i:s', $pool['LastShareTime']) . "</td> \n <td>" . $pool['Diff1Shares'] . "</td> \n <td>" . round($pool['DifficultyAccepted']) . " [" . (!$pool['Diff1Shares'] == 0 ? round($pool['DifficultyAccepted'] / $pool['Diff1Shares'] * 100) : 0) . "%]</td>\n <td>" . round($pool['DifficultyRejected']) . " [" . (!$pool['Diff1Shares'] == 0 ? round($pool['DifficultyRejected'] / $pool['Diff1Shares'] * 100) : 0) . "%]</td>\n <td>" . round($pool['LastShareDifficulty'], 0) . "</td>\n <td>" . $pool['BestShare'] . "</td>\n </tr>"; $poolID++; } return $table; }