blob: f42aa7a25a5ee5df33ecfa920af4335f80bf2f80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
<?php
/**
* Parameter input functions.
* This file contains functions for getting input from get/post variables.
*
* @package Elgg
* @subpackage Core
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Marcus Povey <marcus@dushka.co.uk>
* @copyright Curverider Ltd 2008
* @link http://elgg.org/
*/
/**
* Get some input from variables passed on the GET or POST line.
*
* @param $variable string The variable we want to return.
* @param $default mixed A default value for the variable if it is not found.
*/
function get_input($variable, $default = "")
{
if (isset($_REQUEST[$variable])) {
if (is_array($_REQUEST[$variable]))
return $_REQUEST[$variable];
else
return trim($_REQUEST[$variable]);
}
global $CONFIG;
if (isset($CONFIG->input[$variable]))
return $CONFIG->input[$variable];
return $default;
}
/**
* Sets an input value that may later be retrieved by get_input
*
* @param string $variable The name of the variable
* @param string $value The value of the variable
*/
function set_input($variable, $value) {
global $CONFIG;
if (!isset($CONFIG->input))
$CONFIG->input = array();
$CONFIG->input[trim($variable)] = trim($value);
}
/**
* This is a function to make url clickable
* @param string text
* @return string text
**/
function parse_urls($text) {
if (preg_match_all('/(?<!href=["\'])((ht|f)tps?:\/\/[^\s\r\n\t<>"\'\!\(\)]+)/ie', $text, $urls)) {
foreach (array_unique($urls[1]) AS $url){
$urltext = $url;
$text = str_replace($url, '<a href="'. $url .'" style="text-decoration:underline;">view link</a>', $text);
}
}
return $text;
}
?>
|