Skip to content

Commit

Permalink
JetPhotos & PlanePictures fix :)
Browse files Browse the repository at this point in the history
Another day another fix :)
Fixed JetPhotos and PlanePictures sources to reflect their code changes.
Now they work again.

One question can i somehow force to update photos of all aircraft in db without image?
I can do this one by one by addSpotterImage() but how to make it to whole db at once? :)
  • Loading branch information
Struart88 authored Jun 13, 2020
1 parent b78c73b commit 136a39f
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions require/class.Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function getExifCopyright($url) {
elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
if ($copyright != '') {
$copyright = str_replace('Copyright ','',$copyright);
$copyright = str_replace('© ','',$copyright);
$copyright = str_replace('© ','',$copyright);
$copyright = str_replace('(c) ','',$copyright);
}
return $copyright;
Expand Down Expand Up @@ -365,32 +365,32 @@ public function fromDeviantart($type,$registration, $name='') {
*/
public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
$Common = new Common();
$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
$url= 'https://www.jetphotos.com/photo/keyword/'.$aircraft_registration;
$data = $Common->getData($url);
$dom = new DOMDocument();
@$dom->loadHTML($data);
$all_pics = array();
foreach($dom->getElementsByTagName('img') as $image) {
if ($image->getAttribute('itemprop') == "http://schema.org/image") {
$all_pics[] = $image->getAttribute('src');
}
}
foreach($dom->getElementsByTagName('img') as $image) {
$all_pics[] = $image->getAttribute('src');
}
$all_authors = array();
foreach($dom->getElementsByTagName('meta') as $author) {
if ($author->getAttribute('itemprop') == "http://schema.org/author") {
$all_authors[] = $author->getAttribute('content');
}
}
foreach($dom->getElementsByTagName('span') as $author) {
if (strpos($author->nodeValue, "By: ") !== false) {
$all_authors[] = $author->nodeValue;
}
}
$all_ref = array();
foreach($dom->getElementsByTagName('a') as $link) {
$all_ref[] = $link->getAttribute('href');
}
if (isset($all_pics[0])) {
foreach($dom->getElementsByTagName('a') as $link) {
if (strpos($link->getAttribute('href'), "/photo/") !== false) {
$all_ref[] = $link->getAttribute('href');
}
}
if (isset($all_pics[8])) {
$image_url = array();
$image_url['thumbnail'] = $all_pics[0];
$image_url['original'] = str_replace('_tb','',$all_pics[0]);
$image_url['copyright'] = $all_authors[0];
$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
$image_url['thumbnail'] = 'http:'.$all_pics[3];
$image_url['original'] = 'http:'.str_replace('/400/','/full/',$all_pics[3]);
$image_url['copyright'] = str_replace('By: ','',$all_authors[0]);
$image_url['source_website'] = 'https://jetphotos.net'.$all_ref[0];
$image_url['source'] = 'JetPhotos';
return $image_url;
}
Expand All @@ -407,7 +407,7 @@ public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
*/
public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
$Common = new Common();
$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
$url= 'https://www.planepictures.net/v3/search_en.php?srch='.$aircraft_registration.'&stype=reg&srng=2';
$data = $Common->getData($url);
$dom = new DOMDocument();
@$dom->loadHTML($data);
Expand All @@ -419,12 +419,12 @@ public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='
foreach($dom->getElementsByTagName('a') as $link) {
$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
}
if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) {
if (isset($all_pics[4])) {
$image_url = array();
$image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1];
$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]);
$image_url['copyright'] = $all_links[6]['text'];
$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
$image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[4];
$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN','',$all_pics[4]);
$image_url['copyright'] = $all_links[28]['text'];
$image_url['source_website'] = 'https://www.planepictures.net'.str_replace('./','/',$all_links[23]['href']);
$image_url['source'] = 'PlanePictures';
return $image_url;
}
Expand Down

0 comments on commit 136a39f

Please sign in to comment.