<?php
/*
--------------------------------------------------------------------------------
Project: Genealogy
From: 11-sept-2010
To:
Version: 0.6 du 06/03/2011
Author: Pierre FAUQUE, pierre@fauque.net
Filename: init.php (v0.2 27-oct-2010)
--------------------------------------------------------------------------------
*/
// ---------- Language
$language = "en"; // English. Only "en" or "fr" for the moment...
if(file_exists("texts-$language.php")) {
require("texts-$language.php"); }
else {
if(file_exists("texts-en.php")) {
require("texts-en.php"); }
else {
exit("Cannot find default language file. Stop. here!");
}
}
// ---------- Used tables
// Scripts are using defined constants. So, you can change the names of MySQL tables only here, not in scripts
// For genealogy
define(TB_ADDR, 'gen_Addresses'); // Table of postal addresses of people
define(TB_PEOPLE, 'gen_People'); // Table of people
define(TB_TUNIONS, 'gen_Unions'); // Table of type of unions and end of unions
define(TB_UNIONS, 'gen_Marry'); // Table of families
define(TB_NOTES, 'gen_Notes'); // Table of note's people
define(TB_SOURCES, 'gen_Sources'); // Table of sources
define(TB_VISITORS, 'gen_Visitors'); // Visitors who ask for the files PDFFILE or GEDFILE
// For location (specific for France). Can be adapted. See desc-tables.txt
define(TB_DEPARTMTS, 'geo_Departments');
define(TB_COUNTRIES, 'geo_Countries');
define(TB_REGIONS, 'geo_Regions');
define(TB_CITIES, 'geo_Cities');
// ---------- Directories
// Define your root genealogy directory
// example: define(URLSITE, 'http://www.mywebsite.com/gen');
define(URLSITE, 'http://............./...'); // Root genealogy directory
define(PICDIR, './photos'); // Directory of people photos
define(ICODIR, './img'); // Directory of pictures, icons other than people photos
define(SRCDIR, './src'); // Directory of sources
// ---------- Files
define(GEDFILE, 'family.ged');
define(PDFFILE, 'family.pdf');
define(IMGLOGO, 'logo.jpg');
define(BARCODE2D, 'qr_url.jpg'); // See 'README-FIRST.txt #QR_CODE'
// ---------- PDF
define(PDFOBJ, 'FOURRIER - KERMAREC - LE GALL'); // Your family names
define(PDFAUTH, 'Yann KERMAREC'); // Author of the genealogy website (you)
define(PDFAMAIL, 'yann.kermarec@my_isp.com'); // Mail author (your mail address)
define(PDFSUBJ, 'Families FOURRIER-KERMAREC-LE GALL'); // Subject of PDF file
define(PDFKW, 'family genealogy FOURRIER KERMAREC LE GALL Script PHP MySQL'); // keywords of PDF file
define(PDFTITLE, 'People database at');
// ---------- Options
// disp is a field of the table TB_PEOPLE. It's an option number to allow to DISPlay some elements. Actual default is 33 (32+0+0+0+0+1)
// ex: disp = 13 (001101) => allow to show: house phone (b3), mail address (b2), picture (b0),
// but no notes (b5), no postal address (b4) and no mobile phone (b1)
define(PICT, 1); // disp, bit 0: set to 1 allows the diffusion of the photo. (default is 1)
define(MOBILE, 2); // disp, bit 1: set to 1 allows the diffusion of the mobile phone number. (default is 0)
define(MAIL, 4); // disp, bit 2: set to 1 allows the diffusion of the mail address. (default is 0)
define(PHONE, 8); // disp, bit 3: set to 1 allows the diffusion of the house phone number. (default is 0)
define(ADDR, 16); // disp, bit 4: set to 1 allows the diffusion if the postal address. (default is 0)
define(NOTE, 32); // disp, bit 5: set to 1 allows the diffusion of note's people. (default is 0). Each note can be forbidden
define(SOUR, 64); // disp, bit 6: set to 1 allows the diffusion of sources for this person (default is 0). Each source can be forbidden
define(BIO, 128); // disp, bit 7: set to 1 allows the diffusion of the biography of this person (default is 0).
// ---------- For connection to the database
// Setup your informations for the MySQL database connection
define (NOM, "wwwwwwww"); // MySQL user
define (PASS, "xxxxxxxx"); // Password
define (SERVER, "yyyyyyyy"); // Your MySQL server. Often 'localhost'
define (BASE, "zzzzzzzz"); // Name of your database
// Display an eventual error message and stops
function showError($error,$sql) {
$cnx = $GLOBALS["connexion"];
if($error == 1) { echo ERR_200; }
if($error == 2) { echo ERR_201; }
if($error == 3) { echo ERR_202."<br/>".mysql_error($cnx)."<br/>$sql"; }
exit;
}
// Execute a request and return its result or an error message
function ExecRequest($request,$connexion) {
$result = mysql_query($request,$connexion);
if($result) { return $result; } else { showError(3,$request); }
}
// Do the connection to the database server then the selection of the database
if(!@$connexion = mysql_pconnect(SERVER,NOM,PASS)) { showError(1); }
if(!@$ok = mysql_select_db(BASE,$connexion)) { showError(2); }
// ---------- Useful functions
function isphone($client) {
// Différent constructors
$p[] = "alcatel"; $p[] = "benefon"; $p[] = "ericsson";
$p[] = "lg"; $p[] = "motorola"; $p[] = "nokia";
$p[] = "panasonic"; $p[] = "philips"; $p[] = "sagem";
$p[] = "samsung"; $p[] = "siemens"; $p[] = "sony";
$p[] = "trium";
// WAP emulators
$p[] = "klondike"; $p[] = "tagtag";
for($i=0; $i<count($p); $i++) { if(strstr($client,$p[$i])) { return true; } }
return false;
}
$client = strtolower($HTTP_USER_AGENT);
if (isphone($client)) { $phone=1; } else { $phone=0; }
// date_default_timezone_set('GMT'); // You have to verify if this function runs on your web server
// $hour = "e"; // if date_default_timezone_set('GMT') runs. => 29/02/2011 09:37:52 GMT
$hour = "O"; // if date_default_timezone_set('GMT') doesn't run. => 29/02/2011 11:37:52 +0200
function lastMAJ($cnx) {
global $hour;
$request = "SHOW TABLE STATUS WHERE Name='".TB_PEOPLE."' OR Name='".TB_UNIONS."';";
$result = ExecRequest($request,$cnx);
$r1 = mysql_fetch_object($result); $r2 = mysql_fetch_object($result);
return TXT_LUD." : ".date("d/m/Y H:i $hour",strtotime(max($r1->Update_time,$r2->Update_time)));
}
// ---------- Menus
// Icons and menu
define(MNU_PRN, 1); // button Print
define(MNU_LST, 2); // button Nominative List
define(MNU_PIC, 4); // button Pictures
define(MNU_ALL, 8); // button Show all
define(MNU_GED, 16); // button GEDCOM
define(MNU_CRD, 32); // button card
define(MNU_SHT, 64); // button sheet
define(MNU_MSG, 128); // button message
define(MNU_PDF, 256); // button PDF
define(MNU_HLP, 512); // button Help
define(MNU_SEL, 1024); // Control SELECT
define(MNU_CLS, 2048); // button close
// Show the menu-icons
function buttons($btns,$id=0) {
$NA = "Not available in this demo\\nSee the full demo on my website\\nhttp://www.fauque.fr/demogen";
echo "<div class='noprint'>\n<p>\n";
echo "<hr size='1' align='left' width='400' noshade>\n";
if($btns & MNU_SEL) { echo "<form method='post' name='choix'>\n"; }
if($btns & MNU_PRN) { echo "<a href=\"javascript:window.print()\"><img src='".ICODIR."/iprint.png' border='0' alt='Print the page'></a>\n"; }
if($btns & MNU_LST) { echo "<a href=\"showlist.php\"><img src='".ICODIR."/ilist.png' border='0' alt='Show the people list'></a>\n"; }
if($btns & MNU_PIC) { echo "<a href=\"javascript:alert('$NA')\"><img src='".ICODIR."/iphotos.jpg' border='0' alt='See the pictures'></a>\n"; }
if($btns & MNU_ALL) { echo "<a href=\"javascript:alert('$NA')\"><img src='".ICODIR."/iall.png' border='0' alt='Show all'></a>\n"; }
if($btns & MNU_GED) { echo "<a href=\"javascript:getgedcom()\"><img src='".ICODIR."/iged.png' border='0' alt='Download the GEDCOM file'></a>\n"; }
if($btns & MNU_SHT) { echo "<a href=\"showsheet.php?id=$id\"><img src='".ICODIR."/isheet.png' border='0' alt='See the sheet'></a>\n"; }
if($btns & MNU_MSG) { echo "<a href=\"javascript:alert('$NA')\"><img src='".ICODIR."/imail.png' border='0' alt='Send informations about this person'></a>\n"; }
if($btns & MNU_PDF) { echo "<a href=\"javascript:alert('$NA')\"><img src='".ICODIR."/ipdf.png' border='0' alt='Detailed list in PDF file'></a>\n"; }
if($btns & MNU_HLP) { echo "<a href=\"javascript:alert('$NA')\"><img src='".ICODIR."/ihelp.png' border='0' alt='Help'></a>"; }
if($btns & MNU_CLS) { echo "<a href=\"javascript:window.close()\"><img src='".ICODIR."/iexit.png' border='0' alt='Close this window'></a>\n"; }
if($btns & MNU_SEL) {
// commented in this demo script
// download and use the package 2625 (class list) to display easily a combo list to select another person
// -------------------------------
// require("class.liste.php"); // include the class
// $LDind = new liste("people"); // instanciate the list
// $LDind->texte = "--- Choose the person ---"; // redefine the default text
// echo "<br/>\n"; $LDind->write(); // display the combo list
echo "</form>\n";
}
echo "</p>\n</div>\n";
}
// ---------- Various variables
$LogExport = 0; // 1: Log downloaded PDF and/or GEDCOM files ; 0: Don't log
?>
|