forked from HuubMons/HuMo-genealogy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbirthday_rss.php
138 lines (118 loc) · 4.54 KB
/
birthday_rss.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
// author: Louis Ywema
// date: 31-07-2007
// purpose: rssfeed present birthday's
// RSS link in html-page:
// <link rel="alternate" type="application/rss+xml" href="birthday_rss.php" title="RSS feed birthdays" >
// Update by: Huub Mons.
// Added multiple languages.
session_start();
define("CMS_ROOTPATH", "");
include_once(CMS_ROOTPATH."include/db_login.php");
include_once(CMS_ROOTPATH."include/settings_global.php");
include_once(CMS_ROOTPATH."include/person_cls.php");
include_once(CMS_ROOTPATH."include/safe.php");
include_once(CMS_ROOTPATH."include/settings_user.php");
include_once(CMS_ROOTPATH."include/db_functions_cls.php");
$db_functions = New db_functions;
// *** Set timezone ***
include_once(CMS_ROOTPATH."include/timezone.php");
timezone();
$today = date("d M Y");
$month_name = date("F");
$today_day = date("d");
$month_number = date ("M");
$year = date("Y");
$newline ="\n";
/*
header ("Content-Type: application/rss+xml; charset=UTF-8");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<rss version=\"2.0\"
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"
xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\">\n";
*/
$language_rss="en";
if (isset($_GET['lang']) AND file_exists(CMS_ROOTPATH.'languages/'.$_GET['lang'].'/'.$_GET['lang'].'.mo')){ $language_rss=$_GET['lang']; }
// *** Extra check if file exists ***
if (file_exists(CMS_ROOTPATH.'languages/'.$language_rss.'/'.$language_rss.'.mo')){
// *** .mo language text files ***
include_once(CMS_ROOTPATH."languages/gettext.php");
// *** Load ***
$_SESSION["language_selected"]=$language_rss;
Load_default_textdomain();
}
header("Content-Type: application/xml; charset=iso-8859-1");
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
echo '<rss version="2.0">';
// channel info
echo "<channel>\n";
echo "<title>".__('Birthday calendar')."</title>".$newline;
echo '<link>'.$humo_option["rss_link"].'</link>'.$newline;
echo "<description>".__('Whose birthday is it today?')."</description>".$newline;
echo "<language>".__('En-en')."</language>".$newline;
$counter=0;
$datasql = $dbh->query("SELECT * FROM humo_trees WHERE tree_prefix!='EMPTY' ORDER BY tree_order");
while ($dataDb = $datasql->fetch(PDO::FETCH_OBJ)) {
// *** Check is family tree is shown or hidden for user group ***
$hide_tree_array=explode(";",$user['group_hide_trees']);
$hide_tree=false;
for ($x=0; $x<=count($hide_tree_array)-1; $x++){
if ($hide_tree_array[$x]==$dataDb->tree_id){ $hide_tree=true; }
}
if ($hide_tree==false){
$sql="SELECT *,
substring(pers_birth_date,1,2) as birth_day,
substring(pers_birth_date,8,4) as birth_year,
substring(pers_death_date,8,4) as death_year
FROM humo_persons
WHERE pers_tree_id='".$dataDb->tree_id."'
AND (pers_birth_date!=''
AND (substring(pers_birth_date,3,3) = '$month_number' AND CONCAT('0',substring(pers_birth_date,1,1)) = '$today_day')
OR (substring(pers_birth_date,4,3) = '$month_number' AND substring(pers_birth_date,1,2)='$today_day')
) order by pers_lastname";
$query = $dbh->query($sql);
while($record = $query->fetch(PDO::FETCH_OBJ)) {
$person_cls1 = New person_cls;
$person_cls1->construct($record);
$privacy=$person_cls1->privacy;
if($privacy!=1) {
$death_date = $record->pers_death_date;
$calculated_age='';
if ($death_date !=''){
$death_date =' († '.$death_date.')';
if ($record->death_year-$record->birth_year < 120){
$calculated_age = ' ('.($record->death_year-$record->birth_year).')';
}
}
else{
$death_date = '';
if ($year - $record->birth_year<120){
$calculated_age = ' ('.($year - $record->birth_year).')';
}
}
$person_cls = New person_cls;
$name=$person_cls->person_name($record);
$title = $name["standard_name"];
$title = str_replace('&', '&', $title); // Los & teken niet toegestaan in RSS
$title.=$calculated_age.$death_date;
$url = CMS_ROOTPATH.'family.php?database='.$dataDb->tree_prefix.'&id='.$record->pers_indexnr;
// show content
echo "<item>".$newline;
echo "<title>".$title."</title>".$newline;
echo "<link>".$humo_option["rss_link"]."/".$url."</link>".$newline;
echo "</item>".$newline;
$counter++;
}
} // close channel and rss
} // End check if tree is hidden
} // End of multiple family trees
// *** No results found ***
if ($counter==0){
echo "<item>".$newline;
echo "<title>".__('No results found.').$today_day.'-'.$month_number.'-'.$year."</title>".$newline;
echo "</item>".$newline;
}
echo "</channel>".$newline;
echo "</rss>";
?>