[php?xml] Sonderzeichen Problem

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • [php?xml] Sonderzeichen Problem

    Hallo zusammen,

    ich habe mir folgende Datei geschrieben:

    Quellcode

    1. <?php
    2. /*
    3. ____ _
    4. / __ \ | |
    5. | | | |_ __ ___ _ __ ___ ___ __ _ _ __ ___| |__
    6. | | | | '_ \ / _ \ '_ \/ __|/ _ \/ _` | '__/ __| '_ \
    7. | |__| | |_) | __/ | | \__ \ __/ (_| | | | (__| | | |
    8. \____/| .__/ \___|_| |_|___/\___|\__,_|_| \___|_| |_|
    9. | | v0.2
    10. |_|
    11. Copyright : Sumale.nin
    12. Kontakt : ben88b@googlemail.com
    13. Credits : V@no
    14. */
    15. $main_template = 0;
    16. $nozip = 1;
    17. $nocache = 1;
    18. define('GET_CACHES', (isset($_GET['s'])));
    19. define('ROOT_PATH', '../');
    20. include(ROOT_PATH.'global.php');
    21. $url = "http://".$_SERVER['HTTP_HOST'].str_replace("//", "/", "/".dirname($PHP_SELF)."/")."";
    22. $favicon = ROOT_PATH."favicon.ico";
    23. function get_opensearch_favicon($favicon) {
    24. global $config;
    25. if (file_exists($favicon)) {
    26. return $favicon;
    27. }
    28. else {
    29. return ROOT_PATH."/opensearch/img/opensearch_favicon.png";
    30. }
    31. }
    32. /*
    33. Einstellungen > Start
    34. */
    35. $url_suggestions = $url."opensearch.php?s=";
    36. $num = 10;
    37. $show_num_results = 1;
    38. /*
    39. Einstellungen > Ende
    40. */
    41. if (isset($HTTP_GET_VARS['s']))
    42. {
    43. require(ROOT_PATH.'includes/sessions.php');
    44. $user_access = get_permission();
    45. include(ROOT_PATH.'includes/search_utils.php');
    46. $r = "";
    47. $n = "";
    48. if (strlen($HTTP_GET_VARS['s']))
    49. {
    50. $cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
    51. $cat_id_sql = $cat_id_sql !== 0 ? "AND i.cat_id NOT IN (".$cat_id_sql.")" : "";
    52. $sql = "SELECT DISTINCT w.word_text".($show_num_results ? ", COUNT(w.word_text) as num" : "")."
    53. FROM (".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m)
    54. LEFT JOIN ".IMAGES_TABLE." i ON (i.image_id = m.image_id)
    55. WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $HTTP_GET_VARS['s']))."%'
    56. AND m.word_id = w.word_id $cat_id_sql
    57. GROUP BY w.word_text
    58. ".($show_num_results ? "ORDER BY num DESC" : "")."
    59. LIMIT $num";
    60. $result = $site_db->query($sql);
    61. while($row = $site_db->fetch_array($result))
    62. {
    63. $r .= ($r?',':'').'"'.str_replace('"', "&quot;", stripslashes($row['word_text'])).'"';
    64. if ($show_num_results)
    65. $n .= ($n?',':'').'"'.number_format($row['num']).' '.$lang['opensearch_results'].'"';
    66. }
    67. }
    68. echo '["'.str_replace('"', "&quot;", stripslashes($HTTP_GET_VARS['s'])).'",['.$r.'], ['.$n.']]';
    69. }
    70. elseif (isset($HTTP_GET_VARS['xml']))
    71. {
    72. header ("content-type: text/xml");
    73. $array = array("x-ico", "gif", "jpg", "png");
    74. echo ' <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">\n';
    75. echo ' <ShortName>'.htmlspecialchars($config['site_name'], ENT_QUOTES).'</ShortName>\n';
    76. echo ' <Description>'.$lang['search'].'</Description>\n';
    77. echo ' <InputEncoding>'.$lang['charset'].'</InputEncoding>\n';
    78. $favicon_info = getimagesize(get_opensearch_favicon($favicon));
    79. if (!isset($favicon_info[2]) || !isset($array[$favicon_info[2]]))
    80. $favicon_info[2] = 0;
    81. echo ' <Image width="16" height="16" type="image/'.$array[$favicon_info[2]].'">'.$url.get_opensearch_favicon($favicon).'</Image>\n';
    82. echo ' <Url type="text/html" method="get" template="'.$url.'search.php?search_keywords={searchTerms}"/>\n';
    83. if (isset($url_suggestions) && $url_suggestions)
    84. {
    85. echo ' <Url type="application/x-suggestions+json" template="'.$url_suggestions.'{searchTerms}"/>\n';
    86. }
    87. echo ' </OpenSearchDescription>';
    88. }
    89. elseif (isset($HTTP_GET_VARS['js']))
    90. {
    91. echo '
    92. function addEngine()
    93. {
    94. if (window.external && ("AddSearchProvider" in window.external))
    95. {
    96. window.external.AddSearchProvider("'.$url.'opensearch.php?xml" );
    97. }
    98. else if (window.sidebar && ("addSearchEngine" in window.sidebar))
    99. {
    100. window.sidebar.addSearchEngine("'.$url.'opensearch.php?xml",
    101. "'.$url.get_opensearch_favicon($favicon).'",
    102. "opensearch.xml",
    103. "(c) by Sumale.nin"
    104. );
    105. }
    106. else
    107. {
    108. alert("'.$lang['opensearch_support'].'");
    109. }
    110. }
    111. ';
    112. }
    113. ?>
    Alles anzeigen


    Das funktioniert auch ohne Probleme, allerdings nur wenn keine Sonderzeichen vorkommen. Ich habe das nun so versucht zu lösen:

    Quellcode

    1. echo ' <ShortName>'.htmlentities($config['site_name'], ENT_QUOTES).'</ShortName>';

    und

    Quellcode

    1. echo ' <ShortName>'.htmlspecialchars($config['site_name'], ENT_QUOTES).'</ShortName>\n';


    Brachte aber beides keinen Erfolg. Kann jemand weiterhelfen?