function search_440()
{
    include '440_core.php';
    if (!isset($_GET['pg'])) {
        $defindex = array();
        $effect = array();
        foreach ($_POST as $key => $value) {
            if (stripos($value, ",") > -1) {
                //this is to find the array key where the script stored the values.
                $process = explode(',', $value);
                foreach ($process as $key => $value) {
                    if (stripos($value, "def_") > -1) {
                        $defindex[] = preg_replace("/[^0-9]/", "", $value);
                    }
                    if (stripos($value, "eff_") > -1) {
                        $effect[] = preg_replace("/[^0-9]/", "", $value);
                    }
                }
            }
        }
    } else {
        $defindex = (int) $_GET['def'];
        $effect = (int) $_GET['eff'];
        $pg = $_GET['pg'];
        var_dump_html($_GET);
    }
    if (isset($_GET['pg']) && is_numeric($_GET['pg'])) {
        $pg = (int) $_GET['pg'];
    }
    $input = array('defindex' => $defindex, 'effect' => $effect, 'pg' => $pg);
    /*Here's how it works. The parameters are only used if they are present.
    	If they are not present, they are not used as a part of the query and they are therefore equivalent to an sql "*".*/
    //find
    $qWhere = array();
    if (!isset($input) || $input == NULL || empty($input)) {
        echo "No data submitted<br>";
        return 0;
    }
    //$defVal = array( '$exists'=>true );
    $match = array();
    //{"unusual":{"$all":[{"$elemMatch":{"defindex":30030,"_particleEffect":{"$exists":true}}}]},"date_reserved":{"$not":{"$gt":1409106749}}}
    //{"unusual":{"$all":[{"$elemMatch":{"defindex":"30030"}, "_particleEffect":{"$exists":true}}]},"date_reserved":{"$lt":1409106917}}
    if (!in_array(1, $input['defindex']) && !empty($input['defindex'][0])) {
        $match['$elemMatch']['defindex'] = (int) $input['defindex'][0];
    } else {
        $match['$elemMatch']['defindex']['$exists'] = true;
    }
    if (!in_array(1, $input['effect']) && !empty($input['effect'][0])) {
        $match['$elemMatch']['_particleEffect'] = (int) $input['effect'][0];
    } else {
        $match['$elemMatch']['_particleEffect']['$exists'] = true;
    }
    $outdate_reserve = time() - 432000;
    $query = array('unusual' => array('$all' => array($match)), 'date_reserved' => array('$not' => array('$gt' => $outdate_reserve)));
    //echo json_encode($query);
    //{ price: { $not: { $gt: 1.99 } } }
    //{ "price": { "$not": { "gt": 1.99 } } }
    //'date_reserved' => array( '$not' => array( 'gt' => $outdate_reserve ) )
    //echo '<br><br>' . json_encode( $query ) . '<br><br><br>';
    if (isset($pg) && $pg != 0) {
        $skip = (int) $pg * 100;
    } else {
        $skip = 0;
    }
    $col = db_init('items', 'unusual');
    $sort = 'hrs.440';
    $sortList = array(1 => 'hrs.440', 2 => 'recent', 3 => 'first');
    if (isset($_POST['sortby']) && isset($sortList[$_POST['sortby']])) {
        $sort = $sortList[$_POST['sortby']];
    }
    $sortorder = 1;
    if (isset($_POST['sortorder']) && $_POST['sortorder'] == 2) {
        $sortorder = -1;
    }
    $cursor = $col->find($query)->sort(array($sort => $sortorder))->limit(100)->skip($skip);
    $resultCount = 0;
    $resultCount = $cursor->count();
    if ($resultCount > 0) {
        echo $resultCount . ' Users found.<br>';
        userlist_display($cursor, $input, 440);
        if (is_array($defVal)) {
            $defVal = 1;
        }
        if (is_array($effVal)) {
            $effVal = 1;
        }
        $page = $pg + 1;
        echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="GET"><br><br>Next Page: <input type="hidden" name="def" value="' . (int) $defindex[0] . '"><input type="hidden" name="eff" value="' . (int) $effect[0] . '"><input type="hidden" name="gid" value=440><input type="submit" name="pg" value="' . (int) $page . '"></form>';
    } else {
        echo 'No matches found.';
    }
}
Beispiel #2
0
    $gid = (int) $_GET['gid'];
}
echo '<h2><a href=' . $_SERVER['PHP_SELF'] . '?gid=440>Your TF2 reserved users.</a></h2><br>';
echo '<h2><a href=' . $_SERVER['PHP_SELF'] . '?gid=730>Your CSGO reserved users.</a></h2><br>';
if (isset($gid) && is_numeric($_SESSION['sid']) && donator_level(20)) {
    switch ($_GET['gid']) {
        case 440:
            $collection = $c = db_init('items', 'unusual');
            include_once 'php/440_core.php';
            break;
        case 730:
            $collection = db_init('archive', 'items_730');
            include 'php/730_core.php';
            break;
    }
    $steamid = (int) $_SESSION['sid'];
    if (isset($_POST['notes'])) {
        $notes = (string) $_POST['notes'];
    } else {
        $notes = 'no notes.';
    }
    $cursor = $collection->find(array('user_reserver' => $steamid));
    if ($cursor->count() > 0) {
        echo '<input type="hidden" id=gameid value="' . $gid . '">';
        echo '<h3>These are your currently reserved users.</h3><br>';
        userlist_display($cursor, null, $gid);
    } else {
        echo '<h1>No currently reserved users</h1>';
    }
}
createFooter(440);