first commit

This commit is contained in:
egarette@silique.fr 2023-02-14 14:19:15 +01:00
commit 3301706ca8
9043 changed files with 1270346 additions and 0 deletions
README.md
seed
README.md
dotclear
galette
README.mdapplicationservice.yml
dictionaries
extras/machine
manual/image/postinstall
galette.sh
galette
ajouter_adherent.phpajouter_contribution.phpetiquettes_adherents.phpetiquettes_adherents_2.phpfooter.phpgalette.cssgestion_adherents.phpgestion_contributions.phpheader.phpicon-mini.png
images
includes
index.php

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# dataset-gnunux
[This dataset application services](seed/README.md)

6
seed/README.md Normal file
View file

@ -0,0 +1,6 @@
# Application services
- [dotclear](dotclear/README.md): Dotclear an open-source web publishing software
- [galette](galette/README.md): Galette, a membership management web application towards non profit organizations
- [joomla](joomla/README.md): Joomla, Joomla Content Management System (CMS)
- [sensmotdire](sensmotdire/README.md): Sens Mot Dire, a french conjugaison service

44
seed/dotclear/README.md Normal file
View file

@ -0,0 +1,44 @@
---
gitea: none
include_toc: true
---
# dotclear
[All applications services for this dataset.](../README.md)
## Description
Dotclear an open-source web publishing software.
[For more informations](https://dotclear.org)
## Dependances
- [base-fedora-36 (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base-fedora-36/README.md)
- [base-fedora (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base-fedora/README.md)
- [systemd (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/systemd/README.md)
- [base-machine (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base-machine/README.md)
- [base (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base/README.md)
- [dns-local (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/dns-local/README.md)
- [pki-tls (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/pki-tls/README.md)
- [postgresql-client (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/postgresql-client/README.md)
- [nginx-https (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/nginx-https/README.md)
- [nginx-common (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/nginx-common/README.md)
- [reverse-proxy-client (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/reverse-proxy-client/README.md)
- [php-fpm (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/php-fpm/README.md)
- [php (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/php/README.md)
## Variables
### Général (*general*)
#### Dotclear (*general.dotclear*)
| Description | Type |
|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
| **Adresse courriel de l'administrateur** (*[admin_mail_from](dictionaries/40_dotclear.xml)*) | [mail](https://forge.cloud.silique.fr/risotto/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) |
- [+]: variable is multiple
- **bold**: variable is mandatory

View file

@ -0,0 +1,8 @@
format: '0.1'
description: Dotclear an open-source web publishing software
website: https://dotclear.org
depends:
- base-fedora-36
- postgresql-client
- nginx-https
- php-fpm

View file

@ -0,0 +1,26 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<services>
<service name="dotclear" target="multi-user" engine="none">
<file>/etc/dotclear/config.php</file>
<file source="dotclear.nginx.conf">/etc/nginx/default.d/dotclear.conf</file>
<file source="tmpfile-dotclear.conf">/tmpfiles.d/0dotclear.conf</file>
</service>
</services>
<variables>
<family name="dotclear" description="Dotclear">
<variable name="admin_mail_from" type="mail" description="Adresse courriel de l'administrateur" mandatory="True"/>
<variable name="dotclear_secret_key" type="password" hidden="True"/>
</family>
</variables>
<constraints>
<fill name="get_password">
<param name="server_name" type="variable">domain_name_eth0</param>
<param name="username">secret_key</param>
<param name="description">dotclear</param>
<param name="type">cleartext</param>
<param name="hide" type="variable">hide_secret</param>
<target>dotclear_secret_key</target>
</fill>
</constraints>
</rougail>

View file

@ -0,0 +1,16 @@
set -e
ORIPWD=$PWD
mkdir -p "$IMAGE_NAME_RISOTTO_IMAGE_DIR_TMP/usr/local/share"
cd "$IMAGE_NAME_RISOTTO_IMAGE_DIR_TMP/usr/local/share"
wget -q "https://download.dotclear.net/latest.tar.gz"
tar xf *tar.gz
rm -f *tar.gz
chown -R root: dotclear
cd dotclear
rmdir public
ln -s /srv/dotclear/public public
cd inc
ln -s /etc/dotclear/config.php config.php
cd $ORIPWD

View file

@ -0,0 +1 @@
PKG="$PKG php-pgsql php-mbstring php-xml"

View file

@ -0,0 +1,108 @@
<?php
/**
* @package Dotclear
*
* @copyright Olivier Meunier & Association Dotclear
* @copyright GPL-2.0-only
*/
if (!defined('DC_RC_PATH')) {
return;
}
// Database driver (mysql (deprecated, disabled in PHP7), mysqli, mysqlimb4 (full UTF-8), pgsql, sqlite)
define('DC_DBDRIVER', 'pgsql');
// Database hostname (usually "localhost")
define('DC_DBHOST', '%%pg_client_server_domainname');
// Database user
define('DC_DBUSER', '%%pg_client_username');
// Database password
define('DC_DBPASSWORD', '%%pg_client_password');
// Database name
define('DC_DBNAME', '%%pg_client_database');
// Tables' prefix
define('DC_DBPREFIX', 'dc_');
// Persistent database connection
define('DC_DBPERSIST', false);
// Crypt key (password storage)
define('DC_MASTER_KEY', '%%dotclear_secret_key');
// Admin URL. You need to set it for some features.
%set %%location = %%revprox_client_external_domainnames[0].revprox_client_location
define('DC_ADMIN_URL', 'https://%%revprox_client_external_domainnames[0]%%{location}admin');
// Admin mail from address. For password recovery and such.
define('DC_ADMIN_MAILFROM', '%%admin_mail_from');
// Cookie's name
define('DC_SESSION_NAME', 'dcxd');
// Session TTL
//define('DC_SESSION_TTL','120 seconds');
// Plugins root
define('DC_PLUGINS_ROOT', '/srv/dotclear/plugins');
// Template cache directory
//>GNUNUX
//define('DC_TPL_CACHE', path::real(__DIR__ . '/..') . '/cache');
define('DC_TPL_CACHE', '/srv/dotclear/cache');
//<GNUNUX
// Var directory
define('DC_VAR', '/srv/dotclear/var');
// Cryptographic algorithm
define('DC_CRYPT_ALGO', 'sha512');
// Vendor name
//define('DC_VENDOR_NAME', 'Dotclear');
// Do not check for update
//define('DC_NOT_UPDATE', false);
//>GNUNUX
define('DC_NOT_UPDATE', false);
//<GNUNUX
// Update URL
//define('DC_UPDATE_URL','https://download.dotclear.org/versions.xml');
// Update channel (stable, unstable, testing)
//define('DC_UPDATE_VERSION', 'stable');
// Proxy config
//define('HTTP_PROXY_HOST','127.0.0.1');
//define('HTTP_PROXY_PORT','8080');
// Reverse Proxy
//define('DC_REVERSE_PROXY',false);
//>GNUNUX
define('DC_REVERSE_PROXY',true);
//<GNUNUX
// Show hidden media dirs
//define('DC_SHOW_HIDDEN_DIRS', false);
// Store update checking
//define('DC_STORE_NOT_UPDATE', false);
// If you have PATH_INFO issue, uncomment following lines
//if (!isset($_SERVER['ORIG_PATH_INFO'])) {
// $_SERVER['ORIG_PATH_INFO'] = '';
//}
//$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
// If you have mail problems, uncomment following lines and adapt it to your hosting configuration
// For more information about this setting, please refer to http://doc.dotclear.net/2.0/admin/install/custom-sendmail
//function _mail($to, $subject, $message, $headers)
//{
// socketMail::$smtp_relay = 'my.smtp.relay.org';
// socketMail::mail($to, $subject, $message, $headers);
//}

View file

@ -0,0 +1,34 @@
# To allow POST on static pages
error_page 405 =200 $uri;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains;';
add_header Referrer-Policy no-referrer always;
%set %%locations = []
%for %%revprox in %%revprox_client_external_domainnames
%set %%location = %%revprox.revprox_client_location
%if %%location in %%locations
%continue
%end if
%%locations.append(%%location)
location %%location {
%if %%location == '/'
root %slurp
%else
alias %slurp
%end if
/usr/local/share/dotclear/;
index index.php;
location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
fastcgi_pass php-fpm;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
%end for

View file

@ -0,0 +1,18 @@
[Unit]
Description=Dotclear management
After=risotto.target
Before=nginx.service php-fpm.service
[Service]
Type=oneshot
ExecStart=/usr/bin/cp -f /usr/local/share/dotclear/var/.htaccess /srv/dotclear/var/
ExecStart=/usr/bin/cp -f /usr/local/share/dotclear/cache/.htaccess /srv/dotclear/cache/
ExecStart=/usr/bin/cp -f /usr/local/share/dotclear/plugins/.htaccess /srv/dotclear/plugins/
ExecStart=/usr/bin/rm -rf /srv/dotclear/plugins/*
ExecStart=/bin/bash -c '/usr/bin/cp -fr /usr/local/share/dotclear/plugins/* /srv/dotclear/plugins/'
User=nginx
Group=nginx
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,4 @@
d /srv/dotclear/cache 770 root nginx - -
d /srv/dotclear/public 770 root nginx - -
d /srv/dotclear/var 770 root nginx - -
d /srv/dotclear/plugins 770 root nginx - -

45
seed/galette/README.md Normal file
View file

@ -0,0 +1,45 @@
---
gitea: none
include_toc: true
---
# galette
[All applications services for this dataset.](../README.md)
## Description
Galette, a membership management web application towards non profit organizations.
[For more informations](https://galette.eu/)
## Dependances
- [base-fedora-36 (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base-fedora-36/README.md)
- [base-fedora (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base-fedora/README.md)
- [systemd (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/systemd/README.md)
- [base-machine (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base-machine/README.md)
- [base (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base/README.md)
- [dns-local (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/dns-local/README.md)
- [pki-tls (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/pki-tls/README.md)
- [mariadb-client (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/mariadb-client/README.md)
- [nginx-https (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/nginx-https/README.md)
- [nginx-common (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/nginx-common/README.md)
- [reverse-proxy-client (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/reverse-proxy-client/README.md)
- [php-fpm (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/php-fpm/README.md)
- [php (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/php/README.md)
## Variables
### Machine (*machine*)
| Description | Values |
|-------------------------------------------------|----------|
| *[**var_size**](extras/machine/20_galette.xml)* | 256 |
| *[**add_tmp**](extras/machine/20_galette.xml)* | False |
| *[**add_srv**](extras/machine/20_galette.xml)* | False |
| *[**add_swap**](extras/machine/20_galette.xml)* | False |
- [+]: variable is multiple
- **bold**: variable is mandatory

View file

@ -0,0 +1,8 @@
format: '0.1'
description: Galette, a membership management web application towards non profit organizations
website: https://galette.eu/
depends:
- base-fedora-36
- mariadb-client
- nginx-https
- php-fpm

View file

@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail version="0.10">
<services>
<service name="galette" manage="False">
<file>/etc/galette/config.inc.php</file>
<file source="galette.nginx.conf">/etc/nginx/default.d/galette.conf</file>
</service>
</services>
</rougail>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<rougail version="0.10">
<variables>
<variable name="var_size" redefine="True">
<value>256</value>
</variable>
<variable name="add_tmp" redefine="True">
<value>False</value>
</variable>
<variable name="add_srv" redefine="True">
<value>False</value>
</variable>
<variable name="add_swap" redefine="True">
<value>False</value>
</variable>
<variable name='memory' redefine="True" exists="True">
<value>512</value>
</variable>
</variables>
</rougail>

View file

@ -0,0 +1,8 @@
set -e
mkdir -p "$IMAGE_NAME_RISOTTO_IMAGE_DIR_TMP/usr/local/share"
cp -a $IMAGE_DIR_RECIPIENT_IMAGE/postinstall/galette "$IMAGE_NAME_RISOTTO_IMAGE_DIR_TMP/usr/local/share"
chown -R root: "$IMAGE_NAME_RISOTTO_IMAGE_DIR_TMP/usr/local/share/galette"
ln -s /etc/galette/config.inc.php "$IMAGE_NAME_RISOTTO_IMAGE_DIR_TMP/usr/local/share/galette/includes/config.inc.php"
cd $ORIPWD

View file

@ -0,0 +1,810 @@
<?php
/* ajouter_adherent.php
* - Saisie d'un adhérent
* Copyright (c) 2004 Frédéric Jaqcuot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
include("includes/config.inc.php");
include(WEB_ROOT."includes/database.inc.php");
include(WEB_ROOT."includes/functions.inc.php");
include(WEB_ROOT."includes/lang.inc.php");
include(WEB_ROOT."includes/session.inc.php");
if ($_SESSION["logged_status"]==0)
{
header("location: index.php");
die();
}
// On vérifie si on a une référence => modif ou création
$values = Array();
$id_adh = "";
$values['date_crea_adh'] = "";
if (isset($_GET["id_adh"]))
if (is_numeric($_GET["id_adh"]))
$id_adh = $_GET["id_adh"];
if (isset($_POST["id_adh"]))
if (is_numeric($_POST["id_adh"]))
$id_adh = $_POST["id_adh"];
// Si c'est un user qui est loggé, on va à sa fiche
if ($_SESSION["admin_status"]!=1)
$id_adh = $_SESSION["logged_id_adh"];
$values['id_adh'] = $id_adh;
// variables d'erreur (pour affichage)
$error_detected = "";
$warning_detected = "";
$confirm_detected = "";
//
// DEBUT parametrage des champs
// On recupere de la base la longueur et les flags des champs
// et on initialise des valeurs par defaut
// recuperation de la liste de champs de la table
$fields = $DB->MetaColumns(PREFIX_DB."adherents");
foreach ($fields as $champ => $proprietes)
{
$proprietes_arr = get_object_vars($proprietes);
// on obtient name, max_length, type, not_null, has_default, primary_key,
// auto_increment et binary
$fieldname = $proprietes_arr["name"];
// on ne met jamais a jour id_adh
if ($fieldname!="id_adh" && $fieldname!="date_echeance")
$$fieldname= "";
$fieldlen = $fieldname."_len";
$fieldreq = $fieldname."_req";
// definissons aussi la longueur des input text
$max_tmp = $proprietes_arr["max_length"];
if ($max_tmp == "-1")
$max_tmp = 10;
$fieldlen = $fieldname."_len";
$$fieldlen=$max_tmp;
// et s'ils sont obligatoires (à partir de la base)
if ($proprietes_arr["not_null"]==1)
$$fieldreq = "style=\"color: #FF0000;\"";
else
$$fieldreq = "";
}
reset($fields);
// et les valeurs par defaut
$id_statut = "4";
$values['titre_adh'] = "1";
//
// FIN parametrage des champs
//
//
// Validation du formulaire
//
if (isset($_POST["valid"]))
{
// verification de champs
$update_string = "";
$insert_string_fields = "";
$insert_string_values = "";
// recuperation de la liste de champs de la table
foreach ($fields as $champ => $proprietes)
{
$proprietes_arr = get_object_vars($proprietes);
// on obtient name, max_length, type, not_null, has_default, primary_key,
// auto_increment et binary
$fieldname = $proprietes_arr["name"];
// on précise les champs non modifiables
if (
($_SESSION["admin_status"]==1 && $fieldname!="id_adh"
&& $fieldname!="date_echeance") ||
($_SESSION["admin_status"]==0 && $fieldname!="date_crea_adh"
&& $fieldname!="panier_adh"
&& $fieldname!="pain_adh"
&& $fieldname!="volaille_adh"
&& $fieldname!="chevre_adh"
&& $fieldname!="boeuf_adh"
&& $fieldname!="veau_adh"
&& $fieldname!="cochon_adh"
&& $fieldname!="farine_adh"
&& $fieldname!="id_adh"
&& $fieldname!="titre_adh"
&& $fieldname!="id_statut"
&& $fieldname!="nom_adh"
&& $fieldname!="prenom_adh"
&& $fieldname!="activite_adh"
&& $fieldname!="bool_exempt_adh"
&& $fieldname!="bool_admin_adh"
&& $fieldname!="date_echeance"
&& $fieldname!="info_adh")
)
{
if (isset($_POST[$fieldname]))
$post_value=trim($_POST[$fieldname]);
else
$post_value="";
// on declare les variables pour la présaisie en cas d'erreur
$values[$fieldname] = htmlentities(stripslashes($post_value),ENT_QUOTES);
$fieldreq = $fieldname."_req";
// vérification de la présence des champs obligatoires
if ($$fieldreq!="" && $post_value=="")
$error_detected .= "<LI>"._T("- Champ obligatoire non renseigné.")."</LI>";
else
{
// validation des dates
if($proprietes_arr["type"]=="date" && $post_value!="")
{
if (preg_match("/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/", $post_value, $array_jours) || $post_value=="")
{
if (checkdate($array_jours[2],$array_jours[1],$array_jours[3]) || $post_value=="")
// $value=$DB->DBDate(mktime(0,0,0,$array_jours[2],$array_jours[1],$array_jours[3]));
$value = $DB->DBDate($array_jours[3].'/'.$array_jours[2].'/'.$array_jours[1]);
else
$error_detected .= "<LI>"._T("- Date non valide !")."</LI>";
}
else
$error_detected .= "<LI>"._T("- Mauvais format de date (jj/mm/aaaa) !")."</LI>";
}
elseif ($fieldname=="email_adh")
{
$post_value=strtolower($post_value);
if (!is_valid_email($post_value) && $post_value!="")
$error_detected .= "<LI>"._T("- Adresse E-mail non valide !")."</LI>";
else
$value = $DB->qstr($post_value, true);
if ($post_value=="" && isset($_POST["mail_confirm"]))
$error_detected .= "<LI>"._T("- Vous ne pouvez pas envoyer de confirmation par mail si l'adhérent n'a pas d'adresse !")."</LI>";
}
elseif ($fieldname=="url_adh")
{
if (!is_valid_web_url($post_value) && $post_value!="" && $post_value!="http://")
$error_detected .= "<LI>"._T("- Adresse web non valide ! Oubli du http:// ?")."</LI>";
else
{
if ($post_value=="http://")
$post_value="";
$value = $DB->qstr($post_value, true);
}
}
elseif ($fieldname=="login_adh")
{
if (strlen($post_value)<4)
$error_detected .= "<LI>"._T("- L'identifiant doit être composé d'au moins 4 caractères !")."</LI>";
else
{
// on vérifie que le login n'est pas déjà utilisé
$requete = "SELECT id_adh
FROM ".PREFIX_DB."adherents
WHERE login_adh=". $DB->qstr($post_value, true);
if ($id_adh!="")
$requete .= " AND id_adh!=" . $DB->qstr($id_adh, true);
echo $requete;
$result = $DB->Execute($requete);
if (!$result->EOF || $post_value==PREF_ADMIN_LOGIN)
$error_detected .= "<LI>"._T("- Cet identifiant est déjà utilisé par un autre adhérent !")."</LI>";
else
$value = $DB->qstr($post_value, true);
}
}
elseif ($fieldname=="mdp_adh")
{
if (strlen($post_value)<4)
$error_detected .= "<LI>"._T("- Le mot de passe doit être composé d'au moins 4 caractères !")."</LI>";
else
$value = $DB->qstr($post_value, true);
}
else
{
// on se contente d'escaper le html et les caracteres speciaux
$value = $DB->qstr($post_value, true);
}
// mise à jour des chaines d'insertion/update
if ($value=="''")
$value="NULL";
$update_string .= ",".$fieldname."=".$value;
$insert_string_fields .= ",".$fieldname;
$insert_string_values .= ",".$value;
}
}
}
reset($fields);
// modif ou ajout
if ($error_detected=="")
{
if ($id_adh!="")
{
// modif
$requete = "UPDATE ".PREFIX_DB."adherents
SET " . substr($update_string,1) . "
WHERE id_adh=" . $id_adh;
$DB->Execute("SET NAMES utf8");
$DB->Execute($requete);
$DB->Execute("SET NAMES latin1");
$result = $DB->Execute("SET NAMES latin1");
dblog(_T("Mise à jour de la fiche adhérent :")." ".strtoupper($_POST["nom_adh"])." ".$_POST["prenom_adh"], $requete);
$date_fin = get_echeance($DB, $id_adh);
if ($date_fin!="")
// $date_fin_update = $DB->DBDate(mktime(0,0,0,$date_fin[1],$date_fin[0],$date_fin[2]));
$date_fin_update = $DB->DBDate($date_fin[2].'/'.$date_fin[1].'/'.$date_fin[0]);
else
$date_fin_update = "NULL";
$requete = "UPDATE ".PREFIX_DB."adherents
SET date_echeance=".$date_fin_update."
WHERE id_adh=" . $id_adh;
}
else
{
// ajout
$insert_string_fields = substr($insert_string_fields,1);
$insert_string_values = substr($insert_string_values,1);
$requete = "INSERT INTO ".PREFIX_DB."adherents
(" . $insert_string_fields . ")
VALUES (" . $insert_string_values . ")";
dblog(_T("Ajout de la fiche adhérent :")." ".strtoupper($_POST["nom_adh"])." ".$_POST["prenom_adh"], $requete);
}
if ($DB->Execute($requete) === false) {
print 'error inserting: '. $DB->ErrorMsg().'<BR>';
return;
};
// il est temps d'envoyer un mail
if (isset($_POST["mail_confirm"]))
if ($_POST["mail_confirm"]=="1")
if ($email_adh!="")
{
$mail_subject = _T("Vos identifiants Galette");
$mail_text = _T("Bonjour,")."\n";
$mail_text .= "\n";
$mail_text .= _T("Vous venez d'être inscrit sur le système de gestion d'adhérents de l'association.")."\n";
$mail_text .= _T("Il vous est désormais possible de suivre en temps réel l'état de votre adhésion")."\n";
$mail_text .= _T("et de mettre à jour vos coordonnées par l'interface web prévue à cet effet.")."\n";
$mail_text .= "\n";
$mail_text .= _T("Veuillez vous identifier à cette adresse :")."\n";
$mail_text .= "http://".$_SERVER["SERVER_NAME"].dirname($_SERVER["REQUEST_URI"])."\n";
$mail_text .= "\n";
$mail_text .= _T("Identifiant :")." ".custom_html_entity_decode($values['login_adh'])."\n";
$mail_text .= _T("Mot de passe :")." ".custom_html_entity_decode($values['mdp_adh'])."\n";
$mail_text .= "\n";
$mail_text .= _T("A très bientôt !")."\n";
$mail_text .= "\n";
$mail_text .= _T("(ce mail est un envoi automatique)")."\n";
$mail_headers = "From: ".PREF_EMAIL_NOM." <".PREF_EMAIL.">\n";
mail ($email_adh,$mail_subject,$mail_text, $mail_headers);
}
// récupération du max pour insertion photo
// ou passage en mode modif apres insertion
if ($id_adh=="")
{
$requete = "SELECT max(id_adh)
AS max
FROM ".PREFIX_DB."adherents";
$max = $DB->Execute($requete);
$id_adh_new = $max->fields["max"];
}
else
$id_adh_new = $id_adh;
if (isset($_FILES["photo"]["tmp_name"]))
if ($_FILES["photo"]["tmp_name"]!="none" &&
$_FILES["photo"]["tmp_name"]!="")
{
if ($_FILES['photo']['type']=="image/jpeg" ||
(function_exists("ImageCreateFromGif") && $_FILES['photo']['type']=="image/gif") ||
$_FILES['photo']['type']=="image/png" ||
$_FILES['photo']['type']=="image/x-png")
{
$tmp_name = $HTTP_POST_FILES["photo"]["tmp_name"];
// extension du fichier (en fonction du type mime)
if ($_FILES['photo']['type']=="image/jpeg")
$ext_image = ".jpg";
if ($_FILES['photo']['type']=="image/png" || $_FILES['photo']['type']=="image/x-png")
$ext_image = ".png";
if ($_FILES['photo']['type']=="image/gif")
$ext_image = ".gif";
// suppression ancienne photo
// NB : une verification sur le type de $id_adh permet d'eviter une faille
// du style $id_adh = "../../../image"
@unlink(WEB_ROOT . "photos/".$id_adh_new.".jpg");
@unlink(WEB_ROOT . "photos/".$id_adh_new.".gif");
@unlink(WEB_ROOT . "photos/".$id_adh_new.".jpg");
@unlink(WEB_ROOT . "photos/tn_".$id_adh_new.".jpg");
@unlink(WEB_ROOT . "photos/tn_".$id_adh_new.".gif");
@unlink(WEB_ROOT . "photos/tn_".$id_adh_new.".jpg");
// copie fichier temporaire
if (!@move_uploaded_file($tmp_name,WEB_ROOT . "photos/".$id_adh_new.$ext_image))
$warning_detected .= "<LI>"._T("- La photo semble ne pas avoir été transmise correstement. L'enregistrement a cependant été effectué.")."</LI>";
else
resizeimage(WEB_ROOT . "photos/".$id_adh_new.$ext_image,WEB_ROOT . "photos/tn_".$id_adh_new.$ext_image,130,130);
}
else
{
if (function_exists("imagegif"))
$warning_detected .= "<LI>"._T("- Le fichier transmis n'est pas une image valide (GIF, PNG ou JPEG). L'enregistrement a cependant été effectué.")."</LI>";
else
$warning_detected .= "<LI>"._T("- Le fichier transmis n'est pas une image valide (PNG ou JPEG). L'enregistrement a cependant été effectué.")."</LI>";
}
}
// retour à la liste ou passage à la contribution
if ($warning_detected=="" && $id_adh=="")
{
header("location: ajouter_contribution.php?id_adh=".$id_adh_new);
die();
}
elseif ($warning_detected=="" && !isset($_FILES["photo"]))
{
header("location: gestion_adherents.php");
die();
}
elseif ($warning_detected=="" && ($_FILES["photo"]["tmp_name"]=="none" || $_FILES["photo"]["tmp_name"]==""))
{
header("location: gestion_adherents.php");
die();
}
$id_adh=$id_adh_new;
}
}
// suppression photo
if (isset($_POST["del_photo"]))
{
@unlink(WEB_ROOT . "photos/" . $id_adh . ".jpg");
@unlink(WEB_ROOT . "photos/" . $id_adh . ".png");
@unlink(WEB_ROOT . "photos/" . $id_adh . ".gif");
@unlink(WEB_ROOT . "photos/tn_" . $id_adh . ".jpg");
@unlink(WEB_ROOT . "photos/tn_" . $id_adh . ".png");
@unlink(WEB_ROOT . "photos/tn_" . $id_adh . ".gif");
}
//
// Pré-remplissage des champs
// avec des valeurs issues de la base
// -> donc uniquement si l'enregistrement existe et que le formulaire
// n'a pas déja été posté avec des erreurs (pour pouvoir corriger)
if (!isset($_POST["valid"]) || (isset($_POST["valid"]) && $error_detected==""))
if ($id_adh != "")
{
// recup des données
$requete = "SELECT *
FROM ".PREFIX_DB."adherents
WHERE id_adh=$id_adh";
$result = $DB->Execute($requete);
if ($result->EOF)
{
header("location: index.php");
die();
}
// recuperation de la liste de champs de la table
//$fields = &$DB->MetaColumns(PREFIX_DB."cotisations");
foreach ($fields as $champ => $proprietes)
{
//echo $proprietes_arr["name"]." -- (".$result->fields[$proprietes_arr["name"]].")<br>";
$val="";
$proprietes_arr = get_object_vars($proprietes);
// on obtient name, max_length, type, not_null, has_default, primary_key,
// auto_increment et binary
// déclaration des variables correspondant aux champs
// et reformatage des dates.
// on doit faire cette verif pour une enventuelle valeur "NULL"
// non renvoyée -> ex: pas de societe membre
// sinon on obtient un warning
if (isset($result->fields[$proprietes_arr["name"]]))
$val = $result->fields[$proprietes_arr["name"]];
if($proprietes_arr["type"]=="date" && $val!="")
{
list($a,$m,$j)=explode("-",$val);
$val="$j/$m/$a";
}
$values[$proprietes_arr["name"]]=htmlentities(stripslashes(addslashes($val)), ENT_QUOTES);
}
reset($fields);
}
else
{
// initialisation des champs
}
// la date de creation de fiche, ici vide si nouvelle fiche
if ($values['date_crea_adh']=="")
$values['date_crea_adh'] = date("d/m/Y");
if ($url_adh=="")
$url_adh = "http://";
if ($mdp_adh=="")
$mdp_adh = makeRandomPassword();
// variable pour la desactivation de champs
if ($_SESSION["admin_status"]==0)
$disabled_field = "disabled";
else
$disabled_field = "";
include("header.php");
?>
<H1 class="titre"><?php echo _T("Fiche adhérent"); ?> (<?php if ($id_adh!="") echo _T("modification"); else echo _T("création"); ?>)</H1>
<FORM action="ajouter_adherent.php" method="post" enctype="multipart/form-data">
<?php
// Affichage des erreurs
if ($error_detected!="")
{
?>
<DIV id="errorbox">
<H1><?php echo _T("- ERREUR -"); ?></H1>
<UL>
<?php echo $error_detected; ?>
</UL>
</DIV>
<?php
}
if ($warning_detected!="")
{
?>
<DIV id="warningbox">
<H1><?php echo _T("- AVERTISSEMENT -"); ?></H1>
<UL>
<?php echo $warning_detected; ?>
</UL>
</DIV>
<?php
}
?>
<BLOCKQUOTE>
<DIV align="center">
<TABLE border="0" id="input-table">
<TR>
<TH <?php echo $titre_adh_req ?> id="libelle"><?php echo _T("Titre :"); ?></TH>
<TD colspan="3">
<INPUT type="radio" name="titre_adh" value="3"<?php isChecked($values['titre_adh'],"3") ?> <?php echo $disabled_field; ?>> <?php echo _T("Mademoiselle"); ?>&nbsp;&nbsp;
<INPUT type="radio" name="titre_adh" value="2"<?php isChecked($values['titre_adh'],"2") ?> <?php echo $disabled_field; ?>> <?php echo _T("Madame"); ?>&nbsp;&nbsp;
<INPUT type="radio" name="titre_adh" value="1"<?php isChecked($values['titre_adh'],"1") ?> <?php echo $disabled_field; ?>> <?php echo _T("Monsieur"); ?>&nbsp;&nbsp;
</TD>
</TR>
<TR>
<TH <?php echo $nom_adh_req ?> id="libelle"><?php echo _T("Nom :"); ?></TH>
<TD><INPUT type="text" name="nom_adh" value="<?php if(array_key_exists('nom_adh', $values)) echo $values['nom_adh']; ?>" maxlength="<?php echo $nom_adh_len; ?>" <?php echo $disabled_field; ?>></TD>
<TD colspan="2" rowspan="5" align="center" width="130">
<?php
$image_adh = "";
if (file_exists(WEB_ROOT . "photos/tn_" . $id_adh . ".jpg"))
$image_adh = "photos/tn_" . $id_adh . ".jpg";
elseif (file_exists(WEB_ROOT . "photos/tn_" . $id_adh . ".gif"))
$image_adh = "photos/tn_" . $id_adh . ".gif";
elseif (file_exists(WEB_ROOT . "photos/tn_" . $id_adh . ".png"))
$image_adh = "photos/tn_" . $id_adh . ".png";
elseif (file_exists(WEB_ROOT . "photos/" . $id_adh . ".jpg"))
$image_adh = "photos/" . $id_adh . ".jpg";
elseif (file_exists(WEB_ROOT . "photos/" . $id_adh . ".gif"))
$image_adh = "photos/" . $id_adh . ".gif";
elseif (file_exists(WEB_ROOT . "photos/" . $id_adh . ".png"))
$image_adh = "photos/" . $id_adh . ".png";
if ($image_adh != "")
{
if (function_exists("ImageCreateFromString"))
$imagedata = getimagesize($image_adh);
else
$imagedata = array("130","");
?>
<IMG src="<?php echo $image_adh."?nocache=".time(); ?>" border="1" alt="<?php echo _T("Photo"); ?>" width="<?php echo $imagedata[0]; ?>" height="<?php echo $imagedata[1]; ?>">
<?php
}
else
echo _T("[ pas de photo ]");
?>
</TD>
</TR>
<TR>
<TH <?php echo $prenom_adh_req ?> id="libelle"><?php echo _T("Prénom :"); ?></TH>
<TD><INPUT type="text" name="prenom_adh" value="<?php if(array_key_exists('prenom_adh', $values)) echo $values['prenom_adh']; ?>" maxlength="<?php echo $prenom_adh_len; ?>" <?php echo $disabled_field; ?>></TD>
</TR>
<TR>
<TH <?php echo $pseudo_adh_req ?> id="libelle"><?php echo _T("Pseudo :"); ?></TH>
<TD><INPUT type="text" name="pseudo_adh" value="<?php if(array_key_exists('pseudo_adh', $values)) echo $values['pseudo_adh']; ?>" maxlength="<?php echo $pseudo_adh_len; ?>"></TD>
</TR>
<TR>
<TH <?php echo $ddn_adh_req ?> id="libelle"><?php echo _T("Date de naissance :"); ?><br>&nbsp;</TH>
<TD><INPUT type="text" name="ddn_adh" value="<?php if(array_key_exists('ddn_adh', $values)) echo $values['ddn_adh']; ?>" maxlength="10"><BR><DIV class="exemple"><?php echo _T("(format jj/mm/aaaa)"); ?></DIV></TD>
</TR>
<TR>
<TH <?php echo $prof_adh_req ?> id="libelle"><?php echo _T("Profession :"); ?></TH>
<TD><input type="text" name="prof_adh" value="<?php if(array_key_exists('prof_adh', $values)) echo $values['prof_adh']; ?>" maxlength="<?php echo $prof_adh_len; ?>"></TD>
</TR>
<TR>
<TH id="libelle"><?php echo _T("Je souhaite apparaître dans la liste des membres :"); ?></TH>
<TD><input type="checkbox" name="bool_display_info" value="1"<?php if(array_key_exists('bool_display_info', $values)) isChecked($values['bool_display_info'],"1") ?>></TD>
<TH id="libelle"><?php echo _T("Photo :"); ?></TH>
<TD>
<?php
if (file_exists(WEB_ROOT . "photos/" . $id_adh . ".jpg") ||
file_exists(WEB_ROOT . "photos/" . $id_adh . ".png") ||
file_exists(WEB_ROOT . "photos/" . $id_adh . ".gif"))
{
?>
<INPUT type="submit" name="del_photo" value="<?php echo _T("Supprimer la photo"); ?>">
<?php
}
else
{
?>
<INPUT type="file" name="photo"><BR>
<?php
}
?>
</TD>
</TR>
<TR>
<TH <?php echo $panier_adh_req ?> id="libelle"><?php echo _T("Panier :"); ?></TH>
<TD>
<SELECT name="panier_adh" <?php echo $disabled_field; ?>>
<OPTION value="-1"<?php if(array_key_exists('panier_adh', $values)) isSelected($values['panier_adh'],"-1") ?>><?php echo "-"; ?></OPTION>
<OPTION value="1"<?php if(array_key_exists('panier_adh', $values)) isSelected($values['panier_adh'],"1") ?>><?php echo _T("GP"); ?></OPTION>
<OPTION value="0"<?php if(array_key_exists('panier_adh', $values)) isSelected($values['panier_adh'],"0") ?>><?php echo _T("pp"); ?></OPTION>
</SELECT>
</TD>
<TH <?php echo $pain_adh_req ?> id="libelle"><?php echo _T("Pain :"); ?></TH>
<TD>
<SELECT name="pain_adh" <?php echo $disabled_field; ?>>
<OPTION value="0"<?php if(array_key_exists('pain_adh', $values)) isSelected($values['pain_adh'],"0") ?>><?php echo "-"; ?></OPTION>
<OPTION value="4"<?php if(array_key_exists('pain_adh', $values)) isSelected($values['pain_adh'],"4") ?>><?php echo _T("9¿50"); ?></OPTION>
<OPTION value="3"<?php if(array_key_exists('pain_adh', $values)) isSelected($values['pain_adh'],"3") ?>><?php echo _T("7¿"); ?></OPTION>
<OPTION value="2"<?php if(array_key_exists('pain_adh', $values)) isSelected($values['pain_adh'],"2") ?>><?php echo _T("5¿"); ?></OPTION>
<OPTION value="1"<?php if(array_key_exists('pain_adh', $values)) isSelected($values['pain_adh'],"1") ?>><?php echo _T("3¿"); ?></OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TH <?php echo $volaille_adh_req ?> id="libelle"><?php echo _T("Volaille :"); ?></TH>
<TD>
<SELECT name="volaille_adh" <?php echo $disabled_field; ?>>
<OPTION value="0"<?php if(array_key_exists('volaille_adh', $values)) isSelected($values['volaille_adh'],"0") ?>><?php echo "non"; ?></OPTION>
<OPTION value="1"<?php if(array_key_exists('volaille_adh', $values)) isSelected($values['volaille_adh'],"1") ?>><?php echo "oui"; ?></OPTION>
</SELECT>
</TD>
<TH <?php echo $boeuf_adh_req ?> id="libelle"><?php echo _T("Boeuf :"); ?></TH>
<TD>
<SELECT name="boeuf_adh" <?php echo $disabled_field; ?>>
<OPTION value="0"<?php if(array_key_exists('boeuf_adh', $values)) isSelected($values['boeuf_adh'],"0") ?>><?php echo "non"; ?></OPTION>
<OPTION value="1"<?php if(array_key_exists('boeuf_adh', $values)) isSelected($values['boeuf_adh'],"1") ?>><?php echo "oui"; ?></OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TH <?php echo $veau_adh_req ?> id="libelle"><?php echo _T("Veau :"); ?></TH>
<TD>
<SELECT name="veau_adh" <?php echo $disabled_field; ?>>
<OPTION value="0"<?php if(array_key_exists('veau_adh', $values)) isSelected($values['veau_adh'],"0") ?>><?php echo "non"; ?></OPTION>
<OPTION value="1"<?php if(array_key_exists('veau_adh', $values)) isSelected($values['veau_adh'],"1") ?>><?php echo "oui"; ?></OPTION>
</SELECT>
</TD>
<TH <?php echo $cochon_adh_req ?> id="libelle"><?php echo _T("Cochon :"); ?></TH>
<TD>
<SELECT name="cochon_adh" <?php echo $disabled_field; ?>>
<OPTION value="0"<?php if(array_key_exists('cochon_adh', $values)) isSelected($values['cochon_adh'],"0") ?>><?php echo "non"; ?></OPTION>
<OPTION value="1"<?php if(array_key_exists('cochon_adh', $values)) isSelected($values['cochon_adh'],"1") ?>><?php echo "oui"; ?></OPTION>
</SELECT>
</TD>
<TR>
<TR>
<TH <?php echo $chevre_adh_req ?> id="libelle"><?php echo _T("Fromage de chèvre :"); ?></TH>
<TD>
<SELECT name="chevre_adh" <?php echo $disabled_field; ?>>
<OPTION value="0"<?php if(array_key_exists('chevre_adh', $values)) isSelected($values['chevre_adh'],"0") ?>><?php echo "non"; ?></OPTION>
<OPTION value="1"<?php if(array_key_exists('chevre_adh', $values)) isSelected($values['chevre_adh'],"1") ?>><?php echo "oui"; ?></OPTION>
</SELECT>
</TD>
<TR>
<TR>
<TH <?php echo $farine_adh_req ?> id="libelle"><?php echo _T("Farine-Huile :"); ?></TH>
<TD>
<SELECT name="farine_adh" <?php echo $disabled_field; ?>>
<OPTION value="0"<?php if(array_key_exists('farine_adh', $values)) isSelected($values['farine_adh'],"0") ?>><?php echo "non"; ?></OPTION>
<OPTION value="1"<?php if(array_key_exists('farine_adh', $values)) isSelected($values['farine_adh'],"1") ?>><?php echo "oui"; ?></OPTION>
</SELECT>
</TD>
<TD>
</TD>
</TR>
<?php
if ($_SESSION["admin_status"]!=0)
{
?>
<TR>
<TH colspan="4" id="header">&nbsp;</TH>
</TR>
<TR>
<TH <?php echo $activite_adh_req ?> id="libelle"><?php echo _T("Compte :"); ?></TH>
<TD>
<SELECT name="activite_adh">
<OPTION value="1"<?php if(array_key_exists('activite_adh', $values)) isSelected($values['activite_adh'],"1") ?>><?php echo _T("Actif"); ?></OPTION>
<OPTION value="0"<?php if(array_key_exists('activite_adh', $values)) isSelected($values['activite_adh'],"0") ?>><?php echo _T("Inactif"); ?></OPTION>
</SELECT>
</TD>
<TH id="header" colspan="2">&nbsp;</TH>
</TR>
<TR>
<TH <?php echo $id_statut_req ?> id="libelle"><?php echo _T("Statut :"); ?></TH>
<TD>
<SELECT name="id_statut">
<?php
$requete = "SELECT *
FROM ".PREFIX_DB."statuts
ORDER BY priorite_statut";
$result = $DB->Execute($requete);
while (!$result->EOF)
{
?>
<OPTION value="<?php echo $result->fields["id_statut"] ?>"<?php isSelected($id_statut,$result->fields["id_statut"]) ?>><?php echo _T($result->fields["libelle_statut"]); ?></OPTION>
<?php
$result->MoveNext();
}
$result->Close();
?>
</SELECT>
</TD>
<TH id="header" colspan="2">&nbsp;</TH>
</TR>
<TR>
<TH id="libelle"><?php echo _T("Admin Galette :"); ?></TH>
<TD><input type="checkbox" name="bool_admin_adh" value="1"<?php if(array_key_exists('bool_admin_adh', $values)) isChecked($values['bool_admin_adh'],"1") ?>></TD>
<TH id="header" colspan="2">&nbsp;</TH>
</TR>
<TR>
<TH id="libelle"><?php echo _T("Exempt de cotisation :"); ?></TH>
<TD><INPUT type="checkbox" name="bool_exempt_adh" value="1"<?php if(array_key_exists('bool_exempt_adh', $values)) isChecked($values['bool_exempt_adh'],"1") ?>></TD>
<TH id="header" colspan="2">&nbsp;</TH>
</TR>
<?php
}
?>
<TR>
<TH colspan="4" id="header">&nbsp;</TH>
</TR>
<TR>
<TH id="libelle" <?php echo $adresse_adh_req ?>><?php echo _T("Adresse :"); ?></TH>
<TD colspan="3">
<INPUT type="text" name="adresse_adh" value="<?php if(array_key_exists('adresse_adh', $values)) echo $values['adresse_adh']; ?>" maxlength="<?php echo $adresse_adh_len; ?>" size="63"><BR>
<INPUT type="text" name="adresse2_adh" value="<?php if(array_key_exists('adresse2_adh', $values)) echo $values['adresse2_adh']; ?>" maxlength="<?php echo $adresse2_adh_len; ?>" size="63">
</TD>
</TR>
<TR>
<TH id="libelle" <?php echo $cp_adh_req ?>><?php echo _T("Code Postal :"); ?></TH>
<TD><INPUT type="text" name="cp_adh" value="<?php if(array_key_exists('cp_adh', $values)) echo $values['cp_adh']; ?>" maxlength="<?php echo $cp_adh_len; ?>"></TD>
<TH id="libelle" <?php echo $ville_adh_req ?>><?php echo _T("Ville :"); ?></TH>
<TD><INPUT type="text" name="ville_adh" value="<?php if(array_key_exists('ville_adh', $values)) echo $values['ville_adh']; ?>" maxlength="<?php echo $ville_adh_len; ?>"></TD>
</TR>
<TR>
<TH id="libelle" <?php echo $pays_adh_req ?>><?php echo _T("Pays :"); ?></TH>
<TD><INPUT type="text" name="pays_adh" value="<?php if(array_key_exists('pays_adh', $values)) echo $values['pays_adh']; ?>" maxlength="<?php echo $pays_adh_len; ?>"></TD>
<TH id="libelle" <?php echo $tel_adh_req ?>><?php echo _T("Tel :"); ?></TH>
<TD><INPUT type="text" name="tel_adh" value="<?php if(array_key_exists('tel_adh', $values)) echo $values['tel_adh']; ?>" maxlength="<?php echo $tel_adh_len; ?>"></TD>
</TR>
<TR>
<TH id="libelle" <?php echo $gsm_adh_req ?>><?php echo _T("GSM :"); ?></TH>
<TD><INPUT type="text" name="gsm_adh" value="<?php if(array_key_exists('gsm_adh', $values)) echo $values['gsm_adh']; ?>" maxlength="<?php echo $gsm_adh_len; ?>"></TD>
<TH id="libelle" <?php echo $email_adh_req ?>><?php echo _T("E-Mail :"); ?></TH>
<TD><INPUT type="text" name="email_adh" value="<?php if(array_key_exists('email_adh', $values)) echo $values['email_adh']; ?>" maxlength="<?php echo $email_adh_len; ?>" size="30"></TD>
</TR>
<TR>
<TH id="libelle" <?php echo $url_adh_req ?>><?php echo _T("Site Web :"); ?></TH>
<TD><INPUT type="text" name="url_adh" value="<?php if(array_key_exists('url_adh', $values)) echo $values['url_adh']; ?>" maxlength="<?php echo $url_adh_len; ?>" size="30"></TD>
<TH id="libelle" <?php echo $icq_adh_req ?>><?php echo _T("ICQ :"); ?></TH>
<TD><INPUT type="text" name="icq_adh" value="<?php if(array_key_exists('icq_adh', $values)) echo $values['icq_adh']; ?>" maxlength="<?php echo $icq_adh_len; ?>"></TD>
</TR>
<TR>
<TH id="libelle" <?php echo $jabber_adh_req ?>><?php echo _T("Jabber :"); ?></TH>
<TD><INPUT type="text" name="jabber_adh" value="<?php if(array_key_exists('jabber_adh', $values)) echo $values['jabber_adh']; ?>" maxlength="<?php echo $jabber_adh_len; ?>" size="30"></TD>
<TH id="libelle" <?php echo $msn_adh_req ?>><?php echo _T("MSN :"); ?></TH>
<TD><INPUT type="text" name="msn_adh" value="<?php if(array_key_exists('msn_adh', $values)) echo $values['msn_adh']; ?>" maxlength="<?php echo $msn_adh_len; ?>" size="30"></TD>
</TR>
<TR>
<TH colspan="4" id="header">&nbsp;</TH>
</TR>
<TR>
<TH id="libelle" <?php echo $login_adh_req ?>><?php echo _T("Identifiant :"); ?><BR>&nbsp;</TH>
<TD><INPUT type="text" name="login_adh" value="<?php if(array_key_exists('login_adh', $values)) echo $values['login_adh']; ?>" maxlength="<?php echo $login_adh_len; ?>"><BR><DIV class="exemple"><?php echo _T("(au moins 4 caractères)"); ?></DIV></TD>
<TH id="libelle" <?php echo $mdp_adh_req ?>><?php echo _T("Mot de passe :"); ?><BR>&nbsp;</TH>
<TD><INPUT type="text" name="mdp_adh" value="<?php if(array_key_exists('mdp_adh', $values)) echo $values['mdp_adh']; ?>" maxlength="<?php echo $mdp_adh_len; ?>"><BR><DIV class="exemple"><?php echo _T("(au moins 4 caractères)"); ?></DIV></TD>
</TR>
<?php
if ($_SESSION["admin_status"]!=0)
{
?>
<TR>
<TH id="libelle"><?php echo _T("Envoi de mail :"); ?><BR>&nbsp;</TH>
<TD colspan="3"><INPUT type="checkbox" name="mail_confirm" value="1"><BR><DIV class="exemple"><?php echo _T("(l'adhérent recevra son identifiant et son mot de passe par mail, s'il a une adresse.)"); ?></DIV></TD>
</TR>
<TR>
<TH id="libelle"><?php echo _T("Date de création :"); ?><BR>&nbsp;</TH>
<TD colspan="3"><INPUT type="text" name="date_crea_adh" value="<?php if(array_key_exists('date_crea_adh', $values)) echo $values['date_crea_adh']; ?>" maxlength="10"><BR><DIV class="exemple"><?php echo _T("(format jj/mm/aaaa)"); ?></DIV></TD>
</TR>
<TR>
<TH id="libelle" <?php echo $info_adh_req ?>><?php echo _T("Autres informations (admin) :"); ?></TH>
<TD colspan="3"><TEXTAREA name="info_adh" cols="61" rows="6"><?php if(array_key_exists('info_adh', $values)) echo $values['info_adh']; ?></TEXTAREA><BR><DIV class="exemple"><?php echo _T("Ce commentaire n'est visible que par les administrateurs."); ?></DIV></TD>
</TR>
<?php
}
?>
<TR>
<TH id="libelle" <?php echo $info_public_adh_req ?>><?php echo _T("Autres informations :"); ?></TH>
<TD colspan="3">
<TEXTAREA name="info_public_adh" cols="61" rows="6"><?php if(array_key_exists('info_public_adh', $values)) echo $values['info_public_adh']; ?></TEXTAREA>
<?php
if ($_SESSION["admin_status"]!=0)
{
?>
<BR><DIV class="exemple"><?php echo _T("Ce commentaire est réservé à l'adhérent."); ?></DIV>
<?php
}
?>
</TD>
</TR>
<TR>
<TH align="center" colspan="4"><BR><INPUT type="submit" name="valid" value="<?php echo _T("Enregistrer"); ?>"></TH>
</TR>
</TABLE>
</DIV>
<BR>
<?php echo _T("NB : Les champs obligatoires apparaissent en"); ?> <FONT style="color: #FF0000"><?php echo _T("rouge"); ?></FONT>.
</BLOCKQUOTE>
<INPUT type="hidden" name="id_adh" value="<?php echo $id_adh ?>">
</FORM>
<?php
include("footer.php")
?>

View file

@ -0,0 +1,392 @@
<?php
/* ajouter_contribution.php
* - Saisie d'une contributions
* Copyright (c) 2003 Frédéric Jaqcuot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
include("includes/config.inc.php");
include(WEB_ROOT."includes/database.inc.php");
include(WEB_ROOT."includes/functions.inc.php");
include(WEB_ROOT."includes/lang.inc.php");
include(WEB_ROOT."includes/session.inc.php");
if ($_SESSION["logged_status"]==0)
{
header("location: index.php");
die();
}
if ($_SESSION["admin_status"]==0)
{
header("location: voir_adherent.php");
die();
}
// On vérifie si on a une référence => modif ou création
$id_cotis = "";
if (isset($_GET["id_cotis"]))
if (is_numeric($_GET["id_cotis"]))
$id_cotis = $_GET["id_cotis"];
if (isset($_POST["id_cotis"]))
if (is_numeric($_POST["id_cotis"]))
$id_cotis = $_POST["id_cotis"];
// variables d'erreur (pour affichage)
$error_detected = "";
//
// DEBUT parametrage des champs
// On recupere de la base la longueur et les flags des champs
// et on initialise des valeurs par defaut
// recuperation de la liste de champs de la table
$fields = $DB->MetaColumns(PREFIX_DB."cotisations");
foreach ($fields as $champ => $proprietes)
{
$proprietes_arr = get_object_vars($proprietes);
// on obtient name, max_length, type, not_null, has_default, primary_key,
// auto_increment et binary
$fieldname = $proprietes_arr["name"];
$fieldreq = $fieldname."_req";
$fieldlen = $fieldname."_len";
// on ne met jamais a jour id_cotis -> on le saute
if ($fieldname!="id_cotis")
$$fieldname = "";
// definissons aussi la longueur des input text
$max_tmp = $proprietes_arr["max_length"];
if ($max_tmp == "-1")
$max_tmp = 10;
$$fieldlen = $max_tmp;
// et s'ils sont obligatoires (à partir de la base)
if ($proprietes_arr["not_null"]==1)
$$fieldreq = " style=\"color: #FF0000;\"";
else
$$fieldreq = "";
}
reset($fields);
// et les valeurs par defaut
$id_type_cotis = "1";
$duree_mois_cotis = "12";
//
// FIN parametrage des champs
//
$values = Array();
$values['id_adh'] = "";
if (isset($_GET["id_adh"]))
$values['id_adh'] = $_GET["id_adh"];
elseif (isset($_POST["id_adh"]))
$values['id_adh'] = $_POST["id_adh"];
if ($values['id_adh']!="")
{
$requete = "SELECT nom_adh, prenom_adh FROM ".PREFIX_DB."adherents WHERE id_adh=".$DB->qstr($values['id_adh']);
$resultat = $DB->Execute($requete);
if (!$resultat->EOF)
{
$nom_adh = $resultat->fields[0];
$prenom_adh = $resultat->fields[1];
$resultat->Close();
}
}
//
// Validation du formulaire
//
if (isset($_POST["valid"]))
{
// verification de champs
$update_string = "";
$insert_string_fields = "";
$insert_string_values = "";
// recuperation de la liste de champs de la table
//$fields = &$DB->MetaColumns(PREFIX_DB."cotisations");
foreach ($fields as $champ => $proprietes)
{
$proprietes_arr = get_object_vars($proprietes);
// on obtient name, max_length, type, not_null, has_default, primary_key,
// auto_increment et binary
$fieldname = $proprietes_arr["name"];
$fieldreq = $fieldname."_req";
// on ne met jamais a jour id_cotis -> on le saute
if ($fieldname!="id_cotis")
{
if (isset($_POST[$fieldname]))
$post_value=trim($_POST[$fieldname]);
else
$post_value="";
// on declare les variables pour la présaisie en cas d'erreur
$$fieldname = htmlentities(stripslashes($post_value),ENT_QUOTES);
// vérification de la présence des champs obligatoires
if ($$fieldreq!="" && $post_value=="")
$error_detected = "<LI>"._T("- Vérifiez que tous les champs obligatoires sont renseignés.")."</LI>";
else
{
$value = "";
// validation des dates
if($proprietes_arr["type"]=="date")
{
if (preg_match("/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/", $post_value, $array_jours))
{
if (checkdate($array_jours[2],$array_jours[1],$array_jours[3]))
$value=$DB->DBDate(mktime(0,0,0,$array_jours[2],$array_jours[1],$array_jours[3]));
else
$error_detected .= "<LI>"._T("- Date non valide !")."</LI>";
}
else
$error_detected .= "<LI>"._T("- Mauvais format de date (jj/mm/aaaa) !")."</LI>";
}
elseif(strstr($proprietes_arr["type"],"int"))
{
if (is_numeric($post_value) || $post_value=="")
$value=$DB->qstr($post_value,ENT_QUOTES);
else
$error_detected .= "<LI>"._T("- La durée doit être un entier !")."</LI>";
}
elseif(strstr($proprietes_arr["type"],"float"))
{
$us_value = strtr($post_value, ",", ".");
if (is_numeric($us_value) || $us_value=="")
$value=$DB->qstr($us_value,ENT_QUOTES);
else
$error_detected .= "<LI>"._T("- Le montant doit être un chiffre !")."</LI>";
}
else
{
// on se contente d'escaper le html et les caracteres speciaux
$value = $DB->qstr($post_value,ENT_QUOTES);
}
// mise à jour des chaines d'insertion/update
$update_string .= ",".$fieldname."=".$value;
$insert_string_fields .= ",".$fieldname;
$insert_string_values .= ",".$value;
}
}
}
reset($fields);
// modif ou ajout
if ($error_detected=="")
{
if ($id_cotis!="")
{
// modif
$requete = "UPDATE ".PREFIX_DB."cotisations
SET " . substr($update_string,1) . "
WHERE id_cotis=" . $DB->qstr($id_cotis);
dblog(_T("Mise à jour d'une contribution :")." ".strtoupper($nom_adh)." ".$prenom_adh, $requete);
}
else
{
// ajout
$requete = "INSERT INTO ".PREFIX_DB."cotisations
(" . substr($insert_string_fields,1) . ")
VALUES (" . substr($insert_string_values,1) . ")";
dblog(_T("Ajout d'une contribution :")." ".strtoupper($nom_adh)." ".$prenom_adh, $requete);
}
$DB->Execute("SET NAMES utf8");
$DB->Execute($requete);
$DB->Execute("SET NAMES latin1");
// mise a jour de l'échéance
$date_fin = get_echeance($DB, $values['id_adh']);
if ($date_fin!="")
$date_fin_update = $DB->DBDate(mktime(0,0,0,$date_fin[1],$date_fin[0],$date_fin[2]));
else
$date_fin_update = "'NULL'";
$requete = "UPDATE ".PREFIX_DB."adherents
SET date_echeance=".$date_fin_update."
WHERE id_adh='".$values['id_adh']."'";
$DB->Execute($requete);
// retour à la liste
header("location: gestion_contributions.php?id_adh=".$values['id_adh']);
// récupération du max pour passage en mode modif apres insertion
if ($id_cotis=="")
{
$requete = "SELECT max(id_cotis)
AS max
FROM ".PREFIX_DB."cotisations";
$max = $DB->Execute($requete);
$id_cotis = $max->fields["max"];
}
}
}
//
// Pré-remplissage des champs
// avec des valeurs issues de la base
// -> donc uniquement si l'enregistrement existe et que le formulaire
// n'a pas déja été posté avec des erreurs (pour pouvoir corriger)
if (!isset($_POST["valid"]) || (isset($_POST["valid"]) && $error_detected==""))
if ($id_cotis != "")
{
// recup des données
$requete = "SELECT *
FROM ".PREFIX_DB."cotisations
WHERE id_cotis=$id_cotis";
$result = $DB->Execute($requete);
if ($result->EOF)
header("location: index.php");
// recuperation de la liste de champs de la table
//$fields = &$DB->MetaColumns(PREFIX_DB."cotisations");
foreach ($fields as $champ => $proprietes)
{
$proprietes_arr = get_object_vars($proprietes);
// on obtient name, max_length, type, not_null, has_default, primary_key,
// auto_increment et binary
// déclaration des variables correspondant aux champs
// et reformatage des dates.
$val = $result->fields[$proprietes_arr["name"]];
if($proprietes_arr["type"]=="date" && $val!="")
{
list($a,$m,$j)=explode("-",$val);
$val="$j/$m/$a";
}
$values[$proprietes_arr["name"]] = htmlentities(stripslashes(addslashes($val)), ENT_QUOTES);
}
}
else
{
// initialisation des champs
}
// la date de creation de fiche, ici vide si nouvelle fiche
if ($date_cotis=="")
$date_cotis = date("d/m/Y");
include("header.php");
?>
<H1 class="titre"><?php echo _T("Fiche contribution"); ?> (<?php if ($id_cotis!="") echo _T("modification"); else echo _T("création"); ?>)</H1>
<FORM action="ajouter_contribution.php" method="post">
<?php
// Affichage des erreurs
if ($error_detected!="")
{
?>
<DIV id="errorbox">
<H1><?php echo _T("- ERREUR -"); ?></H1>
<UL>
<?php echo $error_detected; ?>
</UL>
</DIV>
<?php
}
?>
<BLOCKQUOTE>
<div align="center">
<table border="0" id="input-table">
<tr>
<TH id="libelle" <?php echo $id_adh_req ?>><?php echo _T("Contributeur :"); ?></TH>
<td>
<select name="id_adh">
<option value="" <?php isSelected($values['id_adh'],"") ?>><?php echo _T("-- selectionner un nom --"); ?></option>
<?php
$requete = "SELECT id_adh, nom_adh, prenom_adh
FROM ".PREFIX_DB."adherents
ORDER BY nom_adh, prenom_adh";
$result = $DB->Execute($requete);
while (!$result->EOF)
{
?>
<option value="<?php echo $result->fields[0] ?>"<?php isSelected($values['id_adh'],$result->fields[0]) ?>><?php echo htmlentities(strtoupper($result->fields[1]), ENT_QUOTES)." ".htmlentities($result->fields[2], ENT_QUOTES); ?></option>
<?php
$result->MoveNext();
}
$result->Close();
?>
</select>
</td>
<TH id="libelle" <?php echo $id_type_cotis_req ?>><?php echo _T("Type de contribution :"); ?></TH>
<td>
<select name="id_type_cotis">
<?php
$requete = "SELECT id_type_cotis, libelle_type_cotis
FROM ".PREFIX_DB."types_cotisation
ORDER BY libelle_type_cotis";
$result = $DB->Execute($requete);
while (!$result->EOF)
{
?>
<option value="<?php echo $result->fields["id_type_cotis"] ?>"<?php isSelected($id_type_cotis,$result->fields["id_type_cotis"]) ?>><?php echo _T($result->fields["libelle_type_cotis"]) ?></option>
<?php
$result->MoveNext();
}
$result->Close();
?>
</select>
</td>
</tr>
<tr>
<TH id="libelle" <?php echo $montant_cotis_req ?>><?php echo _T("Montant :"); ?></TH>
<td><input type="text" name="montant_cotis" value="<?php if(array_key_exists('montant_cotis', $values)) echo $values['montant_cotis']; ?>" maxlength="<?php echo $montant_cotis_len; ?>"></td>
<TH id="libelle" <?php echo $duree_mois_cotis_req ?>><?php echo _T("Prolongation adhésion :"); ?></TH>
<td><input type="text" name="duree_mois_cotis" value="<?php if(array_key_exists('duree_mois_cotis', $values)) echo $values['duree_mois_cotis']; ?>" maxlength="<?php echo $duree_mois_cotis_len; ?>"> <?php echo _T("mois"); ?></td>
</tr>
<tr>
<TH id="libelle" <?php echo $date_cotis_req ?>><?php echo _T("Date contribution :"); ?><br>&nbsp;</TH>
<td colspan="3"><input type="text" name="date_cotis" value="<?php if(array_key_exists('date_cotis', $values)) echo $values['date_cotis']; ?>" maxlength="10"><BR><DIV class="exemple"><?php echo _T("(format jj/mm/aaaa)"); ?></DIV></td>
</tr>
<tr>
<TH id="libelle" <?php echo $info_cotis_req ?>><?php echo _T("Commentaire :"); ?></TH>
<td colspan="3"><textarea name="info_cotis" cols="61" rows="6"><?php if(array_key_exists('info_cotis', $values)) echo $values['info_cotis']; ?></textarea></td>
</tr>
<tr>
<TH align="center" colspan="4"><BR><input type="submit" name="valid" value="<?php echo _T("Enregistrer"); ?>"></TH>
</tr>
</table>
</div>
<br>
<?php echo _T("NB : Les champs obligatoires apparaissent en"); ?> <font style="color: #FF0000"><?php echo _T("rouge"); ?></font>.
</BLOCKQUOTE>
<input type="hidden" name="id_cotis" value="<?php echo $id_cotis ?>">
</form>
<?php
// }
include("footer.php")
?>

View file

@ -0,0 +1,208 @@
<?php
/* etiquettes_adherents.php
* - Generation d'un PDF d'étiquettes
* Copyright (c) 2003 Frédéric Jaqcuot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
include("includes/config.inc.php");
include(WEB_ROOT."includes/database.inc.php");
include(WEB_ROOT."includes/functions.inc.php");
include(WEB_ROOT."includes/lang.inc.php");
include(WEB_ROOT."includes/session.inc.php");
include(WEB_ROOT."includes/phppdflib/phppdflib.class.php");
if ($_SESSION["logged_status"]==0)
die();
if ($_SESSION["admin_status"]==0)
die();
$mailing_adh = array();
if (isset($_POST["mailing_adh"]))
{
while (list($key,$value)=each($_POST["mailing_adh"]))
$mailing_adh[]=$value;
}
else
die();
$requete = "SELECT id_adh, nom_adh, prenom_adh, adresse_adh,
titre_adh, cp_adh, ville_adh, pays_adh, adresse2_adh, panier_adh, pain_adh
FROM ".PREFIX_DB."adherents
WHERE ";
$where_clause = "";
if ( ! isset($_POST['mois']))
$mois=date("m");
else
$mois=$_POST['mois'];
$annee=date("Y");
if ($mois == "13")
{
$mois="01";
$annee=$annee+1;
}
$datenow=$annee . "-" . $mois . "-0";
while(list($key,$value)=each($mailing_adh))
{
if ($where_clause!="")
$where_clause .= " OR ";
$where_clause .= "id_adh=".$DB->qstr($value);
}
$requete .= $where_clause." ORDER by nom_adh, prenom_adh;";
$resultat = &$DB->Execute($requete);
$pdf = new pdffile;
$pdf->set_default('margin', 0);
$firstpage = $pdf->new_page("a4-landscape");
$param["height"] = PREF_ETIQ_CORPS;
$param["fillcolor"] = $pdf->get_color('#000000');
$param["align"] = "center";
$param["width"] = 1;
$param["strokecolor"] = $pdf->get_color('#000000');
if ($resultat->EOF)
die();
$yorigin=545;
$xorigin=round(PREF_ETIQ_MARGES*2.835);
$row=1;
$nb_etiq=0;
$concatname = "";
$i=0;
$j=0;
while (date("Ym",strtotime("$j saturday", strtotime($datenow))) <= $annee.$mois)
{
$j++;
if (date("m",strtotime("$j saturday", strtotime($datenow))) == $mois) {
$panier[$i][0]=0;
$panier[$i][1]=0;
$date[$i]=date("d/m/Y",strtotime($j . " saturday", strtotime($datenow)));
$date2[$i]=date("Y-m-d",strtotime($j . " saturday", strtotime($datenow)));
$i++;
}
if ($j > 10) {
print "Problème dans le calcul des mois !";
die();
}
}
$col = $i;
$ligne = 18;
$x1 = 70;
$x2 = 300;
$ecart = 480/$col;
$hecart = 490/$ligne;
while (!$resultat->EOF)
{
$y1 = $yorigin-(($row-1)*($hecart));
$y2 = $y1 - $hecart;
if ($row==1)
{
$param["font"] = "Helvetica-Bold";
$pdf->draw_rectangle($yorigin+20, $x1, $yorigin, $x2, $firstpage, $param);
$pdf->draw_paragraph($yorigin+20, $x1, $yorigin, $x2, "Nom", $firstpage, $param);
$pdf->draw_rectangle($yorigin+20, $x2, $yorigin, $x2+40, $firstpage, $param);
$pdf->draw_paragraph($yorigin+20, $x2, $yorigin, $x2+40, "Prix", $firstpage, $param);
$i=0;
while($i<$col)
{
$xdr1=$x2+40+$i*$ecart;
$xdr2=$x2+40+($i+1)*$ecart;
$pdf->draw_paragraph($yorigin+20, $xdr1, $yorigin, $xdr2, $date[$i], $firstpage, $param);
$pdf->draw_rectangle($yorigin+20, $xdr1, $yorigin, $xdr2, $firstpage, $param);
$i++;
}
}
if ( ($_POST['panier'] == "legume" && $resultat->fields[9] != "-1") || ($_POST['panier'] == "pain" && $resultat->fields[10] != "0") ) {
$nom_adh_ext="";
switch($resultat->fields[4])
{
case "1" :
$nom_adh_ext .= _T("M.");
break;
case "2" :
$nom_adh_ext .= _T("Mme.");
break;
default :
$nom_adh_ext .= _T("Mlle.");
}
$nom_adh_ext .= " ".strtoupper($resultat->fields[1])." ".ucfirst(strtolower($resultat->fields[2]));
$concatname = $concatname . " - " . $nom_adh_ext;
$param["font"] = "Helvetica";
$pdf->draw_paragraph($y1-5, $x1, $y2, $x2, $nom_adh_ext, $firstpage, $param);
$pdf->draw_rectangle ($y1, $x1, $y2, $x2, $firstpage, $param);
$pdf->draw_rectangle($y1, $x2, $y2, $x2+40, $firstpage, $param);
// $pdf->draw_rectangle($y1, $x2+20, $y2, $x2+40, $firstpage, $param);
if ($_POST['panier'] == "legume")
{
$qpanier=$resultat->fields[9];
if ($qpanier == "0" )
$qpanier_result="pp";
else
$qpanier_result="GP";
} else if ($_POST['panier'] == "pain") {
$qpanier=$resultat->fields[10];
if ($qpanier == "1" )
$qpanier_result="3";
if ($qpanier == "2" )
$qpanier_result="5";
if ($qpanier == "3" )
$qpanier_result="7";
if ($qpanier == "4" )
$qpanier_result="9,50";
}
$pdf->draw_paragraph($y1, $x2, $y2, $x2+40, $qpanier_result, $firstpage, $param);
$i=0;
while($i<$col)
{
$absence = &$DB->Execute("SELECT * FROM `galette_absences` WHERE `id_adh` = " . $resultat->fields[0] . " AND `date_abs` = '$date2[$i]'");
if (!$absence->EOF)
$pdf->draw_paragraph($y1, $x2+$i*$ecart+40, $y2, $x2+($i+1)*$ecart+40, "Absent", $firstpage, $param);
else
$panier[$i+1][$qpanier]=$panier[$i+1][$qpanier]+1;
$pdf->draw_rectangle($y1, $x2+$i*$ecart+40, $y2, $x2+($i+1)*$ecart+40, $firstpage, $param);
$i++;
}
$row++;
if ($row>$ligne)
{
$row=1;
$firstpage = $pdf->new_page("a4-landscape");
}
$nb_etiq++;
}
$resultat->MoveNext();
}
$i=0;
while($i<$col)
{
$pdf->draw_rectangle($y2, $x2+$i*$ecart+40, $y2-20, $x2+($i+1)*$ecart+40, $firstpage, $param);
if ($_POST['panier'] == "legume")
$display="pp : " . $panier[$i+1][0] . " | GP : " . $panier[$i+1][1];
if ($_POST['panier'] == "pain")
$display="3E : " . $panier[$i+1][1] . " | 5E : " . $panier[$i+1][2] . " | 7E : " . $panier[$i+1][3] . " | 9E50 : " . $panier[$i+1][4];
$pdf->draw_paragraph($y2, $x2+$i*$ecart+40, $y2-20, $x2+($i+1)*$ecart+40, $display, $firstpage, $param);
$i++;
}
$resultat->Close();
dblog(_T("Génération de ")." ".$nb_etiq." "._T("feuille emargement"),$concatname);
header("Content-Disposition: filename=feuille_emargement.pdf");
header("Content-Type: application/pdf");
$temp = $pdf->generate();
header('Content-Length: ' . strlen($temp));
echo $temp;
?>

View file

@ -0,0 +1,127 @@
<?php
/* etiquettes_adherents.php
* - Generation d'un PDF d'étiquettes
* Copyright (c) 2003 Frédéric Jaqcuot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
include("includes/config.inc.php");
include(WEB_ROOT."includes/database.inc.php");
include(WEB_ROOT."includes/functions.inc.php");
include(WEB_ROOT."includes/lang.inc.php");
include(WEB_ROOT."includes/session.inc.php");
include(WEB_ROOT."includes/phppdflib/phppdflib.class.php");
if ($_SESSION["logged_status"]==0)
die();
if ($_SESSION["admin_status"]==0)
die();
$mailing_adh = array();
if (isset($_POST["mailing_adh"]))
{
while (list($key,$value)=each($_POST["mailing_adh"]))
$mailing_adh[]=$value;
}
else
die();
$requete = "SELECT id_adh, nom_adh, prenom_adh, adresse_adh,
titre_adh, cp_adh, ville_adh, pays_adh, adresse2_adh
FROM ".PREFIX_DB."adherents
WHERE ";
$where_clause = "";
while(list($key,$value)=each($mailing_adh))
{
if ($where_clause!="")
$where_clause .= " OR ";
$where_clause .= "id_adh=".$DB->qstr($value);
}
$requete .= $where_clause." ORDER by nom_adh, prenom_adh;";
// echo $requete;
$resultat = &$DB->Execute($requete);
$pdf = new pdffile;
$pdf->set_default('margin', 0);
$firstpage = $pdf->new_page("a4");
$param["height"] = PREF_ETIQ_CORPS;
$param["fillcolor"] = $pdf->get_color('#000000');
$param["align"] = "center";
$param["width"] = 1;
$param["strokecolor"] = $pdf->get_color('#DDDDDD');
if ($resultat->EOF)
die();
$yorigin=842-round(PREF_ETIQ_MARGES*2.835);
$xorigin=round(PREF_ETIQ_MARGES*2.835);
$col=1;
$row=1;
$nb_etiq=0;
$concatname = "";
while (!$resultat->EOF)
{
$nom_adh_ext="";
switch($resultat->fields[4])
{
case "1" :
$nom_adh_ext .= _T("M.");
break;
case "2" :
$nom_adh_ext .= _T("Mme.");
break;
default :
$nom_adh_ext .= _T("Mlle.");
}
$x1 = $xorigin + ($col-1)*(round(PREF_ETIQ_HSIZE*2.835)+round(PREF_ETIQ_HSPACE*2.835));
$x2 = $x1 + round(PREF_ETIQ_HSIZE*2.835);
$y1 = $yorigin-($row-1)*(round(PREF_ETIQ_VSIZE*2.835)+round(PREF_ETIQ_VSPACE*2.835));
$y2 = $y1 - round(PREF_ETIQ_VSIZE*2.835);
$nom_adh_ext .= " ".strtoupper($resultat->fields[1])." ".ucfirst(strtolower($resultat->fields[2]));
$concatname = $concatname . " - " . $nom_adh_ext;
$param["font"] = "Helvetica-Bold";
$pdf->draw_paragraph($y1-10, $x1, $y1-10-(round(PREF_ETIQ_VSIZE*2.835)/5)+5, $x2, $nom_adh_ext, $firstpage, $param);
$param["font"] = "Helvetica";
$pdf->draw_paragraph ($y1-10-(round(PREF_ETIQ_VSIZE*2.835)/5), $x1, $y1-10-(round(PREF_ETIQ_VSIZE*2.835)/5)-(round(PREF_ETIQ_VSIZE*2.835)*4/5), $x2, $resultat->fields[3]."\n".$resultat->fields[8]."\n".$resultat->fields[5]." - ".$resultat->fields[6]."\n".$resultat->fields[7], $firstpage, $param);
$pdf->draw_rectangle ($y1, $x1, $y2, $x2, $firstpage, $param);
$resultat->MoveNext();
$col++;
if ($col>PREF_ETIQ_COLS)
{
$col=1;
$row++;
}
if ($row>PREF_ETIQ_ROWS)
{
$col=1;
$row=1;
$firstpage = $pdf->new_page("a4");
}
$nb_etiq++;
}
$resultat->Close();
dblog(_T("Génération de ")." ".$nb_etiq." "._T("étiquette(s)"),$concatname);
header("Content-Disposition: filename=example.pdf");
header("Content-Type: application/pdf");
$temp = $pdf->generate();
header('Content-Length: ' . strlen($temp));
echo $temp;
?>

View file

@ -0,0 +1,168 @@
<?php
/* footer.php
* - Pied de page
* Copyright (c) 2003 Frédéric Jaqcuot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
$end = utime(); $run = $end - $start;
?>
<DIV id="copyright">
<A href="http://www.zopeuse.org/projets/galette/Wiki_galette/FrontPage">Galette <?php echo GALETTE_VERSION ?></A> - <?php echo _T("Réalisation :"); ?> <A href="mailto:deelight@logeek.com">Deelight</A> - <?php echo _T("Graphisme :"); ?> <A href="http://www.gimp.org">Gimp</A> - <?php echo _T("Editeur :"); ?> <A href="http://bluefish.openoffice.nl">Bluefish</A> - <?php echo _T("Page affichée en")." ".substr($run, 0, 5)." "._T("secondes."); ?>
</DIV>
</DIV>
<DIV id="menu">
<DIV id="logo">
<IMG src="images/galette.jpg" alt="[ Galette ]" width="103" height="80"><BR>
Galette
</DIV>
<DIV id="nav1">
<H1><?php echo _T("Navigation"); ?></H1>
<UL>
<?php
if ($_SESSION["admin_status"]==1)
{
?>
<LI><A href="gestion_adherents.php"><?php echo _T("Liste des adhérents"); ?></A></LI>
<LI><A href="gestion_contributions.php"><?php echo _T("Liste des contributions"); ?></A></LI>
<LI><A href="ajouter_adherent.php"><?php echo _T("Ajouter un adhérent"); ?></A></LI>
<LI><A href="ajouter_contribution.php"><?php echo _T("Ajouter une contribution"); ?></A></LI>
<LI><A href="log.php"><?php echo _T("Historique"); ?></A></LI>
<LI><A href="preferences.php"><?php echo _T("Préférences"); ?></A></LI>
<?php
}
else
{
?>
<LI><A href="voir_adherent.php"><?php echo _T("Mes informations"); ?></A></LI>
<LI><A href="gestion_contributions.php"><?php echo _T("Mes contributions"); ?></A></LI>
<?php
}
?>
</UL>
</DIV>
<DIV id="logout">
<A href="index.php?logout=1"><?php echo _T("Déconnexion"); ?></A>
</DIV>
<?php
if (basename($_SERVER["SCRIPT_NAME"])=="gestion_adherents.php" || basename($_SERVER["SCRIPT_NAME"])=="mailing_adherents.php")
{
?>
<DIV id="legende">
<H1><?php echo _T("Légende"); ?></H1>
<TABLE>
<TR>
<TD width="30" class="back"><IMG src="images/icon-male.png" Alt="<?php echo _T("[H]"); ?>" align="middle" width="10" height="12"></TD>
<TD class="back"><?php echo _T("Homme"); ?></TD>
</TR>
<TR>
<TD width="30" class="back"><IMG src="images/icon-female.png" Alt="<?php echo _T("[F]"); ?>" align="middle" width="9" height="12"></TD>
<TD class="back"><?php echo _T("Femme"); ?></TD>
</TR>
<?php
if (basename($_SERVER["SCRIPT_NAME"])=="gestion_adherents.php")
{
?>
<TR>
<TD width="30" class="back"><IMG src="images/icon-mail.png" Alt="<?php echo _T("[Mail]"); ?>" align="middle" border="0" width="14" height="10"></TD>
<TD class="back"><?php echo _T("Envoyer un mail"); ?></TD>
</TR>
<?php
}
?>
<TR>
<TD width="30" class="back"><IMG src="images/icon-star.png" Alt="<?php echo _T("[admin]"); ?>" align="middle" width="12" height="13"></TD>
<TD class="back"><?php echo _T("Administrateur"); ?></TD>
</TR>
<TR>
<TD width="30" class="back"><IMG src="images/icon-edit.png" alt="<?php echo _T("[mod]"); ?>" border="0" width="12" height="13"></TD>
<TD class="back"><?php echo _T("Modification"); ?></TD>
</TR>
<TR>
<TD width="30" class="back"><IMG src="images/icon-money.png" alt="<?php echo _T("[$]"); ?>" border="0" width="13" height="13"></TD>
<TD class="back"><?php echo _T("Contributions"); ?></TD>
</TR>
<TR>
<TD width="30" class="back"><IMG src="images/icon-trash.png" alt="<?php echo _T("[sup]"); ?>" border="0" width="11" height="13"></TD>
<TD class="back"><?php echo _T("Suppression"); ?></TD>
</TR>
<TR>
<TD width="30" class="back"><?php echo _T("Nom"); ?></TD>
<TD class="back"><?php echo _T("Compte actif"); ?></TD>
</TR>
<TR>
<TD width="30" class="inactif back"><?php echo _T("Nom"); ?></TD>
<TD class="back"><?php echo _T("Compte désactivé"); ?></TD>
</TR>
<TR>
<TD width="30" class="cotis-never color-sample">&nbsp;</TD>
<TD class="back"><?php echo _T("N'a jamais cotisé"); ?></TD>
</TR>
<TR>
<TD width="30" class="cotis-ok color-sample">&nbsp;</TD>
<TD class="back"><?php echo _T("Adhésion en règle"); ?></TD>
</TR>
<TR>
<TD width="30" class="cotis-soon color-sample">&nbsp;</TD>
<TD class="back"><?php echo _T("Adhésion à échéance (<30j)"); ?></TD>
</TR>
<TR>
<TD width="30" class="cotis-late color-sample">&nbsp;</TD>
<TD class="back"><?php echo _T("Retard de cotisation"); ?></TD>
</TR>
</TABLE>
</DIV>
<?php
}
elseif (basename($_SERVER["SCRIPT_NAME"])=="gestion_contributions.php")
{
?>
<DIV id="legende">
<H1><?php echo _T("Légende"); ?></H1>
<TABLE>
<?php
if ($_SESSION["admin_status"]==1)
{
?>
<TR>
<TD width="30" class="back"><IMG src="images/icon-edit.png" alt="<?php echo _T("[mod]"); ?>" border="0" width="12" height="13"></TD>
<TD class="back"><?php echo _T("Modification"); ?></TD>
</TR>
<TR>
<TD width="30" class="back"><IMG src="images/icon-trash.png" alt="<?php echo _T("[sup]"); ?>" border="0" width="11" height="13"></TD>
<TD class="back"><?php echo _T("Suppression"); ?></TD>
</TR>
<?php
}
?>
<TR>
<TD width="30" class="cotis-normal color-sample">&nbsp;</TD>
<TD class="back"><?php echo _T("Cotisation"); ?></TD>
</TR>
<TR>
<TD width="30" class="cotis-give color-sample">&nbsp;</TD>
<TD class="back"><?php echo _T("Don"); ?></TD>
</TR>
</TABLE>
</DIV>
<?php
}
?>
</DIV>
</BODY>
</HTML>

View file

@ -0,0 +1,414 @@
body {
margin-top: 0px;
margin-left: 0px;
margin-right: 0px;
margin-bottom: 0px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px
}
td {
font-size: 11px
}
input {
font-size: 11px
}
select {
font-size: 11px
}
textarea {
font-size: 11px
}
a {
text-decoration: none;
color: #0000FF;
}
a:hover {
color: #FF0000;
}
.left {
text-align: left;
}
.right {
text-align: right;
}
.center {
text-align: center;
}
.cotis-ok {
background-color: #DDFFDD;
vertical-align: top;
}
.cotis-never {
background-color: #EEEEEE;
vertical-align: top;
}
.cotis-exempt {
background-color: #DDFFDD;
vertical-align: top;
}
.cotis-soon {
background-color: #FFE9AB;
vertical-align: top;
}
.cotis-late {
background-color: #FFDDDD;
vertical-align: top;
}
.cotis-lastday {
background-color: #FFDDDD;
vertical-align: top;
}
.cotis-normal {
background-color: #DDFFDD;
vertical-align: top;
}
.cotis-give {
background-color: #FFDDDD;
vertical-align: top;
}
.totalcount {
text-align: left;
}
.pageswitch {
text-align: center;
margin-top: 4px;
}
.pagelink {
font-weight: bold;
}
.filtermenus {
text-align: right;
}
.titre {
font-size: 15px;
text-align: center;
font-weight: bold;
border-style: solid;
border-width: 1px;
background-color: #FBFBFB;
border-color: #BBBBBB;
margin-top: 10px;
margin-bottom: 20px;
color: #000000;
width: 100%;
}
th.listing {
font-size: 10px;
background-color: #000000;
color: #FFFFFF;
}
a.listing {
color: #FFFFFF;
font-weight: bold;
}
a.listing:hover {
color: #FF0000;
}
.emptylist {
background-color: #EEEEEE;
text-align: center;
font-style: italic;
}
.actif {
}
.inactif {
color: #777777;
font-style: italic;
}
.acronyme {
color: #AAAAAA;
font-style: italic;
}
#copyright {
color: #CCCCCC;
font-style: italic;
text-align: center;
padding-top: 10px;
margin-bottom: 10px;
}
#copyright a {
color: #CCCCCC;
}
#copyright a:hover {
color: #FF0000;
}
.exemple {
color: #999999;
}
#logo {
text-align: center;
font-weight: bold;
margin-top: 10px;
width: 150px;
height: 100px;
}
#nav1 {
width: 150px;
margin-left: 5px;
border-color: #7777FF;
border-width: 2px;
border-style: solid;
}
#nav1 h1 {
margin: 2px;
font-size: 10px;
background-color: #DDDDFF;
padding-left: 2px;
}
#nav1 ul {
list-style-type: none;
margin: 2px;
padding: 0px;
border: none;
}
#nav1 li {
background-color: #EEEEEE;
margin-bottom: 2px;
padding-left: 2px;
}
#logout {
width: 150px;
margin-left: 5px;
text-align: center;
margin-top: 10px;
margin-bottom: 10px;
}
#legende {
width: 150px;
margin-left: 5px;
margin-bottom: 5px;
border-color: #7777FF;
border-width: 2px;
border-style: solid;
}
#legende table {
width: 100%;
}
#legende h1 {
margin: 2px;
font-size: 10px;
background-color: #DDDDFF;
padding-left: 2px;
text-align: left;
}
#legende td {
padding-left: 2px;
}
#legende .back {
background-color: #EEEEEE;
}
.color-sample {
border-color: #AAAAAA;
border-width: 1px;
border-style: solid;
}
#content {
position: absolute;
padding-right: 15px;
left: 170px;
}
#menu {
float: left;
position: absolute;
top: 0px;
left: 0px;
}
#listfilter {
text-align: right;
}
#listfilter form {
margin-bottom: 0px;
}
#infoline {
margin-top: 10px;
}
#infoline2 {
margin-top: 2px;
}
#mailing_preview {
margin-top: 10px;
margin-bottom: 10px;
margin-left: 30px;;
margin-right: 30px;
border-color: #DDDDDD;
border-width: 2px;
border-style: solid;
}
#mailing_preview th {
font-size: 10px;
font-weight: bold;
text-align: left;
background-color: #EEEEEE;
}
#errorbox {
color: #FF0000;
border-color: #FFDDDD;
border-width: 2px;
border-style: solid;
}
#errorbox h1 {
background-color: #FFDDDD;
text-align: center;
font-size: 10px;
font-weight: bold;
margin-top: 0px;
margin-bottom: 0px;
}
#errorbox ul {
list-style-type: none;
margin: 2px;
padding: 0px;
border: none;
}
#warningbox {
color: #000000;
border-color: #FFE8CC;
border-width: 2px;
border-style: solid;
}
#warningbox h1 {
background-color: #FFE8CC;
text-align: center;
font-size: 10px;
font-weight: bold;
margin-top: 0px;
margin-bottom: 0px;
}
#warningbox ul {
list-style-type: none;
margin: 2px;
padding: 0px;
border: none;
}
#input-table #libelle {
font-size: 11px;
text-align: left;
background-color: #DDDDFF;
font-weight: normal;
}
#input-table #header {
text-align: left;
font-weight: bold;
}
#input-table td {
background-color: #EEEEEE;
}
#installpage {
background-color: #DDDDFF;
padding-left: 20px;
}
#installpage p {
background-color: #DDDDFF;
padding-left: 20px;
width: 80%;
}
#installpage h1 {
text-align: left;
margin: 0px;
font-size: 12px;
}
#installpage #submitbutton2 {
text-align: center;
padding-left: 20px;
}
#installpage #submitbutton3 {
text-align: right;
padding-right: 20px;
}
.titreinstall {
font-size: 15px;
text-align: center;
font-weight: bold;
border-style: solid;
border-width: 1px;
background-color: #FBFBFB;
border-color: #BBBBBB;
color: #000000;
left: 0px;
right: 0px;
padding: 10px 0px 10px 0px;
margin: 0px;
}
.footerinstall {
font-size: 11px;
text-align: right;
padding-right: 20px;
font-weight: normal;
border-style: solid;
border-width: 1px;
background-color: #FBFBFB;
border-color: #BBBBBB;
color: #000000;
left: 0px;
right: 0px;
margin: 0px;
}

View file

@ -0,0 +1,449 @@
<?php
/* gestion_adherents.php
* - Récapitulatif des adhérents
* Copyright (c) 2003 Frédéric Jaqcuot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
include("includes/config.inc.php");
include(WEB_ROOT."includes/database.inc.php");
include(WEB_ROOT."includes/functions.inc.php");
include(WEB_ROOT."includes/lang.inc.php");
include(WEB_ROOT."includes/session.inc.php");
if ($_SESSION["logged_status"]==0)
{
header("location: index.php");
die();
}
if ($_SESSION["admin_status"]==0)
{
header("location: voir_adherent.php");
die();
}
$page = 1;
if (isset($_GET["page"]))
$page = $_GET["page"];
if (isset($_GET["filtre"]))
if (is_numeric($_GET["filtre"]))
$_SESSION["filtre_adh"]=$_GET["filtre"];
if (! isset($_SESSION["filtre_adh"]))
$_SESSION["filtre_adh"]='';
if (isset($_GET["filtre_adh_2"]))
if (is_numeric($_GET["filtre_2"]))
$_SESSION["filtre_adh_2"]=$_GET["filtre_2"];
if (! isset($_SESSION["filtre_adh_2"]))
$_SESSION["filtre_adh_2"]='';
if (isset($_GET["filtre_3"]))
if (is_numeric($_GET["filtre_3"]))
$_SESSION["filtre_adh_3"]=$_GET["filtre_3"];
if (! isset($_SESSION["filtre_adh_3"]))
$_SESSION["filtre_adh_3"]='';
// Tri
if (isset($_GET["tri"]))
if (is_numeric($_GET["tri"]))
{
if ($_SESSION["tri_adh"]==$_GET["tri"])
$_SESSION["tri_adh_sens"]=($_SESSION["tri_adh_sens"]+1)%2;
else
{
$_SESSION["tri_adh"]=$_GET["tri"];
$_SESSION["tri_adh_sens"]=0;
}
}
include("header.php");
if (isset($_GET["sup"]))
{
if (is_numeric($_GET["sup"]))
{
$requetesup = "SELECT nom_adh, prenom_adh FROM ".PREFIX_DB."adherents WHERE id_adh=".$DB->qstr($_GET["sup"]);
$resultat = $DB->Execute($requetesup);
if (!$resultat->EOF)
{
// supression record adhérent
$requetesup = "DELETE FROM ".PREFIX_DB."adherents
WHERE id_adh=".$DB->qstr($_GET["sup"]);
$DB->Execute($requetesup);
// suppression de l'eventuelle photo
@unlink(WEB_ROOT . "photos/".$id_adh.".jpg");
@unlink(WEB_ROOT . "photos/".$id_adh.".gif");
@unlink(WEB_ROOT . "photos/".$id_adh.".jpg");
@unlink(WEB_ROOT . "photos/tn_".$id_adh.".jpg");
@unlink(WEB_ROOT . "photos/tn_".$id_adh.".gif");
@unlink(WEB_ROOT . "photos/tn_".$id_adh.".jpg");
// suppression records cotisations
$requetesup = "DELETE FROM ".PREFIX_DB."cotisations
WHERE id_adh=" . $DB->qstr($_GET["sup"]);
$DB->Execute($requetesup);
dblog(_T("Suppression de la fiche adhérent (et cotisations) :")." ".strtoupper($resultat->fields[0])." ".$resultat->fields[1], $requetesup);
}
$resultat->Close();
}
}
?>
<H1 class="titre"><?php echo _T("Gestion des adhérents"); ?></H1>
<?php
// selection des adherents et application filtre / tri
$requete[0] = "SELECT id_adh, nom_adh, prenom_adh, pseudo_adh, activite_adh,
libelle_statut, bool_exempt_adh, titre_adh, email_adh, bool_admin_adh, date_echeance
FROM ".PREFIX_DB."adherents, ".PREFIX_DB."statuts
WHERE ".PREFIX_DB."adherents.id_statut=".PREFIX_DB."statuts.id_statut ";
$requete[1] = "SELECT count(id_adh)
FROM ".PREFIX_DB."adherents
WHERE 1=1 ";
// filtre d'affichage des adherents activés/desactivés
if ($_SESSION["filtre_adh_2"]=="1")
{
$requete[0] .= "AND ".PREFIX_DB."adherents.activite_adh='1' ";
$requete[1] .= "AND ".PREFIX_DB."adherents.activite_adh='1' ";
}
elseif ($_SESSION["filtre_adh_2"]=="2")
{
$requete[0] .= "AND ".PREFIX_DB."adherents.activite_adh='0' ";
$requete[1] .= "AND ".PREFIX_DB."adherents.activite_adh='0' ";
}
// filtre par panier
if ($_SESSION["filtre_adh_3"]=="1")
{
$requete[0] .= "AND ".PREFIX_DB."adherents.panier_adh != '-1' ";
$requete[1] .= "AND ".PREFIX_DB."adherents.panier_adh != '-1' ";
}
elseif ($_SESSION["filtre_adh_3"]=="2")
{
$requete[0] .= "AND ".PREFIX_DB."adherents.pain_adh != '0' ";
$requete[1] .= "AND ".PREFIX_DB."adherents.pain_adh != '0' ";
}
elseif ($_SESSION["filtre_adh_3"]=="3")
{
$requete[0] .= "AND ".PREFIX_DB."adherents.volaille_adh != '0' ";
$requete[1] .= "AND ".PREFIX_DB."adherents.volaille_adh != '0' ";
}
elseif ($_SESSION["filtre_adh_3"]=="4")
{
$requete[0] .= "AND ".PREFIX_DB."adherents.boeuf_adh != '0' ";
$requete[1] .= "AND ".PREFIX_DB."adherents.boeuf_adh != '0' ";
}
elseif ($_SESSION["filtre_adh_3"]=="5")
{
$requete[0] .= "AND ".PREFIX_DB."adherents.veau_adh != '0' ";
$requete[1] .= "AND ".PREFIX_DB."adherents.veau_adh != '0' ";
}
elseif ($_SESSION["filtre_adh_3"]=="6")
{
$requete[0] .= "AND ".PREFIX_DB."adherents.cochon_adh != '0' ";
$requete[1] .= "AND ".PREFIX_DB."adherents.cochon_adh != '0' ";
}
elseif ($_SESSION["filtre_adh_3"]=="7")
{
$requete[0] .= "AND ".PREFIX_DB."adherents.farine_adh != '0' ";
$requete[1] .= "AND ".PREFIX_DB."adherents.farine_adh != '0' ";
}
elseif ($_SESSION["filtre_adh_3"]=="8")
{
$requete[0] .= "AND ".PREFIX_DB."adherents.chevre_adh != '0' ";
$requete[1] .= "AND ".PREFIX_DB."adherents.chevre_adh != '0' ";
}
// filtre d'affichage des adherents retardataires
if ($_SESSION["filtre_adh"]=="2")
{
$requete[0] .= "AND date_echeance < ".$DB->DBDate(time())." ";
$requete[1] .= "AND date_echeance < ".$DB->DBDate(time())." ";
}
// filtre d'affichage des adherents à jour
if ($_SESSION["filtre_adh"]=="3")
{
$requete[0] .= "AND (date_echeance > ".$DB->DBDate(time())." OR bool_exempt_adh='1') ";
$requete[1] .= "AND (date_echeance > ".$DB->DBDate(time())." OR bool_exempt_adh='1') ";
}
// filtre d'affichage des adherents bientot a echeance
if ($_SESSION["filtre_adh"]=="1")
{
$requete[0] .= "AND date_echeance > ".$DB->DBDate(time())."
AND date_echeance < ".$DB->OffsetDate(30)." ";
$requete[1] .= "AND date_echeance > ".$DB->DBDate(time())."
AND date_echeance < ".$DB->OffsetDate(30)." ";
}
// phase de tri
if ($_SESSION["tri_adh_sens"]=="0")
$tri_adh_sens_txt="ASC";
else
$tri_adh_sens_txt="DESC";
$requete[0] .= "ORDER BY ";
// tri par pseudo
if ($_SESSION["tri_adh"]=="1")
$requete[0] .= "pseudo_adh ".$tri_adh_sens_txt.",";
// tri par statut
elseif ($_SESSION["tri_adh"]=="2")
$requete[0] .= "priorite_statut ".$tri_adh_sens_txt.",";
// tri par echeance
elseif ($_SESSION["tri_adh"]=="3")
$requete[0] .= "bool_exempt_adh ".$tri_adh_sens_txt.", date_echeance ".$tri_adh_sens_txt.",";
// defaut : tri par nom, prenom
$requete[0] .= "nom_adh ".$tri_adh_sens_txt.", prenom_adh ".$tri_adh_sens_txt;
$resultat = $DB->SelectLimit($requete[0],PREF_NUMROWS,($page-1)*PREF_NUMROWS);
$nbadh = $DB->Execute($requete[1]);
if ($nbadh->fields[0]%PREF_NUMROWS==0)
$nbpages = intval($nbadh->fields[0]/PREF_NUMROWS);
else
$nbpages = intval($nbadh->fields[0]/PREF_NUMROWS)+1;
$pagestring = "";
if ($nbpages==0)
$pagestring = "<b>1</b>";
else for ($i=1;$i<=$nbpages;$i++)
{
if ($i!=$page)
$pagestring .= "<A href=\"gestion_adherents.php?page=".$i."\">".$i."</A> ";
else
$pagestring .= $i." ";
}
?>
<DIV id="listfilter">
<FORM action="gestion_adherents.php" method="get" name="filtre">
<?php echo _T("Afficher :"); ?>&nbsp;
<SELECT name="filtre" onChange="form.submit()">
<OPTION value="0"<?php isSelected("0",$_SESSION["filtre_adh"]) ?>><?php echo _T("Tous les adhérents"); ?></OPTION>
<OPTION value="3"<?php isSelected("3",$_SESSION["filtre_adh"]) ?>><?php echo _T("Les adhérents à jour"); ?></OPTION>
<OPTION value="1"<?php isSelected("1",$_SESSION["filtre_adh"]) ?>><?php echo _T("Les échéances proches"); ?></OPTION>
<OPTION value="2"<?php isSelected("2",$_SESSION["filtre_adh"]) ?>><?php echo _T("Les retardataires"); ?></OPTION>
</SELECT>
<SELECT name="filtre_2" onChange="form.submit()">
<OPTION value="0"<?php isSelected("0",$_SESSION["filtre_adh_2"]) ?>><?php echo _T("Tous les comptes"); ?></OPTION>
<OPTION value="1"<?php isSelected("1",$_SESSION["filtre_adh_2"]) ?>><?php echo _T("Comptes actifs"); ?></OPTION>
<OPTION value="2"<?php isSelected("2",$_SESSION["filtre_adh_2"]) ?>><?php echo _T("Comptes désactivés"); ?></OPTION>
</SELECT>
<SELECT name="filtre_3" onChange="form.submit()">
<OPTION value="0"<?php isSelected("0",$_SESSION["filtre_adh_3"]) ?>><?php echo _T("Tous les paniers"); ?></OPTION>
<OPTION value="1"<?php isSelected("1",$_SESSION["filtre_adh_3"]) ?>><?php echo _T("Legumes"); ?></OPTION>
<OPTION value="2"<?php isSelected("2",$_SESSION["filtre_adh_3"]) ?>><?php echo _T("Pain"); ?></OPTION>
<OPTION value="3"<?php isSelected("3",$_SESSION["filtre_adh_3"]) ?>><?php echo _T("Volaille"); ?></OPTION>
<OPTION value="4"<?php isSelected("4",$_SESSION["filtre_adh_3"]) ?>><?php echo _T("Boeuf"); ?></OPTION>
<OPTION value="5"<?php isSelected("4",$_SESSION["filtre_adh_3"]) ?>><?php echo _T("Veau"); ?></OPTION>
<OPTION value="6"<?php isSelected("4",$_SESSION["filtre_adh_3"]) ?>><?php echo _T("Cochon"); ?></OPTION>
<OPTION value="7"<?php isSelected("5",$_SESSION["filtre_adh_3"]) ?>><?php echo _T("Farine-Huile"); ?></OPTION>
<OPTION value="8"<?php isSelected("6",$_SESSION["filtre_adh_3"]) ?>><?php echo _T("Fromage de chèvre"); ?></OPTION>
</SELECT>
<INPUT type="submit" value="<?php echo _T("Filtrer"); ?>">
</FORM>
</DIV>
<TABLE id="infoline" width="100%">
<TR>
<TD class="left"><?php echo $nbadh->fields[0]." "; if ($nbadh->fields[0]!=1) echo _T("adhérents"); else echo _T("adhérent"); ?></TD>
<TD class="right"><?php echo _T("Pages :"); ?> <SPAN class="pagelink"><?php echo $pagestring; ?></SPAN></TD>
</TR>
</TABLE>
<TABLE width="100%">
<TR>
<TH width="15" class="listing">#</TH>
<TH width="250" class="listing left">
<A href="gestion_adherents.php?tri=0" class="listing"><?php echo _T("Nom"); ?></A>
<?php
if ($_SESSION["tri_adh"]=="0")
{
if ($_SESSION["tri_adh_sens"]=="0")
$img_sens = "asc.png";
else
$img_sens = "desc.png";
}
else
$img_sens = "icon-empty.png";
?>
<IMG src="images/<?php echo $img_sens; ?>" width="7" height="7" alt="">
</TH>
<TH class="listing left" nowrap>
<A href="gestion_adherents.php?tri=1" class="listing"><?php echo _T("Pseudo"); ?></A>
<?php
if ($_SESSION["tri_adh"]=="1")
{
if ($_SESSION["tri_adh_sens"]=="0")
$img_sens = "asc.png";
else
$img_sens = "desc.png";
}
else
$img_sens = "icon-empty.png";
?>
<IMG src="images/<?php echo $img_sens; ?>" width="7" height="7" alt="">
</TH>
<TH class="listing left">
<A href="gestion_adherents.php?tri=2" class="listing"><?php echo _T("Statut"); ?></A>
<?php
if ($_SESSION["tri_adh"]=="2")
{
if ($_SESSION["tri_adh_sens"]=="0")
$img_sens = "asc.png";
else
$img_sens = "desc.png";
}
else
$img_sens = "icon-empty.png";
?>
<IMG src="images/<?php echo $img_sens; ?>" width="7" height="7" alt="">
</TH>
<TH class="listing left">
<A href="gestion_adherents.php?tri=3" class="listing"><?php echo _T("Etat cotisations"); ?></A>
<?php
if ($_SESSION["tri_adh"]=="3")
{
if ($_SESSION["tri_adh_sens"]=="0")
$img_sens = "asc.png";
else
$img_sens = "desc.png";
}
else
$img_sens = "icon-empty.png";
?>
<IMG src="images/<?php echo $img_sens; ?>" width="7" height="7" alt="">
</TH>
<TH width="55" class="listing"><?php echo _T("Actions"); ?></TH>
</TR>
<?php
$compteur = 1+($page-1)*PREF_NUMROWS;
if ($resultat->EOF)
{
?>
<TR><TD colspan="6" class="emptylist"><?php echo _T("aucun adhérent"); ?></TD></TR>
<?php
}
else while (!$resultat->EOF)
{
// définition CSS pour adherent désactivé
if ($resultat->fields[4]=="1")
$row_class = "actif";
else
$row_class = "inactif";
// temps d'adhésion
if($resultat->fields[6])
{
$statut_cotis = _T("Exempt de cotisation");
$row_class .= " cotis-exempt";
}
else
{
if ($resultat->fields[10]=="")
{
$statut_cotis = _T("N'a jamais cotisé");
$row_class .= " cotis-never";
}
else
{
$date_fin = preg_split("~-~",$resultat->fields[10]);
$ts_date_fin = mktime(0,0,0,$date_fin[1],$date_fin[2],$date_fin[0]);
$aujourdhui = time();
$difference = intval(($ts_date_fin - $aujourdhui)/(3600*24));
if ($difference==0)
{
$statut_cotis = _T("Dernier jour !");
$row_class .= " cotis-lastday";
}
elseif ($difference<0)
{
$statut_cotis = _T("En retard de ").-$difference." "._T("jours")." ("._T("depuis le")." ".$date_fin[2]."/".$date_fin[1]."/".$date_fin[0].")";
$row_class .= " cotis-late";
}
else
{
if ($difference!=1)
$statut_cotis = $difference." "._T("jours restants")." ("._T("fin le")." ".$date_fin[2]."/".$date_fin[1]."/".$date_fin[0].")";
else
$statut_cotis = $difference." "._T("jour restant")." ("._T("fin le")." ".$date_fin[2]."/".$date_fin[1]."/".$date_fin[0].")";
if ($difference < 30)
$row_class .= " cotis-soon";
else
$row_class .= " cotis-ok";
}
}
}
?>
<TR>
<TD width="15" class="<?php echo $row_class ?>"><?php echo $compteur ?></TD>
<TD class="<?php echo $row_class ?>" nowrap>
<?php
if ($resultat->fields[7]=="1") {
?>
<IMG src="images/icon-male.png" Alt="<?php echo _T("[H]"); ?>" align="middle" width="10" height="12">
<?php
} else {
?>
<IMG src="images/icon-female.png" Alt="<?php echo _T("[F]"); ?>" align="middle" width="9" height="12">
<?php
}
if ($resultat->fields[8]!="") {
?>
<A href="mailto:<?php echo $resultat->fields[8] ?>"><IMG src="images/icon-mail.png" Alt="<?php echo _T("[Mail]"); ?>" align="middle" border="0" width="14" height="10"></A>
<?php
} else {
?>
<IMG src="images/icon-empty.png" Alt="" align="middle" border="0" width="14" height="10">
<?php
}
if ($resultat->fields[9]=="1") {
?>
<IMG src="images/icon-star.png" Alt="<?php echo _T("[admin]"); ?>" align="middle" width="12" height="13">
<?php
} else {
?>
<IMG src="images/icon-empty.png" Alt="" align="middle" width="12" height="13">
<?php
}
?>
<A href="voir_adherent.php?id_adh=<?php echo $resultat->fields["id_adh"] ?>"><?php echo htmlentities(strtoupper($resultat->fields[1]),ENT_QUOTES)." ".htmlentities($resultat->fields[2], ENT_QUOTES) ?></A>
</TD>
<TD class="<?php echo $row_class ?>" nowrap><?php echo htmlentities($resultat->fields[3], ENT_QUOTES) ?></TD>
<TD class="<?php echo $row_class ?>" nowrap><?php echo _T($resultat->fields[5]) ?></TD>
<TD class="<?php echo $row_class ?>" nowrap><?php echo $statut_cotis ?></TD>
<TD class="<?php echo $row_class ?> center">
<A href="ajouter_adherent.php?id_adh=<?php echo $resultat->fields[0] ?>"><IMG src="images/icon-edit.png" alt="<?php echo _T("[mod]"); ?>" border="0" width="12" height="13"></A>
<A href="gestion_contributions.php?id_adh=<?php echo $resultat->fields[0] ?>"><IMG src="images/icon-money.png" alt="<?php echo _T("[$]"); ?>" border="0" width="13" height="13"></A>
<A onClick="return confirm('<?php echo str_replace("\n","\\n",addslashes(_T("Voulez-vous vraiment supprimer cet adhérent de la base, ceci supprimera aussi l'historique de ses cotisations. Pour éviter cela vous pouvez simplement désactiver le compte.\n\nVoulez-vous tout de même supprimer cet adhérent ?"))); ?>')" href="gestion_adherents.php?sup=<?php echo $resultat->fields[0] ?>"><IMG src="images/icon-trash.png" alt="<?php echo _T("[sup]"); ?>" border="0" width="11" height="13"></A>
</TD>
</TR>
<?php
$compteur++;
$resultat->MoveNext();
}
$resultat->Close();
?>
</TABLE>
<DIV id="infoline2" class="right"><?php echo _T("Pages :"); ?> <SPAN class="pagelink"><?php echo $pagestring; ?></SPAN></DIV>
<?php
include("footer.php");
?>

View file

@ -0,0 +1,465 @@
<?php
/* gestion_contributions.php
* - Récapitulatif des contributions
* Copyright (c) 2004 Frédéric Jaqcuot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
include("includes/config.inc.php");
include(WEB_ROOT."includes/database.inc.php");
include(WEB_ROOT."includes/functions.inc.php");
include(WEB_ROOT."includes/lang.inc.php");
include(WEB_ROOT."includes/session.inc.php");
$filtre_id_adh = "";
if ($_SESSION["logged_status"]==0)
{
header("location: index.php");
die();
}
if ($_SESSION["admin_status"]==0)
$_SESSION["filtre_cotis_adh"] = $_SESSION["logged_id_adh"];
else
{
if (isset($_GET["id_adh"]))
{
if (is_numeric($_GET["id_adh"]))
$_SESSION["filtre_cotis_adh"]=$_GET["id_adh"];
else
$_SESSION["filtre_cotis_adh"]="";
}
else
$_SESSION["filtre_cotis_adh"]="";
}
if (isset($_GET["contrib_filter_1"]))
if (ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $_GET["contrib_filter_1"], $array_jours))
{
if (checkdate($array_jours[2],$array_jours[1],$array_jours[3]))
$_SESSION["filtre_date_cotis_1"]=$_GET["contrib_filter_1"];
else
$error_detected .= "<LI>"._T("- Date non valide !")."</LI>";
}
elseif (ereg("^([0-9]{4})$", $_GET["contrib_filter_1"], $array_jours))
$_SESSION["filtre_date_cotis_1"]="01/01/".$array_jours[1];
elseif ($_GET["contrib_filter_1"]=="")
$_SESSION["filtre_date_cotis_1"]="";
else
$error_detected .= "<LI>"._T("- Mauvais format de date (jj/mm/aaaa) !")."</LI>";
if (isset($_GET["contrib_filter_2"]))
if (ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $_GET["contrib_filter_2"], $array_jours))
{
if (checkdate($array_jours[2],$array_jours[1],$array_jours[3]))
$_SESSION["filtre_date_cotis_2"]=$_GET["contrib_filter_2"];
else
$error_detected .= "<LI>"._T("- Date non valide !")."</LI>";
}
elseif (ereg("^([0-9]{4})$", $_GET["contrib_filter_2"], $array_jours))
$_SESSION["filtre_date_cotis_2"]="01/01/".$array_jours[1];
elseif ($_GET["contrib_filter_2"]=="")
$_SESSION["filtre_date_cotis_2"]="";
else
$error_detected .= "<LI>"._T("- Mauvais format de date (jj/mm/aaaa) !")."</LI>";
$page = 1;
if (isset($_GET["page"]))
$page = $_GET["page"];
// Tri
if (isset($_GET["tri"]))
{
if ($_SESSION["tri_cotis"]==$_GET["tri"])
$_SESSION["tri_cotis_sens"]=($_SESSION["tri_cotis_sens"]+1)%2;
else
{
$_SESSION["tri_cotis"]=$_GET["tri"];
$_SESSION["tri_cotis_sens"]=0;
}
}
include("header.php");
if ($_SESSION["admin_status"]==1)
if (isset($_GET["sup"]))
{
// recherche adherent
$requetesel = "SELECT id_adh
FROM ".PREFIX_DB."cotisations
WHERE id_cotis=".$DB->qstr($_GET["sup"]);
$result_adh = $DB->Execute($requetesel);
if (!$result_adh->EOF)
{
$id_adh = $result_adh->fields["id_adh"];
$requetesup = "SELECT nom_adh, prenom_adh FROM ".PREFIX_DB."adherents WHERE id_adh=".$DB->qstr($id_adh);
$resultat = $DB->Execute($requetesup);
if (!$resultat->EOF)
{
// supression record cotisation
$requetesup = "DELETE FROM ".PREFIX_DB."cotisations
WHERE id_cotis=".$DB->qstr($_GET["sup"]);
$DB->Execute($requetesup);
// mise a jour de l'échéance
$date_fin = get_echeance($DB, $id_adh);
if ($date_fin!="")
$date_fin_update = $DB->DBDate(mktime(0,0,0,$date_fin[1],$date_fin[0],$date_fin[2]));
else
$date_fin_update = "NULL";
$requeteup = "UPDATE ".PREFIX_DB."adherents
SET date_echeance=".$date_fin_update."
WHERE id_adh=".$DB->qstr($id_adh);
$DB->Execute("SET NAMES utf8");
$DB->Execute($requeteup);
$DB->Execute("SET NAMES latin1");
dblog(_T("Suppression d'une contribution :")." ".strtoupper($resultat->fields[0])." ".$resultat->fields[1], $requetesup);
}
$resultat->Close();
}
$result_adh->Close();
}
?>
<H1 class="titre"><?php echo _T("Gestion des contributions"); ?></H1>
<?php
$requete[0] = "SELECT ".PREFIX_DB."cotisations.*, ".PREFIX_DB."adherents.nom_adh, ".PREFIX_DB."adherents.prenom_adh,
".PREFIX_DB."types_cotisation.libelle_type_cotis
FROM ".PREFIX_DB."cotisations,".PREFIX_DB."adherents,".PREFIX_DB."types_cotisation
WHERE ".PREFIX_DB."cotisations.id_adh=".PREFIX_DB."adherents.id_adh
AND ".PREFIX_DB."types_cotisation.id_type_cotis=".PREFIX_DB."cotisations.id_type_cotis ";
$requete[1] = "SELECT count(id_cotis)
FROM ".PREFIX_DB."cotisations
WHERE 1=1 ";
// phase filtre
if ($_SESSION["filtre_cotis_adh"]!="")
{
$requete[0] .= "AND ".PREFIX_DB."cotisations.id_adh='" . $_SESSION["filtre_cotis_adh"] . "' ";
$requete[1] .= "AND ".PREFIX_DB."cotisations.id_adh='" . $_SESSION["filtre_cotis_adh"] . "' ";
}
// date filter
if ($_SESSION["filtre_date_cotis_1"]!="")
{
ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $_SESSION["filtre_date_cotis_1"], $array_jours);
$datemin = $DB->DBDate(mktime(0,0,0,$array_jours[2],$array_jours[1],$array_jours[3]));
$requete[0] .= "AND ".PREFIX_DB."cotisations.date_cotis >= " . $datemin . " ";
$requete[1] .= "AND ".PREFIX_DB."cotisations.date_cotis >= " . $datemin . " ";
}
if ($_SESSION["filtre_date_cotis_2"]!="")
{
ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $_SESSION["filtre_date_cotis_2"], $array_jours);
$datemax = $DB->DBDate(mktime(0,0,0,$array_jours[2],$array_jours[1],$array_jours[3]));
$requete[0] .= "AND ".PREFIX_DB."cotisations.date_cotis <= " . $datemax . " ";
$requete[1] .= "AND ".PREFIX_DB."cotisations.date_cotis <= " . $datemax . " ";
}
// phase de tri
if ($_SESSION["tri_cotis_sens"]=="0")
$tri_cotis_sens_txt="ASC";
else
$tri_cotis_sens_txt="DESC";
$requete[0] .= "ORDER BY ";
// tri par adherent
if ($_SESSION["tri_cotis"]=="1")
$requete[0] .= "nom_adh ".$tri_cotis_sens_txt.", prenom_adh ".$tri_cotis_sens_txt.",";
// tri par type
elseif ($_SESSION["tri_cotis"]=="2")
$requete[0] .= "libelle_type_cotis ".$tri_cotis_sens_txt.",";
// tri par montant
elseif ($_SESSION["tri_cotis"]=="3")
$requete[0] .= "montant_cotis ".$tri_cotis_sens_txt.",";
// tri par duree
elseif ($_SESSION["tri_cotis"]=="4")
$requete[0] .= "duree_mois_cotis ".$tri_cotis_sens_txt.",";
// defaut : tri par date
$requete[0] .= " ".PREFIX_DB."cotisations.date_cotis ".$tri_cotis_sens_txt;
// $resultat = &$DB->Execute($requete[0]);
$resultat = $DB->SelectLimit($requete[0],PREF_NUMROWS,($page-1)*PREF_NUMROWS);
$nbcotis = $DB->Execute($requete[1]);
if ($nbcotis->fields[0]%PREF_NUMROWS==0)
$nbpages = intval($nbcotis->fields[0]/PREF_NUMROWS);
else
$nbpages = intval($nbcotis->fields[0]/PREF_NUMROWS)+1;
$pagestring = "";
if ($nbpages==0)
$pagestring = "<b>1</b>";
else for ($i=1;$i<=$nbpages;$i++)
{
if ($i!=$page)
$pagestring .= "<a href=\"gestion_contributions.php?page=".$i."\">".$i."</a> ";
else
$pagestring .= $i." ";
}
?>
<DIV id="listfilter">
<FORM action="gestion_contributions.php" method="get" name="filtre">
<?php echo _T("Afficher les contributions du"); ?>&nbsp;
<INPUT type="text" name="contrib_filter_1" maxlength="10" size="10" value="<?php echo $_SESSION["filtre_date_cotis_1"]; ?>">
<?php echo _T("au"); ?>&nbsp;
<INPUT type="text" name="contrib_filter_2" maxlength="10" size="10" value="<?php echo $_SESSION["filtre_date_cotis_2"]; ?>">
<INPUT type="submit" value="<?php echo _T("Filtrer"); ?>">
</FORM>
</DIV>
<TABLE id="infoline" width="100%">
<TR>
<TD class="left"><?php echo $nbcotis->fields[0]." "; if ($nbcotis->fields[0]!=1) echo _T("contributions"); else echo _T("contribution"); ?></TD>
<TD class="right"><?php echo _T("Pages :"); ?> <SPAN class="pagelink"><?php echo $pagestring; ?></SPAN></TD>
</TR>
</TABLE>
<TABLE width="100%">
<TR>
<TH width="15" class="listing">#</TH>
<TH class="listing left">
<A href="gestion_contributions.php?tri=0&amp;id_adh=<?php echo $_SESSION["filtre_cotis_adh"] ?>" class="listing"><?php echo _T("Date"); ?></A>
<?php
if ($_SESSION["tri_cotis"]=="0")
if ($_SESSION["tri_cotis_sens"]=="0")
echo "<IMG src=\"images/asc.png\" width=\"7\" height=\"7\" alt=\"\">";
else
echo "<IMG src=\"images/desc.png\" width=\"7\" height=\"7\" alt=\"\">";
?>
</TH>
<?php
if ($_SESSION["admin_status"]==1)
{
?>
<TH class="listing left">
<A href="gestion_contributions.php?tri=1&amp;id_adh=<?php echo $_SESSION["filtre_cotis_adh"] ?>" class="listing"><?php echo _T("Adhérent"); ?></A>
<?php
if ($_SESSION["tri_cotis"]=="1")
if ($_SESSION["tri_cotis_sens"]=="0")
echo "<IMG src=\"images/asc.png\" width=\"7\" height=\"7\" alt=\"\">";
else
echo "<IMG src=\"images/desc.png\" width=\"7\" height=\"7\" alt=\"\">";
?>
</TH>
<?php
}
?>
<TH class="listing left">
<A href="gestion_contributions.php?tri=2&amp;id_adh=<?php echo $_SESSION["filtre_cotis_adh"] ?>" class="listing"><?php echo _T("Type"); ?></A>
<?php
if ($_SESSION["tri_cotis"]=="2")
if ($_SESSION["tri_cotis_sens"]=="0")
echo "<IMG src=\"images/asc.png\" width=\"7\" height=\"7\" alt=\"\">";
else
echo "<IMG src=\"images/desc.png\" width=\"7\" height=\"7\" alt=\"\">";
?>
</TH>
<TH class="listing left">
<A href="gestion_contributions.php?tri=3&amp;id_adh=<?php echo $_SESSION["filtre_cotis_adh"] ?>" class="listing"><?php echo _T("Montant"); ?></A>
<?php
if ($_SESSION["tri_cotis"]=="3")
if ($_SESSION["tri_cotis_sens"]=="0")
echo "<IMG src=\"images/asc.png\" width=\"7\" height=\"7\" alt=\"\">";
else
echo "<IMG src=\"images/desc.png\" width=\"7\" height=\"7\" alt=\"\">";
?>
</TH>
<TH class="listing left">
<A href="gestion_contributions.php?tri=4&amp;id_adh=<?php echo $_SESSION["filtre_cotis_adh"] ?>" class="listing"><?php echo _T("Durée"); ?></A>
<?php
if ($_SESSION["tri_cotis"]=="4")
if ($_SESSION["tri_cotis_sens"]=="0")
echo "<IMG src=\"images/asc.png\" width=\"7\" height=\"7\" alt=\"\">";
else
echo "<IMG src=\"images/desc.png\" width=\"7\" height=\"7\" alt=\"\">";
?>
</TH>
<?php
if ($_SESSION["admin_status"]==1)
{
?>
<TH width="55" class="listing">
<?php echo _T("Actions"); ?>
</TH>
<?php
}
?>
</TR>
<?php
$compteur = 1+($page-1)*PREF_NUMROWS;
$activity_class = "";
if ($resultat->EOF)
{
if ($_SESSION["admin_status"]==1)
$colspan = 7;
else
$colspan = 5;
?>
<TR>
<TD colspan="<?php echo $colspan; ?>" class="emptylist"><?php echo _T("aucune contribution"); ?></TD>
</TR>
<?php
}
else while(!$resultat->EOF)
{
if ($resultat->fields["duree_mois_cotis"]!="0")
$row_class = "cotis-normal";
else
$row_class = "cotis-give";
?>
<TR>
<TD width="15" class="<?php echo $row_class; ?> center" nowrap><?php echo $compteur ?></TD>
<TD width="50" class="<?php echo $row_class; ?>" nowrap>
<?php
list($a,$m,$j)=explode("-",$resultat->fields["date_cotis"]);
echo "$j/$m/$a";
?>
</TD>
<?php
if ($_SESSION["admin_status"]==1)
{
?>
<TD class="<?php echo $row_class; ?>" nowrap>
<A href="gestion_contributions.php?id_adh=<?php echo $resultat->fields["id_adh"] ?>"><?php
echo htmlentities(strtoupper($resultat->fields["nom_adh"]), ENT_QUOTES)." ";
if (isset($resultat->fields["prenom_adh"]))
echo htmlentities($resultat->fields["prenom_adh"], ENT_QUOTES);
?></A>
</TD>
<?php
}
?>
<TD class="<?php echo $row_class; ?>" nowrap><?php echo _T($resultat->fields["libelle_type_cotis"]) ?></TD>
<TD class="<?php echo $row_class; ?>" nowrap><?php echo $resultat->fields["montant_cotis"] ?></TD>
<TD class="<?php echo $row_class; ?>" nowrap><?php echo $resultat->fields["duree_mois_cotis"] ?></TD>
<?php
if ($_SESSION["admin_status"]==1)
{
?>
<TD width="55" class="<?php echo $row_class; ?> center" nowrap>
<A href="ajouter_contribution.php?id_cotis=<?php echo $resultat->fields["id_cotis"] ?>"><IMG src="images/icon-edit.png" alt="<?php echo _T("[mod]"); ?>" border="0" width="12" height="13"></A>
<A onClick="return confirm('<?php echo str_replace("\n","\\n",addslashes(_T("Voulez-vous vraiment supprimer cette contribution de la base ?"))); ?>')" href="gestion_contributions.php?sup=<?php echo $resultat->fields["id_cotis"] ?>"><IMG src="images/icon-trash.png" alt="<?php echo _T("[sup]"); ?>" border="0" width="11" height="13"></A>
</TD>
<?php
}
$compteur++;
$resultat->MoveNext();
}
$resultat->Close();
?>
</TABLE>
<DIV id="infoline2" class="right"><?php echo _T("Pages :"); ?> <SPAN class="pagelink"><?php echo $pagestring; ?></SPAN></DIV>
<?php
// affichage du temps d'ahésion restant si on est en train de visualiser
// les cotisations d'un membre unique
if ($_SESSION["filtre_cotis_adh"]!="")
{
$requete = "SELECT date_echeance, bool_exempt_adh
FROM ".PREFIX_DB."adherents
WHERE id_adh='".$_SESSION["filtre_cotis_adh"]."'";
$resultat = $DB->Execute($requete);
// temps d'adhésion
if($resultat->fields[1])
{
$statut_cotis = _T("Exempt de cotisation");
$color = "#DDFFDD";
}
else
{
if ($resultat->fields[0]=="")
{
$statut_cotis = _T("N'a jamais cotisé");
$color = "#EEEEEE";
}
else
{
$date_fin = explode("-",$resultat->fields[0]);
$ts_date_fin = mktime(0,0,0,$date_fin[1],$date_fin[2],$date_fin[0]);
$aujourdhui = time();
$difference = intval(($ts_date_fin - $aujourdhui)/(3600*24));
if ($difference==0)
{
$statut_cotis = _T("Dernier jour !");
$color = "#FFDDDD";
}
elseif ($difference<0)
{
$statut_cotis = _T("En retard de")." ".-$difference." "._T("jours")." ("._T("depuis le")." ".$date_fin[2]."/".$date_fin[1]."/".$date_fin[0].")";
$color = "#FFDDDD";
}
else
{
if ($difference!=1)
$statut_cotis = $difference." "._T("jours restants")." ("._T("fin le")." ".$date_fin[2]."/".$date_fin[1]."/".$date_fin[0].")";
else
$statut_cotis = $difference." "._T("jour restant")." ("._T("fin le")." ".$date_fin[2]."/".$date_fin[1]."/".$date_fin[0].")";
if ($difference < 30)
$color = "#FFE9AB";
else
$color = "#DDFFDD";
}
}
}
/*$days_left = get_days_left($DB, $_SESSION["filtre_cotis_adh"]);
$cumul = $days_left["cumul"];
$statut_cotis = $days_left["text"];
$color = $days_left["color"];*/
?>
<BR>
<DIV align="center">
<TABLE bgcolor="<?php echo $color; ?>">
<TR>
<TD><?php echo $statut_cotis; ?></TD>
</TR>
</TABLE>
<?php
if ($_SESSION["admin_status"]==1)
{
?>
<BR>
<A href="voir_adherent.php?id_adh=<?php echo $_SESSION["filtre_cotis_adh"]; ?>"><?php echo _T("[ Voir la fiche adhérent ]"); ?></A>
&nbsp;&nbsp;&nbsp;
<A href="ajouter_contribution.php?id_adh=<?php echo $_SESSION["filtre_cotis_adh"]; ?>"><?php echo _T("[ Ajouter une contribution ]"); ?></A>
<?php
}
?>
</DIV>
<?php
}
?>
<?php
include("footer.php");
?>

View file

@ -0,0 +1,46 @@
<?php
/* header.php
* - En-tete
* Copyright (c) 2003 Frédéric Jaqcuot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Galette <?php echo GALETTE_VERSION ?></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK rel="stylesheet" type="text/css" href="galette.css" >
<style type="text/css">
ul.menu {
text-align: center;
font-size: 13px;
}
ul.menu li {
display: inline;
margin: 0px;
color: green;
}
ul.menu a:link, ul.menu a:visited, ul.menu a:hover, ul.menu a:active {
color: green;
text-decoration: none;
}
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<DIV id="content">

Binary file not shown.

After

(image error) Size: 1.9 KiB

Binary file not shown.

After

(image error) Size: 150 B

Binary file not shown.

After

(image error) Size: 151 B

Binary file not shown.

After

(image error) Size: 2.2 KiB

Binary file not shown.

After

(image error) Size: 231 B

Binary file not shown.

After

(image error) Size: 355 B

Binary file not shown.

After

(image error) Size: 783 B

Binary file not shown.

After

(image error) Size: 556 B

Binary file not shown.

After

(image error) Size: 780 B

Binary file not shown.

After

(image error) Size: 231 B

Binary file not shown.

After

(image error) Size: 451 B

Binary file not shown.

After

(image error) Size: 205 B

View file

@ -0,0 +1,258 @@
<?php
/**
* @version V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
* The following code is adapted from the PEAR DB error handling code.
* Portions (c)1997-2002 The PHP Group.
*/
if (!defined("DB_ERROR")) define("DB_ERROR",-1);
if (!defined("DB_ERROR_SYNTAX")) {
define("DB_ERROR_SYNTAX", -2);
define("DB_ERROR_CONSTRAINT", -3);
define("DB_ERROR_NOT_FOUND", -4);
define("DB_ERROR_ALREADY_EXISTS", -5);
define("DB_ERROR_UNSUPPORTED", -6);
define("DB_ERROR_MISMATCH", -7);
define("DB_ERROR_INVALID", -8);
define("DB_ERROR_NOT_CAPABLE", -9);
define("DB_ERROR_TRUNCATED", -10);
define("DB_ERROR_INVALID_NUMBER", -11);
define("DB_ERROR_INVALID_DATE", -12);
define("DB_ERROR_DIVZERO", -13);
define("DB_ERROR_NODBSELECTED", -14);
define("DB_ERROR_CANNOT_CREATE", -15);
define("DB_ERROR_CANNOT_DELETE", -16);
define("DB_ERROR_CANNOT_DROP", -17);
define("DB_ERROR_NOSUCHTABLE", -18);
define("DB_ERROR_NOSUCHFIELD", -19);
define("DB_ERROR_NEED_MORE_DATA", -20);
define("DB_ERROR_NOT_LOCKED", -21);
define("DB_ERROR_VALUE_COUNT_ON_ROW", -22);
define("DB_ERROR_INVALID_DSN", -23);
define("DB_ERROR_CONNECT_FAILED", -24);
define("DB_ERROR_EXTENSION_NOT_FOUND",-25);
define("DB_ERROR_NOSUCHDB", -25);
define("DB_ERROR_ACCESS_VIOLATION", -26);
}
function adodb_errormsg($value)
{
global $ADODB_LANG,$ADODB_LANG_ARRAY;
if (empty($ADODB_LANG)) $ADODB_LANG = 'en';
if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ;
else {
include_once(ADODB_DIR."/lang/adodb-$ADODB_LANG.inc.php");
}
return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR];
}
function adodb_error($provider,$dbType,$errno)
{
//var_dump($errno);
if (is_numeric($errno) && $errno == 0) return 0;
switch($provider) {
case 'mysql': $map = adodb_error_mysql(); break;
case 'oracle':
case 'oci8': $map = adodb_error_oci8(); break;
case 'ibase': $map = adodb_error_ibase(); break;
case 'odbc': $map = adodb_error_odbc(); break;
case 'mssql':
case 'sybase': $map = adodb_error_mssql(); break;
case 'informix': $map = adodb_error_ifx(); break;
case 'postgres': return adodb_error_pg($errno); break;
case 'sqlite': return $map = adodb_error_sqlite(); break;
default:
return DB_ERROR;
}
//print_r($map);
//var_dump($errno);
if (isset($map[$errno])) return $map[$errno];
return DB_ERROR;
}
//**************************************************************************************
function adodb_error_pg($errormsg)
{
if (is_numeric($errormsg)) return (integer) $errormsg;
static $error_regexps = array(
'/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE,
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS,
'/divide by zero$/' => DB_ERROR_DIVZERO,
'/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER,
'/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD,
'/parser: parse error at or near \"/' => DB_ERROR_SYNTAX,
'/referential integrity violation/' => DB_ERROR_CONSTRAINT,
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/'
=> DB_ERROR_ALREADY_EXISTS
);
reset($error_regexps);
while (list($regexp,$code) = each($error_regexps)) {
if (preg_match($regexp, $errormsg)) {
return $code;
}
}
// Fall back to DB_ERROR if there was no mapping.
return DB_ERROR;
}
function adodb_error_odbc()
{
static $MAP = array(
'01004' => DB_ERROR_TRUNCATED,
'07001' => DB_ERROR_MISMATCH,
'21S01' => DB_ERROR_MISMATCH,
'21S02' => DB_ERROR_MISMATCH,
'22003' => DB_ERROR_INVALID_NUMBER,
'22008' => DB_ERROR_INVALID_DATE,
'22012' => DB_ERROR_DIVZERO,
'23000' => DB_ERROR_CONSTRAINT,
'24000' => DB_ERROR_INVALID,
'34000' => DB_ERROR_INVALID,
'37000' => DB_ERROR_SYNTAX,
'42000' => DB_ERROR_SYNTAX,
'IM001' => DB_ERROR_UNSUPPORTED,
'S0000' => DB_ERROR_NOSUCHTABLE,
'S0001' => DB_ERROR_NOT_FOUND,
'S0002' => DB_ERROR_NOSUCHTABLE,
'S0011' => DB_ERROR_ALREADY_EXISTS,
'S0012' => DB_ERROR_NOT_FOUND,
'S0021' => DB_ERROR_ALREADY_EXISTS,
'S0022' => DB_ERROR_NOT_FOUND,
'S1000' => DB_ERROR_NOSUCHTABLE,
'S1009' => DB_ERROR_INVALID,
'S1090' => DB_ERROR_INVALID,
'S1C00' => DB_ERROR_NOT_CAPABLE
);
return $MAP;
}
function adodb_error_ibase()
{
static $MAP = array(
-104 => DB_ERROR_SYNTAX,
-150 => DB_ERROR_ACCESS_VIOLATION,
-151 => DB_ERROR_ACCESS_VIOLATION,
-155 => DB_ERROR_NOSUCHTABLE,
-157 => DB_ERROR_NOSUCHFIELD,
-158 => DB_ERROR_VALUE_COUNT_ON_ROW,
-170 => DB_ERROR_MISMATCH,
-171 => DB_ERROR_MISMATCH,
-172 => DB_ERROR_INVALID,
-204 => DB_ERROR_INVALID,
-205 => DB_ERROR_NOSUCHFIELD,
-206 => DB_ERROR_NOSUCHFIELD,
-208 => DB_ERROR_INVALID,
-219 => DB_ERROR_NOSUCHTABLE,
-297 => DB_ERROR_CONSTRAINT,
-530 => DB_ERROR_CONSTRAINT,
-803 => DB_ERROR_CONSTRAINT,
-551 => DB_ERROR_ACCESS_VIOLATION,
-552 => DB_ERROR_ACCESS_VIOLATION,
-922 => DB_ERROR_NOSUCHDB,
-923 => DB_ERROR_CONNECT_FAILED,
-924 => DB_ERROR_CONNECT_FAILED
);
return $MAP;
}
function adodb_error_ifx()
{
static $MAP = array(
'-201' => DB_ERROR_SYNTAX,
'-206' => DB_ERROR_NOSUCHTABLE,
'-217' => DB_ERROR_NOSUCHFIELD,
'-329' => DB_ERROR_NODBSELECTED,
'-1204' => DB_ERROR_INVALID_DATE,
'-1205' => DB_ERROR_INVALID_DATE,
'-1206' => DB_ERROR_INVALID_DATE,
'-1209' => DB_ERROR_INVALID_DATE,
'-1210' => DB_ERROR_INVALID_DATE,
'-1212' => DB_ERROR_INVALID_DATE
);
return $MAP;
}
function adodb_error_oci8()
{
static $MAP = array(
1 => DB_ERROR_ALREADY_EXISTS,
900 => DB_ERROR_SYNTAX,
904 => DB_ERROR_NOSUCHFIELD,
923 => DB_ERROR_SYNTAX,
942 => DB_ERROR_NOSUCHTABLE,
955 => DB_ERROR_ALREADY_EXISTS,
1476 => DB_ERROR_DIVZERO,
1722 => DB_ERROR_INVALID_NUMBER,
2289 => DB_ERROR_NOSUCHTABLE,
2291 => DB_ERROR_CONSTRAINT,
2449 => DB_ERROR_CONSTRAINT
);
return $MAP;
}
function adodb_error_mssql()
{
static $MAP = array(
208 => DB_ERROR_NOSUCHTABLE,
2601 => DB_ERROR_ALREADY_EXISTS
);
return $MAP;
}
function adodb_error_sqlite()
{
static $MAP = array(
1 => DB_ERROR_SYNTAX
);
return $MAP;
}
function adodb_error_mysql()
{
static $MAP = array(
1004 => DB_ERROR_CANNOT_CREATE,
1005 => DB_ERROR_CANNOT_CREATE,
1006 => DB_ERROR_CANNOT_CREATE,
1007 => DB_ERROR_ALREADY_EXISTS,
1008 => DB_ERROR_CANNOT_DROP,
1045 => DB_ERROR_ACCESS_VIOLATION,
1046 => DB_ERROR_NODBSELECTED,
1049 => DB_ERROR_NOSUCHDB,
1050 => DB_ERROR_ALREADY_EXISTS,
1051 => DB_ERROR_NOSUCHTABLE,
1054 => DB_ERROR_NOSUCHFIELD,
1062 => DB_ERROR_ALREADY_EXISTS,
1064 => DB_ERROR_SYNTAX,
1100 => DB_ERROR_NOT_LOCKED,
1136 => DB_ERROR_VALUE_COUNT_ON_ROW,
1146 => DB_ERROR_NOSUCHTABLE,
1048 => DB_ERROR_CONSTRAINT,
2002 => DB_ERROR_CONNECT_FAILED,
2005 => DB_ERROR_CONNECT_FAILED
);
return $MAP;
}
?>

View file

@ -0,0 +1,79 @@
<?php
/**
* @version V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com
*
*/
// added Claudio Bustos clbustos#entelchile.net
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler');
/**
* Default Error Handler. This will be called with the following params
*
* @param $dbms the RDBMS you are connecting to
* @param $fn the name of the calling function (in uppercase)
* @param $errno the native error number from the database
* @param $errmsg the native error msg from the database
* @param $p1 $fn specific parameter - see below
* @param $p2 $fn specific parameter - see below
* @param $thisConn $current connection object - can be false if no connection object created
*/
function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
{
if (error_reporting() == 0) return; // obey @ protocol
switch($fn) {
case 'EXECUTE':
$sql = $p1;
$inputparams = $p2;
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")\n";
break;
case 'PCONNECT':
case 'CONNECT':
$host = $p1;
$database = $p2;
$s = "$dbms error: [$errno: $errmsg] in $fn($host, '****', '****', $database)\n";
break;
default:
$s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
break;
}
/*
* Log connection error somewhere
* 0 message is sent to PHP's system logger, using the Operating System's system
* logging mechanism or a file, depending on what the error_log configuration
* directive is set to.
* 1 message is sent by email to the address in the destination parameter.
* This is the only message type where the fourth parameter, extra_headers is used.
* This message type uses the same internal function as mail() does.
* 2 message is sent through the PHP debugging connection.
* This option is only available if remote debugging has been enabled.
* In this case, the destination parameter specifies the host name or IP address
* and optionally, port number, of the socket receiving the debug information.
* 3 message is appended to the file destination
*/
if (defined('ADODB_ERROR_LOG_TYPE')) {
$t = date('Y-m-d H:i:s');
if (defined('ADODB_ERROR_LOG_DEST'))
error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST);
else
error_log("($t) $s", ADODB_ERROR_LOG_TYPE);
}
//print "<p>$s</p>";
trigger_error($s,ADODB_ERROR_HANDLER_TYPE);
}
?>

View file

@ -0,0 +1,88 @@
<?php
/**
* @version V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com
*
*/
include_once('PEAR.php');
if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR');
/*
* Enabled the following if you want to terminate scripts when an error occurs
*/
//PEAR::setErrorHandling (PEAR_ERROR_DIE);
/*
* Name of the PEAR_Error derived class to call.
*/
if (!defined('ADODB_PEAR_ERROR_CLASS')) define('ADODB_PEAR_ERROR_CLASS','PEAR_Error');
/*
* Store the last PEAR_Error object here
*/
global $ADODB_Last_PEAR_Error; $ADODB_Last_PEAR_Error = false;
/**
* Error Handler with PEAR support. This will be called with the following params
*
* @param $dbms the RDBMS you are connecting to
* @param $fn the name of the calling function (in uppercase)
* @param $errno the native error number from the database
* @param $errmsg the native error msg from the database
* @param $p1 $fn specific parameter - see below
* @param $P2 $fn specific parameter - see below
*/
function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
{
global $ADODB_Last_PEAR_Error;
if (error_reporting() == 0) return; // obey @ protocol
switch($fn) {
case 'EXECUTE':
$sql = $p1;
$inputparams = $p2;
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")";
break;
case 'PCONNECT':
case 'CONNECT':
$host = $p1;
$database = $p2;
$s = "$dbms error: [$errno: $errmsg] in $fn('$host', ?, ?, '$database')";
break;
default:
$s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";
break;
}
$class = ADODB_PEAR_ERROR_CLASS;
$ADODB_Last_PEAR_Error = new $class($s, $errno,
$GLOBALS['_PEAR_default_error_mode'],
$GLOBALS['_PEAR_default_error_options'],
$errmsg);
//print "<p>!$s</p>";
}
/**
* Returns last PEAR_Error object. This error might be for an error that
* occured several sql statements ago.
*/
function ADODB_PEAR_Error()
{
global $ADODB_Last_PEAR_Error;
return $ADODB_Last_PEAR_Error;
}
?>

View file

@ -0,0 +1,80 @@
<?php
/**
* @version V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com
*
* Exception-handling code using PHP5 exceptions (try-catch-throw).
*/
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
define('ADODB_ERROR_HANDLER','adodb_throw');
class ADODB_Exception extends Exception {
var $dbms;
var $fn;
var $sql = '';
var $params = '';
var $host = '';
var $database = '';
function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
{
switch($fn) {
case 'EXECUTE':
$this->sql = $p1;
$this->params = $p2;
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n";
break;
case 'PCONNECT':
case 'CONNECT':
$user = $thisConnection->user;
$s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)\n";
break;
default:
$s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
break;
}
$this->dbms = $dbms;
$this->host = $thisConnection->host;
$this->database = $thisConnection->database;
$this->fn = $fn;
$this->msg = $errmsg;
if (!is_numeric($errno)) $errno = -1;
parent::__construct($s,$errno);
}
}
/**
* Default Error Handler. This will be called with the following params
*
* @param $dbms the RDBMS you are connecting to
* @param $fn the name of the calling function (in uppercase)
* @param $errno the native error number from the database
* @param $errmsg the native error msg from the database
* @param $p1 $fn specific parameter - see below
* @param $P2 $fn specific parameter - see below
*/
function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
{
global $ADODB_EXCEPTION;
if (error_reporting() == 0) return; // obey @ protocol
if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
else $errfn = 'ADODB_EXCEPTION';
throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
}
?>

View file

@ -0,0 +1,84 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
Declares the ADODB Base Class for PHP5 "ADODB_BASE_RS", and supports iteration with
the ADODB_Iterator class.
$rs = $db->Execute("select * from adoxyz");
foreach($rs as $k => $v) {
echo $k; print_r($v); echo "<br>";
}
Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2
*/
class ADODB_Iterator implements Iterator {
private $rs;
function __construct($rs)
{
$this->rs = $rs;
}
function rewind()
{
$this->rs->MoveFirst();
}
function valid()
{
return !$this->rs->EOF;
}
function key()
{
return $this->rs->_currentRow;
}
function current()
{
return $this->rs->fields;
}
function next()
{
$this->rs->MoveNext();
}
function __call($func, $params)
{
return call_user_func_array(array($this->rs, $func), $params);
}
function hasMore()
{
return !$this->rs->EOF;
}
}
class ADODB_BASE_RS implements IteratorAggregate {
function getIterator() {
return new ADODB_Iterator($this);
}
/* this is experimental - i don't really know what to return... */
function __toString()
{
include_once(ADODB_DIR.'/toexport.inc.php');
return _adodb_export($this,',',',',false,true);
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,290 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
This class provides recordset pagination with
First/Prev/Next/Last links.
Feel free to modify this class for your own use as
it is very basic. To learn how to use it, see the
example in adodb/tests/testpaging.php.
"Pablo Costa" <pablo@cbsp.com.br> implemented Render_PageLinks().
Please note, this class is entirely unsupported,
and no free support requests except for bug reports
will be entertained by the author.
*/
class ADODB_Pager {
var $id; // unique id for pager (defaults to 'adodb')
var $db; // ADODB connection object
var $sql; // sql used
var $rs; // recordset generated
var $curr_page; // current page number before Render() called, calculated in constructor
var $rows; // number of rows per page
var $linksPerPage=10; // number of links per page in navigation bar
var $showPageLinks;
var $gridAttributes = 'width=100% border=1 bgcolor=white';
// Localize text strings here
var $first = '<code>|&lt;</code>';
var $prev = '<code>&lt;&lt;</code>';
var $next = '<code>>></code>';
var $last = '<code>>|</code>';
var $moreLinks = '...';
var $startLinks = '...';
var $gridHeader = false;
var $htmlSpecialChars = true;
var $page = 'Page';
var $linkSelectedColor = 'red';
var $cache = 0; #secs to cache with CachePageExecute()
//----------------------------------------------
// constructor
//
// $db adodb connection object
// $sql sql statement
// $id optional id to identify which pager,
// if you have multiple on 1 page.
// $id should be only be [a-z0-9]*
//
function ADODB_Pager(&$db,$sql,$id = 'adodb', $showPageLinks = false)
{
global $PHP_SELF;
$curr_page = $id.'_curr_page';
if (empty($PHP_SELF)) $PHP_SELF = $_SERVER['PHP_SELF'];
$this->sql = $sql;
$this->id = $id;
$this->db = $db;
$this->showPageLinks = $showPageLinks;
$next_page = $id.'_next_page';
if (isset($_GET[$next_page])) {
$_SESSION[$curr_page] = $_GET[$next_page];
}
if (empty($_SESSION[$curr_page])) $_SESSION[$curr_page] = 1; ## at first page
$this->curr_page = $_SESSION[$curr_page];
}
//---------------------------
// Display link to first page
function Render_First($anchor=true)
{
global $PHP_SELF;
if ($anchor) {
?>
<a href="<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"><?php echo $this->first;?></a> &nbsp;
<?php
} else {
print "$this->first &nbsp; ";
}
}
//--------------------------
// Display link to next page
function render_next($anchor=true)
{
global $PHP_SELF;
if ($anchor) {
?>
<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() + 1 ?>"><?php echo $this->next;?></a> &nbsp;
<?php
} else {
print "$this->next &nbsp; ";
}
}
//------------------
// Link to last page
//
// for better performance with large recordsets, you can set
// $this->db->pageExecuteCountRows = false, which disables
// last page counting.
function render_last($anchor=true)
{
global $PHP_SELF;
if (!$this->db->pageExecuteCountRows) return;
if ($anchor) {
?>
<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->LastPageNo() ?>"><?php echo $this->last;?></a> &nbsp;
<?php
} else {
print "$this->last &nbsp; ";
}
}
//---------------------------------------------------
// original code by "Pablo Costa" <pablo@cbsp.com.br>
function render_pagelinks()
{
global $PHP_SELF;
$pages = $this->rs->LastPageNo();
$linksperpage = $this->linksPerPage ? $this->linksPerPage : $pages;
for($i=1; $i <= $pages; $i+=$linksperpage)
{
if($this->rs->AbsolutePage() >= $i)
{
$start = $i;
}
}
$numbers = '';
$end = $start+$linksperpage-1;
$link = $this->id . "_next_page";
if($end > $pages) $end = $pages;
if ($this->startLinks && $start > 1) {
$pos = $start - 1;
$numbers .= "<a href=$PHP_SELF?$link=$pos>$this->startLinks</a> ";
}
for($i=$start; $i <= $end; $i++) {
if ($this->rs->AbsolutePage() == $i)
$numbers .= "<font color=$this->linkSelectedColor><b>$i</b></font> ";
else
$numbers .= "<a href=$PHP_SELF?$link=$i>$i</a> ";
}
if ($this->moreLinks && $end < $pages)
$numbers .= "<a href=$PHP_SELF?$link=$i>$this->moreLinks</a> ";
print $numbers . ' &nbsp; ';
}
// Link to previous page
function render_prev($anchor=true)
{
global $PHP_SELF;
if ($anchor) {
?>
<a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() - 1 ?>"><?php echo $this->prev;?></a> &nbsp;
<?php
} else {
print "$this->prev &nbsp; ";
}
}
//--------------------------------------------------------
// Simply rendering of grid. You should override this for
// better control over the format of the grid
//
// We use output buffering to keep code clean and readable.
function RenderGrid()
{
global $gSQLBlockRows; // used by rs2html to indicate how many rows to display
include_once(ADODB_DIR.'/tohtml.inc.php');
ob_start();
$gSQLBlockRows = $this->rows;
rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars);
$s = ob_get_contents();
ob_end_clean();
return $s;
}
//-------------------------------------------------------
// Navigation bar
//
// we use output buffering to keep the code easy to read.
function RenderNav()
{
ob_start();
if (!$this->rs->AtFirstPage()) {
$this->Render_First();
$this->Render_Prev();
} else {
$this->Render_First(false);
$this->Render_Prev(false);
}
if ($this->showPageLinks){
$this->Render_PageLinks();
}
if (!$this->rs->AtLastPage()) {
$this->Render_Next();
$this->Render_Last();
} else {
$this->Render_Next(false);
$this->Render_Last(false);
}
$s = ob_get_contents();
ob_end_clean();
return $s;
}
//-------------------
// This is the footer
function RenderPageCount()
{
if (!$this->db->pageExecuteCountRows) return '';
$lastPage = $this->rs->LastPageNo();
if ($lastPage == -1) $lastPage = 1; // check for empty rs.
if ($this->curr_page > $lastPage) $this->curr_page = 1;
return "<font size=-1>$this->page ".$this->curr_page."/".$lastPage."</font>";
}
//-----------------------------------
// Call this class to draw everything.
function Render($rows=10)
{
global $ADODB_COUNTRECS;
$this->rows = $rows;
if ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL;
$savec = $ADODB_COUNTRECS;
if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true;
if ($this->cache)
$rs = &$this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page);
else
$rs = &$this->db->PageExecute($this->sql,$rows,$this->curr_page);
$ADODB_COUNTRECS = $savec;
$this->rs = &$rs;
if (!$rs) {
print "<h3>Query failed: $this->sql</h3>";
return;
}
if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage()))
$header = $this->RenderNav();
else
$header = "&nbsp;";
$grid = $this->RenderGrid();
$footer = $this->RenderPageCount();
$this->RenderLayout($header,$grid,$footer);
$rs->Close();
$this->rs = false;
}
//------------------------------------------------------
// override this to control overall layout and formating
function RenderLayout($header,$grid,$footer,$attributes='border=1 bgcolor=beige')
{
echo "<table ".$attributes."><tr><td>",
$header,
"</td></tr><tr><td>",
$grid,
"</td></tr><tr><td>",
$footer,
"</td></tr></table>";
}
}
?>

View file

@ -0,0 +1,374 @@
<?php
/**
* @version V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
* PEAR DB Emulation Layer for ADODB.
*
* The following code is modelled on PEAR DB code by Stig Bakken <ssb@fast.no> |
* and Tomas V.V.Cox <cox@idecnet.com>. Portions (c)1997-2002 The PHP Group.
*/
/*
We support:
DB_Common
---------
query - returns PEAR_Error on error
limitQuery - return PEAR_Error on error
prepare - does not return PEAR_Error on error
execute - does not return PEAR_Error on error
setFetchMode - supports ASSOC and ORDERED
errorNative
quote
nextID
disconnect
getOne
getAssoc
getRow
getCol
getAll
DB_Result
---------
numRows - returns -1 if not supported
numCols
fetchInto - does not support passing of fetchmode
fetchRows - does not support passing of fetchmode
free
*/
define('ADODB_PEAR',dirname(__FILE__));
include_once "PEAR.php";
include_once ADODB_PEAR."/adodb-errorpear.inc.php";
include_once ADODB_PEAR."/adodb.inc.php";
if (!defined('DB_OK')) {
define("DB_OK", 1);
define("DB_ERROR",-1);
// autoExecute constants
define('DB_AUTOQUERY_INSERT', 1);
define('DB_AUTOQUERY_UPDATE', 2);
/**
* This is a special constant that tells DB the user hasn't specified
* any particular get mode, so the default should be used.
*/
define('DB_FETCHMODE_DEFAULT', 0);
/**
* Column data indexed by numbers, ordered from 0 and up
*/
define('DB_FETCHMODE_ORDERED', 1);
/**
* Column data indexed by column names
*/
define('DB_FETCHMODE_ASSOC', 2);
/* for compatibility */
define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED);
define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC);
/**
* these are constants for the tableInfo-function
* they are bitwised or'ed. so if there are more constants to be defined
* in the future, adjust DB_TABLEINFO_FULL accordingly
*/
define('DB_TABLEINFO_ORDER', 1);
define('DB_TABLEINFO_ORDERTABLE', 2);
define('DB_TABLEINFO_FULL', 3);
}
/**
* The main "DB" class is simply a container class with some static
* methods for creating DB objects as well as some utility functions
* common to all parts of DB.
*
*/
class DB
{
/**
* Create a new DB object for the specified database type
*
* @param $type string database type, for example "mysql"
*
* @return object a newly created DB object, or a DB error code on
* error
*/
function factory($type)
{
include_once(ADODB_DIR."/drivers/adodb-$type.inc.php");
$obj = &NewADOConnection($type);
if (!is_object($obj)) $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
return $obj;
}
/**
* Create a new DB object and connect to the specified database
*
* @param $dsn mixed "data source name", see the DB::parseDSN
* method for a description of the dsn format. Can also be
* specified as an array of the format returned by DB::parseDSN.
*
* @param $options mixed if boolean (or scalar), tells whether
* this connection should be persistent (for backends that support
* this). This parameter can also be an array of options, see
* DB_common::setOption for more information on connection
* options.
*
* @return object a newly created DB connection object, or a DB
* error object on error
*
* @see DB::parseDSN
* @see DB::isError
*/
function connect($dsn, $options = false)
{
if (is_array($dsn)) {
$dsninfo = $dsn;
} else {
$dsninfo = DB::parseDSN($dsn);
}
switch ($dsninfo["phptype"]) {
case 'pgsql': $type = 'postgres7'; break;
case 'ifx': $type = 'informix9'; break;
default: $type = $dsninfo["phptype"]; break;
}
if (is_array($options) && isset($options["debug"]) &&
$options["debug"] >= 2) {
// expose php errors with sufficient debug level
@include_once("adodb-$type.inc.php");
} else {
@include_once("adodb-$type.inc.php");
}
@$obj =& NewADOConnection($type);
if (!is_object($obj)) {
$obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
return $obj;
}
if (is_array($options)) {
foreach($options as $k => $v) {
switch(strtolower($k)) {
case 'persist':
case 'persistent': $persist = $v; break;
#ibase
case 'dialect': $obj->dialect = $v; break;
case 'charset': $obj->charset = $v; break;
case 'buffers': $obj->buffers = $v; break;
#ado
case 'charpage': $obj->charPage = $v; break;
#mysql
case 'clientflags': $obj->clientFlags = $v; break;
}
}
} else {
$persist = false;
}
if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket'];
else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port'];
if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);
else $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);
if (!$ok) $obj = ADODB_PEAR_Error();
return $obj;
}
/**
* Return the DB API version
*
* @return int the DB API version number
*/
function apiVersion()
{
return 2;
}
/**
* Tell whether a result code from a DB method is an error
*
* @param $value int result code
*
* @return bool whether $value is an error
*/
function isError($value)
{
if (!is_object($value)) return false;
$class = get_class($value);
return $class == 'pear_error' || is_subclass_of($value, 'pear_error') ||
$class == 'db_error' || is_subclass_of($value, 'db_error');
}
/**
* Tell whether a result code from a DB method is a warning.
* Warnings differ from errors in that they are generated by DB,
* and are not fatal.
*
* @param $value mixed result value
*
* @return bool whether $value is a warning
*/
function isWarning($value)
{
return false;
/*
return is_object($value) &&
(get_class( $value ) == "db_warning" ||
is_subclass_of($value, "db_warning"));*/
}
/**
* Parse a data source name
*
* @param $dsn string Data Source Name to be parsed
*
* @return array an associative array with the following keys:
*
* phptype: Database backend used in PHP (mysql, odbc etc.)
* dbsyntax: Database used with regards to SQL syntax etc.
* protocol: Communication protocol to use (tcp, unix etc.)
* hostspec: Host specification (hostname[:port])
* database: Database to use on the DBMS server
* username: User name for login
* password: Password for login
*
* The format of the supplied DSN is in its fullest form:
*
* phptype(dbsyntax)://username:password@protocol+hostspec/database
*
* Most variations are allowed:
*
* phptype://username:password@protocol+hostspec:110//usr/db_file.db
* phptype://username:password@hostspec/database_name
* phptype://username:password@hostspec
* phptype://username@hostspec
* phptype://hostspec/database
* phptype://hostspec
* phptype(dbsyntax)
* phptype
*
* @author Tomas V.V.Cox <cox@idecnet.com>
*/
function parseDSN($dsn)
{
if (is_array($dsn)) {
return $dsn;
}
$parsed = array(
'phptype' => false,
'dbsyntax' => false,
'protocol' => false,
'hostspec' => false,
'database' => false,
'username' => false,
'password' => false
);
// Find phptype and dbsyntax
if (($pos = strpos($dsn, '://')) !== false) {
$str = substr($dsn, 0, $pos);
$dsn = substr($dsn, $pos + 3);
} else {
$str = $dsn;
$dsn = NULL;
}
// Get phptype and dbsyntax
// $str => phptype(dbsyntax)
if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
$parsed['phptype'] = $arr[1];
$parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2];
} else {
$parsed['phptype'] = $str;
$parsed['dbsyntax'] = $str;
}
if (empty($dsn)) {
return $parsed;
}
// Get (if found): username and password
// $dsn => username:password@protocol+hostspec/database
if (($at = strpos($dsn,'@')) !== false) {
$str = substr($dsn, 0, $at);
$dsn = substr($dsn, $at + 1);
if (($pos = strpos($str, ':')) !== false) {
$parsed['username'] = urldecode(substr($str, 0, $pos));
$parsed['password'] = urldecode(substr($str, $pos + 1));
} else {
$parsed['username'] = urldecode($str);
}
}
// Find protocol and hostspec
// $dsn => protocol+hostspec/database
if (($pos=strpos($dsn, '/')) !== false) {
$str = substr($dsn, 0, $pos);
$dsn = substr($dsn, $pos + 1);
} else {
$str = $dsn;
$dsn = NULL;
}
// Get protocol + hostspec
// $str => protocol+hostspec
if (($pos=strpos($str, '+')) !== false) {
$parsed['protocol'] = substr($str, 0, $pos);
$parsed['hostspec'] = urldecode(substr($str, $pos + 1));
} else {
$parsed['hostspec'] = urldecode($str);
}
// Get dabase if any
// $dsn => database
if (!empty($dsn)) {
$parsed['database'] = $dsn;
}
return $parsed;
}
/**
* Load a PHP database extension if it is not loaded already.
*
* @access public
*
* @param $name the base name of the extension (without the .so or
* .dll suffix)
*
* @return bool true if the extension was already or successfully
* loaded, false if it could not be loaded
*/
function assertExtension($name)
{
if (!extension_loaded($name)) {
$dlext = (strncmp(PHP_OS,'WIN',3) === 0) ? '.dll' : '.so';
@dl($name . $dlext);
}
if (!extension_loaded($name)) {
return false;
}
return true;
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,16 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
*/
class ADODB_BASE_RS {
}
?>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,183 @@
<?php
/**
* Helper functions to convert between ADODB recordset objects and XMLRPC values.
* Uses John Lim's AdoDB and Edd Dumbill's phpxmlrpc libs
*
* @author Daniele Baroncelli
* @author Gaetano Giunta
* @copyright (c) 2003-2004 Giunta/Baroncelli. All rights reserved.
*
* @todo some more error checking here and there
* @todo document the xmlrpc-struct used to encode recordset info
* @todo verify if using xmlrpc_encode($rs->GetArray()) would work with:
* - ADODB_FETCH_BOTH
* - null values
*/
/**
* Include the main libraries
*/
require_once('xmlrpc.inc');
if (!defined('ADODB_DIR')) require_once('adodb.inc.php');
/**
* Builds an xmlrpc struct value out of an AdoDB recordset
*/
function rs2xmlrpcval(&$adodbrs) {
$header =& rs2xmlrpcval_header($adodbrs);
$body =& rs2xmlrpcval_body($adodbrs);
// put it all together and build final xmlrpc struct
$xmlrpcrs = new xmlrpcval ( array(
"header" => $header,
"body" => $body,
), "struct");
return $xmlrpcrs;
}
/**
* Builds an xmlrpc struct value describing an AdoDB recordset
*/
function rs2xmlrpcval_header($adodbrs)
{
$numfields = $adodbrs->FieldCount();
$numrecords = $adodbrs->RecordCount();
// build structure holding recordset information
$fieldstruct = array();
for ($i = 0; $i < $numfields; $i++) {
$fld = $adodbrs->FetchField($i);
$fieldarray = array();
if (isset($fld->name))
$fieldarray["name"] = new xmlrpcval ($fld->name);
if (isset($fld->type))
$fieldarray["type"] = new xmlrpcval ($fld->type);
if (isset($fld->max_length))
$fieldarray["max_length"] = new xmlrpcval ($fld->max_length, "int");
if (isset($fld->not_null))
$fieldarray["not_null"] = new xmlrpcval ($fld->not_null, "boolean");
if (isset($fld->has_default))
$fieldarray["has_default"] = new xmlrpcval ($fld->has_default, "boolean");
if (isset($fld->default_value))
$fieldarray["default_value"] = new xmlrpcval ($fld->default_value);
$fieldstruct[$i] = new xmlrpcval ($fieldarray, "struct");
}
$fieldcount = new xmlrpcval ($numfields, "int");
$recordcount = new xmlrpcval ($numrecords, "int");
$sql = new xmlrpcval ($adodbrs->sql);
$fieldinfo = new xmlrpcval ($fieldstruct, "array");
$header = new xmlrpcval ( array(
"fieldcount" => $fieldcount,
"recordcount" => $recordcount,
"sql" => $sql,
"fieldinfo" => $fieldinfo
), "struct");
return $header;
}
/**
* Builds an xmlrpc struct value out of an AdoDB recordset
* (data values only, no data definition)
*/
function rs2xmlrpcval_body($adodbrs)
{
$numfields = $adodbrs->FieldCount();
// build structure containing recordset data
$adodbrs->MoveFirst();
$rows = array();
while (!$adodbrs->EOF) {
$columns = array();
// This should work on all cases of fetch mode: assoc, num, both or default
if ($adodbrs->fetchMode == 'ADODB_FETCH_BOTH' || count($adodbrs->fields) == 2 * $adodbrs->FieldCount())
for ($i = 0; $i < $numfields; $i++)
if ($adodbrs->fields[$i] === null)
$columns[$i] = new xmlrpcval ('');
else
$columns[$i] =& xmlrpc_encode ($adodbrs->fields[$i]);
else
foreach ($adodbrs->fields as $val)
if ($val === null)
$columns[] = new xmlrpcval ('');
else
$columns[] =& xmlrpc_encode ($val);
$rows[] = new xmlrpcval ($columns, "array");
$adodbrs->MoveNext();
}
$body = new xmlrpcval ($rows, "array");
return $body;
}
/**
* Returns an xmlrpc struct value as string out of an AdoDB recordset
*/
function rs2xmlrpcstring (&$adodbrs) {
$xmlrpc = rs2xmlrpcval ($adodbrs);
if ($xmlrpc)
return $xmlrpc->serialize();
else
return null;
}
/**
* Given a well-formed xmlrpc struct object returns an AdoDB object
*
* @todo add some error checking on the input value
*/
function xmlrpcval2rs (&$xmlrpcval) {
$fields_array = array();
$data_array = array();
// rebuild column information
$header =& $xmlrpcval->structmem('header');
$numfields = $header->structmem('fieldcount');
$numfields = $numfields->scalarval();
$numrecords = $header->structmem('recordcount');
$numrecords = $numrecords->scalarval();
$sqlstring = $header->structmem('sql');
$sqlstring = $sqlstring->scalarval();
$fieldinfo =& $header->structmem('fieldinfo');
for ($i = 0; $i < $numfields; $i++) {
$temp =& $fieldinfo->arraymem($i);
$fld = new ADOFieldObject();
while (list($key,$value) = $temp->structeach()) {
if ($key == "name") $fld->name = $value->scalarval();
if ($key == "type") $fld->type = $value->scalarval();
if ($key == "max_length") $fld->max_length = $value->scalarval();
if ($key == "not_null") $fld->not_null = $value->scalarval();
if ($key == "has_default") $fld->has_default = $value->scalarval();
if ($key == "default_value") $fld->default_value = $value->scalarval();
} // while
$fields_array[] = $fld;
} // for
// fetch recordset information into php array
$body =& $xmlrpcval->structmem('body');
for ($i = 0; $i < $numrecords; $i++) {
$data_array[$i]= array();
$xmlrpcrs_row =& $body->arraymem($i);
for ($j = 0; $j < $numfields; $j++) {
$temp =& $xmlrpcrs_row->arraymem($j);
$data_array[$i][$j] = $temp->scalarval();
} // for j
} // for i
// finally build in-memory recordset object and return it
$rs = new ADORecordSet_array();
$rs->InitArrayFields($data_array,$fields_array);
return $rs;
}
?>

Binary file not shown.

After

(image error) Size: 1.1 KiB

Binary file not shown.

After

(image error) Size: 1.4 KiB

View file

@ -0,0 +1,986 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
MySQL code that does not support transactions. Use mysqlt if you need transactions.
Requires mysql client. Works on Windows and Unix.
21 October 2003: MySQLi extension implementation by Arjen de Rijke (a.de.rijke@xs4all.nl)
Based on adodb 3.40
*/
// security - hide paths
//if (!defined('ADODB_DIR')) die();
if (! defined("_ADODB_MYSQLI_LAYER")) {
define("_ADODB_MYSQLI_LAYER", 1 );
// PHP5 compat...
if (! defined("MYSQLI_BINARY_FLAG")) define("MYSQLI_BINARY_FLAG", 128);
if (!defined('MYSQLI_READ_DEFAULT_GROUP')) define('MYSQLI_READ_DEFAULT_GROUP',1);
// disable adodb extension - currently incompatible.
global $ADODB_EXTENSION; $ADODB_EXTENSION = false;
class ADODB_mysqli extends ADOConnection {
var $databaseType = 'mysqli';
var $dataProvider = 'native';
var $hasInsertID = true;
var $hasAffectedRows = true;
var $metaTablesSQL = "SHOW TABLES";
var $metaColumnsSQL = "SHOW COLUMNS FROM %s";
var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $hasLimit = true;
var $hasMoveFirst = true;
var $hasGenID = true;
var $isoDates = true; // accepts dates in ISO format
var $sysDate = 'CURDATE()';
var $sysTimeStamp = 'NOW()';
var $hasTransactions = true;
var $forceNewConnect = false;
var $poorAffectedRows = true;
var $clientFlags = 0;
var $substr = "substring";
var $port = false;
var $socket = false;
var $_bindInputArray = false;
var $nameQuote = '`'; /// string to use to quote identifiers and names
var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0));
function __construct()
{
// if(!extension_loaded("mysqli"))
;//trigger_error("You must have the mysqli extension installed.", E_USER_ERROR);
}
// returns true or false
// To add: parameter int $port,
// parameter string $socket
function _connect($argHostname = NULL,
$argUsername = NULL,
$argPassword = NULL,
$argDatabasename = NULL, $persist=false)
{
if(!extension_loaded("mysqli")) {
return null;
}
$this->_connectionID = @mysqli_init();
if (is_null($this->_connectionID)) {
// mysqli_init only fails if insufficient memory
if ($this->debug)
ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());
return false;
}
/*
I suggest a simple fix which would enable adodb and mysqli driver to
read connection options from the standard mysql configuration file
/etc/my.cnf - "Bastien Duclaux" <bduclaux#yahoo.com>
*/
foreach($this->optionFlags as $arr) {
mysqli_options($this->_connectionID,$arr[0],$arr[1]);
}
#if (!empty($this->port)) $argHostname .= ":".$this->port;
$ok = mysqli_real_connect($this->_connectionID,
$argHostname,
$argUsername,
$argPassword,
$argDatabasename,
$this->port,
$this->socket,
$this->clientFlags);
if ($ok) {
if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
} else {
if ($this->debug)
ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
return false;
}
}
// returns true or false
// How to force a persistent connection
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true);
}
// When is this used? Close old connection first?
// In _connect(), check $this->forceNewConnect?
function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
$this->forceNewConnect = true;
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
}
function IfNull( $field, $ifNull )
{
return " IFNULL($field, $ifNull) "; // if MySQL
}
function ServerInfo()
{
$arr['description'] = $this->GetOne("select version()");
$arr['version'] = ADOConnection::_findvers($arr['description']);
return $arr;
}
function BeginTrans()
{
if ($this->transOff) return true;
$this->transCnt += 1;
$this->Execute('SET AUTOCOMMIT=0');
$this->Execute('BEGIN');
return true;
}
function CommitTrans($ok=true)
{
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
$this->Execute('COMMIT');
$this->Execute('SET AUTOCOMMIT=1');
return true;
}
function RollbackTrans()
{
if ($this->transOff) return true;
if ($this->transCnt) $this->transCnt -= 1;
$this->Execute('ROLLBACK');
$this->Execute('SET AUTOCOMMIT=1');
return true;
}
function RowLock($tables,$where='',$flds='1 as adodb_ignore')
{
if ($this->transCnt==0) $this->BeginTrans();
if ($where) $where = ' where '.$where;
$rs =& $this->Execute("select $flds from $tables $where for update");
return !empty($rs);
}
// if magic quotes disabled, use mysql_real_escape_string()
// From readme.htm:
// Quotes a string to be sent to the database. The $magic_quotes_enabled
// parameter may look funny, but the idea is if you are quoting a
// string extracted from a POST/GET variable, then
// pass get_magic_quotes_gpc() as the second parameter. This will
// ensure that the variable is not quoted twice, once by qstr and once
// by the magic_quotes_gpc.
//
//Eg. $s = $db->qstr(_GET['name'],get_magic_quotes_gpc());
function qstr($s, $magic_quotes = false)
{
if (!$magic_quotes) {
if (PHP_VERSION >= 5)
return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'";
if ($this->replaceQuote[0] == '\\')
$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
return "'".str_replace("'",$this->replaceQuote,$s)."'";
}
// undo magic quotes for "
$s = str_replace('\\"','"',$s);
return "'$s'";
}
function _insertid()
{
$result = @mysqli_insert_id($this->_connectionID);
if ($result == -1){
if ($this->debug) ADOConnection::outp("mysqli_insert_id() failed : " . $this->ErrorMsg());
}
return $result;
}
// Only works for INSERT, UPDATE and DELETE query's
function _affectedrows()
{
$result = @mysqli_affected_rows($this->_connectionID);
if ($result == -1) {
if ($this->debug) ADOConnection::outp("mysqli_affected_rows() failed : " . $this->ErrorMsg());
}
return $result;
}
// See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
// Reference on Last_Insert_ID on the recommended way to simulate sequences
var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
var $_genSeqSQL = "create table %s (id int not null)";
var $_genSeq2SQL = "insert into %s values (%s)";
var $_dropSeqSQL = "drop table %s";
function CreateSequence($seqname='adodbseq',$startID=1)
{
if (empty($this->_genSeqSQL)) return false;
$u = strtoupper($seqname);
$ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
if (!$ok) return false;
return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
}
function GenID($seqname='adodbseq',$startID=1)
{
// post-nuke sets hasGenID to false
if (!$this->hasGenID) return false;
$getnext = sprintf($this->_genIDSQL,$seqname);
$holdtransOK = $this->_transOK; // save the current status
$rs = @$this->Execute($getnext);
if (!$rs) {
if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset
$u = strtoupper($seqname);
$this->Execute(sprintf($this->_genSeqSQL,$seqname));
$this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
$rs = $this->Execute($getnext);
}
$this->genID = mysqli_insert_id($this->_connectionID);
if ($rs) $rs->Close();
return $this->genID;
}
function MetaDatabases()
{
$query = "SHOW DATABASES";
$ret =& $this->Execute($query);
if ($ret && is_object($ret)){
$arr = array();
while (!$ret->EOF){
$db = $ret->Fields('Database');
if ($db != 'mysql') $arr[] = $db;
$ret->MoveNext();
}
return $arr;
}
return $ret;
}
function MetaIndexes ($table, $primary = FALSE, $owner = false)
{
// save old fetch mode
global $ADODB_FETCH_MODE;
$false = false;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== FALSE) {
$savem = $this->SetFetchMode(FALSE);
}
// get index details
$rs = $this->Execute(sprintf('SHOW INDEXES FROM %s',$table));
// restore fetchmode
if (isset($savem)) {
$this->SetFetchMode($savem);
}
$ADODB_FETCH_MODE = $save;
if (!is_object($rs)) {
return $false;
}
$indexes = array ();
// parse index data into array
while ($row = $rs->FetchRow()) {
if ($primary == FALSE AND $row[2] == 'PRIMARY') {
continue;
}
if (!isset($indexes[$row[2]])) {
$indexes[$row[2]] = array(
'unique' => ($row[1] == 0),
'columns' => array()
);
}
$indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
}
// sort columns by order in the index
foreach ( array_keys ($indexes) as $index )
{
ksort ($indexes[$index]['columns']);
}
return $indexes;
}
// Format date column in sql string given an input format that understands Y M D
function SQLDate($fmt, $col=false)
{
if (!$col) $col = $this->sysTimeStamp;
$s = 'DATE_FORMAT('.$col.",'";
$concat = false;
$len = strlen($fmt);
for ($i=0; $i < $len; $i++) {
$ch = $fmt[$i];
switch($ch) {
case 'Y':
case 'y':
$s .= '%Y';
break;
case 'Q':
case 'q':
$s .= "'),Quarter($col)";
if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
else $s .= ",('";
$concat = true;
break;
case 'M':
$s .= '%b';
break;
case 'm':
$s .= '%m';
break;
case 'D':
case 'd':
$s .= '%d';
break;
case 'H':
$s .= '%H';
break;
case 'h':
$s .= '%I';
break;
case 'i':
$s .= '%i';
break;
case 's':
$s .= '%s';
break;
case 'a':
case 'A':
$s .= '%p';
break;
case 'w':
$s .= '%w';
break;
case 'l':
$s .= '%W';
break;
default:
if ($ch == '\\') {
$i++;
$ch = substr($fmt,$i,1);
}
$s .= $ch;
break;
}
}
$s.="')";
if ($concat) $s = "CONCAT($s)";
return $s;
}
// returns concatenated string
// much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator
function Concat()
{
$s = "";
$arr = func_get_args();
// suggestion by andrew005@mnogo.ru
$s = implode(',',$arr);
if (strlen($s) > 0) return "CONCAT($s)";
else return '';
}
// dayFraction is a day in floating point
function OffsetDate($dayFraction,$date=false)
{
if (!$date)
$date = $this->sysDate;
return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)";
}
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
$save = $this->metaTablesSQL;
if ($showSchema && is_string($showSchema)) {
$this->metaTablesSQL .= " from $showSchema";
}
if ($mask) {
$mask = $this->qstr($mask);
$this->metaTablesSQL .= " like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
$this->metaTablesSQL = $save;
return $ret;
}
// "Innox - Juan Carlos Gonzalez" <jgonzalez#innox.com.mx>
function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE )
{
if ( !empty($owner) ) {
$table = "$owner.$table";
}
$a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
if ($associative) $create_sql = $a_create_table["Create Table"];
else $create_sql = $a_create_table[1];
$matches = array();
if (!preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches)) return false;
$foreign_keys = array();
$num_keys = count($matches[0]);
for ( $i = 0; $i < $num_keys; $i ++ ) {
$my_field = explode('`, `', $matches[1][$i]);
$ref_table = $matches[2][$i];
$ref_field = explode('`, `', $matches[3][$i]);
if ( $upper ) {
$ref_table = strtoupper($ref_table);
}
$foreign_keys[$ref_table] = array();
$num_fields = count($my_field);
for ( $j = 0; $j < $num_fields; $j ++ ) {
if ( $associative ) {
$foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
} else {
$foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}";
}
}
}
return $foreign_keys;
}
function MetaColumns($table, $normalize = true)
{
$false = false;
if (!$this->metaColumnsSQL)
return $false;
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false)
$savem = $this->SetFetchMode(false);
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!is_object($rs))
return $false;
$retarr = array();
while (!$rs->EOF) {
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$type = $rs->fields[1];
// split type into type(length):
$fld->scale = null;
if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
$fld->type = $query_array[1];
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
$fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
} elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
$fld->type = $query_array[1];
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
} elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
$fld->type = $query_array[1];
$fld->max_length = max(array_map("strlen",explode(",",$query_array[2]))) - 2; // PHP >= 4.0.6
$fld->max_length = ($fld->max_length == 0 ? 1 : $fld->max_length);
} else {
$fld->type = $type;
$fld->max_length = -1;
}
$fld->not_null = ($rs->fields[2] != 'YES');
$fld->primary_key = ($rs->fields[3] == 'PRI');
$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
$fld->binary = (strpos($type,'blob') !== false);
$fld->unsigned = (strpos($type,'unsigned') !== false);
if (!$fld->binary) {
$d = $rs->fields[4];
if ($d != '' && $d != 'NULL') {
$fld->has_default = true;
$fld->default_value = $d;
} else {
$fld->has_default = false;
}
}
if ($save == ADODB_FETCH_NUM) {
$retarr[] = $fld;
} else {
$retarr[strtoupper($fld->name)] = $fld;
}
$rs->MoveNext();
}
$rs->Close();
return $retarr;
}
// returns true or false
function SelectDB($dbName)
{
// $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID);
$this->database = $dbName;
$this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
if ($this->_connectionID) {
$result = @mysqli_select_db($this->_connectionID, $dbName);
if (!$result) {
ADOConnection::outp("Select of database " . $dbName . " failed. " . $this->ErrorMsg());
}
return $result;
}
return false;
}
// parameters use PostgreSQL convention, not MySQL
function SelectLimit($sql,
$nrows = -1,
$offset = -1,
$inputarr = false,
$arg3 = false,
$secs = 0)
{
$offsetStr = ($offset >= 0) ? "$offset," : '';
if ($nrows < 0) $nrows = '18446744073709551615';
if ($secs)
$rs = $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3);
else
$rs = $this->Execute($sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3);
return $rs;
}
function Prepare($sql)
{
return $sql;
$stmt = $this->_connectionID->prepare($sql);
if (!$stmt) {
echo $this->ErrorMsg();
return $sql;
}
return array($sql,$stmt);
}
// returns queryID or false
function _query($sql, $inputarr)
{
global $ADODB_COUNTRECS;
if (is_array($sql)) {
$stmt = $sql[1];
$a = '';
foreach($inputarr as $k => $v) {
if (is_string($v)) $a .= 's';
else if (is_integer($v)) $a .= 'i';
else $a .= 'd';
}
$fnarr = array_merge( array($stmt,$a) , $inputarr);
$ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr);
$ret = mysqli_stmt_execute($stmt);
return $ret;
}
if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {
if ($this->debug) ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg());
return false;
}
return $mysql_res;
}
/* Returns: the last error message from previous database operation */
function ErrorMsg()
{
if (empty($this->_connectionID))
$this->_errorMsg = @mysqli_connect_error();
else
$this->_errorMsg = @mysqli_error($this->_connectionID);
return $this->_errorMsg;
}
/* Returns: the last error number from previous database operation */
function ErrorNo()
{
if (empty($this->_connectionID))
return @mysqli_connect_errno();
else
return @mysqli_errno($this->_connectionID);
}
// returns true or false
function _close()
{
@mysqli_close($this->_connectionID);
$this->_connectionID = false;
}
/*
* Maximum size of C field
*/
function CharMax()
{
return 255;
}
/*
* Maximum size of X field
*/
function TextMax()
{
return 4294967295;
}
// this is a set of functions for managing client encoding - very important if the encodings
// of your database and your output target (i.e. HTML) don't match
// for instance, you may have UTF8 database and server it on-site as latin1 etc.
// GetCharSet - get the name of the character set the client is using now
// Under Windows, the functions should work with MySQL 4.1.11 and above, the set of charsets supported
// depends on compile flags of mysql distribution
function GetCharSet()
{
//we will use ADO's builtin property charSet
if (!is_callable($this->_connectionID,'character_set_name'))
return false;
$this->charSet = @$this->_connectionID->character_set_name();
if (!$this->charSet) {
return false;
} else {
return $this->charSet;
}
}
// SetCharSet - switch the client encoding
function SetCharSet($charset_name)
{
if (!is_callable($this->_connectionID,'set_charset'))
return false;
if ($this->charSet !== $charset_name) {
$if = @$this->_connectionID->set_charset($charset_name);
if ($if == "0" & $this->GetCharSet() == $charset_name) {
return true;
} else return false;
} else return true;
}
}
/*--------------------------------------------------------------------------------------
Class Name: Recordset
--------------------------------------------------------------------------------------*/
class ADORecordSet_mysqli extends ADORecordSet{
var $databaseType = "mysqli";
var $canSeek = true;
function __construct($queryID, $mode = false)
{
if ($mode === false)
{
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM:
$this->fetchMode = MYSQLI_NUM;
break;
case ADODB_FETCH_ASSOC:
$this->fetchMode = MYSQLI_ASSOC;
break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
default:
$this->fetchMode = MYSQLI_BOTH;
break;
}
$this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
function _initrs()
{
global $ADODB_COUNTRECS;
$this->_numOfRows = $ADODB_COUNTRECS ? @mysqli_num_rows($this->_queryID) : -1;
$this->_numOfFields = @mysqli_num_fields($this->_queryID);
}
/*
1 = MYSQLI_NOT_NULL_FLAG
2 = MYSQLI_PRI_KEY_FLAG
4 = MYSQLI_UNIQUE_KEY_FLAG
8 = MYSQLI_MULTIPLE_KEY_FLAG
16 = MYSQLI_BLOB_FLAG
32 = MYSQLI_UNSIGNED_FLAG
64 = MYSQLI_ZEROFILL_FLAG
128 = MYSQLI_BINARY_FLAG
256 = MYSQLI_ENUM_FLAG
512 = MYSQLI_AUTO_INCREMENT_FLAG
1024 = MYSQLI_TIMESTAMP_FLAG
2048 = MYSQLI_SET_FLAG
32768 = MYSQLI_NUM_FLAG
16384 = MYSQLI_PART_KEY_FLAG
32768 = MYSQLI_GROUP_FLAG
65536 = MYSQLI_UNIQUE_FLAG
131072 = MYSQLI_BINCMP_FLAG
*/
function FetchField($fieldOffset = -1)
{
$fieldnr = $fieldOffset;
if ($fieldOffset != -1) {
$fieldOffset = mysqli_field_seek($this->_queryID, $fieldnr);
}
$o = mysqli_fetch_field($this->_queryID);
/* Properties of an ADOFieldObject as set by MetaColumns */
$o->primary_key = $o->flags & MYSQLI_PRI_KEY_FLAG;
$o->not_null = $o->flags & MYSQLI_NOT_NULL_FLAG;
$o->auto_increment = $o->flags & MYSQLI_AUTO_INCREMENT_FLAG;
$o->binary = $o->flags & MYSQLI_BINARY_FLAG;
// $o->blob = $o->flags & MYSQLI_BLOB_FLAG; /* not returned by MetaColumns */
$o->unsigned = $o->flags & MYSQLI_UNSIGNED_FLAG;
return $o;
}
function GetRowAssoc($upper = true)
{
if ($this->fetchMode == MYSQLI_ASSOC && !$upper)
return $this->fields;
$row =& ADORecordSet::GetRowAssoc($upper);
return $row;
}
/* Use associative array to get fields array */
function Fields($colname)
{
if ($this->fetchMode != MYSQLI_NUM)
return @$this->fields[$colname];
if (!$this->bind) {
$this->bind = array();
for ($i = 0; $i < $this->_numOfFields; $i++) {
$o = $this->FetchField($i);
$this->bind[strtoupper($o->name)] = $i;
}
}
return $this->fields[$this->bind[strtoupper($colname)]];
}
function _seek($row)
{
if ($this->_numOfRows == 0)
return false;
if ($row < 0)
return false;
mysqli_data_seek($this->_queryID, $row);
$this->EOF = false;
return true;
}
// 10% speedup to move MoveNext to child class
// This is the only implementation that works now (23-10-2003).
// Other functions return no or the wrong results.
function MoveNext()
{
if ($this->EOF) return false;
$this->_currentRow++;
$this->fields = @mysqli_fetch_array($this->_queryID,$this->fetchMode);
if (is_array($this->fields)) return true;
$this->EOF = true;
return false;
}
function _fetch()
{
$this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode);
return is_array($this->fields);
}
function _close()
{
mysqli_free_result($this->_queryID);
$this->_queryID = false;
}
/*
0 = MYSQLI_TYPE_DECIMAL
1 = MYSQLI_TYPE_CHAR
1 = MYSQLI_TYPE_TINY
2 = MYSQLI_TYPE_SHORT
3 = MYSQLI_TYPE_LONG
4 = MYSQLI_TYPE_FLOAT
5 = MYSQLI_TYPE_DOUBLE
6 = MYSQLI_TYPE_NULL
7 = MYSQLI_TYPE_TIMESTAMP
8 = MYSQLI_TYPE_LONGLONG
9 = MYSQLI_TYPE_INT24
10 = MYSQLI_TYPE_DATE
11 = MYSQLI_TYPE_TIME
12 = MYSQLI_TYPE_DATETIME
13 = MYSQLI_TYPE_YEAR
14 = MYSQLI_TYPE_NEWDATE
247 = MYSQLI_TYPE_ENUM
248 = MYSQLI_TYPE_SET
249 = MYSQLI_TYPE_TINY_BLOB
250 = MYSQLI_TYPE_MEDIUM_BLOB
251 = MYSQLI_TYPE_LONG_BLOB
252 = MYSQLI_TYPE_BLOB
253 = MYSQLI_TYPE_VAR_STRING
254 = MYSQLI_TYPE_STRING
255 = MYSQLI_TYPE_GEOMETRY
*/
function MetaType($t, $len = -1, $fieldobj = false)
{
if (is_object($t)) {
$fieldobj = $t;
$t = $fieldobj->type;
$len = $fieldobj->max_length;
}
$len = -1; // mysql max_length is not accurate
switch (strtoupper($t)) {
case 'STRING':
case 'CHAR':
case 'VARCHAR':
case 'TINYBLOB':
case 'TINYTEXT':
case 'ENUM':
case 'SET':
case MYSQLI_TYPE_TINY_BLOB :
case MYSQLI_TYPE_CHAR :
case MYSQLI_TYPE_STRING :
case MYSQLI_TYPE_ENUM :
case MYSQLI_TYPE_SET :
case 253 :
if ($len <= $this->blobSize) return 'C';
case 'TEXT':
case 'LONGTEXT':
case 'MEDIUMTEXT':
return 'X';
// php_mysql extension always returns 'blob' even if 'text'
// so we have to check whether binary...
case 'IMAGE':
case 'LONGBLOB':
case 'BLOB':
case 'MEDIUMBLOB':
case MYSQLI_TYPE_BLOB :
case MYSQLI_TYPE_LONG_BLOB :
case MYSQLI_TYPE_MEDIUM_BLOB :
return !empty($fieldobj->binary) ? 'B' : 'X';
case 'YEAR':
case 'DATE':
case MYSQLI_TYPE_DATE :
case MYSQLI_TYPE_YEAR :
return 'D';
case 'TIME':
case 'DATETIME':
case 'TIMESTAMP':
case MYSQLI_TYPE_DATETIME :
case MYSQLI_TYPE_NEWDATE :
case MYSQLI_TYPE_TIME :
case MYSQLI_TYPE_TIMESTAMP :
return 'T';
case 'INT':
case 'INTEGER':
case 'BIGINT':
case 'TINYINT':
case 'MEDIUMINT':
case 'SMALLINT':
case MYSQLI_TYPE_INT24 :
case MYSQLI_TYPE_LONG :
case MYSQLI_TYPE_LONGLONG :
case MYSQLI_TYPE_SHORT :
case MYSQLI_TYPE_TINY :
if (!empty($fieldobj->primary_key)) return 'R';
return 'I';
// Added floating-point types
// Maybe not necessery.
case 'FLOAT':
case 'DOUBLE':
// case 'DOUBLE PRECISION':
case 'DECIMAL':
case 'DEC':
case 'FIXED':
default:
//if (!is_numeric($t)) echo "<p>--- Error in type matching $t -----</p>";
return 'N';
}
} // function
} // rs class
}
?>

View file

@ -0,0 +1,138 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
MySQL code that supports transactions. For MySQL 3.23 or later.
Code from James Poon <jpoon88@yahoo.com>
Requires mysql client. Works on Windows and Unix.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php");
class ADODB_mysqlt extends ADODB_mysql {
var $databaseType = 'mysqlt';
var $ansiOuter = true; // for Version 3.23.17 or later
var $hasTransactions = true;
var $autoRollback = true; // apparently mysql does not autorollback properly
function ADODB_mysqlt()
{
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
}
function BeginTrans()
{
if ($this->transOff) return true;
$this->transCnt += 1;
$this->Execute('SET AUTOCOMMIT=0');
$this->Execute('BEGIN');
return true;
}
function CommitTrans($ok=true)
{
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
$this->Execute('COMMIT');
$this->Execute('SET AUTOCOMMIT=1');
return true;
}
function RollbackTrans()
{
if ($this->transOff) return true;
if ($this->transCnt) $this->transCnt -= 1;
$this->Execute('ROLLBACK');
$this->Execute('SET AUTOCOMMIT=1');
return true;
}
function RowLock($tables,$where='',$flds='1 as adodb_ignore')
{
if ($this->transCnt==0) $this->BeginTrans();
if ($where) $where = ' where '.$where;
$rs =& $this->Execute("select $flds from $tables $where for update");
return !empty($rs);
}
}
class ADORecordSet_mysqlt extends ADORecordSet_mysql{
var $databaseType = "mysqlt";
function ADORecordSet_mysqlt($queryID,$mode=false)
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
default: $this->fetchMode = MYSQL_BOTH; break;
}
$this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
function MoveNext()
{
if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
$this->_currentRow += 1;
return true;
}
if (!$this->EOF) {
$this->_currentRow += 1;
$this->EOF = true;
}
return false;
}
}
class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
function ADORecordSet_ext_mysqlt($queryID,$mode=false)
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
default:
$this->fetchMode = MYSQL_BOTH; break;
}
$this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
function MoveNext()
{
return adodb_movenext($this);
}
}
?>

View file

@ -0,0 +1,732 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
*/
// Code contributed by "stefan bogdan" <sbogdan#rsb.ro>
// security - hide paths
if (!defined('ADODB_DIR')) die();
define("_ADODB_ODBTP_LAYER", 2 );
class ADODB_odbtp extends ADOConnection{
var $databaseType = "odbtp";
var $dataProvider = "odbtp";
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
var $replaceQuote = "''"; // string to use to replace quotes
var $odbc_driver = 0;
var $hasAffectedRows = true;
var $hasInsertID = false;
var $hasGenID = true;
var $hasMoveFirst = true;
var $_genSeqSQL = "create table %s (seq_name char(30) not null unique , seq_value integer not null)";
var $_dropSeqSQL = "delete from adodb_seq where seq_name = '%s'";
var $_bindInputArray = false;
var $_useUnicodeSQL = false;
var $_canPrepareSP = false;
var $_dontPoolDBC = true;
function ADODB_odbtp()
{
}
function ServerInfo()
{
return array('description' => @odbtp_get_attr( ODB_ATTR_DBMSNAME, $this->_connectionID),
'version' => @odbtp_get_attr( ODB_ATTR_DBMSVER, $this->_connectionID));
}
function ErrorMsg()
{
if (empty($this->_connectionID)) return @odbtp_last_error();
return @odbtp_last_error($this->_connectionID);
}
function ErrorNo()
{
if (empty($this->_connectionID)) return @odbtp_last_error_state();
return @odbtp_last_error_state($this->_connectionID);
}
function _insertid()
{
// SCOPE_IDENTITY()
// Returns the last IDENTITY value inserted into an IDENTITY column in
// the same scope. A scope is a module -- a stored procedure, trigger,
// function, or batch. Thus, two statements are in the same scope if
// they are in the same stored procedure, function, or batch.
return $this->GetOne($this->identitySQL);
}
function _affectedrows()
{
if ($this->_queryID) {
return @odbtp_affected_rows ($this->_queryID);
} else
return 0;
}
function CreateSequence($seqname='adodbseq',$start=1)
{
//verify existence
$num = $this->GetOne("select seq_value from adodb_seq");
$seqtab='adodb_seq';
if( $this->odbc_driver == ODB_DRIVER_FOXPRO ) {
$path = @odbtp_get_attr( ODB_ATTR_DATABASENAME, $this->_connectionID );
//if using vfp dbc file
if( !strcasecmp(strrchr($path, '.'), '.dbc') )
$path = substr($path,0,strrpos($path,'\/'));
$seqtab = $path . '/' . $seqtab;
}
if($num == false) {
if (empty($this->_genSeqSQL)) return false;
$ok = $this->Execute(sprintf($this->_genSeqSQL ,$seqtab));
}
$num = $this->GetOne("select seq_value from adodb_seq where seq_name='$seqname'");
if ($num) {
return false;
}
$start -= 1;
return $this->Execute("insert into adodb_seq values('$seqname',$start)");
}
function DropSequence($seqname)
{
if (empty($this->_dropSeqSQL)) return false;
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
}
function GenID($seq='adodbseq',$start=1)
{
$seqtab='adodb_seq';
if( $this->odbc_driver == ODB_DRIVER_FOXPRO) {
$path = @odbtp_get_attr( ODB_ATTR_DATABASENAME, $this->_connectionID );
//if using vfp dbc file
if( !strcasecmp(strrchr($path, '.'), '.dbc') )
$path = substr($path,0,strrpos($path,'\/'));
$seqtab = $path . '/' . $seqtab;
}
$MAXLOOPS = 100;
while (--$MAXLOOPS>=0) {
$num = $this->GetOne("select seq_value from adodb_seq where seq_name='$seq'");
if ($num === false) {
//verify if abodb_seq table exist
$ok = $this->GetOne("select seq_value from adodb_seq ");
if(!$ok) {
//creating the sequence table adodb_seq
$this->Execute(sprintf($this->_genSeqSQL ,$seqtab));
}
$start -= 1;
$num = '0';
$ok = $this->Execute("insert into adodb_seq values('$seq',$start)");
if (!$ok) return false;
}
$ok = $this->Execute("update adodb_seq set seq_value=seq_value+1 where seq_name='$seq'");
if($ok) {
$num += 1;
$this->genID = $num;
return $num;
}
}
if ($fn = $this->raiseErrorFn) {
$fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num);
}
return false;
}
//example for $UserOrDSN
//for visual fox : DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBF;SOURCEDB=c:\YourDbfFileDir;EXCLUSIVE=NO;
//for visual fox dbc: DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBC;SOURCEDB=c:\YourDbcFileDir\mydb.dbc;EXCLUSIVE=NO;
//for access : DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\path_to_access_db\base_test.mdb;UID=root;PWD=;
//for mssql : DRIVER={SQL Server};SERVER=myserver;UID=myuid;PWD=mypwd;DATABASE=OdbtpTest;
//if uid & pwd can be separate
function _connect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='')
{
$this->_connectionID = @odbtp_connect($HostOrInterface,$UserOrDSN,$argPassword,$argDatabase);
if ($this->_connectionID === false) {
$this->_errorMsg = $this->ErrorMsg() ;
return false;
}
if ($this->_dontPoolDBC) {
if (function_exists('odbtp_dont_pool_dbc'))
@odbtp_dont_pool_dbc($this->_connectionID);
}
else {
$this->_dontPoolDBC = true;
}
$this->odbc_driver = @odbtp_get_attr(ODB_ATTR_DRIVER, $this->_connectionID);
$dbms = strtolower(@odbtp_get_attr(ODB_ATTR_DBMSNAME, $this->_connectionID));
$this->odbc_name = $dbms;
// Account for inconsistent DBMS names
if( $this->odbc_driver == ODB_DRIVER_ORACLE )
$dbms = 'oracle';
else if( $this->odbc_driver == ODB_DRIVER_SYBASE )
$dbms = 'sybase';
// Set DBMS specific attributes
switch( $dbms ) {
case 'microsoft sql server':
$this->databaseType = 'odbtp_mssql';
$this->fmtDate = "'Y-m-d'";
$this->fmtTimeStamp = "'Y-m-d h:i:sA'";
$this->sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
$this->sysTimeStamp = 'GetDate()';
$this->ansiOuter = true;
$this->leftOuter = '*=';
$this->rightOuter = '=*';
$this->hasTop = 'top';
$this->hasInsertID = true;
$this->hasTransactions = true;
$this->_bindInputArray = true;
$this->_canSelectDb = true;
$this->substr = "substring";
$this->length = 'len';
$this->identitySQL = 'select @@IDENTITY';
$this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'";
$this->_canPrepareSP = true;
break;
case 'access':
$this->databaseType = 'odbtp_access';
$this->fmtDate = "#Y-m-d#";
$this->fmtTimeStamp = "#Y-m-d h:i:sA#";
$this->sysDate = "FORMAT(NOW,'yyyy-mm-dd')";
$this->sysTimeStamp = 'NOW';
$this->hasTop = 'top';
$this->hasTransactions = false;
$this->_canPrepareSP = true; // For MS Access only.
break;
case 'visual foxpro':
$this->databaseType = 'odbtp_vfp';
$this->fmtDate = "{^Y-m-d}";
$this->fmtTimeStamp = "{^Y-m-d, h:i:sA}";
$this->sysDate = 'date()';
$this->sysTimeStamp = 'datetime()';
$this->ansiOuter = true;
$this->hasTop = 'top';
$this->hasTransactions = false;
$this->replaceQuote = "'+chr(39)+'";
$this->true = '.T.';
$this->false = '.F.';
break;
case 'oracle':
$this->databaseType = 'odbtp_oci8';
$this->fmtDate = "'Y-m-d 00:00:00'";
$this->fmtTimeStamp = "'Y-m-d h:i:sA'";
$this->sysDate = 'TRUNC(SYSDATE)';
$this->sysTimeStamp = 'SYSDATE';
$this->hasTransactions = true;
$this->_bindInputArray = true;
$this->concat_operator = '||';
break;
case 'sybase':
$this->databaseType = 'odbtp_sybase';
$this->fmtDate = "'Y-m-d'";
$this->fmtTimeStamp = "'Y-m-d H:i:s'";
$this->sysDate = 'GetDate()';
$this->sysTimeStamp = 'GetDate()';
$this->leftOuter = '*=';
$this->rightOuter = '=*';
$this->hasInsertID = true;
$this->hasTransactions = true;
$this->identitySQL = 'select @@IDENTITY';
break;
default:
$this->databaseType = 'odbtp';
if( @odbtp_get_attr(ODB_ATTR_TXNCAPABLE, $this->_connectionID) )
$this->hasTransactions = true;
else
$this->hasTransactions = false;
}
@odbtp_set_attr(ODB_ATTR_FULLCOLINFO, TRUE, $this->_connectionID );
if ($this->_useUnicodeSQL )
@odbtp_set_attr(ODB_ATTR_UNICODESQL, TRUE, $this->_connectionID);
return true;
}
function _pconnect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='')
{
$this->_dontPoolDBC = false;
return $this->_connect($HostOrInterface, $UserOrDSN, $argPassword, $argDatabase);
}
function SelectDB($dbName)
{
if (!@odbtp_select_db($dbName, $this->_connectionID)) {
return false;
}
$this->database = $dbName;
$this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
return true;
}
function MetaTables($ttype='',$showSchema=false,$mask=false)
{
global $ADODB_FETCH_MODE;
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savefm = $this->SetFetchMode(false);
$arr =& $this->GetArray("||SQLTables||||$ttype");
if (isset($savefm)) $this->SetFetchMode($savefm);
$ADODB_FETCH_MODE = $savem;
$arr2 = array();
for ($i=0; $i < sizeof($arr); $i++) {
if ($arr[$i][3] == 'SYSTEM TABLE' ) continue;
if ($arr[$i][2])
$arr2[] = $showSchema ? $arr[$i][1].'.'.$arr[$i][2] : $arr[$i][2];
}
return $arr2;
}
function MetaColumns($table,$upper=true)
{
global $ADODB_FETCH_MODE;
$schema = false;
$this->_findschema($table,$schema);
if ($upper) $table = strtoupper($table);
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savefm = $this->SetFetchMode(false);
$rs = $this->Execute( "||SQLColumns||$schema|$table" );
if (isset($savefm)) $this->SetFetchMode($savefm);
$ADODB_FETCH_MODE = $savem;
if (!$rs || $rs->EOF) {
$false = false;
return $false;
}
$retarr = array();
while (!$rs->EOF) {
//print_r($rs->fields);
if (strtoupper($rs->fields[2]) == $table) {
$fld = new ADOFieldObject();
$fld->name = $rs->fields[3];
$fld->type = $rs->fields[5];
$fld->max_length = $rs->fields[6];
$fld->not_null = !empty($rs->fields[9]);
$fld->scale = $rs->fields[7];
if (!is_null($rs->fields[12])) {
$fld->has_default = true;
$fld->default_value = $rs->fields[12];
}
$retarr[strtoupper($fld->name)] = $fld;
} else if (!empty($retarr))
break;
$rs->MoveNext();
}
$rs->Close();
return $retarr;
}
function MetaPrimaryKeys($table, $owner='')
{
global $ADODB_FETCH_MODE;
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$arr =& $this->GetArray("||SQLPrimaryKeys||$owner|$table");
$ADODB_FETCH_MODE = $savem;
//print_r($arr);
$arr2 = array();
for ($i=0; $i < sizeof($arr); $i++) {
if ($arr[$i][3]) $arr2[] = $arr[$i][3];
}
return $arr2;
}
function MetaForeignKeys($table, $owner='', $upper=false)
{
global $ADODB_FETCH_MODE;
$savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$constraints =& $this->GetArray("||SQLForeignKeys|||||$owner|$table");
$ADODB_FETCH_MODE = $savem;
$arr = false;
foreach($constraints as $constr) {
//print_r($constr);
$arr[$constr[11]][$constr[2]][] = $constr[7].'='.$constr[3];
}
if (!$arr) {
$false = false;
return $false;
}
$arr2 = array();
foreach($arr as $k => $v) {
foreach($v as $a => $b) {
if ($upper) $a = strtoupper($a);
$arr2[$a] = $b;
}
}
return $arr2;
}
function BeginTrans()
{
if (!$this->hasTransactions) return false;
if ($this->transOff) return true;
$this->transCnt += 1;
$this->autoCommit = false;
if (defined('ODB_TXN_DEFAULT'))
$txn = ODB_TXN_DEFAULT;
else
$txn = ODB_TXN_READUNCOMMITTED;
$rs = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS,$txn,$this->_connectionID);
if(!$rs) return false;
return true;
}
function CommitTrans($ok=true)
{
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
$this->autoCommit = true;
if( ($ret = @odbtp_commit($this->_connectionID)) )
$ret = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS, ODB_TXN_NONE, $this->_connectionID);//set transaction off
return $ret;
}
function RollbackTrans()
{
if ($this->transOff) return true;
if ($this->transCnt) $this->transCnt -= 1;
$this->autoCommit = true;
if( ($ret = @odbtp_rollback($this->_connectionID)) )
$ret = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS, ODB_TXN_NONE, $this->_connectionID);//set transaction off
return $ret;
}
function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
{
// TOP requires ORDER BY for Visual FoxPro
if( $this->odbc_driver == ODB_DRIVER_FOXPRO ) {
if (!preg_match('/ORDER[ \t\r\n]+BY/is',$sql)) $sql .= ' ORDER BY 1';
}
$ret =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
return $ret;
}
function Prepare($sql)
{
if (! $this->_bindInputArray) return $sql; // no binding
$stmt = @odbtp_prepare($sql,$this->_connectionID);
if (!$stmt) {
// print "Prepare Error for ($sql) ".$this->ErrorMsg()."<br>";
return $sql;
}
return array($sql,$stmt,false);
}
function PrepareSP($sql)
{
if (!$this->_canPrepareSP) return $sql; // Can't prepare procedures
$stmt = @odbtp_prepare_proc($sql,$this->_connectionID);
if (!$stmt) return false;
return array($sql,$stmt);
}
/*
Usage:
$stmt = $db->PrepareSP('SP_RUNSOMETHING'); -- takes 2 params, @myid and @group
# note that the parameter does not have @ in front!
$db->Parameter($stmt,$id,'myid');
$db->Parameter($stmt,$group,'group',false,64);
$db->Parameter($stmt,$group,'photo',false,100000,ODB_BINARY);
$db->Execute($stmt);
@param $stmt Statement returned by Prepare() or PrepareSP().
@param $var PHP variable to bind to. Can set to null (for isNull support).
@param $name Name of stored procedure variable name to bind to.
@param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in odbtp.
@param [$maxLen] Holds an maximum length of the variable.
@param [$type] The data type of $var. Legal values depend on driver.
See odbtp_attach_param documentation at http://odbtp.sourceforge.net.
*/
function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=0, $type=0)
{
if ( $this->odbc_driver == ODB_DRIVER_JET ) {
$name = '['.$name.']';
if( !$type && $this->_useUnicodeSQL
&& @odbtp_param_bindtype($stmt[1], $name) == ODB_CHAR )
{
$type = ODB_WCHAR;
}
}
else {
$name = '@'.$name;
}
return @odbtp_attach_param($stmt[1], $name, $var, $type, $maxLen);
}
/*
Insert a null into the blob field of the table first.
Then use UpdateBlob to store the blob.
Usage:
$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
$conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
*/
function UpdateBlob($table,$column,$val,$where,$blobtype='image')
{
$sql = "UPDATE $table SET $column = ? WHERE $where";
if( !($stmt = @odbtp_prepare($sql, $this->_connectionID)) )
return false;
if( !@odbtp_input( $stmt, 1, ODB_BINARY, 1000000, $blobtype ) )
return false;
if( !@odbtp_set( $stmt, 1, $val ) )
return false;
return @odbtp_execute( $stmt ) != false;
}
function IfNull( $field, $ifNull )
{
switch( $this->odbc_driver ) {
case ODB_DRIVER_MSSQL:
return " ISNULL($field, $ifNull) ";
case ODB_DRIVER_JET:
return " IIF(IsNull($field), $ifNull, $field) ";
}
return " CASE WHEN $field is null THEN $ifNull ELSE $field END ";
}
function _query($sql,$inputarr=false)
{
global $php_errormsg;
if ($inputarr) {
if (is_array($sql)) {
$stmtid = $sql[1];
} else {
$stmtid = @odbtp_prepare($sql,$this->_connectionID);
if ($stmtid == false) {
$this->_errorMsg = $php_errormsg;
return false;
}
}
$num_params = @odbtp_num_params( $stmtid );
for( $param = 1; $param <= $num_params; $param++ ) {
@odbtp_input( $stmtid, $param );
@odbtp_set( $stmtid, $param, $inputarr[$param-1] );
}
if (!@odbtp_execute($stmtid) ) {
return false;
}
} else if (is_array($sql)) {
$stmtid = $sql[1];
if (!@odbtp_execute($stmtid)) {
return false;
}
} else {
$stmtid = @odbtp_query($sql,$this->_connectionID);
}
$this->_lastAffectedRows = 0;
if ($stmtid) {
$this->_lastAffectedRows = @odbtp_affected_rows($stmtid);
}
return $stmtid;
}
function _close()
{
$ret = @odbtp_close($this->_connectionID);
$this->_connectionID = false;
return $ret;
}
}
class ADORecordSet_odbtp extends ADORecordSet {
var $databaseType = 'odbtp';
var $canSeek = true;
function ADORecordSet_odbtp($queryID,$mode=false)
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
$this->fetchMode = $mode;
$this->ADORecordSet($queryID);
}
function _initrs()
{
$this->_numOfFields = @odbtp_num_fields($this->_queryID);
if (!($this->_numOfRows = @odbtp_num_rows($this->_queryID)))
$this->_numOfRows = -1;
if (!$this->connection->_useUnicodeSQL) return;
if ($this->connection->odbc_driver == ODB_DRIVER_JET) {
if (!@odbtp_get_attr(ODB_ATTR_MAPCHARTOWCHAR,
$this->connection->_connectionID))
{
for ($f = 0; $f < $this->_numOfFields; $f++) {
if (@odbtp_field_bindtype($this->_queryID, $f) == ODB_CHAR)
@odbtp_bind_field($this->_queryID, $f, ODB_WCHAR);
}
}
}
}
function FetchField($fieldOffset = 0)
{
$off=$fieldOffset; // offsets begin at 0
$o= new ADOFieldObject();
$o->name = @odbtp_field_name($this->_queryID,$off);
$o->type = @odbtp_field_type($this->_queryID,$off);
$o->max_length = @odbtp_field_length($this->_queryID,$off);
if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
return $o;
}
function _seek($row)
{
return @odbtp_data_seek($this->_queryID, $row);
}
function fields($colname)
{
if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
if (!$this->bind) {
$this->bind = array();
for ($i=0; $i < $this->_numOfFields; $i++) {
$name = @odbtp_field_name( $this->_queryID, $i );
$this->bind[strtoupper($name)] = $i;
}
}
return $this->fields[$this->bind[strtoupper($colname)]];
}
function _fetch_odbtp($type=0)
{
switch ($this->fetchMode) {
case ADODB_FETCH_NUM:
$this->fields = @odbtp_fetch_row($this->_queryID, $type);
break;
case ADODB_FETCH_ASSOC:
$this->fields = @odbtp_fetch_assoc($this->_queryID, $type);
break;
default:
$this->fields = @odbtp_fetch_array($this->_queryID, $type);
}
return is_array($this->fields);
}
function _fetch()
{
return $this->_fetch_odbtp();
}
function MoveFirst()
{
if (!$this->_fetch_odbtp(ODB_FETCH_FIRST)) return false;
$this->EOF = false;
$this->_currentRow = 0;
return true;
}
function MoveLast()
{
if (!$this->_fetch_odbtp(ODB_FETCH_LAST)) return false;
$this->EOF = false;
$this->_currentRow = $this->_numOfRows - 1;
return true;
}
function NextRecordSet()
{
if (!@odbtp_next_result($this->_queryID)) return false;
$this->_inited = false;
$this->bind = false;
$this->_currentRow = -1;
$this->Init();
return true;
}
function _close()
{
return @odbtp_free_query($this->_queryID);
}
}
class ADORecordSet_odbtp_mssql extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_mssql';
function ADORecordSet_odbtp_mssql($id,$mode=false)
{
return $this->ADORecordSet_odbtp($id,$mode);
}
}
class ADORecordSet_odbtp_access extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_access';
function ADORecordSet_odbtp_access($id,$mode=false)
{
return $this->ADORecordSet_odbtp($id,$mode);
}
}
class ADORecordSet_odbtp_vfp extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_vfp';
function ADORecordSet_odbtp_vfp($id,$mode=false)
{
return $this->ADORecordSet_odbtp($id,$mode);
}
}
class ADORecordSet_odbtp_oci8 extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_oci8';
function ADORecordSet_odbtp_oci8($id,$mode=false)
{
return $this->ADORecordSet_odbtp($id,$mode);
}
}
class ADORecordSet_odbtp_sybase extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_sybase';
function ADORecordSet_odbtp_sybase($id,$mode=false)
{
return $this->ADORecordSet_odbtp($id,$mode);
}
}
?>

View file

@ -0,0 +1,39 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
*/
// Code contributed by "Robert Twitty" <rtwitty#neutron.ushmm.org>
// security - hide paths
if (!defined('ADODB_DIR')) die();
/*
Because the ODBTP server sends and reads UNICODE text data using UTF-8
encoding, the following HTML meta tag must be included within the HTML
head section of every HTML form and script page:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Also, all SQL query strings must be submitted as UTF-8 encoded text.
*/
if (!defined('_ADODB_ODBTP_LAYER')) {
include(ADODB_DIR."/drivers/adodb-odbtp.inc.php");
}
class ADODB_odbtp_unicode extends ADODB_odbtp {
var $databaseType = 'odbtp';
var $_useUnicodeSQL = true;
function ADODB_odbtp_unicode()
{
$this->ADODB_odbtp();
}
}
?>

View file

@ -0,0 +1,146 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
*/
class ADODB_pdo_mysql extends ADODB_pdo {
var $metaTablesSQL = "SHOW TABLES";
var $metaColumnsSQL = "SHOW COLUMNS FROM %s";
var $_bindInputArray = false;
var $sysDate = 'CURDATE()';
var $sysTimeStamp = 'NOW()';
function _init($parentDriver)
{
$parentDriver->hasTransactions = false;
$parentDriver->_bindInputArray = true;
$parentDriver->hasInsertID = true;
$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
}
function ServerInfo()
{
$arr['description'] = ADOConnection::GetOne("select version()");
$arr['version'] = ADOConnection::_findvers($arr['description']);
return $arr;
}
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
$save = $this->metaTablesSQL;
if ($showSchema && is_string($showSchema)) {
$this->metaTablesSQL .= " from $showSchema";
}
if ($mask) {
$mask = $this->qstr($mask);
$this->metaTablesSQL .= " like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
$this->metaTablesSQL = $save;
return $ret;
}
function MetaColumns($table)
{
$this->_findschema($table,$schema);
if ($schema) {
$dbName = $this->database;
$this->SelectDB($schema);
}
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
if ($schema) {
$this->SelectDB($dbName);
}
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!is_object($rs)) {
$false = false;
return $false;
}
$retarr = array();
while (!$rs->EOF){
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$type = $rs->fields[1];
// split type into type(length):
$fld->scale = null;
if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
$fld->type = $query_array[1];
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
$fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
} elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
$fld->type = $query_array[1];
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
} elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
$fld->type = $query_array[1];
$arr = explode(",",$query_array[2]);
$fld->enums = $arr;
$zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6
$fld->max_length = ($zlen > 0) ? $zlen : 1;
} else {
$fld->type = $type;
$fld->max_length = -1;
}
$fld->not_null = ($rs->fields[2] != 'YES');
$fld->primary_key = ($rs->fields[3] == 'PRI');
$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
$fld->binary = (strpos($type,'blob') !== false);
$fld->unsigned = (strpos($type,'unsigned') !== false);
if (!$fld->binary) {
$d = $rs->fields[4];
if ($d != '' && $d != 'NULL') {
$fld->has_default = true;
$fld->default_value = $d;
} else {
$fld->has_default = false;
}
}
if ($save == ADODB_FETCH_NUM) {
$retarr[] = $fld;
} else {
$retarr[strtoupper($fld->name)] = $fld;
}
$rs->MoveNext();
}
$rs->Close();
return $retarr;
}
// parameters use PostgreSQL convention, not MySQL
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
{
$offsetStr =($offset>=0) ? "$offset," : '';
// jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
if ($nrows < 0) $nrows = '18446744073709551615';
if ($secs)
$rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr);
else
$rs =& $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr);
return $rs;
}
}
?>

View file

@ -0,0 +1,93 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
*/
class ADODB_pdo_oci extends ADODB_pdo_base {
var $concat_operator='||';
var $sysDate = "TRUNC(SYSDATE)";
var $sysTimeStamp = 'SYSDATE';
var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS'
var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)";
var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW')";
var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno";
var $_initdate = true;
var $_hasdual = true;
function _init($parentDriver)
{
$parentDriver->_bindInputArray = true;
if ($this->_initdate) {
$parentDriver->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'");
}
}
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
if ($mask) {
$save = $this->metaTablesSQL;
$mask = $this->qstr(strtoupper($mask));
$this->metaTablesSQL .= " AND table_name like $mask";
}
$ret =& ADOConnection::MetaTables($ttype,$showSchema);
if ($mask) {
$this->metaTablesSQL = $save;
}
return $ret;
}
function MetaColumns($table)
{
global $ADODB_FETCH_MODE;
$false = false;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
$rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!$rs) {
return $false;
}
$retarr = array();
while (!$rs->EOF) { //print_r($rs->fields);
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
$fld->max_length = $rs->fields[2];
$fld->scale = $rs->fields[3];
if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) {
$fld->type ='INT';
$fld->max_length = $rs->fields[4];
}
$fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0);
$fld->binary = (strpos($fld->type,'BLOB') !== false);
$fld->default_value = $rs->fields[6];
if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
else $retarr[strtoupper($fld->name)] = $fld;
$rs->MoveNext();
}
$rs->Close();
if (empty($retarr))
return $false;
else
return $retarr;
}
}
?>

View file

@ -0,0 +1,33 @@
<?php
$ADODB_LANG_ARRAY = array (
'LANG' => 'fr',
DB_ERROR => 'erreur inconnue',
DB_ERROR_ALREADY_EXISTS => 'existe d&eacute;j&agrave;',
DB_ERROR_CANNOT_CREATE => 'cr&eacute;tion impossible',
DB_ERROR_CANNOT_DELETE => 'effacement impossible',
DB_ERROR_CANNOT_DROP => 'suppression impossible',
DB_ERROR_CONSTRAINT => 'violation de contrainte',
DB_ERROR_DIVZERO => 'division par z&eacute;ro',
DB_ERROR_INVALID => 'invalide',
DB_ERROR_INVALID_DATE => 'date ou heure invalide',
DB_ERROR_INVALID_NUMBER => 'nombre invalide',
DB_ERROR_MISMATCH => 'erreur de concordance',
DB_ERROR_NODBSELECTED => 'pas de base de donn&eacute;ess&eacute;lectionn&eacute;e',
DB_ERROR_NOSUCHFIELD => 'nom de colonne invalide',
DB_ERROR_NOSUCHTABLE => 'table ou vue inexistante',
DB_ERROR_NOT_CAPABLE => 'fonction optionnelle non install&eacute;e',
DB_ERROR_NOT_FOUND => 'pas trouv&eacute;',
DB_ERROR_NOT_LOCKED => 'non verrouill&eacute;',
DB_ERROR_SYNTAX => 'erreur de syntaxe',
DB_ERROR_UNSUPPORTED => 'non support&eacute;',
DB_ERROR_VALUE_COUNT_ON_ROW => 'valeur ins&eacute;r&eacute;e trop grande pour colonne',
DB_ERROR_INVALID_DSN => 'DSN invalide',
DB_ERROR_CONNECT_FAILED => '&eacute;chec &agrave; la connexion',
0 => "pas d'erreur", // DB_OK
DB_ERROR_NEED_MORE_DATA => 'donn&eacute;es fournies insuffisantes',
DB_ERROR_EXTENSION_NOT_FOUND=> 'extension non trouv&eacute;e',
DB_ERROR_NOSUCHDB => 'base de donn&eacute;es inconnue',
DB_ERROR_ACCESS_VIOLATION => 'droits insuffisants'
);
?>

View file

@ -0,0 +1,182 @@
ADOdb is dual licensed using BSD and LGPL.
In plain English, you do not need to distribute your application in source code form, nor do you need to distribute ADOdb source code, provided you follow the rest of terms of the BSD license.
For more info about ADOdb, visit http://adodb.sourceforge.net/
BSD Style-License
=================
Copyright (c) 2000, 2001, 2002, 2003, 2004 John Lim
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
Neither the name of the John Lim nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior written
permission.
DISCLAIMER:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
JOHN LIM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
==========================================================
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

View file

@ -0,0 +1,413 @@
<?php
//
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Martin Jansen <mj@php.net>
// | Richard Tango-Lowy <richtl@arscognita.com> |
// +----------------------------------------------------------------------+
//
// $Id: ADOdb.php,v 1.3 2005/05/18 06:58:47 jlim Exp $
//
require_once 'Auth/Container.php';
require_once 'adodb.inc.php';
require_once 'adodb-pear.inc.php';
require_once 'adodb-errorpear.inc.php';
/**
* Storage driver for fetching login data from a database using ADOdb-PHP.
*
* This storage driver can use all databases which are supported
* by the ADBdb DB abstraction layer to fetch login data.
* See http://php.weblogs.com/adodb for information on ADOdb.
* NOTE: The ADOdb directory MUST be in your PHP include_path!
*
* @author Richard Tango-Lowy <richtl@arscognita.com>
* @package Auth
* @version $Revision: 1.3 $
*/
class Auth_Container_ADOdb extends Auth_Container
{
/**
* Additional options for the storage container
* @var array
*/
var $options = array();
/**
* DB object
* @var object
*/
var $db = null;
var $dsn = '';
/**
* User that is currently selected from the DB.
* @var string
*/
var $activeUser = '';
// {{{ Constructor
/**
* Constructor of the container class
*
* Initate connection to the database via PEAR::ADOdb
*
* @param string Connection data or DB object
* @return object Returns an error object if something went wrong
*/
function Auth_Container_ADOdb($dsn)
{
$this->_setDefaults();
if (is_array($dsn)) {
$this->_parseOptions($dsn);
if (empty($this->options['dsn'])) {
PEAR::raiseError('No connection parameters specified!');
}
} else {
// Extract db_type from dsn string.
$this->options['dsn'] = $dsn;
}
}
// }}}
// {{{ _connect()
/**
* Connect to database by using the given DSN string
*
* @access private
* @param string DSN string
* @return mixed Object on error, otherwise bool
*/
function _connect($dsn)
{
if (is_string($dsn) || is_array($dsn)) {
if(!$this->db) {
$this->db = &ADONewConnection($dsn);
if( $err = ADODB_Pear_error() ) {
return PEAR::raiseError($err);
}
}
} else {
return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__,
41,
PEAR_ERROR_RETURN,
null,
null
);
}
if(!$this->db) {
return PEAR::raiseError(ADODB_Pear_error());
} else {
return true;
}
}
// }}}
// {{{ _prepare()
/**
* Prepare database connection
*
* This function checks if we have already opened a connection to
* the database. If that's not the case, a new connection is opened.
*
* @access private
* @return mixed True or a DB error object.
*/
function _prepare()
{
if(!$this->db) {
$res = $this->_connect($this->options['dsn']);
}
return true;
}
// }}}
// {{{ query()
/**
* Prepare query to the database
*
* This function checks if we have already opened a connection to
* the database. If that's not the case, a new connection is opened.
* After that the query is passed to the database.
*
* @access public
* @param string Query string
* @return mixed a DB_result object or DB_OK on success, a DB
* or PEAR error on failure
*/
function query($query)
{
$err = $this->_prepare();
if ($err !== true) {
return $err;
}
return $this->db->query($query);
}
// }}}
// {{{ _setDefaults()
/**
* Set some default options
*
* @access private
* @return void
*/
function _setDefaults()
{
$this->options['db_type'] = 'mysql';
$this->options['table'] = 'auth';
$this->options['usernamecol'] = 'username';
$this->options['passwordcol'] = 'password';
$this->options['dsn'] = '';
$this->options['db_fields'] = '';
$this->options['cryptType'] = 'md5';
}
// }}}
// {{{ _parseOptions()
/**
* Parse options passed to the container class
*
* @access private
* @param array
*/
function _parseOptions($array)
{
foreach ($array as $key => $value) {
if (isset($this->options[$key])) {
$this->options[$key] = $value;
}
}
/* Include additional fields if they exist */
if(!empty($this->options['db_fields'])){
if(is_array($this->options['db_fields'])){
$this->options['db_fields'] = join($this->options['db_fields'], ', ');
}
$this->options['db_fields'] = ', '.$this->options['db_fields'];
}
}
// }}}
// {{{ fetchData()
/**
* Get user information from database
*
* This function uses the given username to fetch
* the corresponding login data from the database
* table. If an account that matches the passed username
* and password is found, the function returns true.
* Otherwise it returns false.
*
* @param string Username
* @param string Password
* @return mixed Error object or boolean
*/
function fetchData($username, $password)
{
// Prepare for a database query
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
}
// Find if db_fields contains a *, i so assume all col are selected
if(strstr($this->options['db_fields'], '*')){
$sql_from = "*";
}
else{
$sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields'];
}
$query = "SELECT ".$sql_from.
" FROM ".$this->options['table'].
" WHERE ".$this->options['usernamecol']." = " . $this->db->Quote($username);
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$rset = $this->db->Execute( $query );
$res = $rset->fetchRow();
if (DB::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->getCode());
}
if (!is_array($res)) {
$this->activeUser = '';
return false;
}
if ($this->verifyPassword(trim($password, "\r\n"),
trim($res[$this->options['passwordcol']], "\r\n"),
$this->options['cryptType'])) {
// Store additional field values in the session
foreach ($res as $key => $value) {
if ($key == $this->options['passwordcol'] ||
$key == $this->options['usernamecol']) {
continue;
}
// Use reference to the auth object if exists
// This is because the auth session variable can change so a static call to setAuthData does not make sence
if(is_object($this->_auth_obj)){
$this->_auth_obj->setAuthData($key, $value);
} else {
Auth::setAuthData($key, $value);
}
}
return true;
}
$this->activeUser = $res[$this->options['usernamecol']];
return false;
}
// }}}
// {{{ listUsers()
function listUsers()
{
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
}
$retVal = array();
// Find if db_fileds contains a *, i so assume all col are selected
if(strstr($this->options['db_fields'], '*')){
$sql_from = "*";
}
else{
$sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields'];
}
$query = sprintf("SELECT %s FROM %s",
$sql_from,
$this->options['table']
);
$res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC);
if (DB::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->getCode());
} else {
foreach ($res as $user) {
$user['username'] = $user[$this->options['usernamecol']];
$retVal[] = $user;
}
}
return $retVal;
}
// }}}
// {{{ addUser()
/**
* Add user to the storage container
*
* @access public
* @param string Username
* @param string Password
* @param mixed Additional information that are stored in the DB
*
* @return mixed True on success, otherwise error object
*/
function addUser($username, $password, $additional = "")
{
if (function_exists($this->options['cryptType'])) {
$cryptFunction = $this->options['cryptType'];
} else {
$cryptFunction = 'md5';
}
$additional_key = '';
$additional_value = '';
if (is_array($additional)) {
foreach ($additional as $key => $value) {
$additional_key .= ', ' . $key;
$additional_value .= ", '" . $value . "'";
}
}
$query = sprintf("INSERT INTO %s (%s, %s%s) VALUES ('%s', '%s'%s)",
$this->options['table'],
$this->options['usernamecol'],
$this->options['passwordcol'],
$additional_key,
$username,
$cryptFunction($password),
$additional_value
);
$res = $this->query($query);
if (DB::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->getCode());
} else {
return true;
}
}
// }}}
// {{{ removeUser()
/**
* Remove user from the storage container
*
* @access public
* @param string Username
*
* @return mixed True on success, otherwise error object
*/
function removeUser($username)
{
$query = sprintf("DELETE FROM %s WHERE %s = '%s'",
$this->options['table'],
$this->options['usernamecol'],
$username
);
$res = $this->query($query);
if (DB::isError($res)) {
return PEAR::raiseError($res->getMessage(), $res->getCode());
} else {
return true;
}
}
// }}}
}
function showDbg( $string ) {
print "
-- $string</P>";
}
function dump( $var, $str, $vardump = false ) {
print "<H4>$str</H4><pre>";
( !$vardump ) ? ( print_r( $var )) : ( var_dump( $var ));
print "</pre>";
}
?>

View file

@ -0,0 +1,20 @@
From: Rich Tango-Lowy (richtl#arscognita.com)
Date: Sat, May 29, 2004 11:20 am
OK, I hacked out an ADOdb container for PEAR-Auth. The error handling's
a bit of a mess, but all the methods work.
Copy ADOdb.php to your pear/Auth/Container/ directory.
Use the ADOdb container exactly as you would the DB
container, but specify 'ADOdb' instead of 'DB':
$dsn = "mysql://myuser:mypass@localhost/authdb";
$a = new Auth("ADOdb", $dsn, "loginFunction");
-------------------
John Lim adds:
See http://pear.php.net/manual/en/package.authentication.php

View file

@ -0,0 +1,315 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Library for basic performance monitoring and tuning
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class perf_mysql extends adodb_perf{
var $tablesSQL = 'show table status';
var $createTableSQL = "CREATE TABLE adodb_logsql (
created datetime NOT NULL,
sql0 varchar(250) NOT NULL,
sql1 text NOT NULL,
params text NOT NULL,
tracer text NOT NULL,
timer decimal(16,6) NOT NULL
)";
var $settings = array(
'Ratios',
'MyISAM cache hit ratio' => array('RATIO',
'=GetKeyHitRatio',
'=WarnCacheRatio'),
'InnoDB cache hit ratio' => array('RATIO',
'=GetInnoDBHitRatio',
'=WarnCacheRatio'),
'data cache hit ratio' => array('HIDE', # only if called
'=FindDBHitRatio',
'=WarnCacheRatio'),
'sql cache hit ratio' => array('RATIO',
'=GetQHitRatio',
''),
'IO',
'data reads' => array('IO',
'=GetReads',
'Number of selects (Key_reads is not accurate)'),
'data writes' => array('IO',
'=GetWrites',
'Number of inserts/updates/deletes * coef (Key_writes is not accurate)'),
'Data Cache',
'MyISAM data cache size' => array('DATAC',
array("show variables", 'key_buffer_size'),
'' ),
'BDB data cache size' => array('DATAC',
array("show variables", 'bdb_cache_size'),
'' ),
'InnoDB data cache size' => array('DATAC',
array("show variables", 'innodb_buffer_pool_size'),
'' ),
'Memory Usage',
'read buffer size' => array('CACHE',
array("show variables", 'read_buffer_size'),
'(per session)'),
'sort buffer size' => array('CACHE',
array("show variables", 'sort_buffer_size'),
'Size of sort buffer (per session)' ),
'table cache' => array('CACHE',
array("show variables", 'table_cache'),
'Number of tables to keep open'),
'Connections',
'current connections' => array('SESS',
array('show status','Threads_connected'),
''),
'max connections' => array( 'SESS',
array("show variables",'max_connections'),
''),
false
);
function perf_mysql(&$conn)
{
$this->conn =& $conn;
}
function Explain($sql,$partial=false)
{
if (strtoupper(substr(trim($sql),0,6)) !== 'SELECT') return '<p>Unable to EXPLAIN non-select statement</p>';
$save = $this->conn->LogSQL(false);
if ($partial) {
$sqlq = $this->conn->qstr($sql.'%');
$arr = $this->conn->GetArray("select distinct sql1 from adodb_logsql where sql1 like $sqlq");
if ($arr) {
foreach($arr as $row) {
$sql = reset($row);
if (crc32($sql) == $partial) break;
}
}
}
$sql = str_replace('?',"''",$sql);
if ($partial) {
$sqlq = $this->conn->qstr($sql.'%');
$sql = $this->conn->GetOne("select sql1 from adodb_logsql where sql1 like $sqlq");
}
$s = '<p><b>Explain</b>: '.htmlspecialchars($sql).'</p>';
$rs = $this->conn->Execute('EXPLAIN '.$sql);
$s .= rs2html($rs,false,false,false,false);
$this->conn->LogSQL($save);
$s .= $this->Tracer($sql);
return $s;
}
function Tables()
{
if (!$this->tablesSQL) return false;
$rs = $this->conn->Execute($this->tablesSQL);
if (!$rs) return false;
$html = rs2html($rs,false,false,false,false);
return $html;
}
function GetReads()
{
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
$rs = $this->conn->Execute('show status');
if (isset($savem)) $this->conn->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!$rs) return 0;
$val = 0;
while (!$rs->EOF) {
switch($rs->fields[0]) {
case 'Com_select':
$val = $rs->fields[1];
$rs->Close();
return $val;
}
$rs->MoveNext();
}
$rs->Close();
return $val;
}
function GetWrites()
{
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
$rs = $this->conn->Execute('show status');
if (isset($savem)) $this->conn->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!$rs) return 0;
$val = 0.0;
while (!$rs->EOF) {
switch($rs->fields[0]) {
case 'Com_insert':
$val += $rs->fields[1]; break;
case 'Com_delete':
$val += $rs->fields[1]; break;
case 'Com_update':
$val += $rs->fields[1]/2;
$rs->Close();
return $val;
}
$rs->MoveNext();
}
$rs->Close();
return $val;
}
function FindDBHitRatio()
{
// first find out type of table
//$this->conn->debug=1;
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
$rs = $this->conn->Execute('show table status');
if (isset($savem)) $this->conn->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!$rs) return '';
$type = strtoupper($rs->fields[1]);
$rs->Close();
switch($type){
case 'MYISAM':
case 'ISAM':
return $this->DBParameter('MyISAM cache hit ratio').' (MyISAM)';
case 'INNODB':
return $this->DBParameter('InnoDB cache hit ratio').' (InnoDB)';
default:
return $type.' not supported';
}
}
function GetQHitRatio()
{
//Total number of queries = Qcache_inserts + Qcache_hits + Qcache_not_cached
$hits = $this->_DBParameter(array("show status","Qcache_hits"));
$total = $this->_DBParameter(array("show status","Qcache_inserts"));
$total += $this->_DBParameter(array("show status","Qcache_not_cached"));
$total += $hits;
if ($total) return round(($hits*100)/$total,2);
return 0;
}
/*
Use session variable to store Hit percentage, because MySQL
does not remember last value of SHOW INNODB STATUS hit ratio
# 1st query to SHOW INNODB STATUS
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000
# 2nd query to SHOW INNODB STATUS
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool activity since the last printout
*/
function GetInnoDBHitRatio()
{
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
$rs = $this->conn->Execute('show innodb status');
if (isset($savem)) $this->conn->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!$rs || $rs->EOF) return 0;
$stat = $rs->fields[0];
$rs->Close();
$at = strpos($stat,'Buffer pool hit rate');
$stat = substr($stat,$at,200);
if (preg_match('!Buffer pool hit rate\s*([0-9]*) / ([0-9]*)!',$stat,$arr)) {
$val = 100*$arr[1]/$arr[2];
$_SESSION['INNODB_HIT_PCT'] = $val;
return round($val,2);
} else {
if (isset($_SESSION['INNODB_HIT_PCT'])) return $_SESSION['INNODB_HIT_PCT'];
return 0;
}
return 0;
}
function GetKeyHitRatio()
{
$hits = $this->_DBParameter(array("show status","Key_read_requests"));
$reqs = $this->_DBParameter(array("show status","Key_reads"));
if ($reqs == 0) return 0;
return round(($hits/($reqs+$hits))*100,2);
}
// start hack
var $optimizeTableLow = 'CHECK TABLE %s FAST QUICK';
var $optimizeTableHigh = 'OPTIMIZE TABLE %s';
/**
* @see adodb_perf#optimizeTable
*/
function optimizeTable( $table, $mode = ADODB_OPT_LOW)
{
if ( !is_string( $table)) return false;
$conn = $this->conn;
if ( !$conn) return false;
$sql = '';
switch( $mode) {
case ADODB_OPT_LOW : $sql = $this->optimizeTableLow; break;
case ADODB_OPT_HIGH : $sql = $this->optimizeTableHigh; break;
default :
{
// May dont use __FUNCTION__ constant for BC (__FUNCTION__ Added in PHP 4.3.0)
ADOConnection::outp( sprintf( "<p>%s: '%s' using of undefined mode '%s'</p>", __CLASS__, __FUNCTION__, $mode));
return false;
}
}
$sql = sprintf( $sql, $table);
return $conn->Execute( $sql) !== false;
}
// end hack
}
?>

View file

@ -0,0 +1,185 @@
<?php
/**
* @version V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com
*
* Requires PHP4.01pl2 or later because it uses include_once
*/
/*
* Concept from daniel.lucazeau@ajornet.com.
*
* @param db Adodb database connection
* @param tables List of tables to join
* @rowfields List of fields to display on each row
* @colfield Pivot field to slice and display in columns, if we want to calculate
* ranges, we pass in an array (see example2)
* @where Where clause. Optional.
* @aggfield This is the field to sum. Optional.
* Since 2.3.1, if you can use your own aggregate function
* instead of SUM, eg. $sumfield = 'AVG(fieldname)';
* @sumlabel Prefix to display in sum columns. Optional.
* @aggfn Aggregate function to use (could be AVG, SUM, COUNT)
* @showcount Show count of records
*
* @returns Sql generated
*/
function PivotTableSQL($db,$tables,$rowfields,$colfield, $where=false,
$aggfield = false,$sumlabel='Sum ',$aggfn ='SUM', $showcount = true)
{
if ($aggfield) $hidecnt = true;
else $hidecnt = false;
$iif = strpos($db->databaseType,'access') !== false;
// note - vfp still doesn' work even with IIF enabled || $db->databaseType == 'vfp';
//$hidecnt = false;
if ($where) $where = "\nWHERE $where";
if (!is_array($colfield)) $colarr = $db->GetCol("select distinct $colfield from $tables $where order by 1");
if (!$aggfield) $hidecnt = false;
$sel = "$rowfields, ";
if (is_array($colfield)) {
foreach ($colfield as $k => $v) {
$k = trim($k);
if (!$hidecnt) {
$sel .= $iif ?
"\n\t$aggfn(IIF($v,1,0)) AS \"$k\", "
:
"\n\t$aggfn(CASE WHEN $v THEN 1 ELSE 0 END) AS \"$k\", ";
}
if ($aggfield) {
$sel .= $iif ?
"\n\t$aggfn(IIF($v,$aggfield,0)) AS \"$sumlabel$k\", "
:
"\n\t$aggfn(CASE WHEN $v THEN $aggfield ELSE 0 END) AS \"$sumlabel$k\", ";
}
}
} else {
foreach ($colarr as $v) {
if (!is_numeric($v)) $vq = $db->qstr($v);
else $vq = $v;
$v = trim($v);
if (strlen($v) == 0 ) $v = 'null';
if (!$hidecnt) {
$sel .= $iif ?
"\n\t$aggfn(IIF($colfield=$vq,1,0)) AS \"$v\", "
:
"\n\t$aggfn(CASE WHEN $colfield=$vq THEN 1 ELSE 0 END) AS \"$v\", ";
}
if ($aggfield) {
if ($hidecnt) $label = $v;
else $label = "{$v}_$aggfield";
$sel .= $iif ?
"\n\t$aggfn(IIF($colfield=$vq,$aggfield,0)) AS \"$label\", "
:
"\n\t$aggfn(CASE WHEN $colfield=$vq THEN $aggfield ELSE 0 END) AS \"$label\", ";
}
}
}
if ($aggfield && $aggfield != '1'){
$agg = "$aggfn($aggfield)";
$sel .= "\n\t$agg as \"$sumlabel$aggfield\", ";
}
if ($showcount)
$sel .= "\n\tSUM(1) as Total";
else
$sel = substr($sel,0,strlen($sel)-2);
$sql = "SELECT $sel \nFROM $tables $where \nGROUP BY $rowfields";
return $sql;
}
/* EXAMPLES USING MS NORTHWIND DATABASE */
if (0) {
# example1
#
# Query the main "product" table
# Set the rows to CompanyName and QuantityPerUnit
# and the columns to the Categories
# and define the joins to link to lookup tables
# "categories" and "suppliers"
#
$sql = PivotTableSQL(
$gDB, # adodb connection
'products p ,categories c ,suppliers s', # tables
'CompanyName,QuantityPerUnit', # row fields
'CategoryName', # column fields
'p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID' # joins/where
);
print "<pre>$sql";
$rs = $gDB->Execute($sql);
rs2html($rs);
/*
Generated SQL:
SELECT CompanyName,QuantityPerUnit,
SUM(CASE WHEN CategoryName='Beverages' THEN 1 ELSE 0 END) AS "Beverages",
SUM(CASE WHEN CategoryName='Condiments' THEN 1 ELSE 0 END) AS "Condiments",
SUM(CASE WHEN CategoryName='Confections' THEN 1 ELSE 0 END) AS "Confections",
SUM(CASE WHEN CategoryName='Dairy Products' THEN 1 ELSE 0 END) AS "Dairy Products",
SUM(CASE WHEN CategoryName='Grains/Cereals' THEN 1 ELSE 0 END) AS "Grains/Cereals",
SUM(CASE WHEN CategoryName='Meat/Poultry' THEN 1 ELSE 0 END) AS "Meat/Poultry",
SUM(CASE WHEN CategoryName='Produce' THEN 1 ELSE 0 END) AS "Produce",
SUM(CASE WHEN CategoryName='Seafood' THEN 1 ELSE 0 END) AS "Seafood",
SUM(1) as Total
FROM products p ,categories c ,suppliers s WHERE p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID
GROUP BY CompanyName,QuantityPerUnit
*/
//=====================================================================
# example2
#
# Query the main "product" table
# Set the rows to CompanyName and QuantityPerUnit
# and the columns to the UnitsInStock for diiferent ranges
# and define the joins to link to lookup tables
# "categories" and "suppliers"
#
$sql = PivotTableSQL(
$gDB, # adodb connection
'products p ,categories c ,suppliers s', # tables
'CompanyName,QuantityPerUnit', # row fields
# column ranges
array(
' 0 ' => 'UnitsInStock <= 0',
"1 to 5" => '0 < UnitsInStock and UnitsInStock <= 5',
"6 to 10" => '5 < UnitsInStock and UnitsInStock <= 10',
"11 to 15" => '10 < UnitsInStock and UnitsInStock <= 15',
"16+" =>'15 < UnitsInStock'
),
' p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID', # joins/where
'UnitsInStock', # sum this field
'Sum' # sum label prefix
);
print "<pre>$sql";
$rs = $gDB->Execute($sql);
rs2html($rs);
/*
Generated SQL:
SELECT CompanyName,QuantityPerUnit,
SUM(CASE WHEN UnitsInStock <= 0 THEN UnitsInStock ELSE 0 END) AS "Sum 0 ",
SUM(CASE WHEN 0 < UnitsInStock and UnitsInStock <= 5 THEN UnitsInStock ELSE 0 END) AS "Sum 1 to 5",
SUM(CASE WHEN 5 < UnitsInStock and UnitsInStock <= 10 THEN UnitsInStock ELSE 0 END) AS "Sum 6 to 10",
SUM(CASE WHEN 10 < UnitsInStock and UnitsInStock <= 15 THEN UnitsInStock ELSE 0 END) AS "Sum 11 to 15",
SUM(CASE WHEN 15 < UnitsInStock THEN UnitsInStock ELSE 0 END) AS "Sum 16+",
SUM(UnitsInStock) AS "Sum UnitsInStock",
SUM(1) as Total
FROM products p ,categories c ,suppliers s WHERE p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID
GROUP BY CompanyName,QuantityPerUnit
*/
}
?>

View file

@ -0,0 +1,62 @@
>> ADODB Library for PHP4
(c) 2000-2004 John Lim (jlim@natsoft.com.my)
Released under both BSD and GNU Lesser GPL library license.
This means you can use it in proprietary products.
>> Introduction
PHP's database access functions are not standardised. This creates a
need for a database class library to hide the differences between the
different databases (encapsulate the differences) so we can easily
switch databases.
We currently support MySQL, Interbase, Sybase, PostgreSQL, Oracle,
Microsoft SQL server, Foxpro ODBC, Access ODBC, Informix, DB2,
Sybase SQL Anywhere, generic ODBC and Microsoft's ADO.
We hope more people will contribute drivers to support other databases.
>> Documentation and Examples
Refer to the adodb/docs directory for full documentation and examples.
There is also a tutorial tute.htm that contrasts ADODB code with
mysql code.
>>> Files
Adodb.inc.php is the main file. You need to include only this file.
Adodb-*.inc.php are the database specific driver code.
Test.php contains a list of test commands to exercise the class library.
Adodb-session.php is the PHP4 session handling code.
Testdatabases.inc.php contains the list of databases to apply the tests on.
Benchmark.php is a simple benchmark to test the throughput of a simple SELECT
statement for databases described in testdatabases.inc.php. The benchmark
tables are created in test.php.
readme.htm is the main documentation.
tute.htm is the tutorial.
>> More Info
For more information, including installation see readme.htm
or visit
http://adodb.sourceforge.net/
>> Feature Requests and Bug Reports
Email to jlim@natsoft.com.my

View file

@ -0,0 +1,61 @@
<?php
/**
* @version V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
* Latest version is available at http://php.weblogs.com
*
* Requires PHP4.01pl2 or later because it uses include_once
*/
/*
Filter all fields and all rows in a recordset and returns the
processed recordset. We scroll to the beginning of the new recordset
after processing.
We pass a recordset and function name to RSFilter($rs,'rowfunc');
and the function will be called multiple times, once
for each row in the recordset. The function will be passed
an array containing one row repeatedly.
Example:
// ucwords() every element in the recordset
function do_ucwords(&$arr,$rs)
{
foreach($arr as $k => $v) {
$arr[$k] = ucwords($v);
}
}
$rs = RSFilter($rs,'do_ucwords');
*/
function RSFilter($rs,$fn)
{
if ($rs->databaseType != 'array') {
if (!$rs->connection) return false;
$rs = &$rs->connection->_rs2rs($rs);
}
$rows = $rs->RecordCount();
for ($i=0; $i < $rows; $i++) {
if (is_array ($fn)) {
$obj = $fn[0];
$method = $fn[1];
$obj->$method ($rs->_array[$i],$rs);
} else {
$fn($rs->_array[$i],$rs);
}
}
if (!$rs->EOF) {
$rs->_currentRow = 0;
$rs->fields = $rs->_array[0];
}
return $rs;
}
?>

View file

@ -0,0 +1,100 @@
<?php
/**
* @version V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
*/
/* Documentation on usage is at http://php.weblogs.com/adodb_csv
*
* Legal query string parameters:
*
* sql = holds sql string
* nrows = number of rows to return
* offset = skip offset rows of data
* fetch = $ADODB_FETCH_MODE
*
* example:
*
* http://localhost/php/server.php?select+*+from+table&nrows=10&offset=2
*/
/*
* Define the IP address you want to accept requests from
* as a security measure. If blank we accept anyone promisciously!
*/
$ACCEPTIP = '127.0.0.1';
/*
* Connection parameters
*/
$driver = 'mysql';
$host = 'localhost'; // DSN for odbc
$uid = 'root';
$pwd = 'garbase-it-is';
$database = 'test';
/*============================ DO NOT MODIFY BELOW HERE =================================*/
// $sep must match csv2rs() in adodb.inc.php
$sep = ' :::: ';
include('./adodb.inc.php');
include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
function err($s)
{
die('**** '.$s.' ');
}
// undo stupid magic quotes
function undomq(&$m)
{
if (get_magic_quotes_gpc()) {
// undo the damage
$m = str_replace('\\\\','\\',$m);
$m = str_replace('\"','"',$m);
$m = str_replace('\\\'','\'',$m);
}
return $m;
}
///////////////////////////////////////// DEFINITIONS
$remote = $_SERVER["REMOTE_ADDR"];
if (!empty($ACCEPTIP))
if ($remote != '127.0.0.1' && $remote != $ACCEPTIP)
err("Unauthorised client: '$remote'");
if (empty($_REQUEST['sql'])) err('No SQL');
$conn = &ADONewConnection($driver);
if (!$conn->Connect($host,$uid,$pwd,$database)) err($conn->ErrorNo(). $sep . $conn->ErrorMsg());
$sql = undomq($_REQUEST['sql']);
if (isset($_REQUEST['fetch']))
$ADODB_FETCH_MODE = $_REQUEST['fetch'];
if (isset($_REQUEST['nrows'])) {
$nrows = $_REQUEST['nrows'];
$offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : -1;
$rs = $conn->SelectLimit($sql,$nrows,$offset);
} else
$rs = $conn->Execute($sql);
if ($rs){
//$rs->timeToLive = 1;
echo _rs2serialize($rs,$conn,$sql);
$rs->Close();
} else
err($conn->ErrorNo(). $sep .$conn->ErrorMsg());
?>

View file

@ -0,0 +1,118 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
if (!function_exists('bzcompress')) {
trigger_error('bzip2 functions are not available', E_USER_ERROR);
return 0;
}
/*
*/
class ADODB_Compress_Bzip2 {
/**
*/
var $_block_size = null;
/**
*/
var $_work_level = null;
/**
*/
var $_min_length = 1;
/**
*/
function getBlockSize() {
return $this->_block_size;
}
/**
*/
function setBlockSize($block_size) {
assert('$block_size >= 1');
assert('$block_size <= 9');
$this->_block_size = (int) $block_size;
}
/**
*/
function getWorkLevel() {
return $this->_work_level;
}
/**
*/
function setWorkLevel($work_level) {
assert('$work_level >= 0');
assert('$work_level <= 250');
$this->_work_level = (int) $work_level;
}
/**
*/
function getMinLength() {
return $this->_min_length;
}
/**
*/
function setMinLength($min_length) {
assert('$min_length >= 0');
$this->_min_length = (int) $min_length;
}
/**
*/
function ADODB_Compress_Bzip2($block_size = null, $work_level = null, $min_length = null) {
if (!is_null($block_size)) {
$this->setBlockSize($block_size);
}
if (!is_null($work_level)) {
$this->setWorkLevel($work_level);
}
if (!is_null($min_length)) {
$this->setMinLength($min_length);
}
}
/**
*/
function write($data, $key) {
if (strlen($data) < $this->_min_length) {
return $data;
}
if (!is_null($this->_block_size)) {
if (!is_null($this->_work_level)) {
return bzcompress($data, $this->_block_size, $this->_work_level);
} else {
return bzcompress($data, $this->_block_size);
}
}
return bzcompress($data);
}
/**
*/
function read($data, $key) {
return $data ? bzdecompress($data) : $data;
}
}
return 1;
?>

View file

@ -0,0 +1,93 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
if (!function_exists('gzcompress')) {
trigger_error('gzip functions are not available', E_USER_ERROR);
return 0;
}
/*
*/
class ADODB_Compress_Gzip {
/**
*/
var $_level = null;
/**
*/
var $_min_length = 1;
/**
*/
function getLevel() {
return $this->_level;
}
/**
*/
function setLevel($level) {
assert('$level >= 0');
assert('$level <= 9');
$this->_level = (int) $level;
}
/**
*/
function getMinLength() {
return $this->_min_length;
}
/**
*/
function setMinLength($min_length) {
assert('$min_length >= 0');
$this->_min_length = (int) $min_length;
}
/**
*/
function ADODB_Compress_Gzip($level = null, $min_length = null) {
if (!is_null($level)) {
$this->setLevel($level);
}
if (!is_null($min_length)) {
$this->setMinLength($min_length);
}
}
/**
*/
function write($data, $key) {
if (strlen($data) < $this->_min_length) {
return $data;
}
if (!is_null($this->_level)) {
return gzcompress($data, $this->_level);
} else {
return gzcompress($data);
}
}
/**
*/
function read($data, $key) {
return $data ? gzuncompress($data) : $data;
}
}
return 1;
?>

View file

@ -0,0 +1,24 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
/*
This file is provided for backwards compatibility purposes
*/
require_once dirname(__FILE__) . '/adodb-session.php';
require_once ADODB_SESSION . '/adodb-encrypt-md5.php';
ADODB_Session::filter(new ADODB_Encrypt_MD5());
?>

View file

@ -0,0 +1,109 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
if (!function_exists('mcrypt_encrypt')) {
trigger_error('Mcrypt functions are not available', E_USER_ERROR);
return 0;
}
/**
*/
class ADODB_Encrypt_MCrypt {
/**
*/
var $_cipher;
/**
*/
var $_mode;
/**
*/
var $_source;
/**
*/
function getCipher() {
return $this->_cipher;
}
/**
*/
function setCipher($cipher) {
$this->_cipher = $cipher;
}
/**
*/
function getMode() {
return $this->_mode;
}
/**
*/
function setMode($mode) {
$this->_mode = $mode;
}
/**
*/
function getSource() {
return $this->_source;
}
/**
*/
function setSource($source) {
$this->_source = $source;
}
/**
*/
function ADODB_Encrypt_MCrypt($cipher = null, $mode = null, $source = null) {
if (!$cipher) {
$cipher = MCRYPT_RIJNDAEL_256;
}
if (!$mode) {
$mode = MCRYPT_MODE_ECB;
}
if (!$source) {
$source = MCRYPT_RAND;
}
$this->_cipher = $cipher;
$this->_mode = $mode;
$this->_source = $source;
}
/**
*/
function write($data, $key) {
$iv_size = mcrypt_get_iv_size($this->_cipher, $this->_mode);
$iv = mcrypt_create_iv($iv_size, $this->_source);
return mcrypt_encrypt($this->_cipher, $key, $data, $this->_mode, $iv);
}
/**
*/
function read($data, $key) {
$iv_size = mcrypt_get_iv_size($this->_cipher, $this->_mode);
$iv = mcrypt_create_iv($iv_size, $this->_source);
$rv = mcrypt_decrypt($this->_cipher, $key, $data, $this->_mode, $iv);
return rtrim($rv, "\0");
}
}
return 1;
?>

View file

@ -0,0 +1,39 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
// security - hide paths
if (!defined('ADODB_SESSION')) die();
include_once ADODB_SESSION . '/crypt.inc.php';
/**
*/
class ADODB_Encrypt_MD5 {
/**
*/
function write($data, $key) {
$md5crypt = new MD5Crypt();
return $md5crypt->encrypt($data, $key);
}
/**
*/
function read($data, $key) {
$md5crypt = new MD5Crypt();
return $md5crypt->decrypt($data, $key);
}
}
return 1;
?>

View file

@ -0,0 +1,48 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
@define('HORDE_BASE', dirname(dirname(dirname(__FILE__))) . '/horde');
if (!is_dir(HORDE_BASE)) {
trigger_error(sprintf('Directory not found: \'%s\'', HORDE_BASE), E_USER_ERROR);
return 0;
}
include_once HORDE_BASE . '/lib/Horde.php';
include_once HORDE_BASE . '/lib/Secret.php';
/**
NOTE: On Windows 2000 SP4 with PHP 4.3.1, MCrypt 2.4.x, and Apache 1.3.28,
the session didn't work properly.
This may be resolved with 4.3.3.
*/
class ADODB_Encrypt_Secret {
/**
*/
function write($data, $key) {
return Secret::write($key, $data);
}
/**
*/
function read($data, $key) {
return Secret::read($key, $data);
}
}
return 1;
?>

View file

@ -0,0 +1,32 @@
<?php
if (!defined('ADODB_SESSION')) die();
include_once ADODB_SESSION . '/crypt.inc.php';
/**
*/
class ADODB_Encrypt_SHA1 {
function write($data, $key)
{
$sha1crypt = new SHA1Crypt();
return $sha1crypt->encrypt($data, $key);
}
function read($data, $key)
{
$sha1crypt = new SHA1Crypt();
return $sha1crypt->decrypt($data, $key);
}
}
return 1;
?>

View file

@ -0,0 +1,131 @@
John,
I have been an extremely satisfied ADODB user for several years now.
To give you something back for all your hard work, I've spent the last 3
days rewriting the adodb-session.php code.
----------
What's New
----------
Here's a list of the new code's benefits:
* Combines the functionality of the three files:
adodb-session.php
adodb-session-clob.php
adodb-cryptsession.php
each with very similar functionality, into a single file adodb-session.php.
This will ease maintenance and support issues.
* Supports multiple encryption and compression schemes.
Currently, we support:
MD5Crypt (crypt.inc.php)
MCrypt
Secure (Horde's emulation of MCrypt, if MCrypt module is not available.)
GZip
BZip2
These can be stacked, so if you want to compress and then encrypt your
session data, it's easy.
Also, the built-in MCrypt functions will be *much* faster, and more secure,
than the MD5Crypt code.
* adodb-session.php contains a single class ADODB_Session that encapsulates
all functionality.
This eliminates the use of global vars and defines (though they are
supported for backwards compatibility).
* All user defined parameters are now static functions in the ADODB_Session
class.
New parameters include:
* encryptionKey(): Define the encryption key used to encrypt the session.
Originally, it was a hard coded string.
* persist(): Define if the database will be opened in persistent mode.
Originally, the user had to call adodb_sess_open().
* dataFieldName(): Define the field name used to store the session data, as
'DATA' appears to be a reserved word in the following cases:
ANSI SQL
IBM DB2
MS SQL Server
Postgres
SAP
* filter(): Used to support multiple, simulataneous encryption/compression
schemes.
* Debug support is improved thru _rsdump() function, which is called after
every database call.
------------
What's Fixed
------------
The new code includes several bug fixes and enhancements:
* sesskey is compared in BINARY mode for MySQL, to avoid problems with
session keys that differ only by case.
Of course, the user should define the sesskey field as BINARY, to
correctly fix this problem, otherwise performance will suffer.
* In ADODB_Session::gc(), if $expire_notify is true, the multiple DELETES in
the original code have been optimized to a single DELETE.
* In ADODB_Session::destroy(), since "SELECT expireref, sesskey FROM $table
WHERE sesskey = $qkey" will only return a single value, we don't loop on the
result, we simply process the row, if any.
* We close $rs after every use.
---------------
What's the Same
---------------
I know backwards compatibility is *very* important to you. Therefore, the
new code is 100% backwards compatible.
If you like my code, but don't "trust" it's backwards compatible, maybe we
offer it as beta code, in a new directory for a release or two?
------------
What's To Do
------------
I've vascillated over whether to use a single function to get/set
parameters:
$user = ADODB_Session::user(); // get
ADODB_Session::user($user); // set
or to use separate functions (which is the PEAR/Java way):
$user = ADODB_Session::getUser();
ADODB_Session::setUser($user);
I've chosen the former as it's makes for a simpler API, and reduces the
amount of code, but I'd be happy to change it to the latter.
Also, do you think the class should be a singleton class, versus a static
class?
Let me know if you find this code useful, and will be including it in the
next release of ADODB.
If so, I will modify the current documentation to detail the new
functionality. To that end, what file(s) contain the documentation? Please
send them to me if they are not publically available.
Also, if there is *anything* in the code that you like to see changed, let
me know.
Thanks,
Ross

View file

@ -0,0 +1,23 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
/*
This file is provided for backwards compatibility purposes
*/
require_once dirname(__FILE__) . '/adodb-session.php';
ADODB_Session::clob('CLOB');
?>

View file

@ -0,0 +1,917 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
*/
/*
You may want to rename the 'data' field to 'session_data' as
'data' appears to be a reserved word for one or more of the following:
ANSI SQL
IBM DB2
MS SQL Server
Postgres
SAP
If you do, then execute:
ADODB_Session::dataFieldName('session_data');
*/
if (!defined('_ADODB_LAYER')) {
require_once realpath(dirname(__FILE__) . '/../adodb.inc.php');
}
if (defined('ADODB_SESSION')) return 1;
define('ADODB_SESSION', dirname(__FILE__));
/*
Unserialize session data manually. See http://phplens.com/lens/lensforum/msgs.php?id=9821
From Kerr Schere, to unserialize session data stored via ADOdb.
1. Pull the session data from the db and loop through it.
2. Inside the loop, you will need to urldecode the data column.
3. After urldecode, run the serialized string through this function:
*/
function adodb_unserialize( $serialized_string )
{
$variables = array( );
$a = preg_split( "/(\w+)\|/", $serialized_string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
for( $i = 0; $i < count( $a ); $i = $i+2 ) {
$variables[$a[$i]] = unserialize( $a[$i+1] );
}
return( $variables );
}
/*
Thanks Joe Li. See http://phplens.com/lens/lensforum/msgs.php?id=11487&x=1
Since adodb 4.61.
*/
function adodb_session_regenerate_id()
{
$conn =& ADODB_Session::_conn();
if (!$conn) return false;
$old_id = session_id();
if (function_exists('session_regenerate_id')) {
session_regenerate_id();
} else {
session_id(md5(uniqid(rand(), true)));
$ck = session_get_cookie_params();
setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
//@session_start();
}
$new_id = session_id();
$ok =& $conn->Execute('UPDATE '. ADODB_Session::table(). ' SET sesskey='. $conn->qstr($new_id). ' WHERE sesskey='.$conn->qstr($old_id));
/* it is possible that the update statement fails due to a collision */
if (!$ok) {
session_id($old_id);
if (empty($ck)) $ck = session_get_cookie_params();
setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
return false;
}
return true;
}
/*
Generate database table for session data
@see http://phplens.com/lens/lensforum/msgs.php?id=12280
@return 0 if failure, 1 if errors, 2 if successful.
@author Markus Staab http://www.public-4u.de
*/
function adodb_session_create_table($schemaFile=null,$conn = null)
{
// set default values
if ($schemaFile===null) $schemaFile = ADODB_SESSION . '/session_schema.xml';
if ($conn===null) $conn =& ADODB_Session::_conn();
if (!$conn) return 0;
$schema = new adoSchema($conn);
$schema->ParseSchema($schemaFile);
return $schema->ExecuteSchema();
}
/*!
\static
*/
class ADODB_Session {
/////////////////////
// getter/setter methods
/////////////////////
/*
function Lock($lock=null)
{
static $_lock = false;
if (!is_null($lock)) $_lock = $lock;
return $lock;
}
*/
/*!
*/
function driver($driver = null) {
static $_driver = 'mysql';
static $set = false;
if (!is_null($driver)) {
$_driver = trim($driver);
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_DRIVER'])) {
return $GLOBALS['ADODB_SESSION_DRIVER'];
}
}
return $_driver;
}
/*!
*/
function host($host = null) {
static $_host = 'localhost';
static $set = false;
if (!is_null($host)) {
$_host = trim($host);
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_CONNECT'])) {
return $GLOBALS['ADODB_SESSION_CONNECT'];
}
}
return $_host;
}
/*!
*/
function user($user = null) {
static $_user = 'root';
static $set = false;
if (!is_null($user)) {
$_user = trim($user);
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_USER'])) {
return $GLOBALS['ADODB_SESSION_USER'];
}
}
return $_user;
}
/*!
*/
function password($password = null) {
static $_password = '';
static $set = false;
if (!is_null($password)) {
$_password = $password;
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_PWD'])) {
return $GLOBALS['ADODB_SESSION_PWD'];
}
}
return $_password;
}
/*!
*/
function database($database = null) {
static $_database = 'xphplens_2';
static $set = false;
if (!is_null($database)) {
$_database = trim($database);
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_DB'])) {
return $GLOBALS['ADODB_SESSION_DB'];
}
}
return $_database;
}
/*!
*/
function persist($persist = null)
{
static $_persist = true;
if (!is_null($persist)) {
$_persist = trim($persist);
}
return $_persist;
}
/*!
*/
function lifetime($lifetime = null) {
static $_lifetime;
static $set = false;
if (!is_null($lifetime)) {
$_lifetime = (int) $lifetime;
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESS_LIFE'])) {
return $GLOBALS['ADODB_SESS_LIFE'];
}
}
if (!$_lifetime) {
$_lifetime = ini_get('session.gc_maxlifetime');
if ($_lifetime <= 1) {
// bug in PHP 4.0.3 pl 1 -- how about other versions?
//print "<h3>Session Error: PHP.INI setting <i>session.gc_maxlifetime</i>not set: $lifetime</h3>";
$_lifetime = 1440;
}
}
return $_lifetime;
}
/*!
*/
function debug($debug = null) {
static $_debug = false;
static $set = false;
if (!is_null($debug)) {
$_debug = (bool) $debug;
$conn = ADODB_Session::_conn();
if ($conn) {
$conn->debug = $_debug;
}
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESS_DEBUG'])) {
return $GLOBALS['ADODB_SESS_DEBUG'];
}
}
return $_debug;
}
/*!
*/
function expireNotify($expire_notify = null) {
static $_expire_notify;
static $set = false;
if (!is_null($expire_notify)) {
$_expire_notify = $expire_notify;
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_EXPIRE_NOTIFY'])) {
return $GLOBALS['ADODB_SESSION_EXPIRE_NOTIFY'];
}
}
return $_expire_notify;
}
/*!
*/
function table($table = null) {
static $_table = 'sessions';
static $set = false;
if (!is_null($table)) {
$_table = trim($table);
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_TBL'])) {
return $GLOBALS['ADODB_SESSION_TBL'];
}
}
return $_table;
}
/*!
*/
function optimize($optimize = null) {
static $_optimize = false;
static $set = false;
if (!is_null($optimize)) {
$_optimize = (bool) $optimize;
$set = true;
} elseif (!$set) {
// backwards compatibility
if (defined('ADODB_SESSION_OPTIMIZE')) {
return true;
}
}
return $_optimize;
}
/*!
*/
function syncSeconds($sync_seconds = null) {
static $_sync_seconds = 60;
static $set = false;
if (!is_null($sync_seconds)) {
$_sync_seconds = (int) $sync_seconds;
$set = true;
} elseif (!$set) {
// backwards compatibility
if (defined('ADODB_SESSION_SYNCH_SECS')) {
return ADODB_SESSION_SYNCH_SECS;
}
}
return $_sync_seconds;
}
/*!
*/
function clob($clob = null) {
static $_clob = false;
static $set = false;
if (!is_null($clob)) {
$_clob = strtolower(trim($clob));
$set = true;
} elseif (!$set) {
// backwards compatibility
if (isset($GLOBALS['ADODB_SESSION_USE_LOBS'])) {
return $GLOBALS['ADODB_SESSION_USE_LOBS'];
}
}
return $_clob;
}
/*!
*/
function dataFieldName($data_field_name = null) {
static $_data_field_name = 'data';
if (!is_null($data_field_name)) {
$_data_field_name = trim($data_field_name);
}
return $_data_field_name;
}
/*!
*/
function filter($filter = null) {
static $_filter = array();
if (!is_null($filter)) {
if (!is_array($filter)) {
$filter = array($filter);
}
$_filter = $filter;
}
return $_filter;
}
/*!
*/
function encryptionKey($encryption_key = null) {
static $_encryption_key = 'CRYPTED ADODB SESSIONS ROCK!';
if (!is_null($encryption_key)) {
$_encryption_key = $encryption_key;
}
return $_encryption_key;
}
/////////////////////
// private methods
/////////////////////
/*!
*/
function _conn($conn=null) {
return $GLOBALS['ADODB_SESS_CONN'];
}
/*!
*/
function _crc($crc = null) {
static $_crc = false;
if (!is_null($crc)) {
$_crc = $crc;
}
return $_crc;
}
/*!
*/
function _init() {
session_module_name('user');
session_set_save_handler(
array('ADODB_Session', 'open'),
array('ADODB_Session', 'close'),
array('ADODB_Session', 'read'),
array('ADODB_Session', 'write'),
array('ADODB_Session', 'destroy'),
array('ADODB_Session', 'gc')
);
}
/*!
*/
function _sessionKey() {
// use this function to create the encryption key for crypted sessions
// crypt the used key, ADODB_Session::encryptionKey() as key and session_id() as salt
return crypt(ADODB_Session::encryptionKey(), session_id());
}
/*!
*/
function _dumprs($rs) {
$conn =& ADODB_Session::_conn();
$debug = ADODB_Session::debug();
if (!$conn) {
return;
}
if (!$debug) {
return;
}
if (!$rs) {
echo "<br />\$rs is null or false<br />\n";
return;
}
//echo "<br />\nAffected_Rows=",$conn->Affected_Rows(),"<br />\n";
if (!is_object($rs)) {
return;
}
require_once ADODB_SESSION.'/../tohtml.inc.php';
rs2html($rs);
}
/////////////////////
// public methods
/////////////////////
/*!
Create the connection to the database.
If $conn already exists, reuse that connection
*/
function open($save_path, $session_name, $persist = null) {
$conn =& ADODB_Session::_conn();
if ($conn) {
return true;
}
$database = ADODB_Session::database();
$debug = ADODB_Session::debug();
$driver = ADODB_Session::driver();
$host = ADODB_Session::host();
$password = ADODB_Session::password();
$user = ADODB_Session::user();
if (!is_null($persist)) {
ADODB_Session::persist($persist);
} else {
$persist = ADODB_Session::persist();
}
# these can all be defaulted to in php.ini
# assert('$database');
# assert('$driver');
# assert('$host');
// cannot use =& below - do not know why...
$conn =& ADONewConnection($driver);
if ($debug) {
$conn->debug = true;
// ADOConnection::outp( " driver=$driver user=$user pwd=$password db=$database ");
}
if ($persist) {
switch($persist) {
default:
case 'P': $ok = $conn->PConnect($host, $user, $password, $database); break;
case 'C': $ok = $conn->Connect($host, $user, $password, $database); break;
case 'N': $ok = $conn->NConnect($host, $user, $password, $database); break;
}
} else {
$ok = $conn->Connect($host, $user, $password, $database);
}
if ($ok) $GLOBALS['ADODB_SESS_CONN'] =& $conn;
else
ADOConnection::outp('<p>Session: connection failed</p>', false);
return $ok;
}
/*!
Close the connection
*/
function close() {
/*
$conn =& ADODB_Session::_conn();
if ($conn) $conn->Close();
*/
return true;
}
/*
Slurp in the session variables and return the serialized string
*/
function read($key) {
$conn =& ADODB_Session::_conn();
$data = ADODB_Session::dataFieldName();
$filter = ADODB_Session::filter();
$table = ADODB_Session::table();
if (!$conn) {
return '';
}
assert('$table');
$qkey = $conn->quote($key);
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
$sql = "SELECT $data FROM $table WHERE sesskey = $binary $qkey AND expiry >= " . time();
/* Lock code does not work as it needs to hold transaction within whole page, and we don't know if
developer has commited elsewhere... :(
*/
#if (ADODB_Session::Lock())
# $rs =& $conn->RowLock($table, "$binary sesskey = $qkey AND expiry >= " . time(), $data);
#else
$rs =& $conn->Execute($sql);
//ADODB_Session::_dumprs($rs);
if ($rs) {
if ($rs->EOF) {
$v = '';
} else {
$v = reset($rs->fields);
$filter = array_reverse($filter);
foreach ($filter as $f) {
if (is_object($f)) {
$v = $f->read($v, ADODB_Session::_sessionKey());
}
}
$v = rawurldecode($v);
}
$rs->Close();
ADODB_Session::_crc(strlen($v) . crc32($v));
return $v;
}
return '';
}
/*!
Write the serialized data to a database.
If the data has not been modified since the last read(), we do not write.
*/
function write($key, $val) {
$clob = ADODB_Session::clob();
$conn =& ADODB_Session::_conn();
$crc = ADODB_Session::_crc();
$data = ADODB_Session::dataFieldName();
$debug = ADODB_Session::debug();
$driver = ADODB_Session::driver();
$expire_notify = ADODB_Session::expireNotify();
$filter = ADODB_Session::filter();
$lifetime = ADODB_Session::lifetime();
$table = ADODB_Session::table();
if (!$conn) {
return false;
}
$qkey = $conn->qstr($key);
assert('$table');
$expiry = time() + $lifetime;
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
// crc32 optimization since adodb 2.1
// now we only update expiry date, thx to sebastian thom in adodb 2.32
if ($crc !== false && $crc == (strlen($val) . crc32($val))) {
if ($debug) {
echo '<p>Session: Only updating date - crc32 not changed</p>';
}
$sql = "UPDATE $table SET expiry = ".$conn->Param('0')." WHERE $binary sesskey = ".$conn->Param('1')." AND expiry >= ".$conn->Param('2');
$rs =& $conn->Execute($sql,array($expiry,$key,time()));
ADODB_Session::_dumprs($rs);
if ($rs) {
$rs->Close();
}
return true;
}
$val = rawurlencode($val);
foreach ($filter as $f) {
if (is_object($f)) {
$val = $f->write($val, ADODB_Session::_sessionKey());
}
}
$arr = array('sesskey' => $key, 'expiry' => $expiry, $data => $val, 'expireref' => '');
if ($expire_notify) {
$var = reset($expire_notify);
global $$var;
if (isset($$var)) {
$arr['expireref'] = $$var;
}
}
if (!$clob) { // no lobs, simply use replace()
$arr[$data] = $conn->qstr($val);
$rs = $conn->Replace($table, $arr, 'sesskey', $autoQuote = true);
ADODB_Session::_dumprs($rs);
} else {
// what value shall we insert/update for lob row?
switch ($driver) {
// empty_clob or empty_lob for oracle dbs
case 'oracle':
case 'oci8':
case 'oci8po':
case 'oci805':
$lob_value = sprintf('empty_%s()', strtolower($clob));
break;
// null for all other
default:
$lob_value = 'null';
break;
}
// do we insert or update? => as for sesskey
$rs =& $conn->Execute("SELECT COUNT(*) AS cnt FROM $table WHERE $binary sesskey = $qkey");
ADODB_Session::_dumprs($rs);
if ($rs && reset($rs->fields) > 0) {
$sql = "UPDATE $table SET expiry = $expiry, $data = $lob_value WHERE sesskey = $qkey";
} else {
$sql = "INSERT INTO $table (expiry, $data, sesskey) VALUES ($expiry, $lob_value, $qkey)";
}
if ($rs) {
$rs->Close();
}
$err = '';
$rs1 =& $conn->Execute($sql);
ADODB_Session::_dumprs($rs1);
if (!$rs1) {
$err = $conn->ErrorMsg()."\n";
}
$rs2 =& $conn->UpdateBlob($table, $data, $val, " sesskey=$qkey", strtoupper($clob));
ADODB_Session::_dumprs($rs2);
if (!$rs2) {
$err .= $conn->ErrorMsg()."\n";
}
$rs = ($rs && $rs2) ? true : false;
if ($rs1) {
$rs1->Close();
}
if (is_object($rs2)) {
$rs2->Close();
}
}
if (!$rs) {
ADOConnection::outp('<p>Session Replace: ' . $conn->ErrorMsg() . '</p>', false);
return false;
} else {
// bug in access driver (could be odbc?) means that info is not committed
// properly unless select statement executed in Win2000
if ($conn->databaseType == 'access') {
$sql = "SELECT sesskey FROM $table WHERE $binary sesskey = $qkey";
$rs =& $conn->Execute($sql);
ADODB_Session::_dumprs($rs);
if ($rs) {
$rs->Close();
}
}
}/*
if (ADODB_Session::Lock()) {
$conn->CommitTrans();
}*/
return $rs ? true : false;
}
/*!
*/
function destroy($key) {
$conn =& ADODB_Session::_conn();
$table = ADODB_Session::table();
$expire_notify = ADODB_Session::expireNotify();
if (!$conn) {
return false;
}
assert('$table');
$qkey = $conn->quote($key);
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
if ($expire_notify) {
reset($expire_notify);
$fn = next($expire_notify);
$savem = $conn->SetFetchMode(ADODB_FETCH_NUM);
$sql = "SELECT expireref, sesskey FROM $table WHERE $binary sesskey = $qkey";
$rs =& $conn->Execute($sql);
ADODB_Session::_dumprs($rs);
$conn->SetFetchMode($savem);
if (!$rs) {
return false;
}
if (!$rs->EOF) {
$ref = $rs->fields[0];
$key = $rs->fields[1];
//assert('$ref');
//assert('$key');
$fn($ref, $key);
}
$rs->Close();
}
$sql = "DELETE FROM $table WHERE $binary sesskey = $qkey";
$rs =& $conn->Execute($sql);
ADODB_Session::_dumprs($rs);
if ($rs) {
$rs->Close();
}
return $rs ? true : false;
}
/*!
*/
function gc($maxlifetime) {
$conn =& ADODB_Session::_conn();
$debug = ADODB_Session::debug();
$expire_notify = ADODB_Session::expireNotify();
$optimize = ADODB_Session::optimize();
$sync_seconds = ADODB_Session::syncSeconds();
$table = ADODB_Session::table();
if (!$conn) {
return false;
}
assert('$table');
$time = time();
$binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
if ($expire_notify) {
reset($expire_notify);
$fn = next($expire_notify);
$savem = $conn->SetFetchMode(ADODB_FETCH_NUM);
$sql = "SELECT expireref, sesskey FROM $table WHERE expiry < $time";
$rs =& $conn->Execute($sql);
ADODB_Session::_dumprs($rs);
$conn->SetFetchMode($savem);
if ($rs) {
$conn->BeginTrans();
$keys = array();
while (!$rs->EOF) {
$ref = $rs->fields[0];
$key = $rs->fields[1];
$fn($ref, $key);
$del = $conn->Execute("DELETE FROM $table WHERE sesskey='$key'");
$rs->MoveNext();
}
$rs->Close();
$conn->CommitTrans();
}
} else {
if (1) {
$sql = "SELECT sesskey FROM $table WHERE expiry < $time";
$arr =& $conn->GetAll($sql);
foreach ($arr as $row) {
$sql2 = "DELETE FROM $table WHERE sesskey='$row[0]'";
$conn->Execute($sql2);
}
} else {
$sql = "DELETE FROM $table WHERE expiry < $time";
$rs =& $conn->Execute($sql);
ADODB_Session::_dumprs($rs);
if ($rs) $rs->Close();
}
if ($debug) {
ADOConnection::outp("<p><b>Garbage Collection</b>: $sql</p>");
}
}
// suggested by Cameron, "GaM3R" <gamr@outworld.cx>
if ($optimize) {
$driver = ADODB_Session::driver();
if (preg_match('/mysql/i', $driver)) {
$sql = "OPTIMIZE TABLE $table";
}
if (preg_match('/postgres/i', $driver)) {
$sql = "VACUUM $table";
}
if (!empty($sql)) {
$conn->Execute($sql);
}
}
if ($sync_seconds) {
$sql = 'SELECT ';
if ($conn->dataProvider === 'oci8') {
$sql .= "TO_CHAR({$conn->sysTimeStamp}, 'RRRR-MM-DD HH24:MI:SS')";
} else {
$sql .= $conn->sysTimeStamp;
}
$sql .= " FROM $table";
$rs =& $conn->SelectLimit($sql, 1);
if ($rs && !$rs->EOF) {
$dbts = reset($rs->fields);
$rs->Close();
$dbt = $conn->UnixTimeStamp($dbts);
$t = time();
if (abs($dbt - $t) >= $sync_seconds) {
$msg = __FILE__ .
": Server time for webserver {$_SERVER['HTTP_HOST']} not in synch with database: " .
" database=$dbt ($dbts), webserver=$t (diff=". (abs($dbt - $t) / 60) . ' minutes)';
error_log($msg);
if ($debug) {
ADOConnection::outp("<p>$msg</p>");
}
}
}
}
return true;
}
}
ADODB_Session::_init();
register_shutdown_function('session_write_close');
// for backwards compatability only
function adodb_sess_open($save_path, $session_name, $persist = true) {
return ADODB_Session::open($save_path, $session_name, $persist);
}
// for backwards compatability only
function adodb_sess_gc($t)
{
return ADODB_Session::gc($t);
}
?>

View file

@ -0,0 +1,16 @@
-- $CVSHeader$
CREATE DATABASE /*! IF NOT EXISTS */ adodb_sessions;
USE adodb_sessions;
DROP TABLE /*! IF EXISTS */ sessions;
CREATE TABLE /*! IF NOT EXISTS */ sessions (
sesskey CHAR(32) /*! BINARY */ NOT NULL DEFAULT '',
expiry INT(11) /*! UNSIGNED */ NOT NULL DEFAULT 0,
expireref VARCHAR(64) DEFAULT '',
data LONGTEXT DEFAULT '',
PRIMARY KEY (sesskey),
INDEX expiry (expiry)
);

View file

@ -0,0 +1,16 @@
-- $CVSHeader$
DROP TABLE adodb_sessions;
CREATE TABLE sessions (
sesskey CHAR(32) DEFAULT '' NOT NULL,
expiry INT DEFAULT 0 NOT NULL,
expireref VARCHAR(64) DEFAULT '',
data VARCHAR(4000) DEFAULT '',
PRIMARY KEY (sesskey),
INDEX expiry (expiry)
);
CREATE INDEX ix_expiry ON sessions (expiry);
QUIT;

View file

@ -0,0 +1,161 @@
<?php
// Session Encryption by Ari Kuorikoski <ari.kuorikoski@finebyte.com>
class MD5Crypt{
function keyED($txt,$encrypt_key)
{
$encrypt_key = md5($encrypt_key);
$ctr=0;
$tmp = "";
for ($i=0;$i<strlen($txt);$i++){
if ($ctr==strlen($encrypt_key)) $ctr=0;
$tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
$ctr++;
}
return $tmp;
}
function Encrypt($txt,$key)
{
srand((double)microtime()*1000000);
$encrypt_key = md5(rand(0,32000));
$ctr=0;
$tmp = "";
for ($i=0;$i<strlen($txt);$i++)
{
if ($ctr==strlen($encrypt_key)) $ctr=0;
$tmp.= substr($encrypt_key,$ctr,1) .
(substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
$ctr++;
}
return base64_encode($this->keyED($tmp,$key));
}
function Decrypt($txt,$key)
{
$txt = $this->keyED(base64_decode($txt),$key);
$tmp = "";
for ($i=0;$i<strlen($txt);$i++){
$md5 = substr($txt,$i,1);
$i++;
$tmp.= (substr($txt,$i,1) ^ $md5);
}
return $tmp;
}
function RandPass()
{
$randomPassword = "";
srand((double)microtime()*1000000);
for($i=0;$i<8;$i++)
{
$randnumber = rand(48,120);
while (($randnumber >= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96))
{
$randnumber = rand(48,120);
}
$randomPassword .= chr($randnumber);
}
return $randomPassword;
}
}
class SHA1Crypt{
function keyED($txt,$encrypt_key)
{
$encrypt_key = sha1($encrypt_key);
$ctr=0;
$tmp = "";
for ($i=0;$i<strlen($txt);$i++){
if ($ctr==strlen($encrypt_key)) $ctr=0;
$tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
$ctr++;
}
return $tmp;
}
function Encrypt($txt,$key)
{
srand((double)microtime()*1000000);
$encrypt_key = sha1(rand(0,32000));
$ctr=0;
$tmp = "";
for ($i=0;$i<strlen($txt);$i++)
{
if ($ctr==strlen($encrypt_key)) $ctr=0;
$tmp.= substr($encrypt_key,$ctr,1) .
(substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
$ctr++;
}
return base64_encode($this->keyED($tmp,$key));
}
function Decrypt($txt,$key)
{
$txt = $this->keyED(base64_decode($txt),$key);
$tmp = "";
for ($i=0;$i<strlen($txt);$i++){
$sha1 = substr($txt,$i,1);
$i++;
$tmp.= (substr($txt,$i,1) ^ $sha1);
}
return $tmp;
}
function RandPass()
{
$randomPassword = "";
srand((double)microtime()*1000000);
for($i=0;$i<8;$i++)
{
$randnumber = rand(48,120);
while (($randnumber >= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96))
{
$randnumber = rand(48,120);
}
$randomPassword .= chr($randnumber);
}
return $randomPassword;
}
}
?>

View file

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<schema version="0.2">
<table name="sessions">
<desc>table for ADOdb session-management</desc>
<field name="SESSKEY" type="C" size="32">
<descr>session key</descr>
<KEY/>
<NOTNULL/>
</field>
<field name="EXPIRY" type="I" size="11">
<descr></descr>
<NOTNULL/>
</field>
<field name="EXPIREREF" type="C" size="64">
<descr></descr>
</field>
<field name="DATA" type="XL">
<descr></descr>
<NOTNULL/>
</field>
</table>
</schema>

View file

@ -0,0 +1,133 @@
<?php
/**
* @version V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Code to export recordsets in several formats:
*
* AS VARIABLE
* $s = rs2csv($rs); # comma-separated values
* $s = rs2tab($rs); # tab delimited
*
* TO A FILE
* $f = fopen($path,'w');
* rs2csvfile($rs,$f);
* fclose($f);
*
* TO STDOUT
* rs2csvout($rs);
*/
// returns a recordset as a csv string
function rs2csv(&$rs,$addtitles=true)
{
return _adodb_export($rs,',',',',false,$addtitles);
}
// writes recordset to csv file
function rs2csvfile(&$rs,$fp,$addtitles=true)
{
_adodb_export($rs,',',',',$fp,$addtitles);
}
// write recordset as csv string to stdout
function rs2csvout(&$rs,$addtitles=true)
{
$fp = fopen('php://stdout','wb');
_adodb_export($rs,',',',',true,$addtitles);
fclose($fp);
}
function rs2tab(&$rs,$addtitles=true)
{
return _adodb_export($rs,"\t",',',false,$addtitles);
}
// to file pointer
function rs2tabfile(&$rs,$fp,$addtitles=true)
{
_adodb_export($rs,"\t",',',$fp,$addtitles);
}
// to stdout
function rs2tabout(&$rs,$addtitles=true)
{
$fp = fopen('php://stdout','wb');
_adodb_export($rs,"\t",' ',true,$addtitles);
if ($fp) fclose($fp);
}
function _adodb_export(&$rs,$sep,$sepreplace,$fp=false,$addtitles=true,$quote = '"',$escquote = '"',$replaceNewLine = ' ')
{
if (!$rs) return '';
//----------
// CONSTANTS
$NEWLINE = "\r\n";
$BUFLINES = 100;
$escquotequote = $escquote.$quote;
$s = '';
if ($addtitles) {
$fieldTypes = $rs->FieldTypesArray();
reset($fieldTypes);
while(list(,$o) = each($fieldTypes)) {
$v = $o->name;
if ($escquote) $v = str_replace($quote,$escquotequote,$v);
$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
$elements[] = $v;
}
$s .= implode($sep, $elements).$NEWLINE;
}
$hasNumIndex = isset($rs->fields[0]);
$line = 0;
$max = $rs->FieldCount();
while (!$rs->EOF) {
$elements = array();
$i = 0;
if ($hasNumIndex) {
for ($j=0; $j < $max; $j++) {
$v = $rs->fields[$j];
if (!is_object($v)) $v = trim($v);
else $v = 'Object';
if ($escquote) $v = str_replace($quote,$escquotequote,$v);
$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote";
else $elements[] = $v;
}
} else { // ASSOCIATIVE ARRAY
foreach($rs->fields as $v) {
if ($escquote) $v = str_replace($quote,$escquotequote,trim($v));
$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote";
else $elements[] = $v;
}
}
$s .= implode($sep, $elements).$NEWLINE;
$rs->MoveNext();
$line += 1;
if ($fp && ($line % $BUFLINES) == 0) {
if ($fp === true) echo $s;
else fwrite($fp,$s);
$s = '';
}
}
if ($fp) {
if ($fp === true) echo $s;
else fwrite($fp,$s);
$s = '';
}
return $s;
}
?>

View file

@ -0,0 +1,195 @@
<?php
/*
V4.71 24 Jan 2006 (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Some pretty-printing by Chris Oxenreider <oxenreid@state.net>
*/
// specific code for tohtml
GLOBAL $gSQLMaxRows,$gSQLBlockRows,$ADODB_ROUND;
$ADODB_ROUND=4; // rounding
$gSQLMaxRows = 1000; // max no of rows to download
$gSQLBlockRows=20; // max no of rows per table block
// RecordSet to HTML Table
//------------------------------------------------------------
// Convert a recordset to a html table. Multiple tables are generated
// if the number of rows is > $gSQLBlockRows. This is because
// web browsers normally require the whole table to be downloaded
// before it can be rendered, so we break the output into several
// smaller faster rendering tables.
//
// $rs: the recordset
// $ztabhtml: the table tag attributes (optional)
// $zheaderarray: contains the replacement strings for the headers (optional)
//
// USAGE:
// include('adodb.inc.php');
// $db = ADONewConnection('mysql');
// $db->Connect('mysql','userid','password','database');
// $rs = $db->Execute('select col1,col2,col3 from table');
// rs2html($rs, 'BORDER=2', array('Title1', 'Title2', 'Title3'));
// $rs->Close();
//
// RETURNS: number of rows displayed
function rs2html(&$rs,$ztabhtml=false,$zheaderarray=false,$htmlspecialchars=true,$echo = true)
{
$s ='';$rows=0;$docnt = false;
GLOBAL $gSQLMaxRows,$gSQLBlockRows,$ADODB_ROUND;
if (!$rs) {
printf(ADODB_BAD_RS,'rs2html');
return false;
}
if (! $ztabhtml) $ztabhtml = "BORDER='1' WIDTH='98%'";
//else $docnt = true;
$typearr = array();
$ncols = $rs->FieldCount();
$hdr = "<TABLE COLS=$ncols $ztabhtml><tr>\n\n";
for ($i=0; $i < $ncols; $i++) {
$field = $rs->FetchField($i);
if ($field) {
if ($zheaderarray) $fname = $zheaderarray[$i];
else $fname = htmlspecialchars($field->name);
$typearr[$i] = $rs->MetaType($field->type,$field->max_length);
//print " $field->name $field->type $typearr[$i] ";
} else {
$fname = 'Field '.($i+1);
$typearr[$i] = 'C';
}
if (strlen($fname)==0) $fname = '&nbsp;';
$hdr .= "<TH>$fname</TH>";
}
$hdr .= "\n</tr>";
if ($echo) print $hdr."\n\n";
else $html = $hdr;
// smart algorithm - handles ADODB_FETCH_MODE's correctly by probing...
$numoffset = isset($rs->fields[0]) ||isset($rs->fields[1]) || isset($rs->fields[2]);
while (!$rs->EOF) {
$s .= "<TR valign=top>\n";
for ($i=0; $i < $ncols; $i++) {
if ($i===0) $v=($numoffset) ? $rs->fields[0] : reset($rs->fields);
else $v = ($numoffset) ? $rs->fields[$i] : next($rs->fields);
$type = $typearr[$i];
switch($type) {
case 'D':
if (empty($v)) $s .= "<TD> &nbsp; </TD>\n";
else if (!strpos($v,':')) {
$s .= " <TD>".$rs->UserDate($v,"D d, M Y") ."&nbsp;</TD>\n";
}
break;
case 'T':
if (empty($v)) $s .= "<TD> &nbsp; </TD>\n";
else $s .= " <TD>".$rs->UserTimeStamp($v,"D d, M Y, h:i:s") ."&nbsp;</TD>\n";
break;
case 'N':
if (abs($v) - round($v,0) < 0.00000001)
$v = round($v);
else
$v = round($v,$ADODB_ROUND);
case 'I':
$s .= " <TD align=right>".stripslashes((trim($v))) ."&nbsp;</TD>\n";
break;
/*
case 'B':
if (substr($v,8,2)=="BM" ) $v = substr($v,8);
$mtime = substr(str_replace(' ','_',microtime()),2);
$tmpname = "tmp/".uniqid($mtime).getmypid();
$fd = @fopen($tmpname,'a');
@ftruncate($fd,0);
@fwrite($fd,$v);
@fclose($fd);
if (!function_exists ("mime_content_type")) {
function mime_content_type ($file) {
return exec("file -bi ".escapeshellarg($file));
}
}
$t = mime_content_type($tmpname);
$s .= (substr($t,0,5)=="image") ? " <td><img src='$tmpname' alt='$t'></td>\\n" : " <td><a
href='$tmpname'>$t</a></td>\\n";
break;
*/
default:
if ($htmlspecialchars) $v = htmlspecialchars(trim($v));
$v = trim($v);
if (strlen($v) == 0) $v = '&nbsp;';
$s .= " <TD>". str_replace("\n",'<br>',stripslashes($v)) ."</TD>\n";
}
} // for
$s .= "</TR>\n\n";
$rows += 1;
if ($rows >= $gSQLMaxRows) {
$rows = "<p>Truncated at $gSQLMaxRows</p>";
break;
} // switch
$rs->MoveNext();
// additional EOF check to prevent a widow header
if (!$rs->EOF && $rows % $gSQLBlockRows == 0) {
//if (connection_aborted()) break;// not needed as PHP aborts script, unlike ASP
if ($echo) print $s . "</TABLE>\n\n";
else $html .= $s ."</TABLE>\n\n";
$s = $hdr;
}
} // while
if ($echo) print $s."</TABLE>\n\n";
else $html .= $s."</TABLE>\n\n";
if ($docnt) if ($echo) print "<H2>".$rows." Rows</H2>";
return ($echo) ? $rows : $html;
}
// pass in 2 dimensional array
function arr2html(&$arr,$ztabhtml='',$zheaderarray='')
{
if (!$ztabhtml) $ztabhtml = 'BORDER=1';
$s = "<TABLE $ztabhtml>";//';print_r($arr);
if ($zheaderarray) {
$s .= '<TR>';
for ($i=0; $i<sizeof($zheaderarray); $i++) {
$s .= " <TH>{$zheaderarray[$i]}</TH>\n";
}
$s .= "\n</TR>";
}
for ($i=0; $i<sizeof($arr); $i++) {
$s .= '<TR>';
$a = &$arr[$i];
if (is_array($a))
for ($j=0; $j<sizeof($a); $j++) {
$val = $a[$j];
if (empty($val)) $val = '&nbsp;';
$s .= " <TD>$val</TD>\n";
}
else if ($a) {
$s .= ' <TD>'.$a."</TD>\n";
} else $s .= " <TD>&nbsp;</TD>\n";
$s .= "\n</TR>\n";
}
$s .= '</TABLE>';
print $s;
}
?>

View file

@ -0,0 +1,39 @@
<?xml version="1.0"?>
<!DOCTYPE adodb_schema [
<!ELEMENT schema (table*, sql*)>
<!ATTLIST schema version CDATA #REQUIRED>
<!ELEMENT table ((field+|DROP), CONSTRAINT*, descr?, index*, data*)>
<!ELEMENT field ((NOTNULL|KEY|PRIMARY)?, (AUTO|AUTOINCREMENT)?, (DEFAULT|DEFDATE|DEFTIMESTAMP)?,
NOQUOTE?, CONSTRAINT*, descr?)>
<!ELEMENT data (row+)>
<!ELEMENT row (f+)>
<!ELEMENT f (#CDATA)>
<!ELEMENT descr (#CDATA)>
<!ELEMENT NOTNULL EMPTY>
<!ELEMENT KEY EMPTY>
<!ELEMENT PRIMARY EMPTY>
<!ELEMENT AUTO EMPTY>
<!ELEMENT AUTOINCREMENT EMPTY>
<!ELEMENT DEFAULT EMPTY>
<!ELEMENT DEFDATE EMPTY>
<!ELEMENT DEFTIMESTAMP EMPTY>
<!ELEMENT NOQUOTE EMPTY>
<!ELEMENT DROP EMPTY>
<!ELEMENT CONSTRAINT (#CDATA)>
<!ATTLIST table name CDATA #REQUIRED platform CDATA #IMPLIED version CDATA #IMPLIED>
<!ATTLIST field name CDATA #REQUIRED type (C|C2|X|X2|B|D|T|L|I|F|N) #REQUIRED size CDATA #IMPLIED>
<!ATTLIST data platform CDATA #IMPLIED>
<!ATTLIST f name CDATA #IMPLIED>
<!ATTLIST DEFAULT VALUE CDATA #REQUIRED>
<!ELEMENT index ((col+|DROP), CLUSTERED?, BITMAP?, UNIQUE?, FULLTEXT?, HASH?, descr?)>
<!ELEMENT col (#CDATA)>
<!ELEMENT CLUSTERED EMPTY>
<!ELEMENT BITMAP EMPTY>
<!ELEMENT UNIQUE EMPTY>
<!ELEMENT FULLTEXT EMPTY>
<!ELEMENT HASH EMPTY>
<!ATTLIST index name CDATA #REQUIRED platform CDATA #IMPLIED>
<!ELEMENT sql (query+, descr?)>
<!ELEMENT query (#CDATA)>
<!ATTLIST sql name CDATA #IMPLIED platform CDATA #IMPLIED, key CDATA, prefixmethod (AUTO|MANUAL|NONE) >
] >

View file

@ -0,0 +1,205 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
<!-- Schema -->
<xsl:template match="/">
<xsl:comment>
ADODB XMLSchema
http://adodb-xmlschema.sourceforge.net
</xsl:comment>
<xsl:element name="schema">
<xsl:attribute name="version">0.2</xsl:attribute>
<xsl:apply-templates select="schema/table|schema/sql"/>
</xsl:element>
</xsl:template>
<!-- Table -->
<xsl:template match="table">
<xsl:variable name="table_name" select="@name"/>
<xsl:element name="table">
<xsl:attribute name="name"><xsl:value-of select="$table_name"/></xsl:attribute>
<xsl:if test="string-length(@platform) > 0">
<xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
</xsl:if>
<xsl:if test="string-length(@version) > 0">
<xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates select="descr[1]"/>
<xsl:choose>
<xsl:when test="count(DROP) > 0">
<xsl:element name="DROP"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="field"/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="constraint"/>
<xsl:apply-templates select="../index[@table=$table_name]"/>
</xsl:element>
</xsl:template>
<!-- Field -->
<xsl:template match="field">
<xsl:element name="field">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
<xsl:if test="string-length(@size) > 0">
<xsl:attribute name="size"><xsl:value-of select="@size"/></xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="count(PRIMARY) > 0">
<xsl:element name="PRIMARY"/>
</xsl:when>
<xsl:when test="count(KEY) > 0">
<xsl:element name="KEY"/>
</xsl:when>
<xsl:when test="count(NOTNULL) > 0">
<xsl:element name="NOTNULL"/>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="count(AUTO) > 0">
<xsl:element name="AUTO"/>
</xsl:when>
<xsl:when test="count(AUTOINCREMENT) > 0">
<xsl:element name="AUTOINCREMENT"/>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="count(DEFAULT) > 0">
<xsl:element name="DEFAULT">
<xsl:attribute name="value">
<xsl:value-of select="DEFAULT[1]/@value"/>
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:when test="count(DEFDATE) > 0">
<xsl:element name="DEFDATE">
<xsl:attribute name="value">
<xsl:value-of select="DEFDATE[1]/@value"/>
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:when test="count(DEFTIMESTAMP) > 0">
<xsl:element name="DEFDTIMESTAMP">
<xsl:attribute name="value">
<xsl:value-of select="DEFTIMESTAMP[1]/@value"/>
</xsl:attribute>
</xsl:element>
</xsl:when>
</xsl:choose>
<xsl:if test="count(NOQUOTE) > 0">
<xsl:element name="NOQUOTE"/>
</xsl:if>
<xsl:apply-templates select="constraint"/>
</xsl:element>
</xsl:template>
<!-- Constraint -->
<xsl:template match="constraint">
<xsl:element name="constraint">
<xsl:value-of select="normalize-space(text())"/>
</xsl:element>
</xsl:template>
<!-- Index -->
<xsl:template match="index">
<xsl:element name="index">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:apply-templates select="descr[1]"/>
<xsl:if test="count(CLUSTERED) > 0">
<xsl:element name="CLUSTERED"/>
</xsl:if>
<xsl:if test="count(BITMAP) > 0">
<xsl:element name="BITMAP"/>
</xsl:if>
<xsl:if test="count(UNIQUE) > 0">
<xsl:element name="UNIQUE"/>
</xsl:if>
<xsl:if test="count(FULLTEXT) > 0">
<xsl:element name="FULLTEXT"/>
</xsl:if>
<xsl:if test="count(HASH) > 0">
<xsl:element name="HASH"/>
</xsl:if>
<xsl:choose>
<xsl:when test="count(DROP) > 0">
<xsl:element name="DROP"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="col"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<!-- Index Column -->
<xsl:template match="col">
<xsl:element name="col">
<xsl:value-of select="normalize-space(text())"/>
</xsl:element>
</xsl:template>
<!-- SQL QuerySet -->
<xsl:template match="sql">
<xsl:element name="sql">
<xsl:if test="string-length(@platform) > 0">
<xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
</xsl:if>
<xsl:if test="string-length(@key) > 0">
<xsl:attribute name="key"><xsl:value-of select="@key"/></xsl:attribute>
</xsl:if>
<xsl:if test="string-length(@prefixmethod) > 0">
<xsl:attribute name="prefixmethod"><xsl:value-of select="@prefixmethod"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates select="descr[1]"/>
<xsl:apply-templates select="query"/>
</xsl:element>
</xsl:template>
<!-- Query -->
<xsl:template match="query">
<xsl:element name="query">
<xsl:if test="string-length(@platform) > 0">
<xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
</xsl:if>
<xsl:value-of select="normalize-space(text())"/>
</xsl:element>
</xsl:template>
<!-- Description -->
<xsl:template match="descr">
<xsl:element name="descr">
<xsl:value-of select="normalize-space(text())"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,207 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
<!-- Schema -->
<xsl:template match="/">
<xsl:comment>
ADODB XMLSchema
http://adodb-xmlschema.sourceforge.net
</xsl:comment>
<xsl:element name="schema">
<xsl:attribute name="version">0.1</xsl:attribute>
<xsl:apply-templates select="schema/table|schema/sql"/>
</xsl:element>
</xsl:template>
<!-- Table -->
<xsl:template match="table">
<xsl:variable name="table_name" select="@name"/>
<xsl:element name="table">
<xsl:attribute name="name"><xsl:value-of select="$table_name"/></xsl:attribute>
<xsl:if test="string-length(@platform) > 0">
<xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
</xsl:if>
<xsl:if test="string-length(@version) > 0">
<xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates select="descr[1]"/>
<xsl:choose>
<xsl:when test="count(DROP) > 0">
<xsl:element name="DROP"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="field"/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="constraint"/>
</xsl:element>
<xsl:apply-templates select="index"/>
</xsl:template>
<!-- Field -->
<xsl:template match="field">
<xsl:element name="field">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
<xsl:if test="string-length(@size) > 0">
<xsl:attribute name="size"><xsl:value-of select="@size"/></xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="count(PRIMARY) > 0">
<xsl:element name="PRIMARY"/>
</xsl:when>
<xsl:when test="count(KEY) > 0">
<xsl:element name="KEY"/>
</xsl:when>
<xsl:when test="count(NOTNULL) > 0">
<xsl:element name="NOTNULL"/>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="count(AUTO) > 0">
<xsl:element name="AUTO"/>
</xsl:when>
<xsl:when test="count(AUTOINCREMENT) > 0">
<xsl:element name="AUTOINCREMENT"/>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="count(DEFAULT) > 0">
<xsl:element name="DEFAULT">
<xsl:attribute name="value">
<xsl:value-of select="DEFAULT[1]/@value"/>
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:when test="count(DEFDATE) > 0">
<xsl:element name="DEFDATE">
<xsl:attribute name="value">
<xsl:value-of select="DEFDATE[1]/@value"/>
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:when test="count(DEFTIMESTAMP) > 0">
<xsl:element name="DEFDTIMESTAMP">
<xsl:attribute name="value">
<xsl:value-of select="DEFTIMESTAMP[1]/@value"/>
</xsl:attribute>
</xsl:element>
</xsl:when>
</xsl:choose>
<xsl:if test="count(NOQUOTE) > 0">
<xsl:element name="NOQUOTE"/>
</xsl:if>
<xsl:apply-templates select="constraint"/>
</xsl:element>
</xsl:template>
<!-- Constraint -->
<xsl:template match="constraint">
<xsl:element name="constraint">
<xsl:value-of select="normalize-space(text())"/>
</xsl:element>
</xsl:template>
<!-- Index -->
<xsl:template match="index">
<xsl:element name="index">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="table"><xsl:value-of select="../@name"/></xsl:attribute>
<xsl:apply-templates select="descr[1]"/>
<xsl:if test="count(CLUSTERED) > 0">
<xsl:element name="CLUSTERED"/>
</xsl:if>
<xsl:if test="count(BITMAP) > 0">
<xsl:element name="BITMAP"/>
</xsl:if>
<xsl:if test="count(UNIQUE) > 0">
<xsl:element name="UNIQUE"/>
</xsl:if>
<xsl:if test="count(FULLTEXT) > 0">
<xsl:element name="FULLTEXT"/>
</xsl:if>
<xsl:if test="count(HASH) > 0">
<xsl:element name="HASH"/>
</xsl:if>
<xsl:choose>
<xsl:when test="count(DROP) > 0">
<xsl:element name="DROP"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="col"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<!-- Index Column -->
<xsl:template match="col">
<xsl:element name="col">
<xsl:value-of select="normalize-space(text())"/>
</xsl:element>
</xsl:template>
<!-- SQL QuerySet -->
<xsl:template match="sql">
<xsl:element name="sql">
<xsl:if test="string-length(@platform) > 0">
<xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
</xsl:if>
<xsl:if test="string-length(@key) > 0">
<xsl:attribute name="key"><xsl:value-of select="@key"/></xsl:attribute>
</xsl:if>
<xsl:if test="string-length(@prefixmethod) > 0">
<xsl:attribute name="prefixmethod"><xsl:value-of select="@prefixmethod"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates select="descr[1]"/>
<xsl:apply-templates select="query"/>
</xsl:element>
</xsl:template>
<!-- Query -->
<xsl:template match="query">
<xsl:element name="query">
<xsl:if test="string-length(@platform) > 0">
<xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
</xsl:if>
<xsl:value-of select="normalize-space(text())"/>
</xsl:element>
</xsl:template>
<!-- Description -->
<xsl:template match="descr">
<xsl:element name="descr">
<xsl:value-of select="normalize-space(text())"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
<!-- Schema -->
<xsl:template match="/">
<xsl:comment>
ADODB XMLSchema
http://adodb-xmlschema.sourceforge.net
</xsl:comment>
<xsl:comment>
Uninstallation Schema
</xsl:comment>
<xsl:element name="schema">
<xsl:attribute name="version">0.2</xsl:attribute>
<xsl:apply-templates select="schema/table">
<xsl:sort select="position()" data-type="number" order="descending"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<!-- Table -->
<xsl:template match="table">
<xsl:if test="count(DROP) = 0">
<xsl:element name="table">
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:if test="string-length(@platform) > 0">
<xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
</xsl:if>
<xsl:if test="string-length(@version) > 0">
<xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates select="descr[1]"/>
<xsl:element name="DROP"/>
</xsl:element>
</xsl:if>
</xsl:template>
<!-- Description -->
<xsl:template match="descr">
<xsl:element name="descr">
<xsl:value-of select="normalize-space(text())"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,106 @@
<?php
define("GALETTE_VERSION", "v0.62");
/*
*@author steve gricci
*@access public
*@skill beginner
*@site www.deepcode.net
*/
function utime ()
{
$time = explode( " ", microtime());
$usec = (double)$time[0];
$sec = (double)$time[1];
return $sec + $usec;
}
$start = utime();
include(WEB_ROOT."/includes/adodb/adodb.inc.php");
$DB = ADONewConnection(TYPE_DB);
$DB->debug = false;
if(!@$DB->Connect(HOST_DB, USER_DB, PWD_DB, NAME_DB)) die("No database connection...");
if (!defined("PREFIX_DB"))
define("PREFIX_DB","");
// Chargement des preferences
$result = $DB->Execute("SELECT * FROM ".PREFIX_DB."preferences");
if ($result != false) {
$result->MoveFirst();
while (!$result->EOF)
{
define(strtoupper($result->fields["nom_pref"]), $result->fields["val_pref"]);
$result->MoveNext();
}
$result->Close();
}
function get_echeance ($DB, $cotisant, $exempt_default="") {
if ($exempt_default=="")
{
$requete_cotis = "SELECT bool_exempt_adh
FROM ".PREFIX_DB."adherents
WHERE id_adh=" . $cotisant;
$resultat_cotis = $DB->Execute($requete_cotis);
if ($resultat_cotis->EOF)
$exempt="1";
else
$exempt=$resultat_cotis->fields[0];
$resultat_cotis->Close();
}
else
$exempt=$exempt_default;
// définition couleur pour adherent exempt de cotisation
if ($exempt=="1")
return "";
else
{
$requete_cotis = "SELECT *
FROM ".PREFIX_DB."cotisations
WHERE id_adh=" . $cotisant . "
ORDER BY date_cotis";
$resultat_cotis = $DB->Execute($requete_cotis);
$diff = 0;
$duree_old = 0;
$ts_old = 0;
while (!$resultat_cotis->EOF)
{
// difference avec date precedente
// timestamp actuel
list($a,$m,$j)=explode("-",$resultat_cotis->fields["date_cotis"]);
$ts = mktime(0,0,0,$m,$j,$a);
// duree cotisation courante (en s)
$duree = (mktime(0,0,0,$m+$resultat_cotis->fields["duree_mois_cotis"],$j,$a)-mktime(0,0,0,$m,$j,$a));
// diff = (date_prec + duree_prec + diff) - date_courante
$diff = ($ts_old + $duree_old + $diff)-$ts;
if ($diff < 0)
$diff = 0;
$ts_old = $ts;
$duree_old = $duree;
$resultat_cotis->MoveNext();
}
$resultat_cotis->Close();
if ($ts_old==0)
return "";
else
$cumul = intval((($ts_old + $duree_old + $diff)-time())/(3600*24));
}
//
// Fin du calcul du temps d'adhésion
//
$return_date = date("d/m/Y",time()+$cumul*3600*24);
return explode("/",$return_date);
}
?>

View file

@ -0,0 +1,150 @@
<?php
/* functions.inc.php
* - Fonctions utilitaires
* Copyright (c) 2003 Frédéric Jaqcuot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
function makeRandomPassword()
{
$pass = "";
$salt = "abcdefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 6)
{
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
function isSelected($champ1, $champ2) {
if ($champ1 == $champ2) {
echo " selected";
}
}
function isChecked($champ1, $champ2) {
if ($champ1 == $champ2) {
echo " checked";
}
}
function txt_sqls($champ) {
return "'".str_replace("'", "\'", str_replace('\\', '', $champ))."'";
}
function is_valid_web_url($url) {
return (preg_match(
'/^(http|https):\/\/'.
'.*/i', $url, $m
));
}
/*
*
* is_valid_email(): an e-mail validation utility routine
* Version 1.1.1 -- September 10, 2000
*
* Written by Michael A. Alderete
* Please send bug reports and improvements to: <michael@aldosoft.com>
*
* This function matches a proposed e-mail address against a validating
* regular expression. It's intended for use in web registration systems
* and other places where the user is inputting their e-mail address and
* you want to check that it's OK.
*
*/
function is_valid_email ($address) {
return (preg_match(
'/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+'. // the user name
'@'. // the ubiquitous at-sign
'([-0-9A-Z]+\.)+' . // host, sub-, and domain names
'([0-9A-Z]){2,4}$/i', // top-level domain (TLD)
trim($address)));
}
function dblog($text, $query="")
{
if (PREF_LOG=="2")
{
$requete = "INSERT INTO ".PREFIX_DB."logs (date_log, ip_log, adh_log, text_log) VALUES (" . $GLOBALS["DB"]->DBTimeStamp(time()) . ", " . $GLOBALS["DB"]->qstr($_SERVER["REMOTE_ADDR"]) . ", " . $GLOBALS["DB"]->qstr($_SESSION["logged_nom_adh"]) . ", " . $GLOBALS["DB"]->qstr($text."\n".$query) . ");";
$GLOBALS["DB"]->Execute($requete);
}
elseif (PREF_LOG=="1")
{
$requete = "INSERT INTO ".PREFIX_DB."logs (date_log, ip_log, adh_log, text_log) VALUES (" . $GLOBALS["DB"]->DBTimeStamp(time()) . ", " . $GLOBALS["DB"]->qstr($_SERVER["REMOTE_ADDR"]) . ", " . $GLOBALS["DB"]->qstr($_SESSION["logged_nom_adh"]) . ", " . $GLOBALS["DB"]->qstr($text) . ");";
$GLOBALS["DB"]->Execute($requete);
}
}
function resizeimage($img,$img2,$w,$h)
{
if (function_exists("imagecreate"))
{
$ext = substr($img,-4);
$imagedata = getimagesize($img);
$ratio = $imagedata[0]/$imagedata[1];
if ($imagedata[0]>$imagedata[1])
$h = $w/$ratio;
else
$w = $h*$ratio;
$thumb = imagecreate ($w, $h);
switch($ext)
{
case ".jpg":
$image = ImageCreateFromJpeg($img);
imagecopyresized ($thumb, $image, 0, 0, 0, 0, $w, $h, $imagedata[0], $imagedata[1]);
imagejpeg($thumb, $img2);
break;
case ".png":
$image = ImageCreateFromPng($img);
imagecopyresized ($thumb, $image, 0, 0, 0, 0, $w, $h, $imagedata[0], $imagedata[1]);
imagepng($thumb, $img2);
break;
case ".gif":
if (function_exists("imagegif"))
{
$image = ImageCreateFromGif($img);
imagecopyresized ($thumb, $image, 0, 0, 0, 0, $w, $h, $imagedata[0], $imagedata[1]);
imagegif($thumb, $img2);
}
break;
}
}
}
function custom_html_entity_decode( $given_html, $quote_style = ENT_QUOTES )
{
$trans_table = array_flip(get_html_translation_table( HTML_ENTITIES, $quote_style ));
$trans_table['&#39;'] = "'";
return ( strtr( $given_html, $trans_table ) );
}
?>

View file

@ -0,0 +1,13 @@
<?php
include(WEB_ROOT."lang/lang_".PREF_LANG.".php");
function _T($chaine)
{
// echo "$chaine";die();
if (!isset($GLOBALS["lang"][$chaine]))
return $chaine." (not translated)";
elseif ($GLOBALS["lang"][$chaine]=="")
return $chaine." (not translated)";
else
return $GLOBALS["lang"][$chaine];
}
?>

View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View file

@ -0,0 +1,130 @@
<?php
/*
php pdf chart generation library
Copyright (C) Potential Technologies 2002 - 2003
http://www.potentialtech.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: chart.class.php 7 2004-02-11 20:44:53Z gruiick $
*/
class chart
{
var $colors; // global colors
var $series; // Array of series
var $pdf; // reference to the parent class
function chart()
{
$this->clearchart();
}
function clearchart()
{
// Default colors
unset($this->colors);
// This oughta make things more readible
$white['red'] = $white['green'] = $white['blue'] = 1;
$black['red'] = $black['green'] = $black['blue'] = 0;
$this->colors['background'] = $white;
$this->colors['border'] = $black;
$this->colors['hlabel'] = $black;
$this->colors['vlabel'] = $black;
$this->colors['vgrade'] = $black;
$this->colors['hgrade'] = $black;
unset($this->series);
}
/* Set up default colors to use globally on the chart
*/
function setcolor($name, $red, $green, $blue)
{
$this->colors[$name]['red'] = $red;
$this->colors[$name]['green'] = $green;
$this->colors[$name]['blue'] = $blue;
}
function add_series($name, $points, $color = 'black', $width = 1, $style = 'default')
{
$t['points'] = $points;
$t['color'] = $color;
$t['width'] = $width;
$t['style'] = $style;
$this->series[$name] = $t;
}
function place_chart($page, $left, $bottom, $width, $height, $type = 'line')
{
switch (strtolower($type)) {
case 'pie' :
case '3dpie' :
case 'bar' :
case '3dbar' :
case '3dline' :
case 'line' :
default :
$this->_place_line_chart($page, $left, $bottom, $width, $height);
}
}
function _place_line_chart($page, $left, $bottom, $width, $height)
{
// First a filled rectangle to set background color
$this->_fill_background($page, $left, $bottom, $width, $height);
// caclulate a scale
$low = $high = $numx = 0;
foreach($this->series as $data) {
foreach($data['points'] as $value) {
if ($value < $low) $low = $value;
if ($value > $high) $high = $value;
}
if (count($data['points']) > $numx) $numx = count($data);
}
if (($high - $low) <= 0) return false;
$xscale = $width / $numx;
$yscale = $height / ($high - $low);
foreach($this->series as $data) {
$a['strokecolor'] = $this->pdf->get_color($data['color']);
$a['width'] = $data['width'];
$c = 0;
unset($x);
unset($y);
foreach ($data['points'] as $value) {
$x[$c] = ($c * $xscale) + $left;
//echo $x[$c] . " ";
$y[$c] = (($value - $low) * $yscale) + $bottom;
//echo $y[$c] . "<br>\n";
$c++;
}
$this->pdf->draw_line($x, $y, $page, $a);
}
}
function _fill_background($page, $left, $bottom, $width, $height)
{
$a['fillcolor'] = $this->colors['background'];
$a['mode'] = 'fill';
$this->pdf->draw_rectangle($bottom + $height,
$left,
$bottom,
$left + $width,
$page,
$a);
}
}
?>

View file

@ -0,0 +1,443 @@
<?php
/*
php pdf generation library - import extension
Copyright (C) Potential Technologies 2002 - 2003
http://www.potentialtech.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: import.class.php 7 2004-02-11 20:44:53Z gruiick $
*/
class import
{
var $pdf; // reference to the parent class
var $xref; // Array holding the xref table data
var $pdftolib; // Array storing conversions from PDF to library OID
var $d; // store the PDF stream object here
var $ob; // Array of data on each PDF object
// Actually append the specified PDF to the end of the current
function append($data)
{
// Basic magic check
if (substr($data, 0, 6) != '%PDF-1') {
echo "Bad magic\n";
return false;
}
$this->xref =
$this->pdftolib =
$this->ob = array();
$this->d = new StreamHandler($data);
if (!$this->capture_xref()) {
echo "Couldn't find xref\n";
return false;
}
foreach ($this->xref as $pdfid => $junk) {
$this->extract($pdfid);
}
foreach ($this->ob as $id => $junk) {
$this->import_ob($id);
}
$root = $this->find_root();
$this->recursive_create($root);
return true;
}
function capture_xref()
{
$data = &$this->d;
// First we find the start of the xref
$data->end();
while ($data->previous_word() != 'startxref')
;
// Now we capture where the xref starts
$data->next_word(); // slurp 'startxref'
$xref = $data->next_word();
$data->l = (int)$xref;
echo "found xref at $xref<br>\n";
if ($data->next_word() != 'xref') {
echo "Proposed xref location was bogus: $xref\n";
return false;
}
$firstx = $data->next_word();
$numx = $data->next_word();
echo "firstx=$firstx, numx=$numx<br>\n";
for ($i = $firstx; $i < $firstx + $numx; $i++) {
$loc = $data->next_word();
$gen = $data->next_word();
if ($data->next_word() == 'n') {
$this->xref[$i] = $loc;
}
}
return true;
}
function find_root()
{
// Find trailer
$d = &$this->d;
$d->end();
while ($d->previous_word() != 'trailer')
;
while ($d->next_word() != '/Root')
;
return $d->next_word();
}
function recursive_create($id)
{
if (!isset($this->ob[$id]['/Type'])}
$this->ob[$id]['/Type'] = '';
switch ($this->ob[$id]['/Type']) {
case '/Info' :
return false;
break;
case '/Root' :
return $this->
break;
}
}
function extract($id)
{
if (!isset($this->ob[$id])) {
$location = $this->xref[$id];
$data = &$this->d;
$data->l = $location;
$id = $data->next_word();
$gn = $data->next_word();
echo "Found $id $gn R at $location<br>\n";
flush();
$this->extract_obj($id);
}
return $this->ob[$id];
}
function extract_obj($id)
{
$d = &$this->d;
// Magic test
if ($d->next_word() != 'obj') {
echo "Didn't find an object here!<br>\n";
return false;
}
$this->ob[$id]['value'] = '';
while (true) {
$d->skip_whitespace();
if (substr($d->d, $d->l, 2) == '<<') {
echo "Found a dictionary<br>\n";
$this->ob[$id] = $this->extract_dictionary();
} else {
$w = $d->next_word();
if ($w == 'endobj') break;
if ($w == 'stream') {
echo "Found a stream: {$d->l}<br>\n";
$d->l -= 6;
$this->ob[$id]['stream'] =
$this->extract_stream($this->ob[$id]);
} else {
// Must be a raw value
echo "Assuming a raw value in object<br>\n";
$this->ob[$id]['value'] .= $w . ' ';
}
}
}
echo "<pre>\n";
print_r($this->ob[$id]);
echo "</pre>\n";
}
function extract_dictionary()
{
$d = &$this->d;
if (substr($d->d, $d->l, 2) != '<<') {
echo "Didn't find a dictionary here!<br>\n";
return array();
}
$d->l += 2; // Slurp the '<<'
$r = array();
$r['itype'] = 'dictionary';
$label = false;
$state = array();
while (true) {
$d->skip_whitespace();
if (substr($d->d, $d->l, 2) == '>>') {
echo "Found end of dictionary<br>\n";
$d->l += 2;
if (count($state) > 0) {
$r[$l] = '';
foreach ($state as $v) {
$r[$l] .= $v . ' ';
echo "Popping remainer of stack for [$l] = '{$r[$l]}'<br>\n";
}
}
break;
}
if (substr($d->d, $d->l, 2) == '<<') {
echo "Found subdictionary<br>\n";
$r[$l] = $this->extract_dictionary();
$label = false;
continue;
}
if (substr($d->d, $d->l, 1) == '[') {
echo "Analyzing array '" . substr($d->d, $d->l, 15) .
"...' for [$l]<br>\n";
$r[$l] = $d->get_array();
$label = false;
continue;
}
$w = $d->next_word();
if (!$label) {
echo "Making '$w' a label<br>\n";
$label = true;
$l = $w;
} else {
echo "Current character = '" . $d->cc() . "'<br>\n";
if ($w{0} == '/') {
if (!isset($state[0])) {
echo "Assigning '$w' as value of [$l]<br>\n";
$r[$l] = $w;
} else {
$d->rewind();
echo "Popping the stack for [$l]<br>\n";
$r[$l] = $state[0];
$state = array();
}
} else if ($w{0} == '(' && $w{strlen($w) - 1} == ')') {
// We've got a string
echo "Assigning string value '$w' to [$l]<br>\n";
$r[$l] = $w;
} else if ($w == 'R') {
$ir = $state[0] . ' ' . $state[1] . ' R';
echo "Stored IR $ir<br>\n";
$r[$l] = $ir;
$state = array();
} else {
// Push this on the stack
echo "pushing '$w' on the stack<br>\n";
$state[] = $w;
continue;
}
$label = false;
}
}
return $r;
}
function extract_stream($meta)
{
$d = &$this->d;
$t = $d->next_word();
if ($t == 'stream') {
if ($d->strpos($meta['/Length'], 'R')) {
// We must resolve an indirect reference
echo "Resolving IR for /Length<br>\n";
$t = $d->l;
$this->extract((int)$meta['/Length']);
$d->l = $t;
$length = $this->ob[(int)$meta['/Length']]['value'];
} else {
$length = (int)$meta['/Length'];
}
echo "Stream should be {$length}<br>\n";
$stream = substr($d->d, $d->l + 1, $length);
$d->l += 1 + $length;
$d->next_word(); // Consume "endstream"
if (!isset($meta['/Filter'])) $meta['/Filter'] = '';
$r = new StreamHandler($stream, $meta['/Filter']);
return $r;
} else {
echo "I didn't find a stream here: '$t'<br>\n";
$d->rewind();
return '';
}
}
}
class StreamHandler
{
var $d;
var $l;
function StreamHandler($stream, $filter = '')
{
$this->l = 0;
if ($this->strpos($filter, 'FlateDecode')) {
$this->d = trim(gzuncompress($stream)) . "\n";
} else {
$this->d = trim($stream) . "\n";
}
}
function get_array()
{
$s = new StreamHandler($this->read_array());
echo "Got array of '" . $s->d . "'<br>\n";
$r = array();
$r['itype'] = 'array';
$as = array();
while ($s->l < strlen($s->d) - 1) {
$c = $s->next_word();
if ($c == 'R') {
$t = $as[0] . ' ' . $as[1] . ' R';
$r[] = $t;
$as = array();
} else {
$as[] = $c;
}
}
return array_merge($r, $as);
}
function read_array()
{
$this->back_to_array();
if ($this->cc() != '[') {
// No array here
echo "I don't see an array: '" .
substr($this->d, $this->l, 15) . "...'<br>\n";
return '';
}
$this->next();
$r = '';
do {
$r .= $this->cc();
$this->l++;
} while ($this->cc() != ']');
$this->next();
return $r;
}
function back_to_array()
{
if ($this->cc() != '[') {
$this->l--;
}
}
function end()
{
$this->l = strlen($this->d) - 1;
}
function start()
{
$this->l = 0;
}
function next_word()
{
$this->skip_whitespace();
$r = '';
// Slurp a PDF string
if ($this->cc() == '(') {
while ($this->cc() != ')' || $this->cc($this->l - 1) == '\\') {
$r .= $this->cc();
$this->next();
}
$r .= $this->cc();
$this->next();
return $r;
}
do {
$r .= $this->cc();
$this->next();
} while (!$this->is_whitespace() &&
!$this->boundry() &&
$this->l < strlen($this->d));
return $r;
}
function previous_word()
{
$this->rewind();
$r = $this->next_word();
$this->rewind();
return $r;
}
// Backs up 1 word
function rewind()
{
$this->skip_whitespace(false);
do {
$this->l--;
} while (!$this->is_whitespace() && !$this->boundry());
}
function skip_whitespace($forward = true)
{
while ($this->is_whitespace()) {
if ($forward) {
$this->next();
} else {
$this->l--;
}
if ($this->l == 0 || $this->l == (strlen($this->d) - 1)) break;
}
return $this->l;
}
function boundry($c = false)
{
if ($c === false) $c = $this->cc();
if ($this->strpos('()/><[]', $c)) {
return true;
} else {
return false;
}
}
function is_whitespace($c = '')
{
if ($c == '') $c = $this->cc();
if ($c == ' ' ||
$c == "\x0a" ||
$c == "\x0d" ||
$c == "\t") {
return true;
} else {
return false;
}
}
// Returns current byte (character)
function cc($l = false)
{
if ($l === false) $l = $this->l;
return $this->d{$l};
}
function next()
{
$this->l++;
if ($this->l >= strlen($this->d)) {
echo "fell off the end!<br>\n";
$this->end();
}
}
function strpos($haystack, $needle)
{
if (strpos($haystack, $needle) === false) {
return false;
} else {
return true;
}
}
}
?>

View file

@ -0,0 +1,357 @@
<?php
/*
php pdf generation library - template extension
Copyright (C) Potential Technologies 2002 - 2003
http://www.potentialtech.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: packer.class.php 7 2004-02-11 20:44:53Z gruiick $
*/
/* The packer class should allow automatic placement of objects
* and automatic creation of new pages. (wish me luck)
*/
/* This is a class for the field object itself
*/
class packer
{
var $pdf, // reference to the parent class
$curpage = false, // Current page ID
$fields = array(); // Array of available fields
function packer()
{
// Initialize the extension
}
/* This is a wrapper around the pdffile class' ->new_page()
* that saves the relevent information for packer operation
*/
function new_page()
{
$this->curpage = $this->pdf->new_page();
$right = $this->pdf->objects[$this->curpage]['width'] -
$this->pdf->default['margin-right'];
$top = $this->pdf->objects[$this->curpage]['height'] -
$this->pdf->default['margin-top'];
$this->fields[] = $this->newfield($this->pdf->default['margin-left'],
$right,
$this->pdf->default['margin-bottom'],
$top);
foreach (array('margin-left',
'margin-right',
'margin-top',
'margin-bottom') as $margin) {
$this->pdf->objects[$this->curpage][$margin] = 0;
}
return $this->curpage;
}
/* Fill text into the remaining space.
* padding is in ems
* minwidth is in ems, current defaults are used for all parameters
*/
function fill_text($text, $padding = 1, $minwidth = 10)
{
$ignore = array();
$m = $this->pdf->strlen('M');
$w = $minwidth * $m;
$p = $m * $padding;
while (strlen($text)) {
$r = $this->find_upper_left($ignore);
if ($r === false) break;
$f = $this->fields[$r];
if (($f->r - $f->l - (2 * $p)) <= $w) {
$ignore[] = $r;
continue;
}
$text = $this->pdf->draw_paragraph($f->t - $p, $f->l + $p,
$f->b + $p, $f->r - $p,
$text, $this->curpage);
if (is_string($text)) {
unset($this->fields[$r]);
$this->fields_cleanup();
} else {
$this->fields[$r]->t = $text;
$this->fields_cleanup();
break;
}
}
if (is_string($text))
return $text;
else
return true;
}
/* Here we manually allocate a set region from the fields
* This is likely to be the foundation of everything else that's
* done in this class. $space is a 'field' object.
*/
function allocate($space)
{
foreach ($this->fields as $fid => $field) {
if (!$space->intersects($field)) continue;
if ($space->obliterates($field)) {
unset($this->fields[$fid]);
$this->fields_cleanup();
continue;
}
if ($space->punches($field)) {
$this->punch($space, $fid);
continue;
}
if (($n = $space->notches($field)) != 0) {
$this->notch($space, $fid, $n);
}
}
$this->merge();
}
// Punch a hole in $target
function punch($hole, $target) {
$t = $this->fields[$target];
$this->newfield($hole->l, $hole->r, $t->t, $hole->t); // top
$this->newfield($hole->l, $hole->r, $t->b, $hole->b); // bottom
$this->newfield($t->l, $hole->l, $t->t, $t->b); // left
$this->fields[$target]->l = $hole->r; // right
$this->fields_cleanup();
}
/* Don't call this unless you've already established the operation to
* be a notch, behaviour is undefined otherwise.
*/
function notch($hole, $target, $how) {
$t = &$this->fields[$target];
// 3 scenerios
if ($how == 1 || $how == 2 || $how == 4 || $how == 8) {
// Side notch
switch ($how) {
case 1 : // Bottom
$this->newfield($t->l, $hole->l, $t->t, $t->b);
$this->newfield($t->r, $hole->r, $t->t, $t->b);
$t->l = $hole->l;
$t->r = $hole->r;
$t->b = $hole->t;
break;
case 4 : // Top
$this->newfield($t->l, $hole->l, $t->t, $t->b);
$this->newfield($t->r, $hole->r, $t->t, $t->b);
$t->l = $hole->l;
$t->r = $hole->r;
$t->t = $hole->b;
break;
case 2 : // Left
$this->newfield($t->l, $hole->r, $t->t, $hole->t);
$this->newfield($t->l, $hole->r, $hole->b, $t->b);
$t->l = $hole->r;
break;
case 8 : // Right
$this->newfield($t->r, $hole->l, $t->t, $hole->t);
$this->newfield($t->r, $hole->l, $hole->b, $t->b);
$t->r = $hole->l;
break;
}
} else if ($how == 3 || $how == 6 || $how == 12 || $how == 9) {
// Corner notch
if (($how & 2) == 2) { // Notching left side
if (($how & 4) == 4) { // left top
$this->newfield($t->l, $hole->r, $hole->b, $t->b);
} else { // left bottom
$this->newfield($t->l, $hole->r, $hole->t, $t->t);
}
$t->l = $hole->r;
} else { // notching right side
if (($how & 4) == 4) { // right top
$this->newfield($t->r, $hole->l, $hole->b, $t->b);
} else { // right bottom
$this->newfield($t->r, $hole->l, $hole->t, $t->t);
}
$t->r = $hole->l;
}
} else {
// We assume it must be a chop
switch ($how) {
case 11 : // bottom
$t->b = $hole->t; break;
case 7 : // left
$t->l = $hole->r; break;
case 14 : // top
$t->t = $hole->b; break;
case 13 : // right
$t->r = $hold->l; break;
default : // error
$this->pdf->push_error(666, 'notch encountered invalid chop');
}
}
}
function find_upper_left($ignore = array())
{
if (!count($this->fields)) return false;
$r = false;
$top = $this->pdf->objects[$this->curpage]['height'];
$dist = $this->dist($top, $this->pdf->objects[$this->curpage]['width']);
foreach ($this->fields as $fid => $f) {
if (in_array($fid, $ignore)) continue;
$tdist = $this->dist($top - $f->t, $f->l);
if ($tdist < $dist) {
$r = $fid;
$dist = $tdist;
}
}
return $r;
}
function dist($x, $y)
{
return pow(pow($x, 2) + pow($y, 2), 0.5);
}
/* Scan the array of regions for regions that share an exactly equal border
* and can thus be joined without altering the function of things.
*/
function merge()
{
foreach ($this->fields as $fid1 => $f1) {
foreach ($this->fields as $fid2 => $f2) {
if ($f1->l == $f2->r && $f1->t == $f2->t && $f1->b == $f2->b) {
$this->fields[$fid1]->l = $f2->l;
unset($this->fields[$fid2]);
}
if ($f1->r == $f2->l && $f1->t == $f2->t && $f1->b == $f2->b) {
$this->fields[$fid1]->r = $f2->r;
unset($this->fields[$fid2]);
}
if ($f1->t == $f2->b && $f1->l == $f2->l && $f1->l == $f2->l) {
$this->fields[$fid1]->t = $f2->t;
unset($this->fields[$fid2]);
}
if ($f1->b == $f2->t && $f1->l == $f2->l && $f1->l == $f2->l) {
$this->fields[$fid1]->b = $f2->b;
unset($this->fields[$fid2]);
}
}
}
$this->fields_cleanup();
}
function newfield($l, $r, $t, $b)
{
$temp = new field($l, $r, $t, $b);
$this->fields[] = $temp;
}
/* PHP seems to have a lot of trouble not messing up its arrays. Some
* operations leave gaps in the array that I wouldn't have expected to do
* so. In lieu of having to contstantly check for gaps in the array prior
* to processing, I call this to remove them whenever I identify an
* operation that can cause gaps. Hopefully I'll find a better way to
* handle this, as this seems like a hack to me.
*/
function fields_cleanup()
{
$t = array();
foreach ($this->fields as $f) {
if (is_object($f)) {
$t[] = $f;
}
}
$this->fields = $t;
reset($this->fields);
}
}
class field
{
var $l, $r, $t, $b; // left, right, top, bottom
function field($x1, $x2, $y1, $y2)
{
if ($x1 < $x2) {
$this->l = $x1;
$this->r = $x2;
} else {
$this->l = $x2;
$this->r = $x1;
}
if ($y1 < $y2) {
$this->t = $y2;
$this->b = $y1;
} else {
$this->t = $y1;
$this->b = $y2;
}
}
// Return true if any part of me includes $target
function intersects($target)
{
if ($this->t <= $target->b) return false;
if ($this->b >= $target->t) return false;
if ($this->l >= $target->r) return false;
if ($this->r <= $target->l) return false;
return true;
}
// Returns true if this field completely covers $target
function obliterates($target)
{
if ($this->l <= $target->l &&
$this->r >= $target->r &&
$this->t >= $target->t &&
$this->b <= $target->b) {
return true;
} else {
return false;
}
}
// Returns true if this field punches a hole in $target
function punches($target) {
if ($this->l > $target->l &&
$this->r < $target->r &&
$this->t < $target->t &&
$this->b > $target->b) {
return true;
} else {
return false;
}
}
/* Returns a bitmap of notches in $target
* 0 = no notches
* 1 = notches bottom
* 2 = notches left
* 4 = notches top
* 8 = notches right
*/
function notches($target) {
$notch = 0;
if ($this->t > $target->b && $this->b <= $target->b) $notch = 1;
if ($this->r > $target->l && $this->l <= $target->l) $notch += 2;
if ($this->b < $target->t && $this->t >= $target->t) $notch += 4;
if ($this->l < $target->r && $this->r >= $target->r) $notch += 8;
return $notch;
}
}
?>

View file

@ -0,0 +1,290 @@
<?php
/*
php pdf generation library
Copyright (C) Potential Technologies 2002 - 2003
http://www.potentialtech.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: strlen.inc.php 7 2004-02-11 20:44:53Z gruiick $
*/
$this->needsset = false;
$this->widths['Symbol']= array ( 32 => 250, 33 => 333, 34 => 713, 35 => 500, 36 => 549,
37 => 833, 38 => 778, 39 => 439, 40 => 333, 41 => 333,
42 => 500, 43 => 549, 44 => 250, 45 => 549, 46 => 250,
47 => 278, 48 => 500, 49 => 500, 50 => 500, 51 => 500,
52 => 500, 53 => 500, 54 => 500, 55 => 500, 56 => 500,
57 => 500, 58 => 278, 59 => 278, 60 => 549, 61 => 549,
62 => 549, 63 => 444, 64 => 549, 65 => 722, 66 => 667,
67 => 722, 68 => 612, 69 => 611, 70 => 763, 71 => 603,
72 => 722, 73 => 333, 74 => 631, 75 => 722, 76 => 686,
77 => 889, 78 => 722, 79 => 722, 80 => 768, 81 => 741,
82 => 556, 83 => 592, 84 => 611, 85 => 690, 86 => 439,
87 => 768, 88 => 645, 89 => 795, 90 => 611, 91 => 333,
92 => 863, 93 => 333, 94 => 658, 95 => 500, 96 => 500,
97 => 631, 98 => 549, 99 => 549, 100 => 494, 101 => 439,
102 => 521, 103 => 411, 104 => 603, 105 => 329, 106 => 603,
107 => 549, 108 => 549, 109 => 576, 110 => 521, 111 => 549,
112 => 549, 113 => 521, 114 => 549, 115 => 603, 116 => 439,
117 => 576, 118 => 713, 119 => 686, 120 => 493, 121 => 686,
122 => 494, 123 => 480, 124 => 200, 125 => 480, 126 => 549,
161 => 620, 162 => 247, 163 => 549, 164 => 167, 165 => 713,
166 => 500, 167 => 753, 168 => 753, 169 => 753, 170 => 753,
171 => 1042, 172 => 987, 173 => 603, 174 => 987, 175 => 603,
176 => 400, 177 => 549, 178 => 411, 179 => 549, 180 => 549,
181 => 713, 182 => 494, 183 => 460, 184 => 549, 185 => 549,
186 => 549, 187 => 549, 188 => 1000, 189 => 603, 190 => 1000,
191 => 658, 192 => 823, 193 => 686, 194 => 795, 195 => 987,
196 => 768, 197 => 768, 198 => 823, 199 => 768, 200 => 768,
201 => 713, 202 => 713, 203 => 713, 204 => 713, 205 => 713,
206 => 713, 207 => 713, 208 => 768, 209 => 713, 210 => 790,
211 => 790, 212 => 890, 213 => 823, 214 => 549, 215 => 250,
216 => 713, 217 => 603, 218 => 603, 219 => 1042, 220 => 987,
221 => 603, 222 => 987, 223 => 603, 224 => 494, 225 => 329,
226 => 790, 227 => 790, 228 => 786, 229 => 713, 230 => 384,
231 => 384, 232 => 384, 233 => 384, 234 => 384, 235 => 384,
236 => 494, 237 => 494, 238 => 494, 239 => 494, 241 => 329,
242 => 274, 243 => 686, 244 => 686, 245 => 686, 246 => 384,
247 => 384, 248 => 384, 249 => 384, 250 => 384, 251 => 384,
252 => 494, 253 => 494, 254 => 494 );
$this->widths['Dingbats'] = array (32 => 278, 33 => 974, 34 => 961, 35 => 974, 36 => 980,
37 => 719, 38 => 789, 39 => 790, 40 => 791, 41 => 690,
42 => 960, 43 => 939, 44 => 549, 45 => 855, 46 => 911,
47 => 933, 48 => 911, 49 => 945, 50 => 974, 51 => 755,
52 => 846, 53 => 762, 54 => 761, 55 => 571, 56 => 677,
57 => 763, 58 => 760, 59 => 759, 60 => 754, 61 => 494,
62 => 552, 63 => 537, 64 => 577, 65 => 692, 66 => 786,
67 => 788, 68 => 788, 69 => 790, 70 => 793, 71 => 794,
72 => 816, 73 => 823, 74 => 789, 75 => 841, 76 => 823,
77 => 833, 78 => 816, 79 => 831, 80 => 923, 81 => 744,
82 => 723, 83 => 749, 84 => 790, 85 => 792, 86 => 695,
87 => 776, 88 => 768, 89 => 792, 90 => 759, 91 => 707,
92 => 708, 93 => 682, 94 => 701, 95 => 826, 96 => 815,
97 => 789, 98 => 789, 99 => 707, 100 => 687, 101 => 696,
102 => 689, 103 => 786, 104 => 787, 105 => 713, 106 => 791,
107 => 785, 108 => 791, 109 => 873, 110 => 761, 111 => 762,
112 => 762, 113 => 759, 114 => 759, 115 => 892, 116 => 892,
117 => 788, 118 => 784, 119 => 438, 120 => 138, 121 => 277,
122 => 415, 123 => 392, 124 => 392, 125 => 668, 126 => 668,
161 => 732, 162 => 544, 163 => 544, 164 => 910, 165 => 667,
166 => 760, 167 => 760, 168 => 776, 169 => 595, 170 => 694,
171 => 626, 172 => 788, 173 => 788, 174 => 788, 175 => 788,
176 => 788, 177 => 788, 178 => 788, 179 => 788, 180 => 788,
181 => 788, 182 => 788, 183 => 788, 184 => 788, 185 => 788,
186 => 788, 187 => 788, 188 => 788, 189 => 788, 190 => 788,
191 => 788, 192 => 788, 193 => 788, 194 => 788, 195 => 788,
196 => 788, 197 => 788, 198 => 788, 199 => 788, 200 => 788,
201 => 788, 202 => 788, 203 => 788, 204 => 788, 205 => 788,
206 => 788, 207 => 788, 208 => 788, 209 => 788, 210 => 788,
211 => 788, 212 => 894, 213 => 838, 214 => 1016, 215 => 458,
216 => 748, 217 => 924, 218 => 748, 219 => 918, 220 => 927,
221 => 928, 222 => 928, 223 => 834, 224 => 873, 225 => 828,
226 => 924, 227 => 924, 228 => 917, 229 => 930, 230 => 931,
231 => 463, 232 => 883, 233 => 836, 234 => 836, 235 => 867,
236 => 867, 237 => 696, 238 => 696, 239 => 874, 241 => 874,
242 => 760, 243 => 946, 244 => 771, 245 => 865, 246 => 771,
247 => 888, 248 => 967, 249 => 888, 250 => 831, 251 => 873,
252 => 927, 253 => 970, 254 => 918);
$this->widths['Helvetica-Bold'] = array (32 => 278, 33 => 333, 34 => 474, 35 => 556,
36 => 556, 37 => 889, 38 => 722, 39 => 278,
40 => 333, 41 => 333, 42 => 389, 43 => 584,
44 => 278, 45 => 333, 46 => 278, 47 => 278,
48 => 556, 49 => 556, 50 => 556, 51 => 556,
52 => 556, 53 => 556, 54 => 556, 55 => 556,
56 => 556, 57 => 556, 58 => 333, 59 => 333,
60 => 584, 61 => 584, 62 => 584, 63 => 611,
64 => 975, 65 => 722, 66 => 722, 67 => 722,
68 => 722, 69 => 667, 70 => 611, 71 => 778,
72 => 722, 73 => 278, 74 => 556, 75 => 722,
76 => 611, 77 => 833, 78 => 722, 79 => 778,
80 => 667, 81 => 778, 82 => 722, 83 => 667,
84 => 611, 85 => 722, 86 => 667, 87 => 944,
88 => 667, 89 => 667, 90 => 611, 91 => 333,
92 => 278, 93 => 333, 94 => 584, 95 => 556,
96 => 278, 97 => 556, 98 => 611, 99 => 556,
100 => 611, 101 => 556, 102 => 333, 103 => 611,
104 => 611, 105 => 278, 106 => 278, 107 => 556,
108 => 278, 109 => 889, 110 => 611, 111 => 611,
112 => 611, 113 => 611, 114 => 389, 115 => 556,
116 => 333, 117 => 611, 118 => 556, 119 => 778,
120 => 556, 121 => 556, 122 => 500, 123 => 389,
124 => 280, 125 => 389, 126 => 584, 161 => 333,
162 => 556, 163 => 556, 164 => 167, 165 => 556,
166 => 556, 167 => 556, 168 => 556, 169 => 238,
170 => 500, 171 => 556, 172 => 333, 173 => 333,
174 => 611, 175 => 611, 177 => 556, 178 => 556,
179 => 556, 180 => 278, 182 => 556, 183 => 350,
184 => 278, 185 => 500, 186 => 500, 187 => 556,
188 => 1000, 189 => 1000, 191 => 611, 193 => 333,
194 => 333, 195 => 333, 196 => 333, 197 => 333,
198 => 333, 199 => 333, 200 => 333, 202 => 333,
203 => 333, 205 => 333, 206 => 333, 207 => 333,
208 => 1000, 225 => 1000, 227 => 370, 232 => 611,
233 => 778, 234 => 1000, 235 => 365, 241 => 889,
245 => 278, 248 => 278, 249 => 611, 250 => 944,
251 => 611 );
$this->widths['Helvetica'] = array (32 => 278, 33 => 278, 34 => 355, 35 => 556, 36 => 556,
37 => 889, 38 => 667, 39 => 222, 40 => 333, 41 => 333,
42 => 389, 43 => 584, 44 => 278, 45 => 333, 46 => 278,
47 => 278, 48 => 556, 49 => 556, 50 => 556, 51 => 556,
52 => 556, 53 => 556, 54 => 556, 55 => 556, 56 => 556,
57 => 556, 58 => 278, 59 => 278, 60 => 584, 61 => 584,
62 => 584, 63 => 556, 64 => 1015, 65 => 667, 66 => 667,
67 => 722, 68 => 722, 69 => 667, 70 => 611, 71 => 778,
72 => 722, 73 => 278, 74 => 500, 75 => 667, 76 => 556,
77 => 833, 78 => 722, 79 => 778, 80 => 667, 81 => 778,
82 => 722, 83 => 667, 84 => 611, 85 => 722, 86 => 667,
87 => 944, 88 => 667, 89 => 667, 90 => 611, 91 => 278,
92 => 278, 93 => 278, 94 => 469, 95 => 556, 96 => 222,
97 => 556, 98 => 556, 99 => 500, 100 => 556, 101 => 556,
102 => 278, 103 => 556, 104 => 556, 105 => 222, 106 => 222,
107 => 500, 108 => 222, 109 => 833, 110 => 556, 111 => 556,
112 => 556, 113 => 556, 114 => 333, 115 => 500, 116 => 278,
117 => 556, 118 => 500, 119 => 722, 120 => 500, 121 => 500,
122 => 500, 123 => 334, 124 => 260, 125 => 334, 126 => 584,
161 => 333, 162 => 556, 163 => 556, 164 => 167, 165 => 556,
166 => 556, 167 => 556, 168 => 556, 169 => 191, 170 => 333,
171 => 556, 172 => 333, 173 => 333, 174 => 500, 175 => 500,
177 => 556, 178 => 556, 179 => 556, 180 => 278, 182 => 537,
183 => 350, 184 => 222, 185 => 333, 186 => 333, 187 => 556,
188 => 1000, 189 => 1000, 191 => 611, 193 => 333, 194 => 333,
195 => 333, 196 => 333, 197 => 333, 198 => 333, 199 => 333,
200 => 333, 202 => 333, 203 => 333, 205 => 333, 206 => 333,
207 => 333, 208 => 1000, 225 => 1000, 227 => 370, 232 => 556,
233 => 778, 234 => 1000, 235 => 365, 241 => 889, 245 => 278,
248 => 222, 249 => 611, 250 => 944, 251 => 611 );
$this->widths['Times'] = array (32 => 250, 33 => 333, 34 => 408, 35 => 500, 36 => 500,
37 => 833, 38 => 778, 39 => 333, 40 => 333, 41 => 333,
42 => 500, 43 => 564, 44 => 250, 45 => 333, 46 => 250,
47 => 278, 48 => 500, 49 => 500, 50 => 500, 51 => 500,
52 => 500, 53 => 500, 54 => 500, 55 => 500, 56 => 500,
57 => 500, 58 => 278, 59 => 278, 60 => 564, 61 => 564,
62 => 564, 63 => 444, 64 => 921, 65 => 722, 66 => 667,
67 => 667, 68 => 722, 69 => 611, 70 => 556, 71 => 722,
72 => 722, 73 => 333, 74 => 389, 75 => 722, 76 => 611,
77 => 889, 78 => 722, 79 => 722, 80 => 556, 81 => 722,
82 => 667, 83 => 556, 84 => 611, 85 => 722, 86 => 722,
87 => 944, 88 => 722, 89 => 722, 90 => 611, 91 => 333,
92 => 278, 93 => 333, 94 => 469, 95 => 500, 96 => 333,
97 => 444, 98 => 500, 99 => 444, 100 => 500, 101 => 444,
102 => 333, 103 => 500, 104 => 500, 105 => 278, 106 => 278,
107 => 500, 108 => 278, 109 => 778, 110 => 500, 111 => 500,
112 => 500, 113 => 500, 114 => 333, 115 => 389, 116 => 278,
117 => 500, 118 => 500, 119 => 722, 120 => 500, 121 => 500,
122 => 444, 123 => 480, 124 => 200, 125 => 480, 126 => 541,
161 => 333, 162 => 500, 163 => 500, 164 => 167, 165 => 500,
166 => 500, 167 => 500, 168 => 500, 169 => 180, 170 => 444,
171 => 500, 172 => 333, 173 => 333, 174 => 556, 175 => 556,
177 => 500, 178 => 500, 179 => 500, 180 => 250, 182 => 453,
183 => 350, 184 => 333, 185 => 444, 186 => 444, 187 => 500,
188 => 1000, 189 => 1000, 191 => 444, 193 => 333, 194 => 333,
195 => 333, 196 => 333, 197 => 333, 198 => 333, 199 => 333,
200 => 333, 202 => 333, 203 => 333, 205 => 333, 206 => 333,
207 => 333, 208 => 1000, 225 => 889, 227 => 276, 232 => 611,
233 => 722, 234 => 889, 235 => 310, 241 => 667, 245 => 278,
248 => 278, 249 => 500, 250 => 722, 251 => 500);
$this->widths['Times-Bold'] = array (32 => 250, 33 => 333, 34 => 555, 35 => 500, 36 => 500,
37 => 1000, 38 => 833, 39 => 333, 40 => 333, 41 => 333,
42 => 500, 43 => 570, 44 => 250, 45 => 333, 46 => 250,
47 => 278, 48 => 500, 49 => 500, 50 => 500, 51 => 500,
52 => 500, 53 => 500, 54 => 500, 55 => 500, 56 => 500,
57 => 500, 58 => 333, 59 => 333, 60 => 570, 61 => 570,
62 => 570, 63 => 500, 64 => 930, 65 => 722, 66 => 667,
67 => 722, 68 => 722, 69 => 667, 70 => 611, 71 => 778,
72 => 778, 73 => 389, 74 => 500, 75 => 778, 76 => 667,
77 => 944, 78 => 722, 79 => 778, 80 => 611, 81 => 778,
82 => 722, 83 => 556, 84 => 667, 85 => 722, 86 => 722,
87 => 1000, 88 => 722, 89 => 722, 90 => 667, 91 => 333,
92 => 278, 93 => 333, 94 => 581, 95 => 500, 96 => 333,
97 => 500, 98 => 556, 99 => 444, 100 => 556, 101 => 444,
102 => 333, 103 => 500, 104 => 556, 105 => 278, 106 => 333,
107 => 556, 108 => 278, 109 => 833, 110 => 556, 111 => 500,
112 => 556, 113 => 556, 114 => 444, 115 => 389, 116 => 333,
117 => 556, 118 => 500, 119 => 722, 120 => 500, 121 => 500,
122 => 444, 123 => 394, 124 => 220, 125 => 394, 126 => 520,
161 => 333, 162 => 500, 163 => 500, 164 => 167, 165 => 500,
166 => 500, 167 => 500, 168 => 500, 169 => 278, 170 => 500,
171 => 500, 172 => 333, 173 => 333, 174 => 556, 175 => 556,
177 => 500, 178 => 500, 179 => 500, 180 => 250, 182 => 540,
183 => 350, 184 => 333, 185 => 500, 186 => 500, 187 => 500,
188 => 1000, 189 => 1000, 191 => 500, 193 => 333, 194 => 333,
195 => 333, 196 => 333, 197 => 333, 198 => 333, 199 => 333,
200 => 333, 202 => 333, 203 => 333, 205 => 333, 206 => 333,
207 => 333, 208 => 1000, 225 => 1000, 227 => 300, 232 => 667,
233 => 778, 234 => 1000, 235 => 330, 241 => 722, 245 => 278,
248 => 278, 249 => 500, 250 => 722, 251 => 556);
$this->widths['Times-Italic'] = array (32 => 250, 33 => 333, 34 => 420, 35 => 500, 36 => 500,
37 => 833, 38 => 778, 39 => 333, 40 => 333, 41 => 333,
42 => 500, 43 => 675, 44 => 250, 45 => 333, 46 => 250,
47 => 278, 48 => 500, 49 => 500, 50 => 500, 51 => 500,
52 => 500, 53 => 500, 54 => 500, 55 => 500, 56 => 500,
57 => 500, 58 => 333, 59 => 333, 60 => 675, 61 => 675,
62 => 675, 63 => 500, 64 => 920, 65 => 611, 66 => 611,
67 => 667, 68 => 722, 69 => 611, 70 => 611, 71 => 722,
72 => 722, 73 => 333, 74 => 444, 75 => 667, 76 => 556,
77 => 833, 78 => 667, 79 => 722, 80 => 611, 81 => 722,
82 => 611, 83 => 500, 84 => 556, 85 => 722, 86 => 611,
87 => 833, 88 => 611, 89 => 556, 90 => 556, 91 => 389,
92 => 278, 93 => 389, 94 => 422, 95 => 500, 96 => 333,
97 => 500, 98 => 500, 99 => 444, 100 => 500, 101 => 444,
102 => 278, 103 => 500, 104 => 500, 105 => 278, 106 => 278,
107 => 444, 108 => 278, 109 => 722, 110 => 500, 111 => 500,
112 => 500, 113 => 500, 114 => 389, 115 => 389, 116 => 278,
117 => 500, 118 => 444, 119 => 667, 120 => 444, 121 => 444,
122 => 389, 123 => 400, 124 => 275, 125 => 400, 126 => 541,
161 => 389, 162 => 500, 163 => 500, 164 => 167, 165 => 500,
166 => 500, 167 => 500, 168 => 500, 169 => 214, 170 => 556,
171 => 500, 172 => 333, 173 => 333, 174 => 500, 175 => 500,
177 => 500, 178 => 500, 179 => 500, 180 => 250, 182 => 523,
183 => 350, 184 => 333, 185 => 556, 186 => 556, 187 => 500,
188 => 889, 189 => 1000, 191 => 500, 193 => 333, 194 => 333,
195 => 333, 196 => 333, 197 => 333, 198 => 333, 199 => 333,
200 => 333, 202 => 333, 203 => 333, 205 => 333, 206 => 333,
207 => 333, 208 => 889, 225 => 889, 227 => 276, 232 => 556,
233 => 722, 234 => 944, 235 => 310, 241 => 667, 245 => 278,
248 => 278, 249 => 500, 250 => 667, 251 => 500);
$this->widths['Times-BoldItalic'] = array (32 => 250, 33 => 389, 34 => 555, 35 => 500, 36 => 500,
37 => 833, 38 => 778, 39 => 333, 40 => 333, 41 => 333,
42 => 500, 43 => 570, 44 => 250, 45 => 333, 46 => 250,
47 => 278, 48 => 500, 49 => 500, 50 => 500, 51 => 500,
52 => 500, 53 => 500, 54 => 500, 55 => 500, 56 => 500,
57 => 500, 58 => 333, 59 => 333, 60 => 570, 61 => 570,
62 => 570, 63 => 500, 64 => 832, 65 => 667, 66 => 667,
67 => 667, 68 => 722, 69 => 667, 70 => 667, 71 => 722,
72 => 778, 73 => 389, 74 => 500, 75 => 667, 76 => 611,
77 => 889, 78 => 722, 79 => 722, 80 => 611, 81 => 722,
82 => 667, 83 => 556, 84 => 611, 85 => 722, 86 => 667,
87 => 889, 88 => 667, 89 => 611, 90 => 611, 91 => 333,
92 => 278, 93 => 333, 94 => 570, 95 => 500, 96 => 333,
97 => 500, 98 => 500, 99 => 444, 100 => 500, 101 => 444,
102 => 333, 103 => 500, 104 => 556, 105 => 278, 106 => 278,
107 => 500, 108 => 278, 109 => 778, 110 => 556, 111 => 500,
112 => 500, 113 => 500, 114 => 389, 115 => 389, 116 => 278,
117 => 556, 118 => 444, 119 => 667, 120 => 500, 121 => 444,
122 => 389, 123 => 348, 124 => 220, 125 => 348, 126 => 570,
161 => 389, 162 => 500, 163 => 500, 164 => 167, 165 => 500,
166 => 500, 167 => 500, 168 => 500, 169 => 278, 170 => 500,
171 => 500, 172 => 333, 173 => 333, 174 => 556, 175 => 556,
177 => 500, 178 => 500, 179 => 500, 180 => 250, 182 => 500,
183 => 350, 184 => 333, 185 => 500, 186 => 500, 187 => 500,
188 => 1000, 189 => 1000, 191 => 500, 193 => 333, 194 => 333,
195 => 333, 196 => 333, 197 => 333, 198 => 333, 199 => 333,
200 => 333, 202 => 333, 203 => 333, 205 => 333, 206 => 333,
207 => 333, 208 => 1000, 225 => 944, 227 => 266, 232 => 611,
233 => 722, 234 => 944, 235 => 300, 241 => 722, 245 => 278,
248 => 278, 249 => 500, 250 => 722, 251 => 500);
?>

View file

@ -0,0 +1,222 @@
<?php
/*
php pdf generation library - template extension
Copyright (C) Potential Technologies 2002 - 2003
http://www.potentialtech.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: template.class.php 7 2004-02-11 20:44:53Z gruiick $
*/
class template
{
var $nexttid, $templ;
var $pdf; // reference to the parent class
function template()
{
$this->tid = 0;
}
function create()
{
$temp = $this->nexttid;
// Stores the next object ID within this template
$this->templ[$temp]['next'] = 0;
$this->nexttid ++;
return $temp;
}
function size($tid, $width, $height)
{
$this->templ[$tid]["height"] = $height;
$this->templ[$tid]["width"] = $width;
return true;
}
function rectangle($tid, $bottom, $left, $top, $right, $attrib = array())
{
$temp = $this->pdf->_resolve_param($attrib);
$temp["type"] = "rectangle";
$temp["top"] = $top;
$temp["left"] = $left;
$temp["bottom"] = $bottom;
$temp["right"] = $right;
return $this->_add_object($temp, $tid);
}
function circle($tid, $cenx, $ceny, $radius, $attrib = array())
{
$temp = $this->pdf->_resolve_param($attrib);
$temp["type"] = "circle";
$temp["x"] = $cenx;
$temp["y"] = $ceny;
$temp["radius"] = $radius;
return $this->_add_object($temp, $tid);
}
function line($tid, $x, $y, $attrib = array())
{
$temp = $this->pdf->_resolve_param($attrib);
$temp["type"] = "line";
$temp["x"] = $x;
$temp["y"] = $y;
return $this->_add_object($temp, $tid);
}
function image($tid, $left, $bottom, $width, $height, $image, $attrib = array())
{
$this->ifield($tid, $left, $bottom, $width, $height, false, $image, $attrib);
}
function ifield($tid, $left, $bottom, $width, $height, $name, $default = false, $attrib = array())
{
$temp = $this->pdf->_resolve_param($attrib);
$temp['type'] = "ifield";
$temp['left'] = $left;
$temp['bottom'] = $bottom;
$temp['name'] = $name;
$temp['default'] = $default;
$temp['width'] = $width;
$temp['height'] = $height;
return $this->_add_object($temp, $tid);
}
function text($tid, $left, $bottom, $text, $attrib = array())
{
return $this->field($tid, $left, $bottom, false, $text, $attrib);
}
function field($tid, $left, $bottom, $name, $default = '', $attrib = array())
{
$temp = $this->pdf->_resolve_param($attrib);
$temp["type"] = "field";
$temp["left"] = $left;
$temp["bottom"] = $bottom;
$temp["name"] = $name;
$temp["default"] = $default;
return $this->_add_object($temp, $tid);
}
function paragraph($tid, $bottom, $left, $top, $right, $text, $attrib = array())
{
return $this->pfield($tid, $bottom, $left, $top, $right, false, $text, $attrib);
}
function pfield($tid, $bottom, $left, $top, $right, $name, $default = '', $attrib = array())
{
$temp = $this->pdf->_resolve_param($attrib);
$temp['type'] = 'pfield';
$temp['left'] = $left;
$temp['bottom'] = $bottom;
$temp['top'] = $top;
$temp['right'] = $right;
$temp['name'] = $name;
$temp['default'] = $default;
return $this->_add_object($temp, $tid);
}
function place($tid, $page, $left, $bottom, $data = array())
{
$ok = true;
foreach( $this->templ[$tid]["objects"] as $o ) {
switch ($o['type']) {
case 'rectangle' :
$ok = $ok && $this->pdf->draw_rectangle($bottom + $o["top"],
$left + $o["left"],
$bottom + $o["bottom"],
$left + $o["right"],
$page,
$o);
break;
case 'circle' :
$ok = $ok && $this->pdf->draw_circle($left + $o['x'],
$bottom + $o['y'],
$o['radius'],
$page,
$o);
break;
case 'line' :
foreach ($o['x'] as $key => $value) {
$o['x'][$key] += $left;
$o['y'][$key] += $bottom;
}
$ok = $ok && $this->pdf->draw_line($o['x'],
$o['y'],
$page,
$o);
break;
case 'field' :
$temp = ($o['name'] === false) || !isset($data[$o['name']]) || !strlen($data[$o['name']]) ? $o['default'] : $data[$o['name']];
$ok = $ok && $this->pdf->draw_text($left + $o['left'],
$bottom + $o['bottom'],
$temp,
$page,
$o);
break;
case 'pfield' :
$temp = ($o['name'] === false) || !isset($data[$o['name']]) || !strlen($data[$o['name']]) ? $o['default'] : $data[$o['name']];
$t = $this->pdf->draw_paragraph($bottom + $o['top'],
$left + $o['left'],
$bottom + $o['bottom'],
$left + $o['right'],
$temp,
$page,
$o);
if (is_string($t)) {
$ok = false;
$this->pdf->_push_error(6013, "Text overflowed available area: $t");
}
break;
case 'ifield' :
$temp = ($o['name'] === false) || empty($data[$o['name']]) ? $o['default'] : $data[$o['name']];
if ($temp === false) {
break;
}
$id = $this->pdf->get_image_size($temp);
unset($o['scale']);
$o['scale']['x'] = $o['width'] / $id['width'];
$o['scale']['y'] = $o['height'] / $id['height'];
$ok = $ok && $this->pdf->image_place($temp,
$o['bottom'] + $bottom,
$o['left'] + $left,
$page,
$o);
break;
}
}
return $ok;
}
/* Private methods
*/
function _add_object($objarray, $tid)
{
$oid = $this->templ[$tid]["next"];
$this->templ[$tid]["next"] ++;
$this->templ[$tid]["objects"][$oid] = $objarray;
return $oid;
}
}
?>

View file

@ -0,0 +1,56 @@
<?php
/* session.inc.php
* - Gestion de la session
* Copyright (c) 2003 Frédéric Jaqcuot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
session_start();
@ini_set('session.use_trans_sid', '0');
if (!isset($_SESSION["logged_status"]) ||
isset($_POST["logout"]) ||
isset($_GET["logout"]))
{
if (isset($_POST["logout"]) ||
isset($_GET["logout"])){
dblog(_("Log off"));
}
$_SESSION["admin_status"]=0;
$_SESSION["logged_status"]=0;
$_SESSION["logged_id_adh"]=0;
$_SESSION["logged_nom_adh"]="";
$_SESSION["filtre_adh"]=0;
$_SESSION["filtre_adh_2"]=1;
$_SESSION["filtre_date_cotis_1"]="";
$_SESSION["filtre_date_cotis_2"]="";
$_SESSION["tri_adh"]=0;
$_SESSION["tri_adh_sens"]=0;
$_SESSION["tri_log"]=0;
$_SESSION["tri_log_sens"]=0;
$_SESSION["filtre_cotis"]=0;
$_SESSION["tri_cotis"]=0;
$_SESSION["tri_cotis_sens"]=1;
$_SESSION["filtre_cotis_adh"]="";
if (isset($_POST["logout"]) ||
isset($_GET["logout"]))
{
dblog(_T("Deconnexion"));
session_destroy();
}
}
?>

View file

@ -0,0 +1,125 @@
<?php
/* index.php
* - Identification
* Copyright (c) 2003 Frédéric Jacquot
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
include("includes/config.inc.php");
include(WEB_ROOT."includes/database.inc.php");
include(WEB_ROOT."includes/functions.inc.php");
include(WEB_ROOT."includes/lang.inc.php");
include(WEB_ROOT."includes/session.inc.php");
if (isset($_POST["ident"]))
{
if ($_POST["login"]==PREF_ADMIN_LOGIN && $_POST["password"]==PREF_ADMIN_PASS)
{
$_SESSION["logged_status"]=1;
$_SESSION["admin_status"]=1;
$_SESSION["logged_username"]=$_POST["login"];
$_SESSION["logged_nom_adh"]=_T("Administrateur");
$_SESSION["sess_cuser"]='O:5:"tUser":3:{s:2:"id";s:1:"4";s:4:"name";s:5:"admin";s:4:"perm";s:3:"126";}';
dblog(_T("Identification"));
}
else
{
$requete = "SELECT id_adh, bool_admin_adh, nom_adh, prenom_adh
FROM ".PREFIX_DB."adherents
WHERE login_adh=" . txt_sqls($_POST["login"]) . "
AND activite_adh='1'
AND mdp_adh=" . txt_sqls($_POST["password"]);
$resultat = &$DB->Execute($requete);
if (!$resultat->EOF)
{
if ($resultat->fields[1]=="1")
$_SESSION["admin_status"]=1;
$_SESSION["logged_id_adh"]=$resultat->fields[0];
$_SESSION["logged_status"]=1;
$_SESSION["logged_nom_adh"]=strtoupper($resultat->fields[2]) . " " . strtolower($resultat->fields[3]);
if ($_SESSION["admin_status"] == "1")
{
$_SESSION["sess_cuser"]='O:5:"tUser":3:{s:2:"id";s:1:"4";s:4:"name";s:5:"admin";s:4:"perm";s:3:"126";}';
} else {
$_SESSION["sess_cuser"]='O:5:"tUser":3:{s:2:"id";s:1:"1";s:4:"name";s:9:"Anonymous";s:4:"perm";s:1:"0";}';
}
$_SESSION["sess_clogin"] = $_SESSION["logged_nom_adh"];
$_SESSION["sess_sort"] = "258";
$_SESSION["sess_grp"]="1";
dblog(_T("Identification"));
}
else
dblog(_T("Echec authentification. Login :")." \"" . $_POST["login"] . "\"");
}
}
if ($_SESSION["logged_status"]!=0)
header("location: gestion_adherents.php");
else
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr-FR" lang="fr-FR"><head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>LA.M.A.P. des Jardins de Virgile - Produits</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="icon" type="image/png" href="icon-mini.png" />
<meta name="Author" content="GARETTE Emmanuel" />
<meta name="Keywords" content="AMAP, Dijon, Les bourroches, Le jardin de Virgile, A.M.A.P." />
<meta name="Description" content="AMAP Dijon le Jardin de Virgile." />
</head>
<body>
<h1>Partie privée de l'<acronym title="Association pour le Maintien de l'Agriculture Paysanne">A.M.A.P.</acronym> <br />les Jardins de Virgile</h1>
<p id="soustitre">::&nbsp;L<acronym title="Association pour le Maintien de l'Agriculture Paysanne">A.M.A.P.</acronym> des Jardins de Virgile des bourroches, Dijon en Côte dOr&nbsp;::</p>
<div id="body">
<div id="content">
<h2>Accès à la partie privée</h2>
<form action="index.php" method="post">
<fieldset>
<legend><?php echo _T("Identification"); ?></legend>
<p><label><?php echo _T("Identifiant :"); ?></label><input type="text" name="login" /></p>
<p><label><?php echo _T("Mot de passe :"); ?></label><input type="password" name="password" /></p>
<p><input type="submit" name="ident" value="<?php echo _T("Identification"); ?>" /></p>
</fieldset>
</form>
<p><a href="lostpasswd.php"><?php echo _T("Mot de passe perdu ?"); ?></a></p>
</div>
<p id="pieddepage">
::&nbsp;Mise en page <a href="http://www.gnunux.info">GARETTE Emmanuel</a>&nbsp;::
</p>
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</body>
</html>
<?php
}
?>

Some files were not shown because too many files have changed in this diff Show more