Fix grab web site
This commit is contained in:
parent
94c2d7194c
commit
e8d29c644b
@ -348,6 +348,15 @@ if ($action == 'addcontainer')
|
|||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
||||||
|
|
||||||
|
if (! preg_match('/^http/', $urltograb))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
setEventMessages('Error URL must start with http:// or https://', null, 'errors');
|
||||||
|
$action = 'createcontainer';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
// Clean url to grab, so url can be
|
// Clean url to grab, so url can be
|
||||||
// http://www.example.com/ or http://www.example.com/dir1/ or http://www.example.com/dir1/aaa
|
// http://www.example.com/ or http://www.example.com/dir1/ or http://www.example.com/dir1/aaa
|
||||||
$urltograbwithoutdomainandparam = preg_replace('/^https?:\/\/[^\/]+\/?/i', '', $urltograb);
|
$urltograbwithoutdomainandparam = preg_replace('/^https?:\/\/[^\/]+\/?/i', '', $urltograb);
|
||||||
@ -362,6 +371,7 @@ if ($action == 'addcontainer')
|
|||||||
$urltograbdirrootwithoutslash = getRootURLFromURL($urltograbdirwithoutslash);
|
$urltograbdirrootwithoutslash = getRootURLFromURL($urltograbdirwithoutslash);
|
||||||
// Exemple, now $urltograbdirwithoutslash is https://www.dolimed.com/screenshots
|
// Exemple, now $urltograbdirwithoutslash is https://www.dolimed.com/screenshots
|
||||||
// and $urltograbdirrootwithoutslash is https://www.dolimed.com
|
// and $urltograbdirrootwithoutslash is https://www.dolimed.com
|
||||||
|
}
|
||||||
|
|
||||||
// Check pageurl is not already used
|
// Check pageurl is not already used
|
||||||
if ($pageurl)
|
if ($pageurl)
|
||||||
@ -465,6 +475,7 @@ if ($action == 'addcontainer')
|
|||||||
$tmp = $objectpage->htmlheader;
|
$tmp = $objectpage->htmlheader;
|
||||||
|
|
||||||
preg_match_all('/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
|
preg_match_all('/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
|
||||||
|
$errorforsubresource = 0;
|
||||||
foreach ($regs[0] as $key => $val)
|
foreach ($regs[0] as $key => $val)
|
||||||
{
|
{
|
||||||
dol_syslog("We will grab the resource found into script tag ".$regs[2][$key]);
|
dol_syslog("We will grab the resource found into script tag ".$regs[2][$key]);
|
||||||
@ -500,13 +511,15 @@ if ($action == 'addcontainer')
|
|||||||
if ($tmpgeturl['curl_error_no'])
|
if ($tmpgeturl['curl_error_no'])
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
|
setEventMessages('Error getting script url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
|
||||||
|
$errorforsubresource++;
|
||||||
$action='createcontainer';
|
$action='createcontainer';
|
||||||
}
|
}
|
||||||
elseif ($tmpgeturl['http_code'] != '200')
|
elseif ($tmpgeturl['http_code'] != '200')
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
|
setEventMessages('Error getting script url '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
|
||||||
|
$errorforsubresource++;
|
||||||
$action='createcontainer';
|
$action='createcontainer';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -531,9 +544,10 @@ if ($action == 'addcontainer')
|
|||||||
$pagecsscontent = "\n".'<style>'."\n";
|
$pagecsscontent = "\n".'<style>'."\n";
|
||||||
|
|
||||||
preg_match_all('/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
|
preg_match_all('/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
|
||||||
|
$errorforsubresource = 0;
|
||||||
foreach ($regs[0] as $key => $val)
|
foreach ($regs[0] as $key => $val)
|
||||||
{
|
{
|
||||||
dol_syslog("We will grab the resource found into link tag ".$regs[2][$key]);
|
dol_syslog("We will grab the resources found into link tag ".$regs[2][$key]);
|
||||||
|
|
||||||
$linkwithoutdomain = $regs[2][$key];
|
$linkwithoutdomain = $regs[2][$key];
|
||||||
if (preg_match('/^\//', $regs[2][$key]))
|
if (preg_match('/^\//', $regs[2][$key]))
|
||||||
@ -564,14 +578,16 @@ if ($action == 'addcontainer')
|
|||||||
$tmpgeturl = getURLContent($urltograbbis);
|
$tmpgeturl = getURLContent($urltograbbis);
|
||||||
if ($tmpgeturl['curl_error_no'])
|
if ($tmpgeturl['curl_error_no'])
|
||||||
{
|
{
|
||||||
$error++;
|
$errorforsubresource++;
|
||||||
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
|
setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors');
|
||||||
|
dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']);
|
||||||
$action='createcontainer';
|
$action='createcontainer';
|
||||||
}
|
}
|
||||||
elseif ($tmpgeturl['http_code'] != '200')
|
elseif ($tmpgeturl['http_code'] != '200')
|
||||||
{
|
{
|
||||||
$error++;
|
$errorforsubresource++;
|
||||||
setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
|
setEventMessages('Error getting link tag url'.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors');
|
||||||
|
dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']);
|
||||||
$action='createcontainer';
|
$action='createcontainer';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -694,14 +710,11 @@ if ($action == 'addcontainer')
|
|||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
||||||
//header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid);
|
|
||||||
//exit;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessages('Failed to write file '.$filetpl, null, 'errors');
|
setEventMessages('Failed to write file '.$filetpl, null, 'errors');
|
||||||
//header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid);
|
$action = 'createcontainer';
|
||||||
//exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user