Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/patientapps_www/modules/connectionDirect/model/ |
Upload File : |
<?php
// copied from agentLinux
// Connect to a server, also test connection_aborted
require_once realpath(__DIR__ . '/../../output/model/output_base.php');
// to do: run in background; capture output; pipe to pkp; view update in realtime
class Connection {
private $DATA;
protected $timeout;
// while this is enabled, crontab cannot run - ownership problem:
// protected $logging = '/phil/connection.txt';
protected $logging = FALSE;
protected $output_transport; // class for returning process output to the user.
private $lp = FALSE;
private $x_script;
public $error_output;
private $operatingsystem;
private $temp;
public function __construct() {
# attach the appropriate `output_base` class
$this->output_transport = \output_base::Transport();
$this->operatingsystem = 'linux';
$this->temp = '/tmp';
}
public function ServerData() {
if (func_num_args()) {
$this->DATA = func_get_arg(0);
return $this;
}
return $this->DATA;
}
public function timeout() {
if (func_num_args()) {
$this->timeout = func_get_arg(0);
return $this;
}
return $this->timeout;
}
public function LogFilename() {
if (func_num_args()) {
$this->logging = func_get_arg(0);
return $this;
}
return $this->logging;
}
public function OperatingSystem() {
if (func_num_args()) {
$this->operatingsystem = func_get_arg(0);
return $this;
}
return $this->operatingsystem;
}
public function Temp() {
if (func_num_args()) {
$this->temp = func_get_arg(0);
return $this;
}
return $this->temp;
}
public function isWindows() {
return stripos($this->operatingsystem, 'WIN') === 0;
}
public function getServerId() {
return $this->DATA->server_id;
}
public function Log($message) {
if ($this->logging !== FALSE) {
if ($this->lp === FALSE) $this->lp = fopen($this->logging, 'a');
$dt = date('Y-m-d H:i:s');
if (is_resource($this->lp)) {
fwrite($this->lp, "$dt: {$message}\n");
}
}
}
public function LogOutput($remotecommand) {
if (is_resource($this->lp)) {
$output = $remotecommand->output;
if (substr($output, 0, 2) == "\x1f\x8b") {
fwrite($this->lp, "(gzipped output)\n");
$output = gzdecode($output);
}
fwrite($this->lp, "\n\n{$output}\n\n");
if (trim($remotecommand->error) != '') {
fwrite($this->lp, "\n\nSTDERR:\n{$remotecommand->error}\n\n");
}
}
}
// if logged in (and FULL), perform checks:
// uptime
// 32/64bit
// webserver used: apache, httpd, nginx
// mysql used. socket, version, etc/?
// ... and any other checks requested by other modules
// this will fail (will never return) if mod_rewrite is disabled
public function GetServerStatus() {
if ($this->isWindows()) {
$sequence = hook_list('agent.windows');
} else {
$sequence = hook_list('agent.linux');
}
foreach($sequence as $priority => $items) {
foreach($items as $item) {
$item->connection($this);
$this->Execute($item);
}
}
}
public function Execute($remote) {
// this must be overridden.
}
public function ExecuteScript($script, $user, $decompress = FALSE) {
$this->x_script = $script;
$remote = remote_script([$this, '__generic_script'], NULL, $user, $this);
$this->timeout(600); // this may take a while
$j = $this->Execute($remote);
$this->timeout(15);
$this->error_output = $remote->error;
$output = $remote->output;
if ($decompress && substr($output, 0, 2) == "\x1f\x8b") {
$output = gzdecode($output);
}
// j = -3: script not executed.
return ($j == -3) ? FALSE : $output;
}
function __generic_script($remote) {
return $this->x_script;
}
public function UploadFile($filename, $content) {
}
// upload the file, return commands to execute and delete target file
protected function prepareScript($content, $user) {
$content = str_replace("\r\n", "\n", $content);
$filename = 'pkp' . mt_rand(100000,999999);
$folder = $this->Temp();
if ($this->isWindows()) { // must always be a php file, and must self delete?
$filename = $folder . '\\' . $filename;
$this->Log("\n\nPUT: $filename\n\n$content\n");
$this->UploadFile($filename, $content);
// to do: eggshell
return ['', $filename]; // client will locate php, run it, then delete the temp file
} else {
if (empty($folder)) $folder = '/tmp';
$filename = $folder . '/' . $filename;
$this->Log("\n\nPUT: $filename\n\n$content\n");
$this->UploadFile($filename, $content);
$executableCommand = $filename;
// We don't need to do anything with the output - so direct it to seashells or eggshell.
if ($this->output_transport->isBackground()) {
$executableCommand = $this->output_transport->prepareCommand($executableCommand);
if ($executableCommand === NULL) { // no command to be executed - assume already done
return [ NULL, NULL ];
}
}
if ($user != 'root') {
$prefix = "chmod 755 $filename; chown $user:$user $filename; ";
$command = "$executableCommand; rm $filename";
} else {
$prefix = '';
$command = "chmod 755 $filename; $executableCommand; rm $filename";
}
return [$prefix, $command];
}
}
// log in
public function EstablishConnection() {
}
}