]>
git.agnieray.net Git - galette.git/blob - galette/includes/functions.inc.php
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2003-2014 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
30 * @author Frédéric Jacquot <unknown@unknow.com>
31 * @author Georges Khaznadar (password encryption, images) <unknown@unknow.com>
32 * @author Johan Cwiklinski <johan@x-tnd.be>
33 * @copyright 2003-2014 The Galette Team
34 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
35 * @link http://galette.tuxfamily.org
38 if (!defined('GALETTE_ROOT')) {
39 die("Sorry. You can't access directly to this file");
47 * @param string $url The URL to check
51 function isValidWebUrl($url)
54 '#^http[s]?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i',
60 * Custom HTML entitiy decode
62 * @param string $given_html Original HTML
63 * @param int $quote_style Quoting style
67 function custom_html_entity_decode($given_html, $quote_style = ENT_QUOTES
)
69 $trans_table = array_flip(
70 get_html_translation_table(
75 $trans_table['''] = "'";
76 return strtr($given_html, $trans_table);
80 * Get a value sent by a form, either in POST and GET arrays
82 * @param string $name property name
83 * @param string $defval default rollback value
85 * @return string value retrieved from :
86 * - GET array if defined and numeric,
87 * - POST array if defined and numéric
90 function get_form_value($name, $defval)
93 if (isset($_GET[$name])) {
95 } elseif (isset($_POST[$name])) {
102 * Get a numeric value sent by a form, either in POST and GET arrays
104 * @param string $name property name
105 * @param string $defval default rollback value
107 * @return numeric value retrieved from :
108 * - GET array if defined and numeric,
109 * - POST array if defined and numéric
110 * - $defval otherwise
112 function get_numeric_form_value($name, $defval)
114 $val = get_form_value($name, $defval);
115 if (!is_numeric($val)) {
117 '[get_numeric_form_value] not a numeric value! (value was: `' .
127 * Get a post numeric value
129 * @param string $name property name
130 * @param string $defval default rollback value
132 * @return string value retrieved from :
133 * - POST array if defined and numéric
134 * - $defval otherwise
136 function get_numeric_posted_value($name, $defval)
138 if (isset($_POST[$name])) {
139 $val = $_POST[$name];
140 if (is_numeric($val)) {