Post by nickpapoutsis » Sun Dec 22, 2019 10:26 pm

Hi,

Is there a way to have an extension or module automatically update its own files?

If we have the usual php files in admin/controller/extension/etc or catalog/controller/extension/etc can we automatically download new files from "the internet" and replace the existing files in those folders (or even add more files in different folders)?

A user-initiated update (where they click the Update button) is good enough as well.

User avatar
New member

Posts

Joined
Mon Mar 25, 2019 7:49 am

Post by straightlight » Sun Dec 22, 2019 10:29 pm

No OC version posted. However, your request would not be suggested to be used directly into that folder location but rather from the storage/modification folder where, more likely, this could be possibly done. However, if you're requiring specific data to be downloaded from the internet, and if no extensions are available on the Marketplace to deliver the needs, you could create a new service request in the Commercial Support section of the forum to get this done as a custom job.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by nickpapoutsis » Sun Dec 22, 2019 11:05 pm

straightlight wrote:
Sun Dec 22, 2019 10:29 pm
No OC version posted.
Mostly 3.x but I'd like 2.x as well.

I think however that you have misunderstood, to some degree, what I'm asking.

You have a smartphone, you open the appstore and find an app you like so you download it. A few days later the app's developer updates it so you open the appstore again, click the update button next to the app's name and the appstore updates the app by downloading newer files from the internet and replacing the old ones.

I want this exact same functionality but without modifying core Opencart files, just having the extension itself update its own files.

User avatar
New member

Posts

Joined
Mon Mar 25, 2019 7:49 am

Post by IP_CAM » Mon Dec 23, 2019 1:20 am

Well, it only depends on your Investment, but for about 8 to 10 US grands,
some specialists would possibly be able, to develop an OC Version for you,
as well as an App, meeting such tasks. :laugh:
The only problem could be, that you then have to get your own upgrades too,
and such would not come for free either ... ::)

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by straightlight » Mon Dec 23, 2019 1:45 am

You have a smartphone, you open the appstore and find an app you like so you download it. A few days later the app's developer updates it so you open the appstore again, click the update button next to the app's name and the appstore updates the app by downloading newer files from the internet and replacing the old ones.

I want this exact same functionality but without modifying core Opencart files, just having the extension itself update its own files.
Then, I understood your request perfectly as my last reply stands by providing the answer you were looking for.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by nickpapoutsis » Mon Dec 23, 2019 3:41 am

Ok, let's rephrase it a bit.

Can a basic, already installed extension replace/modify files in catalog\controller\extension\analytics and other such directories without outside help, the same way it does with system\storage\download directory?

User avatar
New member

Posts

Joined
Mon Mar 25, 2019 7:49 am

Post by straightlight » Mon Dec 23, 2019 3:59 am

Without security risks: no. Better to remain with the storage folder which is why we highly recommend people to put that folder outside of their public_html folder. FAQ: viewtopic.php?f=176&t=200804#p717782

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by thekrotek » Mon Dec 23, 2019 3:54 pm

Theoretically it IS possible, but nobody will do this for his own extensions separately. What is needed in OC is a nice update system similar to WordPress.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by paulfeakins » Mon Dec 23, 2019 6:41 pm

thekrotek wrote:
Mon Dec 23, 2019 3:54 pm
What is needed in OC is a nice update system similar to WordPress.
Oh yes it's very nice, one day your user clicks the innocent "Update" button and suddenly destroys their website :laugh:

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by paulfeakins » Mon Dec 23, 2019 6:42 pm

nickpapoutsis wrote:
Mon Dec 23, 2019 3:41 am
Can a basic, already installed extension replace/modify files in catalog\controller\extension\analytics and other such directories without outside help, the same way it does with system\storage\download directory?
Yes. Why do you ask?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by nickpapoutsis » Tue Dec 24, 2019 2:30 am

paulfeakins wrote:
Mon Dec 23, 2019 6:42 pm
Yes. Why do you ask?
I'd like to implement an update mechanism for an extension I'm coding so whenever a new version gets released they can click a button and update (replace) all of the extension's files without having to go through the trouble of downloading files and then trying to install them over ftp or installer.

Most users can install an extension (one way or the other) but updates (esp. if you have to delete some file without replacing it) can be rather tricky and I'd prefer not having to offer that kind of support.

User avatar
New member

Posts

Joined
Mon Mar 25, 2019 7:49 am

Post by thekrotek » Tue Dec 24, 2019 2:45 am

Develop extension for WordPress then.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by nickpapoutsis » Tue Dec 24, 2019 5:04 pm

thekrotek wrote:
Tue Dec 24, 2019 2:45 am
Develop extension for WordPress then.
That's not a bad suggestion, there's money to be made there but for now I'd rather not.

User avatar
New member

Posts

Joined
Mon Mar 25, 2019 7:49 am

Post by paulfeakins » Tue Dec 24, 2019 5:19 pm

nickpapoutsis wrote:
Tue Dec 24, 2019 5:04 pm
there's money to be made there but for now I'd rather not.
We all know that's because there isn't really money to be made there :laugh:

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by thekrotek » Tue Dec 24, 2019 5:34 pm

nickpapoutsis wrote:
Tue Dec 24, 2019 5:04 pm
That's not a bad suggestion, there's money to be made there but for now I'd rather not.
Money made on WordPress extension? Wow! You probably know some kind of a secret, because this is the worst selling platform ever created.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by nickpapoutsis » Tue Jan 14, 2020 4:29 am

I'm glad you are having fun but I'd prefer some doing it as safely (and easily) as possible.

What's the best way to download (and overwrite) a file to some admin or catalog subfolder?

User avatar
New member

Posts

Joined
Mon Mar 25, 2019 7:49 am

Post by thekrotek » Tue Jan 14, 2020 4:46 am

Short version: you don't. If you REALLY want to have live updates, go WordPress. I'm serious.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by sw!tch » Tue Jan 14, 2020 9:05 am

nickpapoutsis wrote:
Sun Dec 22, 2019 11:05 pm
Mostly 3.x but I'd like 2.x as well.

I think however that you have misunderstood, to some degree, what I'm asking.

You have a smartphone, you open the appstore and find an app you like so you download it. A few days later the app's developer updates it so you open the appstore again, click the update button next to the app's name and the appstore updates the app by downloading newer files from the internet and replacing the old ones.

I want this exact same functionality but without modifying core Opencart files, just having the extension itself update its own files.
Smartphone apps are sandboxed and need to be signed for one thing. Further they go through a QC process before being accepted (even updates). What you're trying to accomplish on this framework is not advised. The fact you're asking how to do it, means you don't have the expertise and shouldn't even attempt it.

The amount of work to do this securely and manage it would exceed its value. What if you were somehow unknowingly breached and sent out exploited code to all your extension users or leave a gaping backdoor into peoples stores..?

This is an e-commerce framework: You are dealing with a platform that could house credit cards and personal information.

Do you really want that liability..?

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by patjuh » Tue Jan 14, 2020 4:31 pm

i think you need the knowledge of curl for that and create every now and then a server request, so as i can imagine to so so you would need to write
* a curl library
* new controller library to overrule controller
*so model needs to be overruled to
* then server request task
* and you need to generate a db tabel to store the update and a table to find user versions

New member

Posts

Joined
Sat Feb 11, 2017 7:22 pm

Post by letxobnav » Tue Jan 14, 2020 5:23 pm

downloading and overwriting a file is easy...

via file get/put contents

Code: Select all

$file_url = 'https://url';
$file_name = basename($file_url);
$dir = 'WHERE TO SAVE';
if(file_put_contents($dir.$file_name,file_get_contents($file_url))) error_log('File '.$file_name.' downloaded';}
via curl

Code: Select all

$file_url = 'https://url';
$ch = curl_init($file_url);
$dir = 'WHERE TO SAVE';
$file_name = basename($url);
$fp = fopen($dir.$file_name, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
Making it solid and secure for you and your customers is another matter.

Apart from obvious security challenges (api etc.), if you need to overwrite multiple files and one fails, how do you revert back?
In other words, automated in-the-background updates need to be absolutely solid and fail-safe as they are unattended.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: Baidu [Spider], NicNie and 229 guests