Skip to content

Commit 3c07208

Browse files
author
mr.n1cky
committed
Initial
1 parent d76c216 commit 3c07208

File tree

185 files changed

+26200
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+26200
-0
lines changed

Diff for: backend/composer.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "itform/form",
3+
"description": "description_text",
4+
"minimum-stability": "alpha",
5+
"license": "proprietary",
6+
"authors": [
7+
{
8+
"name": "author's name",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"require": {
13+
"phpmailer/phpmailer": "v5.2.15"
14+
}
15+
}

Diff for: backend/composer.lock

+79
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: backend/mail.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
require_once 'src/init.php';
3+
if (OPTIONS_REQUEST)
4+
exit(0);
5+
6+
require_once 'settings.php';
7+
require_once 'src/mail.classes.php';
8+
9+
class FnCalledAuthSettings implements AuthSettings
10+
{
11+
/**
12+
* @param $mail PHPMailer
13+
*/
14+
function setUpAuth($mail)
15+
{
16+
if (function_exists('IsSetAuth'))
17+
ItSetAuth($mail);
18+
else
19+
$mail->isMail();
20+
}
21+
}
22+
23+
$authSettings = new FnCalledAuthSettings();
24+
$mailFactory = new MailFactory($authSettings);
25+
26+
#$json = json_decode(file_get_contents('php://input'));
27+
#ItSetUpMailData($json);
28+
29+
$mail = $mailFactory->createMail();
30+
ItSetUpMail($mail);
31+
ItSetUpBody($_POST, $mail);
32+
ItSetUpAttachments($_FILES, $mail);
33+
34+
echo ($mail->send()) ? 'sent' : 'error';
35+
36+
if (ITFORM_DEBUG)
37+
{
38+
echo "<pre>";
39+
var_dump($mail);
40+
echo "</pre>";
41+
}

Diff for: backend/private.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
define("ITFORM_DEBUG", false);
3+
define("ITFORM_ATTACH_SIZE", 10000000); // 10Mb
4+
5+
define("ITFORM_LOGIN", '[email protected]');
6+
define("ITFORM_PASSWORD", 'a8f15a4ff');
7+
8+
//Удалите старый файл если изменили логин и пароль
9+
//Измените имя файла вкотором храниться токен!!!
10+
define("ITFORM_TOKEN_FILE", 'youbetterkeepitisdfsdfsdf535nsercet');
11+
12+
if (ITFORM_DEBUG)
13+
error_reporting(E_ALL);
14+
15+
//Закоментируйте что бы спользовать mail();
16+
function ItSetAuth($mail)
17+
{
18+
$mail->isMail();
19+
}

Diff for: backend/proxy.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
require_once 'src/init.php';
3+
if (OPTIONS_REQUEST) {
4+
exit(0);
5+
}
6+
7+
require_once 'settings.php';
8+
require_once 'src/proxy.classes.php';
9+
10+
try {
11+
$credentials = new ItLogin(ITFORM_LOGIN, ITFORM_PASSWORD);
12+
$cache = new ItTokenFileCache($credentials, ITFORM_TOKEN_FILE);
13+
$proxy = new ItProxy($cache);
14+
echo $proxy->forward(ItRequest::fromCurrentRequest());
15+
} catch (Throwable $e) {
16+
echo json_encode(array("error" => $e->getMessage()));
17+
}

Diff for: backend/settings.php

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
require_once ('private.php');
3+
4+
function ItSetUpMailData($data)
5+
{
6+
// ?
7+
}
8+
9+
function ItSetUpMail($mail)
10+
{
11+
$mail->setFrom('[email protected]');
12+
$mail->CharSet = 'UTF-8';
13+
}
14+
15+
function ItSetUpBody($data, $mail)
16+
{
17+
if (empty($data))
18+
return false;
19+
20+
// $address = '[email protected]';
21+
$address = '[email protected]';
22+
$subject = 'Заявка на страхование с сайта';
23+
24+
$mail->addAddress($address);
25+
$mail->AddCC($addressTest);
26+
$mail->Body = $data['message'];
27+
28+
return true;
29+
}
30+
31+
function ItSetUpAttachments($files, $mail)
32+
{
33+
if (empty($files))
34+
return false;
35+
36+
$mimeTypes = array(
37+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", // docx
38+
"application/pdf", // pdf
39+
"application/msword", // doc
40+
"rtf;application/rtf", // rtf
41+
"rtf;application/x-rtf",
42+
"rtf;text/richtext",
43+
"application/vnd.oasis.opendocument.text", // odt
44+
"image/bmp", // bmp
45+
"image/png", // png
46+
"image/jpg", // jpg
47+
"image/jpeg", // jpeg
48+
"image/gif" // gif
49+
);
50+
51+
$count = 0;
52+
foreach ($files as $file)
53+
{
54+
$name = 'file_' . $count;
55+
if (!empty($files[$name]['tmp_name']) && is_uploaded_file($files[$name]['tmp_name']))
56+
{
57+
if (!in_array($files[$name]['type'], $mimeTypes))
58+
continue;
59+
60+
if (intval($files[$name]['size']) > ITFORM_ATTACH_SIZE)
61+
continue;
62+
63+
$mail->AddAttachment($files[$name]['tmp_name'],
64+
$files[$name]['name']);
65+
}
66+
67+
$count++;
68+
}
69+
70+
return true;
71+
}

0 commit comments

Comments
 (0)