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
775b470e
Commit
775b470e
authored
Jun 05, 2017
by
Георгий Попов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
send curl request to the site with typo
parent
1edce730
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
2 deletions
+57
-2
language.php
language.php
+1
-1
Typo.php
new_cp/application/models/Typo.php
+55
-0
typos.php
new_cp/application/views/users/typos.php
+1
-1
No files found.
language.php
View file @
775b470e
...
@@ -23,7 +23,7 @@ $_language['ru']['mail_error'] = "Ошибка при отправлении п
...
@@ -23,7 +23,7 @@ $_language['ru']['mail_error'] = "Ошибка при отправлении п
$_language
[
'ru'
][
'mail_site'
]
=
"Сайт:"
;
$_language
[
'ru'
][
'mail_site'
]
=
"Сайт:"
;
$_language
[
'ru'
][
'mail_url'
]
=
"Ссылка:"
;
$_language
[
'ru'
][
'mail_url'
]
=
"Ссылка:"
;
$_language
[
'ru'
][
'mail_click_url'
]
=
"нажмите"
;
$_language
[
'ru'
][
'mail_click_url'
]
=
"нажмите"
;
$_language
[
'ru'
][
'mail_comment'
]
=
"
Комментарий
:"
;
$_language
[
'ru'
][
'mail_comment'
]
=
"
Предложенное исправление
:"
;
$_language
[
'ru'
][
'mail_text'
]
=
"Текст с опечаткой:"
;
$_language
[
'ru'
][
'mail_text'
]
=
"Текст с опечаткой:"
;
?>
?>
new_cp/application/models/Typo.php
View file @
775b470e
...
@@ -208,6 +208,10 @@ class Typo extends CI_Model {
...
@@ -208,6 +208,10 @@ class Typo extends CI_Model {
function
editMessage
(
$data
)
{
function
editMessage
(
$data
)
{
if
(
$this
->
getMessageRights
(
$data
))
{
if
(
$this
->
getMessageRights
(
$data
))
{
if
(
$data
[
'status'
]
)
{
correctTypo
(
$data
[
"id_message"
]);
}
$this
->
db
->
set
(
"status"
,
$data
[
'status'
]);
$this
->
db
->
set
(
"status"
,
$data
[
'status'
]);
$this
->
db
->
where
(
"id"
,
$data
[
'id_message'
]);
$this
->
db
->
where
(
"id"
,
$data
[
'id_message'
]);
$this
->
db
->
where
(
"site_id"
,
$data
[
'id_site'
]);
$this
->
db
->
where
(
"site_id"
,
$data
[
'id_site'
]);
...
@@ -252,7 +256,57 @@ class Typo extends CI_Model {
...
@@ -252,7 +256,57 @@ class Typo extends CI_Model {
return
false
;
return
false
;
}
}
}
}
/**
* Отправляет запрос на исправление ошибки на сервер
*
* @param type $message_id
* Номер сообщения в бд
*/
function
correctTypo
(
$message_id
)
{
/* TODO: брать из конфига */
$correctPath
=
"correctTypo"
;
$authToken
=
"fksdjsdlfks"
;
/* Получаем исправление */
$this
->
db
->
select
(
"m.link as link, m.text as text, m.comment as comment"
);
$this
->
db
->
from
(
"messages as m"
);
$this
->
db
->
where
(
"m.id"
,
$message_id
);
$correction
=
$this
->
db
->
get
();
/* Получаем адрес необходимого сайта */
$parsed_url
=
parse_url
(
$correction
->
link
);
// Адресс на который шлем запрос исправления
$url
=
$parsed_url
[
"scheme"
]
+
"://"
+
$parsed_url
[
"host"
]
+
"/"
+
$correctPath
;
/* Посылаем запрос с помощью cUrl */
$curl
=
curl_init
(
$url
);
curl_setopt_array
(
$curl
,
array
(
CURLOPT_USE_SSL
=>
true
,
CURLOPT_RETURNTRANSFER
=>
true
,
CURLOPT_POST
=>
true
,
CURLOPT_FAILONERROR
=>
true
,
CURLOPT_USERNAME
=>
"typos.etersoft"
,
CURLOPT_PASSWORD
=>
$authToken
,
CURLOPT_POSTFIELDS
=>
array
(
text
=>
$correction
->
text
,
corrected
=>
$correction
->
comment
,
link
=>
$correction
->
link
),
));
if
(
(
$res
=
curl_exec
(
$curl
))
===
false
)
{
error_log
(
"CorrectTypo error: "
+
curl_error
(
$curl
));
return
;
}
log_message
(
"debug"
,
$res
);
curl_close
(
$curl
);
}
}
}
/**/
/**/
\ No newline at end of file
new_cp/application/views/users/typos.php
View file @
775b470e
...
@@ -35,7 +35,7 @@ jQuery("#table_sites").jqGrid({ //Привязка плагина к табли
...
@@ -35,7 +35,7 @@ jQuery("#table_sites").jqGrid({ //Привязка плагина к табли
url
:
TYPOS
.
base_url
+
'users/typos/get_list_messages?id='
+
row_id
,
url
:
TYPOS
.
base_url
+
'users/typos/get_list_messages?id='
+
row_id
,
editurl
:
TYPOS
.
base_url
+
'users/typos/panel_messages?id_site='
+
row_id
+
'&id='
+
row_id
,
editurl
:
TYPOS
.
base_url
+
'users/typos/panel_messages?id_site='
+
row_id
+
'&id='
+
row_id
,
datatype
:
"json"
,
datatype
:
"json"
,
colNames
:
[
'Номер'
,
'Ссылка'
,
'Текст'
,
'
Комментарий'
,
'Дата добавления'
,
'Статус сообщения
'
],
colNames
:
[
'Номер'
,
'Ссылка'
,
'Текст'
,
'
Исправление'
,
'Дата добавления'
,
'Принято?
'
],
colModel
:
[
colModel
:
[
{
name
:
"id"
,
index
:
"m.id"
,
width
:
80
,
searchtype
:
"integer"
,
align
:
'center'
},
{
name
:
"id"
,
index
:
"m.id"
,
width
:
80
,
searchtype
:
"integer"
,
align
:
'center'
},
{
name
:
"link"
,
index
:
"m.link"
,
width
:
80
,
sortable
:
false
,
searchtype
:
"string"
,
align
:
'center'
,
editable
:
true
},
{
name
:
"link"
,
index
:
"m.link"
,
width
:
80
,
sortable
:
false
,
searchtype
:
"string"
,
align
:
'center'
,
editable
:
true
},
...
...
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