'; if (!empty($title)) { echo '
'; print_r($object); echo ''; } public static function table($tableName) { return TABLENAME_PREFIX . $tableName; } public static function markdown($md, $clear) { preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/', $md, $md_a_img); // Markdown [![alt](src)](href) preg_match_all('/!\[(.*?)\]\((.*?)\)/', $md, $md_img); // Markdown ![alt](src) preg_match_all('/\[(.*?)\]\((.*?)\)/', $md, $md_a); // Markdown [text](href) if (isset($md_a_img[2][0]) && $md_a_img[2][0] != '' && isset($md_a_img[3][0]) && $md_a_img[3][0] != '') { // [![alt](src)](href) $text = stripslashes($md_a_img[1][0]); $html = ''; } elseif (isset($md_img[2][0]) && $md_img[2][0] != '') { // ![alt](src) $text = stripslashes($md_img[1][0]); $html = ''; } elseif (isset($md_a[2][0]) && $md_a[2][0] != '') { // [text](href) $text = stripslashes($md_a[1][0]); $html = '' . $text . ''; } else { // text only $text = stripslashes($md); $html = $text; } return $clear ? $text : $html; } public static function htmlEscape($html) { return htmlentities($html, ENT_HTML5 | ENT_QUOTES); } public static function csvEscape($text) { $escaped = str_replace('"', '""', $text); $escaped = str_replace("\r\n", '', $escaped); $escaped = str_replace("\n", '', $escaped); return '"' . $escaped . '"'; } public static function cleanFilename($title) { $cleaned = preg_replace('[^a-zA-Z0-9._-]', '_', $title); $cleaned = preg_replace(' {2,}', ' ', $cleaned); return $cleaned; } public static function fromPostOrDefault($postKey, $default = '') { return !empty($_POST[$postKey]) ? Utils::htmlEscape($_POST[$postKey]) : $default; } }