function admAnswerRename(&$session) { global $rename_oldname, $rename_newname, $rename_rename, $rename_backlinks; $session->trace(TC_Gui1, 'admAnswerRename'); $message = null; $origin = isset($rename_newname) ? $rename_newname : null; if (!isset($rename_oldname)) { $message = '+++ kein bisheriger Name angegeben!'; } elseif (($page_id = dbPageId($session, $rename_oldname)) <= 0) { $message = '+++ Seite ' . $rename_oldname . ' existiert nicht'; } elseif (isset($rename_rename) && !isset($rename_newname)) { $message = '+++ kein neuer Name angegeben!'; } elseif (isset($rename_rename) && ($rename_newname = normalizeWikiName($session, $rename_newname)) != $origin) { $message = '+++ Unzulässiger neuer Name (' . $origin . ') wurde korrigiert'; } elseif (isset($rename_rename) && dbPageId($session, $rename_newname) > 0) { $message = '+++ Seite ' . $rename_newname . ' existiert schon!'; } elseif (isset($rename_rename)) { dbUpdate($session, T_Page, $page_id, 'name=' . dbSQLString($session, $rename_newname) . ','); $message = 'Seite ' . $rename_oldname . ' wurde in ' . $rename_newname . ' umbenannt.'; $pages = 0; $hits = 0; if ($rename_backlinks == C_CHECKBOX_TRUE) { $row = dbFirstRecord($session, 'select id,text from ' . dbTable($session, T_Text) . ' where replacedby is null and text like ' . dbSqlString($session, "%{$rename_oldname}%")); $pattern1 = '/([^' . CL_WikiName . '])' . $rename_oldname . '([^' . CL_WikiName . '])/'; $pattern2 = '/^' . $rename_oldname . '([^' . CL_WikiName . '])/'; $pattern3 = '/([^' . CL_WikiName . '])' . $rename_oldname . '$/'; $replacement1 = '\\1' . $rename_newname . '\\2'; $replacement2 = $rename_newname . '\\1'; $replacement3 = '\\1' . $rename_newname; while ($row) { $text = $row[1]; $count1 = preg_match_all($pattern1, $row[1], $dummy); if ($count1 > 0) { $text = preg_replace($pattern1, $replacement1, $text); } $count2 = preg_match($pattern2, $row[1]); if ($count2 > 0) { $text = preg_replace($pattern2, $replacement2, $text); } $count3 = preg_match($pattern3, $text); if ($count3 > 0) { $text = preg_replace($pattern3, $replacement3, $text); } if ($count1 + $count2 + $count3 > 0) { dbUpdate($session, T_Text, $row[0], 'text=' . dbSQLString($session, $text) . ','); $pages++; $hits += $count1 + $count2 + $count3; } $row = dbNextRecord($session); } if ($pages > 0) { $message .= '<br>Es wurde' . ($hits == 1 ? ' ' : 'n ') . $hits . ($hits == 1 ? ' Verweis auf ' : ' Verweise auf ') . $pages . ($pages == 1 ? ' Seite umbenannt.' : ' Seiten umbenannt.'); } } addSystemMessage($session, $rename_oldname . ' >> ' . $rename_newname . ': ' . (0 + $hits)); $rename_oldname = ''; $rename_newname = ''; } admRename($session, $message); }
function instImportPages(&$session, $import_file, $import_replace) { $message = null; if (!file_exists($import_file)) { $message = "Datei nicht gefunden: " . $import_file; } elseif (checkDB($session, $message) == DB_EXISTS) { $file = fopen($import_file, "r"); $count_inserts = 0; $count_updates = 0; $count_lines = 0; while ($line = fgets($file)) { if (preg_match('/^#name=(\\S+)\\tlines=(\\d+)\\ttype=(\\w+)\\t/', $line, $param)) { $name = $param[1]; $lines = $param[2]; $type = $param[3]; $session->trace(TC_Gui1, 'instImportPagesAnswer-2: ' . $line); if (($page = dbPageId($session, $name)) > 0) { $count_updates++; if ($import_replace) { dbDeleteByClause($session, T_Text, 'page=' . $page); } } else { $page = dbInsert($session, T_Page, 'name,type', dbSqlString($session, $name) . ',' . dbSqlString($session, $type)); $count_inserts++; } $text = ""; $session->trace(TC_Gui1, 'instImportPagesAnswer-3: ' . $lines); $count_lines += $lines; for ($ii = 0; $ii < $lines; $ii++) { $text .= fgets($file); } if ($import_replace) { $old_id = dbSingleValue($session, 'select max(id) from ' . dbTable($session, T_Text) . ' where page=' . (0 + $page)); } $text_id = dbInsert($session, T_Text, 'page,type,text', $page . ',' . dbSqlString($session, $type) . ',' . dbSqlString($session, $text)); if ($import_replace && $old_id > 0) { dbUpdate($session, T_Text, $old_id, 'replacedby=' . $text_id); } } } fclose($file); $message = 'Datei ' . $import_file . ' wurde eingelesen. Neu: ' . (0 + $count_inserts) . ' Geändert: ' . (0 + $count_updates) . ' Zeilen: ' . (0 + $count_lines); } return $message; }
function getLogPageId() { $this->trace(TC_Session1, 'getLogPageId'); if ($this->fLogPageId == null) { $this->fLogPageId = dbPageId($this, PN_SystemLog); if ($this->fLogPageId <= 0) { $this->fLogPageId = dbInsert($this, T_Page, 'name,type,createdat,changedat,readgroup,writegroup', dbSqlString($this, PN_SystemLog) . ',' . dbSqlString($this, TT_Text) . ',now(),now(),0,0'); } } return $this->fLogPageId; }
function baseCustomStart(&$session) { $session->trace(TC_Gui2, 'baseCustomStart'); if (empty($session->fUserStartPage)) { $session->fUserStartPage = P_Home; } $session->setPageName($session->fUserStartPage); if (!baseCallStandardPage($session)) { if (($page_id = dbPageId($session, $session->fUserStartPage)) > 0) { $session->SetLocation(encodeWikiName($session, $session->fUserStartPage)); guiShowPageById($session, $page_id, null); } else { $session->SetLocation(P_Home); guiHome($session); } } }
function writeWikiName($name, $text, &$status) { $status->trace(TC_Util2, "WriteWikiName: {$name} / {$text}"); if ($text == '') { $text = $name; } if (substr($name, 0, 1) == "!") { echo htmlentities(substr($name, 1)); } else { normWikiName($status->fSession, $name); if (dbPageId($status->fSession, $name) > 0) { guiInternLink($status->fSession, $name, $text); } else { guiPageReference($status->fSession, $name, $text); } } }