]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions2.php
sanitize: allow <hr> elements
[tt-rss.git] / include / functions2.php
index 27b1933d0a0717c38b50b30b53c024c171660dcc..8046deb55bc9bfa1691e6427497310e210be31db 100644 (file)
                        'caption', 'cite', 'center', 'code', 'col', 'colgroup',
                        'data', 'dd', 'del', 'details', 'div', 'dl', 'font',
                        'dt', 'em', 'footer', 'figure', 'figcaption',
-                       'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'html', 'i',
+                       'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'html', 'hr', 'i',
                        'img', 'ins', 'kbd', 'li', 'main', 'mark', 'nav', 'noscript',
                        'ol', 'p', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'section',
                        'small', 'source', 'span', 'strike', 'strong', 'sub', 'summary',
 
                $tag = preg_replace('/[\'\"\+\>\<]/', "", $tag);
 
-//             $tag = str_replace('"', "", $tag);
-//             $tag = str_replace("+", " ", $tag);
-               $tag = str_replace("technorati tag: ", "", $tag);
+               if (DB_TYPE == "mysql") {
+                       $tag = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $tag);
+               }
 
                return $tag;
        }
         * @return string Fixed URL.
         */
        function fix_url($url) {
+
+               // support schema-less urls
+               if (strpos($url, '//') === 0) {
+                       $url = 'https:' . $url;
+               }
+
                if (strpos($url, '://') === false) {
                        $url = 'http://' . $url;
                } else if (substr($url, 0, 5) == 'feed:') {
                return LABEL_BASE_INDEX - 1 + abs($feed);
        }
 
-       function theme_valid($file) {
-               if ($file == "default.css" || $file == "night.css") return true; // needed for array_filter
-               $file = "themes/" . basename($file);
+       function get_theme_path($theme) {
+               $check = "themes/$theme";
+               if (file_exists($check)) return $check;
+
+               $check = "themes.local/$theme";
+               if (file_exists($check)) return $check;
+       }
+
+       function theme_valid($theme) {
+               if ($theme == "default.css" || $theme == "night.css") return true; // needed for array_filter
+               $file = "themes/" . basename($theme);
+
+               if (!file_exists($file)) $file = "themes.local/" . basename($theme);
 
                if (file_exists($file) && is_readable($file)) {
                        $fh = fopen($file, "r");
                        array("code" => $code, "message" => $message)));
 
        }
+
+       function abs_to_rel_path($dir) {
+               $tmp = str_replace(dirname(__DIR__), "", $dir);
+
+               if (strlen($tmp) > 0 && substr($tmp, 0, 1) == "/") $tmp = substr($tmp, 1);
+
+               return $tmp;
+       }
 ?>