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
483c73d1
Commit
483c73d1
authored
Jun 05, 2017
by
Георгий Попов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move all params to config. fix bugs with correctTypo method
parent
775b470e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
13 deletions
+25
-13
typos_config.php
new_cp/application/config/typos_config.php
+6
-0
Typo.php
new_cp/application/models/Typo.php
+19
-13
No files found.
new_cp/application/config/typos_config.php
View file @
483c73d1
...
...
@@ -11,3 +11,8 @@ $config['pass']['key_3'] = "&^^%$%$*Gposwорапо7д";
$config
[
'error_login_count'
]
=
3
;
$config
[
'error_login_time'
]
=
600
;
//10 минут
/* Typos credentials for external apis */
$config
[
'correction_path'
]
=
"correctTypo"
;
$config
[
'typos_user'
]
=
'typos.etersoft'
;
$config
[
'typos_password'
]
=
'Ync~YC{jBamlfuw7N3kG?XkiMpn}l6YJ'
;
\ No newline at end of file
new_cp/application/models/Typo.php
View file @
483c73d1
...
...
@@ -209,7 +209,7 @@ class Typo extends CI_Model {
function
editMessage
(
$data
)
{
if
(
$this
->
getMessageRights
(
$data
))
{
if
(
$data
[
'status'
]
)
{
correctTypo
(
$data
[
"id_message"
]);
$this
->
correctTypo
(
$data
[
"id_message"
]);
}
$this
->
db
->
set
(
"status"
,
$data
[
'status'
]);
...
...
@@ -264,22 +264,25 @@ class Typo extends CI_Model {
* Номер сообщения в бд
*/
function
correctTypo
(
$message_id
)
{
xdebug_break
();
/* TODO: брать из конфига */
$correctPath
=
"correctTypo"
;
$authToken
=
"fksdjsdlfks"
;
$correctPath
=
$this
->
config
->
item
(
"correction_path"
);
$authToken
=
$this
->
config
->
item
(
"typos_password"
);
$username
=
$this
->
config
->
item
(
"typos_user"
);
/* Получаем исправление */
$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
();
$correction
=
$this
->
db
->
get
()
->
row
()
;
/* Получаем адрес необходимого сайта */
$parsed_url
=
parse_url
(
$correction
->
link
);
// Адресс на который шлем запрос исправления
$url
=
$parsed_url
[
"scheme"
]
+
"://"
+
$parsed_url
[
"host"
]
+
"/"
+
$correctPath
;
$url
=
$parsed_url
[
"scheme"
]
.
"://"
.
$parsed_url
[
"host"
]
.
"/"
.
$correctPath
;
/* Посылаем запрос с помощью cUrl */
$curl
=
curl_init
(
$url
);
...
...
@@ -289,21 +292,24 @@ class Typo extends CI_Model {
CURLOPT_RETURNTRANSFER
=>
true
,
CURLOPT_POST
=>
true
,
CURLOPT_FAILONERROR
=>
true
,
CURLOPT_USERNAME
=>
"typos.etersoft"
,
CURLOPT_USERNAME
=>
$username
,
CURLOPT_PASSWORD
=>
$authToken
,
CURLOPT_POSTFIELDS
=>
array
(
text
=>
$correction
->
text
,
corrected
=>
$correction
->
comment
,
link
=>
$correction
->
link
'text'
=>
$correction
->
text
,
'corrected'
=>
$correction
->
comment
,
'link'
=>
$correction
->
link
),
));
if
(
(
$res
=
curl_exec
(
$curl
))
===
false
)
{
error_log
(
"CorrectTypo error: "
+
curl_error
(
$curl
));
log_message
(
"debug"
,
"sending request to
$url
"
);
if
(
!
(
$res
=
curl_exec
(
$curl
))
)
{
log_message
(
"debug"
,
"CorrectTypo error: "
.
curl_error
(
$curl
));
return
;
}
}
log_message
(
"debug"
,
$res
);
log_message
(
"debug"
,
"response taken"
);
log_message
(
"debug"
,
"Response from
$url
:
$res
"
);
curl_close
(
$curl
);
}
...
...
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