Jump to content

[Resolved] 6.0.12 external link (complete URL) Digital url's do not work


jpayam

Recommended Posts

I had a similar problem yesterday when checking on the one digital product I have (just building a new, upgraded store with CC6, from CC3), the file didn't seem to be there. 

What I did to associate the file with the product was > In the Downloads section in admin, click the fourth tab to 'update file list' and that popped the digital file into the list on the files tab.  Then edit the product itself and on the 'Digital' tab, check the box for the file for that product.

Link to comment
Share on other sites

As I understand it, there were edits in seo.class.php and gui.class.php in an attempt to stop non-seo formed urls from cropping up. Bsmither has already provided a fix for the sitemap timestamp issue this caused. I wonder if there is a digital product already created on the demo store, so this can be tested.....

There is NOT a digital product already in the demo store, so we can't be sure at this point if this is a bug or not. I'm going to change the title of this thread to encourage some feedback from other digital sellers who have upgraded to 6.0.12.

Link to comment
Share on other sites

For CC6012, in the file /admin/sources/products.index.inc.php, near line 1204:

Find:
		// Check digital download path exists
		if(!empty($result[0]['digital_path'])) {
			if(!file_exists($result[0]['digital_path'])) {
				$GLOBALS['main']->setACPWarning($GLOBALS['language']->filemanager['error_dl_3']." ".$result[0]['digital_path']);
			}
		}

Replace that with:
		// Check digital download path exists
		if(!empty($result[0]['digital_path'])) {
			$no_exist_response = true;
			$no_curl_response = true;
			// Use curl_init() to check if valid URL
			if(filter_var($result[0]['digital_path'], FILTER_VALIDATE_URL) !== false){
				$curl_handle = curl_init();
				curl_setopt($curl_handle, CURLOPT_URL, $result[0]['digital_path']);
				curl_setopt($curl_handle, CURLOPT_HEADER, false);
				curl_setopt($curl_handle, CURLOPT_NOBODY, true);
				curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10);
				$curl_response = curl_exec($curl_handle);
				if (!curl_errno($curl_handle)) $curl_info = curl_getinfo($curl_handle);
				curl_close($curl_handle);
				$no_curl_response = (floatval($curl_info['http_code']) >= 400) ? true : false ;
			} else {
				$no_exist_response = !file_exists($result[0]['digital_path']);
			}

			if($no_exist_response &&$no_curl_response ) {
				$GLOBALS['main']->setACPWarning($GLOBALS['language']->filemanager['error_dl_3']." ".$result[0]['digital_path']);
			}
		}

The PHP documentation seems to suggest that file_exists() will get a valid response from a remote URL, that is, true if the file exists at that URL. My experiments show otherwise. So, if the 'digital path' looks like a web address, we use CURL to have CubeCart make a request to the remote server.

We do not actually want to fetch the file, so part of this curl() preparation is to specify simply sending a HEAD request -- which means to send back response headers, but no actual content. If the response headers have an 'http_code' of 400 or higher (such as 404 Not Found), there will be a problem getting this file anyway.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...