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
8c09e531
Commit
8c09e531
authored
Mar 07, 2019
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do support for projects with subdirs
parent
283eed00
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
1 deletion
+64
-1
dbfunctions.php
dbfunctions.php
+50
-0
server.php
server.php
+14
-1
No files found.
dbfunctions.php
0 → 100644
View file @
8c09e531
<?php
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 ?"
;
$STH
=
$DBH
->
prepare
(
$query_sites
);
$STH
->
execute
(
array
(
"^(https?://)*(www.)*"
.
$host
.
"/?"
));
if
(
$STH
->
rowCount
()
==
0
)
{
error_log
(
"no host
$host
"
);
return
0
;
}
$max_id
=
0
;
$max_len
=
0
;
while
(
$row
=
$STH
->
fetch
(
PDO
::
FETCH_ASSOC
))
{
//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
;
}
/*
// Uncomment for test
require __DIR__ . "/vendor/autoload.php";
require_once('configuration.php');
$DBH = new PDO(DB_DRIVER . ":host=" . DB_HOSTNAME . ";dbname=" . DB_DATABASE, DB_USERNAME, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));
get_site_id($DBH, "https://bogaiskov.ru");
get_site_id($DBH, "https://bogaiskov.ru/test/t1/page.php");
get_site_id($DBH, "https://bogaiskov.ru/dum");
*/
server.php
View file @
8c09e531
...
...
@@ -12,6 +12,7 @@ header('Access-Control-Allow-Origin: *');
require_once
(
'configuration.php'
);
require_once
(
'functions.php'
);
require_once
(
'dbfunctions.php'
);
require_once
(
'language.php'
);
require_once
(
'constants.php'
);
...
...
@@ -70,7 +71,6 @@ $userdata['url'] = getFormatingUrl(rawurldecode(getRequest('url', '')));
$userdata
[
'text'
]
=
htmlspecialchars
(
rawurldecode
(
getRequest
(
'text'
,
''
)));
$userdata
[
'context'
]
=
htmlspecialchars
(
rawurldecode
(
getRequest
(
'context'
,
''
)));
/* Парсим сайт для получения коренного сайта */
$mas_url
=
parse_url
(
$userdata
[
'url'
]);
if
(
!
isset
(
$mas_url
[
'host'
]))
{
echoJsonData
(
array
(
'success'
=>
'false'
,
'message'
=>
$_language
[
$code_language
][
"error_valid_url"
]));
...
...
@@ -87,6 +87,7 @@ 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
...
...
@@ -104,7 +105,19 @@ try {
// 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'
]);
$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
))
{
...
...
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