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.'; } }
function sl_getsnmp(&$object, $debug = false) { $object_id = $object['id']; $object_name = $object['name']; if (isset($object['SNMP'])) { if ($debug) { echo "INFO: No SNMP Object \"{$object_name}\" ID: {$object_id}<br>"; } return null; } if (!considerConfiguredConstraint($object, 'IPV4OBJ_LISTSRC')) { if ($debug) { echo "INFO: No IPv4 Object \"{$object_name}\" ID: {$object_id}<br>"; } return False; } /* get object saved SNMP settings */ $snmpconfig = explode(':', strtok($object['comment'], "\n\r")); if ($snmpconfig[0] != "SNMP") { if ($debug) { echo "INFO: No saved SNMP Settings for \"{$object_name}\" ID: {$object_id}<br>"; } return False; } /* set objects SNMP ip address */ $ipv4 = $snmpconfig[1]; if (0) { var_dump_html($snmpconfig); } if (!$ipv4) { echo "ERROR: no ip for \"{$object_name}!!\"<br>"; return False; } $object['SNMP']['IP'] = $ipv4; if (count($snmpconfig) < 4) { echo "SNMP Error: Missing Setting for {$object_name} ({$ipv4})"; return False; } /* SNMP prerequisites successfull */ $s = new sl_ifxsnmp($snmpconfig[2], $ipv4, $snmpconfig[3], $snmpconfig); if (!$s->error) { /* get snmp data */ $iftable = $s->getiftable(); if ($debug && $s->error) { echo $s->getError(); } if ($iftable) { return $iftable; } else { echo "SNMP Error: " . $s->getError() . " for {$object_name} ({$ipv4})<br>"; return False; } } else { echo "SNMP Config Error: " . $s->error . " for \"{$object_name}\"<br>"; return False; } return null; }