function action_history() { global $diff_mode, $full, $HistMax, $page, $pagestore, $UserName, $ver1; global $ver2; $history = $pagestore->history($page); gen_headers($history[0][0]); $versions = diff_get_history_versions($history, $ver1, $ver2); $latest_ver = $versions['latest_ver']; $previous_ver = $versions['previous_ver']; $text = ''; for ($i = 0; $i < count($history); $i++) { if ($i < $HistMax || $full) { $text = $text . html_history_entry($page, $history[$i][2], $history[$i][0], $history[$i][1], $history[$i][3], $previous_ver == $history[$i][2], $latest_ver == $history[$i][2], $history[$i][4]); } } if ($i >= $HistMax && !$full) { $text = $text . html_fullhistory($page, count($history)); } $p1 = $pagestore->page($page); $p1->version = $previous_ver; $p2 = $pagestore->page($page); $p2->version = $latest_ver; $diff = do_diff($p1->read(), $p2->read()); template_history(array('page' => $page, 'history' => $text, 'diff' => $diff, 'editver' => $UserName && $p2->mutable ? 0 : -1, 'timestamp' => $p2->time, 'edituser' => $p2->username, 'diff_mode' => $diff_mode)); }
function page_write($page, $postdata, $notimestamp = FALSE) { global $trackback; if (PKWK_READONLY) { return; } // Do nothing $postdata = make_str_rules($postdata); // Create and write diff $oldpostdata = is_page($page) ? join('', get_source($page)) : ''; $diffdata = do_diff($oldpostdata, $postdata); file_write(DIFF_DIR, $page, $diffdata); // Create backup make_backup($page, $postdata == ''); // Is $postdata null? // Create wiki text file_write(DATA_DIR, $page, $postdata, $notimestamp); if ($trackback) { // TrackBack Ping $_diff = explode("\n", $diffdata); $plus = join("\n", preg_replace('/^\\+/', '', preg_grep('/^\\+/', $_diff))); $minus = join("\n", preg_replace('/^-/', '', preg_grep('/^-/', $_diff))); tb_send($page, $plus, $minus); } links_update($page); }
function getNotificationObjects($course_id, $since, $user_id) { $items = array(); $type = get_object_type($course_id, array('sem', 'inst', 'fak')); if ($type == 'sem') { $query = 'SELECT wiki.*, seminare.Name, ' . $GLOBALS['_fullname_sql']['full'] . ' as fullname FROM wiki JOIN auth_user_md5 USING (user_id) JOIN user_info USING (user_id) JOIN seminar_user ON (range_id = Seminar_id) JOIN seminare USING (Seminar_id) WHERE seminar_user.user_id = ? AND Seminar_id = ? AND wiki.chdate > ?'; } else { $query = 'SELECT wiki.*, Institute.Name, ' . $GLOBALS['_fullname_sql']['full'] . ' as fullname FROM wiki JOIN auth_user_md5 USING (user_id) JOIN user_info USING (user_id) JOIN user_inst ON (range_id = Institut_id) JOIN Institute USING (Institut_id) WHERE user_inst.user_id = ? AND Institut_id = ? AND wiki.chdate > ?'; } $wikipage_stmt = DBManager::get()->prepare("SELECT * FROM wiki\n WHERE keyword = ? AND range_id = ?\n AND version = ?"); $stmt = DBManager::get()->prepare($query); $stmt->execute(array($user_id, $course_id, $since)); while ($row = $stmt->fetch()) { // use correct text depending on type of object if ($type == 'sem') { if ($row['version'] > 1) { $summary = sprintf('%s hat im Wiki der Veranstaltung "%s" die Seite "%s" geändert.', $row['fullname'], $row['Name'], $row['keyword']); } else { $summary = sprintf('%s hat im Wiki der Veranstaltung "%s" die Seite "%s" erstellt.', $row['fullname'], $row['Name'], $row['keyword']); } } else { if ($row['version'] > 1) { $summary = sprintf('%s hat im Wiki der Einreichtung "%s" die Seite "%s" geändert.', $row['fullname'], $row['Name'], $row['keyword']); } else { $summary = sprintf('%s hat im Wiki der Einreichtung "%s" die Seite "%s" erstellt.', $row['fullname'], $row['Name'], $row['keyword']); } } $content = ''; if ($row['version'] > 1) { $wikipage_stmt->execute(array($row['keyword'], $row['range_id'], $row['version'] - 1)); $old_page = $wikipage_stmt->fetch(PDO::FETCH_ASSOC); $content = '<table>' . do_diff($old_page['body'], $row['body']) . '</table>'; } else { $content = wikiReady($row['body']); } $items[] = new ContentElement('Wiki: ' . $row['keyword'], $summary, $content, $row['user_id'], $row['fullname'], URLHelper::getLink('wiki.php', array('cid' => $row['range_id'], 'keyword' => $row['keyword'])), $row['chdate']); } return $items; }
function do_preview() { foreach ($this->options as $key => $val) { ${$key} = $val; } $diff = ''; $pages = $this->get_pages($filter, $page, $fromhere); foreach ($pages as $apage) { if (($replace = $this->replace($apage)) == '') { continue; } $source = implode("", get_source($apage)); $diff = do_diff($source, $replace); break; } $this->options['fromhere'] = $apage; $body = $this->view->preview($apage, $diff); return $body; }
function do_preview() { foreach ($this->options as $key => $val) { ${$key} = $val; } $diff = ''; $pages = $this->get_pages($filter, $except, $page); foreach ($pages as $apage) { $replaced = $this->replace($apage, $search, $replace, $msearch, $mreplace, $regexp); if (is_null($replaced)) { continue; } $source = implode("", get_source($apage)); $diff = do_diff($source, $replaced); break; } $body = $this->view->preview($apage, $diff, $pages); return $body; }
function action_preview() { global $archive, $diff_mode, $document, $minoredit, $nextver, $page; global $pagefrom, $pagestore, $ParseEngine, $section, $template, $text_after; global $text_before; $document = str_replace("\r", "", $document); $text_before = str_replace("\r", "", $text_before); $text_after = str_replace("\r", "", $text_after); $pg = $pagestore->page($page); $pg->read(); // computes the diff of the current changes $body1_pg = $pagestore->page($page); $body1_pg->version = $nextver - 1; $body1 = $body1_pg->read(); $body2 = $document; if ($section) { $body2 = $text_before . "\n\n" . trim($document) . "\n\n" . $text_after; } $diff = do_diff($body1, $body2); template_preview(array('page' => $page, 'pagefrom' => $pagefrom, 'text' => $document, 'section' => $section, 'text_before' => $text_before, 'text_after' => $text_after, 'html' => parseText($document, $ParseEngine, $page), 'diff' => $diff, 'diff_mode' => $diff_mode, 'timestamp' => $pg->time, 'nextver' => $nextver, 'archive' => $archive, 'minoredit' => $minoredit, 'template' => $template, 'edituser' => $pg->username)); }
function page_write($page,$postdata,$notimestamp=FALSE) { $postdata = make_str_rules($postdata); // 差分ファイルの作成 $oldpostdata = is_page($page) ? join('',get_source($page)) : ''; $diffdata = do_diff($oldpostdata,$postdata); file_write(DIFF_DIR,$page,$diffdata); // バックアップの作成 make_backup($page,$postdata == ''); // ファイルの書き込み file_write(DATA_DIR,$page,$postdata,$notimestamp); // TrackBack Ping の送信 // 「追加」行を抽出 $lines = join("\n",preg_replace('/^\+/','',preg_grep('/^\+/',explode("\n",$diffdata)))); tb_send($page,$lines); // linkデータベースを更新 links_update($page); }
function plugin_backup_action() { global $vars, $do_backup, $hr, $script; global $layout_pages, $style_name; $qm = get_qm(); $editable = edit_auth($page, FALSE, FALSE); if (!$editable) { header("Location: {$script}"); exit; } if (!$do_backup) { return; } $page = isset($vars['page']) ? $vars['page'] : ''; if ($page == '') { return array('msg' => $qm->m['plg_backup']['title_backuplist'], 'body' => plugin_backup_get_list_all()); } //レイアウト部品の場合、スタイルを変更する $is_layout = FALSE; if (isset($layout_pages) && isset($layout_pages[$page])) { $style_name = '..'; $is_layout = TRUE; } check_readable($page, true, true); $s_page = htmlspecialchars($page); $r_page = rawurlencode($page); $action = isset($vars['action']) ? $vars['action'] : ''; if ($action == 'delete') { return plugin_backup_delete($page); } $s_action = $r_action = ''; if ($action != '') { $s_action = htmlspecialchars($action); $r_action = rawurlencode($action); } $s_age = isset($vars['age']) && is_numeric($vars['age']) ? $vars['age'] : 0; if ($s_age <= 0) { $title = $is_layout ? h($layout_pages[$page]) . 'のバックアップ一覧' : $qm->m['plg_backup']['title_pagebackuplist']; return array('msg' => $title, 'body' => plugin_backup_get_list($page)); } $script = get_script_uri(); $body = '<ul>' . "\n"; if (!$is_layout) { $body .= ' <li><a href="' . $script . '?cmd=backup">' . $qm->m['plg_backup']['backuplist'] . '</a></li>' . "\n"; } $href = $script . '?cmd=backup&page=' . $r_page . '&age=' . $s_age; $is_page = is_page($page); if ($is_page && $action != 'diff') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=diff">' . $qm->m['plg_backup']['diff'] . '</a>', $qm->m['plg_backup']['view']) . '</li>' . "\n"; } if ($is_page && $action != 'nowdiff') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=nowdiff">' . $qm->m['plg_backup']['nowdiff'] . '</a>', $qm->m['plg_backup']['view']) . '</li>' . "\n"; } if ($action != 'source') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=source">' . $qm->m['plg_backup']['source'] . '</a>', $qm->m['plg_backup']['view']) . '</li>' . "\n"; } if (!PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING && $action) { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '">' . $qm->m['plg_backup']['backup'] . '</a>', $qm->m['plg_backup']['view']) . '</li>' . "\n"; } if ($is_page && $is_layout) { $body .= ' <li><a href="' . $script . '?cmd=edit&page=' . $r_page . '">' . h($layout_pages[$page]) . 'を編集する</a>'; } else { if ($is_page) { $body .= ' <li>' . str_replace('$1', '<a href="' . $script . '?' . $r_page . '">' . $s_page . '</a>', $qm->m['fmt_msg_goto']) . "\n"; } else { $body .= ' <li>' . str_replace('$1', $s_page, $qm->m['plg_backup']['deleted']) . "\n"; } } $backups = get_backup($page); $backups_count = count($backups); if ($s_age > $backups_count) { $s_age = $backups_count; } if ($backups_count > 0) { $body .= ' <ul>' . "\n"; foreach ($backups as $age => $val) { $date = format_date($val['time'], TRUE); $body .= $age == $s_age ? ' <li><em>' . $age . ' ' . $date . '</em></li>' . "\n" : ' <li><a href="' . $script . '?cmd=backup&action=' . $r_action . '&page=' . $r_page . '&age=' . $age . '">' . $age . ' ' . $date . '</a></li>' . "\n"; } $body .= ' </ul>' . "\n"; } $body .= ' </li>' . "\n"; $body .= '</ul>' . "\n"; if ($action == 'diff') { $title = $is_layout ? h($layout_pages[$page]) . ' のバックアップ差分(No.$2)' : $qm->m['plg_backup']['title_backupdiff']; $old = $s_age > 1 ? join('', $backups[$s_age - 1]['data']) : ''; $cur = join('', $backups[$s_age]['data']); $body .= plugin_backup_diff(do_diff($old, $cur)); } else { if ($s_action == 'nowdiff') { $title = $is_layout ? h($layout_pages[$page]) . ' のバックアップの現在との差分(No.$2)' : $qm->m['plg_backup']['title_backupnowdiff']; $old = join('', $backups[$s_age]['data']); $cur = join('', get_source($page)); $body .= plugin_backup_diff(do_diff($old, $cur)); } else { if ($s_action == 'source') { $title = $is_layout ? h($layout_pages[$page]) . ' のバックアップソース(No.$2)' : $qm->m['plg_backup']['title_backupsource']; $body .= '<pre>' . htmlspecialchars(join('', $backups[$s_age]['data'])) . '</pre>' . "\n"; } else { if (PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING) { die_message($qm->m['fmt_err_prohibited']); } else { $title = $is_layout ? h($layout_pages[$page]) . ' のバックアップ(No.$2)' : $qm->m['plg_backup']['title_backup']; $body .= $hr . "\n" . drop_submit(convert_html($backups[$s_age]['data'])); } } } } return array('msg' => str_replace('$2', $s_age, $title), 'body' => $body); }
} else { $vars['showalllink'] = '<a href="' . $diff . $passIgnoreWhitespace . '&all=1' . '">' . $lang['SHOWENTIREFILE'] . '</a>'; } $passShowAll = $all ? '&all=1' : ''; if ($ignoreWhitespace) { $vars['regardwhitespacelink'] = '<a href="' . $diff . $passShowAll . '">' . $lang['REGARDWHITESPACE'] . '</a>'; } else { $vars['ignorewhitespacelink'] = '<a href="' . $diff . $passShowAll . '&ignorews=1">' . $lang['IGNOREWHITESPACE'] . '</a>'; } // Get the contents of the two files $newerFile = tempnam($config->getTempDir(), ''); $highlightedNew = $svnrep->getFileContents($history->entries[0]->path, $newerFile, $history->entries[0]->rev, $peg, '', true); $olderFile = tempnam($config->getTempDir(), ''); $highlightedOld = $svnrep->getFileContents($history->entries[1]->path, $olderFile, $history->entries[1]->rev, $peg, '', true); // TODO: Figured out why diffs across a move/rename are currently broken. $ent = !$highlightedNew && !$highlightedOld; $listing = do_diff($all, $ignoreWhitespace, $ent, $newerFile, $olderFile); // Remove our temporary files @unlink($newerFile); @unlink($olderFile); } } if (!$rep->hasReadAccess($path, false)) { $vars['error'] = $lang['NOACCESS']; } } $vars['template'] = 'diff'; $template = $rep ? $rep->getTemplatePath() : $config->getTemplatePath(); parseTemplate($template . 'header.tmpl', $vars, $listing); parseTemplate($template . 'diff.tmpl', $vars, $listing); parseTemplate($template . 'footer.tmpl', $vars, $listing);
function page_write($page, $postdata, $notimestamp = FALSE) { global $trackback, $autoalias, $aliaspage; global $autoglossary, $glossarypage; global $use_spam_check; // if (PKWK_READONLY) return; // Do nothing if (auth::check_role('readonly')) { return; } // Do nothing if (is_page($page)) { $oldpostdata = get_source($page, TRUE, TRUE); } else { if (auth::is_check_role(PKWK_CREATE_PAGE)) { die_message(_('PKWK_CREATE_PAGE prohibits editing')); } $oldpostdata = ''; } $postdata = make_str_rules($postdata); // Create and write diff $diffdata = do_diff($oldpostdata, $postdata); $role_adm_contents = auth::check_role('role_adm_contents'); $links = array(); if ($trackback > 1 || $role_adm_contents && $use_spam_check['page_contents']) { $links = get_this_time_links($postdata, $diffdata); } // Blocking SPAM if ($role_adm_contents) { if ($use_spam_check['page_remote_addr'] && SpamCheck($_SERVER['REMOTE_ADDR'], 'ip')) { die_message('Writing was limited by IPBL (Blocking SPAM).'); } if ($use_spam_check['page_contents'] && SpamCheck($links)) { die_message('Writing was limited by DNSBL (Blocking SPAM).'); } if ($use_spam_check['page_write_proxy'] && is_proxy()) { die_message('Writing was limited by PROXY (Blocking SPAM).'); } } // Logging postdata postdata_write(); // Create diff text file_write(DIFF_DIR, $page, $diffdata); // Create backup make_backup($page, $postdata == ''); // Is $postdata null? // Create wiki text file_write(DATA_DIR, $page, $postdata, $notimestamp); if (function_exists('senna_update')) { senna_update($page, $oldpostdata, $postdata); } if ($trackback > 1) { // TrackBack Ping tb_send($page, $links); } unset($oldpostdata, $diffdata, $links); links_update($page); // Update autoalias.dat (AutoAliasName) if ($autoalias && $page == $aliaspage) { $aliases = get_autoaliases(); if (empty($aliases)) { // Remove @unlink(CACHE_DIR . PKWK_AUTOALIAS_REGEX_CACHE); } else { // Create or Update autolink_pattern_write(CACHE_DIR . PKWK_AUTOALIAS_REGEX_CACHE, get_autolink_pattern(array_keys($aliases), $autoalias)); } } // Update glossary.dat (AutoGlossary) if ($autoglossary && $page == $glossarypage) { $words = get_autoglossaries(); if (empty($words)) { // Remove @unlink(CACHE_DIR . PKWK_GLOSSARY_REGEX_CACHE); } else { // Create or Update autolink_pattern_write(CACHE_DIR . PKWK_GLOSSARY_REGEX_CACHE, get_glossary_pattern(array_keys($words), $autoglossary)); } } log_write('update', $page); }
function plugin_backup_action() { global $vars, $do_backup, $hr, $script; // global $_msg_backuplist, $_msg_diff, $_msg_nowdiff, $_msg_source, $_msg_backup; // global $_msg_view, $_msg_goto, $_msg_deleted; // global $_msg_visualdiff; // global $_title_backupdiff, $_title_backupnowdiff, $_title_backupsource; // global $_title_backup, $_title_pagebackuplist, $_title_backuplist; $_msg_backuplist = _('Backup list'); $_msg_diff = _('diff'); $_msg_nowdiff = _('diff current'); $_msg_source = _('source'); $_msg_backup = _('backup'); $_msg_visualdiff = _('diff for visual'); $_msg_view = _('View the $1.'); $_msg_goto = _('Go to $1.'); $_msg_deleted = _(' $1 has been deleted.'); $_title_backupdiff = _('Backup diff of $1(No. $2)'); $_title_backupnowdiff = _('Backup diff of $1 vs current(No. $2)'); $_title_backupsource = _('Backup source of $1(No. $2)'); $_title_backup = _('Backup of $1(No. $2)'); $_title_pagebackuplist = _('Backup list of $1'); $_title_backuplist = _('Backup list'); if (!$do_backup) { return; } $page = isset($vars['page']) ? $vars['page'] : ''; if ($page == '') { return array('msg' => $_title_backuplist, 'body' => plugin_backup_get_list_all()); } check_readable($page, true, true); $s_page = htmlspecialchars($page); $r_page = rawurlencode($page); $action = isset($vars['action']) ? $vars['action'] : ''; if ($action == 'delete') { return plugin_backup_delete($page); } $s_action = $r_action = ''; if ($action != '') { $s_action = htmlspecialchars($action); $r_action = rawurlencode($action); } $s_age = isset($vars['age']) && is_numeric($vars['age']) ? $vars['age'] : 0; if ($s_age <= 0) { return array('msg' => $_title_pagebackuplist, 'body' => plugin_backup_get_list($page)); } $body = '<ul>' . "\n"; $body .= ' <li><a href="' . $script . '?cmd=backup">' . $_msg_backuplist . '</a></li>' . "\n"; $href = $script . '?cmd=backup&page=' . $r_page . '&age=' . $s_age; $is_page = is_page($page); if ($is_page && $action != 'diff') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=diff">' . $_msg_diff . '</a>', $_msg_view) . '</li>' . "\n"; } if ($is_page && $action != 'nowdiff') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=nowdiff">' . $_msg_nowdiff . '</a>', $_msg_view) . '</li>' . "\n"; } if ($is_page && $action != 'visualdiff') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=visualdiff">' . $_msg_visualdiff . '</a>', $_msg_view) . '</li>' . "\n"; } if ($action != 'source') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=source">' . $_msg_source . '</a>', $_msg_view) . '</li>' . "\n"; } if (!PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING && $action) { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '">' . $_msg_backup . '</a>', $_msg_view) . '</li>' . "\n"; } if ($is_page) { $body .= ' <li>' . str_replace('$1', '<a href="' . get_page_uri($page) . '">' . $s_page . '</a>', $_msg_goto) . "\n"; } else { $body .= ' <li>' . str_replace('$1', $s_page, $_msg_deleted) . "\n"; } $backups = get_backup($page); $backups_count = count($backups); if ($s_age > $backups_count) { $s_age = $backups_count; } if ($backups_count > 0 && $action != 'visualdiff') { $body .= ' <ul>' . "\n"; foreach ($backups as $age => $val) { $time = isset($val['real']) ? $val['real'] : $val['time']; $date = format_date($time, TRUE); $body .= $age == $s_age ? ' <li><em>' . $age . ' ' . $date . '</em></li>' . "\n" : ' <li><a href="' . $script . '?cmd=backup&action=' . $r_action . '&page=' . $r_page . '&age=' . $age . '">' . $age . ' ' . $date . '</a></li>' . "\n"; } $body .= ' </ul>' . "\n"; } $body .= ' </li>' . "\n"; $body .= '</ul>' . "\n"; if ($action == 'diff') { if (auth::check_role('safemode')) { die_message(_('PKWK_SAFE_MODE prohibits this')); } $title =& $_title_backupdiff; $old = $s_age > 1 ? join('', $backups[$s_age - 1]['data']) : ''; $cur = join('', $backups[$s_age]['data']); auth::is_role_page($old); auth::is_role_page($cur); $body .= plugin_backup_diff(do_diff($old, $cur)); } else { if ($s_action == 'nowdiff') { if (auth::check_role('safemode')) { die_message(_('PKWK_SAFE_MODE prohibits this')); } $title =& $_title_backupnowdiff; $old = join('', $backups[$s_age]['data']); $cur = join('', get_source($page)); auth::is_role_page($old); auth::is_role_page($cur); $body .= plugin_backup_diff(do_diff($old, $cur)); } else { if ($s_action == 'visualdiff') { $old = join('', $backups[$s_age]['data']); $cur = join('', get_source($page)); auth::is_role_page($old); auth::is_role_page($cur); $source = do_diff($old, $cur); $source = plugin_backup_visualdiff($source); $body .= "{$hr}\n" . drop_submit(convert_html($source)); $body = preg_replace('#<p>\\#spandel(.*?)(</p>)#si', '<span class="remove_word">$1', $body); $body = preg_replace('#<p>\\#spanadd(.*?)(</p>)#si', '<span class="add_word">$1', $body); $body = preg_replace('#<p>\\#spanend(.*?)(</p>)#si', '$1</span>', $body); $body = preg_replace('#&spandel;#i', '<span class="remove_word">', $body); $body = preg_replace('#&spanadd;#i', '<span class="add_word">', $body); $body = preg_replace('#&spanend;#i', '</span>', $body); $title =& $_title_backupnowdiff; } else { if ($s_action == 'source') { if (auth::check_role('safemode')) { die_message(_('PKWK_SAFE_MODE prohibits this')); } $title =& $_title_backupsource; auth::is_role_page($backups[$s_age]['data']); $body .= '<pre>' . htmlspecialchars(join('', $backups[$s_age]['data'])) . '</pre>' . "\n"; } else { if (PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING) { die_message(_('This feature is prohibited')); } else { $title =& $_title_backup; auth::is_role_page($backups[$s_age]['data']); $body .= $hr . "\n" . drop_submit(convert_html($backups[$s_age]['data'])); } } } } } return array('msg' => str_replace('$2', $s_age, $title), 'body' => $body); }
function plugin_backup_action() { global $vars, $do_backup, $hr; global $_msg_backuplist, $_msg_diff, $_msg_nowdiff, $_msg_source, $_msg_backup; global $_msg_view, $_msg_goto, $_msg_deleted; global $_title_backupdiff, $_title_backupnowdiff, $_title_backupsource; global $_title_backup, $_title_pagebackuplist, $_title_backuplist; if (!$do_backup) { return; } $page = isset($vars['page']) ? $vars['page'] : ''; if ($page == '') { return array('msg' => $_title_backuplist, 'body' => plugin_backup_get_list_all()); } check_readable($page, true, true); $s_page = htmlsc($page); $r_page = rawurlencode($page); $action = isset($vars['action']) ? $vars['action'] : ''; if ($action == 'delete') { return plugin_backup_delete($page); } $s_action = $r_action = ''; if ($action != '') { $s_action = htmlsc($action); $r_action = rawurlencode($action); } $s_age = isset($vars['age']) && is_numeric($vars['age']) ? $vars['age'] : 0; if ($s_age <= 0) { return array('msg' => $_title_pagebackuplist, 'body' => plugin_backup_get_list($page)); } $script = get_script_uri(); $body = '<ul>' . "\n"; $body .= ' <li><a href="' . $script . '?cmd=backup">' . $_msg_backuplist . '</a></li>' . "\n"; $href = $script . '?cmd=backup&page=' . $r_page . '&age=' . $s_age; $is_page = is_page($page); if ($is_page && $action != 'diff') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=diff">' . $_msg_diff . '</a>', $_msg_view) . '</li>' . "\n"; } if ($is_page && $action != 'nowdiff') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=nowdiff">' . $_msg_nowdiff . '</a>', $_msg_view) . '</li>' . "\n"; } if ($action != 'source') { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '&action=source">' . $_msg_source . '</a>', $_msg_view) . '</li>' . "\n"; } if (!PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING && $action) { $body .= ' <li>' . str_replace('$1', '<a href="' . $href . '">' . $_msg_backup . '</a>', $_msg_view) . '</li>' . "\n"; } if ($is_page) { $body .= ' <li>' . str_replace('$1', '<a href="' . $script . '?' . $r_page . '">' . $s_page . '</a>', $_msg_goto) . "\n"; } else { $body .= ' <li>' . str_replace('$1', $s_page, $_msg_deleted) . "\n"; } $backups = get_backup($page); $backups_count = count($backups); if ($s_age > $backups_count) { $s_age = $backups_count; } if ($backups_count > 0) { $body .= ' <ul>' . "\n"; foreach ($backups as $age => $val) { $date = format_date($val['time'], true); $body .= $age == $s_age ? ' <li><em>' . $age . ' ' . $date . '</em></li>' . "\n" : ' <li><a href="' . $script . '?cmd=backup&action=' . $r_action . '&page=' . $r_page . '&age=' . $age . '">' . $age . ' ' . $date . '</a></li>' . "\n"; } $body .= ' </ul>' . "\n"; } $body .= ' </li>' . "\n"; $body .= '</ul>' . "\n"; if ($action == 'diff') { $title =& $_title_backupdiff; $old = $s_age > 1 ? join('', $backups[$s_age - 1]['data']) : ''; $cur = join('', $backups[$s_age]['data']); $body .= plugin_backup_diff(do_diff($old, $cur)); } elseif ($s_action == 'nowdiff') { $title =& $_title_backupnowdiff; $old = join('', $backups[$s_age]['data']); $cur = join('', get_source($page)); $body .= plugin_backup_diff(do_diff($old, $cur)); } elseif ($s_action == 'source') { $title =& $_title_backupsource; $body .= '<pre>' . htmlsc(join('', $backups[$s_age]['data'])) . '</pre>' . "\n"; } else { if (PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING) { die_message('This feature is prohibited'); } else { $title =& $_title_backup; $body .= $hr . "\n" . drop_submit(convert_html($backups[$s_age]['data'])); } } return array('msg' => str_replace('$2', $s_age, $title), 'body' => $body); }
function get_deltas($in_row) { // returns array of strings or FALSE global $thresh_n, $thresh_m, $thresh_h; $deltas = array("", "", "", "", "", "", ""); // length 7 // $thresh = array(10, 20, 30, 40, 50, 60, 1); // minutes switch ($in_row['severity']) { case $GLOBALS['SEVERITY_NORMAL']: $thresh = $thresh_n; break; case $GLOBALS['SEVERITY_MEDIUM']: $thresh = $thresh_m; break; case $GLOBALS['SEVERITY_HIGH']: $thresh = $thresh_h; break; default: $thresh = $thresh_n; } if (!is_date($in_row["problemstart"])) { return $deltas; } else { // dispatched if (!is_date($in_row["dispatched"]) || $in_row["dispatched"] < $in_row["problemstart"]) { $deltas[0] = ""; } else { $diff = do_diff(0, $in_row); // returns seconds $class = $diff / 60 <= $thresh[0] ? "ok" : "over"; // dump(($diff/60)); dump($thresh[0]); $deltas[0] = "<SPAN CLASS='{$class}'>(" . show_diff($diff) . ")</SPAN>"; } // responding if (!is_date($in_row["responding"]) || $in_row["responding"] < $in_row["problemstart"]) { $deltas[1] = ""; } else { $diff = do_diff(1, $in_row); // returns seconds $class = $diff / 60 <= $thresh[1] ? "ok" : "over"; $deltas[1] = "<SPAN CLASS='{$class}'>(" . show_diff($diff) . ")</SPAN>"; } // on_scene if (!is_date($in_row["on_scene"]) || $in_row["on_scene"] < $in_row["problemstart"]) { $deltas[2] = ""; } else { $diff = do_diff(2, $in_row); // returns seconds $class = $diff / 60 <= $thresh[2] ? "ok" : "over"; $deltas[2] = "<SPAN CLASS='{$class}'>(" . show_diff($diff) . ")</SPAN>"; } // u2fenr if (!is_date($in_row["u2fenr"]) || $in_row["u2fenr"] < $in_row["problemstart"]) { $deltas[3] = ""; } else { $diff = do_diff(3, $in_row); // returns seconds $class = $diff / 60 <= $thresh[3] ? "ok" : "over"; $deltas[3] = "<SPAN CLASS='{$class}'>(" . show_diff($diff) . ")</SPAN>"; } // u2farr if (!is_date($in_row["u2farr"]) || $in_row["u2farr"] < $in_row["problemstart"]) { $deltas[4] = ""; } else { $diff = do_diff(4, $in_row); // returns seconds $class = $diff / 60 <= $thresh[4] ? "ok" : "over"; $deltas[4] = "<SPAN CLASS='{$class}'>(" . show_diff($diff) . ")</SPAN>"; } // clear if (!is_date($in_row["clear"]) || $in_row["clear"] < $in_row["problemstart"]) { $deltas[5] = ""; } else { $diff = do_diff(5, $in_row); // returns seconds $class = $diff / 60 <= $thresh[5] ? "ok" : "over"; $deltas[5] = "<SPAN CLASS='{$class}'>(" . show_diff($diff) . ")</SPAN>"; } // problemend if (!is_date($in_row["problemend"]) || $in_row["problemend"] < $in_row["problemstart"]) { $deltas[6] = ""; } else { $diff = do_diff(6, $in_row); // returns seconds $class = $diff / 60 <= $thresh[6] ? "ok" : "over"; $deltas[6] = "<SPAN CLASS='{$class}'>(" . show_diff($diff) . ")</SPAN>"; } return $deltas; } // end if/else }
/** * Display Page diffs, restrictable to recent versions * * @param string WikiPage name * @param string Only show versions newer than this timestamp * **/ function showDiffs($keyword, $versions_since) { global $SessSemName; $query = "SELECT * FROM wiki WHERE keyword = ? AND range_id = ? ORDER BY version DESC"; $statement = DBManager::get()->prepare($query); $statement->execute(array($keyword, $SessSemName[1])); $versions = $statement->fetchAll(PDO::FETCH_ASSOC); if (count($versions) === 0) { throw new InvalidArgumentException(_('Es gibt keine zu vergleichenden Versionen.')); } showPageFrameStart(); wikiSinglePageHeader($wikiData, $keyword); echo "\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">"; $version = array_shift($versions); $last = $version['body']; $lastversion = $version['version']; $zusatz = getZusatz($version); foreach ($versions as $version) { echo '<tr>'; $current = $version['body']; $currentversion = $version['version']; $diffarray = '<b><font size=-1>'. _("Änderungen zu") . " </font> $zusatz</b><p>"; $diffarray .= "<table cellpadding=0 cellspacing=0 border=0 width=\"100%\">\n"; $diffarray .= do_diff($current, $last); $diffarray .= "</table>\n"; printcontent(0, 0, $diffarray, ''); echo '</tr>'; $last = $current; $lastversion = $currentversion; $zusatz = getZusatz($version); if ($versions_since && $version['chdate'] < $versions_since) { break; } } echo '</table>'; getDiffPageInfobox($keyword); showPageFrameEnd(); }