diff --git a/htdocs/includes/menus/init_menu_auguria.sql b/htdocs/includes/menus/init_menu_auguria.sql index 99015589c33..0c1e2964fd3 100644 --- a/htdocs/includes/menus/init_menu_auguria.sql +++ b/htdocs/includes/menus/init_menu_auguria.sql @@ -17,7 +17,7 @@ insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->product->enabled || $conf->service->enabled', 3__+MAX_llx_menu__, __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'Products/Services', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 3, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', 5__+MAX_llx_menu__, __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 5, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->compta->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled', 6__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->commande->lire || $user->rights->facture->lire', '', 2, 6, __ENTITY__); -insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->banque->enabled || $conf->prelevement->enabled', 14__+MAX_llx_menu__, __HANDLER__, 'top', 'bank', '', 0, '/compta/bank/index.php?mainmenu=bank&leftmenu=bank', 'MenuBankCash', -1, 'banks', '$user->rights->banque->lire', '', 2, 6, __ENTITY__); +insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->banque->enabled || $conf->prelevement->enabled', 14__+MAX_llx_menu__, __HANDLER__, 'top', 'bank', '', 0, '/compta/bank/index.php?mainmenu=bank&leftmenu=bank', 'MenuBankCash', -1, 'banks', '$user->rights->banque->lire || $user->rights->prelevement->bons->lire', '', 2, 6, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 0, 7, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->mailing->enabled || $conf->export->enabled || $conf->global->MAIN_MODULE_IMPORT || $conf->global->MAIN_MODULE_DOMAIN', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/index.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '$user->rights->mailing->lire || $user->rights->bookmark->lire || $user->rights->export->lire', '', 2, 8, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('! empty($conf->boutique->enabled)', 11__+MAX_llx_menu__, __HANDLER__, 'top', 'shop', '', 0, '/boutique/index.php?mainmenu=shop&leftmenu=', 'OSCommerce', -1, 'shop', '', '', 0, 11, __ENTITY__); @@ -103,9 +103,9 @@ insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->categorie->enabled', __HANDLER__, 'left', 3200__+MAX_llx_menu__, 'products', '', 3__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=0', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->categorie->enabled', __HANDLER__, 'left', 3201__+MAX_llx_menu__, 'products', '', 3200__+MAX_llx_menu__, '/categories/fiche.php?action=create&type=0', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); -- Product - Shipment -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->expedition->enabled', __HANDLER__, 'left', 1300__+MAX_llx_menu__, 'commercial', '', 3__+MAX_llx_menu__, '/expedition/index.php?leftmenu=sendings', 'Shipments', 0, 'orders', '$user->rights->expedition->lire', '', 2, 6, __ENTITY__); -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->expedition->enabled && $leftmenu=="sendings"', __HANDLER__, 'left', 1301__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/expedition/liste.php?leftmenu=sendings', 'List', 1, 'orders', '$user->rights->expedition->lire', '', 2, 0, __ENTITY__); -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->expedition->enabled && $leftmenu=="sendings"', __HANDLER__, 'left', 1302__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/expedition/stats/index.php?leftmenu=sendings', 'Statistics', 1, 'orders', '$user->rights->expedition->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->expedition->enabled', __HANDLER__, 'left', 1300__+MAX_llx_menu__, 'commercial', '', 3__+MAX_llx_menu__, '/expedition/index.php?leftmenu=sendings', 'Shipments', 0, 'sendings', '$user->rights->expedition->lire', '', 2, 6, __ENTITY__); +insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->expedition->enabled && $leftmenu=="sendings"', __HANDLER__, 'left', 1301__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/expedition/liste.php?leftmenu=sendings', 'List', 1, 'sendings', '$user->rights->expedition->lire', '', 2, 0, __ENTITY__); +insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->expedition->enabled && $leftmenu=="sendings"', __HANDLER__, 'left', 1302__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/expedition/stats/index.php?leftmenu=sendings', 'Statistics', 1, 'sendings', '$user->rights->expedition->lire', '', 2, 1, __ENTITY__); -- Commercial - Suppliers insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->fournisseur->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'commercial', '', 5__+MAX_llx_menu__, '/compta/index.php?leftmenu=suppliers', 'Suppliers', 0, 'companies', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 0, __ENTITY__); @@ -220,11 +220,11 @@ insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->compta->enabled || $conf->accounting->enabled', __HANDLER__, 'left', 2703__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/stats/index.php?leftmenu=ca', 'ReportTurnover', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->compta->enabled || $conf->accounting->enabled', __HANDLER__, 'left', 2704__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/casoc.php?leftmenu=ca', 'ByCompanies', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->compta->enabled || $conf->accounting->enabled', __HANDLER__, 'left', 2705__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyuser.php?leftmenu=ca', 'ByUsers', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); ---- Check deposit +-- Check deposit insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->facture->enabled && $conf->banque->enabled', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', '', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank', 'MenuChequeDeposits', 0, 'bills', '$user->rights->facture->lire', '', 2, 9, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->facture->enabled && $conf->banque->enabled && $leftmenu=="checks"', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/fiche.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'bills', '$user->rights->facture->lire', '', 2, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->facture->enabled && $conf->banque->enabled && $leftmenu=="checks"', __HANDLER__, 'left', 1713__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/liste.php?leftmenu=checks', 'MenuChequesReceipts', 1, 'bills', '$user->rights->facture->lire', '', 2, 1, __ENTITY__); --- Prelevement +-- Withdrawal insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled', __HANDLER__, 'left', 2500__+MAX_llx_menu__, 'accountancy', '', 14__+MAX_llx_menu__, '/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank', 'StandingOrders', 0, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 9, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2502__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/create.php?leftmenu=withdraw', 'NewStandingOrder', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->prelevement->enabled && $leftmenu=="withdraw"', __HANDLER__, 'left', 2501__+MAX_llx_menu__, 'accountancy', '', 2500__+MAX_llx_menu__, '/compta/prelevement/demandes.php?status=0&leftmenu=withdraw', 'StandingOrderToProcess', 1, 'withdrawals', '$user->rights->prelevement->bons->lire', '', 2, 1, __ENTITY__); diff --git a/htdocs/includes/menus/init_menu_iphone.sql b/htdocs/includes/menus/init_menu_iphone.sql index 05f3b72814c..25cc22734a6 100644 --- a/htdocs/includes/menus/init_menu_iphone.sql +++ b/htdocs/includes/menus/init_menu_iphone.sql @@ -17,7 +17,7 @@ insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->product->enabled || $conf->service->enabled', 3__+MAX_llx_menu__, __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'Products/Services', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 3, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', 5__+MAX_llx_menu__, __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 5, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->compta->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled', 6__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->commande->lire || $user->rights->facture->lire', '', 2, 6, __ENTITY__); -insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->banque->enabled || $conf->prelevement->enabled', 14__+MAX_llx_menu__, __HANDLER__, 'top', 'bank', '', 0, '/compta/bank/index.php?mainmenu=bank&leftmenu=bank', 'MenuBankCash', -1, 'banks', '$user->rights->banque->lire', '', 2, 6, __ENTITY__); +insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->banque->enabled || $conf->prelevement->enabled', 14__+MAX_llx_menu__, __HANDLER__, 'top', 'bank', '', 0, '/compta/bank/index.php?mainmenu=bank&leftmenu=bank', 'MenuBankCash', -1, 'banks', '$user->rights->banque->lire || $user->rights->prelevement->bons->lire', '', 2, 6, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 0, 7, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->mailing->enabled || $conf->export->enabled || $conf->global->MAIN_MODULE_IMPORT || $conf->global->MAIN_MODULE_DOMAIN', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/index.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '$user->rights->mailing->lire || $user->rights->bookmark->lire || $user->rights->export->lire', '', 2, 8, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('! empty($conf->boutique->enabled)', 11__+MAX_llx_menu__, __HANDLER__, 'top', 'shop', '', 0, '/boutique/index.php?mainmenu=shop&leftmenu=', 'OSCommerce', -1, 'shop', '', '', 0, 11, __ENTITY__); diff --git a/htdocs/includes/menus/standard/eldy.lib.php b/htdocs/includes/menus/standard/eldy.lib.php index e850973b5d2..fe160b84f5e 100644 --- a/htdocs/includes/menus/standard/eldy.lib.php +++ b/htdocs/includes/menus/standard/eldy.lib.php @@ -256,7 +256,7 @@ function print_eldy_menu($db,$atarget,$type_user) } $idsel='bank'; - if ($user->rights->banque->lire) + if ($user->rights->banque->lire || $user->rights->prelevement->bons->lire) { print_start_menu_entry($idsel); print ''; diff --git a/htdocs/includes/modules/action/rapport.pdf.php b/htdocs/includes/modules/action/rapport.pdf.php index 14c4056f3ba..b8f15e057ef 100644 --- a/htdocs/includes/modules/action/rapport.pdf.php +++ b/htdocs/includes/modules/action/rapport.pdf.php @@ -83,7 +83,7 @@ class CommActionRapport if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php index e373c2d7a39..f88a1593807 100644 --- a/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php @@ -89,7 +89,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("companies"); diff --git a/htdocs/includes/modules/commande/pdf_edison.modules.php b/htdocs/includes/modules/commande/pdf_edison.modules.php index 88c76065aa5..33b02f2c25e 100644 --- a/htdocs/includes/modules/commande/pdf_edison.modules.php +++ b/htdocs/includes/modules/commande/pdf_edison.modules.php @@ -98,7 +98,7 @@ class pdf_edison extends ModelePDFCommandes if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -491,7 +491,8 @@ class pdf_edison extends ModelePDFCommandes $pdf->SetTextColor(0,0,0); $pdf->SetFont('','',10); $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); - $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), 95); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); } diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 69a93e2eea4..6e112c3d325 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -113,7 +113,7 @@ class pdf_einstein extends ModelePDFCommandes if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -759,7 +759,8 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0,0,0); $pdf->SetFont('','',8); $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); - $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top -3); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); $pdf->SetDrawColor(128,128,128); diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php index ec80f290aaf..6405ef3f157 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php @@ -77,9 +77,13 @@ Class pdf_expedition_merou extends ModelePdfExpedition { global $user,$conf,$langs,$mysoc; + $object->fetch_thirdparty(); + + if (empty($object->lines)) $object->lines=$object->lignes; + if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -200,8 +204,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Generation du tableau $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); - //Recuperation des produits de la commande. - $nblignes = sizeof($object->$origin->lines); + $nblignes = sizeof($object->lines); for ($i = 0 ; $i < $nblignes ; $i++) { @@ -213,7 +216,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Insertion de la reference du produit $pdf->SetXY (30, $curY+1 ); $pdf->SetFont('','B', 7); - $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->$origin->lines[$i]->ref), 0, 'L', 0); + $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0); //Insertion du libelle $pdf->SetFont('','', 7); $pdf->SetXY (50, $curY+1 ); @@ -427,13 +430,13 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Definition Emplacement du bloc Societe $Xoff = 110; $blSocX=90; - $blSocY=24; + $blSocY=21; $blSocW=50; $blSocX2=$blSocW+$blSocXs; // Sender name $pdf->SetTextColor(0,0,60); - $pdf->SetXY($blSocX,$blSocY+3); + $pdf->SetXY($blSocX,$blSocY); $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->nom), 0, 'L'); $pdf->SetTextColor(0,0,0); @@ -441,7 +444,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); $pdf->SetFont('','',7); - $pdf->SetXY($blSocX,$blSocY+6); + $pdf->SetXY($blSocX,$blSocY+3); $pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L'); diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php index 523a74ebd7f..c86cfb8b7a9 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php @@ -220,9 +220,11 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $object->fetch_thirdparty(); + if (empty($object->lines)) $object->lines=$object->lignes; + if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index 4ec52a09068..d2e1b1e6a8f 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -115,7 +115,7 @@ class pdf_crabe extends ModelePDFFactures if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -123,6 +123,8 @@ class pdf_crabe extends ModelePDFFactures $outputlangs->load("bills"); $outputlangs->load("products"); + $default_font_size = pdf_getPDFFontSize($outputlangs); + if ($conf->facture->dir_output) { $object->fetch_thirdparty(); @@ -205,7 +207,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); - $pdf->SetFont('','', 9); + $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -219,7 +221,7 @@ class pdf_crabe extends ModelePDFFactures { $tab_top = 88; - $pdf->SetFont('','', 9); + $pdf->SetFont('','', $default_font_size - 1); $pdf->SetXY ($this->posxdesc-1, $tab_top); //$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'J', false, 1, '', '', true, 0, false, false, 0, 'T', true); $pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'L'); // FPDF @@ -251,14 +253,14 @@ class pdf_crabe extends ModelePDFFactures $curY = $nexY; // Description of product line - $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page + $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $curX = $this->posxdesc-1; - //$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); + //$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY); //$pdf->writeHTMLCell($this->posxtva-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); - $pdf->SetFont('','', 9); // On repositionne la police par defaut + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $nexY = $pdf->GetY(); // TVA @@ -358,7 +360,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->SetFont('','', 9); + $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -434,13 +436,15 @@ class pdf_crabe extends ModelePDFFactures $tab3_width = 80; $tab3_height = 4; - $pdf->SetFont('','',8); + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $pdf->SetFont('','', $default_font_size - 2); $pdf->SetXY ($tab3_posx, $tab3_top - 5); $pdf->MultiCell(60, 5, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0); $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); - $pdf->SetFont('','',6); + $pdf->SetFont('','', $default_font_size - 4); $pdf->SetXY ($tab3_posx, $tab3_top ); $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0); $pdf->SetXY ($tab3_posx+21, $tab3_top ); @@ -452,7 +456,7 @@ class pdf_crabe extends ModelePDFFactures $y=0; - $pdf->SetFont('','',6); + $pdf->SetFont('','', $default_font_size - 4); // Loop on each deposits and credit notes included $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; @@ -552,12 +556,14 @@ class pdf_crabe extends ModelePDFFactures { global $conf; - $pdf->SetFont('','', 9); + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $pdf->SetFont('','', $default_font_size - 1); // If France, show VAT mention if not applicable if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) { - $pdf->SetFont('','B',8); + $pdf->SetFont('','B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); @@ -567,12 +573,12 @@ class pdf_crabe extends ModelePDFFactures // Show payments conditions if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) { - $pdf->SetFont('','B',8); + $pdf->SetFont('','B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentConditions").':'; $pdf->MultiCell(80, 4, $titre, 0, 'L'); - $pdf->SetFont('','',8); + $pdf->SetFont('','', $default_font_size - 2); $pdf->SetXY(52, $posy); $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); @@ -591,7 +597,7 @@ class pdf_crabe extends ModelePDFFactures { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B',8); + $pdf->SetFont('','B', $default_font_size - 2); $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); $pdf->SetTextColor(0,0,0); @@ -603,12 +609,12 @@ class pdf_crabe extends ModelePDFFactures && $object->mode_reglement_code != 'CHQ' && $object->mode_reglement_code != 'VIR') { - $pdf->SetFont('','B',8); + $pdf->SetFont('','B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); $titre = $outputlangs->transnoentities("PaymentMode").':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('','',8); + $pdf->SetFont('','', $default_font_size - 2); $pdf->SetXY(50, $posy); $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); @@ -628,24 +634,24 @@ class pdf_crabe extends ModelePDFFactures $account->fetch($conf->global->FACTURE_CHQ_NUMBER); $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','B',8); + $pdf->SetFont('','B', $default_font_size - 2); $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio).':',0,'L',0); $posy=$pdf->GetY()+1; $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','',8); + $pdf->SetFont('','', $default_font_size - 2); $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); $posy=$pdf->GetY()+2; } if ($conf->global->FACTURE_CHQ_NUMBER == -1) { $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','B',8); + $pdf->SetFont('','B', $default_font_size - 2); $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->nom).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); $posy=$pdf->GetY()+1; $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('','',8); + $pdf->SetFont('','', $default_font_size - 2); $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $posy=$pdf->GetY()+2; } @@ -687,10 +693,12 @@ class pdf_crabe extends ModelePDFFactures { global $conf,$mysoc; + $default_font_size = pdf_getPDFFontSize($outputlangs); + $tab2_top = $posy; $tab2_hl = 5; $tab2_height = $tab2_hl * 4; - $pdf->SetFont('','', 9); + $pdf->SetFont('','', $default_font_size - 1); // Tableau total $lltot = 200; $col1x = 120; $col2x = 170; $largcol2 = $lltot - $col2x; @@ -884,7 +892,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); // Fin - $pdf->SetFont('','', 9); + $pdf->SetFont('','', $default_font_size - 1); $pdf->SetTextColor(0,0,0); } @@ -900,11 +908,14 @@ class pdf_crabe extends ModelePDFFactures { global $conf; + $default_font_size = pdf_getPDFFontSize($outputlangs); + // Amount in (at tab_top - 1) $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','',8); + $pdf->SetFont('','', $default_font_size - 2); $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); - $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top -3); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); $pdf->SetDrawColor(128,128,128); @@ -913,7 +924,7 @@ class pdf_crabe extends ModelePDFFactures // line prend une position y en 2eme param et 4eme param $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); - $pdf->SetFont('','',9); + $pdf->SetFont('','', $default_font_size - 1); $pdf->SetXY ($this->posxdesc-1, $tab_top+2); $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); @@ -965,6 +976,8 @@ class pdf_crabe extends ModelePDFFactures $outputlangs->load("propal"); $outputlangs->load("companies"); + $default_font_size = pdf_getPDFFontSize($outputlangs); + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) ) @@ -973,7 +986,7 @@ class pdf_crabe extends ModelePDFFactures } $pdf->SetTextColor(0,0,60); - $pdf->SetFont('','B',13); + $pdf->SetFont('','B', $default_font_size + 3); $posy=$this->marge_haute; @@ -990,7 +1003,7 @@ class pdf_crabe extends ModelePDFFactures else { $pdf->SetTextColor(200,0,0); - $pdf->SetFont('','B',8); + $pdf->SetFont('','B',$default_font_size - 2); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); } @@ -1001,7 +1014,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } - $pdf->SetFont('','B',13); + $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY(100,$posy); $pdf->SetTextColor(0,0,60); $title=$outputlangs->transnoentities("Invoice"); @@ -1011,7 +1024,7 @@ class pdf_crabe extends ModelePDFFactures if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat"); $pdf->MultiCell(100, 4, $title, '' , 'R'); - $pdf->SetFont('','B',12); + $pdf->SetFont('','B', $default_font_size + 2); $posy+=6; $pdf->SetXY(100,$posy); @@ -1019,7 +1032,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); $posy+=2; - $pdf->SetFont('','',9); + $pdf->SetFont('','', $default_font_size - 1); $objectidnext=$object->getIdReplacingInvoice('validated'); if ($object->type == 0 && $objectidnext) @@ -1095,7 +1108,7 @@ class pdf_crabe extends ModelePDFFactures { $posy+=4; $pdf->SetXY(100,$posy); - $pdf->SetFont('','',9); + $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref), '', 'R'); } } @@ -1121,7 +1134,7 @@ class pdf_crabe extends ModelePDFFactures { $posy+=4; $pdf->SetXY(100,$posy); - $pdf->SetFont('','',9); + $pdf->SetFont('','', $default_font_size - 1); $text=$newobject->ref; if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')'; $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); @@ -1144,7 +1157,7 @@ class pdf_crabe extends ModelePDFFactures // Show sender frame $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','',8); + $pdf->SetFont('','', $default_font_size - 2); $pdf->SetXY($posx,$posy-5); $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx,$posy); @@ -1154,12 +1167,12 @@ class pdf_crabe extends ModelePDFFactures // Show sender name $pdf->SetXY($posx+2,$posy+3); - $pdf->SetFont('','B',10); + $pdf->SetFont('','B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->nom), 0, 'L'); // Show sender information $pdf->SetXY($posx+2,$posy+8); - $pdf->SetFont('','',9); + $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); @@ -1195,18 +1208,18 @@ class pdf_crabe extends ModelePDFFactures // Show recipient frame $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','',8); + $pdf->SetFont('','', $default_font_size - 2); $pdf->SetXY($posx+2,$posy-5); $pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":",0,'L'); $pdf->rect($posx, $posy, 100, $hautcadre); // Show recipient name $pdf->SetXY($posx+2,$posy+3); - $pdf->SetFont('','B',10); + $pdf->SetFont('','B', $default_font_size); $pdf->MultiCell(96,4, $carac_client_name, 0, 'L'); // Show recipient information - $pdf->SetFont('','',9); + $pdf->SetFont('','', $default_font_size - 1); $pdf->SetXY($posx+2,$posy+8); $pdf->MultiCell(86,4, $carac_client, 0, 'L'); } diff --git a/htdocs/includes/modules/facture/pdf_oursin.modules.php b/htdocs/includes/modules/facture/pdf_oursin.modules.php index fc62f4a2b95..f6841d4fca1 100644 --- a/htdocs/includes/modules/facture/pdf_oursin.modules.php +++ b/htdocs/includes/modules/facture/pdf_oursin.modules.php @@ -113,7 +113,7 @@ class pdf_oursin extends ModelePDFFactures if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -998,7 +998,8 @@ class pdf_oursin extends ModelePDFFactures $pdf->SetTextColor(0,0,0); $pdf->SetFont('','',10); $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); - $pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), 91); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); } /** diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php index fa570ad466b..9c1f5539a1b 100644 --- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php +++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php @@ -87,7 +87,7 @@ class pdf_soleil extends ModelePDFFicheinter if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php index 1e50e644412..1aeef869545 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php @@ -85,7 +85,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -327,13 +327,6 @@ class pdf_sirocco extends ModelePDFDeliveryOrder // $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top); $pdf->Rect(10, $tab_top, 190, $tab_height); - - - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','',10); - // $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentitiesnoconv("Currency".$conf->monnaie)); - // $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); - } /** diff --git a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php index d60af248b44..672b53f611d 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php @@ -107,7 +107,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -438,12 +438,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder { global $conf,$mysoc; - // Montants exprimes en (en tab_top - 1) - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','',8); - //$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); - //$pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); - $pdf->SetDrawColor(128,128,128); // Rect prend une longueur en 3eme param @@ -451,6 +445,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder // line prend une position y en 3eme param $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); + $pdf->SetTextColor(0,0,0); $pdf->SetFont('','',10); $pdf->SetXY ($this->posxdesc-1, $tab_top+2); diff --git a/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php b/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php index 6c1f45fbf14..73e218f3ec2 100644 --- a/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php +++ b/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php @@ -123,9 +123,10 @@ class mailing_dolibarr_services_expired extends MailingTargets $cibles[$j] = array( 'email' => $obj->email, 'name' => $obj->name, - 'id' => $obj->id, 'other' => dol_print_date($this->db->jdate($obj->date_ouverture),'day').';'.dol_print_date($this->db->jdate($obj->date_fin_validite),'day').';'.$obj->fk_contrat.';'.$obj->cdid, - 'url' => $this->url($obj->rowid) + 'source_url' => $this->url($obj->rowid), + 'source_id' => $obj->cdid, + 'source_type' => 'contract_line' ); $old = $obj->email; $j++; diff --git a/htdocs/includes/modules/mailings/fraise.modules.php b/htdocs/includes/modules/mailings/fraise.modules.php index 512c505eef2..fb638de29a3 100644 --- a/htdocs/includes/modules/mailings/fraise.modules.php +++ b/htdocs/includes/modules/mailings/fraise.modules.php @@ -131,7 +131,7 @@ class mailing_fraise extends MailingTargets /** * \brief Ajoute destinataires dans table des cibles - * \param mailing_id Id du mailing concerne + * \param mailing_id Id of emailing * \param filterarray Param to filter sql request. Deprecated. Should use $_POST instead. * \return int < 0 si erreur, nb ajout si ok */ @@ -184,7 +184,9 @@ class mailing_fraise extends MailingTargets 'name' => $obj->name, 'firstname' => $obj->firstname, 'other' => $obj->datefin?($langs->transnoentities("DateEnd").'='.dol_print_date($this->db->jdate($obj->datefin),'day')):'', - 'url' => $this->url($obj->id) + 'source_url' => $this->url($obj->id), + 'source_id' => $obj->id, + 'source_type' => 'member' ); $old = $obj->email; $j++; diff --git a/htdocs/includes/modules/mailings/framboise.modules.php b/htdocs/includes/modules/mailings/framboise.modules.php index 55b89780136..555247dbacb 100644 --- a/htdocs/includes/modules/mailings/framboise.modules.php +++ b/htdocs/includes/modules/mailings/framboise.modules.php @@ -92,7 +92,9 @@ class mailing_framboise extends MailingTargets 'name' => $obj->name, 'firstname' => $obj->firstname, 'other' => ($obj->label?$langs->transnoentities("Category").'='.$obj->label:''), - 'url' => $this->url($obj->id) + 'source_url' => $this->url($obj->id), + 'source_id' => $obj->id, + 'source_type' => 'member' ); $old = $obj->email; $j++; diff --git a/htdocs/includes/modules/mailings/kiwi.modules.php b/htdocs/includes/modules/mailings/kiwi.modules.php index 91252e93f2e..8ae04b98059 100644 --- a/htdocs/includes/modules/mailings/kiwi.modules.php +++ b/htdocs/includes/modules/mailings/kiwi.modules.php @@ -92,7 +92,9 @@ class mailing_kiwi extends MailingTargets 'name' => $obj->name, 'firstname' => $obj->firstname, 'other' => ($obj->label?$langs->transnoentities("Category").'='.$obj->label:''), - 'url' => $this->url($obj->id) + 'source_url' => $this->url($obj->id), + 'source_id' => $obj->id, + 'source_type' => 'thirdparty' ); $old = $obj->email; $j++; diff --git a/htdocs/includes/modules/mailings/modules_mailings.php b/htdocs/includes/modules/mailings/modules_mailings.php index f2f3b006f46..1d35b08cf13 100644 --- a/htdocs/includes/modules/mailings/modules_mailings.php +++ b/htdocs/includes/modules/mailings/modules_mailings.php @@ -125,8 +125,8 @@ class MailingTargets /** * \brief Ajoute destinataires dans table des cibles - * \param mailing_id Id du mailing concern� - * \param sql Requete sql de selection des destinataires + * \param mailing_id Id of emailing + * \param cibles Array with targets * \return int < 0 si erreur, nb ajout si ok */ function add_to_target($mailing_id, $cibles) @@ -141,14 +141,16 @@ class MailingTargets $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " (fk_mailing,"; $sql .= " fk_contact,"; - $sql .= " nom, prenom, email, other, url)"; + $sql .= " nom, prenom, email, other, source_url, source_id, source_type)"; $sql .= " VALUES (".$mailing_id.","; $sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .","; $sql .= "'".$this->db->escape($cibles[$i]['name'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['email'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['other'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['url'])."')"; + $sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',"; + $sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',"; + $sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')"; $result=$this->db->query($sql); if ($result) { @@ -177,7 +179,7 @@ class MailingTargets /** * \brief Supprime tous les destinataires de la table des cibles - * \param mailing_id Id du mailing concern� + * \param mailing_id Id of emailing */ function clear_target($mailing_id) { diff --git a/htdocs/includes/modules/mailings/peche.modules.php b/htdocs/includes/modules/mailings/peche.modules.php index 2989ed2df23..d4761abde83 100644 --- a/htdocs/includes/modules/mailings/peche.modules.php +++ b/htdocs/includes/modules/mailings/peche.modules.php @@ -98,7 +98,7 @@ class mailing_peche extends MailingTargets /** * \brief Ajoute destinataires dans table des cibles - * \param mailing_id Id du mailing concerne + * \param mailing_id Id of emailing * \param filterarray Requete sql de selection des destinataires * \return int < 0 si erreur, nb ajout si ok */ @@ -154,7 +154,9 @@ class mailing_peche extends MailingTargets 'name' => $name, 'firstname' => $firstname, 'other' => $other, - 'url' => $this->url($id) + 'source_url' => '', + 'source_id' => '', + 'source_type' => 'file' ); $old = $email; $j++; diff --git a/htdocs/includes/modules/mailings/poire.modules.php b/htdocs/includes/modules/mailings/poire.modules.php index 6e349b8b617..3952938487d 100644 --- a/htdocs/includes/modules/mailings/poire.modules.php +++ b/htdocs/includes/modules/mailings/poire.modules.php @@ -152,7 +152,7 @@ class mailing_poire extends MailingTargets /** * \brief Ajoute destinataires dans table des cibles - * \param mailing_id Id du mailing concern� + * \param mailing_id Id of emailing * \param filterarray Requete sql de selection des destinataires * \return int <0 si erreur, nb ajout si ok */ @@ -228,7 +228,9 @@ class mailing_poire extends MailingTargets 'name' => $obj->name, 'firstname' => $obj->firstname, 'other' => $other, - 'url' => $this->url($obj->id) + 'source_url' => $this->url($obj->id), + 'source_id' => $obj->id, + 'source_type' => 'contact' ); $old = $obj->email; $j++; diff --git a/htdocs/includes/modules/mailings/pomme.modules.php b/htdocs/includes/modules/mailings/pomme.modules.php index 78a86d4f6c3..603a5386b09 100644 --- a/htdocs/includes/modules/mailings/pomme.modules.php +++ b/htdocs/includes/modules/mailings/pomme.modules.php @@ -119,7 +119,7 @@ class mailing_pomme extends MailingTargets /** * \brief Ajoute destinataires dans table des cibles - * \param mailing_id Id du mailing concern� + * \param mailing_id Id of emailing * \param filterarray Requete sql de selection des destinataires * \return int < 0 si erreur, nb ajout si ok */ @@ -164,7 +164,9 @@ class mailing_pomme extends MailingTargets 'name' => $obj->name, 'firstname' => $obj->firstname, 'other' => $langs->transnoentities("Login").'='.$obj->login.';'.$langs->transnoentities("PhonePro").'='.$obj->office_phone, - 'url' => $this->url($obj->id) + 'source_url' => $this->url($obj->id), + 'source_id' => $obj->id, + 'source_type' => 'user' ); $old = $obj->email; $j++; diff --git a/htdocs/includes/modules/member/cards/pdf_standard.class.php b/htdocs/includes/modules/member/cards/pdf_standard.class.php index 2651ab8d259..9d85754d8fe 100644 --- a/htdocs/includes/modules/member/cards/pdf_standard.class.php +++ b/htdocs/includes/modules/member/cards/pdf_standard.class.php @@ -376,7 +376,7 @@ class pdf_standard { if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php b/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php index 967a7862b09..29a09fcc8ba 100644 --- a/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php +++ b/htdocs/includes/modules/member/labels/pdf_standardlabel.class.php @@ -355,7 +355,7 @@ class pdf_standardlabel { if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); diff --git a/htdocs/includes/modules/modPaybox.class.php b/htdocs/includes/modules/modPaybox.class.php index 1b0d45ae739..a1894b9722c 100644 --- a/htdocs/includes/modules/modPaybox.class.php +++ b/htdocs/includes/modules/modPaybox.class.php @@ -219,7 +219,7 @@ class modPayBox extends DolibarrModules */ function load_tables() { - return $this->_load_tables('/paybox/sql/'); + return $this->_load_tables(''); } } diff --git a/htdocs/includes/modules/modPaypal.class.php b/htdocs/includes/modules/modPaypal.class.php index d1185298c33..efc5dd77dc8 100644 --- a/htdocs/includes/modules/modPaypal.class.php +++ b/htdocs/includes/modules/modPaypal.class.php @@ -219,7 +219,7 @@ class modPaypal extends DolibarrModules */ function load_tables() { - return $this->_load_tables('/paybox/sql/'); + return $this->_load_tables(''); } } diff --git a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php index a3a60173d54..832e2a7e3c2 100644 --- a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php @@ -96,7 +96,7 @@ class pdf_baleine extends ModelePDFProjects if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -307,12 +307,6 @@ class pdf_baleine extends ModelePDFProjects { global $conf,$mysoc; - // Montants exprimes en (en tab_top - 1) - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','',8); - //$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); - //$pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); - $pdf->SetDrawColor(128,128,128); // Rect prend une longueur en 3eme param @@ -320,6 +314,7 @@ class pdf_baleine extends ModelePDFProjects // line prend une position y en 3eme param $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); + $pdf->SetTextColor(0,0,0); $pdf->SetFont('','',10); $pdf->SetXY ($this->posxref-1, $tab_top+2); diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index 7abf78baa3f..ed70a823e48 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -113,7 +113,7 @@ class pdf_propale_azur extends ModelePDFPropales if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO $sav_charset_output=$outputlangs->charset_output; - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -784,7 +784,8 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->SetTextColor(0,0,0); $pdf->SetFont('','',8); $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); - $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); $pdf->SetDrawColor(128,128,128); diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php index eb01741d66f..946e9ec187f 100644 --- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php @@ -89,7 +89,7 @@ class pdf_propale_jaune extends ModelePDFPropales if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO $sav_charset_output=$outputlangs->charset_output; - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -454,6 +454,13 @@ class pdf_propale_jaune extends ModelePDFPropales $langs->load("main"); $langs->load("bills"); + // Montants exprimes en (en tab_top - 1) + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','',8); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + $pdf->SetFont('','',11); $pdf->SetXY(10,$tab_top); diff --git a/htdocs/includes/modules/rapport/pdf_paiement.class.php b/htdocs/includes/modules/rapport/pdf_paiement.class.php index 01a5da1b329..861a2e4e6d6 100644 --- a/htdocs/includes/modules/rapport/pdf_paiement.class.php +++ b/htdocs/includes/modules/rapport/pdf_paiement.class.php @@ -82,7 +82,7 @@ class pdf_paiement if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $this->month=$month; $this->year=$year; diff --git a/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 9bd2e363230..45e71b25524 100755 --- a/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -104,7 +104,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -508,7 +508,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetTextColor(0,0,0); $pdf->SetFont('','',8); $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); - $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top -3); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); $pdf->SetDrawColor(128,128,128); @@ -702,7 +703,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetTextColor(0,0,0); $pdf->SetFont('','',8); $pdf->SetXY($this->marge_gauche,$posy-5); - $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillTo").":"); + $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillTo").":",0,"L"); $pdf->SetXY($this->marge_gauche,$posy); diff --git a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php index 9edad6c0442..7dfd7e5ccd8 100644 --- a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -104,7 +104,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!class_exists('TCPDF', false)) $outputlangs->charset_output='ISO-8859-1'; + if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -519,7 +519,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetTextColor(0,0,0); $pdf->SetFont('','',8); $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); - $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top -3); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); $pdf->SetDrawColor(128,128,128); @@ -630,13 +631,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($showadress) { - // Receive email + // Show sender address $posy=42; $hautcadre=40; $pdf->SetTextColor(0,0,0); $pdf->SetFont('','',8); $pdf->SetXY($this->marge_gauche,$posy-5); - $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillTo").":"); + $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillTo").":",0,'L'); $pdf->SetXY($this->marge_gauche,$posy); diff --git a/htdocs/includes/nusoap/lib/Mail/PEAR.php b/htdocs/includes/nusoap/lib/Mail/PEAR.php new file mode 100755 index 00000000000..249a1142af1 --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/PEAR.php @@ -0,0 +1,1101 @@ + + * @author Stig Bakken + * @author Tomas V.V.Cox + * @author Greg Beaver + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id$ + * @link http://pear.php.net/package/PEAR + * @since File available since Release 0.1 + */ + +/**#@+ + * ERROR constants + */ +define('PEAR_ERROR_RETURN', 1); +define('PEAR_ERROR_PRINT', 2); +define('PEAR_ERROR_TRIGGER', 4); +define('PEAR_ERROR_DIE', 8); +define('PEAR_ERROR_CALLBACK', 16); +/** + * WARNING: obsolete + * @deprecated + */ +define('PEAR_ERROR_EXCEPTION', 32); +/**#@-*/ +define('PEAR_ZE2', (function_exists('version_compare') && + version_compare(zend_version(), "2-dev", "ge"))); + +if (substr(PHP_OS, 0, 3) == 'WIN') { + define('OS_WINDOWS', true); + define('OS_UNIX', false); + define('PEAR_OS', 'Windows'); +} else { + define('OS_WINDOWS', false); + define('OS_UNIX', true); + define('PEAR_OS', 'Unix'); // blatant assumption +} + +// instant backwards compatibility +if (!defined('PATH_SEPARATOR')) { + if (OS_WINDOWS) { + define('PATH_SEPARATOR', ';'); + } else { + define('PATH_SEPARATOR', ':'); + } +} + +$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; +$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; +$GLOBALS['_PEAR_destructor_object_list'] = array(); +$GLOBALS['_PEAR_shutdown_funcs'] = array(); +$GLOBALS['_PEAR_error_handler_stack'] = array(); + +@ini_set('track_errors', true); + +/** + * Base class for other PEAR classes. Provides rudimentary + * emulation of destructors. + * + * If you want a destructor in your class, inherit PEAR and make a + * destructor method called _yourclassname (same name as the + * constructor, but with a "_" prefix). Also, in your constructor you + * have to call the PEAR constructor: $this->PEAR();. + * The destructor method will be called without parameters. Note that + * at in some SAPI implementations (such as Apache), any output during + * the request shutdown (in which destructors are called) seems to be + * discarded. If you need to get any debug information from your + * destructor, use error_log(), syslog() or something similar. + * + * IMPORTANT! To use the emulated destructors you need to create the + * objects by reference: $obj =& new PEAR_child; + * + * @category pear + * @package PEAR + * @author Stig Bakken + * @author Tomas V.V. Cox + * @author Greg Beaver + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: 1.4.11 + * @link http://pear.php.net/package/PEAR + * @see PEAR_Error + * @since Class available since PHP 4.0.2 + * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear + */ +class PEAR +{ + // {{{ properties + + /** + * Whether to enable internal debug messages. + * + * @var bool + * @access private + */ + var $_debug = false; + + /** + * Default error mode for this object. + * + * @var int + * @access private + */ + var $_default_error_mode = null; + + /** + * Default error options used for this object when error mode + * is PEAR_ERROR_TRIGGER. + * + * @var int + * @access private + */ + var $_default_error_options = null; + + /** + * Default error handler (callback) for this object, if error mode is + * PEAR_ERROR_CALLBACK. + * + * @var string + * @access private + */ + var $_default_error_handler = ''; + + /** + * Which class to use for error objects. + * + * @var string + * @access private + */ + var $_error_class = 'PEAR_Error'; + + /** + * An array of expected errors. + * + * @var array + * @access private + */ + var $_expected_errors = array(); + + // }}} + + // {{{ constructor + + /** + * Constructor. Registers this object in + * $_PEAR_destructor_object_list for destructor emulation if a + * destructor object exists. + * + * @param string $error_class (optional) which class to use for + * error objects, defaults to PEAR_Error. + * @access public + * @return void + */ + function PEAR($error_class = null) + { + $classname = strtolower(get_class($this)); + if ($this->_debug) { + print "PEAR constructor called, class=$classname\n"; + } + if ($error_class !== null) { + $this->_error_class = $error_class; + } + while ($classname && strcasecmp($classname, "pear")) { + $destructor = "_$classname"; + if (method_exists($this, $destructor)) { + global $_PEAR_destructor_object_list; + $_PEAR_destructor_object_list[] = &$this; + if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { + register_shutdown_function("_PEAR_call_destructors"); + $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; + } + break; + } else { + $classname = get_parent_class($classname); + } + } + } + + // }}} + // {{{ destructor + + /** + * Destructor (the emulated type of...). Does nothing right now, + * but is included for forward compatibility, so subclass + * destructors should always call it. + * + * See the note in the class desciption about output from + * destructors. + * + * @access public + * @return void + */ + function _PEAR() { + if ($this->_debug) { + printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); + } + } + + // }}} + // {{{ getStaticProperty() + + /** + * If you have a class that's mostly/entirely static, and you need static + * properties, you can use this method to simulate them. Eg. in your method(s) + * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); + * You MUST use a reference, or they will not persist! + * + * @access public + * @param string $class The calling classname, to prevent clashes + * @param string $var The variable to retrieve. + * @return mixed A reference to the variable. If not set it will be + * auto initialised to NULL. + */ + function &getStaticProperty($class, $var) + { + static $properties; + return $properties[$class][$var]; + } + + // }}} + // {{{ registerShutdownFunc() + + /** + * Use this function to register a shutdown method for static + * classes. + * + * @access public + * @param mixed $func The function name (or array of class/method) to call + * @param mixed $args The arguments to pass to the function + * @return void + */ + function registerShutdownFunc($func, $args = array()) + { + // if we are called statically, there is a potential + // that no shutdown func is registered. Bug #6445 + if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { + register_shutdown_function("_PEAR_call_destructors"); + $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; + } + $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); + } + + // }}} + // {{{ isError() + + /** + * Tell whether a value is a PEAR error. + * + * @param mixed $data the value to test + * @param int $code if $data is an error object, return true + * only if $code is a string and + * $obj->getMessage() == $code or + * $code is an integer and $obj->getCode() == $code + * @access public + * @return bool true if parameter is an error + */ + function isError($data, $code = null) + { + if (is_a($data, 'PEAR_Error')) { + if (is_null($code)) { + return true; + } elseif (is_string($code)) { + return $data->getMessage() == $code; + } else { + return $data->getCode() == $code; + } + } + return false; + } + + // }}} + // {{{ setErrorHandling() + + /** + * Sets how errors generated by this object should be handled. + * Can be invoked both in objects and statically. If called + * statically, setErrorHandling sets the default behaviour for all + * PEAR objects. If called in an object, setErrorHandling sets + * the default behaviour for that object. + * + * @param int $mode + * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, + * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, + * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. + * + * @param mixed $options + * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one + * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). + * + * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected + * to be the callback function or method. A callback + * function is a string with the name of the function, a + * callback method is an array of two elements: the element + * at index 0 is the object, and the element at index 1 is + * the name of the method to call in the object. + * + * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is + * a printf format string used when printing the error + * message. + * + * @access public + * @return void + * @see PEAR_ERROR_RETURN + * @see PEAR_ERROR_PRINT + * @see PEAR_ERROR_TRIGGER + * @see PEAR_ERROR_DIE + * @see PEAR_ERROR_CALLBACK + * @see PEAR_ERROR_EXCEPTION + * + * @since PHP 4.0.5 + */ + + function setErrorHandling($mode = null, $options = null) + { + if (isset($this) && is_a($this, 'PEAR')) { + $setmode = &$this->_default_error_mode; + $setoptions = &$this->_default_error_options; + } else { + $setmode = &$GLOBALS['_PEAR_default_error_mode']; + $setoptions = &$GLOBALS['_PEAR_default_error_options']; + } + + switch ($mode) { + case PEAR_ERROR_EXCEPTION: + case PEAR_ERROR_RETURN: + case PEAR_ERROR_PRINT: + case PEAR_ERROR_TRIGGER: + case PEAR_ERROR_DIE: + case null: + $setmode = $mode; + $setoptions = $options; + break; + + case PEAR_ERROR_CALLBACK: + $setmode = $mode; + // class/object method callback + if (is_callable($options)) { + $setoptions = $options; + } else { + trigger_error("invalid error callback", E_USER_WARNING); + } + break; + + default: + trigger_error("invalid error mode", E_USER_WARNING); + break; + } + } + + // }}} + // {{{ expectError() + + /** + * This method is used to tell which errors you expect to get. + * Expected errors are always returned with error mode + * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, + * and this method pushes a new element onto it. The list of + * expected errors are in effect until they are popped off the + * stack with the popExpect() method. + * + * Note that this method can not be called statically + * + * @param mixed $code a single error code or an array of error codes to expect + * + * @return int the new depth of the "expected errors" stack + * @access public + */ + function expectError($code = '*') + { + if (is_array($code)) { + array_push($this->_expected_errors, $code); + } else { + array_push($this->_expected_errors, array($code)); + } + return sizeof($this->_expected_errors); + } + + // }}} + // {{{ popExpect() + + /** + * This method pops one element off the expected error codes + * stack. + * + * @return array the list of error codes that were popped + */ + function popExpect() + { + return array_pop($this->_expected_errors); + } + + // }}} + // {{{ _checkDelExpect() + + /** + * This method checks unsets an error code if available + * + * @param mixed error code + * @return bool true if the error code was unset, false otherwise + * @access private + * @since PHP 4.3.0 + */ + function _checkDelExpect($error_code) + { + $deleted = false; + + foreach ($this->_expected_errors AS $key => $error_array) { + if (in_array($error_code, $error_array)) { + unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); + $deleted = true; + } + + // clean up empty arrays + if (0 == count($this->_expected_errors[$key])) { + unset($this->_expected_errors[$key]); + } + } + return $deleted; + } + + // }}} + // {{{ delExpect() + + /** + * This method deletes all occurences of the specified element from + * the expected error codes stack. + * + * @param mixed $error_code error code that should be deleted + * @return mixed list of error codes that were deleted or error + * @access public + * @since PHP 4.3.0 + */ + function delExpect($error_code) + { + $deleted = false; + + if ((is_array($error_code) && (0 != count($error_code)))) { + // $error_code is a non-empty array here; + // we walk through it trying to unset all + // values + foreach($error_code as $key => $error) { + if ($this->_checkDelExpect($error)) { + $deleted = true; + } else { + $deleted = false; + } + } + return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME + } elseif (!empty($error_code)) { + // $error_code comes alone, trying to unset it + if ($this->_checkDelExpect($error_code)) { + return true; + } else { + return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME + } + } else { + // $error_code is empty + return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME + } + } + + // }}} + // {{{ raiseError() + + /** + * This method is a wrapper that returns an instance of the + * configured error class with this object's default error + * handling applied. If the $mode and $options parameters are not + * specified, the object's defaults are used. + * + * @param mixed $message a text error message or a PEAR error object + * + * @param int $code a numeric error code (it is up to your class + * to define these if you want to use codes) + * + * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, + * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, + * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. + * + * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter + * specifies the PHP-internal error level (one of + * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). + * If $mode is PEAR_ERROR_CALLBACK, this + * parameter specifies the callback function or + * method. In other error modes this parameter + * is ignored. + * + * @param string $userinfo If you need to pass along for example debug + * information, this parameter is meant for that. + * + * @param string $error_class The returned error object will be + * instantiated from this class, if specified. + * + * @param bool $skipmsg If true, raiseError will only pass error codes, + * the error message parameter will be dropped. + * + * @access public + * @return object a PEAR error object + * @see PEAR::setErrorHandling + * @since PHP 4.0.5 + */ + function &raiseError($message = null, + $code = null, + $mode = null, + $options = null, + $userinfo = null, + $error_class = null, + $skipmsg = false) + { + // The error is yet a PEAR error object + if (is_object($message)) { + $code = $message->getCode(); + $userinfo = $message->getUserInfo(); + $error_class = $message->getType(); + $message->error_message_prefix = ''; + $message = $message->getMessage(); + } + + if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) { + if ($exp[0] == "*" || + (is_int(reset($exp)) && in_array($code, $exp)) || + (is_string(reset($exp)) && in_array($message, $exp))) { + $mode = PEAR_ERROR_RETURN; + } + } + // No mode given, try global ones + if ($mode === null) { + // Class error handler + if (isset($this) && isset($this->_default_error_mode)) { + $mode = $this->_default_error_mode; + $options = $this->_default_error_options; + // Global error handler + } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { + $mode = $GLOBALS['_PEAR_default_error_mode']; + $options = $GLOBALS['_PEAR_default_error_options']; + } + } + + if ($error_class !== null) { + $ec = $error_class; + } elseif (isset($this) && isset($this->_error_class)) { + $ec = $this->_error_class; + } else { + $ec = 'PEAR_Error'; + } + if ($skipmsg) { + $a = &new $ec($code, $mode, $options, $userinfo); + return $a; + } else { + $a = &new $ec($message, $code, $mode, $options, $userinfo); + return $a; + } + } + + // }}} + // {{{ throwError() + + /** + * Simpler form of raiseError with fewer options. In most cases + * message, code and userinfo are enough. + * + * @param string $message + * + */ + function &throwError($message = null, + $code = null, + $userinfo = null) + { + if (isset($this) && is_a($this, 'PEAR')) { + $a = &$this->raiseError($message, $code, null, null, $userinfo); + return $a; + } else { + $a = &PEAR::raiseError($message, $code, null, null, $userinfo); + return $a; + } + } + + // }}} + function staticPushErrorHandling($mode, $options = null) + { + $stack = &$GLOBALS['_PEAR_error_handler_stack']; + $def_mode = &$GLOBALS['_PEAR_default_error_mode']; + $def_options = &$GLOBALS['_PEAR_default_error_options']; + $stack[] = array($def_mode, $def_options); + switch ($mode) { + case PEAR_ERROR_EXCEPTION: + case PEAR_ERROR_RETURN: + case PEAR_ERROR_PRINT: + case PEAR_ERROR_TRIGGER: + case PEAR_ERROR_DIE: + case null: + $def_mode = $mode; + $def_options = $options; + break; + + case PEAR_ERROR_CALLBACK: + $def_mode = $mode; + // class/object method callback + if (is_callable($options)) { + $def_options = $options; + } else { + trigger_error("invalid error callback", E_USER_WARNING); + } + break; + + default: + trigger_error("invalid error mode", E_USER_WARNING); + break; + } + $stack[] = array($mode, $options); + return true; + } + + function staticPopErrorHandling() + { + $stack = &$GLOBALS['_PEAR_error_handler_stack']; + $setmode = &$GLOBALS['_PEAR_default_error_mode']; + $setoptions = &$GLOBALS['_PEAR_default_error_options']; + array_pop($stack); + list($mode, $options) = $stack[sizeof($stack) - 1]; + array_pop($stack); + switch ($mode) { + case PEAR_ERROR_EXCEPTION: + case PEAR_ERROR_RETURN: + case PEAR_ERROR_PRINT: + case PEAR_ERROR_TRIGGER: + case PEAR_ERROR_DIE: + case null: + $setmode = $mode; + $setoptions = $options; + break; + + case PEAR_ERROR_CALLBACK: + $setmode = $mode; + // class/object method callback + if (is_callable($options)) { + $setoptions = $options; + } else { + trigger_error("invalid error callback", E_USER_WARNING); + } + break; + + default: + trigger_error("invalid error mode", E_USER_WARNING); + break; + } + return true; + } + + // {{{ pushErrorHandling() + + /** + * Push a new error handler on top of the error handler options stack. With this + * you can easily override the actual error handler for some code and restore + * it later with popErrorHandling. + * + * @param mixed $mode (same as setErrorHandling) + * @param mixed $options (same as setErrorHandling) + * + * @return bool Always true + * + * @see PEAR::setErrorHandling + */ + function pushErrorHandling($mode, $options = null) + { + $stack = &$GLOBALS['_PEAR_error_handler_stack']; + if (isset($this) && is_a($this, 'PEAR')) { + $def_mode = &$this->_default_error_mode; + $def_options = &$this->_default_error_options; + } else { + $def_mode = &$GLOBALS['_PEAR_default_error_mode']; + $def_options = &$GLOBALS['_PEAR_default_error_options']; + } + $stack[] = array($def_mode, $def_options); + + if (isset($this) && is_a($this, 'PEAR')) { + $this->setErrorHandling($mode, $options); + } else { + PEAR::setErrorHandling($mode, $options); + } + $stack[] = array($mode, $options); + return true; + } + + // }}} + // {{{ popErrorHandling() + + /** + * Pop the last error handler used + * + * @return bool Always true + * + * @see PEAR::pushErrorHandling + */ + function popErrorHandling() + { + $stack = &$GLOBALS['_PEAR_error_handler_stack']; + array_pop($stack); + list($mode, $options) = $stack[sizeof($stack) - 1]; + array_pop($stack); + if (isset($this) && is_a($this, 'PEAR')) { + $this->setErrorHandling($mode, $options); + } else { + PEAR::setErrorHandling($mode, $options); + } + return true; + } + + // }}} + // {{{ loadExtension() + + /** + * OS independant PHP extension load. Remember to take care + * on the correct extension name for case sensitive OSes. + * + * @param string $ext The extension name + * @return bool Success or not on the dl() call + */ + function loadExtension($ext) + { + if (!extension_loaded($ext)) { + // if either returns true dl() will produce a FATAL error, stop that + if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { + return false; + } + if (OS_WINDOWS) { + $suffix = '.dll'; + } elseif (PHP_OS == 'HP-UX') { + $suffix = '.sl'; + } elseif (PHP_OS == 'AIX') { + $suffix = '.a'; + } elseif (PHP_OS == 'OSX') { + $suffix = '.bundle'; + } else { + $suffix = '.so'; + } + return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); + } + return true; + } + + // }}} +} + +// {{{ _PEAR_call_destructors() + +function _PEAR_call_destructors() +{ + global $_PEAR_destructor_object_list; + if (is_array($_PEAR_destructor_object_list) && + sizeof($_PEAR_destructor_object_list)) + { + reset($_PEAR_destructor_object_list); + if (@PEAR::getStaticProperty('PEAR', 'destructlifo')) { + $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); + } + while (list($k, $objref) = each($_PEAR_destructor_object_list)) { + $classname = get_class($objref); + while ($classname) { + $destructor = "_$classname"; + if (method_exists($objref, $destructor)) { + $objref->$destructor(); + break; + } else { + $classname = get_parent_class($classname); + } + } + } + // Empty the object list to ensure that destructors are + // not called more than once. + $_PEAR_destructor_object_list = array(); + } + + // Now call the shutdown functions + if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) { + foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { + call_user_func_array($value[0], $value[1]); + } + } +} + +// }}} +/** + * Standard PEAR error class for PHP 4 + * + * This class is supserseded by {@link PEAR_Exception} in PHP 5 + * + * @category pear + * @package PEAR + * @author Stig Bakken + * @author Tomas V.V. Cox + * @author Gregory Beaver + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: 1.4.11 + * @link http://pear.php.net/manual/en/core.pear.pear-error.php + * @see PEAR::raiseError(), PEAR::throwError() + * @since Class available since PHP 4.0.2 + */ +class PEAR_Error +{ + // {{{ properties + + var $error_message_prefix = ''; + var $mode = PEAR_ERROR_RETURN; + var $level = E_USER_NOTICE; + var $code = -1; + var $message = ''; + var $userinfo = ''; + var $backtrace = null; + + // }}} + // {{{ constructor + + /** + * PEAR_Error constructor + * + * @param string $message message + * + * @param int $code (optional) error code + * + * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, + * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, + * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION + * + * @param mixed $options (optional) error level, _OR_ in the case of + * PEAR_ERROR_CALLBACK, the callback function or object/method + * tuple. + * + * @param string $userinfo (optional) additional user/debug info + * + * @access public + * + */ + function PEAR_Error($message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null) + { + if ($mode === null) { + $mode = PEAR_ERROR_RETURN; + } + $this->message = $message; + $this->code = $code; + $this->mode = $mode; + $this->userinfo = $userinfo; + if (function_exists("debug_backtrace")) { + if (@!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) { + $this->backtrace = debug_backtrace(); + } + } + if ($mode & PEAR_ERROR_CALLBACK) { + $this->level = E_USER_NOTICE; + $this->callback = $options; + } else { + if ($options === null) { + $options = E_USER_NOTICE; + } + $this->level = $options; + $this->callback = null; + } + if ($this->mode & PEAR_ERROR_PRINT) { + if (is_null($options) || is_int($options)) { + $format = "%s"; + } else { + $format = $options; + } + printf($format, $this->getMessage()); + } + if ($this->mode & PEAR_ERROR_TRIGGER) { + trigger_error($this->getMessage(), $this->level); + } + if ($this->mode & PEAR_ERROR_DIE) { + $msg = $this->getMessage(); + if (is_null($options) || is_int($options)) { + $format = "%s"; + if (substr($msg, -1) != "\n") { + $msg .= "\n"; + } + } else { + $format = $options; + } + die(sprintf($format, $msg)); + } + if ($this->mode & PEAR_ERROR_CALLBACK) { + if (is_callable($this->callback)) { + call_user_func($this->callback, $this); + } + } + if ($this->mode & PEAR_ERROR_EXCEPTION) { + trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); + eval('$e = new Exception($this->message, $this->code);throw($e);'); + } + } + + // }}} + // {{{ getMode() + + /** + * Get the error mode from an error object. + * + * @return int error mode + * @access public + */ + function getMode() { + return $this->mode; + } + + // }}} + // {{{ getCallback() + + /** + * Get the callback function/method from an error object. + * + * @return mixed callback function or object/method array + * @access public + */ + function getCallback() { + return $this->callback; + } + + // }}} + // {{{ getMessage() + + + /** + * Get the error message from an error object. + * + * @return string full error message + * @access public + */ + function getMessage() + { + return ($this->error_message_prefix . $this->message); + } + + + // }}} + // {{{ getCode() + + /** + * Get error code from an error object + * + * @return int error code + * @access public + */ + function getCode() + { + return $this->code; + } + + // }}} + // {{{ getType() + + /** + * Get the name of this error/exception. + * + * @return string error/exception name (type) + * @access public + */ + function getType() + { + return get_class($this); + } + + // }}} + // {{{ getUserInfo() + + /** + * Get additional user-supplied information. + * + * @return string user-supplied information + * @access public + */ + function getUserInfo() + { + return $this->userinfo; + } + + // }}} + // {{{ getDebugInfo() + + /** + * Get additional debug information supplied by the application. + * + * @return string debug information + * @access public + */ + function getDebugInfo() + { + return $this->getUserInfo(); + } + + // }}} + // {{{ getBacktrace() + + /** + * Get the call backtrace from where the error was generated. + * Supported with PHP 4.3.0 or newer. + * + * @param int $frame (optional) what frame to fetch + * @return array Backtrace, or NULL if not available. + * @access public + */ + function getBacktrace($frame = null) + { + if (defined('PEAR_IGNORE_BACKTRACE')) { + return null; + } + if ($frame === null) { + return $this->backtrace; + } + return $this->backtrace[$frame]; + } + + // }}} + // {{{ addUserInfo() + + function addUserInfo($info) + { + if (empty($this->userinfo)) { + $this->userinfo = $info; + } else { + $this->userinfo .= " ** $info"; + } + } + + // }}} + // {{{ toString() + + /** + * Make a string representation of this object. + * + * @return string a string with an object summary + * @access public + */ + function toString() { + $modes = array(); + $levels = array(E_USER_NOTICE => 'notice', + E_USER_WARNING => 'warning', + E_USER_ERROR => 'error'); + if ($this->mode & PEAR_ERROR_CALLBACK) { + if (is_array($this->callback)) { + $callback = (is_object($this->callback[0]) ? + strtolower(get_class($this->callback[0])) : + $this->callback[0]) . '::' . + $this->callback[1]; + } else { + $callback = $this->callback; + } + return sprintf('[%s: message="%s" code=%d mode=callback '. + 'callback=%s prefix="%s" info="%s"]', + strtolower(get_class($this)), $this->message, $this->code, + $callback, $this->error_message_prefix, + $this->userinfo); + } + if ($this->mode & PEAR_ERROR_PRINT) { + $modes[] = 'print'; + } + if ($this->mode & PEAR_ERROR_TRIGGER) { + $modes[] = 'trigger'; + } + if ($this->mode & PEAR_ERROR_DIE) { + $modes[] = 'die'; + } + if ($this->mode & PEAR_ERROR_RETURN) { + $modes[] = 'return'; + } + return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. + 'prefix="%s" info="%s"]', + strtolower(get_class($this)), $this->message, $this->code, + implode("|", $modes), $levels[$this->level], + $this->error_message_prefix, + $this->userinfo); + } + + // }}} +} + +/* + * Local Variables: + * mode: php + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ +?> diff --git a/htdocs/includes/nusoap/lib/Mail/RFC822.php b/htdocs/includes/nusoap/lib/Mail/RFC822.php new file mode 100755 index 00000000000..90f4db5af8b --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/RFC822.php @@ -0,0 +1,923 @@ + | +// | Chuck Hagenbuch | +// +-----------------------------------------------------------------------+ + +/** + * RFC 822 Email address list validation Utility + * + * What is it? + * + * This class will take an address string, and parse it into it's consituent + * parts, be that either addresses, groups, or combinations. Nested groups + * are not supported. The structure it returns is pretty straight forward, + * and is similar to that provided by the imap_rfc822_parse_adrlist(). Use + * print_r() to view the structure. + * + * How do I use it? + * + * $address_string = 'My Group: "Richard" (A comment), ted@example.com (Ted Bloggs), Barney;'; + * $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', true) + * print_r($structure); + * + * @author Richard Heyes + * @author Chuck Hagenbuch + * @version $Revision$ + * @license BSD + * @package Mail + */ +class Mail_RFC822 { + + /** + * The address being parsed by the RFC822 object. + * @var string $address + */ + var $address = ''; + + /** + * The default domain to use for unqualified addresses. + * @var string $default_domain + */ + var $default_domain = 'localhost'; + + /** + * Should we return a nested array showing groups, or flatten everything? + * @var boolean $nestGroups + */ + var $nestGroups = true; + + /** + * Whether or not to validate atoms for non-ascii characters. + * @var boolean $validate + */ + var $validate = true; + + /** + * The array of raw addresses built up as we parse. + * @var array $addresses + */ + var $addresses = array(); + + /** + * The final array of parsed address information that we build up. + * @var array $structure + */ + var $structure = array(); + + /** + * The current error message, if any. + * @var string $error + */ + var $error = null; + + /** + * An internal counter/pointer. + * @var integer $index + */ + var $index = null; + + /** + * The number of groups that have been found in the address list. + * @var integer $num_groups + * @access public + */ + var $num_groups = 0; + + /** + * A variable so that we can tell whether or not we're inside a + * Mail_RFC822 object. + * @var boolean $mailRFC822 + */ + var $mailRFC822 = true; + + /** + * A limit after which processing stops + * @var int $limit + */ + var $limit = null; + + /** + * Sets up the object. The address must either be set here or when + * calling parseAddressList(). One or the other. + * + * @access public + * @param string $address The address(es) to validate. + * @param string $default_domain Default domain/host etc. If not supplied, will be set to localhost. + * @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing. + * @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance. + * + * @return object Mail_RFC822 A new Mail_RFC822 object. + */ + function Mail_RFC822($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null) + { + if (isset($address)) $this->address = $address; + if (isset($default_domain)) $this->default_domain = $default_domain; + if (isset($nest_groups)) $this->nestGroups = $nest_groups; + if (isset($validate)) $this->validate = $validate; + if (isset($limit)) $this->limit = $limit; + } + + /** + * Starts the whole process. The address must either be set here + * or when creating the object. One or the other. + * + * @access public + * @param string $address The address(es) to validate. + * @param string $default_domain Default domain/host etc. + * @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing. + * @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance. + * + * @return array A structured array of addresses. + */ + function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null) + { + if (!isset($this) || !isset($this->mailRFC822)) { + $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit); + return $obj->parseAddressList(); + } + + if (isset($address)) $this->address = $address; + if (isset($default_domain)) $this->default_domain = $default_domain; + if (isset($nest_groups)) $this->nestGroups = $nest_groups; + if (isset($validate)) $this->validate = $validate; + if (isset($limit)) $this->limit = $limit; + + $this->structure = array(); + $this->addresses = array(); + $this->error = null; + $this->index = null; + + // Unfold any long lines in $this->address. + $this->address = preg_replace('/\r?\n/', "\r\n", $this->address); + $this->address = preg_replace('/\r\n(\t| )+/', ' ', $this->address); + + while ($this->address = $this->_splitAddresses($this->address)); + + if ($this->address === false || isset($this->error)) { + require_once 'PEAR.php'; + return PEAR::raiseError($this->error); + } + + // Validate each address individually. If we encounter an invalid + // address, stop iterating and return an error immediately. + foreach ($this->addresses as $address) { + $valid = $this->_validateAddress($address); + + if ($valid === false || isset($this->error)) { + require_once 'PEAR.php'; + return PEAR::raiseError($this->error); + } + + if (!$this->nestGroups) { + $this->structure = array_merge($this->structure, $valid); + } else { + $this->structure[] = $valid; + } + } + + return $this->structure; + } + + /** + * Splits an address into separate addresses. + * + * @access private + * @param string $address The addresses to split. + * @return boolean Success or failure. + */ + function _splitAddresses($address) + { + if (!empty($this->limit) && count($this->addresses) == $this->limit) { + return ''; + } + + if ($this->_isGroup($address) && !isset($this->error)) { + $split_char = ';'; + $is_group = true; + } elseif (!isset($this->error)) { + $split_char = ','; + $is_group = false; + } elseif (isset($this->error)) { + return false; + } + + // Split the string based on the above ten or so lines. + $parts = explode($split_char, $address); + $string = $this->_splitCheck($parts, $split_char); + + // If a group... + if ($is_group) { + // If $string does not contain a colon outside of + // brackets/quotes etc then something's fubar. + + // First check there's a colon at all: + if (strpos($string, ':') === false) { + $this->error = 'Invalid address: ' . $string; + return false; + } + + // Now check it's outside of brackets/quotes: + if (!$this->_splitCheck(explode(':', $string), ':')) { + return false; + } + + // We must have a group at this point, so increase the counter: + $this->num_groups++; + } + + // $string now contains the first full address/group. + // Add to the addresses array. + $this->addresses[] = array( + 'address' => trim($string), + 'group' => $is_group + ); + + // Remove the now stored address from the initial line, the +1 + // is to account for the explode character. + $address = trim(substr($address, strlen($string) + 1)); + + // If the next char is a comma and this was a group, then + // there are more addresses, otherwise, if there are any more + // chars, then there is another address. + if ($is_group && substr($address, 0, 1) == ','){ + $address = trim(substr($address, 1)); + return $address; + + } elseif (strlen($address) > 0) { + return $address; + + } else { + return ''; + } + + // If you got here then something's off + return false; + } + + /** + * Checks for a group at the start of the string. + * + * @access private + * @param string $address The address to check. + * @return boolean Whether or not there is a group at the start of the string. + */ + function _isGroup($address) + { + // First comma not in quotes, angles or escaped: + $parts = explode(',', $address); + $string = $this->_splitCheck($parts, ','); + + // Now we have the first address, we can reliably check for a + // group by searching for a colon that's not escaped or in + // quotes or angle brackets. + if (count($parts = explode(':', $string)) > 1) { + $string2 = $this->_splitCheck($parts, ':'); + return ($string2 !== $string); + } else { + return false; + } + } + + /** + * A common function that will check an exploded string. + * + * @access private + * @param array $parts The exloded string. + * @param string $char The char that was exploded on. + * @return mixed False if the string contains unclosed quotes/brackets, or the string on success. + */ + function _splitCheck($parts, $char) + { + $string = $parts[0]; + + for ($i = 0; $i < count($parts); $i++) { + if ($this->_hasUnclosedQuotes($string) + || $this->_hasUnclosedBrackets($string, '<>') + || $this->_hasUnclosedBrackets($string, '[]') + || $this->_hasUnclosedBrackets($string, '()') + || substr($string, -1) == '\\') { + if (isset($parts[$i + 1])) { + $string = $string . $char . $parts[$i + 1]; + } else { + $this->error = 'Invalid address spec. Unclosed bracket or quotes'; + return false; + } + } else { + $this->index = $i; + break; + } + } + + return $string; + } + + /** + * Checks if a string has an unclosed quotes or not. + * + * @access private + * @param string $string The string to check. + * @return boolean True if there are unclosed quotes inside the string, false otherwise. + */ + function _hasUnclosedQuotes($string) + { + $string = explode('"', $string); + $string_cnt = count($string); + + for ($i = 0; $i < (count($string) - 1); $i++) + if (substr($string[$i], -1) == '\\') + $string_cnt--; + + return ($string_cnt % 2 === 0); + } + + /** + * Checks if a string has an unclosed brackets or not. IMPORTANT: + * This function handles both angle brackets and square brackets; + * + * @access private + * @param string $string The string to check. + * @param string $chars The characters to check for. + * @return boolean True if there are unclosed brackets inside the string, false otherwise. + */ + function _hasUnclosedBrackets($string, $chars) + { + $num_angle_start = substr_count($string, $chars[0]); + $num_angle_end = substr_count($string, $chars[1]); + + $this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]); + $this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]); + + if ($num_angle_start < $num_angle_end) { + $this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')'; + return false; + } else { + return ($num_angle_start > $num_angle_end); + } + } + + /** + * Sub function that is used only by hasUnclosedBrackets(). + * + * @access private + * @param string $string The string to check. + * @param integer &$num The number of occurences. + * @param string $char The character to count. + * @return integer The number of occurences of $char in $string, adjusted for backslashes. + */ + function _hasUnclosedBracketsSub($string, &$num, $char) + { + $parts = explode($char, $string); + for ($i = 0; $i < count($parts); $i++){ + if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i])) + $num--; + if (isset($parts[$i + 1])) + $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1]; + } + + return $num; + } + + /** + * Function to begin checking the address. + * + * @access private + * @param string $address The address to validate. + * @return mixed False on failure, or a structured array of address information on success. + */ + function _validateAddress($address) + { + $is_group = false; + $addresses = array(); + + if ($address['group']) { + $is_group = true; + + // Get the group part of the name + $parts = explode(':', $address['address']); + $groupname = $this->_splitCheck($parts, ':'); + $structure = array(); + + // And validate the group part of the name. + if (!$this->_validatePhrase($groupname)){ + $this->error = 'Group name did not validate.'; + return false; + } else { + // Don't include groups if we are not nesting + // them. This avoids returning invalid addresses. + if ($this->nestGroups) { + $structure = new stdClass; + $structure->groupname = $groupname; + } + } + + $address['address'] = ltrim(substr($address['address'], strlen($groupname . ':'))); + } + + // If a group then split on comma and put into an array. + // Otherwise, Just put the whole address in an array. + if ($is_group) { + while (strlen($address['address']) > 0) { + $parts = explode(',', $address['address']); + $addresses[] = $this->_splitCheck($parts, ','); + $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ','))); + } + } else { + $addresses[] = $address['address']; + } + + // Check that $addresses is set, if address like this: + // Groupname:; + // Then errors were appearing. + if (!count($addresses)){ + $this->error = 'Empty group.'; + return false; + } + + // Trim the whitespace from all of the address strings. + array_map('trim', $addresses); + + // Validate each mailbox. + // Format could be one of: name + // geezer@domain.com + // geezer + // ... or any other format valid by RFC 822. + for ($i = 0; $i < count($addresses); $i++) { + if (!$this->validateMailbox($addresses[$i])) { + if (empty($this->error)) { + $this->error = 'Validation failed for: ' . $addresses[$i]; + } + return false; + } + } + + // Nested format + if ($this->nestGroups) { + if ($is_group) { + $structure->addresses = $addresses; + } else { + $structure = $addresses[0]; + } + + // Flat format + } else { + if ($is_group) { + $structure = array_merge($structure, $addresses); + } else { + $structure = $addresses; + } + } + + return $structure; + } + + /** + * Function to validate a phrase. + * + * @access private + * @param string $phrase The phrase to check. + * @return boolean Success or failure. + */ + function _validatePhrase($phrase) + { + // Splits on one or more Tab or space. + $parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY); + + $phrase_parts = array(); + while (count($parts) > 0){ + $phrase_parts[] = $this->_splitCheck($parts, ' '); + for ($i = 0; $i < $this->index + 1; $i++) + array_shift($parts); + } + + foreach ($phrase_parts as $part) { + // If quoted string: + if (substr($part, 0, 1) == '"') { + if (!$this->_validateQuotedString($part)) { + return false; + } + continue; + } + + // Otherwise it's an atom: + if (!$this->_validateAtom($part)) return false; + } + + return true; + } + + /** + * Function to validate an atom which from rfc822 is: + * atom = 1* + * + * If validation ($this->validate) has been turned off, then + * validateAtom() doesn't actually check anything. This is so that you + * can split a list of addresses up before encoding personal names + * (umlauts, etc.), for example. + * + * @access private + * @param string $atom The string to check. + * @return boolean Success or failure. + */ + function _validateAtom($atom) + { + if (!$this->validate) { + // Validation has been turned off; assume the atom is okay. + return true; + } + + // Check for any char from ASCII 0 - ASCII 127 + if (!preg_match('/^[\\x00-\\x7E]+$/i', $atom, $matches)) { + return false; + } + + // Check for specials: + if (preg_match('/[][()<>@,;\\:". ]/', $atom)) { + return false; + } + + // Check for control characters (ASCII 0-31): + if (preg_match('/[\\x00-\\x1F]+/', $atom)) { + return false; + } + + return true; + } + + /** + * Function to validate quoted string, which is: + * quoted-string = <"> *(qtext/quoted-pair) <"> + * + * @access private + * @param string $qstring The string to check + * @return boolean Success or failure. + */ + function _validateQuotedString($qstring) + { + // Leading and trailing " + $qstring = substr($qstring, 1, -1); + + // Perform check, removing quoted characters first. + return !preg_match('/[\x0D\\\\"]/', preg_replace('/\\\\./', '', $qstring)); + } + + /** + * Function to validate a mailbox, which is: + * mailbox = addr-spec ; simple address + * / phrase route-addr ; name and route-addr + * + * @access public + * @param string &$mailbox The string to check. + * @return boolean Success or failure. + */ + function validateMailbox(&$mailbox) + { + // A couple of defaults. + $phrase = ''; + $comment = ''; + $comments = array(); + + // Catch any RFC822 comments and store them separately. + $_mailbox = $mailbox; + while (strlen(trim($_mailbox)) > 0) { + $parts = explode('(', $_mailbox); + $before_comment = $this->_splitCheck($parts, '('); + if ($before_comment != $_mailbox) { + // First char should be a (. + $comment = substr(str_replace($before_comment, '', $_mailbox), 1); + $parts = explode(')', $comment); + $comment = $this->_splitCheck($parts, ')'); + $comments[] = $comment; + + // +1 is for the trailing ) + $_mailbox = substr($_mailbox, strpos($_mailbox, $comment)+strlen($comment)+1); + } else { + break; + } + } + + foreach ($comments as $comment) { + $mailbox = str_replace("($comment)", '', $mailbox); + } + + $mailbox = trim($mailbox); + + // Check for name + route-addr + if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') { + $parts = explode('<', $mailbox); + $name = $this->_splitCheck($parts, '<'); + + $phrase = trim($name); + $route_addr = trim(substr($mailbox, strlen($name.'<'), -1)); + + if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false) { + return false; + } + + // Only got addr-spec + } else { + // First snip angle brackets if present. + if (substr($mailbox, 0, 1) == '<' && substr($mailbox, -1) == '>') { + $addr_spec = substr($mailbox, 1, -1); + } else { + $addr_spec = $mailbox; + } + + if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { + return false; + } + } + + // Construct the object that will be returned. + $mbox = new stdClass(); + + // Add the phrase (even if empty) and comments + $mbox->personal = $phrase; + $mbox->comment = isset($comments) ? $comments : array(); + + if (isset($route_addr)) { + $mbox->mailbox = $route_addr['local_part']; + $mbox->host = $route_addr['domain']; + $route_addr['adl'] !== '' ? $mbox->adl = $route_addr['adl'] : ''; + } else { + $mbox->mailbox = $addr_spec['local_part']; + $mbox->host = $addr_spec['domain']; + } + + $mailbox = $mbox; + return true; + } + + /** + * This function validates a route-addr which is: + * route-addr = "<" [route] addr-spec ">" + * + * Angle brackets have already been removed at the point of + * getting to this function. + * + * @access private + * @param string $route_addr The string to check. + * @return mixed False on failure, or an array containing validated address/route information on success. + */ + function _validateRouteAddr($route_addr) + { + // Check for colon. + if (strpos($route_addr, ':') !== false) { + $parts = explode(':', $route_addr); + $route = $this->_splitCheck($parts, ':'); + } else { + $route = $route_addr; + } + + // If $route is same as $route_addr then the colon was in + // quotes or brackets or, of course, non existent. + if ($route === $route_addr){ + unset($route); + $addr_spec = $route_addr; + if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { + return false; + } + } else { + // Validate route part. + if (($route = $this->_validateRoute($route)) === false) { + return false; + } + + $addr_spec = substr($route_addr, strlen($route . ':')); + + // Validate addr-spec part. + if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { + return false; + } + } + + if (isset($route)) { + $return['adl'] = $route; + } else { + $return['adl'] = ''; + } + + $return = array_merge($return, $addr_spec); + return $return; + } + + /** + * Function to validate a route, which is: + * route = 1#("@" domain) ":" + * + * @access private + * @param string $route The string to check. + * @return mixed False on failure, or the validated $route on success. + */ + function _validateRoute($route) + { + // Split on comma. + $domains = explode(',', trim($route)); + + foreach ($domains as $domain) { + $domain = str_replace('@', '', trim($domain)); + if (!$this->_validateDomain($domain)) return false; + } + + return $route; + } + + /** + * Function to validate a domain, though this is not quite what + * you expect of a strict internet domain. + * + * domain = sub-domain *("." sub-domain) + * + * @access private + * @param string $domain The string to check. + * @return mixed False on failure, or the validated domain on success. + */ + function _validateDomain($domain) + { + // Note the different use of $subdomains and $sub_domains + $subdomains = explode('.', $domain); + + while (count($subdomains) > 0) { + $sub_domains[] = $this->_splitCheck($subdomains, '.'); + for ($i = 0; $i < $this->index + 1; $i++) + array_shift($subdomains); + } + + foreach ($sub_domains as $sub_domain) { + if (!$this->_validateSubdomain(trim($sub_domain))) + return false; + } + + // Managed to get here, so return input. + return $domain; + } + + /** + * Function to validate a subdomain: + * subdomain = domain-ref / domain-literal + * + * @access private + * @param string $subdomain The string to check. + * @return boolean Success or failure. + */ + function _validateSubdomain($subdomain) + { + if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){ + if (!$this->_validateDliteral($arr[1])) return false; + } else { + if (!$this->_validateAtom($subdomain)) return false; + } + + // Got here, so return successful. + return true; + } + + /** + * Function to validate a domain literal: + * domain-literal = "[" *(dtext / quoted-pair) "]" + * + * @access private + * @param string $dliteral The string to check. + * @return boolean Success or failure. + */ + function _validateDliteral($dliteral) + { + return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\'; + } + + /** + * Function to validate an addr-spec. + * + * addr-spec = local-part "@" domain + * + * @access private + * @param string $addr_spec The string to check. + * @return mixed False on failure, or the validated addr-spec on success. + */ + function _validateAddrSpec($addr_spec) + { + $addr_spec = trim($addr_spec); + + // Split on @ sign if there is one. + if (strpos($addr_spec, '@') !== false) { + $parts = explode('@', $addr_spec); + $local_part = $this->_splitCheck($parts, '@'); + $domain = substr($addr_spec, strlen($local_part . '@')); + + // No @ sign so assume the default domain. + } else { + $local_part = $addr_spec; + $domain = $this->default_domain; + } + + if (($local_part = $this->_validateLocalPart($local_part)) === false) return false; + if (($domain = $this->_validateDomain($domain)) === false) return false; + + // Got here so return successful. + return array('local_part' => $local_part, 'domain' => $domain); + } + + /** + * Function to validate the local part of an address: + * local-part = word *("." word) + * + * @access private + * @param string $local_part + * @return mixed False on failure, or the validated local part on success. + */ + function _validateLocalPart($local_part) + { + $parts = explode('.', $local_part); + $words = array(); + + // Split the local_part into words. + while (count($parts) > 0){ + $words[] = $this->_splitCheck($parts, '.'); + for ($i = 0; $i < $this->index + 1; $i++) { + array_shift($parts); + } + } + + // Validate each word. + foreach ($words as $word) { + // If this word contains an unquoted space, it is invalid. (6.2.4) + if (strpos($word, ' ') && $word[0] !== '"') + { + return false; + } + + if ($this->_validatePhrase(trim($word)) === false) return false; + } + + // Managed to get here, so return the input. + return $local_part; + } + + /** + * Returns an approximate count of how many addresses are in the + * given string. This is APPROXIMATE as it only splits based on a + * comma which has no preceding backslash. Could be useful as + * large amounts of addresses will end up producing *large* + * structures when used with parseAddressList(). + * + * @param string $data Addresses to count + * @return int Approximate count + */ + function approximateCount($data) + { + return count(preg_split('/(?@. This can be sufficient for most + * people. Optional stricter mode can be utilised which restricts + * mailbox characters allowed to alphanumeric, full stop, hyphen + * and underscore. + * + * @param string $data Address to check + * @param boolean $strict Optional stricter mode + * @return mixed False if it fails, an indexed array + * username/domain if it matches + */ + function isValidInetAddress($data, $strict = false) + { + $regex = $strict ? '/^([.0-9a-z_-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i'; + if (preg_match($regex, trim($data), $matches)) { + return array($matches[1], $matches[2]); + } else { + return false; + } + } + +} diff --git a/htdocs/includes/nusoap/lib/Mail/mail.php b/htdocs/includes/nusoap/lib/Mail/mail.php new file mode 100755 index 00000000000..6c06f791879 --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/mail.php @@ -0,0 +1,130 @@ + | +// +----------------------------------------------------------------------+ +// +// $Id$ + +/** + * internal PHP-mail() implementation of the PEAR Mail:: interface. + * @package Mail + * @version $Revision$ + */ +class Mail_mail extends Mail { + + /** + * Any arguments to pass to the mail() function. + * @var string + */ + var $_params = ''; + + /** + * Constructor. + * + * Instantiates a new Mail_mail:: object based on the parameters + * passed in. + * + * @param array $params Extra arguments for the mail() function. + */ + function Mail_mail($params = null) + { + /* The other mail implementations accept parameters as arrays. + * In the interest of being consistent, explode an array into + * a string of parameter arguments. */ + if (is_array($params)) { + $this->_params = join(' ', $params); + } else { + $this->_params = $params; + } + + /* Because the mail() function may pass headers as command + * line arguments, we can't guarantee the use of the standard + * "\r\n" separator. Instead, we use the system's native line + * separator. */ + $this->sep = (strstr(PHP_OS, 'WIN')) ? "\r\n" : "\n"; + } + + /** + * Implements Mail_mail::send() function using php's built-in mail() + * command. + * + * @param mixed $recipients Either a comma-seperated list of recipients + * (RFC822 compliant), or an array of recipients, + * each RFC822 valid. This may contain recipients not + * specified in the headers, for Bcc:, resending + * messages, etc. + * + * @param array $headers The array of headers to send with the mail, in an + * associative array, where the array key is the + * header name (ie, 'Subject'), and the array value + * is the header value (ie, 'test'). The header + * produced from those values would be 'Subject: + * test'. + * + * @param string $body The full text of the message body, including any + * Mime parts, etc. + * + * @return mixed Returns true on success, or a PEAR_Error + * containing a descriptive error message on + * failure. + * + * @access public + */ + function send($recipients, $headers, $body) + { + // If we're passed an array of recipients, implode it. + if (is_array($recipients)) { + $recipients = implode(', ', $recipients); + } + + // Get the Subject out of the headers array so that we can + // pass it as a seperate argument to mail(). + $subject = ''; + if (isset($headers['Subject'])) { + $subject = $headers['Subject']; + unset($headers['Subject']); + } + + // Flatten the headers out. + $headerElements = $this->prepareHeaders($headers); + if (PEAR::isError($headerElements)) { + return $headerElements; + } + list(, $text_headers) = $headerElements; + + /* + * We only use mail()'s optional fifth parameter if the additional + * parameters have been provided and we're not running in safe mode. + */ + if (empty($this->_params) || ini_get('safe_mode')) { + $result = mail($recipients, $subject, $body, $text_headers); + } else { + $result = mail($recipients, $subject, $body, $text_headers, + $this->_params); + } + + /* + * If the mail() function returned failure, we need to create a + * PEAR_Error object and return it instead of the boolean result. + */ + if ($result === false) { + $result = PEAR::raiseError('mail() returned failure'); + } + + return $result; + } + +} diff --git a/htdocs/includes/nusoap/lib/Mail/mime.php b/htdocs/includes/nusoap/lib/Mail/mime.php new file mode 100755 index 00000000000..a7f4070dbde --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/mime.php @@ -0,0 +1,713 @@ + | +// | Tomas V.V.Cox (port to PEAR) | +// +-----------------------------------------------------------------------+ +// +// $Id$ + +require_once('PEAR.php'); +require_once('Mail/mimePart.php'); + +/** + * Mime mail composer class. Can handle: text and html bodies, embedded html + * images and attachments. + * Documentation and examples of this class are avaible here: + * http://pear.php.net/manual/ + * + * @notes This class is based on HTML Mime Mail class from + * Richard Heyes which was based also + * in the mime_mail.class by Tobias Ratschiller and + * Sascha Schumann + * + * @author Richard Heyes + * @author Tomas V.V.Cox + * @package Mail + * @access public + */ +class Mail_mime +{ + /** + * Contains the plain text part of the email + * @var string + */ + var $_txtbody; + /** + * Contains the html part of the email + * @var string + */ + var $_htmlbody; + /** + * contains the mime encoded text + * @var string + */ + var $_mime; + /** + * contains the multipart content + * @var string + */ + var $_multipart; + /** + * list of the attached images + * @var array + */ + var $_html_images = array(); + /** + * list of the attachements + * @var array + */ + var $_parts = array(); + /** + * Build parameters + * @var array + */ + var $_build_params = array(); + /** + * Headers for the mail + * @var array + */ + var $_headers = array(); + /** + * End Of Line sequence (for serialize) + * @var string + */ + var $_eol; + + + /** + * Constructor function + * + * @access public + */ + function Mail_mime($crlf = "\r\n") + { + $this->_setEOL($crlf); + $this->_build_params = array( + 'text_encoding' => '7bit', + 'html_encoding' => 'quoted-printable', + '7bit_wrap' => 998, + 'html_charset' => 'ISO-8859-1', + 'text_charset' => 'ISO-8859-1', + 'head_charset' => 'ISO-8859-1' + ); + } + + /** + * Wakeup (unserialize) - re-sets EOL constant + * + * @access private + */ + function __wakeup() + { + $this->_setEOL($this->_eol); + } + + /** + * Accessor function to set the body text. Body text is used if + * it's not an html mail being sent or else is used to fill the + * text/plain part that emails clients who don't support + * html should show. + * + * @param string $data Either a string or + * the file name with the contents + * @param bool $isfile If true the first param should be treated + * as a file name, else as a string (default) + * @param bool $append If true the text or file is appended to + * the existing body, else the old body is + * overwritten + * @return mixed true on success or PEAR_Error object + * @access public + */ + function setTXTBody($data, $isfile = false, $append = false) + { + if (!$isfile) { + if (!$append) { + $this->_txtbody = $data; + } else { + $this->_txtbody .= $data; + } + } else { + $cont = $this->_file2str($data); + if (PEAR::isError($cont)) { + return $cont; + } + if (!$append) { + $this->_txtbody = $cont; + } else { + $this->_txtbody .= $cont; + } + } + return true; + } + + /** + * Adds a html part to the mail + * + * @param string $data Either a string or the file name with the + * contents + * @param bool $isfile If true the first param should be treated + * as a file name, else as a string (default) + * @return mixed true on success or PEAR_Error object + * @access public + */ + function setHTMLBody($data, $isfile = false) + { + if (!$isfile) { + $this->_htmlbody = $data; + } else { + $cont = $this->_file2str($data); + if (PEAR::isError($cont)) { + return $cont; + } + $this->_htmlbody = $cont; + } + + return true; + } + + /** + * Adds an image to the list of embedded images. + * + * @param string $file The image file name OR image data itself + * @param string $c_type The content type + * @param string $name The filename of the image. + * Only use if $file is the image data + * @param bool $isfilename Whether $file is a filename or not + * Defaults to true + * @return mixed true on success or PEAR_Error object + * @access public + */ + function addHTMLImage($file, $c_type='application/octet-stream', + $name = '', $isfilename = true) + { + $filedata = ($isfilename === true) ? $this->_file2str($file) + : $file; + if ($isfilename === true) { + $filename = ($name == '' ? basename($file) : basename($name)); + } else { + $filename = basename($name); + } + if (PEAR::isError($filedata)) { + return $filedata; + } + $this->_html_images[] = array( + 'body' => $filedata, + 'name' => $filename, + 'c_type' => $c_type, + 'cid' => md5(uniqid(time())) + ); + return true; + } + + /** + * Adds a file to the list of attachments. + * + * @param string $file The file name of the file to attach + * OR the file data itself + * @param string $c_type The content type + * @param string $name The filename of the attachment + * Only use if $file is the file data + * @param bool $isFilename Whether $file is a filename or not + * Defaults to true + * @return mixed true on success or PEAR_Error object + * @access public + */ + function addAttachment($file, $c_type = 'application/octet-stream', + $name = '', $isfilename = true, + $encoding = 'base64') + { + $filedata = ($isfilename === true) ? $this->_file2str($file) + : $file; + if ($isfilename === true) { + // Force the name the user supplied, otherwise use $file + $filename = (!empty($name)) ? $name : $file; + } else { + $filename = $name; + } + if (empty($filename)) { + return PEAR::raiseError( + 'The supplied filename for the attachment can\'t be empty' + ); + } + $filename = basename($filename); + if (PEAR::isError($filedata)) { + return $filedata; + } + + $this->_parts[] = array( + 'body' => $filedata, + 'name' => $filename, + 'c_type' => $c_type, + 'encoding' => $encoding + ); + return true; + } + + /** + * Get the contents of the given file name as string + * + * @param string $file_name path of file to process + * @return string contents of $file_name + * @access private + */ + function &_file2str($file_name) + { + if (!is_readable($file_name)) { + return PEAR::raiseError('File is not readable ' . $file_name); + } + if (!$fd = fopen($file_name, 'rb')) { + return PEAR::raiseError('Could not open ' . $file_name); + } + $filesize = filesize($file_name); + if ($filesize == 0){ + $cont = ""; + }else{ + $cont = fread($fd, $filesize); + } + fclose($fd); + return $cont; + } + + /** + * Adds a text subpart to the mimePart object and + * returns it during the build process. + * + * @param mixed The object to add the part to, or + * null if a new object is to be created. + * @param string The text to add. + * @return object The text mimePart object + * @access private + */ + function &_addTextPart(&$obj, $text) + { + $params['content_type'] = 'text/plain'; + $params['encoding'] = $this->_build_params['text_encoding']; + $params['charset'] = $this->_build_params['text_charset']; + if (is_object($obj)) { + return $obj->addSubpart($text, $params); + } else { + return new Mail_mimePart($text, $params); + } + } + + /** + * Adds a html subpart to the mimePart object and + * returns it during the build process. + * + * @param mixed The object to add the part to, or + * null if a new object is to be created. + * @return object The html mimePart object + * @access private + */ + function &_addHtmlPart(&$obj) + { + $params['content_type'] = 'text/html'; + $params['encoding'] = $this->_build_params['html_encoding']; + $params['charset'] = $this->_build_params['html_charset']; + if (is_object($obj)) { + return $obj->addSubpart($this->_htmlbody, $params); + } else { + return new Mail_mimePart($this->_htmlbody, $params); + } + } + + /** + * Creates a new mimePart object, using multipart/mixed as + * the initial content-type and returns it during the + * build process. + * + * @return object The multipart/mixed mimePart object + * @access private + */ + function &_addMixedPart() + { + $params['content_type'] = 'multipart/mixed'; + return new Mail_mimePart('', $params); + } + + /** + * Adds a multipart/alternative part to a mimePart + * object (or creates one), and returns it during + * the build process. + * + * @param mixed The object to add the part to, or + * null if a new object is to be created. + * @return object The multipart/mixed mimePart object + * @access private + */ + function &_addAlternativePart(&$obj) + { + $params['content_type'] = 'multipart/alternative'; + if (is_object($obj)) { + return $obj->addSubpart('', $params); + } else { + return new Mail_mimePart('', $params); + } + } + + /** + * Adds a multipart/related part to a mimePart + * object (or creates one), and returns it during + * the build process. + * + * @param mixed The object to add the part to, or + * null if a new object is to be created + * @return object The multipart/mixed mimePart object + * @access private + */ + function &_addRelatedPart(&$obj) + { + $params['content_type'] = 'multipart/related'; + if (is_object($obj)) { + return $obj->addSubpart('', $params); + } else { + return new Mail_mimePart('', $params); + } + } + + /** + * Adds an html image subpart to a mimePart object + * and returns it during the build process. + * + * @param object The mimePart to add the image to + * @param array The image information + * @return object The image mimePart object + * @access private + */ + function &_addHtmlImagePart(&$obj, $value) + { + $params['content_type'] = $value['c_type']; + $params['encoding'] = 'base64'; + $params['disposition'] = 'inline'; + $params['dfilename'] = $value['name']; + $params['cid'] = $value['cid']; + $obj->addSubpart($value['body'], $params); + } + + /** + * Adds an attachment subpart to a mimePart object + * and returns it during the build process. + * + * @param object The mimePart to add the image to + * @param array The attachment information + * @return object The image mimePart object + * @access private + */ + function &_addAttachmentPart(&$obj, $value) + { + $params['content_type'] = $value['c_type']; + $params['encoding'] = $value['encoding']; + $params['disposition'] = 'attachment'; + $params['dfilename'] = $value['name']; + $obj->addSubpart($value['body'], $params); + } + + /** + * Builds the multipart message from the list ($this->_parts) and + * returns the mime content. + * + * @param array Build parameters that change the way the email + * is built. Should be associative. Can contain: + * text_encoding - What encoding to use for plain text + * Default is 7bit + * html_encoding - What encoding to use for html + * Default is quoted-printable + * 7bit_wrap - Number of characters before text is + * wrapped in 7bit encoding + * Default is 998 + * html_charset - The character set to use for html. + * Default is iso-8859-1 + * text_charset - The character set to use for text. + * Default is iso-8859-1 + * head_charset - The character set to use for headers. + * Default is iso-8859-1 + * @return string The mime content + * @access public + */ + function &get($build_params = null) + { + if (isset($build_params)) { + while (list($key, $value) = each($build_params)) { + $this->_build_params[$key] = $value; + } + } + + if (!empty($this->_html_images) AND isset($this->_htmlbody)) { + foreach ($this->_html_images as $value) { + $regex = '#(\s)((?i)src|background|href(?-i))\s*=\s*(["\']?)' . preg_quote($value['name'], '#') . + '\3#'; + $rep = '\1\2=\3cid:' . $value['cid'] .'\3'; + $this->_htmlbody = preg_replace($regex, $rep, + $this->_htmlbody + ); + } + } + + $null = null; + $attachments = !empty($this->_parts) ? true : false; + $html_images = !empty($this->_html_images) ? true : false; + $html = !empty($this->_htmlbody) ? true : false; + $text = (!$html AND !empty($this->_txtbody)) ? true : false; + + switch (true) { + case $text AND !$attachments: + $message =& $this->_addTextPart($null, $this->_txtbody); + break; + + case !$text AND !$html AND $attachments: + $message =& $this->_addMixedPart(); + for ($i = 0; $i < count($this->_parts); $i++) { + $this->_addAttachmentPart($message, $this->_parts[$i]); + } + break; + + case $text AND $attachments: + $message =& $this->_addMixedPart(); + $this->_addTextPart($message, $this->_txtbody); + for ($i = 0; $i < count($this->_parts); $i++) { + $this->_addAttachmentPart($message, $this->_parts[$i]); + } + break; + + case $html AND !$attachments AND !$html_images: + if (isset($this->_txtbody)) { + $message =& $this->_addAlternativePart($null); + $this->_addTextPart($message, $this->_txtbody); + $this->_addHtmlPart($message); + } else { + $message =& $this->_addHtmlPart($null); + } + break; + + case $html AND !$attachments AND $html_images: + if (isset($this->_txtbody)) { + $message =& $this->_addAlternativePart($null); + $this->_addTextPart($message, $this->_txtbody); + $related =& $this->_addRelatedPart($message); + } else { + $message =& $this->_addRelatedPart($null); + $related =& $message; + } + $this->_addHtmlPart($related); + for ($i = 0; $i < count($this->_html_images); $i++) { + $this->_addHtmlImagePart($related, $this->_html_images[$i]); + } + break; + + case $html AND $attachments AND !$html_images: + $message =& $this->_addMixedPart(); + if (isset($this->_txtbody)) { + $alt =& $this->_addAlternativePart($message); + $this->_addTextPart($alt, $this->_txtbody); + $this->_addHtmlPart($alt); + } else { + $this->_addHtmlPart($message); + } + for ($i = 0; $i < count($this->_parts); $i++) { + $this->_addAttachmentPart($message, $this->_parts[$i]); + } + break; + + case $html AND $attachments AND $html_images: + $message =& $this->_addMixedPart(); + if (isset($this->_txtbody)) { + $alt =& $this->_addAlternativePart($message); + $this->_addTextPart($alt, $this->_txtbody); + $rel =& $this->_addRelatedPart($alt); + } else { + $rel =& $this->_addRelatedPart($message); + } + $this->_addHtmlPart($rel); + for ($i = 0; $i < count($this->_html_images); $i++) { + $this->_addHtmlImagePart($rel, $this->_html_images[$i]); + } + for ($i = 0; $i < count($this->_parts); $i++) { + $this->_addAttachmentPart($message, $this->_parts[$i]); + } + break; + + } + + if (isset($message)) { + $output = $message->encode(); + $this->_headers = array_merge($this->_headers, + $output['headers']); + return $output['body']; + + } else { + return false; + } + } + + /** + * Returns an array with the headers needed to prepend to the email + * (MIME-Version and Content-Type). Format of argument is: + * $array['header-name'] = 'header-value'; + * + * @param array $xtra_headers Assoc array with any extra headers. + * Optional. + * @return array Assoc array with the mime headers + * @access public + */ + function &headers($xtra_headers = null) + { + // Content-Type header should already be present, + // So just add mime version header + $headers['MIME-Version'] = '1.0'; + if (isset($xtra_headers)) { + $headers = array_merge($headers, $xtra_headers); + } + $this->_headers = array_merge($headers, $this->_headers); + + return $this->_encodeHeaders($this->_headers); + } + + /** + * Get the text version of the headers + * (usefull if you want to use the PHP mail() function) + * + * @param array $xtra_headers Assoc array with any extra headers. + * Optional. + * @return string Plain text headers + * @access public + */ + function txtHeaders($xtra_headers = null) + { + $headers = $this->headers($xtra_headers); + $ret = ''; + foreach ($headers as $key => $val) { + $ret .= "$key: $val" . MAIL_MIME_CRLF; + } + return $ret; + } + + /** + * Sets the Subject header + * + * @param string $subject String to set the subject to + * access public + */ + function setSubject($subject) + { + $this->_headers['Subject'] = $subject; + } + + /** + * Set an email to the From (the sender) header + * + * @param string $email The email direction to add + * @access public + */ + function setFrom($email) + { + $this->_headers['From'] = $email; + } + + /** + * Add an email to the Cc (carbon copy) header + * (multiple calls to this method are allowed) + * + * @param string $email The email direction to add + * @access public + */ + function addCc($email) + { + if (isset($this->_headers['Cc'])) { + $this->_headers['Cc'] .= ", $email"; + } else { + $this->_headers['Cc'] = $email; + } + } + + /** + * Add an email to the Bcc (blank carbon copy) header + * (multiple calls to this method are allowed) + * + * @param string $email The email direction to add + * @access public + */ + function addBcc($email) + { + if (isset($this->_headers['Bcc'])) { + $this->_headers['Bcc'] .= ", $email"; + } else { + $this->_headers['Bcc'] = $email; + } + } + + /** + * Encodes a header as per RFC2047 + * + * @param string $input The header data to encode + * @return string Encoded data + * @access private + */ + function _encodeHeaders($input) + { + foreach ($input as $hdr_name => $hdr_value) { + preg_match_all('/(\w*[\x80-\xFF]+\w*)/', $hdr_value, $matches); + foreach ($matches[1] as $value) { + $replacement = preg_replace('/([\x80-\xFF])/e', + '"=" . + strtoupper(dechex(ord("\1")))', + $value); + $hdr_value = str_replace($value, '=?' . + $this->_build_params['head_charset'] . + '?Q?' . $replacement . '?=', + $hdr_value); + } + $input[$hdr_name] = $hdr_value; + } + + return $input; + } + + /** + * Set the object's end-of-line and define the constant if applicable + * + * @param string $eol End Of Line sequence + * @access private + */ + function _setEOL($eol) + { + $this->_eol = $eol; + if (!defined('MAIL_MIME_CRLF')) { + define('MAIL_MIME_CRLF', $this->_eol, true); + } + } + + + +} // End of class +?> diff --git a/htdocs/includes/nusoap/lib/Mail/mimeDecode.php b/htdocs/includes/nusoap/lib/Mail/mimeDecode.php new file mode 100755 index 00000000000..07fe88f6e25 --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/mimeDecode.php @@ -0,0 +1,837 @@ + | +// +-----------------------------------------------------------------------+ + +require_once 'PEAR.php'; + +/** +* +----------------------------- IMPORTANT ------------------------------+ +* | Usage of this class compared to native php extensions such as | +* | mailparse or imap, is slow and may be feature deficient. If available| +* | you are STRONGLY recommended to use the php extensions. | +* +----------------------------------------------------------------------+ +* +* Mime Decoding class +* +* This class will parse a raw mime email and return +* the structure. Returned structure is similar to +* that returned by imap_fetchstructure(). +* +* USAGE: (assume $input is your raw email) +* +* $decode = new Mail_mimeDecode($input, "\r\n"); +* $structure = $decode->decode(); +* print_r($structure); +* +* Or statically: +* +* $params['input'] = $input; +* $structure = Mail_mimeDecode::decode($params); +* print_r($structure); +* +* TODO: +* o Implement multipart/appledouble +* o UTF8: ??? + + > 4. We have also found a solution for decoding the UTF-8 + > headers. Therefore I made the following function: + > + > function decode_utf8($txt) { + > $trans=array("‘"=>"õ","ű"=>"û","Ő"=>"•","Ű" + =>"›"); + > $txt=strtr($txt,$trans); + > return(utf8_decode($txt)); + > } + > + > And I have inserted the following line to the class: + > + > if (strtolower($charset)=="utf-8") $text=decode_utf8($text); + > + > ... before the following one in the "_decodeHeader" function: + > + > $input = str_replace($encoded, $text, $input); + > + > This way from now on it can easily decode the UTF-8 headers too. + +* +* @author Richard Heyes +* @version $Revision$ +* @package Mail +*/ +class Mail_mimeDecode extends PEAR +{ + /** + * The raw email to decode + * @var string + */ + var $_input; + + /** + * The header part of the input + * @var string + */ + var $_header; + + /** + * The body part of the input + * @var string + */ + var $_body; + + /** + * If an error occurs, this is used to store the message + * @var string + */ + var $_error; + + /** + * Flag to determine whether to include bodies in the + * returned object. + * @var boolean + */ + var $_include_bodies; + + /** + * Flag to determine whether to decode bodies + * @var boolean + */ + var $_decode_bodies; + + /** + * Flag to determine whether to decode headers + * @var boolean + */ + var $_decode_headers; + + /** + * Constructor. + * + * Sets up the object, initialise the variables, and splits and + * stores the header and body of the input. + * + * @param string The input to decode + * @access public + */ + function Mail_mimeDecode($input) + { + list($header, $body) = $this->_splitBodyHeader($input); + + $this->_input = $input; + $this->_header = $header; + $this->_body = $body; + $this->_decode_bodies = false; + $this->_include_bodies = true; + } + + /** + * Begins the decoding process. If called statically + * it will create an object and call the decode() method + * of it. + * + * @param array An array of various parameters that determine + * various things: + * include_bodies - Whether to include the body in the returned + * object. + * decode_bodies - Whether to decode the bodies + * of the parts. (Transfer encoding) + * decode_headers - Whether to decode headers + * input - If called statically, this will be treated + * as the input + * @return object Decoded results + * @access public + */ + function decode($params = null) + { + // determine if this method has been called statically + $isStatic = !(isset($this) && get_class($this) == __CLASS__); + + // Have we been called statically? + // If so, create an object and pass details to that. + if ($isStatic AND isset($params['input'])) { + + $obj = new Mail_mimeDecode($params['input']); + $structure = $obj->decode($params); + + // Called statically but no input + } elseif ($isStatic) { + return PEAR::raiseError('Called statically and no input given'); + + // Called via an object + } else { + $this->_include_bodies = isset($params['include_bodies']) ? + $params['include_bodies'] : false; + $this->_decode_bodies = isset($params['decode_bodies']) ? + $params['decode_bodies'] : false; + $this->_decode_headers = isset($params['decode_headers']) ? + $params['decode_headers'] : false; + + $structure = $this->_decode($this->_header, $this->_body); + if ($structure === false) { + $structure = $this->raiseError($this->_error); + } + } + + return $structure; + } + + /** + * Performs the decoding. Decodes the body string passed to it + * If it finds certain content-types it will call itself in a + * recursive fashion + * + * @param string Header section + * @param string Body section + * @return object Results of decoding process + * @access private + */ + function _decode($headers, $body, $default_ctype = 'text/plain') + { + $return = new stdClass; + $return->headers = array(); + $headers = $this->_parseHeaders($headers); + + foreach ($headers as $value) { + if (isset($return->headers[strtolower($value['name'])]) AND !is_array($return->headers[strtolower($value['name'])])) { + $return->headers[strtolower($value['name'])] = array($return->headers[strtolower($value['name'])]); + $return->headers[strtolower($value['name'])][] = $value['value']; + + } elseif (isset($return->headers[strtolower($value['name'])])) { + $return->headers[strtolower($value['name'])][] = $value['value']; + + } else { + $return->headers[strtolower($value['name'])] = $value['value']; + } + } + + reset($headers); + while (list($key, $value) = each($headers)) { + $headers[$key]['name'] = strtolower($headers[$key]['name']); + switch ($headers[$key]['name']) { + + case 'content-type': + $content_type = $this->_parseHeaderValue($headers[$key]['value']); + + if (preg_match('/([0-9a-z+.-]+)\/([0-9a-z+.-]+)/i', $content_type['value'], $regs)) { + $return->ctype_primary = $regs[1]; + $return->ctype_secondary = $regs[2]; + } + + if (isset($content_type['other'])) { + while (list($p_name, $p_value) = each($content_type['other'])) { + $return->ctype_parameters[$p_name] = $p_value; + } + } + break; + + case 'content-disposition': + $content_disposition = $this->_parseHeaderValue($headers[$key]['value']); + $return->disposition = $content_disposition['value']; + if (isset($content_disposition['other'])) { + while (list($p_name, $p_value) = each($content_disposition['other'])) { + $return->d_parameters[$p_name] = $p_value; + } + } + break; + + case 'content-transfer-encoding': + $content_transfer_encoding = $this->_parseHeaderValue($headers[$key]['value']); + break; + } + } + + if (isset($content_type)) { + switch (strtolower($content_type['value'])) { + case 'text/plain': + $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit'; + $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body) : null; + break; + + case 'text/html': + $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit'; + $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body) : null; + break; + + case 'multipart/parallel': + case 'multipart/report': // RFC1892 + case 'multipart/signed': // PGP + case 'multipart/digest': + case 'multipart/alternative': + case 'multipart/related': + case 'multipart/mixed': + if(!isset($content_type['other']['boundary'])){ + $this->_error = 'No boundary found for ' . $content_type['value'] . ' part'; + return false; + } + + $default_ctype = (strtolower($content_type['value']) === 'multipart/digest') ? 'message/rfc822' : 'text/plain'; + + $parts = $this->_boundarySplit($body, $content_type['other']['boundary']); + for ($i = 0; $i < count($parts); $i++) { + list($part_header, $part_body) = $this->_splitBodyHeader($parts[$i]); + $part = $this->_decode($part_header, $part_body, $default_ctype); + if($part === false) + $part = $this->raiseError($this->_error); + $return->parts[] = $part; + } + break; + + case 'message/rfc822': + $obj = &new Mail_mimeDecode($body); + $return->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies, + 'decode_bodies' => $this->_decode_bodies, + 'decode_headers' => $this->_decode_headers)); + unset($obj); + break; + + default: + if(!isset($content_transfer_encoding['value'])) + $content_transfer_encoding['value'] = '7bit'; + $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $content_transfer_encoding['value']) : $body) : null; + break; + } + + } else { + $ctype = explode('/', $default_ctype); + $return->ctype_primary = $ctype[0]; + $return->ctype_secondary = $ctype[1]; + $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body) : $body) : null; + } + + return $return; + } + + /** + * Given the output of the above function, this will return an + * array of references to the parts, indexed by mime number. + * + * @param object $structure The structure to go through + * @param string $mime_number Internal use only. + * @return array Mime numbers + */ + function &getMimeNumbers(&$structure, $no_refs = false, $mime_number = '', $prepend = '') + { + $return = array(); + if (!empty($structure->parts)) { + if ($mime_number != '') { + $structure->mime_id = $prepend . $mime_number; + $return[$prepend . $mime_number] = &$structure; + } + for ($i = 0; $i < count($structure->parts); $i++) { + + + if (!empty($structure->headers['content-type']) AND substr(strtolower($structure->headers['content-type']), 0, 8) == 'message/') { + $prepend = $prepend . $mime_number . '.'; + $_mime_number = ''; + } else { + $_mime_number = ($mime_number == '' ? $i + 1 : sprintf('%s.%s', $mime_number, $i + 1)); + } + + $arr = &Mail_mimeDecode::getMimeNumbers($structure->parts[$i], $no_refs, $_mime_number, $prepend); + foreach ($arr as $key => $val) { + $no_refs ? $return[$key] = '' : $return[$key] = &$arr[$key]; + } + } + } else { + if ($mime_number == '') { + $mime_number = '1'; + } + $structure->mime_id = $prepend . $mime_number; + $no_refs ? $return[$prepend . $mime_number] = '' : $return[$prepend . $mime_number] = &$structure; + } + + return $return; + } + + /** + * Given a string containing a header and body + * section, this function will split them (at the first + * blank line) and return them. + * + * @param string Input to split apart + * @return array Contains header and body section + * @access private + */ + function _splitBodyHeader($input) + { + if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $input, $match)) { + return array($match[1], $match[2]); + } + $this->_error = 'Could not split header and body'; + return false; + } + + /** + * Parse headers given in $input and return + * as assoc array. + * + * @param string Headers to parse + * @return array Contains parsed headers + * @access private + */ + function _parseHeaders($input) + { + + if ($input !== '') { + // Unfold the input + $input = preg_replace("/\r?\n/", "\r\n", $input); + $input = preg_replace("/\r\n(\t| )+/", ' ', $input); + $headers = explode("\r\n", trim($input)); + + foreach ($headers as $value) { + $hdr_name = substr($value, 0, $pos = strpos($value, ':')); + $hdr_value = substr($value, $pos+1); + if($hdr_value[0] == ' ') + $hdr_value = substr($hdr_value, 1); + + $return[] = array( + 'name' => $hdr_name, + 'value' => $this->_decode_headers ? $this->_decodeHeader($hdr_value) : $hdr_value + ); + } + } else { + $return = array(); + } + + return $return; + } + + /** + * Function to parse a header value, + * extract first part, and any secondary + * parts (after ;) This function is not as + * robust as it could be. Eg. header comments + * in the wrong place will probably break it. + * + * @param string Header value to parse + * @return array Contains parsed result + * @access private + */ + function _parseHeaderValue($input) + { + + if (($pos = strpos($input, ';')) !== false) { + + $return['value'] = trim(substr($input, 0, $pos)); + $input = trim(substr($input, $pos+1)); + + if (strlen($input) > 0) { + + // This splits on a semi-colon, if there's no preceeding backslash + // Now works with quoted values; had to glue the \; breaks in PHP + // the regex is already bordering on incomprehensible + $splitRegex = '/([^;\'"]*[\'"]([^\'"]*([^\'"]*)*)[\'"][^;\'"]*|([^;]+))(;|$)/'; + preg_match_all($splitRegex, $input, $matches); + $parameters = array(); + for ($i=0; $i_quotedPrintableDecode($input); + break; + + case 'base64': + return base64_decode($input); + break; + + default: + return $input; + } + } + + /** + * Given a quoted-printable string, this + * function will decode and return it. + * + * @param string Input body to decode + * @return string Decoded body + * @access private + */ + function _quotedPrintableDecode($input) + { + // Remove soft line breaks + $input = preg_replace("/=\r?\n/", '', $input); + + // Replace encoded characters + $input = preg_replace('/=([a-f0-9]{2})/ie', "chr(hexdec('\\1'))", $input); + + return $input; + } + + /** + * Checks the input for uuencoded files and returns + * an array of them. Can be called statically, eg: + * + * $files =& Mail_mimeDecode::uudecode($some_text); + * + * It will check for the begin 666 ... end syntax + * however and won't just blindly decode whatever you + * pass it. + * + * @param string Input body to look for attahcments in + * @return array Decoded bodies, filenames and permissions + * @access public + * @author Unknown + */ + function &uudecode($input) + { + // Find all uuencoded sections + preg_match_all("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", $input, $matches); + + for ($j = 0; $j < count($matches[3]); $j++) { + + $str = $matches[3][$j]; + $filename = $matches[2][$j]; + $fileperm = $matches[1][$j]; + + $file = ''; + $str = preg_split("/\r?\n/", trim($str)); + $strlen = count($str); + + for ($i = 0; $i < $strlen; $i++) { + $pos = 1; + $d = 0; + $len=(int)(((ord(substr($str[$i],0,1)) -32) - ' ') & 077); + + while (($d + 3 <= $len) AND ($pos + 4 <= strlen($str[$i]))) { + $c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20); + $c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20); + $c2 = (ord(substr($str[$i],$pos+2,1)) ^ 0x20); + $c3 = (ord(substr($str[$i],$pos+3,1)) ^ 0x20); + $file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4)); + + $file .= chr(((($c1 - ' ') & 077) << 4) | ((($c2 - ' ') & 077) >> 2)); + + $file .= chr(((($c2 - ' ') & 077) << 6) | (($c3 - ' ') & 077)); + + $pos += 4; + $d += 3; + } + + if (($d + 2 <= $len) && ($pos + 3 <= strlen($str[$i]))) { + $c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20); + $c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20); + $c2 = (ord(substr($str[$i],$pos+2,1)) ^ 0x20); + $file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4)); + + $file .= chr(((($c1 - ' ') & 077) << 4) | ((($c2 - ' ') & 077) >> 2)); + + $pos += 3; + $d += 2; + } + + if (($d + 1 <= $len) && ($pos + 2 <= strlen($str[$i]))) { + $c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20); + $c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20); + $file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4)); + + } + } + $files[] = array('filename' => $filename, 'fileperm' => $fileperm, 'filedata' => $file); + } + + return $files; + } + + /** + * getSendArray() returns the arguments required for Mail::send() + * used to build the arguments for a mail::send() call + * + * Usage: + * $mailtext = Full email (for example generated by a template) + * $decoder = new Mail_mimeDecode($mailtext); + * $parts = $decoder->getSendArray(); + * if (!PEAR::isError($parts) { + * list($recipents,$headers,$body) = $parts; + * $mail = Mail::factory('smtp'); + * $mail->send($recipents,$headers,$body); + * } else { + * echo $parts->message; + * } + * @return mixed array of recipeint, headers,body or Pear_Error + * @access public + * @author Alan Knowles + */ + function getSendArray() + { + // prevent warning if this is not set + $this->_decode_headers = FALSE; + $headerlist =$this->_parseHeaders($this->_header); + $to = ""; + if (!$headerlist) { + return $this->raiseError("Message did not contain headers"); + } + foreach($headerlist as $item) { + $header[$item['name']] = $item['value']; + switch (strtolower($item['name'])) { + case "to": + case "cc": + case "bcc": + $to = ",".$item['value']; + default: + break; + } + } + if ($to == "") { + return $this->raiseError("Message did not contain any recipents"); + } + $to = substr($to,1); + return array($to,$header,$this->_body); + } + + /** + * Returns a xml copy of the output of + * Mail_mimeDecode::decode. Pass the output in as the + * argument. This function can be called statically. Eg: + * + * $output = $obj->decode(); + * $xml = Mail_mimeDecode::getXML($output); + * + * The DTD used for this should have been in the package. Or + * alternatively you can get it from cvs, or here: + * http://www.phpguru.org/xmail/xmail.dtd. + * + * @param object Input to convert to xml. This should be the + * output of the Mail_mimeDecode::decode function + * @return string XML version of input + * @access public + */ + function getXML($input) + { + $crlf = "\r\n"; + $output = '' . $crlf . + '' . $crlf . + '' . $crlf . + Mail_mimeDecode::_getXML($input) . + ''; + + return $output; + } + + /** + * Function that does the actual conversion to xml. Does a single + * mimepart at a time. + * + * @param object Input to convert to xml. This is a mimepart object. + * It may or may not contain subparts. + * @param integer Number of tabs to indent + * @return string XML version of input + * @access private + */ + function _getXML($input, $indent = 1) + { + $htab = "\t"; + $crlf = "\r\n"; + $output = ''; + $headers = @(array)$input->headers; + + foreach ($headers as $hdr_name => $hdr_value) { + + // Multiple headers with this name + if (is_array($headers[$hdr_name])) { + for ($i = 0; $i < count($hdr_value); $i++) { + $output .= Mail_mimeDecode::_getXML_helper($hdr_name, $hdr_value[$i], $indent); + } + + // Only one header of this sort + } else { + $output .= Mail_mimeDecode::_getXML_helper($hdr_name, $hdr_value, $indent); + } + } + + if (!empty($input->parts)) { + for ($i = 0; $i < count($input->parts); $i++) { + $output .= $crlf . str_repeat($htab, $indent) . '' . $crlf . + Mail_mimeDecode::_getXML($input->parts[$i], $indent+1) . + str_repeat($htab, $indent) . '' . $crlf; + } + } elseif (isset($input->body)) { + $output .= $crlf . str_repeat($htab, $indent) . 'body . ']]>' . $crlf; + } + + return $output; + } + + /** + * Helper function to _getXML(). Returns xml of a header. + * + * @param string Name of header + * @param string Value of header + * @param integer Number of tabs to indent + * @return string XML version of input + * @access private + */ + function _getXML_helper($hdr_name, $hdr_value, $indent) + { + $htab = "\t"; + $crlf = "\r\n"; + $return = ''; + + $new_hdr_value = ($hdr_name != 'received') ? Mail_mimeDecode::_parseHeaderValue($hdr_value) : array('value' => $hdr_value); + $new_hdr_name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $hdr_name))); + + // Sort out any parameters + if (!empty($new_hdr_value['other'])) { + foreach ($new_hdr_value['other'] as $paramname => $paramvalue) { + $params[] = str_repeat($htab, $indent) . $htab . '' . $crlf . + str_repeat($htab, $indent) . $htab . $htab . '' . htmlspecialchars($paramname) . '' . $crlf . + str_repeat($htab, $indent) . $htab . $htab . '' . htmlspecialchars($paramvalue) . '' . $crlf . + str_repeat($htab, $indent) . $htab . '' . $crlf; + } + + $params = implode('', $params); + } else { + $params = ''; + } + + $return = str_repeat($htab, $indent) . '
' . $crlf . + str_repeat($htab, $indent) . $htab . '' . htmlspecialchars($new_hdr_name) . '' . $crlf . + str_repeat($htab, $indent) . $htab . '' . htmlspecialchars($new_hdr_value['value']) . '' . $crlf . + $params . + str_repeat($htab, $indent) . '
' . $crlf; + + return $return; + } + +} // End of class +?> diff --git a/htdocs/includes/nusoap/lib/Mail/mimePart.php b/htdocs/includes/nusoap/lib/Mail/mimePart.php new file mode 100755 index 00000000000..b429b905e1d --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/mimePart.php @@ -0,0 +1,351 @@ + | +// +-----------------------------------------------------------------------+ + +/** +* +* Raw mime encoding class +* +* What is it? +* This class enables you to manipulate and build +* a mime email from the ground up. +* +* Why use this instead of mime.php? +* mime.php is a userfriendly api to this class for +* people who aren't interested in the internals of +* mime mail. This class however allows full control +* over the email. +* +* Eg. +* +* // Since multipart/mixed has no real body, (the body is +* // the subpart), we set the body argument to blank. +* +* $params['content_type'] = 'multipart/mixed'; +* $email = new Mail_mimePart('', $params); +* +* // Here we add a text part to the multipart we have +* // already. Assume $body contains plain text. +* +* $params['content_type'] = 'text/plain'; +* $params['encoding'] = '7bit'; +* $text = $email->addSubPart($body, $params); +* +* // Now add an attachment. Assume $attach is +* the contents of the attachment +* +* $params['content_type'] = 'application/zip'; +* $params['encoding'] = 'base64'; +* $params['disposition'] = 'attachment'; +* $params['dfilename'] = 'example.zip'; +* $attach =& $email->addSubPart($body, $params); +* +* // Now build the email. Note that the encode +* // function returns an associative array containing two +* // elements, body and headers. You will need to add extra +* // headers, (eg. Mime-Version) before sending. +* +* $email = $message->encode(); +* $email['headers'][] = 'Mime-Version: 1.0'; +* +* +* Further examples are available at http://www.phpguru.org +* +* TODO: +* - Set encode() to return the $obj->encoded if encode() +* has already been run. Unless a flag is passed to specifically +* re-build the message. +* +* @author Richard Heyes +* @version $Revision$ +* @package Mail +*/ + +class Mail_mimePart { + + /** + * The encoding type of this part + * @var string + */ + var $_encoding; + + /** + * An array of subparts + * @var array + */ + var $_subparts; + + /** + * The output of this part after being built + * @var string + */ + var $_encoded; + + /** + * Headers for this part + * @var array + */ + var $_headers; + + /** + * The body of this part (not encoded) + * @var string + */ + var $_body; + + /** + * Constructor. + * + * Sets up the object. + * + * @param $body - The body of the mime part if any. + * @param $params - An associative array of parameters: + * content_type - The content type for this part eg multipart/mixed + * encoding - The encoding to use, 7bit, 8bit, base64, or quoted-printable + * cid - Content ID to apply + * disposition - Content disposition, inline or attachment + * dfilename - Optional filename parameter for content disposition + * description - Content description + * charset - Character set to use + * @access public + */ + function Mail_mimePart($body = '', $params = array()) + { + if (!defined('MAIL_MIMEPART_CRLF')) { + define('MAIL_MIMEPART_CRLF', defined('MAIL_MIME_CRLF') ? MAIL_MIME_CRLF : "\r\n", TRUE); + } + + foreach ($params as $key => $value) { + switch ($key) { + case 'content_type': + $headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : ''); + break; + + case 'encoding': + $this->_encoding = $value; + $headers['Content-Transfer-Encoding'] = $value; + break; + + case 'cid': + $headers['Content-ID'] = '<' . $value . '>'; + break; + + case 'disposition': + $headers['Content-Disposition'] = $value . (isset($dfilename) ? '; filename="' . $dfilename . '"' : ''); + break; + + case 'dfilename': + if (isset($headers['Content-Disposition'])) { + $headers['Content-Disposition'] .= '; filename="' . $value . '"'; + } else { + $dfilename = $value; + } + break; + + case 'description': + $headers['Content-Description'] = $value; + break; + + case 'charset': + if (isset($headers['Content-Type'])) { + $headers['Content-Type'] .= '; charset="' . $value . '"'; + } else { + $charset = $value; + } + break; + } + } + + // Default content-type + if (!isset($headers['Content-Type'])) { + $headers['Content-Type'] = 'text/plain'; + } + + //Default encoding + if (!isset($this->_encoding)) { + $this->_encoding = '7bit'; + } + + // Assign stuff to member variables + $this->_encoded = array(); + $this->_headers = $headers; + $this->_body = $body; + } + + /** + * encode() + * + * Encodes and returns the email. Also stores + * it in the encoded member variable + * + * @return An associative array containing two elements, + * body and headers. The headers element is itself + * an indexed array. + * @access public + */ + function encode() + { + $encoded =& $this->_encoded; + + if (!empty($this->_subparts)) { + srand((double)microtime()*1000000); + $boundary = '=_' . md5(rand() . microtime()); + $this->_headers['Content-Type'] .= ';' . MAIL_MIMEPART_CRLF . "\t" . 'boundary="' . $boundary . '"'; + + // Add body parts to $subparts + for ($i = 0; $i < count($this->_subparts); $i++) { + $headers = array(); + $tmp = $this->_subparts[$i]->encode(); + foreach ($tmp['headers'] as $key => $value) { + $headers[] = $key . ': ' . $value; + } + $subparts[] = implode(MAIL_MIMEPART_CRLF, $headers) . MAIL_MIMEPART_CRLF . MAIL_MIMEPART_CRLF . $tmp['body']; + } + + $encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF . + implode('--' . $boundary . MAIL_MIMEPART_CRLF, $subparts) . + '--' . $boundary.'--' . MAIL_MIMEPART_CRLF; + + } else { + $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding) . MAIL_MIMEPART_CRLF; + } + + // Add headers to $encoded + $encoded['headers'] =& $this->_headers; + + return $encoded; + } + + /** + * &addSubPart() + * + * Adds a subpart to current mime part and returns + * a reference to it + * + * @param $body The body of the subpart, if any. + * @param $params The parameters for the subpart, same + * as the $params argument for constructor. + * @return A reference to the part you just added. It is + * crucial if using multipart/* in your subparts that + * you use =& in your script when calling this function, + * otherwise you will not be able to add further subparts. + * @access public + */ + function &addSubPart($body, $params) + { + $this->_subparts[] = new Mail_mimePart($body, $params); + return $this->_subparts[count($this->_subparts) - 1]; + } + + /** + * _getEncodedData() + * + * Returns encoded data based upon encoding passed to it + * + * @param $data The data to encode. + * @param $encoding The encoding type to use, 7bit, base64, + * or quoted-printable. + * @access private + */ + function _getEncodedData($data, $encoding) + { + switch ($encoding) { + case '8bit': + case '7bit': + return $data; + break; + + case 'quoted-printable': + return $this->_quotedPrintableEncode($data); + break; + + case 'base64': + return rtrim(chunk_split(base64_encode($data), 76, MAIL_MIMEPART_CRLF)); + break; + + default: + return $data; + } + } + + /** + * quoteadPrintableEncode() + * + * Encodes data to quoted-printable standard. + * + * @param $input The data to encode + * @param $line_max Optional max line length. Should + * not be more than 76 chars + * + * @access private + */ + function _quotedPrintableEncode($input , $line_max = 76) + { + $lines = preg_split("/\r?\n/", $input); + $eol = MAIL_MIMEPART_CRLF; + $escape = '='; + $output = ''; + + while(list(, $line) = each($lines)){ + + $linlen = strlen($line); + $newline = ''; + + for ($i = 0; $i < $linlen; $i++) { + $char = substr($line, $i, 1); + $dec = ord($char); + + if (($dec == 32) AND ($i == ($linlen - 1))){ // convert space at eol only + $char = '=20'; + + } elseif(($dec == 9) AND ($i == ($linlen - 1))) { // convert tab at eol only + $char = '=09'; + } elseif($dec == 9) { + ; // Do nothing if a tab. + } elseif(($dec == 61) OR ($dec < 32 ) OR ($dec > 126)) { + $char = $escape . strtoupper(sprintf('%02s', dechex($dec))); + } + + if ((strlen($newline) + strlen($char)) >= $line_max) { // MAIL_MIMEPART_CRLF is not counted + $output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay + $newline = ''; + } + $newline .= $char; + } // end of for + $output .= $newline . $eol; + } + $output = substr($output, 0, -1 * strlen($eol)); // Don't want last crlf + return $output; + } +} // End of class +?> diff --git a/htdocs/includes/nusoap/lib/Mail/null.php b/htdocs/includes/nusoap/lib/Mail/null.php new file mode 100755 index 00000000000..49a03323508 --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/null.php @@ -0,0 +1,60 @@ + | +// +----------------------------------------------------------------------+ +// +// $Id$ +// + +/** + * Null implementation of the PEAR Mail:: interface. + * @access public + * @package Mail + * @version $Revision$ + */ +class Mail_null extends Mail { + + /** + * Implements Mail_null::send() function. Silently discards all + * mail. + * + * @param mixed $recipients Either a comma-seperated list of recipients + * (RFC822 compliant), or an array of recipients, + * each RFC822 valid. This may contain recipients not + * specified in the headers, for Bcc:, resending + * messages, etc. + * + * @param array $headers The array of headers to send with the mail, in an + * associative array, where the array key is the + * header name (ie, 'Subject'), and the array value + * is the header value (ie, 'test'). The header + * produced from those values would be 'Subject: + * test'. + * + * @param string $body The full text of the message body, including any + * Mime parts, etc. + * + * @return mixed Returns true on success, or a PEAR_Error + * containing a descriptive error message on + * failure. + * @access public + */ + function send($recipients, $headers, $body) + { + return true; + } + +} diff --git a/htdocs/includes/nusoap/lib/Mail/sendmail.php b/htdocs/includes/nusoap/lib/Mail/sendmail.php new file mode 100755 index 00000000000..6925be24563 --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/sendmail.php @@ -0,0 +1,145 @@ + | +// +----------------------------------------------------------------------+ + +/** + * Sendmail implementation of the PEAR Mail:: interface. + * @access public + * @package Mail + * @version $Revision$ + */ +class Mail_sendmail extends Mail { + + /** + * The location of the sendmail or sendmail wrapper binary on the + * filesystem. + * @var string + */ + var $sendmail_path = '/usr/sbin/sendmail'; + + /** + * Any extra command-line parameters to pass to the sendmail or + * sendmail wrapper binary. + * @var string + */ + var $sendmail_args = ''; + + /** + * Constructor. + * + * Instantiates a new Mail_sendmail:: object based on the parameters + * passed in. It looks for the following parameters: + * sendmail_path The location of the sendmail binary on the + * filesystem. Defaults to '/usr/sbin/sendmail'. + * + * sendmail_args Any extra parameters to pass to the sendmail + * or sendmail wrapper binary. + * + * If a parameter is present in the $params array, it replaces the + * default. + * + * @param array $params Hash containing any parameters different from the + * defaults. + * @access public + */ + function Mail_sendmail($params) + { + if (isset($params['sendmail_path'])) $this->sendmail_path = $params['sendmail_path']; + if (isset($params['sendmail_args'])) $this->sendmail_args = $params['sendmail_args']; + + /* + * Because we need to pass message headers to the sendmail program on + * the commandline, we can't guarantee the use of the standard "\r\n" + * separator. Instead, we use the system's native line separator. + */ + $this->sep = (strstr(PHP_OS, 'WIN')) ? "\r\n" : "\n"; + } + + /** + * Implements Mail::send() function using the sendmail + * command-line binary. + * + * @param mixed $recipients Either a comma-seperated list of recipients + * (RFC822 compliant), or an array of recipients, + * each RFC822 valid. This may contain recipients not + * specified in the headers, for Bcc:, resending + * messages, etc. + * + * @param array $headers The array of headers to send with the mail, in an + * associative array, where the array key is the + * header name (ie, 'Subject'), and the array value + * is the header value (ie, 'test'). The header + * produced from those values would be 'Subject: + * test'. + * + * @param string $body The full text of the message body, including any + * Mime parts, etc. + * + * @return mixed Returns true on success, or a PEAR_Error + * containing a descriptive error message on + * failure. + * @access public + */ + function send($recipients, $headers, $body) + { + $recipients = $this->parseRecipients($recipients); + if (PEAR::isError($recipients)) { + return $recipients; + } + $recipients = escapeShellCmd(implode(' ', $recipients)); + + $headerElements = $this->prepareHeaders($headers); + if (PEAR::isError($headerElements)) { + return $headerElements; + } + list($from, $text_headers) = $headerElements; + + if (!isset($from)) { + return PEAR::raiseError('No from address given.'); + } elseif (strstr($from, ' ') || + strstr($from, ';') || + strstr($from, '&') || + strstr($from, '`')) { + return PEAR::raiseError('From address specified with dangerous characters.'); + } + + $result = 0; + if (@is_file($this->sendmail_path)) { + $from = escapeShellCmd($from); + $mail = popen($this->sendmail_path . (!empty($this->sendmail_args) ? ' ' . $this->sendmail_args : '') . " -f$from -- $recipients", 'w'); + fputs($mail, $text_headers); + fputs($mail, $this->sep); // newline to end the headers section + fputs($mail, $body); + $result = pclose($mail); + if (version_compare(phpversion(), '4.2.3') == -1) { + // With older php versions, we need to shift the + // pclose result to get the exit code. + $result = $result >> 8 & 0xFF; + } + } else { + return PEAR::raiseError('sendmail [' . $this->sendmail_path . '] is not a valid file'); + } + + if ($result != 0) { + return PEAR::raiseError('sendmail returned error code ' . $result, + $result); + } + + return true; + } + +} diff --git a/htdocs/includes/nusoap/lib/Mail/smtp.php b/htdocs/includes/nusoap/lib/Mail/smtp.php new file mode 100755 index 00000000000..59a0127f374 --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/smtp.php @@ -0,0 +1,223 @@ + | +// | Jon Parise | +// +----------------------------------------------------------------------+ + +/** + * SMTP implementation of the PEAR Mail:: interface. Requires the PEAR + * Net_SMTP:: class. + * @access public + * @package Mail + * @version $Revision$ + */ +class Mail_smtp extends Mail { + + /** + * The SMTP host to connect to. + * @var string + */ + var $host = 'localhost'; + + /** + * The port the SMTP server is on. + * @var integer + */ + var $port = 25; + + /** + * Should SMTP authentication be used? + * + * This value may be set to true, false or the name of a specific + * authentication method. + * + * If the value is set to true, the Net_SMTP package will attempt to use + * the best authentication method advertised by the remote SMTP server. + * + * @var mixed + */ + var $auth = false; + + /** + * The username to use if the SMTP server requires authentication. + * @var string + */ + var $username = ''; + + /** + * The password to use if the SMTP server requires authentication. + * @var string + */ + var $password = ''; + + /** + * Hostname or domain that will be sent to the remote SMTP server in the + * HELO / EHLO message. + * + * @var string + */ + var $localhost = 'localhost'; + + /** + * SMTP connection timeout value. NULL indicates no timeout. + * + * @var integer + */ + var $timeout = null; + + /** + * Whether to use VERP or not. If not a boolean, the string value + * will be used as the VERP separators. + * + * @var mixed boolean or string + */ + var $verp = false; + + /** + * Turn on Net_SMTP debugging? + * + * @var boolean $debug + */ + var $debug = false; + + /** + * Constructor. + * + * Instantiates a new Mail_smtp:: object based on the parameters + * passed in. It looks for the following parameters: + * host The server to connect to. Defaults to localhost. + * port The port to connect to. Defaults to 25. + * auth SMTP authentication. Defaults to none. + * username The username to use for SMTP auth. No default. + * password The password to use for SMTP auth. No default. + * localhost The local hostname / domain. Defaults to localhost. + * timeout The SMTP connection timeout. Defaults to none. + * verp Whether to use VERP or not. Defaults to false. + * debug Activate SMTP debug mode? Defaults to false. + * + * If a parameter is present in the $params array, it replaces the + * default. + * + * @param array Hash containing any parameters different from the + * defaults. + * @access public + */ + function Mail_smtp($params) + { + if (isset($params['host'])) $this->host = $params['host']; + if (isset($params['port'])) $this->port = $params['port']; + if (isset($params['auth'])) $this->auth = $params['auth']; + if (isset($params['username'])) $this->username = $params['username']; + if (isset($params['password'])) $this->password = $params['password']; + if (isset($params['localhost'])) $this->localhost = $params['localhost']; + if (isset($params['timeout'])) $this->timeout = $params['timeout']; + if (isset($params['verp'])) $this->verp = $params['verp']; + if (isset($params['debug'])) $this->debug = (boolean)$params['debug']; + } + + /** + * Implements Mail::send() function using SMTP. + * + * @param mixed $recipients Either a comma-seperated list of recipients + * (RFC822 compliant), or an array of recipients, + * each RFC822 valid. This may contain recipients not + * specified in the headers, for Bcc:, resending + * messages, etc. + * + * @param array $headers The array of headers to send with the mail, in an + * associative array, where the array key is the + * header name (e.g., 'Subject'), and the array value + * is the header value (e.g., 'test'). The header + * produced from those values would be 'Subject: + * test'. + * + * @param string $body The full text of the message body, including any + * Mime parts, etc. + * + * @return mixed Returns true on success, or a PEAR_Error + * containing a descriptive error message on + * failure. + * @access public + */ + function send($recipients, $headers, $body) + { + include_once 'Net/SMTP.php'; + + if (!($smtp = &new Net_SMTP($this->host, $this->port, $this->localhost))) { + return PEAR::raiseError('unable to instantiate Net_SMTP object'); + } + + if ($this->debug) { + $smtp->setDebug(true); + } + + if (PEAR::isError($smtp->connect($this->timeout))) { + return PEAR::raiseError('unable to connect to smtp server ' . + $this->host . ':' . $this->port); + } + + if ($this->auth) { + $method = is_string($this->auth) ? $this->auth : ''; + + if (PEAR::isError($smtp->auth($this->username, $this->password, + $method))) { + return PEAR::raiseError('unable to authenticate to smtp server'); + } + } + + $headerElements = $this->prepareHeaders($headers); + if (PEAR::isError($headerElements)) { + return $headerElements; + } + list($from, $text_headers) = $headerElements; + + /* Since few MTAs are going to allow this header to be forged + * unless it's in the MAIL FROM: exchange, we'll use + * Return-Path instead of From: if it's set. */ + if (!empty($headers['Return-Path'])) { + $from = $headers['Return-Path']; + } + + if (!isset($from)) { + return PEAR::raiseError('No from address given'); + } + + $args['verp'] = $this->verp; + if (PEAR::isError($smtp->mailFrom($from, $args))) { + return PEAR::raiseError('unable to set sender to [' . $from . ']'); + } + + $recipients = $this->parseRecipients($recipients); + if (PEAR::isError($recipients)) { + return $recipients; + } + + foreach ($recipients as $recipient) { + if (PEAR::isError($res = $smtp->rcptTo($recipient))) { + return PEAR::raiseError('unable to add recipient [' . + $recipient . ']: ' . $res->getMessage()); + } + } + + if (PEAR::isError($smtp->data($text_headers . "\r\n" . $body))) { + return PEAR::raiseError('unable to send data'); + } + + $smtp->disconnect(); + return true; + } + +} diff --git a/htdocs/includes/nusoap/lib/Mail/xmail.dtd b/htdocs/includes/nusoap/lib/Mail/xmail.dtd new file mode 100755 index 00000000000..9779796167e --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/xmail.dtd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/htdocs/includes/nusoap/lib/Mail/xmail.xsl b/htdocs/includes/nusoap/lib/Mail/xmail.xsl new file mode 100755 index 00000000000..0e4ffe680de --- /dev/null +++ b/htdocs/includes/nusoap/lib/Mail/xmail.xsl @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + : + + + + + + + + ; + + =" + + " + + + + + + + + + + + + + + + + + + + + -- + + + + ---- + + + + + + + + + + + \ No newline at end of file diff --git a/htdocs/install/etape0.php b/htdocs/install/etape0.php index bb3fc844df0..cf4a1ccb2d2 100644 --- a/htdocs/install/etape0.php +++ b/htdocs/install/etape0.php @@ -227,7 +227,7 @@ if (! $error && $db->connected) if (! $error && $db->connected) { ?> - +
+ connected) + '--') { + $buf=preg_replace('/--(.+)*/','',$buf); $buffer .= $buf; } } diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 58ea405085e..4e30c87efe1 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -212,6 +212,9 @@ print $dolibarr_main_url_root; + + diff --git a/htdocs/install/mysql/data/llx_action_def.sql b/htdocs/install/mysql/data/llx_action_def.sql index 9f347803639..dcb4d6241f8 100644 --- a/htdocs/install/mysql/data/llx_action_def.sql +++ b/htdocs/install/mysql/data/llx_action_def.sql @@ -5,6 +5,7 @@ -- Copyright (C) 2004 Guillaume Delecourt -- Copyright (C) 2005-2009 Regis Houssin -- Copyright (C) 2007 Patrick Raguin +-- Copyright (C) 2010 Juanjo Menentn -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -38,3 +39,5 @@ insert into llx_action_def (rowid,code,titre,description,objet_type) values (3,' insert into llx_action_def (rowid,code,titre,description,objet_type) values (4,'NOTIFY_REF_ORDER_SUPPLIER','Refus commande fournisseur','Executed when a supplier order is refused','order_supplier'); insert into llx_action_def (rowid,code,titre,description,objet_type) values (5,'NOTIFY_VAL_ORDER','Validation commande client','Executed when a customer order is validated','order'); insert into llx_action_def (rowid,code,titre,description,objet_type) values (6,'NOTIFY_VAL_PROPAL','Validation proposition client','Executed when a commercial proposal is validated','propal'); +insert into llx_action_def (rowid,code,titre,description,objet_type) values (7,'NOTIFY_TRN_WITHDRAW','Transmission prélèvement','Executed when a withdrawal is transmited','withdraw'); +insert into llx_action_def (rowid,code,titre,description,objet_type) values (8,'NOTIFY_CRD_WITHDRAW','Créditer prélèvement','Executed when a withdrawal is credited','withdraw'); diff --git a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql index 8b2b836fc57..a96fe2fbfb8 100644 --- a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql +++ b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql @@ -14,15 +14,15 @@ UPDATE llx_bank_url SET type='payment' WHERE type='?' AND label='(payment)' AND url LIKE '%compta/paiement/fiche.php%'; -- Add recuperableonly field -ALTER TABLE llx_product add column recuperableonly integer NOT NULL DEFAULT '0' after tva_tx; -ALTER TABLE llx_product_price add column recuperableonly integer NOT NULL DEFAULT '0' after tva_tx; +ALTER TABLE llx_product add COLUMN recuperableonly integer NOT NULL DEFAULT '0' after tva_tx; +ALTER TABLE llx_product_price add COLUMN recuperableonly integer NOT NULL DEFAULT '0' after tva_tx; -- Rename envente into tosell and add tobuy -ALTER TABLE llx_product CHANGE column envente tosell tinyint DEFAULT 1; -ALTER TABLE llx_product add column tobuy tinyint DEFAULT 1 after tosell; -ALTER TABLE llx_product_price CHANGE column envente tosell tinyint DEFAULT 1; +ALTER TABLE llx_product CHANGE COLUMN envente tosell tinyint DEFAULT 1; +ALTER TABLE llx_product add COLUMN tobuy tinyint DEFAULT 1 after tosell; +ALTER TABLE llx_product_price CHANGE COLUMN envente tosell tinyint DEFAULT 1; -ALTER TABLE llx_bank MODIFY column fk_type varchar(6); +ALTER TABLE llx_bank MODIFY COLUMN fk_type varchar(6); ALTER TABLE llx_boxes_def DROP INDEX uk_boxes_def; ALTER TABLE llx_boxes_def MODIFY file varchar(200) NOT NULL; @@ -77,10 +77,10 @@ ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX idx_ecm_directories (label, fk_ ALTER TABLE llx_ecm_documents ADD UNIQUE INDEX idx_ecm_documents (fullpath_dol); --Add modules facture fournisseur -insert into llx_const (name, value, type, note, visible) values ('INVOICE_SUPPLIER_ADDON_PDF', 'canelle','chaine','',0); +INSERT INTO llx_const (name, value, type, note, visible) values ('INVOICE_SUPPLIER_ADDON_PDF', 'canelle','chaine','',0); ALTER TABLE llx_facture_fourn ADD COLUMN model_pdf varchar(50) after note_public; -create table llx_c_ziptown +CREATE TABLE llx_c_ziptown ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, code varchar(5) DEFAULT NULL, @@ -94,20 +94,20 @@ ALTER TABLE llx_c_ziptown ADD INDEX idx_c_ziptown_fk_county (fk_county); ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_county FOREIGN KEY (fk_county) REFERENCES llx_c_departements (rowid); ALTER TABLE llx_socpeople ADD COLUMN canvas varchar(32) DEFAULT 'default' after default_lang; -ALTER TABLE llx_socpeople MODIFY canvas varchar(32) DEFAULT 'default'; +ALTER TABLE llx_socpeople MODIFY canvas varchar(32) DEFAULT 'default'; UPDATE llx_socpeople SET canvas = 'default' WHERE canvas = 'default@contact'; UPDATE llx_societe SET canvas = 'default' WHERE canvas = 'default@thirdparty'; UPDATE llx_societe SET canvas = 'individual' WHERE canvas = 'individual@thirdparty'; -insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS','7','chaine','Tolérance de retard avant alerte (en jours) sur commandes fournisseurs non traitées',0); +INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS','7','chaine','Tolérance de retard avant alerte (en jours) sur commandes fournisseurs non traitées',0); ALTER TABLE llx_actioncomm ADD COLUMN fulldayevent smallint NOT NULL default 0 after priority; -- Enhance POS module DROP TABLE llx_tmp_caisse; CREATE TABLE llx_pos_tmp ( - id integer NOT NULL auto_increment, + id integer NOT NULL AUTO_INCREMENT PRIMARY KEY, fk_article integer NOT NULL, qte real NOT NULL, fk_tva integer NOT NULL, @@ -115,7 +115,31 @@ CREATE TABLE llx_pos_tmp ( remise real NOT NULL, total_ht double(24,8) NOT NULL, total_tva double(24,8) NOT NULL, - total_ttc double(24,8) NOT NULL, - PRIMARY KEY (id) + total_ttc double(24,8) NOT NULL ) ENGINE=innodb; +-- Add external ref +ALTER TABLE llx_facture ADD COLUMN ref_ext varchar(30) after entity; +ALTER TABLE llx_commande ADD COLUMN ref_ext varchar(30) after entity; +ALTER TABLE llx_propal ADD COLUMN ref_ext varchar(30) after entity; +ALTER TABLE llx_user ADD COLUMN ref_ext varchar(30) after entity; +ALTER TABLE llx_societe ADD COLUMN ref_ext varchar(60) after entity; + + +ALTER TABLE llx_mailing_cibles CHANGE COLUMN url source_url integer; +ALTER TABLE llx_mailing_cibles ADD COLUMN source_id integer after source_url; +ALTER TABLE llx_mailing_cibles ADD COLUMN source_type varchar(16) after source_id; + +ALTER TABLE llx_facture_rec MODIFY frequency integer; +ALTER TABLE llx_facture_rec ADD COLUMN unit_frequency varchar(2) DEFAULT 'd'; +ALTER TABLE llx_facture_rec ADD COLUMN date_when datetime DEFAULT NULL; +ALTER TABLE llx_facture_rec ADD COLUMN date_last_gen datetime DEFAULT NULL; +ALTER TABLE llx_facture_rec ADD COLUMN nb_gen_done integer DEFAULT NULL; +ALTER TABLE llx_facture_rec ADD COLUMN nb_gen_max integer DEFAULT NULL; + + +ALTER TABLE llx_user ADD COLUMN openid varchar(255); + +-- Enhance Withdrawal module +INSERT INTO llx_action_def (rowid,code,titre,description,objet_type) values (7,'NOTIFY_TRN_WITHDRAW','Transmission prélèvement','Executed when a withdrawal is transmited','withdraw'); +INSERT INTO llx_action_def (rowid,code,titre,description,objet_type) values (8,'NOTIFY_CRD_WITHDRAW','Créditer prélèvement','Executed when a withdrawal is credited','withdraw'); diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 09d5dddfc98..da21c574d22 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -26,9 +26,12 @@ create table llx_commande tms timestamp, fk_soc integer NOT NULL, fk_projet integer DEFAULT 0, -- projet auquel est rattache la commande - ref varchar(30) NOT NULL, -- order number + + ref varchar(30) NOT NULL, -- order reference number entity integer DEFAULT 1 NOT NULL, -- multi company id - ref_client varchar(30), -- customer order number + + ref_ext varchar(30), -- reference into an external system (not used by dolibarr) + ref_client varchar(30), -- reference for customer date_creation datetime, -- date de creation date_valid datetime, -- date de validation diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index ecdeebb8091..f6129431c89 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -1,8 +1,8 @@ -- =========================================================================== -- Copyright (C) 2001-2005 Rodolphe Quiedeville --- Copyright (C) 2004-2009 Laurent Destailleur +-- Copyright (C) 2004-2010 Laurent Destailleur -- Copyright (C) 2005-2009 Regis Houssin --- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2010 Juanjo Menent -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -25,10 +25,14 @@ create table llx_facture ( rowid integer AUTO_INCREMENT PRIMARY KEY, - facnumber varchar(30) NOT NULL, + + facnumber varchar(30) NOT NULL, -- invoice reference number entity integer DEFAULT 1 NOT NULL, -- multi company id - type smallint DEFAULT 0 NOT NULL, - ref_client varchar(30), + + ref_ext varchar(30), -- reference into an external system (not used by dolibarr) + ref_client varchar(30), -- reference for customer + + type smallint DEFAULT 0 NOT NULL, -- type of invoice increment varchar(10), fk_soc integer NOT NULL, datec datetime, -- date de creation de la facture @@ -41,8 +45,8 @@ create table llx_facture remise_absolue real DEFAULT 0, -- remise absolue remise real DEFAULT 0, -- remise totale calculee - close_code varchar(16), -- Code motif cloture sans paiement complet - close_note varchar(128), -- Commentaire cloture sans paiement complet + close_code varchar(16), -- Code motif cloture sans paiement complet + close_note varchar(128), -- Commentaire cloture sans paiement complet tva double(24,8) DEFAULT 0, -- montant tva apres remise totale localtax1 double(24,8) DEFAULT 0, -- amount localtax1 diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index ca578ee2014..d6388dbd46c 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -42,12 +42,16 @@ create table llx_facture_rec fk_user_author integer, -- createur fk_projet integer, -- projet auquel est associe la facture fk_cond_reglement integer DEFAULT 0, -- condition de reglement - fk_mode_reglement integer DEFAULT 0, -- mode de reglement (Virement, Prelevement) - date_lim_reglement date, -- date limite de reglement + fk_mode_reglement integer DEFAULT 0, -- mode de reglement (Virement, Prelevement) + date_lim_reglement date, -- date limite de reglement note text, - note_public text, + note_public text, - frequency char(2) DEFAULT NULL, - last_gen varchar(7) DEFAULT NULL + frequency integer, + unit_frequency varchar(2) DEFAULT 'd', + date_when datetime DEFAULT NULL, + date_last_gen datetime DEFAULT NULL, + nb_gen_done integer DEFAULT NULL, + nb_gen_max integer DEFAULT NULL )type=innodb; diff --git a/htdocs/install/mysql/tables/llx_mailing_cibles.sql b/htdocs/install/mysql/tables/llx_mailing_cibles.sql index 13da8a5aff0..a9c2483a121 100644 --- a/htdocs/install/mysql/tables/llx_mailing_cibles.sql +++ b/htdocs/install/mysql/tables/llx_mailing_cibles.sql @@ -30,7 +30,9 @@ create table llx_mailing_cibles email varchar(160) NOT NULL, other varchar(255) NULL, statut smallint NOT NULL DEFAULT 0, - url varchar(160), + source_url varchar(160), + source_id integer, + source_type varchar(16), date_envoi datetime )type=innodb; diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index 6685e77959a..787be3bdf21 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -1,7 +1,8 @@ -- =================================================================== -- Copyright (C) 2001-2003 Rodolphe Quiedeville -- Copyright (C) 2005-2009 Regis Houssin --- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2010 Laurent Destailleur +-- Copyright (C) 2010 Juanjo Menent -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -25,8 +26,11 @@ create table llx_propal rowid integer AUTO_INCREMENT PRIMARY KEY, fk_soc integer, fk_projet integer DEFAULT 0, -- projet auquel est rattache la propale - ref varchar(30) NOT NULL, -- propal number - entity integer DEFAULT 1 NOT NULL, -- multi company id + + ref varchar(30) NOT NULL, -- proposal reference number + entity integer DEFAULT 1 NOT NULL, -- multi company id + + ref_ext varchar(30), -- reference into an external system (not used by dolibarr) ref_client varchar(30), -- customer order number datec datetime, -- date de creation diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 3ab6165c927..4dc1a835250 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -29,8 +29,12 @@ create table llx_societe tms timestamp, datec datetime, -- creation date datea datetime, -- activation date - nom varchar(60), -- company name + + nom varchar(60), -- company reference name entity integer DEFAULT 1 NOT NULL, -- multi company id + + ref_ext varchar(60), -- reference into an external system (not used by dolibarr) + code_client varchar(15), -- code client code_fournisseur varchar(15), -- code founisseur code_compta varchar(15), -- code compta client diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index f0cfc98c7b9..b48ef199c76 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -25,8 +25,12 @@ create table llx_user rowid integer AUTO_INCREMENT PRIMARY KEY, datec datetime, tms timestamp, - login varchar(24) NOT NULL, - entity integer DEFAULT 1 NOT NULL, -- multi company id + + login varchar(30) NOT NULL, -- user reference number + entity integer DEFAULT 1 NOT NULL, -- multi company id + + ref_ext varchar(30), -- reference into an external system (not used by dolibarr) + pass varchar(32), pass_crypted varchar(128), pass_temp varchar(32), -- temporary password when asked for forget password @@ -50,6 +54,7 @@ create table llx_user datepreviouslogin datetime, egroupware_id integer, ldap_sid varchar(255) DEFAULT NULL, + openid varchar(255), statut tinyint DEFAULT 1, photo varchar(255), -- filename or url of photo lang varchar(6)
@@ -255,15 +255,18 @@ if (! $error && $db->connected)
trans("CharacterSetDatabase"); ?> '; $selected=""; foreach ($listOfCharacterSet as $characterSet) { - // We keep only utf8 and iso $linedisabled=false; - if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/(utf8|latin1)/i',$characterSet['charset'])) $linedisabled=true; + + // We keep only utf8 + //if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/(utf8|latin1)/i',$characterSet['charset'])) $linedisabled=true; + if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/utf8/i',$characterSet['charset'])) $linedisabled=true; if ($defaultCharacterSet == $characterSet['charset'] ) { @@ -273,10 +276,12 @@ if (! $error && $db->connected) { $selected=""; } + if (! $linedisabled) $nbofchoice++; print ''; } print ''; - if ($disabled=="disabled"){ + if ($disabled=="disabled") + { print ''; } } @@ -284,10 +289,12 @@ if (! $error && $db->connected) { print ''; } + if ($nbofchoice > 1) { ?>
trans("CharacterSetDatabaseComment"); ?>
trans("CollationConnection"); ?> '; $selected=""; foreach ($listOfCollation as $collation) { - // We keep only utf8 and iso $linedisabled=false; - if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/(utf8_general|latin1_swedish)/i',$collation['collation'])) $linedisabled=true; + + // We keep only utf8 and iso + //if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/(utf8_general|latin1_swedish)/i',$collation['collation'])) $linedisabled=true; + if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/utf8/i',$collation['collation'])) $linedisabled=true; if ($defaultCollationConnection == $collation['collation']) { @@ -316,21 +326,24 @@ if (! $error && $db->connected) { $selected=""; } + if (! $linedisabled) $nbofchoice++; print ''; } print ''; if ($disabled=="disabled"){ - print ''; + print ''; } } else { - print ''; + print ''; } + if ($nbofchoice > 1) { ?> -
trans("CollationConnectionComment"); ?>
+
1) echo $langs->trans("CollationConnectionComment"); ?>
trans("ForceHttps"); ?>