-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.php
executable file
·86 lines (71 loc) · 2.06 KB
/
helper.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
<?php
/*
# mod_sp_quickcontact - Ajax based quick contact Module by JoomShaper.com
# -----------------------------------------------------------------------
# Author JoomShaper http://www.joomshaper.com
# Copyright (C) 2010 - 2014 JoomShaper.com. All Rights Reserved.
# License - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.joomshaper.com
*/
class modSpQuickcontactHelper
{
public static function getAjax()
{
jimport('joomla.application.module.helper');
$input = JFactory::getApplication()->input;
$module = JModuleHelper::getModule('sp_quickcontact');
$params = new JRegistry();
$params->loadString($module->params);
$mail = JFactory::getMailer();
$success = $params->get('success');
$failed = $params->get('failed');
$recipient = $params->get('email');
$failed_captcha = $params->get('failed_captcha');
$formcaptcha = $params->get('formcaptcha', 1);
$captcha_question = $params->get('captcha_question');
$captcha_answer = $params->get('captcha_answer');
//inputs
$inputs = $input->get('data', array(), 'ARRAY');
foreach ($inputs as $input) {
if( $input['name'] == 'email' )
{
$email = $input['value'];
}
if( $input['name'] == 'name' )
{
$name = $input['value'];
}
if( $input['name'] == 'subject' )
{
$subject = $input['value'];
}
if( $input['name'] == 'message' )
{
$message = nl2br( $input['value'] );
}
if($formcaptcha) {
if( $input['name'] == 'sccaptcha' )
{
$sccaptcha = $input['value'];
}
}
}
if($formcaptcha) {
if ($sccaptcha != $captcha_answer) {
return '<p class="sp_qc_warn">' . $failed_captcha . '</p>';
}
}
$sender = array($email, $name);
$mail->setSender($sender);
$mail->addRecipient($recipient);
$mail->setSubject($subject);
$mail->isHTML(true);
$mail->Encoding = 'base64';
$mail->setBody($message);
if ($mail->Send()) {
return '<p class="sp_qc_success">' . $success . '</p>';
} else {
return '<p class="sp_qc_warn">' . $failed . '</p>';
}
}
}