Fix whitespaces in include/submit.php
This commit is contained in:
parent
b833a8d255
commit
cdb8670dea
|
@ -6,17 +6,17 @@ require_once('site-health.php');
|
||||||
function run_submit($url) {
|
function run_submit($url) {
|
||||||
|
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
if(! strlen($url))
|
if(! strlen($url))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
logger('Updating: ' . $url);
|
logger('Updating: ' . $url);
|
||||||
|
|
||||||
//First run a notice script for the site it is hosted on.
|
//First run a notice script for the site it is hosted on.
|
||||||
$site_health = notice_site($url, true);
|
$site_health = notice_site($url, true);
|
||||||
|
|
||||||
$submit_start = microtime(true);
|
$submit_start = microtime(true);
|
||||||
|
|
||||||
$nurl = str_replace(array('https:','//www.'), array('http:','//'), $url);
|
$nurl = str_replace(array('https:','//www.'), array('http:','//'), $url);
|
||||||
|
|
||||||
$profile_exists = false;
|
$profile_exists = false;
|
||||||
|
@ -26,7 +26,7 @@ function run_submit($url) {
|
||||||
dbesc($nurl)
|
dbesc($nurl)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
$profile_exists = true;
|
$profile_exists = true;
|
||||||
$profile_id = $r[0]['id'];
|
$profile_id = $r[0]['id'];
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ function run_submit($url) {
|
||||||
intval($profile_id)
|
intval($profile_id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove duplicates.
|
//Remove duplicates.
|
||||||
if(count($r) > 1){
|
if(count($r) > 1){
|
||||||
for($i=1; $i<count($r); $i++){
|
for($i=1; $i<count($r); $i++){
|
||||||
|
@ -51,43 +51,43 @@ function run_submit($url) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once('Scrape.php');
|
require_once('Scrape.php');
|
||||||
|
|
||||||
//Skip the scrape? :D
|
//Skip the scrape? :D
|
||||||
$noscrape = $site_health && $site_health['no_scrape_url'];
|
$noscrape = $site_health && $site_health['no_scrape_url'];
|
||||||
if($noscrape){
|
if($noscrape){
|
||||||
|
|
||||||
//Find out who to look up.
|
//Find out who to look up.
|
||||||
$which = str_replace($site_health['base_url'], '', $url);
|
$which = str_replace($site_health['base_url'], '', $url);
|
||||||
$noscrape = preg_match('~/profile/([^/]+)~', $which, $matches) === 1;
|
$noscrape = preg_match('~/profile/([^/]+)~', $which, $matches) === 1;
|
||||||
|
|
||||||
//If that did not fail...
|
//If that did not fail...
|
||||||
if($noscrape){
|
if($noscrape){
|
||||||
$parms = noscrape_dfrn($site_health['no_scrape_url'].'/'.$matches[1]);
|
$parms = noscrape_dfrn($site_health['no_scrape_url'].'/'.$matches[1]);
|
||||||
$noscrape = !!$parms; //If the result was false, do a scrape after all.
|
$noscrape = !!$parms; //If the result was false, do a scrape after all.
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$noscrape){
|
if(!$noscrape){
|
||||||
$parms = scrape_dfrn($url);
|
$parms = scrape_dfrn($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Empty result is due to an offline site.
|
//Empty result is due to an offline site.
|
||||||
if(!count($parms)){
|
if(!count($parms)){
|
||||||
|
|
||||||
//For large sites this could lower the health too quickly, so don't track health.
|
//For large sites this could lower the health too quickly, so don't track health.
|
||||||
//But for sites that are already in bad status. Do a cleanup now.
|
//But for sites that are already in bad status. Do a cleanup now.
|
||||||
if($profile_exists && $site_health['health_score'] < $a->config['maintenance']['remove_profile_health_threshold']){
|
if($profile_exists && $site_health['health_score'] < $a->config['maintenance']['remove_profile_health_threshold']){
|
||||||
logger('Nuked bad health record.');
|
logger('Nuked bad health record.');
|
||||||
nuke_record($url);
|
nuke_record($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//We don't care about valid dfrn if the user indicates to be hidden.
|
//We don't care about valid dfrn if the user indicates to be hidden.
|
||||||
elseif($parms['explicit-hide'] && $profile_exists) {
|
elseif($parms['explicit-hide'] && $profile_exists) {
|
||||||
logger('User opted out of the directory.');
|
logger('User opted out of the directory.');
|
||||||
|
@ -117,18 +117,18 @@ function run_submit($url) {
|
||||||
$parms['comm'] = intval($parms['comm']);
|
$parms['comm'] = intval($parms['comm']);
|
||||||
|
|
||||||
if($profile_exists) {
|
if($profile_exists) {
|
||||||
$r = q("UPDATE `profile` SET
|
$r = q("UPDATE `profile` SET
|
||||||
`name` = '%s',
|
`name` = '%s',
|
||||||
`pdesc` = '%s',
|
`pdesc` = '%s',
|
||||||
`locality` = '%s',
|
`locality` = '%s',
|
||||||
`region` = '%s',
|
`region` = '%s',
|
||||||
`postal-code` = '%s',
|
`postal-code` = '%s',
|
||||||
`country-name` = '%s',
|
`country-name` = '%s',
|
||||||
`homepage` = '%s',
|
`homepage` = '%s',
|
||||||
`nurl` = '%s',
|
`nurl` = '%s',
|
||||||
`comm` = %d,
|
`comm` = %d,
|
||||||
`tags` = '%s',
|
`tags` = '%s',
|
||||||
`updated` = '%s'
|
`updated` = '%s'
|
||||||
WHERE `id` = %d LIMIT 1",
|
WHERE `id` = %d LIMIT 1",
|
||||||
|
|
||||||
$parms['fn'],
|
$parms['fn'],
|
||||||
|
@ -140,7 +140,7 @@ function run_submit($url) {
|
||||||
dbesc($url),
|
dbesc($url),
|
||||||
dbesc($nurl),
|
dbesc($nurl),
|
||||||
intval($parms['comm']),
|
intval($parms['comm']),
|
||||||
$parms['tags'],
|
$parms['tags'],
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($profile_id)
|
intval($profile_id)
|
||||||
);
|
);
|
||||||
|
@ -206,15 +206,15 @@ function run_submit($url) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$submit_photo_start = microtime(true);
|
$submit_photo_start = microtime(true);
|
||||||
|
|
||||||
require_once("Photo.php");
|
require_once("Photo.php");
|
||||||
|
|
||||||
$photo_failure = false;
|
$photo_failure = false;
|
||||||
|
|
||||||
$status = false;
|
$status = false;
|
||||||
|
|
||||||
if($profile_id) {
|
if($profile_id) {
|
||||||
$img_str = fetch_url($photo,true);
|
$img_str = fetch_url($photo,true);
|
||||||
$img = new Photo($img_str);
|
$img = new Photo($img_str);
|
||||||
|
@ -232,11 +232,11 @@ function run_submit($url) {
|
||||||
nuke_record($url);
|
nuke_record($url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$submit_end = microtime(true);
|
$submit_end = microtime(true);
|
||||||
$photo_time = round(($submit_end - $submit_photo_start) * 1000);
|
$photo_time = round(($submit_end - $submit_photo_start) * 1000);
|
||||||
$time = round(($submit_end - $submit_start) * 1000);
|
$time = round(($submit_end - $submit_start) * 1000);
|
||||||
|
|
||||||
//Record the scrape speed in a scrapes table.
|
//Record the scrape speed in a scrapes table.
|
||||||
if($site_health && $status) q(
|
if($site_health && $status) q(
|
||||||
"INSERT INTO `site-scrape` (`site_health_id`, `dt_performed`, `request_time`, `scrape_time`, `photo_time`, `total_time`)".
|
"INSERT INTO `site-scrape` (`site_health_id`, `dt_performed`, `request_time`, `scrape_time`, `photo_time`, `total_time`)".
|
||||||
|
@ -247,7 +247,7 @@ function run_submit($url) {
|
||||||
$photo_time,
|
$photo_time,
|
||||||
$time
|
$time
|
||||||
);
|
);
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue