Пример #1
0
 static function get_filecontent($var, $args, $data)
 {
     $file = $data["filename"]["data"][0];
     if (!file_exists($file)) {
         return "";
     }
     return modify::displayfile("modules", $file, false, false);
 }
Пример #2
0
function db_search_update($table, $id, $fields, $field_arr = array())
{
    if (strpos($table, "_nodb_")) {
        return;
    }
    $row = db_select_first($table, "*", "id=@id@", "", array("id" => $id));
    if (empty($row["id"])) {
        return;
    }
    if ($table == "simple_sys_tree") {
        $id = 0;
    } else {
        $id = $row["id"];
    }
    if ($table == "simple_sys_events") {
        $folder = db_select_value("simple_sys_tree", "id", "ftype=@ftype@", array("ftype" => "sys_events"));
        if (empty($folder)) {
            return;
        }
    } else {
        $folder = $row["folder"];
    }
    $rread_users = "|anonymous|";
    $rread_groups = "";
    $searchindex = "";
    $searchindex_snd = "";
    $searchcontent = "";
    foreach ($row as $data_key => $data) {
        if ($data_key == "rread_users") {
            $rread_users = $data;
        }
        if ($data_key == "rread_groups") {
            $rread_groups = $data;
        }
        if (count($field_arr) > 0 and isset($field_arr[$data_key])) {
            $fields[$data_key] = array("SIMPLE_TYPE" => $field_arr[$data_key]);
        }
        if (isset($fields[$data_key]) and $data != "" and (!is_numeric($data) or $data != 0) and $data != "null") {
            $field = $fields[$data_key];
            if (isset($field["NOTINALL"]) or isset($field["NO_SEARCH_INDEX"])) {
                continue;
            }
            $data = trim($data, "|");
            $data2 = $data;
            switch ($field["SIMPLE_TYPE"]) {
                case "pid":
                case "password":
                    $data = "";
                    $data2 = "";
                    break;
                case "folder":
                case "id":
                    $data2 = "";
                    break;
                case "checkbox":
                    if ($data) {
                        $data = $data_key;
                    } else {
                        $data = "";
                    }
                    $data2 = $data;
                    break;
                case "time":
                    $data = sys_date("{t}g:i a{/t}", $data);
                    $data2 = $data;
                    break;
                case "date":
                    $data = sys_date("{t}m/d/Y{/t}", $data);
                    $data2 = $data;
                    break;
                case "dateselect":
                    $data2 = "";
                    foreach (explode("|", $data) as $date) {
                        $data2 .= " " . sys_date("{t}m/d/Y g:i a{/t}", $date);
                    }
                    $data = $data2;
                    break;
                case "datetime":
                    $data = sys_date("{t}m/d/Y g:i a{/t}", $data);
                    $data2 = $data;
                    break;
                case "files":
                    $data2 = "";
                    foreach (explode("|", $data) as $file) {
                        $text = modify::displayfile($table, $file, true);
                        $data2 .= " " . strip_tags($text) . " " . modify::basename($file);
                    }
                    $data = $data2;
                    break;
                case "select":
                    $data = str_replace("|", " ", $data);
                    $data2 = $data;
                    break;
                case "multitext":
                    $data = str_replace(",", " ", $data);
                    $data2 = $data;
                    break;
            }
            if ($data != "") {
                $searchindex .= " " . preg_replace("/[ ]+/i", " ", modify::searchindex(trim($data)));
            }
            if ($data2 != "") {
                $searchcontent .= " " . trim(preg_replace("/[ ]+/i", " ", $data2));
            }
        }
    }
    $searchcontent = trim($searchcontent);
    $searchindex = trim($searchindex);
    if (strlen($searchindex) > INDEX_LIMIT) {
        $pos = strpos($searchindex, " ", INDEX_LIMIT);
        if ($pos > 0) {
            $searchindex = substr($searchindex, 0, $pos);
        }
    }
    $search_arr = array_unique(explode(" ", $searchindex));
    foreach ($search_arr as $key => $value) {
        $val = soundex($value);
        if ($val != "0000") {
            $search_arr[$key] = $val;
        } else {
            unset($search_arr[$key]);
        }
    }
    $searchindex_snd = implode(" ", $search_arr);
    if (strlen($searchindex_snd) > 8192) {
        $pos = strpos($searchindex_snd, " ", 8192);
        if ($pos > 0) {
            $searchindex_snd = substr($searchindex_snd, 0, $pos);
        }
    }
    $data = array("sindex" => $searchindex, "sindex_snd" => $searchindex_snd, "searchcontent" => $searchcontent, "lastmodifiedby" => !empty($row["lastmodifiedby"]) ? $row["lastmodifiedby"] : "anonymous", "lastmodified" => !empty($row["lastmodified"]) ? $row["lastmodified"] : 0, "rread_users" => $rread_users, "rread_groups" => $rread_groups);
    $count = db_count("simple_sys_search", array("id=@id@", "folder=@folder@"), array("id" => $id, "folder" => $folder));
    if ($count > 0) {
        db_update("simple_sys_search", $data, array("id=@id@", "folder=@folder@"), array("id" => $id, "folder" => $folder));
    } else {
        $data = array_merge($data, array("id" => $id, "folder" => $folder, "history" => ""));
        db_insert("simple_sys_search", $data);
    }
}