Permalink
Browse files

added nusearchclass.php

  • Loading branch information...
steven-copley committed Oct 24, 2016
1 parent a82fd62 commit 71e783df66494c6b510dc20a9a774d4b154c8d85
Showing with 168 additions and 20 deletions.
  1. +11 −7 index.php
  2. +0 −13 nucommon.js
  3. +157 −0 nusearchclass.php
@@ -21,6 +21,12 @@
<script>
function nuValidCaller(o){
if(o === null){return false;}
return o.hasOwnProperty('nuVersion');
}
function nuHomeWarning(){
@@ -32,10 +38,9 @@ function nuHomeWarning(){
}
window.onbeforeunload = nuHomeWarning;
window.nuHASH = [];
window.nuVersion = 'nuBuilder4';
window.onbeforeunload = nuHomeWarning;
window.nuHASH = [];
@@ -67,15 +72,14 @@ function nuLoad(){
nuLogin();
}
}else{
function nuLoad(){
if(nuIsOpener(window)){
var from = window['opener'];
var from = window.opener;
}else{
var from = window['parent'];
var from = window.parent;
}
window.nuFORM.caller = from.nuFORM.current;
@@ -471,19 +471,6 @@ function nuTranslate(s){
}
function nuValidCaller(o){
for (var key in o) {
if (key == 'nuVersion' && o[key] == 'nuBuilder4'){
return true;
}
}
return false;
}
function nuIsOpener() {
@@ -0,0 +1,157 @@
<?php
class nuSearchClass{
private $where = array();
private $not = array();
private $columns = array();
private $search = array();
public function __construct($s){
$q = '"';
$S = str_split($s);
$min = '-';
$dbl = '"';
$o = array();
$isP = false;
$isN = false;
for($i = 0 ; $i < count($S) ; $i++){
$c = new stdClass;
$c->value = $S[$i];
$c->not = false;
$c->phrase = false;
$o[] = $c;
}
for($i = 0 ; $i < count($o) ; $i++){
$isP = $this->phrase($o, $i, $isP);
}
$isN = false;
for($i = 0 ; $i < count($o) ; $i++){
if($o[$i]->value == '-'){
$isN = true;
}
if(!$o[$i]->phrase and $o[$i]->value == ' '){
$isN = false;
}
$o[$i]->not = $isN;
}
$W = '';
$N = '';
$where = true;
for($i = 0 ; $i < count($o) ; $i++){
$O = $o[$i];
if($O->value == '"'){
}else if($O->value == '-' and !$O->phrase){
}else if($O->value == ' ' and !$O->phrase){
if($W != ''){
$this->where[] = $W;
}
if($N != ''){
$this->not[] = $N;
}
$N = '';
$W = '';
}else if($O->not){
$N .= $O->value;
}else if(!$O->not){
$W .= $O->value;
}
}
if($W != ''){
$this->where[] = $W;
}
if($N != ''){
$this->not[] = $N;
}
return this;
}
public function phrase(&$o, $i, $isP){
if($o[$i]->value != '"'){return $isP;}
if($isP){ //-- is ending quote
$o[$i]->phrase = true;
return false;
}else{
if($this->hasNextQuoted($o, $i)){ //-- quote with matching quote
$o[$i]->phrase = true;
return true;
}else{
return false;
}
}
}
public function hasNextQuoted($o, $i){
$i++;
$s = $i;
for($i ; $i < count($o) ; $i++){
if($o[$i]->value == '"'){
$this->addPhraseTag($o, $s, $i);
return true;
}
}
return false;
}
private function addPhraseTag(&$o, $s, $I){
for($i = $s ; $i < $I ; $i++){
$o[$i]->phrase = true;
}
}
}
?>

0 comments on commit 71e783d

Please sign in to comment.