예제 #1
0
function parseStringA($text, $dialects = array())
{
    global $errorstring, $parameters, $aspellpath;
    $dialect = "english";
    if (isset($dialects[1]) && $dialects[1] != "") {
        $dialect = $dialects[1];
    }
    $text = str_replace(array("\r", "\n"), array(" ", " "), $text);
    $temptext = tempnam(".", "spelltext");
    $tempouttext = $temptext . ".out.spell";
    // do not check alt attributes
    if ($fd = fopen($temptext, "w")) {
        $textarray = explode("\n", $text);
        fwrite($fd, "!\n");
        foreach ($textarray as $key => $value) {
            fwrite($fd, "^{$value}\n");
            //prohibit aspell from believing that lines are aspell commands
        }
        fclose($fd);
        // next run aspell
        $return = my_exec($aspellpath . "aspell -a -d " . $dialect . " -H --rem-sgml-check=alt < " . $temptext . " > " . $tempouttext);
        //RST: works on PHP4 < 4.3.0
        if (!function_exists('file_get_contents')) {
            $file = @fopen($tempouttext, "rb", 0);
            if ($file) {
                while (!feof($file)) {
                    $return .= fread($file, 1024);
                }
                fclose($file);
            } else {
                /* There was a problem opening the file. */
                return FALSE;
            }
            return $return;
        } else {
            $return = file_get_contents($tempouttext);
        }
        // unlink tempfile
        $ureturn = unlink($temptext);
        $ureturn = unlink($tempouttext);
        // next parse $return and $text line by line, eh
        $returnarray = explode("\n", $return);
        $returnlines = count($returnarray);
        $textlines = count($textarray);
        $lineindex = -1;
        $poscorrect = 0;
        $jstext = "";
        $jsarrindex = 0;
        foreach ($returnarray as $key => $value) {
            // if there is a correction here, processes it, else move the $textarray pointer to the next line
            if (substr($value, 0, 1) == "&") {
                $correction = explode(" ", $value);
                $word = $correction[1];
                if (addedWord($word)) {
                    continue;
                }
                $absposition = substr($correction[3], 0, -1) - 1;
                $position = $absposition + $poscorrect;
                $niceposition = $lineindex . "," . $absposition;
                $suggstart = strpos($value, ":") + 2;
                $suggestions = substr($value, $suggstart);
                $suggestionarray = explode(", ", $suggestions);
                //$opener= '<span onclick="fillOptions(this)" onmouseover="captureTooltip(event);" options="'.implode("|", $suggestionarray).'" class="nosuggestion">';
                $opener = '<span badword=1>';
                //$closer= "</span>";
                $closer = "</span>";
                // highlight in text
                $beforeword = substr($textarray[$lineindex], 0, $position);
                $afterword = substr($textarray[$lineindex], $position + strlen($word));
                $textarray[$lineindex] = $beforeword . "{$opener}{$word}{$closer}" . $afterword;
                $jstext .= "\nwords[" . $jsarrindex . "] = new Object();";
                $jstext .= "\nwords[" . $jsarrindex . "].status = 0;";
                $jstext .= "\nwords[" . $jsarrindex . "].word = \"" . $word . "\";";
                $jstext .= "\nwords[" . $jsarrindex . "].suggestions = new Array();";
                $jsarrindex2 = 0;
                foreach ($suggestionarray as $suggestion) {
                    $jstext .= "\nwords[" . $jsarrindex . "].suggestions[" . $jsarrindex2 . "] = \"" . str_replace(array("\r", "\n"), array("", ""), $suggestion) . "\";";
                    $jsarrindex2++;
                }
                $jsarrindex++;
                // dirty hack for recalculating next index position
                $poscorrect = $poscorrect + strlen("{$opener}{$closer}");
            } elseif (substr($value, 0, 1) == "#") {
                $correction = explode(" ", $value);
                $word = $correction[1];
                $absposition = $correction[2] - 1;
                $position = $absposition + $poscorrect;
                $niceposition = $lineindex . "," . $absposition;
                $suggestions = "";
                $suggestionarray = explode(", ", $suggestions);
                //$opener= '<span onclick="fillOptions(this)" onmouseover="captureTooltip(event);" options="'.implode("|", $suggestionarray).'" class="nosuggestion">';
                $opener = '<span badword=1>';
                //$closer= "</span>";
                $closer = "</span>";
                $jstext .= "\nwords[" . $jsarrindex . "] = new Object();";
                $jstext .= "\nwords[" . $jsarrindex . "].status = 0;";
                $jstext .= "\nwords[" . $jsarrindex . "].word = \"" . $word . "\";";
                $jstext .= "\nwords[" . $jsarrindex . "].suggestions = new Array();";
                $jsarrindex2 = 0;
                foreach ($suggestionarray as $suggestion) {
                    $jstext .= "\nwords[" . $jsarrindex . "].suggestions[" . $jsarrindex2 . "] = \"" . str_replace(array("\r", "\n"), array("", ""), $suggestion) . "\";";
                    $jsarrindex2++;
                }
                $jsarrindex++;
                // highlight in text
                $beforeword = substr($textarray[$lineindex], 0, $position);
                $afterword = substr($textarray[$lineindex], $position + strlen($word));
                $textarray[$lineindex] = $beforeword . "{$opener}{$word}{$closer}" . $afterword;
                // dirty hack for recalculating next index position
                $poscorrect = $poscorrect + strlen("{$opener}{$closer}");
            } else {
                $poscorrect = 0;
                $lineindex = $lineindex + 1;
            }
        }
    }
    $toret = implode("\n", $textarray);
    //$toret = str_replace("\"", "&quot;", $toret);
    return array($toret, $jstext);
}
예제 #2
0
<?php 
function my_exec($cmd, $input = '')
{
    $proc = proc_open($cmd, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
    fwrite($pipes[0], $input);
    fclose($pipes[0]);
    $stdout = stream_get_contents($pipes[1]);
    fclose($pipes[1]);
    $stderr = stream_get_contents($pipes[2]);
    fclose($pipes[2]);
    $rtn = proc_close($proc);
    return array('stdout' => $stdout, 'stderr' => $stderr, 'return' => $rtn);
}
$command = 'svn update';
echo 'Command: <pre>' . $command . '</pre><br>';
$vals = my_exec($command, '');
echo 'stdout:<br><hr>';
echo "<pre>\n";
echo $vals['stdout'];
echo '</pre><hr>';
echo 'stderr:<br><hr>';
echo '<pre>';
echo $vals['stderr'];
echo '</pre><hr>';
echo '<p>Returned: ' . $vals['return'];
?>

</body>
</html>
    while ($row = mysql_fetch_array($sql)) {
        $device = $row['iphost'];
    }
    $sql6c = mysql_query(" select * from hosts where host='{$device}' ");
    while ($row = mysql_fetch_array($sql6c)) {
        $ip = $row['ip'];
    }
    $sql6 = mysql_query(" select * from tblDemo2 where Hostname='{$device}' ");
    while ($row = mysql_fetch_array($sql6)) {
        $password = $row['Passwrd'];
        $username = $row['Username'];
    }
    $out .= "\n" . $device . " :  \n";
    $commande = 'sh mac address-table static';
    //echo "plink -ssh ".$username."@".$ip." -pw ".' '.$password.' '.'"'. $commande.'"';
    $p2 = my_exec("(echo 'y') | /usr/local/bin/plink -ssh " . $username . "@" . $ip . " -pw " . ' ' . $password . ' ' . '"' . $commande . '"');
    $out .= $p2["stdout"];
    $name = $device . '.out';
    $monfichier = fopen("Maclogs/{$name}", "r+");
    fputs($monfichier, $out);
    fclose($monfichier);
}
date_default_timezone_set('UTC');
$date = date("d-m-Y");
$heure = date("H:i");
$time = $date . "  " . $heure;
print "Mis à jour le {$date} à {$heure} ";
$sql233 = mysql_query("truncate table time");
$sqltime = mysql_query("INSERT INTO time(time) VALUES('{$time}')");
?>
    
예제 #4
0
        #echo(" -> Found a jpg: ${file}\n");
        log_message("* [Evaluating for blank: /tmp/{$file}]");
        $retval = my_exec("/usr/local/bin/detect_blank_page.sh /tmp/{$file}");
        log_message("*  *Returned value {$retval}]");
        if (strpos($retval, 'blank') !== false) {
            log_message("*  *  *Removing blank file: /tmp/{$file}");
            my_exec("rm /tmp/{$file}");
            // blank page detected, remove it
        } else {
            log_message("* *  *Leaving file alone, not blank: /tmp/{$file}");
        }
    }
}
# Convert the image and copy to the correct filename
log_message("* Converting from .jpg to .tif with lzw compression");
$convertlog = my_exec("/opt/local/bin/convert -compress lzw -units PixelsPerInch /tmp/lastscan*.jpg -density 150 -colorspace Gray /tmp/lastscan.tif");
# Detect some common errors and display messages to user
if (!file_exists('/tmp/lastscan.tif')) {
    log_message("* Error: unable to locate a file named /tmp/lastscan.tif. Exiting.");
    $error = "Unable to locate the scanned file.  Please call Neal for support.";
    die("Error Scanning: " . $error . "\n");
}
# Copying the lastscan.tif file to whatever filename TBE is expecting
log_message("* Copying the file from /tmp/lastscan.tif to /tmp/{$cfg->UnixFile}");
system("cp /tmp/lastscan.tif /tmp/{$cfg->UnixFile}");
notifyuser("Uploading", "Floating your pixels up to the cloud.");
# Upload the file
$data = array("destdir" => $cfg->UnixDir, "file" => "@/tmp/{$cfg->UnixFile}");
log_message("* Preparing to use curl to send the file.  data is set to {$data}");
$ch = curl_init($cfg->UnixUrl);
log_message("* Result of curl_init is {$ch}");
예제 #5
0
    }
}
// теперь в $ops остались те, кто только что стал опом
$changed = array_merge($changed, $ops);
// массив user, new_class
$myFile = "/tmp/ops_changed.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
foreach ($changed as $nick => $op) {
    fwrite($fh, $nick . "\n");
}
fclose($fh);
system("chmod 777 {$myFile}");
db_set_ops($changed);
putenv("HOME=/etc/verlihub/");
putenv("LC_ALL=ru_RU.utf8");
$tmp = my_exec("/usr/local/bin/microdc2", $input = 'say пыщ');
echo $tmp['stderr'];
function my_exec($cmd, $input = '')
{
    $proc = proc_open($cmd, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
    sleep(1);
    fwrite($pipes[0], $input);
    sleep(1);
    fclose($pipes[0]);
    $stdout = stream_get_contents($pipes[1]);
    fclose($pipes[1]);
    $stderr = stream_get_contents($pipes[2]);
    fclose($pipes[2]);
    $rtn = proc_close($proc);
    return array('stdout' => $stdout, 'stderr' => $stderr, 'return' => $rtn);
}
예제 #6
0
 function validate_imagick()
 {
     $pos = strpos(my_exec('convert'), 'ImageMagick');
     if ($pos === false) {
         return 0;
     } else {
         return 1;
     }
 }
예제 #7
0
# Function Definitions
###############################################################
# Handle running a process and including stderr in stdout
function my_exec($cmd)
{
    $proc = proc_open($cmd, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
    $stdout = stream_get_contents($pipes[1]);
    fclose($pipes[1]);
    $stdout .= stream_get_contents($pipes[2]);
    fclose($pipes[2]);
    $rtn = proc_close($proc);
    return $stdout;
}
# Notifications to provide the user with some feedback as to what's going on.
function notifyuser($title, $msg)
{
    exec("osascript -e 'display notification \"{$msg}\" with title \"{$title}\"'");
}
# Check if a function exists. Use this to catch missing packages.
function command_exist($cmd)
{
    $returnVal = shell_exec("which {$cmd}");
    return empty($returnVal) ? false : true;
}
###############################################################
# Call the Scanning App
###############################################################
my_exec("logger BSM file located at: {$argv['1']}");
my_exec("logger Calling the scanning app now");
my_exec("open -n /Applications/ScannerApp.app --args \"{$argv['1']}\" silent");