Changeset 17373 for trunk/FACT++/www


Ignore:
Timestamp:
11/25/13 19:49:20 (11 years ago)
Author:
tbretz
Message:
Unified all exec calls, suppress logging (actually only a warning message) when dimctrl is called
File:
1 edited

Legend:

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

    r17023 r17373  
    6767    return "Sorry, your credentials don't match!";
    6868}
     69
     70function execute($cmd, $out)
     71{
     72    // Execute
     73    $str = exec($cmd, $out, $rc);
     74
     75        // Logging (mainly for debugging)
     76    $d = date("Y/m");
     77    $path = "log/".$d;
     78
     79    if (!file_exists($path))
     80        mkdir($path, 0777, true);
     81
     82    $file = fopen($path."/exec.log", "a");
     83
     84    fwrite($file, $cmd);
     85    fwrite($file, "\n");
     86    if ($rc>0)
     87        fwrite($file, print_r($out,true)."\n");
     88    fwrite($file, "\n");
     89
     90    fclose($file);
     91
     92    return $rc;
     93}
     94
    6995// --------------------------------------------------------------------
    7096
     
    190216
    191217if (isset($_GET['stop']))
    192     $str = exec($path."/dimctrl --user '".$_SERVER['PHP_AUTH_USER']."' --stop", $out, $rc);
     218{
     219    unset($_GET['stop']);
     220
     221    $cmd = $path."/dimctrl --no-log --user '".$_SERVER['PHP_AUTH_USER']."' --stop 2>&1";
     222
     223    $rc = execute($cmd, $out);
     224}
    193225
    194226if (isset($_GET['start']))
     
    232264
    233265        // $args = "filename":label --arg:"key1=value" --arg:"key2=value"
    234         $cmd = $path.'/dimctrl --user "'.$_SERVER['PHP_AUTH_USER'].'"  --start '.escapeshellarg($script.$args);
    235 
    236         // Execute
    237         $str = exec($cmd, $out, $rc);
    238 
    239         // Logging (mainly for debugging)
    240         $d = date("Y/m");
    241         $path = "log/".$d;
    242         if (!file_exists($path))
    243             mkdir($path, 0777, true);
    244         $file = fopen($path."/exec.log", "a");
    245         fwrite($file, $cmd."\n".$str."\n\n");
    246         fclose($file);
     266        $cmd = $path.'/dimctrl --no-log --user "'.$_SERVER['PHP_AUTH_USER'].'"  --start '.escapeshellarg($script.$args). " 2>&1";
     267
     268        $rc = execute($cmd, $out);
    247269    }
    248270
     
    252274
    253275        // $args = "filename":label --arg:"key1=value" --arg:"key2=value"
    254         $cmd = $path.'/dimctrl --user "'.$_SERVER['PHP_AUTH_USER'].'"  --msg '.escapeshellarg($msg);
    255 
    256         // Execute
    257         $str = exec($cmd, $out, $rc);
    258 
    259         // Logging (mainly for debugging)
    260         $d = date("Y/m");
    261         $path = "log/".$d;
    262         if (!file_exists($path))
    263             mkdir($path, 0777, true);
    264         $file = fopen($path."/exec.log", "a");
    265         fwrite($file, $cmd."\n".$str."\n\n");
    266         fclose($file);
     276        $cmd = $path.'/dimctrl --no-log --user "'.$_SERVER['PHP_AUTH_USER'].'"  --msg '.escapeshellarg($msg)." 2>&1";
     277
     278        $rc = execute($cmd, $out);
    267279    }
    268280
     
    285297        $args .= ' "'.$key.'"="'.$value.'"';
    286298
    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);
     299    $cmd = $path.'/dimctrl --no-log --user "'.$_SERVER['PHP_AUTH_USER'].'"  --interrupt '.escapeshellarg($irq.$args)." 2>&1";
     300
     301    $rc = execute($cmd, $out);
    300302}
    301303
Note: See TracChangeset for help on using the changeset viewer.