-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
86 lines (78 loc) · 2.21 KB
/
functions.php
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
76
77
78
79
80
81
82
83
84
85
86
<?php
function getProperLetters($original) {
// Umlaute entfernen
$umlaute = Array("/ä/","/ö/","/ü/","/Ä/","/Ö/","/Ü/","/ß/");
$replace = Array("ä","ö","ü","Ä","Ö","Ü","ß");
$result = preg_replace($umlaute, $replace, $original);
return $result;
}
function returnUmlaute($result) {
// Umlaute einsetzen
$umlaute = Array("ä","ö","ü","Ä","Ö","Ü");
$replace = Array("ae","oe","ue","Ae","Oe","Ue");
$original = str_replace($replace, $umlaute, $result);
return $original;
}
function link2click($str)
{
$s_patter[]='"(((ftp|http|https){1}://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)"i';
$r_patter[]='<a href="\1" class="active">\\1</a>';
//$s_patter[]='"(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)"i';
//$r_patter[]='\\1<a href="http://\2" class="active">\\2</a>';
//$s_patter[]='"([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})"i';
//$r_patter[]='<a href="mailto:\1" class="active">\\1</a>';
$str=preg_replace($s_patter,$r_patter,$str);
return $str;
}
/*
item type can be
all folders and pictures
folder only folders
picture only pictures
*/
function get_folder_content($foldername, $folder_ordering_mode, $item_type) {
$handle = opendir($foldername);
$list = array();
$files = array();
$folders = array();
while ($item = readdir($handle)) {
if(is_dir($foldername."/".$item) && $item != "." && $item != ".." )
{
array_push($folders, $item);
}
if(
strtolower(strrchr($item, '.')) == ".jpg" OR
strtolower(strrchr($item, '.')) == ".jpeg" OR
strtolower(strrchr($item, '.')) == ".png" OR
strtolower(strrchr($item, '.')) == ".gif"
)
{
array_push($files, $item);
}
}
closedir($handle);
$folders = order_folders($folders, $folder_ordering_mode);
sort($files);
$list = array_merge($folders, $files);
switch($item_type) {
case "all": return $list;
case "folders" : return $folders;
case "pictures" : return $files;
default: return null;
}
}
function order_folders($folders, $folder_ordering_mode) {
// cover all cases
switch($folder_ordering_mode) {
case "sort":
sort($folders);
break;
case "reverse_sort":
sort($folders);
case "reverse":
$folders = array_reverse($folders);
break;
}
return $folders;
}
?>