Completed
Push — master ( 3f8ec2...f62223 )
by Michael
03:23 queued 14s
created

extcal_getHeader()   B

Complexity

Conditions 4
Paths 6

Size

Total Lines 40
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 18
nc 6
nop 2
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 40 and the first side effect is on line 25.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    {@link https://xoops.org/ XOOPS Project}
14
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @package      extcal
16
 * @since
17
 * @author       XOOPS Development Team,
18
 *
19
 * L'utilisation de ce formulaire d'adminitration suppose
20
 * que la classe correspondante de la table a été générées avec classGenerator
21
 **/
22
23
use XoopsModules\Extcal;
24
25
require_once __DIR__ . '/../../../class/uploader.php';
26
require_once __DIR__ . '/../../../class/mail/phpmailer/class.phpmailer.php'; // First we require the PHPMailer libary in our script
27
// require_once __DIR__ . '/../class/Utility.php';
28
require_once __DIR__ . '/constantes.php';
29
require_once __DIR__ . '/../../../class/template.php';
30
31
/********************************************************************
32
 *
33
 *******************************************************************
34
 * @param $mode
35
 * @param $event_id
36
 * @param $member_uid
37
 * @param $subject
38
 * @param $tplMessage
39
 */
40
function sendMail2member($mode, $event_id, $member_uid, $subject, $tplMessage)
0 ignored issues
show
Unused Code introduced by
The parameter $mode is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

40
function sendMail2member(/** @scrutinizer ignore-unused */ $mode, $event_id, $member_uid, $subject, $tplMessage)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
{
42
    //mode = 0 pas d'entete
43
    //mode = 1 format text
44
    //mode = 2: format html
45
46
    global $xoopsConfig, $xoopsDB;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
47
    // $t = print_r($xoopsConfig, true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
    // echo "<pre>{$t}</pre>";
49
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
50
    $member_uid = 1;
51
    $event_id = 393;
52
    $message = "Bonne journée à tous";
53
    $newStatus = 1;
54
    $oldStatus = 0;
55
56
    */
57
58
    //l'utilisateur ne pas etre notifié par mail
59
    //if ($mode == 0) exit;
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
60
    //-------------------------------------------------------
61
    $tblMember    = $xoopsDB->prefix('extcal_eventmember');
62
    $tblNotMember = $xoopsDB->prefix('extcal_eventnotmember');
63
    $tblUsers     = $xoopsDB->prefix('users');
64
    $tblEvent     = $xoopsDB->prefix('extcal_event');
0 ignored issues
show
Unused Code introduced by
The assignment to $tblEvent is dead and can be removed.
Loading history...
65
66
    //--------------------------------------------------------------
67
    //Recuperation des données event,user et member
68
    //Recuperation des données de l'evennement
69
    $eventHandler = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_EVENT);
70
    $obj          = $eventHandler->getEvent($event_id);
71
    $event        = $eventHandler->objectToArray($obj);
72
    $eventHandler->formatEventDate($event, _MD_EXTCAL_FORMAT_DATE);
73
74
    $submiter_uid = $event['event_submitter'];
75
    // Extcal\Utility::echoArray($event,'event');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
76
    //--------------------------------------------------------------
77
    //Recuperation des données du user createur de l'evennement
78
    $sql = <<<__sql__
79
  SELECT if(tu.name='', tu.uname, tu.name) AS name,     tu.uname,   tu.email
80
  FROM {$tblUsers} tu
81
  WHERE tu.uid = {$submiter_uid};
82
__sql__;
83
84
    $rst      = $xoopsDB->query($sql);
85
    $submiter = $xoopsDB->fetchArray($rst);
86
    // echo "{$sql}<br>";
87
    // Extcal\Utility::echoArray($submiter,'submiter');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
88
    //--------------------------------------------------------------
89
    //Recuperation des données du membre inscrit
90
    $sql = <<<__sql__
91
  SELECT if(tu.name='', tu.uname, tu.name) AS name,     tu.uname,   tu.email
92
  FROM {$tblUsers} tu
93
  WHERE tu.uid = {$member_uid};
94
__sql__;
95
96
    $rst    = $xoopsDB->query($sql);
97
    $acteur = $xoopsDB->fetchArray($rst);
98
    //echo "{$sql}<br>";
99
    // Extcal\Utility::echoArray($acteur,'acteur');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
100
    //--------------------------------------------------------------
101
    //Recuperation des données des membres présents
102
    $sql = <<<__sql__
103
SELECT tu.uid, if(tu.name='', tu.uname, tu.name) AS name,   tu.uname,   tu.email,
104
        tm.status
105
FROM {$tblMember} tm,
106
     {$tblUsers}  tu
107
WHERE tm.uid = tu.uid
108
  AND tm.event_id = {$event_id}
109
__sql__;
110
111
    $rst     = $xoopsDB->query($sql);
112
    $members = [];
113
    while (false !== ($row = $xoopsDB->fetchArray($rst))) {
114
        $row['status']        = _MD_EXTCAL_PRESENT;
115
        $members[$row['uid']] = $row;
116
    }
117
118
    //--------------------------------------------------------------
119
    //Recuperation des données des membres absents
120
    $sql = <<<__sql__
121
SELECT tu.uid, if(tu.name='', tu.uname, tu.name) AS name,   tu.uname,   tu.email,
122
        tm.status
123
FROM {$tblNotMember} tm,
124
     {$tblUsers}  tu
125
WHERE tm.uid = tu.uid
126
  AND tm.event_id = {$event_id}
127
__sql__;
128
129
    $rst = $xoopsDB->query($sql);
130
    while (false !== ($row = $xoopsDB->fetchArray($rst))) {
131
        $row['status']        = _MD_EXTCAL_ABSENT;
132
        $members[$row['uid']] = $row;
133
    }
134
135
    // Extcal\Utility::echoArray($members,'members');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
136
    // exit;
137
138
    //--------------------------------------------------------------
139
    //Message et sujet du mail
140
    $action  = ''; //a voir   JJD
141
    $message = sprintf($tplMessage, $acteur['name']);
142
    //$subject .= ' (' . rand(1, 100) . ')';
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
143
    $subject .= ' - ' . $acteur['name'];
144
    //--------------------------------------------------------------
145
    //Chargement du template dans le dossier de langue
146
    //$f = _EXTCAL_PATH_LG . $xoopsConfig['language'] . '\mail_inscription.html';
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
147
    //$tpl = new tpl($f);
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
148
    $tpl = new \XoopsTpl();
0 ignored issues
show
Bug introduced by
The type XoopsTpl was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
149
150
    $tpl->assign('dateAction', date(_MD_EXTCAL_FORMAT_DATE));
151
    $tpl->assign('submiter', $submiter);
152
    $tpl->assign('event', $event);
153
    $tpl->assign('acteur', $acteur);
154
    $tpl->assign('members', $members);
155
    $tpl->assign('action', $action);
156
    $tpl->assign('subject', $subject);
157
    $tpl->assign('message', $message);
158
    $tpl->assign('xoopsConfig', $xoopsConfig);
159
    $tpl->assign('br', '<br>');
160
161
    //--------------------------------------------------------------
162
    $destinataires                     = [];
163
    $destinataires[$submiter['email']] = $submiter['email'];
164
    $destinataires[$acteur['email']]   = $acteur['email'];
165
    //    while (list($k, $row) = each($members)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
166
    foreach ($members as $k => $row) {
167
        $destinataires[$row['email']] = $row['email'];
168
    }
169
170
    // Extcal\Utility::echoArray($destinataires);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
171
    // exit;
172
173
    $mail_fromName  = $xoopsConfig['sitename'];
174
    $mail_fromemail = $xoopsConfig['adminmail'];
175
    $mail_subject   = $subject;
176
177
    $bEcho = false;
0 ignored issues
show
Unused Code introduced by
The assignment to $bEcho is dead and can be removed.
Loading history...
178
    $mode  = _EXTCAL_HEADER_HTML;
179
    $sep   = '|';
0 ignored issues
show
Unused Code introduced by
The assignment to $sep is dead and can be removed.
Loading history...
180
181
    $template = 'extcal_mail_member_text.tpl';
182
    if (_EXTCAL_HEADER_HTML == $mode) {
0 ignored issues
show
introduced by
The condition _EXTCAL_HEADER_HTML == $mode is always true.
Loading history...
183
        $template = 'extcal_mail_member_html.tpl';
184
    }
185
    $mail_body = $tpl->fetch('db:' . $template);
186
187
    extcal_SendMail($destinataires, $mail_fromName, $mail_fromemail, $mail_subject, $mail_body, $bEcho = false, $mode = 0, $sep = '|');
188
189
    //Prépartion de l'envoi
190
191
    //--------------------------------------------------------------
192
}
193
194
/*****************************************************************
195
 ****************************************************************
196
 * @param        $destinataires
197
 * @param        $mail_fromname
198
 * @param        $mail_fromemail
199
 * @param        $mail_subject
200
 * @param        $mail_body
201
 * @param bool   $bEcho
202
 * @param int    $mode
203
 * @param string $sep
204
 */
205
function extcal_SendMail(
206
    $destinataires,
207
    $mail_fromname,
208
    $mail_fromemail,
209
    $mail_subject,
210
    $mail_body,
211
    $bEcho = false,
212
    $mode = 0,
0 ignored issues
show
Unused Code introduced by
The parameter $mode is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

212
    /** @scrutinizer ignore-unused */ $mode = 0,

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
213
    $sep = '|'
214
) {
215
    global $ModName, $signature, $mail_admin, $xoopsConfig, $xoopsDB, $xoopsModule;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
216
217
    //$bEcho=false;
218
    //echo "<hr>function hermesMail<hr>";
219
220
    // $destinataires = array('[email protected]','[email protected]','[email protected]');
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
221
    //$mail_fromname = "test jjd hermes";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
222
    if ('' == $mail_fromname) {
223
        $mail_fromname = $mail_fromemail;
224
    }
225
226
    //$mail_fromemail = "[email protected]";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
227
    //$mail_subject = "test hemes";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
228
    //$mail_body = getContentTestMail();
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
229
    //-----------------------------
230
    if (!is_array($destinataires)) {
231
        $destinataires = explode($sep, $destinataires);
232
    }
233
    $header = extcal_getHeader(1, $mail_fromemail);
0 ignored issues
show
Unused Code introduced by
The assignment to $header is dead and can be removed.
Loading history...
234
    //-----------------------------
235
    $myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
Bug introduced by
The type MyTextSanitizer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
236
    //$xoopsMailer = getMailer();
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
237
    $xoopsMailer = xoops_getMailer();
0 ignored issues
show
Bug introduced by
The function xoops_getMailer was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

237
    $xoopsMailer = /** @scrutinizer ignore-call */ xoops_getMailer();
Loading history...
238
239
    //$xoopsMailer->setToUsers($destinataires[$i]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
90% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
240
241
    //    while (list($k, $v) = each($destinataires)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
242
    foreach ($destinataires as $k => $v) {
243
        //for ( $i = 0, $iMax = count($destinataires); $i < $iMax; ++$i) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
52% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
244
        //$xoopsMailer->setToUsers($destinataires[$i]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
90% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
245
        $xoopsMailer->setToEmails($v);
246
        //echo "setToUsers : {$destinataires[$i]}<br>";
247
    }
248
249
    $xoopsMailer->multimailer->isHTML(true);
250
    $xoopsMailer->setFromName($myts->oopsStripSlashesGPC($mail_fromname));
251
252
    $xoopsMailer->setFromEmail($myts->oopsStripSlashesGPC($mail_fromemail));
253
254
    $xoopsMailer->setSubject($myts->oopsStripSlashesGPC($mail_subject));
255
    $xoopsMailer->setBody($myts->oopsStripSlashesGPC($mail_body));
256
    //$xoopsMailer->encodeBody($mail_body);
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
257
258
    $xoopsMailer->useMail();
259
260
    //function $xoopsMailer->sendMail($email, $subject, $body, $headers)
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
261
    $xoopsMailer->send($bEcho);
262
263
    if ($bEcho) {
264
        Extcal\Utility::extEcho($xoopsMailer->getSuccess());
265
        Extcal\Utility::extEcho($xoopsMailer->getErrors());
266
    }
267
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
268
269
     echo "<hr>mail_fromname : {$mail_fromname}<br>"
270
          ."mail_fromemail : {$mail_fromemail}<br>"
271
          ."mail_subject : {$mail_subject}<br>"
272
          ."mail_body : {$mail_body}<br><hr>";
273
    */
274
    //---------------------------
275
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
276
277
      $adresse = "[email protected]";
278
      $bolOk = mail($adresse, "test envoi mail", "test envoi envoi mail via php");
279
      $r= (($bolOk) ? " => Succés" : "Echec");
280
      echo "<hr>==> <b>{$r}</b> de l'envoi du mail a: ==> {$adresse}<br>" ;
281
    */
282
}
283
284
/****************************************************************************
285
 *
286
 ***************************************************************************
287
 * @param $mode
288
 * @param $emailSender
289
 *
290
 * @return string
291
 */
292
function extcal_getHeader($mode, $emailSender)
293
{
294
    //mode = 0 pas d'entete
295
    //mode = 1 format text
296
    //mode = 2: format html
297
298
    global $xoopsConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
299
300
    // $t = print_r($xoopsConfig, true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
301
    // echo "<pre>{$t}</pre>";
302
303
    //------------------------------------------------------
304
    $d = date('d-m-Y h:m:h', time());
0 ignored issues
show
Unused Code introduced by
The assignment to $d is dead and can be removed.
Loading history...
305
    //-----------------------------------------------------------
306
    //defini l'expediteur du mail
307
    if ('' == $emailSender) {
308
        if ('' == $xoopsConfig['adminmail']) {
309
            $emailSender = "webmaster@{$_SERVER['SERVER_NAME']}";
310
        } else {
311
            $emailSender = $xoopsConfig['adminmail'];
312
        }
313
    }
314
    //-----------------------------------------------------------
315
    $header   = [];
316
    $header[] = "From: {$emailSender}";
317
    $header[] = "Reply-To: {$emailSender}";
318
    $header[] = 'X-Mailer: PHP/' . PHP_VERSION;
319
320
    if (_EXTCAL_HEADER_HTML == $mode) {
321
        $header[] = 'MIME-Version: 1.0';
322
        $header[] = 'Content-type: text/html; charset=iso-8859-1';
323
    } else {
0 ignored issues
show
Unused Code introduced by
This else statement is empty and can be removed.

This check looks for the else branches of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These else branches can be removed.

if (rand(1, 6) > 3) {
print "Check failed";
} else {
    //print "Check succeeded";
}

could be turned into

if (rand(1, 6) > 3) {
    print "Check failed";
}

This is much more concise to read.

Loading history...
324
        //bin rien a prori
325
    }
326
    $header[] = '';
327
328
    //$sHeader = implode("\r\n", $header);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
329
    $sHeader = implode("\r\n", $header);
330
331
    return $sHeader;
332
}
333