aMule Forum

English => Feature requests => Topic started by: kam on October 11, 2014, 10:02:42 PM

Title: amuleweb: GET of others file type and php support of fopen()
Post by: kam on October 11, 2014, 10:02:42 PM
Can be added to the amuleweb the possibility to download also others files types. Not only html, js, css but also json and manifest and others.

With *.json and *.manifest could be implemented: web app for android (https://developer.chrome.com/multidevice/android/installtohomescreen) and AppCache (http://docs.webplatform.org/wiki/apis/appcache/ApplicationCache)

If can be also added php functions like fopen(), fread() and fwrite(), allowing users preserve some configuration for web interface.
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: Stu Redman on October 12, 2014, 12:07:53 PM
Probably not, unless somebody wants to actually implement this. amuleweb has only been maintained in recent years, to add features like this it may have to be redone from ground up.
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: kam on October 12, 2014, 02:15:52 PM
Do you think is it not enough add here the new extension?

Code: [Select]
wxString req_file(wxFileName(m_wwwroot, filename).GetFullPath());
        if (req_file.EndsWith(wxT(".html"))) {
                httpOut = ProcessHtmlRequest(unicode2char(req_file), httpOutLen);
        } else if (req_file.EndsWith(wxT(".php"))) {
                httpOut = ProcessPhpRequest(unicode2char(req_file), session, httpOutLen);
        } else if (req_file.EndsWith(wxT(".css"))) {
                session->m_vars["content_type"] = "text/css";
                httpOut = ProcessHtmlRequest(unicode2char(req_file), httpOutLen);
        } else if (req_file.EndsWith(wxT(".js"))) {
                session->m_vars["content_type"] = "text/javascript";
                httpOut = ProcessHtmlRequest(unicode2char(req_file), httpOutLen);
        } else if (     req_file.EndsWith(wxT(".dtd"))
                                || req_file.EndsWith(wxT(".xsd"))
                                || req_file.EndsWith(wxT(".xsl"))) {
                session->m_vars["content_type"] = "text/xml";
                httpOut = ProcessHtmlRequest(unicode2char(req_file), httpOutLen);
        } else {
                httpOut = GetErrorPage("aMuleweb doesn't handle the requested file type ", httpOutLen);
        }


something like:
Code: [Select]
 
} else if (req_file.EndsWith(wxT(".appcache"))) {
                session->m_vars["content_type"] = "text/cache-manifest";
                httpOut = ProcessHtmlRequest(unicode2char(req_file), httpOutLen);
} else if (req_file.EndsWith(wxT(".json"))) {
                session->m_vars["content_type"] = "application/json";
                httpOut = ProcessHtmlRequest(unicode2char(req_file), httpOutLen);
}

for the fopen()...patience ;)
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: Stu Redman on October 12, 2014, 03:46:28 PM
I think you would need a "ProcessJsonRequest()" and that is the hard part.
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: kam on October 12, 2014, 03:50:44 PM
mhhh... but also text/css and text/javascript use ProcessHtmlRequest...

.appcache and .json are only a plain text file, you have not need to process. What do I mistake?
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: Stu Redman on October 12, 2014, 10:29:27 PM
Well, maybe you are right after all. I don't know all too much about the web server.  :-[
How about you try compile that patch you suggested, try if it accomplishes what you hope it does and then post again?
If it works I'll add it to the code and give you credit for it. :)
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: GonoszTopi on October 12, 2014, 11:37:02 PM
Adding the proposed new extensions is ok, fopen() and friends are not. I don't feel like enabling a template directly accessing any file on my hard drive. Or anyone's.

If you're interested, I can explain in detail what would have to be done...
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: kam on October 13, 2014, 11:58:04 AM
Compiled and tested this new patch: http://pastebin.com/vmfHLk18

Works like a charm :)

For the fopen(), I understand what I mean...what I need is that user can save some config for web interface (not amule stuff).
How can I preserve this info/config from a session to another (don't say cookies!)?

Can be implemented also the support for folder...It's quite dirty put all files in a root of template..

Last one, I don't know why but var_dump() for me do nothing... ???

thanks!

When you think, my patch will be ready on upstream?
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: GonoszTopi on October 19, 2014, 12:47:35 AM
When you think, my patch will be ready on upstream?
Now. Committed as r10852.

One advice for the future: if you're posting patches, you'd better attach the patch file here, on the forum. Pastebin and similar sites mangle whitespace, which makes the patch unusable.

Last one, I don't know why but var_dump() for me do nothing... ???
The implementation of var_dump in amuleweb prints the information to stdout rather than sending it to the browser...

Can be implemented also the support for folder...It's quite dirty put all files in a root of template..
Yes, it's dirty, but you'll have to live with it. At least for now.

For the fopen(), I understand what I mean...what I need is that user can save some config for web interface (not amule stuff).
How can I preserve this info/config from a session to another (don't say cookies!)?
Reading might be enabled if we can ensure that only the template files can be accessed. But for writing... at the moment I cannot think of any safe way. If you come up with a usable idea, we can discuss it.
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: kam on October 19, 2014, 11:37:55 AM
Thanks GonoszTopi! My template/skin for aMule (https://github.com/elbowz/mobileMule), now it should be more lightweight and speedy.

...for the next patch, if ever there will be one, I'll attach here on forum (why do you not consider to publish on github? Pull requests are very powerful and easy to mange)

Quote
Reading might be enabled if we can ensure that only the template files can be accessed. But for writing... at the moment I cannot think of any safe way. If you come up with a usable idea, we can discuss it.
I'll think to some clean solution...in the meantime I'll use client side storage for this (cookies).

Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: Stu Redman on October 19, 2014, 12:51:16 PM
why do you not consider to publish on github?
Because I dislike GIT and we are not exactly running a Linux Kernel project. With less than one external contribution per month SVN works fine.
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: kam on October 19, 2014, 12:52:51 PM
clear...thanks for your work!
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: Vollstrecker on December 31, 2014, 07:39:23 PM
Qick&Dirty idea for the fopen(): don't implement it. But for saving web-config, it would be possible to implement some saveWebConfig function, that gets the config to save and writes it to exactly one file.
Title: Re: amuleweb: GET of others file type and php support of fopen()
Post by: kam on December 31, 2014, 07:46:12 PM
I have "solved" with client side storage (browser local storage)  :-X