aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: amuleweb: GET of others file type and php support of fopen()  (Read 12834 times)

kam

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
amuleweb: GET of others file type and php support of fopen()
« 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.
Logged
mobileMule (template/skin for mobile and desktop): https://github.com/elbowz/mobileMule

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #1 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.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

kam

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #2 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 ;)
« Last Edit: October 12, 2014, 02:20:03 PM by kam »
Logged
mobileMule (template/skin for mobile and desktop): https://github.com/elbowz/mobileMule

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #3 on: October 12, 2014, 03:46:28 PM »

I think you would need a "ProcessJsonRequest()" and that is the hard part.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

kam

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #4 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?
Logged
mobileMule (template/skin for mobile and desktop): https://github.com/elbowz/mobileMule

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #5 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. :)
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #6 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...
Logged
concordia cum veritate

kam

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #7 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?
« Last Edit: October 13, 2014, 12:07:22 PM by kam »
Logged
mobileMule (template/skin for mobile and desktop): https://github.com/elbowz/mobileMule

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 169
  • Offline Offline
  • Posts: 2685
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #8 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.
Logged
concordia cum veritate

kam

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #9 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).

Logged
mobileMule (template/skin for mobile and desktop): https://github.com/elbowz/mobileMule

Stu Redman

  • Administrator
  • Hero Member
  • *****
  • Karma: 214
  • Offline Offline
  • Posts: 3739
  • Engines screaming
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #10 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.
Logged
The image of mother goddess, lying dormant in the eyes of the dead, the sheaf of the corn is broken, end the harvest, throw the dead on the pyre -- Iron Maiden, Isle of Avalon

kam

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #11 on: October 19, 2014, 12:52:51 PM »

clear...thanks for your work!
Logged
mobileMule (template/skin for mobile and desktop): https://github.com/elbowz/mobileMule

Vollstrecker

  • Administrator
  • Hero Member
  • *****
  • Karma: 67
  • Offline Offline
  • Posts: 1546
  • Unofficial Debian Packager
    • http://vollstreckernet.de
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #12 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.
Logged
Homefucking is killing prostitution

kam

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
Re: amuleweb: GET of others file type and php support of fopen()
« Reply #13 on: December 31, 2014, 07:46:12 PM »

I have "solved" with client side storage (browser local storage)  :-X
Logged
mobileMule (template/skin for mobile and desktop): https://github.com/elbowz/mobileMule