Nextrek
@ 1349
Nextrek / legal-map / ajax / openDiff.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
<?php $pathArticoli = dirname(__FILE__).'/../articoli/'; $originalFile = $pathArticoli.$_REQUEST['original']; $changedFile = $pathArticoli.$_REQUEST['changed']; function loadArticleAsString($originalFile) { $html = file_get_contents($originalFile); $html = str_replace("\r\n","\n", $html); $html = str_replace("\n\n","\n", $html); $html = str_replace("\n"," ", $html); $html = str_replace('<br>',"\n", $html); $html = str_replace('</p>',"</p>\n", $html); $html = str_replace('<p',"\n<p", $html); $html = str_replace(" \n","\n", $html); $bodyPos = strpos($html, '<body'); $bodyPos = strpos($html, '>', $bodyPos) + 1; $endBody = strpos($html, '</body>'); $result = substr($html, $bodyPos, $endBody-$bodyPos); $result = utf8_encode($result); return $result; } $response = array( 'originalContent' => loadArticleAsString($originalFile), 'changedContent' => loadArticleAsString($changedFile) ); header('Content-Type: application/json'); echo json_encode($response); //ob_flush(); /* if (isset($_REQUEST["popup"])) { $xmlRoot; if (file_exists(dirname(__FILE__)."/../itinerari/".$_COOKIE["lm-session"].".xml")) { $xmlRoot = simplexml_load_file(dirname(__FILE__)."/../itinerari/".$_COOKIE["lm-session"].".xml", 'SimpleXMLExtended'); $articoloNodo = $xmlRoot->xpath('//articolo[@articoloId="'.$_REQUEST["padreArt"].'"]')[0]; $articoloPopup = $articoloNodo->addChild("articolopopup"); $intestazione = $articoloPopup->addChild("intestazione"); $intestazione->addCData($d->getElementsByTagName('title')->item(0)->textContent); $xmlRoot->saveXML(dirname(__FILE__)."/../itinerari/".$_COOKIE["lm-session"].".xml"); } } */ ?> |