/[health_html]/inc/pgOvulacija2.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /inc/pgOvulacija2.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Tue Oct 30 16:11:28 2001 UTC (22 years, 5 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Added the "pošalji e-mailom" feature. Added the ability to register on "Kalendar ovulacije" for e-mail notifications. Other fixes/improvements.

1 <?php
2 include("inc/conn.php");
3 $foo = getdate();
4 $tpl->assign("year", $foo["year"]);
5 $tpl->assign("ME", HTMLSpecialChars("?section=$section&section_menu=$section_menu"));
6 $godine = array();
7 for ($i = $foo["year"] - 1; $i <= $foo["year"] + 1; $i++) array_push($godine, $i);
8 $tpl->assign("godine", $godine);
9 $mjeseci = array();
10 for ($i = 1; $i <= 12; $i++) array_push($mjeseci, $i);
11 $tpl->assign("mjeseci", $mjeseci);
12 $days = array(31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
13 $y = $godina ? $godina : $foo["year"];
14 $dani = array();
15 for ($i = 1; $i <= 31; $i++) array_push($dani, $i);
16 $tpl->assign("dani", $dani);
17 $trajanja = array();
18 for ($i = 24; $i <= 35; $i++) array_push($trajanja, $i);
19 $tpl->assign("trajanja", $trajanja);
20 $tpl->assign("dan", $dan ? $dan : $foo["mday"]);
21 $tpl->assign("mjesec", $mjesec ? $mjesec : $foo["mon"]);
22 $tpl->assign("godina", $godina ? $godina : $foo["year"]);
23 $tpl->assign("trajanje", $trajanje ? $trajanje : 28);
24 $tpl->assign("email", $email ? $email : "");
25 $tpl->assign("ime", $ime);
26 $emailerr = 0;
27 if ($email && !$emailerr) {
28 if (!ereg('^[^\@]+\@[^\.]+\.[^\.]+.*$', $email)) $emailerr = 1;
29 }
30 if ($email && !$print && !$emailerr) {
31 $sql = "SELECT email FROM ovulacija WHERE (email = '$email')";
32 $sth = $dbh->prepare($sql);
33 if (!$sth) error("Cannot prepare query: \"$sql\"");
34 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
35 $row = $sth->fetchrow_array();
36 if ($row) $row = array_shift($row);
37 $sth->finish();
38 if ($row) $emailerr = 2;
39 }
40 $tpl->assign("emailerr", $emailerr);
41 if ($kalendar || $print) {
42 $tpl->assign("old_dan", $dan);
43 $tpl->assign("old_mjesec", $mjesec);
44 $tpl->assign("old_godina", $godina);
45 $tpl->assign("old_trajanje", $trajanje);
46 $tpl->assign("old_kalendar", true);
47 $kal = array();
48 $tim = mktime(0, 0, 0, $mjesec, $dan, $godina);
49 $dat = getdate($tim);
50 $dat = getdate(mktime(0, 0, 0, $mjesec, $dan - (($dat["wday"] - 1) % 7), $godina));
51 $ovul = mktime(0, 0, 0, $mjesec, $dan + $trajanje - 14, $godina);
52 $cd = 0;
53 define("DAY", 24 * 60 * 60);
54 if ($email && !$print && !$emailerr) {
55 $ovul_1 = getdate(mktime(0, 0, 0, $mjesec, $dan + ($trajanje / 2), $godina));
56 $ovul_p = getdate(mktime(0, 0, 0, $ovul_1["mon"], $ovul_1["mday"] - 5, $ovul_1["year"]));
57 $ovul_k = getdate(mktime(0, 0, 0, $ovul_1["mon"], $ovul_1["mday"] + 2, $ovul_1["year"]));
58 $menga = getdate(mktime(0, 0, 0, $mjesec, $dan + $trajanje, $godina));
59 $sql = "INSERT INTO ovulacija (email, ime, type, dan, mjesec, godina) VALUES ('$email', '$ime', 1, ".$ovul_p["mday"].", ".$ovul_p["mon"].", ".$ovul_p["year"].")";
60 $dbh->dbh_do($sql);
61 $sql = "INSERT INTO ovulacija (email, ime, type, dan, mjesec, godina) VALUES ('$email', '$ime', 2, ".$ovul_1["mday"].", ".$ovul_1["mon"].", ".$ovul_1["year"].")";
62 $dbh->dbh_do($sql);
63 $sql = "INSERT INTO ovulacija (email, ime, type, dan, mjesec, godina) VALUES ('$email', '$ime', 3, ".$ovul_k["mday"].", ".$ovul_k["mon"].", ".$ovul_k["year"].")";
64 $dbh->dbh_do($sql);
65 $sql = "INSERT INTO ovulacija (email, ime, type, dan, mjesec, godina) VALUES ('$email', '$ime', 4, ".$menga["mday"].", ".$menga["mon"].", ".$menga["year"].")";
66 $dbh->dbh_do($sql);
67 $tpl->assign("emailok", true);
68 }
69 for ($i = 0; $i < 7; $i++) {
70 $tmp = array();
71 for ($j = 0; $j < 7; $j++) {
72 if ($dat["mon"] > $mjesec) $cd++;
73 if ($dat["mon"] == $mjesec && $dat["mday"] >= $dan) $cd++;
74 $tim2 = mktime(0, 0, 0, $dat["mon"], $dat["mday"], $godina);
75 $msg = 0;
76 if ($tim2 == $tim) $msg = -1;
77 if ($tim2 == mktime(0, 0, 0, $mjesec, $dan + $trajanje, $godina)) $msg = 1;
78 if ($tim2 == mktime(0, 0, 0, $mjesec, $dan + $trajanje + 2, $godina)) $msg = -2;
79 if ($ovul - $tim2 == DAY || $ovul - $tim2 == (DAY * 2)) $msg = 9;
80 if ($tim2 == $ovul) $msg = 10;
81 if ($tim2 - $ovul == (DAY * 10)) $msg = 3;
82 if ($tim2 - $ovul == (DAY * 12)) $msg = 2;
83 if ($tim2 - $ovul == DAY || $tim2 - $ovul == DAY * 2) $msg = 4;
84 if ($ovul - $tim2 == DAY * 3 || $ovul - $tim2 == DAY * 4 || $ovul - $tim2 == DAY * 5) $msg = 5;
85 array_push($tmp, array(
86 "cd" => $cd,
87 "dat_dan" => $dat["mday"],
88 "dat_mjesec" => $dat["mon"],
89 "msg" => $msg
90 ));
91 $dat = getdate(mktime(0, 0, 0, $dat["mon"], $dat["mday"] + 1, $godina));
92 }
93 array_push($kal, $tmp);
94 }
95 $tp = new Smarty();
96 $tp->assign("section", $section);
97 $tp->assign("section_menu", $section_menu);
98 $tp->assign("section_menu2", $section_menu2);
99 $tp->assign("dan", $dan);
100 $tp->assign("mjesec", $mjesec);
101 $tp->assign("godina", $godina);
102 $tp->assign("trajanje", $trajanje);
103 $tp->assign("ime", $ime);
104 $tp->assign("ime2", urlencode($ime));
105 $tp->assign("kal", $kal);
106 $table = $tp->fetch("kalendar".($print?"-print":"").".tpl");
107 $tpl->assign("CONTENT", $table);
108 if (!$print) {
109 include_once("print.php");
110 $tpl->assign("PRINT", GetPrint(array("dan", "mjesec", "godina", "trajanje", "ime"), false));
111 } else $main_template = "wrapper.tpl";
112 }
113 if (!$ns4) {
114 $date = ($dan && $mjesec && $godina) ? "new Date($godina, $mjesec, $dan)" : "null";
115 if (!$godina) $godina = $foo["year"];
116 $before = $godina - $foo["year"] + 1;
117 $after = $foo["year"] - $godina + 1;
118 $onload .= "DS = new DateSelector(document.forms[1], $date, $before, $after);";
119 }
120 $dbh->disconnect();
121 ?>

  ViewVC Help
Powered by ViewVC 1.1.26