本文整理汇总了PHP中ewiki_db::FIND方法的典型用法代码示例。如果您正苦于以下问题:PHP ewiki_db::FIND方法的具体用法?PHP ewiki_db::FIND怎么用?PHP ewiki_db::FIND使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ewiki_db
的用法示例。
在下文中一共展示了ewiki_db::FIND方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ewiki_page_wantedpages
function ewiki_page_wantedpages($id, $data, $action)
{
#-- collect referenced pages
$result = ewiki_db::GETALL(array("refs"));
while ($row = $result->get()) {
if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
continue;
}
$refs .= $row["refs"];
}
#-- build array
$refs = array_unique(explode("\n", $refs));
#-- strip existing pages from array
$refs = ewiki_db::FIND($refs);
foreach ($refs as $id => $exists) {
if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
continue;
}
if (!$exists && !strstr($id, "://") && strlen(trim($id))) {
$wanted[] = $id;
}
}
#-- print out
$o .= "<ul>\n";
foreach ($wanted as $page) {
$o .= " <li>" . ewiki_link($page) . "</li>\n";
}
$o .= "<ul>\n";
return $o;
}
示例2: ewiki_linking_titlefix
function ewiki_linking_titlefix(&$title, &$href, &$href2, &$type)
{
global $ewiki_links;
$href_mod = str_replace(" ", " ", $href);
$href_mod = str_replace(' ', '_', $href);
// Edit 'Nov09: replace spaces with underscores
$find = ewiki_db::FIND(array($href_mod));
if ($find[$href_mod]) {
$str = '<a href="' . ewiki_script("", rawurlencode($href_mod)) . htmlentities($href2) . '">' . $title . '</a>';
$type = array("wikipage", "title-swapped");
} else {
$str = '<span class="NotFound"><a href="' . ewiki_script("", rawurlencode($href_mod)) . htmlentities($href2) . '">' . $title . '</a></span>';
$type = array("wikipage", "title-swapped");
}
return $str;
}
示例3: ewiki_plural_alternative
function ewiki_plural_alternative($id)
{
#-- make possible plural/singular $id versions
$variants = ewiki_plural_variants($id);
array_shift($variants);
# skip original
#-- search in DB
$variants = ewiki_db::FIND($variants);
foreach ($variants as $new_id => $exists) {
if ($new_id && $exists) {
return $new_id;
}
}
#-- none found
return false;
}
示例4: ewiki_imgupload_better_fn
function ewiki_imgupload_better_fn(&$fn, &$id, &$meta, &$ext)
{
$parent = $_REQUEST[EWIKI_UP_PARENTID];
$name = $meta["Content-Location"];
$bad_names = '/^(DSC.?0\\d+|test|bild.?\\d+|pic.?\\d+|image.?\\d+|img.?\\d+)/i';
#-- normalize desired name (discard path/ and old .extension)
$name = substr($name, strrpos($name, "/\\"));
$name = substr($name, 0, strrpos($name, "."));
$name = preg_replace('/[^-_+.\\w\\d]+/', "_", $name);
#-- filter names
if (preg_match($bad_names, $name)) {
$name = "";
} elseif (strlen($name) < 5) {
$name = "";
}
#-- check if wish name is free
if ($name) {
$name = $name . ".{$ext}";
$found = ewiki_db::FIND(array($name));
if ($found[$name]) {
$name = "";
// no, is used
}
}
#-- else use page name as base
if (!$name && $parent) {
for ($n = 1; $n++; $n <= 99) {
$name = "{$parent}.{$n}.{$ext}";
$found = ewiki_db::FIND(array($name));
if ($found[$name]) {
$name = "";
// name is already occoupied
} else {
break;
// done
}
}
}
#-- assign new internal:// name
if ($name) {
$id = EWIKI_IDF_INTERNAL . $name;
} else {
// (it else gets a md5md5md5md5-sum as name)
}
}
示例5: ewiki_initialization_wizard
function ewiki_initialization_wizard($id, &$data, &$action)
{
global $ewiki_plugins;
#-- proceed only if frontpage missing or explicetely requested
if (strtolower($id) == "wikisetupwizard" || $id == EWIKI_PAGE_INDEX && $action == "edit" && empty($data["version"]) && !$_REQUEST["abort"]) {
if ($_REQUEST["abort"]) {
} elseif (empty($_REQUEST["init"])) {
$o = "<h2>WikiSetupWizard</h2>\n";
$o .= "You don't have any pages in your Wiki yet, so we should try to read-in the default ones from <tt>init-pages/</tt> now.<br /><br />";
$o .= '<a href="' . ewiki_script("", $id, array("init" => "now")) . '">[InitializeWikiDatabase]</a>';
$o .= " ";
$o .= '<a href="' . ewiki_script("", $id, array("abort" => "this")) . '">[NoThanks]</a>';
$o .= "<br /><br />";
#-- analyze and print settings and misconfigurations
$pf_db = $ewiki_plugins["database"][0];
$db = substr("_{$pf_db}", strrpos($pf_db, "_") + 1);
$o .= '<table border="0" width="90%" class="diagnosis">';
$o .= '<tr><td>DatabaseBackend</td><td>';
$o .= "<b>" . $db . "</b><br />";
if ($db == "files" || strstr($db, "f2")) {
$o .= "<small>_DBFILES_DIR='</small><tt>" . EWIKI_DBFILES_DIRECTORY . "'</tt>";
if (strpos(EWIKI_DBFILES_DIRECTORY, "tmp")) {
$o .= "<br /><b>Warning</b>: Storing your pages into a temporary directory is not what you want (there they would get deleted randomly), except for testing purposes of course. See the README.";
}
} else {
$o .= "(looks ok)";
}
$o .= "</td></tr>";
$o .= '<tr><td>WikiSoftware</td><td>ewiki ' . EWIKI_VERSION . "</td></tr>";
$o .= "</table>";
#-- more diagnosis
if (ini_get("magic_quotes")) {
$o .= "<b>Warning</b>: Your PHP interpreter has enabled the ugly and outdated '<i>magic_quotes</i>'. This will lead to problems, so please ask your provider to correct it; or fix it yourself with .htaccess settings as documented in the README. Otherwise don't forget to include() the <tt>fragments/strip_wonderful_slashes.php</tt> (it's ok to proceed for the moment).<br /><br />";
}
if (ini_get("register_globals")) {
$o .= "<b>Security warning</b>: The horrible '<i>register_globals</i>' setting is enabled. Without always using <tt>fragments/strike_register_globals.php</tt> or letting your provider fix that, you could get into trouble some day.<br /><br />";
}
return '<div class="wiki view WikiSetupWizard">' . $o . '</div>';
} else {
ewiki_db::INIT();
if ($dh = @opendir($path = EWIKI_INIT_PAGES)) {
while ($filename = readdir($dh)) {
if (preg_match('/^([' . EWIKI_CHARS_U . ']+[' . EWIKI_CHARS_L . ']+\\w*)+/', $filename)) {
$found = ewiki_db::FIND(array($filename));
if (!$found[$filename]) {
$content = implode("", file("{$path}/{$filename}"));
ewiki_scan_wikiwords($content, $ewiki_links, "_STRIP_EMAIL=1");
$refs = "\n\n" . implode("\n", array_keys($ewiki_links)) . "\n\n";
$save = array("id" => "{$filename}", "version" => "1", "flags" => "1", "content" => $content, "author" => ewiki_author("ewiki_initialize"), "refs" => $refs, "lastmodified" => filemtime("{$path}/{$filename}"), "created" => filectime("{$path}/{$filename}"));
ewiki_db::WRITE($save);
}
}
}
closedir($dh);
ewiki_log("initializing database", 0);
} else {
return "<b>ewiki error</b>: could not read from directory " . realpath($path) . "<br />\n";
}
#-- try to view/ that newly inserted page
if ($data = ewiki_db::GET($id)) {
$action = "view";
}
#-- let ewiki_page() proceed as usual
return "";
}
}
}
示例6: ewiki_make_title
<?php
/*
lists pages which are referenced but not yet written
(AKA "DanglingSymlinks")
*/
#-- title
echo ewiki_make_title($id, $id, 2);
#-- collect referenced pages
$result = ewiki_db::GETALL(array("refs"));
while ($row = $result->get()) {
if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
continue;
}
$refs .= $row["refs"];
}
#-- build array
$refs = array_unique(explode("\n", $refs));
#-- strip existing pages from array
$refs = ewiki_db::FIND($refs);
foreach ($refs as $id => $exists) {
if (!$exists && !strstr($id, "://") && strlen(trim($id))) {
$wanted[] = $id;
}
}
#-- print out
echo "<ul>\n";
foreach ($wanted as $page) {
echo " <li>" . ewiki_link($page) . "</li>\n";
}
echo "<ul>\n";
示例7: ewiki_linkdatabase
function ewiki_linkdatabase($id, &$data, $action)
{
if ($_REQUEST["action"] == "links" && $id == "action=links" && empty($_REQUEST["id"])) {
$o = array("editlink" => 0, "empty" => 0, "names" => 1, "unique" => 1, "sort" => 1, "exists" => 2, "url" => 0, "inter" => 0, "search" => "");
$o = array_merge($o, $_REQUEST);
#-- first read in all pages
$res = ewiki_db::GETALL(array("flags", "version", "refs"));
$all = array();
while ($row = $res->get()) {
if (($row["version"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
$refs = trim($row["refs"]);
if (!$o["empty"] && empty($refs)) {
continue;
}
$all[$row["id"]] = $refs;
}
}
#-- sort
ksort($all);
#-- output
$out = "";
foreach ($all as $i => $refs) {
$refs = explode("\n", $refs);
if ($refs) {
$refs = ewiki_db::FIND($refs);
}
foreach ($refs as $ri => $rv) {
if ($o["exists"] != 2) {
if ($rv != $o["exists"]) {
unset($refs[$ri]);
}
}
if ($o["url"] != 1) {
if ($o["url"] xor strpos($ri, "://")) {
unset($refs[$ri]);
}
}
if ($o["inter"] != 1) {
if ($o["inter"] xor strpos($ri, ":") && !strpos($ri, "://")) {
unset($refs[$ri]);
}
}
if ($o["search"] && strpos($ri, $o["search"]) === false) {
unset($refs[$ri]);
}
}
if (!$o["empty"] && empty($refs)) {
continue;
}
if ($o["sort"]) {
asort($refs);
}
$out .= "<a href=\"" . ewiki_script("", $i) . "\">{$i}</a> ";
foreach ($refs as $i => $rv) {
$title = $o[names] ? $i : " ";
if ($rv) {
$out .= " <a href=\"" . ewiki_script("", $i) . "\">{$title}</a>";
} else {
$out .= " {$title}";
if ($o["editlink"]) {
$out .= "<a href=\"" . ewiki_script("", $i) . "\">?</a>";
}
}
}
$out .= "\n";
}
return "\n<pre>\n\n\n\n{$out}</pre>\n";
} elseif ($id == "LinkDatabase") {
$url = "url:?";
# $url = "ErfurtWiki:";
return ewiki_format(<<<EOT
!!! LinkDatabase
The LinkDatabase provides a list of all internal pages together with the
links outgoing from each.
* [{$url}action=links] list pages and links, using default options
* [{$url}action=links&editlink=1] add the "?" link for not existent pages
* [{$url}action=links&empty=1] allowes listing of pages without forward links
* [{$url}action=links&names=0] no link title, just the <a href="...">
* [{$url}action=links&sort=0] order pages and their links
* [{$url}action=links&exists=0] only links to not existing pages
* [{$url}action=links&exists=1] only existing page links
* [{$url}action=links&url=1] add URLs
* [{$url}action=links&url=2] __only__ URLs
* [{$url}action=links&inter=1] add ~InterWiki:Links
* [{$url}action=links&inter=2] __only__ ~InterWiki:Links
* [{$url}action=links&search=google] apply search pattern to page links
handy combinations
* [{$url}action=links&inter=1&editlink=1&empty=1&url=1&sort=0&names=1] show all links
* [{$url}action=links&search=sourceforge&url=2] only URL links to sourceforge
* [{$url}action=links&sort=0&exists=0] unsorted missing pages
Only [{$url}action=links&unique=0] has not been implemented.
EOT
);
}
}
示例8: renderCalendar
function renderCalendar($pgname, $more, $year = NULL, $month = NULL)
{
if (preg_match(CALENDAR_PAGE_TITLE_REGEX, $pgname, $match)) {
$pgname = $match[1];
}
$month_names = explode(" ", ewiki_t("MONTHS"));
$day_names = explode(" ", ewiki_t("DAYABBRVS"));
if (!isset($year)) {
$year = date("Y");
}
if (!isset($month)) {
$month = date("n");
}
$shift = 0;
$today_ts = mktime(0, 0, 0, $month, date("d"), $year);
// non relative date
$firstday_month_ts = mktime(0, 0, 0, $month, 1, $year);
// first day of the month
$lastday_month_ts = mktime(0, 0, 0, $month + 1, 0, $year);
// last day of the month
$numYear = date("Y", $firstday_month_ts);
$numMonth = date("m", $firstday_month_ts);
$textMonth = $month_names[date("m", $firstday_month_ts) - 1];
$daysInMonth = date("t", $firstday_month_ts);
$dayMonth_start = date("w", $firstday_month_ts);
if ($dayMonth_start == 0) {
$dayMonth_start = 7;
}
$dayMonth_end = date("w", $lastday_month_ts);
if ($dayMonth_end == 0) {
$dayMonth_end = 7;
}
$ret = "";
#-- start table, print month name as title
$ret .= '<table class="calendar caltable" cellpadding="2" cellspacing="1">' . "\n";
$ret .= '<tr><th class="head calhead" colspan="7">';
$ret .= ($more ? '<a href="' . ewiki_script(EWIKI_ACTION_CALENDAR, $pgname, 'year=' . $year) . '">' : "") . $textMonth . " " . $numYear . ($more ? "</a>" : "");
$ret .= "</th></tr>\n";
#-- output days
$ret .= "<tr>\n";
for ($n = 0; $n < 7; $n++) {
$ret .= '<th class="days daynames caldays">' . $day_names[$n] . '</th>';
}
$ret .= "</tr>\n";
#-- not-existent days
$ret .= "<tr>\n";
for ($k = 1; $k < $dayMonth_start; $k++) {
$ret .= "<td> </td>\n";
}
#-- pre-scan for calendar day pages
$f = array();
for ($i = 1; $i <= $daysInMonth; $i++) {
$f[] = $pgname . CALENDAR_NAME_SEP . $numYear . $numMonth . (strlen($i) < 2 ? "0{$i}" : "{$i}");
}
$f = ewiki_db::FIND($f);
for ($i = 1; $i <= $daysInMonth; $i++) {
$day_i_ts = mktime(0, 0, 0, date("n", $firstday_month_ts), $i, date("Y", $firstday_month_ts));
$day_i = date("w", $day_i_ts);
if ($day_i == 0) {
$day_i = 7;
}
#-- calendar day page name
$page = $pgname . CALENDAR_NAME_SEP . $numYear . $numMonth . (strlen($i) < 2 ? "0{$i}" : "{$i}");
#-- retrieve and check rights if running in protected mode
if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && $f[$page] && !ewiki_auth($page, $uu, "view", $ring = false, $force = 0)) {
unset($f[$page]);
}
#-- link to calendar day page
$link_i = '<a href="' . ewiki_script("", $page) . '"' . ($f[$page] ? ' class="found calpg"><b>' . $i . '</b>' : ' class="hide calhide">' . $i) . "</a>";
#-- day table cell
$day_class = $month == date("n") && $today_ts == $day_i_ts ? "today caltoday" : "day calday";
$ret .= '<td class="' . $day_class . '">' . $link_i . "</td>";
#-- close week-row
if ($day_i == 7 && $i < $daysInMonth) {
$ret .= "</tr><tr>\n";
} else {
if ($day_i == 7 && $i == $daysInMonth) {
$ret .= "</tr>\n";
} else {
if ($i == $daysInMonth) {
for ($h = $dayMonth_end; $h < 7; $h++) {
$ret .= "<td> </td>\n";
}
$ret .= "</tr>\n";
}
}
}
}
$ret .= "</table>\n";
return $ret;
}