Creating default object from empty value
Ik zie niet waaraan dit kan liggen.
Dit is lijn 49 van email.php
$this->data->from_name = JRequest::getVar('from_name',$user_name);
Dit is de volledige file :
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<?php
/********************************************************************
Product : Flexicontact
Date : 25 July 2011
Copyright : Les Arbres Design 2010-2011
Contact : http://extensions.lesarbresdesign.info
Licence : GNU General Public License
*********************************************************************/
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.model');
class FlexicontactModelEmail extends JModel
{
var $_data;
var $_app = null;
function __construct()
{
parent::__construct();
$this->_app = &JFactory::getApplication();
}
//--------------------------------------------------------------------------------
// Get post data
//
function getPostData($config_data)
{
// Get the user name and email defaults
//
switch ($config_data->autofill)
{
case 'off':
$user_name = '';
$user_email = '';
break;
case 'username':
$user =& JFactory::getUser();
$user_name = $user->username;
$user_email = $user->email;
break;
case 'name':
$user =& JFactory::getUser();
$user_name = $user->name;
$user_email = $user->email;
break;
}
$this->data->from_name = JRequest::getVar('from_name',$user_name);
$this->data->from_email = JRequest::getVar('from_email',$user_email);
$this->data->subject = JRequest::getVar('subject',$config_data->default_subject);
$this->data->copy_me = JRequest::getVar('copy_me',''); // checkbox
$this->data->agreement_check = JRequest::getVar('agreement_check',''); // checkbox
$this->data->list1 = JRequest::getVar('list1','');
$this->data->field1 = JRequest::getVar('field1','');
$this->data->field2 = JRequest::getVar('field2','');
$this->data->field3 = JRequest::getVar('field3','');
$this->data->field4 = JRequest::getVar('field4','');
$this->data->field5 = JRequest::getVar('field5','');
$this->data->area_data = JRequest::getVar('area_data','');
$this->data->magic_word = JRequest::getVar('magic_word','');
$this->data->pic_selected = JRequest::getVar('picselected','');
$this->data->pic_requested = JRequest::getVar('picrequested','');
return $this->data;
}
// -------------------------------------------------------------------------------
// Initialise the errors array
//
function init_errors()
{
$errors = array();
$errors['message_not_sent'] = '';
$errors['imageTest'] = '';
$errors['from_name'] = '';
$errors['from_email'] = '';
$errors['subject'] = '';
$errors['list'] = '';
$errors['field1'] = '';
$errors['field2'] = '';
$errors['field3'] = '';
$errors['field4'] = '';
$errors['field5'] = '';
$errors['area_data'] = '';
$errors['magic_word'] = '';
return $errors;
}
// -------------------------------------------------------------------------------
// Validate the user input
// Returns true if valid, false if not
//
function validate(&$errors, $config_data)
{
$ret = true;
// if using captcha, validate the image
if ($config_data->num_images > 0)
{
$pic_selected = substr(strtoupper($this->data->pic_selected),2); // strip off the i_
$targetText = JText::_('COM_FLEXICONTACT_IMAGE_'.$pic_selected);
if (strcmp($this->data->pic_requested,$targetText) != 0)
{
$ret = false;
$errors['imageTest'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_WRONG_PICTURE').'</span>';
}
}
// if using magic word, validate the word
if ($config_data->magic_word != '')
{
if (strcasecmp($this->data->magic_word,$config_data->magic_word) != 0)
{
$ret = false;
$errors['magic_word'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_WRONG_MAGIC_WORD').'</span>';
}
}
// validate the from name
if (empty($this->data->from_name))
{
$ret = false;
$errors['from_name'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate the from address
jimport('joomla.mail.helper');
if (!JMailHelper::isEmailAddress($this->data->from_email))
{
$ret = false;
$errors['from_email'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_BAD_EMAIL').'</span>';
}
// validate the subject
if (($config_data->show_subject) and (empty($this->data->subject)))
{
$ret = false;
$errors['subject'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate the list selection
if (($config_data->list_opt == "mandatory") and (empty($this->data->list1)))
{
$ret = false;
$errors['list'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate field1
if (($config_data->field_opt1 == "mandatory") and (empty($this->data->field1)))
{
$ret = false;
$errors['field1'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate field2
if (($config_data->field_opt2 == "mandatory") and (empty($this->data->field2)))
{
$ret = false;
$errors['field2'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate field3
if (($config_data->field_opt3 == "mandatory") and (empty($this->data->field3)))
{
$ret = false;
$errors['field3'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate field4
if (($config_data->field_opt4 == "mandatory") and (empty($this->data->field4)))
{
$ret = false;
$errors['field4'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate field5
if (($config_data->field_opt5 == "mandatory") and (empty($this->data->field5)))
{
$ret = false;
$errors['field5'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate area_data
if (($config_data->area_opt == "mandatory") and (empty($this->data->area_data)))
{
$ret = false;
$errors['area_data'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
if (!$ret)
$errors['message_not_sent'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_MESSAGE_NOT_SENT').'</span>';
return $ret;
}
//-----------------------------------------
// Get client's IP address
//
function getIPaddress()
{
if (isset($_SERVER["REMOTE_ADDR"]))
return $_SERVER["REMOTE_ADDR"];
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
return $_SERVER["HTTP_X_FORWARDED_FOR"];
if (isset($_SERVER["HTTP_CLIENT_IP"]))
return $_SERVER["HTTP_CLIENT_IP"];
return "unknown";
}
//-------------------------------------------------------------------------------
// Get client's browser (changed for 5.06)
// Returns 99 for unknown, 0 for msie, 1 for firefix, etc
//
function getBrowser(&$browser_string)
{
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$browser_string = 'Unknown';
if (strstr($u_agent, 'MSIE') && !strstr($u_agent, 'Opera'))
{
$browser_string = 'MSIE';
return 0;
}
if (strstr($u_agent, 'Firefox'))
{
$browser_string = 'Firefox';
return 1;
}
if (strstr($u_agent, 'Chrome')) // must test for Chrome before Safari!
{
$browser_string = 'Chrome';
return 3;
}
if (strstr($u_agent, 'Safari'))
{
$browser_string = 'Safari';
return 2;
}
if (strstr($u_agent, 'Opera'))
{
$browser_string = 'Opera';
return 4;
}
if (strstr($u_agent, 'Netscape'))
{
$browser_string = 'Netscape';
return 5;
}
if (strstr($u_agent, 'Konqueror'))
{
$browser_string = 'Konqueror';
return 6;
}
}
//-------------------------------------------------------------------------------
// Resolve an email variable
//
function email_resolve($config_data, $variable)
{
switch ($variable)
{
case LAFC_T_FROM_NAME:
return $this->data->from_name;
case LAFC_T_FROM_EMAIL:
return $this->data->from_email;
case LAFC_T_SUBJECT:
return $this->data->subject;
case LAFC_T_MESSAGE_PROMPT:
return $config_data->area_prompt;
case LAFC_T_MESSAGE_DATA:
return $this->data->area_data;
case LAFC_T_LIST_PROMPT:
return $config_data->list_prompt;
case LAFC_T_LIST_DATA:
return $this->data->list_choice;
case LAFC_T_FIELD1_PROMPT:
return $config_data->field_prompt1;
case LAFC_T_FIELD1_DATA:
return $this->data->field1;
case LAFC_T_FIELD2_PROMPT:
return $config_data->field_prompt2;
case LAFC_T_FIELD2_DATA:
return $this->data->field2;
case LAFC_T_FIELD3_PROMPT:
return $config_data->field_prompt3;
case LAFC_T_FIELD3_DATA:
return $this->data->field3;
case LAFC_T_FIELD4_PROMPT:
return $config_data->field_prompt4;
case LAFC_T_FIELD4_DATA:
return $this->data->field4;
case LAFC_T_FIELD5_PROMPT:
return $config_data->field_prompt5;
case LAFC_T_FIELD5_DATA:
return $this->data->field5;
case LAFC_T_BROWSER:
return $this->data->browser_string;
case LAFC_T_IP_ADDRESS:
return $this->data->ip;
default: return '';
}
}
//-------------------------------------------------------------------------------
// Merge an email template with post data
//
function email_merge($template_text, $config_data)
{
$text = $template_text;
$variable_regex = "#%V_*(.*?)%#s";
preg_match_all($variable_regex, $text, $variable_matches, PREG_SET_ORDER);
foreach ($variable_matches as $match)
{
$resolved_text = $this->email_resolve($config_data, $match[0]);
$text = str_replace($match[0], $resolved_text, $text);
}
return $text;
}
// -------------------------------------------------------------------------------
// Send the email
// Returns blank if ok, or an error message on failure
//
function sendEmail($config_data)
{
// get the user's ip address, browser, and list choice text
$this->data->ip = $this->getIPaddress();
$this->data->browser_id = $this->getBrowser($this->data->browser_string);
if ($this->data->list1 != '')
$this->data->list_choice = $config_data->list_array[$this->data->list1];
else
$this->data->list_choice = '';
// build the message to be sent to the site admin
$body = $this->email_merge($config_data->admin_template, $config_data);
jimport('joomla.mail.helper');
$clean_body = JMailHelper::cleanBody($body);
$clean_subject = JMailHelper::cleanSubject($this->data->subject);
// build the Joomla mail object
$app = &JFactory::getApplication();
$mail =& JFactory::getMailer();
if ($config_data->email_html)
$mail->IsHTML(true);
else
$clean_body = $this->html2text($clean_body);
$mail->setSender(array($app->getCfg('mailfrom'), $app->getCfg('fromname')));
$mail->addRecipient($config_data->toPrimary);
if (!empty($config_data->ccAddress))
$mail->addCC($config_data->ccAddress);
if (!empty($config_data->bccAddress))
$mail->addBCC($config_data->bccAddress);
$mail->addReplyTo(array($this->data->from_email, $this->data->from_name));
$mail->setSubject($clean_subject);
$mail->setBody($clean_body);
$ret_main = $mail->Send();
if ($ret_main === true)
$this->data->status_main = '1';
else
$this->data->status_main = $mail->ErrorInfo;
// if the user wanted a copy, send that separately
if ($this->data->copy_me == 1)
{
$body = $this->email_merge($config_data->user_template, $config_data);
$clean_body = JMailHelper::cleanBody($body);
$mail =& JFactory::getMailer();
if ($config_data->email_html)
$mail->IsHTML(true);
else
$clean_body = $this->html2text($clean_body);
$mail->setSender(array($app->getCfg('mailfrom'), $app->getCfg('fromname')));
$mail->addRecipient($this->data->from_email);
$mail->setSubject($clean_subject);
$mail->setBody($clean_body);
$ret_copy = $mail->Send();
if ($ret_copy === true)
$this->data->status_copy = '1';
else
$this->data->status_copy = $mail->ErrorInfo;
}
else
$this->data->status_copy = '0'; // copy not requested
return $this->data->status_main; // both statuses are logged, but the main status decides what happens next
}
// -------------------------------------------------------------------------------
// Found at http://sb2.info/php-script-html-plain-text-convert/
//
function html2text($html)
{
$tags = array (
0 => '~<h[123][^>]+>~si',
1 => '~<h[456][^>]+>~si',
2 => '~<table[^>]+>~si',
3 => '~<tr[^>]+>~si',
4 => '~<li[^>]+>~si',
5 => '~<br[^>]+>~si',
6 => '~<p[^>]+>~si',
7 => '~<div[^>]+>~si',
);
$html = preg_replace($tags,"\n",$html);
$html = preg_replace('~</t(d|h)>\s*<t(d|h)[^>]+>~si',' - ',$html);
$html = preg_replace('~<[^>]+>~s','',$html);
// reducing spaces
$html = preg_replace('~ +~s',' ',$html);
$html = preg_replace('~^\s+~m','',$html);
$html = preg_replace('~\s+$~m','',$html);
// reducing newlines
$html = preg_replace('~\n+~s',"\n",$html);
return $html;
}
}
/********************************************************************
Product : Flexicontact
Date : 25 July 2011
Copyright : Les Arbres Design 2010-2011
Contact : http://extensions.lesarbresdesign.info
Licence : GNU General Public License
*********************************************************************/
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.model');
class FlexicontactModelEmail extends JModel
{
var $_data;
var $_app = null;
function __construct()
{
parent::__construct();
$this->_app = &JFactory::getApplication();
}
//--------------------------------------------------------------------------------
// Get post data
//
function getPostData($config_data)
{
// Get the user name and email defaults
//
switch ($config_data->autofill)
{
case 'off':
$user_name = '';
$user_email = '';
break;
case 'username':
$user =& JFactory::getUser();
$user_name = $user->username;
$user_email = $user->email;
break;
case 'name':
$user =& JFactory::getUser();
$user_name = $user->name;
$user_email = $user->email;
break;
}
$this->data->from_name = JRequest::getVar('from_name',$user_name);
$this->data->from_email = JRequest::getVar('from_email',$user_email);
$this->data->subject = JRequest::getVar('subject',$config_data->default_subject);
$this->data->copy_me = JRequest::getVar('copy_me',''); // checkbox
$this->data->agreement_check = JRequest::getVar('agreement_check',''); // checkbox
$this->data->list1 = JRequest::getVar('list1','');
$this->data->field1 = JRequest::getVar('field1','');
$this->data->field2 = JRequest::getVar('field2','');
$this->data->field3 = JRequest::getVar('field3','');
$this->data->field4 = JRequest::getVar('field4','');
$this->data->field5 = JRequest::getVar('field5','');
$this->data->area_data = JRequest::getVar('area_data','');
$this->data->magic_word = JRequest::getVar('magic_word','');
$this->data->pic_selected = JRequest::getVar('picselected','');
$this->data->pic_requested = JRequest::getVar('picrequested','');
return $this->data;
}
// -------------------------------------------------------------------------------
// Initialise the errors array
//
function init_errors()
{
$errors = array();
$errors['message_not_sent'] = '';
$errors['imageTest'] = '';
$errors['from_name'] = '';
$errors['from_email'] = '';
$errors['subject'] = '';
$errors['list'] = '';
$errors['field1'] = '';
$errors['field2'] = '';
$errors['field3'] = '';
$errors['field4'] = '';
$errors['field5'] = '';
$errors['area_data'] = '';
$errors['magic_word'] = '';
return $errors;
}
// -------------------------------------------------------------------------------
// Validate the user input
// Returns true if valid, false if not
//
function validate(&$errors, $config_data)
{
$ret = true;
// if using captcha, validate the image
if ($config_data->num_images > 0)
{
$pic_selected = substr(strtoupper($this->data->pic_selected),2); // strip off the i_
$targetText = JText::_('COM_FLEXICONTACT_IMAGE_'.$pic_selected);
if (strcmp($this->data->pic_requested,$targetText) != 0)
{
$ret = false;
$errors['imageTest'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_WRONG_PICTURE').'</span>';
}
}
// if using magic word, validate the word
if ($config_data->magic_word != '')
{
if (strcasecmp($this->data->magic_word,$config_data->magic_word) != 0)
{
$ret = false;
$errors['magic_word'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_WRONG_MAGIC_WORD').'</span>';
}
}
// validate the from name
if (empty($this->data->from_name))
{
$ret = false;
$errors['from_name'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate the from address
jimport('joomla.mail.helper');
if (!JMailHelper::isEmailAddress($this->data->from_email))
{
$ret = false;
$errors['from_email'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_BAD_EMAIL').'</span>';
}
// validate the subject
if (($config_data->show_subject) and (empty($this->data->subject)))
{
$ret = false;
$errors['subject'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate the list selection
if (($config_data->list_opt == "mandatory") and (empty($this->data->list1)))
{
$ret = false;
$errors['list'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate field1
if (($config_data->field_opt1 == "mandatory") and (empty($this->data->field1)))
{
$ret = false;
$errors['field1'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate field2
if (($config_data->field_opt2 == "mandatory") and (empty($this->data->field2)))
{
$ret = false;
$errors['field2'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate field3
if (($config_data->field_opt3 == "mandatory") and (empty($this->data->field3)))
{
$ret = false;
$errors['field3'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate field4
if (($config_data->field_opt4 == "mandatory") and (empty($this->data->field4)))
{
$ret = false;
$errors['field4'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate field5
if (($config_data->field_opt5 == "mandatory") and (empty($this->data->field5)))
{
$ret = false;
$errors['field5'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
// validate area_data
if (($config_data->area_opt == "mandatory") and (empty($this->data->area_data)))
{
$ret = false;
$errors['area_data'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_REQUIRED').'</span>';
}
if (!$ret)
$errors['message_not_sent'] = '<span class="fc_error">'.JText::_('COM_FLEXICONTACT_MESSAGE_NOT_SENT').'</span>';
return $ret;
}
//-----------------------------------------
// Get client's IP address
//
function getIPaddress()
{
if (isset($_SERVER["REMOTE_ADDR"]))
return $_SERVER["REMOTE_ADDR"];
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
return $_SERVER["HTTP_X_FORWARDED_FOR"];
if (isset($_SERVER["HTTP_CLIENT_IP"]))
return $_SERVER["HTTP_CLIENT_IP"];
return "unknown";
}
//-------------------------------------------------------------------------------
// Get client's browser (changed for 5.06)
// Returns 99 for unknown, 0 for msie, 1 for firefix, etc
//
function getBrowser(&$browser_string)
{
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$browser_string = 'Unknown';
if (strstr($u_agent, 'MSIE') && !strstr($u_agent, 'Opera'))
{
$browser_string = 'MSIE';
return 0;
}
if (strstr($u_agent, 'Firefox'))
{
$browser_string = 'Firefox';
return 1;
}
if (strstr($u_agent, 'Chrome')) // must test for Chrome before Safari!
{
$browser_string = 'Chrome';
return 3;
}
if (strstr($u_agent, 'Safari'))
{
$browser_string = 'Safari';
return 2;
}
if (strstr($u_agent, 'Opera'))
{
$browser_string = 'Opera';
return 4;
}
if (strstr($u_agent, 'Netscape'))
{
$browser_string = 'Netscape';
return 5;
}
if (strstr($u_agent, 'Konqueror'))
{
$browser_string = 'Konqueror';
return 6;
}
}
//-------------------------------------------------------------------------------
// Resolve an email variable
//
function email_resolve($config_data, $variable)
{
switch ($variable)
{
case LAFC_T_FROM_NAME:
return $this->data->from_name;
case LAFC_T_FROM_EMAIL:
return $this->data->from_email;
case LAFC_T_SUBJECT:
return $this->data->subject;
case LAFC_T_MESSAGE_PROMPT:
return $config_data->area_prompt;
case LAFC_T_MESSAGE_DATA:
return $this->data->area_data;
case LAFC_T_LIST_PROMPT:
return $config_data->list_prompt;
case LAFC_T_LIST_DATA:
return $this->data->list_choice;
case LAFC_T_FIELD1_PROMPT:
return $config_data->field_prompt1;
case LAFC_T_FIELD1_DATA:
return $this->data->field1;
case LAFC_T_FIELD2_PROMPT:
return $config_data->field_prompt2;
case LAFC_T_FIELD2_DATA:
return $this->data->field2;
case LAFC_T_FIELD3_PROMPT:
return $config_data->field_prompt3;
case LAFC_T_FIELD3_DATA:
return $this->data->field3;
case LAFC_T_FIELD4_PROMPT:
return $config_data->field_prompt4;
case LAFC_T_FIELD4_DATA:
return $this->data->field4;
case LAFC_T_FIELD5_PROMPT:
return $config_data->field_prompt5;
case LAFC_T_FIELD5_DATA:
return $this->data->field5;
case LAFC_T_BROWSER:
return $this->data->browser_string;
case LAFC_T_IP_ADDRESS:
return $this->data->ip;
default: return '';
}
}
//-------------------------------------------------------------------------------
// Merge an email template with post data
//
function email_merge($template_text, $config_data)
{
$text = $template_text;
$variable_regex = "#%V_*(.*?)%#s";
preg_match_all($variable_regex, $text, $variable_matches, PREG_SET_ORDER);
foreach ($variable_matches as $match)
{
$resolved_text = $this->email_resolve($config_data, $match[0]);
$text = str_replace($match[0], $resolved_text, $text);
}
return $text;
}
// -------------------------------------------------------------------------------
// Send the email
// Returns blank if ok, or an error message on failure
//
function sendEmail($config_data)
{
// get the user's ip address, browser, and list choice text
$this->data->ip = $this->getIPaddress();
$this->data->browser_id = $this->getBrowser($this->data->browser_string);
if ($this->data->list1 != '')
$this->data->list_choice = $config_data->list_array[$this->data->list1];
else
$this->data->list_choice = '';
// build the message to be sent to the site admin
$body = $this->email_merge($config_data->admin_template, $config_data);
jimport('joomla.mail.helper');
$clean_body = JMailHelper::cleanBody($body);
$clean_subject = JMailHelper::cleanSubject($this->data->subject);
// build the Joomla mail object
$app = &JFactory::getApplication();
$mail =& JFactory::getMailer();
if ($config_data->email_html)
$mail->IsHTML(true);
else
$clean_body = $this->html2text($clean_body);
$mail->setSender(array($app->getCfg('mailfrom'), $app->getCfg('fromname')));
$mail->addRecipient($config_data->toPrimary);
if (!empty($config_data->ccAddress))
$mail->addCC($config_data->ccAddress);
if (!empty($config_data->bccAddress))
$mail->addBCC($config_data->bccAddress);
$mail->addReplyTo(array($this->data->from_email, $this->data->from_name));
$mail->setSubject($clean_subject);
$mail->setBody($clean_body);
$ret_main = $mail->Send();
if ($ret_main === true)
$this->data->status_main = '1';
else
$this->data->status_main = $mail->ErrorInfo;
// if the user wanted a copy, send that separately
if ($this->data->copy_me == 1)
{
$body = $this->email_merge($config_data->user_template, $config_data);
$clean_body = JMailHelper::cleanBody($body);
$mail =& JFactory::getMailer();
if ($config_data->email_html)
$mail->IsHTML(true);
else
$clean_body = $this->html2text($clean_body);
$mail->setSender(array($app->getCfg('mailfrom'), $app->getCfg('fromname')));
$mail->addRecipient($this->data->from_email);
$mail->setSubject($clean_subject);
$mail->setBody($clean_body);
$ret_copy = $mail->Send();
if ($ret_copy === true)
$this->data->status_copy = '1';
else
$this->data->status_copy = $mail->ErrorInfo;
}
else
$this->data->status_copy = '0'; // copy not requested
return $this->data->status_main; // both statuses are logged, but the main status decides what happens next
}
// -------------------------------------------------------------------------------
// Found at http://sb2.info/php-script-html-plain-text-convert/
//
function html2text($html)
{
$tags = array (
0 => '~<h[123][^>]+>~si',
1 => '~<h[456][^>]+>~si',
2 => '~<table[^>]+>~si',
3 => '~<tr[^>]+>~si',
4 => '~<li[^>]+>~si',
5 => '~<br[^>]+>~si',
6 => '~<p[^>]+>~si',
7 => '~<div[^>]+>~si',
);
$html = preg_replace($tags,"\n",$html);
$html = preg_replace('~</t(d|h)>\s*<t(d|h)[^>]+>~si',' - ',$html);
$html = preg_replace('~<[^>]+>~s','',$html);
// reducing spaces
$html = preg_replace('~ +~s',' ',$html);
$html = preg_replace('~^\s+~m','',$html);
$html = preg_replace('~\s+$~m','',$html);
// reducing newlines
$html = preg_replace('~\n+~s',"\n",$html);
return $html;
}
}
Mogelijk biedt het toevoegen van het volgende voor regel 31 soelaas:
Wat natuurlijk ook interessant is is uitvinden waarom $user_name niet fatsoenlijk (meer) kan worden geïnitialiseerd, dit is een indicatie dat er mogelijk meer aan de hand is...
En dit zul je mogelijk ook voor andere variabelen naast $user_name moeten doen, maar wat wellicht beter is is om te kijken of deze module inmiddels een update heeft gehad. Het contactformulier stamt uit 2011. PHP en Joomla hebben ondertussen niet stil gezeten. En je provider waarschijnlijk ook niet. Mogelijk is dit formulier simpelweg niet meer compatibel met de huidige PHP-versie.
Intussen geupdate naar joomla 3.8 en daar eens geprobeerd met een gewoon contactformulier.
Hier lukt het ook niet om een mailtje te zenden via die form.
Krijg melding " kan mailfunctie niet opstarten"
Wat kan hiervan de oorzaak zijn ?
Wat @Rob zegt helpt je wellicht verder, maar het blijft modderen in verouderde code. Tijd voor een update/upgrade.
Zie onderstaande :
Joomla admin wachtwoord vergeten
Wanneer u het ‘admin’ wachtwoord van een Joomla website vergeten bent, kunt u niet meer inloggen in het Joomla backend gedeelte als Administrator.
Een oplossing kan zijn het wachtwoord direct in de MySql database te wijzigen.
Hiervoor heeft u wel toegang tot de database nodig via een programma als PhpMyAdmin.
Log in via PhpMyadmin met de database gebruikersnaam en het wachtwoord van de database gebruiker.
Selecteer aan de linkerbovenkant in PhpMyAdmin de database die gebruikt wordt voor de Joomla
installatie.
Klik aan de linkerkant op de table ‘jos_users’.
Klik op ‘Browse’.
Klik op het edit symbool (potloot) dat aan de linkerkant staat van de gebruiker met de username ‘admin’.
Wijzig de waarde van het veld ‘Password’ in: 21232f297a57a5a743894a0e4a801fc3 .
Klik op de knop ‘Go’.
Sluit PhpMyAdmin
Het admin wachtwoord is nu veranderd in: admin .
Wijzig dit wachtwoord direct na het inloggen in het Joomla backend gedeelte bij ‘User management’.
Ik vraag me af of Joomla deze password-hasing nog wel ondersteund. In zulke gevallen zou ik altijd een backup maken.
Gewijzigd op 18/04/2018 18:37:44 door - Ariën -
Het is vrij belangrijk dat de versie enigszins bij de tijd is, of dat je in ieder geval weet welke mogelijke veiligheids-issues je huidige (en volgende) versie(s) heeft.
En een backup maken kan i.i.g. nooit kwaad, al was het enkel van de reeds aanwezige password-hash.
Misschien is dat wel de reden dat je niet kan inloggen: Je old-skoel hash komt niet overeen met een andere encryptie die Joomla tegenwoordig wel gebruikt.
En als de instructies wel werken zou mij dat verontrusten. Ik meen mij te herinneren dat toen ik een keer een password-reset moest uitvoeren in Joomla (en dit is alweer jaren terug) dat het toen al geavanceerder was dan dat. Maar zo te zien is je Joomla versie vrij nieuw (3.8.7).
Wat je aan administratie dient te wijzigen om weer in te kunnen loggen hangt waarschijnlijk af van de versie die Joomla gebruikt, want die zal bepalen hoe wachtwoorden beveiligd zijn.
EDIT: deze instructies klinken wat actueler. Raadpleeg bij voorkeur altijd officiële / actuele documentatie.
Gewijzigd op 19/04/2018 09:30:50 door Thomas van den Heuvel
Heb ze uitgevoerd als beschreven en kan nu weer op mijn backend.
Meteen ook paswoord terug aangepast.
Dit even ter info !!
Vanavond zoek ik verder waarom het contactformulier niet werkt !!
mijn site : kwbvlamertinge.be
- Ariën - op 18/04/2018 18:08:50:
Kan je wel normaal mailen met PHP via de mail() functie?
Ik vraag me af of Joomla deze password-hasing nog wel ondersteund. In zulke gevallen zou ik altijd een backup maken.
Ik vraag me af of Joomla deze password-hasing nog wel ondersteund. In zulke gevallen zou ik altijd een backup maken.
Als ik de mail in joomla wil testen krijg ik telkens een foutmelding :
PHP : Kan mailfunctie niet opstarten
Sendmail : Kan niet uitvoeren: /usr/sbin/sendmail
SMTP : SMTP verbinding mislukt https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Ik zit bij one.com
https://help.one.com/hc/nl/articles/115005594345-Kan-ik-e-mails-verzenden-vanaf-mijn-website-
Zo te zien zou je gewoon sendmail en dus php mail() moeten kunnen gebruiken.
Wat gebeurt er als je een test mail verstuurd?
Vervang [email protected] voor je eigen prive mailadres.
Zo te zien zou je gewoon sendmail en dus php mail() moeten kunnen gebruiken.
Wat gebeurt er als je een test mail verstuurd?
Code (php)
Vervang [email protected] voor je eigen prive mailadres.
Gewijzigd op 20/04/2018 17:29:33 door Frank Nietbelangrijk
Vorig jaar werd onze site gehacked en werd er spam verspreid via onze site.
Daardoor had one.com onze mail service geblokkeerd.
Na de update van joomla en alle componenten heb ik gevraagd om deze weer vrij te geven.
Nu werkt alles weer.
Sorry voor de overlast
Dus het echte probleem is de beveiliging van de website?
>> het probleem is opgelost
Maar is de website nu weer enigszins waterdicht?
Het is Joomla, ik zou dus verwachten van niet.