예제 #1
0
/**
 * install_get_transcode_modes
 * get transcode modes available on this machine.
 */
function install_get_transcode_modes()
{
    $modes = array();
    if (command_exists('ffmpeg')) {
        $modes[] = 'ffmpeg';
    }
    if (command_exists('avconv')) {
        $modes[] = 'avconv';
    }
    return $modes;
}
<?php

error_reporting(E_ERROR | E_PARSE);
function command_exists($command)
{
    return !empty(system("command -v {$command}"));
}
global $dependencies_exist;
$dependencies_exist = true;
if (!command_exists('php')) {
    $dependencies_exist = false;
    echo "php missing" . PHP_EOL;
}
if (!command_exists('git')) {
    $dependencies_exist = false;
    echo "git missing" . PHP_EOL;
}
if ($dependencies_exist) {
    echo "All dependencies Found" . PHP_EOL;
} else {
    exit(0);
}
예제 #3
0
function translate_with_pkg_isocodes()
{
    if (false === gettext_available()) {
        return false;
    }
    if (command_exists('git')) {
        if (is_dir(__DIR__ . DIRECTORY_SEPARATOR . 'iso-codes')) {
            chdir(__DIR__ . DIRECTORY_SEPARATOR . 'iso-codes');
            $result = shell_exec("git pull");
            chdir(__DIR__);
        } else {
            $result = shell_exec("git clone git://anonscm.debian.org/pkg-isocodes/iso-codes.git --branch master --single-branch");
        }
    }
    if (!is_dir(__DIR__ . DIRECTORY_SEPARATOR . 'iso-codes' . DIRECTORY_SEPARATOR . 'iso_639')) {
        return false;
    }
    // Create the folder structure for gettext
    if (!file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'Locale')) {
        mkdir(__DIR__ . DIRECTORY_SEPARATOR . 'Locale');
    }
    if (!is_dir(__DIR__ . DIRECTORY_SEPARATOR . 'Locale')) {
        return false;
    }
    $dir_handle = opendir(__DIR__ . DIRECTORY_SEPARATOR . 'iso-codes' . DIRECTORY_SEPARATOR . 'iso_639');
    while (false !== ($file = readdir($dir_handle))) {
        $source_file = __DIR__ . DIRECTORY_SEPARATOR . 'iso-codes' . DIRECTORY_SEPARATOR . 'iso_639' . DIRECTORY_SEPARATOR . $file;
        $pathinfo = pathinfo($source_file);
        if (isset($pathinfo['extension'])) {
            if (strcasecmp($pathinfo['extension'], 'po') === 0) {
                if (!file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $pathinfo['filename'])) {
                    mkdir(__DIR__ . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $pathinfo['filename']);
                }
                if (is_dir(__DIR__ . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $pathinfo['filename'])) {
                    if (!file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $pathinfo['filename'] . DIRECTORY_SEPARATOR . 'LC_MESSAGES')) {
                        mkdir(__DIR__ . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $pathinfo['filename'] . DIRECTORY_SEPARATOR . 'LC_MESSAGES');
                    }
                    if (is_dir(__DIR__ . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $pathinfo['filename'] . DIRECTORY_SEPARATOR . 'LC_MESSAGES')) {
                        shell_exec('msgfmt "' . $source_file . '" -o "' . __DIR__ . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $pathinfo['filename'] . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR . 'messages.mo"');
                    }
                }
            }
        }
    }
    closedir($dir_handle);
}
예제 #4
0
파일: io.php 프로젝트: php-kit/tools
/**
 * Runs the `tput` command (if available) for controlling the terminal.
 *
 * @param string $s tput command argument.
 * @return string The output from the tput program or an empty string if tput is not available.
 */
function tput($s)
{
    static $available = null;
    if (is_null($available)) {
        $available = command_exists('tput') && `tput colors` > 8 && !stdoutIsRedirected();
    }
    return $available ? `tput {$s}` : '';
}
예제 #5
0
파일: syncr.php 프로젝트: jgrossi/syncr
function commands_check()
{
    $commands = array('rsync', 'ssh', 'sshpass', 'mysqldump', 'gzip', 'scp');
    foreach ($commands as $command) {
        if (!command_exists($command)) {
            return false;
        }
    }

    return true;
}