Run applications from links

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Miguel

    Run applications from links

    Hello

    I'm using PHP to build a menu of links based on information stored on
    database.
    There is a table with two fields. One regards the name of the
    application (Appname) and the other one the corresponding link (lnk).
    My PHP code looks like:

    <?php

    while (odbc_fetch_row ($rs))
    {
    $app=odbc_resul t($rs,"Appname" );
    $lnk=odbc_resul t($rs,"lnk");
    echo "<li><a href='$lnk'>$ap p</a></li>";
    }

    ?>

    The problem is that $lnk can simply be either a web link or a
    reference to an application (.exe), which is server side. In that
    case, $lnk is something like:
    "C:\Program Files\Common Files\Microsoft
    shared\AccessRu ntime\Office10\ MSACCESS.EXE" /Runtime
    "\\PTmacc\wmrep orts\Macc\Macc. mde" /cmd server=PTmacc, database=macc4

    When $lnk is a web link, the application works as I want, but if not,
    the application isn't executed. The ‘path' is assumed as a web link
    and the browser tries to open it.

    Does any PHP function that allows opening applications from a normal
    link. I know exec() function but I really don't know if it works as I
    wish. Besides I think it's not possible to make something like:

    <?php

    echo "<li><a href='exec('$ln k')'>$app</a></li>";

    ?>

    Does anybody who can help me please?

    Thanks.
    Regards,
    Miguel
  • Dank

    #2
    Re: Run applications from links

    On 19 May 2004 03:09:43 -0700, Miguel <albanomiguel@i ol.pt> wrote:
    [color=blue]
    > Hello
    >
    > I'm using PHP to build a menu of links based on information stored on
    > database.
    > There is a table with two fields. One regards the name of the
    > application (Appname) and the other one the corresponding link (lnk).
    > My PHP code looks like:
    >
    > <?php
    > …
    > while (odbc_fetch_row ($rs))
    > {
    > $app=odbc_resul t($rs,"Appname" );
    > $lnk=odbc_resul t($rs,"lnk");
    > echo "<li><a href='$lnk'>$ap p</a></li>";
    > }
    > …
    > ?>
    >
    > The problem is that $lnk can simply be either a web link or a
    > reference to an application (.exe), which is server side. In that
    > case, $lnk is something like:
    > "C:\Program Files\Common Files\Microsoft
    > shared\AccessRu ntime\Office10\ MSACCESS.EXE" /Runtime
    > "\\PTmacc\wmrep orts\Macc\Macc. mde" /cmd server=PTmacc, database=macc4
    >
    > When $lnk is a web link, the application works as I want, but if not,
    > the application isn't executed. The ‘path' is assumed as a web link
    > and the browser tries to open it.
    > Does any PHP function that allows opening applications from a normal
    > link. I know exec() function but I really don't know if it works as I
    > wish. Besides I think it's not possible to make something like:
    >
    > <?php
    > …
    > echo "<li><a href='exec('$ln k')'>$app</a></li>";
    > …
    > ?>
    >
    > Does anybody who can help me please?
    >
    > Thanks.
    > Regards,
    > Miguel[/color]

    Exec is what you need to use, if you want someone to click a link to
    launch a server-side program, make the link pass a value e.g.

    then just pass it through some if statements to pick the program:

    if($_GET["launch"] == 1 echo exec(ping www.google.com);

    you can't use php functions from the client side, php is *server side* so
    you need to get the logic working over on the server.

    HTH.

    --
    If we can't play God, who will?

    Comment

    Working...