diff -r 000000000000 -r 902822492a68 index.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/index.php Wed Jun 13 16:03:00 2007 -0400 @@ -0,0 +1,425 @@ +The action "'.$_GET['do'].'" is not defined. Return to viewing this page\'s text.
'); + break; + case 'view': + // echo PageUtils::getpage($paths->page, true, ( (isset($_GET['oldid'])) ? $_GET['oldid'] : false )); + $page = new PageProcessor( $paths->cpage['urlname_nons'], $paths->namespace ); + $page->send_headers = true; + $page->send(); + break; + case 'comments': + $template->header(); + $sub = ( isset ($_GET['sub']) ) ? $_GET['sub'] : false; + switch($sub) + { + case 'admin': + default: + $act = ( isset ($_GET['action']) ) ? $_GET['action'] : false; + $id = ( isset ($_GET['id']) ) ? intval($_GET['id']) : -1; + echo PageUtils::comments_html($paths->cpage['urlname_nons'], $paths->namespace, $act, Array('id'=>$id)); + break; + case 'postcomment': + if(empty($_POST['name']) || + empty($_POST['subj']) || + empty($_POST['text']) + ) { echo 'Invalid request'; break; } + $cid = ( isset($_POST['captcha_id']) ) ? $_POST['captcha_id'] : false; + $cin = ( isset($_POST['captcha_input']) ) ? $_POST['captcha_input'] : false; + PageUtils::addcomment($paths->cpage['urlname_nons'], $paths->namespace, $_POST['name'], $_POST['subj'], $_POST['text'], $cin, $cid); // All filtering, etc. is handled inside this method + echo PageUtils::comments_html($paths->cpage['urlname_nons'], $paths->namespace); + break; + case 'editcomment': + if(!isset($_GET['id']) || ( isset($_GET['id']) && !preg_match('#^([0-9]+)$#', $_GET['id']) )) { echo 'Invalid comment ID
'; break; } + $q = $db->sql_query('SELECT subject,comment_data,comment_id FROM '.table_prefix.'comments WHERE comment_id='.$_GET['id']); + if(!$q) $db->_die('The comment data could not be selected.'); + $row = $db->fetchrow(); + $db->free_result(); + echo ''; + break; + case 'savecomment': + if(empty($_POST['subj']) || empty($_POST['text'])) { echo 'Invalid request
'; break; } + $r = PageUtils::savecomment_neater($paths->cpage['urlname_nons'], $paths->namespace, $_POST['subj'], $_POST['text'], (int)$_POST['id']); + if($r != 'good') { echo "$r"; break; } + echo PageUtils::comments_html($paths->cpage['urlname_nons'], $paths->namespace); + break; + case 'deletecomment': + if(!empty($_GET['id'])) + { + PageUtils::deletecomment_neater($paths->cpage['urlname_nons'], $paths->namespace, (int)$_GET['id']); + } + echo PageUtils::comments_html($paths->cpage['urlname_nons'], $paths->namespace); + break; + } + $template->footer(); + break; + case 'edit': + if(isset($_POST['_cancel'])) { header('Location: '.makeUrl($paths->page)); echo '
The URL parameter "id" is not an integer. Exiting to prevent nasties like SQL injection, etc.
'); + $rb = PageUtils::rollback( (int) $id ); + $template->header(); + echo ''.$rb.' Return to the page.
'; + $template->footer(); + break; + case 'catedit': + if(isset($_POST['__enanoSaveButton'])) + { + unset($_POST['__enanoSaveButton']); + $val = PageUtils::catsave($paths->cpage['urlname_nons'], $paths->namespace, $_POST); + if($val == 'GOOD') + { + header('Location: '.makeUrl($paths->page)); echo ''.$val.'
'); + } + } + elseif(isset($_POST['__enanoCatCancel'])) + { + header('Location: '.makeUrl($paths->page)); echo 'No protection level specified
'); + if(!empty($_POST['reason'])) + { + if(!preg_match('#^([0-2]*){1}$#', $_POST['level'])) die_friendly('Error protecting page', 'Request validation failed
'); + PageUtils::protect($paths->cpage['urlname_nons'], $paths->namespace, intval($_POST['level']), $_POST['reason']); + die_friendly('Page protected', 'The protection setting has been applied. Return to the page.
'); + } + $template->header(); + ?> + + footer(); + break; + case 'rename': + if(!empty($_POST['newname'])) + { + $r = PageUtils::rename($paths->cpage['urlname_nons'], $paths->namespace, $_POST['newname']); + die_friendly('Page renamed', ''.nl2br($r).' Return to the page.
'); + } + $template->header(); + ?> + + footer(); + break; + case 'flushlogs': + if(!$session->get_permissions('clear_logs')) die_friendly('Access denied', 'Flushing the logs for a page requires administrative rights.
'); + if(isset($_POST['_downthejohn'])) + { + $template->header(); + $result = PageUtils::flushlogs($paths->cpage['urlname_nons'], $paths->namespace); + echo ''.$result.' Return to the page.
'; + $template->footer(); + break; + } + $template->header(); + ?> + + footer(); + break; + case 'delvote': + if(isset($_POST['_ballotbox'])) + { + $template->header(); + $result = PageUtils::delvote($paths->cpage['urlname_nons'], $paths->namespace); + echo ''.$result.' Return to the page.
'; + $template->footer(); + break; + } + $template->header(); + ?> + + footer(); + break; + case 'resetvotes': + if(!$session->get_permissions('vote_reset')) die_friendly('Access denied', 'Resetting the deletion votes against this page requires admin rights.
'); + if(isset($_POST['_youmaylivealittlelonger'])) + { + $template->header(); + $result = PageUtils::resetdelvotes($paths->cpage['urlname_nons'], $paths->namespace); + echo ''.$result.' Return to the page.
'; + $template->footer(); + break; + } + $template->header(); + ?> + + footer(); + break; + case 'deletepage': + if(!$session->get_permissions('delete_page')) die_friendly('Access denied', 'Deleting pages requires admin rights.
'); + if(isset($_POST['_adiossucker'])) + { + $template->header(); + $result = PageUtils::deletepage($paths->cpage['urlname_nons'], $paths->namespace); + echo ''.$result.' Return to the page.
'; + $template->footer(); + break; + } + $template->header(); + ?> + + footer(); + break; + case 'setwikimode': + if(!$session->get_permissions('set_wiki_mode')) die_friendly('Access denied', 'Changing the wiki mode setting requires admin rights.
'); + if(!isset($_GET['level']) || ( isset($_GET['level']) && !preg_match('#^([0-9])$#', $_GET['level']))) die_friendly('Invalid request', 'Level not specified
'); + $template->header(); + $template->footer(); + break; + case 'diff': + $template->header(); + $id1 = ( isset($_GET['diff1']) ) ? (int)$_GET['diff1'] : false; + $id2 = ( isset($_GET['diff2']) ) ? (int)$_GET['diff2'] : false; + if(!$id1 || !$id2) { echo 'Invalid request.
'; $template->footer(); break; } + if(!preg_match('#^([0-9]+)$#', (string)$_GET['diff1']) || + !preg_match('#^([0-9]+)$#', (string)$_GET['diff2'] )) { echo 'SQL injection attempt
'; $template->footer(); break; } + echo PageUtils::pagediff($paths->cpage['urlname_nons'], $paths->namespace, $id1, $id2); + $template->footer(); + break; + case 'aclmanager': + $data = ( isset($_POST['data']) ) ? $_POST['data'] : Array('mode' => 'listgroups'); + PageUtils::aclmanager($data); + break; + } + + // + // Optimize HTML by replacing newlines with spaces (excludes,