function getGoogleTotal($url) { $googleResult = getDoc($url); $iniPos = strpos($googleResult, "Results <b>"); $endPos = strpos($googleResult, " for <b>"); $totalInfo = substr($googleResult, $iniPos, $endPos - $iniPos); preg_match_all("/<b>([0-9,]+)<\\/b>/", $totalInfo, $totalPeaces); $total = $totalPeaces[1][2]; if ($total == "") { $total = 0; } return $total; }
function getGoogleTotal($url) { $googleResult = getDoc($url); if (preg_match('/scholar\\./', $url)) { $iniPos = strpos($googleResult, "Results <b>"); $endPos = strpos($googleResult, " for <b>"); $totalInfo = substr($googleResult, $iniPos, 200); preg_match_all("/<b>([0-9,]+)<\\/b>/", $totalInfo, $totalPeaces); $total = $totalPeaces[1][2]; } else { $iniPos = strpos($googleResult, "About "); $endPos = strpos($googleResult, " results ("); $totalInfo = substr($googleResult, $iniPos, 200); preg_match_all("/[0-9,]+/", $totalInfo, $totalPeaces); $total = $totalPeaces[0][0]; } if ($total == "") { $total = 0; } return $total; }
function getVocabulary($parentElement) { $vocElements = $parentElement->xpath('xs:complexType/xs:simpleContent/xs:extension/xs:attribute/xs:simpleType/xs:restriction/xs:enumeration'); if ($vocElements) { //get/display xs:complexType[1]/xs:simpleContent[1]/xs:extension[1]/xs:attribute[1]->name $att = $parentElement->xpath('xs:complexType/xs:simpleContent/xs:extension/xs:attribute'); $vocabName = (string)$att[0]['name']; $html = "\n<div class=" . '"vocab"' . ">\n<h2>$vocabName</h2>\n<dl>\n"; //for each enumeration foreach ($vocElements as $vocElement) { //get/display the value attribute $value = (string)$vocElement['value']; //get/display the documentation node $doc = getDoc($vocElement,'xs:annotation/xs:documentation'); $html .= " <dt>$value</dt>\n"; $html .= ($doc) ? " <dd>$doc</dd>\n" : ''; } //end for each enumeration $html .= "</dl>\n</div>\n"; } //end if $vocab return $html; }
$startpos = strpos($haystack, $startpostext); $endpostext = $endsection; $endposlen = strlen($endpostext); $endpos = strpos($haystack, $endpostext, $startpos); return substr($haystack, $startpos + $startposlen, $endpos - ($startpos + $startposlen)); } $back = $_SERVER["HTTP_REFERER"]; $page = $_REQUEST["page"]; $id = $checked['id']; $lang = $checked['lang']; $action = $_POST["action"]; $xml = $localPath["xml"] . $checked["id"] . ".xml"; $xmlSave = 'xml/' . $checked['lang'] . '/' . $checked["id"] . ".xml"; $admPath = substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], 'htmlarea.php')); if (file_exists($xml)) { $xml = getDoc($xml); if (strpos($xml, '<content>') > 0) { $startTag = "<content>"; $endTag = "</content>"; // retira marcas CDATA $xml = str_replace(array('<![CDATA[', ']]>'), '', $xml); $textarea = trim(stripFromText($xml, $startTag, $endTag)); $textarea = html_entity_decode($textarea); } else { $textarea = ""; } } $messageArray = array("es" => array("title" => "Administración: Biblioteca Virtual en Salud", "available" => "Disponible", "unavailable" => "Indisponible", "exit" => "Salir", "save" => "Graba"), "pt" => array("title" => "Administração: Biblioteca Virtual em Saúde", "available" => "Disponível", "unavailable" => "Indisponível", "exit" => "Sai", "save" => "Grava"), "en" => array("title" => "Administration: Virtual Health Library", "available" => "Available", "unavailable" => "Unavailable", "exit" => "Exit", "save" => "Save")); $message = $messageArray[$lang]; //die($textarea); ?>
function search($word) { global $conn; $tab_returned = array(); $sql = "SELECT id_doc, MAX(poids) FROM `doc_mot`,`mot` WHERE mot.mot ='" . $word . "' AND mot.id_mot=doc_mot.id_mot GROUP BY id_doc"; //echo $sql; $result = $conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $tab_id_doc[] = $row['id_doc']; } $tab_add = array(); foreach ($tab_id_doc as $id_doc) { $tab_add[] = getDoc($id_doc); } return $tab_add; } else { return false; } }
$startposlen = strlen($startpostext); $startpos = strpos($haystack, $startpostext); $endpostext = $endsection; $endposlen = strlen($endpostext); $endpos = strpos($haystack, $endpostext, $startpos); return substr($haystack, $startpos + $startposlen, $endpos - ($startpos + $startposlen)); } $back = $_SERVER["HTTP_REFERER"]; $id = $_REQUEST["id"]; $page = $_REQUEST["page"]; $xmlSave = $def['DATABASE_PATH'] . "xml/" . $checked['lang'] . "/" . $id . ".xml"; if ($id == "" || $lang == "") { die("error: missing parameter id or lang"); } if (file_exists($xmlSave)) { $xml = getDoc($xmlSave); if (strpos($xml, '<url>') > 0) { // retira marcas CDATA $buffer = trim(stripFromText($xml, "<url>", "</url>")); } else { $buffer = ""; } } else { $buffer = ""; } $messageArray = array("es" => array("title" => "Administración: Biblioteca Virtual en Salud", "available" => "Disponible", "unavailable" => "Indisponible", "exit" => "Salir", "save" => "Graba", "url" => "Localizacion del servicio ", "service" => "Servicio "), "pt" => array("title" => "Administração: Biblioteca Virtual em Saúde", "available" => "Disponível", "unavailable" => "Indisponível", "exit" => "Sai", "save" => "Grava", "url" => "Localização do serviço ", "service" => "Serviço "), "en" => array("title" => "Administration: Virtual Health Library", "available" => "Available", "unavailable" => "Unavailable", "exit" => "Exit", "save" => "Save", "url" => "Service link", "service" => "Service ")); $message = $messageArray[$lang]; ?> <html> <head> <title>BVS-Site Admin</title>
function cText($node, $value) { $node2 = getDoc()->createTextNode($value); $node->appendChild($node2); return $node; }
<?php $DirNameLocal = dirname(__FILE__) . '/'; include_once $DirNameLocal . "./include.php"; include_once $DirNameLocal . "./common.php"; $query = trim($_REQUEST['query']); $query = str_replace(" ", "+", $query); $query = replace_accents($query) . "*"; $serviceUrl = "http://regional.bvsalud.org:8080/decsQuickTerm/search?query=" . $query . "&lang=" . $checked["lang"]; $serviceResponse = getDoc($serviceUrl); header("Content-type: text/xml"); echo $serviceResponse; ?>
createPersonne($_GET); break; case "deletepersonne": deletePersonne($_GET); break; case "updatepersonne": updatePersonne($_GET); break; case "getpersonne": getPersonne(); break; case "auth": auth($_GET); break; case "document": getDoc(); break; case "coords": getCoords($_GET["idDoc"]); break; default: break; } function createScore($data) { global $conn; $sql = "INSERT INTO scores (id_doc, id_perso, distance, maj)\n\tVALUES (" . $data["id_doc"] . ", " . $data["id_perso"] . ", " . $data["distance"] . ",NOW())"; //echo $sql; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else {
$options = $select->getElementsByTagName('option'); foreach ($options as $option) { $faculties[] = $option->nodeValue; } } if ($select->getAttribute('name') === 'wantbuilding') { $options = $select->getElementsByTagName('option'); foreach ($options as $option) { $buildings[] = $option->nodeValue; } } } // For each of the faculties, the printer details are listed on the page as // hidden inputs. foreach ($faculties as $faculty) { $data = array('wantfaculty' => $faculty); $page = getDoc($istUrl, $data); // As of April 13th, 2013, each printer is a separate form on the page. parsePrinterListPage($page, $printers, $faculty); } // Do the same for buildings. foreach ($buildings as $building) { $data = array('wantbuilding' => $building); $page = getDoc($istUrl, $data); // As of April 13th, 2013, each printer is a separate form on the page. parsePrinterListPage($page, $printers); } fwrite(STDOUT, 'printer,ad,server,comment,driver,room,faculty' . "\n"); foreach ($printers as $printer) { fputcsv(STDOUT, $printer); }
<?php if ($network != "") { echo ">" . $network; } ?> </div> <div id="portal"> <div class="content"> <h4><span><?php if ($network != "") { echo $network; } else { echo $texts["network"]; } ?> </span></h4> <?php $bvsNetList = getDoc($bvsNetUrl); if ($bvsNetList == "[open failure]") { echo "<img src='/image/common/alert.gif'>" . $texts["connection.fail"]; } else { echo utf8_encode($bvsNetList); } ?> </div> </div> </div> </div> </div> <?php get_footer();
function filterHTML($codeContent) { global $state; // Array holds information about the current state of parsing // e.g. the current tag, the last tag, etc. $state = array(); // Clear the document in case function is called several times on one page clearDoc(); // set up state defaults setState('abort_filtering', false); // used to abort filtering on encountering an unsupported tag setState('current_tag', ""); // the current tag being processed setState('in_list', false); // whether the parser is currently inside a list (<ul> or <ol> etc...) setState('is_ordered_list', false); // whether the current list being parsed is an <ol> (for preservation) setState('last_tag', ""); // the last tag that was processed setState('css', ""); // keeps track of css styles to add to the next p tag (used to grab textformat attributes) setState('empty', true); // keeps track of whether an element is empty setState('depth', 0); // keeps track of the depth of the current node setState('style_depth', 0); // keeps track of the depth of the current styling node (used to remove redundant styles) setState('last_style_depth', 0); // keeps track of the depth of the current styling node (used to remove redundant styles) setState('last_depth', 0); // keeps track of the last depth processed setState('last_font', ""); // keeps track of the last font family (used to avoid redundant styles) setState('last_size', ""); // keeps track of the last font size (used to avoid redundant styles) setState('last_color', ""); // keeps track of the last foreground color (used to avoid redundant styles) // // URL-Decode the incoming content (obedit will url-encode it before sending.) // $codeContent = urldecode($codeContent); // // Initialize the XML parser and set element handler functions // $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); // // Wrap the obedit document in XML to prevent validation errors // from the XML parser (this extra stuff is ignored by the filter and won't show up in the output) // $xml_data = "<?xml version='1.0'?><parserdocument>".$codeContent."</parserdocument>"; // // Do the parsing. See the handler functions above. // $filterResult = @xml_parse($xml_parser, $xml_data, true); // // If the document is invalidly formed or not valid obedit-generated HTML (e.g. hand-coded), // then spit out the originally submitted HTML (but still perform unicode conversion) // if (!$filterResult || filterWasAborted()) { clearDoc(); add2Doc(unicode_to_entities(utf8_to_unicode($codeContent))); } else { // // If we're here, the document is a valid RTE document and was successfully parsed and filtered. // // Now we just have to check if the document ended with a list, and if so, // close the list off with the appropriate </ul> or </ol> to wrap things up. // if (isInsideList()) { if (isOrderedList()) add2Doc("\n</ol>"); else add2Doc("\n</ul>"); setInsideList(false); } } // Free up memory xml_parser_free($xml_parser); // Return the final HTML document return getDoc(); }
background-color:#ffffcc; margin-bottom:20px; } --> </style> </head> <body> <h1>obedit output preview</h1> <h2>obHTML (HTML submitted from obedit)</h2> <div class="obHTML"><? echo htmlspecialchars(str_replace(">",">",urldecode($_POST['content']))); ?></div> <h2>XHTML (filtered obHTML)</h2> <div class="finalHTML"><? echo trim(htmlspecialchars(getDoc())); //preg_replace("#^(\n|\r\n|\n\r|\r)#", "", ); ?></div> <? // // Output the filtered HTML. // echo $filteredHTML; ?> </body> </html> <? } else // No text was submitted. Show a submission form instead (ONLY for debugging - remove this for real usage!) {
$returnvalue .= "</div>"; } // $returnvalue = "<[CDATA[ " . $returnvalue ." ]]>"; return $returnvalue; } $xmlstr = scrapePage($feedurl); $xmlstr = preg_replace('/<rss version="2.0">/', '<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">', $xmlstr); // $xmlstr = preg_replace( '/<channel>/', '<channel xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" // xsi:schemaLocation="file:///feed_scraper.xsd">' ,$xmlstr); $output = new SimpleXMLElement($xmlstr); $lessonurls = array(); foreach ($output->channel->item as $element) { $title = $element->title; $lessonurls[] = (string) $element->description[0]; // echo preg_replace(array('/Future Quest Island - /','/Future Quest Island/'), '',"$title") . "<br />" . $element->description . "<br /><br />"; } $xmlObj = getDoc(); $nsNode = $xmlObj->channel; $i = 0; foreach ($nsNode->item as $lowlev) { if ($lowlev !== null) { $contentfield = $lowlev->addChild('content:encoded', outputScrape($lessonurls[$i]), "http://purl.org/rss/1.0/modules/content/"); $i = $i + 1; } } $xmloutput = $xmlObj->asxml(); function getDoc() { global $feedurl; global $xmlstr; return new SimpleXMLElement($xmlstr); }
<div class="container"> <?php if (file_exists($fileXml)) { ?> <div class="confirm"> <b><?php echo $messages["exist"]; ?> </b><br/> <div align="center"> <input type="button" value="confirmar" onclick="javascript:document.formPage.submit();" class="submit"/> <input type="button" value="cancelar" onclick="javascript:window.close();" class="submit"/> </div> </div> <div class="middle"> <div class="secondColumn"> <?php if (file_exists($fileHtml)) { print getDoc($fileHtml); } ?> </div> </div> <?php } ?> </div> </body> </html>
$t->pass('->insert() fails if category callback returns a non-scalar'); } $h->set('categories', array('Forum', '%stringable_object%')); $indexer->delete(); $indexer->insert(); $lucene->commit(); $doc = getDoc($lucene, $indexer->getModelGuid()); $t->is($doc->sfl_category, 'Forum Strings!', '->insert() configures categories correctly with a object-returning callback'); $t->is($doc->sfl_categories_cache, serialize(array('Forum', 'Strings!')), '->insert() configures categories cache correctly with a object-returning callback'); $t->is($lucene->getCategoriesHarness()->getCategory('Forum')->getCount(), 1, '->insert() updated category database count for first category with object-returning callback'); $t->is($lucene->getCategoriesHarness()->getCategory('Strings!')->getCount(), 1, '->insert() updated category database count for second category with object-returning callback'); $h->remove('categories'); $indexer->delete(); $indexer->insert(); $lucene->commit(); $doc = getDoc($lucene, $indexer->getModelGuid()); $t->ok(!in_array('sfl_category', $doc->getDocument()->getFieldNames()), '->insert() does not create a category key without categories'); $t->ok(!in_array('sfl_category', $doc->getDocument()->getFieldNames()), '->insert() does not create a category cache key without categories'); $t->diag('testing ->delete()'); $indexer->delete(); for ($i = 0; $i < 5; $i++) { $indexer->insert(); } $lucene->setParameter('delete_lock', true); $indexer->delete(); $lucene->commit(); $t->is($lucene->numDocs(), 5, '->delete() does nothing if parameter "delete_lock" is set'); $lucene->setParameter('delete_lock', false); $indexer->delete(); $lucene->commit(); $t->is($lucene->numDocs(), 0, '->delete() deletes all matching documents in the index');