'; if (!empty($title)) { echo '' . stripslashes($title) . ' - ' . NOMAPPLICATION . ''; } else { echo '' . NOMAPPLICATION . ''; } echo ' '; if ('en' != $locale) { echo ' '; } echo ' '; if (is_file($_SERVER['DOCUMENT_ROOT'] . "/nav/nav.js")) { echo ''; } echo '
'; } /** * Function allowing to generate poll's url * @param string $id The poll's id * @param bool $admin True to generate an admin URL, false for a public one * @param string $vote_id (optional) The vote's unique id * @return string The poll's URL. */ public static function getUrlSondage($id, $admin = false, $vote_id = '', $action = null, $action_value = null) { // URL-Encode $action_value $action_value = $action_value == null ? null : Utils::base64url_encode($action_value); if (URL_PROPRE) { if ($admin === true) { $url = self::get_server_name() . $id . '/admin'; } else { $url = self::get_server_name() . $id; } if ($vote_id != '') { $url .= '/vote/' . $vote_id . "#edit"; } elseif ($action != null) { if ($action_value != null) { $url .= '/action/' . $action . '/' . $action_value; } else { $url .= '/action/' . $action; } } } else { if ($admin === true) { $url = self::get_server_name() . 'adminstuds.php?poll=' . $id; } else { $url = self::get_server_name() . 'studs.php?poll=' . $id; } if ($vote_id != '') { $url .= '&vote=' . $vote_id . "#edit"; } elseif ($action != null) { if ($action_value != null) { $url .= '&' . $action . "=" . $action_value; } else { $url .= '&' . $action . "="; } } } return $url; } /** * This method pretty prints an object to the page framed by pre tags. * * @param mixed $object The object to print. */ public static function debug($object) { 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 = self::htmlEscape($md_a_img[1][0]); $html = '' . $text . ''; } elseif (isset($md_img[2][0]) && $md_img[2][0] != '') { // ![alt](src) $text = self::htmlEscape($md_img[1][0]); $html = '' . $text . ''; } elseif (isset($md_a[2][0]) && $md_a[2][0] != '') { // [text](href) $text = self::htmlEscape($md_a[1][0]); $html = '' . $text . ''; } else { // text only $text = self::htmlEscape($md); $html = $text; } return $clear ? $text : $html; } public static function htmlEscape($html) { return htmlentities($html, ENT_HTML5 | ENT_QUOTES); } public static function htmlMailEscape($html) { return htmlspecialchars($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); $escaped = preg_replace("/^(=|\+|\-|\@)/", "'$1", $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]) ? $_POST[$postKey] : $default; } public static function base64url_encode($input) { return rtrim(strtr(base64_encode($input), '+/', '-_'), '='); } public static function base64url_decode($input) { return base64_decode(str_pad(strtr($input, '-_', '+/'), strlen($input) % 4, '=', STR_PAD_RIGHT)); } }