function html2xhtml($html) { process_pagebreak_commands($html); // Remove SCRIPT tags from the page being processed, as script content may // mess the firther html-parsing utilities $html = process_script($html); // Remove STYLE tags for the same reason and store them in the temporary variable // later they will be added back to HEAD section $styles = process_style($html); // Convert HTML character references to their Unicode analogues process_character_references($html); remove_comments($html); fix_attrs_spaces($html); $html = quote_attrs($html); $html = escape_attrs_entities($html); $html = lowercase_tags($html); $html = lowercase_closing_tags($html); $html = fix_closing_tags($html); $html = close_tag("area", $html); $html = close_tag("base", $html); $html = close_tag("basefont", $html); $html = close_tag("br", $html); $html = close_tag("col", $html); $html = close_tag("embed", $html); $html = close_tag("frame", $html); $html = close_tag("hr", $html); $html = close_tag("img", $html); $html = close_tag("input", $html); $html = close_tag("isindex", $html); $html = close_tag("link", $html); $html = close_tag("meta", $html); $html = close_tag("param", $html); $html = make_attr_value("checked", $html); $html = make_attr_value("compact", $html); $html = make_attr_value("declare", $html); $html = make_attr_value("defer", $html); $html = make_attr_value("disabled", $html); $html = make_attr_value("ismap", $html); $html = make_attr_value("multiple", $html); $html = make_attr_value("nohref", $html); $html = make_attr_value("noresize", $html); $html = make_attr_value("noshade", $html); $html = make_attr_value("nowrap", $html); $html = make_attr_value("readonly", $html); $html = make_attr_value("selected", $html); $html = process_html($html); $html = process_body($html); $html = process_head($html); $html = process_p($html); $html = escape_amp($html); $html = escape_lt($html); $html = escape_gt($html); $html = escape_textarea_content($html); process_tables($html, 0); process_lists($html, 0); process_deflists($html, 0); process_selects($html, 0); $html = fix_tags($html); $html = fix_attrs($html); $html = insert_styles($html, $styles); return $html; }
// we now have a project, is it one of the ones that need updating? // If so, save it, and record the project name and version. $proj_name = xtract($proj1[4]); foreach ($adiffs as $name => $version) { if ($proj_name == $name) { //pdbg("Found $name, saving"); $Yupdate = "{$name} " . "has a new version:" . " {$version}\n"; save_Yupdated($P2up, $Yupdate); //pdbg("\$proj1 is:", $proj1); write_pxml($Cxml, $proj1); break; } } } // must write the closing tag before closing the xml file close_tag($Cxml); fclose($P2up); fclose($Cxml); if ($diffs_found > 0) { echo "{$diffs_found} differences were found. Please consult the following files:\n"; echo "{$projs2update} and {$xml_changes}\n"; exit($diffs_found); } /** * mklists make a list (array) of the passed in xml file * * The list is an associative array with the project name as the key and * the latest version as the value. * * @param string $xml_file path to XML file to parse * @return array $p associative array with name as key and latest version
NOTE: I'm bothered by something here... while one gets the top 1000, there could be drastic differences (not likely between any two days, but possible)....It doesn't really affect this code, but could affect users of the output files. */ $Output = fopen("{$out_file}", 'w') or die("Can' open: {$php_errormsg}\n"); echo "Extracting the top {$HowMany_projects} projects from:\n{$in_file}\n"; echo "\nWriting the top {$HowMany_projects} projects to: {$out_file}\n"; // need a valid doc, write the header 1st, and open tag write_hdr($Output); while (false != ($line = fgets($F1, 1024))) { # echo "Line is:\n$line\n"; if (preg_match('/<project>/', $line)) { $proj_mark = ftell($F1); } elseif (preg_match('/<popularity_rank>[0-9].*</', $line)) { $pos = strpos($line, '>'); $rank_pos = $pos + 1; $rank_end = strpos($line, '</', $rank_pos); $rank_len = $rank_end - $rank_pos; $rank = substr($line, $rank_pos, $rank_len); if ((int) $rank <= $HowMany_projects) { //pdbg("Processing rank:$rank"); write_entry($F1, $proj_mark, $Output); } } } // write the end tag and close up shop close_tag($Output); fclose($F1); fclose($Output); echo "Done\n";
function link_to_internal($module, $controller, $action, $title, $options = array()) { if (!$module || !$controller || !$action) { return ""; } $router = Router::getInstance(); $url = $router->toURL($module, $controller, $action); $options["href"] = $url; $options["title"] = $title; $tag = tag("a", $options, false); $tag .= $title; $tag .= close_tag("a"); return $tag; }