ACC SHELL

Path : /srv/www/vhosts/alfa-com/engine/
File Upload :
Current File : /srv/www/vhosts/alfa-com/engine/CoreTemplates.php

<?php
	// Author: Jakub Macek, CZ; Copyright: Poski.com s.r.o.; Code is 100% my work. Do not copy.
	
	class CoreTemplates
	{
		public static function plaintext0($template)
		{
			$result = i()->dispatch();
			echo View::common('messages-output-0');
		}

		public static function html($template)
		{
			$body = null;
			$head = null;
			
			if ($temp0 = view()->getTemplateOfType(Template::TYPE_FRAME))
				$body = $temp0->render();
			else if ($temp0 = view()->getTemplateOfType(Template::TYPE_MAIN))
				$body = $temp0->render();
				
			$temp0 = view()->getTemplateOfType(Template::TYPE_DEFAULT);
			if (!$temp0)
			{
				echo $body;
				return;
			}
			
			if ($temp0 = view()->getTemplateOfType(Template::TYPE_HTML_HEAD))
				$head = $temp0->render();

			if ($body === null)
			{
				header('HTTP/1.1 410 Gone');
				header('Status: 410');
				return;
			}

			if (page()->administration)
				echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
			else
				echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
			echo "\n".'<html xmlns="http://www.w3.org/1999/xhtml">';
			echo "\n".'	<head>';
			echo "\n".'		<meta http-equiv="content-type"     content="text/html; charset=utf-8" />';
			echo "\n".'		<meta http-equiv="content-language" content="'.L.'" />';
			if (!U::flagGet('reduced-meta'))
			{
				echo "\n".'		<meta http-equiv="cache-control"    content="no-cache" />';
				echo "\n".'		<meta http-equiv="pragma"           content="no-cache" />';
				echo "\n".'		<meta name="robots"                 content="index, follow" />';
				echo "\n".'		<meta name="author"                 content="Poski.com s.r.o." />';
				echo "\n".'		<meta name="copyright"              content="Poski.com s.r.o." />';
				echo "\n".'		<meta name="owner"                  content="Poski.com s.r.o." />';
				echo "\n".'		<meta name="keywords"               content="'.page()->keywords.'" />';
				echo "\n".'		<meta name="description"            content="'.page()->description.'" />';
			}
			$temp = page()->title;
			if (page()->title && page()->siteTitle)
				$temp .= page()->titleSeparator;
			$temp .= page()->siteTitle;
			echo "\n".'		<title>' . HTML::e($temp) . '</title>';
			echo "\n".$head;
			$temp = BASE . 'web/head.html';
			if (is_file($temp) && !@page()->administration)
				echo "\n" . str_replace(
					array('{#path#}', '{#locale#}'),
					array(PATH, L),
					file_get_contents($temp))
				. "\n";
			echo "\n".'	</head>';
			$body_class = 'location_' . page()->location . ' directory_' . rtrim(page()->directory, '/') . ' file_' . page()->file;
			$body_class = strtr($body_class, '-/', '__');
			echo "\n".'	<body class="'.$body_class.'">' . "\n";
			if (site()->googleAnalytics)
			{
				echo HTML::js('var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));')."\n";
				foreach (site()->googleAnalytics as $tracker)
				{
					$var = str_replace('-', '', $tracker);
					echo 'var pageTracker'.$var.' = _gat._getTracker("'.$tracker.'");';
					echo 'pageTracker'.$var.'._trackPageview();';
				}
			}
			echo $body;

			echo "\n".'	</body>';
			echo "\n".'</html>';
		}

		public static function head($template)
		{
			$a = (bool) ((page()->location == 'a') || (page()->location == 'aa'));
			$administration = (bool) (page()->location == 'administration');
			$apda = (bool) (page()->location == 'apda');
			
			if ($administration)
				$administration_version = page()->get('administrationTheme', 4);

			if ($a || $administration)
				echo '
				<script type="text/javascript"><!--//--><![CDATA[//><!--
					var G = new Object();
					G.site = new Object();
					G.site.path = "'.PATH.'";
					G.site.url = "'.site()->url.'";
					G.site.locales = '.json_encode(site()->locales).';
					G.page = new Object();
					G.page.panel = "'.page()->panel.'";
					G.page.viewstate = "'.page()->viewstate.'";
				//--><!]]></script>
				<script type="text/javascript" src="'.PATH.'web/_administration/application.js"></script>
				<script type="text/javascript" src="'.PATH.'web/_js/base64.js"></script>';
			if (page()->administration)
			{
				U::flagSet('tinymce', true);
				U::flagSet('jscalendar', true);
			}
			if (!$apda)
			{
				U::flagSet('jquery', true);
				//U::flagSet('slimbox2', true);
				U::flagSet('prettyPhoto', true);
				//U::flagSet('mootools', false);
			}
			if (page()->administration && !$apda)
				U::flagSet('thickbox', true);

			if ($a)
			{
				echo '		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_administration/a.css" />'."\n";
				if (is_file($temp = BASE . 'web/_administration/a.override.css'))
					echo '		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_administration/a.override.css" />'."\n";
			}	
			else if ($apda)
				echo '		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_administration/apda.css" />'."\n";
			else if ($administration)
			{
				echo '		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_administration/administration_v'.$administration_version.'.css" />'."\n";
				if (is_file($temp = BASE . 'web/_administration/administration.override.css'))
					echo '		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_administration/administration.override.css" />'."\n";
			}
			else
			{
				echo '		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_css/style.css" />'."\n";
				if (is_file($temp = BASE . 'web/' . L . '/_css/style.css'))
					echo '		<link rel="stylesheet" type="text/css" href="'.PATH.'web/'.L.'/_css/style.css" />'."\n";
			}

			if (U::flagGet('jquery'))
			{
				echo '		<script type="text/javascript" src="'.PATH.'web/_js/jquery.js"></script>'."\n";
				echo '		<script type="text/javascript" src="'.PATH.'web/_js/jquery.idTabs.js"></script>'."\n";
			}

			if (U::flagGet('lytebox'))
				echo '		<script type="text/javascript" src="'.PATH.'web/_js/lytebox.js"></script>
		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_css/lytebox.css" media="screen" />'."\n";
		
			if (U::flagGet('slimbox2'))
				echo '		<script type="text/javascript" src="'.PATH.'web/_js/slimbox2.js"></script>
		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_css/slimbox2.css" media="screen" />'."\n";
				
			if (U::flagGet('prettyPhoto'))
				echo '		<script type="text/javascript" src="'.PATH.'web/_js/jquery.prettyPhoto.js"></script>
		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_css/prettyPhoto.css" media="screen" />
		<script type="text/javascript"><!--//--><![CDATA[//><!--
			$(document).ready(function(){
				$("a[rel^=\'prettyPhoto\']").prettyPhoto();
			});
		//--><!]]></script>'."\n";

			if (U::flagGet('thickbox'))
				echo '		<script type="text/javascript" src="'.PATH.'web/_js/thickbox.js"></script>
		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_css/thickbox.css" media="screen" />'."\n";

			if (U::flagGet('tinymce'))
			{
				if (U::flagGet('tinymce-custom'))
				{
					echo file_get_contents(BASE . 'web/tinymce-head.html');
				}
				else
				{
					/*echo '<script type="text/javascript" src="'.PATH.'third-party/tiny_mce/tiny_mce_gzip.js"></script>
						<script type="text/javascript"><!--//--><![CDATA[//><!--
							tinyMCE_GZ.init({
								plugins : "style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",
								themes : "simple,advanced",
								languages : "cs,en",
								disk_cache : true,
								debug : false
							});
						//--><!]]></script>';*/
					echo '<script type="text/javascript" src="'.PATH.'third-party/tiny_mce/tiny_mce.js"></script>';
					/*echo '<script type="text/javascript"><!--//--><![CDATA[//><!--
							function kfm_for_tiny_mce(field_name, url, type, win)
							{
								window.SetUrl = function(url, width, height, caption)
								{
									win.document.forms[0].elements[field_name].value = url;
									if(caption)
									{
										win.document.forms[0].elements["alt"].value = caption;
										win.document.forms[0].elements["title"].value = caption;
									}
								}
								window.open("' . PATH . 'third-party/kfm/index.php?mode=selector&type=" + type, "kfm", "modal,width=800,height=600");
							}
						//--><!]]></script>';*/
					echo '<script type="text/javascript"><!--//--><![CDATA[//><!--
							function ajaxfilemanager(field_name, url, type, win)
							{
								tinyMCE.activeEditor.windowManager.open({
									url: "' . PATH . 'third-party/ajaxfilemanager/ajaxfilemanager.php",
									width: 782,
									height: 440,
									inline : "yes",
									close_previous : "no"
								},{
									window : win,
									input : field_name
								});
							}
						//--><!]]></script>';
					echo '<script type="text/javascript"><!--//--><![CDATA[//><!--
							tinyMCE.init({
								mode : "none",
								editor_selector : "mceEditor",
								theme : "advanced",
								entity_encoding : "raw",
								remove_linebreaks : false,
								apply_source_formatting : true,
								plugins : "style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",
								theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
								theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
								theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
								theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,|,visualchars,nonbreaking",
								theme_advanced_toolbar_location : "top",
								theme_advanced_toolbar_align : "left",
								theme_advanced_statusbar_location : "bottom",
								theme_advanced_resizing : true,
								extended_valid_elements : "a[name|href|target|title|onclick],img[style|class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
								file_browser_callback : "ajaxfilemanager",
								auto_resize : true,
								relative_urls : false,
								remove_script_host : true,
								document_base_url : "' . site()->url . '"
							});
						//--><!]]></script>';
				}
			}

			if (U::flagGet('jscalendar'))
			{
				echo '		<link rel="stylesheet" type="text/css" href="'.PATH.'web/_css/calendar.css" media="all" title="win2k-cold-1" />
		<script type="text/javascript" src="'.PATH.'web/_js/calendar.js"></script>'."\n";
				if (L == 'cs')
					echo '		<script type="text/javascript" src="'.PATH.'web/_js/calendar-cs-utf8.js"></script>'."\n";
				else
					echo '		<script type="text/javascript" src="'.PATH.'web/_js/calendar-en.js"></script>'."\n";
			}

			if (U::flagGet('mootools'))
				echo '		<script type="text/javascript" src="'.PATH.'web/_js/mootools.js"></script>'."\n";

			if (page()->redirect)
			{
				$timeout = page()->redirectTimeout; if (!$timeout) $timeout = 1;
				//echo '		' . HTML::js('setTimeout(\'window.location = " . ' . page()->redirect . ' . "\', 5000);');
				echo '		<meta http-equiv="refresh" content="'.$timeout.';url='.HTML::e(page()->redirect).'" />';
			}
		}

		public static function error404($template)
		{
			header('HTTP/1.1 404 Not Found');
			header('Status: 404');
			echo '<h1>404 ' . __('http-404', '@core') . '</h1>';
			echo '<p>' . __('http-404-message', '@core') . '</p>';
			echo '<p><a href="' . site()->url . '">' . site()->url . '</a></p>';
		}

		public static function administration_action($template)
		{
			//header('Content-Type: text/plain; charset=utf-8');
			$result = array();
			$result['info'] = array();
			$invocation = i();
			if ($invocation)
			{
				$invocation->dispatch();
				$url = $invocation->url(null, null, 1);
			}
			else
				$url = substr(site()->url, 0, strlen(site()->url) - strlen(PATH));
			$result['info']['url'] = $url;
			$result['info']['page'] = $GLOBALS["page"];
			$result['info']['title'] = page()->title;
			$result['info']['module'] = '';
			$result['messages'] = array();
			$result['output'] = '';
			if ($invocation)
			{
				$result['info']['module'] = $invocation->module()->id;
				foreach ($invocation->messages as $message)
					$result['messages'][] = $message;
				$result['output'] = View::common('output');
			}
				
			if ($template->get('encode', true))
				echo '=' . base64_encode(json_encode($result));
			else
				$GLOBALS['temp'] = $result;
		
			if (DEV)
			{
				$dump = '';
				$dump .= dump($result['info'], null, false, false);
				$dump .= $result['output'];
				file_put_contents(DATA . 'temp/action-output.html', $dump);
				chmod(DATA . 'temp/action-output.html', 0666);
			}
		}
		
		public static function list_filter_form($template)
		{
			$form = $template->get('form');
			
			if ((page()->location == 'a') || (page()->location == 'aa'))
			{
				echo '<div class="full" id="filter_form_container" style="display: none;">';
				echo $form->renderPrototype(null);;
				echo '</div>';
				echo '<div class="quick">';
				$counter = 0;
				$quick = array();
				foreach ($form->i('_main')->elementsRecursive() as $element)
					if ($element->get('filter-quick') || ($element->field && $element->field->get('filter-quick')))
						$quick[] = $element;
				if ($quick)
				{
					foreach ($quick as $element)
					{
						$element = clone($element);
						if (($element->type() == 'checkbox') || ($element->type() == 'radio'))
							$element->attributeSet('onclick', 'document.getElementById(\''.$element->id.'\').checked = this.checked;');
						else
							$element->attributeSet('onchange', 'document.getElementById(\''.$element->id.'\').value = this.value;');
						$element->id .= '_filter_quick';
						echo $element->renderPrototype(null);
					}
					foreach (array('filter-submit', 'filter-clear') as $element)
					{
						$element = $form->i('_submit')->i($element);
						$element = clone($element);
						$element->attributeSet('onclick', 'document.getElementById(\''.$element->id.'\').click();');
						$element->id .= '_filter_quick';
						echo $element->renderPrototype(null);
					}
				}
				echo '&nbsp;<a href="#" onclick="$(\'#filter_form_container\').toggle();">' . __('search-full', '#core') . '</a>';
				echo '</div>';
			}
			else
			{
				echo '<div class="full" id="filter_form_container" style="display: none;">';
				echo '<a href="#" class="close" onclick="$(\'#filter_form_container\').hide(); return false;">' . __('search-close', '#core') . '</a>';
				echo $form->renderPrototype(null);;
				echo '</div>';
			}
		}
		
		public static function data_image($template)
		{
			$file = U::request('file');
			$method = U::request('method');
			$fileX = explode('-', $file);
			$methodX = explode(',', $method);

			if (!$method)
			{
				header('Location: '.PATH.'data/blob/' . $file);
				return;
			}

			if (in_array($methodX[0], array('scale', 'scalecrop', 'scaleexpand')))
			{
				//TODO
			}
			else if (isset($methodX[1]))
			{
				$suffix = $methodX[1];
				$file_orig = DATA . 'blob/' . $file;
				$file_trans = DATA . 'blob/' . $file . $suffix;
				if (is_file($file_trans) && (filemtime($file_trans) > filemtime($file_orig)))
				{
					header('Location: '.PATH.'data/blob/' . $file . $suffix);
					header('X-Image-Regenerated: 0');
					return;
				}
				else if (o($fileX[0]))
				{
					$object = o($fileX[0]);
					$field = $methodX[0];
					if (isset($object->$field))
					{
						$field = $object->f($field);
						$field->imageTransform($file);
						header('X-Image-Regenerated: 1');
						header('Location: '.PATH.'data/blob/' . $file . $suffix);
						return;
					}
				}
				die('test');
			}

			echo 'error';
		}
		
		public static function data_blob_rename($template)
		{
			$file = U::request('file');;
			$newName = U::request('new-name'); 
			$path = DATA . 'blob/' . $file;

			if (is_file($path))
			{
				$disposition = 'attachment';
				$meta = array();
				if (is_file($path . '.meta'))
					$meta = U::metaStringToArray(file_get_contents($path . '.meta'));
				if (preg_match('~^([\w_]+)-([\w_]+)-(\d+)-(.*)\.([\w\d]+)$~', $file, $matches))
				{
					//$module = $matches[1];
					$type = strtr($matches[2], '_', '/');
					//$timestamp = strtotime($matches[3]);
					//$name = $matches[4];
					//$extension = $matches[5];
					
					if (!$newName)
						$newName = @$meta['name'];
					if (!$newName)
						$newName = 'unknown_file';
					
					$parameters = '';
					$parameters .= '; filename="'.$newName.'"';
					$parameters .= '; size="'.filesize($path).'"';
					
					header('Content-Type: ' . $type);
					header('Content-Disposition: ' . $disposition . $parameters);
					readfile($path);
					return;
				}
				else if ($meta)
				{
					$parameters = '';
					$parameters .= '; filename="'.@$meta['name'].'"';
					$parameters .= '; size="'.filesize($path).'"';
					
					if (@$meta['type'])
						header('Content-Type: ' . $meta['type']);
					header('Content-Disposition: ' . $disposition . $parameters);
					readfile($path);
					return;
				}
			}
				
			self::error404();
		}
	}
?>

ACC SHELL 2018