function pref_validate($input)
{
    $css_default = quality_colours_prefs(1);
    foreach ($css_default as $quality => $val) {
        if (ctype_xdigit($input['css'][$quality]['bg'])) {
            $css[$quality]['bg'] = (string) $input['css'][$quality]['bg'];
        } else {
            $css[$quality]['bg'] = (string) $val['bg'];
        }
        if (ctype_xdigit($input['css'][$quality]['border'])) {
            $css[$quality]['border'] = (string) $input['css'][$quality]['border'];
        } else {
            $css[$quality]['border'] = (string) $val['border'];
        }
    }
    $numeric = $input['numeric'];
    arrayToNumeric($numeric);
    $res['css'] = $css;
    $res['numeric'] = $numeric;
    return $res;
}
示例#2
0
function mongoHandler($input)
{
    /*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>";
        break;
    }
    if (in_array(1, $input['defindex']) || empty($input['defindex'])) {
        $defVal = array('$exists' => true);
    } else {
        arrayToNumeric($input['defindex']);
        $defVal = reset($input['defindex']);
    }
    //use the defindex array as a parameter.
    if (in_array(1, $input['effect']) || empty($input['effect'])) {
        $effVal = array('$exists' => true);
        //search type is any effect
    } else {
        arrayToNumeric($input['effect']);
        $effVal = reset($input['effect']);
    }
    $outdate_reserve = time() - 432000;
    if (isset($defVal) && isset($effVal)) {
        $match = array('$elemMatch' => array('defindex' => $defVal, '_particleEffect' => $effVal));
        $query = array('unusual' => array('$all' => array($match)), 'date_reserved' => array('$not' => array('$gt' => $outdate_reserve)));
        //{ 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 ($input['pg'] != 0) {
            $skip = (int) $input['pg'] * 100;
        } else {
            $skip = 0;
        }
        $m = new MongoClient();
        $db = $m->items;
        $collection = $db->unusual;
        $cursor = $collection->find($query)->sort(array("hrs.440" => 1))->limit(100)->skip($skip);
        $resultCount = 0;
        $resultCount = $cursor->count();
        if ($resultCount > 0) {
            echo $resultCount . ' Users found.<br>';
            userList($cursor, $input);
            if (is_array($defVal)) {
                $defVal = 1;
            }
            if (is_array($effVal)) {
                $effVal = 1;
            }
            $page = $input['pg'] + 1;
            echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="GET"><br><br>Next Page: <input type="hidden" name="def" value="' . $defVal . '"><input type="hidden" name="eff" value="' . $effVal . '"><input type="submit" name="pg" value="' . $page . '"></form>';
        } else {
            echo 'No matches found.';
        }
    }
}