OpenWrt Forum Archive

Topic: Web Interface

The content of this topic has been archived on 1 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I've started working on an interface.  It shouldn't take me much longer to have a beta version ready.  Especially since I'm going to be stuck in a hotel room in the middle of nowhere all day tomorrow.

Right now the thing I'm pretty jazzed about is I've made it really easy for packages to add their own pages to the admin page.  All they have to do is install a directory in the ./packages dir of the server root that contains a name.php and index.php file, and it will automagically be added as a menu option in the admin page.

And yes, this interface is written in php (v. 3), and i know there are some who feel that this is overkill, too big, totally unsuited for embedded use, not as good as X scripting language, violation of federal law, etc . . .

Putting that aside (or at least, leaving it for a different Forum Topic), I think at the very least, my interface should -- if one was so inclined -- be reasonably easy to port to the super-small interpreted language that your brother-in-law is about to write. . .  wink

OK, a beta is up.  Use it at your own risk.  It requires either php or my slimmed down version of php (now known as lwhp so as not to run afoul of the php license)

All are available at my repository:

src sam http://davidoffdotnet.net/openwrt/ipkg

A few things to note --

1. This is very basic, only the Network and Wireless sections do anything.  The truth is you should probably mostly use it just to see the direction I'm going int. Functionality is minimal

2. It's in PHP. I know people have some objections to that, and I may be coming around to that point of view.  But for now . . . it is what it is

3. Its only set up for the V2 or GS configuration so probably don't bother to try it on an earlier, or at least be prepared to change some code.

4. On a more general note -- the interface assumes that all users will configure in the following routing arrangement:

Internet <---> WRT <---> LAN

It allows you to change which interfaces make which connection, but it doesn't, for example, allow you to have two (or more lans).  My thinking is that you have to settle on some level of abstraction for a user interface and this makes sense, if for no other reasons than that that's what the nvram variables are set up for.

I'm eager for any comments.  In the meantime, I'll keep working.

Is it enough to use the lwphp package and your pages to get it working (to use it with the default httpd)? Or do I still need thttpd?

no need to use thttpd

lwhp and interface-wrt packages are all you need.

the thttpd packages was made to get php4 running, but its not necessary to run the interface.

hm, i just wondering why my browser is trying to download the files while i want to view them.
That's why I asked for.

Any solutions? Is there a config i need to add for the httpd, to load the php module or so?

hmmm.  i'm not exactly sure what you mean.  since php is built as a cgi app for busybox any script needs to prefaced with

#!/usr/bin/php

the only script that has that magic in my interface is index.php because that is the only page ever directly called.  it calls the other pages as necessary.

if that's not working for some reason please let me know.

if you simply want to view my scripts, i'd suggest just using vi or moving them to a different computer and using the editor of your choice.

if you still can't get it to work, let me know.  i'm very interested in bugs  wink

hm, still can't get it working.
It still wants me to download the index.php, eventhough there is a #!/usr/bin/php in the first line of index.php

Could you query me on IRC (phil_ at #wrt54g)? Then I could give you the link to my box. Then you can see it on your own, it's hard to describe.

A few more clarifications, after talking with phil (thanks, phil).

1. you need to access the inteface by going to yourrouter/cgi-bin/index.php not yourrouter/openwrt/index.php.  the one is just a symlink to the other, but if you don't get cgi-bin in the url busybox doesn't know its a script.  if you just type in your router's address it should give you the appropriate link.

2.  my statement about only supporting the
Internet <---> WRT <---LAN-->
configuration was only meant to mean that currently the router
1. only routes between two networks and
2. it masquerades traffice between them
the networks need not be the actual internet or a lan. a better diagrman might have been
WAN <---> WRT <---> LAN

3. the package magic is there in the sense that if you add a folder to the packages direcotry in /www/openwrt and include in that folder the following
a. a names.php file that containes
[code]<? $package_name="Your Package Name" ?>[/code]
b. an index.php file
the interface will automatically add the name to the Packages sidebar and display your index.php page.

You can also easily hook into my status and control templates to mimic the look of the interface (and maybe save yourself some work).  this will all get documented once i finish the basic interface work.

[/code]

I think I detected another error:
While I was coding on the package management stuff of the interface, i found out that lwhp is missing lots of functions which I need for package management. So I installed your php3 package. Worked fine - till one point:
When I now click on a link in the interface (no matter what link .. let's say the "managment"-link above, the default page is loaded, but not the "managment" page. This happens for every other page, i call.

Any solutions?

try moving the php3.ini file from /etc to /usr/lib. (or symlink)  i think my php3 package looks for it there and you need a variable to be set in php3.ini otherwise it won't accept the HTTP_*_VARS which would lead to the behavior you describe.

out of curiosity, what functions are you using that aren't available in lwhp?  i could backport them or possible suggest a workaround.

uhm ..
actually, there is *no* php3.ini in /etc, /usr/lib or any other directory. sad
Do you have a example one, or can you post yours?

At the moment I'm working on package managment, especially the removing function for installed packages. Will tell you more about this later (when it's at least working a bit).

i meant the one from the lwhp package. the easiest thing is just to create a php3.ini file in /usr/lib containing the following text:

track_vars = On

Hi,

i did a

root@ap:/usr/lib# echo "track_vars = On" > php3.ini

restarted the webserver, and still the same. sad

Cheers,
phil

edit: got it working .. I had to put it into /etc and not into /usr/lib.

new version up on my repository.  for some reason ipkg upgrade throws a bad number error (anyone know why?)

you can still get it via

ipkg remove interface-wrt
ipkg install interface-wrt

this adds some services to the management page, most importantly, to allow dhcp configuration.

still very beta.  use at your own risk.

A few, small errors:

Management Page -> Status:
It says 'grep: /etc/init.d/S50services: No such file or directory'. The file has to be /etc/init.d/S50service, not /etc/init.d/S50services.

It says 'grep: /etc/inittab: No such file or directory'. I think it should be /etc/initd instead of /etc/inittab.

Management Page -> telnet
It says 'grep: /etc/init.d/S50services: No such file or directory', should be /etc/init.d/S50service.

Management Page -> DHCP
The same as it's on the telnet page.

Management Page -> DNS
/etc/initd instead of /etc/inittab.

at least on my version of the firmware (b4, not cvs) the file is S50services.  also, dnsmasq is respawned from inittab which is why that file is parsed.

is it possible you modified the files when you copied over from rom?

Hum, yes. They are modified. But they still have the same name.
Do you think that's the problem?

the files need to be named
/etc/inittab
and
/etc/init.d/S50services

these are their names in rom (i think), and that's what i used.

okay. (shame on me, sorry :oops:)

wink

i don't like the layout (well that's my personal taste)
but the code isn't that flexible because of the " " and there are only those div tags you need for your layout.
i suggest adding more even if you don't use them to have more flexibility with the stylesheets.. and of coure remove the bgcolor from the body tag

The reason I did my layout is becase I hated yours .. personal preferences.

nbsp: Most of the problem comes from rewriting the page to be compatible with Internet Explorer; dropping support for that would greatly simplify things, but IE is a popular browser and I'm sure that dropping support for it would juste lead to some post about how it didn't look good in IE.

bgcolor: yes, I did set it in the body tag, the reason for this is that not all browsers support CSS *gasp*, so for those browsers that don't, change the page background to a simple white .. you can still override it in CSS.

div tags: yes, I could add more divs tags, but if you'd take the time to study css and it's selectors you'd realize that you really don't need them.

so this is your final code?
i'll try to tweak the sheme to my needs and test it with the most common browsers

IMHO, simple is best.

Also, a flexible interface allowing addon skins would be even better than a nice looking one.

The discussion might have continued from here.