Esempio n. 1
0
function SearchDF($path, $upath, &$ci, &$counter, &$lastfolder)
{
    global $_FILTER;
    if (($dh = @opendir($path)) === false) {
        echo ListElement($ci, 0, str_replace('{TEXT}', sprintf(LNG_REPORTS_RESULT_SEDIR, htmlEntitiesEx($path)), THEME_STRING_ERROR), -1, 0);
    } else {
        $subdirs = array();
        //Работаем на скорость. Есть повторяющиеся фрагменты!
        while (($file = readdir($dh)) !== false) {
            if (strcmp($file, '.') !== 0 && strcmp($file, '..') !== 0) {
                $npath = $path . '/' . $file;
                $nupath = ($upath == '' ? '' : $upath . '/') . $file;
                if (is_dir($npath)) {
                    $subdirs[] = array($npath, $nupath);
                    if ($_FILTER['q'] == '' && matchStringInExpression($rname = urldecode($file), $_FILTER['mask'], 0, 1)) {
                        if (strcasecmp($lastfolder, $upath) !== 0) {
                            $ci = 0;
                            $lastfolder = $upath;
                            TitleAsPathNavigator($upath);
                        }
                        $a = str_replace(array('{URL}', '{TEXT}'), array(QUERY_STRING_HTML . '&path=' . htmlEntitiesEx(urlencode($upath)) . '&sub=' . htmlEntitiesEx(urlencode($file)), htmlEntitiesEx('[' . $rname . ']')), THEME_LIST_ANCHOR);
                        echo ListElement($ci, $nupath, $a, LNG_REPORTS_LIST_DIR, @filemtime($npath));
                        $counter[0]++;
                    }
                } else {
                    if (is_file($npath) && matchStringInExpression($rname = urldecode($file), $_FILTER['mask'], 0, 1) && ($_FILTER['q'] == '' || SearchString($_FILTER['q'], $_FILTER['cs'], $npath, $ci))) {
                        if (strcasecmp($lastfolder, $upath) !== 0) {
                            $ci = 0;
                            $lastfolder = $upath;
                            TitleAsPathNavigator($upath);
                        }
                        $a = str_replace(array('{URL}', '{TEXT}'), array(QUERY_STRING_HTML . '&path=' . htmlEntitiesEx(urlencode($upath)) . '&file=' . htmlEntitiesEx(urlencode($file)), htmlEntitiesEx($rname)), THEME_LIST_ANCHOR);
                        echo ListElement($ci, $nupath, $a, $sz = @filesize($npath), @filemtime($npath));
                        $counter[1]++;
                        $counter[2] += $sz;
                    }
                }
            }
        }
        @closedir($dh);
        foreach ($subdirs as $sd) {
            SearchDF($sd[0], $sd[1], $ci, $counter, $lastfolder);
        }
    }
}
Esempio n. 2
0
function BuildSearchSql(&$Where, &$Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2)
{
    $sWrk = "";
    $FldParm = substr($Fld->FldVar, 2);
    $FldVal = ew_StripSlashes($FldVal);
    if (is_array($FldVal)) {
        $FldVal = implode(",", $FldVal);
    }
    $FldVal2 = ew_StripSlashes($FldVal2);
    if (is_array($FldVal2)) {
        $FldVal2 = implode(",", $FldVal2);
    }
    $FldOpr = strtoupper(trim($FldOpr));
    if ($FldOpr == "") {
        $FldOpr = "=";
    }
    $FldOpr2 = strtoupper(trim($FldOpr2));
    if ($FldOpr2 == "") {
        $FldOpr2 = "=";
    }
    if ($Fld->FldDataType == EW_DATATYPE_BOOLEAN) {
        if ($FldVal != "") {
            $FldVal = $FldVal == "1" ? $Fld->TrueValue : $Fld->FalseValue;
        }
        if ($FldVal2 != "") {
            $FldVal2 = $FldVal2 == "1" ? $Fld->TrueValue : $Fld->FalseValue;
        }
    } elseif ($Fld->FldDataType == EW_DATATYPE_DATE) {
        if ($FldVal != "") {
            $FldVal = ew_UnFormatDateTime($FldVal, $Fld->FldDateTimeFormat);
        }
        if ($FldVal2 != "") {
            $FldVal2 = ew_UnFormatDateTime($FldVal2, $Fld->FldDateTimeFormat);
        }
    }
    if ($FldOpr == "BETWEEN") {
        $IsValidValue = $Fld->FldDataType != EW_DATATYPE_NUMBER || $Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal) && is_numeric($FldVal2);
        if ($FldVal != "" && $FldVal2 != "" && $IsValidValue) {
            $sWrk = $Fld->FldExpression . " BETWEEN " . ew_QuotedValue($FldVal, $Fld->FldDataType) . " AND " . ew_QuotedValue($FldVal2, $Fld->FldDataType);
        }
    } elseif ($FldOpr == "IS NULL" || $FldOpr == "IS NOT NULL") {
        $sWrk = $Fld->FldExpression . " " . $FldOpr;
    } else {
        $IsValidValue = $Fld->FldDataType != EW_DATATYPE_NUMBER || $Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal);
        if ($FldVal != "" && $IsValidValue && ew_IsValidOpr($FldOpr, $Fld->FldDataType)) {
            $sWrk = $Fld->FldExpression . SearchString($FldOpr, $FldVal, $Fld->FldDataType);
        }
        $IsValidValue = $Fld->FldDataType != EW_DATATYPE_NUMBER || $Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal2);
        if ($FldVal2 != "" && $IsValidValue && ew_IsValidOpr($FldOpr2, $Fld->FldDataType)) {
            if ($sWrk != "") {
                $sWrk .= " " . ($FldCond == "OR" ? "OR" : "AND") . " ";
            }
            $sWrk .= $Fld->FldExpression . SearchString($FldOpr2, $FldVal2, $Fld->FldDataType);
        }
    }
    if ($sWrk != "") {
        if ($Where != "") {
            $Where .= " AND ";
        }
        $Where .= "(" . $sWrk . ")";
    }
}