forked from clefarray/cfFormMailer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnippet.cfFormMailer.php
89 lines (80 loc) · 2.08 KB
/
snippet.cfFormMailer.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
<?php
/**
* cfFormMailer
*
* @author Clefarray Factory
* @link http://www.clefarray-web.net/
* @version 1.3
*
* Documentation: http://www.clefarray-web.net/blog/manual/cfFormMailer_manual.html
* LICENSE: GNU General Public License (GPL) (http://www.gnu.org/copyleft/gpl.html)
*/
if ($modx->isBackend()) {
return '';
}
$snippet_path = $modx->config['base_path'] . "assets/snippets/cfFormMailer/";
include_once $snippet_path . "class.cfFormMailer.inc.php";
$mf = new Class_cfFormMailer($modx);
/**
* read config
*/
$lang = (isset($language)) ? $language : strtolower($modx->config['manager_language']);
if(strpos($lang,'euc-jp')===false) $lang = 'utf8';
else $lang = 'euc-jp';
define(CHARSET, $lang);
if (!isset($config)) {
return '<strong>ERROR!:</strong> `config`パラメータは必須です';
}
if (($result = $mf->parseConfig($config)) !== true) {
return '<strong>ERROR!:</strong> ' . $result;
}
/**
* read validate & filter methods
*/
if (file_exists($snippet_path . 'additionalMethods.inc.php')) {
include_once $snippet_path . 'additionalMethods.inc.php';
}
/**
* Action
*/
switch($_POST['_mode']) {
case "conf":
$pageType = ($mf->validate()) ? 'conf' : 'error';
break;
case "send":
if ($_POST['return']) {
if (!$mf->validate()) {
return $mf->raiseError('未知のエラーです');
}
$pageType = 'return';
break;
}
if ($mf->validate()) {
if ($mf->isMultiple()) {
return $mf->raiseError('すでに送信しています');
} elseif (!$mf->isValidToken()) {
return $mf->raiseError('画面遷移が正常に行われませんでした');
} elseif (!$mf->sendMail()) {
return $mf->raiseError($mf->getError());
} else {
$mf->storeDataInSession();
$mf->storeDB();
$pageType = "comp";
}
} else {
$pageType = 'error';
}
break;
default:
$pageType = 'input';
break;
}
/**
* Display page
*/
if ($html = $mf->createPageHtml($pageType)) {
return $html;
} else {
return $mf->raiseError($mf->getError());
}
?>