new pisilinux web sites

This commit is contained in:
Erkan IŞIK
2026-07-01 16:44:17 +03:00
commit b58488b586
21740 changed files with 2066209 additions and 0 deletions
+136
View File
@@ -0,0 +1,136 @@
<?php namespace ZN\Prompt;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
use ZN\Config;
use ZN\Buffering;
class Processor implements ProcessorInterface
{
/**
* @var string
*/
protected $output;
/**
* @var int
*/
protected $return;
/**
* @var string
*/
protected $driver;
/**
* @var array
*/
protected $getConfig;
/**
* Magic Constructor
*/
public function __construct()
{
$this->getConfig = Config::default('ZN\Prompt\PromptDefaultConfiguration')::get('Services', 'processor');
$this->driver = $this->getConfig['driver'];
}
/**
* Sapi Name
*
* @return string
*/
public function type() : string
{
switch( $name = substr($sapi = php_sapi_name(), 0, 3) )
{
case 'cli' :
case 'cgi' : return $name;
default : return $sapi; // @codeCoverageIgnore
}
}
/**
* Execute
*
* @param string $command
*
* @return string|false
*/
public function exec($command)
{
switch( $this->driver )
{
case 'exec':
$return = exec($command, $this->output, $this->return);
break;
case 'shell_exec':
case 'shell' :
$return = shell_exec($command);
$this->output = $this->_split($return);
$this->return = 0;
break;
case 'system':
$return = Buffering\Callback::do(function() use($command) {system($command, $this->return);});
$this->output = $this->_split($return);
break;
}
$this->driver = NULL;
return $return ?? false;
}
/**
* Select Driver
*
* @param string $driver
*
* @return Processor
*/
public function driver(string $driver) : Processor
{
$this->driver = $driver;
return $this;
}
/**
* Output
*
* @return array
*/
public function output() : array
{
return (array) $this->output;
}
/**
* Return
*
* @return int
*/
public function return() : int
{
return (int) $this->return;
}
/**
* Protected Split
*/
protected function _split($string)
{
return explode("\n", rtrim($string, "\n"));
}
}
@@ -0,0 +1,52 @@
<?php namespace ZN\Prompt;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
interface ProcessorInterface
{
/**
* Sapi Name
*
* @return string
*/
public function type() : string;
/**
* Execute
*
* @param string $command
*
* @return string|false
*/
public function exec($command);
/**
* Select Driver
*
* @param string $driver
*
* @return Processor
*/
public function driver(string $driver) : Processor;
/**
* Output
*
* @return array
*/
public function output() : array;
/**
* Return
*
* @return int
*/
public function return() : int;
}
@@ -0,0 +1,30 @@
<?php namespace ZN\Prompt;
/**
* ZN PHP Web Framework
*
* "Simplicity is the ultimate sophistication." ~ Da Vinci
*
* @package ZN
* @license MIT [http://opensource.org/licenses/MIT]
* @author Ozan UYKUN [ozan@znframework.com]
*/
/**
* Default Configuration
*
* Enabled when the configuration file can not be accessed.
*/
class PromptDefaultConfiguration
{
/*
|--------------------------------------------------------------------------
| Prompt
|--------------------------------------------------------------------------
|
| The current PHP path. Especially necessary for crontab.
|
*/
public $path = '/usr/bin/php';
public $driver = 'exec';
}