Ejemplo n.º 1
0
function my_sort(&$array, $left, $right)
{
    $l = $left;
    $r = $right;
    $center = $array[(int) ($left + $right) / 2];
    do {
        while ($array[$r] > $center) {
            $r--;
        }
        while ($array[$l] < $center) {
            $l++;
        }
        if ($l <= $r) {
            list($array[$r], $array[$l]) = array($array[$l], $array[$r]);
            $l++;
            $r--;
        }
    } while ($l <= $r);
    if ($r > $left) {
        my_sort($array, $left, $r);
    }
    if ($l < $right) {
        my_sort($array, $l, $right);
    }
}
Ejemplo n.º 2
0
 public function index()
 {
     $where['status'] = 2;
     $slist = M('sale')->where($where)->field('bsid,amount,add_date,add_time,email')->order('add_time desc')->limit(5)->select();
     $blist = M('buy')->where($where)->field('bsid,amount,add_date,add_time,email')->order('add_time desc')->limit(5)->select();
     $cards = array_merge($slist, $blist);
     //	$person = my_sort($person,'name',SORT_ASC,SORT_STRING);
     $art = my_sort($cards, 'add_time');
     //按照add_time字段排序降序
     $this->assign('art', $art);
     $this->display();
 }
Ejemplo n.º 3
0
    }
    $ord = array();
    for ($i = 0; $i < $co; ++$i) {
        $ord[$i] = $i;
    }
    function my_sort($ord, $assoc, $co)
    {
        for ($i = 0; $i < $co; ++$i) {
            for ($j = 0; $j < $co; ++$j) {
                if ($assoc[$ord[$i]] > $assoc[$ord[$j]]) {
                    $ord[$i] ^= $ord[$j] ^= $ord[$i] ^= $ord[$j];
                }
            }
        }
        return $ord;
    }
    $ord = my_sort($ord, $id_to_popularity, $co);
    echo "<table>\n";
    echo "  <tr>  ";
    echo "<th>Elev</th>  ";
    echo "<th>Popularitate</th>  ";
    echo "  <tr>\n";
    for ($j = 0; $j < $co; ++$j) {
        echo " <tr> ";
        echo "<td>" . $id_to_name[$ord[$j]] . "</td>  ";
        echo "<td>" . $id_to_popularity[$ord[$j]] . "</td>  ";
        echo "  <tr>\n";
    }
    echo "</table>";
}
mysqli_close($conn);
Ejemplo n.º 4
0
        while ($lindex < $llen) {
            list($lid_array[$lindex++]) = mysql_fetch_row($lresult);
        }
        if (@$l_remain != '' && $lexact_phrase != "on") {
            return array_values(array_unique(array_merge($lid_array, search($lwhere, substr($l_remain, 1), $lexact_phrase, $lcase_sensitivity, $lsearch_array))));
        }
        return array_values(array_intersect($lid_array, $lsearch_array));
    }
    $current_user = new User($_SESSION['uid'], $GLOBALS['connection'], DB_NAME);
    $user_perms = new User_Perms($_SESSION['uid'], $GLOBALS['connection'], DB_NAME);
    $current_user_permission = new UserPermission($_SESSION['uid'], $GLOBALS['connection'], DB_NAME);
    //$s_getFTime = getmicrotime();
    if ($_GET['where'] == 'author_locked_files') {
        $view_able_files_id = $current_user->getExpiredFileIds();
    } else {
        $view_able_files_id = $current_user_permission->getViewableFileIds(false);
    }
    //$e_getFTime = getmicrotime();
    $id_array_len = sizeof($view_able_files_id);
    $query_array = array();
    $search_result = search(@$_GET['where'], @$_GET['keyword'], @$_GET['exact_phrase'], @$_GET['case_sensitivity'], $view_able_files_id);
    //echo 'khoa' . sizeof($search_result);
    $sorted_result = my_sort($search_result);
    // Call the plugin API
    callPluginMethod('onSearch');
    list_files($sorted_result, $current_user_permission, $GLOBALS['CONFIG']['dataDir'], false, false);
    echo '<br />';
    draw_footer();
    //echo '<br> <b> Load Page Time: ' . (getmicrotime() - $start_time) . ' </b>';
    //echo '<br> <b> Load Permission Time: ' . ($e_getFTime - $s_getFTime) . ' </b>';
}