Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
retypos-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
retypos-server
Commits
3f09f843
Commit
3f09f843
authored
Apr 19, 2019
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server.php: divide accept typo request and send emails
parent
92494a78
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
45 deletions
+30
-45
server.php
server.php
+30
-45
No files found.
server.php
View file @
3f09f843
...
...
@@ -63,7 +63,7 @@ if (!validate()) {
return
false
;
}
//TODO - работу со старыми бра
зу
ерами будем подерживать или нет? Если будем, то надо доработать работу на стороне сервера (закрытие окна)
//TODO - работу со старыми бра
уз
ерами будем подерживать или нет? Если будем, то надо доработать работу на стороне сервера (закрытие окна)
$userdata
[
'old_browser'
]
=
getRequest
(
'old_browser'
,
0
);
$userdata
[
'comment'
]
=
htmlspecialchars
(
rawurldecode
(
getRequest
(
'comment'
,
''
)));
$userdata
[
'corrected'
]
=
htmlspecialchars
(
rawurldecode
(
getRequest
(
'corrected'
,
''
)));
...
...
@@ -85,77 +85,60 @@ if (!isset($mas_url['host'])) {
* - отправка писем
* ******************************** */
/* Достаем номер сайта и email-ы пользователей */
try
{
/*
$query_emails = "SELECT r.id_site AS id_site,
u.email AS email
FROM users AS u, responsible AS r
WHERE r.id IN (
SELECT r.id
FROM responsible AS r
JOIN sites AS s
WHERE s.site REGEXP ?
AND r.id_site = s.id
AND r.status = '1')
AND r.id_user = u.id";
$id_site
=
get_site_id
(
$DBH
,
$userdata
[
'url'
]);
}
catch
(
PDOException
$e
)
{
error_log
(
$e
);
echoJsonData
(
array
(
'success'
=>
'false'
,
'message'
=>
$_language
[
$code_language
][
"error_support_site"
]));
return
;
}
$STH = $DBH->prepare($query_emails);
try
{
$data
=
array
(
null
,
$id_site
,
$userdata
[
'url'
],
$userdata
[
'text'
],
$userdata
[
'context'
],
$userdata
[
'corrected'
],
$userdata
[
'comment'
],
0
,
getIp
());
$STH
=
$DBH
->
prepare
(
"INSERT INTO messages (id, site_id, link, text, context, corrected, comment, date, status, user_ip) VALUES (?, ?, ?, ?, ?, ?, ?, DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s'), ?, ?)"
);
$result
=
$STH
->
execute
(
$data
);
// 08.06.17: supports every protocol
// ^(https?://)*(www.)*etersoft.com/?$
$STH->execute(array("^(https?://)*(www.)*" . $mas_url["host"] . "/?$"));
*/
$id_site
=
get_site_id
(
$DBH
,
$userdata
[
'url'
]);
if
(
$result
!==
true
)
{
// TODO: повторение с catch ниже
$errorInfo
=
$STH
->
errorInfo
();
error_log
(
"Возникла ошибка при добавлении опечатки в базу данных. Код SQLSTATE:
{
$errorInfo
[
0
]
}
.
Код ошибки драйвера:
{
$errorInfo
[
1
]
}
. Текст ошибки:
{
$errorInfo
[
2
]
}
"
);
echoJsonData
(
array
(
'success'
=>
'false'
,
'message'
=>
$_language
[
$code_language
][
'error_database'
]));
return
;
}
}
catch
(
PDOException
$e
)
{
echoJsonData
(
array
(
'success'
=>
'false'
,
'message'
=>
$_language
[
$code_language
][
'error_database'
]));
return
;
}
try
{
$email_users
=
array
();
$query_emails
=
"SELECT r.id_site AS id_site,
u.email AS email
FROM users AS u
INNER JOIN responsible AS r ON r.id_user = u.id
WHERE r.id_site =
$id_site
AND r.status = '1'"
;
//error_log($query_emails);
$STH
=
$DBH
->
prepare
(
$query_emails
);
$STH
->
execute
(
array
(
$id_site
));
if
(
$STH
->
rowCount
()
>
0
)
{
$email_users
=
array
();
while
(
$row
=
$STH
->
fetch
(
PDO
::
FETCH_ASSOC
))
{
$email_users
[]
=
array
(
'id_site'
=>
$row
[
'id_site'
],
'email'
=>
$row
[
'email'
]
);
}
}
else
{
$email_users
=
false
;
}
}
catch
(
PDOException
$e
)
{
error_log
(
$e
);
echoJsonData
(
array
(
'success'
=>
'false'
,
'message'
=>
$_language
[
$code_language
][
"error_support_site"
]));
return
;
}
/* Если активных пользователей за сайт нет, то возвращаем сообщение об ошибке */
if
(
$email_users
)
{
try
{
$data
=
array
(
null
,
$email_users
[
0
][
'id_site'
],
$userdata
[
'url'
],
$userdata
[
'text'
],
$userdata
[
'context'
],
$userdata
[
'corrected'
],
$userdata
[
'comment'
],
0
,
getIp
());
$STH
=
$DBH
->
prepare
(
"INSERT INTO messages (id, site_id, link, text, context, corrected, comment, date, status, user_ip) VALUES (?, ?, ?, ?, ?, ?, ?, DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s'), ?, ?)"
);
$result
=
$STH
->
execute
(
$data
);
if
(
$result
!==
true
)
{
$errorInfo
=
$STH
->
errorInfo
();
error_log
(
"Возникла ошибка при добавлении опечатки в базу данных. Код SQLSTATE:
{
$errorInfo
[
0
]
}
.
Код ошибки драйвера:
{
$errorInfo
[
1
]
}
. Текст ошибки:
{
$errorInfo
[
2
]
}
"
);
echoJsonData
(
array
(
'success'
=>
'false'
,
'message'
=>
$_language
[
$code_language
][
'error_database'
]));
return
;
}
}
catch
(
PDOException
$e
)
{
echoJsonData
(
array
(
'success'
=>
'false'
,
'message'
=>
$_language
[
$code_language
][
'error_database'
]));
return
;
}
$controlPanelUrl
=
getControlPanelUrl
();
$message_email
=
""
;
...
...
@@ -181,8 +164,10 @@ if ($email_users) {
echoJsonData
(
array
(
'success'
=>
'false'
,
'message'
=>
$_language
[
$code_language
][
'mail_error'
]));
return
;
}
/*
} else {
error_log("No active users for {$mas_url["scheme"]}://{$mas_url["host"]}");
echoJsonData(array('success' => 'false', 'message' => $_language[$code_language]['error_support_site']));
return;
*/
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment