Banco del Tiempo
Check-in [dcc5867fa1]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:dcc5867fa153f0c7d7ee28e37c396edf07262fec
Date: 2011-12-25 23:42:10
User: goyo
Comment:First commit (source provided by konecta).
Tags And Properties
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added bdt.sql

            1  +-- phpMyAdmin SQL Dump
            2  +-- version 2.11.6
            3  +-- http://www.phpmyadmin.net
            4  +--
            5  +-- Servidor: localhost
            6  +-- Tiempo de generación: 31-08-2009 a las 01:24:29
            7  +-- Versión del servidor: 5.0.51
            8  +-- Versión de PHP: 5.2.6
            9  +
           10  +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
           11  +
           12  +
           13  +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
           14  +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
           15  +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
           16  +/*!40101 SET NAMES utf8 */;
           17  +
           18  +--
           19  +-- Base de datos: `bdt`
           20  +--
           21  +
           22  +-- --------------------------------------------------------
           23  +
           24  +--
           25  +-- Estructura de tabla para la tabla `admin_activity`
           26  +--
           27  +
           28  +DROP TABLE IF EXISTS `admin_activity`;
           29  +CREATE TABLE `admin_activity` (
           30  +  `log_id` mediumint(8) unsigned NOT NULL auto_increment,
           31  +  `log_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
           32  +  `admin_id` varchar(15) collate utf8_unicode_ci NOT NULL default '',
           33  +  `category` char(1) collate utf8_unicode_ci NOT NULL default '',
           34  +  `action` char(1) collate utf8_unicode_ci NOT NULL default '',
           35  +  `ref_id` varchar(15) collate utf8_unicode_ci NOT NULL default '',
           36  +  `note` varchar(100) collate utf8_unicode_ci default NULL,
           37  +  PRIMARY KEY  (`log_id`)
           38  +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
           39  +
           40  +--
           41  +-- Volcar la base de datos para la tabla `admin_activity`
           42  +--
           43  +
           44  +
           45  +-- --------------------------------------------------------
           46  +
           47  +--
           48  +-- Estructura de tabla para la tabla `categories`
           49  +--
           50  +
           51  +DROP TABLE IF EXISTS `categories`;
           52  +CREATE TABLE `categories` (
           53  +  `category_id` smallint(4) unsigned NOT NULL auto_increment,
           54  +  `parent_id` smallint(4) unsigned default NULL,
           55  +  `description` varchar(30) collate utf8_unicode_ci NOT NULL default '',
           56  +  PRIMARY KEY  (`category_id`)
           57  +) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=19 ;
           58  +
           59  +--
           60  +-- Volcar la base de datos para la tabla `categories`
           61  +--
           62  +
           63  +INSERT INTO `categories` (`category_id`, `parent_id`, `description`) VALUES
           64  +(1, NULL, 'Arte y artesanía'),
           65  +(2, NULL, 'Albañilería y construcción'),
           66  +(3, NULL, 'Servicios de empresa'),
           67  +(4, NULL, 'Cuidado de niños/as'),
           68  +(5, NULL, 'Informática'),
           69  +(6, NULL, 'Psicopedagogía y terapia'),
           70  +(7, NULL, 'Cocina'),
           71  +(8, NULL, 'Trabajos de jardinería'),
           72  +(9, NULL, 'Servicio técnico'),
           73  +(10, NULL, 'Salud y cuidado de personas'),
           74  +(11, NULL, 'Trabajos del hogar'),
           75  +(12, NULL, 'Otros'),
           76  +(13, NULL, 'Música y entretenimiento'),
           77  +(14, NULL, 'Cuidado de animales'),
           78  +(15, NULL, 'Deportes y animación'),
           79  +(16, NULL, 'Enseñanza'),
           80  +(17, NULL, 'Transporte'),
           81  +(18, NULL, 'Compras y comercio');
           82  +
           83  +-- --------------------------------------------------------
           84  +
           85  +--
           86  +-- Estructura de tabla para la tabla `feedback`
           87  +--
           88  +
           89  +DROP TABLE IF EXISTS `feedback`;
           90  +CREATE TABLE `feedback` (
           91  +  `feedback_id` mediumint(8) unsigned NOT NULL auto_increment,
           92  +  `feedback_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
           93  +  `status` char(1) collate utf8_unicode_ci NOT NULL default '',
           94  +  `member_id_author` varchar(15) collate utf8_unicode_ci NOT NULL default '',
           95  +  `member_id_about` varchar(15) collate utf8_unicode_ci NOT NULL default '',
           96  +  `trade_id` mediumint(8) unsigned NOT NULL default '0',
           97  +  `rating` char(1) collate utf8_unicode_ci NOT NULL default '',
           98  +  `comment` text collate utf8_unicode_ci,
           99  +  PRIMARY KEY  (`feedback_id`)
          100  +) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=18 ;
          101  +
          102  +--
          103  +-- Volcar la base de datos para la tabla `feedback`
          104  +--
          105  +
          106  +
          107  +-- --------------------------------------------------------
          108  +
          109  +--
          110  +-- Estructura de tabla para la tabla `feedback_rebuttal`
          111  +--
          112  +
          113  +DROP TABLE IF EXISTS `feedback_rebuttal`;
          114  +CREATE TABLE `feedback_rebuttal` (
          115  +  `rebuttal_id` mediumint(6) unsigned NOT NULL auto_increment,
          116  +  `rebuttal_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
          117  +  `feedback_id` mediumint(8) unsigned default NULL,
          118  +  `member_id` varchar(15) collate utf8_unicode_ci NOT NULL default '',
          119  +  `comment` varchar(255) collate utf8_unicode_ci default NULL,
          120  +  PRIMARY KEY  (`rebuttal_id`)
          121  +) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=12 ;
          122  +
          123  +--
          124  +-- Volcar la base de datos para la tabla `feedback_rebuttal`
          125  +--
          126  +
          127  +
          128  +-- --------------------------------------------------------
          129  +
          130  +--
          131  +-- Estructura de tabla para la tabla `listings`
          132  +--
          133  +
          134  +DROP TABLE IF EXISTS `listings`;
          135  +CREATE TABLE `listings` (
          136  +  `title` varchar(60) collate utf8_unicode_ci NOT NULL default '',
          137  +  `description` text collate utf8_unicode_ci,
          138  +  `category_code` smallint(4) unsigned NOT NULL default '0',
          139  +  `member_id` varchar(15) collate utf8_unicode_ci NOT NULL default '',
          140  +  `rate` varchar(30) collate utf8_unicode_ci default NULL,
          141  +  `status` char(1) collate utf8_unicode_ci NOT NULL default '',
          142  +  `posting_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
          143  +  `expire_date` date default NULL,
          144  +  `reactivate_date` date default NULL,
          145  +  `type` char(1) collate utf8_unicode_ci NOT NULL default '',
          146  +  PRIMARY KEY  (`title`,`member_id`,`type`)
          147  +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
          148  +
          149  +--
          150  +-- Volcar la base de datos para la tabla `listings`
          151  +--
          152  +
          153  +
          154  +-- --------------------------------------------------------
          155  +
          156  +--
          157  +-- Estructura de tabla para la tabla `logins`
          158  +--
          159  +
          160  +DROP TABLE IF EXISTS `logins`;
          161  +CREATE TABLE `logins` (
          162  +  `member_id` varchar(15) collate utf8_unicode_ci NOT NULL default '',
          163  +  `total_failed` mediumint(6) unsigned NOT NULL default '0',
          164  +  `consecutive_failures` mediumint(3) unsigned NOT NULL default '0',
          165  +  `last_failed_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
          166  +  `last_success_date` timestamp NOT NULL default '0000-00-00 00:00:00',
          167  +  PRIMARY KEY  (`member_id`)
          168  +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
          169  +
          170  +--
          171  +-- Volcar la base de datos para la tabla `logins`
          172  +--
          173  +
          174  +
          175  +-- --------------------------------------------------------
          176  +
          177  +--
          178  +-- Estructura de tabla para la tabla `member`
          179  +--
          180  +
          181  +DROP TABLE IF EXISTS `member`;
          182  +CREATE TABLE `member` (
          183  +  `member_id` varchar(15) collate utf8_unicode_ci NOT NULL default '',
          184  +  `password` varchar(50) collate utf8_unicode_ci NOT NULL default '',
          185  +  `member_role` char(1) collate utf8_unicode_ci NOT NULL default '',
          186  +  `security_q` varchar(25) collate utf8_unicode_ci default NULL,
          187  +  `security_a` varchar(15) collate utf8_unicode_ci default NULL,
          188  +  `status` char(1) collate utf8_unicode_ci NOT NULL default '',
          189  +  `member_note` varchar(100) collate utf8_unicode_ci default NULL,
          190  +  `admin_note` varchar(100) collate utf8_unicode_ci default NULL,
          191  +  `join_date` date NOT NULL default '0000-00-00',
          192  +  `expire_date` date default NULL,
          193  +  `away_date` date default NULL,
          194  +  `account_type` char(1) collate utf8_unicode_ci NOT NULL default '',
          195  +  `email_updates` int(3) unsigned NOT NULL default '0',
          196  +  `balance` decimal(8,2) NOT NULL default '0.00',
          197  +  PRIMARY KEY  (`member_id`)
          198  +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
          199  +
          200  +--
          201  +-- Volcar la base de datos para la tabla `member`
          202  +--
          203  +
          204  +INSERT INTO `member` (`member_id`, `password`, `member_role`, `security_q`, `security_a`, `status`, `member_note`, `admin_note`, `join_date`, `expire_date`, `away_date`, `account_type`, `email_updates`, `balance`) VALUES
          205  +('admin', 'password', '9', NULL, NULL, 'A', NULL, NULL, '2009-07-07', NULL, NULL, 'S', 7, '0.00');
          206  +
          207  +-- --------------------------------------------------------
          208  +
          209  +--
          210  +-- Estructura de tabla para la tabla `news`
          211  +--
          212  +
          213  +DROP TABLE IF EXISTS `news`;
          214  +CREATE TABLE `news` (
          215  +  `news_id` mediumint(6) unsigned NOT NULL auto_increment,
          216  +  `title` varchar(100) collate utf8_unicode_ci NOT NULL default '',
          217  +  `description` text collate utf8_unicode_ci NOT NULL,
          218  +  `sequence` decimal(6,4) NOT NULL default '0.0000',
          219  +  `expire_date` date default NULL,
          220  +  PRIMARY KEY  (`news_id`)
          221  +) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;
          222  +
          223  +--
          224  +-- Volcar la base de datos para la tabla `news`
          225  +--
          226  +
          227  +
          228  +-- --------------------------------------------------------
          229  +
          230  +--
          231  +-- Estructura de tabla para la tabla `person`
          232  +--
          233  +
          234  +DROP TABLE IF EXISTS `person`;
          235  +CREATE TABLE `person` (
          236  +  `person_id` mediumint(6) unsigned NOT NULL auto_increment,
          237  +  `member_id` varchar(15) collate utf8_unicode_ci NOT NULL default '',
          238  +  `primary_member` char(1) collate utf8_unicode_ci NOT NULL default '',
          239  +  `directory_list` char(1) collate utf8_unicode_ci NOT NULL default '',
          240  +  `first_name` varchar(20) collate utf8_unicode_ci NOT NULL default '',
          241  +  `last_name` varchar(30) collate utf8_unicode_ci NOT NULL default '',
          242  +  `mid_name` varchar(20) collate utf8_unicode_ci default NULL,
          243  +  `dob` date default NULL,
          244  +  `mother_mn` varchar(30) collate utf8_unicode_ci default NULL,
          245  +  `email` varchar(40) collate utf8_unicode_ci default NULL,
          246  +  `phone1_area` char(3) collate utf8_unicode_ci default NULL,
          247  +  `phone1_number` varchar(7) collate utf8_unicode_ci default NULL,
          248  +  `phone1_ext` varchar(4) collate utf8_unicode_ci default NULL,
          249  +  `phone2_area` char(3) collate utf8_unicode_ci default NULL,
          250  +  `phone2_number` varchar(7) collate utf8_unicode_ci default NULL,
          251  +  `phone2_ext` varchar(4) collate utf8_unicode_ci default NULL,
          252  +  `fax_area` char(3) collate utf8_unicode_ci default NULL,
          253  +  `fax_number` varchar(7) collate utf8_unicode_ci default NULL,
          254  +  `fax_ext` varchar(4) collate utf8_unicode_ci default NULL,
          255  +  `address_street1` varchar(30) collate utf8_unicode_ci default NULL,
          256  +  `address_street2` varchar(30) collate utf8_unicode_ci default NULL,
          257  +  `address_city` varchar(30) collate utf8_unicode_ci NOT NULL default '',
          258  +  `address_state_code` char(2) collate utf8_unicode_ci NOT NULL default '',
          259  +  `address_post_code` varchar(6) collate utf8_unicode_ci NOT NULL default '',
          260  +  `address_country` varchar(30) collate utf8_unicode_ci NOT NULL default '',
          261  +  `imagen` varchar(21) collate utf8_unicode_ci default NULL,
          262  +  PRIMARY KEY  (`person_id`)
          263  +) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=135 ;
          264  +
          265  +--
          266  +-- Volcar la base de datos para la tabla `person`
          267  +--
          268  +
          269  +INSERT INTO `person` (`person_id`, `member_id`, `primary_member`, `directory_list`, `first_name`, `last_name`, `mid_name`, `dob`, `mother_mn`, `email`, `phone1_area`, `phone1_number`, `phone1_ext`, `phone2_area`, `phone2_number`, `phone2_ext`, `fax_area`, `fax_number`, `fax_ext`, `address_street1`, `address_street2`, `address_city`, `address_state_code`, `address_post_code`, `address_country`, `imagen`) VALUES
          270  +(1, 'admin', 'Y', 'Y', 'Administrador', 'del Sistema', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', '', '', '', NULL);
          271  +
          272  +-- --------------------------------------------------------
          273  +
          274  +--
          275  +-- Estructura de tabla para la tabla `trades`
          276  +--
          277  +
          278  +DROP TABLE IF EXISTS `trades`;
          279  +CREATE TABLE `trades` (
          280  +  `trade_id` mediumint(8) unsigned NOT NULL auto_increment,
          281  +  `trade_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
          282  +  `status` char(1) collate utf8_unicode_ci default NULL,
          283  +  `member_id_from` varchar(15) collate utf8_unicode_ci NOT NULL default '',
          284  +  `member_id_to` varchar(15) collate utf8_unicode_ci NOT NULL default '',
          285  +  `amount` decimal(8,2) NOT NULL default '0.00',
          286  +  `category` smallint(4) unsigned NOT NULL default '0',
          287  +  `description` varchar(255) collate utf8_unicode_ci default NULL,
          288  +  `type` char(1) collate utf8_unicode_ci NOT NULL default '',
          289  +  PRIMARY KEY  (`trade_id`)
          290  +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
          291  +
          292  +--
          293  +-- Volcar la base de datos para la tabla `trades`
          294  +--
          295  +
          296  +
          297  +-- --------------------------------------------------------
          298  +
          299  +--
          300  +-- Estructura de tabla para la tabla `uploads`
          301  +--
          302  +
          303  +DROP TABLE IF EXISTS `uploads`;
          304  +CREATE TABLE `uploads` (
          305  +  `upload_id` mediumint(6) unsigned NOT NULL auto_increment,
          306  +  `upload_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
          307  +  `title` varchar(100) collate utf8_unicode_ci NOT NULL default '',
          308  +  `type` char(1) collate utf8_unicode_ci NOT NULL default '',
          309  +  `filename` varchar(100) collate utf8_unicode_ci default NULL,
          310  +  `note` varchar(100) collate utf8_unicode_ci default NULL,
          311  +  PRIMARY KEY  (`upload_id`)
          312  +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
          313  +
          314  +--
          315  +-- Volcar la base de datos para la tabla `uploads`
          316  +--
          317  +

Added bdt/admin_menu.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = ADMINISTRATION;
            4  +$p->page_title = "Menú de Administración";
            5  +
            6  +$cUser->MustBeLevel(1);
            7  +
            8  +$list = "<STRONG>Cuentas</STRONG><P>";
            9  +$list .= "<A HREF=member_create.php><FONT SIZE=3>Crear un nuevo usuario o usuaria</FONT></A><BR>";
           10  +$list .= "<A HREF=member_to_edit.php><FONT SIZE=3>Editar un usuario o usuaria</FONT></A><BR>";
           11  +$list .= "<A HREF=member_to_edit_waitings.php><FONT SIZE=3>Ver usuarios o usuarias pendientes de aceptar</FONT></A><BR>";
           12  +if ($cUser->member_role > 1) {
           13  +    $list .= "<A HREF=member_choose.php?action=member_status_change&inactive=Y><FONT SIZE=3>Desactivar / Reactivar a un usuario o usuaria</FONT></A><BR>";
           14  +}
           15  +//$list .= "<A HREF=member_contact_create.php?mode=admin><FONT SIZE=3>Adjuntar una persona a un usuario o usuaria</FONT></A><BR>";
           16  +//$list .= "<A HREF=member_contact_to_edit.php><FONT SIZE=3>Editar/Borrar un compañero/a de un/a usuario/a</FONT></A><BR>";
           17  +$list .= "<A HREF=member_unlock.php><FONT SIZE=3>Desbloquear una Cuenta y resetear la contraseña</FONT></A><P>";
           18  +
           19  +if ($cUser->member_role > 1) {
           20  +    $list .= "<STRONG>Intercambios</STRONG><P>";
           21  +    $list .= "<A HREF=member_choose.php?action=trade><FONT SIZE=3>Crear un intercambio</FONT></A><BR>";
           22  +    $list .= "<A HREF=trade_reverse.php><FONT SIZE=3>Deshacer un intercambio hecho por error</FONT></A><BR>";
           23  +    $list .= "<A HREF=member_choose.php?action=feedback_choose><FONT SIZE=3>Grabar la Valoración de un usuario o usuaria</FONT></A><P>";
           24  +}
           25  +
           26  +$list .= "<STRONG>Ofertas</STRONG><P>";
           27  +$list .= "<A HREF=member_choose.php?action=listing_to_edit&get1=type&get1val=Offer><FONT SIZE=3>Editar una oferta</FONT></A><BR>";
           28  +$list .= "<A HREF=member_choose.php?action=listing_delete&get1=type&get1val=Offer><FONT SIZE=3>Borrar una oferta</FONT></A><P>";
           29  +
           30  +$list .= "<STRONG>Demandas</STRONG><P>";
           31  +$list .= "<A HREF=member_choose.php?action=listing_to_edit&get1=type&get1val=Want><FONT SIZE=3>Editar una demanda</FONT></A><BR>";
           32  +$list .= "<A HREF=member_choose.php?action=listing_delete&get1=type&get1val=Want><FONT SIZE=3>Borrar una demanda</FONT></A><P>";
           33  +
           34  +$list .= "<STRONG>Varios</STRONG><P>";
           35  +$list .= "<A HREF=member_choose.php?action=holiday><FONT SIZE=3>Un usuario o usuaria se va de vacaciones</FONT></A>";
           36  +if ($cUser->member_role > 1) {
           37  +    $list .= "<BR><A HREF=category_create.php><FONT SIZE=3>Crear una nueva categoría</FONT></A><BR>";
           38  +    $list .= "<A HREF=category_choose.php><FONT SIZE=3>Editar / Borrar una categoría</FONT></A>";
           39  +}
           40  +$list .= "<P>";
           41  +
           42  +
           43  +$list .= "<STRONG>Sistema</STRONG><P>";
           44  +if ($cUser->member_role > 1) {
           45  +    $list .= "<A HREF=export.php><FONT SIZE=3>Exportar / Hacer un backup de datos en hoja de cálculo</FONT></A><BR>";
           46  +    $list .= "<A HREF=contact_all.php><FONT SIZE=3>Enviar un email a todas las personas usuarias</FONT></A><BR>";
           47  +}
           48  +$list .= "<A HREF=report_no_login.php><FONT SIZE=3>Ver quiénes no han entrado nunca</FONT></A><P>";
           49  +
           50  +$list .= "<STRONG>Noticias y Eventos</STRONG><P>";
           51  +$list .= "<A HREF=news_create.php><FONT SIZE=3>Crear una noticia</FONT></A><BR>";
           52  +$list .= "<A HREF=news_to_edit.php><FONT SIZE=3>Editar una noticia</FONT></A><BR>";
           53  +//$list .= "<A HREF=newsletter_upload.php><FONT SIZE=3>Subir una publicación</FONT></A><BR>";
           54  +//$list .= "<A HREF=newsletter_delete.php><FONT SIZE=3>Borrar periódico</FONT></A><BR>";
           55  +
           56  +$p->DisplayPage($list);
           57  +
           58  +
           59  +
           60  +?>

Added bdt/capture_photo.php

            1  +<?
            2  +include_once("includes/inc.global.php"); 
            3  +
            4  +
            5  +$cUser->MustBeLevel(1);
            6  +$p->site_section = ADMINISTRATION;
            7  +$p->page_title = "Capturar foto";
            8  +
            9  +$list='<div id="captura"></div>'; 
           10  +$list.='<br/><form><input type=hidden name="member_id" value="'.$_REQUEST["member_id"].'"><input type=button value="Configurar..." onClick="webcam.configure()">&nbsp;&nbsp;&nbsp;<input type=button value="Sacar foto" onClick="webcam.snap()"></form>'; 
           11  +$list.='<div id="guardada"></div>';
           12  +
           13  +
           14  +$miembro = $_REQUEST["member_id"]; 
           15  + 
           16  +if(isset($_POST["Aceptar"])) {
           17  + $imageurl =  $_POST["nombre_imagen"];
           18  + $imagen = basename($imageurl);  
           19  + createThumbnail("media/fotos", $imagen, "media/fotos/mini", 100);
           20  + updateImage($miembro, $imagen);
           21  + header("location:http://".HTTP_BASE."/member_edit.php?mode=admin&member_id=".$miembro);
           22  + exit;
           23  +
           24  +}
           25  + 
           26  +
           27  +$p->DisplayPage($list);
           28  +
           29  +
           30  +
           31  +function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth)
           32  +{
           33  +$srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");
           34  +$origWidth = imagesx($srcImg);
           35  +$origHeight = imagesy($srcImg);
           36  +
           37  +$ratio = $thumbWidth / $origWidth;
           38  +$thumbHeight = $origHeight * $ratio;
           39  +
           40  +$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
           41  +imagecopyresized($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $origWidth, $origHeight);
           42  +
           43  +imagejpeg($thumbImg, "$thumbDirectory/$imageName");
           44  +}
           45  +
           46  +function updateImage($userid, $imagen)
           47  +{ 
           48  + global $cDB, $cErr;
           49  + 
           50  + $update = $cDB->Query("UPDATE ". DATABASE_PERSONS ." SET imagen='". $imagen ."' WHERE member_id='". $userid ."';"); 
           51  + if(!$update)
           52  +            $cErr->Error("No se ha podido actualizar la imagen");         
           53  +
           54  +}
           55  +
           56  +?>   
           57  +    <!-- First, include the JPEGCam JavaScript Library -->
           58  +    <script type="text/javascript" src="webcam.js"></script>
           59  +    
           60  +    <!-- Configure a few settings -->
           61  +    <script language="JavaScript">
           62  +        webcam.set_api_url( 'test.php' );
           63  +        webcam.set_quality( 90 ); // JPEG quality (1 - 100)
           64  +        webcam.set_shutter_sound( true ); // play shutter click sound
           65  +    </script>
           66  +    
           67  +    <!-- Next, write the movie to the page at 320x240 -->
           68  +
           69  + 
           70  +     <script language="JavaScript">
           71  +     
           72  +        document.getElementById('captura').innerHTML = webcam.get_html(320,240);
           73  +
           74  +    </script>
           75  +
           76  +    
           77  +
           78  +<script language="JavaScript">
           79  +        webcam.set_hook( 'onComplete', 'my_completion_handler' );
           80  +        
           81  +        function my_completion_handler(msg) {
           82  +            // extract URL out of PHP output
           83  +            if (msg.match(/(http\:\/\/\S+)/)) {
           84  +                var image_url = RegExp.$1;
           85  +                // show JPEG image in page
           86  +                document.getElementById('guardada').innerHTML = 
           87  +                    '<h3>Imagen guardada</h3>' + 
           88  +                    '<img src="'+image_url+'">' +
           89  +                    '<form action="capture_photo.php" method="post"><input type=hidden name="member_id" value="<?php echo $_REQUEST["member_id"] ?>"><br><input type="submit" name="Aceptar" value="Aceptar"><INPUT type="hidden" value="'+image_url+'" name="nombre_imagen"/></form>';
           90  +            }
           91  +            else alert("PHP Error: " + msg);
           92  +        }
           93  +    </script>
           94  +
           95  +   
           96  +
           97  +                   
           98  +
           99  +
          100  +
          101  +   

Added bdt/category_choose.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$p->site_section = LISTINGS;
            6  +$p->page_title = "Elegir categoría";
            7  +
            8  +include("includes/inc.forms.php");
            9  +include_once("classes/class.category.php");
           10  +
           11  +//
           12  +// Define form elements
           13  +//
           14  +$cUser->MustBeLevel(2);
           15  +
           16  +$categories = new cCategoryList;
           17  +$category_list = $categories->MakeCategoryArray();
           18  +unset($category_list[0]);
           19  +
           20  +$form->addElement("select", "category", "¿Qué categoría?", $category_list);
           21  +$form->addElement("static", null, null, null);
           22  +
           23  +$buttons[] = &HTML_QuickForm::createElement('submit', 'btnEdit', 'Editar');
           24  +$buttons[] = &HTML_QuickForm::createElement('submit', 'btnDelete', 'Borrar');
           25  +$form->addGroup($buttons, null, null, '&nbsp;');
           26  +
           27  +//
           28  +// Define form rules
           29  +//
           30  +
           31  +
           32  +//
           33  +// Then check if we are processing a submission or just displaying the form
           34  +//
           35  +if ($form->validate()) { // Form is validated so processes the data
           36  +   $form->freeze();
           37  + 	$form->process("process_data", false);
           38  +} else {
           39  +   $p->DisplayPage($form->toHtml());  // just display the form
           40  +}
           41  +
           42  +function process_data ($values) {
           43  +	global $p, $cErr;
           44  +	
           45  +	if(isset($values["btnDelete"])) {
           46  +		$category = new cCategory;
           47  +		$category->LoadCategory($values["category"]);
           48  +		if($category->HasListings()) {
           49  +			$output = "Esta categoría todavía tiene elementos en ella. Debes mover esos elementos a nuevas categorías, o borrarlos, antes de borrar esta categoría. Observa que los elementos podrían estar temporalmente inactivos, o haber expirado. En ese caso no aparecen en la lista de Ofertas o de Demandas.<P>";
           50  +
           51  +			$output .= "Elementos en esta categoría:<BR>";
           52  +			$listings = new cListingGroup(OFFER_LISTING);
           53  +			$listings->LoadListingGroup(null, $values["category"]);
           54  +			foreach($listings->listing as $listing)
           55  +				$output .= "OFFERED: ". $listing->description ." (". $listing->member_id .")<BR>"; 
           56  +				
           57  +			$listings = new cListingGroup(WANT_LISTING);
           58  +			$listings->LoadListingGroup(null, $values["category"]);
           59  +			foreach($listings->listing as $listing)
           60  +				$output .= "WANTED: ". $listing->description ." (". $listing->member_id .")<BR>";			
           61  +		} else {
           62  +			if($category->DeleteCategory())
           63  +				$output = "La categoría ha sido borrada.";
           64  +		}
           65  +	} else {
           66  +		header("location:http://".HTTP_BASE."/category_edit.php?category_id=". $values["category"]);
           67  +		exit;	
           68  +	}
           69  +	
           70  +	$p->DisplayPage($output);
           71  +}
           72  +
           73  +//
           74  +// Form rule validation functions
           75  +//
           76  +
           77  +
           78  +?>

Added bdt/category_create.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$p->site_section = LISTINGS;
            6  +$p->page_title = "Crear una nueva categoría";
            7  +
            8  +include("includes/inc.forms.php");
            9  +include_once("classes/class.category.php");
           10  +
           11  +//
           12  +// Define form elements
           13  +//
           14  +$cUser->MustBeLevel(2);
           15  +
           16  +$form->addElement("text", "category", "Descripción de la categoría", array("size" => 30, "maxlength" => 30));
           17  +$form->addElement("static", null, null, null);
           18  +
           19  +$form->addElement('submit', 'btnSubmit', 'Enviar');
           20  +
           21  +//
           22  +// Define form rules
           23  +//
           24  +$form->addRule('category', 'Introduce la descripción', 'required');
           25  +
           26  +//
           27  +// Then check if we are processing a submission or just displaying the form
           28  +//
           29  +if ($form->validate()) { // Form is validated so processes the data
           30  +   $form->freeze();
           31  + 	$form->process("process_data", false);
           32  +} else {
           33  +   $p->DisplayPage($form->toHtml());  // just display the form
           34  +}
           35  +
           36  +function process_data ($values) {
           37  +	global $p, $cErr;
           38  +	
           39  +	$category = new cCategory($values["category"]);
           40  +	
           41  +	if ($category->SaveNewCategory()) {
           42  +		$output = "Se ha creado la categoría.";
           43  +	} else {
           44  +		$output = "No se ha podido guardar la categoría. Prueba más tarde.";
           45  +	}
           46  +	
           47  +	$p->DisplayPage($output);
           48  +}
           49  +
           50  +//
           51  +// Form rule validation functions
           52  +//
           53  +
           54  +
           55  +?>

Added bdt/category_edit.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$p->site_section = LISTINGS;
            6  +$p->page_title = "Editar categoría";
            7  +
            8  +include("includes/inc.forms.php");
            9  +include_once("classes/class.category.php");
           10  +
           11  +//
           12  +// Define form elements
           13  +//
           14  +$cUser->MustBeLevel(2);
           15  +
           16  +$category = new cCategory();
           17  +$category->LoadCategory($_REQUEST["category_id"]);
           18  +
           19  +$form->addElement("hidden", "category_id", $_REQUEST["category_id"]);
           20  +$form->addElement("text", "category", "Descripción de la categoría", array("size" => 30, "maxlength" => 30));
           21  +$form->addElement("static", null, null, null);
           22  +
           23  +$form->addElement('submit', 'btnSubmit', 'Enviar');
           24  +
           25  +//
           26  +// Define form rules
           27  +//
           28  +$form->addRule('category', 'La descripción no puede estar en blanco', 'required');
           29  +
           30  +//
           31  +// Then check if we are processing a submission or just displaying the form
           32  +//
           33  +if ($form->validate()) { // Form is validated so processes the data
           34  +   $form->freeze();
           35  + 	$form->process("process_data", false);
           36  +} else {
           37  +	$form->setDefaults(array("category"=>$category->description));
           38  +   $p->DisplayPage($form->toHtml());  // just display the form
           39  +}
           40  +
           41  +function process_data ($values) {
           42  +	global $p, $cErr, $category;
           43  +	
           44  +	$category->description = $values["category"];
           45  +	if ($category->SaveCategory()) {
           46  +		$output = "La categoría ha sido actualizada.";
           47  +	} else {
           48  +		$output = "No se han podido guardar los cambios. Por favor inténtelo más tarde.";
           49  +	}
           50  +	
           51  +	$p->DisplayPage($output);
           52  +}
           53  +
           54  +//
           55  +// Form rule validation functions
           56  +//
           57  +
           58  +
           59  +?>

Added bdt/classes/class.backup.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +require_once ('Spreadsheet/Excel/Writer.php');
            9  +
           10  +class cBackup {
           11  +	var $all_tables; // an array of all table names
           12  +	var $workbook; // an object of class Spreadsheet_Excel_Writer;
           13  +	
           14  +	function cBackup() {
           15  +		global $cUser, $cDB;
           16  +		
           17  +		$this->workbook = new Spreadsheet_Excel_Writer();
           18  +		$this->workbook->setTempDir('/tmp');
           19  +		
           20  +		// TODO: The following should be dynamically generated
           21  +		$this->all_tables = array(DATABASE_LISTINGS, DATABASE_PERSONS, DATABASE_MEMBERS, DATABASE_TRADES, DATABASE_LOGINS, DATABASE_LOGGING, DATABASE_CATEGORIES, DATABASE_FEEDBACK, DATABASE_REBUTTAL, DATABASE_NEWS);
           22  +		$this->workbook->send('export_'. $cUser->member_id .'.xls');
           23  +	}
           24  +	
           25  +	function PrintHeaders($table_name, &$worksheet) {
           26  +		global $cDB;
           27  +	
           28  +		$query = $cDB->Query("DESC ". $table_name);
           29  +		$i=0;
           30  +		while($row = mysql_fetch_array($query)) {
           31  +			$worksheet->write(0, $i, $row[0]);			
           32  +			$field_names[$i] = $row[0];
           33  +			$i += 1;
           34  +		}		
           35  +		return $field_names;
           36  +	}
           37  +	
           38  +	function BackupAll() {
           39  +		global $cDB;
           40  +
           41  +		foreach ($this->all_tables as $table_name) {
           42  +			$worksheet =& $this->workbook->addWorksheet($table_name);
           43  +			
           44  +			$field_names = $this->PrintHeaders($table_name, $worksheet);
           45  +			
           46  +			$query = $cDB->Query("SELECT * FROM ". $table_name .";");
           47  +			
           48  +			$row_num=1;
           49  +			while($row = mysql_fetch_array($query)) {
           50  +				$col_num=0;
           51  +				foreach ($field_names as $field) {
           52  +					$worksheet->write($row_num, $col_num, $row[$field]);
           53  +					$col_num += 1;
           54  +				}
           55  +				$row_num += 1;
           56  +			}
           57  +		}
           58  +		// Let's send the file
           59  +		$this->workbook->close();		
           60  +	}
           61  +
           62  +
           63  +}
           64  +
           65  +?>

Added bdt/classes/class.category.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +include_once("class.listing.php");
            9  +
           10  +class cCategory
           11  +{
           12  +	var $id;
           13  +	var $parent;
           14  +	var $description;
           15  +	
           16  +	function cCategory($description=null, $parent=null) {
           17  +		if($description) {
           18  +			$this->description = $description;
           19  +			$this->parent = $parent;
           20  +		}
           21  +	}	
           22  +	
           23  +	function SaveNewCategory() {
           24  +		global $cDB, $cErr;
           25  +
           26  +		$insert = $cDB->Query("INSERT INTO ". DATABASE_CATEGORIES ."(parent_id, description) VALUES (". $cDB->EscTxt($this->parent) .", '". $this->description ."');");
           27  +		
           28  +		if(mysql_affected_rows() == 1) {
           29  +			$this->id = mysql_insert_id();
           30  +			return true;
           31  +		} else {
           32  +			return false;
           33  +		}
           34  +	}
           35  +	
           36  +	function SaveCategory() {
           37  +		global $cDB;
           38  +		
           39  +		$update = $cDB->Query("UPDATE ". DATABASE_CATEGORIES ." SET parent_id=". $cDB->EscTxt($this->parent) .", description='". $this->description ."' WHERE category_id=". $this->id .";");
           40  +		
           41  +		return $update;
           42  +	}
           43  +	
           44  +	function LoadCategory($id) {
           45  +		global $cDB, $cErr;
           46  +	
           47  +		// select description for this code
           48  +		$query = $cDB->Query("SELECT parent_id, description FROM ".DATABASE_CATEGORIES." WHERE category_id='".$id."';");
           49  +		
           50  +		if($row = mysql_fetch_array($query)) {		
           51  +			$this->id = $id;
           52  +			$this->parent = $row[0];
           53  +			$this->description = $row[1];
           54  +		} else {
           55  +			$cErr->Error("There was an error accessing category code '".$id."'.  Please try again later.");
           56  +			include("redirect.php");
           57  +		}			
           58  +	}
           59  +
           60  +	function DeleteCategory() {
           61  +		global $cDB, $cErr;
           62  +	
           63  +		$delete = $cDB->Query("DELETE FROM ".DATABASE_CATEGORIES." WHERE category_id=". $this->id);
           64  +		
           65  +		if(mysql_affected_rows() == 1) {
           66  +			unset($this);	
           67  +			return true;
           68  +		} else {
           69  +			$cErr->Error("There was an error deleting category code '".$id."'.  Please try again later.");
           70  +			include("redirect.php");
           71  +		}
           72  +	}
           73  +
           74  +	function ShowCategory() {
           75  +		$output = $this->id .", ". $this->description . "<BR>";
           76  +		
           77  +		return $output;		
           78  +	}
           79  +	
           80  +	function HasListings() {
           81  +		$listings = new cListingGroup(OFFER_LISTING);
           82  +		if($listings->LoadListingGroup(null, $this->id))
           83  +			return true;	
           84  +			
           85  +		$listings = new cListingGroup(WANT_LISTING);
           86  +		if($listings->LoadListingGroup(null, $this->id))
           87  +			return true;	
           88  +			
           89  +		return false;		
           90  +	}	
           91  +} // cCategory
           92  +
           93  +class cCategoryList {
           94  +	var $category;	//Will be an array of object class cCategory
           95  +
           96  +	function LoadCategoryList($active_only=false, $type="%", $redirect=false) {	
           97  +		global $cDB, $cErr;
           98  +		
           99  +		if($active_only) {
          100  +			$query = $cDB->Query("SELECT DISTINCT ".DATABASE_CATEGORIES.".category_id, ".DATABASE_CATEGORIES.".description FROM ".DATABASE_CATEGORIES.", ".DATABASE_LISTINGS." WHERE ".DATABASE_LISTINGS.".category_code =".DATABASE_CATEGORIES.".category_id AND status='". ACTIVE ."' AND type LIKE '".$type."' ORDER BY ". DATABASE_CATEGORIES .".description;");
          101  +		
          102  +		} else {
          103  +			$query = $cDB->Query("SELECT category_id, description FROM ".DATABASE_CATEGORIES." ORDER BY description;");
          104  +		}
          105  +		
          106  +		$i = 0;
          107  +
          108  +		while($row = mysql_fetch_array($query))
          109  +		{
          110  +			$this->category[$i] = new cCategory;
          111  +			$this->category[$i]->LoadCategory($row[0]);
          112  +			$i += 1;
          113  +		}
          114  +
          115  +		if($i == 0) {
          116  +			if ($redirect) {
          117  +				$cErr->Error("There was an error accessing a category record.  Please try again later.");
          118  +				include("redirect.php");			
          119  +			} else {
          120  +				return false;
          121  +			}
          122  +		}	
          123  +		return true;	
          124  +	}
          125  +	
          126  +	function MakeCategoryArray($active_only=false, $type="%") {	
          127  +		$array["0"] = "";
          128  +		
          129  +		if($this->LoadCategoryList($active_only, $type)) {
          130  +			foreach($this->category as $category) {
          131  +				$array[$category->id] = $category->description;
          132  +			}
          133  +		}
          134  +		
          135  +		return $array;
          136  +	}
          137  +
          138  +}
          139  +
          140  +?>

Added bdt/classes/class.database.php

            1  +<?
            2  +if (!isset($global))
            3  +{
            4  +	die(__FILE__." was included directly.  This file should only be included via inc.global.php.  Include() that one instead.");
            5  +}
            6  +
            7  +class cDatabase
            8  +{
            9  +	var $isConnected;
           10  +	var $db_link;
           11  +
           12  +	function Database()
           13  +	{
           14  +		$this->isConnected = false;
           15  +	}
           16  +
           17  +	function Connect()
           18  +	{
           19  +		if ($this->isConnected)
           20  +			return;
           21  +
           22  +		$this->db_link = mysql_connect(DATABASE_SERVER,DATABASE_USERNAME,DATABASE_PASSWORD)
           23  +		       or die("Could not connect");	// TODO: fix error messages
           24  +		mysql_selectdb(DATABASE_NAME)
           25  +		       or die("Could not select database");	// TODO: fix error messages
           26  +		$this->isConnected=true;
           27  +	}
           28  +
           29  +	function Query($thequery)
           30  +	{
           31  +		if (!$this->isConnected)
           32  +			$this->Connect();
           33  +
           34  +		$ret = mysql_query($thequery);
           35  +//		       or die ("Query failed: ".mysql_errno() . ": " . mysql_error()); // TODO: fix error messages
           36  +		return $ret;
           37  +	}
           38  +
           39  +	function NumRows($thequery)
           40  +	{
           41  +		if (!$this->isConnected)
           42  +			$this->Connect();
           43  +
           44  +		$result = mysql_query($thequery);
           45  +
           46  +		return mysql_num_rows($result);
           47  +	}
           48  +
           49  +	function MakeSimpleTable($theQuery)
           50  +	{
           51  +		$query = $this->Query($theQuery);
           52  +
           53  +		/* Printing results in HTML */
           54  +		$table = "<TABLE>\n";
           55  +		while ($line = mysql_fetch_array($query, MYSQL_ASSOC)) {
           56  +			$table .= "\t<TR>\n";
           57  +			foreach ($line as $col_value)
           58  +			{
           59  +				$table .= "\t\t<TD>$col_value</TD>\n";
           60  +			}
           61  +			$table .= "\t</TR>\n";
           62  +		}
           63  +		$table .= "</TABLE>\n";
           64  +
           65  +		return $table;
           66  +	}
           67  +
           68  +	function EscTxt($text) {
           69  +		if($text) {
           70  +			if(MAGIC_QUOTES_ON) 
           71  +				return "'". $text ."'";
           72  +			else 
           73  +				return "'". addslashes($text) ."'";
           74  +		} else {
           75  +			return "null";
           76  +		}
           77  +	}
           78  +	
           79  +	function EscTxt2($text) {  // TODO: Rename to EscQueryTxt() and update through site
           80  +		if($text) {
           81  +			if(MAGIC_QUOTES_ON) 
           82  +				return "='". $text ."'";
           83  +			else 
           84  +				return "='". addslashes($text) ."'";
           85  +		} else {
           86  +			return " IS NULL";
           87  +		}
           88  +	}
           89  +		
           90  +	function UnEscTxt($text) {
           91  +		if(MAGIC_QUOTES_ON)
           92  +			return $text;
           93  +		else
           94  +			return stripslashes($text);
           95  +	}	
           96  +
           97  +}
           98  +
           99  +
          100  +$cDB = new cDatabase;
          101  +?>

Added bdt/classes/class.datetime.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +class cDateTime {
            9  +	var $year;					
           10  +	var $month;
           11  +	var $day;
           12  +	var $hour;
           13  +	var $minute;
           14  +	var $second;
           15  +	
           16  +	function cDateTime ($date_str, $redirect=true) { // TODO: There is a problem with timestamp()
           17  +		global $cErr;											 // for dates much earlier than 1970.	
           18  +		
           19  +		if(!$date_str)
           20  +			return;
           21  +		
           22  +		if(is_numeric($date_str)) {  // Probably came direct from the database -- try to format
           23  +			$date_str = substr($date_str,0,4)."-".substr($date_str,4,2)."-".substr($date_str,6,2)." ".substr($date_str,8,2).":".substr($date_str,10,2).":".substr($date_str,12,2);
           24  +		}
           25  +		
           26  +		if(($timestamp = strtotime($date_str)) == -1) {
           27  +			if(!$redirect)
           28  +				return false;
           29  +				
           30  +			$cErr->Error("Date format invalid in cDateTime.");
           31  +			include("redirect.php");
           32  +		}
           33  +		
           34  +		$this->year = date("Y", $timestamp);
           35  +		$this->month = date("m", $timestamp);
           36  +		$this->day = date("d", $timestamp);			
           37  +		$this->hour = date("H", $timestamp);
           38  +		$this->minute = date("i", $timestamp);
           39  +		$this->second = date("s", $timestamp);
           40  +		return true;
           41  +	}
           42  +	
           43  +	function Set($datestr) {
           44  +		return $this->cDateTime($datestr);
           45  +	}
           46  +	
           47  +	function MySQLTime () {
           48  +		return $this->year . $this->month . $this->day . $this->hour . $this->minute . $this->second;
           49  +	}
           50  +	
           51  +	function MySQLDate () {
           52  +		return $this->year . $this->month . $this->day;
           53  +	}
           54  +	
           55  +	function StandardDate () {
           56  +		return $this->year ."/". $this->month ."/". $this->day;
           57  +	}
           58  +	
           59  +	function ShortDate () {
           60  +		if (MONTH_FIRST)
           61  +			return sprintf("%d/%d/%s", $this->month, $this->day, substr($this->year, 2, 2));
           62  +		else
           63  +			return sprintf("%d/%d/%s", $this->day, $this->month, substr($this->year, 2, 2));
           64  +	}
           65  +	
           66  +	function Timestamp () {
           67  +		return strtotime($this->year ."/". $this->month ."/". $this->day ." ". $this->hour .":". $this->minute .":". $this->second);
           68  +	}
           69  +	
           70  +	function DateArray() {
           71  +		return array ('d'=>$this->day,'F'=>$this->month,'Y'=>$this->year);
           72  +	}
           73  +	
           74  +	function MinutesAgo () {
           75  +		return floor((strtotime("now") - $this->Timestamp())/60);
           76  +	}	
           77  +	
           78  +	function DaysAgo () {
           79  +		return floor((strtotime("now") - $this->Timestamp())/86400);
           80  +	}
           81  +}
           82  +
           83  +?>

Added bdt/classes/class.directory.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +    die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +require_once ("class.listing.php");
            9  +require_once ("File/PDF.php");
           10  +//require_once ("File_PDF/PDF.php");
           11  +
           12  +class cDirectory {
           13  +    var $member_list;
           14  +    var $offer_list;
           15  +    var $want_list;
           16  +    var $pdf;
           17  +    var $font;
           18  +    var $font_size;
           19  +    var $font_spacing;
           20  +    var $margin;
           21  +    var $column;
           22  +    
           23  +
           24  +    function cDirectory () {
           25  +        $this->member_list = new cMemberGroup();
           26  +        $this->member_list->LoadMemberGroup();
           27  +        $this->offer_list = new cListingGroup(OFFER_LISTING);
           28  +        $this->offer_list->LoadListingGroup("%");
           29  +        $this->want_list = new cListingGroup(WANT_LISTING);
           30  +        $this->want_list->LoadListingGroup("%");
           31  +        $this->column = 1;    
           32  +        $this->margin = 15;
           33  +        $this->font = "Times";
           34  +        $this->font_size = 12;
           35  +        $this->font_spacing = 5;
           36  +        $this->pdf = &File_PDF::factory("P", "mm", "A4");
           37  +        $this->pdf->open();
           38  +        $this->pdf->addPage("P");
           39  +        $this->pdf->setFont($this->font,"",$this->font_size);
           40  +        $this->pdf->setMargins($this->margin, $this->margin, "105");
           41  +        $this->pdf->setAutoPageBreak(true,"2");
           42  +        $this->pdf->setXY($this->margin,$this->margin);
           43  +        $this->pdf->SetDisplayMode("real","single");
           44  +    }
           45  +    
           46  +    function DownloadDirectory () {    
           47  +        $this->PrintFirstPage();
           48  +    
           49  +        $this->PrintSectionHeader("INFORMACIÓN DE LOS MIEMBROS",FIRST);
           50  +        $this->PrintMembers();
           51  +    
           52  +        $this->PrintSectionHeader("OFERTAS");
           53  +        $this->PrintListings(OFFER_LISTING);
           54  +        
           55  +        $this->PrintSectionHeader("DEMANDAS");
           56  +        $this->PrintListings(WANT_LISTING);
           57  +        
           58  +        $this->pdf->Output("bancodetiempo.pdf",false);
           59  +    }
           60  +    
           61  +    function PrintMembers() {    
           62  +        foreach($this->member_list->members as $member) {
           63  +            if ($member->account_type == "F")
           64  +                continue;    // Skip fund accounts
           65  +        
           66  +            $this->PrintLine("");
           67  +            $this->PrintTitle($member->PrimaryName());
           68  +            $this->PrintLine(" (". $member->member_id .")");
           69  +            if($member->person[0]->email)
           70  +                $this->PrintLine($member->person[0]->email);
           71  +            if($member->person[0]->phone1_number) {
           72  +                $this->PrintText($member->person[0]->DisplayPhone(1));
           73  +                if($member->person[0]->phone2_number)
           74  +                    $this->PrintText(", ". $member->person[0]->DisplayPhone(2));
           75  +                $this->PrintLine("");                
           76  +            }
           77  +        }
           78  +    }
           79  +    
           80  +    function PrintListings($type) {
           81  +        $curr_category = "";
           82  +        if($type == OFFER_LISTING)
           83  +            $listings =& $this->offer_list->listing;
           84  +        else 
           85  +            $listings =& $this->want_list->listing;
           86  +            
           87  +        foreach ($listings as $listing) {
           88  +            if($listing->status != ACTIVE)
           89  +                continue;
           90  +                
           91  +            if($listing->category->id != $curr_category) {
           92  +                $this->PrintCategoryHeader($listing->category->description);
           93  +                $curr_category = $listing->category->id;
           94  +            }
           95  +            
           96  +            $this->PrintTitle($listing->title);
           97  +            $this->PrintDescription($listing->description);
           98  +            $this->PrintMember($listing->member->PrimaryName());
           99  +        }    
          100  +    }
          101  +    
          102  +    function PrintSectionHeader($header, $first_page=false) {
          103  +        if(!$first_page)
          104  +            $this->NewPage();
          105  +        else
          106  +            $header = "\n". $header;
          107  + // HAY QUE HACER UNA FUNCION PARA QUE PASE DE UTF-8 A WINCP1252 AL LLAMAR AL WRITE           
          108  +        $this->pdf->setFont($this->font,"B", $this->font_size + 6);
          109  +        $header=iconv('utf-8', 'windows-1252', $header); 
          110  +        $this->pdf->Write($this->font_spacing + 2, $header . "\n");
          111  +        $this->pdf->setFont($this->font,"", $this->font_size);    
          112  +    }
          113  +    
          114  +    function PrintCategoryHeader($category) {
          115  +        $this->DoPageBreaks();
          116  +        $this->pdf->setFont($this->font,"B", $this->font_size + 2);
          117  +        $category=iconv('utf-8', 'windows-1252', $category); 
          118  +        $this->pdf->Write($this->font_spacing + 1, "\n" . $category . "\n");
          119  +        $this->pdf->setFont($this->font,"", $this->font_size);
          120  +    } 
          121  +    
          122  +    function PrintFirstPage() {
          123  +        $this->pdf->setFont($this->font,"BI",26);
          124  +        $this->pdf->Write(8,SITE_LONG_TITLE ." \n ");
          125  +   //     $this->pdf->Write(8,"Directorio de miembros\n");
          126  +        $this->pdf->setFont($this->font,"",$this->font_size);
          127  +    }
          128  +    
          129  +    function PrintTitle($title) {
          130  +        $this->pdf->setFont($this->font,"BI",$this->font_size);
          131  +        $title=iconv('utf-8', 'windows-1252', $title); 
          132  +        $this->pdf->Write($this->font_spacing, $title);
          133  +        $this->pdf->setFont($this->font,"",$this->font_size);
          134  +    }
          135  +    
          136  +    function PrintDescription($desc) {
          137  +        if ($desc) { 
          138  +            $this->pdf->setFont($this->font,"BI",$this->font_size);
          139  +            $desc=iconv('utf-8', 'windows-1252', $desc);
          140  +            $this->pdf->Write($this->font_spacing, ": ");
          141  +            $this->pdf->setFont($this->font,"",$this->font_size);
          142  +            
          143  +            if(strlen($desc) < 40) {
          144  +                $this->pdf->Write($this->font_spacing,$desc);
          145  +            } else {
          146  +                // Need to print long descriptions word-by-word so my 
          147  +                // simple column pagebreak system will work.  
          148  +                // TODO: Should extend File_PDF class instead...            
          149  +                $words = split(" ",$desc);
          150  +                foreach($words as $word) {
          151  +                    $this->DoPageBreaks();
          152  +                    $this->pdf->Write($this->font_spacing,$word . " ");
          153  +                }
          154  +            }
          155  +        } 
          156  +    }
          157  +    
          158  +    function PrintMember($name) {
          159  +        $this->PrintLine(" (". $name .")");
          160  +    }
          161  +    
          162  +    function PrintText ($text) {
          163  +        $text=iconv('utf-8', 'windows-1252', $text);
          164  +        $this->pdf->Write($this->font_spacing, $text);
          165  +    }
          166  +    
          167  +    function PrintLine($line) {
          168  +        $this->DoPageBreaks();
          169  +        $line=iconv('utf-8', 'windows-1252', $line);
          170  +        $this->pdf->Write($this->font_spacing, $line . "\n");
          171  +    }
          172  +
          173  +    function DoPageBreaks() {
          174  +        if($this->pdf->getY() >= 270) {
          175  +            if($this->column == 2) {
          176  +                $this->NewPage();
          177  +            } else { // New Column
          178  +                $this->NewColumn();
          179  +            } 
          180  +        }    
          181  +    }
          182  +    
          183  +    function NewPage() {
          184  +        $this->pdf->addPage("P");
          185  +        $this->pdf->setXY($this->margin,$this->margin);
          186  +        $this->pdf->setMargins($this->margin,$this->margin,"105");
          187  +        $this->pdf->setFont($this->font,"", $this->font_size);
          188  +        $this->column = 1;    
          189  +    }
          190  +    
          191  +    function NewColumn() {
          192  +        $this->pdf->setMargins("115",$this->margin,$this->margin);
          193  +        $this->pdf->setXY("115",$this->margin);
          194  +        $this->column = 2;    
          195  +    }
          196  +}
          197  +
          198  +?>

Added bdt/classes/class.error.php

            1  +<?
            2  +if (!isset($global))
            3  +{
            4  +	die(__FILE__." was included directly.  This file should only be included via inc.global.php.  Include() that one instead.");
            5  +}
            6  +
            7  +define ("ERROR_ARRAY_SEVERITY", 0);
            8  +define ("ERROR_ARRAY_MESSAGE", 1);
            9  +define ("ERROR_ARRAY_FILE", 2);
           10  +define ("ERROR_ARRAY_LINE", 3);
           11  +
           12  +define ("ERROR_SEVERITY_INFO",1);
           13  +define ("ERROR_SEVERITY_LOW",2);
           14  +define ("ERROR_SEVERITY_MED",3);
           15  +define ("ERROR_SEVERITY_HIGH",4);
           16  +define ("ERROR_SEVERITY_STOP",5);
           17  +
           18  +
           19  +class cError
           20  +{
           21  +
           22  +	var $retval;
           23  +	var $retobj;
           24  +
           25  +	var $arrErrors;
           26  +
           27  +	function cError()
           28  +	{
           29  +		$this->arrErrors = array();
           30  +
           31  +		if (isset($_SESSION["errors_saved"]))
           32  +		{
           33  +			$this->arrErrors = $_SESSION["errors_saved"];
           34  +			unset ($_SESSION["errors_saved"]);	// don't want the errors to keep appearing...
           35  +		}
           36  +
           37  +
           38  +	}
           39  +
           40  +	function Error($message, $severity=0, $file="", $line=0)
           41  +	{
           42  +		if ($severity==0)
           43  +			$severity = ERROR_SEVERITY_LOW;
           44  +
           45  +		$this->arrErrors[]=array(ERROR_ARRAY_MESSAGE => $message,
           46  +					ERROR_ARRAY_SEVERITY => $severity,
           47  +					ERROR_ARRAY_FILE => $file,
           48  +					ERROR_ARRAY_LINE => $line);
           49  +
           50  +		if ($severity==ERROR_SEVERITY_STOP)
           51  +			$this->DoStopError();
           52  +	}
           53  +
           54  +	function SaveErrors()
           55  +	{	// we're about to redirect, but want to remember the errors, so put them in session temporarily.
           56  +
           57  +		$_SESSION["errors_saved"] = $this->arrErrors;
           58  +	}
           59  +
           60  +	function DoStopError()
           61  +	{
           62  +
           63  +		$box = $this->ErrorBox();
           64  +
           65  +		die ($box);
           66  +	}
           67  +
           68  +	function ErrorBox()
           69  +	{
           70  +		$output="";
           71  +
           72  +		foreach($this->arrErrors as $oneErr)
           73  +		{
           74  +			$output.=$this->ErrorBoxError($oneErr);
           75  +		}
           76  +
           77  +//		$msg = "<DIV class=ErrorBoxMsg>Errors occured on this page:</DIV>";
           78  +		$msg = "<FONT color=RED size=2>Ha ocurrido un error:<BR>";
           79  +
           80  +		if (strlen($output)>0)
           81  +			$output = $msg.$output."</FONT><BR>";
           82  +//			$output = "<CENTER><DIV class=ErrorBox>".$msg.$output."</DIV></CENTER>";
           83  +
           84  +		return $output;
           85  +	}
           86  +
           87  +	function ErrorBoxError($oneErr)
           88  +	{
           89  +		//if ($oneErr[ERROR_ARRAY_SEVERITY]==ERROR_SEVERITY_INFO && !DEBUG)
           90  +		//	return "";
           91  +
           92  +		$output="<DIV class=ErrorBoxLine>".$this->SeverityNote($oneErr[ERROR_ARRAY_SEVERITY]).$oneErr[ERROR_ARRAY_MESSAGE];
           93  +
           94  +		if  (DEBUG && $oneErr[ERROR_ARRAY_FILE] != "")
           95  +		{
           96  +			$output.="<DIV class=FileLine> ".$oneErr[ERROR_ARRAY_FILE];
           97  +			if ($oneErr[ERROR_ARRAY_LINE] != 0)
           98  +				$output.=" (".$oneErr[ERROR_ARRAY_LINE].")";
           99  +			$output.="</DIV>";
          100  +		}
          101  +
          102  +		$output .= "</DIV>";
          103  +
          104  +		return $output;
          105  +	}
          106  +
          107  +	function SeverityNote($sev)
          108  +	{
          109  +		switch($sev)
          110  +		{
          111  +			case ERROR_SEVERITY_INFO:
          112  +//				return "(INFO) ";
          113  +				return "";
          114  +				break;
          115  +			case ERROR_SEVERITY_LOW:
          116  +				return "";
          117  +				break;
          118  +			case ERROR_SEVERITY_MED:
          119  +				return "(MED) ";
          120  +				break;
          121  +			case ERROR_SEVERITY_HIGH:
          122  +				return "(HIGH) ";
          123  +				break;
          124  +			case ERROR_SEVERITY_STOP:
          125  +				return "(STOP) ";
          126  +				break;
          127  +			default:
          128  +				return "";
          129  +				break;
          130  +		}
          131  +
          132  +	}
          133  +
          134  +
          135  +	function ReturnValue($message, $obj="")
          136  +	{
          137  +		$this->retval = $message;
          138  +		$this->retobj = $obj;
          139  +	}
          140  +}
          141  +
          142  +
          143  +$cErr = new cError;
          144  +?>

Added bdt/classes/class.feedback.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +require_once("class.trade.php");
            9  +
           10  +class cFeedback {	
           11  +	var $feedback_id;
           12  +	var $feedback_date;
           13  +	var $status;
           14  +	var $member_author;  // will be an object of class cMember
           15  +	var $member_about;	// will be an object of class cMember
           16  +	var $trade_id;
           17  +	var $rating;
           18  +	var $comment;
           19  +	var $rebuttals;		// will be an object of class cRebuttalGroup, if rebuttals exist
           20  +	var $context;			// indicates whether the author of this feedback was the BUYER or SELLER
           21  +	var $category;			// category of the associated trade
           22  +		
           23  +	function cFeedback ($member_id_author=null, $member_id_about=null, $context=null, $category=null, $trade_id=null, $rating=null, $comment=null) { // TODO: derive context & category
           24  +		if($member_id_author) {												// rather than passing them
           25  +			$this->status = ACTIVE;
           26  +			$this->member_author = new cMember();
           27  +			$this->member_author->LoadMember($member_id_author);
           28  +			$this->member_about = new cMember();
           29  +			$this->member_about->LoadMember($member_id_about);
           30  +			$this->trade_id = $trade_id;
           31  +			$this->rating = $rating;
           32  +			$this->comment = $comment;
           33  +			$this->context = $context;
           34  +			$this->category = new cCategory();
           35  +			$this->category->LoadCategory($category);
           36  +		}
           37  +	}
           38  +	
           39  +/*	function VerifyTradeMembers() { // Prevent accidental or malicious entry of feedback in which
           40  +		global $cErr;					  // seller and buyer do not match up with the recorded trade.
           41  +		
           42  +		if ($this->member_about->member_id == $this->trade->member_from->member_id) {
           43  +			if ($this->member_author->member_id == $this->trade->member_to->member_id)
           44  +				return true;
           45  +		} elseif ($this->member_about->member_id == $this->trade->member_to->member_id) {
           46  +			if ($this->member_author->member_id == $this->trade->member_from->member_id)
           47  +				return true;
           48  +		} 
           49  +		
           50  +		$cErr->Error("Members do not match the trade selected.");
           51  +		include("redirect.php");	
           52  +	} */
           53  +	
           54  +	function SaveFeedback () {
           55  +		global $cDB, $cErr;
           56  +		
           57  +//		$this->VerifyTradeMembers();
           58  +		if($this->FindTradeFeedback($this->trade_id, $this->member_author->member_id)) {
           59  +			$cErr->Error("No se puede crear una doble valoración.");
           60  +			return false;
           61  +		}
           62  +		
           63  +		$insert = $cDB->Query("INSERT INTO ". DATABASE_FEEDBACK ."(feedback_date, status, member_id_author, member_id_about, trade_id, rating, comment) VALUES (now(), '".$this->status ."', '". $this->member_author->member_id ."', '". $this->member_about->member_id ."', ". $this->trade_id .", '".$this->rating ."', ". $cDB->EscTxt($this->comment) .");");
           64  +
           65  +		if(mysql_affected_rows() == 1) {
           66  +			$this->feedback_id = mysql_insert_id();	
           67  +			$query = $cDB->Query("SELECT feedback_date from ". DATABASE_FEEDBACK ." WHERE feedback_id=". $this->feedback_id .";");
           68  +			$row = mysql_fetch_array($query);
           69  +			$this->feedback_date = $row[0];	
           70  +			return true;
           71  +		} else {
           72  +			return false;
           73  +		}	
           74  +	}
           75  +	
           76  +	function LoadFeedback ($feedback_id) {
           77  +		global $cDB, $cErr;
           78  +		
           79  +		$query = $cDB->Query("SELECT feedback_date, ".DATABASE_FEEDBACK.".status, member_id_author, member_id_about, ".DATABASE_FEEDBACK.".trade_id, rating, comment, member_id_from, category FROM ".DATABASE_FEEDBACK.",". DATABASE_TRADES ." WHERE ".DATABASE_FEEDBACK.".trade_id=". DATABASE_TRADES .".trade_id AND feedback_id=".$feedback_id.";");
           80  +		
           81  +		if($row = mysql_fetch_array($query)) {		
           82  +			$this->feedback_id = $feedback_id;		
           83  +			$this->feedback_date = new cDateTime($row[0]);
           84  +			$this->status = $row[1];
           85  +			$this->member_author = new cMember; 
           86  +			$this->member_author->LoadMember($row[2]);
           87  +			$this->member_about = new cMember;
           88  +			$this->member_about->LoadMember($row[3]);
           89  +			$this->trade_id = $row[4];
           90  +			$this->rating = $row[5];
           91  +			$this->comment = $cDB->UnEscTxt($row[6]);
           92  +			if($row[7] == $row[3])
           93  +				$this->context = BUYER;
           94  +			else
           95  +				$this->context = SELLER;
           96  +				
           97  +			$this->category = new cCategory();
           98  +			$this->category->LoadCategory($row[8]);	
           99  +			$rebuttal_group = new cFeedbackRebuttalGroup();
          100  +			if($rebuttal_group->LoadRebuttalGroup($feedback_id))
          101  +				$this->rebuttals = $rebuttal_group;
          102  +			return true;
          103  +		} else {
          104  +			$cErr->Error("Ocurrió un error al acceder a la tabla de valoraciones.  Por favor, inténtelo más tarde.");
          105  +			include("redirect.php");
          106  +		}		
          107  +	}
          108  +
          109  +	function FindTradeFeedback ($trade_id, $member_id) {
          110  +		global $cDB;
          111  +		
          112  +		$query = $cDB->Query("SELECT feedback_id FROM ". DATABASE_FEEDBACK ." WHERE trade_id=". $trade_id ." AND member_id_author='". $member_id ."';");
          113  +		
          114  +		if($row = mysql_fetch_array($query))
          115  +			return $row[0];
          116  +		else
          117  +			return false;
          118  +	}
          119  +	
          120  +	function DisplayFeedback () {
          121  +		return $this->RatingText() . "<BR>" . $this->feedback_date->StandardDate(). "<BR>". $this->Context() . "<BR>". $this->member_author->PrimaryName() ." (" . $this->member_author->member_id . ")" . "<BR>" . $this->category->description . "<BR>" . $this->comment;
          122  +	}
          123  +	
          124  +	function RatingText () {
          125  +		if ($this->rating == POSITIVE)
          126  +			return "Positivo";
          127  +		elseif ($this->rating == NEGATIVE)
          128  +			return "Negativo";
          129  +		else
          130  +			return "Neutral";
          131  +	}	
          132  +	
          133  +	function Context () {
          134  +		if ($this->context == SELLER)
          135  +			return "Vendedor";
          136  +		else
          137  +			return "Comprador";
          138  +	}
          139  +}
          140  +	
          141  +class cFeedbackGroup {
          142  +	var $feedback;		// will be an array of cFeedback objects
          143  +	var $member_id;
          144  +	var $context;		// Buyer or Seller or Both
          145  +	var $since_date;
          146  +	var $num_positive=0;
          147  +	var $num_negative=0;
          148  +	var $num_neutral=0;
          149  +	
          150  +	function LoadFeedbackGroup ($member_id, $context=null, $since_date=LONG_LONG_AGO) {
          151  +		global $cDB, $cErr;
          152  +				
          153  +		$this->member_id = $member_id;
          154  +		$this->since_date = new cDateTime($since_date);
          155  +				
          156  +		$query = "SELECT feedback_id FROM ".DATABASE_FEEDBACK;
          157  +		
          158  +		if($context == BUYER)
          159  +			$query .= ", ". DATABASE_TRADES ." WHERE member_id_to=member_id_about AND";
          160  +		elseif ($context == SELLER) 
          161  +			$query .= ", ". DATABASE_TRADES ." WHERE member_id_from=member_id_about AND";
          162  +		else
          163  +			$query .= " WHERE";
          164  +		
          165  +		$query .= " feedback_date >= '". $this->since_date->MySQLTime() ."' AND member_id_about='".$this->member_id."' AND status='A' ORDER BY feedback_date DESC;";
          166  +		//echo $query;
          167  +		
          168  +		$query = $cDB->Query($query);
          169  +		
          170  +		$i=0;
          171  +		while($row = mysql_fetch_array($query))
          172  +		{
          173  +			$this->feedback[$i] = new cFeedback;			
          174  +			$this->feedback[$i]->LoadFeedback($row[0]);
          175  +			if($this->feedback[$i]->rating == POSITIVE)
          176  +				$this->num_positive += 1;
          177  +			elseif($this->feedback[$i]->rating == NEGATIVE)
          178  +				$this->num_negative += 1;
          179  +			else
          180  +				$this->num_neutral += 1;
          181  +			$i += 1;
          182  +		}
          183  +		
          184  +		if($i == 0)
          185  +			return false;
          186  +		else
          187  +			return true;
          188  +	}
          189  +	
          190  +	function PercentPositive() {
          191  +		return number_format(($this->num_positive / ($this->num_positive + $this->num_negative + $this->num_neutral)) * 100, 0); 
          192  +	}
          193  +	
          194  +	function TotalFeedback() {
          195  +		return $this->num_positive + $this->num_negative + $this->num_neutral;
          196  +	}
          197  +	
          198  +	function DisplayFeedbackTable($member_viewing) {		
          199  +		$output = "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH=\"100%\"><TR BGCOLOR=\"#d8dbea\"><TD><FONT SIZE=2><B>Tipo</B></FONT></TD><TD><FONT SIZE=2><B>Fecha</B></FONT></TD><TD><FONT SIZE=2><B>Contexto</B></FONT></TD><TD><FONT SIZE=2><B>De</B></FONT></TD><TD><FONT SIZE=2><B>Comentario</B></FONT></TD></TR>";
          200  +		
          201  +		if(!$this->feedback)
          202  +			return $output. "</TABLE>";   // No feedback yet, presumably
          203  +		
          204  +		$i=0;
          205  +		foreach($this->feedback as $feedback) {
          206  +			if($feedback->rating == NEGATIVE)
          207  +				$fcolor = "red";
          208  +			elseif ($feedback->rating == POSITIVE)
          209  +				$fcolor = "#4a5fa4";
          210  +			else
          211  +				$fcolor = "#554f4f";
          212  +				
          213  +			if($i % 2)
          214  +				$bgcolor = "#e4e9ea";
          215  +			else
          216  +				$bgcolor = "#FFFFFF";
          217  +				
          218  +			$output .= "<TR VALIGN=TOP BGCOLOR=". $bgcolor ."><TD><FONT SIZE=2 COLOR=".$fcolor.">". $feedback->RatingText()."</FONT></TD><TD><FONT SIZE=2 COLOR=".$fcolor.">". $feedback->feedback_date->ShortDate() ."</FONT></TD><TD><FONT SIZE=2 COLOR=".$fcolor.">". $feedback->Context() .": " . $feedback->category->description ."</FONT></TD><TD><FONT SIZE=2 COLOR=".$fcolor.">". $feedback->member_author->member_id ."</FONT></TD><TD><FONT SIZE=2 COLOR=".$fcolor.">". $feedback->comment;
          219  +			if(isset($feedback->rebuttals))
          220  +				$output .= $feedback->rebuttals->DisplayRebuttalGroup($feedback->member_about->member_id); // TODO: Shouldn't have to pass this value, should incorporate into cFeedbackRebuttal
          221  +			
          222  +			if($feedback->rating != POSITIVE) {
          223  +				if ($member_viewing == $feedback->member_about->member_id)
          224  +					$output .= "<BR><A HREF=feedback_reply.php?feedback_id=". $feedback->feedback_id ."&mode=self&author=". $member_viewing ."&about=".$feedback->member_author->member_id .">Responder</A> "; 
          225  +				elseif ($member_viewing == $feedback->member_author->member_id)
          226  +					$output .= "<BR><A HREF=feedback_reply.php?feedback_id=". $feedback->feedback_id ."&mode=self&author=". $member_viewing ."&about=".$feedback->member_about->member_id .">Ampliar comentario</A> ";
          227  +			}
          228  +			
          229  +			$output .= "</FONT></TD></TR>";
          230  +			$i+=1;
          231  +		}	
          232  +		return $output ."</TABLE>";
          233  +	}
          234  +	
          235  +}
          236  +
          237  +class cFeedbackRebuttal {
          238  +	var $rebuttal_id;
          239  +	var $rebuttal_date;
          240  +	var $feedback_id;
          241  +	var $member_author;
          242  +	var $comment;
          243  +
          244  +	function cFeedbackRebuttal ($feedback_id=null, $member_id=null, $comment=null) {
          245  +		if($feedback_id) {
          246  +			$this->feedback_id = $feedback_id;
          247  +			$this->member_author = new cMember;
          248  +			$this->member_author->LoadMember($member_id);
          249  +			$this->comment = $comment;
          250  +		}
          251  +	}
          252  +	
          253  +	function SaveRebuttal () {
          254  +		global $cDB, $cErr;
          255  +		
          256  +		$insert = $cDB->Query("INSERT INTO ". DATABASE_REBUTTAL ."(rebuttal_date, member_id, feedback_id, comment) VALUES (now(), '".$this->member_author->member_id ."', '". $this->feedback_id ."', ". $cDB->EscTxt($this->comment) .");");
          257  +
          258  +		if(mysql_affected_rows() == 1) {
          259  +			$this->rebuttal_id = mysql_insert_id();	
          260  +			$query = $cDB->Query("SELECT rebuttal_date from ". DATABASE_REBUTTAL ." WHERE rebuttal_id=". $this->rebuttal_id .";");
          261  +			$row = mysql_fetch_array($query);
          262  +			$this->rebuttal_date = $row[0];	
          263  +			return true;
          264  +		} else {
          265  +			return false;
          266  +		}	
          267  +	}
          268  +	
          269  +	function LoadRebuttal ($rebuttal_id) {
          270  +		global $cDB, $cErr;
          271  +		
          272  +		$query = $cDB->Query("SELECT rebuttal_date, feedback_id, member_id, comment FROM ".DATABASE_REBUTTAL." WHERE rebuttal_id=".$rebuttal_id.";");
          273  +		
          274  +		if($row = mysql_fetch_array($query)) {		
          275  +			$this->rebuttal_id = $rebuttal_id;		
          276  +			$this->rebuttal_date = new cDateTime($row[0]);
          277  +			$this->feedback_id = $row[1];
          278  +			$this->member_author = new cMember; 
          279  +			$this->member_author->LoadMember($row[2]);
          280  +			$this->comment = $cDB->UnEscTxt($row[3]);
          281  +
          282  +			return true;
          283  +		} else {
          284  +			$cErr->Error("Ocurrió un error al acceder a la tabla de réplicas.  Por favor, inténtelo más tarde.");
          285  +			include("redirect.php");
          286  +		}		
          287  +	}
          288  +}	
          289  +
          290  +class cFeedbackRebuttalGroup {
          291  +	var $rebuttals;		// will be an array of cFeedbackRebuttal objects
          292  +	var $feedback_id;
          293  +	
          294  +	function LoadRebuttalGroup($feedback_id) {
          295  +		global $cDB, $cErr;
          296  +		
          297  +		$this->feedback_id = $feedback_id;
          298  +		$query = $cDB->Query("SELECT rebuttal_id FROM ".DATABASE_REBUTTAL." WHERE feedback_id=".$feedback_id." ORDER by rebuttal_date;");		
          299  +	
          300  +		$i=0;
          301  +		while($row = mysql_fetch_array($query))
          302  +		{
          303  +			$this->rebuttals[$i] = new cFeedbackRebuttal;			
          304  +			$this->rebuttals[$i]->LoadRebuttal($row[0]);
          305  +			$i += 1;
          306  +		}
          307  +		
          308  +		if($i == 0)
          309  +			return false;
          310  +		else
          311  +			return true;
          312  +	}
          313  +	
          314  +	function DisplayRebuttalGroup($member_about) {
          315  +		$output = "";
          316  +		foreach($this->rebuttals as $rebuttal) {
          317  +			if($member_about == $rebuttal->member_author->member_id)
          318  +				$output .= "<BR><B>Respuesta: </B>";
          319  +			else
          320  +				$output .= "<BR><B>Ampliación: </B>";
          321  +				
          322  +			$output .= $rebuttal->comment;
          323  +		}		
          324  +		return $output;
          325  +	}
          326  +}
          327  +	
          328  +?>

Added bdt/classes/class.ficha.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +    die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +require_once ("class.member.php");
            9  +require_once ("File/PDF.php");
           10  +//require_once ("File_PDF/PDF.php");
           11  +
           12  +class cFicha {
           13  +    var $member;
           14  +    var $pdf;
           15  +    var $font;
           16  +    var $font_size;
           17  +    var $font_spacing;
           18  +    var $margin;
           19  +    var $column;
           20  +       
           21  +        
           22  +
           23  +    function cFicha ($member=null) {
           24  +        if($member) {
           25  +        $this->member = $member;
           26  +        $this->column = 1;    
           27  +        $this->margin = 15;
           28  +        $this->font = "Helvetica";
           29  +        $this->font_size = 8;
           30  +        $this->font_spacing = 5;
           31  +        $this->pdf = &File_PDF::factory("P", "mm", "A4");
           32  +        $this->pdf->open();
           33  +        $this->pdf->addPage("P");
           34  +        $this->pdf->setFont($this->font,"",$this->font_size);
           35  +        $this->pdf->setMargins($this->margin, $this->margin, "105");
           36  +        $this->pdf->setAutoPageBreak(true,"2");
           37  +        $this->pdf->setXY($this->margin,$this->margin);
           38  +        $this->pdf->SetDisplayMode("real","single");
           39  +        }
           40  +    }
           41  + 
           42  +    function GenerarFicha () {    
           43  +        $this->ImagenTop();
           44  +        $this->LineasCorte(); 
           45  +        $this->Foto();
           46  +        $this->InfoContacto();
           47  +        $this->InfoComun();                      
           48  +        $this->pdf->Output("ficha.pdf",false);
           49  +    }
           50  +
           51  +    function LineasCorte () {
           52  +    $this->pdf->setLineWidth(0.2);
           53  +    $this->pdf->Line(25.7,23.7,25.7,103.8);
           54  +    $this->pdf->Line(105.7,23.7,105.7,103.8);
           55  +    $this->pdf->Line(13.2,36.3,128.2,36.3);
           56  +    $this->pdf->Line(13.2,84.3,128.2,84.3);  
           57  +    }
           58  +
           59  +     function ImagenTop () {
           60  +     $this->pdf->image('images/top.png', 23.6, 33.0, 94.2, 18.0); 
           61  +    }   
           62  +    
           63  +     function Foto () {       
           64  +     $imagen = 'media/fotos/'.$this->member->person[0]->imagen.'.jpg';     
           65  +     $this->pdf->image($imagen, 30.6, 54.2, 21.4, 17.2); 
           66  +    }  
           67  +    
           68  +    function InfoContacto() {
           69  +     $this->pdf->setXY( 48.0, 59.0); 
           70  +     $this->pdf->setFont($this->font,"",$this->font_size); 
           71  +     $fecha = new cDateTime($this->member->join_date);  
           72  +     $inscripcion='Fecha de inscripción    '.$fecha->ShortDate();
           73  +     $inscripcion=iconv('utf-8', 'windows-1252', $inscripcion);
           74  +     $this->pdf->Cell( 53.8,"", $inscripcion,"","", $align = 'R');
           75  +     
           76  +  /*   $this->pdf->setXY( 30.6, 77.0); 
           77  +     $this->pdf->setFont($this->font,"",$this->font_size);   
           78  +     $socio='Socio';
           79  +     $socio=iconv('utf-8', 'windows-1252', $socio);
           80  +     $this->pdf->Cell( 30.6,"", $socio,"","", $align = 'L');
           81  +   */  
           82  +     $this->pdf->setXY( 29.6, 75.0); 
           83  +     $this->pdf->setFont($this->font,"B",10);   
           84  +     $socio=$this->member->member_id;  
           85  +     $socio=iconv('utf-8', 'windows-1252', $socio);
           86  +     $this->pdf->Cell( 29.6,"", $socio,"","", $align = 'L');  
           87  +       
           88  +     if($this->member->person[0]->phone1_number !="")
           89  +        {   
           90  +        $this->pdf->setXY( 48.0, 64.0);                
           91  +        $telefono='Teléfono 1 - ';
           92  +        $this->pdf->setFont($this->font,"I",$this->font_size);        
           93  +        $telefono.=$this->member->person[0]->DisplayPhone("1");
           94  +        $telefono=iconv('utf-8', 'windows-1252', $telefono);       
           95  +        $this->pdf->Cell( 53.8,"", $telefono,"","", $align = 'R');  
           96  +        }  
           97  +     if($this->member->person[0]->phone2_number !="")
           98  +        {   
           99  +        $this->pdf->setXY( 48.0, 69.0);               
          100  +        $telefono='Teléfono 2 - ';
          101  +        $this->pdf->setFont($this->font,"I",$this->font_size);        
          102  +        $telefono.=$this->member->person[0]->DisplayPhone("2");
          103  +        $telefono=iconv('utf-8', 'windows-1252', $telefono);       
          104  +        $this->pdf->Cell( 53.8,"", $telefono,"","", $align = 'R');  
          105  +        } 
          106  +     if($this->member->person[0]->email !="")
          107  +        {   
          108  +        $this->pdf->setXY( 48.0, 74.0);               
          109  +        $this->pdf->setFont($this->font,"B",$this->font_size);     
          110  +        $this->pdf->setFillColor('rgb',0.55, 0, 0);    
          111  +        $email=$this->member->person[0]->email;
          112  +        $telefono=iconv('utf-8', 'windows-1252', $email);       
          113  +        $this->pdf->Cell( 53.8,"", $email,"","", $align = 'R');  
          114  +        }   
          115  +    }
          116  +    
          117  +    function InfoComun()
          118  +    {
          119  +     $this->pdf->setXY( 48.0, 53.0); 
          120  +     $this->pdf->setFont($this->font,"",8);
          121  +     $this->pdf->setFillColor('rgb',0.13, 0.19, 0.42);   
          122  +     $pie='www.bdtbilbao.org';
          123  +     $pie=iconv('utf-8', 'windows-1252', $pie);
          124  +     $this->pdf->Cell( 53.8,"", $pie,"","", $align = 'R');
          125  +     
          126  +     $this->pdf->setXY( 30.6, 80.5); 
          127  +     $this->pdf->setFont($this->font,"",5);   
          128  +     $pie='Si encuentra esta tarjeta, por favor, avísenos en bancodeltiempo@barriosaltos.net';
          129  +     $pie=iconv('utf-8', 'windows-1252', $pie);
          130  +     $this->pdf->Cell( 30.6,"", $pie,"","", $align = 'L');
          131  +    }                        
          132  +   
          133  +}
          134  + ?>

Added bdt/classes/class.fraction.php

            1  +<?
            2  +/**
            3  +* Fraction class
            4  +* Author: Ferry Firmansjah (firmanf@bigfoot.com)
            5  +* Version: 0.8 (getting there, but still not perfect yet)
            6  +* Last update: 2001/05/28
            7  +* Description:
            8  +*   A class that represents a Fraction number.
            9  +*   The class can perform the more common mathematical
           10  +*   operations: addition, subtraction, multiplication,
           11  +*   division.  The only caveat is that the other
           12  +*   argument also has to be a Fraction.
           13  +*
           14  +*   The constructor is able to accept almost any variable
           15  +*   data type: string, double, integer, even another Fraction.
           16  +*   The class is also able to reduce the Fraction to
           17  +*   (practically) the lowest common denominator (using the
           18  +*   reduce() method call) using Euclid's Algorithm
           19  +*   (www.mcn.net/~jimloy/euclids.html).
           20  +*
           21  +* Changes:
           22  +*   For 0.8:
           23  +*   Pretty major reorganization of the classes: we now
           24  +*   use a factory to get the Fraction.
           25  +*   The advantages are:
           26  +*   - all Fraction has a reference to the factory that
           27  +*     created it.
           28  +*   - the factory also provides methods to manipulate
           29  +*     the Fraction class itself.
           30  +*
           31  +*   Modification to fraction/Fraction class:
           32  +*   - class name changed to Fraction; 'fraction' will still
           33  +*     work.
           34  +*   - Fraction class constructor now accepts an optional
           35  +*     second parameter which is a reference to the fraction
           36  +*     factory/tool.
           37  +*   - Fraction class now correctly prints 0 if the fraction's
           38  +*     value is 0.
           39  +*   - a lot of the functionality has been moved to the
           40  +*     FractionTool class -- which should make the Fraction
           41  +*     class leaner.
           42  +*   - Fraction takes advantage of a singleton FractionTool
           43  +*     instance.
           44  +*
           45  +*   Modification to fractionTool/FractionTool class:
           46  +*   - class name changed to FractionTool; 'fractionTool' will still
           47  +*     work.
           48  +*   - reduce corrected to work with negative numbers.
           49  +*     Previously, this would cause an infinite loop.
           50  +*   - upon instantiation, unserialize self to the global
           51  +*     constant variable 'FractionTool_instance'.  If
           52  +*     fraction class needs this, then the FractionTool
           53  +*     can be retrieved by deserializing the 'FractionTool_instance'
           54  +*     constant variable.
           55  +*
           56  +*
           57  +*   For 0.7:
           58  +*   ========
           59  +*   pack() is now replaced by reduce().
           60  +*   toString() now does not automatically
           61  +*     reduce().
           62  +*
           63  +* To do:
           64  +*   (1) Add other operations if needed.  I don't know
           65  +*       how much interest there is for the more complex
           66  +*       operations, but it might be added in the future.
           67  +*       I just don't want the class to get too bloated.
           68  +*
           69  +*/
           70  +class Fraction {
           71  +  var $num = 1, $denom = 1;
           72  +  var $classname = "Fraction";
           73  +  var $tool = null;
           74  +
           75  +  /**
           76  +   * Creates a Fraction.  This constructor accepts
           77  +   * a string, double, integer, or an array of
           78  +   * one, two or three elements.
           79  +   * e.g. $val1 = new Fraction("5 1/3");
           80  +   *      $val1 = new Fraction(1.25);
           81  +   *      $val1 = new Fraction(20);
           82  +   *      $val1 = new Fraction(array (5, 1, 3));
           83  +   */
           84  +  function Fraction ($val, $tool=null) {
           85  +    $this->tool = $tool;
           86  +    if (is_string($val)) {
           87  +      if (ereg("^(-?[0-9]+)$", $val, $regs)) {
           88  +        $this->create(0, $regs[1],1);
           89  +      } elseif (ereg("^(-?[0-9]+)[ ]*/[ ]*([0-9]+)$",$val,$regs)) {
           90  +        $this->create(0, $regs[1], $regs[2]);
           91  +      } elseif (ereg("^(-?[0-9]+)[ ]+([0-9]+)[ ]*/[ ]*([0-9]+)$",$val,$regs)){
           92  +        $this->create($regs[1], $regs[2], $regs[3]);
           93  +      }
           94  +    } elseif (is_double($val)) {
           95  +      $len = strlen($val);
           96  +      $pos = strpos($val, ".");
           97  +      $this->create(0, ((double)$val) * pow (10, ($len - $pos - 1))
           98  +        , pow (10, ($len - $pos - 1)));
           99  +    } elseif (is_int($val)) {
          100  +      $this->create(0, $val,1);
          101  +    } elseif (is_array($val)) {
          102  +      if (sizeof($val) == 1) { $this->create(0, $val[0], 1); }
          103  +      elseif (sizeof($val)==2) { $this->create(0, $val[0],$val[1]); }
          104  +      elseif (sizeof($val)>=3) {
          105  +        $this->create ($val[0], $val[1], $val[2]);
          106  +      }
          107  +    } elseif (is_bool($val)) {
          108  +      $this->create(0, ($val?$val:0), 1);
          109  +    } else {
          110  +      // don't know what to do... just return null
          111  +      return $this->create (0, 0, 1);
          112  +    }
          113  +  }
          114  +
          115  +  /** Inner method that actually creates the Fraction.
          116  +   * This should not be called directly from outside of this class.
          117  +   */
          118  +  function create($whole, $num, $denom) {
          119  +    if ($denom == 0) { $denom = 1; }
          120  +    // negative?
          121  +    if ((($whole < 0) xor ($denom < 0)) xor ($num < 0)) {
          122  +      // yes make the numerator negative
          123  +      $this->num = -1 * (abs($whole) * abs($denom) + abs($num));
          124  +    } else {
          125  +      $this->num = (abs($whole) * abs($denom) + abs($num));
          126  +    }
          127  +    // denom always positive
          128  +    $this->denom = abs($denom);
          129  +  }
          130  +
          131  +  /** Subtract another Fraction/integer from this Fraction */
          132  +  function subtract ($other) {
          133  +    $this->getTool();
          134  +    return ($this->tool->subtract(&$this, $other));
          135  +  }
          136  +
          137  +  /**
          138  +   * Adds another Fraction/integer to this Fraction.
          139  +   */
          140  +  function add ($other) {
          141  +    $this->getTool();
          142  +    return ($this->tool->add(&$this, $other));
          143  +  }
          144  +
          145  +  /** Multiple this Fraction by another Fraction or whole number */
          146  +  function multiply ($other) {
          147  +    $this->getTool();
          148  +    return ($this->tool->multiply(&$this, $other));
          149  +  }
          150  +
          151  +  /** Divide this Fraction by another Fraction or whole number */
          152  +  function divide ($other) {
          153  +    $this->getTool();
          154  +    return ($this->tool->divide(&$this, $other));
          155  +  }
          156  +
          157  +
          158  +  /** Whether the object is a Fraction or not */
          159  +  function isFraction ($other) {
          160  +    $this->getTool();
          161  +    return ($this->tool->isFraction($other));
          162  +  }
          163  +
          164  +  /** Reduce the Fraction */
          165  +  function reduce () {
          166  +    $this->getTool();
          167  +    $this->tool->reduce (&$this);
          168  +  }
          169  +
          170  +  /** Returns a string representation of the Fraction. */
          171  +  function toString() {
          172  +    if (abs($this->num) >= abs($this->denom)) {
          173  +      if ($this->denom == 1) {
          174  +        return $this->num;
          175  +      }
          176  +
          177  +      if ($this->isNegative()) {
          178  +        $whole = ceil ($this->num / $this->denom);
          179  +      } else {
          180  +        $whole = floor ($this->num / $this->denom);
          181  +      }
          182  +      $num = abs($this->num % $this->denom);
          183  +    } else {
          184  +      $num = $this->num;
          185  +    }
          186  +    return ((empty($whole)?(empty($num)?"0":""):$whole)
          187  +      . (empty($num)? "" : " " . $num ."/". $this->denom));
          188  +  }
          189  +
          190  +  /** Returns a double representation of the Fraction **/
          191  +  function toDouble() {
          192  +    return (double) $this->num / $this->denom;
          193  +  }
          194  +
          195  +  /**
          196  +   * Whether this Fraction is equal to another Fraction.
          197  +   * Returns true or half.
          198  +   */
          199  +  function equals ($other) {
          200  +    $this->getTool();
          201  +    if ($this->tool->isFraction($other)) {
          202  +      return ($this->tool->areEqual ($this, $other));
          203  +    } elseif ($this->tool->canBeFraction($other)) {
          204  +      $tmp = $this->tool->createFraction($other);
          205  +      return ($this->equals($tmp));
          206  +    }
          207  +    return false;
          208  +  }
          209  +
          210  +  /**
          211  +   * Is this Fraction negative?
          212  +   * Returns true or false.
          213  +   */
          214  +  function isNegative () {
          215  +    return (($this->num < 0) xor ($this->denom < 0));
          216  +  }
          217  +
          218  +  function getTool() {
          219  +    if ($this->tool == null) {
          220  +      if (defined ("FractionTool_instance")) {
          221  +        $this->tool = unserialize (FractionTool_instance);
          222  +      } else {
          223  +        $this->tool = new FractionTool();
          224  +        define ("FractionTool_instance", serialize($this->tool));
          225  +      }
          226  +    }
          227  +    return $this->tool;
          228  +  }
          229  +}
          230  +
          231  +/**
          232  +* Fraction related tool.  Used by Fraction, but
          233  +* this class does not require Fraction.
          234  +*/
          235  +class FractionTool {
          236  +  var $classname = "FractionTool";
          237  +
          238  +  /* Constructor */
          239  +  function FractionTool(){
          240  +    // create an instance, and store it in a global instance variable
          241  +    if (! defined ("FractionTool_instance")) {
          242  +      define ("FractionTool_instance", serialize($this));
          243  +    }
          244  +  }
          245  +
          246  +  function createFraction ($val) {
          247  +    return (new Fraction ($val, &$this));
          248  +  }
          249  +
          250  +  /**
          251  +   * Find the greatest common divisor (gcd)
          252  +   * using Euclid's Algorithm. (read it from
          253  +   * http://www.mcn.net/~jimloy/euclids.html)
          254  +   * Takes in 2 values (numerator and denominator)
          255  +   * and returns the greatest common divisor.
          256  +   * Ideally, the first parameter is the larger
          257  +   * number of the two, but it's not necessary.
          258  +   */
          259  +  function gcd ($a, $b) {
          260  +    if ($b < 0 || $a < 0) {
          261  +      return $this->gcd(abs($a), abs($b));
          262  +    }
          263  +    if ($b > $a) {
          264  +      return $this->gcd($b, $a);
          265  +    }
          266  +    $rem = $a % $b;
          267  +    return (($rem == 0)?$b:$this->gcd($b,$rem));
          268  +  }
          269  +
          270  +  /**
          271  +   * Lowest Common Denominator (lcd) or
          272  +   * Lowest Common Multiple (lcm)
          273  +   */
          274  +  function lcd ($a, $b) {
          275  +    return (($a * $b) / $this->gcd($a, $b));
          276  +  }
          277  +
          278  +  /** Lowest Common Multiple (lcm),
          279  +   * another name for Lowest Common Denominator (lcd)
          280  +   */
          281  +  function lcm($a, $b) {
          282  +    return $this->lcd($a, $b);
          283  +  }
          284  +
          285  +  /** Subtract the part (Fraction or whole number) from the whole (Fraction) */
          286  +  function subtract ($whole, $part) {
          287  +    if ($this->isFraction($whole)
          288  +        && ($this->isFraction($part) || is_int($part))) {
          289  +      if (is_int($part)) {
          290  +        $whole->num -= $part * $whole->denom;
          291  +      } else {
          292  +        $lcd = $this->lcd ($whole->denom, $part->denom);
          293  +        $whole->num *= ($lcd / $whole->denom);
          294  +        $whole->denom *= ($lcd / $whole->denom);
          295  +        $whole->num -= ($part->num * ($lcd / $part->denom));
          296  +        $whole->reduce();
          297  +      }
          298  +    }
          299  +    return $whole;
          300  +  }
          301  +
          302  +  /**
          303  +   * Adds a Fraction to another Fraction or whole number.
          304  +   */
          305  +  function add ($other, $another) {
          306  +    if ($this->isFraction($other)
          307  +        && ($this->isFraction($another) || is_int($another))) {
          308  +      if (is_int($another)) {
          309  +        $other->num += $another * $other->denom;
          310  +      } else {
          311  +        $lcd = $this->lcd ($other->denom, $another->denom);
          312  +        $other->num *= ($lcd / $other->denom);
          313  +        $other->denom *= ($lcd / $other->denom);
          314  +        $other->num += ($another->num * ($lcd / $another->denom));
          315  +        $other->reduce();
          316  +      }
          317  +    }
          318  +    return $other;
          319  +  }
          320  +
          321  +  /** Multiple a Fraction by another Fraction or whole number */
          322  +  function multiply ($other, $another) {
          323  +    if ($this->isFraction($other)
          324  +        && ($this->isFraction($another) || is_int($another))) {
          325  +      if (is_int($another)) {
          326  +        $other->num *= $another;
          327  +      } else {
          328  +        $other->num *= $another->num;
          329  +        $other->denom *= $another->denom;
          330  +
          331  +        // reduce at the end as we usually get big numbers here
          332  +        $other->reduce();
          333  +      }
          334  +    }
          335  +    return $other;
          336  +  }
          337  +
          338  +  /** Divide the dividend Fraction by the divisor (Fraction or whole number) */
          339  +  function divide ($dividend, $divisor) {
          340  +    if ($this->isFraction($dividend)
          341  +        && ($this->isFraction($divisor) || is_int($divisor))) {
          342  +      if (is_int($divisor)) {
          343  +        $dividend->denom *= $divisor;
          344  +      } else {
          345  +        $dividend->num *= $divisor->denom;
          346  +        $dividend->denom *= $divisor->num;
          347  +      }
          348  +    }
          349  +    $dividend->reduce();
          350  +    return $dividend;
          351  +  }
          352  +
          353  +
          354  +
          355  +
          356  +  /**
          357  +   * Whether 2 Fractions are equal.
          358  +   * Returns true or false.
          359  +   */
          360  +  function areEqual ($other, $another) {
          361  +    if ($this->isFraction($other) && $this->isFraction($another)) {
          362  +      $other->reduce();
          363  +      $another->reduce();
          364  +      return ($other->toString() == $another->toString());
          365  +    } else {
          366  +      return false;
          367  +    }
          368  +  }
          369  +
          370  +  /** Reduce the Fraction */
          371  +  function reduce (&$obj) {
          372  +    if ($this->isFraction($obj)) {
          373  +      $gcd = $this->gcd($obj->num, $obj->denom);
          374  +      $obj->num /= $gcd;
          375  +      $obj->denom /= $gcd;
          376  +    }
          377  +    return $obj;
          378  +  }
          379  +
          380  +  /**
          381  +   * Whether the object is a Fraction.
          382  +   */
          383  +  function isFraction ($obj) {
          384  +    return (is_object($obj)
          385  +        && isset($obj->classname)
          386  +        && $obj->classname == "Fraction");
          387  +  }
          388  +
          389  +  /**
          390  +   * Whether the variable can be turned into a Fraction.
          391  +   */
          392  +  function canBeFraction ($obj) {
          393  +    return (is_string($obj)
          394  +        || is_double($obj)
          395  +        || is_integer($obj)
          396  +        || is_array($obj));
          397  +  }
          398  +}
          399  +
          400  +?>

Added bdt/classes/class.listing.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +include_once("class.category.php");
            9  +include_once("class.feedback.php");
           10  +
           11  +class cListing
           12  +{
           13  +	var $member; // this will be an object of class cMember
           14  +	var $title;
           15  +	var $description;
           16  +	var $category; // this will be an object of class cCategory
           17  +	var $rate;
           18  +	var $status;
           19  +	var $posting_date; // the date a listing was created or last modified
           20  +	var $expire_date;
           21  +	var $reactivate_date;
           22  +	var $type;
           23  +
           24  +
           25  +	function cListing($member=null, $values=null) {
           26  +		if($member) {
           27  +			$this->member = $member;
           28  +			$this->title = $values['title'];
           29  +			$this->description = $values['description'];
           30  +			$this->rate = $values['rate'];
           31  +			$this->expire_date = $values['expire_date'];
           32  +			$this->type = $values['type'];
           33  +			$this->reactivate_date = null;
           34  +			$this->status = 'A';
           35  +			$this->category = new cCategory();
           36  +			$this->category->LoadCategory($values['category']);
           37  +		}
           38  +		
           39  +	}	
           40  +
           41  +	function TypeCode() {
           42  +		if($this->type == OFFER_LISTING)
           43  +			return OFFER_LISTING_CODE;
           44  +		else
           45  +			return WANT_LISTING_CODE;			
           46  +	}
           47  +
           48  +	function TypeDesc($type_code) {
           49  +		if($type_code == OFFER_LISTING_CODE)
           50  +			return OFFER_LISTING;
           51  +		else
           52  +			return WANT_LISTING;			
           53  +	}
           54  +
           55  +	function SaveNewListing() {
           56  +		global $cDB, $cErr;		
           57  +
           58  +		$insert = $cDB->Query("INSERT INTO ".DATABASE_LISTINGS." (title, description, category_code, member_id, rate, status, expire_date, reactivate_date, type) VALUES (". $cDB->EscTxt($this->title) .",". $cDB->EscTxt($this->description) .",'". $this->category->id ."','". $this->member->member_id ."',". $cDB->EscTxt($this->rate) .",'". $this->status ."',". $cDB->EscTxt($this->expire_date) .",". $cDB->EscTxt($this->reactivate_date) .",'". $this->TypeCode() ."');");	
           59  +
           60  +		return $insert;
           61  +	}			
           62  +		
           63  +	function SaveListing($update_posting_date=true) {
           64  +		global $cDB, $cErr;			
           65  +		
           66  +		if(!$update_posting_date)
           67  +			$posting_date = ", posting_date=posting_date";
           68  +		else
           69  +			$posting_date = "";
           70  +
           71  +		$update = $cDB->Query("UPDATE ".DATABASE_LISTINGS." SET title=". $cDB->EscTxt($this->title) .", description=". $cDB->EscTxt($this->description) .", category_code='". $this->category->id ."', rate=". $cDB->EscTxt($this->rate) .", status='". $this->status ."', expire_date=". $cDB->EscTxt($this->expire_date) .", reactivate_date=". $cDB->EscTxt($this->reactivate_date) . $posting_date ." WHERE title=". $cDB->EscTxt($this->title) ." AND member_id='".$this->member->member_id ."' AND type='". $this->TypeCode() ."';");	
           72  +
           73  +		return $update;
           74  +	}
           75  +	
           76  +	function DeleteListing($title,$member_id,$type_code) {
           77  +		global $cDB, $cErr;
           78  +		
           79  +		$query = $cDB->Query("DELETE FROM ". DATABASE_LISTINGS ." WHERE title=".$cDB->EscTxt($title)." AND member_id='".$member_id."' AND type='". $type_code ."';");
           80  +
           81  +		return mysql_affected_rows();
           82  +	}
           83  +							
           84  +	function LoadListing($title,$member_id,$type_code)
           85  +	{
           86  +		global $cDB, $cErr;
           87  +		
           88  +		// select all offer data and populate the variables
           89  +		$query = $cDB->Query("SELECT description, category_code, member_id, rate, status, posting_date, expire_date, reactivate_date FROM ".DATABASE_LISTINGS." WHERE title=".$cDB->EscTxt($title)." AND member_id='".$member_id."' AND type='". $type_code ."';");
           90  +		
           91  +		if($row = mysql_fetch_array($query))
           92  +		{		
           93  +			$this->title=$title;
           94  +			$this->description=$cDB->UnEscTxt($row[0]);
           95  +			$this->member_id=$row[2];
           96  +			$this->rate=$cDB->UnEscTxt($row[3]);
           97  +			$this->status=$row[4];
           98  +			$this->posting_date=$row[5];
           99  +			$this->expire_date=$row[6];
          100  +			$this->reactivate_date=$row[7];
          101  +			$this->type=$this->TypeDesc($type_code);	
          102  +			$this->category = new cCategory();
          103  +			$this->category->LoadCategory($row[1]);		
          104  +		}
          105  +		else 
          106  +		{
          107  +			$cErr->Error("There was an error accessing the '".$cDB->EscTxt($title)."' listing for ".$member_id.".  Please try again later.");
          108  +			include("redirect.php");
          109  +		}		
          110  +		
          111  +		// load member associated with member_id
          112  +		$this->member = new cMember;
          113  +		$this->member->LoadMember($member_id);
          114  +		
          115  +		$this->DeactivateReactivate();
          116  +	}
          117  +	
          118  +    
          119  +	function DeactivateReactivate() {
          120  +		if($this->reactivate_date) {
          121  +			$reactivate_date = new cDateTime($this->reactivate_date);
          122  +			if ($this->status == INACTIVE and $reactivate_date->Timestamp() <= strtotime("now")) {
          123  +				$this->status = ACTIVE;
          124  +				$this->reactivate_date = null;
          125  +				$this->SaveListing();
          126  +			}
          127  +		}
          128  +		if($this->expire_date) {
          129  +			$expire_date = new cDateTime($this->expire_date);
          130  +			if ($this->status <> EXPIRED and $expire_date->Timestamp() <= strtotime("now")) {
          131  +				$this->status = EXPIRED;
          132  +				$this->SaveListing();
          133  +			}
          134  +		}
          135  +	}
          136  +			
          137  +	function ShowListing()
          138  +	{
          139  +		$output = $this->type . ":<BR>";
          140  +		$output .= $this->title . ", " . $this->description . ", " . $this->category->id . ", " . $this->member->member_id . ", " . $this->rate . ", " . $this->status . ", " . $this->posting_date . ", " . $this->expire_date . ", " . $this->reactivate_date . "<BR><BR>";
          141  +		$output .= $this->member->ShowMember();
          142  +		
          143  +		return $output;
          144  +	}
          145  +	
          146  +	function DisplayListing()
          147  +	{
          148  +		$output = "";
          149  +		if($this->description != "")
          150  +			$output .= "<STRONG>Descripción:</STRONG> ". $this->description ."<BR>";
          151  +		if($this->rate != "")
          152  +			$output .= "<STRONG>Valoración:</STRONG> ". $this->rate ."<BR>";		
          153  +		$output .= $this->member->DisplayMember();
          154  +		return $output;
          155  +	}	
          156  +}
          157  +
          158  +class cListingGroup
          159  +{
          160  +	var $title;
          161  +	var $listing;  // this will be an array of objects of type cListing
          162  +	var $num_listings;  // number of active offers
          163  +	var $type;
          164  +	var $type_code;
          165  +	
          166  +	function cListingGroup($type) {
          167  +		$this->type = $type;
          168  +		if($type == OFFER_LISTING)
          169  +			$this->type_code = OFFER_LISTING_CODE;
          170  +		else
          171  +			$this->type_code = WANT_LISTING_CODE;		
          172  +	}
          173  +	
          174  +	function InactivateAll($reactivate_date) {
          175  +		global $cErr;
          176  +		
          177  +		if (!isset($this->listing))
          178  +			return true;
          179  +		
          180  +		foreach($this->listing as $listing)	{
          181  +			$current_reactivate = new cDateTime($listing->reactivate_date, false);
          182  +			if(($listing->reactivate_date == null or $current_reactivate->Timestamp() < $reactivate_date->Timestamp()) and $listing->status != EXPIRED) {
          183  +				$listing->reactivate_date = $reactivate_date->MySQLDate();
          184  +				$listing->status = INACTIVE;
          185  +				$success = $listing->SaveListing();
          186  +				
          187  +				if(!$success)
          188  +					$cErr->Error("Could not inactivate listing: '".$listing->title."'");
          189  +			}
          190  +		}
          191  +		return true;
          192  +	}
          193  +	
          194  +	function ExpireAll($expire_date) {
          195  +		global $cErr;
          196  +		
          197  +		if (!isset($this->listing))
          198  +			return true;
          199  +		
          200  +		foreach($this->listing as $listing)	{
          201  +			$listing->expire_date = $expire_date->MySQLDate();
          202  +			$success = $listing->SaveListing(false);
          203  +				
          204  +			if(!$success)
          205  +				$cErr->Error("Could not expire listing: '".$listing->title."'");
          206  +		}
          207  +		return true;
          208  +	}	
          209  +	
          210  +	function LoadListingGroup($title=null, $category=null, $member_id=null, $since=null, $include_expired=true)
          211  +	{
          212  +		global $cDB, $cErr;
          213  +
          214  +		if($title == null)
          215  +			$this->title = "%";
          216  +		else
          217  +			$this->title = $title;
          218  +			
          219  +		if($category == null)
          220  +			$category = "%";
          221  +			
          222  +		if($member_id == null)
          223  +			$member_id = "%";
          224  +			
          225  +		if($since == null) 
          226  +			$since = "19990101000000";
          227  +			
          228  +		if($include_expired)
          229  +			$expired = "";
          230  +		else
          231  +			$expired = " AND expire_date is null";
          232  +			
          233  +		//select all the member_ids for this $title
          234  +		$query = $cDB->Query("SELECT title, member_id FROM ".DATABASE_LISTINGS.", ".DATABASE_CATEGORIES." WHERE title LIKE ".$cDB->EscTxt($this->title)." AND ".DATABASE_LISTINGS.".category_code =".DATABASE_CATEGORIES.".category_id AND ".DATABASE_CATEGORIES.".category_id LIKE '".$category."' AND type='". $this->type_code ."' AND member_id LIKE '".$member_id."' AND posting_date >= '". $since ."'". $expired ." ORDER BY ".DATABASE_CATEGORIES.".description, title, member_id;");
          235  +
          236  +		// instantiate new cOffer objects and load them
          237  +		$i = 0;
          238  +		$this->num_listings = 0;
          239  +				
          240  +		while($row = mysql_fetch_array($query))
          241  +		{
          242  +			$this->listing[$i] = new cListing;			
          243  +			$this->listing[$i]->LoadListing($row[0],$row[1],$this->type_code);
          244  +			if($this->listing[$i]->status == 'A')
          245  +			{
          246  +				$this->num_listings += 1;
          247  +			}
          248  +			$i += 1;
          249  +		}
          250  +
          251  +		if($i == 0) {
          252  +			return false;
          253  +		}
          254  +		
          255  +		return true;
          256  +	}
          257  +	
          258  +	function DisplayListingGroup($show_ids=false, $active_only=true)
          259  +	{
          260  +		global $cUser;
          261  +	
          262  +		$output = "";
          263  +		$current_cat = "";
          264  +		if(isset($this->listing)) {
          265  +			foreach($this->listing as $listing) {
          266  +				if($active_only and $listing->status != ACTIVE)
          267  +					continue; // Skip inactive items
          268  +					
          269  +				if($current_cat != $listing->category->id) {
          270  +					$output .= "<P><STRONG>" . $listing->category->description . "</STRONG><P>";
          271  +				}
          272  +				
          273  +				if ($listing->description != "")
          274  +					$details = "&#8212;". $listing->description;
          275  +				else
          276  +					$details = "";
          277  +				
          278  +				if($show_ids)
          279  +                {   $details .= " (". $listing->member_id; 
          280  +                    if($listing->member->balance <= 1 and $_REQUEST["type"] == "Want") 
          281  +					$details .= ': <font color="red">Su saldo es inferior a 1 Hora</font>';  
          282  +                    $details .= ")";                   
          283  +				}
          284  +				$output .= "<A HREF=http://".HTTP_BASE."/listing_detail.php?type=". $this->type ."&title=" . urlencode($listing->title) ."&member_id=". $listing->member_id ."><FONT SIZE=2>" . $listing->title ."</A>". $details ."</FONT><BR>";
          285  +			
          286  +				$current_cat = $listing->category->id;
          287  +				$current_title = $listing->title;
          288  +			}
          289  +		} 
          290  +		
          291  +		if($output == "")
          292  +			$output = "No se han encontrado.";
          293  +									
          294  +		return $output;		
          295  +	}
          296  +}
          297  +
          298  +
          299  +
          300  +class cTitleList  // This class circumvents the cListing class for performance reasons
          301  +{
          302  +	var $type;
          303  +	var $type_code;  // TODO: 'type' needs to be its own class which would include 'type_code'
          304  +	var $items_per_page;  // Not using yet...
          305  +	var $current_page;   // Not using yet...
          306  +
          307  +	function cTitleList($type) {
          308  +		$this->type = $type;
          309  +		if($type == OFFER_LISTING)
          310  +			$this->type_code = OFFER_LISTING_CODE;
          311  +		else
          312  +			$this->type_code = WANT_LISTING_CODE;
          313  +	}	
          314  +									
          315  +	function MakeTitleArray($member_id="%") {
          316  +		global $cDB, $cErr;
          317  +
          318  +		$query = $cDB->Query("SELECT DISTINCT title FROM ".DATABASE_LISTINGS." WHERE member_id LIKE '". $member_id . "' AND type='". $this->type_code ."';");
          319  +
          320  +		$i=0;		
          321  +		while($row = mysql_fetch_array($query))
          322  +		{
          323  +			$titles[$i]= $cDB->UnEscTxt($row[0]);
          324  +			$i += 1;
          325  +		}
          326  +		
          327  +		if ($i == 0)
          328  +			$titles[0]= "";
          329  +		
          330  +		return $titles;
          331  +	}	
          332  +
          333  +	function DisplayMemberListings($member) {
          334  +		global $cDB;
          335  +
          336  +		$query = $cDB->Query("SELECT title FROM ".DATABASE_LISTINGS." WHERE member_id='".$member->member_id."' AND type='". $this->type_code ."' ORDER BY title;");
          337  +		
          338  +		$output = "";
          339  +		$current_cat = "";
          340  +		while($row = mysql_fetch_array($query)) {
          341  +			$output .= "<A HREF=listing_edit.php?title=" . urlencode($cDB->UnEscTxt($row[0])) ."&member_id=".$member->member_id ."&type=". $this->type ."&mode=" . $_REQUEST["mode"] ."><FONT SIZE=2>". $cDB->UnEscTxt($row[0]) ."</FONT></A><BR>";
          342  +		}
          343  +
          344  +		return $output;
          345  +	}
          346  +
          347  +}
          348  +
          349  +
          350  +?>

Added bdt/classes/class.logging.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +class cLogEntry {
            9  +	var $log_id;
           10  +	var $log_date;
           11  +	var $admin_id; // usually a member_id, but not always
           12  +	var $category; // See inc.global.php for constants used in this field
           13  +	var $action;	// See inc.global.php for constants used in this field
           14  +	var $ref_id; // usually refences a trade_id, feedback_id, or similar
           15  +	var $note;
           16  +	
           17  +	function cLogEntry ($category, $action, $ref_id, $note=null) {
           18  +		global $cUser;
           19  +	
           20  +		$this->category = $category;
           21  +		$this->action = $action;
           22  +		$this->ref_id = $ref_id;
           23  +		$this->note = $note;
           24  +		$this->admin_id = $cUser->member_id;
           25  +	}
           26  +	
           27  +	function SaveLogEntry () {
           28  +		global $cDB, $cErr;
           29  +		
           30  +		$insert = $cDB->Query("INSERT INTO ". DATABASE_LOGGING ." (admin_id, category, action, ref_id, log_date, note) VALUES ('". $this->admin_id ."', '". $this->category ."', '". $this->action ."', '". $this->ref_id ."', now(), ". $cDB->EscTxt($this->note) .");");
           31  +
           32  +		if(mysql_affected_rows() == 1) {
           33  +			$this->log_id = mysql_insert_id();	
           34  +			$query = $cDB->Query("SELECT log_date from ". DATABASE_LOGGING ." WHERE log_id=". $this->log_id .";");
           35  +			$row = mysql_fetch_array($query);
           36  +			$this->log_date = $row[0];	
           37  +			return true;
           38  +		} else {
           39  +			return false;
           40  +		}		
           41  +	}
           42  +}
           43  +
           44  +class cLogStatistics {
           45  +	function MostRecentLog ($category, $action=null) {
           46  +		global $cDB;
           47  +	
           48  +		if($action != null)
           49  +			$exclusions = " AND action='". $action ."'";
           50  +		else
           51  +			$exclusions = null;
           52  +	
           53  +		$query = $cDB->Query("SELECT max(log_date) FROM ". DATABASE_LOGGING ." WHERE category='". $category ."'". $exclusions .";");
           54  +		
           55  +		if($row = mysql_fetch_array($query))	
           56  +			return new cDateTime($row[0]);
           57  +		else
           58  +			return false;
           59  +	}
           60  +}
           61  +
           62  +
           63  +// System events are processes which only need to run periodically,
           64  +// and so are run at intervals rather than weighing the system
           65  +// down by running them each time a particlular page is loaded.
           66  +
           67  +class cSystemEvent {
           68  +	var $event_type; // See inc.global.php for constants used in this field
           69  +	var $event_interval; // See inc.config.php for interval settings
           70  +	
           71  +	function cSystemEvent ($event_type, $event_interval=null) {
           72  +		global $SYSTEM_EVENTS;
           73  +		$this->event_type = $event_type;
           74  +		
           75  +		if($event_interval)
           76  +			$this->event_interval = $event_interval; // use explicit interval
           77  +		else
           78  +			$this->event_interval = $SYSTEM_EVENTS[$event_type]; // use defined interval
           79  +	}
           80  +	
           81  +	function TimeForEvent () {
           82  +		$logs = new cLogStatistics;
           83  +		$last_event = $logs->MostRecentLog($this->event_type);
           84  +		if($last_event->MinutesAgo() >= $this->event_interval)
           85  +			return true;
           86  +		elseif ($last_event == "") // Never run before, so now's as good a time as any
           87  +			return true;
           88  +		else
           89  +			return false;
           90  +	}
           91  +	
           92  +	function LogEvent() {
           93  +		$e = new cLogEntry($this->event_type, $this->event_type, $this->event_type);
           94  +		$e->admin_id = "EVENT_SYSTEM";
           95  +		$e->SaveLogEntry();
           96  +	}
           97  +
           98  +}
           99  +
          100  +?>

Added bdt/classes/class.login_history.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +class cLoginHistory {  
            9  +	var $member_id;
           10  +	var $total_failed;
           11  +	var $consecutive_failures;
           12  +	var $last_failed_date;
           13  +	var $last_success_date;
           14  +	
           15  +	// NEED TO MODIFY MEMBER CLASS TO SET STATUS FIELD TO LOCKED AND CHECK DURING LOGIN
           16  +	
           17  +	function LoadLoginHistory ($member_id) {
           18  +		global $cDB, $cErr;
           19  +		
           20  +		$query = $cDB->Query("SELECT total_failed, consecutive_failures, last_failed_date, last_success_date FROM ".DATABASE_LOGINS." WHERE member_id='".$member_id."';");
           21  +		
           22  +		if($row = mysql_fetch_array($query)) {	
           23  +			$this->member_id = $member_id;	
           24  +			$this->total_failed = $row[0];
           25  +			$this->consecutive_failures = $row[1];
           26  +			$this->last_failed_date = $row[2];
           27  +			$this->last_success_date = $row[3];	
           28  +			return true;
           29  +		} else {
           30  +			return false;
           31  +		}			
           32  +	}
           33  +	
           34  +	function SaveLoginHistory () {
           35  +		global $cDB, $cErr;				
           36  +
           37  +		$update = $cDB->Query("UPDATE ".DATABASE_LOGINS." SET total_failed=". $this->total_failed .", consecutive_failures=". $this->consecutive_failures .", last_failed_date=". $cDB->EscTxt($this->last_failed_date) .", last_success_date=". $cDB->EscTxt($this->last_success_date) ." WHERE member_id='".$this->member_id ."';");	
           38  +
           39  +		if(!$update) {
           40  +			$cErr->Error("Could not save changes to login history '". $this->member_id ."'. Please try again later.");	
           41  +			include("redirect.php");
           42  +		} else {
           43  +			return true;
           44  +		}
           45  +	}
           46  +	
           47  +	function SaveNewLoginHistory () {
           48  +		global $cDB, $cErr;
           49  +		
           50  +		$insert = $cDB->Query("INSERT INTO ". DATABASE_LOGINS ." (member_id, total_failed, consecutive_failures, last_failed_date, last_success_date) VALUES ('". $this->member_id ."', ". $this->total_failed .", ". $this->consecutive_failures .", ". $cDB->EscTxt($this->last_failed_date) .", ". $cDB->EscTxt($this->last_success_date) .");");
           51  +
           52  +		if(mysql_affected_rows() == 1) {	
           53  +			return true;
           54  +		} else {
           55  +			return false;  // Don't display error because it may just be the userid was wrong
           56  +		}	
           57  +	}	
           58  +	
           59  +	function RecordLoginSuccess ($member_id) {
           60  +		if($this->LoadLoginHistory($member_id)) {
           61  +			$this->last_success_date = $this->CurrentTimestamp();
           62  +			$this->consecutive_failures = 0;
           63  +			return $this->SaveLoginHistory();
           64  +		} else {
           65  +			$this->member_id = $member_id;
           66  +			$this->total_failed = 0;
           67  +			$this->consecutive_failures = 0;
           68  +			$this->last_success_date = $this->CurrentTimestamp();
           69  +			$this->last_failed_date = "00000000000000"; // MySQL won't allow a timestamp to be NULL
           70  +			return $this->SaveNewLoginHistory();
           71  +		}
           72  +	}
           73  +	
           74  +	function RecordLoginFailure ($member_id) {
           75  +		global $cDB;
           76  +		
           77  +		if($this->LoadLoginHistory($member_id)) {
           78  +			$this->last_failed_date = $this->CurrentTimestamp();
           79  +			$this->consecutive_failures += 1;
           80  +			$this->total_failed += 1;
           81  +			if($this->consecutive_failures > FAILED_LOGIN_LIMIT) {
           82  +				$member = new cMember;
           83  +				$member->LoadMember($member_id);
           84  +				$member->status = LOCKED;
           85  +				$member->SaveMember();
           86  +			}
           87  +			return $this->SaveLoginHistory();
           88  +		} else {
           89  +			$query = $cDB->Query("SELECT NULL FROM ". DATABASE_MEMBERS." WHERE member_id='". $member_id ."';");
           90  +			if (!$row = mysql_fetch_array($query))
           91  +				return false;	// Userid must have been misspelled or didn't exist.
           92  +			
           93  +			$this->member_id = $member_id;
           94  +			$this->total_failed = 1;
           95  +			$this->consecutive_failures = 1;
           96  +			$this->last_failed_date = $this->CurrentTimestamp();
           97  +			$this->last_success_date = "00000000000000"; // MySQL won't allow a timestamp to be NULL
           98  +			return $this->SaveNewLoginHistory();
           99  +		}
          100  +	}
          101  +	
          102  +	function CurrentTimestamp () { // TODO: Move to a new class (maybe "class.time_date.php")...
          103  +											 // Also probably shouldn't depend on the default string format.
          104  +		$date = getdate();
          105  +		$now = $date["year"] . str_pad($date["mon"],2,"0","STR_PAD_LEFT") . str_pad($date["mday"],2,"0","STR_PAD_LEFT") . str_pad($date["hours"],2,"0","STR_PAD_LEFT") . str_pad($date["minutes"],2,"0","STR_PAD_LEFT") . str_pad($date["seconds"],2,"0","STR_PAD_LEFT");
          106  +		return $now;		
          107  +	}
          108  +	
          109  +}
          110  +
          111  +?>

Added bdt/classes/class.member.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +include_once("class.person.php");
            9  +include_once("Text/Password.php");
           10  +require_once "Mail.php";
           11  +require_once "Mail/mime.php";
           12  +
           13  +class cMember
           14  +{
           15  +	var $person;  // this will be an array of cPerson class objects
           16  +	var $member_id;
           17  +	var $password;
           18  +	var $member_role;
           19  +	var $security_q;
           20  +	var $security_a;
           21  +	var $status;
           22  +	var $member_note;
           23  +	var $admin_note;
           24  +	var $join_date;
           25  +	var $expire_date;
           26  +	var $away_date;
           27  +	var $account_type;
           28  +	var $email_updates;
           29  +	var $balance;
           30  +
           31  +	function cMember($values=null) {
           32  +		if ($values) {
           33  +			$this->member_id = $values['member_id'];
           34  +			$this->password = $values['password'];
           35  +			$this->member_role = $values['member_role'];
           36  +			$this->security_q = $values['security_q'];
           37  +			$this->security_a = $values['security_a'];
           38  +			$this->status = $values['status'];
           39  +			$this->member_note = $values['member_note'];
           40  +			$this->admin_note = $values['admin_note'];
           41  +			$this->join_date = $values['join_date'];
           42  +			$this->expire_date = $values['expire_date'];
           43  +			$this->away_date = $values['away_date'];
           44  +			$this->account_type = $values['account_type'];
           45  +			$this->email_updates = $values['email_updates'];
           46  +			$this->balance = $values['balance'];	
           47  +		}
           48  +	}
           49  +
           50  +	function SaveNewMember() {
           51  +		global $cDB, $cErr;	
           52  +		
           53  +		$insert = $cDB->Query("INSERT INTO ".DATABASE_MEMBERS." (member_id, password, member_role, security_q, security_a, status, member_note, admin_note, join_date, expire_date, away_date, account_type, email_updates, balance) VALUES ('". $this->member_id ."',sha('". $this->password ."'),'". $this->member_role ."',". $cDB->EscTxt($this->security_q) .",". $cDB->EscTxt($this->security_a) .",'". $this->status ."',". $cDB->EscTxt($this->member_note) .",". $cDB->EscTxt($this->admin_note) .",'". $this->join_date ."',". $cDB->EscTxt($this->expire_date) .",". $cDB->EscTxt($this->away_date) .",'". $this->account_type ."',". $this->email_updates .",'". $this->balance ."');");
           54  +
           55  +		return $insert;
           56  +	}
           57  +
           58  +	function RegisterWebUser()
           59  +	{	
           60  +		if (isset($_SESSION["user_login"]) and $_SESSION["user_login"] != LOGGED_OUT) {
           61  +			$this->member_id = $_SESSION["user_login"];
           62  +			$this->LoadMember($_SESSION["user_login"]);
           63  +		}
           64  +		else {
           65  +			$this->LoginFromCookie();
           66  +		}		
           67  +	}
           68  +	
           69  +	function LoginFromCookie()
           70  +	{
           71  +		if (isset($_COOKIE["login"]) && isset($_COOKIE["pass"]))
           72  +		{
           73  +			$this->Login($_COOKIE["login"], $_COOKIE["pass"], true);
           74  +		}
           75  +	}
           76  +
           77  +	function IsLoggedOn()
           78  +	{
           79  +		if (isset($_SESSION["user_login"]) and $_SESSION["user_login"] != LOGGED_OUT)
           80  +			return true;
           81  +		else
           82  +			return false;
           83  +	}
           84  +
           85  +	function Login($user, $pass, $from_cookie=false) {
           86  +		global $cDB,$cErr;
           87  +
           88  +		$login_history = new cLoginHistory();
           89  +
           90  +		$query = $cDB->Query("SELECT member_id, password, member_role FROM ".DATABASE_USERS." WHERE member_id = '".$user."' AND (password=sha('".$pass."') OR password='".$pass."') and status = 'A';");	
           91  +	
           92  +		if($row = mysql_fetch_array($query)) {
           93  +
           94  +			$login_history->RecordLoginSuccess($user);
           95  +			$this->DoLoginStuff($user, $row["password"]);	// using pass from db since it's encrypted, and $pass isn't, if it was entered in the browser.
           96  +			return true;
           97  +		} elseif (!$from_cookie) {
           98  +			$query = $cDB->Query("SELECT NULL FROM ".DATABASE_USERS." WHERE status = 'L' and member_id='". $user ."';");
           99  +			if($row = mysql_fetch_array($query)) {
          100  +				$cErr->Error("Tu cuenta ha sido bloqueada por demasiados intentos fallidos. Por favor, contacta con <A HREF=contact.php>la administración</A> para desbloquearla.");
          101  +			} else {
          102  +				
          103  +			$query = $cDB->Query("SELECT NULL FROM ".DATABASE_USERS." WHERE status = 'X' and member_id='". $user ."';");
          104  +			if($row = mysql_fetch_array($query)) {
          105  +				$cErr->Error("Todavía no se te ha dado de alta. Ten un poco de paciencia.");
          106  +				} else {
          107  +
          108  +
          109  +
          110  +				$cErr->Error("Contraseña o número de identidad incorrecto. Por favor, inténtalo de nuevo, o ve <A HREF=password_reset.php>aquí</A> para resetear tu contraseña.", ERROR_SEVERITY_INFO);}
          111  +			}
          112  +			$login_history->RecordLoginFailure($user);
          113  +			return false;
          114  +		}	
          115  +		return false;
          116  +	}
          117  +	
          118  +	function ValidatePassword($pass) {
          119  +		global $cDB;
          120  +
          121  +		$query = $cDB->Query("SELECT member_id, password, member_role FROM ".DATABASE_USERS." WHERE member_id = '".$this->member_id."' AND (password=sha('".$pass."') OR password='".$pass."');");	
          122  +
          123  +		if($row = mysql_fetch_array($query))
          124  +			return true;
          125  +		else
          126  +			return false;
          127  +	}
          128  +	function UnlockAccount() {
          129  +		$history = new cLoginHistory;
          130  +		$has_logged_on = $history->LoadLoginHistory($this->member_id);
          131  +		if($has_logged_on) {
          132  +			$consecutive_failures = $history->consecutive_failures;
          133  +			$history->consecutive_failures = 0;  // Set count back to zero whether locked or not
          134  +			$history->SaveLoginHistory();	
          135  +		} 
          136  +		
          137  +		if($this->status == LOCKED) {
          138  +			$this->status = ACTIVE;
          139  +			if($this->SaveMember()) {
          140  +				return $consecutive_failures;
          141  +			}			
          142  +		}
          143  +		return false;
          144  +	}
          145  +	
          146  +	function DeactivateMember() {
          147  +		if($this->status == ACTIVE) {
          148  +			$this->status = INACTIVE;
          149  +			return $this->SaveMember();
          150  +		} else {
          151  +			return false;	
          152  +		}
          153  +	}
          154  +	
          155  +	function ReactivateMember() {
          156  +		if($this->status != ACTIVE) {
          157  +			$this->status = ACTIVE;
          158  +			return $this->SaveMember();
          159  +		} else {
          160  +			return false;	
          161  +		}
          162  +	}
          163  +	
          164  +	function ChangePassword($pass) { // TODO: Should use SaveMember and should reset $this->password
          165  +		global $cDB, $cErr;
          166  +		
          167  +		$update = $cDB->Query("UPDATE ". DATABASE_MEMBERS ." SET password=sha('". $pass ."') WHERE member_id='". $this->member_id ."';");
          168  +		
          169  +		if($update) {
          170  +			return true;
          171  +		} else {
          172  +			$cErr->Error("Ha habido un error redirigiendo la contraseña. Por favor inténtalo más tarde.");
          173  +			include("redirect.php");
          174  +		}
          175  +	}
          176  +	
          177  +	function GeneratePassword() {  
          178  +		return Text_Password::create(6) . chr(rand(50,57));
          179  +	}
          180  +
          181  +	function DoLoginStuff($user, $pass)
          182  +	{
          183  +		global $cDB;
          184  +		
          185  +		setcookie("login",$user,time()+60*60*24*1,"/");
          186  +		setcookie("pass",$pass,time()+60*60*24*1,"/");
          187  +
          188  +		$this->LoadMember($user);
          189  +		$_SESSION["user_login"] = $user;
          190  +	}
          191  +
          192  +	function UserLoginPage() // A free-standing login page
          193  +	{
          194  +// ORIGINAL (PRIMERA LINEA)	$output = "<DIV STYLE='width=60%; padding: 5px;'><FORM ACTION=".SERVER_PATH_URL."/login.php METHOD=POST>
          195  +// Cambiada también tercera línea: 
          196  +//					<INPUT TYPE=HIDDEN NAME=location VALUE='".$_SERVER["REQUEST_URI"]."'>
          197  +		$output = "<DIV STYLE='width=60%; padding: 5px;'><FORM ACTION=login.php METHOD=POST>
          198  +					<INPUT TYPE=HIDDEN NAME=action VALUE=login>
          199  +					<INPUT TYPE=HIDDEN NAME=location VALUE='".$_SERVER["REQUEST_URI"]."'>
          200  +					<TABLE class=NoBorder><TR><TD ALIGN=LEFT>ID miembro:</TD><TD ALIGN=LEFT><INPUT TYPE=TEXT SIZE=12 NAME=user></TD></TR>
          201  +					<TR><TD ALIGN=LEFT>Contraseña:</TD><TD ALIGN=LEFT><INPUT TYPE=PASSWORD SIZE=12 NAME=pass></TD></TR></TABLE>
          202  +					<DIV align=LEFT><INPUT TYPE=SUBMIT VALUE='Login'></DIV>
          203  +					</FORM></DIV>
          204  +					<BR>
          205  +					Si aún no tienes una cuenta,  <A HREF=contact.php>contáctanos</A> para unirte al Banco de tiempo.
          206  +					<BR>";	
          207  +		return $output;
          208  +	}
          209  +
          210  +	function UserLoginLogout() {
          211  +		if ($this->IsLoggedOn())
          212  +		{
          213  +	//		$output = "<FONT SIZE=1><A HREF='".SERVER_PATH_URL."/member_logout.php'>Logout</A>&nbsp;&nbsp;&nbsp;";
          214  +                $output = "<FONT SIZE=3><A HREF='".SERVER_PATH_URL."/member_logout.php'><B>Salir</B></A>";
          215  +		} else {
          216  +	//		$output = "<FONT SIZE=1><A HREF='".SERVER_PATH_URL."/member_login.php'>Login</A>&nbsp;&nbsp;&nbsp;";
          217  +                $output = "<FONT SIZE=3><A HREF='".SERVER_PATH_URL."/member_login.php'><B>Entrar</B></A>";		
          218  +		}
          219  +
          220  +		return $output;		
          221  +	}
          222  +
          223  +	function MustBeLoggedOn()
          224  +	{
          225  +		global $p, $cErr;
          226  +		
          227  +		if ($this->IsLoggedOn())
          228  +			return true;
          229  +		
          230  +		// user isn't logged on, but is in a section of the site where they should be logged on.
          231  +		$_SESSION['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
          232  +		$cErr->SaveErrors();
          233  +		header("location:http://".HTTP_BASE."/login_redirect.php");
          234  +				
          235  +		exit;
          236  +	}
          237  +
          238  +	function Logout() {
          239  +		setcookie("login","",time()-3600,"/");
          240  +		setcookie("pass","",time()-3600,"/");
          241  +		$_SESSION["user_login"] = LOGGED_OUT;
          242  +	}
          243  +
          244  +	function MustBeLevel($level) {
          245  +		global $p;
          246  +		$this->MustBeLoggedOn(); // seems prudent to check first.
          247  +
          248  +		if ($this->member_role<$level)
          249  +		{
          250  +			$page = "<DIV Class='AccessDenied'>Lo siento, no tienes permisos para acceder<BR></DIV>";
          251  +			$p->DisplayPage($page);
          252  +			exit;
          253  +
          254  +		}
          255  +
          256  +	}
          257  +	
          258  +	function LoadMember($member, $redirect=true) {
          259  +		global $cDB, $cErr;
          260  +
          261  +		//
          262  +		// select all Member data and populate the properties
          263  +		//
          264  +		$query = $cDB->Query("SELECT member_id, password, member_role, security_q, security_a, status, member_note, admin_note, join_date, expire_date, away_date, account_type, email_updates, balance FROM ".DATABASE_MEMBERS." WHERE member_id='".$member."'");
          265  +		
          266  +		if($row = mysql_fetch_array($query))
          267  +		{		
          268  +			$this->member_id=$row[0];
          269  +			$this->password=$row[1];
          270  +			$this->member_role=$row[2];
          271  +			$this->security_q=$cDB->UnEscTxt($row[3]);
          272  +			$this->security_a=$cDB->UnEscTxt($row[4]);
          273  +			$this->status=$row[5];
          274  +			$this->member_note=$cDB->UnEscTxt($row[6]);
          275  +			$this->admin_note=$cDB->UnEscTxt($row[7]);
          276  +			$this->join_date=$row[8];
          277  +			$this->expire_date=$row[9];
          278  +			$this->away_date=$row[10];
          279  +			$this->account_type=$row[11];
          280  +			$this->email_updates=$row[12];
          281  +			$this->balance=$row[13];		
          282  +		}
          283  +		else
          284  +		{
          285  +			if ($redirect) {
          286  +				$cErr->Error("There was an error accessing this member (".$member.").  Please try again later.");
          287  +				include("redirect.php");
          288  +			}
          289  +			return false;
          290  +		}	
          291  +						
          292  +		//
          293  +		// Select associated person records and load into person object array
          294  +		//
          295  +
          296  +		$query = $cDB->Query("SELECT person_id FROM ".DATABASE_PERSONS." WHERE member_id='".$member."' ORDER BY primary_member DESC, last_name, first_name");
          297  +		$i = 0;
          298  +		
          299  +		while($row = mysql_fetch_array($query))
          300  +		{
          301  +			$this->person[$i] = new cPerson;			// instantiate new cPerson objects and load them
          302  +			$this->person[$i]->LoadPerson($row[0]);
          303  +			$i += 1;
          304  +		}
          305  +
          306  +		if($i == 0)
          307  +		{
          308  +			if ($redirect) {
          309  +				$cErr->Error("Ocurrió un error al acceder al miembro (".$member.").  Por favor, inténtelos más tarde.");
          310  +				include("redirect.php");			
          311  +			}
          312  +			return false;
          313  +		}
          314  +		return true;
          315  +	}
          316  +	
          317  +	function ShowMember()
          318  +	{
          319  +		$output = "Member Data:<BR>";
          320  +		$output .= $this->member_id . ", " . $this->password . ", " . $this->member_role . ", " . $this->security_q . ", " . $this->security_a . ", " . $this->status . ", " . $this->member_note . ", " . $this->admin_note . ", " . $this->join_date . ", " . $this->expire_date . ", " . $this->away_date . ", " . $this->account_type . ", " . $this->email_updates . ", " . $this->balance . "<BR><BR>";
          321  +		
          322  +		$output .= "Person Data:<BR>";
          323  +		
          324  +		foreach($this->person as $person)
          325  +		{
          326  +			$output .= $person->ShowPerson();
          327  +			$output .= "<BR><BR>";
          328  +		}			
          329  +						
          330  +		return $output;
          331  +	}		
          332  +	
          333  +	function UpdateBalance($amount) {
          334  +		$this->balance += $amount;
          335  +		return $this->SaveMember();
          336  +	}
          337  +	
          338  +	function SaveMember() {
          339  +		global $cDB, $cErr;				
          340  +		
          341  +		$update = $cDB->Query("UPDATE ".DATABASE_MEMBERS." SET password='". $this->password ."', member_role=". $this->member_role .", security_q=". $cDB->EscTxt($this->security_q) .", security_a=". $cDB->EscTxt($this->security_a) .", status='". $this->status ."', member_note=". $cDB->EscTxt($this->member_note) .", admin_note=". $cDB->EscTxt($this->admin_note) .", join_date='". $this->join_date ."', expire_date=". $cDB->EscTxt($this->expire_date) .", away_date=". $cDB->EscTxt($this->away_date) .", account_type='". $this->account_type ."', email_updates=". $this->email_updates .", balance=". $this->balance ." WHERE member_id='".$this->member_id ."';");	
          342  +
          343  +		if(!$update)
          344  +			$cErr->Error("No se pudieron guardar los cambios para '". $this->member_id ."'. Por favor, inténtelo más tarde.");
          345  +
          346  +		foreach($this->person as $person) {
          347  +			$person->SavePerson();
          348  +		}
          349  +				
          350  +		return $update;	
          351  +	}
          352  +	
          353  +	function PrimaryName () {
          354  +		return $this->person[0]->first_name . " " . $this->person[0]->last_name;
          355  +	}
          356  +	
          357  +	function VerifyPersonInAccount($person_id) { // Make sure hacker didn't manually change URL
          358  +		global $cErr;
          359  +		foreach($this->person as $person) {
          360  +			if($person->person_id == $person_id)
          361  +				return true;
          362  +		}
          363  +		$cErr->Error("Invalid person id in URL.  This break-in attempt has been reported.",ERROR_SEVERITY_HIGH);
          364  +		include("redirect.php");
          365  +	}
          366  +	
          367  +	function PrimaryAddress () {
          368  +		if($this->person[0]->address_street1 != "") {
          369  +			$address = $this->person[0]->address_street1 . ", ";
          370  +			if($this->person[0]->address_street2 != "")
          371  +				$address .= $this->person[0]->address_street2 . ", ";
          372  +		} else {
          373  +			$address = "";
          374  +		}
          375  +		
          376  +		return $address . $this->person[0]->address_city;
          377  +	}
          378  +	
          379  +	function AllNames () {
          380  +		foreach($this->person as $person) {
          381  +			if($person->primary_member == "Y") {
          382  +				$names = $person->first_name ." ". $person->last_name;
          383  +			} else {
          384  +				$names .= ", ". $person->first_name ." ". $person->last_name;
          385  +			}	
          386  +		}
          387  +		return $names;
          388  +	}
          389  +	
          390  +	function AllPhones () {
          391  +		$phones = "";
          392  +		$reg_phones[]="";
          393  +		$fax_phones[]="";
          394  +		foreach($this->person as $person) {
          395  +			if($person->primary_member == "Y") {
          396  +				if($person->phone1_number != "") {
          397  +					$phones .= $person->DisplayPhone(1);
          398  +					$reg_phones[] = $person->DisplayPhone(1);
          399  +				}
          400  +				if($person->phone2_number != "") {
          401  +					$phones .= ", ". $person->DisplayPhone(2);
          402  +					$reg_phones[] = $person->DisplayPhone(2);
          403  +				}
          404  +				if($person->fax_number != "") {
          405  +					$phones .= ", ". $person->DisplayPhone("fax"). " (Fax)";
          406  +					$fax_phones[] = $person->DisplayPhone("fax");
          407  +				}
          408  +			} else {
          409  +				if($person->phone1_number != "" and array_search($person->DisplayPhone(1), $reg_phones) === false){ 
          410  +					$phones .= ", ". $person->DisplayPhone(1). " (". $person->first_name .")";
          411  +					$reg_phones[] = $person->DisplayPhone(1);
          412  +				}
          413  +				if($person->phone2_number != "" and array_search($person->DisplayPhone(2), $reg_phones) === false) {
          414  +					$phones .= ", ". $person->DisplayPhone(2). " (". $person->first_name .")";
          415  +					$reg_phones[] = $person->DisplayPhone(2);
          416  +				}
          417  +				if($person->fax_number != "" and array_search($person->DisplayPhone("fax"), $fax_phones) === false) {
          418  +					$phones .= ", ". $person->DisplayPhone("fax"). " (". $person->first_name ."'s Fax)";
          419  +					$fax_phones[] = $person->DisplayPhone("fax");
          420  +				}
          421  +			}	
          422  +		}
          423  +		return $phones;		
          424  +	}
          425  +	
          426  +	function AllEmails () {
          427  +		foreach($this->person as $person) {
          428  +			if($person->primary_member == "Y") {
          429  +				$emails = '<A HREF=email.php?email_to='. $person->email .'&member_to='. $this->member_id .'>'. $person->email .'</A>';
          430  +			} else {
          431  +				if($person->email != "" and strpos($emails, $person->email) === false)
          432  +					$emails .= ', <A HREF=email.php?email_to='. $person->email .'&member_to='. $this->member_id .'>'. $person->email .'</A> ('. $person->first_name .')';
          433  +			}	
          434  +		}
          435  +		return $emails;	
          436  +	}
          437  +	
          438  +	function VerifyMemberExists($member_id) {
          439  +		global $cDB;
          440  +	
          441  +		$query = $cDB->Query("SELECT NULL FROM ".DATABASE_MEMBERS." WHERE member_id='".$member_id."'");
          442  +		
          443  +		if($row = mysql_fetch_array($query))
          444  +			return true;
          445  +		else
          446  +			return false;
          447  +	}
          448  +	
          449  +	function MemberLink () {
          450  +		return "<A HREF=member_summary.php?member_id=". $this->member_id .">". $this->member_id ."</A>";
          451  +	}
          452  +	
          453  +	function DisplayMember () {
          454  +		$output = "<STRONG>Asociado/a:</STRONG> ". $this->PrimaryName() . " (". $this->MemberLink().")"."<BR>";
          455  +        if($this->member_role<1){
          456  +        $output .= "<STRONG>Saldo de ". $this->PrimaryName() . ": </STRONG>";
          457  +        if ($this->balance <= 0)
          458  +            $output .= '<font color="red">'." ". $this->balance ." ". strtolower(UNITS) .'</font><BR>';    
          459  +        else        
          460  +            $output .= " ". $this->balance ." ". strtolower(UNITS) .'<BR>';
          461  +        }      
          462  +		$stats = new cTradeStats($this->member_id);
          463  +		$output .= "<STRONG>Actividad:</STRONG> ";
          464  +		if ($stats->most_recent == "")
          465  +			$output .= "Sin intercambios aún<BR>";
          466  +		else		
          467  +			$output .= '<A HREF="trade_history.php?mode=other&member_id='. $this->member_id .'">'. $stats->total_trades ." intercambios en total</A> , sumando ". $stats->total_units . " ". strtolower(UNITS) . ", el último el día ". $stats->most_recent->ShortDate() ."<BR>";
          468  +		$feedbackgrp = new cFeedbackGroup;
          469  +		$feedbackgrp->LoadFeedbackGroup($this->member_id);
          470  +		if(isset($feedbackgrp->feedback)) {
          471  +			$output .= "<b>Valoración:</b> <A HREF=feedback_all.php?mode=other&member_id=". $this->member_id . ">" . $feedbackgrp->PercentPositive() . "% votos positivos</A> (" . $feedbackgrp->TotalFeedback() . " en total, " . $feedbackgrp->num_negative ." negativos y " . $feedbackgrp->num_neutral . " neutrales)<BR>";		
          472  +		}
          473  +
          474  +		$joined = new cDateTime($this->join_date);
          475  +		$output .= "<STRONG>Apuntado:</STRONG> ". $joined->ShortDate() ."<BR>";
          476  +
          477  +		if($this->person[0]->email != "")
          478  +			$output .= "<STRONG>Email:</STRONG> ". "<A HREF=email.php?email_to=". $this->person[0]->email ."&member_to=". $this->member_id .">". $this->person[0]->email ."</A><BR>";	
          479  +		if($this->person[0]->phone1_number != "")
          480  +			$output .= "<STRONG>Teléfono:</STRONG> ". $this->person[0]->DisplayPhone("1") ."<BR>";
          481  +		if($this->person[0]->phone2_number != "")
          482  +			$output .= "<STRONG>Segundo teléfono:</STRONG> ". $this->person[0]->DisplayPhone("2") ."<BR>";						
          483  +		if($this->person[0]->fax_number != "")
          484  +			$output .= "<STRONG>Fax:</STRONG> ". $this->person[0]->DisplayPhone("fax") ."<BR>";	
          485  +			
          486  +		foreach($this->person as $person) {
          487  +			if($person->primary_member == "Y")
          488  +				continue;	// Skip the primary member, since we already displayed above
          489  +		
          490  +			if($person->directory_list == "Y") {
          491  +				$output .= "<STRONG>Miembro asociado:</STRONG> ". $person->first_name ." ". $person->last_name ."<BR>";
          492  +				if($person->email != "")
          493  +					$output .= "<STRONG>Email de ". $person->first_name .":</STRONG> ". "<A HREF=email.php?email_to=". $person->email ."&member_to=". $this->member_id .">". $person->email ."</A><BR>";				
          494  +				if($person->phone1_number != "")
          495  +					$output .= "<STRONG>Teléfono de ". $person->first_name .":</STRONG> ". $person->DisplayPhone("1") ."<BR>";
          496  +				if($person->phone2_number != "")
          497  +					$output .= "<STRONG>Segundo teléfono de ". $person->first_name .":</STRONG> ". $person->DisplayPhone("2") ."<BR>";						
          498  +				if($person->fax_number != "")
          499  +				$output .= "<STRONG>Fax de ". $person->first_name .":</STRONG> ". $person->DisplayPhone("fax") ."<BR>";				
          500  +			}
          501  +		}		
          502  +	return $output;	
          503  +	}
          504  +	
          505  +	function MakeJointMemberArray() {
          506  +		global $cDB;
          507  +		
          508  +		$names="";				
          509  +		foreach ($this->person as $person) {
          510  +			if($person->primary_member != 'Y') {
          511  +				$names[$person->person_id] = $person->first_name ." ". $person->last_name;
          512  +				}
          513  +		}
          514  +		
          515  +		return $names;	
          516  +	}		
          517  +	
          518  +	function DaysSinceLastTrade() {
          519  +		global $cDB;
          520  +	
          521  +		$query = $cDB->Query("SELECT max(trade_date) FROM ". DATABASE_TRADES ." WHERE member_id_to='".$this->member_id."' OR member_id_from='".$this->member_id."';");
          522  +		
          523  +		$row = mysql_fetch_array($query);
          524  +		
          525  +		if($row[0] != "")
          526  +			$last_trade = new cDateTime($row[0]);
          527  +		else
          528  +			$last_trade = new cDateTime($this->join_date);
          529  +
          530  +		return $last_trade->DaysAgo();
          531  +	}
          532  +	
          533  +	function DaysSinceUpdatedListing() {
          534  +		global $cDB;
          535  +	
          536  +		$query = $cDB->Query("SELECT max(posting_date) FROM ". DATABASE_LISTINGS ." WHERE member_id='".$this->member_id."';");
          537  +		
          538  +		$row = mysql_fetch_array($query);
          539  +		
          540  +		if($row[0] != "")
          541  +			$last_update = new cDateTime($row[0]);
          542  +		else
          543  +			$last_update = new cDateTime($this->join_date);
          544  +
          545  +		return $last_update->DaysAgo();
          546  +	}	
          547  +    
          548  +    function Limites ()
          549  +    {
          550  +        global $cDB, $cErr;
          551  +        
          552  +         if($this->balance <= 0) {
          553  +             $success5 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='B' WHERE status='A' AND member_id='". $this->member_id."' AND type='W';");  
          554  +             $success5 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='J' WHERE status='I' AND member_id='". $this->member_id."' AND type='W';");
          555  +             }
          556  +         else 
          557  +         {
          558  +             $success5 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='A' WHERE status='B' AND member_id='". $this->member_id."' AND type='W';"); 
          559  +             $success5 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='I' WHERE status='J' AND member_id='". $this->member_id."' AND type='W';"); 
          560  +                if ($this->balance >= 7 and $this->balance <12)
          561  +                {    
          562  +                $success6 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='B' WHERE status='A' AND member_id='". $this->member_id."' AND type='O';");  
          563  +                $success6 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='J' WHERE status='I' AND member_id='". $this->member_id."' AND type='O';");
          564  +
          565  +                $demandas_necesarias=0;
          566  +                if($this->balance >= 7 and $this->balance <8)
          567  +                $demandas_necesarias=1;
          568  +                if($this->balance >= 8 and $this->balance <9)
          569  +                $demandas_necesarias=2;
          570  +                if($this->balance >= 9 and $this->balance <10)
          571  +                $demandas_necesarias=3;
          572  +                if($this->balance >= 10 and $this->balance <11)
          573  +                $demandas_necesarias=5;
          574  +                if($this->balance >= 11 and $this->balance <12)
          575  +                $demandas_necesarias=10;
          576  +     
          577  +                $query = $cDB->Query("SELECT COUNT(title) AS total FROM ".DATABASE_LISTINGS." WHERE status='A' AND  member_id='". $this->member_id."' AND type='W';");
          578  +                $demandas_actuales= mysql_fetch_row($query);    
          579  +                    if(doubleval($demandas_actuales[0]) >= $demandas_necesarias) {        
          580  +                        $success6 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='A' WHERE status='B' AND member_id='". $this->member_id."' AND type='O';"); 
          581  +                        $success6 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='I' WHERE status='J' AND member_id='". $this->member_id."' AND type='O';"); 
          582  +                        }
          583  +                }
          584  +                elseif ($this->balance < 7){
          585  +                $success6 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='A' WHERE status='B' AND member_id='". $this->member_id."' AND type='O';"); 
          586  +                $success6 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='I' WHERE status='J' AND member_id='". $this->member_id."' AND type='O';"); 
          587  +                }
          588  +                elseif ($this->balance >= 12){
          589  +                $success6 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='B' WHERE status='A' AND member_id='". $this->member_id."' AND type='O';"); 
          590  +                $success6 = $cDB->Query("UPDATE ". DATABASE_LISTINGS ." SET status='J' WHERE status='I' AND member_id='". $this->member_id."' AND type='O';"); 
          591  +                }
          592  +           }
          593  +    }
          594  +    
          595  +    function LimitesPasados($tipo="")                //al llamarla hay que pasar el tipo, si es oferta o demanda   como "Oferta" o "Demanda"
          596  +    {  
          597  +        global $cDB, $cErr, $p; 
          598  +        
          599  +        if($_REQUEST["type"] == "Want")
          600  +            $tipo = "Demanda";
          601  +        if($_REQUEST["type"] == "Offer") 
          602  +            $tipo = "Oferta";
          603  +            
          604  +           if($this->balance <= 0 and $tipo=="Demanda"){ 
          605  +        $p->DisplayPage("Tus demandas están desactivadas.");    
          606  +        exit;
          607  +        }
          608  +        
          609  +       elseif ($this->balance >= 7 and $this->balance <12 and $tipo=="Oferta"){     
          610  +                $demandas_necesarias=0;
          611  +                if($this->balance >= 7 and $this->balance <8)
          612  +                $demandas_necesarias=1;
          613  +                if($this->balance >= 8 and $this->balance <9)
          614  +                $demandas_necesarias=2;
          615  +                if($this->balance >= 9 and $this->balance <10)
          616  +                $demandas_necesarias=3;
          617  +                if($this->balance >= 10 and $this->balance <11)
          618  +                $demandas_necesarias=5;
          619  +                if($this->balance >= 11 and $this->balance <12)
          620  +                $demandas_necesarias=10;
          621  +     
          622  +                $query = $cDB->Query("SELECT COUNT(title) AS total FROM ".DATABASE_LISTINGS." WHERE status='A' AND  member_id='". $this->member_id."' AND type='W';");
          623  +                $demandas_actuales= mysql_fetch_row($query);
          624  +                $demandas_actuales= doubleval($demandas_actuales[0]);
          625  +                $almenos= $demandas_necesarias-$demandas_actuales;
          626  +                if($demandas_actuales < $demandas_necesarias) {
          627  +                    if ($almenos == 1)       
          628  +                    $p->DisplayPage("Tus ofertas están desactivadas. <BR>Necesitas crear al menos <B>". $almenos ." demanda </B>para que tus ofertas sean visibles.</BR>");
          629  +                    else
          630  +                    $p->DisplayPage("Tus ofertas están desactivadas. <BR>Necesitas crear al menos <B>". $almenos ." demandas </B>para que tus ofertas sean visibles.</BR>"); 
          631  +                     exit;
          632  +                        }    
          633  +        }
          634  +
          635  +           elseif ($this->balance >= 12 and $tipo=="Oferta"){     
          636  +                    $p->DisplayPage("Tus ofertas están desactivadas. <BR>Has acumulado más de 12 horas de saldo.<B> Tienes que demandar algún servicio</B> para que tus ofertas sean visibles.</BR>"); 
          637  +                     exit;
          638  +        }
          639  +    }
          640  +        
          641  +}
          642  +
          643  +class cMemberGroup {
          644  +	var $members;
          645  +	
          646  +	function LoadMemberGroup ($active_only=TRUE, $non_members=FALSE, $waiting_members=FALSE) {
          647  +		global $cDB;
          648  +				
          649  +		if($active_only)
          650  +			$exclusions = " AND status in ('A','L')";
          651  +		else
          652  +			$exclusions = null;
          653  +
          654  +		if($waiting_members)
          655  +			$exclusions .= " AND status = 'X'";	
          656  +		
          657  +		if(!$non_members)
          658  +			$exclusions .= " AND member_role != '9'";
          659  +
          660  +
          661  +		
          662  +		$query = $cDB->Query("SELECT ".DATABASE_MEMBERS.".member_id FROM ". DATABASE_MEMBERS .",". DATABASE_PERSONS." WHERE ". DATABASE_MEMBERS .".member_id=". DATABASE_PERSONS.".member_id". $exclusions. " AND primary_member='Y' ORDER BY first_name, last_name;");
          663  +		
          664  +		$i=0;
          665  +		while($row = mysql_fetch_array($query))
          666  +		{
          667  +			$this->members[$i] = new cMember;			
          668  +			$this->members[$i]->LoadMember($row[0]);
          669  +			$i += 1;
          670  +		}
          671  +		
          672  +		if($i == 0)
          673  +			return false;
          674  +		else
          675  +			return true;		
          676  +	}	
          677  +	
          678  +	function MakeIDArray() {
          679  +		global $cDB, $cErr;
          680  +		
          681  +		$ids="";		
          682  +		if($this->members) {
          683  +			foreach($this->members as $member) {
          684  +					$ids[$member->member_id] = $member->PrimaryName() ." (". $member->member_id .")";
          685  +			}		
          686  +		}
          687  +		
          688  +		return $ids;	
          689  +	}	
          690  +	
          691  +	function MakeNameArray() {
          692  +		global $cDB, $cErr;
          693  +		
          694  +		$names["0"] = "";
          695  +		
          696  +		if($this->members) {
          697  +			foreach($this->members as $member) {
          698  +				foreach ($member->person as $person) {			
          699  +					$names[$member->member_id ."?". $person->person_id] = $person->first_name ." ". $person->last_name ." (". $member->member_id .")";
          700  +				}
          701  +			}	
          702  +		
          703  +			array_multisort($names);// sort purely by person name (instead of member, person)
          704  +		}
          705  +		
          706  +		return $names;		
          707  +	}	
          708  +	
          709  +	// Use of this function requires the inclusion of class.listing.php
          710  +	function EmailListingUpdates($interval) {
          711  +		if(!isset($this->members)) {
          712  +			if(!$this->LoadMemberGroup())
          713  +				return false;
          714  +		}
          715  +
          716  +		$listings = new cListingGroup(OFFER_LISTING);
          717  +		$since = new cDateTime("-". $interval ." days"); 
          718  +		$listings->LoadListingGroup(null,null,null,$since->MySQLTime());
          719  +		$offered_text = $listings->DisplayListingGroup(true);
          720  +		$listings = new cListingGroup(WANT_LISTING);
          721  +		$listings->LoadListingGroup(null,null,null,$since->MySQLTime());
          722  +		$wanted_text = $listings->DisplayListingGroup(true);
          723  +		
          724  +		$email_text = "";
          725  +		if($offered_text != "No se han encontrado.")
          726  +			$email_text .= "<h2>Listas de Ofertas</h2><br>". $offered_text ."<p><br>";
          727  +		if($wanted_text != "No se han encontrado.")
          728  +			$email_text .= "<h2>Listas de Demandas</h2><br>". $wanted_text;
          729  +		if(!$email_text)
          730  +			return; // If no new listings, don't email
          731  +		
          732  +		$email_text = "<html><body>". LISTING_UPDATES_MESSAGE ."<p><br>".$email_text. "</body></html>";
          733  +			
          734  +		if ($interval == '1')
          735  +			$period = " el día";
          736  +		elseif ($interval == '7')
          737  +			$period = "la última semana";
          738  +		else
          739  +			$period = "el último mes";			
          740  +		set_time_limit(0); 
          741  +        ignore_user_abort();   
          742  +		foreach($this->members as $member) {						
          743  +			if($member->email_updates == $interval and $member->person[0]->email) {
          744  +	//			mail($member->person[0]->email, SITE_SHORT_TITLE .": Ofertas o demandas nuevas o actualizadas durante el periodo  ". $period, wordwrap($email_text, 64), "De:". EMAIL_ADMIN ."\nMIME-Version: 1.0\n" . "Content-type: text/html; charset=UTF-8"); 
          745  +    $text = wordwrap($email_text, 64);
          746  +    $html = iconv('utf-8', 'windows-1252', ROTULO_MAIL.$text.AVISO_LEGAL); 
          747  +    $to = $member->person[0]->email;
          748  +    $crlf = "\n";
          749  +    $headers = array ('From' => EMAIL_FROM,
          750  +    'To' => $to,
          751  +    'Subject' => SITE_SHORT_TITLE .": Ofertas o demandas nuevas o actualizadas en ". $period);
          752  +            $mime = new Mail_mime($crlf);
          753  +            $mime->setTXTBody($text);
          754  +            $mime->setHTMLBody($html); 
          755  +            $body = $mime->get();
          756  +            $headers = $mime->headers($headers);
          757  +     $smtp = Mail::factory('mail');
          758  +     $mailed = $smtp->send($to, $headers, $body);
          759  +            }
          760  +		
          761  +		}
          762  +	
          763  +	}
          764  +	
          765  +	// Use of this function requires the inclusion of class.listing.php
          766  +	function ExpireListings4InactiveMembers() {
          767  +		if(!isset($this->members)) {
          768  +			if(!$this->LoadMemberGroup())
          769  +				return false;
          770  +		}
          771  +		
          772  +		foreach($this->members as $member) {
          773  +			if($member->DaysSinceLastTrade() >= MAX_DAYS_INACTIVE
          774  +			and $member->DaysSinceUpdatedListing() >= MAX_DAYS_INACTIVE) {
          775  +				$offer_listings = new cListingGroup(OFFER_LISTING);
          776  +				$want_listings = new cListingGroup(WANT_LISTING);
          777  +				
          778  +				$offered_exist = $offer_listings->LoadListingGroup(null, null, $member->member_id, null, false);
          779  +				$wanted_exist = $want_listings->LoadListingGroup(null, null, $member->member_id, null, false);
          780  +				
          781  +				if($offered_exist or $wanted_exist)	{
          782  +					$expire_date = new cDateTime("+". EXPIRATION_WINDOW ." days");
          783  +					if($offered_exist)
          784  +						$offer_listings->ExpireAll($expire_date);
          785  +					if($wanted_exist)
          786  +						$want_listings->ExpireAll($expire_date);
          787  +				
          788  +					if($member->person[0]->email != null) {
          789  +	//					mail($member->person[0]->email, "Información importante sobre tu cuenta en  ". SITE_SHORT_TITLE ." ", wordwrap(EXPIRED_LISTINGS_MESSAGE, 64), "De:". EMAIL_ADMIN); 
          790  +						$note = "";
          791  +						$subject_note = "";
          792  +					} else {
          793  +						$note = "\n\n***NOTE: Este miembro no tiene email, hay que avisarle por teléfono de que su cuenta está inactiva.";
          794  +						$subject_note = " (sin email)";
          795  +					}
          796  +					
          797  +	//				mail(EMAIL_ADMIN, SITE_SHORT_TITLE ." ofertas y demandas finalizadas de ". $member->member_id. $subject_note, wordwrap("Todas las ofertas y demandas de este miembro han sido finalizadas por inactividad.  To turn off this feature, see inc.config.php.". $note, 64) , "From:". EMAIL_ADMIN);
          798  +				}
          799  +			}
          800  +		}
          801  +	}
          802  +}
          803  +
          804  +class cMemberGroupMenu extends cMemberGroup {		
          805  +	var $id;
          806  +	var $name;
          807  +	var $person_id;
          808  +
          809  +	function MakeMenuArrays() {
          810  +		global $cDB, $cErr;
          811  +		
          812  +		$i = 0;
          813  +		$j = 0;	
          814  +		foreach($this->members as $member) {
          815  +			foreach ($member->person as $person) {
          816  +				$this->id[$i] = $member->member_id;
          817  +				$this->name[$i][$j] = $person->first_name." ".$person->last_name;
          818  +				$this->person_id[$i][$j] = $person->person_id;						
          819  +				$j += 1;
          820  +			}
          821  +			$i += 1;
          822  +		}
          823  +		
          824  +		if($i <> 0)
          825  +			return true;
          826  +		else 
          827  +			return false;
          828  +	}
          829  +}
          830  +
          831  +class cBalancesTotal {
          832  +	var $balance;
          833  +    var $usuarios;
          834  +	function Balanced() {
          835  +		global $cDB, $cErr;
          836  +		
          837  +	//	$query = $cDB->Query("SELECT sum(balance) from ". DATABASE_MEMBERS .";");
          838  +		$query = $cDB->Query("SELECT sum(balance), COUNT(*) from ". DATABASE_MEMBERS .";"); 
          839  +        
          840  +		if($row = mysql_fetch_array($query)) {
          841  +			$this->balance = $row[0];
          842  +			$this->usuarios = $row[1];
          843  +			if($this->balance == ($this->usuarios)*3)                 // if($row[0] == 0 aunque ahora no es así     CORREGIR LUEGO QUE SERA -1 PORQUE BORRAMOS AL ADMIN
          844  +				return true;
          845  +			else
          846  +				return false;
          847  +		} else {
          848  +			$cErr->Error("Could not query database for balance information. Please try again later.");
          849  +			return false;
          850  +		}		
          851  +	}
          852  +}
          853  +
          854  +$cUser = new cMember();
          855  +$cUser->RegisterWebUser();
          856  +
          857  +?>

Added bdt/classes/class.news.php

            1  +<?
            2  +
            3  +class cNews {
            4  +    var $news_id;
            5  +    var $title;
            6  +    var $description;
            7  +    var $expire_date;
            8  +    var $sequence;
            9  +
           10  +    function cNews ($title=null, $description=null, $expire_date=null, $sequence=null) {
           11  +        if($title) {
           12  +            $this->title = $title;
           13  +            $this->description = $description;
           14  +            $this->expire_date = new cDateTime($expire_date);
           15  +            $this->sequence = $sequence;
           16  +        }
           17  +    }
           18  +    
           19  +    function SaveNewNews () {
           20  +        global $cDB, $cErr;
           21  +        
           22  +        $insert = $cDB->Query("INSERT INTO ". DATABASE_NEWS ." (title, description, expire_date, sequence) VALUES (".$cDB->EscTxt($this->title) .", ". $cDB->EscTxt($this->description) .", '". $this->expire_date->MySQLDate() ."', ". $this->sequence .");");
           23  +
           24  +        if(mysql_affected_rows() == 1) {
           25  +            $this->news_id = mysql_insert_id();        
           26  +            return true;
           27  +        } else {
           28  +            $cErr->Error("No se ha podido grabar el elemento.");
           29  +            return false;
           30  +        }        
           31  +    }
           32  +    
           33  +    function SaveNews () {
           34  +        global $cDB, $cErr;            
           35  +        
           36  +        $update = $cDB->Query("UPDATE ".DATABASE_NEWS." SET title=". $cDB->EscTxt($this->title) .", description=". $cDB->EscTxt($this->description) .", expire_date='". $this->expire_date->MySQLDate(). "', sequence=". $this->sequence ." WHERE news_id=". $this->news_id .";");    
           37  +
           38  +        return $update;    
           39  +    }
           40  +    
           41  +    function LoadNews ($news_id) {
           42  +        global $cDB, $cErr;
           43  +        
           44  +//        $this->ExpireNews();
           45  +                
           46  +        $query = $cDB->Query("SELECT title, description, expire_date, sequence FROM ".DATABASE_NEWS." WHERE  news_id=". $news_id.";");
           47  +        
           48  +        if($row = mysql_fetch_array($query)) {        
           49  +            $this->news_id = $news_id;
           50  +            $this->title = $cDB->UnEscTxt($row[0]);
           51  +            $this->description = $cDB->UnEscTxt($row[1]);        
           52  +            $this->expire_date = new cDateTime($row[2]);
           53  +            $this->sequence = $row[3];
           54  +            return true;
           55  +        } else {
           56  +            $cErr->Error("Ha ocurrido un error al acceder a la tabla de noticias.  Por favor, inténtelo más tarde.");
           57  +            include("redirect.php");
           58  +        }
           59  +        
           60  +    }
           61  +
           62  +    function DisplayNews () {
           63  +        $output = "<STRONG>". $this->title ."</STRONG><P>";
           64  +        $output .= $this->description ."<P>";
           65  +        return $output;
           66  +    }
           67  +}
           68  +
           69  +class cNewsGroup {
           70  +    var $newslist;  // will be an array of cNews objects
           71  +    var $max_seq;
           72  +    
           73  +    function LoadNewsGroup () {
           74  +        global $cDB, $cErr;
           75  +        
           76  +        $this->DeleteOldNews();
           77  +    
           78  +        $query = $cDB->Query("SELECT news_id FROM ".DATABASE_NEWS." ORDER BY sequence DESC;");
           79  +        
           80  +        $i = 0;                
           81  +        while($row = mysql_fetch_array($query)) {
           82  +            $this->newslist[$i] = new cNews;            
           83  +            $this->newslist[$i]->LoadNews($row[0]);
           84  +            $i += 1;
           85  +        }
           86  +
           87  +        if($i == 0)
           88  +            return false;
           89  +        else
           90  +            $this->max_seq = $this->newslist[0]->sequence;
           91  +            return true;
           92  +    }
           93  +    
           94  +    function DisplayNewsGroup () {
           95  +        $output = "";
           96  +        if(!isset($this->newslist))
           97  +            return $output;
           98  +        
           99  +        foreach($this->newslist as $news) {
          100  +            if($news->expire_date->Timestamp() > strtotime("yesterday"))
          101  +                $output .= $news->DisplayNews() . "<BR>";
          102  +        }
          103  +        return $output;
          104  +    }
          105  +    
          106  +    function MakeNewsArray() {
          107  +        if (!isset($this->newslist))
          108  +            return false;
          109  +            
          110  +        foreach($this->newslist as $news) {
          111  +            $list[$news->news_id] = $news->title;
          112  +        }
          113  +        return $list;
          114  +    }
          115  +
          116  +    function MakeNewsSeqArray($current_seq=null) { // TODO: OK, this is just ugly...
          117  +        $prior_seq = 0;                                    // Should use 1,2,3,4... and reorder
          118  +        $prior_title = "La primera de la lista";                // all each time.
          119  +        $lead_txt = "";
          120  +        $follow_txt = "";
          121  +        
          122  +        if (!isset($this->newslist))
          123  +            return array("100"=>$prior_title);
          124  +        
          125  +        foreach($this->newslist as $news) {
          126  +            if ($current_seq == $news->sequence) {
          127  +                $list[$this->CutZero($current_seq)] = $lead_txt. $prior_title . $follow_txt;
          128  +            } elseif ($prior_seq != $current_seq or $current_seq == null) {
          129  +                if ($prior_seq == 0)
          130  +                    $seq = $this->GetNewSeqNum();
          131  +                else
          132  +                    $seq = $this->GetSeqNumAfter($prior_seq);
          133  +                    
          134  +                $list[$seq] = $lead_txt. $prior_title .$follow_txt;
          135  +            }
          136  +            
          137  +            $prior_seq = $news->sequence;
          138  +            $saved_title = $prior_title;
          139  +            $prior_title = $news->title;
          140  +            $lead_txt = "Después de '";
          141  +            $follow_txt = "'";
          142  +        }
          143  +        
          144  +        if ($current_seq != $news->sequence) {
          145  +            if ($prior_seq == 0)
          146  +                $seq = $this->GetNewSeqNum();
          147  +            else
          148  +                $seq = $this->GetSeqNumAfter($prior_seq);
          149  +        
          150  +            $list[$seq] = $lead_txt . $prior_title . $follow_txt;
          151  +        }
          152  +        
          153  +        return $list;    
          154  +    }    
          155  +    
          156  +    function CutZero($value) {
          157  +       return preg_replace("/(\.\d+?)0+$/", "$1", $value)*1;
          158  +    }
          159  +
          160  +    function DeleteOldNews () {
          161  +        global $cDB;
          162  +        
          163  +        $future_date = new cDateTime("-14 days");
          164  +        
          165  +        $delete = $cDB->Query("DELETE FROM ".DATABASE_NEWS." WHERE expire_date < '". $future_date->MySQLDate() ."';");
          166  +        return $delete;
          167  +    }
          168  +    
          169  +    function GetSeqNumAfter ($high) {
          170  +        $low = 0;
          171  +        foreach($this->newslist as $news) {
          172  +            if ($news->sequence < $high) {
          173  +                $low = $news->sequence;
          174  +                break;
          175  +            } 
          176  +        }
          177  +        
          178  +        return $low + (($high - $low) / 2);
          179  +    }
          180  +    
          181  +    function GetNewSeqNum () {
          182  +        return round($this->max_seq + 100, -2);
          183  +    }
          184  +}
          185  +
          186  +?>

Added bdt/classes/class.page.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +class cPage {
            9  +	var $page_title;
           10  +	var $page_title_image; // Filename, no path
           11  +	var $page_header;	// HTML
           12  +	var $page_footer;	// HTML
           13  +	var $keywords;		
           14  +	var $site_section;
           15  +	var $sidebar_buttons; 	// An array of cMenuItem objects
           16  +	var $top_buttons;			// An array of cMenuItem objects    TODO: Implement top buttons...
           17  +
           18  +	function cPage() {
           19  +		global $cUser, $SIDEBAR;
           20  +		
           21  +		$this->keywords = SITE_KEYWORDS;
           22  +		$this->page_header = PAGE_HEADER_CONTENT;
           23  +		$this->page_footer = PAGE_FOOTER_CONTENT;
           24  +		
           25  +		foreach ($SIDEBAR as $button) {
           26  +			$this->AddSidebarButton($button[0], $button[1]);
           27  +		}
           28  +
           29  +		if ($cUser->IsLoggedOn()) {	
           30  +			$this->AddSidebarButton("<div style='font-weight:bold'>Mis Ofertas</div>", "listings_menu_ofertas.php");
           31  +			$this->AddSidebarButton("<div style='font-weight:bold'>Mis Demandas</div>", "listings_menu_demandas.php");
           32  +			$this->AddSidebarButton("<div style='font-weight:bold'>Intercambio</div>", "exchange_menu.php");
           33  +			$this->AddSidebarButton("<div style='font-weight:bold'>Miembros</div>", "member_directory.php");
           34  +			$this->AddSidebarButton("<div style='font-weight:bold'>Perfil</div>", "member_profile.php");
           35  +			$this->AddSidebarButton("<div style='font-weight:bold'>Otros</div>", "listings_menu_otros.php");
           36  +		}
           37  +
           38  +		if ($cUser->member_role > 0) 
           39  +			$this->AddSidebarButton("<div style='font-weight:bold'>Administración</div>", "admin_menu.php");
           40  +
           41  +	}		
           42  +									
           43  +	function AddSidebarButton ($button_text, $url) {
           44  +		$this->sidebar_buttons[] = new cMenuItem($button_text, $url);
           45  +	}
           46  +	
           47  +	function AddTopButton ($button_text, $url) { // Top buttons aren't integrated into header yet...
           48  +		$this->top_buttons[] = new cMenuItem($button_text, $url);
           49  +	}
           50  +
           51  +	function MakePageHeader() {
           52  +		global $cUser;
           53  +		
           54  +		if(isset($this->page_title)) 
           55  +			$title = " - ". $this->page_title;
           56  +		else
           57  +			$title = "";
           58  +		
           59  +		$output = '<HEAD><meta name="verify-v1" content="NpBtG7ofqLlzGzlObZCsIkXggmaMlPANDCqjDGgEa6E=" /><link rel="stylesheet" href="http://'. HTTP_BASE .'/'. SITE_STYLESHEET .'" type="text/css"></link><META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=UTF-8"><meta name="description" content="'.$this->page_title.'"><meta NAME="keywords" content="'. $this->keywords .'"><TITLE>'. PAGE_TITLE_HEADER . $title .'</TITLE></HEAD>';
           60  +		
           61  +		$output .= "<HTML><BODY>";
           62  +             
           63  +        $output .= $this->page_header;
           64  +        $output .= "<div align=right>";
           65  +         if ($cUser->IsLoggedOn())
           66  +        $output .= "<B>". $cUser->PrimaryName(). "</B>";
           67  +        $output .= $cUser->UserLoginLogout();                                   
           68  +        $output .= "</div></td></tr>";    
           69  +		return $output;  
           70  +	}
           71  +
           72  +	function MakePageMenu() {
           73  +		global $cUser, $cSite, $cErr;
           74  +	
           75  +		$output = "<td valign=top id=\"sidebar\"><ul>";
           76  +	
           77  +		foreach ($this->sidebar_buttons as $menu_item) {
           78  +
           79  +				$output .= $menu_item->DisplayButton();
           80  +
           81  +		}
           82  +// TO DO:  En el siguiente if he cambiado  $_SESSION["REQUEST_URI"]  por   SERVER_PATH_URL."/member_login.php  
           83  +// porque no leía la sesión.
           84  +		if (!$cUser->IsLoggedOn())
           85  +			$output .= "<li><b><br>Asociados/as:</b></li><li><FORM ACTION='".SERVER_PATH_URL."/login.php' METHOD=POST><INPUT TYPE=HIDDEN NAME=action VALUE=login><INPUT TYPE=HIDDEN NAME=location VALUE='".SERVER_PATH_URL."/member_login.php'>ID Miembro:<br><INPUT TYPE=TEXT SIZE=12 NAME=user></li><li>Contraseña:<br><INPUT TYPE=PASSWORD SIZE=12 NAME=pass></li><li><INPUT TYPE=SUBMIT VALUE='Entrar'></FORM></li>";
           86  +	
           87  +		$output .= "</ul><p>&nbsp;</p></td>";
           88  +
           89  +
           90  +
           91  +		$output .= "<TD id=\"maincontent\" valign=top>".$cErr->ErrorBox();
           92  +	
           93  +		return $output;
           94  +	}
           95  +
           96  +	function MakePageTitle() {
           97  +		global $SECTIONS;
           98  +		
           99  +		if (!isset($this->page_title) or !isset($this->site_section)) {
          100  +			return "";
          101  +		} else {
          102  +			if (!isset($this->page_title_image))
          103  +				$this->page_title_image = $SECTIONS[$this->site_section][2];
          104  +				
          105  +			return '<H2><IMG SRC="http://'. IMAGES_PATH . $this->page_title_image .'" align=middle>'. $this->page_title .'</H2><P>';
          106  +		}		
          107  +	}
          108  +									
          109  +	function MakePageFooter() {
          110  +		return "</TD></TR>". $this->page_footer ."</BODY></HTML>";
          111  +	}	
          112  +			
          113  +	function DisplayPage($content = "") {
          114  +		global $cErr;
          115  +		if ($content=="")
          116  +			$cErr->Error("DisplayPage() was called with no content included!  Was a blank page intended?",ERROR_SEVERITY_HIGH,__FILE__,__LINE__);
          117  +	
          118  +		print $this->MakePageHeader();
          119  +		print $this->MakePageMenu();	
          120  +		print $this->MakePageTitle();
          121  +		
          122  +		print $content;
          123  +		print $this->MakePageFooter();
          124  +	}	
          125  +	
          126  +	
          127  +}
          128  +
          129  +class cMenuItem {
          130  +	var $button_text;
          131  +	var $url;
          132  +	
          133  +	function cMenuItem ($button_text, $url) {
          134  +		$this->button_text = $button_text;
          135  +		$this->url = $url;
          136  +	}
          137  +	
          138  +	function DisplayButton() {
          139  +		return "<li><div align=left><a href=\"http://". HTTP_BASE ."/". $this->url ."\">". $this->button_text ."</a></div></li>";
          140  +	}
          141  +}
          142  +
          143  +$p = new cPage;
          144  +
          145  +?>

Added bdt/classes/class.person.php

            1  +<?
            2  +
            3  +class cPerson
            4  +{
            5  +	var $person_id;			
            6  +	var $member_id;
            7  +	var $primary_member;
            8  +	var $directory_list;
            9  +	var $first_name;
           10  +	var $last_name;
           11  +	var $mid_name;
           12  +	var $dob;
           13  +	var $mother_mn;
           14  +	var $email;
           15  +	var $phone1_area;
           16  +	var $phone1_number;
           17  +	var $phone1_ext;
           18  +	var $phone2_area;
           19  +	var $phone2_number;
           20  +	var $phone2_ext;
           21  +	var $fax_area;
           22  +	var $fax_number;
           23  +	var $fax_ext;
           24  +	var $address_street1;
           25  +	var $address_street2;
           26  +	var $address_city;
           27  +	var $address_state_code;
           28  +	var $address_post_code;
           29  +	var $address_country;
           30  +    var $imagen;
           31  +
           32  +
           33  +	function cPerson($values=null) {
           34  +		if($values) {
           35  +			$this->member_id = $values['member_id'];
           36  +			$this->primary_member = $values['primary_member'];
           37  +			$this->directory_list = $values['directory_list'];
           38  +			$this->first_name = $values['first_name'];
           39  +			$this->last_name = $values['last_name'];
           40  +			$this->mid_name = $values['mid_name'];
           41  +			$this->dob = $values['dob'];
           42  +			$this->mother_mn = $values['mother_mn'];
           43  +			$this->email = $values['email'];
           44  +			$this->phone1_area = $values['phone1_area'];
           45  +			$this->phone1_number = $values['phone1_number'];
           46  +			$this->phone1_ext = $values['phone1_ext'];
           47  +			$this->phone2_area = $values['phone2_area'];
           48  +			$this->phone2_number = $values['phone2_number'];
           49  +			$this->phone2_ext = $values['phone2_ext'];
           50  +			$this->fax_area = $values['fax_area'];
           51  +			$this->fax_number = $values['fax_number'];
           52  +			$this->fax_ext = $values['fax_ext'];
           53  +			$this->address_street1 = $values['address_street1'];
           54  +			$this->address_street2 = $values['address_street2'];
           55  +			$this->address_city = $values['address_city'];
           56  +			$this->address_state_code = $values['address_state_code'];
           57  +			$this->address_post_code = $values['address_post_code'];
           58  +			$this->address_country = $values['address_country'];	
           59  +            $this->imagen = $values['imagen'];	
           60  +		}
           61  +	}
           62  +
           63  +	function SaveNewPerson() {
           64  +		global $cDB, $cErr;
           65  +
           66  +		$duplicate_exists = $cDB->Query("SELECT NULL FROM ".DATABASE_PERSONS." WHERE member_id='". $this->member_id ."' AND first_name". $cDB->EscTxt2($this->first_name) ." AND last_name". $cDB->EscTxt2($this->last_name) ." AND mother_mn". $cDB->EscTxt2($this->mother_mn) ." AND mid_name". $cDB->EscTxt2($this->mid_name) ." AND dob". $cDB->EscTxt2($this->dob) .";");
           67  +		
           68  +		if($row = mysql_fetch_array($duplicate_exists)) {
           69  +			$cErr->Error("Could not save new person. There is already a person in your account with the same name, date of birth, and mother's maiden name. If you received this error after pressing the Back button, try going back to the menu and starting again.");
           70  +			include("redirect.php");
           71  +		}
           72  +		$nadie = "nadie";
           73  +		$insert = $cDB->Query("INSERT INTO ".DATABASE_PERSONS." (member_id, primary_member, directory_list, first_name, last_name, mid_name, dob, mother_mn, email, phone1_area, phone1_number, phone1_ext, phone2_area, phone2_number, phone2_ext, fax_area, fax_number, fax_ext, address_street1, address_street2, address_city, address_state_code, address_post_code, address_country, imagen) VALUES ('". $this->member_id ."','". $this->primary_member ."','". $this->directory_list ."',". $cDB->EscTxt($this->first_name) .",". $cDB->EscTxt($this->last_name) .",". $cDB->EscTxt($this->mid_name) .",". $cDB->EscTxt($this->dob) .",". $cDB->EscTxt($this->mother_mn) .",". $cDB->EscTxt($this->email) .",". $cDB->EscTxt($this->phone1_area) .",". $cDB->EscTxt($this->phone1_number) .",". $cDB->EscTxt($this->phone1_ext) .",". $cDB->EscTxt($this->phone2_area) .",". $cDB->EscTxt($this->phone2_number) .",". $cDB->EscTxt($this->phone2_ext) .",". $cDB->EscTxt($this->fax_area) .",". $cDB->EscTxt($this->fax_number) .",". $cDB->EscTxt($this->fax_ext) .",". $cDB->EscTxt($this->address_street1) .",". $cDB->EscTxt($this->address_street2) .",'". $this->address_city ."','". $this->address_state_code ."','". $this->address_post_code ."','". $this->address_country ."','". $nadie ."');");             //,'". $this->imagen ."');");
           74  +	
           75  +		return $insert;
           76  +	}
           77  +			
           78  +	function SavePerson() {
           79  +		global $cDB, $cErr;
           80  +		
           81  +		$update = $cDB->Query("UPDATE ". DATABASE_PERSONS ." SET member_id='". $this->member_id ."', primary_member='". $this->primary_member ."', directory_list='". $this->directory_list ."', first_name=". $cDB->EscTxt($this->first_name) .", last_name=". $cDB->EscTxt($this->last_name) .", mid_name=". $cDB->EscTxt($this->mid_name) .", dob=". $cDB->EscTxt($this->dob) .", mother_mn=". $cDB->EscTxt($this->mother_mn) .", email=". $cDB->EscTxt($this->email) .", phone1_area=". $cDB->EscTxt($this->phone1_area) .", phone1_number=". $cDB->EscTxt($this->phone1_number) .", phone1_ext=". $cDB->EscTxt($this->phone1_ext) .", phone2_area=". $cDB->EscTxt($this->phone2_area) .", phone2_number=". $cDB->EscTxt($this->phone2_number) .", phone2_ext=". $cDB->EscTxt($this->phone2_ext) .", fax_area=". $cDB->EscTxt($this->fax_area) .", fax_number=". $cDB->EscTxt($this->fax_number) .", fax_ext=". $cDB->EscTxt($this->fax_ext) .", address_street1=". $cDB->EscTxt($this->address_street1) .", address_street2=". $cDB->EscTxt($this->address_street2) .", address_city='". $this->address_city ."', address_state_code='". $this->address_state_code ."', address_post_code='". $this->address_post_code ."', address_country='". $this->address_country ."' WHERE person_id='".$this->person_id ."';");
           82  +
           83  +		if(!$update)
           84  +			$cErr->Error("Could not save changes to '". $this->first_name ." ". $this->last_name ."'. Please try again later.");	
           85  +			
           86  +		return $update;
           87  +	}
           88  +
           89  +	function LoadPerson($who)
           90  +	{
           91  +		global $cDB, $cErr;
           92  +
           93  +		$query = $cDB->Query("SELECT member_id, primary_member, directory_list, first_name, last_name, mid_name, dob, mother_mn, email, phone1_area, phone1_number, phone1_ext, phone2_area, phone2_number, phone2_ext, fax_area, fax_number, fax_ext, address_street1, address_street2, address_city, address_state_code, address_post_code, address_country, imagen FROM ".DATABASE_PERSONS." WHERE person_id=".$who);
           94  +		
           95  +		if($row = mysql_fetch_array($query))
           96  +		{
           97  +			$this->person_id=$who;	
           98  +			$this->member_id=$row[0];
           99  +			$this->primary_member=$row[1];
          100  +			$this->directory_list=$row[2];
          101  +			$this->first_name=$cDB->UnEscTxt($row[3]);
          102  +			$this->last_name=$cDB->UnEscTxt($row[4]);
          103  +			$this->mid_name=$cDB->UnEscTxt($row[5]);
          104  +			$this->dob=$row[6];
          105  +			$this->mother_mn=$cDB->UnEscTxt($row[7]);
          106  +			$this->email=$row[8];
          107  +			$this->phone1_area=$row[9];
          108  +			$this->phone1_number=$row[10];
          109  +			$this->phone1_ext=$row[11];
          110  +			$this->phone2_area=$row[12];
          111  +			$this->phone2_number=$row[13];
          112  +			$this->phone2_ext=$row[14];
          113  +			$this->fax_area=$row[15];
          114  +			$this->fax_number=$row[16];
          115  +			$this->fax_ext=$row[17];
          116  +			$this->address_street1=$cDB->UnEscTxt($row[18]);
          117  +			$this->address_street2=$cDB->UnEscTxt($row[19]);
          118  +			$this->address_city=$row[20];
          119  +			$this->address_state_code=$row[21];
          120  +			$this->address_post_code=$row[22];
          121  +			$this->address_country=$row[23];
          122  +            $this->imagen=$row[24];
          123  +	
          124  +		}
          125  +		else 
          126  +		{
          127  +			$cErr->Error("There was an error accessing this person (".$who.").  Please try again later.");
          128  +			include("redirect.php");
          129  +		}		
          130  +	}		
          131  +	
          132  +	function DeletePerson() {
          133  +		global $cDB, $cErr;
          134  +		
          135  +		if($this->primary_member == 'Y') {
          136  +			$cErr->Error("Cannot delete primary member!");	
          137  +			return false;
          138  +		} 
          139  +		
          140  +		$delete = $cDB->Query("DELETE FROM ".DATABASE_PERSONS." WHERE person_id=". $this->person_id);
          141  +		
          142  +		unset($this->person_id);
          143  +		
          144  +		if (mysql_affected_rows() == 1) {
          145  +			return true;
          146  +		} else {
          147  +			$cErr->Error("Error deleting joint member.  Please try again later.");
          148  +		}
          149  +		
          150  +	}
          151  +							
          152  +	function ShowPerson()
          153  +	{
          154  +		$output = $this->person_id . ", " . $this->member_id . ", " . $this->primary_member . ", " . $this->directory_list . ", " . $this->first_name . ", " . $this->last_name . ", " . $this->mid_name . ", " . $this->dob . ", " . $this->mother_mn . ", " . $this->email . ", " . $this->phone1_area . ", " . $this->phone1_number . ", " . $this->phone1_ext . ", " . $this->phone2_area . ", " . $this->phone2_number . ", " . $this->phone2_ext . ", " . $this->fax_area . ", " . $this->fax_number . ", " . $this->fax_ext . ", " . $this->address_street1 . ", " . $this->address_street2 . ", " . $this->address_city . ", " . $this->address_state_code . ", " . $this->address_post_code . ", " . $this->address_country ."," . $this->imagen;
          155  +		
          156  +		return $output;
          157  +	}
          158  +
          159  +	function Name() {
          160  +		return $this->first_name . " " .$this->last_name;	
          161  +	}
          162  +			
          163  +	function DisplayPhone($type)
          164  +	{
          165  +		global $cErr;
          166  +
          167  +		switch ($type)
          168  +		{
          169  +			case "1":
          170  +				$phone_area = $this->phone1_area;
          171  +				$phone_number = $this->phone1_number;
          172  +				$phone_ext = $this->phone1_ext;
          173  +				break;
          174  +			case "2":
          175  +				$phone_area = $this->phone2_area;
          176  +				$phone_number = $this->phone2_number;
          177  +				$phone_ext = $this->phone2_ext;
          178  +				break;
          179  +			case "fax":
          180  +				$phone_area = $this->fax_area;
          181  +				$phone_number = $this->fax_number;
          182  +				$phone_ext = $this->fax_ext;
          183  +				break;								
          184  +			default:
          185  +				$cErr->Error("No existe ese tipo de teléfono.");
          186  +				return "ERROR";
          187  +		}
          188  +		
          189  +		if($phone_number != "") {
          190  +		    $phone = $phone_area . $phone_number;
          191  +		} else {
          192  +			$phone = "";
          193  +		}
          194  +		
          195  +		return $phone;
          196  +	}
          197  +}
          198  +
          199  +
          200  +class cPhone {
          201  +    var $area;
          202  +    var $prefix;
          203  +    var $suffix;
          204  +    var $ext;
          205  +    
          206  +    function cPhone($phone_str=null) { // this constructor attempts to break down free-form phone #s
          207  +        if($phone_str) {                        // TODO: Use reg expressions to shorten this thing
          208  +            $ext = "";
          209  +            $phone_str = strtolower($phone_str);
          210  +            $phone_str = ereg_replace("\(","",$phone_str);
          211  +            $phone_str = ereg_replace("\)","",$phone_str);
          212  +            $phone_str = ereg_replace("-","",$phone_str);
          213  +            $phone_str = ereg_replace("\.","",$phone_str);
          214  +            $phone_str = ereg_replace(" ","",$phone_str);
          215  +            $phone_str = ereg_replace("e","",$phone_str);
          216  +            
          217  +            if (strlen($phone_str) == 9) {
          218  +                $this->area = substr($phone_str,0,3);
          219  +                $this->prefix = substr($phone_str,3,3);
          220  +                $this->suffix = substr($phone_str,6,3);
          221  +                $this->ext = $ext;                
          222  +            } else {
          223  +                return false;            
          224  +            }
          225  +        }
          226  +    }
          227  +    /* paso de renombrar */
          228  +    function SevenDigits() {
          229  +        return $this->prefix . $this->suffix;
          230  +    }
          231  +    
          232  +} 
          233  +?>

Added bdt/classes/class.site.php

            1  +<?
            2  +
            3  +// Not currently using this class.  Started it with the intention of replacing
            4  +// site configuration constants with classes, but thought better of it, at
            5  +// least for the moment...
            6  +
            7  +class cSite {
            8  +	var $server_domain;
            9  +	var $server_path_url;
           10  +	var $server_filesystem_base;
           11  +	var $redirect_url;
           12  +	var $magic_quotes_gpc_status;
           13  +	var $magic_quotes_runtime_status;
           14  +	var $site_sections  // An array of cSiteSection objects
           15  +	
           16  +	function SetMagicQuotesGPC ($turn_on) {
           17  +		if($turn_on) {
           18  +			if(set_magic_quotes_gpc ($turn_on))
           19  +				$this->magic_quotes_gpc_status = true;
           20  +			else
           21  +				$this->magic_quotes_gpc_status = false;
           22  +		} else {
           23  +			set_magic_quotes_gpc (0);
           24  +			$this->magic_quotes_gpc_status = false;
           25  +		}
           26  +		
           27  +	}
           28  +	
           29  +	function SetMagicQuotesRuntime ($turn_on) {
           30  +		if($turn_on) {
           31  +			if(set_magic_quotes_runtime (1))
           32  +				$this->magic_quotes_runtime_status = true;
           33  +			else
           34  +				$this->magic_quotes_runtime_status = false;
           35  +		} else {
           36  +			set_magic_quotes_runtime (0);
           37  +			$this->magic_quotes_runtime_status = false;
           38  +		}
           39  +		
           40  +	}
           41  +	
           42  +	function BasePath () {
           43  +		return $this->server_domain . $this->server_path_url;
           44  +	}
           45  +	
           46  +	function IncludesPath () {
           47  +		return $server_filesystem_base . $server_path_url ."/includes/";
           48  +	}
           49  +	
           50  +	function ClassesPath () {
           51  +		return $server_filesystem_base . $server_path_url ."/classes/";
           52  +	}
           53  +
           54  +	function AddSiteSection ($description, $url) {
           55  +		$this->site_sections[] = new cSiteSection($description, $url);
           56  +	}
           57  +
           58  +}
           59  +
           60  +class cSiteSection {
           61  +	var $description;
           62  +	var $url;
           63  +	
           64  +	function cSiteSection($description, $url) {
           65  +		$this->description = $description;
           66  +		$this->url = $url;
           67  +	}
           68  +}
           69  +
           70  +$cSite = new cSite;
           71  +
           72  +?>

Added bdt/classes/class.table.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +require_once("HTML/Table.php");
            9  +
           10  +class cTable extends HTML_Table {
           11  +	var $curr_row=0;
           12  +
           13  +	function cTable ($attrs=null) {
           14  +		global $CONTENT_TABLE;
           15  +	
           16  +		if(!$attrs)
           17  +			$attrs = $CONTENT_TABLE;
           18  +			
           19  +		$this->HTML_Table($attrs);
           20  +		$this->setAutoGrow = true;
           21  +	}
           22  +
           23  +	function AddSimpleHeader($fields) {
           24  +		$this->setRowAttributes(0, array("id"=>"tableheader"), true);
           25  +	
           26  +		$i=0;
           27  +		foreach($fields as $field) {
           28  +			$this->setHeaderContents(0, $i, $field); 
           29  +			$i += 1;
           30  +		}
           31  +	}
           32  +	
           33  +	function AddSimpleRow($fields) {
           34  +		$this->curr_row += 1;
           35  +		$i=0;
           36  +		foreach($fields as $field) {
           37  +			$this->setCellContents($this->curr_row, $i, $field); 
           38  +			$i += 1;
           39  +		}
           40  +	}
           41  +	
           42  +	function DisplayTable() {
           43  +		$this->altRowAttributes (1, array("id"=>"tablerow"), array("id"=>"tablealtrow"));
           44  +		return "<P><BR>". $this->toHTML();
           45  +	}
           46  +
           47  +}
           48  +
           49  +
           50  +?>

Added bdt/classes/class.trade.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +	die(__FILE__." was included without inc.global.php being included first.  Include() that file first, then you can include ".__FILE__);
            6  +}
            7  +
            8  +include_once("class.category.php");
            9  +include_once("class.feedback.php");
           10  +
           11  +class cTrade {
           12  +	var $trade_id;
           13  +	var $trade_date;
           14  +	var $status;
           15  +	var $member_from;
           16  +	var $member_to;
           17  +	var $amount;
           18  +	var $category;		// this will be an object of class cCategory
           19  +	var $description;
           20  +	var $type;
           21  +	var $feedback_buyer;	// added after trade completed; object of type cFeedback
           22  +	var $feedback_seller; // added after trade completed; object of type cFeedback
           23  +
           24  +	function cTrade ($member_from=null, $member_to=null, $amount=null, $category=null, $description=null, $type='T') {
           25  +		if($member_from) {
           26  +			$this->status = 'V';  // Doesn't make sense for a new Trade to not be valid
           27  +			$this->amount = $amount;
           28  +			$this->description = $description;
           29  +			$this->member_from = $member_from;
           30  +			$this->member_to = $member_to;
           31  +			$this->type = $type;
           32  +			$this->category = new cCategory();
           33  +			$this->category->LoadCategory($category);
           34  +		}
           35  +	}
           36  +	
           37  +	function ShowTrade() {
           38  +		global $cDB;
           39  +		
           40  +		$content = $this->trade_id .", ". $this->trade_date .", ". $this->status .", ". $this->member_from->member_id .", ". $this->member_to->member_id .", ". $this->amount .", ". $this->category->id .", ". $this->description .", ". $this->type;
           41  +		
           42  +		return $content;
           43  +	}
           44  +
           45  +	function SaveTrade() {  // This function should never be called directly
           46  +		global $cDB, $cErr;
           47  +		
           48  +		$insert = $cDB->Query("INSERT INTO ". DATABASE_TRADES ." (trade_date, status, member_id_from, member_id_to, amount, category, description, type) VALUES (now(), '". $this->status ."', '". $this->member_from->member_id ."', '". $this->member_to->member_id ."', ". $this->amount .", '".$this->category->id ."', ". $cDB->EscTxt($this->description) .", '". $this->type ."');");
           49  +
           50  +		if(mysql_affected_rows() == 1) {
           51  +			$this->trade_id = mysql_insert_id();	
           52  +			$query = $cDB->Query("SELECT trade_date from ". DATABASE_TRADES ." WHERE trade_id=". $this->trade_id .";");
           53  +			$row = mysql_fetch_array($query);
           54  +			$this->trade_date = $row[0];	
           55  +			return true;
           56  +		} else {
           57  +			return false;
           58  +		}
           59  +	}
           60  +	
           61  +	function LoadTrade($trade_id) {
           62  +		global $cDB, $cErr;
           63  +		
           64  +		$query = $cDB->Query("SELECT date_format(trade_date,'%Y-%m-%d'), status, member_id_from, member_id_to, amount, description, type, category FROM ".DATABASE_TRADES." WHERE trade_id=".$trade_id.";");
           65  +		
           66  +		if($row = mysql_fetch_array($query)) {		
           67  +			$this->trade_id = $trade_id;
           68  +			$this->trade_date = $row[0];
           69  +			$this->status = $row[1];
           70  +			$this->member_from = new cMember;
           71  +			$this->member_from->LoadMember($row[2]);
           72  +			$this->member_to = new cMember;
           73  +			$this->member_to->LoadMember($row[3]);
           74  +			$this->amount = $row[4];
           75  +			$this->description = $cDB->UnEscTxt($row[5]);
           76  +			$this->type = $row[6];
           77  +			$this->category = new cCategory();
           78  +			$this->category->LoadCategory($row[7]);
           79  +			
           80  +			$feedback = new cFeedback;
           81  +			$feedback_id = $feedback->FindTradeFeedback($trade_id, $this->member_from->member_id);
           82  +			if($feedback_id) {
           83  +				$this->feedback_buyer = new cFeedback;
           84  +				$this->feedback_buyer->LoadFeedback($feedback_id);
           85  +			}
           86  +			$feedback_id = $feedback->FindTradeFeedback($trade_id, $this->member_to->member_id);
           87  +			if($feedback_id) {
           88  +				$this->feedback_seller = new cFeedback;
           89  +				$this->feedback_seller->LoadFeedback($feedback_id);
           90  +			}
           91  +			
           92  +		} else {
           93  +			$cErr->Error("Ocurrió un error al acceder a la tabla de intercambios.  Por favor, inténtelo más tarde.");
           94  +			include("redirect.php");
           95  +		}				
           96  +	}
           97  +
           98  +	// It is very important that this function prevent the database from going out balance.
           99  +	function MakeTrade($reversed_trade_id=null) { 
          100  +		global $cDB, $cErr;
          101  +		
          102  +		if ($this->amount <= 0 and $this->type != TRADE_REVERSAL) // Amount should be positive unless
          103  +			return false;									 // this is a reversal of a previous trade.
          104  +			
          105  +		if ($this->amount >= 0 and $this->type == TRADE_REVERSAL)	 // And likewise.
          106  +			return false;
          107  +			
          108  +		if ($this->member_from->member_id == $this->member_to->member_id)
          109  +			return false;		// don't allow trade to self
          110  +		
          111  +		$balances = new cBalancesTotal;
          112  +	
          113  +		// TODO: At some point, we should handle out-of-balance problems without shutting 
          114  +		// down all trades.  But for now, seems like a wonderfully simple solution.		
          115  +		if(!$balances->Balanced()) {
          116  +			$cErr->Error("La base de datos de intercambios tiene descompensada el balance!  Contacta con el administrador del sistema en ". EMAIL_ADMIN .".", ERROR_SEVERITY_HIGH);  
          117  +
          118  +			include("redirect.php");
          119  +			exit;  // Probably unnecessary...
          120  +		}	
          121  +
          122  +		// NOTE: Need table type InnoDB to do the following transaction-style statements.		
          123  +		$cDB->Query("SET AUTOCOMMIT=0");
          124  +		
          125  +		$cDB->Query("BEGIN");
          126  +		
          127  +		if($this->SaveTrade()) {
          128  +			$success1 = $this->member_from->UpdateBalance(-($this->amount));
          129  +			$success2 = $this->member_to->UpdateBalance($this->amount);
          130  +			
          131  +			if(LOG_LEVEL > 0 and $this->type != TRADE_ENTRY) {//Log if enabled & not an ordinary trade
          132  +				$log_entry = new cLogEntry (TRADE, $this->type, $this->trade_id);
          133  +				$success3 = $log_entry->SaveLogEntry();
          134  +			} else {
          135  +				$success3 = true;
          136  +			}
          137  +			
          138  +			if($reversed_trade_id) {  // If this is a trade reversal, need to mark old trade reversed
          139  +				$success4 = $cDB->Query("UPDATE ".DATABASE_TRADES." SET status='R', trade_date=trade_date WHERE trade_id=". $reversed_trade_id .";");
          140  +			} else {
          141  +				$success4 = true;
          142  +			}
          143  +
          144  +			if($success1 and $success2 and $success3 and $success4) {
          145  +				$cDB->Query('COMMIT');
          146  +				$cDB->Query("SET AUTOCOMMIT=1"); // Probably isn't necessary...
          147  +                
          148  +                $this->member_from->Limites();
          149  +                $this->member_to->Limites();   
          150  +				return true;
          151  +			} else {
          152  +				$cDB->Query('ROLLBACK');
          153  +				$cDB->Query("SET AUTOCOMMIT=1"); // Probably isn't necessary...
          154  +				return false;
          155  +			}
          156  +		} else {
          157  +			$cDB->Query("SET AUTOCOMMIT=1"); // Probably isn't necessary...
          158  +			return false;
          159  +		}			
          160  +	}
          161  +	
          162  +	function ReverseTrade($description) { 	// This method allows administrators to reverse
          163  +		global $cUser;								// trades that were made in error.
          164  +		
          165  +		if($this->status == "R")
          166  +			return false;		// Can't reverse the same trade twice
          167  +			
          168  +		$new_trade = new cTrade;
          169  +        $trade_date = new cDateTime($this->trade_date);    				
          170  +		$new_trade->status = "V";
          171  +		$new_trade->member_from = $this->member_from;
          172  +		$new_trade->member_to = $this->member_to;
          173  +		$new_trade->amount = -$this->amount;
          174  +		$new_trade->category = $this->category;
          175  +		$new_trade->description = "[Deshecho el intercambio nº". $this->trade_id." de ". $trade_date->ShortDate()." por el/la administrador/a] ". $description;           //'". $cUser->member_id ."'    
          176  +		$new_trade->type = "R";
          177  +		return $new_trade->MakeTrade($this->trade_id);
          178  +	}
          179  +}
          180  +
          181  +class cTradeGroup {
          182  +	var $trade;   	// an array of cTrade objects
          183  +	var $member_id;
          184  +	var $from_date;
          185  +	var $to_date;
          186  +	
          187  +	function cTradeGroup($member_id="%", $from_date=LONG_LONG_AGO, $to_date=FAR_FAR_AWAY) {
          188  +		$this->member_id = $member_id;
          189  +		$this->from_date = $from_date;
          190  +		$this->to_date = $to_date;
          191  +	}
          192  +	
          193  +	function LoadTradeGroup() {
          194  +		global $cDB, $cErr;
          195  +		
          196  +		$to_date = strtotime("+1 days", strtotime($this->to_date));
          197  +		
          198  +		//select all trade_ids for this member
          199  +		$query = $cDB->Query("SELECT trade_id FROM ".DATABASE_TRADES." WHERE (member_id_from LIKE '".$this->member_id."' OR member_id_to LIKE '". $this->member_id ."') AND trade_date > '". $this->from_date ."' AND trade_date < '". date("Ymd", $to_date) ."' ORDER BY trade_date DESC;");
          200  +
          201  +		// instantiate new cTrade objects and load them
          202  +		$i=0;
          203  +		while($row = mysql_fetch_array($query))
          204  +		{
          205  +			$this->trade[$i] = new cTrade;			
          206  +			$this->trade[$i]->LoadTrade($row[0]);
          207  +			$i += 1;
          208  +		}
          209  +		
          210  +		if($i == 0)
          211  +			return false;
          212  +		else
          213  +			return true;
          214  +	}
          215  +	
          216  +	function DisplayTradeGroup() {
          217  +		global $cDB, $cUser;
          218  +		
          219  +		$output = "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH=\"100%\"><TR BGCOLOR=\"#d8dbea\"><TD><FONT SIZE=2><B>Fecha</B></FONT></TD><TD><FONT SIZE=2><B>De</B></FONT></TD><TD><FONT SIZE=2><B>A</B></FONT></TD><TD ALIGN=RIGHT><FONT SIZE=2><B>". UNITS ."&nbsp;</B></FONT></TD><TD><FONT SIZE=2><B>&nbsp;Descripción</B></FONT></TD></TR>";
          220  +		
          221  +		if(!$this->trade)
          222  +			return $output. "</TABLE>";   // No trades yet, presumably
          223  +		
          224  +		$i=0;
          225  +		foreach($this->trade as $trade) {
          226  +			if($trade->type == TRADE_REVERSAL or $trade->status == TRADE_REVERSAL)
          227  +				$fcolor = "pink";
          228  +			elseif ($trade->member_to->member_id == $this->member_id)
          229  +				$fcolor = "#4a5fa4";
          230  +			else
          231  +				$fcolor = "#554f4f";
          232  +				
          233  +			if($i % 2)
          234  +				$bgcolor = "#e4e9ea";
          235  +			else
          236  +				$bgcolor = "#FFFFFF";
          237  +			
          238  +			$trade_date = new cDateTime($trade->trade_date);			
          239  +			
          240  +			$output .= "<TR VALIGN=TOP BGCOLOR=". $bgcolor ."><TD><FONT SIZE=2 COLOR=".$fcolor.">". $trade_date->ShortDate()."</FONT></TD><TD><FONT SIZE=2 COLOR=".$fcolor.">". $trade->member_from->member_id ."</FONT></TD><TD><FONT SIZE=2 COLOR=".$fcolor.">". $trade->member_to->member_id ."</FONT></TD><TD ALIGN=RIGHT><FONT SIZE=2 COLOR=".$fcolor.">". $trade->amount ."&nbsp;</FONT></TD><TD><FONT SIZE=2 COLOR=".$fcolor.">". $cDB->UnEscTxt($trade->description) ."</FONT></TD></TR>";
          241  +			$i+=1;
          242  +		}
          243  +		
          244  +		return $output . "</TABLE>";
          245  +	}
          246  +	
          247  +	function MakeTradeArray() {
          248  +		$trades = "";
          249  +		if($this->trade) {
          250  +			foreach($this->trade as $trade) {
          251  +				if($trade->type != "R" and $trade->status != "R") {
          252  +                    $trade_date = new cDateTime($trade->trade_date);
          253  +					$trades[$trade->trade_id] = "Nº ". $trade->trade_id ." : ". $trade->amount ." ". UNITS . " de ". $trade->member_from->member_id ." a ". $trade->member_to->member_id .", el ". $trade_date->ShortDate();
          254  +				}
          255  +			}
          256  +		}
          257  +		
          258  +		return $trades;
          259  +	}
          260  +}
          261  +
          262  +class cTradeStats extends cTradeGroup {
          263  +	var $total_trades = 0;
          264  +	var $total_units = 0;
          265  +	var $most_recent = ""; // Will be an object of class cDateTime
          266  +	
          267  +	function cTradeStats ($member_id="%", $from_date=LONG_LONG_AGO, $to_date=FAR_FAR_AWAY) {
          268  +		$this->cTradeGroup($member_id, $from_date, $to_date);
          269  +		if(!$this->LoadTradeGroup())
          270  +			return;
          271  +		
          272  +		foreach($this->trade as $trade) {
          273  +			if ($trade->type == TRADE_REVERSAL or $trade->status == TRADE_REVERSAL)
          274  +				continue; // skip reversed trades
          275  +				
          276  +			$this->total_trades += 1;
          277  +			$this->total_units += $trade->amount;
          278  +			
          279  +			if($this->most_recent == "") {
          280  +				$this->most_recent = new cDateTime($trade->trade_date);
          281  +			} elseif ($this->most_recent->MySQLDate() < $trade->trade_date) {
          282  +				$this->most_recent->Set($trade->trade_date);
          283  +			}	
          284  +		}
          285  +	}
          286  +
          287  +}
          288  +
          289  +?>

Added bdt/classes/class.uploads.php

            1  +<?
            2  +
            3  +class cUpload {
            4  +    var $upload_id;
            5  +    var $upload_date;
            6  +    var $type; // for example "N" for "newsletters"
            7  +    var $title;
            8  +    var $filename;
            9  +    var $note;
           10  +
           11  +    function cUpload ($type=null, $title=null, $note=null, $filename=null) {
           12  +        global $cUser;
           13  +    
           14  +        if($type) {
           15  +            $this->type = $type;
           16  +            $this->title = $title;
           17  +            $this->note = $note;
           18  +        }
           19  +    }
           20  +    
           21  +    function SaveUpload() {
           22  +        // Copy file uploaded by UploadForm class to uploads directory and
           23  +        // save entry for it in the database
           24  +        global $cDB, $cErr;
           25  +        
           26  +        if($this->filename == null)
           27  +            $this->filename = $_FILES['userfile']['name'];
           28  +            
           29  +        $query = $cDB->Query("SELECT null from ". DATABASE_UPLOADS ." WHERE filename ='".$_FILES['userfile']['name']."';");
           30  +        
           31  +        if($row = mysql_fetch_array($query)) {
           32  +            $cErr->Error("Ya existe un documento con ese nombre en el sistema");
           33  +            return false;
           34  +        }        
           35  +            
           36  +        if(move_uploaded_file($_FILES['userfile']['tmp_name'], UPLOADS_PATH . $this->filename)) {
           37  +            $insert = $cDB->Query("INSERT INTO ". DATABASE_UPLOADS ." (type, title, filename, note) VALUES ('".$this->type ."', '". $this->title ."', '". $this->filename ."', ". $cDB->EscTxt($this->note) .");");
           38  +                        
           39  +            if(mysql_affected_rows() == 1) {
           40  +                $this->upload_id = mysql_insert_id();    
           41  +                $query = $cDB->Query("SELECT upload_date FROM ".DATABASE_UPLOADS." WHERE  upload_id=". $this->upload_id.";");
           42  +                if($row = mysql_fetch_array($query))
           43  +                    $this->upload_date = $row[0];                    
           44  +                return true;
           45  +            } else {
           46  +                $cErr->Error("No se ha podido insertar el elemento en la base de datos para el documento subido.");
           47  +                return false;
           48  +            }                
           49  +        } else {
           50  +            $cErr->Error("No se ha podido subir el elemento. Puede deberse a un problema de permisos. ¿Tiene el usuario permiso de escritura para el directorio de subidas?  Puede que el documento sea demasiado grande.  El tamaño de fichero máximo permitido es de ".MAX_FILE_UPLOAD." bytes.");
           51  +            return false;
           52  +        }
           53  +    }
           54  +    
           55  +    function LoadUpload ($upload_id) {
           56  +        global $cDB, $cErr;
           57  +                
           58  +        $query = $cDB->Query("SELECT upload_date, type, title, filename, note FROM ".DATABASE_UPLOADS." WHERE upload_id=". $upload_id.";");
           59  +        
           60  +        if($row = mysql_fetch_array($query)) {        
           61  +            $this->upload_id = $upload_id;
           62  +            $this->upload_date = new cDateTime($row[0]);
           63  +            $this->type = $row[1];        
           64  +            $this->title = $row[2];
           65  +            $this->filename = $row[3];
           66  +            $this->note = $cDB->UnEscTxt($row[4]);
           67  +            return true;
           68  +        } else {
           69  +            $cErr->Error("Ha ocurrido un error al acceder a la tabla de subidas.  Por favor, inténtelo más tarde.");
           70  +            include("redirect.php");
           71  +        }
           72  +        
           73  +    }
           74  +
           75  +    function DeleteUpload () {
           76  +        global $cDB, $cErr;
           77  +        
           78  +        if(unlink(UPLOADS_PATH . $this->filename)) {
           79  +            $delete = $cDB->Query("DELETE FROM ". DATABASE_UPLOADS ." WHERE upload_id = ". $this->upload_id .";");
           80  +            if(mysql_affected_rows() == 1) {
           81  +                return true;
           82  +            } else {
           83  +                $cErr->Error("El documento se ha elminado pero no se ha podido borrar la entrada de la base de datos.  La fila deberá borrarse manualmente.  Por favor, contacta con el administrador del sistema.");
           84  +                include("redirect.php");
           85  +            }            
           86  +        } else {
           87  +            $cErr->Error("No se pudo eliminar el documento - ". $this->filename .".  Por favor, inténtelo más tarde.");
           88  +            include("redirect.php");
           89  +        }
           90  +    }
           91  +
           92  +    function DisplayURL ($text=null) {
           93  +        if($text == null)
           94  +            $text = $this->title;
           95  +            
           96  +        return '<A HREF="uploads/'. $this->filename .'">'. $text .'</A>';
           97  +    }
           98  +}
           99  +
          100  +class cUploadGroup {
          101  +    var $uploads; // will be object of class cUpload
          102  +    var $type;
          103  +    
          104  +    function cUploadGroup($type) {
          105  +        $this->type = $type;
          106  +    }
          107  +    
          108  +    function LoadUploadGroup () {
          109  +        global $cDB, $cErr;
          110  +    
          111  +        $query = $cDB->Query("SELECT upload_id FROM ".DATABASE_UPLOADS." WHERE type='".$this->type."' ORDER BY upload_date DESC;");
          112  +        
          113  +        $i = 0;                
          114  +        while($row = mysql_fetch_array($query)) {
          115  +            $this->uploads[$i] = new cUpload;            
          116  +            $this->uploads[$i]->LoadUpload($row[0]);
          117  +            $i += 1;
          118  +        }
          119  +
          120  +        if($i == 0)
          121  +            return false;
          122  +        else
          123  +            return true;
          124  +    }
          125  +    
          126  +
          127  +}
          128  +
          129  +class cUploadForm {
          130  +
          131  +    function DisplayUploadForm($action, $text_fields=null) {
          132  +    
          133  +    $output = '<form enctype="multipart/form-data" action="'. $action.'" method="POST">';
          134  +    foreach($text_fields as $field)
          135  +        $output .= $field .' <input type="text" name="'. $field .'"><BR>';
          136  +        
          137  +    $output .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.MAX_FILE_UPLOAD.'">Elige el archivo a subir <input name="userfile" type="file"><input type="submit" value="Subir"></form>';
          138  +    return $output;
          139  +    }
          140  +
          141  +}
          142  +
          143  +?>

Added bdt/contact.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = SECTION_EMAIL;
            4  +$p->page_title = "Contactar";
            5  +
            6  +include("includes/inc.forms.php");
            7  +require_once "Mail.php";  
            8  +require_once "Mail/mime.php"; 
            9  +
           10  +//
           11  +// First, we define the form
           12  +//
           13  +$form->addElement("static", null, "Para participar del Banco de Tiempo o pedir cualquier información, rellena el siguiente cuestionario, y contestaremos en breve. Los recuadros con asterisco son obligatorios", null);
           14  +$form->addElement("static", null, null, null);
           15  +$form->addElement("text", "name", "Nombre ");
           16  +$form->addElement("text", "email", "Email   ");
           17  +$form->addElement("text", "phone", "Teléfono ");
           18  +$form->addElement("static", null, null, null);
           19  +$form->addElement("textarea", "message", "Mensaje: ", array("cols"=>50, "rows"=>10, "wrap"=>"soft"));
           20  +$form->addElement("static", null, null, null);
           21  +$heard_from = array ("0"=>"(Seleccionar uno)", "1"=>"Buscando en internet", "2"=>"Por un amigo/a", "3"=>"Por Konekta", "4"=>"Otros");
           22  +$form->addElement("select", "how_heard", "¿Cómo nos has conocido?", $heard_from);
           23  +
           24  +$form->addElement("static", null, null, null);
           25  +$form->addElement("submit", "btnSubmit", "Enviar");
           26  +
           27  +//
           28  +// Define form rules
           29  +//
           30  +$form->addRule("name", "Introduce tu nombre", "required");
           31  +$form->addRule("email", "Introduce tu email", "required");
           32  +//$form->addRule("phone", "Enter your phone number", "required");
           33  +
           34  +$form->registerRule('verify_valid_email','function', 'verify_valid_email');
           35  +$form->addRule('email', 'Email no válido', 'verify_valid_email');
           36  +$form->registerRule('verify_phone_format','function','verify_phone_format');
           37  +$form->addRule('phone', 'El número de teléfono no es válido', 'verify_phone_format');
           38  +
           39  +
           40  +
           41  +
           42  +if ($form->validate()) { // Form is validated so processes the data
           43  +   $form->freeze();
           44  +     $form->process("process_data", false);
           45  +} else {  // Display the form
           46  +    $p->DisplayPage($form->toHtml());
           47  +}
           48  +
           49  +//
           50  +// The form has been submitted with valid data, so process it   
           51  +//
           52  +function process_data ($values) {
           53  +    global $p, $heard_from;
           54  +    
           55  +    $text = "De: ". $values["name"]. "\n". "Teléfono: ". $values["phone"] ."\n". "Conocido en: ". $heard_from[$values["how_heard"]] ."\n\n". wordwrap($values["message"], 64);
           56  +    $crlf = "\n"; 
           57  +    $to = EMAIL_ADMIN;
           58  +    $headers = array ('From' => $values["email"],
           59  +    'To' => $to,
           60  +    'Subject' => SITE_SHORT_TITLE ." Formulario de contacto");
           61  +    
           62  +    $mime = new Mail_mime($crlf);
           63  +    $mime->setTXTBody($text);
           64  +    $body = $mime->get();
           65  +    $headers = $mime->headers($headers);
           66  +    
           67  +    $smtp = Mail::factory('mail');
           68  +    $mailed = $smtp->send($to, $headers, $body);
           69  +
           70  +    if (PEAR::isError($mailed)) {
           71  +        $output = "Ha habido un problema enviando tu email. Pulsa 'Atrás' en tu navegador y comprueba que has escrito la dirección de email correctamente.";                                                         
           72  +    } else {
           73  +        $output = "Gracias, se ha enviado tu correo."; 
           74  +    } 
           75  +    $p->DisplayPage($output); 
           76  +    
           77  +    
           78  +}
           79  +function verify_valid_email ($element_name,$element_value) {
           80  +    if ($element_value=="")
           81  +        return true;        // Currently not planning to require this field
           82  +    if (strstr($element_value,"@") and strstr($element_value,"."))
           83  +        return true;    
           84  +    else
           85  +        return false;
           86  +    
           87  +}
           88  +
           89  +function verify_phone_format ($element_name,$element_value) {
           90  +    $phone = new cPhone($element_value);
           91  +    
           92  +    if(substr($phone->area,0,1)== "9" or substr($phone->area,0,1)=="6") 
           93  +        return true;
           94  +    else
           95  +        return false;
           96  +}
           97  +    
           98  +           
           99  +
          100  +?>

Added bdt/contact_all.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = SECTION_EMAIL;
            4  +$p->page_title = "Email a todo el colectivo";
            5  +
            6  +$cUser->MustBeLevel(2);
            7  +
            8  +include("includes/inc.forms.php");
            9  +require_once "Mail.php"; 
           10  +require_once "Mail/mime.php";  
           11  +//
           12  +// First, we define the form
           13  +//
           14  +$form->addElement("static", null, "Este email se enviará a <i>TODAS</i> las personas usuarias de ".SITE_LONG_TITLE.". ESTE PROCESO PUEDE DEMORARSE VARIOS MINUTOS, POR LO QUE NO DEBES CANCELAR EL PROCESO HASTA QUE FINALICE.", null);
           15  +$form->addElement("static", null, null, null);
           16  +$form->addElement("text", "subject", "Encabezamiento", array("size" => 30, "maxlength" => 50));
           17  +$form->addElement("static", null, null, null);
           18  +$form->addElement("textarea", "message", "Tu mensaje", array("cols"=>65, "rows"=>10, "wrap"=>"soft"));
           19  +$form->addElement("static", null, null, null);
           20  +
           21  +$form->addElement("static", null, null, null);
           22  +$form->addElement("submit", "btnSubmit", "Enviar");
           23  +
           24  +//
           25  +// Define form rules
           26  +//
           27  +$form->addRule("subject", "Introduce un encabezamiento", "required");
           28  +$form->addRule("message", "Introduce tu mensaje", "required");
           29  +
           30  +if ($form->validate()) { // Form is validated so processes the data
           31  +   $form->freeze();
           32  + 	$form->process("process_data", false);
           33  +} else {  // Display the form
           34  +	$p->DisplayPage($form->toHtml());
           35  +}
           36  +
           37  +//
           38  +// The form has been submitted with valid data, so process it   
           39  +//
           40  +function process_data ($values) {
           41  +	global $p, $heard_from;
           42  +	
           43  +	$output = "";
           44  +	$errors = "";
           45  +	$all_members = new cMemberGroup;
           46  +	$all_members->LoadMemberGroup();
           47  +    set_time_limit(0);	
           48  +    ignore_user_abort();
           49  +	foreach($all_members->members as $member) {
           50  +		if($errors != "")
           51  +			$errors .= ", ";
           52  +		
           53  +		if($member->person[0]->email != "")
           54  +        {
           55  +	    $text = wordwrap($values["message"], 64);
           56  +        $html = iconv('utf-8', 'windows-1252', ROTULO_MAIL.nl2br($text).AVISO_LEGAL);   
           57  +        $crlf = "\n";
           58  +        $to = $member->person[0]->email;
           59  +        $headers = array ('From' => EMAIL_ADMIN,
           60  +        'To' => $to,
           61  +        'Subject' => $values["subject"]);
           62  +        $mime = new Mail_mime($crlf);
           63  +        $mime->setTXTBody($text);
           64  +        $mime->setHTMLBody($html);  
           65  +        $body = $mime->get();
           66  +        $headers = $mime->headers($headers);
           67  +    
           68  +        $smtp = Mail::factory('mail');
           69  +        $mailed = $smtp->send($to, $headers, $body);
           70  +        }
           71  +		else
           72  +		$mailed = true;
           73  +		
           74  +		if (PEAR::isError($mailed))
           75  +			$errors .= $member->person[0]->email;
           76  +    }    
           77  +	    if($errors == "")
           78  +		    $output .= "El mensaje ha sido enviado a todos los usuarios.";
           79  +	    else
           80  +		    $output .= "Ha habido un error enviando el mensaje a estas direcciones:<BR>". $errors;	
           81  +		
           82  +	    $p->DisplayPage($output);
           83  +}
           84  +   
           85  +
           86  +?>

Added bdt/directory.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +
            4  +$cUser->MustBeLoggedOn();
            5  +$p->site_section = LISTINGS;
            6  +$p->page_title = "Descargar un directorio en formato pdf";
            7  +
            8  +include("classes/class.directory.php");
            9  +include("includes/inc.forms.php");
           10  +
           11  +$form->addElement("static", null, "Aprieta en el botón 'Descargar' y te llegará una versión en formato pdf del directorio. ", null);
           12  +$form->addElement("static", null, null, null);
           13  +$form->addElement("static", null, "Necesitarás un programa que lea documentos en formato pdf, en Linux probablemente tengas varias opciones, y para Windows probablemente necesites <a href='http://www.adobe.com/products/acrobat/readstep2_servefile.html'>Adobe</a>.", null);
           14  +$form->addElement("static", null, null, null);  
           15  +$form->addElement("submit", "btnSubmit", "Descargar");
           16  +
           17  +if ($form->validate()) { // Form is validated so processes the data
           18  +   $form->freeze();
           19  + 	$form->process("process_data", false);
           20  +} else {  // Display the form
           21  +	$p->DisplayPage($form->toHtml());
           22  +}
           23  +
           24  +function process_data ($values) {
           25  +	global $p;
           26  +
           27  +	$dir = new cDirectory();
           28  +	$dir->DownloadDirectory();
           29  +
           30  +	$list = "Descarga completa.";
           31  +	$p->DisplayPage($list);
           32  +}
           33  +?>
           34  +
           35  +

Added bdt/discussion.php

            1  +<?
            2  +echo "No hay aún ningún foro de discusión para esta página";
            3  +// header("location:http://www.4thcornerexchange.com/phpBB2/");
            4  +exit;	
            5  +
            6  +?>

Added bdt/email.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = SECTION_EMAIL;
            4  +$p->page_title = "Enviar un email a algún usuario o usuaria";
            5  +
            6  +$cUser->MustBeLoggedOn();
            7  +
            8  +include("includes/inc.forms.php");
            9  +require_once "Mail.php"; 
           10  +require_once "Mail/mime.php";
           11  +//
           12  +// First, we define the form
           13  +//
           14  +
           15  +$form->addElement("hidden", "email_to", $_REQUEST["email_to"]);
           16  +$form->addElement("hidden", "member_to", $_REQUEST["member_to"]);
           17  +$member_to = new cMember;
           18  +$member_to->LoadMember($_REQUEST["member_to"]);
           19  +$form->addElement("static", null, "Para: <I>". $_REQUEST["email_to"] . " (". $member_to->member_id .")</I>");
           20  +$form->addElement("text", "subject", "Encabezamiento: ", array('size' => 35, 'maxlength' => 100));
           21  +$form->addElement("select", "cc", "¿Quieres recibir una copia?", array("Y"=>"Si", "N"=>"No"));
           22  +
           23  +/*  The following code should work, and works on my server, but not on Open Access.  Bug?
           24  +$cc[] =& HTML_QuickForm::createElement('radio',null,null,'<FONT SIZE=2>Yes</FONT>','Y');
           25  +$cc[] =& HTML_QuickForm::createElement('radio',null,null,'<FONT SIZE=2>No</FONT>','N');
           26  +$form->addGroup($cc, "cc", 'Would you like to recieve a copy?');
           27  +*/
           28  +
           29  +$form->addElement("static", null, null, null);
           30  +$form->addElement("textarea", "message", "Tu mensaje:", array("cols"=>65, "rows"=>10, "wrap"=>"soft"));
           31  +
           32  +$form->addElement("static", null, null, null);
           33  +$form->addElement("submit", "btnSubmit", "Enviar");
           34  +
           35  +//
           36  +// Define form rules
           37  +//
           38  +$form->addRule("message", "Introduce tu mensaje", "required");
           39  +
           40  +if ($form->validate()) { // Form is validated so processes the data
           41  +   $form->freeze();
           42  + 	$form->process("process_data", false);
           43  +} else {  // Display the form
           44  +	$form->setDefaults(array("cc"=>"Y"));
           45  +	$p->DisplayPage($form->toHtml());
           46  +}
           47  +
           48  +//
           49  +// The form has been submitted with valid data, so process it   
           50  +//
           51  +function process_data ($values) {
           52  +	global $p, $cUser;
           53  +	
           54  +	if($values["cc"] == "Y")
           55  +		$copy = $cUser->person[0]->email;
           56  +	else 
           57  +		$copy = "";
           58  +		
           59  +    $text = wordwrap($values["message"], 64);
           60  +    $html = iconv('utf-8', 'windows-1252', ROTULO_MAIL.nl2br($text).AVISO_LEGAL); 
           61  +    $crlf = "\n";
           62  +    $to = $_REQUEST["email_to"];
           63  +    $cc = $copy;
           64  +    $headers = array ('From' => $cUser->person[0]->email,
           65  +    'To' => $to,
           66  +    'CC' => $cc,
           67  +    'Subject' => SITE_SHORT_TITLE .": ". $values["subject"]);
           68  +    
           69  +    $mime = new Mail_mime($crlf);
           70  +    $mime->setTXTBody($text);
           71  +    $mime->setHTMLBody($html); 
           72  +    $body = $mime->get();
           73  +    $headers = $mime->headers($headers);
           74  +    
           75  +    $smtp = Mail::factory('mail');
           76  +    $mailed = $smtp->send(array($to,$cc), $headers, $body);
           77  +
           78  +    if (PEAR::isError($mailed)) 
           79  +     $output = "Ha habido un problema enviando el mensaje. Prueba más tarde.";                                                                                       
           80  +     else 
           81  +        $output = "Tu mensaje se ha enviado."; 		
           82  +	$p->DisplayPage($output);
           83  +}
           84  +
           85  +
           86  +
           87  +?>

Added bdt/exchange_menu.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = EXCHANGES;
            4  +$p->page_title = "Intercambio";
            5  +
            6  +$cUser->MustBeLoggedOn();
            7  +
            8  + 
            9  +$list = "<A HREF=trade.php?mode=self><FONT SIZE=4><B>Transferir horas</b></FONT></A><p>";
           10  +$list .= "<STRONG>Historia de intercambios</STRONG><P>";  
           11  +$list .= "<A HREF=trade_history.php?mode=self><FONT SIZE=2>Ver mis horas y mi historia de intercambios</FONT></A><BR>";
           12  +$list .= "<A HREF=trades_to_view.php><FONT SIZE=2>Ver la historia de intercambios de otra persona y sus horas</FONT></A><br>";
           13  +$list .= "<A HREF=timeframe_choose.php?action=trade_history_all><FONT SIZE=2>Ver todos los intercambios de un período determinado</FONT></A><p>";
           14  +$list .= "<STRONG>Valoración de los servicios prestados</STRONG><P>";
           15  +$list .= "<A HREF=feedback_choose.php?mode=self><FONT SIZE=2>Ver o cambiar la valoración de un intercambio reciente</FONT></A><BR>"; 
           16  +$list .= "<A HREF=feedback_all.php?mode=self><FONT SIZE=2>Ver mi valoración</FONT></A><BR>";
           17  +$list .= "<A HREF=feedback_to_view.php><FONT SIZE=2>Ver la valoración de otra persona</FONT></A><BR>";
           18  +
           19  +
           20  +
           21  +$p->DisplayPage($list);
           22  +
           23  +?>

Added bdt/export.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +
            4  +$cUser->MustBeLevel(2);
            5  +$p->site_section = ADMINISTRATION;
            6  +$p->page_title = "Exportar a hoja de cálculo";
            7  +
            8  +include("classes/class.backup.php");
            9  +include("includes/inc.forms.php");
           10  +
           11  +$form->addElement("static", 'contact', "Esto exportará todas las tablas de la base de datos en una hoja de cálculo Excel para copias de seguridad y otros usos. Aprieta en el botón 'Descargar' y te llegará el archivo. Recuerda que esta información es confidencial, y debes guardarle en un lugar privado y seguro.", null);
           12  +$form->addElement("static", null, null, null);
           13  +$form->addElement("submit", "btnSubmit", "Descargar");
           14  +
           15  +if ($form->validate()) { // Form is validated so processes the data
           16  +   $form->freeze();
           17  + 	$form->process("process_data", false);
           18  +} else {  // Display the form
           19  +	$p->DisplayPage($form->toHtml());
           20  +}
           21  +
           22  +function process_data ($values) {
           23  +	global $p;
           24  +
           25  +	$backup = new cBackup();
           26  +	$backup->BackupAll();
           27  +
           28  +	$list = "Envío completado.";
           29  +	$p->DisplayPage($list);
           30  +}
           31  +?>

Added bdt/feedback.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$member_about = new cMember;
            6  +$member_about->LoadMember($_REQUEST["about"]);
            7  +
            8  +$p->site_section = SECTION_FEEDBACK;
            9  +$p->page_title = "Introducir valoración para ". $member_about->PrimaryName();
           10  +
           11  +include("classes/class.feedback.php");
           12  +include("includes/inc.forms.validation.php");
           13  +
           14  +//
           15  +// Define form elements
           16  +//
           17  +$member = new cMember;
           18  +
           19  +if($_REQUEST["mode"] == "admin") {
           20  +	$cUser->MustBeLevel(2);
           21  +	$member->LoadMember($_REQUEST["author"]);
           22  +	$p->page_title .= " para ". $member->PrimaryName();
           23  +} else {
           24  +	$cUser->MustBeLoggedOn();
           25  +	$member = $cUser;
           26  +}
           27  +
           28  +$form->addElement('static', null, 'Todas las valoraciones son públicas. Antes de otorgar una valoración <i>negativa</i> , recomendamos dialogar directamente con la otra persona. A menudo los desacuerdos pueden arreglarse de esta manera para beneficio de ambas partes.', null);
           29  +$form->addElement('static', null, null, null);
           30  +$ratings = array(0=>"", POSITIVE=>"Positiva", NEUTRAL=>"Neutral", NEGATIVE=>"Negativa"); 
           31  +$form->addElement("select", "rating", "Valoración ", $ratings);
           32  +$form->addElement("hidden", "about", $member_about->member_id);
           33  +$form->addElement("hidden", "author", $_REQUEST["author"]);
           34  +$form->addElement("hidden", "mode", $_REQUEST["mode"]);
           35  +$form->addElement("hidden", "trade_id", $_REQUEST["trade_id"]);
           36  +$form->addElement('static', null, 'Comentarios', null);
           37  +$form->addElement('textarea', 'comments', null, array('cols'=>60, 'rows'=>4, 'wrap'=>'soft'));
           38  +$form->addElement('submit', 'btnSubmit', 'Enviar');
           39  +
           40  +//
           41  +// Define form rules
           42  +//
           43  +$form->registerRule('verify_selection','function','verify_selection');
           44  +$form->addRule('rating', 'Escoge una puntuación', 'verify_selection');
           45  +
           46  +//
           47  +// Then check if we are processing a submission or just displaying the form
           48  +//
           49  +if ($form->validate()) { // Form is validated so processes the data
           50  +   $form->freeze();
           51  + 	$form->process("process_data", false);
           52  +} else {
           53  +   $p->DisplayPage($form->toHtml());  // just display the form
           54  +}
           55  +
           56  +function process_data ($values) {
           57  +	global $p, $member_about, $member, $cErr;
           58  +	
           59  +	$trade = new cTrade();
           60  +	$trade->LoadTrade($_REQUEST["trade_id"]);
           61  +	
           62  +	// Decide whether member leaving feedback was buyer or seller & make sure trade members correct
           63  +	if ($trade->member_from->member_id == $member->member_id and $trade->member_to->member_id == $member_about->member_id) {
           64  +		$context = BUYER;
           65  +	} elseif ($trade->member_to->member_id == $member->member_id and $trade->member_from->member_id == $member_about->member_id) {
           66  +		$context = SELLER;
           67  +	} else {
           68  +		$cErr->Error("Esos miembros no se corresponden con el intercambio realizado."); // Theoretically, must be a hacker
           69  +		include("redirect.php");
           70  +	}
           71  +	
           72  +	$feedback = new cFeedback($member->member_id, $member_about->member_id, $context, $trade->category->id, $_REQUEST["trade_id"], $values["rating"], $values["comments"]);
           73  +	$success = $feedback->SaveFeedback();
           74  +	
           75  +	if($success) {
           76  +		if(LOG_LEVEL > 0 and $_REQUEST["mode"] == "admin") { // Log if enabled & entered by an admin
           77  +			$log_entry = new cLogEntry (FEEDBACK, FEEDBACK_BY_ADMIN, $feedback->feedback_id);
           78  +			$log_entry->SaveLogEntry();	
           79  +		}
           80  +		$output = "Tu valoración ha sido guardada.";
           81  +	} else {
           82  +		$output = "Ha habido un error guardando tu valoración. Por favor, inténtalo más tarde.";
           83  +	}
           84  +	
           85  +	$p->DisplayPage($output);
           86  +}
           87  +
           88  +?>

Added bdt/feedback_all.php

            1  +<?php
            2  +
            3  +include_once("includes/inc.global.php");
            4  +	
            5  +include("classes/class.feedback.php");
            6  +	
            7  +$cUser->MustBeLoggedOn();
            8  +	
            9  +if($_REQUEST["mode"] == "other") 
           10  +	$member_id = $_REQUEST["member_id"];
           11  +else
           12  +	$member_id = $cUser->member_id;
           13  +	
           14  +$p->site_section = SECTION_FEEDBACK;
           15  +$member = new cMember;
           16  +$member->LoadMember($member_id);
           17  +$p->page_title = "Valoración de ". $member->PrimaryName();
           18  +
           19  +$feedbackgrp = new cFeedbackGroup;
           20  +$feedbackgrp->LoadFeedbackGroup($member_id);
           21  +
           22  +if (isset($feedbackgrp->feedback)) {
           23  +    $output = "<p> A continuación se detallan cómo han valorado a este usuario otros miembros del Banco. La primera columna indica si el voto ha sido positivo, negativo o neutral; y 'De' indica quién lo ha emitido. El 'contexto' indica si ". $member->PrimaryName()." actuó como comprador (demandante de servicios) o como vendedor (proveedor de servicios) y la categoría del servicio.</p>"; 
           24  +	$output .= $feedbackgrp->DisplayFeedbackTable($cUser->member_id);
           25  +} else  {
           26  +	if($_REQUEST["mode"] == "self")
           27  +		$output = "Todavía no tienes ninguna valoración.";
           28  +	else
           29  +		$output = "Esta persona no tiene ninguna valoración todavía.";
           30  +}
           31  +
           32  +$p->DisplayPage($output);
           33  +	
           34  +?>	

Added bdt/feedback_choose.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$p->site_section = SECTION_FEEDBACK;
            6  +$p->page_title = "Introducir valoración";
            7  +
            8  +include("classes/class.feedback.php");
            9  +
           10  +$member = new cMember;
           11  +
           12  +if($_REQUEST["mode"] == "admin") {
           13  +	$cUser->MustBeLevel(2);
           14  +	$member->LoadMember($_REQUEST["member_id"]);
           15  +} else {
           16  +	$cUser->MustBeLoggedOn();
           17  +	$member = $cUser;
           18  +}
           19  +
           20  +$since_date = new cDateTime("-". DAYS_REQUEST_FEEDBACK ." days");
           21  +$tradegrp = new cTradeGroup($member->member_id, $since_date->MySQLDate()); 
           22  +$tradegrp->LoadTradeGroup();
           23  +
           24  +$output = "<B>¿Para qué intercambio?</B><BR>";
           25  +$output .= "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH=\"100%\">";
           26  +
           27  +$i=0;
           28  +if(isset($tradegrp->trade)) {
           29  +	foreach($tradegrp->trade as $trade) {	
           30  +		if($trade->type == TRADE_REVERSAL or $trade->status == TRADE_REVERSAL)
           31  +			continue;	// No reason to list reversed trades, so let's skip 'em
           32  +	
           33  +		if($i % 2)
           34  +			$bgcolor = "#EEEEEE";
           35  +		else
           36  +			$bgcolor = "#FFFFFF";
           37  +			
           38  +		// Was member the buyer or seller?
           39  +		if ($trade->member_from->member_id == $member->member_id) {
           40  +			$member_id_other = $trade->member_to->member_id;
           41  +			$feedback_member =& $trade->feedback_buyer;
           42  +		} else {
           43  +			$member_id_other = $trade->member_from->member_id;
           44  +			$feedback_member =& $trade->feedback_seller;
           45  +		}
           46  +		
           47  +		if(!$feedback_member) {	// Member hasn't left feedback yet, show link
           48  +			$date = new cDateTime($trade->trade_date);	
           49  +			$trade_date = $date->ShortDate();
           50  +					
           51  +			$output .= "<TR VALIGN=TOP BGCOLOR=". $bgcolor ."><TD><FONT SIZE=2><A HREF=feedback.php?author=". $member->member_id ."&about=". $member_id_other ."&trade_id=". $trade->trade_id ."&mode=".$_REQUEST["mode"] .">". $trade_date ."</A></FONT></TD><TD><FONT SIZE=2>". $member_id_other ."</FONT></TD><TD><FONT SIZE=2>". $trade->category->description ."</FONT></TD><TD ALIGN=RIGHT><FONT SIZE=2>". $trade->amount ."&nbsp;</FONT></TD><TD><FONT SIZE=2>". $cDB->UnEscTxt($trade->description) ."</FONT></TD></TR>";	
           52  +			$i+=1;
           53  +		} 	
           54  +	}
           55  +}
           56  +
           57  +$output .= "</TABLE>";
           58  +
           59  +if($i == 0)
           60  +	$output .= "No hay intercambios a los que puntuar.  Ya has puntuado tus intercambios recientes.";
           61  +
           62  +$p->DisplayPage($output);
           63  +
           64  +?>

Added bdt/feedback_choose_inbox.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$p->site_section = FEEDBACK;
            6  +$p->page_title = "Introducir valoración";
            7  +
            8  +include("classes/class.feedback.php");
            9  +
           10  +$member = new cMember;
           11  +
           12  +if($_REQUEST["mode"] == "admin") {
           13  +	$cUser->MustBeLevel(2);
           14  +	$member->LoadMember($_REQUEST["member_id"]);
           15  +} else {
           16  +	$cUser->MustBeLoggedOn();
           17  +	$member = $cUser;
           18  +}
           19  +
           20  +$since_date = new cDateTime("-". DAYS_REQUEST_FEEDBACK ." days");
           21  +$tradegrp = new cTradeGroup($member->member_id, $since_date->MySQLDate()); 
           22  +$tradegrp->LoadTradeGroup();
           23  +
           24  +$output = "<B>¿Para qué intercambio?</B><BR>";
           25  +$output .= "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH=\"100%\">";
           26  +
           27  +$i=0;
           28  +
           29  +foreach($tradegrp->trade as $trade) {	
           30  +	if($trade->type == TRADE_REVERSAL or $trade->status == TRADE_REVERSAL)
           31  +		continue;	// No reason to list reversed trades, so let's skip 'em
           32  +
           33  +	if($i % 2)
           34  +		$bgcolor = "#EEEEEE";
           35  +	else
           36  +		$bgcolor = "#FFFFFF";
           37  +	
           38  +	// Ok this page is ugly, my sincere apologies...
           39  +	//
           40  +	// What we want here is to provide a sort of inbox for feedback.
           41  +	//
           42  +	// If the person hasn't left feedback, we want to give them the opportunity.
           43  +	// If they have, then we would still want to provide a link under certain circumstances:
           44  +	//	1) The other member left negative or nuetral feedback.
           45  +	// 2) They left negative/neutral feeback and the other member has responded.
           46  +	//
           47  +	// In both cases, the most recent posting should be shown.
           48  +			
           49  +			
           50  +	// Was this member the buyer or seller?
           51  +	if ($trade->member_from->member_id == $member->member_id) {
           52  +		$member_id_other = $trade->member_to->member_id;
           53  +		$feedback_member =& $trade->feedback_buyer;
           54  +		$feedback_other =& $trade->feedback_seller;
           55  +	} else {
           56  +		$member_id_other = $trade->member_from->member_id;
           57  +		$feedback_other =& $trade->feedback_buyer;
           58  +		$feedback_member =& $trade->feedback_seller;
           59  +	}
           60  +		
           61  +	$context = $feedback_member->context;
           62  +	
           63  +	// Let's set some defaults for the logic to come...
           64  +	$show = false;
           65  +	$description = $cDB->UnEscTxt($trade->description);
           66  +	$link = "feedback.php";
           67  +	
           68  +	if(!$feedback_member) {	// Member hasn't left feedback yet, lets show a simple link
           69  +		$show = true;
           70  +	} elseif (isset($feedback_member->rebuttal) or isset($feedback_other->rebuttal)) {
           71  +		if(isset($feedback_member->rebuttal) and isset($feedback_other->rebuttal)) {
           72  +		
           73  +		} elseif (isset($feedback_member->rebuttal)) {
           74  +				
           75  +		} else {	// Member left negative/neutral feedback earlier, give a chance to follow up
           76  +			$show = true;
           77  +			
           78  +			$description .= "<BR><B>". $text .": </B>". $comment;
           79  +			$link = "feedback_reply.php";
           80  +            
           81  +		}
           82  +		
           83  +	} elseif ($feedback_other->rating == NEGATIVE or $feedback_other->rating == NEUTRAL) {
           84  +		$show = true;
           85  +		$description .= "<BR><B>". $feedback_other->RatingText() ." Valoración: </B>". $feedback_other->comment;
           86  +		$link = "feedback_reply.php";
           87  +	}
           88  +	
           89  +	if($show) {
           90  +		$date = new cDateTime($trade->trade_date);	
           91  +		$trade_date = $date->ShortDate();
           92  +				
           93  +		$output .= "<TR VALIGN=TOP BGCOLOR=". $bgcolor ."><TD><FONT SIZE=2><A HREF=". $link ."?author=". $member->member_id ."&about=". $member_id_other ."&trade_id=". $trade->trade_id ."&mode=".$_REQUEST["mode"] .">". $trade_date ."</A></FONT></TD><TD><FONT SIZE=2>". $member_id_other ."</FONT></TD><TD><FONT SIZE=2>". $trade->category->description ."</FONT></TD><TD ALIGN=RIGHT><FONT SIZE=2>". $trade->amount ."&nbsp;</FONT></TD><TD><FONT SIZE=2>". $description ."</FONT></TD></TR>";	
           94  +	} 	
           95  +	
           96  +	$i+=1;
           97  +}
           98  +
           99  +$output .= "</TABLE>";
          100  +
          101  +if($i == 0)
          102  +	$output .= "No hay intercambios a los que puedas valorar. Ya has puntuado tus intercambios recientes.";
          103  +
          104  +$p->DisplayPage($output);
          105  +
          106  +?>

Added bdt/feedback_rebuttal.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$member_about = new cMember;
            6  +$member_about->LoadMember($_REQUEST["about"]);
            7  +
            8  +$p->site_section = SECTION_FEEDBACK;
            9  +$p->page_title = "Introducir valoración para ". $member_about->PrimaryName();
           10  +
           11  +include("classes/class.feedback.php");
           12  +include("includes/inc.forms.php");
           13  +include("includes/inc.forms.validation.php");
           14  +
           15  +//
           16  +// Define form elements
           17  +//
           18  +$member = new cMember;
           19  +
           20  +if($_REQUEST["mode"] == "admin") {
           21  +	$cUser->MustBeLevel(2);
           22  +	$member->LoadMember($_REQUEST["author"]);
           23  +	$p->page_title .= " for ". $member->PrimaryName();
           24  +} else {
           25  +	$cUser->MustBeLoggedOn();
           26  +	$member = $cUser;
           27  +}
           28  +
           29  +$form->addElement('static', null, 'Todas las valoraciones son públicas. Antes de otorgar una valoración <i>negativa</i> , recomendamos dialogar directamente con la otra persona. A menudo los desacuerdos pueden arreglarse de esta manera para beneficio de ambas partes.', null);
           30  +$form->addElement('static', null, null, null);
           31  +$ratings = array(0=>"", POSITIVE=>"Positiva", NEUTRAL=>"Neutral", NEGATIVE=>"Negativa"); 
           32  +$form->addElement("select", "rating", "Valoración", $ratings);
           33  +$form->addElement("hidden", "about", $member_about->member_id);
           34  +$form->addElement("hidden", "author", $_REQUEST["author"]);
           35  +$form->addElement("hidden", "mode", $_REQUEST["mode"]);
           36  +$form->addElement("hidden", "trade_id", $_REQUEST["trade_id"]);
           37  +$form->addElement('static', null, 'Comentarios (Max. 255 caracteres)', null);
           38  +$form->addElement('textarea', 'comments', null, array('cols'=>60, 'rows'=>5, 'wrap'=>'soft', 'maxlength' => 255));
           39  +$form->addElement('submit', 'btnSubmit', 'Enviar');
           40  +
           41  +//
           42  +// Define form rules
           43  +//
           44  +
           45  +$form->addRule('rating', 'Escoge una puntuación', 'verify_selection');
           46  +$form->addRule('comments', 'Los comentarios no pueden ser más largos de 255 caracteres', 'verify_max255');
           47  +
           48  +//
           49  +// Then check if we are processing a submission or just displaying the form
           50  +//
           51  +if ($form->validate()) { // Form is validated so processes the data
           52  +   $form->freeze();
           53  + 	$form->process("process_data", false);
           54  +} else {
           55  +   $p->DisplayPage($form->toHtml());  // just display the form
           56  +}
           57  +
           58  +function process_data ($values) {
           59  +	global $p, $member_about, $member, $cErr;
           60  +	
           61  +	$feedback = new cFeedback($member->member_id, $member_about->member_id, $_REQUEST["trade_id"], $values["rating"], $values["comments"]);
           62  +	$success = $feedback->SaveFeedback();
           63  +	
           64  +	if($success) {
           65  +		if(LOG_LEVEL > 0 and $_REQUEST["mode"] == "admin") { // Log if enabled & entered by an admin
           66  +			$log_entry = new cLogEntry (FEEDBACK, FEEDBACK_BY_ADMIN, $feedback->feedback_id);
           67  +			$log_entry->SaveLogEntry();	
           68  +		}
           69  +		$output = "Tu valoración ha sido guardada.";
           70  +	} else {
           71  +		$output = "Ha habido un error al grabar tu valoración. Inténtalo más tarde.";
           72  +	}
           73  +	
           74  +	$p->DisplayPage($output);
           75  +}
           76  +
           77  +//
           78  +// Form rule validation functions
           79  +//
           80  +
           81  +
           82  +?>

Added bdt/feedback_reply.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$member_about = new cMember;
            6  +$member_about->LoadMember($_REQUEST["about"]);
            7  +
            8  +$p->site_section = SECTION_FEEDBACK;
            9  +$p->page_title = "Contestar a una valoración";
           10  +
           11  +include("classes/class.feedback.php");
           12  +include("includes/inc.forms.php");
           13  +include("includes/inc.forms.validation.php");
           14  +
           15  +//
           16  +// Define form elements
           17  +//
           18  +$feedback = new cFeedback;
           19  +$feedback->LoadFeedback($_REQUEST["feedback_id"]);
           20  +
           21  +$feedback_history = $feedback->comment;
           22  +if($feedback->rebuttals)
           23  +	 $feedback_history .= "<BR>" . $feedback->rebuttals->DisplayRebuttalGroup($_REQUEST["about"]);
           24  +
           25  +$member = new cMember;
           26  +
           27  +if($_REQUEST["mode"] == "admin") {
           28  +	$cUser->MustBeLevel(2);
           29  +	$member->LoadMember($_REQUEST["author"]);
           30  +	$p->page_title .= " for ". $member->PrimaryName();
           31  +} else {
           32  +	$cUser->MustBeLoggedOn();
           33  +	$member = $cUser;
           34  +}
           35  +
           36  +$form->addElement('static', null, "<B><I>Anteriores comentarios</I></B>", null);
           37  +$form->addElement('static', null, $feedback_history, null);
           38  +$form->addElement("hidden", "about", $member_about->member_id);
           39  +$form->addElement("hidden", "author", $_REQUEST["author"]);
           40  +$form->addElement("hidden", "mode", $_REQUEST["mode"]);
           41  +$form->addElement("hidden", "feedback_id", $_REQUEST["feedback_id"]);
           42  +$form->addElement('static', null, 'Comentario', null);
           43  +$form->addElement('textarea', 'comments', null, array('cols'=>60, 'rows'=>5, 'wrap'=>'soft', 'maxlength' => 255));
           44  +$form->addElement('submit', 'btnSubmit', 'Enviar');
           45  +
           46  +//
           47  +// Define form rules
           48  +//
           49  +$form->addRule('rating', 'Escoge una puntuación', 'verify_selection');
           50  +$form->addRule('comments', 'Los comentarios no pueden tener más de 255 caracteres', 'verify_max255');
           51  +
           52  +//
           53  +// Then check if we are processing a submission or just displaying the form
           54  +//
           55  +if ($form->validate()) { // Form is validated so processes the data
           56  +   $form->freeze();
           57  + 	$form->process("process_data", false);
           58  +} else {
           59  +   $p->DisplayPage($form->toHtml());  // just display the form
           60  +}
           61  +
           62  +function process_data ($values) {
           63  +	global $p, $member_about, $member, $cErr, $feedback;
           64  +	
           65  +
           66  +	
           67  +	$trade = new cTrade();
           68  +	$trade->LoadTrade($feedback->trade_id);
           69  +	
           70  +	// Make sure trade members correct
           71  +	if ($trade->member_from->member_id == $member->member_id and $trade->member_to->member_id == $member_about->member_id) {
           72  +	} elseif ($trade->member_to->member_id == $member->member_id and $trade->member_from->member_id == $member_about->member_id) {
           73  +	} else {
           74  +		$cErr->Error("Los usuarios no coinciden con el intercambio escogido."); // Theoretically, must be a hacker
           75  +		include("redirect.php");
           76  +	}
           77  +	
           78  +	$rebuttal = new cFeedbackRebuttal($_REQUEST["feedback_id"], $member->member_id, $values["comments"]);
           79  +	$success = $rebuttal->SaveRebuttal();
           80  +	
           81  +	if($success) {
           82  +		if(LOG_LEVEL > 0 and $_REQUEST["mode"] == "admin") { // Log if enabled & entered by an admin
           83  +			$log_entry = new cLogEntry (FEEDBACK, FEEDBACK_BY_ADMIN, $feedback->feedback_id);
           84  +			$log_entry->SaveLogEntry();	
           85  +		}
           86  +		$output = "Tu valoración se ha guardado.";
           87  +	} else {
           88  +		$output = "Ha habido un error al grabar tu valoración. Prueba más tarde.";
           89  +	}
           90  +	
           91  +	$p->DisplayPage($output);
           92  +}
           93  +
           94  +//
           95  +// Form rule validation functions
           96  +//
           97  +
           98  +?>

Added bdt/feedback_to_view.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$cUser->MustBeLoggedOn();
            4  +$p->site_section = EXCHANGES;
            5  +$p->page_title = "Escoge un miembro";
            6  +
            7  +include("includes/inc.forms.php");
            8  +
            9  +$ids = new cMemberGroup;
           10  +$ids->LoadMemberGroup();
           11  +$form->addElement("select", "member_id", "¿La valoración de quien?", $ids->MakeIDArray());
           12  +$form->addElement("static", null, null, null);
           13  +$form->addElement('submit', 'btnSubmit', 'Ver');
           14  +
           15  +if ($form->validate()) { // Form is validated so processes the data
           16  +   $form->freeze();
           17  + 	$form->process("process_data", false);
           18  +} else {  // Display the form
           19  +	$p->DisplayPage($form->toHtml());
           20  +}
           21  +
           22  +function process_data ($values) {
           23  +	global $cUser;
           24  +	header("location:http://".HTTP_BASE."/feedback_all.php?mode=other&member_id=".$values["member_id"]);
           25  +	exit;	
           26  +}
           27  +
           28  +?>

Added bdt/holiday.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +
            4  +$cUser->MustBeLoggedOn();
            5  +$p->site_section = PROFILE;
            6  +$p->page_title = "Desactivar ofertas y demandas en vacaciones";
            7  +
            8  +include("classes/class.directory.php");
            9  +include("includes/inc.forms.php");
           10  +
           11  +if($_REQUEST["mode"] == "admin") {
           12  +	$cUser->MustBeLevel(1);
           13  +	$form->addElement("hidden","mode","admin");
           14  +	$member = new cMember();
           15  +	$member->LoadMember($_REQUEST["member_id"]);
           16  +	$text = "Es importante desactivar temporalmente las ofertas y demandas mientras estás de vacaciones o no accesible, mediante esta opción.  ";
           17  +	$pronoun = "they";
           18  +} else {
           19  +	$cUser->MustBeLoggedOn();
           20  +	$member = $cUser;
           21  +	$form->addElement("hidden","mode","self");
           22  +	$text = "Es importante desactivar temporalmente las ofertas y demandas mientras estás de vacaciones o no accesible, mediante esta opción.  ";
           23  +	$pronoun = "you";
           24  +}
           25  +
           26  +$text .= "Tus ofertas y demandas no aparecerán durante el tiempo que marques en el directorio. Cuando termine el plazo se reactivarán automáticamente.";
           27  +$form->addElement("static", null, $text, null);
           28  +$form->addElement("hidden","member_id", $member->member_id);
           29  +$form->addElement("static", null, null, null);
           30  +$today = getdate();
           31  +$options = array('language'=> 'es', 'format' => 'dFY', 'minYear' => $today['year'],'maxYear' => $today['year']+5);
           32  +$form->addElement("date", "return_date", "¿Cuándo terminan las vacaciones?", $options);
           33  +$form->addElement("static", null, null, null);
           34  +$form->addElement("submit", "btnSubmit", "Desactivar");
           35  +
           36  +$form->registerRule('verify_future_date','function','verify_future_date');
           37  +$form->addRule('return_date','Debe ser una fecha futura','verify_future_date');
           38  +$form->registerRule('verify_valid_date','function','verify_valid_date');
           39  +$form->addRule('return_date','La fecha no es válida','verify_valid_date');
           40  +
           41  +if ($form->validate()) { // Form is validated so processes the data
           42  +   $form->freeze();
           43  + 	$form->process("process_data", false);
           44  +} else {  // Display the form
           45  +	$p->DisplayPage($form->toHtml());
           46  +}
           47  +
           48  +function process_data ($values) {
           49  +	global $p, $member;
           50  +	
           51  +	$date = $values['return_date'];
           52  +	$return_date = new cDateTime($date['Y'] . '/' . $date['F'] . '/' . $date['d']);
           53  +	
           54  +	$listings = new cListingGroup(OFFER_LISTING);
           55  +	$listings->LoadListingGroup(null,"%",$member->member_id);
           56  +	$listings->InactivateAll($return_date);
           57  +	
           58  +	$listings = new cListingGroup(WANT_LISTING);
           59  +	$listings->LoadListingGroup(null,"%",$member->member_id);
           60  +	$listings->InactivateAll($return_date);
           61  +	
           62  +	$output="Ofertas y demandas desactivadas.";
           63  +	
           64  +	$p->DisplayPage($output);
           65  +}
           66  +
           67  +function verify_future_date ($element_name,$element_value) {
           68  +	$today = getdate();
           69  +	$date = $element_value;
           70  +	$date_str = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
           71  +
           72  +	if (strtotime($date_str) <= strtotime("now")) // date is a past date
           73  +		return false;
           74  +	else
           75  +		return true;
           76  +}
           77  +
           78  +function verify_valid_date ($element_name,$element_value) {
           79  +	$date = $element_value;
           80  +	return checkdate($date['F'],$date['d'],$date['Y']);
           81  +}
           82  +
           83  +?>

Added bdt/images/Copia de top.png

cannot compute difference between binary files

Added bdt/images/KONEKTA.png

cannot compute difference between binary files

Added bdt/images/Teknologia.jpg

cannot compute difference between binary files

Added bdt/images/admin.png

cannot compute difference between binary files

Added bdt/images/aldaurilogo.jpg

cannot compute difference between binary files

Added bdt/images/bbk.jpg

cannot compute difference between binary files

Added bdt/images/bilbao.gif

cannot compute difference between binary files

Added bdt/images/contact.png

cannot compute difference between binary files

Added bdt/images/directory.png

cannot compute difference between binary files

Added bdt/images/events.gif

cannot compute difference between binary files

Added bdt/images/exchange.gif

cannot compute difference between binary files

Added bdt/images/feedback.png

cannot compute difference between binary files

Added bdt/images/info.png

cannot compute difference between binary files

Added bdt/images/kz.jpg

cannot compute difference between binary files

Added bdt/images/listing.png

cannot compute difference between binary files

Added bdt/images/localx_black.png

cannot compute difference between binary files

Added bdt/images/localx_home.png

cannot compute difference between binary files

Added bdt/images/localx_logo.png

cannot compute difference between binary files

Added bdt/images/localx_title.png

cannot compute difference between binary files

Added bdt/images/member.png

cannot compute difference between binary files

Added bdt/images/mutual_time.png

cannot compute difference between binary files

Added bdt/images/news.png

cannot compute difference between binary files

Added bdt/images/top.png

cannot compute difference between binary files

Added bdt/includes/inc.config.php

            1  +<?
            2  +
            3  +if (!isset($global))
            4  +{
            5  +    die(__FILE__." was included directly.  This file should only be included via inc.global.php.  Include() that one instead.");
            6  +}
            7  +
            8  +/**********************************************************/
            9  +/******************* SITE LOCATIONS ***********************/
           10  +
           11  +// What is the domain name of the site?  
           12  +define ("SERVER_DOMAIN","localhost");    // no http://
           13  +
           14  +// What is the path to the site? This is null for many sites.
           15  +define ("SERVER_PATH_URL","/bdt");    // no ending slash
           16  +
           17  +// The following only needs to be set if Pear has been
           18  +// installed manually by downloading the files
           19  +define ("PEAR_PATH", "C:\wamp\www\bdt\pear"); // no ending slash
           20  +
           21  +// Ok, then lets define some paths (no need to edit these)
           22  +define ("HTTP_BASE",SERVER_DOMAIN.SERVER_PATH_URL);
           23  +define ("CLASSES_PATH",$_SERVER["DOCUMENT_ROOT"].SERVER_PATH_URL."/classes/");
           24  +define ("IMAGES_PATH",SERVER_DOMAIN.SERVER_PATH_URL."/images/");
           25  +//define ("UPLOADS_PATH",$_SERVER["DOCUMENT_ROOT"].SERVER_PATH_URL."/uploads/");
           26  +/**********************************************************/
           27  +/***************** DATABASE LOGIN  ************************/
           28  +
           29  +define ("DATABASE_USERNAME","bdt");
           30  +define ("DATABASE_PASSWORD","bdt");
           31  +define ("DATABASE_NAME","bdt");
           32  +define ("DATABASE_SERVER","localhost"); // often "localhost"
           33  +
           34  +/**********************************************************/
           35  +/********************* SITE NAMES *************************/
           36  +
           37  +// What is the name of the site?
           38  +define ("SITE_LONG_TITLE", "Banco del Tiempo de los Barrios Altos de Bilbao");
           39  +
           40  +// What is the short, friendly, name of the site?
           41  +define ("SITE_SHORT_TITLE", "Banco del Tiempo de Konekta");
           42  +
           43  +/**********************************************************/
           44  +/***************** FOR MAINTENANCE ************************/
           45  +
           46  +// If you need to take the website down for maintenance (such
           47  +// as during an upgrade), set the following value to true
           48  +// and customize the message, if you like
           49  +
           50  +define ("DOWN_FOR_MAINTENANCE", false);
           51  +define ("MAINTENANCE_MESSAGE", SITE_LONG_TITLE ." está llevando a cabo tareas de mantenimiento.  Por favor, vuelva más tarde.");
           52  +
           53  +/**************************************************************/
           54  +/******************** SITE CUSTOMIZATION **********************/
           55  +
           56  +// email addresses & phone number to be listed in the site
           57  +define ("EMAIL_FEATURE_REQUEST","Banco del Tiempo Barrios Altos de Bilbao". "<bancodeltiempo@barriosaltos.net>");
           58  +define ("EMAIL_ADMIN","Banco del Tiempo Barrios Altos de Bilbao". "<bancodeltiempo@barriosaltos.net>");
           59  +define ("PHONE_ADMIN","Banco del Tiempo Barrios Altos de Bilbao". "<bancodeltiempo@barriosaltos.net>"); // an email address may be substituted...
           60  +define ("EMAIL_FROM","Banco del Tiempo Barrios Altos de Bilbao". "<bancodeltiempo@barriosaltos.net>"); // to override EMAIL_ADMIN 
           61  +                                                                                // for replies
           62  +
           63  +// What should appear at the front of all pages?
           64  +// Titles will look like "PAGE_TITLE_HEADER - PAGE_TITLE", or something 
           65  +// like "Local Exchange - Member Directory";
           66  +define ("PAGE_TITLE_HEADER", SITE_LONG_TITLE);
           67  +
           68  +// What keywords should be included in all pages?
           69  +define ("SITE_KEYWORDS", "Konekta,Aldauri,Barriosaltos,Bilbao,Banco del tiempo,San Francisco,Zabala,Bilbao La Vieja,trueque,intercambio,".SITE_LONG_TITLE);
           70  +
           71  +// Logo Graphic for Header
           72  +define ("HEADER_LOGO", "KONEKTA.png");
           73  +define ("HEADER_LOGO2", "aldaurilogo.jpg");
           74  +
           75  +// Title Graphic for Header
           76  +define ("HEADER_TITLE", "localx_title.png");
           77  +
           78  +// Logo for Home Page
           79  +define ("HOME_LOGO", "localx_black.png");
           80  +
           81  +// Picture appearing left of logo on Home Page
           82  +define ("HOME_PIC", "localx_home.png");
           83  +
           84  +// What content should be in the site header and footer?
           85  +//define ("PAGE_HEADER_CONTENT", "<table align=center cellpadding=15 cellspacing=0 id=\"mainTable\"><tr><td id=\"header\" align=center><img style='padding-right:5px' src=\"http://".HTTP_BASE."/images/". HEADER_LOGO ."\" alt=\"". SITE_SHORT_TITLE . " logo\"></td><td id=\"header\"><h1 align=right><br>Banco de tiempo - Konekta<br>");
           86  +
           87  +
           88  +// define ("PAGE_HEADER_CONTENT", "<table align=center cellpadding=15 cellspacing=0 id=\"mainTable\"><tr><td colspan='2'><table><tr><td id=\"header\" align=center><img  src=\"http://".HTTP_BASE."/images/". HEADER_LOGO ."\" alt=\"". SITE_SHORT_TITLE . " logo\"></td><td id=\"header\"><h1 align=right><br>Banco de tiempo - Konekta<br></td></tr></table>");
           89  +
           90  +
           91  +// Posibilidad de añadir    <img src=\"http://".HTTP_BASE."/images/". HEADER_LOGO2 ."\" alt=\"". SITE_SHORT_TITLE . " logo\">
           92  +
           93  +// (ORIGINAL)
           94  +define ("PAGE_HEADER_CONTENT", "<table align=center cellpadding=15 cellspacing=0 id=\"mainTable\"><tr><td id=\"header\" align=center ><img src=\"http://".HTTP_BASE."/images/". HEADER_LOGO ."\" alt=\"". SITE_SHORT_TITLE . " logo\"></td><td id=\"header\"><img src=\"http://".HTTP_BASE."/images/". HEADER_TITLE ."\"><br>");
           95  +
           96  +
           97  +define ("PAGE_FOOTER_CONTENT", "<tr><td id=\"footer\" colspan=2><p align=center><strong>". SITE_LONG_TITLE ." </strong></a><br>Creado bajo <a href=\"http://www.gnu.org/copyleft/gpl.html\">GPL</a> &#8226; <a href=\"http://". SERVER_DOMAIN . SERVER_PATH_URL ."/info/credits.php\">Creditos</a><br><table width=\"269\" border=\"0\" align=\"center\">
           98  +  <tr>
           99  +    <td><div align=\"center\"><a href=\"http://www.bbk.es\"><img src=\"http://".HTTP_BASE."/images/bbk.jpg\" border=\"0\"></a></div></td>
          100  +    <td><div align=\"center\"><a href=\"http://www.bilbao.net\"><img src=\"http://".HTTP_BASE."/images/bilbao.gif\" border=\"0\"></a></div></td>
          101  +  </tr>
          102  +</table></td></tr></table><br>");  
          103  +
          104  +// (ORIGINAL)
          105  +// define ("PAGE_FOOTER_CONTENT", "<tr><td id=\"footer\" colspan=2><p align=center><strong>". SITE_LONG_TITLE ." </strong>&#8226; <a href=\"http://". SERVER_DOMAIN . SERVER_PATH_URL ."\">". SERVER_DOMAIN ."</a><br><a href=\"mailto:". EMAIL_ADMIN ."\">" . EMAIL_ADMIN ."</a> &#8226; ". PHONE_ADMIN ."<br><font size=\"-2\">Licensed under the <a href=\"http://www.gnu.org/copyleft/gpl.html\">GPL</a> &#8226; Local Exchange <a href=\"http://". SERVER_DOMAIN . SERVER_PATH_URL ."/info/credits.php\">Credits</a></td></tr></table><br>");
          106  +
          107  +/**********************************************************/
          108  +/**************** DEFINE SIDEBAR MENU *********************/
          109  +
          110  +$SIDEBAR = array (
          111  +    array("Principal","index.php"),
          112  +    array("Ver Ofertas","listings.php?type=Offer"),
          113  +    array("Ver Demandas","listings.php?type=Want"),
          114  +    array("Contacta","contact.php"),
          115  +    array("Apuntarse","member_self.php"));
          116  +
          117  +// El resto de opciones está en classes/class.page.php
          118  +    
          119  +/**********************************************************/
          120  +/**************** DEFINE SITE SECTIONS ********************/
          121  +
          122  +define ("EXCHANGES",0);
          123  +define ("LISTINGS",1);
          124  +define ("EVENTS",2);
          125  +define ("ADMINISTRATION",3);
          126  +define ("PROFILE",4);
          127  +define ("SECTION_FEEDBACK",5);
          128  +define ("SECTION_EMAIL",6);
          129  +define ("SECTION_INFO",7);
          130  +define ("SECTION_DIRECTORY",8);
          131  +
          132  +$SECTIONS = array (
          133  +    array(0, "Exchanges", "exchange.gif"),
          134  +    array(1, "Listings", "listing.png"),
          135  +    array(2, "Events", "news.png"),
          136  +    array(3, "Administration", "admin.png"),
          137  +    array(4, "Events", "member.png"),
          138  +    array(5, "Feedback", "feedback.png"),
          139  +    array(6, "Email", "contact.png"),
          140  +    array(7, "Info", "info.png"),
          141  +    array(8, "Directory", "directory.png"));
          142  +
          143  +/**********************************************************/
          144  +/******************* GENERAL SETTINGS *********************/
          145  +
          146  +define ("USE_RATES", false); // If turned on, listings will include a "Rate" field
          147  +define ("UNITS", "Horas");  // This setting affects functionality, not just text displayed, so if you want to use hours/minutes this needs to read "Hours" exactly.  All other unit descriptions are ok, but receive no special treatment (i.e. there is no handling of "minutes").
          148  +define ("MAX_FILE_UPLOAD","5000000"); // Maximum file size, in bytes, allowed for uploads to the server
          149  +define ("EMAIL_LISTING_UPDATES", true); // Should users receive automatic updates
          150  +                                                     // for new and modified listings?
          151  +define ("DEFAULT_UPDATE_INTERVAL", WEEKLY); // If automatic updates are sent, this is
          152  +                                                     // the default interval. Possible
          153  +                                                     // values are NEVER, DAILY, WEEKLY & MONTHLY.
          154  +// The following text will appear at the beggining of the email update messages
          155  +define ("LISTING_UPDATES_MESSAGE", "Las siguientes ofertas y demandas son nuevas o se han actualizado.<p>Si prefieres no recibir emails automáticos, o si quieres cambiar su frecuencia, puedes hacerlo en el área de <a href=http://".HTTP_BASE."/member_edit.php?mode=self>Perfil de Miembro</a>.");
          156  +
          157  +// Should inactive accounts have their listings automatically expired?
          158  +// This can be a useful feature.  It is an attempt to deal with the 
          159  +// age-old local currency problem of new members joining and then not 
          160  +// keeping their listings up to date or using the system in any way.  
          161  +// It is designed so that if a member doesn't record a trade OR update 
          162  +// a listing in a given period of time (default is six months), their 
          163  +// listings will be set to expire and they will receive an email to 
          164  +// that effect (as will the admin).
          165  +define ("EXPIRE_INACTIVE_ACCOUNTS",false); 
          166  +
          167  +// If above is set, after this many days, accounts that have had no
          168  +// activity will have their listings set to expire.  They will have 
          169  +// to reactiveate them individually if they still want them.
          170  +define ("MAX_DAYS_INACTIVE","180");  
          171  +
          172  +// How many days in the future the expiration date will be set for
          173  +define ("EXPIRATION_WINDOW","15");    
          174  +
          175  +// How long should expired listings hang around before they are deleted?
          176  +define ("DELETE_EXPIRED_AFTER","90"); 
          177  +
          178  +// The following message is the one that will be emailed to the person 
          179  +// whose listings have been expired (a delicate matter).
          180  +define ("EXPIRED_LISTINGS_MESSAGE", "Hola,\n\nDebido a la inactividad, tu cuenta ".SITE_SHORT_TITLE." ha expirado hace ". EXPIRATION_WINDOW ." días.\n\nPara que ".SITE_LONG_TITLE." esté actualizado y funcionando correctamente para todos los miembros, hemos desarrollado un sistema automático de finalización de cuentas para miembros que no han hecho cambios durante un periodo de ".MAX_DAYS_INACTIVE." días. Queremos que el directorio esté actualizado, así que los miembros no encontrarán cuentas que estén fuera de este periodo. Esto funciona para el beneficio común.\n\nLamentamos cualquier inconveniencia que te haya podido causar y te agradecemos tu participación. \n\n En todo caso, tienes ". EXPIRATION_WINDOW ." días para entrar con tu contraseña y reactivar las cuentas que quieres que sigan funcionando en el directorio. Si no las reactivas durante este plazo, tus cuentas no volverán a aparecer en el directorio, pero segirán almacenadas en el sistema durante ". DELETE_EXPIRED_AFTER ." días, plazo de tiempo durante el cual aún puedes editar y reactivar las cuentas. \n\n\nInstrucciones para reactivación:\n1) Entrar con tu contraseña\n2) Ir a Actualizar Cuentas\n3) Selecciona Editar Cuentas\n4) Selecciona la cuenta\n5) Desactiva el cuadradito correspondiente a '¿Se pondrá esta cuenta para finalización automática?'\n6) Pulsa Actualizar\n7) Repite los pasos 1-6 para todas las cuentas que quieres reactivar. \n");
          181  +
          182  +// The year your local currency started -- the lowest year shown
          183  +// in the Join Year menu option for accounts.
          184  +define ("JOIN_YEAR_MINIMUM", "2008");  
          185  +
          186  +define ("DEFAULT_COUNTRY", "Bizkaia");
          187  +define ("DEFAULT_ZIP_CODE", "48003");
          188  +define ("DEFAULT_CITY", "Bilbao");
          189  +define ("DEFAULT_STATE", "WA");
          190  +define ("DEFAULT_PHONE_AREA", "360");
          191  +
          192  +// Should short date formats display month before day (US convention)?
          193  +define ("MONTH_FIRST", false);        
          194  +
          195  +define ("PASSWORD_RESET_SUBJECT", "Tu cuenta ". SITE_LONG_TITLE ." ");
          196  +define ("PASSWORD_RESET_MESSAGE", "Tu contraseña para ". SITE_LONG_TITLE ." ha sido reseteada. Si no habías pedido este reseteo, es posible que haya habido algún problema con tu cuenta; ponte en contacto con la persona administradora en ".PHONE_ADMIN.".\n\nTu nueva contraseña está al final de este mensaje. Puedes cambiar tu contraseña entrando en el sistema y yendo al Perfil de asociado/a.");
          197  +define ("NEW_MEMBER_SUBJECT", "Bienvenido/a a ". SITE_LONG_TITLE);
          198  +define ("NEW_MEMBER_MESSAGE", "Hola, y bienvenido/a a la comunidad ". SITE_LONG_TITLE ."\n\nSe ha creado una cuenta de asociado/a para tí en :\nhttp://".SERVER_DOMAIN.SERVER_PATH_URL."/member_login.php\n\nPor favor, entra en el sistema y crea tus ofertas y demandas. Tu identificador de usuario/a y contraseña están al final de este mensaje. Puedes cambiar tu contraseña entrando en el sistema yendo al Perfil de asociado/a.\n\nGracias por unirte al Banco de Tiempo. ");
          199  +define ("NEW_MEMBER_PENDING", "Hola, y bienvenido/a a la comunidad ". SITE_LONG_TITLE ."\n\nSe ha creado una cuenta de asociado/a para tí en :\nhttp://".SERVER_DOMAIN.SERVER_PATH_URL."/member_login.php\n\nDe momento no puedes entrar al Banco del Tiempo hasta que el administrador te autorice en el sistema. Tu identificador de usuario/a y contraseña están al final de este mensaje.\n\nYa tienes listo tu carnet de socio del Banco del Tiempo, puedes pasar a recogerlo a Konekta para que puedas empezar a realizar tus intercambios.\n\nRecibirás un correo cuando tu cuenta esté plenamente operativa. Si no has facilitado ningún correo electrónico deberás comprobar pasado un tiempo (generalmente un día) si puedes entrar. También puedes llamar a Konekta para que activemos tu cuenta. Gracias por unirte al Banco del Tiempo. ");  
          200  +define ("ACTIVE_MEMBER_SUBJECT", "Cuenta activada en ". SITE_LONG_TITLE); 
          201  +define ("ACTIVE_MEMBER_MESSAGE", "Hola, y bienvenido/a a la comunidad ". SITE_LONG_TITLE ."\n\nSe ha activado la cuenta de asociado/a para tí en :\nhttp://".SERVER_DOMAIN.SERVER_PATH_URL."/member_login.php\n\nPor favor, entra en el sistema y crea tus ofertas y demandas. Tu identificador de usuario/a está al final de este mensaje. Si lo deseas, puedes cambiar la contraseña que facilitaste al darte de alta entrando en el sistema yendo al Perfil de asociado/a.\n\nGracias por unirte al Banco de Tiempo. ");
          202  +/********************************************************************/
          203  +/************************* ADVANCED SETTINGS ************************/
          204  +// Normally, the defaults for the settings that follow don't need
          205  +// to be changed.
          206  +
          207  +// What's the name and location of the stylesheet?
          208  +define ("SITE_STYLESHEET", "style.css");
          209  +
          210  +// How long should trades be listed on the "leave feedback for 
          211  +// a recent exchange" page?  After this # of days they will be
          212  +// dropped from that list.
          213  +define ("DAYS_REQUEST_FEEDBACK", "30"); 
          214  +
          215  +// Is debug mode on? (display errors to the general UI?)
          216  +define ("DEBUG",true);
          217  +
          218  +// Should adminstrative activity be logged?  Set to 0 for no logging; 1 to 
          219  +// log trades recorded by administrators; 2 to also log changes to member 
          220  +// settings (LEVEL 2 NOT YET IMPLEMENTED)
          221  +define ("LOG_LEVEL", 1);
          222  +
          223  +// How many consecutive failed logins should be allowed before locking out an account?
          224  +// This is important to protect against dictionary attacks.  Don't set higher than 10 or 20.
          225  +define ("FAILED_LOGIN_LIMIT", 10);
          226  +
          227  +// Are magic quotes on?  Site has not been tested with magic_quotes_runtime on, 
          228  +// so if you feel inclined to change this setting, let us know how it goes :-)
          229  +define ("MAGIC_QUOTES_ON",false);
          230  +set_magic_quotes_runtime (0);
          231  +
          232  +// CSS-related settings.  If you'r looking to change colors, 
          233  +// best to edit the CSS rather than add to this...
          234  +$CONTENT_TABLE = array("id"=>"contenttable", "cellspacing"=>"0", "cellpadding"=>"3");
          235  +
          236  +// System events are processes which only need to run periodically,
          237  +// and so are run at intervals rather than weighing the system
          238  +// down by running them each time a particlular page is loaded.
          239  +// System Event Codes (such as ACCOUNT_EXPIRATION) are defined in inc.global.php
          240  +// System Event Frequency (how many minutes between triggering of events)
          241  +$SYSTEM_EVENTS = array (
          242  +    ACCOUT_EXPIRATION => 1440);  // Expire accounts once a day (every 1440 minutes)
          243  +
          244  +
          245  +/**********************************************************/
          246  +//    Everything below this line simply sets up the config.
          247  +//    Nothing should need to be changed, here.
          248  +
          249  +if (PEAR_PATH != "")
          250  +    ini_set("include_path", PEAR_PATH .'/'. PATH_SEPARATOR . ini_get("include_path"));  
          251  + 
          252  +
          253  +if (DEFAULT_COUNTRY == "United States") {
          254  +    define ("ZIP_TEXT", "Zip Code");
          255  +    define ("STATE_TEXT", "State");
          256  +} else {
          257  +    define ("ZIP_TEXT", "Código postal");
          258  +    define ("STATE_TEXT", "Region");
          259  +}
          260  +
          261  +if (DEBUG) error_reporting(E_ALL);
          262  +    else error_reporting(E_ALL ^ E_NOTICE);
          263  +
          264  +define("LOAD_FROM_SESSION",-1);  // Not currently in use
          265  +
          266  +// URL to PHP page which handles redirects and such.
          267  +define ("REDIRECT_URL",SERVER_PATH_URL."/redirect.php");
          268  +
          269  +define ("AVISO_LEGAL",'<p>&nbsp;</p>
          270  +<p>&nbsp;</p><p><font face="Arial" color="#336699" size="1"><strong>LEGEZKO ABISUA</strong>.-
          271  +Mezu elektroniko honetako informazioa jasotzaile gisa ageri den(ar) entzat baino
          272  +ez da. Mezu elektroniko honetako eta berari erantsitako fitxategietako
          273  +informazioa isilpean eduki behar da edota jabetza intelektualaren gaineko legeen
          274  +eta beste legeen babespean dago. Mezu honek ez dio ezartzen inolako
          275  +konpromisorik bidaltzaileari, berak eta jasotzaileak, aldez aurretik, berariazko
          276  +idatzizko itunaren bidez besterik hitzartu ezean. Errakuntzaren bat dela-eta
          277  +mezu hau jasotzen baduzu, bertan jarritako jasotzailea ez izan arren, jakinarazi
          278  +ahalik azkarren bidaltzaileari, mesedez(bancodeltiempo@barriosaltos.net) eta gero ezabatu
          279  +erabat. Horrez gainera, mezuan jarritako jasotzailea ez bazara, ezin duzu
          280  +erabili, banatu, kopiatu ez inprimatu, ez osorik ez zati bat.<br>
          281  +<br>
          282  +<b>AVISO LEGAL</b> - La información contenida en este correo electrónico es
          283  +para el uso exclusivo de la/s persona/s mencionadas como destinataria/s. Este
          284  +correo electrónico y los archivos adjuntos, en su caso, contienen información
          285  +confidencial y/o protegida legalmente por leyes de propiedad intelectual o por
          286  +otras leyes. Este mensaje no constituye ningún compromiso por parte de la
          287  +persona remitente, salvo que exista expreso pacto en contrario, previo y por
          288  +escrito entre la persona destinataria y la remitente. Si usted no es la persona
          289  +destinataria designada y recibe este mensaje por error, por favor, notifíquelo
          290  +a la persona remitente con la mayor brevedad posible a la siguiente dirección:(bancodeltiempo@barriosaltos.net) y proceda inmediatamente a su total destrucción. Así
          291  +mismo, le informamos de que no debe, directa o indirectamente, usar, distribuir,
          292  +reproducir, imprimir o copiar, total o parcialmente este mensaje si no es la
          293  +persona destinataria designada.<br>
          294  +<br>
          295  +<b>DISCLAIMER </b>- The information contained in this email is for the exclusive
          296  +use of the person(s) mentioned as addressee(s). This email and the attached
          297  +files, where appropriate, contain confidential information and/or information
          298  +legally protected by intellectual property laws or other laws. This message does
          299  +not constitute any commitment on the part of the sender, except where there
          300  +exists prior express agreement to the contrary in writing between the addressee
          301  +and the sender. If you are not the designated addressee and receive this message
          302  +by mistake, please notify the sender as soon as possible at the following
          303  +address (bancodeltiempo@barriosaltos.net) and then delete it immediately. We also inform you
          304  +that you may not use, distribute, print or copy this message, either directly or
          305  +indirectly or totally or partially, if you are not the designated addressee</font></p>');
          306  +
          307  +define ("LOPD",'<p>&nbsp;</p>
          308  +<p><font face="Arial" color="#990000" size="1"><b><font color="#660000">AVISO LEGAL</font></b><font color="#660000"> -
          309  +  De conformidad con lo dispuesto en la Ley Orgánica 15/1999, de 13 de diciembre, de Protección de Datos de Carácter Personal, El Banco del Tiempo de Barrios Altos, le informa que los datos que usted remitió están incorporados a un fichero de su titularidad cuya finalidad es la participación en el Banco del Tiempo de Barrios Altos. 
          310  +El Banco del Tiempo de Barrios Altos se compromete a cumplir su obligación de guardar secreto respecto de los datos de carácter personal que figuran en el mismo y garantiza la adopción de las medidas de seguridad necesarias para velar por la confidencialidad de dichos datos, que conservará durante un periodo de dos años desde que Usted lo envió, transcurrido dicho periodo se procederá a su cancelación. 
          311  +Se le reconoce la posibilidad de ejercitar gratuitamente los derechos de acceso, rectificación, cancelación y oposición, en los términos previstos en la Ley Orgánica 15/1999, en la dirección arriba indicada. 
          312  +Transcurridos ocho días desde la emisión de esta comunicación sin que usted manifieste nada en contrario, El Banco del Tiempo de Barrios Altos entenderá que autoriza el tratamiento de sus datos en los términos indicados. </font><br>
          313  +</font></p>');
          314  +
          315  +define("ROTULO_MAIL", '<TABLE width="100%" border="0" cellPadding="0" cellSpacing="0" valign="middle"><TBODY><TR><TD width="100%" style="padding-left: 9px;font-family: Arial,Helvetica,sans-serif;background-color: #D6E7FC;">    
          316  +    <table width="98%" height="61" border="0" cellpadding="0" cellspacing="0" valign="middle">
          317  +    <tbody>
          318  +      <tr>
          319  +        <td style="PADDING-RIGHT: 7px; PADDING-LEFT: 8px; FONT-WEIGHT: bold; FONT-SIZE: 25px; COLOR: #fff; FONT-FAMILY: Arial,Helvetica,sans-serif; BACKGROUND-COLOR: #666666" align="middle">&gt;</td>
          320  +        <td width="100%" style="color: #000000;font-size: 18px;PADDING-LEFT: 8px;"><strong> Banco del Tiempo - Barrios Altos de Bilbao</strong></td>
          321  +      </tr>
          322  +    </tbody>
          323  +  </table>
          324  +          <span style="font-size: 12px; font-weight: bold; color: #666666;">KONEKTA - FUNDACI&Oacute;N ALDAURI</span></TD>
          325  +      </TR>
          326  +</TBODY>
          327  +</TABLE><p>&nbsp;</p>');
          328  +?>

Added bdt/includes/inc.events.php

            1  +<?
            2  +
            3  +// This include file is for processes that only need to be run periodically, 
            4  +// using the cSystemEvent class's TimeForEvent() method to limit their
            5  +// execution so that they don't bog the system down.
            6  +//
            7  +// This file is meant to be included in one or more pages in the system
            8  +// which is regularly visited by users.  It's best to include it AFTER a page has
            9  +// been displayed, also to prevent excessive page load times.
           10  +
           11  +
           12  +// The following will expire listings for inactive members as set
           13  +// in inc.config.php.  
           14  +
           15  +include_once("classes/class.listing.php");
           16  +
           17  +$e = new cSystemEvent(ACCOUT_EXPIRATION);
           18  +if(EXPIRE_INACTIVE_ACCOUNTS and $e->TimeForEvent()) {
           19  +	$members = new cMemberGroup;
           20  +	$members->ExpireListings4InactiveMembers();
           21  +	$e->LogEvent();
           22  +}
           23  +
           24  +
           25  +// The following three events are for automatic email updates regarding new modified 
           26  +// listings
           27  +
           28  +$e = new cSystemEvent(MONTHLY_LISTING_UPDATES, MONTHLY*1440);       
           29  +if(EMAIL_LISTING_UPDATES and $e->TimeForEvent()) {
           30  +	$members = new cMemberGroup;
           31  +	$members->EmailListingUpdates(MONTHLY);
           32  +	$e->LogEvent();
           33  +}
           34  +
           35  +$e = new cSystemEvent(WEEKLY_LISTING_UPDATES, WEEKLY*1440);            
           36  +if(EMAIL_LISTING_UPDATES and $e->TimeForEvent()) {
           37  +	$members = new cMemberGroup;
           38  +	$members->EmailListingUpdates(WEEKLY);
           39  +	$e->LogEvent();
           40  +}
           41  +
           42  +$e = new cSystemEvent(DAILY_LISTING_UPDATES, DAILY*1440);             
           43  +if(EMAIL_LISTING_UPDATES and $e->TimeForEvent()) {
           44  +	$members = new cMemberGroup;
           45  +	$members->EmailListingUpdates(DAILY);
           46  +	$e->LogEvent();
           47  +}
           48  +
           49  +?>

Added bdt/includes/inc.forms.php

            1  +<?
            2  +require_once('HTML/QuickForm.php');
            3  +
            4  +$form = new HTML_QuickForm();
            5  +$renderer =& $form->defaultRenderer();
            6  +
            7  +$renderer->setFormTemplate('<form{attributes}><table id="contentTable">{content}</table></form>');
            8  +$renderer->setHeaderTemplate('<tr><td><H2>{header}</H2></td></tr>');
            9  +$renderer->setElementTemplate('<TR><TD><FONT SIZE=2>{label}<!-- BEGIN required --><font> *</font><!-- END required --></FONT><!-- BEGIN error --><font color=RED size=2>   {error}</font><br /><!-- END error -->&nbsp;{element}</TD></TR>');
           10  +$form->setRequiredNote('<br><tr><td><font size=2>Los campos con asterisco * son obligatorios</font></td></tr>');
           11  +
           12  +?>

Added bdt/includes/inc.forms.validation.php

            1  +<?
            2  +
            3  +require_once("inc.forms.php");
            4  +
            5  +function verify_max255($z, $text) {
            6  +	if(strlen($text) > 255)
            7  +		return false;
            8  +	else
            9  +		return true;
           10  +}
           11  +$form->registerRule('verify_max255','function','verify_max255');
           12  +
           13  +function verify_selection ($z, $selection) {
           14  +	if($selection == "0")
           15  +		return false;
           16  +	else
           17  +		return true;
           18  +}
           19  +$form->registerRule('verify_selection','function','verify_selection');
           20  +
           21  +?>

Added bdt/includes/inc.global.php

            1  +<?
            2  +
            3  +/************************************************************
            4  +This file includes necesary class files and other include files.
            5  +It also defines global constants, and kicks off the session. 
            6  +It should be included by all pages in the site.  It does not
            7  +need to be edited for site installation, and in fact should
            8  +only be modified with care.
            9  +************************************************************/
           10  +
           11  +/*********************************************************/
           12  +/******************* GLOBAL CONSTANTS ********************/
           13  +
           14  +// These constants should only be changed with extreme caution
           15  +define("LOGGED_OUT","!");
           16  +define("GO_BACK","< Back");
           17  +define("GO_NEXT","Next >");
           18  +define("GO_FINISH","Finish");
           19  +define("REDIRECT_ON_ERROR", true);
           20  +define("FIRST", true);
           21  +define("LONG_LONG_AGO", "1970-01-01");
           22  +define("FAR_FAR_AWAY", "2030-01-01");
           23  +define("ACTIVE","A");
           24  +define("INACTIVE","I");
           25  +define("EXPIRED","E");
           26  +define("WAITING","X");
           27  +define("DISABLED","D");
           28  +define("LOCKED","L");
           29  +define("BUYER","B");
           30  +define("SELLER","S");
           31  +define("POSITIVE","3");
           32  +define("NEGATIVE","1");
           33  +define("NEUTRAL","2");
           34  +define ("OFFER_LISTING", "Offer");
           35  +define ("OFFER_LISTING_CODE", "O");
           36  +define ("WANT_LISTING", "Want");
           37  +define ("WANT_LISTING_CODE", "W");
           38  +define("DAILY",1);
           39  +define("WEEKLY",7);
           40  +define("MONTHLY",30);
           41  +define("NEVER",0);
           42  +
           43  +// The following constants are used for logging. Add new categories if
           44  +// needed, but edit existing ones with caution.
           45  +define("TRADE","T"); // Logging event category
           46  +define("TRADE_BY_ADMIN","A");
           47  +define("TRADE_ENTRY","T");
           48  +define("TRADE_REVERSAL","R");
           49  +define("FEEDBACK","F"); // Logging event category
           50  +define("FEEDBACK_BY_ADMIN","A");
           51  +define("ACCOUT_EXPIRATION","E"); // Logging event category - System Event
           52  +define("DAILY_LISTING_UPDATES","D"); // Logging event category - System Event
           53  +define("WEEKLY_LISTING_UPDATES","W"); // Logging event category - System Event
           54  +define("MONTHLY_LISTING_UPDATES","M"); // Logging event category - System Event
           55  +
           56  +/*********************************************************/
           57  +define("LOCALX_VERSION", "0.3.2");
           58  +
           59  +/**********************************************************/
           60  +/***************** DATABASE VARIABLES *********************/
           61  +
           62  +define ("DATABASE_LISTINGS","listings");
           63  +define ("DATABASE_PERSONS","person");
           64  +define ("DATABASE_MEMBERS","member");
           65  +define ("DATABASE_TRADES","trades");
           66  +define ("DATABASE_LOGINS","logins");
           67  +define ("DATABASE_LOGGING","admin_activity");
           68  +define ("DATABASE_USERS","member");
           69  +define ("DATABASE_CATEGORIES", "categories");
           70  +define ("DATABASE_FEEDBACK", "feedback");
           71  +define ("DATABASE_REBUTTAL", "feedback_rebuttal");
           72  +define ("DATABASE_NEWS", "news");
           73  +define ("DATABASE_UPLOADS", "uploads");
           74  +
           75  +/*********************************************************/
           76  +// This section is deprecated.  It has been relocated to 
           77  +// inc.config.php, and would be removed but for a bunch of
           78  +// references to the following two, now bogus, values...
           79  +
           80  +// TODO: Clean up all references and remove the two lines below
           81  +define ("SITE_SECTION_DEFAULT",-1);		
           82  +define ("SITE_SECTION_OFFER_LIST",0); 
           83  +/*********************************************************/
           84  +
           85  +
           86  +$global = ""; 	// $global lets other includes know that 
           87  +					// inc.global.php has been included
           88  +
           89  +session_start();
           90  +
           91  +include_once("inc.config.php");
           92  +include_once(CLASSES_PATH ."class.datetime.php");
           93  +include_once(CLASSES_PATH ."class.error.php");
           94  +include_once(CLASSES_PATH ."class.database.php");
           95  +include_once(CLASSES_PATH ."class.login_history.php");
           96  +include_once(CLASSES_PATH ."class.member.php");
           97  +include_once(CLASSES_PATH ."class.page.php");
           98  +include_once(CLASSES_PATH ."class.logging.php");
           99  +
          100  +// The following is necessary because of a PHP 4.4 bug with passing references
          101  +error_reporting( E_ALL & ~E_NOTICE );
          102  +
          103  +// For maintenance, see inc.config.php
          104  +if(DOWN_FOR_MAINTENANCE and !$running_upgrade_script) {
          105  +	$p->DisplayPage(MAINTENANCE_MESSAGE);
          106  +	exit;
          107  +}
          108  +
          109  +?>

Added bdt/index.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +$p->site_section = SITE_SECTION_OFFER_LIST;
            5  +
            6  +print $p->MakePageHeader();
            7  +print $p->MakePageMenu();
            8  +
            9  +include("classes/class.news.php");
           10  +include("classes/class.uploads.php");
           11  +
           12  +
           13  +?>
           14  +
           15  +<table cellpadding=0 cellspacing=2>
           16  + <tr>
           17  + <td><img src="images/<? echo HOME_PIC ?>" align=top></td>
           18  + <td><p><strong> <font size="4">Banco del Tiempo de Barrios Altos de Bilbao</font></strong></p></td>
           19  +
           20  + </tr>
           21  + </table>
           22  +
           23  +
           24  +
           25  +
           26  +<ul>
           27  +<li><strong><a href='info/que_es.php'>¿Qué es un banco de tiempo?</a><br><br></strong></li>
           28  +<li><strong><a href='info/como_funciona.php'>¿Cómo funciona un banco de tiempo?</a><br><br></strong></li>
           29  +<li><strong><a href='info/tipos_de_intercambio.php'>Tipos de intercambio</a><br><br></strong></li>
           30  +<li><strong><a href='info/condiciones_de_uso.php'>Condiciones de uso</a><br><br></strong></li>
           31  +</ul>
           32  +
           33  +<?
           34  +
           35  +
           36  +$output = "<BR><h2>Últimas novedades</h2><p>";
           37  +
           38  +$news = new cNewsGroup();
           39  +$news->LoadNewsGroup();
           40  +$newstext = $news->DisplayNewsGroup();
           41  +if($newstext != "")
           42  +    $output .= $newstext;
           43  +else
           44  +    $output .= "Próximamente os contaremos novedades sobre el Banco de Tiempo.<P>";
           45  +
           46  +$newsletters = new cUploadGroup("N");
           47  +
           48  +if($newsletters->LoadUploadGroup()) {
           49  +    $output .= "<I>Para leer las últimas novedades de  ". SITE_SHORT_TITLE . ", pulsa <A HREF=newsletters.php>aquí</A>.</I>";
           50  +}
           51  +
           52  +echo $output;
           53  +
           54  +print $p->MakePageFooter(); 
           55  +//  Cabecera original
           56  +
           57  +?>

Added bdt/index2.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +include_once("includes/inc.events.php"); 
            5  +
            6  +
            7  +?>
            8  +

Added bdt/info/agreement.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "Membership Agreement";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +<p><font size="2">1. Fourth Corner Exchange is a non-profit organization whose rights and authority are vested in the members who delegate that authority to the management group who act on their behalf.</font>
           14  +
           15  +<p><font size="2">2. Fourth Corner Exchange provides an information service through which members can exchange goods and services, and maintains a central account of those exchanges for the benefit of members.</font></p>
           16  +
           17  +<p><font size="2">3. Key information is available to all members. Members agree to Fourth Corner Exchange holding their details on computer and distributing to other members those details relevant to the purpose of exchange. Members also agree to the directory of goods and services being distributed to the general membership for publicity purposes.</font></p>
           18  +
           19  +<p><font size="2">4. Members may give or receive from each other credit in the accepted Fourth Corner Exchange unit of account called Time Dollars. These units are considered to represent the nominal value of $10 (e.g. ten dollars = one hour&#8217;s work) and are recorded centrally.</font></p>
           20  +
           21  +<p><font size="2">5. Only the account holder can authorize the transfer of units from their   account to that of another.</font></p>
           22  +
           23  +<p><font size="2">6. No money is deposited or issued. Members may engage in any transaction entirely in time dollars, or on a part cash, part Time Dollar bases, but only time dollars are recorded on the Fourth Corner Exchange system.</font></p>
           24  +
           25  +<p><font size="2">7. All accounts start at zero. Members are not obliged to be in receipt of   any credit before issuing another member with credit from their account, subject to any limit that may be set by the management group from time to time.</font></p>
           26  +
           27  +<p><font size="2">8. No member is obliged to accept any particularly invitation to trade, or to engage in any transaction whatsoever with other members. On leaving the Fourth Corner Exchange however, members with commitments outstanding are obliged to balance their account.</font></p>
           28  +
           29  +<p><font size="2">9. Any member is entitled to know the balance and turnover of another member&#8217;s account. The management group may also decide from time to time to publish the balances and turnovers of all accounts for members to view.</font></p>
           30  +
           31  +<p><font size="2">10. No interest is charged or paid on balances. The management group is authorized to charge joining or renewal fees in time dollars on a cost-of-service basis as the situation requires, and to levy service charges on member's accounts at rates assessed in consultation with the membership or advisory group.</font></p>
           32  +
           33  +<p><font size="2">11. The Fourth Corner Exchange system administrators may decline to record   an account or directory entry considered inappropriate for legal or other reasons.</font></p>
           34  +
           35  +<p><font size="2">12. No warranty or undertaking as to the value, condition or quality of services or items exchanged is expressed or implied by virtue of the introduction of members to each other. Fourth Corner Exchange publishes a list of the resources and services made available to members but cannot be held responsible for the actual goods and services offered.</font></p>
           36  +
           37  +<p><font size="2">13. Members have the right and are encouraged to attend any meeting of the management group and to participate in decision making. Members have a right of appeal to the advisory group on all management decisions.</font></p>
           38  +
           39  +<p><font size="2">14. The management group may act on behalf of members in seeking explanation   or satisfaction from a person whose activity is considered to be contrary to the interests of the membership. The management group, in consultation with the advisory group, may suspend membership in the case of delinquent accounts and as a last resort may remove members from the system. The management group may also reserve the right to deny membership to an applicant in exceptional circumstances at their discretion.</font></p>
           40  +
           41  +<p><font size="2">15. Membership in Fourth Corner Exchange implies acceptance of the conditions  of this agreement.</font><br></p>
           42  +
           43  +<p><font size="2">16. This agreement may be updated, changed or modified at the discretion of the management group.</font><br></p>
           44  +
           45  +
           46  +<?
           47  +
           48  +print $p->MakePageFooter();
           49  +
           50  +?>

Added bdt/info/amusingstory.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "An Amusing Story";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +<p>An American businessman was at the pier of a small coastal Mexican village when a small boat with just one fisherman docked. Inside the small boat were several large yellowfin tuna.</p>
           14  +
           15  +<p>The American complimented the Mexican on the quality of his fish and asked how long it took to catch them. The Mexican replied, "only a little while." The American then asked why didnt he stay out longer and catch more fish? The Mexican said he had enough to support his familys immediate needs.</p>
           16  +
           17  +<p>The American then asked, "But what do you do with the rest of your time?" The Mexican fisherman said, "I sleep late, fish a little, play with my children, take siesta with my wife, Maria, stroll into the village each evening where I sip wine and play guitar with my amigos. I have a full and busy life, senor."</p>
           18  +
           19  +<p>The American scoffed, "I am a Harvard MBA and could help you. You should spend more time fishing and with the proceeds buy a bigger boat, with the proceeds from the bigger boat you could buy several boats, eventually you would have a fleet of fishing boats. Instead of selling your catch to a middleman you would sell directly to the processor, eventually opening your own cannery. You would control the product, processing and distribution. You would need to leave this small coastal fishing village and move to Mexico City, then LA and eventually NYC where you will run your expanding enterprise."</p>
           20  +
           21  +<p>The Mexican fisherman asked, "But senor, how long will this all take?"</p>
           22  +
           23  +<p>To which the American replied, "15 or 20 years."</p>
           24  +
           25  +<p>"But what then, senor?"</p>
           26  +
           27  +<p>The American laughed and said, "thats the best part. When the time is right you would announce an IPO and sell your company stock to the public and become very rich, you would make millions."</p>
           28  +
           29  +<p>"Millions, senor? Then what?"</p>
           30  +
           31  +<p>The American said, "Then you would retire. Move to a small coastal village where you would sleep late, fish a little, play with your kids, take siesta with your wife, stroll to the village in the evenings where you could sip wine and play your guitar with your amigos."</p>
           32  +
           33  +<p><center>~from <a href="http://www.geocities.com/newlibertyvillage/earthstar/nothinnext.htm">http://www.geocities.com/newlibertyvillage/earthstar/nothinnext.htm</a>~</center></p>
           34  +
           35  +<a href="more.php"><font size="2">Back</font></a><br>
           36  +
           37  +<?
           38  +
           39  +print $p->MakePageFooter();
           40  +
           41  +?>
           42  +
           43  +

Added bdt/info/como_funciona.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "¿Cómo funciona un Banco de Tiempo?";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +<ul>
           13  +<li><strong><a href='que_es.php'>¿Qué es un banco de tiempo?</a><br><br></strong></li>
           14  +<li><strong><a href='tipos_de_intercambio.php'>Tipos de intercambio</a><br><br></strong></li>
           15  +<li><strong><a href='condiciones_de_uso.php'>Condiciones de uso</a><br><br></strong></li>
           16  +</ul>
           17  +<p>El dinero de tiempo es una nueva moneda para proporcionar una solución a los recortes masivos del gasto público en materia de bienestar social, pero sin recurrir a la intervención estatal de la economía, sino al contrario, a partir de la libertad de acción económica. </p>
           18  +<p>Plantea que el dinero convencional actualmente no es suficiente para arreglar todos lo problemas que enfrentan las sociedades. La idea entonces es crear un nuevo tipo de dinero para pagar a la gente por lo que se necesita hacer, valorando las contribuciones por igual y sacándole provecho a las habilidades de las personas.</p>
           19  +<p>Los créditos de tiempo son depositados en un banco del tiempo. Pueden ser sacados en cualquier momento y gastado en un gran rango de servicios y oportunidades ofrecidas por los demás usuarios (también el propio banco del tiempo actúa como un usuario ofreciendo y demandando servicios de otros usuarios). </p>
           20  +<p>Estos planes se denominan actualmente bancos de tiempo, y se promueven como una herramienta de regeneración de la comunidad.</p>
           21  +<p>Las habilidades, necesidades y disponibilidad de todos los usuarios están almacenadas en el ordenador del banco de tiempo de forma confidencial y así cualquier necesidad puede ser cubierta por la persona adecuada. </p>
           22  +<p>El software de bancos de tiempo graba y cuenta todas las transacciones hechas entre usuarios e imprime los detalles de todas las cuentas.</p>
           23  +<p>Cuanto mayor crédito de tiempo circule y cuanta más gente compartan su tiempo y sus talentos entre ellos más rica se convertirá la comunidad. Y mayor fuerza se empleará en el cambio social ya que todo el mundo tendría la oportunidad de ser un dador y un receptor y convertirse así en un miembro productivo de la comunidad. </p>
           24  +<p>Transcurrido un tiempo redes informales de confianza y soporte evolucionan y actúan como una forma de familia extendida – conectando a la gente y respetando su autonomía.</p>
           25  +<p>Todos los intercambios que supongan algún ingrediente, material… la persona que demanda el servicio es quien debe suministrarlo (ingredientes en los casos de cocina…)</p>
           26  +
           27  +
           28  +<?
           29  +
           30  +print $p->MakePageFooter();
           31  +
           32  +?>
           33  +

Added bdt/info/condiciones_de_uso.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "Condiciones de Uso";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +<ul>
           13  +<li><strong><a href='que_es.php'>¿Qué es un banco de tiempo?</a><br><br></strong></li>
           14  +<li><strong><a href='como_funciona.php'>¿Cómo funciona un banco de tiempo?</a><br><br></strong></li>
           15  +<li><strong><a href='tipos_de_intercambio.php'>Tipos de intercambio</a><br><br></strong></li>
           16  +</ul>
           17  +<br><b><p>Responsabilidad: </p></b>
           18  +<p>EL Banco del Tiempo de Konekta solo refiere los usuarios que dicen poder ofrecer un servicio. EL Banco del Tiempo de konekta no puede asegurar el rendimiento de ninguno de los usuarios del Banco del Tiempo por lo que nunca será el Banco del Tiempo de konekta responsable por ninguna lesión o daño a la propiedad experimentados durante las transacciones.</p> 
           19  +<p>EL Banco del Tiempo de Konekta ofrece en su herramienta informática formas de conocer las experiencias que todos los usuarios han tenido mientras ofrecían servicios a otros usuarios del banco del tiempo.  </p> 
           20  +<br><p><b>Limitaciones: </b></p>
           21  +<p>Los servicios no están garantizados y puede haber situaciones cuando un proveedor de un servicio no llena las expectativas del que lo recibe. Pedimos la apreciación del esfuerzo que cada uno pone y esto es lo que hace que el Banco del Tiempo funcione.</p> 
           22  +<p>Si hubiera un problema real con el servicio recibido el Banco del Tiempo de Konekta ofrece en su herramienta informática formas de conocer las experiencias que todos los usuarios han tenido mientras ofrecían servicios a otros usuarios del banco del tiempo. El Banco de Tiempo de Konekta mediará dentro de sus capacidades en los conflictos entre usuarios que no se hayan podido arreglar y sus decisiones siempre serán finales y sin posibilidad de apelación. Si hubiera acciones irregulares el Banco del Tiempo de Konekta podrá sancionar a los usuarios, desde obligarles a devolver el crédito obtenido hasta la expulsión del sistema. </p>
           23  +<br><p><b> Confidencialidad y privacidad: </b></p>
           24  +<p>Uno de los criterios en los que se basa el Banco de Tiempo es en la confianza mutua. Todos los usuarios deben proteger la privacidad y confidencialidad de los otros usuarios. Un usuario puede llegar a ser expulsado de la comunidad por este motivo. La única excepción para compartir información es cuando un usuario sienta que la salud o seguridad de otro usuario está en peligro. </p>
           25  +<br><p> <b>QUE HACER CUANDO QUIERE RECIBIR UN SERVICIO </b></p>
           26  +<p>Para poder dar o recibir un servicio tiene que estar registrado en el Banco de Tiempo de Konekta y haber pasado un proceso de verificación.</p> 
           27  +<p>Póngase en contacto con el Banco de Tiempo tan pronto como le sea posible y acuerde un lugar fecha para recibir el servicio seleccionado. Si deja un mensaje y el usuario no responde en unos días inténtelo de nuevo y si aún no lo logra contacte con el administrador. </p>
           28  +
           29  +
           30  +
           31  +<br><br>
           32  +<b><p>QUE HACER Y QUE NO HACER </p>
           33  +<br><p>Que hacer:   </p></b>
           34  +<p>- Asegúrese de que la otra persona entiende lo que va  hacer antes de que empiece a hacerlo </p>
           35  +<p>- Contacte con el usuario por adelantado si no puede llegar a tiempo a ofrecer el servicio o si debe cancelarlo. </p>
           36  +<p>- El recibidor del servicio se compromete a realizar el pago estipulado lo antes posible </p>
           37  +<p>- Sea paciente y abierto más que crítico. Estamos para compartir y el hecho de aprender a conocernos ya es mucho. </p>
           38  +<p>- Respete los demás, ya sea por religión creencias o pertenencia política. </p>
           39  +<p>- Si solicita un servicio asegúrese de pagar por todos los materiales, partes o ingredientes necesarios. </p>
           40  +<br><p><b>Que no hacer: </b></p>
           41  +<p>- No fume en el lugar de otros usuarios sin su consentimiento. </p>
           42  +<p>- Nunca acepte dinero ni propinas. </p>
           43  +<p>- No use alcohol ni drogas mientras ofrece los servicios. (En el caso de ocurrir, será razón para la expulsión automática) </p>
           44  +<p>- No compre alcohol ni tabaco a otros usuarios. </p>
           45  + 
           46  +
           47  +
           48  +
           49  +<?
           50  +
           51  +print $p->MakePageFooter();
           52  +
           53  +?>
           54  +

Added bdt/info/credits.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = LISTINGS;
            5  +$p->page_title = "Créditos";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +Este sitio está basado en el software libre desarrollado por Calvin Priest para <A HREF="http://sourceforge.net/projects/local-exchange/">Local Exchange</A>.<p>
           14  +
           15  +Se ha encargado de su adaptación Borja Aguirre y Aitor Blázquez. 
           16  +
           17  +<?
           18  +
           19  +print $p->MakePageFooter();
           20  +
           21  +?>

Added bdt/info/history.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "History";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +<img src="../images/history.jpg" width="243" height="206" class="image-right">
           14  +
           15  +      <p>This 1915 view of Bay Street shows the Fair Department Store, built in 
           16  +        early 1890. Charles Cissna, who built the store, is best remembered for 
           17  +        his Cissna script, which he issued during the depression of the 1890's. 
           18  +        The script, issued in amounts from 5&cent; to $5, was accepted by other 
           19  +        merchants, as well as The Fair. The building was destroyed by fire in 
           20  +        1928 and today the site is occupied by the Mount Baker Apartments. Note 
           21  +        the overhead trolley wires.</p>
           22  +
           23  +<p>Bellingham also had a LETS (Local Exchange Trading System) in the early 1990's which ran for a few years. Kulshan Cash was another attempt to start a local currency in Bellingham. Several other Local Currecies have passed through Bellingham and Seattle during the last fifteen years. During the Depression years there were over 1,000 local scrips throughout the USA. They were ordered to close down by FDR in 1933.</p>
           24  +
           25  +<?
           26  +
           27  +print $p->MakePageFooter();
           28  +
           29  +?>

Added bdt/info/how_do_i_join.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "How do I join?";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +<p><b>Everyone who approaches with goodwill is welcome.</b></p>
           14  +
           15  +<p>In order to join Fourth Corner Exchange you must do three things:</p>
           16  +
           17  +<p>1. Attend a <a href="../news.php">New Members Meeting.</a> (No, you cannot just sign-up and start trading.)</p>
           18  +
           19  +<p>2. Read, agree to and sign the <a href="agreement.php">Members Agreement.</a> This is a legally binding agreement and is enforcable in law. Read it carefully.</p>
           20  +
           21  +<p>3. Offer at least one skill in the 
           22  +<a href="http://www.fourthcornerexchange.com/listings.php?type=Offer">Members Directory</a> to other members. Think about what you love doing, not just what you do to earn money. The local currency economies are far more varied, creative and stress-free than conventional money. Have fun.</p>
           23  +
           24  +
           25  +<p>We ask everyone who would like to join to attend a New Member Meeting, so that we can meet you, give you the opportunity to meet other prospective members, explain how we run Fourth Corner Exchange, and give you the opportunity to ask questions that you might have about Time Dollars. Membership forms will be available at the meeting for you to fill out. At this time there is no fee for joining, although in the future we may have a small fee to cover administrative costs.</p>
           26  +
           27  +<p>Still have <a href="../contact.php">questions</a>?
           28  +
           29  +<?
           30  +
           31  +print $p->MakePageFooter();
           32  +
           33  +?>

Added bdt/info/how_does_it_work.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "How does Local Currency Work?";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +<p>The Fourth Corner Exchange is a mutual-credit, time-dollar system. It supports 
           14  +a gift economy which is fundamentally different from a cash economy. The 
           15  +system is based on human capital - your skills and energies - and on trust.</p>
           16  +
           17  +<p>Unlike the cash economy your capital is not restricted to the numbers on your
           18  +bank statement. So long as you have something to offer another person (and
           19  +everyone does), you have capital. Since participants don't need to compete
           20  +for scarce resources, it is a fundamentally cooperative trading endeavor.</p>
           21  +
           22  +<p>The goods and services you can obtain are not limited to a single trading
           23  +partner, as with barter, but rather encompass the offerings of the entire trading
           24  +network. You can see the goods and services currently available in our <a href="http://www.fourthcornerexchange.com/listings.php?type=Offer" target="_blank">Members Directory</a>. You must become a member in order to trade. See <a href="how_do_i_join.php">How Do I Join</a> for information on joining Fourth Corner Exchange.</p>
           25  +
           26  +<p>The possibilities are limited only by your imagination and energy.</p>
           27  +
           28  +<p><a href="what_does_it_do.php"><font size="2">Next: What does Local Currency Do?</font></a></p>
           29  +
           30  +<?
           31  +
           32  +print $p->MakePageFooter();
           33  +
           34  +?>

Added bdt/info/links.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "Links";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +<p><a href="http://www.prosperityuk.com/prosperity/prosperity.html" target="_blank">Money Reform in the UK - <em>Prosperity UK</em></a></p>
           14  +
           15  +<p><a href="http://www.neweconomics.org/gen/" target="_blank">New Economics Foundation [UK]</a></p>
           16  +
           17  +<p><a href="http://www.letslinkuk.org/" target="_blank">LETSlink UK</a></p>
           18  +
           19  +<p><a href="http://www.timedollar.org/" target="_blank">Time Dollar Institute</a></p>
           20  +
           21  +<p><a href="http://www.mtdn.org/" target="_blank">Time Dollars in Maine</a></p>
           22  +
           23  +<p><a href="http://www.schumachersociety.org/frameset_local_currencies.html" target="_blank">The E.F. Schumacher Society</a></p>
           24  +
           25  +<p><a href="http://www.schumachersociety.org/frameset_local_currencies.html" target="_blank">The Schumacher Society Conference in June 2004</a></p>
           26  +
           27  +<p><a href="http://www.northlondonlets.ukf.net/" target="_blank">North London LETS UK (Local Exchange Trading System)</a><center>Francis Ayley is the founder of <a href="http://www.northlondonlets.ukf.net/" target="_blank">North London LETS</a></center></p>
           28  +
           29  +<p><a href="http://www.geoffdavies.com/" target="_blank">Economia - The Book by Geoff Davies</a></p>
           30  +
           31  +<p><a href="http://www.timebanks.co.uk/" target="_blank">Time Banks in the UK</a></p>
           32  +
           33  +<p><a href="http://www.ex.ac.uk/~RDavies/arian/local.html" target="_blank">Local and Interest-Free or Alternative Currencies</a></p>
           34  +
           35  +<p><a href="http://www.lightlink.com/hours/ithacahours/home.html" target="_blank">Ithaca Hours Time Dollars</a></p>
           36  +
           37  +<p><a href="http://www.newciv.org/ncn/moneyteam.html" target="_blank">Alternative Money Systems</a></p>
           38  +
           39  +<?
           40  +
           41  +print $p->MakePageFooter();
           42  +
           43  +?>

Added bdt/info/more.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "¿Qué es el Banco de Tiempo?";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +<a href="what_is_local_currency.php"><font size="3">What is a local currency?</font></a>
           14  +
           15  +<ul><li><a href="how_does_it_work.php"><font size="2">How does a local currency work?</font></a></li>
           16  +
           17  +<li><a href="what_does_it_do.php"><font size="2">What does a local currency do?</font></a></li>
           18  +
           19  +<li><a href="how_do_i_join.php"><font size="2">How do I join?</font></a></li></ul>
           20  +
           21  +<a href="what_are_time_dollars.php"><font size="3">What is an 'Hour' or 'Time Dollar'?</font></a>
           22  +
           23  +<p><a href="agreement.php"><font size="3">Members Agreement</font></a></p>
           24  +
           25  +<p><a href="history.php"><font size="3">Local currency history in Whatcom County</font></a></p>
           26  +
           27  +<p><a href="reading.php"><font size="3">Recommended Reading List - Great Books</font></a></p>
           28  +
           29  +<p><a href="links.php"><font size="3">Links to more Information</font></a></p>
           30  +
           31  +<p><a href="amusingstory.php"><font size="3">An Amusing Story - The Harvard MBA and the Mexican Fisherman</font></a></p>
           32  +
           33  +
           34  +<?
           35  +
           36  +print $p->MakePageFooter();
           37  +
           38  +?>

Added bdt/info/que_es.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "¿Qué es un Banco de Tiempo?";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +<ul>
           13  +<li><strong><a href='como_funciona.php'>¿Cómo funciona un banco de tiempo?</a><br><br></strong></li>
           14  +<li><strong><a href='tipos_de_intercambio.php'>Tipos de intercambio</a><br><br></strong></li>
           15  +<li><strong><a href='condiciones_de_uso.php'>Condiciones de uso</a><br><br></strong></li>
           16  +</ul>
           17  +<p>Un banco de tiempo es un sistema de intercambio de servicios por tiempo. </p>
           18  +<p>En el Banco del Tiempo la unidad de intercambio no es el dinero habitual sino una medida de tiempo, en nuestro caso el trabajo por hora. </p>
           19  +<p>Es un sistema de intercambio de servicios por servicios. Propone la ventaja de fomentar las relaciones sociales y la igualdad entre distintos estratos económicos. </p>
           20  +<p>En él el tiempo de cada participante se valora por igual, ya sea que él/ella es un principiante o un experto ampliamente capacitado y es además una herramienta para revitalizar la vida de la comunidad.</p>
           21  +
           22  +<p>La salud de las comunidades depende de la creencia de que las acciones del presente tienen gran significado para el futuro. La más efectiva y eficiente forma de construir capital social es generando reciprocidad de un modo más amplio. De este modo, la confianza y los compromisos cívicos se reproducen automáticamente.</p>
           23  +
           24  +
           25  +<?
           26  +
           27  +print $p->MakePageFooter();
           28  +
           29  +?>
           30  +

Added bdt/info/reading.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "Reading List";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +<h2><center>Alternative Economics</center></h2>
           14  +
           15  +<p><b>The Grip of Death</b> - <cite>Michael Rowbotham [1998]</cite><br>
           16  +<blockquote>A study of modern money, debt slavery and destructive economics. One of the best books ever written about what is wrong with our present money system. <strong>If you never read anything else on alternative economics, read this!</strong></blockquote></p>
           17  +
           18  +<p><b>The Future of Money</b> - <cite>Bernard Lietaer [2001]</cite><br>
           19  +<blockquote>Creating new wealth, work and a wiser world. A great introduction to local currencies worldwide. This book provides a road map for the monetary journey out of a decaying Industrial Age to an Information Age, where greater opportunities become available. It is also a discovery guide to the money system - the way money is created and managed in our society. (This book, published in 2001, is difficult to get hold of because it was originally scheduled to be published USA, but never was. Perhaps Bernard hit too close to the truth in his observations about the present money system we live within.)</blockquote></p>
           20  +
           21  +<p><b>The Soul of Money</b> - <cite>Lynne Twist [2003]</cite><br>
           22  +<blockquote>Transforming your relationship with money and life. This compelling and funamentally liberating book shows us that examining our attitude towards money - earning it, spending it, and giving it away - can offer surprising insight into our lives, our values, and the essence of prosperity.</blockquote></p>
           23  +
           24  +<p><b>Your Money or Your Life</b> - <cite>Joe Dominguez and Vicki Robin [1992]</cite><br>
           25  +<blockquote>Transforming your relationship with money and achieving financial independence. A classic that has transformed many people's lives.</blockquote></p>
           26  +
           27  +<p><b>Interest and Inflation Free Money</b> - <cite>Margrit Kennedy [1995]</cite><br>
           28  +<blockquote>Creating an exchange medium that works for everybody and protects the earth. Interest free money! Think about that.</blockquote></p>
           29  +
           30  +<p><b>LETS Work</b> - <cite>Peter Lang [1994]</cite><br>
           31  +<blockquote>Rebuilding the local economy. An introduction to LETS in the UK.</blockquote></p>
           32  +
           33  +<p><b>Time Dollars</b> - <cite>Edgar Cahn & Jonathan Rowe [1992]</cite><br>
           34  +<blockquote>The new currency that enables Americans to turn their hidden resource - time - into personal security & community renewal. This is what Fourth Corner Exchange is about.</blockquote></p>
           35  +
           36  +<p><b>The Growth Illusion</b> - <cite>Richard Douthwaite [1992]</cite><br>
           37  +<blockquote>How economic growth has enriched the few, impoverished the many and endangered the planet.</blockquote></p>
           38  +
           39  +<p><b>Short Circuit</b> - <cite>Richard Douthwaite [1997]</cite><br>
           40  +<blockquote>Strengthening Local Economies for Security in an Unstable World. Douthwaite is an economist living in Ireland who has thoroughly researched the role of the global market in the dissolution of local communities as well as the role of local currencies in strengthening community. In this book he combines a scholarly and critical review of classical and alternative economics with a "how to" approach to setting up a local currency system. This is an excellent book for those interested in a "thought piece" on modern life as well as those who are seriously interested in exploring and creating alternative economies.</blockquote></p>
           41  +
           42  +<p><b>Secrets of the Temple</b> - <cite>William Greider [1987]</cite><br>
           43  +<blockquote>How the Federal Reserve runs the country.</blockquote></p>
           44  +
           45  +<h2><center>Corporations</center></h2>
           46  +
           47  +<p><b>When Corporations Rule the World</b> - <cite>David Korten [1995]</cite><br>
           48  +<blockquote>A searing indictment of an unjust economic order.</blockquote></p>
           49  +
           50  +<p><b>The Divine Right of Capital</b> - <cite>Marjorie Kelly [2001]</cite><br>
           51  +<blockquote>Dethroning the corporate aristocracy.</blockquote></p>
           52  +
           53  +<p><b>Infectious Greed</b> - <cite>Frank Partnoy [2003]</cite><br>
           54  +<blockquote>How deceit and risk corrupted the financial markets.</blockquote></p>
           55  +
           56  +<h4><center>Corporate Tax Evasion</center></h4>
           57  +
           58  +<p><b>Perfectly Legal</b> - <cite>David Cay Johnston [2003]</cite><br>
           59  +<blockquote>The covert campaign to rig our tax system to benefit the super rich - and cheat everybody else.</blockquote></p>
           60  +
           61  +<p><b>The Cheating of America</b> - <cite>Charles Lewis & Bill Allison [2001]</cite><br>
           62  +<blockquote>How tax avoidance and evasion by the super rich are costing the country billions - and what you can do about it.</blockquote></p>
           63  +
           64  +<h2><center>Democracy & Globalisation</center></h2>
           65  +
           66  +<p><b>Confessions of an Economic Hit Man</b> - <cite>John Perkins [2004]</cite><br>
           67  +<blockquote>"Economic hit men," John Perkins writes, "are highly paid professionals who cheat countries around the globe out of trillions of dollars. Their tools include fraudulent financial reports, rigged elections, payoffs, extortion, sex, and murder." John Perkins should know - he was an economic hit man. His job was to convince countries that are strategically important to the U.S. - from Indonesia to Panama - to accept enormous loans. Saddled with huge debts, these countries came under the control of the United States government, World Bank, and other U.S. dominated aid agencies that acted like loan sharks - dictating repayment terms and bullying foreign governments into submission.</blockquote></p>
           68  +
           69  +<p><font color="red"><b>AMERICA<font color="black"> Beyond Capitalism</b> - <cite>Gar Alperovitz [2005]</cite><br>
           70  +<blockquote>Reclaiming our wealth, our liberty, and our Democracy</blockquote></p>
           71  +
           72  +<p><b>False Dawn</b> - <cite>John Grey [1998]</cite><br>
           73  +<blockquote>"A powerful analysis of the deepening instability of global capitalism. It should be read by all who are concerned about the future of the world economy." - George Soros</blockquote></p>
           74  +
           75  +<h2><center>Older Reference Books</center></h2>
           76  +
           77  +<p><b>The Story of Money</b> - <cite>Norman Angell [1929]</cite><br>
           78  +<blockquote>A poeple's history of money.</blockquote></p>
           79  +
           80  +<p><b>The Banking Crisis of 1933</b> - <cite>Susan Estabrook Kennedy [1973]</cite><br>
           81  +<blockquote>On March 6, 1933 Franklin D. Roosevelt, less than forty-eight hours after becoming president, ordered the suspension of all banking facilities in the United States. How the nation had reached such a desperate situation and how it responded to the banking "holiday" are examined in this book.</blockquote></p>
           82  +
           83  +<p><b>What Everybody Wants to Know About Money</b> - <cite>G.D.H. Cole [1933]</cite><br>
           84  +<blockquote>A textbook on economics by an English economist, that actually explains in straight-forward language what money is, how our money system works, and why it need to be changed.</blockquote></p>
           85  +
           86  +<p><b>The Breakdown of Money</b> - <cite>Christopher Hollis [1934]</cite><br>
           87  +<blockquote>Explains how the banks create money out of nothing and then lend it to us at interest. Hollis has been ignored because he wrote the embarrasing truth about the money system, who creates money and how, and who benefits.</blockquote></p>
           88  +
           89  +<p><b>Stabilizing the Dollar</b> - <cite>Irving Fisher [1919]</cite><br>
           90  +<blockquote>Why America needs a Dollar that hold it's value over time. Something we have never had!</blockquote></p>
           91  +
           92  +<p><b>The Money Illusion</b> - <cite>Irving Fisher [1928]</cite><br><blockquote>How money looses it's value as more is printed. Today this is called inflation and has become an accepted feature of the national money systems. The money in your pocket is worth less every day!</blockquote></p>
           93  +
           94  +<p><b>Booms and Depressions</b> - <cite>Irving Fisher [1932]</cite><br>
           95  +<blockquote>How the money system creates the instability that economists euphemistically call "The Business Cycle" and how unecessarily destructive it is.</blockquote></p>
           96  +
           97  +<p><b>The Debt-Deflation Theory of Great Depressions</b> - <cite>Irving Fisher [1933]</cite><br><blockquote>How unstable money creates economic depressions.</blockquote></p>
           98  +
           99  +<p><b>Inflation</b> - <cite>Irving Fisher [1933]</cite><br><blockquote>What it is, how it is unecessary and how to prevent it. An updated version of "The Money Illusion".</blockquote></p>
          100  +
          101  +<p><b>Stamp Scrip</b> - <cite>Irving Fisher [1933]</cite><br><blockquote>The answer to the Great Depression that FDR turned his back on.</blockquote></p>
          102  +
          103  +<p><b>100% Money</b> - <cite>Irving Fisher [1935]</cite><br><blockquote>How to make sure money  keeps it's value.</blockquote></p>
          104  +
          105  +<p><b>The Science of Money</b> - <cite>Alexander Del Mar [1896]</cite><br>
          106  +<blockquote>An old classic.</blockquote></p>
          107  +
          108  +<?
          109  +
          110  +print $p->MakePageFooter();
          111  +
          112  +?>

Added bdt/info/resources.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SITE_SECTION_OFFER_LIST;
            5  +
            6  +print $p->MakePageHeader();
            7  +
            8  +print $p->MakePageMenu();
            9  +
           10  +?>
           11  +
           12  +<h1><center>Reading List</center></h1>
           13  +
           14  +<h2><center>Alternative Economics</center></h2>
           15  +
           16  +<p><em><b>The Grip of Death</b> - Michael Rowbotham [1998]</em><br>
           17  +<blockquote>A study of modern money, debt slavery and destructive economics. One of the best books ever written about what is wrong with our present money system. <strong>If you never read anything else on alternative economics, read this!</strong></blockquote></p>
           18  +
           19  +<p><em><b>The Future of Money</b> - Bernard Lietaer [2001]</em><br>
           20  +<blockquote>Creating new wealth, work and a wiser world. A great introduction to local currencies worldwide. This book provides a road map for the monetary journey out of a decaying Industrial Age to an Information Age, where greater opportunities become available. It is also a discovery guide to the money system - the way money is created and managed in our society. (This book, published in 2001, is difficult to get hold of because it was originally scheduled to be published USA, but never was. Perhaps Bernard hit too close to the truth in his observations about the present money system we live within.)</blockquote></p>
           21  +
           22  +<p><em><b>The Soul of Money</b> - Lynne Twist [2003]</em><br>
           23  +<blockquote>Transforming your relationship with money and life. This compelling and funamentally liberating book shows us that examining our attitude towards money - earning it, spending it, and giving it away - can offer surprising insight into our lives, our values, and the essence of prosperity.</blockquote></p>
           24  +
           25  +<p><em><b>Your Money or Your Life</b> - Joe Dominguez and Vicki Robin [1992]</em><br>
           26  +<blockquote>Transforming your relationship with money and achieving financial independence. A classic that has transformed many people's lives.</blockquote></p>
           27  +
           28  +<p><em><b>Interest and Inflation Free Money</b> - Margrit Kennedy [1995]</em><br>
           29  +<blockquote>Creating an exchange medium that works for everybody and protects the earth. Interest free money! Think about that.</blockquote></p>
           30  +
           31  +<p><em><b>LETS Work</b> - Peter Lang [1994]</em><br>
           32  +<blockquote>Rebuilding the local economy. An introduction to LETS in the UK.</blockquote></p>
           33  +
           34  +<p><em><b>Time Dollars</b> - Edgar Cahn & Jonathan Rowe [1992]</em><br>
           35  +<blockquote>The new currency that enables Americans to turn their hidden resource - time - into personal security & community renewal. This is what Fourth Corner Exchange is about.</blockquote></p>
           36  +
           37  +<p><em><b>The Growth Illusion</b> - Richard Douthwaite [1992]</em><br>
           38  +<blockquote>How economic growth has enriched the few, impoverished the many and endangered the planet.</blockquote></p>
           39  +
           40  +<p><em><b>Short Circuit</b> - Richard Douthwaite [1997]</em><br>
           41  +<blockquote>Strengthening Local Economies for Security in an Unstable World. Douthwaite is an economist living in Ireland who has thoroughly researched the role of the global market in the dissolution of local communities as well as the role of local currencies in strengthening community. In this book he combines a scholarly and critical review of classical and alternative economics with a "how to" approach to setting up a local currency system. This is an excellent book for those interested in a "thought piece" on modern life as well as those who are seriously interested in exploring and creating alternative economies.</blockquote></p>
           42  +
           43  +<p><em><b>Secrets of the Temple</b> - William Greider [1987]</em><br>
           44  +<blockquote>How the Federal Reserve runs the country.</blockquote></p>
           45  +
           46  +<h2><center>Corporations</center></h2>
           47  +
           48  +<p><em><b>When Corporations Rule the World</b> - David Korten [1995]</em><br>
           49  +<blockquote>A searing indictment of an unjust economic order.</blockquote></p>
           50  +
           51  +<p><em><b>The Divine Right of Capital</b> - Marjorie Kelly [2001]</em><br>
           52  +<blockquote>Dethroning the corporate aristocracy.</blockquote></p>
           53  +
           54  +<p><em><b>Infectious Greed</b> - Frank Partnoy [2003]</em><br>
           55  +<blockquote>How deceit and risk corrupted the financial markets.</blockquote></p>
           56  +
           57  +<h4><center>Corporate Tax Evasion</center></h4>
           58  +
           59  +<p><em><b>Perfectly Legal</b> - David Cay Johnston [2003]</em><br>
           60  +<blockquote>The covert campaign to rig our tax system to benefit the super rich - and cheat everybody else.</blockquote></p>
           61  +
           62  +<p><em><b>The Cheating of America</b> - Charles Lewis & Bill Allison [2001]</em><br>
           63  +<blockquote>How tax avoidance and evasion by the super rich are costing the country billions - and what you can do about it.</blockquote></p>
           64  +
           65  +<h2><center>Democracy & Globalisation</center></h2>
           66  +
           67  +<p><em><b>Confessions of an Economic Hit Man</b> - John Perkins [2004]</em><br>
           68  +<blockquote>"Economic hit men," John Perkins writes, "are highly paid professionals who cheat countries around the globe out of trillions of dollars. Their tools include fraudulent financial reports, rigged elections, payoffs, extortion, sex, and murder." John Perkins should know - he was an economic hit man. His job was to convince countries that are strategically important to the U.S. - from Indonesia to Panama - to accept enormous loans. Saddled with huge debts, these countries came under the control of the United States government, World Bank, and other U.S. dominated aid agencies that acted like loan sharks - dictating repayment terms and bullying foreign governments into submission.</blockquote></p>
           69  +
           70  +<p><em><font color="red"><b>AMERICA<font color="black"> Beyond Capitalism</b> - Gar Alperovitz [2005]</em><br>
           71  +<blockquote>Reclaiming our wealth, our liberty, and our Democracy</blockquote></p>
           72  +
           73  +<p><em><b>False Dawn</b> - John Grey [1998]</em><br>
           74  +<blockquote>"A powerful analysis of the deepening instability of global capitalism. It should be read by all who are concerned about the future of the world economy." - George Soros</blockquote></p>
           75  +
           76  +<h2><center>Older Reference Books</center></h2>
           77  +
           78  +<p><em><b>The Story of Money</b> - Norman Angell [1929]</em><br>
           79  +<blockquote>A poeple's history of money.</blockquote></p>
           80  +
           81  +<p><em><b>The Banking Crisis of 1933</b> - Susan Estabrook Kennedy [1973]</em><br>
           82  +<blockquote>On March 6, 1933 Franklin D. Roosevelt, less than forty-eight hours after becoming president, ordered the suspension of all banking facilities in the United States. How the nation had reached such a desperate situation and how it responded to the banking "holiday" are examined in this book.</blockquote></p>
           83  +
           84  +<p><em><b>What Everybody Wants to Know About Money</b> - G.D.H. Cole [1933]</em><br>
           85  +<blockquote>A textbook on economics by an English economist, that actually explains in straight-forward language what money is, how our money system works, and why it need to be changed.</blockquote></p>
           86  +
           87  +<p><em><b>The Breakdown of Money</b> - Christopher Hollis [1934]</em><br>
           88  +<blockquote>Explains how the banks create money out of nothing and then lend it to us at interest. Hollis has been ignored because he wrote the embarrasing truth about the money system, who creates money and how, and who benefits.</blockquote></p>
           89  +
           90  +<p><em><b>The Science of Money</b> - Alexander Del Mar [1896]</em><br>
           91  +<blockquote>An old classic.</blockquote></p>
           92  +
           93  +<p><em></em><br>
           94  +<blockquote></blockquote></p>
           95  +
           96  +<center><h1>Links</h1></center>
           97  +<p><a href="http://www.prosperityuk.com/prosperity/prosperity.html" target="_blank">Money Reform in the UK - <em>Prosperity UK</em></a></p>
           98  +<p><a href="http://www.neweconomics.org/gen/" target="_blank">New Economics Foundation [UK]</a></p>
           99  +<p><a href="http://www.letslinkuk.org/" target="_blank">LETSlink UK</a></p>
          100  +<p><a href="http://www.timedollar.org/" target="_blank">Time Dollar Institute</a></p>
          101  +<p><a href="http://www.mtdn.org/" target="_blank">Time Dollars in Maine</a></p>
          102  +<p><a href="http://www.schumachersociety.org/frameset_local_currencies.html" target="_blank">The E.F. Schumacher Society</a></p>
          103  +<p><a href="http://www.schumachersociety.org/frameset_local_currencies.html" target="_blank">The Schumacher Society Conference in June 2004</a></p>
          104  +<p><a href="http://www.northlondonlets.ukf.net/" target="_blank">North London LETS UK (Local Exchange Trading System)</a></p>
          105  +<p><a href="http://www.geoffdavies.com/" target="_blank">Economia - The Book by Geoff Davies</a></p>
          106  +<p><a href="http://www.timebanks.co.uk/" target="_blank">Time Banks in the UK</a></p>
          107  +<p><a href="http://www.ex.ac.uk/~RDavies/arian/local.html" target="_blank">Local and Interest-Free or Alternative Currencies</a></p>
          108  +<p><a href="http://www.lightlink.com/hours/ithacahours/home.html" target="_blank">Ithaca Hours Time Dollars</a></p>
          109  +<p><a href="http://www.newciv.org/ncn/moneyteam.html" target="_blank">Alternative Money Systems</a></p>
          110  +
          111  +<?
          112  +
          113  +print $p->MakePageFooter();
          114  +
          115  +?>

Added bdt/info/tipos_de_intercambio.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "Tipos de intercambio";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  + <ul>
           13  +<li><strong><a href='que_es.php'>¿Qué es un banco de tiempo?</a><br><br></strong></li>
           14  +<li><strong><a href='como_funciona.php'>¿Cómo funciona un banco de tiempo?</a><br><br></strong></li>
           15  +<li><strong><a href='condiciones_de_uso.php'>Condiciones de uso</a><br><br></strong></li>
           16  +</ul>
           17  +
           18  +<p><b>Ejercicio físico</b> </p>
           19  +<ul><li>Clases (gimnasia, baile, taichi, fútbol)  </li>
           20  +<li>Entretenimiento o monitorización (partidos de fútbol, ir a correr…)</li>
           21  +<li>Arbitraje de partidos</li></ul>
           22  +
           23  +<p><b>Ocio</b> </p>
           24  +<ul>
           25  +<li>Preparación de fiestas </li>
           26  +<li>Interpretación en eventos o fiestas  </li>
           27  +<li>Juegos de mesa  </li>
           28  +<li>Danzas</li>
           29  +<li>Capoeira</li>
           30  +<li>Paseos en bici</li>
           31  +<li>Excursiones al monte</li>
           32  +<li>Malabares</li>
           33  +</ul>
           34  +
           35  +<p><b>Idiomas</b>  </p>
           36  +<ul><li>Clases de idiomas </li> 
           37  +<li>Conversación en idiomas  </li>
           38  +<li>Traducciones  </li>
           39  +<li>Interprete de idiomas  </li>
           40  +</ul>
           41  +
           42  +<p><b>Informática </b> </p>
           43  +<ul><li>Clases de informática  </li>
           44  +<li>Instalar software </li>
           45  +<li>Reparación y montaje de ordenadores </li>
           46  +<li>Pasar textos a ordenador  </li>
           47  +<li>Montajes fotográficos o videos </li>
           48  +</ul>
           49  +
           50  + 
           51  +<p><b>Belleza</b>  </p>
           52  +<ul><li>Maquillaje  </li>
           53  +<li>Peluquería  </li>
           54  +</ul>
           55  +
           56  +
           57  +<p><b>Bricolaje </b> </p>
           58  +<ul><li>Asesoramiento sobre ahorro de energía  </li>
           59  +<li>Reparaciones de bicis, motos, coches  </li>
           60  +</ul>
           61  +
           62  +<p><b>Arte </b> </p>
           63  +<ul><li>Asesoramiento sobre decoración </li> 
           64  +<li>Teatro  </li>
           65  +<li>Pintura y dibujo  </li>
           66  +<li>Costura  </li>
           67  +</ul>
           68  +
           69  +<p><b>Cocina </b> </p>
           70  +<ul><li>Clases de cocina (tradicional, vegetariana, étnica...)  </li>
           71  +<li>Asesoramiento sobre menús y preparación de recetas  </li>
           72  +<li>Elaboración de comidas (pan, tartas, mermeladas, conservas)  </li>
           73  +<li>Elaboración de comidas para cumpleaños y fiestas </li>
           74  +</ul>
           75  +
           76  +<p><b>Asesoría y orientación </b> </p>
           77  +<ul><li>Asesoramiento para preparación de eventos  </li>
           78  +<li>Asesoramiento en viajes (vacaciones, estudios, negocios...) </li> 
           79  +<li>Asesoramiento para redactar el curriculum vitae  </li>
           80  +<li>Asesoramiento legal  </li>
           81  +<li>Mediación en conflictos  </li>
           82  +<li>Asesoramiento y orientación sobre recursos sociales existentes en Bilbao</li>
           83  +</ul>
           84  +
           85  +<p><b>Atención a personas</b>  </p>
           86  +<ul><li>Lecturas, cuentacuentos  </li>
           87  +<li>Hacer recados  </li>
           88  +<li>Apoyo en mudanzas  </li>
           89  +<li>Escuchar</li>
           90  +</ul>
           91  +
           92  +
           93  +<?
           94  +
           95  +print $p->MakePageFooter();
           96  +
           97  +?>
           98  +

Added bdt/info/what_are_time_dollars.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "What is an 'Hour' or 'Time Dollar'?";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +	Our local currency is based on a unit of time, referred to as either an 'hour' or 'time dollar'.  This seems to beg the question - is all work paid at the same rate?<P>
           14  +
           15  +	Local currency systems are a form of gift economy, and as such are primarily cooperative in nature rather than competitive. In that respect they are naturally more egalitarian than the regular economy.  The Time Dollar Institute uses the term 'co-production' to refer to work done in time-dollar-based systems.  Co-production means that everyone's work is important, and no one's work is to be devalued (for more information see <A HREF="http://www.timedollar.org/cp_four_core_principles.htm">here</A>).<P>
           16  +
           17  +	However, we do not have a strict hour-for-hour equivalence in Fourth Corner.  While much of the work done in the Fourth Corner Exchange is paid at a rate of one hour per hour, much of it is not.  It is common for those offering professional or technical services to charge 2 hours per hour and in rarer cases, 3 hours per hour.  This reflects the general economy and recognizes the investment in skills that professional and technical work require.<P>
           18  +
           19  +	While it is currently unusual in Fourth Corner to charge more than 3 hours per hour, members can and do charge whatever rates they choose.  It is a good idea to ask about someone's rates before making an exchange.  We also recommend if you will be charging more than 3 hours per hour that you make this clear in advance.<P> 
           20  +
           21  +	It also needs to be recognized that overhead costs for some services can be substantial.  Costs such as office rental, travel, research, support personnel, and insurance can make it necessary for someone to charge much higher than 3 hours per hour, even though the actual 'take home' value of that service may only be 2 hours per hour. We encourage members to include overhead in the rates they charge, and to just try to be fair and reasonable in their analysis of those costs.  Sometimes this may mean that a member will charge partly in local currency and partly in national currency (dollars) to cover overhead.
           22  +
           23  +<?
           24  +
           25  +print $p->MakePageFooter();
           26  +
           27  +?>

Added bdt/info/what_does_it_do.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "What Does Local Currency Do?";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +<p>Local currency enriches everyone within the network by connecting people 
           14  +to other people. It allows individuals to utilize talents which may be 
           15  +unrewarded by the cash economy. It builds community by putting a human 
           16  +face on our economic transactions. It is by its very nature local, and 
           17  +thus it promotes a sense of place and is responsive to the people and 
           18  +the needs of this unique corner of the globe.</p>
           19  +
           20  +<p>&nbsp;</p>
           21  +<p><font size="2"><a href="how_do_i_join.php">Next: How do I join?</a></font></p>
           22  +
           23  +<?
           24  +
           25  +print $p->MakePageFooter();
           26  +
           27  +?>

Added bdt/info/what_is_local_currency.php

            1  +<?
            2  +
            3  +include_once("../includes/inc.global.php");
            4  +$p->site_section = SECTION_INFO;
            5  +$p->page_title = "What is Local Currency?";
            6  +
            7  +print $p->MakePageHeader();
            8  +print $p->MakePageMenu();
            9  +print $p->MakePageTitle();
           10  +
           11  +?>
           12  +
           13  +<p>You may have heard it called <strong>scrip</strong>, <strong>hours, a <em>LETS </em> system
           14  +    </strong>or <strong>Time Dollars</strong>. These are just some examples of
           15  +    the many local currency systems working around the world to foster goods
           16  +    and service exchange on the community level.</p>
           17  +
           18  +<p>These complimentary currency systems are now being used all around the world
           19  +  in places like the United Kingdom, Southern Ireland, Germany, France, Australia,
           20  +  Holland, Japan, Mexico, Argentina, Canada and in many communities across the
           21  +  US. The recent expansion of local currency systems reflects a growing grassroots
           22  +  desire to create a more sustainable and humane world.</p>
           23  +<p>Local currencies are not new to the US. During the 1930's many communities
           24  +  created their own scrip in order to build local trading networks connecting
           25  +  people to the goods and services they needed. Scrips were powerful forces for
           26  +  good in those dark economic times when national currency was almost unobtainable
           27  +  for the average person.</p>
           28  +<blockquote>
           29  +
           30  +  <p align="left"><strong>&quot;Time Dollars empower any person to convert personal time into purchasing
           31  +      power - stretching limited cash dollars further and matching unused capacity
           32  +      with unmet demand. They reinforce reciprocity and trust. They reward civic
           33  +      engagement and acts of decency in a way that generates social capital, one
           34  +      hour at a time. They are bringing people together in communities all around
           35  +      the nation.&quot;</strong>
           36  +      </p>
           37  +  </blockquote>
           38  +<div align="right">
           39  +  <p><font size="2">Edgar S. Cahn, CO-Founder of the Antioch School
           40  +      of Law<br>
           41  +      Professor at University of Miami School of Law<br>
           42  +
           43  +      and President of the Time Dollar Institute</font></p>
           44  +
           45  +  <p align="left"><a href="how_does_it_work.php"><font size="2">Next: How does local currency work?</font></a></p>
           46  +</div>
           47  +
           48  +<?
           49  +
           50  +print $p->MakePageFooter();
           51  +
           52  +?>

Added bdt/listing_create.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +
            4  +$cUser->MustBeLoggedOn();
            5  +$p->site_section = LISTINGS;
            6  +if ($_REQUEST["type"] == "Offer") $p->page_title = "Crear una oferta";
            7  +if ($_REQUEST["type"] == "Want") $p->page_title = "Crear una demanda";
            8  +
            9  +include("classes/class.listing.php");
           10  +include("includes/inc.forms.php");
           11  +
           12  +if($cUser->member_id == "ADMIN") {
           13  +	$p->DisplayPage("No puedes crear ofertas o demandas siendo el administrador/a. <p>Puedes crear miembros desde el  <a href=admin_menu.php>Menú de Administración</a>.");	
           14  +	exit;
           15  +}
           16  +
           17  +
           18  +//
           19  +// First, we define the form
           20  +//
           21  +if($_REQUEST["mode"] == "admin") {  // Administrator is creating listing for another member
           22  +	$cUser->MustBeLevel(1);
           23  +	$form->addElement("hidden","mode","admin");
           24  +	if (isset($_REQUEST["member_id"])) {
           25  +		$form->addElement("hidden","member_id", $_REQUEST["member_id"]);
           26  +	} else {
           27  +		$ids = new cMemberGroup;
           28  +		$ids->LoadMemberGroup();
           29  +		$form->addElement("select", "member_id", "¿Para qué miembro?", $ids->MakeIDArray());
           30  +	}
           31  +} else {  // Member is creating offer for his/her self
           32  +	$cUser->MustBeLoggedOn();
           33  +    $cUser->LimitesPasados();
           34  +    /*   if($cUser->balance <= 0 and $_REQUEST["type"] == "Want"){
           35  +       $p->DisplayPage("Tus demandas están desactivadas.");    
           36  +       exit;
           37  +       } */
           38  +	$form->addElement("hidden","member_id", $cUser->member_id);
           39  +	$form->addElement("hidden","mode","self");
           40  +}
           41  +
           42  +$form->addElement('hidden','type',$_REQUEST['type']);
           43  +$title_list = new cTitleList($_REQUEST['type']);
           44  +$form->addElement('text', 'title', 'Título', array('size' => 30, 'maxlength' => 60));
           45  +$form->addRule('title','Introduce un título','required');
           46  +$form->registerRule('verify_not_duplicate','function','verify_not_duplicate');
           47  +$form->addRule('title','Ya tienes una oferta o demanda con ese título','verify_not_duplicate');
           48  +$category_list = new cCategoryList();
           49  +$form->addElement('select', 'category', 'Categoría', $category_list->MakeCategoryArray());
           50  +
           51  +if(USE_RATES)
           52  +	$form->addElement('text', 'rate', 'Puntuación', array('size' => 15, 'maxlength' => 30));
           53  +else
           54  +	$form->addElement('hidden', 'rate');
           55  +
           56  +$form->addElement('static', null, 'Descripción', null);
           57  +$form->addElement('textarea', 'description', null, array('cols'=>45, 'rows'=>5, 'wrap'=>'soft'));
           58  +$form->addElement('html', '<TR><TD></TD><TD><BR></TD></TR>');
           59  +$form->addElement('advcheckbox', 'set_expire_date', '¿Esta oferta o demanda debe expirar automáticamente?');
           60  +$today = getdate();
           61  +$options = array('language'=> 'es', 'format' => 'dFY', 'minYear' => $today['year'],'maxYear' => $today['year']+5, 'addEmptyOption'=>'Y', 'emptyOptionValue'=>'0');
           62  +$form->addElement('date','expire_date', 'Expira', $options);
           63  +$form->registerRule('verify_temporary','function','verify_temporary');
           64  +//$form->addRule('expire_date','Temporary listing box must be checked for expiration','verify_temporary');
           65  +$form->registerRule('verify_future_date','function','verify_future_date');
           66  +$form->addRule('expire_date','Debe ser una fecha futura','verify_future_date');
           67  +$form->registerRule('verify_valid_date','function','verify_valid_date');
           68  +$form->addRule('expire_date','La fecha no es válida','verify_valid_date');
           69  +$form->registerRule('verify_category','function','verify_category');
           70  +$form->addRule('category', 'Escoge una categoría', 'verify_category');
           71  +
           72  +$form->addElement('submit', 'btnSubmit', 'Enviar');
           73  +
           74  +//
           75  +// Then check if we are processing a submission or just displaying the form
           76  +//
           77  +if ($form->validate()) { // Form is validated so processes the data
           78  +   $form->freeze();
           79  + 	$form->process('process_data', false);
           80  +} else {
           81  +   $p->DisplayPage($form->toHtml());  // just display the form
           82  +}
           83  +
           84  +//
           85  +// The form has been submitted with valid data, so process it   
           86  +//
           87  +function process_data ($values) {
           88  +	global $p, $cUser,$cErr;
           89  +	
           90  +	$member = new cMember;
           91  +	
           92  +	if($_REQUEST["mode"] == "admin")
           93  +		$member->LoadMember($_REQUEST["member_id"]);
           94  +	else
           95  +		$member = $cUser;
           96  +		
           97  +	$list = "";
           98  +	$date = $values['expire_date'];
           99  +
          100  +	if($date['F'] == '0' and $date['d'] == '0' and $date['Y'] == '0') {
          101  +		$parms['expire_date'] = null;
          102  +	} else {
          103  +		$expire_date = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          104  +		$parms['expire_date'] = $expire_date;
          105  +	}
          106  +	$parms['title'] = $values['title'];
          107  +	$parms['description'] = $values['description'];
          108  +	$parms['category'] = $values['category'];	
          109  +	$parms['rate'] = $values['rate'];
          110  +	$parms['type'] = $_REQUEST['type'];
          111  +
          112  +	$listing = new cListing($member, $parms);
          113  +	$created = $listing->SaveNewListing();
          114  +
          115  +	if($created) {
          116  +		$list .= "Elemento creado. Crear <A HREF=listing_create.php?type=".$_REQUEST["type"]."&mode=".$_REQUEST["mode"]."&member_id=".$member->member_id.">otro</A>?";	
          117  +	} else {
          118  +		$cErr->Error("Ha habido un error grabando el elemento. Inténtalo más tarde.");
          119  +	}
          120  +    $member->Limites(); 
          121  +   $p->DisplayPage($list);
          122  +}
          123  +//
          124  +// And the following functions verify form data
          125  +//
          126  +
          127  +function verify_future_date ($element_name,$element_value) {
          128  +	global $form;
          129  +
          130  +	$today = getdate();
          131  +	$date = $element_value;
          132  +	
          133  +	if($date['F'] == '0' and $date['d'] == '0' and $date['Y'] == '0')
          134  +		return true;
          135  +	
          136  +	$date_str = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          137  +
          138  +	if (strtotime($date_str) <= strtotime("now")) // date is a past date
          139  +		return false;
          140  +	else
          141  +		return true;
          142  +}
          143  +
          144  +function verify_valid_date ($element_name,$element_value) {
          145  +	$date = $element_value;
          146  +	
          147  +	if($date['F'] == '0' and $date['d'] == '0' and $date['Y'] == '0')
          148  +		return true;
          149  +	return checkdate($date['F'],$date['d'],$date['Y']);
          150  +}
          151  +
          152  +function verify_not_duplicate ($element_name,$element_value) {
          153  +	global $title_list;
          154  +	
          155  +	$titles = $title_list->MakeTitleArray($_REQUEST["member_id"]);
          156  +	
          157  +	foreach ($titles as $title) {
          158  +		if($element_value == $title)
          159  +			return false;
          160  +	}
          161  +	return true;
          162  +}
          163  +
          164  +function verify_category ($z, $category) {
          165  +	if($category == "0")
          166  +		return false;
          167  +	else
          168  +		return true;
          169  +}
          170  +
          171  +?>

Added bdt/listing_delete.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$cUser->MustBeLoggedOn();
            6  +$p->site_section = LISTINGS;
            7  +if ($_REQUEST['type'] == "Offer") $p->page_title = 'Borrar oferta';
            8  +if ($_REQUEST['type'] == "Want") $p->page_title = 'Borrar demanda';
            9  +
           10  +include("classes/class.listing.php");
           11  +include("includes/inc.forms.php");
           12  +
           13  +$message = "";
           14  +
           15  +// First, need to change the default form template so checkbox comes before the label
           16  +$renderer->setElementTemplate('<TR><TD>{element}<!-- BEGIN required --><font> *</font><!-- END required --></FONT><!-- BEGIN error --><font color=RED size=2>   *{error}*</font><br /><!-- END error -->&nbsp;<FONT SIZE=2>{label}</FONT></TD></TR>');  
           17  +
           18  +$form->addElement('hidden','type',$_REQUEST['type']);
           19  +$form->addElement('hidden','mode',$_REQUEST['mode']);
           20  +
           21  +
           22  +$member = new cMember;
           23  +
           24  +if($_REQUEST["mode"] == "admin")
           25  +	$member->LoadMember($_REQUEST["member_id"]);
           26  +else
           27  +    {
           28  +	$member = $cUser;
           29  +    $cUser->LimitesPasados();
           30  +       /* if($cUser->balance <= 0 and $_REQUEST["type"] == "Want"){
           31  +         $p->DisplayPage("Tus demandas están desactivadas.");    
           32  +          exit; */
           33  +         
           34  +    }
           35  +$form->addElement('hidden','member_id',$member->member_id);
           36  +
           37  +$title_list = new cTitleList($_REQUEST['type']);
           38  +$titles = $title_list->MakeTitleArray($member->member_id);
           39  +
           40  +$listings_exist = false;
           41  +
           42  +while (list($key, $title) = each ($titles)) {
           43  +	if($title != "") {
           44  +		$form->addElement('checkbox', $key, $title);
           45  +		$listings_exist=true;
           46  +	}
           47  +}
           48  +
           49  +if ($listings_exist) {
           50  +	$form->addElement('static', null, null);
           51  +	$form->addElement('submit', 'btnSubmit', 'Borrar');
           52  +} else {
           53  +	if($_REQUEST["mode"] == "self")
           54  +		$text = "No tienes ";
           55  +	else
           56  +		$text = $member->PrimaryName() . " no tiene ";
           57  +	
           58  +		if ($_REQUEST['type'] == "Offer") $message = $text ."actualmente ninguna oferta";
           59  +		if ($_REQUEST['type'] == "Want") $message = $text ."actualmente ninguna demanda";
           60  +	
           61  +	
           62  +}
           63  +
           64  +if ($form->validate()) { // Form is validated so processes the data
           65  +   $form->freeze();
           66  + 	$form->process('process_data', false);
           67  +} else {
           68  +   $p->DisplayPage($form->toHtml() ."<BR>". $message);  // just display the form
           69  +}
           70  +
           71  +function process_data ($values) {
           72  +	global $p, $cErr, $titles, $member;
           73  +	$list = "";
           74  +	$deleted = 0;
           75  +	$listing = new cListing;
           76  +	while (list ($key, $value) = each ($values)) {
           77  +		$affected = 0;
           78  +		if(is_numeric($key))  // Two of the values are hidden fields.  Need to skip those.
           79  +			$affected = $listing->DeleteListing($titles[$key],$member->member_id,substr($_REQUEST['type'],0,1));
           80  +
           81  +		$deleted += $affected;
           82  +	}
           83  +	
           84  +	if($deleted == 1) 
           85  +		$list .= "1 elemento borrado.";
           86  +	elseif($deleted > 1)
           87  +		$list .= $deleted . " elementos borrados.";	
           88  +	else
           89  +		$cErr->Error("Hubo un error borrando el elemento. ¿Has comprobado todos los items?");
           90  +	$member->Limites(); 	
           91  +   $p->DisplayPage($list);
           92  +}
           93  +
           94  +?>

Added bdt/listing_detail.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$cUser->MustBeLoggedOn();
            6  +$p->site_section = LISTINGS;
            7  +$p->page_title = $cDB->UnEscTxt($_GET['title']);
            8  +
            9  +include("classes/class.listing.php");
           10  +
           11  +$listing = new cListing();
           12  +$listing->LoadListing($cDB->UnEscTxt($_GET['title']), $_GET['member_id'], substr($_GET['type'],0,1));
           13  +$output = $listing->DisplayListing();
           14  +
           15  +$p->DisplayPage($output);
           16  +
           17  +include("includes/inc.events.php");
           18  +
           19  +?>

Added bdt/listing_edit.php

            1  +<?
            2  +/* MODIFICADO : ABS */
            3  +
            4  +include_once("includes/inc.global.php");  
            5  +
            6  +$cUser->MustBeLoggedOn();
            7  +$p->site_section = LISTINGS;
            8  +$title = $cDB->UnEscTxt($_REQUEST['title']);
            9  +if ($_REQUEST["type"] == "Offer") $p->page_title = "Editar oferta: ".$title;
           10  +if ($_REQUEST["type"] == "Want") $p->page_title = "Editar demanda: ".$title;
           11  +
           12  +
           13  +include("classes/class.listing.php");
           14  +include("includes/inc.forms.php");
           15  +
           16  +
           17  +//
           18  +// First we define the form
           19  +//
           20  +if($_REQUEST["mode"] == "admin") {  // Administrator is creating listing for another member
           21  +    $cUser->MustBeLevel(1);
           22  +    $form->addElement("hidden","mode","admin");
           23  +    $form->addElement("hidden", "member_id", $_REQUEST["member_id"]);
           24  +} else {  // Member is creating offer for his/her self
           25  +    $cUser->MustBeLoggedOn();
           26  +    $cUser->LimitesPasados();   
           27  +       /* if($cUser->balance <= 0 and $_REQUEST["type"] == "Want"){
           28  +        $p->DisplayPage("Tus demandas están desactivadas.");    
           29  +        exit;      */
           30  +        
           31  +    $form->addElement("hidden","member_id", $cUser->member_id);
           32  +    $form->addElement("hidden","mode","self");
           33  +}
           34  +
           35  +$form->addRule('title','Introduce un título','required');
           36  +$form->registerRule('verify_not_duplicate','function','verify_not_duplicate'); 
           37  +//$form->addRule('title','You already have a listing with this title','verify_not_duplicate');
           38  +$category_list = new cCategoryList();
           39  +$form->addElement('select', 'category', 'Categoría', $category_list->MakeCategoryArray());
           40  +
           41  +if(USE_RATES)
           42  +    $form->addElement('text', 'rate', 'Puntuación', array('size' => 15, 'maxlength' => 30));
           43  +else
           44  +    $form->addElement('hidden', 'rate');
           45  +
           46  +$form->addElement('hidden', 'title', $title);
           47  +$form->addElement('hidden','type',$_REQUEST['type']);
           48  +$form->addElement('static', null, 'Descripción', null);
           49  +$form->addElement('textarea', 'description', null, array('cols'=>45, 'rows'=>5, 'wrap'=>'soft'));
           50  +$form->addElement('html', '<TR><TD></TD><TD><BR></TD></TR>');
           51  +$form->addElement('advcheckbox', 'set_expire_date', '¿Esta oferta o demanda debe expirar automáticamente?');
           52  +$today = getdate();
           53  +$options = array('language'=> 'es', 'format' => 'dFY', 'minYear' => $today['year'],'maxYear' =>$today['year']+5, 'addEmptyOption'=>'Y', 'emptyOptionValue'=>'0');
           54  +$form->addElement('date','expire_date', 'Expira el', $options);
           55  +$form->registerRule('verify_future_date','function','verify_future_date');
           56  +$form->addRule('expire_date','Debe ser una fecha futura','verify_future_date');
           57  +$form->registerRule('verify_valid_date','function','verify_valid_date');
           58  +$form->addRule('expire_date','La fecha no es válida','verify_valid_date');
           59  +$form->addElement('advcheckbox', 'set_reactivate_date', '¿Esta oferta o demanda estará temporalmente inactiva?');
           60  +$form->addElement('date','reactivate_date', 'Se reactivará el', $options);
           61  +$form->addRule('reactivate_date','Debe ser una fecha futura','verify_future_date');
           62  +$form->addRule('reactivate_date','La fecha no es válida','verify_valid_date');
           63  +$form->addElement('submit', 'btnSubmit', 'Actualizar');
           64  +
           65  +//
           66  +// Then check if we are processing a submission or just displaying the form
           67  +//
           68  +if ($form->validate()) { // Form is validated so processes the data
           69  +   $form->freeze();
           70  +     $form->process('process_data', false);
           71  +} else {  // Download existing values and display them
           72  +    $listing = new cListing;
           73  +    $listing->LoadListing($title,$_REQUEST['member_id'],substr($_REQUEST['type'],0,1));
           74  +    if ($listing->expire_date) {
           75  +        $temporary_listing = true;
           76  +        $expire_date = array ('d'=>substr($listing->expire_date,8,2),'F'=>date('n',strtotime($listing->expire_date)),'Y'=>substr($listing->expire_date,0,4));  // Using 'n' due to a bug in Quickform
           77  +    } else {
           78  +        $temporary_listing = false;
           79  +        $expire_date = array("d"=>0, "F"=>0, "Y"=>0);
           80  +    }
           81  +    if ($listing->reactivate_date) {
           82  +        $inactive_listing = true;
           83  +        $reactivate_date = array ('d'=>substr($listing->reactivate_date,8,2),'F'=>date('n',strtotime($listing->reactivate_date)),'Y'=>substr($listing->reactivate_date,0,4));  // Using 'n' due to a bug in Quickform
           84  +    } else {
           85  +        $inactive_listing = false;
           86  +        $reactivate_date = array("d"=>0, "F"=>0, "Y"=>0);
           87  +    }
           88  +        
           89  +    $current_values = array ("title"=>$listing->title, "description"=>$listing->description, "rate"=>$listing->rate, "category"=>$listing->category->id, "set_expire_date"=>$temporary_listing, "expire_date"=>$expire_date, "set_reactivate_date"=>$inactive_listing, "reactivate_date"=>$reactivate_date);
           90  +
           91  +    $form->setDefaults($current_values);
           92  +   $p->DisplayPage($form->toHtml());  // just display the form
           93  +}
           94  +
           95  +//
           96  +// The form has been submitted with valid data, so process it   
           97  +//
           98  +function process_data ($values) {
           99  +    global $p, $cUser,$cErr, $cDB, $title;
          100  +    $list = "";
          101  +    
          102  +    $listing = new cListing();
          103  +    $listing->LoadListing($title,$_REQUEST['member_id'],substr($_REQUEST['type'],0,1));  
          104  +    $date = $values['expire_date'];
          105  +    $expire_date = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          106  +    $date = $values['reactivate_date'];
          107  +    $reactivate_date = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          108  +    $today = getdate();
          109  +    if($values['set_expire_date'] and $expire_date != "0/0/0") { 
          110  +        // they checked the box and entered a date, so store the value
          111  +        $listing->expire_date = $expire_date;
          112  +    } elseif ($listing->expire_date==null and $expire_date != "0/0/0") {    
          113  +        // they didn't check it but they changed the date, so store
          114  +        $listing->expire_date = $expire_date;
          115  +    } else { 
          116  +        $listing->expire_date = null;
          117  +        if($listing->status == 'E') // they must have unchecked the box or blanked the date
          118  +            $listing->status = 'A';
          119  +    }    
          120  +    if($values['set_reactivate_date'] and $reactivate_date != "0/0/0") { 
          121  +        // they checked the box and entered a date, so store the value
          122  +        $listing->reactivate_date = $reactivate_date;
          123  +        $listing->status = 'I';
          124  +    } elseif ($listing->reactivate_date==null and $reactivate_date != "0/0/0") {    
          125  +        // they didn't check it but they changed the date, so store
          126  +        $listing->reactivate_date = $reactivate_date;
          127  +        $listing->status = 'I';
          128  +    } else { 
          129  +        $listing->reactivate_date = null;
          130  +        if($listing->status == 'I') // they must have unchecked the box or blanked the date
          131  +            $listing->status = 'A';
          132  +    }    
          133  +    
          134  +    $listing->title = $title;
          135  +    $listing->description = $values['description'];
          136  +    $listing->category->id = $values['category'];    
          137  +    $listing->rate = $values['rate'];
          138  +
          139  +    $created = $listing->SaveListing();
          140  +
          141  +    if($created) {
          142  +        $list .= 'Se han grabado los cambios. Editar <A HREF="listing_to_edit.php?mode='. $_REQUEST['mode'] .'&member_id='. $_REQUEST["member_id"] .'&type='. $_REQUEST["type"] .'">otro</A>?';    
          143  +    } else {
          144  +        $cErr->Error("Ha habido un error grabando el elemento. Inténtalo más tarde.");
          145  +    }
          146  +    
          147  +    // desde aqui
          148  +    $member = new cMember;
          149  +
          150  +if($_REQUEST["mode"] == "admin")
          151  +    $member->LoadMember($_REQUEST["member_id"]);
          152  +else
          153  +    $member = $cUser;
          154  +
          155  +    $member->Limites();
          156  +    //hasta aqui
          157  +    
          158  +   $p->DisplayPage($list);
          159  +}
          160  +
          161  +//
          162  +// And finally, the following functions verify form data
          163  +//
          164  +function verify_future_date ($element_name,$element_value) {
          165  +    global $form, $title;
          166  +
          167  +    $listing = new cListing;
          168  +    $listing->LoadListing($title,$_REQUEST['member_id'],substr($_REQUEST['type'],0,1));
          169  +    if ($listing->status == 'E' and !$form->getElementValue("set_expire_date")) {
          170  +        return true; // They must have unchecked the box to reactivate the listing
          171  +    }
          172  +    
          173  +    $today = getdate();
          174  +    $date = $element_value;
          175  +
          176  +    if($date['F'] == '0' and $date['d'] == '0' and $date['Y'] == '0')
          177  +        return true;
          178  +    
          179  +    $date_str = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          180  +
          181  +    if (strtotime($date_str) <= strtotime("now")) // date is a past date
          182  +        return false;
          183  +    else
          184  +        return true;
          185  +}
          186  +
          187  +function verify_valid_date ($element_name,$element_value) {
          188  +    $date = $element_value;
          189  +    
          190  +    if($date['F'] == '0' and $date['d'] == '0' and $date['Y'] == '0')
          191  +        return true;
          192  +    return checkdate($date['F'],$date['d'],$date['Y']);
          193  +}
          194  +
          195  +function verify_not_duplicate ($element_name,$element_value) {
          196  +    global $cUser;
          197  +    $title_list = new cTitleList();
          198  +    
          199  +    $titles = $title_list->MakeTitleArray($cUser->member_id);
          200  +    
          201  +    foreach ($titles as $title) {
          202  +        if($element_value == $title)
          203  +            return false;
          204  +    }
          205  +    return true;
          206  +}
          207  +
          208  +?>

Added bdt/listing_to_edit.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = LISTINGS;
            4  +// $p->page_title = "Choose the ". $_REQUEST["type"] ." Listing to Edit";
            5  +if ($_REQUEST["type"] == "Offer") $p->page_title = "Escoge la Oferta a editar";
            6  +if ($_REQUEST["type"] == "Want") $p->page_title = "Escoge la Demanda a editar";
            7  +
            8  +
            9  +include("classes/class.listing.php");
           10  +
           11  +$listings = new cTitleList($_GET['type']);
           12  +
           13  +$member = new cMember;
           14  +
           15  +if($_REQUEST["mode"] == "admin") {
           16  +	$cUser->MustBeLevel(1);
           17  +	$member->LoadMember($_REQUEST["member_id"]);
           18  +} else {
           19  +	$cUser->MustBeLoggedOn();
           20  +    $cUser->LimitesPasados();
           21  +	$member = $cUser;
           22  +}
           23  +
           24  +$list = $listings->DisplayMemberListings($member);
           25  +
           26  +if($list == "")
           27  +	$list = "No hay ningún elemento a editar.";
           28  +
           29  +$p->DisplayPage($list);
           30  +
           31  +?>

Added bdt/listings.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = LISTINGS;
            4  +if ($_REQUEST["type"] == "Offer") $p->page_title = "Lista de Ofertas";
            5  +if ($_REQUEST["type"] == "Want") $p->page_title = "Lista de Demandas";
            6  +
            7  +include("classes/class.listing.php");
            8  +include("includes/inc.forms.php");
            9  +
           10  +$form->addElement("hidden","type", $_REQUEST["type"]);
           11  +$form->addElement("static", null, "Selecciona la categoría y la franja de tiempo que quieres consultar y después pulsa Continuar; para ver todos los listados, simplemente pulsa Continuar. <br>Si quieres imprimir o bajar a tu ordenador el directorio completo, pulsa <A HREF=directory.php>aquí</A>.<br>Y si quieres añadir alguna nueva oferta o demanda, pulsa <A HREF=listings_menu.php>aquí</A>", null);
           12  +$form->addElement("static", null, null, null);
           13  +$category_list = new cCategoryList();
           14  +$categories = $category_list->MakeCategoryArray(ACTIVE, substr($_REQUEST["type"],0,1));
           15  +$categories[0] = "(Todas las categorías)";
           16  +$form->addElement("select", "category", "Según la categoría", $categories);
           17  +$text = "Propuesto hace menos de ";
           18  +$form->addElement("select", "timeframe", "Según el tiempo", array("0"=>"(Todos los listados)", "3"=>$text ."3 días", "7"=>$text ."una semana", "14"=>$text ."2 semanas", "30"=>$text ."un mes", "90"=>$text ."3 meses"));
           19  +$form->addElement("static", null, null, null);
           20  +$form->addElement("submit", "btnSubmit", "Continuar");
           21  +
           22  +//$form->registerRule('verify_selection','function','verify_selection');
           23  +//$form->addRule('category', 'Choose a category', 'verify_selection');
           24  +
           25  +if ($form->validate()) { // Form is validated so processes the data
           26  +   $form->freeze();
           27  + 	$form->process("process_data", false);
           28  +} else {  // Display the form
           29  +	$p->DisplayPage($form->toHtml());
           30  +}
           31  +
           32  +function process_data ($values) {
           33  +	global $p;
           34  +
           35  +	header("location:http://".HTTP_BASE."/listings_found.php?type=".$_REQUEST["type"]."&category=".$values["category"]."&timeframe=".$_REQUEST["timeframe"]);
           36  +	exit;
           37  +}
           38  +
           39  +function verify_selection ($z, $selection) {
           40  +	if($selection == "0")
           41  +		return false;
           42  +	else
           43  +		return true;
           44  +}
           45  +
           46  +
           47  +?>

Added bdt/listings_create.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = LISTINGS;
            4  +$p->page_title = "Create Listings";
            5  +
            6  +$cUser->MustBeLoggedOn();
            7  +
            8  +$list = "<STRONG>Offered Listings</STRONG><P>";
            9  +$list .= "<A HREF=listing_create.php?type=Offer><FONT SIZE=2>Create New Offer Listing</FONT></A><BR>";
           10  +$list .= "<A HREF=listing_to_edit.php?type=Offer><FONT SIZE=2>Edit Offered Listings</FONT></A><BR>";
           11  +$list .= "<A HREF=listing_delete.php?type=Offer><FONT SIZE=2>Delete Offered Listings</FONT></A><P>";
           12  +
           13  +$list .= "<STRONG>Wanted Listings</STRONG><P>";
           14  +$list .= "<A HREF=listing_create.php?type=Want><FONT SIZE=2>Create New Want Listing</FONT></A><BR>";
           15  +$list .= "<A HREF=listing_to_edit.php?type=Want><FONT SIZE=2>Edit Wanted Listings</FONT></A><BR>";
           16  +$list .= "<A HREF=listing_delete.php?type=Want><FONT SIZE=2>Delete Wanted Listings</FONT></A><P>";
           17  +
           18  +$p->DisplayPage($list);
           19  +
           20  +?>

Added bdt/listings_found.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +$p->site_section = LISTINGS;
            5  +// $p->page_title = $_REQUEST["type"] ."ed Listings";
            6  +if ($_REQUEST["type"] == "Offer") $p->page_title = "Ofertas";
            7  +if ($_REQUEST["type"] == "Want") $p->page_title = "Demandas";
            8  +
            9  +include_once("classes/class.listing.php");
           10  +
           11  +if($_REQUEST["category"] == "0")
           12  +	$category = "%";
           13  +else
           14  +	$category = $_REQUEST["category"];
           15  +	
           16  +if($_REQUEST["timeframe"] == "0")
           17  +	$since = new cDateTime(LONG_LONG_AGO);
           18  +else
           19  +	$since = new cDateTime("-". $_REQUEST["timeframe"] ." días");
           20  +
           21  +if ($cUser->IsLoggedOn())
           22  +	$show_ids = true;
           23  +else
           24  +	$show_ids = false;
           25  +
           26  +$listings = new cListingGroup($_GET["type"]);
           27  +$listings->LoadListingGroup(null, $category, null, $since->MySQLTime());
           28  +$output = $listings->DisplayListingGroup($show_ids);
           29  +
           30  +$p->DisplayPage($output); 
           31  +
           32  +include("includes/inc.events.php");
           33  +
           34  +?>

Added bdt/listings_menu.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = LISTINGS;
            4  +$p->page_title = "Añadir ofertas y demandas";
            5  +
            6  +$cUser->MustBeLoggedOn();
            7  +
            8  +$list = "<STRONG>Ofertas</STRONG><P>";
            9  +$list .= "<A HREF=listing_create.php?type=Offer&mode=self><FONT SIZE=2>Crear ofertas</FONT></A><BR>";
           10  +$list .= "<A HREF=listing_to_edit.php?type=Offer&mode=self><FONT SIZE=2>Editar ofertas</FONT></A><BR>";
           11  +$list .= "<A HREF=listing_delete.php?type=Offer&mode=self><FONT SIZE=2>Borrar ofertas</FONT></A><P>";
           12  +
           13  +$list .= "<STRONG>Demandas</STRONG><P>";
           14  +$list .= "<A HREF=listing_create.php?type=Want&mode=self><FONT SIZE=2>Crear demandas</FONT></A><BR>";
           15  +$list .= "<A HREF=listing_to_edit.php?type=Want&mode=self><FONT SIZE=2>Editar demandas</FONT></A><BR>";
           16  +$list .= "<A HREF=listing_delete.php?type=Want&mode=self><FONT SIZE=2>Borrar demandas</FONT></A><P>";
           17  +
           18  +$list .= "<STRONG>Otros</STRONG><P>";
           19  +$list .= "<A HREF=holiday.php?mode=self><FONT SIZE=2>Vacaciones</FONT></A><BR>";
           20  +
           21  +$p->DisplayPage($list);
           22  +
           23  +?>

Added bdt/listings_menu_demandas.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = LISTINGS;
            4  +$p->page_title = "Mis demandas";
            5  +
            6  +$cUser->MustBeLoggedOn();
            7  +$cUser->LimitesPasados("Demanda");
            8  +
            9  +// $list .= "<STRONG>Demandas</STRONG><P>";
           10  +$list .= "<A HREF=listing_create.php?type=Want&mode=self><FONT SIZE=2>Crear demandas</FONT></A><BR>";
           11  +$list .= "<A HREF=listing_to_edit.php?type=Want&mode=self><FONT SIZE=2>Editar demandas</FONT></A><BR>";
           12  +$list .= "<A HREF=listing_delete.php?type=Want&mode=self><FONT SIZE=2>Borrar demandas</FONT></A><P>";
           13  +
           14  +$p->DisplayPage($list);
           15  +
           16  +?>

Added bdt/listings_menu_ofertas.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = LISTINGS;
            4  +$p->page_title = "Mis ofertas";
            5  +
            6  +$cUser->MustBeLoggedOn();
            7  +  
            8  +$cUser->LimitesPasados("Oferta");
            9  +// $list = "<STRONG>Ofertas</STRONG><P>";
           10  +$list .= "<A HREF=listing_create.php?type=Offer&mode=self><FONT SIZE=2>Crear ofertas</FONT></A><BR>";
           11  +$list .= "<A HREF=listing_to_edit.php?type=Offer&mode=self><FONT SIZE=2>Editar ofertas</FONT></A><BR>";
           12  +$list .= "<A HREF=listing_delete.php?type=Offer&mode=self><FONT SIZE=2>Borrar ofertas</FONT></A><P>";
           13  +
           14  +$p->DisplayPage($list);
           15  +
           16  +?>

Added bdt/listings_menu_otros.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = LISTINGS;
            4  +$p->page_title = "Otros";
            5  +
            6  +$cUser->MustBeLoggedOn();
            7  +
            8  +// $list .= "<STRONG>Otros</STRONG><P>";
            9  +$list .= "<A HREF=holiday.php?mode=self><FONT SIZE=2>Desactivar mi cuenta por vacaciones</FONT></A><BR>";
           10  +
           11  +$p->DisplayPage($list);
           12  +
           13  +?>

Added bdt/login.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +
            4  +if (isset($_GET["action"]))
            5  +	$action = $_GET["action"];
            6  +
            7  +if (isset($_POST["action"]))
            8  +	$action = $_POST["action"];
            9  +
           10  +if ($action=="logout")
           11  +{
           12  +	$cUser->Logout();
           13  +}
           14  +
           15  +if ($action=="login")
           16  +{
           17  +	if (isset($_POST["location"]))
           18  +		$redir_url = $_POST["location"];
           19  +
           20  +	$user="";
           21  +	$pass="";
           22  +	if (isset($_POST["user"]))
           23  +		$user = $_POST["user"];
           24  +
           25  +	if (isset($_POST["pass"]))
           26  +		$pass = $_POST["pass"];
           27  +
           28  +	if ($user=="" || $pass=="")
           29  +	{
           30  +		if ($user=="")
           31  +		{
           32  +			$cErr->Error("Por favor, introduce un nombre de usuario para Entrar.");
           33  +		} else {
           34  +			$cErr->Error("Por favor, introduce una contraseña válida para esta cuenta. Si has olvidado tu contraseña, puedes pedir una nueva.");
           35  +		}
           36  +
           37  +	} else {
           38  +		$cUser->Login($user,$pass);
           39  +	}
           40  +
           41  +
           42  +}
           43  +
           44  +include("redirect.php");	// if nothing in particular is set, will redirect to home, but this allows the user login
           45  +				// process to potentially set an alternate location.
           46  +
           47  +?>

Added bdt/login_redirect.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = SITE_SECTION_OFFER_LIST;
            4  +
            5  +$output = "Para poder acceder a esta sección, debes tener una cuenta con tu nombre y contraseña. <br><br>Si ya la tienes, accede aquí mismo:<BR><BR><CENTER><DIV STYLE='width=60%; padding: 5px;'><FORM ACTION=login.php METHOD=POST><INPUT TYPE=HIDDEN NAME=action VALUE=login><INPUT TYPE=HIDDEN NAME=location VALUE='".$_SESSION["REQUEST_URI"]."'><TABLE class=NoBorder><TR><TD ALIGN=RIGHT>ID Miembro:</TD><TD ALIGN=LEFT><INPUT TYPE=TEXT SIZE=12 NAME=user></TD></TR><TR><TD ALIGN=RIGHT>Contraseña:</TD><TD ALIGN=LEFT><INPUT TYPE=PASSWORD SIZE=12 NAME=pass></TD></TR></TABLE><DIV align='right'><INPUT TYPE=SUBMIT VALUE='Login'></DIV></FORM></DIV></CENTER><BR>Si no tienes una cuenta, <A HREF=member_self.php>apúntate</A> al Banco de tiempo.<BR>";
            6  +
            7  +$p->DisplayPage($output);
            8  +// NOTA: Cambiado el inicio del form:  <FORM ACTION=".SERVER_PATH_URL."
            9  +?>

Added bdt/media/fotos/mini/nadie.jpg

cannot compute difference between binary files

Added bdt/media/fotos/nadie.jpg

cannot compute difference between binary files

Added bdt/member_choose.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$cUser->MustBeLevel(1);
            4  +
            5  +$p->site_section = ADMINISTRATION;
            6  +$p->page_title = "¿Para qué miembro?";
            7  +
            8  +include("includes/inc.forms.php");
            9  +
           10  +//$form->addElement("header", null, "For which member?");
           11  +//$form->addElement("html", "<TR></TR>");
           12  +$form->addElement("hidden", "action", $_REQUEST["action"]);
           13  +
           14  +if(isset($_REQUEST["get1"])) {
           15  +	$form->addElement("hidden", "get1", $_REQUEST["get1"]);
           16  +	$form->addElement("hidden", "get1val", $_REQUEST["get1val"]);
           17  +}
           18  +
           19  +$ids = new cMemberGroup;
           20  +		
           21  +if(isset($_REQUEST["inactive"]))
           22  +	$ids->LoadMemberGroup(false, true);
           23  +else
           24  +	$ids->LoadMemberGroup();
           25  +	
           26  +$form->addElement("select", "member_id", "Miembro", $ids->MakeIDArray());
           27  +$form->addElement("static", null, null, null);
           28  +$form->addElement('submit', 'btnSubmit', 'Enviar');
           29  +
           30  +if ($form->validate()) { // Form is validated so processes the data
           31  +   $form->freeze();
           32  + 	$form->process("process_data", false);
           33  +} else {  // Display the form
           34  +	$p->DisplayPage($form->toHtml());
           35  +}
           36  +
           37  +function process_data ($values) {
           38  +	global $cUser;
           39  +	
           40  +	if(isset($_REQUEST["get1"]))
           41  +		$get_string = "&". $_REQUEST["get1"] ."=". $_REQUEST["get1val"];
           42  +	else
           43  +		$get_string = "";
           44  +		
           45  +	header("location:http://".HTTP_BASE."/". $_REQUEST["action"] .".php?mode=admin&member_id=".$values["member_id"] . $get_string);
           46  +	exit;	
           47  +}
           48  +
           49  +?>

Added bdt/member_contact_choose.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +$p->site_section = PROFILE;
            4  +$p->page_title="Escoge miembro acompañante";
            5  +
            6  +$cUser->MustBeLoggedOn();
            7  +include("includes/inc.forms.php");
            8  +
            9  +$form->addElement("select", "person_id", "¿Qué miembro acompañante?", $cUser->MakeJointMemberArray($cUser->member_id));
           10  +
           11  +$form->addElement("static", null, null, null);
           12  +$buttons[] = &HTML_QuickForm::createElement('submit', 'btnEdit', 'Editar');
           13  +$buttons[] = &HTML_QuickForm::createElement('submit', 'btnDelete', 'Borrar');
           14  +$form->addGroup($buttons, null, null, '&nbsp;', false);
           15  +
           16  +if ($form->validate()) { // Form is validated so processes the data
           17  +   $form->freeze();
           18  + 	$form->process("process_data", false);
           19  +} else {  // Display the form
           20  +	$p->DisplayPage($form->toHtml());
           21  +}
           22  +
           23  +function process_data ($values) {
           24  +	if(isset($values["btnDelete"])) {
           25  +		header("location:http://".HTTP_BASE."/member_contact_delete.php?mode=self&person_id=". $values["person_id"]);
           26  +		exit;	
           27  +	} else {
           28  +		header("location:http://".HTTP_BASE."/member_contact_edit.php?mode=self&person_id=". $values["person_id"]);
           29  +		exit;	
           30  +	}
           31  +}
           32  +
           33  +?>

Added bdt/member_contact_create.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +//
            6  +//  Todos los archivos que empiezan por 'member contact' están referidos 
            7  +//  a los 'acompañantes', figura que no estamos utilizando en esta versión
            8  +//  del programa. 
            9  +//  Por tanto, estos formularios NO ESTÁN ACTUALIZADOS
           10  +//   REVISA TB LO DEL TELEFONO QUE ESTA CAMBIADO, SE AÑADIO LA FUNCION DE VERIFICACION
           11  +
           12  +
           13  +$p->site_section = SITE_SECTION_OFFER_LIST;
           14  +
           15  +include("includes/inc.forms.php");
           16  +
           17  +//
           18  +// First, we define the form
           19  +//
           20  +
           21  +$form->addElement("header", null, "Añadir acompañante a un/a Asociado/a");
           22  +$form->addElement("html", "<TR></TR>");
           23  +
           24  +if($_REQUEST["mode"] == "admin") {  // Administrator is adding to a member's account
           25  +	$cUser->MustBeLevel(1);
           26  +	$form->addElement("hidden","mode","admin");
           27  +	if(isset($_REQUEST["member_id"])) {
           28  +		$form->addElement("hidden","member_id", $_REQUEST["member_id"]);
           29  +	} else {
           30  +		$ids = new cMemberGroup;
           31  +		$ids->LoadMemberGroup();
           32  +		$form->addElement("select", "member_id", "Escoge el asociado/a al que acompañar", $ids->MakeIDArray());
           33  +	}
           34  +} else {  // Member is adding to own account
           35  +	$cUser->MustBeLoggedOn();
           36  +	$form->addElement("hidden","member_id", $cUser->member_id);
           37  +	$form->addElement("hidden","mode","self");
           38  +}
           39  +
           40  +$form->addElement("text", "first_name", "Nombre", array("size" => 15, "maxlength" => 20));
           41  +$form->addElement("text", "mid_name", "Primer apellido", array("size" => 10, "maxlength" => 20));
           42  +$form->addElement("text", "last_name", "Segundo apellido", array("size" => 20, "maxlength" => 30));
           43  +$form->addElement("static", null, null, null); 
           44  +
           45  +$today=getdate();
           46  +$options = array("language"=> "es", "format" => "dFY", "maxYear"=>$today["year"], "minYear"=>"1880"); 
           47  +$form->addElement("date", "dob", "Fecha de nacimiento", $options);
           48  +//  $form->addElement("text", "mother_mn", "Mother's Maiden Name", array("size" => 20, "maxlength" => 30)); 
           49  +$form->addElement("static", null, null, null);
           50  +$form->addElement("select","directory_list", "¿Mostrar datos de esta persona en el Directorio?", array("Y"=>"Si", "N"=>"No"));
           51  +$form->addElement("text", "email", "Email", array("size" => 25, "maxlength" => 40));
           52  +$form->addElement("text", "phone1", "Teléfono", array("size" => 20));
           53  +$form->addElement("text", "phone2", "Teléfono 2", array("size" => 20));
           54  +//  $form->addElement("text", "fax", "Fax Number", array("size" => 20));
           55  +$form->addElement("static", null, null, null);
           56  +$form->addElement("text", "address_street1", "Dirección", array("size" => 25, "maxlength" => 30));
           57  +// $form->addElement("text", "address_street2", "Address Line 2", array("size" => 25, "maxlength" => 30));
           58  +$form->addElement("text", "address_city", "Ciudad", array("size" => 20, "maxlength" => 30));
           59  +
           60  +// TODO: The State and Country codes should be Select Menus, and choices should be built
           61  +// dynamically using an internet database (if such exists).
           62  +// $form->addElement("text", "address_state_code", STATE_TEXT, array("size" => 2, "maxlength" => 2));
           63  +// $form->addElement("text", "address_post_code", ZIP_TEXT, array("size" => 5, "maxlength" => 6));
           64  +// $form->addElement("text", "address_country", "Country", array("size" => 20, "maxlength" => 30));
           65  +$form->addElement("static", null, null, null);
           66  +$form->addElement('submit', 'btnSubmit', 'Crear contacto');
           67  +
           68  +//
           69  +// Define form rules
           70  +//
           71  +$form->addRule('password', 'Contraseña demasiado corta', 'minlength', 7);
           72  +$form->addRule('first_name', 'Introduce un nombre', 'required');
           73  +$form->addRule('mid_name', 'Introduce un apellido', 'required');
           74  +$form->addRule('address_city', 'Introduce una ciudad', 'required');
           75  +// $form->addRule('address_state_code', 'Enter a state', 'required');
           76  +// $form->addRule('address_post_code', 'Enter a '.ZIP_TEXT, 'required');
           77  +// $form->addRule('address_country', 'Enter a country', 'required');
           78  +
           79  +$form->registerRule('verify_not_future_date','function','verify_not_future_date');
           80  +$form->addRule('dob', 'El nacimiento no puede ser en el futuro', 'verify_not_future_date');
           81  +$form->registerRule('verify_reasonable_dob','function','verify_reasonable_dob');
           82  +$form->addRule('dob', 'Un poco joven, ¿no crees?', 'verify_reasonable_dob');
           83  +$form->registerRule('verify_valid_email','function', 'verify_valid_email');
           84  +$form->addRule('email', 'Email no válido', 'verify_valid_email');
           85  +$form->registerRule('verify_phone_format','function','verify_phone_format');
           86  +$form->addRule('phone1', 'El número de teléfono no es válido', 'verify_phone_format');
           87  +$form->addRule('phone2', 'El número de teléfono no es válido', 'verify_phone_format');
           88  +// $form->addRule('fax', 'Phone format invalid', 'verify_phone_format');
           89  +
           90  +
           91  +//
           92  +// Check if we are processing a submission or just displaying the form
           93  +//
           94  +if ($form->validate()) { // Form is validated so processes the data
           95  +   $form->freeze();
           96  + 	$form->process("process_data", false);
           97  +} else {
           98  +	$today = getdate();
           99  +	$current_date = array("Y"=>$today["year"], "F"=>$today["mon"], "d"=>$today["mday"]);
          100  +	$defaults = array("dob"=>$current_date, "address_state_code"=>DEFAULT_STATE, "address_country"=>DEFAULT_COUNTRY, "directory_list"=>"Y");
          101  +	$form->setDefaults($defaults);
          102  +   $p->DisplayPage($form->toHtml());  // just display the form
          103  +}
          104  +
          105  +//
          106  +// The form has been submitted with valid data, so process it   
          107  +//
          108  +function process_data ($values) {
          109  +	global $p, $cUser,$cErr, $today;
          110  +	$list = "";
          111  +
          112  +	$values['primary_member'] = "N"; 
          113  +
          114  +	$date = $values['dob'];
          115  +	$values['dob'] = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          116  +	if($values['dob'] == $today['year']."/".$today['mon']."/".$today['mday'])
          117  +		$values['dob'] = ""; // if birthdate was left as default, set to null
          118  +	
          119  +	$phone = new cPhone($values['phone1']);
          120  +	$values['phone1_area'] = $phone->area;
          121  +	$values['phone1_number'] = $phone->SevenDigits();
          122  +//	$values['phone1_ext'] = $phone->ext;
          123  +	$phone = new cPhone($values['phone2']);
          124  +	$values['phone2_area'] = $phone->area;
          125  +	$values['phone2_number'] = $phone->SevenDigits();
          126  +//	$values['phone2_ext'] = $phone->ext;	
          127  +//	$phone = new cPhone($values['fax']);
          128  +//  $values['fax_area'] = $phone->area;
          129  +//	$values['fax_number'] = $phone->SevenDigits();
          130  +//	$values['fax_ext'] = $phone->ext;	
          131  +
          132  +	$new_person = new cPerson($values);
          133  +	$created = $new_person->SaveNewPerson();
          134  +	
          135  +	$member = new cMember();
          136  +	$member->LoadMember($_REQUEST["member_id"]);
          137  +	
          138  +	if($created and $member->account_type == "S") {
          139  +		$member->account_type = "J";  // Now it's a Joint account
          140  +		$member->SaveMember();
          141  +	}	
          142  +
          143  +	if($created) {
          144  +		$list .= "Asociado/a acompañante creado. ¿Quieres <A HREF=member_contact_create.php?mode=". $_REQUEST["mode"] ."&member_id=". $values["member_id"] .">añadir otra persona</A>?<P>";
          145  +	} else {
          146  +		$cErr->Error("Hubo un error guardando los datos de la persona. Inténtalo más tarde.");
          147  +	}
          148  +   $p->DisplayPage($list);
          149  +}
          150  +//
          151  +// The following functions verify form data
          152  +//
          153  +
          154  +// TODO: All my validation functions should go into a new cFormValidation class
          155  +		
          156  +function verify_reasonable_dob($element_name,$element_value) {
          157  +	global $today;
          158  +	$date = $element_value;
          159  +	$date_str = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          160  +//	echo $date_str ."=".$today['year']."/".$today['mon']."/".$today['mday'];
          161  +
          162  +	if ($date_str == $today['year']."/".$today['mon']."/".$today['mday']) 
          163  +		// date wasn't changed by user, so no need to verify it
          164  +		return true;
          165  +	elseif ($today['year'] - $date['Y'] < 17)  // A little young to be trading, presumably a mistake
          166  +		return false;
          167  +	else
          168  +		return true;
          169  +}
          170  +
          171  +function verify_not_future_date ($element_name,$element_value) {
          172  +	$date = $element_value;
          173  +	$date_str = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          174  +
          175  +	if (strtotime($date_str) > strtotime("now"))
          176  +		return false;
          177  +	else
          178  +		return true;
          179  +}
          180  +
          181  +// TODO: This simplistic function should ultimately be replaced by this class method on Pear:
          182  +// 		http://pear.php.net/manual/en/package.mail.mail-rfc822.intro.php
          183  +function verify_valid_email ($element_name,$element_value) {
          184  +	if ($element_value=="")
          185  +		return true;		// Currently not planning to require this field
          186  +	if (strstr($element_value,"@") and strstr($element_value,"."))
          187  +		return true;	
          188  +	else
          189  +		return false;
          190  +	
          191  +}
          192  +
          193  +function verify_phone_format ($element_name,$element_value) {
          194  +    $phone = new cPhone($element_value);
          195  +    
          196  +    if(substr($phone->area,0,1)== "9" or substr($phone->area,0,1)=="6") 
          197  +        return true;
          198  +    else
          199  +        return false;
          200  +}
          201  +
          202  +?>

Added bdt/member_contact_delete.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +
            4  +//
            5  +//  Todos los archivos que empiezan por 'member contact' están referidos 
            6  +//  a los 'acompañantes', figura que no estamos utilizando en esta versión
            7  +//  del programa. 
            8  +//  Por tanto, estos formularios NO ESTÁN ACTUALIZADOS
            9  +//
           10  +
           11  +$p->site_section = PROFILE;
           12  +$p->page_title = "Borrar asociado/a acompañante";
           13  +
           14  +include("includes/inc.forms.php");
           15  +
           16  +if($_REQUEST["mode"] == "admin") {
           17  +	$cUser->MustBeLevel(1);
           18  +	$form->addElement("hidden","mode","admin");
           19  +} else {
           20  +	$cUser->MustBeLoggedOn();
           21  +	$form->addElement("hidden","mode","self");
           22  +}
           23  +
           24  +$person = new cPerson;
           25  +$person->LoadPerson($_REQUEST["person_id"]);
           26  +
           27  +$form->addElement("hidden", "person_id", $_REQUEST["person_id"]);
           28  +$form->addElement("static", null, "¿Estás seguro de borrar a ". $person->Name() ." permanentemente?", null);
           29  +$form->addElement("static",null,null);
           30  +$form->addElement('submit', 'btnSubmit', 'Borrar');
           31  +
           32  +if ($form->validate()) { // Form is validated so processes the data
           33  +   $form->freeze();
           34  + 	$form->process("process_data", false);
           35  +} else {  // Display the form
           36  +	$p->DisplayPage($form->toHtml());
           37  +}
           38  +
           39  +function process_data ($values) {
           40  +	global $p, $person;
           41  +	
           42  +	if($person->DeletePerson())
           43  +		$output = "Asociado/a acompañante borrada.";
           44  +	else
           45  +		$output = "Hubo un error borrando a esta persona.";
           46  +		
           47  +	$p->DisplayPage($output);
           48  +}
           49  +
           50  +?>

Added bdt/member_contact_edit.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +//
            6  +//  Todos los archivos que empiezan por 'member contact' están referidos 
            7  +//  a los 'acompañantes', figura que no estamos utilizando en esta versión
            8  +//  del programa. 
            9  +//  Por tanto, estos formularios NO ESTÁN ACTUALIZADOS
           10  +//
           11  +
           12  +
           13  +$p->site_section = SITE_SECTION_OFFER_LIST;
           14  +
           15  +include("includes/inc.forms.php");
           16  +
           17  +//
           18  +// First, we define the form
           19  +//
           20  +if($_REQUEST["mode"] == "admin") {  // Administrator is editing a member's account
           21  +	$cUser->MustBeLevel(1);
           22  +	$form->addElement("hidden","mode","admin");
           23  +	$form->addElement("hidden","member_id",$_REQUEST["member_id"]);		
           24  +} else {  // Member is editing own account
           25  +	$cUser->MustBeLoggedOn();
           26  +	$cUser->VerifyPersonInAccount($_REQUEST["person_id"]); // Make sure hacker didn't change URL
           27  +	$form->addElement("hidden","member_id", $cUser->member_id);
           28  +	$form->addElement("hidden","mode","self");
           29  +}
           30  +
           31  +$person = new cPerson;
           32  +$person->LoadPerson($_REQUEST["person_id"]);
           33  +$form->addElement("header", null, "Editar acompañante " . $person->first_name . " " . $person->mid_name);
           34  +$form->addElement("html", "<TR></TR>");
           35  +
           36  +$form->addElement("hidden","person_id",$_REQUEST["person_id"]);
           37  +$form->addElement("text", "first_name", "Nombre", array("size" => 15, "maxlength" => 20));
           38  +$form->addElement("text", "mid_name", "Primer Apellido", array("size" => 10, "maxlength" => 20));
           39  +$form->addElement("text", "last_name", "Segundo Apellido", array("size" => 20, "maxlength" => 30));
           40  +$form->addElement("static", null, null, null);
           41  +
           42  +if ($_REQUEST["mode"] == "admin") {
           43  +	$today = getdate();
           44  +	$options = array("language"=> "es", "format" => "dFY", "maxYear"=>$today["year"], "minYear"=>"1880");
           45  +	$form->addElement("date", "dob", "Fecha de nacimiento", $options);
           46  +//	$form->addElement("text", "mother_mn", "Mother's Maiden Name", array("size" => 20, "maxlength" => 30)); 
           47  +	$form->addElement("static", null, null, null);
           48  +}
           49  +
           50  +$form->addElement("select","directory_list", "¿Mostrar datos de esta persona en el Directorio?", array("Y"=>"Yes", "N"=>"No"));
           51  +$form->addElement("text", "email", "Email", array("size" => 25, "maxlength" => 40));
           52  +$form->addElement("text", "phone1", "Teléfono", array("size" => 20));
           53  +$form->addElement("text", "phone2", "Teléfono 2", array("size" => 20));
           54  +// $form->addElement("text", "fax", "Fax Number", array("size" => 20));
           55  +$form->addElement("static", null, null, null);
           56  +$form->addElement("text", "address_street1", "Dirección", array("size" => 25, "maxlength" => 30));
           57  +// $form->addElement("text", "address_street2", "Address Line 2", array("size" => 25, "maxlength" => 30));
           58  +$form->addElement("text", "address_city", "Ciudad", array("size" => 20, "maxlength" => 30));
           59  +
           60  +// TODO: The State and Country codes should be Select Menus, and choices should be built
           61  +// dynamically using an internet database (if such exists).
           62  +// $form->addElement("text", "address_state_code", STATE_TEXT, array("size" => 2, "maxlength" => 2));
           63  +// $form->addElement("text", "address_post_code", ZIP_TEXT, array("size" => 5, "maxlength" => 6));
           64  +// $form->addElement("text", "address_country", "Country", array("size" => 20, "maxlength" => 30));
           65  +
           66  +// TODO: Add the ability to make this person the primary member on the account
           67  +
           68  +$form->addElement("static", null, null, null);
           69  +$form->addElement('submit', 'btnSubmit', 'Enviar');
           70  +
           71  +//
           72  +// Define form rules
           73  +//
           74  +$form->addRule('password', 'Contraseña demasiado corta', 'minlength', 7);
           75  +$form->addRule('first_name', 'Introduce un nombre', 'required');
           76  +$form->addRule('mid_name', 'Introduce un apellido', 'required');
           77  +$form->addRule('address_city', 'Introduce una ciudad', 'required');
           78  +// $form->addRule('address_state_code', 'Enter a state', 'required');
           79  +// $form->addRule('address_post_code', 'Enter a '.ZIP_TEXT, 'required');
           80  +// $form->addRule('address_country', 'Enter a country', 'required');
           81  +
           82  +$form->registerRule('verify_not_future_date','function','verify_not_future_date');
           83  +$form->addRule('dob', 'El nacimiento no puede ser en el futuro', 'verify_not_future_date');
           84  +$form->registerRule('verify_reasonable_dob','function','verify_reasonable_dob');
           85  +$form->addRule('dob', 'Un poco joven, ¿no crees?', 'verify_reasonable_dob');
           86  +$form->registerRule('verify_valid_email','function', 'verify_valid_email');
           87  +$form->addRule('email', 'Email no válido', 'verify_valid_email');
           88  +$form->registerRule('verify_phone_format','function','verify_phone_format');
           89  +$form->addRule('phone1', 'El número de teléfono no es válido', 'verify_phone_format');
           90  +$form->addRule('phone2', 'El número de teléfono no es válido', 'verify_phone_format');
           91  +// $form->addRule('fax', 'Phone format invalid', 'verify_phone_format');
           92  +
           93  +
           94  +//
           95  +// Check if we are processing a submission or just displaying the form
           96  +//
           97  +if ($form->validate()) { // Form is validated so processes the data
           98  +   $form->freeze();
           99  + 	$form->process("process_data", false);
          100  +} else {  // Otherwise we need to load the existing values			
          101  +	$current_values = array ("first_name"=>$person->first_name, "mid_name"=>$person->mid_name, "last_name"=>$person->last_name, "directory_list"=>$person->directory_list, "email"=>$person->email, "phone1"=>$person->DisplayPhone(1), "phone2"=>$person->DisplayPhone(2), "fax"=>$person->DisplayPhone("fax"), "address_street1"=>$person->address_street1, "address_street2"=>$person->address_street2, "address_city"=>$person->address_city, "address_state_code"=>$person->address_state_code, "address_post_code"=>$person->address_post_code, "address_country"=>$person->address_country);
          102  +	
          103  +	if($_REQUEST["mode"] == "admin") {  // Load defaults for extra fields visible by administrators
          104  +		$current_values["mother_mn"] = $person->mother_mn;
          105  +		
          106  +		if ($person->dob) {		
          107  +			$current_values["dob"] = array ('d'=>substr($person->dob,8,2),'F'=>date('n',strtotime($person->dob)),'Y'=>substr($person->dob,0,4));  // Using 'n' due to a bug in Quickform
          108  +		} else { // If date of birth was left empty originally, display default date
          109  +			$today = getdate();
          110  +			$current_values["dob"] = array ('d'=>$today['mday'],'F'=>$today['mon'],'Y'=>$today['year']);
          111  +		}		
          112  +	}	
          113  +		
          114  +	$form->setDefaults($current_values);
          115  +   $p->DisplayPage($form->toHtml());  // display the form
          116  +}
          117  +
          118  +//
          119  +// The form has been submitted with valid data, so process it   
          120  +//
          121  +function process_data ($values) {
          122  +	global $p, $cUser, $cErr, $person, $today;
          123  +	$list = "";
          124  +
          125  +	$person->first_name = $values["first_name"];
          126  +	$person->mid_name = $values["mid_name"];
          127  +	$person->last_name = $values["last_name"];
          128  +	$person->directory_list = $values["directory_list"];
          129  +	$person->email = $values["email"];
          130  +	$person->address_street1 = $values["address_street1"];
          131  +	$person->address_street2 = $values["address_street2"];
          132  +	$person->address_city = $values["address_city"];
          133  +	$person->address_state_code = $values["address_state_code"];
          134  +	$person->address_post_code = $values["address_post_code"];
          135  +	$person->address_country = $values["address_country"];	
          136  +
          137  +	$phone = new cPhone($values['phone1']);
          138  +	$person->phone1_area = $phone->area;
          139  +	$person->phone1_number = $phone->SevenDigits();
          140  +//	$person->phone1_ext = $phone->ext;
          141  +	$phone = new cPhone($values['phone2']);
          142  +	$person->phone2_area = $phone->area;
          143  +	$person->phone2_number = $phone->SevenDigits();
          144  +//	$person->phone2_ext = $phone->ext;	
          145  +//	$phone = new cPhone($values['fax']);
          146  +//	$person->fax_area = $phone->area;
          147  +//	$person->fax_number = $phone->SevenDigits();
          148  +//	$person->fax_ext = $phone->ext;	
          149  +	
          150  +	if($_REQUEST["mode"] == "admin")	{
          151  +		$person->mother_mn = $values["mother_mn"];
          152  +		$date = $values['dob'];
          153  +		$dob = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          154  +//		echo $dob ."=". $today['year']."/".$today['mon']."/".$today['mday'];
          155  +		if($dob != $today['year']."/".$today['mon']."/".$today['mday']) { 
          156  +			$person->dob = $dob; 
          157  +		} // if date left as default (today's date), we don't want to set it
          158  +	} 	
          159  +	
          160  +	if($person->SavePerson()) {
          161  +		$list .= "Cambios guardados.";	 
          162  +	} else {
          163  +		$cErr->Error("Ha habido un error guardando los cambios. Inténtalo más tarde.");
          164  +	}
          165  +   $p->DisplayPage($list);
          166  +}
          167  +//
          168  +// The following functions verify form data
          169  +//
          170  +
          171  +// TODO: All my validation functions should go into a new cFormValidation class
          172  +
          173  +function verify_no_apostraphes_or_backslashes($element_name,$element_value) {
          174  +	if(strstr($element_value,"'") or strstr($element_value,"\\"))
          175  +		return false;
          176  +	else
          177  +		return true;
          178  +}
          179  +
          180  +// TODO: This simplistic function should ultimately be replaced by this class method on Pear:
          181  +// 		http://pear.php.net/manual/en/package.mail.mail-rfc822.intro.php
          182  +function verify_valid_email ($element_name,$element_value) {
          183  +	if ($element_value=="")
          184  +		return true;		// Currently not planning to require this field
          185  +	if (strstr($element_value,"@") and strstr($element_value,"."))
          186  +		return true;	
          187  +	else
          188  +		return false;
          189  +	
          190  +}
          191  +
          192  +function verify_phone_format ($element_name,$element_value) {
          193  +    $phone = new cPhone($element_value);
          194  +    
          195  +    if(substr($phone->area,0,1)== "9" or substr($phone->area,0,1)=="6") 
          196  +        return true;
          197  +    else
          198  +        return false;
          199  +}
          200  +
          201  +function verify_reasonable_dob($element_name,$element_value) {
          202  +	global $today;
          203  +	$date = $element_value;
          204  +	$date_str = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          205  +//	echo $date_str ."=".$today['year']."/".$today['mon']."/".$today['mday'];
          206  +
          207  +	if ($date_str == $today['year']."/".$today['mon']."/".$today['mday']) 
          208  +		// date wasn't changed by user, so no need to verify it
          209  +		return true;
          210  +	elseif ($today['year'] - $date['Y'] < 17)  // A little young to be trading, presumably a mistake
          211  +		return false;
          212  +	else
          213  +		return true;
          214  +}
          215  +
          216  +function verify_not_future_date ($element_name,$element_value) {
          217  +	$date = $element_value;
          218  +	$date_str = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          219  +
          220  +	if (strtotime($date_str) > strtotime("now"))
          221  +		return false;
          222  +	else
          223  +		return true;
          224  +}
          225  +
          226  +?>

Added bdt/member_contact_to_edit.php

            1  +<?
            2  +include_once("includes/inc.global.php");
            3  +
            4  +//
            5  +//  Todos los archivos que empiezan por 'member contact' están referidos 
            6  +//  a los 'acompañantes', figura que no estamos utilizando en esta versión
            7  +//  del programa. 
            8  +//  Por tanto, estos formularios NO ESTÁN ACTUALIZADOS
            9  +//
           10  +
           11  +$p->site_section = SITE_SECTION_OFFER_LIST;
           12  +$cUser->MustBeLevel(1);
           13  +
           14  +include("includes/inc.forms.php");
           15  +
           16  +$form->addElement("header", null, "Escoge asociado/a acompañante a editar");
           17  +$form->addElement("html", "<TR></TR>");
           18  +    
           19  +$sel =& $form->addElement("hierselect", "member", "Escoge asociado/a y persona");
           20  +$items = new cMemberGroupMenu;
           21  +$items->LoadMemberGroup();
           22  +$items->MakeMenuArrays();
           23  +$sel->setMainOptions($items->id);
           24  +$sel->setSecOptions($items->name);
           25  +
           26  +$form->addElement("static", null, null, null);
           27  +$buttons[] = &HTML_QuickForm::createElement('submit', 'btnEdit', 'Editar');
           28  +$buttons[] = &HTML_QuickForm::createElement('submit', 'btnDelete', 'Borrar');
           29  +$form->addGroup($buttons, null, null, '&nbsp;');
           30  +
           31  +
           32  +if ($form->validate()) { // Form is validated so processes the data
           33  +   $form->freeze();
           34  + 	$form->process("process_data", false);
           35  +} else {  // Display the form
           36  +	$p->DisplayPage($form->toHtml());
           37  +}
           38  +
           39  +function process_data ($values) {
           40  +	global $p, $items;
           41  +	
           42  +	$member = $values["member"];
           43  +	if(isset($values["btnDelete"])) {
           44  +		header("location:http://".HTTP_BASE."/member_contact_delete.php?mode=admin&person_id=". $items->person_id[$member[0]][$member[1]]);
           45  +		exit;	
           46  +	} else {
           47  +		header("location:http://".HTTP_BASE."/member_contact_edit.php?mode=admin&member_id=".$items->id[$member[0]] ."&person_id=". $items->person_id[$member[0]][$member[1]]);
           48  +		exit;	
           49  +	}
           50  +}
           51  +
           52  +?>

Added bdt/member_create.php

            1  +<?
            2  +
            3  +include_once("includes/inc.global.php");
            4  +
            5  +$cUser->MustBeLevel(1);
            6  +$p->site_section = SITE_SECTION_OFFER_LIST;
            7  +
            8  +include("includes/inc.forms.php");
            9  +require_once "Mail.php";
           10  +require_once "Mail/mime.php";  
           11  +//
           12  +// First, we define the form
           13  +//
           14  +$form->addElement("header", null, "Crear nuevo/a asociado/a");
           15  +$form->addElement("html", "<TR></TR>");
           16  +
           17  +
           18  +$form->addElement("text", "member_id", "ID asociado/a", array("size" => 10, "maxlength" => 15));
           19  +$form->addElement("text", "password", "Contraseña", array("size" => 10, "maxlength" => 15));
           20  +
           21  +$form->addElement("select", "member_role", "Rol", array("0"=>"Asociado/a", "1"=>"Administrador/a nivel 1", "2"=>"Administrador/a nivel 2"));
           22  +// $acct_types = array("S"=>"Normal", "J"=>"Acompañante", "H"=>"Hogar", "O"=>"Organización", "B"=>"Negocios", "F"=>"Asociación");
           23  +// $form->addElement("select", "account_type", "Tipo de cuenta", $acct_types);
           24  +$form->addElement("static", null, "Notas del administrador/a", null);
           25  +$form->addElement("textarea", "admin_note", null, array("cols"=>45, "rows"=>2, "wrap"=>"soft", "maxlength" => 100));
           26  +
           27  +$today = getdate();
           28  +$options = array("language"=> "es", "format" => "dFY", "minYear"=>JOIN_YEAR_MINIMUM, "maxYear"=>$today["year"]);
           29  +$form->addElement("date", "join_date",    "Fecha de inscripción", $options);    
           30  +$form->addElement("static", null, null, null);    
           31  +
           32  +$form->addElement("text", "first_name", "Nombre", array("size" => 15, "maxlength" => 20));
           33  +$form->addElement("text", "last_name", "Primer Apellido", array("size" => 20, "maxlength" => 30));
           34  +$form->addElement("text", "mid_name", "Segundo Apellido", array("size" => 10, "maxlength" => 20));
           35  +$form->addElement("static", null, null, null); 
           36  +
           37  +$options = array("language"=> "es", "format" => "dFY", "maxYear"=>$today["year"], "minYear"=>"1880"); 
           38  +$form->addElement("date", "dob", "Fecha de nacimiento", $options);
           39  +// $form->addElement("text", "mother_mn", "Mother's Maiden Name", array("size" => 20, "maxlength" => 30)); 
           40  +$form->addElement("static", null, null, null);
           41  +$form->addElement("text", "email", "Email", array("size" => 25, "maxlength" => 40));
           42  +$form->addElement("text", "phone1", "Teléfono", array("size" => 20));
           43  +$form->addElement("text", "phone2", "Teléfono 2", array("size" => 20));
           44  +// $form->addElement("text", "fax", "Fax Number", array("size" => 20));
           45  +$form->addElement("static", null, null, null);
           46  +$frequency = array("0"=>"Nunca", "1"=>"Diariamente", "7"=>"Semanalmente", "30"=>"Mensualmente");
           47  +$form->addElement("select", "email_updates", "¿Con qué frecuencia recibirá emails?", $frequency);
           48  +$form->addElement("static", null, null, null);
           49  +$form->addElement("text", "address_street1", "Dirección", array("size" => 25, "maxlength" => 30));
           50  +// $form->addElement("text", "address_street2", "Address Line 2", array("size" => 25, "maxlength" => 30));
           51  +$form->addElement("text", "address_city", "Ciudad", array("size" => 20, "maxlength" => 30));
           52  +
           53  +// TODO: The State and Country codes should be Select Menus, and choices should be built
           54  +// dynamically using an internet database (if such exists).
           55  +// $form->addElement("text", "address_state_code", STATE_TEXT, array("size" => 2, "maxlength" => 2));
           56  + $form->addElement("text", "address_post_code", "Código Postal", array("size" => 5, "maxlength" => 6));
           57  + $form->addElement("text", "address_country", "Provincia", array("size" => 20, "maxlength" => 30));
           58  +$form->addElement("static", null, null, null);
           59  +$form->addElement('submit', 'btnSubmit', 'Crear asociado/a');
           60  +
           61  +//
           62  +// Define form rules
           63  +//
           64  +$form->addRule('password', 'Contraseña demasiado corta', 'minlength', 7);
           65  +$form->addRule('first_name', 'Introduce un nombre', 'required');
           66  +// $form->addRule('mid_name', 'Introduce un apellido', 'required');
           67  +// Por alguna razón que no conozco, si se quita la siguiente línea el programa da un error. 
           68  +$form->addRule('last_name', 'Introduce un apellido', 'required');
           69  +$form->addRule('address_city', 'Introduce una ciudad', 'required');
           70  +// $form->addRule('address_state_code', 'Enter a state', 'required');
           71  +// $form->addRule('address_post_code', 'Enter a '.ZIP_TEXT, 'required');
           72  +// $form->addRule('address_country', 'Enter a country', 'required');
           73  +
           74  +$form->registerRule('verify_not_future_date','function','verify_not_future_date');
           75  +$form->addRule('dob', 'El nacimiento no puede ser en el futuro', 'verify_not_future_date');
           76  +$form->registerRule('verify_reasonable_dob','function','verify_reasonable_dob');
           77  +$form->addRule('dob', 'Un poco joven, ¿no crees?', 'verify_reasonable_dob');
           78  +$form->registerRule('verify_valid_email','function', 'verify_valid_email');
           79  +$form->addRule('email', 'Email no válido', 'verify_valid_email');
           80  +$form->registerRule('verify_phone_format','function','verify_phone_format');
           81  +$form->addRule('phone1', 'El número de teléfono no es válido', 'verify_phone_format');
           82  +$form->addRule('phone2', 'El número de teléfono no es válido', 'verify_phone_format');
           83  +// $form->addRule('fax', 'Phone format invalid', 'verify_phone_format');
           84  +
           85  +$form->registerRule('verify_unique_member_id','function','verify_unique_member_id');
           86  +$form->addRule('member_id','Este ID ya está siendo usado','verify_unique_member_id');
           87  +$form->registerRule('verify_good_member_id','function','verify_good_member_id');
           88  +$form->addRule('member_id','No se permiten caracteres especiales','verify_good_member_id');
           89  +$form->registerRule('verify_good_password','function','verify_good_password');
           90  +$form->addRule('password', 'La contraseña debe contener al menos un número', 'verify_good_password');
           91  +$form->registerRule('verify_no_apostraphes_or_backslashes','function','verify_no_apostraphes_or_backslashes');
           92  +$form->addRule("password", "Es mejor no utilizar apóstrofes o comillas en contraseñas", "verify_no_apostraphes_or_backslashes");
           93  +$form->registerRule('verify_role_allowed','function','verify_role_allowed');
           94  +$form->addRule('member_role','No puedes asignar un mayor nivel de acceso del que tienes','verify_role_allowed');
           95  +$form->addRule('join_date', 'La fecha no puede estar en el futuro', 'verify_not_future_date');
           96  +
           97  +
           98  +
           99  +//
          100  +// Check if we are processing a submission or just displaying the form
          101  +//
          102  +if ($form->validate()) { // Form is validated so processes the data
          103  +   $form->freeze();
          104  +     $form->process("process_data", false);
          105  +} else {
          106  +    $today = getdate();
          107  +    $current_date = array("Y"=>$today["year"], "F"=>$today["mon"], "d"=>$today["mday"]);
          108  +    $defaults = array("password"=>$cUser->GeneratePassword(), "dob"=>$current_date, "join_date"=>$current_date, "account_type"=>"S", "member_role"=>"0", "email_updates"=>DEFAULT_UPDATE_INTERVAL, "address_state_code"=>DEFAULT_STATE, "address_city"=>DEFAULT_CITY, "address_country"=>DEFAULT_COUNTRY);
          109  +    $form->setDefaults($defaults);
          110  +   $p->DisplayPage($form->toHtml());  // just display the form
          111  +}
          112  +
          113  +//
          114  +// The form has been submitted with valid data, so process it   
          115  +//
          116  +function process_data ($values) {
          117  +    global $p, $cUser,$cErr, $today;
          118  +    $list = "";
          119  +
          120  +    // Following are default values for which this form doesn't allow input
          121  +    $values['security_q'] = "";
          122  +    $values['security_a'] = "";
          123  +    $values['status'] = "A";
          124  +    $values['member_note'] = "";
          125  +    $values['expire_date'] = "";
          126  +    $values['away_date'] = "";
          127  +    $values['balance'] = 3;
          128  +    $values['primary_member'] = "Y";
          129  +    $values['directory_list'] = "Y";
          130  +
          131  +
          132  +    $date = $values['join_date'];
          133  +    $values['join_date'] = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          134  +    $date = $values['dob'];
          135  +    $values['dob'] = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          136  +    if($values['dob'] == $today['year']."/".$today['mon']."/".$today['mday'])
          137  +        $values['dob'] = ""; // if birthdate was left as default, set to null
          138  +    
          139  +    $phone = new cPhone($values['phone1']);
          140  +    $values['phone1_area'] = $phone->area;
          141  +    $values['phone1_number'] = $phone->SevenDigits();
          142  +//  $values['phone1_ext'] = $phone->ext;
          143  +    $phone = new cPhone($values['phone2']);
          144  +    $values['phone2_area'] = $phone->area;
          145  +    $values['phone2_number'] = $phone->SevenDigits();
          146  +//  $values['phone2_ext'] = $phone->ext;    
          147  +//  $phone = new cPhone($values['fax']);
          148  +//  $values['fax_area'] = $phone->area;
          149  +//  $values['fax_number'] = $phone->SevenDigits();
          150  +//  $values['fax_ext'] = $phone->ext;    
          151  +
          152  +
          153  +    $new_member = new cMember($values);
          154  +    $new_person = new cPerson($values);
          155  +
          156  +    if($created = $new_person->SaveNewPerson()) 
          157  +        $created = $new_member->SaveNewMember();
          158  +
          159  +    if($created) {
          160  +        $list .= "Asociado/a creado/a. Pulsa <A HREF=member_create.php>aquí </A>para crear otra.<P>";
          161  +        $list .= "También puedes <b>añadir una foto y genera el carnet de socio</b> pulsando <A HREF=member_edit.php?type=".$_REQUEST["type"]."&mode=admin&member_id=".$values['member_id'].">aquí</A>. ";  
          162  +        if($values['email'] == "") {
          163  +            $list .= "Esta persona tendrá que ser informada del ID de asociado/a ('". $values["member_id"]. "') y la contraseña ('". $values["password"] ."').";    
          164  +        } else {
          165  +
          166  +            $text = NEW_MEMBER_MESSAGE . "\n\nID Miembro: ". $values['member_id'] ."\n". "Contraseña: ". $values['password'];
          167  +            $html = iconv('utf-8', 'windows-1252', ROTULO_MAIL.nl2br($text).LOPD.AVISO_LEGAL);
          168  +            $to = $values['email'];
          169  +            $crlf = "\n";
          170  +            $headers = array ('From' => EMAIL_FROM,
          171  +            'To' => $to,
          172  +            'Subject' => NEW_MEMBER_SUBJECT);
          173  +            $mime = new Mail_mime($crlf);
          174  +            $mime->setTXTBody($text);
          175  +            $mime->setHTMLBody($html); 
          176  +            $body = $mime->get();
          177  +            $headers = $mime->headers($headers);
          178  +            
          179  +            $smtp = Mail::factory('mail');
          180  +            $mailed = $smtp->send($to, $headers, $body);
          181  +
          182  +            if (PEAR::isError($mailed)) {
          183  +              $list .= "Ha fallado el intento de enviar un email. Probablemente se deba a un problema técnico. Contacta con tu administrador en ". PHONE_ADMIN .". <I>El nuevo asociado/a debe ser informado del id ('". $values["member_id"]. "') y la contraseña ('". $values["password"] ."').</I>";                                                                             
          184  +               } else {
          185  +                 $list .= "Se ha enviado un email a '". $values["email"] ."' conteniendo el nuevo id y contraseña.";                                                                                                                                                                   
          186  +                  } 
          187  +        }         
          188  +    } else {
          189  +        $cErr->Error("Hubo un error guardando el número. Inténtalo más tarde.");
          190  +    }
          191  +   $p->DisplayPage($list);
          192  +}
          193  +//
          194  +// The following functions verify form data
          195  +//
          196  +
          197  +// TODO: All my validation functions should go into a new cFormValidation class
          198  +
          199  +function verify_unique_member_id ($element_name,$element_value) {
          200  +    $member = new cMember();
          201  +    
          202  +    return !($member->LoadMember($element_value, false));
          203  +}
          204  +
          205  +function verify_good_member_id ($element_name,$element_value) {
          206  +    if(ctype_alnum($element_value)) { // it's good, so return immediately & save a little time
          207  +        return true;
          208  +    } else {
          209  +        $member_id = ereg_replace("\_","",$element_value);
          210  +        $member_id = ereg_replace("\-","",$member_id);
          211  +        $member_id = ereg_replace("\.","",$member_id);
          212  +        if(ctype_alnum($member_id))  // test again now that we've stripped the allowable special chars
          213  +            return true;        
          214  +    }
          215  +}
          216  +
          217  +function verify_role_allowed($element_name,$element_value) {
          218  +    global $cUser;
          219  +    if($element_value > $cUser->member_role)
          220  +        return false;
          221  +    else
          222  +        return true;
          223  +}
          224  +        
          225  +function verify_reasonable_dob($element_name,$element_value) {
          226  +    global $today;
          227  +    $date = $element_value;
          228  +    $date_str = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          229  +//    echo $date_str ."=".$today['year']."/".$today['mon']."/".$today['mday'];
          230  +
          231  +    if ($date_str == $today['year']."/".$today['mon']."/".$today['mday']) 
          232  +        // date wasn't changed by user, so no need to verify it
          233  +        return true;
          234  +    elseif ($today['year'] - $date['Y'] < 17)  // A little young to be trading, presumably a mistake
          235  +        return false;
          236  +    else
          237  +        return true;
          238  +}
          239  +
          240  +function verify_good_password($element_name,$element_value) {
          241  +    $i=0;
          242  +    $length=strlen($element_value);
          243  +    
          244  +    while($i<$length) {
          245  +        if(ctype_digit($element_value{$i}))
          246  +            return true;    
          247  +        $i+=1;
          248  +    }
          249  +    
          250  +    return false;
          251  +}
          252  +
          253  +function verify_no_apostraphes_or_backslashes($element_name,$element_value) {
          254  +    if(strstr($element_value,"'") or strstr($element_value,"\\"))
          255  +        return false;
          256  +    else
          257  +        return true;
          258  +}
          259  +
          260  +function verify_not_future_date ($element_name,$element_value) {
          261  +    $date = $element_value;
          262  +    $date_str = $date['Y'] . '/' . $date['F'] . '/' . $date['d'];
          263  +
          264  +    if (strtotime($date_str) > strtotime("now"))
          265  +        return false;
          266  +    else
          267  +        return true;
          268  +