Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/captainhook/captainhook/src/Hook/Template/Local/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/captainhook/captainhook/src/Hook/Template/Local/Shell.php
<?php

/**
 * This file is part of CaptainHook
 *
 * (c) Sebastian Feldmann <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace CaptainHook\App\Hook\Template\Local;

use CaptainHook\App\CH;
use CaptainHook\App\Hook\Template;
use CaptainHook\App\Hooks;
use SebastianFeldmann\Camino\Path;
use SebastianFeldmann\Camino\Path\Directory;
use Symfony\Component\Process\PhpExecutableFinder;

/**
 * Shell class
 *
 * Generates the sourcecode for the php hook scripts in .git/hooks/*.
 *
 * @package CaptainHook
 * @author  Sebastian Feldmann <[email protected]>
 * @link    https://github.com/captainhookphp/captainhook
 * @since   Class available since Release 5.0.0
 */
class Shell extends Template\Local
{
    /**
     * Returns lines of code for the local src installation
     *
     * @param  string $hook
     * @return array<string>
     */
    protected function getHookLines(string $hook): array
    {
        $useStdIn = ' <&0';
        $useTTY   = [];

        if (Hooks::allowsUserInput($hook)) {
            $useStdIn = '';
            $useTTY   = [
                'if [ -t 1 ]; then',
                '    # If we\'re in a terminal, redirect stdout and stderr to /dev/tty and',
                '    # read stdin from /dev/tty. Allow interactive mode for CaptainHook.',
                '    exec >/dev/tty 2>/dev/tty </dev/tty',
                '    INTERACTIVE=""',
                'fi',
            ];
        }

        return array_merge(
            [
                '#!/bin/sh',
                '',
                '# installed by CaptainHook ' . CH::VERSION,
                '',
                'INTERACTIVE="--no-interaction"',
            ],
            $useTTY,
            [
                '',
                $this->getExecutable()
                    . ' $INTERACTIVE'
                    . ' --configuration=' . $this->pathInfo->getConfigPath()
                    . ' --bootstrap=' . $this->config->getBootstrap()
                    . ' hook:' . $hook . ' "$@"' . $useStdIn,
            ]
        );
    }

    /**
     * Returns the path to the executable including a configured php executable
     *
     * @return string
     */
    private function getExecutable(): string
    {
        $executable = !empty($this->config->getPhpPath()) ? $this->config->getPhpPath() . ' ' : '';

        if (!empty($this->config->getRunConfig()->getCaptainsPath())) {
            return $executable . $this->config->getRunConfig()->getCaptainsPath();
        }

        return $executable . $this->pathInfo->getExecutablePath();
    }
}

Spamworldpro Mini