} exit; } /****************************************************************************** * Save ******************************************************************************/ if ($_REQUEST[save] && ($cfg['disable_edit_content'] != TRUE || $_SESSION['ltype'] == 'admin')) { if (!$error) { // save it to the database print "<br /><br />" . $_SESSION[settings][sitename] . "<br /><br />"; /****************************************************************************** * replace media library urls with $mediapath/$sitename/filename * replace specific url with general url ******************************************************************************/ $mod_header = convertInteralLinksToTags($_SESSION[settings][sitename], $_SESSION[siteObj]->getField("header")); $mod_footer = convertInteralLinksToTags($_SESSION[settings][sitename], $_SESSION[siteObj]->getField("footer")); // Lets pass the cleaning of editor text off to the editor. $mod_header = cleanEditorText($mod_header); $mod_footer = cleanEditorText($mod_footer); $_SESSION[siteObj]->setField("header", $mod_header); $_SESSION[siteObj]->setField("footer", $mod_footer); if ($_SESSION[settings][add]) { $_SESSION[siteObj]->insertDB(); log_entry("add_site", "{$_SESSION['auser']} added " . $_SESSION[siteObj]->name, $_SESSION[siteObj]->name, $_SESSION[siteObj]->id, "site"); } if ($_SESSION[settings][edit]) { $_SESSION[siteObj]->updateDB(1); log_entry("edit_site", "{$_SESSION['auser']} edited " . $_SESSION[siteObj]->name, $_SESSION[siteObj]->name, $_SESSION[siteObj]->id, "site"); } /* ----------------------------------------------------- */ /* will have to update this to use object-related site copy functions */
function _commithttpdata() { global $sid, $error, $_full_uri; global $mailposts, $cfg; //require_once("htmleditor/editor.inc.php"); if ($_REQUEST['commit'] && ($cfg['disable_discussion'] != TRUE || $_SESSION['ltype'] == 'admin')) { // indeed, we are supposed to commit $site = $_REQUEST['site']; $action = $_REQUEST['action']; $a = $_REQUEST['discuss']; if (!$_REQUEST['subject']) { error("You must enter a subject.\n"); } if (!$_REQUEST['content']) { error("You must enter some text to post.\n"); } if (isset($_REQUEST['rating']) && !is_numeric($_REQUEST['rating']) && $_REQUEST['rating'] != "") { $error = "Post rating must be numeric.\n"; } if ($error) { unset($_REQUEST['commit']); return false; } /****************************************************************************** * if public discussion and no log in then add user to user table * uname = email address, type = visitor ******************************************************************************/ if (!$_SESSION[auser]) { if (user::userEmailExists($_REQUEST['visitor_email'])) { error("A user with that email address already exists. Please log in before posting."); } /****************************************************************************** * Visitor account validation: * check that a name has been entered * check that the email enter doesn't already exist in Segue and * is not part of the $cfg[visitor_email_excludes] specified in the config ******************************************************************************/ if (!$_REQUEST['visitor_name']) { error("You must enter a username."); } if (!$_REQUEST['visitor_email'] || !ereg("@", $_REQUEST['visitor_email'])) { error("You must enter a valid email address."); } else { if ($_REQUEST['visitor_email']) { foreach ($cfg[visitor_email_excludes] as $visitor_email_exclude) { if ($exclude = ereg($visitor_email_exclude, $_REQUEST['visitor_email'])) { error("Please log in above with your {$cfg['inst_name']} account."); } } } } // all good if (!$error) { $obj =& new user(); $obj->uname = $_REQUEST['visitor_email']; $obj->fname = $_REQUEST['visitor_name']; $obj->email = $_REQUEST['visitor_email']; $obj->type = "visitor"; $obj->authtype = 'db'; $obj->randpass(5, 3); $obj->insertDB(); $obj->sendemail(); $visitor_id = lastid(); } } if ($error) { unset($_REQUEST['commit']); return false; } if ($a == 'edit') { $d =& new discussion($_REQUEST['story']); $d->fetchID($_REQUEST['id']); if ($_SESSION['auser'] != $d->authoruname) { return false; } $d->subject = $_REQUEST['subject']; $d->content = cleanEditorText($_REQUEST['content']); $d->content = convertInteralLinksToTags($site, $d->content); $d->update(); //log_entry("discussion","$_SESSION[auser] edited story ".$_REQUEST['story']." discussion post id ".$_REQUEST['id']." in site ".$_REQUEST['site'],$_REQUEST['site'],$_REQUEST['story'],"story"); unset($_REQUEST['discuss'], $_REQUEST['commit']); //unset($d); } if ($a == 'rate') { $d =& new discussion($_REQUEST['story']); $d->fetchID($_REQUEST['id']); $d->rating = $_REQUEST['rating']; $d->update(); //log_entry("discussion","$_SESSION[auser] edited story ".$_REQUEST['story']." discussion post id ".$_REQUEST['id']." in site ".$_REQUEST['site'],$_REQUEST['site'],$_REQUEST['story'],"story"); unset($_REQUEST['discuss'], $_REQUEST['commit']); // unset($d); } if ($a == 'reply' || $a == 'newpost') { $d =& new discussion($_REQUEST['story']); $d->subject = $_REQUEST['subject']; // Lets pass the cleaning of editor text off to the editor. $d->content = cleanEditorText($_REQUEST['content']); $d->content = convertInteralLinksToTags($site, $d->content); if ($a == 'reply') { $d->parentid = $_REQUEST['replyto']; //log_entry("discussion","$_SESSION[auser] replied to story ".$_REQUEST['story']." discussion post id ".$_REQUEST['replyto']." in site ".$_REQUEST['site'],$_REQUEST['site'],$_REQUEST['story'],"story"); } else { //log_entry("discussion","$_SESSION[auser] posted to story ".$_REQUEST['story']." discussion in site ".$_REQUEST['site'],$_REQUEST['site'],$_REQUEST['story'],"story"); } $d->authorid = $_SESSION['aid'] ? $_SESSION['aid'] : $visitor_id; $d->authorfname = $_SESSION['afname'] ? $_SESSION['afname'] : $_REQUEST['visitor_name']; $d->libraryfileid = $_REQUEST['libraryfileid']; $newid = $d->insert(); } /****************************************************************************** * gather data for sendmail function ******************************************************************************/ if ($mailposts == 1) { //printpre("email sending..."); $this->sendemail($newid); } unset($_REQUEST['discuss'], $_REQUEST['commit']); } }
/** * Answer an element that represents a version of a story. * * @param array $version * @param string $storyType One of link, rss, file, image, text * @param optional string $textType text or html * @return DOMITElement * @access protected * @since 3/24/08 */ function getVersion($version, $storyType, $textType = 'html', $obj = null) { $element = $this->_document->createElement('version'); $element->setAttribute('id', $version['version_id']); $element->setAttribute('number', $version['version_order']); $element->setAttribute('time_stamp', $version['create_time_stamp']); $element->setAttribute('agent_id', $version['author_uname']); $commentElement = $element->appendChild($this->_document->createElement('comment')); $commentElement->appendChild($this->_document->createCDATASection($version['version_comments'])); switch ($storyType) { case 'link': $field1 = 'description'; $field2 = 'url'; $value1 = urldecode($version['version_text_short']); $value2 = urldecode($version['version_text_long']); break; case 'rss': // RSS url info is not in the version, so just return it empty return $element; case 'file': case 'image': $field1 = 'description'; $field2 = 'filename'; $value1 = urldecode($version['version_text_short']); $filename = addslashes(urldecode(db_get_value("media", "media_tag", "media_id='" . addslashes(urldecode($version['version_text_long'])) . "'"))); $value2 = htmlspecialchars($filename); break; default: $field1 = 'shorttext'; $field2 = 'longertext'; $value1 = stripslashes(convertInteralLinksToTags($obj->owning_site, urldecode($version['version_text_short']))); $value2 = stripslashes(convertInteralLinksToTags($obj->owning_site, urldecode($version['version_text_long']))); } $shortText = $element->appendChild($this->_document->createElement($field1)); $shortText->appendChild($this->_document->createCDATASection($value1)); $shortText->setAttribute('text_type', $textType); $shortText = $element->appendChild($this->_document->createElement($field2)); $shortText->appendChild($this->_document->createCDATASection($value2)); $shortText->setAttribute('text_type', $textType); return $element; }
/** * Convert the link in the passed string to the new ids from the global site hash. * * @param string $oldSitename The name of the old site to search for. * @param array $patterns The indexed array of patterns to send to preg_replace. * @param array $replacements The indexed array of replacements to send to preg_replace. * @param string $text The text to search for links. * @return string The text with the links converted. * @access public * @date 9/16/04 */ function updateLinksToNewSite($oldSitename, $patterns, $replacements, $text) { // First, lets make sure that all the links were converted to tags. // This should get rid of any references to our site. $text = convertInteralLinksToTags($oldSitename, $text); // Replace the link ids. $text = preg_replace($patterns, $replacements, $text); return $text; }
/** * Adds a story to the buffer. * * @param object story $story The story to add. * @param integer $indent The indent level of the object */ function addStory(&$story, &$pageElement) { $storyElement =& $this->_document->createElement('story'); $pageElement->appendChild($storyElement); $this->addCommonProporties($story, $storyElement); if ($story->getField('texttype') == "text") { $texttype = "text"; } else { $texttype = "html"; } if ($story->getField('shorttext')) { $shorttext =& $this->_document->createElement('shorttext'); $storyElement->appendChild($shorttext); $shorttext->appendChild($this->_document->createTextNode(htmlspecialchars(convertInteralLinksToTags($story->owning_site, $story->getField('shorttext'))))); $shorttext->setAttribute('text_type', $texttype); } if ($story->getField('longertext')) { $longertext =& $this->_document->createElement('longertext'); $storyElement->appendChild($longertext); $longertext->appendChild($this->_document->createTextNode(htmlspecialchars(convertInteralLinksToTags($story->owning_site, $story->getField('longertext'))))); $longertext->setAttribute('text_type', $texttype); } $this->addStoryProporties($story, $storyElement); }
if ($_SESSION[pageObj]->getField("type") == 'link') { $url = convertInteralLinksToTags($_SESSION[settings][site], $_REQUEST[url]); // save general internal_linkpath to object $_SESSION[pageObj]->setField("url", $url); } else { if ($_SESSION[pageObj]->getField("type") == 'content') { $page_title = $_SESSION[pageObj]->getField("title"); $content = $_SESSION[pageObj]->getField("text"); // $content = convertWikiMarkupToLinks($_SESSION[settings][site],$_SESSION[settings][section],$_SESSION[pageObj]->id, $page_title, $content); // $content = recordInternalLinks ($_SESSION[settings][site],$_SESSION[settings][section],$_SESSION[pageObj]->id, $page_title, $content); $content = convertInteralLinksToTags($_SESSION[settings][site], $content); // save general internal_linkpath to object $_SESSION[pageObj]->setField("text", $content); } else { if ($_SESSION[pageObj]->getField("type") == 'rss') { $url = convertInteralLinksToTags($_SESSION[settings][site], $_REQUEST[url]); $_SESSION[pageObj]->setField("url", $url); } } } /****************************************************************************** * Save: calls insertDB and updateDB functions ******************************************************************************/ if ($_SESSION[settings][edit]) { $_SESSION[pageObj]->updateDB(); log_entry("edit_page", "{$_SESSION['auser']} edited page id " . $_SESSION[pageObj]->id . " in site " . $_SESSION[pageObj]->owning_site . ", section " . $_SESSION[pageObj]->owning_section, $_SESSION[pageObj]->owning_site, $_SESSION[pageObj]->id, "page"); // $query = "update pages set editedby='$_SESSION['auser']',"; $where = " where id=$_SESSION[settings][page]"; // printpre($_REQUEST[location]); // exit(); } if ($_SESSION[settings][add]) {
} /****************************************************************************** * replace media library urls with $mediapath/$sitename/filename * replace specific url with general url ($linkpath) ******************************************************************************/ if ($_SESSION[storyObj]->getField("type") == "link") { $url = $_SESSION[storyObj]->getField("url"); $url = convertInteralLinksToTags($_SESSION[settings][site], $url); // save general mediapath and internal_linkpath to object $_SESSION[storyObj]->setField("url", $url); } // Lets pass the cleaning of editor text off to the editor. $texttype = $_SESSION[storyObj]->getField("texttype"); $text = $_SESSION[storyObj]->getField("longertext"); // $text = convertWikiMarkupToLinks($_SESSION[settings][site],$_SESSION[settings][section],$_SESSION[settings][page], $page_title, $text); $text = convertInteralLinksToTags($_SESSION[settings][site], $text); $text = cleanEditorText($text, $texttype); $_SESSION[storyObj]->setField("longertext", $text); // check make sure the owner is the current user if they are changing permissions /* if ($site_owner != $_SESSION[auser]) { */ /* if ($_SESSION[settings][edit]) $_SESSION[storyObj]->buildPermissionsArray(); */ /* else $_SESSION[storyObj]->setPermissions($thisPage->getPermissions()); */ /* } */ /****************************************************************************** * Save: calls insertDB and updateDB functions ******************************************************************************/ if ($_SESSION[settings][add]) { $_SESSION[storyObj]->insertDB(); log_entry("add_story", "{$_SESSION['auser']} added content id " . $_SESSION[storyObj]->id . " in site " . $_SESSION[storyObj]->owning_site . ", section " . $_SESSION[storyObj]->owning_section . ", page " . $_SESSION[storyObj]->owning_page, $_SESSION[storyObj]->owning_site, $_SESSION[storyObj]->id, "story"); } if ($_SESSION[settings][edit]) {
//printpre ($_SESSION); //exit(); // error checking if ($_SESSION[sectionObj]->getField("type") == 'section' && (!$_SESSION[sectionObj]->getField("title") || $_SESSION[sectionObj]->getField("title") == '')) { error("You must enter a section title."); } if ($_SESSION[sectionObj]->getField("type") == 'link' && (!$_SESSION[sectionObj]->getField("url") || $_SESSION[sectionObj]->getField("url") == '' || $_SESSION[sectionObj]->getField("url") == 'http://')) { error("You must enter a URL."); } if (!$error) { // save it to the database /****************************************************************************** * Link section types: replace specific url with general url ($linkpath) ******************************************************************************/ if ($_SESSION[sectionObj]->getField("type") == 'link') { $_SESSION[sectionObj]->setField("url", convertInteralLinksToTags($_SESSION[settings][site], $_SESSION[sectionObj]->getField("url"))); } // add the new section id to the sites table if ($_SESSION[settings][add]) { $_SESSION[sectionObj]->setPermissions($thisSite->getPermissions()); $_SESSION[sectionObj]->insertDB(); log_entry("add_section", "{$_SESSION['auser']} added section id " . $_SESSION[sectionObj]->id . " in site " . $_SESSION[sectionObj]->owning_site, $_SESSION[sectionObj]->owning_site, $_SESSION[sectionObj]->id, "section"); // convertAddNodeLinks($_SESSION[sectionObj]->owning_site, $_SESSION[sectionObj]->id, $_SESSION[settings][source_story], $_SESSION[settings][source_title], $page=0, $story=0); } if ($_SESSION[settings][edit]) { $_SESSION[sectionObj]->updateDB(); log_entry("edit_section", "{$_SESSION['auser']} edited section id " . $_SESSION[sectionObj]->id . " in site " . $_SESSION[sectionObj]->owning_site, $_SESSION[sectionObj]->owning_site, $_SESSION[sectionObj]->id, "section"); } header("Location: index.php?{$sid}&action=viewsite&site=" . $_SESSION[sectionObj]->owning_site . ($_SESSION[sectionObj]->getField("type") == 'section' ? "§ion=" . $_SESSION[sectionObj]->id : "")); exit; } else {