当前位置: 首页>>代码示例>>PHP>>正文


PHP ewiki_db::SEARCH方法代码示例

本文整理汇总了PHP中ewiki_db::SEARCH方法的典型用法代码示例。如果您正苦于以下问题:PHP ewiki_db::SEARCH方法的具体用法?PHP ewiki_db::SEARCH怎么用?PHP ewiki_db::SEARCH使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ewiki_db的用法示例。


在下文中一共展示了ewiki_db::SEARCH方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ewiki_powersearch

function ewiki_powersearch($q, $where = 'content')
{
    $q = ewiki_lowercase(preg_replace('/\\s*[\\000-\\040]+\\s*/', ' ', $q));
    $found = array();
    $scored = array();
    #-- initial scan
    foreach (explode(" ", $q) as $search) {
        if (empty($search)) {
            continue;
        }
        $result = ewiki_db::SEARCH($where, $search);
        while ($row = $result->get()) {
            if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
                $id = $row["id"];
                $content = strtolower($row[$where]);
                unset($row);
                #-- have a closer look
                $len1 = strlen($content) + 1;
                if (!isset($scored[$id])) {
                    $scored[$id] = 1;
                }
                $scored[$id] += 800 * (strlen($search) / $len1);
                $scored[$id] += 65 * (count(explode($search, $content)) - 2);
                $p = -1;
                while (($p = strpos($content, $search, $p + 1)) !== false) {
                    $scored[$id] += 80 * (1 - $p / $len1);
                }
            }
            #if-TXT
        }
    }
    #-- output results
    arsort($scored);
    $o = "<ol>\n";
    $n = 0;
    foreach ($scored as $id => $score) {
        #-- refetch page for top 10 entries (still cached by OS or DB)
        $row = $n < 10 ? ewiki_db::GET($id) : NULL;
        #-- check access rights in protected mode
        if (EWIKI_PROTECTED_MODE && !ewiki_auth($id, $row, "view", $ring = false, $force = 0)) {
            if (EWIKI_PROTECTED_MODE_HIDING) {
                continue;
            } else {
                $row["content"] = ewiki_t("FORBIDDEN");
            }
        }
        $o .= "<li>\n";
        $o .= '<div class="search-result ' . ($oe ^= 1 ? "odd" : "even") . '">' . '<a href="' . ewiki_script("", $id) . '">' . $id . "</a> " . "\n";
        #-- top 10 results are printed more verbosely
        if ($n++ < 10) {
            preg_match_all('/([_-\\w]+)/', $row["content"], $uu);
            $text = htmlentities(substr(implode(" ", $uu[1]), 0, 200));
            $o .= "<br />\n<small>{$text}\n" . "<br />" . strftime(ewiki_t("LASTCHANGED"), $row["lastmodified"]) . "<br /><br /></small>\n";
        }
        $o .= "</div>\n";
        $o .= "</li>\n";
    }
    $o .= "</ol>\n";
    return $o;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:60,代码来源:powersearch.php

示例2: ewiki_tcn_find_variants

function ewiki_tcn_find_variants($id)
{
    list($base_id, $id_lang) = ewiki_tcn_which_variant($id);
    $variants = array("{$id}" => "{$id_lang}");
    $result = ewiki_db::SEARCH("id", $base_id);
    while ($result && ($row = $result->get())) {
        if (substr($row["id"], 0, strlen($base_id)) == $base_id) {
            list($i, $l) = ewiki_tcn_which_variant($row["id"]);
            if ($i == $base_id) {
                $variants[$row["id"]] = $l;
            }
        }
    }
    return $variants;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:15,代码来源:tcn.php

示例3: ewiki_subpage_list

function ewiki_subpage_list($id, $postfix = "")
{
    $_hiding = EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING;
    $result = ewiki_db::SEARCH("id", $id . $postfix);
    while ($row = $result->get()) {
        #-- retrieve and check rights if running in protected mode
        if ($_hiding) {
            if (!ewiki_auth($row["id"], $uu, 'view', $ring = false, $force = 0)) {
                continue;
            }
        }
        $pages[$row["id"]] = "";
    }
    return $pages;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:15,代码来源:subpagelist.php

示例4: calendar_exists

function calendar_exists($always = false)
{
    if ($always) {
        return true;
    }
    $result = ($id = $GLOBALS["ewiki_id"]) && ($Qresult = ewiki_db::SEARCH("id", $id . CALENDAR_NAME_SEP)) && $Qresult->count();
    if (!$result || $id == EWIKI_PAGE_CALENDAR || $id == EWIKI_PAGE_YEAR_CALENDAR || !empty($_REQUEST["year"])) {
        return false;
    }
    while ($row = $Qresult->get(0, 0x1037)) {
        if (ewiki_isCalendarId($row["id"])) {
            return true;
        }
    }
    return false;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:16,代码来源:calendar.php

示例5: ewiki_page_like

function ewiki_page_like($id, $data, $action)
{
    preg_match_all("/([" . EWIKI_CHARS_U . "][" . EWIKI_CHARS_L . "]+)/", $id, $words);
    $pages = array();
    foreach ($words[1] as $find) {
        $result = ewiki_db::SEARCH("id", $find);
        while ($row = $result->get()) {
            if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) {
                continue;
            }
            $pages[$row["id"]] = "";
        }
    }
    $o = ewiki_make_title($id, ewiki_t(strtoupper($action) . "_TITLE"), 3);
    $o .= ewiki_list_pages($pages, 0);
    return $o;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:17,代码来源:like_pages.php

示例6: ewiki_view_append_threads

function ewiki_view_append_threads($id, $data, $action)
{
    if (isThread($id)) {
        return "";
    }
    $result = ewiki_db::SEARCH("id", $id . EWIKI_THREAD_SEPARATOR);
    while ($row = $result->get()) {
        if (!isPost($row["id"])) {
            $pages[$row["id"]] = "";
        }
    }
    if (0 != count($pages)) {
        $o = "<div class='wiki_threads'><small>" . ewiki_t('THREADS') . ":</small><br />";
        $o .= ewiki_list_pages($pages) . "</div>\n";
    }
    $o .= "<form action='" . ewiki_script('addthread', $id) . "' method='POST'>" . ewiki_t("NEWTHREAD") . ":  <input type='text' name='threadname'>" . "<input type='submit' value='Add Thread'>" . "</form>";
    return "<div class='wiki aview threads'>" . $o . '</div>';
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:18,代码来源:threads.php

示例7: ewiki_view_append_attachments

function ewiki_view_append_attachments($id, $data, $action)
{
    $o = '<hr><h4><a href="' . ewiki_script(EWIKI_ACTION_ATTACHMENTS, $id) . '">' . ewiki_t("ATTACHMENTS") . '</a></h4>';
    $scan = 's:7:"section";' . serialize($id);
    $result = ewiki_db::SEARCH("meta", $scan);
    $ord = array();
    while ($row = $result->get()) {
        $ord[$row["id"]] = $row["created"];
    }
    arsort($ord);
    foreach ($ord as $id => $uu) {
        $row = ewiki_db::GET($id);
        if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) {
            continue;
        }
        $o .= ewiki_entry_downloads($row, "*");
    }
    return $o;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:19,代码来源:downloadlist.php

示例8: ewiki_linking_findany

function ewiki_linking_findany($moniker, $page)
{
    global $ewiki_config;
    #-- lists
    $page_i = strtolower($page);
    $search = array_merge($ewiki_config["instant"], $ewiki_config["interwiki"]);
    foreach ($search as $pn => $url) {
        if (strtolower($pn) == $page_i) {
            return $url;
        }
    }
    #-- find a page
    $result = ewiki_db::SEARCH("id", $page_i);
    while ($row = $result->get()) {
        if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
            return ewiki_script("", $row["id"]);
        }
    }
    #-- Google saves the day!
    return "http://www.google.com/search?q=" . urlencode($page);
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:21,代码来源:instanturl_find.php

示例9: ewiki_aedit_templates

function ewiki_aedit_templates(&$html, $id, &$data, $action)
{
    if (!$data["content"]) {
        #-- search template pages
        $list = array();
        $result = ewiki_db::SEARCH("id", "Template");
        while ($row = $result->get(0, 0x21, EWIKI_DB_F_TEXT)) {
            if (preg_match('/Template$/', $row["id"])) {
                $list[] = $row["id"];
            }
        }
        #-- add list
        if ($list) {
            $o = '<form action="' . ewiki_script("", $id) . '" method="POST" entype="multipart/form-data">' . '<input type="hidden" name="id" value="' . $action . '/' . $id . '">' . '<input type="submit" value="load"> ' . '<select name="load_template">';
            foreach ($list as $i) {
                $o .= '<option value="' . $i . '">' . $i . '</option>';
            }
            $o .= '</select></form>';
            #-- output
            $html = $o . $html;
        }
    }
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:23,代码来源:templates.php

示例10: ewiki_action_control_page

function ewiki_action_control_page($id, &$data, $action)
{
    global $ewiki_ring, $ewiki_config, $ewiki_plugins;
    $a_flagnames = array("_TEXT", "_BINARY", "_DISABLED", "_HTML", "_READONLY", "_WRITEABLE", "_APPENDONLY", "_SYSTEM", "_PART", "_MINOR", "_HIDDEN", "_ARCHIVE", "_UU12", "_UU13", "_UU14", "_UU15", "_UU16", "_EXEC", "_UU18", "_UU19");
    $o = ewiki_make_title($id, "control {$id}", 2);
    #-- admin requ. ---------------------------------------------------------
    if (!ewiki_auth($id, $data, $action, $ring = 0, "_FORCE_LOGIN=1") || !isset($ewiki_ring) || $ewiki_ring > 1) {
        if (is_array($data)) {
            $data = "You'll need to be admin. See ewiki_auth() and _PROTECTED_MODE in the README.";
        }
        $o .= $data;
    } elseif (@$_REQUEST["pgc_setflags"]) {
        #-- setted new flags
        $new_f = 0;
        foreach ($_REQUEST["sflag"] as $n => $b) {
            if ($b) {
                $new_f |= 1 << $n;
            }
        }
        #-- administrator may change all flags
        if ($ewiki_ring == 0) {
            $data["flags"] = $new_f;
        } else {
            $data["flags"] = $data["flags"] & ~EWIKI_DB_F_MODERATORFLAGS | $new_f & EWIKI_DB_F_MODERATORFLAGS;
        }
        $data["lastmodified"] = time();
        $data["version"]++;
        if (ewiki_db::WRITE($data)) {
            $o .= "Page flags were updated correctly.";
            ewiki_log("page flags of '{$id}' were set to {$data['flags']}");
        } else {
            $o .= "A database error occoured.";
        }
    } elseif (@$_REQUEST["pgc_rename"] && strlen($new_id = $_REQUEST["mv_to"])) {
        $old_id = $id;
        $report = "";
        $preg_id = "/" . addcslashes($old_id, ".+*?|/\\()\$[]^#") . "/" . ($_REQUEST["mv_cr1"] ? "i" : "");
        #-- check if new name does not already exist in database
        $exists = ewiki_db::GET($new_id);
        if ($exists || !empty($exists)) {
            return $o .= "Cannot overwrite an existing database entry.";
        }
        #-- copy from old name to new name
        $max_ver = $data["version"];
        $data = array();
        for ($v = 1; $v <= $max_ver; $v++) {
            $row = ewiki_db::GET($old_id, $v);
            $row["id"] = $new_id;
            $row["lastmodified"] = time();
            $row["content"] = preg_replace($preg_id, $new_id, $row["content"]);
            ewiki_scan_wikiwords($row["content"], $links, "_STRIP_EMAIL=1");
            $row["refs"] = "\n\n" . implode("\n", array_keys($links)) . "\n\n";
            $row["author"] = ewiki_author("control/");
            if (!ewiki_db::WRITE($row)) {
                $report .= "error while copying version {$v},<br />\n";
            }
        }
        #-- proceed if previous actions error_free
        if (empty($report)) {
            #-- deleting old versions
            for ($v = 1; $v <= $max_ver; $v++) {
                ewiki_db::DELETE($old_id, $v);
            }
            #-- adjust links/references to old page name
            if ($_REQUEST["mv_cr0"]) {
                $result = ewiki_db::SEARCH("refs", $old_id);
                while ($result && ($row = $result->get())) {
                    $row = ewiki_db::GET($row["id"]);
                    if (preg_match($preg_id, $row["content"], $uu)) {
                        $row["content"] = preg_replace($preg_id, $new_id, $row["content"]);
                        $row["lastmodified"] = time();
                        $row["version"]++;
                        ewiki_scan_wikiwords($row["content"], $links, "_STRIP_EMAIL=1");
                        $row["refs"] = "\n\n" . implode("\n", array_keys($links)) . "\n\n";
                        $row["author"] = ewiki_author("control/");
                        if (!ewiki_db::WRITE($row)) {
                            $report .= "could not update references in " . $row['id'] . ",<br />\n";
                        } else {
                            $report .= "updated references in " . $row['id'] . ",<br />\n";
                        }
                    }
                }
            }
            $o .= "This page was correctly renamed from '{$old_id}' to '{$new_id}'.<br /><br />\n{$report}";
            ewiki_log("page renamed from '{$old_id}' to '{$new_id}'", 2);
        } else {
            $o .= "Some problems occoured while processing your request, therefor the old page still exists:<br />\n" . $report;
        }
    } elseif (@$_REQUEST["pgc_setmeta"] && $ewiki_ring == 0 && ($set = explode("\n", $_REQUEST["pgc_meta"]))) {
        $new_meta = array();
        foreach ($set as $line) {
            if (($line = trim($line)) && ($key = trim(strtok($line, ":"))) && ($value = trim(strtok("")))) {
                $new_meta[$key] = $value;
            }
        }
        $data["meta"] = $new_meta;
        $data["lastmodified"] = time();
        $data["version"]++;
        if (ewiki_db::WRITE($data)) {
            $o .= "The {meta} field was updated.";
//.........这里部分代码省略.........
开发者ID:gpuenteallott,项目名称:rox,代码行数:101,代码来源:control.php

示例11: ewiki_uservars_pages_search

function ewiki_uservars_pages_search($varname, $value = NULL)
{
    $result = ewiki_db::SEARCH("content", $varname);
    //Get a list of all pages containing our varname
    while ($row = $result->get()) {
        if (!preg_match("/" . EWIKI_USERVARS_PAGENAME_PREFIX . "(.*)/", $row["id"], $matches)) {
            continue;
        }
        //Page name is properly formed as a UserVars page name
        $username = $matches[1];
        //echo("Checking $username for $varname");
        if (!($data = ewiki_uservars_pages_retrieve($username))) {
            //echo(" rejected, no data retrieved");
            continue;
        }
        //data was retrieved from the page.
        if (!isset($data[$varname])) {
            //echo(" rejected, variable not set $varname");
            continue;
        }
        //The varname we are searching for was there
        if (isset($value) && $value != $data[$varname]) {
            //echo("rejected $value != ".$data[$varname]);
            continue;
        }
        //if we were looking for a value, it matches
        //echo("passed, setting $data[$varname] to $values[$varname]");
        $values[$username] = $data[$varname];
    }
    return $values;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:31,代码来源:uservars_pages.php

示例12: posts_exist

function posts_exist($always = false)
{
    $id = $GLOBALS["ewiki_id"];
    $result = $always || $id && ($result = ewiki_db::SEARCH("id", $id . '_POST')) && $result->count();
    return $id && $id != EWIKI_PAGE_CALENDAR && $id != EWIKI_PAGE_YEAR_CALENDAR && !isPost($id) && empty($_REQUEST["year"]) && $result;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:6,代码来源:posts.php

示例13: while

 if (@$_REQUEST["listall"]) {
     while ($row = $result->get()) {
         $selected[$row["id"]] = "listall <br>";
     }
 } else {
     while ($page = $result->get()) {
         $id = $page["id"];
         if (!strlen($id)) {
             continue;
         }
         $page = ewiki_db::GET($id);
         $flags = $page["flags"];
         if (!strlen(trim($page["content"]))) {
             @($selected[$id] .= "EMPTY <br>");
         }
         $res2 = ewiki_db::SEARCH("content", $id);
         if ($res2 && $res2->count()) {
             $check2 = 1;
             while ($row = $res2->get()) {
                 $check = ewiki_db::GET($row["id"]);
                 $check = strtolower($check["content"]);
                 $check2 &= strpos($check, strtolower($id)) !== false;
                 #echo "rc({$row['id']})==>($id): $check2 <br>";
             }
             $check = $check2;
         }
         if (empty($check)) {
             @($selected[$id] .= "UNREFerenced <br>");
         }
         if ($flags & EWIKI_DB_F_DISABLED) {
             @($selected[$id] .= "disabled_page <br>");
开发者ID:gpuenteallott,项目名称:rox,代码行数:31,代码来源:t_remove.php

示例14: ewiki_page_searchandreplace

function ewiki_page_searchandreplace($id, $data, $action)
{
    global $ewiki_ring, $ewiki_plugins;
    $o = ewiki_make_title($id, $id, 2);
    #-- admin requ. ---------------------------------------------------------
    if (!ewiki_auth($id, $data, $action, $ring = 1, "_FORCE_LOGIN=1") || !isset($ewiki_ring) || $ewiki_ring > 1) {
        if (is_array($data)) {
            $data = "You'll need moderator/administrator privileges to use this.";
        }
        return $o .= $data;
    }
    #-- form ----------------------------------------------------------------
    if (empty($_REQUEST["snr_go"]) && empty($_REQUEST["snr_test"])) {
        $url = ewiki_script("", $id);
        $o .= ewiki_t(<<<END
Use this form to replace all occourences of a phrase in all WikiPages.
<br /><br />
<form action="{$url}" method="POST" enctype="multipart/form-data">
search for string<br />
<input type="text" name="snr_search_string" value="" size="30"><br />
<small>this text snippet always matches case-insensitive, used as
<b>first-stage</b> search string; leave it empty to use only the regular
expression matching (slower)</small><br />
look this string up only in <select name="snr_search_string_where"><option selected="selected" value="content">page content / body</option> <option value="id">page name / title</option></select><br />
<br />
<i>and/or</i> with <tt>/Perl/i</tt> regular expression<br />
<input type="text" name="snr_search_regex" value="" size="30"><br />
<small>this is <b>optional</b>, and is anyhow only used as second-stage search
pattern; if used allows to use regex backreferences in the replacement
string field</small><br />
<br />
then replace with string<br />
<input type="text" name="snr_replace" value="" size="30"><br />
<small>can contain backreferences  and \$1 if the regex search field was
used</small><br />
<br />
<input type="submit" name="snr_test" value="dry run / test regex"> &nbsp;
<input type="submit" name="snr_go" value="Replace All">
</form>
<br />
<br />
The regular expression matching is optional, you'll often only need the
simple string search field and another simple string in the replacement
field.
<br />
<br />
Please note, that this form allows to initially search for a simple string,
but you can leave this empty and only use a regex search. And as it is a
two stage searching, both patterns can be completely different.
<br />
<br />
Text replacement always happens in the WikiPages body, even if the simple
search string can be used to search for page names - if you do so, you
certainly need a second regular expression pattern for content replacement.
<br />
END
);
    } else {
        $do = $_REQUEST["snr_go"];
        #-- prepare vars
        $search_where = $_REQUEST["snr_search_string_where"];
        $search_string = $_REQUEST["snr_search_string"];
        $search_regex = $_REQUEST["snr_search_regex"];
        $replacement = $_REQUEST["snr_replace"];
        if ($search_string == "*") {
            $search_string = "";
        }
        $search_string2 = preg_quote($search_string, "/");
        $replacement2 = addcslashes($replacement, "\$");
        #-- security check in search_regex
        if (preg_match('/([\\w\\s]+)$/', $search_regex, $uu) && strstr($uu[0], "e")) {
            ewiki_log("use of regex '{$search_regex}' could be security circumvention attempt", 1);
            return $o . "wrong regex delimiter";
        }
        #-- complain
        if (empty($search_string) && empty($search_regex) || empty($replacement)) {
            return $o . "too few parameters, needs at least one search and a replacement string";
        }
        #-- initial database string search
        if (empty($search_string)) {
            $result = ewiki_db::GETALL(array("id", "version", "flags"));
        } else {
            $result = ewiki_db::SEARCH($search_where, $search_string);
        }
        #-- walk through pages
        while ($row = $result->get()) {
            #-- skip binary entries
            if (EWIKI_DB_F_TEXT != ($row["flags"] & EWIKI_DB_F_TYPE)) {
                continue;
            }
            $id = $row["id"];
            $save = false;
            $row = ewiki_db::GET($id);
            /*
               if (!ewiki_auth($id, $row, "edit", ...
               ...
            */
            if ($search_regex) {
                if (preg_match($search_regex, $row[$search_where], $uu)) {
                    $save = true;
//.........这里部分代码省略.........
开发者ID:gpuenteallott,项目名称:rox,代码行数:101,代码来源:page_searchandreplace.php


注:本文中的ewiki_db::SEARCH方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。