diff --git a/.editorconfig b/.editorconfig index 143f0739505f027693fb693778bd63f409367f27..5b3e0d6a8df1091ff69dc259ef7d46e6e42ce746 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,14 +8,10 @@ charset = utf-8 end_of_line = lf insert_final_newline = true [*.php] -indent_style = space -indent_size = 4 +indent_style = tab [*.js] -indent_style = space -indent_size = 2 +indent_style = tab [*.css] -indent_style = space -indent_size = 2 +indent_style = tab [*.xml] -indent_style = space -indent_size = 4 +indent_style = tab diff --git a/COPYRIGHT b/COPYRIGHT index e4bd78e7bbfef20b60e6570129fe270fc53f6ee7..3c7cb5bf1cf8a67fa61ddf3b2bee8526079698b5 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -18,6 +18,7 @@ CKEditor 4.3.3 LGPL-2.1+ Yes FPDI 1.5.2 Apache Software License 2.0 Yes PDF templates management GeoIP 1.4 LGPL-2.1+ Yes Sample code to make geoip convert (not into deb package) NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) +PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency odtPHP 1.0.1 GPL-2+ b Yes Library to build/edit ODT files PHPExcel 1.8.0 LGPL-2.1+ Yes Read/Write XLS files, read ODS files php-iban 1.4.6 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php new file mode 100644 index 0000000000000000000000000000000000000000..17dab085259b89b952385c5015eac63dac81cc8a --- /dev/null +++ b/dev/translation/sanity_check_en_langfiles.php @@ -0,0 +1,60 @@ +<?php +/* Copyright (c) 2015 Lorenzo Novaro <novalore@19.coop> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +// directory containing the english lang files +$workdir = "../../htdocs/langs/en_US/"; + +$files = scandir($workdir); +$exludefiles = array('.','..','README'); +$files = array_diff($files,$exludefiles); +$langstrings_3d = array(); +$langstrings_full = array(); +foreach ($files AS $file) { + $path_file = pathinfo($file); + // we're only interested in .lang files + if ($path_file['extension']=='lang') { + $content = file($workdir.$file); + foreach ($content AS $line => $row) { + // don't want comment lines + if (substr($row,0,1) !== '#') { + // don't want lines without the separator (why should those even be here, anyway...) + if (strpos($row,'=')!==false) { + $row_array = explode('=',$row); + $langstrings_3d[$path_file['basename']][$line+1]=$row_array[0]; + $langstrings_full[]=$row_array[0]; + } + } + } + } +} + +foreach ($langstrings_3d AS $filename => $file) { + foreach ($file AS $linenum => $value) { + $keys = array_keys($langstrings_full, $value); + if (count($keys)>1) { + foreach ($keys AS $key) { + $dups[$value][$filename][$linenum] = ''; + } + } + } +} + +echo "<h2>Duplicate strings in lang files in $workdir</h2>"; +echo "<pre>"; +print_r($dups); + +?> \ No newline at end of file diff --git a/htdocs/adherents/admin/public.php b/htdocs/adherents/admin/public.php index 0f92e0174373acdf7fd122f78a219f2855366155..19fce918a318750e7516639209b7ce9e76bea1bb 100644 --- a/htdocs/adherents/admin/public.php +++ b/htdocs/adherents/admin/public.php @@ -164,7 +164,7 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<tr '.$bc[$var].' id="tramount"><td>'; print $langs->trans("DefaultAmount"); print '</td><td align="right">'; -print '<input type="text" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" size="5" value="'.(! empty($conf->global->MEMBER_NEWFORM_AMOUNT)?$conf->global->MEMBER_NEWFORM_AMOUNT:'').'">';; +print '<input type="text" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" size="5" value="'.(! empty($conf->global->MEMBER_NEWFORM_AMOUNT)?$conf->global->MEMBER_NEWFORM_AMOUNT:'').'">'; print "</td></tr>\n"; // Can edit @@ -197,7 +197,7 @@ if (! empty($conf->paybox->enabled) || ! empty($conf->paypal->enabled)) print '<tr '.$bc[$var].' id="tremail"><td>'; print $langs->trans("MEMBER_PAYONLINE_SENDEMAIL"); print '</td><td align="right">'; - print '<input type="text" id="MEMBER_PAYONLINE_SENDEMAIL" name="MEMBER_PAYONLINE_SENDEMAIL" size="24" value="'.(! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL)?$conf->global->MEMBER_PAYONLINE_SENDEMAIL:'').'">';; + print '<input type="text" id="MEMBER_PAYONLINE_SENDEMAIL" name="MEMBER_PAYONLINE_SENDEMAIL" size="24" value="'.(! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL)?$conf->global->MEMBER_PAYONLINE_SENDEMAIL:'').'">'; print "</td></tr>\n"; } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 6aa9e074ff67b6edf4f11f237db350e56484b273..0fe6366ae58e6f6d1f6872ab5472ca51c807a9e4 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -249,7 +249,7 @@ if (empty($reshook)) } $lastname=$_POST["lastname"]; $firstname=$_POST["firstname"]; - $morphy=$morphy=$_POST["morphy"];; + $morphy=$morphy=$_POST["morphy"]; if ($morphy != 'mor' && empty($lastname)) { $error++; $langs->load("errors"); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 83dc71d5403d02915163fd5970ed58594129d194..b9b2d18d512d25a8b72565d66864863eeeed8719 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -369,7 +369,7 @@ if ($action == 'edit' || $action == 'updateedit') // Logo $var=!$var; print '<tr'.dol_bc($var,'hideonsmartphone').'><td><label for="logo">'.$langs->trans("Logo").' (png,jpg)</label></td><td>'; - print '<table width="100%" class="nocellnopadd"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">'; + print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">'; print '<input type="file" class="flat" name="logo" id="logo" size="50">'; print '</td><td valign="middle" align="right">'; if (! empty($mysoc->logo_mini)) @@ -754,7 +754,7 @@ else $var=!$var; print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Logo").'</td><td>'; - print '<table width="100%" class="nocellnopadd"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">'; + print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">'; print $mysoc->logo; print '</td><td valign="center" align="right">'; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 8de52ef73c55ad7b998c291cb991eadf29da565d..167b38562adb736f21124d1bad31b35e59519236 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -913,7 +913,7 @@ if ($id) print "</tr>"; $colspan=count($fieldlist)+2; - if ($id == 4) $colspan++;; + if ($id == 4) $colspan++; if (! empty($alabelisused)) // Si un des champs est un libelle { diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index 7be283528b46a5cc3a092b1ecb40e9d9080ad6ed..4739a55e2c852a6623a28e6dfa4bb597d5435b8d 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -164,7 +164,7 @@ if (! empty($conf->service->enabled)) $var=! $var; print '<tr '.$bc[$var].'><td>'; print $langs->trans("CashdeskShowServices"); - print '<td colspan="2">';; + print '<td colspan="2">'; print $form->selectyesno("CASHDESK_SERVICES",$conf->global->CASHDESK_SERVICES,1); print "</td></tr>\n"; } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 4303c593f1a518bd75cdfb02c981318f2b97ca56..88aea468eabcad68a20fcc2f1a007c56854484a9 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1164,7 +1164,7 @@ class Categorie extends CommonObject { $cats = array(); - $typeid=-1; $table='';; + $typeid=-1; $table=''; if ($type == '0' || $type == 'product') { $typeid=0; $table='product'; $type='product'; } else if ($type == '1' || $type == 'supplier') { $typeid=1; $table='soc'; $type='fournisseur'; } else if ($type == '2' || $type == 'customer') { $typeid=2; $table='soc'; $type='societe'; } diff --git a/htdocs/comm/askpricesupplier/card.php b/htdocs/comm/askpricesupplier/card.php index 3a3b283f8e91ba29ebb59e4ee8ec14fabd7fb5f5..3e6abe98b2d51cd924d79c08fa6303af3d88d311 100644 --- a/htdocs/comm/askpricesupplier/card.php +++ b/htdocs/comm/askpricesupplier/card.php @@ -1730,6 +1730,9 @@ if ($action == 'create') /* * Action presend */ + if (!empty(GETPOST('modelselected'))) { + $action = 'presend'; + } if ($action == 'presend') { $object->fetch_projet(); @@ -1802,6 +1805,7 @@ if ($action == 'create') // Tableau des parametres complementaires $formmail->param['action'] = 'send'; $formmail->param['models'] = 'askpricesupplier_send'; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['id'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; // Init list of files diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 27d958914a27d6f968ca5da875f01c806468e36f..81e8b396963732d989390ba70574693b5286faab 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -155,7 +155,7 @@ if (empty($reshook)) if ($action == 'setoutstanding_limit') { $object->fetch($id); - $object->outstanding_limit=GETPOST('setoutstanding_limit'); + $object->outstanding_limit=GETPOST('outstanding_limit'); $result=$object->set_OutstandingBill($user); if ($result < 0) setEventMessage($object->error,'errors'); } @@ -406,9 +406,15 @@ if ($id > 0) $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; print $form->editfieldval("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer,$limit_field_type,($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); // display amount and link to unpaid bill - $outstandigBills = $object->get_OutstandingBill(); - if ($outstandigBills != 0) - print " (".$langs->trans("CurrentOutstandingBill")." <a href='".DOL_URL_ROOT."/compta/facture/list.php?socid=".$object->id."&search_status=1'>".price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency).'</a>)'; + $outstandingBills = $object->get_OutstandingBill(); + if ($outstandingBills != 0) { + print ' ('.$langs->trans("CurrentOutstandingBill"); + print ' <a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'&search_status=1">'; + print price($outstandingBills, '', $langs, 0, -1, -1, $conf->currency); + print '</a>'; + if ($outstandingBills > $object->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); + print ')'; + } print '</td>'; print '</tr>'; } diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 2a845f1e6e1462acdefd551839fa0b213f4012ff..6705752e71e896225bd219f8c938910d6866d1bb 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -579,6 +579,103 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) } } +/* + * Opened Order + */ +if (! empty($conf->commande->enabled) && $user->rights->commande->lire) +{ + $langs->load("order"); + + $sql = "SELECT s.nom as name, s.rowid, c.rowid as commandeid, c.total as total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv "; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= ", ".MAIN_DB_PREFIX."commande as c"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 1"; + if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND s.rowid = ".$socid; + $sql.= " ORDER BY c.rowid DESC"; + + $result=$db->query($sql); + if ($result) + { + $total = 0; + $num = $db->num_rows($result); + $i = 0; + if ($num > 0) + { + $var=true; + + print '<table class="noborder" width="100%">'; + print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("OrdersOpened").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=1"><span class="badge">'.$num.'</span></td></tr>'; + + $nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD)); + while ($i < $nbofloop) + { + $obj = $db->fetch_object($result); + $var=!$var; + print '<tr '.$bc[$var].'>'; + + // Ref + print '<td class="nowrap" width="140">'; + + $orderstatic->id=$obj->commandeid; + $orderstatic->ref=$obj->ref; + $orderstatic->ref_client=$obj->ref_client; + $orderstatic->total_ht = $obj->total_ht; + $orderstatic->total_tva = $obj->total_tva; + $orderstatic->total_ttc = $obj->total_ttc; + + print '<table class="nobordernopadding"><tr class="nocellnopadd">'; + print '<td class="nobordernopadding nowrap">'; + print $orderstatic->getNomUrl(1); + print '</td>'; + print '<td width="18" class="nobordernopadding nowrap">'; + //if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + print '</td>'; + print '<td width="16" align="center" class="nobordernopadding">'; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; + print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir); + print '</td></tr></table>'; + + print "</td>"; + + print '<td class="nowrap">'; + $companystatic->id=$obj->rowid; + $companystatic->name=$obj->name; + $companystatic->client=$obj->client; + $companystatic->canvas=$obj->canvas; + print $companystatic->getNomUrl(1, 'company', 44); + print '</td>'; + print '<td align="right">'; + print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n"; + print '<td align="right">'.price($obj->total_ttc).'</td>'; + print '<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut,3).'</td>'."\n"; + print '</tr>'."\n"; + $i++; + $total += $obj->total_ttc; + } + if ($num > $nbofloop) + { + print '<tr class="liste_total"><td colspan="5">'.$langs->trans("XMoreLines", ($num - $nbofloop))."</td></tr>"; + } + else if ($total>0) + { + print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td> </td></tr>"; + } + print "</table><br>"; + } + } + else + { + dol_print_error($db); + } +} + + print '</div></div></div>'; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index f0a4b6f1f792c4341a3acd8116afe4549e4b1e6b..e6876637dcf3eee380ceb39c40b8e08a2a58b037 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -2307,6 +2307,10 @@ if ($action == 'create') /* * Action presend */ + //Select mail models is same action as presend + if (!empty(GETPOST('modelselected'))) { + $action = 'presend'; + } if ($action == 'presend') { $object->fetch_projet(); @@ -2401,6 +2405,7 @@ if ($action == 'create') // Tableau des parametres complementaires $formmail->param['action'] = 'send'; $formmail->param['models'] = 'propal_send'; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['id'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; // Init list of files diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 294445705edb05b2102b15c006a0125d60d478e4..0ffb3807467280c8aaefaff7c8dbf537aa82978e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2396,6 +2396,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Tableau des parametres complementaires $formmail->param['action'] = 'send'; $formmail->param['models'] = 'order_send'; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['orderid'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 6f207b198cfd67e58ebbd513efad17116a3a5d7c..c89f45d0d2ca7e837bbc34ab47ebd348818fe326 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -379,7 +379,7 @@ else elseif ($links[$key]['type']=='payment_supplier') { $paymentsupplierstatic->id=$links[$key]['url_id']; - $paymentsupplierstatic->ref=$langs->trans("Payment");; + $paymentsupplierstatic->ref=$langs->trans("Payment"); print ' '.$paymentsupplierstatic->getNomUrl(1); $newline=0; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 4d8ed6007e3a7980aaf2bd6279e5d664147e281f..01df11a61abf09a88d33ed77018b0b5b67752219 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1966,12 +1966,12 @@ if ($action == 'create') print $soc->getNomUrl(1); print '<input type="hidden" name="socid" value="' . $soc->id . '">'; // Outstanding Bill - $outstandigBills = $soc->get_OutstandingBill(); + $outstandingBills = $soc->get_OutstandingBill(); print ' (' . $langs->trans('CurrentOutstandingBill') . ': '; - print price($outstandigBills, '', $langs, 0, 0, -1, $conf->currency); + print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency); if ($soc->outstanding_limit != '') { - if ($outstandigBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); + if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency); } print ')'; @@ -2832,11 +2832,11 @@ if ($action == 'create') print ' '; print '(<a href="' . DOL_URL_ROOT . '/compta/facture/list.php?socid=' . $object->socid . '">' . $langs->trans('OtherBills') . '</a>'; // Outstanding Bill - $outstandigBills = $soc->get_OutstandingBill(); + $outstandingBills = $soc->get_OutstandingBill(); print ' - ' . $langs->trans('CurrentOutstandingBill') . ': '; - print price($outstandigBills, '', $langs, 0, 0, - 1, $conf->currency); + print price($outstandingBills, '', $langs, 0, 0, - 1, $conf->currency); if ($soc->outstanding_limit != '') { - if ($outstandigBills > $soc->outstanding_limit) + if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); print ' / ' . price($soc->outstanding_limit); } @@ -3733,6 +3733,10 @@ if ($action == 'create') } print '<br>'; + //Select mail models is same action as presend + if (!empty(GETPOST('modelselected'))) { + $action = 'presend'; + } if ($action != 'prerelance' && $action != 'presend') { print '<div class="fichecenter"><div class="fichehalfleft">'; @@ -3953,6 +3957,7 @@ if ($action == 'create') // Tableau des parametres complementaires du post $formmail->param['action'] = $action; $formmail->param['models'] = $modelmail; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['facid'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php index dfa1207e4231c23ef2a9761e8d6fbe68019ec337..efe16af1fb949badcaf90c82574d5b7b88f3f1a2 100644 --- a/htdocs/compta/facture/mergepdftool.php +++ b/htdocs/compta/facture/mergepdftool.php @@ -530,6 +530,9 @@ if ($resql) print '<form id="form_unpaid" method="POST" action="'.$_SERVER["PHP_SELF"].'?sortfield='. $sortfield .'&sortorder='. $sortorder .'">'; + if (!empty(GETPOST('modelselected'))) { + $action = 'presend'; + } if (! empty($mode) && $action == 'presend') { include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; @@ -572,6 +575,7 @@ if ($resql) // Tableau des parametres complementaires du post $formmail->param['action']=$action; $formmail->param['models']=$modelmail; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['facid']=$object->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index f704ca90f73ed400c1c9c9ded356219554e0caba..a44cb4ed48e481390223bd2431bafe1835a42785 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -298,7 +298,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) if ($annee_decalage != $year_end) print '<td width="15"> </td>'; } - $total_ht[$annee]+=!empty($cum_ht[$case]) ? $cum_ht[$case] : 0;; + $total_ht[$annee]+=!empty($cum_ht[$case]) ? $cum_ht[$case] : 0; $total[$annee]+=$cum[$case]; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0b7a21416a6eb62643b15a8b7b3f16474ea2c1b8..159cbb7a857e7e729379ef907a745cd91ccf765d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3350,25 +3350,26 @@ abstract class CommonObject $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; - $sql.= " WHERE rowid =".$rowid; + $sql.= " WHERE rowid=".$rowid; dol_syslog(get_class($this)."::delete_resource", LOG_DEBUG); - if ($this->db->query($sql)) - { - if (! $notrigger) + $resql=$this->db->query($sql); + if (! $resql) + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + else + { + if (! $notrigger) { $result=$this->call_trigger(strtoupper($element).'_DELETE_RESOURCE', $user); if ($result < 0) { $this->db->rollback(); return -1; } } - - return 1; - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -1; - } + $this->db->commit(); + return 1; + } } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index ce22996f7864e298e3eae15679e3ac7dfa407db4..3c799b767afc01412aa873fb5ae13be2f012beed 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -291,7 +291,8 @@ class FormMail extends Form foreach($this->lines_model as $line) { $modelmail_array[$line->id]=$line->label; } - if (count($modelmail_array>0)) { + + if (count($modelmail_array)>0) { $out.= '<table class="nobordernopadding" width="100%"><tr><td width="20%">'."\n"; $out.= $langs->trans('SelectMailModel').':'.$this->selectarray('modelmailselected', $modelmail_array,$model_id); $out.= '</td>'; @@ -836,15 +837,15 @@ class FormMail extends Form if ($resql) { $this->lines_model=array(); - while ($obj = $this->db->fetch_object($resql)) { - $line = new ModelMailLine(); + while ($obj = $this->db->fetch_object($resql)) + { + $line = new ModelMail(); $line->id=$obj->rowid; $line->label=$obj->label; $line->topic=$obj->topic; $line->content=$obj->lacontentbel; $line->lang=$obj->lang; $this->lines_model[]=$line; - } $this->db->free($resql); return $num; @@ -857,7 +858,10 @@ class FormMail extends Form } } -class ModelMailLine +/** + * ModelMail + */ +class ModelMail { public $id; public $label; @@ -865,4 +869,3 @@ class ModelMailLine public $content; public $lang; } - diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 4a8ae857a2df71b0ed9dfa3e23558e5676efe3ad..44507bbb919ad82ca6e34cd2ee4e44e52504e226 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2011-2015 Juanjo Menent <jmenent@2byte.es> * * 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 @@ -836,18 +836,18 @@ function monthArray($outputlangs,$short=0) if (! empty($short)) { $montharray = array ( - 1 => $outputlangs->trans("Jan"), - 2 => $outputlangs->trans("Feb"), - 3 => $outputlangs->trans("Mar"), - 4 => $outputlangs->trans("Apr"), - 5 => $outputlangs->trans("May"), - 6 => $outputlangs->trans("Jun"), - 7 => $outputlangs->trans("Jul"), - 8 => $outputlangs->trans("Aug"), - 9 => $outputlangs->trans("Sep"), - 10 => $outputlangs->trans("Oct"), - 11 => $outputlangs->trans("Nov"), - 12 => $outputlangs->trans("Dec") + 1 => $outputlangs->trans("JanuaryMin"), + 2 => $outputlangs->trans("FebruaryMin"), + 3 => $outputlangs->trans("MarchMin"), + 4 => $outputlangs->trans("AprilMin"), + 5 => $outputlangs->trans("MayMin"), + 6 => $outputlangs->trans("JuneMin"), + 7 => $outputlangs->trans("JulyMin"), + 8 => $outputlangs->trans("AugustMin"), + 9 => $outputlangs->trans("SeptemberMin"), + 10 => $outputlangs->trans("OctoberMin"), + 11 => $outputlangs->trans("NovemberMin"), + 12 => $outputlangs->trans("DecemberMin") ); } diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index a6fae1c7b1f30d6373f619957c4a3ad0ecbbd6fd..b68016c3a469d33ab7f17462d85d471d4d9bfe39 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -231,7 +231,7 @@ function dol_getshmop($memoryid) global $shmkeys,$shmoffset; if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0; - $shmkey=dol_getshmopaddress($memoryid);; + $shmkey=dol_getshmopaddress($memoryid); //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n"; $handle=@shmop_open($shmkey,'a',0,0); if ($handle) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 2aa3ae9347460fd638b0cdc8e17b17adf56b5919..af37283d074248367987e9029cd90c47bf7357d6 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -117,17 +117,17 @@ function task_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'task_task'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); $head[$h][1] = $langs->trans("TaskRessourceLinks"); $head[$h][2] = 'task_contact'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); $head[$h][1] = $langs->trans("TimeSpent"); $head[$h][2] = 'task_time'; $h++; @@ -143,14 +143,14 @@ function task_prepare_head($object) $nbNote = 0; if(!empty($object->note_private)) $nbNote++; if(!empty($object->note_public)) $nbNote++; - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; $head[$h][2] = 'task_notes'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); $filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $listoffiles=dol_dir_list($filesdir,'files',1,'','thumbs'); diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index f6623362dccba44adf6c461c15b7246ebb02fbc7..a163047e61b4a401ca26f8c3c134165684bb9f12 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -496,7 +496,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; - $sql.= " AND f.rowid = d.".$fk_facture;; + $sql.= " AND f.rowid = d.".$fk_facture; $sql.= " AND pf.".$fk_facture2." = f.rowid"; $sql.= " AND pa.rowid = pf.".$fk_payment; if ($y && $m) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3139963a6c3d11cee7997095c2373c691b79740b..e076e674be2e1ea455b09b0231cede956e0abced 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -218,9 +218,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0) // Tools - $tmpentry=array('enabled'=>(! empty($conf->barcode->enabled) || ! empty($conf->mailing->enabled) || ! empty($conf->export->enabled) || ! empty($conf->import->enabled) || ! empty($conf->opensurvey->enabled)), - 'perms'=>(! empty($conf->barcode->enabled) || ! empty($user->rights->mailing->lire) || ! empty($user->rights->export->lire) || ! empty($user->rights->import->run) || ! empty($user->rights->opensurvey->read)), - 'module'=>'mailing|export|import|opensurvey'); + $tmpentry=array('enabled'=>(! empty($conf->barcode->enabled) || ! empty($conf->mailing->enabled) || ! empty($conf->export->enabled) || ! empty($conf->import->enabled) || ! empty($conf->opensurvey->enabled) || ! empty($conf->resource->enabled)), + 'perms'=>(! empty($conf->barcode->enabled) || ! empty($user->rights->mailing->lire) || ! empty($user->rights->export->lire) || ! empty($user->rights->import->run) || ! empty($user->rights->opensurvey->read) || ! empty($user->rights->resource->read)), + 'module'=>'mailing|export|import|opensurvey|resource'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 22008bb054dca80e96d46eb3fac1cea2f52a024b..da59679b1bee4186eb95a66e5066c9fecc57da05 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -376,7 +376,7 @@ class ImportCsv extends ModeleImports if ($obj) $tablewithentity_cache[$tablename]=1; // table contains entity field else $tablewithentity_cache[$tablename]=0; // table does not contains entity field } - else dol_print_error($this->db);; + else dol_print_error($this->db); } else { diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index e63f44c3945d41e87decbbfcd57f1ccf509b0e93..da1f807ecacaa76a9a42a63ebba7361ec1fda8a5 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -61,7 +61,7 @@ class modResource extends DolibarrModules // (where XXX is value of numeric property 'numero' of module) $this->description = "Manage resources (printers, cars, room, ...) you can then share into events"; // Possible values for version are: 'development', 'experimental' or version - $this->version = 'development'; + $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled // (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); @@ -114,8 +114,7 @@ class modResource extends DolibarrModules $this->requiredby = array('modPlace'); // Minimum version of PHP required by module $this->phpmin = array(5, 3); - // Minimum version of Dolibarr required by module - $this->need_dolibarr_version = array(3, 5); + $this->langfiles = array("resource@resource"); // langfiles@resource // Constants // List of particular constants to add when module is enabled diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 8a9669dadf1ffc2b1b117261343840d50327910c..31172a32f43a8f3f628b8462dd9f9f84128be4b8 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -416,7 +416,7 @@ class doc_generic_task_odt extends ModelePDFTask $project= new Project($this->db); $project->fetch($object->fk_project); - $dir = $conf->projet->dir_output. "/" . $project->ref. "/";; + $dir = $conf->projet->dir_output. "/" . $project->ref. "/"; $objectref = dol_sanitizeFileName($object->ref); if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; $file = $dir . "/" . $objectref . ".odt"; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index b3ff4710f1bbb58a55dee7e2c221e351ba80bdd8..2d4300f76da58c9a71a6728275ef755011e7d391 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -589,6 +589,57 @@ class pdf_azur extends ModelePDFPropales $this->_pagefoot($pdf,$object,$outputlangs); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + //If propal merge product PDF is active + if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php'; + + $already_merged = array (); + foreach ( $object->lines as $line ) { + if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) { + // Find the desire PDF + $filetomerge = new Propalmergepdfproduct($this->db); + + if ($conf->global->MAIN_MULTILANGS) { + $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang); + } else { + $filetomerge->fetch_by_product($line->fk_product); + } + + $already_merged[] = $line->fk_product; + + // If PDF is selected and file is not empty + if (count($filetomerge->lines) > 0) { + foreach ( $filetomerge->lines as $linefile ) { + if (! empty($linefile->id) && ! empty($linefile->file_name)) { + if (! empty($conf->product->enabled)) + $filetomerge_dir = $conf->product->multidir_output[$conf->entity] . '/' . dol_sanitizeFileName($line->product_ref); + elseif (! empty($conf->service->enabled)) + $filetomerge_dir = $conf->service->multidir_output[$conf->entity] . '/' . dol_sanitizeFileName($line->product_ref); + + dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG); + + $infile = $filetomerge_dir . '/' . $linefile->file_name; + if (is_file($infile)) { + $pagecount = $pdf->setSourceFile($infile); + for($i = 1; $i <= $pagecount; $i ++) { + $tplidx = $pdf->ImportPage($i); + $s = $pdf->getTemplatesize($tplidx); + $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); + $pdf->useTemplate($tplidx); + } + } + } + } + } + } + } + } + + //exit; + + + $pdf->Close(); $pdf->Output($file,'F'); diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index f5e6c957b1a485cc49710b2cb985d5a8763b3758..269232ddb76450d9fa6d6b2d0d8c24ed2f096041 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -56,7 +56,7 @@ else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'link') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();;jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();} + else if (type == 'link') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();} else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 7b4f27ae87e78743adf08ca0dc926b4fc467cb96..f3131ca928af319c1304b916b2407f79c66cc252 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -53,7 +53,9 @@ if (empty($usemargins)) $usemargins=0; <td align="center"><?php $coldisplay++; ?><?php echo ($i+1); ?></td> <?php } ?> <td><?php $coldisplay++; ?><div id="line_<?php echo $line->id; ?>"></div> - <?php if (($line->info_bits & 2) == 2) { ?> + <?php + if (($line->info_bits & 2) == 2) { + ?> <a href="<?php echo DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid; ?>"> <?php $txt=''; @@ -90,9 +92,8 @@ if (empty($usemargins)) $usemargins=0; { if ($line->fk_product > 0) { - echo $form->textwithtooltip($text,$description,3,'','',$i,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); - + // Show range echo get_date_range($line->date_start, $line->date_end); @@ -128,7 +129,7 @@ if (empty($usemargins)) $usemargins=0; <?php } ?> <td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo vatrate($line->tva_tx,'%',$line->info_bits); ?></td> - <td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->pu_ht); ?></td> + <td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->subprice); ?></td> <?php if ($inputalsopricewithtax) { ?> <td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo (isset($line->pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?></td> diff --git a/htdocs/core/tpl/resource_view.tpl.php b/htdocs/core/tpl/resource_view.tpl.php index d57b66cc331e40115fdf8c315a237e0d69c52263..75a6999660335e6af0249932e144afa3b538f36c 100644 --- a/htdocs/core/tpl/resource_view.tpl.php +++ b/htdocs/core/tpl/resource_view.tpl.php @@ -90,7 +90,7 @@ if( (array) $linked_resources && count($linked_resources) > 0) print img_edit(); print '</a>'; print ' '; - print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete_resource&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">'; + print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete_resource&id='.$linked_resource['resource_id'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">'; print img_delete(); print '</a>'; print '</div>'; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index fa451f74f1c7bd393e52e8cf7e74032d71dd830d..c937d5a362152d345e7475f2d4b9a1f9e1c58555 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1513,6 +1513,10 @@ else if ($id || $ref) /* * Action presend */ + //Select mail models is same action as presend + if (!empty(GETPOST('modelselected'))) { + $action = 'presend'; + } if ($action == 'presend') { $ref = dol_sanitizeFileName($object->ref); @@ -1611,6 +1615,7 @@ else if ($id || $ref) // Tableau des parametres complementaires $formmail->param['action']='send'; $formmail->param['models']='shipping_send'; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['shippingid']=$object->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 0d30602987fcc3c90975855bb47d178bdf404f3b..c6c638f06f326ebb8508f175c38c0f0c68b22d03 100755 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -623,7 +623,7 @@ class ExpenseReport extends CommonObject print $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut0'); break; case 2: - print $langs->trans('TripForValid').' '.img_picto($langs->trans('TripForValid'),'statut3');; + print $langs->trans('TripForValid').' '.img_picto($langs->trans('TripForValid'),'statut3'); break; case 5: print $langs->trans('TripForPaid').' '.img_picto($langs->trans('TripForPaid'),'statut3'); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index e95b14398a29f859107a0a1ef2c708e7c000534c..d1fb92a33ab05b3fd0a89130df2a9b541d75cddb 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1732,6 +1732,9 @@ else if ($id > 0 || ! empty($ref)) /* * Action presend */ + if (!empty(GETPOST('modelselected'))) { + $action = 'presend'; + } if ($action == 'presend') { $ref = dol_sanitizeFileName($object->ref); @@ -1819,6 +1822,7 @@ else if ($id > 0 || ! empty($ref)) // Tableau des parametres complementaires $formmail->param['action']='send'; $formmail->param['models']='fichinter_send'; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['fichinter_id']=$object->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 15bee891775333b70db440a81fb55d9a73147f80..48d662774ae148207c52698ddcc570544757051d 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -66,6 +66,14 @@ $conffiletoshow = "htdocs/conf/conf.php"; //$conffile = "/etc/dolibarr/conf.php"; //$conffiletoshow = "/etc/dolibarr/conf.php"; +//replace conf filename with "conf" parameter on url by GET +if (!empty($_GET['conf'])) { + setcookie('dolconf', $_GET['conf'],0,'/'); + $conffile = 'conf/' . $_GET['conf'] . '.php'; +} else { + $conffile = 'conf/' . (!empty($_COOKIE['dolconf']) ? $_COOKIE['dolconf'] : 'conf') . '.php'; +} + // Include configuration $result=@include_once $conffile; // Keep @ because with some error reporting this break the redirect diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5b8f42efc307c2642ca86ebaed63840b03eed54a..3b6de2109280e63be260c31b8617fcb01ce415ab 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2400,7 +2400,7 @@ class CommandeFournisseur extends CommonOrder } } - if ($nb === 0) return $langs->trans('Undefined'); + if ($nb === 0) return ''; else return $nb.' '.$langs->trans('Days'); } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 00eec4d536a918b5be3997ad1851c8c71485d650..59ea55446814012ac00f427f80ca85061e845a61 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -507,7 +507,8 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i]->product_ref = $obj->product_ref; // Internal reference $this->lines[$i]->ref = $obj->product_ref; // deprecated. $this->lines[$i]->ref_supplier = $obj->ref_supplier; // Reference product supplier TODO Rename field ref to ref_supplier into table llx_facture_fourn_det and llx_commande_fournisseurdet and update fields it into updateline - $this->lines[$i]->libelle = $obj->label; // This field may contains label of product (when invoice create from order) + $this->lines[$i]->libelle = $obj->label; // Deprecated + $this->lines[$i]->label = $obj->label; // This field may contains label of product (when invoice create from order) $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit $this->lines[$i]->subprice = $obj->pu_ht; $this->lines[$i]->pu_ht = $obj->pu_ht; @@ -525,6 +526,7 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i]->total_ttc = $obj->total_ttc; $this->lines[$i]->fk_product = $obj->fk_product; $this->lines[$i]->product_type = $obj->product_type; + $this->lines[$i]->product_label = $obj->label; $this->lines[$i]->info_bits = $obj->info_bits; $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; $this->lines[$i]->special_code = $obj->special_code; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index e50095a60487e218e1c382ccf1c7336d6e56888e..fd6c076ecf737184059406963c107c2a319c1134 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2246,6 +2246,9 @@ elseif (! empty($object->id)) /* * Action presend */ + if (!empty(GETPOST('modelselected'))) { + $action = 'presend'; + } if ($action == 'presend') { $ref = dol_sanitizeFileName($object->ref); @@ -2338,6 +2341,7 @@ elseif (! empty($object->id)) // Tableau des parametres complementaires $formmail->param['action']='send'; $formmail->param['models']='order_supplier_send'; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['orderid']=$object->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 1691efc78a58b572bea789752ae85c6725178308..45f300c8a898e9bda9f757fa7887906fe6588da6 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -547,27 +547,25 @@ if (empty($reshook)) { $up = price2num(GETPOST('price_ht')); $price_base_type = 'HT'; - $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type,'','', $date_start, $date_end); } else { $up = price2num(GETPOST('price_ttc')); $price_base_type = 'TTC'; - $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end); } - if (GETPOST('idprod')) + if (GETPOST('productid')) { $prod = new Product($db); - $prod->fetch($_POST['idprod']); + $prod->fetch(GETPOST('productid')); $label = $prod->description; - if (trim($_POST['desc']) != trim($label)) $label=$_POST['desc']; + if (trim($_POST['product_desc']) != trim($label)) $label=$_POST['product_desc']; $type = $prod->type; } else { - $label = $_POST['desc']; + $label = $_POST['product_desc']; $type = $_POST["type"]?$_POST["type"]:0; } @@ -589,7 +587,7 @@ if (empty($reshook)) } } - $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('idprod'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options); + $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options); if ($result >= 0) { unset($_POST['label']); @@ -2501,6 +2499,9 @@ else /* * Show mail form */ + if (!empty(GETPOST('modelselected'))) { + $action = 'presend'; + } if ($action == 'presend') { $ref = dol_sanitizeFileName($object->ref); @@ -2587,6 +2588,7 @@ else // Tableau des parametres complementaires $formmail->param['action']='send'; $formmail->param['models']='invoice_supplier_send'; + $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['facid']=$object->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index a2e6b9d22bc48915cd0a20805f3f144f5b232797..e1b57b60c91e3aa5311a87118e44e5843f3c444a 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -424,7 +424,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Bouton Enregistrer if ($action != 'add_paiement') { - print '<<br><div class="center"><input type="checkbox" checked="checked" name="closepaidinvoices"> '.$langs->trans("ClosePaidInvoicesAutomatically"); + print '<br><div class="center"><input type="checkbox" checked="checked" name="closepaidinvoices"> '.$langs->trans("ClosePaidInvoicesAutomatically"); print '<br><input type="submit" class="button" value="'.$langs->trans('Save').'"></div>'; } diff --git a/htdocs/includes/nusoap/lib/Mail/PEAR.php b/htdocs/includes/nusoap/lib/Mail/PEAR.php deleted file mode 100644 index 406ef9c23baefa425d29bbb4f60fa1613ae905b0..0000000000000000000000000000000000000000 --- a/htdocs/includes/nusoap/lib/Mail/PEAR.php +++ /dev/null @@ -1,1100 +0,0 @@ -<?php -/** - * PEAR, the PHP Extension and Application Repository - * - * PEAR class and PEAR_Error class - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 3.0 of the PHP license - * that is available through the world-wide-web at the following URI: - * http://www.php.net/license/3_0.txt. If you did not receive a copy of - * the PHP License and are unable to obtain it through the web, please - * send a note to license@php.net so we can mail you a copy immediately. - * - * @category pear - * @package PEAR - * @author Sterling Hughes <sterling@php.net> - * @author Stig Bakken <ssb@php.net> - * @author Tomas V.V.Cox <cox@idecnet.com> - * @author Greg Beaver <cellog@php.net> - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @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 <ssb@php.net> - * @author Tomas V.V. Cox <cox@idecnet.com> - * @author Greg Beaver <cellog@php.net> - * @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 <ssb@php.net> - * @author Tomas V.V. Cox <cox@idecnet.com> - * @author Gregory Beaver <cellog@php.net> - * @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 deleted file mode 100644 index 51849fee4a1cae9941a77c149d68b926f7046693..0000000000000000000000000000000000000000 --- a/htdocs/includes/nusoap/lib/Mail/RFC822.php +++ /dev/null @@ -1,922 +0,0 @@ -<?php -// +-----------------------------------------------------------------------+ -// | Copyright (c) 2001-2002, Richard Heyes | -// | All rights reserved. | -// | | -// | Redistribution and use in source and binary forms, with or without | -// | modification, are permitted provided that the following conditions | -// | are met: | -// | | -// | o Redistributions of source code must retain the above copyright | -// | notice, this list of conditions and the following disclaimer. | -// | o Redistributions in binary form must reproduce the above copyright | -// | notice, this list of conditions and the following disclaimer in the | -// | documentation and/or other materials provided with the distribution.| -// | o The names of the authors may not be used to endorse or promote | -// | products derived from this software without specific prior written | -// | permission. | -// | | -// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | -// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | -// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | -// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | -// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | -// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | -// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | -// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | -// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | -// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | -// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | -// | | -// +-----------------------------------------------------------------------+ -// | Authors: Richard Heyes <richard@phpguru.org> | -// | Chuck Hagenbuch <chuck@horde.org> | -// +-----------------------------------------------------------------------+ - -/** - * 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" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;'; - * $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', true) - * print_r($structure); - * - * @author Richard Heyes <richard@phpguru.org> - * @author Chuck Hagenbuch <chuck@horde.org> - * @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@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*<any CHAR except specials, SPACE and CTLs> - * - * 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('/(?<!\\\\),/', $data)); - } - - /** - * This is a email validating function separate to the rest of the - * class. It simply validates whether an email is of the common - * internet form: <user>@<domain>. 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 deleted file mode 100644 index 58c01d95f331c989e8fbe09424822efd03853fb2..0000000000000000000000000000000000000000 --- a/htdocs/includes/nusoap/lib/Mail/mail.php +++ /dev/null @@ -1,128 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2003 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Chuck Hagenbuch <chuck@horde.org> | -// +----------------------------------------------------------------------+ -// - -/** - * internal PHP-mail() implementation of the PEAR Mail:: interface. - * @package Mail - */ -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 index 3d44f050062dca49a837aeddfaa35252d4b54ed0..50297dd3e2f3cf21c7cab6fb08509dec3d21c376 100644 --- a/htdocs/includes/nusoap/lib/Mail/mime.php +++ b/htdocs/includes/nusoap/lib/Mail/mime.php @@ -1,135 +1,221 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ -// +-----------------------------------------------------------------------+ -// | Copyright (c) 2002-2003 Richard Heyes | -// | Copyright (c) 2003-2005 The PHP Group | -// | All rights reserved. | -// | | -// | Redistribution and use in source and binary forms, with or without | -// | modification, are permitted provided that the following conditions | -// | are met: | -// | | -// | o Redistributions of source code must retain the above copyright | -// | notice, this list of conditions and the following disclaimer. | -// | o Redistributions in binary form must reproduce the above copyright | -// | notice, this list of conditions and the following disclaimer in the | -// | documentation and/or other materials provided with the distribution.| -// | o The names of the authors may not be used to endorse or promote | -// | products derived from this software without specific prior written | -// | permission. | -// | | -// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | -// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | -// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | -// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | -// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | -// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | -// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | -// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | -// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | -// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | -// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | -// | | -// +-----------------------------------------------------------------------+ -// | Author: Richard Heyes <richard@phpguru.org> | -// | Tomas V.V.Cox <cox@idecnet.com> (port to PEAR) | -// +-----------------------------------------------------------------------+ -// - -require_once('PEAR.php'); -require_once('Mail/mimePart.php'); +/** + * The Mail_Mime class is used to create MIME E-mail messages + * + * The Mail_Mime class provides an OO interface to create MIME + * enabled email messages. This way you can create emails that + * contain plain-text bodies, HTML bodies, attachments, inline + * images and specific headers. + * + * Compatible with PHP versions 4 and 5 + * + * LICENSE: This LICENSE is in the BSD license style. + * Copyright (c) 2002-2003, Richard Heyes <richard@phpguru.org> + * Copyright (c) 2003-2006, PEAR <pear-group@php.net> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - Neither the name of the authors, nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * @category Mail + * @package Mail_Mime + * @author Richard Heyes <richard@phpguru.org> + * @author Tomas V.V. Cox <cox@idecnet.com> + * @author Cipriano Groenendal <cipri@php.net> + * @author Sean Coates <sean@php.net> + * @author Aleksander Machniak <alec@php.net> + * @copyright 2003-2006 PEAR <pear-group@php.net> + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id$ + * @link http://pear.php.net/package/Mail_mime + * + * This class is based on HTML Mime Mail class from + * Richard Heyes <richard@phpguru.org> which was based also + * in the mime_mail.class by Tobias Ratschiller <tobias@dnet.it> + * and Sascha Schumann <sascha@schumann.cx> + */ + /** - * 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/ + * require PEAR * - * @notes This class is based on HTML Mime Mail class from - * Richard Heyes <richard@phpguru.org> which was based also - * in the mime_mail.class by Tobias Ratschiller <tobias@dnet.it> and - * Sascha Schumann <sascha@schumann.cx> + * This package depends on PEAR to raise errors. + */ +require_once 'PEAR.php'; + +/** + * require Mail_mimePart * - * @author Richard Heyes <richard.heyes@heyes-computing.net> - * @author Tomas V.V.Cox <cox@idecnet.com> - * @package Mail - * @access public + * Mail_mimePart contains the code required to + * create all the different parts a mail can + * consist of. + */ +require_once 'Mail/mimePart.php'; + + +/** + * The Mail_Mime class provides an OO interface to create MIME + * enabled email messages. This way you can create emails that + * contain plain-text bodies, HTML bodies, attachments, inline + * images and specific headers. + * + * @category Mail + * @package Mail_Mime + * @author Richard Heyes <richard@phpguru.org> + * @author Tomas V.V. Cox <cox@idecnet.com> + * @author Cipriano Groenendal <cipri@php.net> + * @author Sean Coates <sean@php.net> + * @copyright 2003-2006 PEAR <pear-group@php.net> + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Mail_mime */ class Mail_mime { /** * Contains the plain text part of the email + * * @var string + * @access private */ var $_txtbody; + /** * Contains the html part of the email + * * @var string + * @access private */ 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 + * @access private */ var $_html_images = array(); + /** * list of the attachements + * * @var array + * @access private */ var $_parts = array(); + /** - * Build parameters + * Headers for the mail + * * @var array + * @access private */ - var $_build_params = array(); + var $_headers = array(); + /** - * Headers for the mail + * Build parameters + * * @var array + * @access private */ - var $_headers = array(); + var $_build_params = array( + // What encoding to use for the headers + // Options: quoted-printable or base64 + 'head_encoding' => 'quoted-printable', + // What encoding to use for plain text + // Options: 7bit, 8bit, base64, or quoted-printable + 'text_encoding' => 'quoted-printable', + // What encoding to use for html + // Options: 7bit, 8bit, base64, or quoted-printable + 'html_encoding' => 'quoted-printable', + // The character set to use for html + 'html_charset' => 'ISO-8859-1', + // The character set to use for text + 'text_charset' => 'ISO-8859-1', + // The character set to use for headers + 'head_charset' => 'ISO-8859-1', + // End-of-line sequence + 'eol' => "\r\n", + // Delay attachment files IO until building the message + 'delay_file_io' => false + ); + /** - * End Of Line sequence (for serialize) - * @var string + * Constructor function + * + * @param mixed $params Build parameters that change the way the email + * is built. Should be an associative array. + * See $_build_params. + * + * @return void + * @access public */ - var $_eol; + function Mail_mime($params = array()) + { + // Backward-compatible EOL setting + if (is_string($params)) { + $this->_build_params['eol'] = $params; + } else if (defined('MAIL_MIME_CRLF') && !isset($params['eol'])) { + $this->_build_params['eol'] = MAIL_MIME_CRLF; + } + // Update build parameters + if (!empty($params) && is_array($params)) { + while (list($key, $value) = each($params)) { + $this->_build_params[$key] = $value; + } + } + } /** - * Constructor function + * Set build parameter value * + * @param string $name Parameter name + * @param string $value Parameter value + * + * @return void * @access public + * @since 1.6.0 */ - function Mail_mime($crlf = "\r\n") + function setParam($name, $value) { - $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' - ); + $this->_build_params[$name] = $value; } /** - * Wakeup (unserialize) - re-sets EOL constant + * Get build parameter value * - * @access private + * @param string $name Parameter name + * + * @return mixed Parameter value + * @access public + * @since 1.6.0 */ - function __wakeup() + function getParam($name) { - $this->_setEOL($this->_eol); + return isset($this->_build_params[$name]) ? $this->_build_params[$name] : null; } /** @@ -138,14 +224,15 @@ class Mail_mime * 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 + * @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) @@ -158,7 +245,7 @@ class Mail_mime } } else { $cont = $this->_file2str($data); - if (PEAR::isError($cont)) { + if ($this->_isError($cont)) { return $cont; } if (!$append) { @@ -167,17 +254,31 @@ class Mail_mime $this->_txtbody .= $cont; } } + return true; } /** - * Adds a html part to the mail + * Get message text body * - * @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 + * @return string Text body + * @access public + * @since 1.6.0 + */ + function getTXTBody() + { + return $this->_txtbody; + } + + /** + * Adds a html part to the mail. + * + * @param string $data Either a string or the file name with the + * contents + * @param bool $isfile A flag that determines whether $data is a + * filename, or a string(false, default) + * + * @return bool True on success * @access public */ function setHTMLBody($data, $isfile = false) @@ -186,7 +287,7 @@ class Mail_mime $this->_htmlbody = $data; } else { $cont = $this->_file2str($data); - if (PEAR::isError($cont)) { + if ($this->_isError($cont)) { return $cont; } $this->_htmlbody = $cont; @@ -196,105 +297,192 @@ class Mail_mime } /** - * Adds an image to the list of embedded images. + * Get message HTML body * - * @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 + * @return string HTML body * @access public + * @since 1.6.0 */ - function addHTMLImage($file, $c_type='application/octet-stream', - $name = '', $isfilename = true) + function getHTMLBody() { - $filedata = ($isfilename === true) ? $this->_file2str($file) - : $file; - if ($isfilename === true) { - $filename = ($name == '' ? basename($file) : basename($name)); + return $this->_htmlbody; + } + + /** + * 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 used if $file is the image data. + * @param bool $isfile Whether $file is a filename or not. + * Defaults to true + * @param string $content_id Desired Content-ID of MIME part + * Defaults to generated unique ID + * + * @return bool True on success + * @access public + */ + function addHTMLImage($file, + $c_type='application/octet-stream', + $name = '', + $isfile = true, + $content_id = null + ) { + $bodyfile = null; + + if ($isfile) { + // Don't load file into memory + if ($this->_build_params['delay_file_io']) { + $filedata = null; + $bodyfile = $file; + } else { + if ($this->_isError($filedata = $this->_file2str($file))) { + return $filedata; + } + } + $filename = ($name ? $name : $file); } else { - $filename = basename($name); + $filedata = $file; + $filename = $name; } - if (PEAR::isError($filedata)) { - return $filedata; + + if (!$content_id) { + $content_id = preg_replace('/[^0-9a-zA-Z]/', '', uniqid(time(), true)); } + $this->_html_images[] = array( - 'body' => $filedata, - 'name' => $filename, - 'c_type' => $c_type, - 'cid' => md5(uniqid(time())) - ); + 'body' => $filedata, + 'body_file' => $bodyfile, + 'name' => $filename, + 'c_type' => $c_type, + 'cid' => $content_id + ); + 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 + * @param string $file The file name of the file to attach + * or the file contents itself + * @param string $c_type The content type + * @param string $name The filename of the attachment + * Only use if $file is the contents + * @param bool $isfile Whether $file is a filename or not. Defaults to true + * @param string $encoding The type of encoding to use. Defaults to base64. + * Possible values: 7bit, 8bit, base64 or quoted-printable. + * @param string $disposition The content-disposition of this file + * Defaults to attachment. + * Possible values: attachment, inline. + * @param string $charset The character set of attachment's content. + * @param string $language The language of the attachment + * @param string $location The RFC 2557.4 location of the attachment + * @param string $n_encoding Encoding of the attachment's name in Content-Type + * By default filenames are encoded using RFC2231 method + * Here you can set RFC2047 encoding (quoted-printable + * or base64) instead + * @param string $f_encoding Encoding of the attachment's filename + * in Content-Disposition header. + * @param string $description Content-Description header + * @param string $h_charset The character set of the headers e.g. filename + * If not specified, $charset will be used + * @param array $add_headers Additional part headers. Array keys can be in form + * of <header_name>:<parameter_name> + * + * @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) { + function addAttachment($file, + $c_type = 'application/octet-stream', + $name = '', + $isfile = true, + $encoding = 'base64', + $disposition = 'attachment', + $charset = '', + $language = '', + $location = '', + $n_encoding = null, + $f_encoding = null, + $description = '', + $h_charset = null, + $add_headers = array() + ) { + $bodyfile = null; + + if ($isfile) { + // Don't load file into memory + if ($this->_build_params['delay_file_io']) { + $filedata = null; + $bodyfile = $file; + } else { + if ($this->_isError($filedata = $this->_file2str($file))) { + return $filedata; + } + } // Force the name the user supplied, otherwise use $file - $filename = (!empty($name)) ? $name : $file; + $filename = ($name ? $name : $this->_basename($file)); } else { + $filedata = $file; $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; + + if (!strlen($filename)) { + $msg = "The supplied filename for the attachment can't be empty"; + return $this->_raiseError($msg); } $this->_parts[] = array( - 'body' => $filedata, - 'name' => $filename, - 'c_type' => $c_type, - 'encoding' => $encoding - ); + 'body' => $filedata, + 'body_file' => $bodyfile, + 'name' => $filename, + 'c_type' => $c_type, + 'charset' => $charset, + 'encoding' => $encoding, + 'language' => $language, + 'location' => $location, + 'disposition' => $disposition, + 'description' => $description, + 'add_headers' => $add_headers, + 'name_encoding' => $n_encoding, + 'filename_encoding' => $f_encoding, + 'headers_charset' => $h_charset, + ); + 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 + * @param string $file_name Path of file to process + * + * @return string Contents of $file_name * @access private */ - function &_file2str($file_name) + function _file2str($file_name) { + // Check state of file and raise an error properly + if (!file_exists($file_name)) { + return $this->_raiseError('File not found: ' . $file_name); + } + if (!is_file($file_name)) { + return $this->_raiseError('Not a regular file: ' . $file_name); + } if (!is_readable($file_name)) { - return PEAR::raiseError('File is not readable ' . $file_name); + return $this->_raiseError('File is not readable: ' . $file_name); } - if (!$fd = fopen($file_name, 'rb')) { - return PEAR::raiseError('Could not open ' . $file_name); + + // Temporarily reset magic_quotes_runtime and read file contents + if ($magic_quote_setting = get_magic_quotes_runtime()) { + @ini_set('magic_quotes_runtime', 0); } - $filesize = filesize($file_name); - if ($filesize == 0){ - $cont = ""; - }else{ - $cont = fread($fd, $filesize); + $cont = file_get_contents($file_name); + if ($magic_quote_setting) { + @ini_set('magic_quotes_runtime', $magic_quote_setting); } - fclose($fd); + return $cont; } @@ -302,31 +490,37 @@ class Mail_mime * 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 + * @param mixed &$obj The object to add the part to, or + * anything else if a new object is to be created. + * @param string $text The text to add. + * + * @return object The text mimePart object * @access private */ - function &_addTextPart(&$obj, $text) + function &_addTextPart(&$obj, $text = '') { $params['content_type'] = 'text/plain'; $params['encoding'] = $this->_build_params['text_encoding']; $params['charset'] = $this->_build_params['text_charset']; + $params['eol'] = $this->_build_params['eol']; + if (is_object($obj)) { - return $obj->addSubpart($text, $params); + $ret = $obj->addSubpart($text, $params); } else { - return new Mail_mimePart($text, $params); + $ret = new Mail_mimePart($text, $params); } + + return $ret; } /** * 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 + * @param mixed &$obj The object to add the part to, or + * anything else if a new object is to be created. + * + * @return object The html mimePart object * @access private */ function &_addHtmlPart(&$obj) @@ -334,11 +528,15 @@ class Mail_mime $params['content_type'] = 'text/html'; $params['encoding'] = $this->_build_params['html_encoding']; $params['charset'] = $this->_build_params['html_charset']; + $params['eol'] = $this->_build_params['eol']; + if (is_object($obj)) { - return $obj->addSubpart($this->_htmlbody, $params); + $ret = $obj->addSubpart($this->_htmlbody, $params); } else { - return new Mail_mimePart($this->_htmlbody, $params); + $ret = new Mail_mimePart($this->_htmlbody, $params); } + + return $ret; } /** @@ -346,13 +544,17 @@ class Mail_mime * the initial content-type and returns it during the * build process. * - * @return object The multipart/mixed mimePart object + * @return object The multipart/mixed mimePart object * @access private */ function &_addMixedPart() { $params['content_type'] = 'multipart/mixed'; - return new Mail_mimePart('', $params); + $params['eol'] = $this->_build_params['eol']; + + // Create empty multipart/mixed Mail_mimePart object to return + $ret = new Mail_mimePart('', $params); + return $ret; } /** @@ -360,19 +562,24 @@ class Mail_mime * 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 + * @param mixed &$obj The object to add the part to, or + * anything else 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'; + $params['eol'] = $this->_build_params['eol']; + if (is_object($obj)) { - return $obj->addSubpart('', $params); + $ret = $obj->addSubpart('', $params); } else { - return new Mail_mimePart('', $params); + $ret = new Mail_mimePart('', $params); } + + return $ret; } /** @@ -380,28 +587,34 @@ class Mail_mime * 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 + * @param mixed &$obj The object to add the part to, or + * anything else 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'; + $params['eol'] = $this->_build_params['eol']; + if (is_object($obj)) { - return $obj->addSubpart('', $params); + $ret = $obj->addSubpart('', $params); } else { - return new Mail_mimePart('', $params); + $ret = new Mail_mimePart('', $params); } + + return $ret; } /** * 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 + * @param object &$obj The mimePart to add the image to + * @param array $value The image information + * + * @return object The image mimePart object * @access private */ function &_addHtmlImagePart(&$obj, $value) @@ -409,89 +622,281 @@ class Mail_mime $params['content_type'] = $value['c_type']; $params['encoding'] = 'base64'; $params['disposition'] = 'inline'; - $params['dfilename'] = $value['name']; + $params['filename'] = $value['name']; $params['cid'] = $value['cid']; - $obj->addSubpart($value['body'], $params); + $params['body_file'] = $value['body_file']; + $params['eol'] = $this->_build_params['eol']; + + if (!empty($value['name_encoding'])) { + $params['name_encoding'] = $value['name_encoding']; + } + if (!empty($value['filename_encoding'])) { + $params['filename_encoding'] = $value['filename_encoding']; + } + + $ret = $obj->addSubpart($value['body'], $params); + return $ret; } /** * 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 + * @param object &$obj The mimePart to add the image to + * @param array $value The attachment information + * + * @return object The image mimePart object * @access private */ function &_addAttachmentPart(&$obj, $value) { - $params['content_type'] = $value['c_type']; + $params['eol'] = $this->_build_params['eol']; + $params['filename'] = $value['name']; $params['encoding'] = $value['encoding']; - $params['disposition'] = 'attachment'; - $params['dfilename'] = $value['name']; - $obj->addSubpart($value['body'], $params); + $params['content_type'] = $value['c_type']; + $params['body_file'] = $value['body_file']; + $params['disposition'] = isset($value['disposition']) ? + $value['disposition'] : 'attachment'; + + // content charset + if (!empty($value['charset'])) { + $params['charset'] = $value['charset']; + } + // headers charset (filename, description) + if (!empty($value['headers_charset'])) { + $params['headers_charset'] = $value['headers_charset']; + } + if (!empty($value['language'])) { + $params['language'] = $value['language']; + } + if (!empty($value['location'])) { + $params['location'] = $value['location']; + } + if (!empty($value['name_encoding'])) { + $params['name_encoding'] = $value['name_encoding']; + } + if (!empty($value['filename_encoding'])) { + $params['filename_encoding'] = $value['filename_encoding']; + } + if (!empty($value['description'])) { + $params['description'] = $value['description']; + } + if (is_array($value['add_headers'])) { + $params['headers'] = $value['add_headers']; + } + + $ret = $obj->addSubpart($value['body'], $params); + return $ret; + } + + /** + * Returns the complete e-mail, ready to send using an alternative + * mail delivery method. Note that only the mailpart that is made + * with Mail_Mime is created. This means that, + * YOU WILL HAVE NO TO: HEADERS UNLESS YOU SET IT YOURSELF + * using the $headers parameter! + * + * @param string $separation The separation between these two parts. + * @param array $params The Build parameters passed to the + * get() function. See get() for more info. + * @param array $headers The extra headers that should be passed + * to the headers() method. + * See that function for more info. + * @param bool $overwrite Overwrite the existing headers with new. + * + * @return mixed The complete e-mail or PEAR error object + * @access public + */ + function getMessage($separation = null, $params = null, $headers = null, + $overwrite = false + ) { + if ($separation === null) { + $separation = $this->_build_params['eol']; + } + + $body = $this->get($params); + + if ($this->_isError($body)) { + return $body; + } + + return $this->txtHeaders($headers, $overwrite) . $separation . $body; + } + + /** + * Returns the complete e-mail body, ready to send using an alternative + * mail delivery method. + * + * @param array $params The Build parameters passed to the + * get() method. See get() for more info. + * + * @return mixed The e-mail body or PEAR error object + * @access public + * @since 1.6.0 + */ + function getMessageBody($params = null) + { + return $this->get($params, null, true); + } + + /** + * Writes (appends) the complete e-mail into file. + * + * @param string $filename Output file location + * @param array $params The Build parameters passed to the + * get() method. See get() for more info. + * @param array $headers The extra headers that should be passed + * to the headers() function. + * See that function for more info. + * @param bool $overwrite Overwrite the existing headers with new. + * + * @return mixed True or PEAR error object + * @access public + * @since 1.6.0 + */ + function saveMessage($filename, $params = null, $headers = null, $overwrite = false) + { + // Check state of file and raise an error properly + if (file_exists($filename) && !is_writable($filename)) { + return $this->_raiseError('File is not writable: ' . $filename); + } + + // Temporarily reset magic_quotes_runtime and read file contents + if ($magic_quote_setting = get_magic_quotes_runtime()) { + @ini_set('magic_quotes_runtime', 0); + } + + if (!($fh = fopen($filename, 'ab'))) { + return $this->_raiseError('Unable to open file: ' . $filename); + } + + // Write message headers into file (skipping Content-* headers) + $head = $this->txtHeaders($headers, $overwrite, true); + if (fwrite($fh, $head) === false) { + return $this->_raiseError('Error writing to file: ' . $filename); + } + + fclose($fh); + + if ($magic_quote_setting) { + @ini_set('magic_quotes_runtime', $magic_quote_setting); + } + + // Write the rest of the message into file + $res = $this->get($params, $filename); + + return $res ? $res : true; + } + + /** + * Writes (appends) the complete e-mail body into file. + * + * @param string $filename Output file location + * @param array $params The Build parameters passed to the + * get() method. See get() for more info. + * + * @return mixed True or PEAR error object + * @access public + * @since 1.6.0 + */ + function saveMessageBody($filename, $params = null) + { + // Check state of file and raise an error properly + if (file_exists($filename) && !is_writable($filename)) { + return $this->_raiseError('File is not writable: ' . $filename); + } + + // Temporarily reset magic_quotes_runtime and read file contents + if ($magic_quote_setting = get_magic_quotes_runtime()) { + @ini_set('magic_quotes_runtime', 0); + } + + if (!($fh = fopen($filename, 'ab'))) { + return $this->_raiseError('Unable to open file: ' . $filename); + } + + // Write the rest of the message into file + $res = $this->get($params, $filename, true); + + return $res ? $res : true; } /** * 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 + * @param array $params Build parameters that change the way the email + * is built. Should be associative. See $_build_params. + * @param resource $filename Output file where to save the message instead of + * returning it + * @param boolean $skip_head True if you want to return/save only the message + * without headers + * + * @return mixed The MIME message content string, null or PEAR error object * @access public */ - function &get($build_params = null) + function get($params = null, $filename = null, $skip_head = false) { - if (isset($build_params)) { - while (list($key, $value) = each($build_params)) { + if (isset($params)) { + while (list($key, $value) = each($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 - ); + if (isset($this->_headers['From'])) { + // Bug #11381: Illegal characters in domain ID + if (preg_match('#(@[0-9a-zA-Z\-\.]+)#', $this->_headers['From'], $matches)) { + $domainID = $matches[1]; + } else { + $domainID = '@localhost'; + } + foreach ($this->_html_images as $i => $img) { + $cid = $this->_html_images[$i]['cid']; + if (!preg_match('#'.preg_quote($domainID).'$#', $cid)) { + $this->_html_images[$i]['cid'] = $cid . $domainID; + } + } + } + + if (count($this->_html_images) && isset($this->_htmlbody)) { + foreach ($this->_html_images as $key => $value) { + $regex = array(); + $regex[] = '#(\s)((?i)src|background|href(?-i))\s*=\s*(["\']?)' . + preg_quote($value['name'], '#') . '\3#'; + $regex[] = '#(?i)url(?-i)\(\s*(["\']?)' . + preg_quote($value['name'], '#') . '\1\s*\)#'; + + $rep = array(); + $rep[] = '\1\2=\3cid:' . $value['cid'] .'\3'; + $rep[] = 'url(\1cid:' . $value['cid'] . '\1)'; + + $this->_htmlbody = preg_replace($regex, $rep, $this->_htmlbody); + $this->_html_images[$key]['name'] + = $this->_basename($this->_html_images[$key]['name']); } } - $null = null; - $attachments = !empty($this->_parts) ? true : false; - $form_images = !empty($this->_html_images) ? true : false; - $form = !empty($this->_htmlbody) ? true : false; - $text = (!$form AND !empty($this->_txtbody)) ? true : false; + $this->_checkParams(); + + $null = -1; + $attachments = count($this->_parts) > 0; + $html_images = count($this->_html_images) > 0; + $html = strlen($this->_htmlbody) > 0; + $text = !$html && strlen($this->_txtbody); switch (true) { - case $text AND !$attachments: + case $text && !$attachments: $message =& $this->_addTextPart($null, $this->_txtbody); break; - case !$text AND !$form AND $attachments: + case !$text && !$html && $attachments: $message =& $this->_addMixedPart(); for ($i = 0; $i < count($this->_parts); $i++) { $this->_addAttachmentPart($message, $this->_parts[$i]); } break; - case $text AND $attachments: + case $text && $attachments: $message =& $this->_addMixedPart(); $this->_addTextPart($message, $this->_txtbody); for ($i = 0; $i < count($this->_parts); $i++) { @@ -499,7 +904,7 @@ class Mail_mime } break; - case $form AND !$attachments AND !$form_images: + case $html && !$attachments && !$html_images: if (isset($this->_txtbody)) { $message =& $this->_addAlternativePart($null); $this->_addTextPart($message, $this->_txtbody); @@ -509,22 +914,53 @@ class Mail_mime } break; - case $form AND !$attachments AND $form_images: + case $html && !$attachments && $html_images: + // * Content-Type: multipart/alternative; + // * text + // * Content-Type: multipart/related; + // * html + // * image... if (isset($this->_txtbody)) { $message =& $this->_addAlternativePart($null); $this->_addTextPart($message, $this->_txtbody); - $related =& $this->_addRelatedPart($message); + + $ht =& $this->_addRelatedPart($message); + $this->_addHtmlPart($ht); + for ($i = 0; $i < count($this->_html_images); $i++) { + $this->_addHtmlImagePart($ht, $this->_html_images[$i]); + } } else { + // * Content-Type: multipart/related; + // * html + // * image... $message =& $this->_addRelatedPart($null); - $related =& $message; + $this->_addHtmlPart($message); + for ($i = 0; $i < count($this->_html_images); $i++) { + $this->_addHtmlImagePart($message, $this->_html_images[$i]); + } + } + /* + // #13444, #9725: the code below was a non-RFC compliant hack + // * Content-Type: multipart/related; + // * Content-Type: multipart/alternative; + // * text + // * html + // * image... + $message =& $this->_addRelatedPart($null); + if (isset($this->_txtbody)) { + $alt =& $this->_addAlternativePart($message); + $this->_addTextPart($alt, $this->_txtbody); + $this->_addHtmlPart($alt); + } else { + $this->_addHtmlPart($message); } - $this->_addHtmlPart($related); for ($i = 0; $i < count($this->_html_images); $i++) { - $this->_addHtmlImagePart($related, $this->_html_images[$i]); + $this->_addHtmlImagePart($message, $this->_html_images[$i]); } + */ break; - case $form AND $attachments AND !$form_images: + case $html && $attachments && !$html_images: $message =& $this->_addMixedPart(); if (isset($this->_txtbody)) { $alt =& $this->_addAlternativePart($message); @@ -538,7 +974,7 @@ class Mail_mime } break; - case $form AND $attachments AND $form_images: + case $html && $attachments && $html_images: $message =& $this->_addMixedPart(); if (isset($this->_txtbody)) { $alt =& $this->_addAlternativePart($message); @@ -555,17 +991,35 @@ class Mail_mime $this->_addAttachmentPart($message, $this->_parts[$i]); } break; + } + if (!isset($message)) { + return null; } - if (isset($message)) { - $output = $message->encode(); - $this->_headers = array_merge($this->_headers, - $output['headers']); - return $output['body']; + // Use saved boundary + if (!empty($this->_build_params['boundary'])) { + $boundary = $this->_build_params['boundary']; + } else { + $boundary = null; + } + // Write output to file + if ($filename) { + // Append mimePart message headers and body into file + $headers = $message->encodeToFile($filename, $boundary, $skip_head); + if ($this->_isError($headers)) { + return $headers; + } + $this->_headers = array_merge($this->_headers, $headers); + return null; } else { - return false; + $output = $message->encode($boundary, $skip_head); + if ($this->_isError($output)) { + return $output; + } + $this->_headers = array_merge($this->_headers, $output['headers']); + return $output['body']; } } @@ -574,48 +1028,148 @@ class Mail_mime * (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 + * @param array $xtra_headers Assoc array with any extra headers (optional) + * (Don't set Content-Type for multipart messages here!) + * @param bool $overwrite Overwrite already existing headers. + * @param bool $skip_content Don't return content headers: Content-Type, + * Content-Disposition and Content-Transfer-Encoding + * + * @return array Assoc array with the mime headers * @access public */ - function &headers($xtra_headers = null) + function headers($xtra_headers = null, $overwrite = false, $skip_content = false) { - // Content-Type header should already be present, - // So just add mime version header + // Add mime version header $headers['MIME-Version'] = '1.0'; - if (isset($xtra_headers)) { + + // Content-Type and Content-Transfer-Encoding headers should already + // be present if get() was called, but we'll re-set them to make sure + // we got them when called before get() or something in the message + // has been changed after get() [#14780] + if (!$skip_content) { + $headers += $this->_contentHeaders(); + } + + if (!empty($xtra_headers)) { $headers = array_merge($headers, $xtra_headers); } - $this->_headers = array_merge($headers, $this->_headers); - return $this->_encodeHeaders($this->_headers); + if ($overwrite) { + $this->_headers = array_merge($this->_headers, $headers); + } else { + $this->_headers = array_merge($headers, $this->_headers); + } + + $headers = $this->_headers; + + if ($skip_content) { + unset($headers['Content-Type']); + unset($headers['Content-Transfer-Encoding']); + unset($headers['Content-Disposition']); + } else if (!empty($this->_build_params['ctype'])) { + $headers['Content-Type'] = $this->_build_params['ctype']; + } + + $encodedHeaders = $this->_encodeHeaders($headers); + return $encodedHeaders; } /** * 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 + * @param array $xtra_headers Assoc array with any extra headers (optional) + * (Don't set Content-Type for multipart messages here!) + * @param bool $overwrite Overwrite the existing headers with new. + * @param bool $skip_content Don't return content headers: Content-Type, + * Content-Disposition and Content-Transfer-Encoding + * + * @return string Plain text headers * @access public */ - function txtHeaders($xtra_headers = null) + function txtHeaders($xtra_headers = null, $overwrite = false, $skip_content = false) { - $headers = $this->headers($xtra_headers); + $headers = $this->headers($xtra_headers, $overwrite, $skip_content); + + // Place Received: headers at the beginning of the message + // Spam detectors often flag messages with it after the Subject: as spam + if (isset($headers['Received'])) { + $received = $headers['Received']; + unset($headers['Received']); + $headers = array('Received' => $received) + $headers; + } + $ret = ''; + $eol = $this->_build_params['eol']; + foreach ($headers as $key => $val) { - $ret .= "$key: $val" . MAIL_MIME_CRLF; + if (is_array($val)) { + foreach ($val as $value) { + $ret .= "$key: $value" . $eol; + } + } else { + $ret .= "$key: $val" . $eol; + } } + return $ret; } + /** + * Sets message Content-Type header. + * Use it to build messages with various content-types e.g. miltipart/raport + * not supported by _contentHeaders() function. + * + * @param string $type Type name + * @param array $params Hash array of header parameters + * + * @return void + * @access public + * @since 1.7.0 + */ + function setContentType($type, $params = array()) + { + $header = $type; + + $eol = !empty($this->_build_params['eol']) + ? $this->_build_params['eol'] : "\r\n"; + + // add parameters + $token_regexp = '#([^\x21\x23-\x27\x2A\x2B\x2D' + . '\x2E\x30-\x39\x41-\x5A\x5E-\x7E])#'; + if (is_array($params)) { + foreach ($params as $name => $value) { + if ($name == 'boundary') { + $this->_build_params['boundary'] = $value; + } + if (!preg_match($token_regexp, $value)) { + $header .= ";$eol $name=$value"; + } else { + $value = addcslashes($value, '\\"'); + $header .= ";$eol $name=\"$value\""; + } + } + } + + // add required boundary parameter if not defined + if (preg_match('/^multipart\//i', $type)) { + if (empty($this->_build_params['boundary'])) { + $this->_build_params['boundary'] = '=_' . md5(rand() . microtime()); + } + + $header .= ";$eol boundary=\"".$this->_build_params['boundary']."\""; + } + + $this->_build_params['ctype'] = $header; + } + /** * Sets the Subject header * - * @param string $subject String to set the subject to - * access public + * @param string $subject String to set the subject to. + * + * @return void + * @access public */ function setSubject($subject) { @@ -625,7 +1179,9 @@ class Mail_mime /** * Set an email to the From (the sender) header * - * @param string $email The email direction to add + * @param string $email The email address to use + * + * @return void * @access public */ function setFrom($email) @@ -633,11 +1189,31 @@ class Mail_mime $this->_headers['From'] = $email; } + /** + * Add an email to the To header + * (multiple calls to this method are allowed) + * + * @param string $email The email direction to add + * + * @return void + * @access public + */ + function addTo($email) + { + if (isset($this->_headers['To'])) { + $this->_headers['To'] .= ", $email"; + } else { + $this->_headers['To'] = $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 + * @param string $email The email direction to add + * + * @return void * @access public */ function addCc($email) @@ -653,7 +1229,9 @@ class Mail_mime * 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 + * @param string $email The email direction to add + * + * @return void * @access public */ function addBcc($email) @@ -666,61 +1244,251 @@ class Mail_mime } /** - * Encodes a header as per RFC2047 + * Since the PHP send function requires you to specify + * recipients (To: header) separately from the other + * headers, the To: header is not properly encoded. + * To fix this, you can use this public method to + * encode your recipients before sending to the send + * function * - * @param string $input The header data to encode - * @return string Encoded data + * @param string $recipients A comma-delimited list of recipients + * + * @return string Encoded data + * @access public + */ + function encodeRecipients($recipients) + { + $input = array("To" => $recipients); + $retval = $this->_encodeHeaders($input); + return $retval["To"] ; + } + + /** + * Encodes headers as per RFC2047 + * + * @param array $input The header data to encode + * @param array $params Extra build parameters + * + * @return array Encoded data * @access private */ - function _encodeHeaders($input) + function _encodeHeaders($input, $params = array()) { + $build_params = $this->_build_params; + while (list($key, $value) = each($params)) { + $build_params[$key] = $value; + } + foreach ($input as $hdr_name => $hdr_value) { - preg_match_all('/(\w*[\x80-\xFF]+\w*)/', $hdr_value, $matches); - foreach ($matches[1] as $value) { - /* - * preg_replace /e modifier is deprecated in PHP 5.5 - * but anonymous functions for use in preg_replace_callback are only available from 5.3.0 - */ - if (version_compare(PHP_VERSION, '5.3.0') >= 0) { - $replacement = preg_replace_callback( - '/([\x80-\xFF])/', - function ($m) { - return "=" . strtoupper(dechex(ord($m[1]))); - }, - $value + if (is_array($hdr_value)) { + foreach ($hdr_value as $idx => $value) { + $input[$hdr_name][$idx] = $this->encodeHeader( + $hdr_name, $value, + $build_params['head_charset'], $build_params['head_encoding'] ); - } else { - $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); + } else { + $input[$hdr_name] = $this->encodeHeader( + $hdr_name, $hdr_value, + $build_params['head_charset'], $build_params['head_encoding'] + ); } - $input[$hdr_name] = $hdr_value; } return $input; } /** - * Set the object's end-of-line and define the constant if applicable + * Encodes a header as per RFC2047 + * + * @param string $name The header name + * @param string $value The header data to encode + * @param string $charset Character set name + * @param string $encoding Encoding name (base64 or quoted-printable) + * + * @return string Encoded header data (without a name) + * @access public + * @since 1.5.3 + */ + function encodeHeader($name, $value, $charset, $encoding) + { + $mime_part = new Mail_mimePart; + return $mime_part->encodeHeader( + $name, $value, $charset, $encoding, $this->_build_params['eol'] + ); + } + + /** + * Get file's basename (locale independent) + * + * @param string $filename Filename + * + * @return string Basename + * @access private + */ + function _basename($filename) + { + // basename() is not unicode safe and locale dependent + if (stristr(PHP_OS, 'win') || stristr(PHP_OS, 'netware')) { + return preg_replace('/^.*[\\\\\\/]/', '', $filename); + } else { + return preg_replace('/^.*[\/]/', '', $filename); + } + } + + /** + * Get Content-Type and Content-Transfer-Encoding headers of the message + * + * @return array Headers array + * @access private + */ + function _contentHeaders() + { + $attachments = count($this->_parts) ? true : false; + $html_images = count($this->_html_images) ? true : false; + $html = strlen($this->_htmlbody) ? true : false; + $text = (!$html && strlen($this->_txtbody)) ? true : false; + $headers = array(); + + // See get() + switch (true) { + case $text && !$attachments: + $headers['Content-Type'] = 'text/plain'; + break; + + case !$text && !$html && $attachments: + case $text && $attachments: + case $html && $attachments && !$html_images: + case $html && $attachments && $html_images: + $headers['Content-Type'] = 'multipart/mixed'; + break; + + case $html && !$attachments && !$html_images && isset($this->_txtbody): + case $html && !$attachments && $html_images && isset($this->_txtbody): + $headers['Content-Type'] = 'multipart/alternative'; + break; + + case $html && !$attachments && !$html_images && !isset($this->_txtbody): + $headers['Content-Type'] = 'text/html'; + break; + + case $html && !$attachments && $html_images && !isset($this->_txtbody): + $headers['Content-Type'] = 'multipart/related'; + break; + + default: + return $headers; + } + + $this->_checkParams(); + + $eol = !empty($this->_build_params['eol']) + ? $this->_build_params['eol'] : "\r\n"; + + if ($headers['Content-Type'] == 'text/plain') { + // single-part message: add charset and encoding + $charset = 'charset=' . $this->_build_params['text_charset']; + // place charset parameter in the same line, if possible + // 26 = strlen("Content-Type: text/plain; ") + $headers['Content-Type'] + .= (strlen($charset) + 26 <= 76) ? "; $charset" : ";$eol $charset"; + $headers['Content-Transfer-Encoding'] + = $this->_build_params['text_encoding']; + } else if ($headers['Content-Type'] == 'text/html') { + // single-part message: add charset and encoding + $charset = 'charset=' . $this->_build_params['html_charset']; + // place charset parameter in the same line, if possible + $headers['Content-Type'] + .= (strlen($charset) + 25 <= 76) ? "; $charset" : ";$eol $charset"; + $headers['Content-Transfer-Encoding'] + = $this->_build_params['html_encoding']; + } else { + // multipart message: and boundary + if (!empty($this->_build_params['boundary'])) { + $boundary = $this->_build_params['boundary']; + } else if (!empty($this->_headers['Content-Type']) + && preg_match('/boundary="([^"]+)"/', $this->_headers['Content-Type'], $m) + ) { + $boundary = $m[1]; + } else { + $boundary = '=_' . md5(rand() . microtime()); + } + + $this->_build_params['boundary'] = $boundary; + $headers['Content-Type'] .= ";$eol boundary=\"$boundary\""; + } + + return $headers; + } + + /** + * Validate and set build parameters * - * @param string $eol End Of Line sequence + * @return void * @access private */ - function _setEOL($eol) + function _checkParams() { - $this->_eol = $eol; - if (!defined('MAIL_MIME_CRLF')) { - define('MAIL_MIME_CRLF', $this->_eol, true); + $encodings = array('7bit', '8bit', 'base64', 'quoted-printable'); + + $this->_build_params['text_encoding'] + = strtolower($this->_build_params['text_encoding']); + $this->_build_params['html_encoding'] + = strtolower($this->_build_params['html_encoding']); + + if (!in_array($this->_build_params['text_encoding'], $encodings)) { + $this->_build_params['text_encoding'] = '7bit'; + } + if (!in_array($this->_build_params['html_encoding'], $encodings)) { + $this->_build_params['html_encoding'] = '7bit'; + } + + // text body + if ($this->_build_params['text_encoding'] == '7bit' + && !preg_match('/ascii/i', $this->_build_params['text_charset']) + && preg_match('/[^\x00-\x7F]/', $this->_txtbody) + ) { + $this->_build_params['text_encoding'] = 'quoted-printable'; + } + // html body + if ($this->_build_params['html_encoding'] == '7bit' + && !preg_match('/ascii/i', $this->_build_params['html_charset']) + && preg_match('/[^\x00-\x7F]/', $this->_htmlbody) + ) { + $this->_build_params['html_encoding'] = 'quoted-printable'; + } + } + + /** + * PEAR::isError implementation + * + * @param mixed $data Object + * + * @return bool True if object is an instance of PEAR_Error + * @access private + */ + function _isError($data) + { + // PEAR::isError() is not PHP 5.4 compatible (see Bug #19473) + if (is_object($data) && is_a($data, 'PEAR_Error')) { + return true; } + + return false; } - + /** + * PEAR::raiseError implementation + * + * @param $message A text error message + * + * @return PEAR_Error Instance of PEAR_Error + * @access private + */ + function _raiseError($message) + { + // PEAR::raiseError() is not PHP 5.4 compatible + return new PEAR_Error($message); + } } // End of class -?> diff --git a/htdocs/includes/nusoap/lib/Mail/mimeDecode.php b/htdocs/includes/nusoap/lib/Mail/mimeDecode.php deleted file mode 100644 index 7ac931c2fb4c50620e613e454f5368c922f15495..0000000000000000000000000000000000000000 --- a/htdocs/includes/nusoap/lib/Mail/mimeDecode.php +++ /dev/null @@ -1,836 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ -// +-----------------------------------------------------------------------+ -// | Copyright (c) 2002-2003 Richard Heyes | -// | Copyright (c) 2003-2005 The PHP Group | -// | All rights reserved. | -// | | -// | Redistribution and use in source and binary forms, with or without | -// | modification, are permitted provided that the following conditions | -// | are met: | -// | | -// | o Redistributions of source code must retain the above copyright | -// | notice, this list of conditions and the following disclaimer. | -// | o Redistributions in binary form must reproduce the above copyright | -// | notice, this list of conditions and the following disclaimer in the | -// | documentation and/or other materials provided with the distribution.| -// | o The names of the authors may not be used to endorse or promote | -// | products derived from this software without specific prior written | -// | permission. | -// | | -// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | -// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | -// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | -// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | -// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | -// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | -// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | -// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | -// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | -// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | -// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | -// | | -// +-----------------------------------------------------------------------+ -// | Author: Richard Heyes <richard@phpguru.org> | -// +-----------------------------------------------------------------------+ - -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 <richard@phpguru.org> -* @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<count($matches[0]); $i++) { - $param = $matches[0][$i]; - while (substr($param, -2) == '\;') { - $param .= $matches[0][++$i]; - } - $parameters[] = $param; - } - - for ($i = 0; $i < count($parameters); $i++) { - $param_name = trim(substr($parameters[$i], 0, $pos = strpos($parameters[$i], '=')), "'\";\t\\ "); - $param_value = trim(str_replace('\;', ';', substr($parameters[$i], $pos + 1)), "'\";\t\\ "); - if ($param_value[0] == '"') { - $param_value = substr($param_value, 1, -1); - } - $return['other'][$param_name] = $param_value; - $return['other'][strtolower($param_name)] = $param_value; - } - } - } else { - $return['value'] = trim($input); - } - - return $return; - } - - /** - * This function splits the input based - * on the given boundary - * - * @param string Input to parse - * @return array Contains array of resulting mime parts - * @access private - */ - function _boundarySplit($input, $boundary) - { - $parts = array(); - - $bs_possible = substr($boundary, 2, -2); - $bs_check = '\"' . $bs_possible . '\"'; - - if ($boundary == $bs_check) { - $boundary = $bs_possible; - } - - $tmp = explode('--' . $boundary, $input); - - for ($i = 1; $i < count($tmp) - 1; $i++) { - $parts[] = $tmp[$i]; - } - - return $parts; - } - - /** - * Given a header, this function will decode it - * according to RFC2047. Probably not *exactly* - * conformant, but it does pass all the given - * examples (in RFC2047). - * - * @param string Input header value to decode - * @return string Decoded header value - * @access private - */ - function _decodeHeader($input) - { - // Remove white space between encoded-words - $input = preg_replace('/(=\?[^?]+\?(q|b)\?[^?]*\?=)(\s)+=\?/i', '\1=?', $input); - - // For each encoded-word... - while (preg_match('/(=\?([^?]+)\?(q|b)\?([^?]*)\?=)/i', $input, $matches)) { - - $encoded = $matches[1]; - $charset = $matches[2]; - $encoding = $matches[3]; - $text = $matches[4]; - - switch (strtolower($encoding)) { - case 'b': - $text = base64_decode($text); - break; - - case 'q': - $text = str_replace('_', ' ', $text); - preg_match_all('/=([a-f0-9]{2})/i', $text, $matches); - foreach($matches[1] as $value) - $text = str_replace('='.$value, chr(hexdec($value)), $text); - break; - } - - $input = str_replace($encoded, $text, $input); - } - - return $input; - } - - /** - * Given a body string and an encoding type, - * this function will decode and return it. - * - * @param string Input body to decode - * @param string Encoding type to use. - * @return string Decoded body - * @access private - */ - function _decodeBody($input, $encoding = '7bit') - { - switch (strtolower($encoding)) { - case '7bit': - return $input; - break; - - case 'quoted-printable': - return $this->_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 <alan@akbkhome.com> - */ - 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 = '<?xml version=\'1.0\'?>' . $crlf . - '<!DOCTYPE email SYSTEM "http://www.phpguru.org/xmail/xmail.dtd">' . $crlf . - '<email>' . $crlf . - Mail_mimeDecode::_getXML($input) . - '</email>'; - - 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) . '<mimepart>' . $crlf . - Mail_mimeDecode::_getXML($input->parts[$i], $indent+1) . - str_repeat($htab, $indent) . '</mimepart>' . $crlf; - } - } elseif (isset($input->body)) { - $output .= $crlf . str_repeat($htab, $indent) . '<body><![CDATA[' . - $input->body . ']]></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 . '<parameter>' . $crlf . - str_repeat($htab, $indent) . $htab . $htab . '<paramname>' . htmlspecialchars($paramname) . '</paramname>' . $crlf . - str_repeat($htab, $indent) . $htab . $htab . '<paramvalue>' . htmlspecialchars($paramvalue) . '</paramvalue>' . $crlf . - str_repeat($htab, $indent) . $htab . '</parameter>' . $crlf; - } - - $params = implode('', $params); - } else { - $params = ''; - } - - $return = str_repeat($htab, $indent) . '<header>' . $crlf . - str_repeat($htab, $indent) . $htab . '<headername>' . htmlspecialchars($new_hdr_name) . '</headername>' . $crlf . - str_repeat($htab, $indent) . $htab . '<headervalue>' . htmlspecialchars($new_hdr_value['value']) . '</headervalue>' . $crlf . - $params . - str_repeat($htab, $indent) . '</header>' . $crlf; - - return $return; - } - -} // End of class -?> diff --git a/htdocs/includes/nusoap/lib/Mail/mimePart.php b/htdocs/includes/nusoap/lib/Mail/mimePart.php index e44caa255707aaf7e16fa85089e31281471ee30d..93e891bc67c3c7f2de2b5488ae013e1563a3a9fb 100644 --- a/htdocs/includes/nusoap/lib/Mail/mimePart.php +++ b/htdocs/includes/nusoap/lib/Mail/mimePart.php @@ -1,196 +1,284 @@ <?php -// +-----------------------------------------------------------------------+ -// | Copyright (c) 2002-2003 Richard Heyes | -// | All rights reserved. | -// | | -// | Redistribution and use in source and binary forms, with or without | -// | modification, are permitted provided that the following conditions | -// | are met: | -// | | -// | o Redistributions of source code must retain the above copyright | -// | notice, this list of conditions and the following disclaimer. | -// | o Redistributions in binary form must reproduce the above copyright | -// | notice, this list of conditions and the following disclaimer in the | -// | documentation and/or other materials provided with the distribution.| -// | o The names of the authors may not be used to endorse or promote | -// | products derived from this software without specific prior written | -// | permission. | -// | | -// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | -// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | -// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | -// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | -// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | -// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | -// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | -// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | -// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | -// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | -// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | -// | | -// +-----------------------------------------------------------------------+ -// | Author: Richard Heyes <richard@phpguru.org> | -// +-----------------------------------------------------------------------+ +/** + * The Mail_mimePart class is used to create MIME E-mail messages + * + * This class enables you to manipulate and build a mime email + * from the ground up. The Mail_Mime class 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. + * + * Compatible with PHP versions 4 and 5 + * + * LICENSE: This LICENSE is in the BSD license style. + * Copyright (c) 2002-2003, Richard Heyes <richard@phpguru.org> + * Copyright (c) 2003-2006, PEAR <pear-group@php.net> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - Neither the name of the authors, nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * @category Mail + * @package Mail_Mime + * @author Richard Heyes <richard@phpguru.org> + * @author Cipriano Groenendal <cipri@php.net> + * @author Sean Coates <sean@php.net> + * @author Aleksander Machniak <alec@php.net> + * @copyright 2003-2006 PEAR <pear-group@php.net> + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id$ + * @link http://pear.php.net/package/Mail_mime + */ + /** -* -* 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 <richard@phpguru.org> -* @package Mail -*/ - -class Mail_mimePart { - - /** + * The Mail_mimePart class is used to create MIME E-mail messages + * + * This class enables you to manipulate and build a mime email + * from the ground up. The Mail_Mime class 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. + * + * @category Mail + * @package Mail_Mime + * @author Richard Heyes <richard@phpguru.org> + * @author Cipriano Groenendal <cipri@php.net> + * @author Sean Coates <sean@php.net> + * @author Aleksander Machniak <alec@php.net> + * @copyright 2003-2006 PEAR <pear-group@php.net> + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Mail_mime + */ +class Mail_mimePart +{ + /** * The encoding type of this part + * * @var string + * @access private */ var $_encoding; - /** + /** * An array of subparts + * * @var array + * @access private */ var $_subparts; - /** + /** * The output of this part after being built + * * @var string + * @access private */ var $_encoded; - /** + /** * Headers for this part + * * @var array + * @access private */ var $_headers; - /** + /** * The body of this part (not encoded) + * * @var string + * @access private */ 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 - */ + * The location of file with body of this part (not encoded) + * + * @var string + * @access private + */ + var $_body_file; + + /** + * The end-of-line sequence + * + * @var string + * @access private + */ + var $_eol = "\r\n"; + + + /** + * Constructor. + * + * Sets up the object. + * + * @param string $body The body of the mime part if any. + * @param array $params An associative array of optional parameters: + * content_type - The content type for this part eg multipart/mixed + * encoding - The encoding to use, 7bit, 8bit, + * base64, or quoted-printable + * charset - Content character set + * cid - Content ID to apply + * disposition - Content disposition, inline or attachment + * filename - Filename parameter for content disposition + * description - Content description + * name_encoding - Encoding of the attachment name (Content-Type) + * By default filenames are encoded using RFC2231 + * Here you can set RFC2047 encoding (quoted-printable + * or base64) instead + * filename_encoding - Encoding of the attachment filename (Content-Disposition) + * See 'name_encoding' + * headers_charset - Charset of the headers e.g. filename, description. + * If not set, 'charset' will be used + * eol - End of line sequence. Default: "\r\n" + * headers - Hash array with additional part headers. Array keys can be + * in form of <header_name>:<parameter_name> + * body_file - Location of file with part's body (instead of $body) + * + * @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); + if (!empty($params['eol'])) { + $this->_eol = $params['eol']; + } else if (defined('MAIL_MIMEPART_CRLF')) { // backward-copat. + $this->_eol = MAIL_MIMEPART_CRLF; + } + + // Additional part headers + if (!empty($params['headers']) && is_array($params['headers'])) { + $headers = $params['headers']; } 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 'encoding': + $this->_encoding = $value; + $headers['Content-Transfer-Encoding'] = $value; + break; - case 'description': - $headers['Content-Description'] = $value; - break; + case 'cid': + $headers['Content-ID'] = '<' . $value . '>'; + break; - case 'charset': - if (isset($headers['Content-Type'])) { - $headers['Content-Type'] .= '; charset="' . $value . '"'; - } else { - $charset = $value; - } - break; + case 'location': + $headers['Content-Location'] = $value; + break; + + case 'body_file': + $this->_body_file = $value; + break; + + // for backward compatibility + case 'dfilename': + $params['filename'] = $value; + break; } } // Default content-type - if (!isset($headers['Content-Type'])) { - $headers['Content-Type'] = 'text/plain'; + if (empty($params['content_type'])) { + $params['content_type'] = 'text/plain'; } - //Default encoding + // Content-Type + $headers['Content-Type'] = $params['content_type']; + if (!empty($params['charset'])) { + $charset = "charset={$params['charset']}"; + // place charset parameter in the same line, if possible + if ((strlen($headers['Content-Type']) + strlen($charset) + 16) <= 76) { + $headers['Content-Type'] .= '; '; + } else { + $headers['Content-Type'] .= ';' . $this->_eol . ' '; + } + $headers['Content-Type'] .= $charset; + + // Default headers charset + if (!isset($params['headers_charset'])) { + $params['headers_charset'] = $params['charset']; + } + } + + // header values encoding parameters + $h_charset = !empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII'; + $h_language = !empty($params['language']) ? $params['language'] : null; + $h_encoding = !empty($params['name_encoding']) ? $params['name_encoding'] : null; + + + if (!empty($params['filename'])) { + $headers['Content-Type'] .= ';' . $this->_eol; + $headers['Content-Type'] .= $this->_buildHeaderParam( + 'name', $params['filename'], $h_charset, $h_language, $h_encoding + ); + } + + // Content-Disposition + if (!empty($params['disposition'])) { + $headers['Content-Disposition'] = $params['disposition']; + if (!empty($params['filename'])) { + $headers['Content-Disposition'] .= ';' . $this->_eol; + $headers['Content-Disposition'] .= $this->_buildHeaderParam( + 'filename', $params['filename'], $h_charset, $h_language, + !empty($params['filename_encoding']) ? $params['filename_encoding'] : null + ); + } + + // add attachment size + $size = $this->_body_file ? filesize($this->_body_file) : strlen($body); + if ($size) { + $headers['Content-Disposition'] .= ';' . $this->_eol . ' size=' . $size; + } + } + + if (!empty($params['description'])) { + $headers['Content-Description'] = $this->encodeHeader( + 'Content-Description', $params['description'], $h_charset, $h_encoding, + $this->_eol + ); + } + + // Search and add existing headers' parameters + foreach ($headers as $key => $value) { + $items = explode(':', $key); + if (count($items) == 2) { + $header = $items[0]; + $param = $items[1]; + if (isset($headers[$header])) { + $headers[$header] .= ';' . $this->_eol; + } + $headers[$header] .= $this->_buildHeaderParam( + $param, $value, $h_charset, $h_language, $h_encoding + ); + unset($headers[$key]); + } + } + + // Default encoding if (!isset($this->_encoding)) { $this->_encoding = '7bit'; } @@ -202,41 +290,60 @@ class Mail_mimePart { } /** - * encode() - * * Encodes and returns the email. Also stores * it in the encoded member variable * + * @param string $boundary Pre-defined boundary string + * * @return An associative array containing two elements, * body and headers. The headers element is itself - * an indexed array. + * an indexed array. On error returns PEAR error object. * @access public */ - function encode() + function encode($boundary=null) { $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 . '"'; + if (count($this->_subparts)) { + $boundary = $boundary ? $boundary : '=_' . md5(rand() . microtime()); + $eol = $this->_eol; + + $this->_headers['Content-Type'] .= ";$eol boundary=\"$boundary\""; + + $encoded['body'] = ''; - // Add body parts to $subparts for ($i = 0; $i < count($this->_subparts); $i++) { - $headers = array(); + $encoded['body'] .= '--' . $boundary . $eol; $tmp = $this->_subparts[$i]->encode(); + if ($this->_isError($tmp)) { + return $tmp; + } foreach ($tmp['headers'] as $key => $value) { - $headers[] = $key . ': ' . $value; + $encoded['body'] .= $key . ': ' . $value . $eol; } - $subparts[] = implode(MAIL_MIMEPART_CRLF, $headers) . MAIL_MIMEPART_CRLF . MAIL_MIMEPART_CRLF . $tmp['body']; + $encoded['body'] .= $eol . $tmp['body'] . $eol; } - $encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF . - implode('--' . $boundary . MAIL_MIMEPART_CRLF, $subparts) . - '--' . $boundary.'--' . MAIL_MIMEPART_CRLF; + $encoded['body'] .= '--' . $boundary . '--' . $eol; + + } else if ($this->_body) { + $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding); + } else if ($this->_body_file) { + // Temporarily reset magic_quotes_runtime for file reads and writes + if ($magic_quote_setting = get_magic_quotes_runtime()) { + @ini_set('magic_quotes_runtime', 0); + } + $body = $this->_getEncodedDataFromFile($this->_body_file, $this->_encoding); + if ($magic_quote_setting) { + @ini_set('magic_quotes_runtime', $magic_quote_setting); + } + if ($this->_isError($body)) { + return $body; + } + $encoded['body'] = $body; } else { - $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding) . MAIL_MIMEPART_CRLF; + $encoded['body'] = ''; } // Add headers to $encoded @@ -246,105 +353,908 @@ class Mail_mimePart { } /** - * &addSubPart() + * Encodes and saves the email into file. File must exist. + * Data will be appended to the file. * + * @param string $filename Output file location + * @param string $boundary Pre-defined boundary string + * @param boolean $skip_head True if you don't want to save headers + * + * @return array An associative array containing message headers + * or PEAR error object + * @access public + * @since 1.6.0 + */ + function encodeToFile($filename, $boundary=null, $skip_head=false) + { + if (file_exists($filename) && !is_writable($filename)) { + $err = $this->_raiseError('File is not writeable: ' . $filename); + return $err; + } + + if (!($fh = fopen($filename, 'ab'))) { + $err = $this->_raiseError('Unable to open file: ' . $filename); + return $err; + } + + // Temporarily reset magic_quotes_runtime for file reads and writes + if ($magic_quote_setting = get_magic_quotes_runtime()) { + @ini_set('magic_quotes_runtime', 0); + } + + $res = $this->_encodePartToFile($fh, $boundary, $skip_head); + + fclose($fh); + + if ($magic_quote_setting) { + @ini_set('magic_quotes_runtime', $magic_quote_setting); + } + + return $this->_isError($res) ? $res : $this->_headers; + } + + /** + * Encodes given email part into file + * + * @param string $fh Output file handle + * @param string $boundary Pre-defined boundary string + * @param boolean $skip_head True if you don't want to save headers + * + * @return array True on sucess or PEAR error object + * @access private + */ + function _encodePartToFile($fh, $boundary=null, $skip_head=false) + { + $eol = $this->_eol; + + if (count($this->_subparts)) { + $boundary = $boundary ? $boundary : '=_' . md5(rand() . microtime()); + $this->_headers['Content-Type'] .= ";$eol boundary=\"$boundary\""; + } + + if (!$skip_head) { + foreach ($this->_headers as $key => $value) { + fwrite($fh, $key . ': ' . $value . $eol); + } + $f_eol = $eol; + } else { + $f_eol = ''; + } + + if (count($this->_subparts)) { + for ($i = 0; $i < count($this->_subparts); $i++) { + fwrite($fh, $f_eol . '--' . $boundary . $eol); + $res = $this->_subparts[$i]->_encodePartToFile($fh); + if ($this->_isError($res)) { + return $res; + } + $f_eol = $eol; + } + + fwrite($fh, $eol . '--' . $boundary . '--' . $eol); + + } else if ($this->_body) { + fwrite($fh, $f_eol . $this->_getEncodedData($this->_body, $this->_encoding)); + } else if ($this->_body_file) { + fwrite($fh, $f_eol); + $res = $this->_getEncodedDataFromFile( + $this->_body_file, $this->_encoding, $fh + ); + if ($this->_isError($res)) { + return $res; + } + } + + return true; + } + + /** * 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. + * @param string $body The body of the subpart, if any. + * @param array $params The parameters for the subpart, same + * as the $params argument for constructor. + * + * @return Mail_mimePart A reference to the part you just added. In PHP4, 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) + function &addSubpart($body, $params) { - $this->_subparts[] = new Mail_mimePart($body, $params); - return $this->_subparts[count($this->_subparts) - 1]; + $this->_subparts[] = $part = new Mail_mimePart($body, $params); + return $part; } /** - * _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. + * @param string $data The data to encode. + * @param string $encoding The encoding type to use, 7bit, base64, + * or quoted-printable. + * + * @return string * @access private */ function _getEncodedData($data, $encoding) { switch ($encoding) { - case '8bit': - case '7bit': - return $data; - break; - - case 'quoted-printable': - return $this->_quotedPrintableEncode($data); - break; + case 'quoted-printable': + return $this->_quotedPrintableEncode($data); + break; - case 'base64': - return rtrim(chunk_split(base64_encode($data), 76, MAIL_MIMEPART_CRLF)); - break; + case 'base64': + return rtrim(chunk_split(base64_encode($data), 76, $this->_eol)); + break; - default: - return $data; + case '8bit': + case '7bit': + default: + return $data; } } /** - * quoteadPrintableEncode() + * Returns encoded data based upon encoding passed to it + * + * @param string $filename Data file location + * @param string $encoding The encoding type to use, 7bit, base64, + * or quoted-printable. + * @param resource $fh Output file handle. If set, data will be + * stored into it instead of returning it * + * @return string Encoded data or PEAR error object + * @access private + */ + function _getEncodedDataFromFile($filename, $encoding, $fh=null) + { + if (!is_readable($filename)) { + $err = $this->_raiseError('Unable to read file: ' . $filename); + return $err; + } + + if (!($fd = fopen($filename, 'rb'))) { + $err = $this->_raiseError('Could not open file: ' . $filename); + return $err; + } + + $data = ''; + + switch ($encoding) { + case 'quoted-printable': + while (!feof($fd)) { + $buffer = $this->_quotedPrintableEncode(fgets($fd)); + if ($fh) { + fwrite($fh, $buffer); + } else { + $data .= $buffer; + } + } + break; + + case 'base64': + while (!feof($fd)) { + // Should read in a multiple of 57 bytes so that + // the output is 76 bytes per line. Don't use big chunks + // because base64 encoding is memory expensive + $buffer = fread($fd, 57 * 9198); // ca. 0.5 MB + $buffer = base64_encode($buffer); + $buffer = chunk_split($buffer, 76, $this->_eol); + if (feof($fd)) { + $buffer = rtrim($buffer); + } + + if ($fh) { + fwrite($fh, $buffer); + } else { + $data .= $buffer; + } + } + break; + + case '8bit': + case '7bit': + default: + while (!feof($fd)) { + $buffer = fread($fd, 1048576); // 1 MB + if ($fh) { + fwrite($fh, $buffer); + } else { + $data .= $buffer; + } + } + } + + fclose($fd); + + if (!$fh) { + return $data; + } + } + + /** * 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 + * @param string $input The data to encode + * @param int $line_max Optional max line length. Should + * not be more than 76 chars + * + * @return string Encoded data * * @access private */ function _quotedPrintableEncode($input , $line_max = 76) { + $eol = $this->_eol; + /* + // imap_8bit() is extremely fast, but doesn't handle properly some characters + if (function_exists('imap_8bit') && $line_max == 76) { + $input = preg_replace('/\r?\n/', "\r\n", $input); + $input = imap_8bit($input); + if ($eol != "\r\n") { + $input = str_replace("\r\n", $eol, $input); + } + return $input; + } + */ $lines = preg_split("/\r?\n/", $input); - $eol = MAIL_MIMEPART_CRLF; $escape = '='; $output = ''; - while(list(, $line) = each($lines)){ - - $linlen = strlen($line); + while (list($idx, $line) = each($lines)) { $newline = ''; + $i = 0; - for ($i = 0; $i < $linlen; $i++) { - $char = substr($line, $i, 1); + while (isset($line[$i])) { + $char = $line[$i]; $dec = ord($char); + $i++; - if (($dec == 32) AND ($i == ($linlen - 1))){ // convert space at eol only + if (($dec == 32) && (!isset($line[$i]))) { + // 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))); + } elseif ($dec == 9 && isset($line[$i])) { + ; // Do nothing if a TAB is not on eol + } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { + $char = $escape . sprintf('%02X', $dec); + } elseif (($dec == 46) && (($newline == '') + || ((strlen($newline) + strlen("=2E")) >= $line_max)) + ) { + // Bug #9722: convert full-stop at bol, + // some Windows servers need this, won't break anything (cipri) + // Bug #11731: full-stop at bol also needs to be encoded + // if this line would push us over the line_max limit. + $char = '=2E'; } - if ((strlen($newline) + strlen($char)) >= $line_max) { // MAIL_MIMEPART_CRLF is not counted - $output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay + // Note, when changing this line, also change the ($dec == 46) + // check line, as it mimics this line due to Bug #11731 + // EOL is not counted + if ((strlen($newline) + strlen($char)) >= $line_max) { + // soft line break; " =\r\n" is okay + $output .= $newline . $escape . $eol; $newline = ''; } $newline .= $char; } // end of for $output .= $newline . $eol; + unset($lines[$idx]); } - $output = substr($output, 0, -1 * strlen($eol)); // Don't want last crlf + // Don't want last crlf + $output = substr($output, 0, -1 * strlen($eol)); return $output; } + + /** + * Encodes the parameter of a header. + * + * @param string $name The name of the header-parameter + * @param string $value The value of the paramter + * @param string $charset The characterset of $value + * @param string $language The language used in $value + * @param string $encoding Parameter encoding. If not set, parameter value + * is encoded according to RFC2231 + * @param int $maxLength The maximum length of a line. Defauls to 75 + * + * @return string + * + * @access private + */ + function _buildHeaderParam($name, $value, $charset=null, $language=null, + $encoding=null, $maxLength=75 + ) { + // RFC 2045: + // value needs encoding if contains non-ASCII chars or is longer than 78 chars + if (!preg_match('#[^\x20-\x7E]#', $value)) { + $token_regexp = '#([^\x21\x23-\x27\x2A\x2B\x2D' + . '\x2E\x30-\x39\x41-\x5A\x5E-\x7E])#'; + if (!preg_match($token_regexp, $value)) { + // token + if (strlen($name) + strlen($value) + 3 <= $maxLength) { + return " {$name}={$value}"; + } + } else { + // quoted-string + $quoted = addcslashes($value, '\\"'); + if (strlen($name) + strlen($quoted) + 5 <= $maxLength) { + return " {$name}=\"{$quoted}\""; + } + } + } + + // RFC2047: use quoted-printable/base64 encoding + if ($encoding == 'quoted-printable' || $encoding == 'base64') { + return $this->_buildRFC2047Param($name, $value, $charset, $encoding); + } + + // RFC2231: + $encValue = preg_replace_callback( + '/([^\x21\x23\x24\x26\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E])/', + array($this, '_encodeReplaceCallback'), $value + ); + $value = "$charset'$language'$encValue"; + + $header = " {$name}*={$value}"; + if (strlen($header) <= $maxLength) { + return $header; + } + + $preLength = strlen(" {$name}*0*="); + $maxLength = max(16, $maxLength - $preLength - 3); + $maxLengthReg = "|(.{0,$maxLength}[^\%][^\%])|"; + + $headers = array(); + $headCount = 0; + while ($value) { + $matches = array(); + $found = preg_match($maxLengthReg, $value, $matches); + if ($found) { + $headers[] = " {$name}*{$headCount}*={$matches[0]}"; + $value = substr($value, strlen($matches[0])); + } else { + $headers[] = " {$name}*{$headCount}*={$value}"; + $value = ''; + } + $headCount++; + } + + $headers = implode(';' . $this->_eol, $headers); + return $headers; + } + + /** + * Encodes header parameter as per RFC2047 if needed + * + * @param string $name The parameter name + * @param string $value The parameter value + * @param string $charset The parameter charset + * @param string $encoding Encoding type (quoted-printable or base64) + * @param int $maxLength Encoded parameter max length. Default: 76 + * + * @return string Parameter line + * @access private + */ + function _buildRFC2047Param($name, $value, $charset, + $encoding='quoted-printable', $maxLength=76 + ) { + // WARNING: RFC 2047 says: "An 'encoded-word' MUST NOT be used in + // parameter of a MIME Content-Type or Content-Disposition field", + // but... it's supported by many clients/servers + $quoted = ''; + + if ($encoding == 'base64') { + $value = base64_encode($value); + $prefix = '=?' . $charset . '?B?'; + $suffix = '?='; + + // 2 x SPACE, 2 x '"', '=', ';' + $add_len = strlen($prefix . $suffix) + strlen($name) + 6; + $len = $add_len + strlen($value); + + while ($len > $maxLength) { + // We can cut base64-encoded string every 4 characters + $real_len = floor(($maxLength - $add_len) / 4) * 4; + $_quote = substr($value, 0, $real_len); + $value = substr($value, $real_len); + + $quoted .= $prefix . $_quote . $suffix . $this->_eol . ' '; + $add_len = strlen($prefix . $suffix) + 4; // 2 x SPACE, '"', ';' + $len = strlen($value) + $add_len; + } + $quoted .= $prefix . $value . $suffix; + + } else { + // quoted-printable + $value = $this->encodeQP($value); + $prefix = '=?' . $charset . '?Q?'; + $suffix = '?='; + + // 2 x SPACE, 2 x '"', '=', ';' + $add_len = strlen($prefix . $suffix) + strlen($name) + 6; + $len = $add_len + strlen($value); + + while ($len > $maxLength) { + $length = $maxLength - $add_len; + // don't break any encoded letters + if (preg_match("/^(.{0,$length}[^\=][^\=])/", $value, $matches)) { + $_quote = $matches[1]; + } + + $quoted .= $prefix . $_quote . $suffix . $this->_eol . ' '; + $value = substr($value, strlen($_quote)); + $add_len = strlen($prefix . $suffix) + 4; // 2 x SPACE, '"', ';' + $len = strlen($value) + $add_len; + } + + $quoted .= $prefix . $value . $suffix; + } + + return " {$name}=\"{$quoted}\""; + } + + /** + * Encodes a header as per RFC2047 + * + * @param string $name The header name + * @param string $value The header data to encode + * @param string $charset Character set name + * @param string $encoding Encoding name (base64 or quoted-printable) + * @param string $eol End-of-line sequence. Default: "\r\n" + * + * @return string Encoded header data (without a name) + * @access public + * @since 1.6.1 + */ + function encodeHeader($name, $value, $charset='ISO-8859-1', + $encoding='quoted-printable', $eol="\r\n" + ) { + // Structured headers + $comma_headers = array( + 'from', 'to', 'cc', 'bcc', 'sender', 'reply-to', + 'resent-from', 'resent-to', 'resent-cc', 'resent-bcc', + 'resent-sender', 'resent-reply-to', + 'mail-reply-to', 'mail-followup-to', + 'return-receipt-to', 'disposition-notification-to', + ); + $other_headers = array( + 'references', 'in-reply-to', 'message-id', 'resent-message-id', + ); + + $name = strtolower($name); + + if (in_array($name, $comma_headers)) { + $separator = ','; + } else if (in_array($name, $other_headers)) { + $separator = ' '; + } + + if (!$charset) { + $charset = 'ISO-8859-1'; + } + + // Structured header (make sure addr-spec inside is not encoded) + if (!empty($separator)) { + // Simple e-mail address regexp + $email_regexp = '([^\s<]+|("[^\r\n"]+"))@\S+'; + + $parts = Mail_mimePart::_explodeQuotedString("[\t$separator]", $value); + $value = ''; + + foreach ($parts as $part) { + $part = preg_replace('/\r?\n[\s\t]*/', $eol . ' ', $part); + $part = trim($part); + + if (!$part) { + continue; + } + if ($value) { + $value .= $separator == ',' ? $separator . ' ' : ' '; + } else { + $value = $name . ': '; + } + + // let's find phrase (name) and/or addr-spec + if (preg_match('/^<' . $email_regexp . '>$/', $part)) { + $value .= $part; + } else if (preg_match('/^' . $email_regexp . '$/', $part)) { + // address without brackets and without name + $value .= $part; + } else if (preg_match('/<*' . $email_regexp . '>*$/', $part, $matches)) { + // address with name (handle name) + $address = $matches[0]; + $word = str_replace($address, '', $part); + $word = trim($word); + // check if phrase requires quoting + if ($word) { + // non-ASCII: require encoding + if (preg_match('#([^\s\x21-\x7E]){1}#', $word)) { + if ($word[0] == '"' && $word[strlen($word)-1] == '"') { + // de-quote quoted-string, encoding changes + // string to atom + $search = array("\\\"", "\\\\"); + $replace = array("\"", "\\"); + $word = str_replace($search, $replace, $word); + $word = substr($word, 1, -1); + } + // find length of last line + if (($pos = strrpos($value, $eol)) !== false) { + $last_len = strlen($value) - $pos; + } else { + $last_len = strlen($value); + } + $word = Mail_mimePart::encodeHeaderValue( + $word, $charset, $encoding, $last_len, $eol + ); + } else if (($word[0] != '"' || $word[strlen($word)-1] != '"') + && preg_match('/[\(\)\<\>\\\.\[\]@,;:"]/', $word) + ) { + // ASCII: quote string if needed + $word = '"'.addcslashes($word, '\\"').'"'; + } + } + $value .= $word.' '.$address; + } else { + // addr-spec not found, don't encode (?) + $value .= $part; + } + + // RFC2822 recommends 78 characters limit, use 76 from RFC2047 + $value = wordwrap($value, 76, $eol . ' '); + } + + // remove header name prefix (there could be EOL too) + $value = preg_replace( + '/^'.$name.':('.preg_quote($eol, '/').')* /', '', $value + ); + } else { + // Unstructured header + // non-ASCII: require encoding + if (preg_match('#([^\s\x21-\x7E]){1}#', $value)) { + if ($value[0] == '"' && $value[strlen($value)-1] == '"') { + // de-quote quoted-string, encoding changes + // string to atom + $search = array("\\\"", "\\\\"); + $replace = array("\"", "\\"); + $value = str_replace($search, $replace, $value); + $value = substr($value, 1, -1); + } + $value = Mail_mimePart::encodeHeaderValue( + $value, $charset, $encoding, strlen($name) + 2, $eol + ); + } else if (strlen($name.': '.$value) > 78) { + // ASCII: check if header line isn't too long and use folding + $value = preg_replace('/\r?\n[\s\t]*/', $eol . ' ', $value); + $tmp = wordwrap($name.': '.$value, 78, $eol . ' '); + $value = preg_replace('/^'.$name.':\s*/', '', $tmp); + // hard limit 998 (RFC2822) + $value = wordwrap($value, 998, $eol . ' ', true); + } + } + + return $value; + } + + /** + * Explode quoted string + * + * @param string $delimiter Delimiter expression string for preg_match() + * @param string $string Input string + * + * @return array String tokens array + * @access private + */ + function _explodeQuotedString($delimiter, $string) + { + $result = array(); + $strlen = strlen($string); + + for ($q=$p=$i=0; $i < $strlen; $i++) { + if ($string[$i] == "\"" + && (empty($string[$i-1]) || $string[$i-1] != "\\") + ) { + $q = $q ? false : true; + } else if (!$q && preg_match("/$delimiter/", $string[$i])) { + $result[] = substr($string, $p, $i - $p); + $p = $i + 1; + } + } + + $result[] = substr($string, $p); + return $result; + } + + /** + * Encodes a header value as per RFC2047 + * + * @param string $value The header data to encode + * @param string $charset Character set name + * @param string $encoding Encoding name (base64 or quoted-printable) + * @param int $prefix_len Prefix length. Default: 0 + * @param string $eol End-of-line sequence. Default: "\r\n" + * + * @return string Encoded header data + * @access public + * @since 1.6.1 + */ + function encodeHeaderValue($value, $charset, $encoding, $prefix_len=0, $eol="\r\n") + { + // #17311: Use multibyte aware method (requires mbstring extension) + if ($result = Mail_mimePart::encodeMB($value, $charset, $encoding, $prefix_len, $eol)) { + return $result; + } + + // Generate the header using the specified params and dynamicly + // determine the maximum length of such strings. + // 75 is the value specified in the RFC. + $encoding = $encoding == 'base64' ? 'B' : 'Q'; + $prefix = '=?' . $charset . '?' . $encoding .'?'; + $suffix = '?='; + $maxLength = 75 - strlen($prefix . $suffix); + $maxLength1stLine = $maxLength - $prefix_len; + + if ($encoding == 'B') { + // Base64 encode the entire string + $value = base64_encode($value); + + // We can cut base64 every 4 characters, so the real max + // we can get must be rounded down. + $maxLength = $maxLength - ($maxLength % 4); + $maxLength1stLine = $maxLength1stLine - ($maxLength1stLine % 4); + + $cutpoint = $maxLength1stLine; + $output = ''; + + while ($value) { + // Split translated string at every $maxLength + $part = substr($value, 0, $cutpoint); + $value = substr($value, $cutpoint); + $cutpoint = $maxLength; + // RFC 2047 specifies that any split header should + // be separated by a CRLF SPACE. + if ($output) { + $output .= $eol . ' '; + } + $output .= $prefix . $part . $suffix; + } + $value = $output; + } else { + // quoted-printable encoding has been selected + $value = Mail_mimePart::encodeQP($value); + + // This regexp will break QP-encoded text at every $maxLength + // but will not break any encoded letters. + $reg1st = "|(.{0,$maxLength1stLine}[^\=][^\=])|"; + $reg2nd = "|(.{0,$maxLength}[^\=][^\=])|"; + + if (strlen($value) > $maxLength1stLine) { + // Begin with the regexp for the first line. + $reg = $reg1st; + $output = ''; + while ($value) { + // Split translated string at every $maxLength + // But make sure not to break any translated chars. + $found = preg_match($reg, $value, $matches); + + // After this first line, we need to use a different + // regexp for the first line. + $reg = $reg2nd; + + // Save the found part and encapsulate it in the + // prefix & suffix. Then remove the part from the + // $value_out variable. + if ($found) { + $part = $matches[0]; + $len = strlen($matches[0]); + $value = substr($value, $len); + } else { + $part = $value; + $value = ''; + } + + // RFC 2047 specifies that any split header should + // be separated by a CRLF SPACE + if ($output) { + $output .= $eol . ' '; + } + $output .= $prefix . $part . $suffix; + } + $value = $output; + } else { + $value = $prefix . $value . $suffix; + } + } + + return $value; + } + + /** + * Encodes the given string using quoted-printable + * + * @param string $str String to encode + * + * @return string Encoded string + * @access public + * @since 1.6.0 + */ + function encodeQP($str) + { + // Bug #17226 RFC 2047 restricts some characters + // if the word is inside a phrase, permitted chars are only: + // ASCII letters, decimal digits, "!", "*", "+", "-", "/", "=", and "_" + + // "=", "_", "?" must be encoded + $regexp = '/([\x22-\x29\x2C\x2E\x3A-\x40\x5B-\x60\x7B-\x7E\x80-\xFF])/'; + $str = preg_replace_callback( + $regexp, array('Mail_mimePart', '_qpReplaceCallback'), $str + ); + + return str_replace(' ', '_', $str); + } + + /** + * Encodes the given string using base64 or quoted-printable. + * This method makes sure that encoded-word represents an integral + * number of characters as per RFC2047. + * + * @param string $str String to encode + * @param string $charset Character set name + * @param string $encoding Encoding name (base64 or quoted-printable) + * @param int $prefix_len Prefix length. Default: 0 + * @param string $eol End-of-line sequence. Default: "\r\n" + * + * @return string Encoded string + * @access public + * @since 1.8.0 + */ + function encodeMB($str, $charset, $encoding, $prefix_len=0, $eol="\r\n") + { + if (!function_exists('mb_substr') || !function_exists('mb_strlen')) { + return; + } + + $encoding = $encoding == 'base64' ? 'B' : 'Q'; + // 75 is the value specified in the RFC + $prefix = '=?' . $charset . '?'.$encoding.'?'; + $suffix = '?='; + $maxLength = 75 - strlen($prefix . $suffix); + + // A multi-octet character may not be split across adjacent encoded-words + // So, we'll loop over each character + // mb_stlen() with wrong charset will generate a warning here and return null + $length = mb_strlen($str, $charset); + $result = ''; + $line_length = $prefix_len; + + if ($encoding == 'B') { + // base64 + $start = 0; + $prev = ''; + + for ($i=1; $i<=$length; $i++) { + // See #17311 + $chunk = mb_substr($str, $start, $i-$start, $charset); + $chunk = base64_encode($chunk); + $chunk_len = strlen($chunk); + + if ($line_length + $chunk_len == $maxLength || $i == $length) { + if ($result) { + $result .= "\n"; + } + $result .= $chunk; + $line_length = 0; + $start = $i; + } else if ($line_length + $chunk_len > $maxLength) { + if ($result) { + $result .= "\n"; + } + if ($prev) { + $result .= $prev; + } + $line_length = 0; + $start = $i - 1; + } else { + $prev = $chunk; + } + } + } else { + // quoted-printable + // see encodeQP() + $regexp = '/([\x22-\x29\x2C\x2E\x3A-\x40\x5B-\x60\x7B-\x7E\x80-\xFF])/'; + + for ($i=0; $i<=$length; $i++) { + $char = mb_substr($str, $i, 1, $charset); + // RFC recommends underline (instead of =20) in place of the space + // that's one of the reasons why we're not using iconv_mime_encode() + if ($char == ' ') { + $char = '_'; + $char_len = 1; + } else { + $char = preg_replace_callback( + $regexp, array('Mail_mimePart', '_qpReplaceCallback'), $char + ); + $char_len = strlen($char); + } + + if ($line_length + $char_len > $maxLength) { + if ($result) { + $result .= "\n"; + } + $line_length = 0; + } + + $result .= $char; + $line_length += $char_len; + } + } + + if ($result) { + $result = $prefix + .str_replace("\n", $suffix.$eol.' '.$prefix, $result).$suffix; + } + + return $result; + } + + /** + * Callback function to replace extended characters (\x80-xFF) with their + * ASCII values (RFC2047: quoted-printable) + * + * @param array $matches Preg_replace's matches array + * + * @return string Encoded character string + * @access private + */ + function _qpReplaceCallback($matches) + { + return sprintf('=%02X', ord($matches[1])); + } + + /** + * Callback function to replace extended characters (\x80-xFF) with their + * ASCII values (RFC2231) + * + * @param array $matches Preg_replace's matches array + * + * @return string Encoded character string + * @access private + */ + function _encodeReplaceCallback($matches) + { + return sprintf('%%%02X', ord($matches[1])); + } + + /** + * PEAR::isError implementation + * + * @param mixed $data Object + * + * @return bool True if object is an instance of PEAR_Error + * @access private + */ + function _isError($data) + { + // PEAR::isError() is not PHP 5.4 compatible (see Bug #19473) + if (is_object($data) && is_a($data, 'PEAR_Error')) { + return true; + } + + return false; + } + + /** + * PEAR::raiseError implementation + * + * @param $message A text error message + * + * @return PEAR_Error Instance of PEAR_Error + * @access private + */ + function _raiseError($message) + { + // PEAR::raiseError() is not PHP 5.4 compatible + return new PEAR_Error($message); + } + } // End of class -?> diff --git a/htdocs/includes/nusoap/lib/Mail/null.php b/htdocs/includes/nusoap/lib/Mail/null.php deleted file mode 100644 index 5e220a5a39cd3585de4f79eea2c236e191e53ef3..0000000000000000000000000000000000000000 --- a/htdocs/includes/nusoap/lib/Mail/null.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2003 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Phil Kernick <philk@rotfl.com.au> | -// +----------------------------------------------------------------------+ -// -// - -/** - * Null implementation of the PEAR Mail:: interface. - * @access public - * @package Mail - */ -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 deleted file mode 100644 index fc492489a901d43f7ecb3524e8f94bb009960ed2..0000000000000000000000000000000000000000 --- a/htdocs/includes/nusoap/lib/Mail/sendmail.php +++ /dev/null @@ -1,144 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2003 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Chuck Hagenbuch <chuck@horde.org> | -// +----------------------------------------------------------------------+ - -/** - * Sendmail implementation of the PEAR Mail:: interface. - * @access public - * @package Mail - */ -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 deleted file mode 100644 index 200d5dacaa95688a6ecd4455b2efc9e4d59f8cb3..0000000000000000000000000000000000000000 --- a/htdocs/includes/nusoap/lib/Mail/smtp.php +++ /dev/null @@ -1,222 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2003 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Chuck Hagenbuch <chuck@horde.org> | -// | Jon Parise <jon@php.net> | -// +----------------------------------------------------------------------+ - -/** - * SMTP implementation of the PEAR Mail:: interface. Requires the PEAR - * Net_SMTP:: class. - * @access public - * @package Mail - */ -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 deleted file mode 100755 index 9f42ca8b3312fb8a7a55d7a244ddd2f4ddd43932..0000000000000000000000000000000000000000 --- a/htdocs/includes/nusoap/lib/Mail/xmail.dtd +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> - -<!ENTITY lt "&#60;"> -<!ENTITY gt ">"> -<!ENTITY amp "&#38;"> -<!ENTITY apos "'"> -<!ENTITY quot """> -<!ENTITY crlf " "> - -<!ELEMENT email (header+, (body | mimepart+))> -<!ELEMENT mimepart (header+, (body | mimepart+))> -<!ELEMENT body (#PCDATA)> -<!ELEMENT header ((headername|headervalue|parameter)*)> -<!ELEMENT headername (#PCDATA)> -<!ELEMENT headervalue (#PCDATA)> -<!ELEMENT parameter ((paramname|paramvalue)+)> -<!ELEMENT paramvalue (#PCDATA)> -<!ELEMENT paramname (#PCDATA)> - diff --git a/htdocs/includes/nusoap/lib/Mail/xmail.xsl b/htdocs/includes/nusoap/lib/Mail/xmail.xsl deleted file mode 100755 index 0b948913f84d47ea816a8ad42b59bd692efb73b3..0000000000000000000000000000000000000000 --- a/htdocs/includes/nusoap/lib/Mail/xmail.xsl +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> -<xsl:output method="text" omit-xml-declaration="yes" indent="no"/> -<xsl:preserve-space elements="headervalue paramvalue body"/> - - <xsl:template name="mimepart"> - - <xsl:variable name="boundary"> - <xsl:for-each select="./header"> - <xsl:if test="string(./headername) = 'Content-Type'"> - <xsl:for-each select="./parameter"> - <xsl:if test="string(./paramname) = 'boundary'"> - <xsl:value-of select="paramvalue"/> - </xsl:if> - </xsl:for-each> - </xsl:if> - </xsl:for-each> - </xsl:variable> - - <xsl:for-each select="header"> - - <xsl:value-of select="headername"/> - <xsl:text>: </xsl:text> - <xsl:value-of select="headervalue"/> - - <xsl:if test="count(./parameter) = 0"> - <xsl:text> </xsl:text> - </xsl:if> - - <xsl:for-each select="parameter"> - <xsl:text>; 	</xsl:text> - <xsl:value-of select="paramname"/> - <xsl:text>="</xsl:text> - <xsl:value-of select="paramvalue"/> - <xsl:text>"</xsl:text> - </xsl:for-each> - - <xsl:if test="count(./parameter) > 0"> - <xsl:text> </xsl:text> - </xsl:if> - - </xsl:for-each> - - <xsl:text> </xsl:text> - - <!-- Which to do, print a body or process subparts? --> - <xsl:choose> - <xsl:when test="count(./mimepart) = 0"> - <xsl:value-of select="body"/> - <xsl:text> </xsl:text> - </xsl:when> - - <xsl:otherwise> - <xsl:for-each select="mimepart"> - <xsl:text>--</xsl:text><xsl:value-of select="$boundary"/><xsl:text> </xsl:text> - <xsl:call-template name="mimepart"/> - </xsl:for-each> - - <xsl:text>--</xsl:text><xsl:value-of select="$boundary"/><xsl:text>-- </xsl:text> - - </xsl:otherwise> - </xsl:choose> - </xsl:template> - -<!-- This is where the stylesheet really starts, matching the top level email element --> - <xsl:template match="email"> - <xsl:call-template name="mimepart"/> - </xsl:template> - -</xsl:stylesheet> \ No newline at end of file diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index fcf5ed365638210832b16baa3ad9ea9729287167..51388d59c1aa9a4c00b2c58e87798081719d5dd5 100644 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -520,6 +520,18 @@ create table llx_c_price_global_variable_updater ALTER TABLE llx_adherent CHANGE COLUMN note note_private text DEFAULT NULL; ALTER TABLE llx_adherent ADD COLUMN note_public text DEFAULT NULL after note_private; +CREATE TABLE IF NOT EXISTS llx_propal_merge_pdf_product ( + rowid integer NOT NULL auto_increment PRIMARY KEY, + fk_product integer NOT NULL, + file_name varchar(200) NOT NULL, + lang varchar(5) DEFAULT NULL, + fk_user_author integer DEFAULT NULL, + fk_user_mod integer NOT NULL, + datec datetime NOT NULL, + tms timestamp NOT NULL, + import_key varchar(14) DEFAULT NULL +) ENGINE=InnoDB; + -- Feature request: A page to merge two thirdparties into one #2613 ALTER TABLE llx_categorie_societe CHANGE COLUMN fk_societe fk_soc INTEGER NOT NULL; ALTER TABLE llx_societe CHANGE COLUMN fk_societe fk_soc INTEGER NOT NULL; diff --git a/htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql b/htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql new file mode 100644 index 0000000000000000000000000000000000000000..93af93c9190f18c8f4684f95ea92ae44953a2b32 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql @@ -0,0 +1,28 @@ +-- <Product - Quote - PDF> +-- Copyright (C) 2013 Florian HENRY <florian.henry@open-concept.pro> +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. + +CREATE TABLE IF NOT EXISTS llx_propal_merge_pdf_product ( + rowid integer NOT NULL auto_increment PRIMARY KEY, + fk_product integer NOT NULL, + file_name varchar(200) NOT NULL, + lang varchar(5) DEFAULT NULL, + fk_user_author integer DEFAULT NULL, + fk_user_mod integer NOT NULL, + datec datetime NOT NULL, + tms timestamp NOT NULL, + import_key varchar(14) DEFAULT NULL +) ENGINE=InnoDB; + diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4b7ddfe0143e5aad245c427fcc902e16e563e427..06b18dfbc270f30f2b91861a21821772f7cd40a4 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1077,7 +1077,7 @@ TotalNumberOfActivatedModules=Total number of activated feature modules: <b>%s</ YouMustEnableOneModule=You must at least enable 1 module ClassNotFoundIntoPathWarning=Class %s not found into PHP path YesInSummer=Yes in summer -OnlyFollowingModulesAreOpenedToExternalUsers=Note, only following modules are opened to external users (whatever are permission of such users): +OnlyFollowingModulesAreOpenedToExternalUsers=Note, only following modules are open to external users (whatever are permission of such users): SuhosinSessionEncrypt=Session storage encrypted by Suhosin ConditionIsCurrently=Condition is currently %s YouUseBestDriver=You use driver %s that is best driver available currently. @@ -1384,6 +1384,7 @@ NumberOfProductShowInSelect=Max number of products in combos select lists (0=no ConfirmDeleteProductLineAbility=Confirmation when removing product lines in forms ModifyProductDescAbility=Personalization of product descriptions in forms ViewProductDescInFormAbility=Visualization of product descriptions in the forms (otherwise as popup tooltip) +MergePropalProductCard=Activate in product/service Attached Files tab an option to merge product PDF document to proposal PDF azur if product/service is in the proposal ViewProductDescInThirdpartyLanguageAbility=Visualization of products descriptions in the thirdparty language UseSearchToSelectProductTooltip=Also if you have a large number of product (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. UseSearchToSelectProduct=Use a search form to choose a product (rather than a drop-down list). @@ -1594,7 +1595,7 @@ OpenFiscalYear=Open fiscal year CloseFiscalYear=Close fiscal year DeleteFiscalYear=Delete fiscal year ConfirmDeleteFiscalYear=Are you sure to delete this fiscal year ? -Opened=Opened +Opened=Open Closed=Closed AlwaysEditable=Can always be edited MAIN_APPLICATION_TITLE=Force visible name of application (warning: setting your own name here may break autofill login feature when using DoliDroid mobile application) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 87a22582431a2462ac74afa3f312cb769e5e6cb0..dd485291e73c64cca3cfffc73a0311eb2ca06ed9 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -55,7 +55,6 @@ OrderBilledInDolibarr=Order %s classified billed OrderApprovedInDolibarr=Order %s approved OrderRefusedInDolibarr=Order %s refused OrderBackToDraftInDolibarr=Order %s go back to draft status -OrderCanceledInDolibarr=Order %s canceled ProposalSentByEMail=Commercial proposal %s sent by EMail OrderSentByEMail=Customer order %s sent by EMail InvoiceSentByEMail=Customer invoice %s sent by EMail diff --git a/htdocs/langs/en_US/askpricesupplier.lang b/htdocs/langs/en_US/askpricesupplier.lang index b75a3284146212a80971f885e21956e2d763f282..882b2fc22904c34a22df650577ce5c0b2b3d7144 100644 --- a/htdocs/langs/en_US/askpricesupplier.lang +++ b/htdocs/langs/en_US/askpricesupplier.lang @@ -9,7 +9,7 @@ CommRequests=Price requests SearchRequest=Find a request DraftRequests=Draft requests LastModifiedRequests=Last %s modified price requests -RequestsOpened=Opened price requests +RequestsOpened=Open price requests AskPriceSupplierArea=Area price requests suppliers Askpricesupplier=Price request supplier NewAskPrice=New price request @@ -26,7 +26,7 @@ DeleteAsk=Delete request ValidateAsk=Validate request AddAsk=Create a request AskpricesupplierDraft=Drafts -AskpricesupplierOpened=Opened +AskpricesupplierOpened=Open AskpricesupplierStatusDraft=Draft (needs to be validated) AskpricesupplierStatusValidated=Validated (request is open) AskpricesupplierStatusOpened=Validated (request is open) @@ -35,7 +35,7 @@ AskpricesupplierStatusSigned=Accepted AskpricesupplierStatusNotSigned=Refused AskpricesupplierStatusDraftShort=Draft AskpricesupplierStatusValidatedShort=Validated -AskpricesupplierStatusOpenedShort=Opened +AskpricesupplierStatusOpenedShort=Open AskpricesupplierStatusClosedShort=Closed AskpricesupplierStatusSignedShort=Accepted AskpricesupplierStatusNotSignedShort=Refused @@ -54,4 +54,4 @@ CommercialAsk=Price request DefaultModelAskPriceSupplierCreate=Default model creation DefaultModelAskPriceSupplierToBill=Default template when closing a price request (accepted) DefaultModelAskPriceSupplierClosed=Default template when closing a price request (refused) -ListOfAskPriceSupplier=Liste des demandes de prix fournisseurs \ No newline at end of file +ListOfAskPriceSupplier=Liste des demandes de prix fournisseurs diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 72639883e1ac22135ba953b5cfb140a4e53b61c6..f363ffa56c65bb8148ad9c86f839ce858009f5a8 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -94,12 +94,12 @@ Conciliate=Reconcile Conciliation=Reconciliation ConciliationForAccount=Reconcile this account IncludeClosedAccount=Include closed accounts -OnlyOpenedAccount=Only opened accounts +OnlyOpenedAccount=Only open accounts AccountToCredit=Account to credit AccountToDebit=Account to debit DisableConciliation=Disable reconciliation feature for this account ConciliationDisabled=Reconciliation feature disabled -StatusAccountOpened=Opened +StatusAccountOpened=Open StatusAccountClosed=Closed AccountIdShort=Number EditBankRecord=Edit record diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index ec455843cb7656f588c50213ba9e597c26f5ff13..3e645e848345798c51904d8744bc45795893cbc8 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -430,5 +430,5 @@ NotLastInCycle=This invoice in not the last in cycle and must not be modified. DisabledBecauseNotLastInCycle=The next situation already exists. DisabledBecauseFinal=This situation is final. CantBeLessThanMinPercent=The progress can't be smaller than its value in the previous situation. -NoSituations=No opened situations +NoSituations=No open situations InvoiceSituationLast=Final and general invoice diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index c0180bebdaa465789316910eda563b12d1cf25a0..b61cf77019f18c8d1a92c03a83a86fc123afd09c 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -19,7 +19,7 @@ BoxLastContracts=Last contracts BoxLastContacts=Last contacts/addresses BoxLastMembers=Last members BoxFicheInter=Last interventions -BoxCurrentAccounts=Opened accounts balance +BoxCurrentAccounts=Open accounts balance BoxSalesTurnover=Sales turnover BoxTotalUnpaidCustomerBills=Total unpaid customer's invoices BoxTotalUnpaidSuppliersBills=Total unpaid supplier's invoices @@ -47,7 +47,7 @@ BoxTitleLastModifiedMembers=Last %s members BoxTitleLastFicheInter=Last %s modified intervention BoxTitleOldestUnpaidCustomerBills=Oldest %s unpaid customer invoices BoxTitleOldestUnpaidSupplierBills=Oldest %s unpaid supplier invoices -BoxTitleCurrentAccounts=Opened account's balances +BoxTitleCurrentAccounts=Open accounts balances BoxTitleSalesTurnover=Sales turnover BoxTitleTotalUnpaidCustomerBills=Unpaid customer invoices BoxTitleTotalUnpaidSuppliersBills=Unpaid supplier invoices diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 11b1dc8eac089ea66cf5fdc902277d48f44011a1..a73526ca08abe500f930a7f164c52c9a07d6e797 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -42,19 +42,19 @@ ImpossibleAddCat=Impossible to add the tag/category ImpossibleAssociateCategory=Impossible to associate the tag/category to WasAddedSuccessfully=<b>%s</b> was added successfully. ObjectAlreadyLinkedToCategory=Element is already linked to this tag/category. -CategorySuccessfullyCreated=This tag/category %s has been added with success. -ProductIsInCategories=Product/service owns to following tags/categories -SupplierIsInCategories=Third party owns to following suppliers tags/categories -CompanyIsInCustomersCategories=This third party owns to following customers/prospects tags/categories -CompanyIsInSuppliersCategories=This third party owns to following suppliers tags/categories -MemberIsInCategories=This member owns to following members tags/categories -ContactIsInCategories=This contact owns to following contacts tags/categories +CategorySuccessfullyCreated=This tag/category %s has been added successfully. +ProductIsInCategories=Product/service is linked to following tags/categories +SupplierIsInCategories=Third party is linked to following suppliers tags/categories +CompanyIsInCustomersCategories=This third party is linked to following customers/prospects tags/categories +CompanyIsInSuppliersCategories=This third party is linked to following suppliers tags/categories +MemberIsInCategories=This member is linked to following members tags/categories +ContactIsInCategories=This contact is linked to following contacts tags/categories ProductHasNoCategory=This product/service is not in any tags/categories SupplierHasNoCategory=This supplier is not in any tags/categories CompanyHasNoCategory=This company is not in any tags/categories MemberHasNoCategory=This member is not in any tags/categories ContactHasNoCategory=This contact is not in any tags/categories -ClassifyInCategory=Classify in tag/category +ClassifyInCategory=Add to tag/category NoneCategory=None NotCategorized=Without tag/category CategoryExistsAtSameLevel=This category already exists with this ref @@ -67,13 +67,13 @@ ContentsNotVisibleByAllShort=Contents not visible by all CategoriesTree=Tags/categories tree DeleteCategory=Delete tag/category ConfirmDeleteCategory=Are you sure you want to delete this tag/category ? -RemoveFromCategory=Remove link with tag/categorie -RemoveFromCategoryConfirm=Are you sure you want to remove link between the transaction and the tag/category ? +RemoveFromCategory=Remove link with tag/category +RemoveFromCategoryConfirm=Are you sure you want to unlink the transaction from the tag/category ? NoCategoriesDefined=No tag/category defined -SuppliersCategoryShort=Suppliers tags/category -CustomersCategoryShort=Customers tags/category -ProductsCategoryShort=Products tags/category -MembersCategoryShort=Members tags/category +SuppliersCategoryShort=Suppliers tag/category +CustomersCategoryShort=Customers tag/category +ProductsCategoryShort=Products tag/category +MembersCategoryShort=Members tag/category SuppliersCategoriesShort=Suppliers tags/categories CustomersCategoriesShort=Customers tags/categories CustomersProspectsCategoriesShort=Custo./Prosp. categories @@ -107,4 +107,4 @@ CategoriesSetup=Tags/categories setup CategorieRecursiv=Link with parent tag/category automatically CategorieRecursivHelp=If activated, product will also linked to parent category when adding into a subcategory AddProductServiceIntoCategory=Add the following product/service -ShowCategory=Show tag/category \ No newline at end of file +ShowCategory=Show tag/category diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index cf5e1a6198cfaacf0fb04452e19ca783518ee466..5d7abf732ab4a744c257a624d92a281fff08745c 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -26,11 +26,11 @@ CronLastOutput=Last run output CronLastResult=Last result code CronListOfCronJobs=List of scheduled jobs CronCommand=Command -CronList=Scheduled job +CronList=Scheduled jobs CronDelete=Delete scheduled jobs -CronConfirmDelete=Are you sure you want to delete this scheduled jobs ? +CronConfirmDelete=Are you sure you want to delete these scheduled jobs ? CronExecute=Launch scheduled jobs -CronConfirmExecute=Are you sure to execute this scheduled jobs now ? +CronConfirmExecute=Are you sure you want to execute these scheduled jobs now ? CronInfo=Scheduled job module allow to execute job that have been planned CronWaitingJobs=Waiting jobs CronTask=Job @@ -39,8 +39,8 @@ CronDtStart=Start date CronDtEnd=End date CronDtNextLaunch=Next execution CronDtLastLaunch=Last execution -CronFrequency=Frequancy -CronClass=Classe +CronFrequency=Frequency +CronClass=Class CronMethod=Method CronModule=Module CronAction=Action @@ -55,7 +55,7 @@ CronEach=Every JobFinished=Job launched and finished #Page card CronAdd= Add jobs -CronHourStart= Start Hour and date of task +CronHourStart= Start hour and date of task CronEvery= And execute task each CronObject= Instance/Object to create CronArgs=Parameters @@ -79,10 +79,10 @@ CronCreateJob=Create new Scheduled Job # Info CronInfoPage=Information # Common -CronType=Task type +CronType=Job type CronType_method=Call method of a Dolibarr Class CronType_command=Shell command CronMenu=Cron CronCannotLoadClass=Cannot load class %s or object %s UseMenuModuleToolsToAddCronJobs=Go into menu "Home - Modules tools - Job list" to see and edit scheduled jobs. -TaskDisabled=Task disabled +TaskDisabled=Job disabled diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index ffc80289124e0ea8ed6347f2d6bd3540ccc65ea0..7ef4c291d2ad7c42dd83d23e0ac5c9b067255bda 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -421,7 +421,7 @@ Reportings=Reporting Draft=Draft Drafts=Drafts Validated=Validated -Opened=Opened +Opened=Open New=New Discount=Discount Unknown=Unknown @@ -732,4 +732,4 @@ ShortThursday=T ShortFriday=F ShortSaturday=S ShortSunday=S -SelectMailModel=Select email template \ No newline at end of file +SelectMailModel=Select email template diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 8786b3478669b18fece45a4bad3c46354bcac893..7f2902a96e6a2a6ecb1d78b5075dc4944649c5e1 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -75,8 +75,8 @@ AddToMyOrders=Add to my orders AddToOtherOrders=Add to other orders AddToDraftOrders=Add to draft order ShowOrder=Show order -NoOpenedOrders=No opened orders -NoOtherOpenedOrders=No other opened orders +NoOpenedOrders=No open orders +NoOtherOpenedOrders=No other open orders NoDraftOrders=No draft orders OtherOrders=Other orders LastOrders=Last %s customer orders diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang index f0cd2a402928440412d9b40434a0b4b03e854e3d..d86e998cf50faf7162bad344f6b35c142f6ef673 100644 --- a/htdocs/langs/en_US/printing.lang +++ b/htdocs/langs/en_US/printing.lang @@ -49,7 +49,6 @@ PRINTIPP_PORT=Port PRINTIPP_USER=Login PRINTIPP_PASSWORD=Password NoPrinterFound=No printers found (check your CUPS setup) -FileWasSentToPrinter=File %s was sent to printer NoDefaultPrinterDefined=No default printer defined DefaultPrinter=Default printer Printer=Printer diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 85b1d27f3a611763b0bf7454a46c40772432354b..37ceaa49b382be34c3ec4577cc01d40d91c61efe 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -19,4 +19,4 @@ printQty=Qty: %d AddDispatchBatchLine=Add a line for Shelf Life dispatching BatchDefaultNumber=Undefined WhenProductBatchModuleOnOptionAreForced=When module Lot/Serial is on, increase/decrease stock mode is forced to last choice and can't be edited. Other options can be defined as you want. -ProductDoesNotUseBatchSerial=This product does not use batch/serial number +ProductDoesNotUseBatchSerial=This product does not use lot/serial number diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 1b9a49b559d12d5add14afb9e5d188f003754b15..8e3402bf8b0b2fb2b4ce20770a81f027c3664165 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -23,14 +23,14 @@ ProductOrService=Product or Service ProductsAndServices=Products and Services ProductsOrServices=Products or Services ProductsAndServicesOnSell=Products and Services for sale or for purchase -ProductsAndServicesNotOnSell=Products and Services out of sale +ProductsAndServicesNotOnSell=Products and Services not for sale ProductsAndServicesStatistics=Products and Services statistics ProductsStatistics=Products statistics -ProductsOnSell=Product for sale or for pruchase -ProductsNotOnSell=Product out of sale and out of purchase +ProductsOnSell=Product for sale or for purchase +ProductsNotOnSell=Product not for sale and not for purchase ProductsOnSellAndOnBuy=Products for sale and for purchase ServicesOnSell=Services for sale or for purchase -ServicesNotOnSell=Services out of sale +ServicesNotOnSell=Services not for sale ServicesOnSellAndOnBuy=Services for sale and for purchase InternalRef=Internal reference LastRecorded=Last products/services on sell recorded @@ -44,7 +44,7 @@ CardProduct1=Service card CardContract=Contract card Warehouse=Warehouse Warehouses=Warehouses -WarehouseOpened=Warehouse opened +WarehouseOpened=Warehouse open WarehouseClosed=Warehouse closed Stock=Stock Stocks=Stocks @@ -71,21 +71,21 @@ SellingPriceTTC=Selling price (inc. tax) PublicPrice=Public price CurrentPrice=Current price NewPrice=New price -MinPrice=Minim. selling price -MinPriceHT=Minim. selling price (net of tax) -MinPriceTTC=Minim. selling price (inc. tax) +MinPrice=Min. selling price +MinPriceHT=Min. selling price (net of tax) +MinPriceTTC=Min. selling price (inc. tax) CantBeLessThanMinPrice=The selling price can't be lower than minimum allowed for this product (%s without tax). This message can also appears if you type a too important discount. ContractStatus=Contract status ContractStatusClosed=Closed -ContractStatusRunning=Running +ContractStatusRunning=Ongoing ContractStatusExpired=expired -ContractStatusOnHold=Not running -ContractStatusToRun=To get running -ContractNotRunning=This contract is not running +ContractStatusOnHold=On hold +ContractStatusToRun=Make ongoing +ContractNotRunning=This contract is not ongoing ErrorProductAlreadyExists=A product with reference %s already exists. ErrorProductBadRefOrLabel=Wrong value for reference or label. ErrorProductClone=There was a problem while trying to clone the product or service. -ErrorPriceCantBeLowerThanMinPrice=Error Price Can't Be Lower Than Minimum Price. +ErrorPriceCantBeLowerThanMinPrice=Error, price can't be lower than minimum price. Suppliers=Suppliers SupplierRef=Supplier's product ref. ShowProduct=Show product @@ -117,12 +117,12 @@ ServiceLimitedDuration=If product is a service with limited duration: MultiPricesAbility=Several level of prices per product/service MultiPricesNumPrices=Number of prices MultiPriceLevelsName=Price categories -AssociatedProductsAbility=Activate the virtual package feature +AssociatedProductsAbility=Activate the package feature AssociatedProducts=Package product -AssociatedProductsNumber=Number of products composing this virtual package product +AssociatedProductsNumber=Number of products composing this package product ParentProductsNumber=Number of parent packaging product -IfZeroItIsNotAVirtualProduct=If 0, this product is not a virtual package product -IfZeroItIsNotUsedByVirtualProduct=If 0, this product is not used by any virtual package product +IfZeroItIsNotAVirtualProduct=If 0, this product is not a package product +IfZeroItIsNotUsedByVirtualProduct=If 0, this product is not used by any package product EditAssociate=Associate Translation=Translation KeywordFilter=Keyword filter @@ -179,12 +179,12 @@ CloneProduct=Clone product or service ConfirmCloneProduct=Are you sure you want to clone product or service <b>%s</b> ? CloneContentProduct=Clone all main informations of product/service ClonePricesProduct=Clone main informations and prices -CloneCompositionProduct=Clone packaged product/services +CloneCompositionProduct=Clone packaged product/service ProductIsUsed=This product is used NewRefForClone=Ref. of new product/service -CustomerPrices=Customers prices -SuppliersPrices=Suppliers prices -SuppliersPricesOfProductsOrServices=Suppliers prices (of products or services) +CustomerPrices=Customer prices +SuppliersPrices=Supplier prices +SuppliersPricesOfProductsOrServices=Supplier prices (of products or services) CustomCode=Customs code CountryOrigin=Origin country HiddenIntoCombo=Hidden into select lists @@ -214,7 +214,7 @@ CostPmpHT=Net total VWAP ProductUsedForBuild=Auto consumed by production ProductBuilded=Production completed ProductsMultiPrice=Product multi-price -ProductsOrServiceMultiPrice=Customers prices (of products or services, multi-prices) +ProductsOrServiceMultiPrice=Customer prices (of products or services, multi-prices) ProductSellByQuarterHT=Products turnover quarterly VWAP ServiceSellByQuarterHT=Services turnover quarterly VWAP Quarter1=1st. Quarter @@ -237,10 +237,10 @@ ResetBarcodeForAllRecords=Define barcode value for all records (this will also r PriceByCustomer=Different price for each customer PriceCatalogue=Unique price per product/service PricingRule=Rules for customer prices -AddCustomerPrice=Add price by customers +AddCustomerPrice=Add price by customer ForceUpdateChildPriceSoc=Set same price on customer subsidiaries PriceByCustomerLog=Price by customer log -MinimumPriceLimit=Minimum price can't be lower that %s +MinimumPriceLimit=Minimum price can't be lower then %s MinimumRecommendedPrice=Minimum recommended price is : %s PriceExpressionEditor=Price expression editor PriceExpressionSelected=Selected price expression @@ -266,4 +266,6 @@ GlobalVariableUpdaterHelp1=Parses WebService data from specified URL, NS specifi GlobalVariableUpdaterHelpFormat1=format is {"URL": "http://example.com/urlofws", "VALUE": "array,targetvalue", "NS": "http://example.com/urlofns", "METHOD": "myWSMethod", "DATA": {"your": "data, "to": "send"}} UpdateInterval=Update interval (minutes) LastUpdated=Last updated -CorrectlyUpdated=Correctly updated \ No newline at end of file +CorrectlyUpdated=Correctly updated +PropalMergePdfProductActualFile=Files use to add into PDF Azur are/is +PropalMergePdfProductChooseFile=Select PDF files diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index e56ddf2ec4aba3075ded4600f70a92efa9ac99d1..dde2aa7d4691c295549539ed40344418f3522e08 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -11,7 +11,7 @@ ProjectsPublicDesc=This view presents all projects you are allowed to read. ProjectsPublicTaskDesc=This view presents all projects and tasks you are allowed to read. ProjectsDesc=This view presents all projects (your user permissions grant you permission to view everything). MyTasksDesc=This view is limited to projects or tasks you are a contact for (whatever is the type). -OnlyOpenedProject=Only opened projects are visible (projects with draft or closed status are not visible). +OnlyOpenedProject=Only open projects are visible (projects in draft or closed status are not visible). TasksPublicDesc=This view presents all projects and tasks you are allowed to read. TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything). AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task you are assigned on. @@ -29,7 +29,7 @@ ProjectsList=List of projects ShowProject=Show project SetProject=Set project NoProject=No project defined or owned -NbOpenTasks=Nb of opened tasks +NbOpenTasks=Nb of open tasks NbOfProjects=Nb of projects TimeSpent=Time spent TimeSpentByYou=Time spent by you @@ -41,7 +41,7 @@ TaskTimeSpent=Time spent on tasks TaskTimeUser=User TaskTimeNote=Note TaskTimeDate=Date -TasksOnOpenedProject=Tasks on opened projects +TasksOnOpenedProject=Tasks on open projects WorkloadNotDefined=Workload not defined NewTimeSpent=New time spent MyTimeSpent=My time spent @@ -95,7 +95,7 @@ DeleteATimeSpent=Delete time spent ConfirmDeleteATimeSpent=Are you sure you want to delete this time spent ? DoNotShowMyTasksOnly=See also tasks not assigned to me ShowMyTasksOnly=View only tasks assigned to me -TaskRessourceLinks=Ressources +TaskRessourceLinks=Resources ProjectsDedicatedToThisThirdParty=Projects dedicated to this third party NoTasks=No tasks for this project LinkedToAnotherCompany=Linked to other third party @@ -139,7 +139,7 @@ ProjectReferers=Refering objects SearchAProject=Search a project ProjectMustBeValidatedFirst=Project must be validated first ProjectDraft=Draft projects -FirstAddRessourceToAllocateTime=Associate a ressource to allocate time +FirstAddRessourceToAllocateTime=Associate a resource to allocate time InputPerDay=Input per day InputPerWeek=Input per week InputPerAction=Input per action diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 2b6d12870a1b949337f12391f80bec416b02a28b..c57e9c38324b738660fe3637f7bbee2ec432f77a 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -4,7 +4,7 @@ Proposal=Commercial proposal ProposalShort=Proposal ProposalsDraft=Draft commercial proposals ProposalDraft=Draft commercial proposal -ProposalsOpened=Opened commercial proposals +ProposalsOpened=Open commercial proposals Prop=Commercial proposals CommercialProposal=Commercial proposal CommercialProposals=Commercial proposals @@ -31,7 +31,7 @@ AmountOfProposalsByMonthHT=Amount by month (net of tax) NbOfProposals=Number of commercial proposals ShowPropal=Show proposal PropalsDraft=Drafts -PropalsOpened=Opened +PropalsOpened=Open PropalsNotBilled=Closed not billed PropalStatusDraft=Draft (needs to be validated) PropalStatusValidated=Validated (proposal is open) @@ -42,7 +42,7 @@ PropalStatusNotSigned=Not signed (closed) PropalStatusBilled=Billed PropalStatusDraftShort=Draft PropalStatusValidatedShort=Validated -PropalStatusOpenedShort=Opened +PropalStatusOpenedShort=Open PropalStatusClosedShort=Closed PropalStatusSignedShort=Signed PropalStatusNotSignedShort=Not signed @@ -51,8 +51,8 @@ PropalsToClose=Commercial proposals to close PropalsToBill=Signed commercial proposals to bill ListOfProposals=List of commercial proposals ActionsOnPropal=Events on proposal -NoOpenedPropals=No opened commercial proposals -NoOtherOpenedPropals=No other opened commercial proposals +NoOpenedPropals=No open commercial proposals +NoOtherOpenedPropals=No other open commercial proposals RefProposal=Commercial proposal ref SendPropalByMail=Send commercial proposal by mail AssociatedDocuments=Documents associated with the proposal: diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index dae86e3d8de104fe6d269b75b36fbf56f65082e7..1dc182c6fdcc75bb2fed7663ac9561bacd3741c5 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -67,7 +67,7 @@ SendingRunning=Product from ordered customer orders SuppliersReceiptRunning=Product from ordered supplier orders ProductQtyInCustomersOrdersRunning=Product quantity into opened customers orders ProductQtyInSuppliersOrdersRunning=Product quantity into opened suppliers orders -ProductQtyInShipmentAlreadySent=Product quantity from opended customer order already sent +ProductQtyInShipmentAlreadySent=Product quantity from opened customer order already sent ProductQtyInSuppliersShipmentAlreadyRecevied=Product quantity from opened supplier order already received # Sending methods diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index cc9dc79360db62a03365ac743e1f46d473e0864f..924878973bbcf5d847976f97aff1ddaf0db64a17 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -5,7 +5,7 @@ Warehouses=Warehouses NewWarehouse=New warehouse / Stock area WarehouseEdit=Modify warehouse MenuNewWarehouse=New warehouse -WarehouseOpened=Warehouse opened +WarehouseOpened=Warehouse open WarehouseClosed=Warehouse closed WarehouseSource=Source warehouse WarehouseSourceNotDefined=No warehouse defined, @@ -135,5 +135,5 @@ MovementCorrectStock=Stock correction for product %s MovementTransferStock=Stock transfer of product %s into another warehouse WarehouseMustBeSelectedAtFirstStepWhenProductBatchModuleOn=Source warehouse must be defined here when "Product lot" module is on. It will be used to list wich lot/serial is available for product that required lot/serial data for movement. If you want to send products from different warehouses, just make the shipment into several steps. InventoryCodeShort=Inv./Mov. code -NoPendingReceptionOnSupplierOrder=No pending reception due to opened supplier order -ThisSerialAlreadyExistWithDifferentDate=This lot/serial number (<strong>%s</strong>) already exists but with different eatby or sellby date (found <strong>%s</strong> but you enter <strong>%s</strong>). \ No newline at end of file +NoPendingReceptionOnSupplierOrder=No pending reception due to open supplier order +ThisSerialAlreadyExistWithDifferentDate=This lot/serial number (<strong>%s</strong>) already exists but with different eatby or sellby date (found <strong>%s</strong> but you enter <strong>%s</strong>). diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 6b7010439c981a166a69d45db9aa52fff1bb9b0b..39b3ee8c3d96202ee1b72016290684117372b812 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -42,5 +42,5 @@ SentToSuppliers=Sent to suppliers ListOfSupplierOrders=List of supplier orders MenuOrdersSupplierToBill=Supplier orders to invoice NbDaysToDelivery=Delivery delay in days -DescNbDaysToDelivery=The biggest delay is display among order product list +DescNbDaysToDelivery=The biggest deliver delay of the products from this order UseDoubleApproval=Use double approval (the second approval can be done by any user with the dedicated permission) \ No newline at end of file diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 30b6070632b0f879644e6f632843417f86303067..d4e4e8c4359fb6978be31c36375d36e328e97fff 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -44,7 +44,6 @@ TF_HOTEL=Hotel TF_TAXI=Taxi ErrorDoubleDeclaration=You have declared another expense report into a similar date range. -ListTripsAndExpenses=List of expense reports AucuneNDF=No expense reports found for this criteria AucuneLigne=There is no expense report declared yet AddLine=Add a line diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index 84b245fd77c327e127a8939b27f7656cc36ed775..82af8e6c9030c7e8eeaa2127430835b9cb343816 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -1,6 +1,6 @@ # Dolibarr language file - Source file is en_US - admin WorkflowSetup=Workflow module setup -WorkflowDesc=This module is designed to modify the behaviour of automatic actions into application. By default, workflow is opened (you make thing in order you want). You can activate the automatic actions that you are interested in. +WorkflowDesc=This module is designed to modify the behaviour of automatic actions into application. By default, workflow is open (you can do things in the order you want). You can activate the automatic actions you are interested in. ThereIsNoWorkflowToModify=There is no workflow to modify for the activated module. descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a customer order after a commercial proposal is signed descWORKFLOW_PROPAL_AUTOCREATE_INVOICEAutomatically create a customer invoice after a commercial proposal is signed diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index e50fb9c8ea8ed74a26021d09c2be6c185b548430..f4f46e263c21af207c889e8b638b444661f6b331 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -394,7 +394,7 @@ if ($action == 'create') */ print '<td align="center">'; $quantite_livree = $commande->livraisons[$line->id]; - print $quantite_livree;; + print $quantite_livree; print '</td>'; $quantite_commandee = $line->qty; diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index cf4034308ef81f194e2486101ead49ca87d0ead3..a217f34d93923f0f5d92b4705b00f1a55fe6ae66 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -367,7 +367,7 @@ if ($comments) { } else { - print $langs->trans("NoCommentYet").'<br>';; + print $langs->trans("NoCommentYet").'<br>'; } print '<br>'; diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index c3de8edd468d33e40db0e179ede337e353a803dc..05f77597cb239ac68e1364c3e306ba6b22c6bef8 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -159,6 +159,10 @@ else if ($action == 'viewProdTextsInThirdpartyLanguage') $view = GETPOST('activate_viewProdTextsInThirdpartyLanguage','alpha'); $res = dolibarr_set_const($db, "PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE", $view,'chaine',0,'',$conf->entity); } +elseif ($action == 'mergePropalProductCard') { + $view = GETPOST('activate_mergePropalProductCard','alpha'); + $res = dolibarr_set_const($db, "PRODUIT_PDF_MERGE_PROPAL", $view,'chaine',0,'',$conf->entity); +} else if ($action == 'usesearchtoselectproduct') { $usesearch = GETPOST('activate_usesearchtoselectproduct','alpha'); @@ -428,6 +432,21 @@ print '</td>'; print '</tr>'; print '</form>'; +// Activate propal merge produt card +$var=!$var; +print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; +print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; +print '<input type="hidden" name="action" value="mergePropalProductCard">'; +print '<tr '.$bc[$var].'>'; +print '<td>'.$langs->trans("MergePropalProductCard").'</td>'; +print '<td width="60" align="right">'; +print $form->selectyesno("activate_mergePropalProductCard",$conf->global->PRODUIT_PDF_MERGE_PROPAL,1); +print '</td><td align="right">'; +print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; +print '</td>'; +print '</tr>'; +print '</form>'; + // View product description in thirdparty language if (! empty($conf->global->MAIN_MULTILANGS)) { diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php new file mode 100644 index 0000000000000000000000000000000000000000..b2b7296d311f6e58473ea3ee5bc287f0b7fa9e12 --- /dev/null +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -0,0 +1,656 @@ +<?php +/* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2015 Florian HENRY <florian.henry@open-concept.pro> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * \file htdocs/product/class/propalmergepdfproduct.class.php + * \ingroup product + * \brief This file is an CRUD class file (Create/Read/Update/Delete) + */ + +require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); + + + +/** + * Put here description of your class + */ +class Propalmergepdfproduct extends CommonObject +{ + var $db; //!< To store db handler + var $error; //!< To return error code (or message) + var $errors=array(); //!< To return several error codes (or messages) + var $element='propal_merge_pdf_product'; //!< Id that identify managed objects + var $table_element='propal_merge_pdf_product'; //!< Name of table without prefix where object is stored + + var $id; + + var $fk_product; + var $file_name; + var $fk_user_author; + var $fk_user_mod; + var $datec=''; + var $tms=''; + var $import_key; + var $lang; + + var $lines=array(); + + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + function __construct($db) + { + $this->db = $db; + return 1; + } + + + /** + * Create object into database + * + * @param User $user User that creates + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + function create($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + + if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product); + if (isset($this->file_name)) $this->file_name=trim($this->file_name); + if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); + if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod); + if (isset($this->lang)) $this->lang=trim($this->lang); + if (isset($this->import_key)) $this->import_key=trim($this->import_key); + + + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal_merge_pdf_product("; + + $sql.= "fk_product,"; + $sql.= "file_name,"; + if ($conf->global->MAIN_MULTILANGS) { + $sql.= "lang,"; + } + $sql.= "fk_user_author,"; + $sql.= "fk_user_mod,"; + $sql.= "datec"; + + + $sql.= ") VALUES ("; + + $sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->fk_product."'").","; + $sql.= " ".(! isset($this->file_name)?'NULL':"'".$this->db->escape($this->file_name)."'").","; + if ($conf->global->MAIN_MULTILANGS) { + $sql.= " ".(! isset($this->lang)?'NULL':"'".$this->db->escape($this->lang)."'").","; + } + $sql.= " ".$user->id.","; + $sql.= " ".$user->id.","; + $sql.= " '".$this->db->idate(dol_now())."'"; + + + $sql.= ")"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal_merge_pdf_product"); + + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return $this->id; + } + } + + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + function fetch($id) + { + global $langs,$conf; + + $sql = "SELECT"; + $sql.= " t.rowid,"; + + $sql.= " t.fk_product,"; + $sql.= " t.file_name,"; + $sql.= " t.lang,"; + $sql.= " t.fk_user_author,"; + $sql.= " t.fk_user_mod,"; + $sql.= " t.datec,"; + $sql.= " t.tms,"; + $sql.= " t.import_key"; + + + $sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t"; + $sql.= " WHERE t.rowid = ".$id; + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->fk_product = $obj->fk_product; + $this->file_name = $obj->file_name; + if ($conf->global->MAIN_MULTILANGS) { + $this->lang = $obj->lang; + } + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_mod = $obj->fk_user_mod; + $this->datec = $this->db->jdate($obj->datec); + $this->tms = $this->db->jdate($obj->tms); + $this->import_key = $obj->import_key; + + + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $lang lang string id + * @return int <0 if KO, >0 if OK + */ + function fetch_by_product($product_id, $lang='') + { + global $langs,$conf; + + $sql = "SELECT"; + $sql.= " t.rowid,"; + + $sql.= " t.fk_product,"; + $sql.= " t.file_name,"; + $sql.= " t.lang,"; + $sql.= " t.fk_user_author,"; + $sql.= " t.fk_user_mod,"; + $sql.= " t.datec,"; + $sql.= " t.tms,"; + $sql.= " t.import_key"; + + + $sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t"; + $sql.= " WHERE t.fk_product = ".$product_id; + if ($conf->global->MAIN_MULTILANGS && !empty($lang)) { + $sql.= " AND t.lang = '".$lang."'"; + } + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + while($obj = $this->db->fetch_object($resql)) { + + $line = new PropalmergepdfproductLine(); + + $line->id = $obj->rowid; + + $line->fk_product = $obj->fk_product; + $line->file_name = $obj->file_name; + if ($conf->global->MAIN_MULTILANGS) { + $line->lang = $obj->lang; + } + $line->fk_user_author = $obj->fk_user_author; + $line->fk_user_mod = $obj->fk_user_mod; + $line->datec = $this->db->jdate($obj->datec); + $line->tms = $this->db->jdate($obj->tms); + $line->import_key = $obj->import_key; + + + if ($conf->global->MAIN_MULTILANGS) { + $this->lines[$obj->file_name.'_'.$obj->lang]=$line; + }else { + $this->lines[$obj->file_name]=$line; + } + + + } + + + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch_by_product ".$this->error, LOG_ERR); + return -1; + } + } + + + /** + * Update object into database + * + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user=0, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + + if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product); + if (isset($this->file_name)) $this->file_name=trim($this->file_name); + if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod); + if (isset($this->lang)) $this->lang=trim($this->lang); + + + + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."propal_merge_pdf_product SET"; + + $sql.= " fk_product=".(isset($this->fk_product)?$this->fk_product:"null").","; + $sql.= " file_name=".(isset($this->file_name)?"'".$this->db->escape($this->file_name)."'":"null").","; + if ($conf->global->MAIN_MULTILANGS) { + $sql.= " lang=".(isset($this->lang)?"'".$this->db->escape($this->lang)."'":"null").","; + } + $sql.= " fk_user_mod=".$user->id; + + + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + $this->db->begin(); + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; + $sql.= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param int $product_id product_id + * @param string $lang_id language + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete_by_product($user, $product_id, $lang_id='', $notrigger=0) + { + global $conf, $langs; + $error=0; + + $this->db->begin(); + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; + $sql.= " WHERE fk_product=".$product_id; + + if ($conf->global->MAIN_MULTILANGS && !empty($lang_id)) { + $sql.= " AND lang='".$lang_id."'"; + } + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @return int <0 if KO, >0 if OK + */ + function delete_by_file($user) + { + global $conf, $langs; + $error=0; + + $this->db->begin(); + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product"; + $sql.= " WHERE fk_product=".$this->fk_product." AND file_name='".$this->db->escape($this->file_name)."'"; + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + + /** + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + function createFromClone($fromid) + { + global $user,$langs; + + $error=0; + + $object=new Propalmergepdfproduct($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + $object->id=0; + $object->statut=0; + + // Clear fields + // ... + + // Create clone + $result=$object->create($user); + + // Other options + if ($result < 0) + { + $this->error=$object->error; + $error++; + } + + if (! $error) + { + + + } + + // End + if (! $error) + { + $this->db->commit(); + return $object->id; + } + else + { + $this->db->rollback(); + return -1; + } + } + + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + function initAsSpecimen() + { + $this->id=0; + + $this->fk_product=''; + $this->file_name=''; + $this->fk_user_author=''; + $this->fk_user_mod=''; + $this->datec=''; + $this->tms=''; + $this->import_key=''; + + + } + +} + +class PropalmergepdfproductLine{ + var $id; + + var $fk_product; + var $file_name; + var $lang; + var $fk_user_author; + var $fk_user_mod; + var $datec=''; + var $tms=''; + var $import_key; + + function __construct() { + return 1; + } + +} diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index fc3a41a8861027fba87346351af7b314e0d6651b..773d08fae7243710e1e3121fcbbfc347028df770 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -268,7 +268,7 @@ if ($id > 0 || ! empty($ref)) $productstatic->type=$value["fk_product_type"]; $productstatic->ref=$value['label']; print '<tr>'; - print '<td>'.$productstatic->getNomUrl(1,'composition').'</td>';; + print '<td>'.$productstatic->getNomUrl(1,'composition').'</td>'; print '</tr>'; } print '</table>'; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 810a131be60fc5e3b3e9426843342d3a67a85259..615f4accf705d911bd8dfdc58a3d3bea7be225d8 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -33,6 +33,8 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) + require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php'; $langs->load("other"); $langs->load("products"); @@ -84,8 +86,70 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + //Delete line if product propal merge is linked to a file + if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { + if ($action == 'confirm_deletefile' && $confirm == 'yes') + { + print 'toto'; + //extract file name + $urlfile = GETPOST('urlfile', 'alpha'); + $filename = basename($urlfile); + $filetomerge = new Propalmergepdfproduct($db); + $filetomerge->fk_product=$object->id; + $filetomerge->file_name=$filename; + $result=$filetomerge->delete_by_file($user); + if ($result<0) { + setEventMessage($filetomerge->error,'errors'); + } + } + } + // Action sending file include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_pre_headers.tpl.php'; + +} + +if ($action=='filemerge') { + $is_refresh = GETPOST('refresh'); + if (empty($is_refresh)) { + + $filetomerge_file_array = GETPOST('filetoadd'); + + $filetomerge_file_array = GETPOST('filetoadd'); + + if ($conf->global->MAIN_MULTILANGS) { + $lang_id = GETPOST('lang_id'); + } + + // Delete all file already associated + $filetomerge = new Propalmergepdfproduct($db); + + if ($conf->global->MAIN_MULTILANGS) { + $result=$filetomerge->delete_by_product($user, $object->id, $lang_id); + } else { + $result=$filetomerge->delete_by_product($user, $object->id); + } + if ($result<0) { + setEventMessage($filetomerge->error,'errors'); + } + + // for each file checked add it to the product + if (is_array($filetomerge_file_array)) { + foreach ( $filetomerge_file_array as $filetomerge_file ) { + $filetomerge->fk_product = $object->id; + $filetomerge->file_name = $filetomerge_file; + + if ($conf->global->MAIN_MULTILANGS) { + $filetomerge->lang = $lang_id; + } + + $result=$filetomerge->create($user); + if ($result<0) { + setEventMessage($filetomerge->error,'errors'); + } + } + } + } } @@ -142,13 +206,139 @@ if ($object->id) print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '</table>'; - + print '</div>'; $modulepart = 'produit'; $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + + + //Merge propal PDF docuemnt PDF files + if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) + { + $filetomerge = new Propalmergepdfproduct($db); + + if ($conf->global->MAIN_MULTILANGS) { + $lang_id = GETPOST('lang_id'); + $result = $filetomerge->fetch_by_product($object->id, $lang_id); + } else { + $result = $filetomerge->fetch_by_product($object->id); + } + + $form = new Form($db); + + $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1); + + // For each file build select list with PDF extention + if (count($filearray) > 0) { + print '<br>'; + // Actual file to merge is : + if (count($filetomerge->lines) > 0) { + print $langs->trans('PropalMergePdfProductActualFile'); + } + + print '<form name="filemerge" action="' . DOL_URL_ROOT . '/product/document.php?id=' . $object->id . '" method="post">'; + print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; + print '<input type="hidden" name="action" value="filemerge">'; + if (count($filetomerge->lines) == 0) { + print $langs->trans('PropalMergePdfProductChooseFile'); + } + + print '<table class="noborder">'; + + // Get language + if ($conf->global->MAIN_MULTILANGS) { + + $langs->load("languages"); + + print '<tr class="liste_titre"><td>'; + + $delauft_lang = (empty($lang_id)) ? $langs->getDefaultLang() : $lang_id; + + $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); + + print '<select class="flat" id="lang_id" name="lang_id">'; + + asort($langs_available); + + $uncompletelanguages = array ( + 'da_DA', + 'fi_FI', + 'hu_HU', + 'is_IS', + 'pl_PL', + 'ro_RO', + 'ru_RU', + 'sv_SV', + 'tr_TR', + 'zh_CN' + ); + foreach ( $langs_available as $key => $value ) { + if ($showwarning && in_array($key, $uncompletelanguages)) { + // $value.=' - '.$langs->trans("TranslationUncomplete",$key); + } + if ($filter && is_array($filter)) { + if (! array_key_exists($key, $filter)) { + print '<option value="' . $key . '">' . $value . '</option>'; + } + } else if ($delauft_lang == $key) { + print '<option value="' . $key . '" selected="selected">' . $value . '</option>'; + } else { + print '<option value="' . $key . '">' . $value . '</option>'; + } + } + print '</select>'; + + if ($conf->global->MAIN_MULTILANGS) { + print '<input type="submit" class="button" name="refresh" value="' . $langs->trans('Refresh') . '">'; + } + + print '</td></tr>'; + } + + $style = 'impair'; + foreach ( $filearray as $filetoadd ) { + + if ($ext = pathinfo($filetoadd['name'], PATHINFO_EXTENSION) == 'pdf') { + + if ($style == 'pair') { + $style = 'impair'; + } else { + $style = 'pair'; + } + + $checked = ''; + $filename = $filetoadd['name']; + + if ($conf->global->MAIN_MULTILANGS) { + if (array_key_exists($filetoadd['name'] . '_' . $delauft_lang, $filetomerge->lines)) { + $filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $delauft_lang); + $checked = ' checked="checked" '; + } + } else { + if (array_key_exists($filetoadd['name'], $filetomerge->lines)) { + $checked = ' checked="checked" '; + } + } + + print '<tr class="' . $style . '"><td>'; + + print '<input type="checkbox" ' . $checked . ' name="filetoadd[]" id="filetoadd" value="' . $filetoadd['name'] . '">' . $filename . '</input>'; + print '</td></tr>'; + } + } + print '<tr><td>'; + + print '<input type="submit" class="button" name="save" value="' . $langs->trans('Save') . '">'; + print '</td></tr>'; + print '</table>'; + + print '</form>'; + } + } + } else { @@ -157,4 +347,4 @@ else llxFooter(); -$db->close(); +$db->close(); \ No newline at end of file diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 6f5cb7ae578f4b92b821657d9388084ad2399a51..871ec4d30f108815536daa5e36ec7cbfe8423981 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -31,7 +31,7 @@ $langs->load("stocks"); // Security check $result=restrictedArea($user,'stock'); -$sref=GETPOST("sref");; +$sref=GETPOST("sref"); $snom=GETPOST("snom"); $sall=GETPOST("sall"); diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 583326b3e34a101d34541e395599579c6aaa7663..f501f25c866c6ee6328022468188630186603bc2 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -129,7 +129,7 @@ if ($id > 0 || ! empty($ref)) $colwidth=30; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end();; + dol_fiche_end(); } llxFooter(); diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index d50c9a4ec6f14be363a498ee2623ad197ec67ce3..6b6b5553d72261d3818686f45ece0c9457beddc6 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -59,7 +59,7 @@ $hookmanager->initHooks(array('element_resource')); $object->available_resources = array('resource'); // Get parameters -$id = GETPOST('id','int'); +$id = GETPOST('id','int'); $action = GETPOST('action','alpha'); $mode = GETPOST('mode','alpha'); $lineid = GETPOST('lineid','int'); @@ -70,6 +70,7 @@ $resource_type = GETPOST('resource_type','alpha'); $busy = GETPOST('busy','int'); $mandatory = GETPOST('mandatory','int'); $cancel = GETPOST('cancel','alpha'); +$confirm = GETPOST('confirm','alpha'); if($action == 'add_element_resource' && ! $cancel) { @@ -113,22 +114,22 @@ if ($action == 'update_linked_resource' && $user->rights->resource->write && !GE } // Delete a resource linked to an element -if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->delete && GETPOST('confirm') == 'yes') +if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->delete && $confirm === 'yes') { - $res = $object->fetch(GETPOST('id')); - if($res) + $res = $object->fetch($id); + if($res > 0) { - $result = $object->delete_resource($lineid,$element); - - if ($result >= 0) - { - setEventMessage($langs->trans('RessourceLineSuccessfullyDeleted')); - Header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); - exit; - } - else { - setEventMessage($object->error,'errors'); - } + $result = $object->delete_resource($lineid,$element); + + if ($result >= 0) + { + setEventMessage($langs->trans('RessourceLineSuccessfullyDeleted')); + Header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); + exit; + } + else { + setEventMessage($object->error,'errors'); + } } else { @@ -173,7 +174,7 @@ else // Confirmation suppression resource line if ($action == 'delete_resource') { - print $form->formconfirm("element_resource.php?element=".$element."&element_id=".$element_id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_linked_resource",'','',1); + print $form->formconfirm("element_resource.php?element=".$element."&element_id=".$element_id."&id=".$id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_linked_resource",'','',1); } diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index 4ea5afcbdcb0b1b2db6965077e91a3225d6b3af8..26c1e77742f97baafc40452f4433055371bbc48d 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -107,7 +107,7 @@ dol_fiche_head($head, 'card', $langs->trans("ThirdParty"),0,'company'); <tr> <td><?php echo $langs->trans('EMail'); ?></td> - <td><?php echo $this->control->tpl['email'];; ?></td> + <td><?php echo $this->control->tpl['email']; ?></td> <td><?php echo $langs->trans('Web'); ?></td> <td><?php echo $this->control->tpl['url']; ?></td> </tr> diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index d2fc7e5551b692f250e454554ee0fe70fc17acc8..bc83f2955da12668c7b6d3e61c776935ed140351 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -106,7 +106,7 @@ dol_fiche_head($head, 'card', $langs->trans("ThirdParty"),0,'company'); <tr> <td><?php echo $langs->trans('EMail'); ?></td> - <td><?php echo $this->control->tpl['email'];; ?></td> + <td><?php echo $this->control->tpl['email']; ?></td> <td><?php echo $langs->trans('Web'); ?></td> <td><?php echo $this->control->tpl['url']; ?></td> </tr> diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 8b8f3755fff6bdda5ebd2bb665dc8015e9a984c5..6eb8b8231842d9f7d90ef7bf03dac15fb9bdd6c1 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2012-2013 Philippe Berthet <berthet@systune.be> * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2013-2015 Juanjo Menent <jmenent@2byte.es> * * Version V1.1 Initial version of Philippe Berthet * Version V2 Change to be compatible with 3.4 and enhanced to be more generic @@ -75,6 +75,7 @@ $langs->load("bills"); $langs->load("orders"); $langs->load("suppliers"); $langs->load("propal"); +$langs->load("interventions"); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('consumptionthirdparty')); @@ -98,7 +99,7 @@ $form = new Form($db); $formother = new FormOther($db); $productstatic=new Product($db); -$title = $langs->trans("Referer",$object->name); +$title = $langs->trans("Referers",$object->name); if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$title,$help_url); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 43b04ce3a94bf340e3a7d0a2bc8c5c85d5841881..a2c56c014a79addf1af1b35198d4bd53e4a7082c 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -2271,7 +2271,7 @@ else print '</div>'."\n"; //Select mail models is same action as presend - if (!empty(GETPOST('modelselected'))) { + if (GETPOST('modelselected')) { $action = 'presend'; } if ($action == 'presend') diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 6f17f10113a42d6c4a1582822b435014745ab72b..35b63230e1fc6d9ea38f4be048eb847453e03403 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -255,8 +255,9 @@ textarea.cke_source:focus input, input.flat, textarea, textarea.flat, form.flat select, select.flat { font-size: <?php print $fontsize ?>px; - font-family: <?php print $fontlist ?>; - background: #FDFDFD; + font-family: <?php print $fontlist ?>; + background: #FDFDFD; + color: #444; border: 1px solid #C0C0C0; /*padding: 1px 1px 1px 1px; */ margin: 0px 0px 0px 0px; @@ -1778,11 +1779,11 @@ table.noborder tr, div.noborder form { border-left-width: 1px; border-left-color: #BBBBBB; border-left-style: solid; - height: 26px; + min-height: 20px; } table.noborder th, table.noborder td, div.noborder form, div.noborder form div { - padding: 1px 2px 1px 3px; /* t r b l */ + padding: 5px 2px 5px 3px; /* t r b l */ } table.nobordernopadding { @@ -1917,7 +1918,7 @@ table.liste td { background-color: #f9f9f9; } tr.pair td, tr.impair td { - padding: 2px; + padding: 5px 2px; border-bottom: 1px solid #ddd; } div.liste_titre .tagtd { diff --git a/htdocs/webservices/demo_wsclient_actioncomm.php-NORUN b/htdocs/webservices/demo_wsclient_actioncomm.php-NORUN index 1e14c07a5bf98a3d4bef691027e9a7cda30e6ccc..d3044fc9bd837ec889ae2a7d1d320ae1590d7644 100755 --- a/htdocs/webservices/demo_wsclient_actioncomm.php-NORUN +++ b/htdocs/webservices/demo_wsclient_actioncomm.php-NORUN @@ -160,6 +160,6 @@ echo '</pre>'; echo '<h4>SOAP Message</h4>'; echo '<pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>'; -echo '</body>'."\n";; -echo '</html>'."\n";; +echo '</body>'."\n"; +echo '</html>'."\n"; ?> diff --git a/htdocs/webservices/demo_wsclient_category.php-NORUN b/htdocs/webservices/demo_wsclient_category.php-NORUN index 0793fd1806cd7037b8742f229374fc998111c8f8..e0d78681eac01b7c08d1a32d9740c0fe06a5dafc 100755 --- a/htdocs/webservices/demo_wsclient_category.php-NORUN +++ b/htdocs/webservices/demo_wsclient_category.php-NORUN @@ -92,6 +92,6 @@ echo '<h4>SOAP Message</h4>'; echo '<pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>'; -echo '</body>'."\n";; -echo '</html>'."\n";; +echo '</body>'."\n"; +echo '</html>'."\n"; ?> diff --git a/htdocs/webservices/demo_wsclient_invoice.php-NORUN b/htdocs/webservices/demo_wsclient_invoice.php-NORUN index ad6612692fc6d33a056379b8c4f4fb7bfadc6bd2..8708e89e13f3952b2b31deec08f22d6379aef4e1 100755 --- a/htdocs/webservices/demo_wsclient_invoice.php-NORUN +++ b/htdocs/webservices/demo_wsclient_invoice.php-NORUN @@ -136,6 +136,6 @@ echo '</pre>'; echo '<h4>SOAP Message</h4>'; echo '<pre>' . htmlspecialchars($soapclient2->response, ENT_QUOTES) . '</pre>'; -echo '</body>'."\n";; -echo '</html>'."\n";; +echo '</body>'."\n"; +echo '</html>'."\n"; ?> diff --git a/htdocs/webservices/demo_wsclient_other.php-NORUN b/htdocs/webservices/demo_wsclient_other.php-NORUN index 60c801e10fc32861171f5c95cf0a9cdaf2d44f05..0de1ac6b71a54cd9ef3134621eee24091c50b24c 100755 --- a/htdocs/webservices/demo_wsclient_other.php-NORUN +++ b/htdocs/webservices/demo_wsclient_other.php-NORUN @@ -99,6 +99,6 @@ echo '</pre>'; echo '<h4>SOAP Message</h4>'; echo '<pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>'; -echo '</body>'."\n";; -echo '</html>'."\n";; +echo '</body>'."\n"; +echo '</html>'."\n"; ?> diff --git a/htdocs/webservices/demo_wsclient_productorservice.php-NORUN b/htdocs/webservices/demo_wsclient_productorservice.php-NORUN index e27db313bfc7e8c710b14b469d53319b00cf5ce8..e684a39b1e73b6d247e990a44f57f8cfc9036b5b 100755 --- a/htdocs/webservices/demo_wsclient_productorservice.php-NORUN +++ b/htdocs/webservices/demo_wsclient_productorservice.php-NORUN @@ -177,6 +177,6 @@ echo '</pre>'; echo '<h4>SOAP Message</h4>'; echo '<pre>' . htmlspecialchars($soapclient3->response, ENT_QUOTES) . '</pre>'; -echo '</body>'."\n";; -echo '</html>'."\n";; +echo '</body>'."\n"; +echo '</html>'."\n"; ?> diff --git a/htdocs/webservices/demo_wsclient_thirdparty.php-NORUN b/htdocs/webservices/demo_wsclient_thirdparty.php-NORUN index 3260549b7123fb12781310d5c0d819e484260205..45f3d89939fdf78594c0fb1075f55770b25018e2 100755 --- a/htdocs/webservices/demo_wsclient_thirdparty.php-NORUN +++ b/htdocs/webservices/demo_wsclient_thirdparty.php-NORUN @@ -223,6 +223,6 @@ echo '</pre>'; echo '<h4>SOAP Message</h4>'; echo '<pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>'; -echo '</body>'."\n";; -echo '</html>'."\n";; +echo '</body>'."\n"; +echo '</html>'."\n"; ?> diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index ae51af3800948f580d215e9afd993c4657c0923f..44ccb4c7e97d02570a81e15df302e0fbca641669 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -116,7 +116,7 @@ if ($resql) $oldemail = $obj->email; $olduid = $obj->uid; $oldlang = $obj->lang; - $oldsalerepresentative=dolGetFirstLastname($obj->firstname, $obj->lastname);; + $oldsalerepresentative=dolGetFirstLastname($obj->firstname, $obj->lastname); $message = ''; $total = 0; $foundtoprocess = 0; diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 2960e2eb6859496d21907ba2ec9d592857548d16..2870766ff211be4dbb932edcbfaab2cde4bd22d4 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -120,7 +120,7 @@ if ($resql) $oldemail = $obj->email; $olduid = $obj->uid; $oldlang = $obj->lang; - $oldsalerepresentative=dolGetFirstLastname($obj->firstname, $obj->lastname);; + $oldsalerepresentative=dolGetFirstLastname($obj->firstname, $obj->lastname); $message = ''; $total = 0; $foundtoprocess = 0;