source: includes/GlobalFunction.php

Last change on this file was 1, checked in by george, 15 years ago
  • Import souborů projektu.
File size: 3.1 KB
Line 
1<?php
2
3 function AdminLevel()
4 { // BEGIN function AdminLevel
5 $Result = -1;
6 global $db;
7 if (isset($_SESSION['ID'])) {
8 if ($_SESSION['ID'] <> '') {
9 $ID = $_SESSION['ID'];
10 $Name = $_SESSION['User'];
11 $Pass = $_SESSION['Pass'];
12
13 $sql = "SELECT * FROM user WHERE ID = '$ID' AND Name = '$Name' AND Pass = '$Pass'";
14// echo $sql;
15 $ID = $db->SQLCommand($sql);
16 while($Line = mysql_fetch_array($ID)) {
17 $Result = $Line['Level'];
18 }
19 }
20 }
21 return $Result;
22 } // END function AdminLevel
23
24 function WriteLog($Text, $Type)
25 { // BEGIN function Log
26 global $db;
27
28 $Text = mysql_escape_string($Text);
29
30 if (isset($_SESSION['ID']))
31 $User = $_SESSION['ID'];
32 else
33 $User = 0;
34
35 $IP = $_SERVER['REMOTE_ADDR'];
36
37 $sql = "SELECT max(ID) FROM log";
38 $ID = $db->SQLCommand($sql);
39 $Line = mysql_fetch_row($ID);
40 $ID = $Line[0]+1;
41
42 $sql = "INSERT log VALUE('$ID',now(),'$Text','$Type','$User','$IP')";
43 $db->SQLCommand($sql);
44 } // END function Log
45
46 function ReadLog($NumberLines, $Type) //0 = všechno
47 { // BEGIN function ReadLog
48 global $db;
49 global $Color;
50
51 if ($Type <> '0')
52 $sql = "SELECT * FROM log WHERE Type = $Type order by 1 DESC LIMIT $NumberLines";
53 else
54 $sql = "SELECT * FROM log order by 1 DESC LIMIT $NumberLines";
55 $ID = $db->SQLCommand($sql);
56
57 while ($Line = mysql_fetch_array($ID)) {
58 echo '<span style="color: '.$Color[$Line['Type']].'">'.$Line['Date'].': '.strip_tags($Line['Text']).' ('.$Line['UserID'].')</span><br />';
59 }
60 } // END function ReadLog
61
62 function TestLicence($security)
63 { // BEGIN function TestLicence
64 global $AdminLevel;
65 global $NotLicence;
66 if ($AdminLevel < $security) { //level $security
67 echo $NotLicence;
68 include 'FormLogin.php';
69 ShowFooter();
70 die();
71 }
72 } // END function TestLicence
73
74 function IconDownload($Name)
75 { // BEGIN function Icon
76 global $Icons;
77
78 if (isset($Icons[$Name]))
79 return $Icons[$Name];
80 else {
81 WriteLog('Neznámý formát souboru: '.$Name,'5');
82 return $Icons['Unknow'];
83 }
84 } // END function Icon
85
86 function JavaQuestionDel()
87 { // BEGIN function JavaQuestionDel
88 return 'onclick="if (window.confirm(\'Opravdu smazat?\')) {} else {
89return false;
90}"';
91 } // END function JavaQuestionDel
92
93 //funkce na vypsání souborù podle ID složky
94 function WriteFiles($Dir)
95 { // BEGIN function WriteFiles
96 global $db;
97 global $Icons;
98 global $UploadDirDownload;
99
100 echo '<DL>';
101 $sql = "SELECT * FROM downloadfile WHERE Dir = '$Dir' order by 2 DESC";
102 $IDFiles = $db->SQLCommand($sql);
103 while($LineFile = mysql_fetch_array($IDFiles)) {
104 $Type = $LineFile['Type'];
105 echo '<DD><a href="/'.$UploadDirDownload.'/'.$LineFile['FileName'].'" title="'.$LineFile['Description'].' ('.$LineFile['Date'].')">'.IconDownload($Type).' '.$LineFile['Name'].'</a>';
106 }
107 echo '</DL>';
108
109 } // END function WriteFiles
110
111
112
113?>
114
115
116
117
118
119
120
121
Note: See TracBrowser for help on using the repository browser.