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
92494a78
Commit
92494a78
authored
Apr 18, 2019
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix getTyposAdapterUrl
parent
cd5aa584
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
2 deletions
+46
-2
Typo.php
cp/application/models/Typo.php
+46
-2
No files found.
cp/application/models/Typo.php
View file @
92494a78
...
...
@@ -319,14 +319,58 @@ class Typo extends CI_Model {
* @param string $link Ссылка на статью
* @return string URL адаптера JSON RPC
*/
private
function
get_site_id
(
$DBH
,
$url
)
{
//error_log("\nurl: $url\n");
$mas_url
=
parse_url
(
$url
);
if
(
!
isset
(
$mas_url
[
'host'
]))
return
0
;
$host
=
$mas_url
[
'host'
];
$query_sites
=
"SELECT sites.id AS id, sites.site AS url FROM sites
WHERE sites.site REGEXP ?"
;
$query
=
$DBH
->
query
(
$query_sites
,
array
(
"^(https?://)*(www.)*"
.
$host
.
"/?"
));
// if ($query->result() $result->rowCount() == 0) {
// error_log("no host $host");
// return 0;
// }
$max_id
=
0
;
$max_len
=
0
;
foreach
(
$query
->
result_array
()
as
$row
)
{
//echo $row['id'] . " " . $row['url'] . " in " . $url . "\n";
//preg_match('/(foo)(bar)(baz)/', $row['url'] , $matches
// TODO: сравнивать строки, начиная с ://
$pos
=
strpos
(
$url
,
$row
[
'url'
]);
$len
=
strlen
(
$row
[
'url'
]);
//echo "pos = $pos, len = $len\n";
if
(
$pos
!==
false
&&
$max_len
<
$len
)
{
$max_id
=
$row
[
'id'
];
$max_len
=
$len
;
}
}
//echo "Result: $max_id, $max_len\n";
return
$max_id
;
}
private
function
getTyposAdapterUrl
(
string
$link
)
{
$correctPath
=
$this
->
config
->
item
(
"correction_path"
);
/* Получаем адрес необходимого сайта */
$parsed_url
=
parse_url
(
$link
);
//require_once("/home/eterfund/www/eterfund.ru/api/typos/dbfunctions.php");
$id_site
=
$this
->
get_site_id
(
$this
->
db
,
$link
);
$this
->
db
->
select
(
"s.site as site"
);
$this
->
db
->
from
(
"sites as s"
);
$this
->
db
->
where
(
"s.id"
,
$id_site
);
$site
=
$this
->
db
->
get
()
->
row
();
//error_log("result: " . $site->site . "/" . $correctPath);
log_message
(
"error"
,
"result: "
.
$site
->
site
.
"/"
.
$correctPath
);
return
$site
->
site
.
"/"
.
$correctPath
;
// Адрес на который шлем запрос исправления
return
$parsed_url
[
"scheme"
]
.
"://"
.
$parsed_url
[
"host"
]
.
"/"
.
$correctPath
;
//
return $parsed_url["scheme"] . "://" . $parsed_url["host"] . "/" . $correctPath;
}
/**
...
...
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