private static function goToPhraseExistence($phrase, $page, $version) { session_start(); if (!empty($phrase)) { $_SESSION['phrase'] = $phrase; } //prep for redirect if it happens; if (!empty($phrase)) { Feed_ForwardLink_Search::goToNewestWikiRevision($version, $phrase, $page); } if (!empty($_SESSION['phrase'])) { //recover from redirect if it happened $phrase = $_SESSION['phrase']; unset($_SESSION['phrase']); } }
static function wikiView() { global $page, $headerlib; $me = new self(); $phrase = !empty($_REQUEST['phrase']) ? $_REQUEST['phrase'] : ''; Feed_ForwardLink_Search::restoreTextLinkPhrasesInWikiPage($me->getItems(), $phrase); //if we have an awaiting textlink that needs sent, we do so here $result = Tracker_Query::tracker('Wiki Attributes')->byName()->render(false)->filterFieldByValue('Page', $page)->filterFieldByValue('Type', 'TextLink Send')->query(); if (count($result) > 0) { foreach (Feed_ForwardLink_Send::sendAll() as $text => $received) { $receivedJSON = json_decode($received); if (isset($receivedJSON->feed) && $receivedJSON->feed == 'success') { Tracker_Query::tracker('Wiki Attributes')->byName()->render(false)->filterFieldByValue('Page', $page)->filterFieldByValue('Type', 'TextLink Send')->filterFieldByValue('Attribute', $text)->delete(true); $headerlib->add_jq_onready("\$.notify('" . tr("TextLink and ForwardLink created...") . "');"); } } } }
function appendToContents(&$contents, $item) { global $prefs, $_REQUEST; if ($this->debug == true) { ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); } $this->itemsAdded = false; foreach ($item->feed->entry as $i => $newEntry) { $this->verifications[$i] = array(); $this->verifications[$i]["reason"] = array(); //lets remove the new entry if it has already been accepted in the past foreach ($contents->entry as &$existingEntry) { if ($existingEntry->textlink->text == $newEntry->textlink->text && $existingEntry->textlink->href == $newEntry->textlink->href) { $this->verifications[$i]['reason'][] = 'exists'; unset($item->feed->entry[$i]); } } $revision = Feed_ForwardLink_Search::findWikiRevision($newEntry->forwardlink->text); $this->verifications[$i]["hashBy"] = JisonParser_Phraser_Handler::superSanitize($newEntry->forwardlink->author . $newEntry->forwardlink->authorInstitution . $newEntry->forwardlink->authorProfession); $this->verifications[$i]['foundRevision'] = $revision; $this->verifications[$i]["metadataHere"] = $this->metadata->raw; $this->verifications[$i]["phraseThere"] = JisonParser_Phraser_Handler::superSanitize($newEntry->forwardlink->text); $this->verifications[$i]["hashHere"] = hash_hmac("md5", $this->verifications[$i]["hashBy"], $this->verifications[$i]["phraseThere"]); $this->verifications[$i]["hashThere"] = $newEntry->forwardlink->hash; $this->verifications[$i]['exists'] = JisonParser_Phraser_Handler::hasPhrase($revision['data'], $this->verifications[$i]["phraseThere"]); if ($this->verifications[$i]['hashHere'] != $this->verifications[$i]['hashThere']) { $this->verifications[$i]['reason'][] = 'hash_tampering'; unset($item->feed->entry[$i]); } if ($newEntry->forwardlink->websiteTitle != $prefs['browsertitle']) { $this->verifications[$i]['reason'][] = 'title'; unset($item->feed->entry[$i]); } if ($this->verifications[$i]['exists'] == false) { if (empty($this->verifications[$i]['reason'])) { $this->verifications[$i]['reason'][] = 'no_existence_hash_pass'; } else { $this->verifications[$i]['reason'][] = 'no_existence'; } unset($item->feed->entry[$i]); } foreach ($newEntry->forwardlink as $key => $value) { if (isset(Feed_ForwardLink_Metadata::$acceptableKeys[$key]) && Feed_ForwardLink_Metadata::$acceptableKeys[$key] == true) { //all clear } else { $this->verifications[$i]['reason'][] = 'metadata_tampering' . ($this->debug == true ? $key : ''); unset($item->feed->entry[$i]); } } foreach ($newEntry->textlink as $key => $value) { if (isset(Feed_ForwardLink_Metadata::$acceptableKeys[$key]) && Feed_ForwardLink_Metadata::$acceptableKeys[$key] == true) { //all clear } else { $this->verifications[$i]['reason'][] = 'metadata_tampering' . ($this->debug == true ? $key : ''); unset($item->feed->entry[$i]); } } } if (empty($item->feed->entry) == false) { $this->itemsAdded = true; foreach ($item->feed->entry as &$entry) { Tracker_Query::tracker('Wiki Attributes')->byName()->replaceItem(array('Page' => $this->page, 'Attribute' => '', 'Value' => $entry->forwardlink->text, 'Type' => 'ForwardLink Accepted')); } if (empty($contents->entry) == true) { $contents->entry = array(); } $contents->entry = array_merge($contents->entry, $item->feed->entry); } }