| // +---------------------------------------------------------------------------+ // | This file makes the connection to the databases. | // +---------------------------------------------------------------------------+ if (!isset($intConn)) { $intConn = pg_connect("host=207.178.201.201 user=ss password=ssdb dbname=ss") or die("Could not connect to database!"); } ?> 1) { return "(" . implode($strDelimiter, $arySearch) . ")"; } else { return "(" . $arySearch[0] . ")"; } } else { // Match exact phrase $strSearch = addslashes($strSearch); // Build query for ($i = 0; $i < sizeof($arySearchFields); $i++) { $arySearch[$i] = "UPPER({$arySearchFields[$i]}) LIKE UPPER('%{$strSearch}%')"; } // Return if (sizeof($arySearch) > 1) { return "(" . implode(" OR ", $arySearch) . ")"; } else { return $arySearch[0]; } } } /* +--------------------------------------------------+ | PARSE_ADVANCED_QUERY (str AnyWords, str AllWords | | str ExactPhrase, | | str WithoutWords | | ary SearchFields) | +--------------------------------------------------+ | Returns a SQL select statement on any outcome | +--------------------------------------------------+ */ function parse_advanced_query($strAnyWords = "", $strAllWords = "", $strExactPhrase = "", $strWithoutWords = "", $arySearchFields = array()) { // Advanced search $strAnyWords = trim($strAnyWords); $strAllWords = trim($strAllWords); $strExactPhrase = trim($strExactPhrase); $strWithoutWords = trim($strWithoutWords); // Build ANY words query if ($strAnyWords != "") { // Replace multiple spaces with 1 space $strAnyWords = preg_replace("/\s{1,}/", " ", $strAnyWords); // Explode string by space $aryAnyWords = explode(" ", $strAnyWords); for ($i = 0; $i < sizeof($aryAnyWords); $i++) { $aryAnyWords[$i] = addslashes($aryAnyWords[$i]); for ($x = 0; $x < sizeof($arySearchFields); $x++) { if (isset($aryAnyWordsSearch[$i])) { $aryAnyWordsSearch[$i] .= " OR UPPER({$arySearchFields[$x]}) LIKE UPPER('% {$aryAnyWords[$i]}%')"; $aryAnyWordsSearch[$i] .= " OR UPPER({$arySearchFields[$x]}) LIKE UPPER('{$aryAnyWords[$i]}%')"; } else { $aryAnyWordsSearch[$i] .= " UPPER({$arySearchFields[$x]}) LIKE UPPER('% {$aryAnyWords[$i]}%')"; $aryAnyWordsSearch[$i] .= " OR UPPER({$arySearchFields[$x]}) LIKE UPPER('{$aryAnyWords[$i]}%')"; } } } if (isset($aryAnyWordsSearch)) { if (sizeof($aryAnyWordsSearch) > 1) { $strQuery[] = "(" . implode(") OR (", $aryAnyWordsSearch) . ")"; } else { $strQuery[] = "{$aryAnyWordsSearch[0]}"; } } } // Build ALL words query if ($strAllWords != "") { // Replace multiple spaces with 1 space $strAllWords = preg_replace("/\s{1,}/", " ", $strAllWords); // Explode string by space $aryAllWords = explode(" ", $strAllWords); for ($i = 0; $i < sizeof($aryAllWords); $i++) { $aryAllWords[$i] = addslashes($aryAllWords[$i]); for ($x = 0; $x < sizeof($arySearchFields); $x++) { if (isset($aryAllWordsSearch[$i])) { $aryAllWordsSearch[$i] .= " OR UPPER({$arySearchFields[$x]}) LIKE UPPER('% {$aryAllWords[$i]}%')"; $aryAllWordsSearch[$i] .= " OR UPPER({$arySearchFields[$x]}) LIKE UPPER('{$aryAllWords[$i]}%')"; } else { $aryAllWordsSearch[$i] .= " UPPER({$arySearchFields[$x]}) LIKE UPPER('% {$aryAllWords[$i]}%')"; $aryAllWordsSearch[$i] .= " OR UPPER({$arySearchFields[$x]}) LIKE UPPER('{$aryAllWords[$i]}%')"; } } } if (isset($aryAllWordsSearch)) { if (sizeof($aryAllWordsSearch) > 1) { $strQuery[] = "(" . implode(") AND (", $aryAllWordsSearch) . ")"; } else { $strQuery[] = "{$aryAllWordsSearch[0]}"; } } } // Build WITHOUT words query if ($strWithoutWords != "") { // Replace multiple spaces with 1 space $strWithoutWords = preg_replace("/\s{1,}/", " ", $strWithoutWords); // Explode string by space $aryWithoutWords = explode(" ", $strWithoutWords); for ($i = 0; $i < sizeof($aryWithoutWords); $i++) { $aryWithoutWords[$i] = addslashes($aryWithoutWords[$i]); for ($x = 0; $x < sizeof($arySearchFields); $x++) { if (isset($aryWithoutWordsSearch[$i])) { $aryWithoutWordsSearch[$i] .= " AND UPPER({$arySearchFields[$x]}) NOT LIKE UPPER('% {$aryWithoutWords[$i]}%')"; $aryWithoutWordsSearch[$i] .= " AND UPPER({$arySearchFields[$x]}) NOT LIKE UPPER('{$aryWithoutWords[$i]}%')"; } else { $aryWithoutWordsSearch[$i] .= " UPPER({$arySearchFields[$x]}) NOT LIKE UPPER('% {$aryWithoutWords[$i]}%')"; $aryWithoutWordsSearch[$i] .= " AND UPPER({$arySearchFields[$x]}) NOT LIKE UPPER('{$aryWithoutWords[$i]}%')"; } } } if (isset($aryWithoutWordsSearch)) { if (sizeof($aryWithoutWordsSearch) > 1) { $strQuery[] = "(" . implode(") AND (", $aryWithoutWordsSearch) . ")"; } else { $strQuery[] = "{$aryWithoutWordsSearch[0]}"; } } } // Build EXACT PHRASE query if ($strExactPhrase != "") { for ($i = 0; $i < sizeof($arySearchFields); $i++) { if (isset($strExactPhraseSearch)) { $aryExactPhraseSearch[$i] .= " OR UPPER({$arySearchFields[$i]}) LIKE UPPER('% {$strExactPhrase}%')"; $aryExactPhraseSearch[$i] .= " OR UPPER({$arySearchFields[$i]}) LIKE UPPER('{$strExactPhrase}%')"; } else { $aryExactPhraseSearch[$i] .= " UPPER({$arySearchFields[$i]}) LIKE UPPER('% {$strExactPhrase}%')"; $aryExactPhraseSearch[$i] .= " OR UPPER({$arySearchFields[$i]}) LIKE UPPER('{$strExactPhrase}%')"; } } if (isset($aryExactPhraseSearch)) { if (sizeof($aryExactPhraseSearch) > 1) { $strQuery[] = implode(" OR ", $aryExactPhraseSearch); } else { $strQuery[] = $aryExactPhraseSearch[0]; } } } if (isset($strQuery)) { if (sizeof($strQuery) > 1) { return "(" . implode(") AND (", $strQuery) . ")"; } else { return $strQuery[0]; } } return ""; } /* +--------------------------------------------------+ | CHECK_WORD_COUNT (ary Words, str Word) | +--------------------------------------------------+ | Returns the number of times the word occures in | | the array | +--------------------------------------------------+ */ function check_word_count ($aryWords = array(), $strWord = "") { $count = 0; for ($i = 0; $i < sizeof($aryWords); $i++) { if (strtolower($aryWords[$i]) == strtolower($strWord)) $count++; } return $count; } /* +--------------------------------------------------+ | GET_PATH (int node) | +--------------------------------------------------+ | Returns a full path to the node on success and | | false on failure | +--------------------------------------------------+ */ function get_path ($intConn = 0, $intNode = 0) { if ($intNode == 0) { return false; } else if (!preg_match("/^[0-9]+$/", $intNode)) { return false; } if (!($aryRow = get_node_info($intConn, $intNode))) return false; $strPath = "$aryRow[name]"; $intNode = $aryRow["parent_id"]; while (1) { if ($intNode > 1) { if (!($aryRow = get_node_info($intConn, $intNode))) break; $strPath = "$aryRow[name] / {$strPath}"; $intNode = $aryRow["parent_id"]; } else { break; } } return $strPath; } /* +--------------------------------------------------+ | GET_NODE_INFO (int node) | +--------------------------------------------------+ | Returns a result set that contains the node and | | name on success and false on failure | +--------------------------------------------------+ */ function get_node_info ($intConn = 0, $intNode = 0) { $strExec = "SELECT node_id, parent_id, name FROM nodes WHERE node_id = $intNode"; $intQuery = pg_exec($intConn, $strExec); if (pg_numrows($intQuery) > 0) return pg_fetch_array($intQuery, 0); return false; } /* +--------------------------------------------------+ | GET_PAGE_NUMS (int page, int limit, int pages) | +--------------------------------------------------+ | Returns an array containing the start and ending | | points | +--------------------------------------------------+ | 1 = Forward | | 2 = Backward | +--------------------------------------------------+ */ function get_page_nums ($intPage = 1, $intLimit = 1, $intTotalPages) { $tmpArray = explode(".", $intTotalPages); $intTotalPages = $tmpArray[0]; // Figure out the direction to work from if ($intPage > 5) { if ($intPage + 5 < $intTotalPages) { $intDir = 1; $intStart = $intPage - 5; } else { $intDir = 2; $intEnd = $intTotalPages; } } else { $intDir = 1; $intStart = 1; } if ($intDir == 1) { $intEnd = $intStart; // Fordward for ($i = $intStart; $i < $intStart + 10; $i++) { if ($i < $intTotalPages) { $intEnd++; } else { break; } } return array($intStart, $intEnd); } else { // Backward $intStart = $intEnd; // Forward for ($i = $intEnd; $i >= $intEnd - 10; $i--) { if ($i > 1) { $intStart--; } else { break; } } return array($intStart, $intEnd); } } /* +--------------------------------------------------+ | GET_PATH (int node) | +--------------------------------------------------+ | Returns a full path to the node on success and | | false on failure | +--------------------------------------------------+ */ function get_search_path ($intConn = 0, $intNode = 0) { if ($intNode == 0) { return false; } else if (!preg_match("/^[0-9]+$/", $intNode)) { return false; } if (!($aryRow = get_node_info($intConn, $intNode))) return false; $strPath = $aryRow['name']; $intNode = $aryRow["parent_id"]; $nid = $aryRow['node_id']; for ($i = 0; true; $i++) { if ($intNode > 1) { if (!($aryRow = get_node_info($intConn, $intNode))) break; $strPath = $aryRow['name'] . ' / ' . $strPath; $intNode = $aryRow["parent_id"]; } else { break; } } $strPath = "$strPath"; return $strPath; } /* +--------------------------------------------------+ | GET_PATH (int node) | +--------------------------------------------------+ | Returns a full path to the node on success and | | false on failure | +--------------------------------------------------+ */ function get_clean_path ($intConn = 0, $intNode = 0) { if ($intNode == 0) { return false; } else if (!preg_match("/^[0-9]+$/", $intNode)) { return false; } if (!($aryRow = get_node_info($intConn, $intNode))) return false; $strPath = $aryRow['name']; $intNode = $aryRow["parent_id"]; $nid = $aryRow['node_id']; for ($i = 0; true; $i++) { if ($intNode > 1) { if (!($aryRow = get_node_info($intConn, $intNode))) break; $strPath = $aryRow['name'] . ' / ' . $strPath; $intNode = $aryRow["parent_id"]; } else { break; } } return $strPath; } ?> Access Your Account | SearchSystems.net

* Required Fields

Member Login

Log in here to SearchSystems.net for access to criminal records, bankruptcies, judgments, and tax lien databases, as well as our public records directory.

If you don't have a username and password yet become a member.

Members have a subscription issued by SearchSystems.net. No other website or service may offer a SearchSystems.net membership.

SearchSystems.net

One of the "Fifty most useful web sites on the Internet"

- PCWorld Magazine, February 2003