For cycle checks array with URL images but does not detect which images do existHow do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?PHP code for anti hotlinkingHow to check if PHP array is associative or sequential?How do I check if an array includes an object in JavaScript?How do you check if a variable is an array in JavaScript?Checking if a key exists in a JavaScript object?Check if a value exists in an array in RubyHow to check if an object is an array?How much bandwidth do I generate to destination web site with my curl code?ABBYY OCR SDK: I am trying a sample script for recognizing business cards but not getting any outputcURL not working sometimes and gives empty resulthow can i check if RESTAPI is down using curl php
Theorems that impeded progress
Test if tikzmark exists on same page
What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)
Test whether all array elements are factors of a number
Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?
Minkowski space
TGV timetables / schedules?
How is it possible to have an ability score that is less than 3?
Can a Warlock become Neutral Good?
Today is the Center
What do you call a Matrix-like slowdown and camera movement effect?
Why did Neo believe he could trust the machine when he asked for peace?
What is the word for reserving something for yourself before others do?
Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
Writing rule stating superpower from different root cause is bad writing
What does it mean to describe someone as a butt steak?
Adding span tags within wp_list_pages list items
How can I make my BBEG immortal short of making them a Lich or Vampire?
Is a tag line useful on a cover?
Is it possible to do 50 km distance without any previous training?
Are the number of citations and number of published articles the most important criteria for a tenure promotion?
Is it important to consider tone, melody, and musical form while writing a song?
Dragon forelimb placement
For cycle checks array with URL images but does not detect which images do exist
How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?PHP code for anti hotlinkingHow to check if PHP array is associative or sequential?How do I check if an array includes an object in JavaScript?How do you check if a variable is an array in JavaScript?Checking if a key exists in a JavaScript object?Check if a value exists in an array in RubyHow to check if an object is an array?How much bandwidth do I generate to destination web site with my curl code?ABBYY OCR SDK: I am trying a sample script for recognizing business cards but not getting any outputcURL not working sometimes and gives empty resulthow can i check if RESTAPI is down using curl php
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a function which runs through an array of URL images, taken from my database, to see if they exist in order to upload images which do exist to another place. The application is in PHP using CakePhp 2.x and I'm using a function which I found on another Stackoverflow question.
The function which checks if the image exist is the next:
public function checkImageContentType($url)
return (@fopen($url,"r")==true);
But I've also test the next code:
function checkRemoteFile($url)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
// don't download content
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
if($result !== FALSE)
return true;
else
return false;
Its worth mentioning the images are from a remote domain so I can not use file_exist function. The code in question which runs the for of the array of url images and calls the functions to check if the images exist is the next:
foreach($inventories as $inventory)
if (!($this->checkImageContentType($inventory['Inventory']['imgsrc1'])))
echo "<p>Pass: ".$inventory['Inventory']['sku']." <a href='". $inventory['Inventory']['imgsrc1'] ."'>IMG Here</a> </p>";
continue;
echo "<p>Product SKU:".$inventory['Inventory']['sku']."</p>";
....
If the image exists it keeps on with the function to upload, if not it continues on with the next image in array. The only problem is this code is not detecting all images for some reason. It passes on over some images which do exists and detects only a few images, this happens randomly I'm not sure why. Any ideas what I'm doing wrong or what I could try to debug this?
EDIT:
I think I found the reason, its making to many calls to the other server, so it is sending me a 403 error. Is there a way to overcome this? I'm making many calls to the other server I think that is why the other server is preventing me from making any more calls.
EDIT 2:
Just to give a little more context, the images URL where stored on Shopify Files and they have a hot link protection in order to prevent many calls from a single server. So you cant check out that many links even if the links are 404s. And there is a cooldown where Shopify wont allow you to check any more Shopify URLs, hence the 403 error. Or at least that is what I think is happening. All I had to do was keep the request to a minimum and well expand the times of my app checking for the images url from Shopify. Maybe its not the best solution, but for now it was what I found out.
If someone knows how to bypass or workaround the HotLink Protection I would like to hear the ideas :P
php arrays curl cakephp shopify
add a comment |
I have a function which runs through an array of URL images, taken from my database, to see if they exist in order to upload images which do exist to another place. The application is in PHP using CakePhp 2.x and I'm using a function which I found on another Stackoverflow question.
The function which checks if the image exist is the next:
public function checkImageContentType($url)
return (@fopen($url,"r")==true);
But I've also test the next code:
function checkRemoteFile($url)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
// don't download content
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
if($result !== FALSE)
return true;
else
return false;
Its worth mentioning the images are from a remote domain so I can not use file_exist function. The code in question which runs the for of the array of url images and calls the functions to check if the images exist is the next:
foreach($inventories as $inventory)
if (!($this->checkImageContentType($inventory['Inventory']['imgsrc1'])))
echo "<p>Pass: ".$inventory['Inventory']['sku']." <a href='". $inventory['Inventory']['imgsrc1'] ."'>IMG Here</a> </p>";
continue;
echo "<p>Product SKU:".$inventory['Inventory']['sku']."</p>";
....
If the image exists it keeps on with the function to upload, if not it continues on with the next image in array. The only problem is this code is not detecting all images for some reason. It passes on over some images which do exists and detects only a few images, this happens randomly I'm not sure why. Any ideas what I'm doing wrong or what I could try to debug this?
EDIT:
I think I found the reason, its making to many calls to the other server, so it is sending me a 403 error. Is there a way to overcome this? I'm making many calls to the other server I think that is why the other server is preventing me from making any more calls.
EDIT 2:
Just to give a little more context, the images URL where stored on Shopify Files and they have a hot link protection in order to prevent many calls from a single server. So you cant check out that many links even if the links are 404s. And there is a cooldown where Shopify wont allow you to check any more Shopify URLs, hence the 403 error. Or at least that is what I think is happening. All I had to do was keep the request to a minimum and well expand the times of my app checking for the images url from Shopify. Maybe its not the best solution, but for now it was what I found out.
If someone knows how to bypass or workaround the HotLink Protection I would like to hear the ideas :P
php arrays curl cakephp shopify
add a comment |
I have a function which runs through an array of URL images, taken from my database, to see if they exist in order to upload images which do exist to another place. The application is in PHP using CakePhp 2.x and I'm using a function which I found on another Stackoverflow question.
The function which checks if the image exist is the next:
public function checkImageContentType($url)
return (@fopen($url,"r")==true);
But I've also test the next code:
function checkRemoteFile($url)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
// don't download content
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
if($result !== FALSE)
return true;
else
return false;
Its worth mentioning the images are from a remote domain so I can not use file_exist function. The code in question which runs the for of the array of url images and calls the functions to check if the images exist is the next:
foreach($inventories as $inventory)
if (!($this->checkImageContentType($inventory['Inventory']['imgsrc1'])))
echo "<p>Pass: ".$inventory['Inventory']['sku']." <a href='". $inventory['Inventory']['imgsrc1'] ."'>IMG Here</a> </p>";
continue;
echo "<p>Product SKU:".$inventory['Inventory']['sku']."</p>";
....
If the image exists it keeps on with the function to upload, if not it continues on with the next image in array. The only problem is this code is not detecting all images for some reason. It passes on over some images which do exists and detects only a few images, this happens randomly I'm not sure why. Any ideas what I'm doing wrong or what I could try to debug this?
EDIT:
I think I found the reason, its making to many calls to the other server, so it is sending me a 403 error. Is there a way to overcome this? I'm making many calls to the other server I think that is why the other server is preventing me from making any more calls.
EDIT 2:
Just to give a little more context, the images URL where stored on Shopify Files and they have a hot link protection in order to prevent many calls from a single server. So you cant check out that many links even if the links are 404s. And there is a cooldown where Shopify wont allow you to check any more Shopify URLs, hence the 403 error. Or at least that is what I think is happening. All I had to do was keep the request to a minimum and well expand the times of my app checking for the images url from Shopify. Maybe its not the best solution, but for now it was what I found out.
If someone knows how to bypass or workaround the HotLink Protection I would like to hear the ideas :P
php arrays curl cakephp shopify
I have a function which runs through an array of URL images, taken from my database, to see if they exist in order to upload images which do exist to another place. The application is in PHP using CakePhp 2.x and I'm using a function which I found on another Stackoverflow question.
The function which checks if the image exist is the next:
public function checkImageContentType($url)
return (@fopen($url,"r")==true);
But I've also test the next code:
function checkRemoteFile($url)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
// don't download content
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
if($result !== FALSE)
return true;
else
return false;
Its worth mentioning the images are from a remote domain so I can not use file_exist function. The code in question which runs the for of the array of url images and calls the functions to check if the images exist is the next:
foreach($inventories as $inventory)
if (!($this->checkImageContentType($inventory['Inventory']['imgsrc1'])))
echo "<p>Pass: ".$inventory['Inventory']['sku']." <a href='". $inventory['Inventory']['imgsrc1'] ."'>IMG Here</a> </p>";
continue;
echo "<p>Product SKU:".$inventory['Inventory']['sku']."</p>";
....
If the image exists it keeps on with the function to upload, if not it continues on with the next image in array. The only problem is this code is not detecting all images for some reason. It passes on over some images which do exists and detects only a few images, this happens randomly I'm not sure why. Any ideas what I'm doing wrong or what I could try to debug this?
EDIT:
I think I found the reason, its making to many calls to the other server, so it is sending me a 403 error. Is there a way to overcome this? I'm making many calls to the other server I think that is why the other server is preventing me from making any more calls.
EDIT 2:
Just to give a little more context, the images URL where stored on Shopify Files and they have a hot link protection in order to prevent many calls from a single server. So you cant check out that many links even if the links are 404s. And there is a cooldown where Shopify wont allow you to check any more Shopify URLs, hence the 403 error. Or at least that is what I think is happening. All I had to do was keep the request to a minimum and well expand the times of my app checking for the images url from Shopify. Maybe its not the best solution, but for now it was what I found out.
If someone knows how to bypass or workaround the HotLink Protection I would like to hear the ideas :P
php arrays curl cakephp shopify
php arrays curl cakephp shopify
edited 2 days ago
Jurgen Feuchter
asked Mar 9 at 2:21
Jurgen FeuchterJurgen Feuchter
3091319
3091319
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I assume your issue is with your checkImageContentType() method. You are using not so clever @ error suppressor which who knows what fopen($url,"r") return true/false but with suppressor will method return void?
Then you are using loose comparison using ==, you should check for identical values to be sure you are getting expected result using ===.
Also, please check if image does not exist, you don't get 404 server page response, that you might confuse as image response. Some servers might have hot linking protections.
You can always use libraries like guzzlehttp/guzzle to not re-invent the wheel, and make your life a bit easier.
Suppose I'm using the "checkRemoteFile" function, with that one I'm checking for each image URL using CURL but most URLs come out false I'm not even sure why. You think its the hot linking protection? The URLs in question are from Shopify Files
– Jurgen Feuchter
Mar 9 at 3:06
If most are returning, then hot linking is probably not an issue. But you should check contents of those files. Test your file array by converting them into data image, and check what exactly you are seeing.
– HelpNeeder
Mar 9 at 3:19
Most are returning false, even if I run 1 url which I know the image exists it returns false first. Im not even sure why anymore.
– Jurgen Feuchter
Mar 9 at 3:21
Check if url structure is correct; server require https/http; your server require SSL tunel; server can send/receive files of this file; are urls encoded; please debug your image array.
– HelpNeeder
Mar 9 at 3:36
The server has SSL, but still the calls are not working.
– Jurgen Feuchter
Mar 11 at 2:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073389%2ffor-cycle-checks-array-with-url-images-but-does-not-detect-which-images-do-exist%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I assume your issue is with your checkImageContentType() method. You are using not so clever @ error suppressor which who knows what fopen($url,"r") return true/false but with suppressor will method return void?
Then you are using loose comparison using ==, you should check for identical values to be sure you are getting expected result using ===.
Also, please check if image does not exist, you don't get 404 server page response, that you might confuse as image response. Some servers might have hot linking protections.
You can always use libraries like guzzlehttp/guzzle to not re-invent the wheel, and make your life a bit easier.
Suppose I'm using the "checkRemoteFile" function, with that one I'm checking for each image URL using CURL but most URLs come out false I'm not even sure why. You think its the hot linking protection? The URLs in question are from Shopify Files
– Jurgen Feuchter
Mar 9 at 3:06
If most are returning, then hot linking is probably not an issue. But you should check contents of those files. Test your file array by converting them into data image, and check what exactly you are seeing.
– HelpNeeder
Mar 9 at 3:19
Most are returning false, even if I run 1 url which I know the image exists it returns false first. Im not even sure why anymore.
– Jurgen Feuchter
Mar 9 at 3:21
Check if url structure is correct; server require https/http; your server require SSL tunel; server can send/receive files of this file; are urls encoded; please debug your image array.
– HelpNeeder
Mar 9 at 3:36
The server has SSL, but still the calls are not working.
– Jurgen Feuchter
Mar 11 at 2:59
add a comment |
I assume your issue is with your checkImageContentType() method. You are using not so clever @ error suppressor which who knows what fopen($url,"r") return true/false but with suppressor will method return void?
Then you are using loose comparison using ==, you should check for identical values to be sure you are getting expected result using ===.
Also, please check if image does not exist, you don't get 404 server page response, that you might confuse as image response. Some servers might have hot linking protections.
You can always use libraries like guzzlehttp/guzzle to not re-invent the wheel, and make your life a bit easier.
Suppose I'm using the "checkRemoteFile" function, with that one I'm checking for each image URL using CURL but most URLs come out false I'm not even sure why. You think its the hot linking protection? The URLs in question are from Shopify Files
– Jurgen Feuchter
Mar 9 at 3:06
If most are returning, then hot linking is probably not an issue. But you should check contents of those files. Test your file array by converting them into data image, and check what exactly you are seeing.
– HelpNeeder
Mar 9 at 3:19
Most are returning false, even if I run 1 url which I know the image exists it returns false first. Im not even sure why anymore.
– Jurgen Feuchter
Mar 9 at 3:21
Check if url structure is correct; server require https/http; your server require SSL tunel; server can send/receive files of this file; are urls encoded; please debug your image array.
– HelpNeeder
Mar 9 at 3:36
The server has SSL, but still the calls are not working.
– Jurgen Feuchter
Mar 11 at 2:59
add a comment |
I assume your issue is with your checkImageContentType() method. You are using not so clever @ error suppressor which who knows what fopen($url,"r") return true/false but with suppressor will method return void?
Then you are using loose comparison using ==, you should check for identical values to be sure you are getting expected result using ===.
Also, please check if image does not exist, you don't get 404 server page response, that you might confuse as image response. Some servers might have hot linking protections.
You can always use libraries like guzzlehttp/guzzle to not re-invent the wheel, and make your life a bit easier.
I assume your issue is with your checkImageContentType() method. You are using not so clever @ error suppressor which who knows what fopen($url,"r") return true/false but with suppressor will method return void?
Then you are using loose comparison using ==, you should check for identical values to be sure you are getting expected result using ===.
Also, please check if image does not exist, you don't get 404 server page response, that you might confuse as image response. Some servers might have hot linking protections.
You can always use libraries like guzzlehttp/guzzle to not re-invent the wheel, and make your life a bit easier.
answered Mar 9 at 2:51
HelpNeederHelpNeeder
3,2212067130
3,2212067130
Suppose I'm using the "checkRemoteFile" function, with that one I'm checking for each image URL using CURL but most URLs come out false I'm not even sure why. You think its the hot linking protection? The URLs in question are from Shopify Files
– Jurgen Feuchter
Mar 9 at 3:06
If most are returning, then hot linking is probably not an issue. But you should check contents of those files. Test your file array by converting them into data image, and check what exactly you are seeing.
– HelpNeeder
Mar 9 at 3:19
Most are returning false, even if I run 1 url which I know the image exists it returns false first. Im not even sure why anymore.
– Jurgen Feuchter
Mar 9 at 3:21
Check if url structure is correct; server require https/http; your server require SSL tunel; server can send/receive files of this file; are urls encoded; please debug your image array.
– HelpNeeder
Mar 9 at 3:36
The server has SSL, but still the calls are not working.
– Jurgen Feuchter
Mar 11 at 2:59
add a comment |
Suppose I'm using the "checkRemoteFile" function, with that one I'm checking for each image URL using CURL but most URLs come out false I'm not even sure why. You think its the hot linking protection? The URLs in question are from Shopify Files
– Jurgen Feuchter
Mar 9 at 3:06
If most are returning, then hot linking is probably not an issue. But you should check contents of those files. Test your file array by converting them into data image, and check what exactly you are seeing.
– HelpNeeder
Mar 9 at 3:19
Most are returning false, even if I run 1 url which I know the image exists it returns false first. Im not even sure why anymore.
– Jurgen Feuchter
Mar 9 at 3:21
Check if url structure is correct; server require https/http; your server require SSL tunel; server can send/receive files of this file; are urls encoded; please debug your image array.
– HelpNeeder
Mar 9 at 3:36
The server has SSL, but still the calls are not working.
– Jurgen Feuchter
Mar 11 at 2:59
Suppose I'm using the "checkRemoteFile" function, with that one I'm checking for each image URL using CURL but most URLs come out false I'm not even sure why. You think its the hot linking protection? The URLs in question are from Shopify Files
– Jurgen Feuchter
Mar 9 at 3:06
Suppose I'm using the "checkRemoteFile" function, with that one I'm checking for each image URL using CURL but most URLs come out false I'm not even sure why. You think its the hot linking protection? The URLs in question are from Shopify Files
– Jurgen Feuchter
Mar 9 at 3:06
If most are returning, then hot linking is probably not an issue. But you should check contents of those files. Test your file array by converting them into data image, and check what exactly you are seeing.
– HelpNeeder
Mar 9 at 3:19
If most are returning, then hot linking is probably not an issue. But you should check contents of those files. Test your file array by converting them into data image, and check what exactly you are seeing.
– HelpNeeder
Mar 9 at 3:19
Most are returning false, even if I run 1 url which I know the image exists it returns false first. Im not even sure why anymore.
– Jurgen Feuchter
Mar 9 at 3:21
Most are returning false, even if I run 1 url which I know the image exists it returns false first. Im not even sure why anymore.
– Jurgen Feuchter
Mar 9 at 3:21
Check if url structure is correct; server require https/http; your server require SSL tunel; server can send/receive files of this file; are urls encoded; please debug your image array.
– HelpNeeder
Mar 9 at 3:36
Check if url structure is correct; server require https/http; your server require SSL tunel; server can send/receive files of this file; are urls encoded; please debug your image array.
– HelpNeeder
Mar 9 at 3:36
The server has SSL, but still the calls are not working.
– Jurgen Feuchter
Mar 11 at 2:59
The server has SSL, but still the calls are not working.
– Jurgen Feuchter
Mar 11 at 2:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073389%2ffor-cycle-checks-array-with-url-images-but-does-not-detect-which-images-do-exist%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown