Ignore:
Timestamp:
08/19/13 16:32:16 (11 years ago)
Author:
tbretz
Message:
Added the possibility to send interrupts to the dim server.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/www/smartfact/index.php

    r15164 r17023  
    169169// --------------------------------------------------------------------
    170170
    171 if (!isset($_GET['start']) && !isset($_GET['stop']))
     171if (!isset($_GET['start']) && !isset($_GET['stop']) && !isset($_GET['interrupt']))
    172172    return header('HTTP/1.0 400 Command not supported');
    173173
     
    217217    if (isset($_GET['msg']))
    218218    {
    219         if ($_GET['msg']>=0)
    220             $msg = $_GET['msg'];
     219        $msg = $_GET['msg'];
    221220        unset($_GET['msg']);
    222221    }
     
    271270}
    272271
     272if (isset($_GET['interrupt']))
     273{
     274    unset($_GET['interrupt']);
     275
     276    $irq = "";
     277    if (isset($_GET['interrupt']))
     278    {
     279        $irq = $_GET['irq'];
     280        unset($_GET['interrupt']);
     281    }
     282
     283    $args = "";
     284    foreach ($_GET as $key => $value)
     285        $args .= ' "'.$key.'"="'.$value.'"';
     286
     287    $cmd = $path.'/dimctrl --user "'.$_SERVER['PHP_AUTH_USER'].'"  --interrupt '.escapeshellarg($irq.$args);
     288
     289    // Execute
     290    $str = exec($cmd, $out, $rc);
     291
     292    // Logging (mainly for debugging)
     293    $d = date("Y/m");
     294    $path = "log/".$d;
     295    if (!file_exists($path))
     296        mkdir($path, 0777, true);
     297    $file = fopen($path."/exec.log", "a");
     298    fwrite($file, $cmd."\n".$str."\n\n");
     299    fclose($file);
     300}
     301
    273302if ($rc>1)
    274303    return header('HTTP/1.0 500 Execution failed [rc='.$rc."]");
Note: See TracChangeset for help on using the changeset viewer.