Results 1 to 4 of 4
  1. #1

    WAP based uptime script ?

    I am looking for any uptime (server load and time since last reboot) script which works on WAP enabled handsets so that I can check the server status frequently. If possible, can someone with WAP/WML programming knowledge help me in optimizing the following PHP uptime script so that it will work with WAP browsers ?

    Header('Cache-Control: no-cache');
    Header('Pragma: no-cache');

    $loadavg_array = explode(" ", exec("cat /proc/loadavg"));
    $loadavg = $loadavg_array[2];
    print("<b>The average server load now is: " . $loadavg . "%");
    function linuxUptime() {
    $ut = strtok( exec( "cat /proc/uptime" ), "." );
    $days = sprintf( "%2d", ($ut/(3600*24)) );
    $hours = sprintf( "%2d", ( ($ut % (3600*24)) / 3600) );
    $min = sprintf( "%2d", ($ut % (3600*24) % 3600)/60 );
    $sec = sprintf( "%2d", ($ut % (3600*24) % 3600)%60 );
    return array( $days, $hours, $min, $sec );
    $ut = linuxUptime();
    echo "Last reboot: $ut[0] days, $ut[1] hours, $ut[2] minutes, $ut[3] seconds";

  2. #2
    Join Date
    Apr 2005
    2nd biggest state
    Here is a snip of code that I found

    PHP Code:
    <?xml version="1.0"?>
    <card id="card1" title="Card 1"> 
    <p>Hello World!</p>

    So I think if you replace everything between <wml> -- </wml> with your code, this should work. But I'm not sure.

  3. #3
    Join Date
    Jun 2004
    Northwest Colorado
    Sorry Tweakbird, but WML is deprecated outright these days. The card and deck elements are part of WAP 2's WML extensions, but the doctype you've presented is outdated.

    WAP 1 & 2 are XML based. The key thing to remember about delivering content to WAP devices like cellphones is to deliver well-formed markup. This is not well-formed:

    <b>The average server load now is: 2<br>Last reboot: 1 days, 1 hours, 1 minutes, 1 seconds
    It will be rewritten by the gateway of a wireless network.

    What you want, is well-formed output. For this simple two-line page, don't worry about a DOCTYPE, it just adds unnecessary bytes to the transmission. Do worry about well-formedness:

    <?xml version="1.0"?>
    <p>The average server load now is: 2</p>
    <p>Last reboot: 1 days, 1 hours, 1 minutes, 1 seconds</p>
    That's all you need. Wireless network gateways are called "transcoding proxies", and this gives 'em enough to work with.

    Don't worry about bold formatting, this may be stripped depending on network or device, some SSBs (Small Screen Browsers) will use a different type size for bold, others will treat all emphasis tags as italics.

    Edit: Do include the xml declaration.
    Last edited by BigBison; 04-24-2005 at 03:28 PM.
    Eric J. Bowman, principal
    Bison Systems Corporation coming soon: a new sig!
    I'm just a poor, unfrozen caveman Webmaster. Your new 'standards' frighten, and confuse me...

  4. #4
    Join Date
    Apr 2005
    2nd biggest state
    Thanks for the correction! Very good information.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts