Beispiel #1
0
     if ($sizeof > $cutoff) {
         $filename = "/tmp/shm_{$address}_{$input}";
         $sizeof = number_format($sizeof, 0);
         if (file_put_contents($filename, $contents)) {
             out("Contents too big for console; Redirected {$sizeof} bytes to {$filename}");
             out("Note: The file(s) will be removed when you `exit` this console");
             continue;
         }
         out("Contents too big for console but output redirection to '{$filename}' failed.");
         out("Displaying the first 1024 bytes (of {$sizeof} bytes total)");
     }
     out(substr($contents, 0, $cutoff));
     continue;
 case !$address && $input <= 0 && isset($index[abs($input)]):
     $key = $index[abs($input)];
     macro(2, $addresses[$key]);
     out("Setting Address From Shortcut: " . $key);
     continue;
 case !$address && is_numeric($input) && $input > 0:
     $address = $input;
     $shm = shm_attach($input);
     $header_exists = true;
     out("Address {$input} Attached");
     // If no header is written the memory can still be attached but warn them just in case they typo'd or something
     if (!shm_has_var($shm, 1)) {
         $header_exists = false;
         out("Note: This shared memory address appears uninitilized: No header has been written.");
     }
     continue;
 case $address:
     throw new Exception("Invalid Key");
     }
     $out[] = '';
     $out[] = 'Shortcuts come from the $pidfiles array. Add your own shortcuts to make life easier.';
     $out[] = '';
     out(implode(PHP_EOL, $out));
     continue;
 case $pid && is_numeric($input) && $input > 0 && $input < 50:
     out("Sending Signal...");
     posix_kill($pid, $input);
     continue;
 case input(substr($input, 0, 3)) == 'pid':
     if ($pid) {
         out("Releasing PID...");
         $pid = false;
     }
     macro(1, $input);
     continue;
 case $input <= 0 && isset($index[abs($input)]):
     $key = $index[abs($input)];
     $file = $pidfiles[$key];
     if (!file_exists($file)) {
         throw new Exception("Sorry, Pid File Not Found! Tried: {$file}");
     }
     $pid = file_get_contents($file);
     out("Setting PID From Shortcut: {$pid}");
     continue;
 case !$pid && (is_numeric($input) && $input < 40000 && $input > 1):
     // On linux systems, easily verify if the pid is valid by looking for the process in the /proc directory
     if (file_exists("/proc") && !file_exists("/proc/{$input}")) {
         throw new Exception("Pid `{$input}` Does Not Exist");
     }
Beispiel #3
0
function path_macro($paths, $func)
{
    macro('*', $paths, array(), $func);
}