url_name = $_REQUEST['page_name']; $page = getpage($page->url_name); if( $_POST ) { $page->url_name = $_POST['page_name'] ? $_POST['page_name'] : preg_replace('/\s+/', '_', strtolower(trim($_POST['title']))); $page->status = $_POST['page_status'] == 'published' ? 'published' : 'draft'; $page->title = $_POST['title']; $page->body = $_POST['content']; $page->style = $_POST['style']; if( USING_TIDY ) { $tidy = new tidy; $config = $tidy->getConfig(); $tidy->parseString( $page->body, $config, 'UTF8' ); $tidy->cleanRepair(); $page->body = tidy_get_output($tidy); } $action = isset($_POST['publish']) ? 'post' : 'edit'; if( isset( $_POST['publish'] ) ) $page->status = 'published'; // If [publish] button is used, ignore radio button switch( $_POST['action'] ) { case 'new_page': check_nonce('new-page'); if( !insertpage($page) ) { adminlog("Error inserting page.", MTS_PAGE, MTA_INSERT, E_ERROR); mtdie('There was an error inserting the page into the database.', 'SQL Error'); } break; case 'savepage': check_nonce('save-page-' . $page->url_name); updatepage($page); break; } if( $upload_info ) $info.=$upload_info; if( $upload_error ) $error.=$upload_error; if( $error ) $action='edit'; if( 'post' == $action ) _redirect( ADMIN_PATH . '/manage-pages.php?saved=success' ); $info.= '
' . ( $page->status === 'draft' ? 'Page draft saved.' : sprintf('Page published. View on site.', SITE_HOST, SITE_PATH, $page->url_name) ) . '
'; } elseif( !$page->url_name ) { mtdie('Attempted to edit page with no name supplied.', 'Bad Request'); } /////////////////////// Display Edit Form /////////////////////// adminhead('Edit Static Page'); adminmenu('manage-pages.php'); ?>