jablonka.czprosek.czf

is

Subversion Repositories:
[/] [trunk/] [html/] [fce.php] - Blame information for rev 3

 

Line No. Rev Author Line
12simandl<?
2include ("config.php");
3 
4function datum2sql ($datum) {
5$vara = explode(".",$datum);
6return $vara[2]."-".$vara[1]."-".$vara[0];
7}
8 
9function sql2datum ($datum) {
10$vara = explode("-",$datum);
11return @$vara[2].".".@$vara[1].".".@$vara[0];
12}
13 
14function logging ($message) {
15 
16#$islogdir="/home/demois/html/logs/";
17include ("config.php");
18$myFile = $islogdir."/db.log";
19$fh = fopen($myFile, 'a') or die("Can't open file $myFile");
20$stringData = date("d.m.Y H:i:s ").$_SERVER['PHP_AUTH_USER']." ".$_SERVER["REMOTE_ADDR"]." ".$_SERVER["SCRIPT_FILENAME"]." ";
21fwrite($fh, $stringData);
22$stringData = "$message\n";
23fwrite($fh, $stringData);
24fclose($fh);
25 
26return "OK";
27}
28 
29function fid_to_name ($flat, $flatid) {
30$name=MySQL_Query("SELECT name FROM allusers WHERE flat='$flat' AND flatid='$flatid'");
31$name=MySQL_Fetch_Array($name);
32return $name["name"];
33}
34 
35function get_transactions ($fp) {
36 if ($fp) {
37 $message="";
38 while (($s =fgets($fp))) {
39 $message=$message.$s;
40 }
41 fclose($fp);
42 }
43#useknuti zacatku
44 $message=stristr($message, "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"0\" WIDTH=\"100%\" BGCOLOR=\"#FFFFFF\">");
45 $message=stristr($message, "</tr>");
46 $message=stristr($message, "<tr>");
47#useknuti konce
48 $konec=strpos($message,"<TD ALIGN=\"center\" VALIGN=\"TOP\" COLSPAN=\"5\">");
49 $message=substr($message,0,$konec-5);
50 
51return $message;
52}
53 
54function id_to_flat ($id) {
55$name=MySQL_Query("SELECT flat FROM allusers WHERE id='$id'");
56$name=MySQL_Fetch_Array($name);
57return $name["flat"];
58}
59 
60function id_to_vs ($id) {
61$name=MySQL_Query("SELECT vs FROM cleni WHERE id='$id'");
62$name=MySQL_Fetch_Array($name);
63return $name["vs"];
64}
65 
66function id_to_name ($id) {
67$name=MySQL_Query("SELECT * FROM cleni WHERE id='$id'");
68$name=MySQL_Fetch_Array($name);
69return $name["jmeno"]." ".$name["prijmeni"];
70}
71 
72function id_to_ucet ($id) {
73$ucet=MySQL_Query("SELECT * FROM finance WHERE id='$id'");
74$ucet=MySQL_Fetch_Array($ucet);
75return sql2datum($ucet["datum"])." ".$ucet["hodnota"]." ".substr($ucet["komentar"],0,30);
76}
77 
78function id_to_type($id){
79$type=MySQL_Query("SELECT type FROM poplatky WHERE id='$id'");
80$type=MySQL_Fetch_Array($type);
81return $type["type"];
82}
83 
84function id_to_platba($id){
85$type=MySQL_Query("SELECT nazev FROM platby WHERE id='$id'");
86$type=MySQL_Fetch_Array($type);
87return $type["nazev"];
88}
89 
90function id_to_dodavatel($id){
91$type=MySQL_Query("SELECT nazev FROM dodavatele WHERE id='$id'");
92$type=MySQL_Fetch_Array($type);
93return $type["nazev"];
94}
95 
96function id_to_pokladna($id){
97$type=MySQL_Query("SELECT nazev FROM pokladny WHERE id='$id'");
98$type=MySQL_Fetch_Array($type);
99return $type["nazev"];
100}
101 
102function id_to_prenos05($id){
103$type=MySQL_Query("SELECT hodnota FROM finance WHERE clen='$id' AND platba=7 AND YEAR(datum) = 2006");
104$type=MySQL_Fetch_Array($type);
105return $type["hodnota"];
106}
107 
108function id_to_prenos06($id){
109$type=MySQL_Query("SELECT hodnota FROM finance WHERE clen='$id' AND platba=7 AND YEAR(datum) = 2007");
110$type=MySQL_Fetch_Array($type);
111return $type["hodnota"];
112}
113 
114function id_to_prenos07($id){
115$type=MySQL_Query("SELECT hodnota FROM finance WHERE clen='$id' AND platba=7 AND YEAR(datum) = 2008");
116$type=MySQL_Fetch_Array($type);
117return $type["hodnota"];
118}
119 
120function id_to_prenos($id, $rok){
121$type=MySQL_Query("SELECT hodnota FROM finance WHERE clen='$id' AND platba=7 AND YEAR(datum) = '$rok'");
122$type=MySQL_Fetch_Array($type);
123return $type["hodnota"];
124}
125 
126function id_to_sleva($id,$rok){
127$type=MySQL_Query("SELECT * FROM ukony WHERE clen='$id' AND udalost IN (5,6) ORDER BY datum,udalost");
128$cnt=0;
129$count=MySQL_Num_Rows($type);
130$od=strtotime($rok."-01-01");
131$do=strtotime($rok."-12-31");
132$zacatek=0;
133$konec=0;
134$merime=False;
135$celkem=0;
136while($radek=MySQL_Fetch_Array($type))
137 {
138 $cnt=$cnt+1;
139 if (($radek["udalost"] == 5) AND ! $merime AND $radek["datum"])
140 { $cnt=10;
141 $merime=True;
142 $zacatek=strtotime($radek["datum"]);
143 }
144 if (($radek["udalost"] == 6) AND $merime AND $radek["datum"])
145 { $cnt=12;
146 $merime=False;
147 $konec=strtotime($radek["datum"]);
148 #uzavreli jsme interval a jdeme tedy zjistit jestli lezi v nasem roce
149 if (($zacatek < $do) AND ($konec>$od))
150 { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
151 if ($zacatek<$od) $zacatek=$od;
152 #pokud je konec po konci roku tak merime jen do konce roku
153 if ($konec>$do) $konec=$do;
154 #a konecne ziskame rozdil a pricteme do celkove doby kdy clen napaji switch
155 $celkem += $konec-$zacatek;
156 }
157 }
158 }
159# return (strtotime($do)-strtotime($od));
160#zbyva otestovat jestli stale nemerime a pripadne vycislit dobu
161#uzavreli jsme interval a jdeme tedy zjistit jestli zacatek lezi v nasem roce
162 if (($zacatek < $do) AND $merime)
163 { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
164 if ($zacatek<$od) $zacatek=$od;
165 $konec=$do;
166 #a konecne ziskame rozdil a pricteme do celkove doby kdy clen napaji switch
167 $celkem = $konec-$zacatek;
168 }
169 return $celkem;
170}
171 
172function id_to_delkazarok($id,$rok,$zac,$kon){
173#udalost musi byt razeny sestupne DESC aby vsechny konce v dany den byly (8) pred zacatky (7)
174$type=MySQL_Query("SELECT * FROM ukony WHERE clen='$id' AND udalost IN ('$zac','$kon') ORDER BY datum ASC,udalost DESC");
175$od=strtotime($rok."-01-01");
176$do=strtotime($rok."-12-31");
177$zacatek=0;
178$konec=0;
179$merime=False;
180$celkem=0;
181while($radek=MySQL_Fetch_Array($type))
182 {
183 if (($radek["udalost"] == $zac) AND ! $merime AND $radek["datum"])
184 { $merime=True;
185 $zacatek=strtotime($radek["datum"]);
186 }
187 if (($radek["udalost"] == $kon) AND $merime AND $radek["datum"])
188 { $merime=False;
189 $konec=strtotime($radek["datum"]);
190 #uzavreli jsme interval a jdeme tedy zjistit jestli lezi v nasem roce
191 if (($zacatek < $do) AND ($konec>$od))
192 { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
193 if ($zacatek<$od) $zacatek=$od;
194 #pokud je konec po konci roku tak merime jen do konce roku
195 if ($konec>$do) $konec=$do;
196 #a konecne ziskame rozdil a pricteme do celkove doby
197 $celkem += $konec-$zacatek;
198 }
199 }
200 }
201#zbyva otestovat jestli stale nemerime a pripadne vycislit dobu
202#uzavreli jsme interval a jdeme tedy zjistit jestli zacatek lezi v nasem roce
203 if (($zacatek < $do) AND $merime)
204 { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
205 if ($zacatek<$od) $zacatek=$od;
206 $konec=$do;
207 #a konecne ziskame rozdil a pricteme do celkove doby
208 $celkem += $konec-$zacatek;
209 }
210 return $celkem;
211}
212 
213function id_to_delkakonektivity($id,$rok){
214#udalost musi byt razeny sestupne DESC aby vsechny konce v dany den byly (8) pred zacatky (7)
215$type=MySQL_Query("SELECT * FROM ukony WHERE clen='$id' AND udalost IN (7,8) ORDER BY datum ASC,udalost DESC");
216$od=strtotime($rok."-01-01");
217$do=strtotime($rok."-12-31");
218$zacatek=0;
219$konec=0;
220$merime=False;
221$celkem=0;
222while($radek=MySQL_Fetch_Array($type))
223 {
224 if (($radek["udalost"] == 7) AND ! $merime AND $radek["datum"])
225 { $merime=True;
226 $zacatek=strtotime($radek["datum"]);
227 }
228 if (($radek["udalost"] == 8) AND $merime AND $radek["datum"])
229 { $merime=False;
230 $konec=strtotime($radek["datum"]);
231 #uzavreli jsme interval a jdeme tedy zjistit jestli lezi v nasem roce
232 if (($zacatek < $do) AND ($konec>$od))
233 { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
234 if ($zacatek<$od) $zacatek=$od;
235 #pokud je konec po konci roku tak merime jen do konce roku
236 if ($konec>$do) $konec=$do;
237 #a konecne ziskame rozdil a pricteme do celkove doby
238 $celkem += $konec-$zacatek;
239 }
240 }
241 }
242#zbyva otestovat jestli stale nemerime a pripadne vycislit dobu
243#uzavreli jsme interval a jdeme tedy zjistit jestli zacatek lezi v nasem roce
244 if (($zacatek < $do) AND $merime)
245 { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
246 if ($zacatek<$od) $zacatek=$od;
247 $konec=$do;
248 #a konecne ziskame rozdil a pricteme do celkove doby
249 $celkem += $konec-$zacatek;
250 }
251 return $celkem;
252}
253 
254 
255function id_to_delkaspotreby($id,$rok){
256$type=MySQL_Query("SELECT * FROM ukony WHERE majetek='$id' AND udalost IN (17,18) ORDER BY datum,udalost");
257$cnt=0;
258$count=MySQL_Num_Rows($type);
259if($rok=="vsechno")
260{ $od=0;
261 $do=strtotime(date("Y")."-12-31");
262} else {
263 $od=strtotime($rok."-01-01");
264 $do=strtotime($rok."-12-31");
265}
266$zacatek=0;
267$konec=0;
268$merime=False;
269$celkem=0;
270while($radek=MySQL_Fetch_Array($type))
271 {
272 $cnt=$cnt+1;
273 if (($radek["udalost"] == 17) AND ! $merime AND $radek["datum"])
274 { $cnt=10;
275 $merime=True;
276 $zacatek=strtotime($radek["datum"]);
277 }
278 if (($radek["udalost"] == 18) AND $merime AND $radek["datum"])
279 { $cnt=12;
280 $merime=False;
281 $konec=strtotime($radek["datum"]);
282 #uzavreli jsme interval a jdeme tedy zjistit jestli lezi v nasem roce
283 if (($zacatek < $do) AND ($konec>$od))
284 { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
285 if ($zacatek<$od) $zacatek=$od;
286 #pokud je konec po konci roku tak merime jen do konce roku
287 if ($konec>$do) $konec=$do;
288 #a konecne ziskame rozdil a pricteme do celkove doby kdy clen napaji switch
289 $celkem += $konec-$zacatek;
290 }
291 }
292 }
293# return (strtotime($do)-strtotime($od));
294#zbyva otestovat jestli stale nemerime a pripadne vycislit dobu
295#uzavreli jsme interval a jdeme tedy zjistit jestli zacatek lezi v nasem roce
296 if (($zacatek < $do) AND $merime)
297 { #pokud je zacatek pred zacatkem roku tak merime od zacatku roku
298 if ($zacatek<$od) $zacatek=$od;
299 $konec=$do;
300 #a konecne ziskame rozdil a pricteme do celkove doby kdy clen napaji switch
301 $celkem = $konec-$zacatek;
302 }
303 return $celkem;
304}
305 
306function id_to_ipecko($id){
307$type=MySQL_Query("SELECT ip FROM ipecka WHERE id='$id'");
308$type=MySQL_Fetch_Array($type);
309return $type["ip"];
310}
311 
312function id_to_udalost($id){
313$type=MySQL_Query("SELECT nazev FROM udalosti WHERE id='$id'");
314$type=MySQL_Fetch_Array($type);
315return $type["nazev"];
316}
317 
318function id_to_zarizeni($id){
319$type=MySQL_Query("SELECT nazev FROM zarizeni WHERE id='$id'");
320$type=MySQL_Fetch_Array($type);
321return $type["nazev"];
322}
323 
324function id_to_spotreba($id){
325$type=MySQL_Query("SELECT spotreba FROM
326majetek WHERE id='$id'");
327$type=MySQL_Fetch_Array($type);
328return $type["spotreba"];
329}
330 
331function clen_to_ipecko($clen){
332$type=MySQL_Query("SELECT id FROM ipecka WHERE clen='$clen'");
333$type=MySQL_Fetch_Array($type);
334 
335return $type["id"];
336}
337 
338function clen_to_ipecka($clen){
339 $type=MySQL_Query("SELECT id,ip FROM ipecka WHERE clen='$clen'");
340 while ($ipecko=MySQL_Fetch_Array($type)) {
341 $ipecka[$ipecko["id"]]=$ipecko["ip"];
342 }
343return $ipecka;
344}
345 
346function last_ip_action($id){
347$type=MySQL_Query("SELECT udalost FROM ukony WHERE predmet='$id' ORDER BY datum DESC");
348$type=MySQL_Fetch_Array($type);
349return $type["udalost"];
350}
351 
352function id_to_ukon($id){
353$type=MySQL_Query("SELECT * FROM ukony WHERE id='$id' ORDER BY datum DESC");
354$type=MySQL_Fetch_Array($type);
355return sql2datum($type["datum"])." ".id_to_udalost($type["udalost"])." ".id_to_adresa($type["adresa"]);
356}
357 
358function clen_to_adresa($clen){
359$type=MySQL_Query("SELECT id FROM adresy WHERE clen='$clen'");
360$type=MySQL_Fetch_Array($type);
361return $type["id"];
362}
363 
364function id_to_byt($id){
365$type=MySQL_Query("SELECT byt FROM adresy WHERE id='$id'");
366$type=MySQL_Fetch_Array($type);
367return $type["byt"];
368}
369 
370function id_to_ulice($id){
371$type=MySQL_Query("SELECT ulice FROM adresy WHERE id='$id'");
372$type=MySQL_Fetch_Array($type);
373return $type["ulice"];
374}
375 
376function id_to_cp($id){
377$type=MySQL_Query("SELECT cp FROM adresy WHERE id='$id'");
378$type=MySQL_Fetch_Array($type);
379return $type["cp"];
380}
381 
382function id_to_email($id){
383$type=MySQL_Query("SELECT email FROM cleni WHERE id='$id'");
384$type=MySQL_Fetch_Array($type);
385return $type["email"];
386}
387 
388function id_to_adresa($id){
389$type=MySQL_Query("SELECT * FROM adresy WHERE id='$id'");
390$type=MySQL_Fetch_Array($type);
391if ($type["byt"]) return $type["ulice"]." ".$type["cp"]." byt ".$type["byt"];
392return $type["ulice"]." ".$type["cp"];
393}
394 
395function id_to_finance($id){
396$type=MySQL_Query("SELECT * FROM finance WHERE id='$id'");
397$type=MySQL_Fetch_Array($type);
398return id_to_platba($type["platba"])." ".$type["hodnota"];
399}
400 
401function id_to_majetek($id){
402$type=MySQL_Query("SELECT * FROM majetek WHERE id='$id'");
403$type=MySQL_Fetch_Array($type);
404return id_to_zarizeni($type["zarizeni"])." ".$type["scislo"]." ".$type["mac"]." ".$type["komentar"];
405}
406 
407function id_to_objekt($id){
408$type=MySQL_Query("SELECT * FROM objekty WHERE id='$id'");
409$type=MySQL_Fetch_Array($type);
410return $type["nazev"]." ".$type["komentar"];
411}
412 
413function type_count(){
414$type=MySQL_Query("SELECT * FROM poplatky");
415$type=MySQL_Num_Rows($type);
416return $type;
417}
418 
419function flat_to_address($flat){
420if ($flat>999 || $flat==0) return "";
421$patro=10;
422$vchod=420;
423while($flat>33)
424{
425$flat-=33;
426$vchod--;
427}
428while($flat>3)
429{
430$flat-=3;
431$patro--;
432}
433if($vchod==408)$vchod=713;
434if($vchod==407)$vchod=714;
435 
436return $vchod.' - '.$patro;
437}
438 
439/** Kontrola e-mailové adresy
440* @param string $email e-mailová adresa
441* @return bool syntaktická správnost adresy
442* @copyright Jakub Vrána, http://php.vrana.cz
443*/
444function check_email($email)
445{
446 $atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; // znaky tvořící uživatelské jméno
447 $domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; // jedna komponenta domény
448 return eregi("^$atom+(\\.$atom+)*@($domain?\\.)+$domain\$", $email);
449}
450 
451 
452function getweb($URL){
453 
454//Giving the String URL as argument it returns all webpage as a String to you
455$allPage = "";
456 
457if($URL == null){ //Checking provided URL
458echo("<b><font color=\"red\">Please specify a URL to get data from </font></b>");
459}
460 
461$fp= fopen($URL, 'r'); //Opening Connection
462 
463if ( !$fp ) { // Check connection
464echo("<b><font color=\"red\">Connection Failed</font></b>");
465}
466else{
467$num=0;
468while ( !feof($fp) ){
469$pageText[$num] = fread($fp,1024);// read WebPage
470$num++;
471}
472//endwhile;
473}
474 
475$arrayLen=count($pageText);
476for($i=0; $i<$arrayLen; $i++){
477$allPage=$allPage.$pageText[$i];
478}
479fclose($fp);
480return $allPage;
481}
482 
483?>

Powered by WebSVN 2.2.1