Changeset 17023 for trunk/FACT++/www


Ignore:
Timestamp:
08/19/13 16:32:16 (11 years ago)
Author:
tbretz
Message:
Added the possibility to send interrupts to the dim server.
Location:
trunk/FACT++/www/smartfact
Files:
2 edited

Legend:

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

    r15165 r17023  
    203203
    204204
    205 function submit(script)
     205function submit(script, isIrq)
    206206{
    207207    var inputs = document.getElementsByTagName("input");
    208208
    209     var args = "start="+script+".js";
     209    var args = isIrq ? "interrupt="+script : "start="+script+".js";
     210
    210211    for (var i=0; i<inputs.length; i++)
    211212        args += "&"+inputs[i].name+"="+inputs[i].value;
     
    241242
    242243    var title  = lines[0];
    243     var is_cmd = title[0]=='*';
     244    var is_cmd = title[0]=='*' || title[0]=='!';
     245    var is_irq = title[0]=='!';
    244246    var script = title.split('|');
    245247    if (is_cmd)
     
    347349    if (is_cmd)
    348350    {
    349         sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(script); this.style.backgroundColor=''; };
     351        sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(script, is_irq); this.style.backgroundColor=''; };
    350352    }
    351353    else
  • 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.