function admRename(&$session, $message) { global $rename_oldname, $rename_newname, $rename_backlinks; $session->trace(TC_Gui1, 'admRename'); guiHeader($session, 'Umbenennen einer Seite'); guiHeadline($session, 1, 'Umbenennen einer Seite'); if (!empty($message)) { guiParagraph($session, $message, false); } guiStartForm($session, 'Form', P_Rename); echo '<table border="0">'; echo '<tr><td>Bisheriger Name:</td><td>'; guiTextField('rename_oldname', $rename_oldname, 64, 64); echo '<tr><td>Neuer Name:</td><td>'; guiTextField('rename_newname', $rename_newname, 64, 64); echo '</td></tr>' . "\n"; echo '<tr><td></td><td>'; guiButton('rename_info', 'Info'); if (!empty($rename_oldname) && !empty($rename_newname)) { echo ' | '; } guiButton('rename_rename', 'Umbenennen'); echo '<br>'; guiCheckBox('rename_backlinks', 'Alle Verweise umbenennen', !isset($rename_backlinks) || $rename_backlinks == C_CHECKBOX_TRUE); echo '</td></tr></table>' . "\n"; guiFinishForm($session); if (!empty($rename_oldname) && dbPageId($session, $rename_oldname) > 0) { $row = dbFirstRecord($session, 'select page,text,createdby,createdat from ' . dbTable($session, T_Text) . ' where replacedby is null and text like ' . dbSqlString($session, "%{$rename_oldname}%")); if (!$row) { guiParagraph($session, '+++ keine Verweise gefunden', false); } else { echo '<table border="1"><tr><td>Seite:</td><td>Typ:</td>' . '<td>von</td><td>Letzte Änderung</td><td>Fundstelle</td></tr>'; while ($row) { $pagerecord = dbGetRecordById($session, T_Page, $row[0], 'name,type'); $text = findTextInLine($row[1], $rename_oldname, 10, true); if (!empty($text)) { echo "\n<tr><td>"; guiInternLink($session, encodeWikiName($session, $pagerecord[0]), $pagerecord[0], M_Base); echo '</td><td>'; echo $pagerecord[1]; echo '</td><td>'; echo $row[2]; echo '</td><td>'; echo htmlentities($row[3]); echo '</td><td>'; echo $text; echo "</td><tr>\n"; } $row = dbNextRecord($session); } echo "\n</table>\n"; } } guiFinishBody($session, null); }
function dbPrintTable(&$session, $query, $headers, $max_lines) { $session->trace(TC_Db1, "dbPrintTable"); $result = mysql_query($query, $session->fDbInfo); if (!$result) { protoc(mysql_error()); } else { $first = true; $no = 0; if ($max_lines <= 0) { $max_lines = 1000; } while ($row = mysql_fetch_row($result)) { if ($first) { outTable(1); outTableRecord(); foreach ($headers as $key => $value) { outTableCellStrong($value); } outTableRecordEnd(); $first = false; } if (++$no > $max_lines) { break; } outTableRecord(); foreach ($row as $key => $value) { outTableCell($value); } outTableRecordEnd(); } if ($first) { echo "Die Anfrage ergab keine Ergebnisse<br>\n"; } else { outTableEnd(); if ($no > $max_lines) { guiParagraph($session, "Es gibt noch weitere Ergebnisse!", false); } } mysql_free_result($result); } }
function instExit(&$session) { $error = null; $message = null; if (guiChecked($session, 'inst_setpassw')) { if (empty($_POST['inst_passw'])) { $error = '+++ leeres Passwort ist nicht zulässig!'; } else { checkDB($session, $message); $passw = strrev(crypt($_POST['inst_passw'], 'admin')); sqlStatement($session, 'update ' . $session->fDbTablePrefix . "user set code='" . $passw . "' where name='admin'"); $message = 'Passwort wurde gesetzt'; } } if ($error) { instFinish($session, $error); } else { guiHeader($session, 'Ende'); guiHeadline($session, 2, 'Installation beenden'); $error = null; if ($message) { guiParagraph($session, $message, false); } if (guiChecked($session, 'inst_optimized')) { $error = instLink($session, 'base_opt.php', 'index.php'); if ($error != null) { $message = $error; } else { if (($error = instLink($session, 'forum_opt.php', 'forum.php')) == null) { $message = "Links auf optimierte Module wurden erstellt"; } else { $message = $error; } } } else { $error = instLink($session, 'base_module.php', 'index.php'); if ($error != null) { $message = $error; } else { if (($error = instLink($session, 'forum_module.php', 'forum.php')) == null) { $message = "Links auf Standard-Module (nicht optimiert) wurden erstellt"; } else { $message = $error; } } } guiParagraph($session, $message, false); if ($error == null && guiChecked($session, 'inst_documentation')) { instUnlink($session, 'docu', '^/index.html/'); } if ($error == null && guiChecked($session, 'inst_delete')) { instUnlink($session, '.', '^/index.html/'); instUnlink($session, 'db', '^/index.html/'); } guiParagraph($session, 'Die Installation ist jetzt beendet.', false); guiLine($session, 2); guiExternLink($session, '../index.php', 'Zur Anmeldung'); guiFinishBody($session); } }
function guiLogin(&$session, $message) { guiStandardHeader($session, "Anmeldung für den InfoBasar", Th_LoginHeader, Th_LoginBodyStart); guiStartForm($session); if (!empty($message)) { $message = preg_replace('/^\\+/', '+++ Fehler: ', $message); guiParagraph($session, $message, false); } outDivision($session); if (!isset($_POST['login_user'])) { $_POST['login_user'] = $session->fUserName; $_POST['login_email'] = ''; } outTableAndRecord(); outTableTextField($session, 'Benutzername:', 'login_user', null, 32, 32); outTableRecordDelim(); outTablePasswordField($session, 'Passwort:', 'login_code', '', 32, 32); outTableRecordDelim(); outTableButton($session, ' ', 'but_login', 'Anmelden'); outTableAndRecordEnd(); guiLine($session, 2); guiParagraph($session, 'Passwort vergessen?', false); outTableAndRecord(); outTableTextField($session, 'EMail-Adresse:', 'login_email', null, 32, 0); outTableRecordDelim(); outTableButton($session, ' ', 'but_forget', 'Passwort ändern'); outTableAndRecordEnd(); echo '(Das neue Passwort wird dann zugeschickt.)'; outNewline(); outStrong('Achtung:'); echo 'Benutzername muss ausgefüllt sein!'; outDivisionEnd($session); guiFinishForm($session, $session); guiStandardBodyEnd($session, Th_LoginBodyEnd); return 1; }
function diffTest(&$session) { $x2 = "a\nx\ny\nz\nb"; $x1 = "a\nb"; $x2 = "x\ny\nb"; $x1 = "m\nb"; $x2 = "m"; $x1 = "x\ny"; guiParagraph($session, str_replace("\n", "<br>", $x1), false); guiParagraph($session, str_replace("\n", "<br>", $x2), false); $engine = new DiffEngine($session, $x1, $x2); $engine->compare(1, 1); }
function guiShowPageById(&$session, $page, $text_id) { $session->trace(TC_Gui1, 'guiShowPageById: ' . $page . '/' . $text_id); list($name, $type, $readgroup) = dbGetRecordById($session, T_Page, $page, 'name,type,readgroup'); if (!empty($text_id) && $text_id > 0) { $count_newer = dbSingleValue($session, 'select count(id) from ' . dbTable($session, T_Text) . ' where page=' . $page . ' and id>' . $text_id); } else { $count_newer = 0; list($text_id) = dbGetRecordByClause($session, T_Text, 'max(id)', 'page=' . $page); } $session->trace(TC_Gui1, 'guiShowPageById-2: ' . $count_newer); list($content, $created_at, $created_by) = dbGetRecordById($session, T_Text, $text_id, 'text,createdat,createdby'); $has_changed = $name != $session->fPageName; $session->SetPageData($name, $created_at, $created_by); if ($has_changed) { $session->SetLocation($name); } $header = $count_newer == 0 ? $session->fPageName : $session->fPageName . ' (Version ' . $text_id . ')'; if ($type == TT_Wiki) { guiStandardHeader($session, $header, Th_HeaderWiki, Th_BodyStartWiki); } else { guiStandardHeader($session, $header, Th_HeaderHTML, Th_BodyStartHTML); } if ($count_newer > 0) { guiParagraph($session, 'Achtung: es existier' . ($count_newer == 1 ? 't eine neuere Version' : 'en ' . $count_newer . ' neuere Versionen'), false); } guiFormatPage($session, $type, $content); guiStandardBodyEnd($session, $type == TT_Wiki ? Th_BodyEndWiki : Th_BodyEndHTML); }
function baseThread(&$session) { global $thread_id, $posting_id, $page_no; $session->trace(TC_Gui1, 'baseThread'); if (empty($thread_id)) { if (empty($posting_id)) { $thread_id = 1; } else { $thread_id = dbSingleValue($session, 'select top from ' . dbTable($session, T_Posting) . " where id={$posting_id}"); if (empty($thread_id)) { $thread_id = $posting_id; } } } if (!isset($page_no)) { $page_no = isset($posting_id) ? dbPageOfPosting($session, $thread_id, $posting_id) : 1; } $id_list = dbIdListOfThreadPage($session, $thread_id, $page_no); $thread = dbGetRecordById($session, T_Posting, $thread_id, 'author,subject,text,createdat,changedby,changedat,calls,forum'); dbThreadInfo($session, $thread_id, $answers, $pages, $last); $thread_date = dbSqlDateToText($session, $thread[3]); $forum = dbGetRecordById($session, T_Forum, $thread[7], 'name'); guiStandardHeader($session, 'Thema: ' . $thread[1], Th_ThreadHeader, Th_ThreadBodyStart); guiParagraph($session, $thread[0] . ', ' . $thread_date . ', ' . (0 + $answers) . ' Antwort' . ($answers == 1 ? ', ' : 'en, ') . $pages . ' Seite' . ($pages == 1 ? '' : 'n'), true); echo '<table width="100%" border="0"><tr><td>'; echo 'Forum: '; guiInternLink($session, P_Forum . '?forum_id=' . $thread[7], $forum[0]); if ($pages > 1) { echo '</td><td style="text-align: right">'; guiPageLinks($session, P_Thread . '?action=' . A_ShowThread . '&thread_id=' . $thread_id, $page_no, $pages); } echo "</td></tr></table>\n"; dbUpdateRaw($session, T_Posting, $thread_id, 'calls=calls+1'); echo '<table width="100%" border="0">' . "\n"; // Autor Thema-Text foreach ($id_list as $ii => $id) { # echo "alle Postings: $ii / $id<br>"; if ($id == $thread_id) { $posting = $thread; } else { $posting = dbGetRecordById($session, T_Posting, $id, 'author,subject,text,createdat,changedby,changedat'); } dbGetAuthorInfo($session, $posting[0], $author_link, $postings, $avatar, $ranking); echo '<tr><td style="vertical-align:top">'; guiLine(1); echo $thread[0] . '<br/>' . ($postings + 0) . ' Beiträge<br/>' . $ranking; if (!empty($avatar)) { echo '<br/>' . $avatar; } echo '</td><td>'; guiLine(1); if ($id == $thread_id) { guiHeadline($session, 3, 'Thema: ' . $posting[1]); } else { guiHeadline($session, 3, 'Antwort ' . ($ii + $session->fUserPostingsPerPage * ($page_no - 1)) . ': ' . $posting[1]); } echo 'Geschrieben am ' . dbSqlDateToText($session, $posting[3]); if (strcmp($posting[5], $posting[3]) != 0) { echo ' Letzte Änderung: ' . dbSqlDateToText($session, $posting[5]); if (!empty($posting[4]) && strcmp($posting[4], $posting[0]) != 0) { echo ' von ' . $posting[5]; } } echo '<br/>'; wikiToHTML($session, $posting[2]); echo '<p>'; guiInternLink($session, P_Thread . '?action=' . A_Answer . "&thread_id={$thread_id}&reference_id={$id}", 'Antworten'); if (strcmp($posting[0], $session->fUserName) == 0) { echo ' '; guiInternLink($session, P_Thread . '?action=' . A_ChangeThread . "&thread_id={$thread_id}&posting_id={$id}", 'Ändern'); echo "</p>\n"; } echo "</td><tr>\n"; } echo "</table>\n"; guiStandardBodyEnd($session, Th_ThreadBodyEnd); }
function addressPrintTable(&$session, $query, $max_lines) { $result = mysql_query($query, $session->fDbInfo); if (!$result) { protoc(mysql_error()); } else { guiHeadline($session, 2, 'Suchergebnis:'); $first = true; $no = 0; if ($max_lines <= 0) { $max_lines = 1000; } outTable(1); while ($row = mysql_fetch_row($result)) { if ($first) { addressPrintTableHeader($session); $first = false; } if (++$no > $max_lines) { break; } outTableRecord(); addressPrintRow($session, $row); outTableRecordEnd(); } if ($first) { echo "Die Anfrage ergab keine Ergebnisse"; outNewline(); } else { outTableEnd(); if ($no > $max_lines) { guiParagraph($session, "Es gibt noch weitere Ergebnisse!", false); } } mysql_free_result($result); } }
function instExit(&$session) { global $db_prefix, $inst_delete, $inst_passw, $inst_setpassw; $session->trace(TC_Init, 'instExit'); $error = null; $message = null; if (isset($inst_setpassw) && $inst_setpassw == CHECKBOX_TRUE) { if (empty($inst_passw)) { $error = '+++ leeres Passwort ist nicht zulässig!'; } else { checkDB($session, $message); $passw = strrev(crypt($inst_passw, 'admin')); sqlStatement($session, 'update ' . $db_prefix . "user set code='" . $passw . "' where name='admin'"); $message = 'Passwort wurde gesetzt'; } } if ($error) { instFinish($session, $error); } else { guiHeader($session, 'Ende'); guiHeadline($session, 2, 'Installation beenden'); if ($message) { guiParagraph($session, $message, false); } if (isset($inst_delete)) { guiParagraph($session, $session->fScriptFile . ' wurde ' . (unlink($session->fScriptFile) ? ' ' : ' <b>nicht</b>') . 'gelöscht', false); } guiParagraph($session, 'Die Installation ist jetzt beendet.', false); guiLine($session, 2); guiExternLink($session, 'index.php', 'Zur Anmeldung'); guiFinishBody($session); } }
function admShowUsers(&$session, $message) { $session->trace(TC_Gui1, 'admShowUsers'); admStandardHeader($session, 'Alle Benutzer'); if (!empty($message)) { guiParagraph($session, $message, false); } guiStartForm($session); dbPrintTable($session, 'Select id,name,email,theme,startpage from ' . dbTable($session, T_User) . ' where 1', array("Id", "Name", "EMail", "Design", "Startseite"), 0); guiFinishForm($session); admFinishBody($session); }
function admBackupAnswer(&$session) { global $backup_table, $backup_compressed, $backup_save; $session->trace(TC_Gui1, 'admBackupAnswer'); $message = null; guiHeader($session, 'Datenbank-Backup'); if (isset($backup_save)) { if (empty($backup_table)) { guiParagraph($session, '+++ keine Tabelle angegeben!', false); } else { guiHeadline($session, 1, 'Backup der Tabelle ' . $backup_table); $filename = $backup_table == '*' ? 'db_infobasar' : 'table_' . $backup_table; $filename = 'backup/' . $filename; if ($backup_compressed) { $filename .= '.gz'; } $open_name = $backup_compressed ? 'compress.zlib://' . $session->fFileSystemBase . '/' . $filename : $session->fFileSystemBase . '/' . $filename; $file = fopen($open_name, $backup_compressed ? 'wb9' : 'wb'); fwrite($file, '# InfoBasar: SQL Dump / Version: ' . PHP_Version . " \n# gesichert am " . strftime('%Y.%m.%d %H:%M:%S', time()) . "\n"); echo '<table border="0">'; if ($backup_table != '*') { $bytes = admSaveTable($session, $backup_table, false, $file); } else { $bytes = admWriteOneTable($session, dbTable($session, T_Param), $file); $bytes += admWriteOneTable($session, dbTable($session, T_Macro), $file); $bytes += admWriteOneTable($session, dbTable($session, T_User), $file); $bytes += admWriteOneTable($session, dbTable($session, T_Group), $file); $bytes += admWriteOneTable($session, dbTable($session, T_Forum), $file); $bytes += admWriteOneTable($session, dbTable($session, T_Posting), $file); $bytes += admWriteOneTable($session, dbTable($session, T_Text), $file); } fclose($file); $size = !$backup_compressed ? $bytes : filesize($session->fFileSystemBase . '/' . $filename); echo '<tr><td>Summe:</td><td>' . (0 + $bytes) . ' (' . (0 + $size) . ')</td></tr></table>' . "\n"; echo '<br/>'; guiStaticDataLink($session, '', $filename, 'Datei ' . $filename); } } admBackup($session, false, $message); }