From: <fr...@us...> - 2007-10-21 12:52:30
|
Update of /cvsroot/tikiwiki/tiki In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3264 Modified Files: tiki-editpage.php Log Message: [FIX] set $user to 'Anonymous' by edit page Anonymous Index: tiki-editpage.php =================================================================== RCS file: /cvsroot/tikiwiki/tiki/tiki-editpage.php,v retrieving revision 1.183 retrieving revision 1.184 diff -u -d -r1.183 -r1.184 --- tiki-editpage.php 20 Oct 2007 05:16:54 -0000 1.183 +++ tiki-editpage.php 21 Oct 2007 12:52:32 -0000 1.184 @@ -1,26 +1,21 @@ <?php - // $Header$ - // Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. // All Rights Reserved. See copyright.txt for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. - //var_dump($_REQUEST);die; // Initialization $section = "wiki page"; require_once ('tiki-setup.php'); - include_once ('lib/wiki/wikilib.php'); include_once ('lib/structures/structlib.php'); include_once ('lib/notifications/notificationlib.php'); require_once ("lib/ajax/ajaxlib.php"); require_once ("lib/wiki/wiki-ajax.php"); - $access->check_feature('feature_wiki'); - - - +if (!$user) { + $user = 'Anonymous'; +} // Anti-bot feature: if enabled, anon user must type in a code displayed in an image if (isset($_REQUEST['save']) && (!$user || $user == 'anonymous') && $prefs['feature_antibot'] == 'y') { if((!isset($_SESSION['random_number']) || $_SESSION['random_number'] != $_REQUEST['antibotcode'])) { @@ -29,20 +24,17 @@ die; } } - // Get the page from the request var or default it to HomePage if (!isset($_REQUEST["page"]) || $_REQUEST["page"] == '') { $_REQUEST['page'] = $wikilib->get_default_wiki_page(); } $page = $_REQUEST["page"]; $smarty->assign_by_ref('page', $_REQUEST["page"]); - $page_ref_id = ''; if (isset($_REQUEST["page_ref_id"])) { $page_ref_id = $_REQUEST["page_ref_id"]; } $smarty->assign('page_ref_id',$page_ref_id); - //Is new page to be inserted into structure? if (isset($_REQUEST["current_page_id"])) { if (empty($_REQUEST['page'])) { @@ -69,12 +61,9 @@ $smarty->assign('current_page_id',0); $smarty->assign('add_child', false); } - - function compare_import_versions($a1, $a2) { return $a1["version"] - $a2["version"]; } - if (isset($_REQUEST['cancel_edit'])) { $page = urlencode($page); $tikilib->semaphore_unset($page, $_SESSION["edit_lock_$page"]); @@ -85,13 +74,11 @@ header($url); die; } - if (isset($_REQUEST['minor'])) { $_REQUEST['isminor'] = 'on'; $_REQUEST['save'] = true; } // We set empty wiki page name as default here if not set (before including Tiki modules) - if ($prefs['feature_warn_on_edit'] == 'y') { $editpageconflict = 'n'; $beingEdited = 'n'; @@ -126,7 +113,6 @@ die; } } - $category_needed = false; $contribution_needed = false; if (isset($_REQUEST['lock_it']) && $_REQUEST['lock_it'] =='on') { @@ -142,59 +128,46 @@ if (!empty($_REQUEST['contributors'])) { $hash['contributors'] = $_REQUEST['contributors']; } - if (isset($_FILES['userfile1']) && is_uploaded_file($_FILES['userfile1']['tmp_name'])) { check_ticket('edit-page'); require ("lib/mail/mimelib.php"); - $fp = fopen($_FILES['userfile1']['tmp_name'], "rb"); $data = ''; - while (!feof($fp)) { $data .= fread($fp, 8192 * 16); } - fclose ($fp); $name = $_FILES['userfile1']['name']; - $output = mime::decode($data); $parts = array(); parse_output($output, $parts, 0); $last_part = ''; $last_part_ver = 0; usort($parts, 'compare_import_versions'); - foreach ($parts as $part) { if ($part["version"] > $last_part_ver) { $last_part_ver = $part["version"]; $last_part = $part["body"]; } - if (isset($part["pagename"])) { $pagename = urldecode($part["pagename"]); - $version = urldecode($part["version"]); $author = urldecode($part["author"]); $lastmodified = $part["lastmodified"]; - if (isset($part["description"])) { $description = $part["description"]; } else { $description = ''; } $pageLang = isset($part["lang"])? $part["lang"]: ""; - $authorid = urldecode($part["author_id"]); - if (isset($part["hits"])) $hits = urldecode($part["hits"]); else $hits = 0; - $ex = substr($part["body"], 0, 25); //print(strlen($part["body"])); $msg = ''; - if (isset($_REQUEST['save']) && $prefs['feature_contribution'] == 'y' && $prefs['feature_contribution_mandatory'] == 'y' && (empty($_REQUEST['contributions']) || count($_REQUEST['contributions']) <= 0)) { $contribution_needed = true; $smarty->assign('contribution_needed', 'y'); @@ -233,7 +206,6 @@ } } } - if (isset($_REQUEST["save"])) { unset ($_REQUEST["save"]); if ($page_ref_id) { @@ -246,17 +218,14 @@ } $smarty->assign('category_needed',$category_needed); $smarty->assign('contribution_needed',$contribution_needed); - $wiki_up = "img/wiki_up"; if ($tikidomain) { $wiki_up.= "/$tikidomain"; } // Upload pictures here - if (($prefs['feature_wiki_pictures'] == 'y') && (isset($tiki_p_upload_picture)) && ($tiki_p_upload_picture == 'y')) { $i = 1; while ( isset($_FILES['picfile'.$i]) ) { if ( is_uploaded_file($_FILES['picfile'.$i]['tmp_name']) ) { $picname = $_FILES['picfile'.$i]['name']; - if ( preg_match('/\.(gif|png|jpe?g)$/i',$picname) ) { move_uploaded_file($_FILES['picfile'.$i]['tmp_name'], "$wiki_up/$picname"); chmod("$wiki_up/$picname", 0644); // seems necessary on some system (see move_uploaded_file doc on php.net) @@ -265,7 +234,6 @@ $i++; } } - if ($prefs['feature_wiki_attachments'] == 'y' && isset($_REQUEST["attach"]) && ($tiki_p_wiki_attach_files == 'y' || $tiki_p_wiki_admin_attachments == 'y')) { if (isset($_FILES['userfile2']) && is_uploaded_file($_FILES['userfile2']['tmp_name'])) { $ret = $tikilib->attach_file($_FILES['userfile2']['name'], $_FILES['userfile2']['tmp_name'], $prefs['w_use_db'] == 'y'? 'db': 'dir'); @@ -278,8 +246,6 @@ } } } - - /** * \brief Parsed HTML tree walker (used by HTML sucker) * @@ -300,7 +266,6 @@ { return; } - for ($i=0; $i <= $c["contentpos"]; $i++) { // If content type 'text' output it to destination... @@ -328,7 +293,6 @@ case "meta": $c[$i]["content"] = ''; break; - case "br": $src .= '%%%'; break; case "title": $src .= "\n!"; $p['stack'][] = array('tag' => 'title', 'string' => "\n"); break; case "p": $src .= "\n"; $p['stack'][] = array('tag' => 'p', 'string' => "\n"); break; @@ -396,7 +360,6 @@ } $p['stack'][] = array('tag' => 'a', 'string' => ']'); } - if( isset($c[$i]["pars"]["name"]["value"]) ) { $src .= '{ANAME()}'.$c[$i]["pars"]["name"]["value"].'{ANAME}'; @@ -476,7 +439,6 @@ // Should I try to convert HTML to wiki? $parseddata = ''; $p = array('stack' => array(), 'listack' => array(), 'first_td' => false); - $head_url = preg_replace( ';[^/]*$;', '', $_REQUEST["suck_url"] ); walk_and_parse( $htmlparser->content, $parseddata, $p, $head_url ); // Is some tags still opened? (It can be if HTML not valid, but this is not reason @@ -488,7 +450,6 @@ array_pop($p['stack']); } // Unclosed lists r ignored... wiki have no special start/end lists syntax.... - // OK. Things remains to do: // 1) fix linked images $parseddata = preg_replace(',\[(.*)\|\(img src=(.*)\)\],mU','{img src=$2 link=$1}', $parseddata); @@ -506,24 +467,20 @@ $page .= $user; $_REQUEST['page'] = $page; } - if (strtolower($_REQUEST["page"]) == 'sandbox' && $prefs['feature_sandbox'] != 'y') { $smarty->assign('msg', tra("The SandBox is disabled")); $smarty->display("error.tpl"); die; } - if (!isset($_REQUEST["comment"])) { $_REQUEST["comment"] = ''; } - // Get page data $info = $tikilib->get_page_info($page); if(isset($info['wiki_cache'])) { $prefs['wiki_cache'] = $info['wiki_cache']; $smarty->assign('wiki_cache',$prefs['wiki_cache']); } - if ($info["flag"] == 'L' && !$wikilib->is_editable($page, $user, $info)) { $smarty->assign('msg', tra("Cannot edit page because it is locked")); $smarty->display("error.tpl"); @@ -532,7 +489,6 @@ $smarty->assign('editable','y'); $smarty->assign('show_page','n'); $smarty->assign('comments_show','n'); - // Permissions $tikilib->get_perm_object($page, 'wiki page', $info, true); if ($tiki_p_edit != 'y') { @@ -540,34 +496,24 @@ $smarty->display("error.tpl"); die; } - // wysiwyg decision include 'tiki-parsemode_setup.php'; - $smarty->assign_by_ref('data', $info); - $smarty->assign('footnote', ''); $smarty->assign('has_footnote', 'n'); - if ($prefs['feature_wiki_footnotes'] == 'y') { if ($user) { $x = $wikilib->get_footnote($user, $page); - $footnote = $wikilib->get_footnote($user, $page); $smarty->assign('footnote', $footnote); - if ($footnote) $smarty->assign('has_footnote', 'y'); - $smarty->assign('parsed_footnote', $tikilib->parse_data($footnote)); - if (isset($_REQUEST['footnote'])) { check_ticket('edit-page'); $smarty->assign('parsed_footnote', $tikilib->parse_data($_REQUEST['footnote'])); - $smarty->assign('footnote', $_REQUEST['footnote']); $smarty->assign('has_footnote', 'y'); - if (empty($_REQUEST['footnote'])) { $wikilib->remove_footnote($user, $page); } else { @@ -576,14 +522,12 @@ } } } - if (isset($_REQUEST["templateId"]) && $_REQUEST["templateId"] > 0 && !isset($_REQUEST['preview']) && !isset($_REQUEST['save'])) { $template_data = $tikilib->get_template($_REQUEST["templateId"]); $_REQUEST["edit"] = $template_data["content"]."\n".$_REQUEST["edit"]; $_REQUEST["preview"] = 1; $smarty->assign("templateId", $_REQUEST["templateId"]); } - if (isset($_REQUEST["categId"]) && $_REQUEST["categId"] > 0) { $categs = split("\+",$_REQUEST["categId"]); $smarty->assign('categIds',$categs); @@ -611,7 +555,6 @@ $edit_data = htmlspecialchars($edit_data); } } - $likepages = ''; $smarty->assign_by_ref('likepages', $likepages); if ($prefs['feature_likePages'] == 'y' and $edit_data == '' && !$tikilib->page_exists($page)) { @@ -622,16 +565,13 @@ if (isset($_REQUEST['copyrightTitle'])) { $smarty->assign('copyrightTitle', $_REQUEST["copyrightTitle"]); } - if (isset($_REQUEST['copyrightYear'])) { $smarty->assign('copyrightYear', $_REQUEST["copyrightYear"]); } - if (isset($_REQUEST['copyrightAuthors'])) { $smarty->assign('copyrightAuthors', $_REQUEST["copyrightAuthors"]); } } - if (isset($_REQUEST["comment"])) { $smarty->assign_by_ref('commentdata', $_REQUEST["comment"]); } elseif (isset($info['draft'])) { @@ -639,18 +579,14 @@ } else { $smarty->assign('commentdata', ''); } - if (isset($info["description"])) { if (isset($info['draft'])) { $info['description'] = $info['draft']['description']; } $smarty->assign('description', $info["description"]); - $description = $info["description"]; - } else { $smarty->assign('description', ''); - $description = ''; } if(isset($_REQUEST["description"])) { @@ -666,7 +602,6 @@ $lock_it = 'y'; } $smarty->assign_by_ref('lock_it', $lock_it); - if (isset($_REQUEST["lang"])) { if ($prefs['feature_multilingual'] == 'y' && isset($info["lang"]) && $info['lang'] != $_REQUEST["lang"]) { include_once("lib/multilingual/multilinguallib.php"); @@ -684,7 +619,6 @@ $pageLang = ""; } $smarty->assign('lang', $pageLang); - if ( ! isset($_REQUEST['edit']) && ! $is_html ) { // When we get data from database (i.e. we are not in preview mode) and if we don't allow HTML, // then we need to convert database's HTML entities into their "normal chars" equivalents @@ -692,7 +626,6 @@ } else { $smarty->assign('pagedata', $edit_data); } - if ( isset($_REQUEST['edit']) && ! $is_html ) { // When we are in preview mode (i.e. data doesn't come from database) and if we don't allow HTML, // then we need to convert HTML special chars into their HTML entities equivalent; @@ -700,7 +633,6 @@ } else { $parsed = $edit_data; } - // apply the optional post edit filters before preview if(isset($_REQUEST["preview"]) || ($prefs['wiki_spellcheck'] == 'y' && isset($_REQUEST["spellcheck"]) && $_REQUEST["spellcheck"] == 'on')) { $parsed = $tikilib->apply_postedit_handlers($parsed); @@ -708,28 +640,22 @@ } else { $parsed = ""; } - /* SPELLCHECKING INITIAL ATTEMPT */ //This nice function does all the job! if ($prefs['wiki_spellcheck'] == 'y') { if (isset($_REQUEST["spellcheck"]) && $_REQUEST["spellcheck"] == 'on') { $parsed = $tikilib->spellcheckreplace($edit_data, $parsed, $prefs['language'], 'editwiki'); - $smarty->assign('spellcheck', 'y'); } else { $smarty->assign('spellcheck', 'n'); } } - $smarty->assign_by_ref('parsed', $parsed); - - $smarty->assign('preview',0); // If we are in preview mode then preview it! if(isset($_REQUEST["preview"])) { $smarty->assign('preview',1); } - function htmldecode($string) { if ( version_compare(phpversion(), '5', '>=') ) { // Use html_entity_decode with UTF-8 only with PHP5 or later, since @@ -746,8 +672,6 @@ return $string; } } - - function parse_output(&$obj, &$parts,$i) { if(!empty($obj['parts'])) { for($i=0; $i<count($obj['parts']); $i++) @@ -764,21 +688,15 @@ $aux[trim($portions[0])]=trim($portions[1]); } } - - $parts[]=$aux; - } } } - // Pro // Check if the page has changed - $pageAlias = ''; $cat_type='wiki page'; $cat_objid = $_REQUEST["page"]; - if (isset($_REQUEST['save']) && $prefs['feature_contribution'] == 'y' && $prefs['feature_contribution_mandatory'] == 'y' && (empty($_REQUEST['contributions']) || count($_REQUEST['contributions']) <= 0)) { $contribution_needed = true; $smarty->assign('contribution_needed', 'y'); @@ -799,7 +717,6 @@ if(!isset($_REQUEST["description"])) $_REQUEST["description"]=''; if(!isset($_REQUEST["comment"])) $_REQUEST["comment"]=''; if(!isset($_REQUEST["lang"])) $_REQUEST["lang"]=''; - if(isset($_REQUEST['wiki_cache'])) { $wikilib->set_page_cache($_REQUEST['page'],$_REQUEST['wiki_cache']); } @@ -810,15 +727,12 @@ include_once("categorize.php"); include_once("poll_categorize.php"); include_once("freetag_apply.php"); - $page = $_REQUEST["page"]; - if($is_html) { $edit = $_REQUEST["edit"]; } else { $edit = htmlspecialchars($_REQUEST['edit']); } - // add permisions here otherwise return error! if(isset($prefs['wiki_feature_copyrights']) && $prefs['wiki_feature_copyrights'] == 'y' && isset($_REQUEST['copyrightTitle']) @@ -834,17 +748,13 @@ $copyrightAuthors = $_REQUEST['copyrightAuthors']; $copyrightslib->add_copyright($page,$copyrightTitle,$copyrightYear,$copyrightAuthors,$user); } - // Parse $edit and eliminate image references to external URIs (make them internal) $edit = $imagegallib->capture_images($edit); - // apply the optional page edit filters before data storage $edit = $tikilib->apply_postedit_handlers($edit); - // If page exists if(!$tikilib->page_exists($_REQUEST["page"])) { // Extract links and update the page - $links = $tikilib->get_links($_REQUEST["edit"]); /* $notcachedlinks = $tikilib->get_links_nocache($_REQUEST["edit"]); @@ -867,7 +777,6 @@ } $tikilib->update_page($_REQUEST["page"],$edit,$_REQUEST["comment"],$user,$_SERVER["REMOTE_ADDR"],$description,$minor,$pageLang, $is_html, $hash); } - //Page may have been inserted from a structure page view if (isset($_REQUEST['current_page_id']) ) { $page_info = $structlib->s_get_page_info($_REQUEST['current_page_id']); @@ -902,12 +811,10 @@ die; } //save $smarty->assign('pageAlias',$pageAlias); - if ($prefs['feature_wiki_templates'] == 'y' && $tiki_p_use_content_templates == 'y') { $templates = $tikilib->list_templates('wiki', 0, -1, 'name_asc', ''); $smarty->assign_by_ref('templates', $templates["data"]); } - if ($prefs['feature_polls'] =='y' and $prefs['feature_wiki_ratings'] == 'y' && $tiki_p_wiki_admin_ratings == 'y') { function pollnameclean($s) { global $page; if (isset($s['title'])) $s['title'] = substr($s['title'],strlen($page)+2); return $s; } if (!isset($polllib) or !is_object($polllib)) include("lib/polls/polllib_shared.php"); @@ -936,18 +843,15 @@ */ $smarty->assign('listpolls',$listpolls['data']); } - if ($prefs['feature_multilingual'] == 'y') { $languages = array(); $languages = $tikilib->list_languages(); $smarty->assign_by_ref('languages', $languages); } - $cat_type = 'wiki page'; $cat_objid = $_REQUEST["page"]; $smarty->assign('section',$section); include_once ('tiki-section_options.php'); - if ($prefs['feature_freetags'] == 'y') { include_once ("freetag_list.php"); //If in preview mode get the tags from the form and not from database @@ -962,7 +866,6 @@ $categIds = $categlib->get_object_categories('wiki page', $structure_info["pageName"]); $smarty->assign('categIds',$categIds); } - if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'tiki-index.php') && !$tikilib->page_exists($_REQUEST["page"])) { // default the categs the page you come from for a new page if (preg_match('/page=([^\&]+)/', $_SERVER['HTTP_REFERER'], $ms)) $p = $ms[1]; @@ -975,29 +878,23 @@ } } } - $plugins = $wikilib->list_plugins(true); $smarty->assign_by_ref('plugins', $plugins); - $smarty->assign('showstructs', array()); - if ($structlib->page_is_in_structure($_REQUEST["page"])) { $structs = $structlib->get_page_structures($_REQUEST["page"]); } - // Flag for 'page bar' that currently 'Edit' mode active // so no need to show comments & attachments, but need // to show 'wiki quick help' $smarty->assign('edit_page', 'y'); $smarty->assign('categ_checked', 'n'); - // Set variables so the preview page will keep the newly inputted category information if (isset($_REQUEST['cat_categorize'])) { if ($_REQUEST['cat_categorize'] == 'on') { $smarty->assign('categ_checked', 'y'); } } - if ($prefs['wiki_feature_copyrights'] == 'y' && $tiki_p_edit_copyrights == 'y') { include_once ('lib/copyrights/copyrightslib.php'); $copyrightslib = new CopyrightsLib($dbTiki); @@ -1005,14 +902,11 @@ if ($copyrights['cant']) $smarty->assign_by_ref('copyrights', $copyrights['data']); } - include_once("textareasize.php"); - include_once ('lib/quicktags/quicktagslib.php'); $quicktags = $quicktagslib->list_quicktags(0,-1,'taglabel_desc','','wiki'); $smarty->assign_by_ref('quicktags', $quicktags["data"]); $smarty->assign('quicktagscant', $quicktags["cant"]); - if (!$user or $user == 'anonymous') { $smarty->assign('anon_user', 'y'); } @@ -1020,19 +914,14 @@ include_once('contribution.php'); } ask_ticket('edit-page'); - $ajaxlib->registerTemplate('tiki-editpage.tpl'); $ajaxlib->processRequests(); - - // disallow robots to index page: $smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW'); - // Display the Index Template $smarty->assign('mid', 'tiki-editpage.tpl'); $smarty->assign('showtags', 'n'); $smarty->assign('qtnum', '1'); $smarty->assign('qtcycle', ''); $smarty->display("tiki.tpl"); - ?> |