403Webshell
Server IP : 103.119.228.120  /  Your IP : 18.117.232.215
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /var/softaculous/sitepad/editor/site-data/plugins/pagelayer/js/react/src/helpers/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /var/softaculous/sitepad/editor/site-data/plugins/pagelayer/js/react/src/helpers/html-to-react.js
import { createElement } from '@wordpress/element';
import { camelCaseAttrMap } from  "./camel-case-attribute-names";

// eslint-disable-next-line max-len
// https://github.com/facebook/react/blob/15.0-stable/src/renderers/dom/shared/ReactDOMComponent.js#L457
const voidElementTags = [
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr', 'menuitem', 'textarea'
];

// Render block on editor
export function pagelayerParseHtmlToReact(html, props){
	
	var reactEle = '';
	var data = [];
	
	const createElementArray = (node) => {
		
		node = jQuery(node)[0];
		
		if(node.nodeType === 3) {
			return node.data;
		}else if(node.nodeType === 8) {
			
			// FIXME: The following doesn't work as the generated HTML results in
			// "<!--  This is a comment  -->"
			// return '<!-- ' + node.data + ' -->';
			return '';
		}
		
		var localName = node.localName;
	
		// If we start typing like "<s" is changed to "<s< ="" div></s<>", so we replace "<" from tag name
		localName = localName.replace(/[^\w-]/g, '');
		
		if(voidElementTags.indexOf(localName) > -1){
			return pagelayer_createElement(node, props);
		}
		
		var data = '';
		var children = [];
		
		if(jQuery(node).children().length > 0){
			var cn = node.childNodes,
			i = 0;

			while(cn.length > i) {
				children.push(createElementArray(cn[i]));
				i += 1;
			}
			
		}else{
			data = node.innerText;
		}
		
		return pagelayer_createElement(node, props, data, children);
	}
	
	jQuery(html).each(function(){
		data.push( createElementArray(this) );
	});
		
	return data;
}

export function pagelayer_createElement(node, props, data, children){
		
	let elementProps = {};
	let isRichText = false;
	let isGroupHolder = false;
	var localName = node.localName;
	
	// If we start typing like "<s" is changed to "<s< ="" div></s<>", so we replace "<" from tag name
	localName = localName.replace(/[^\w-]/g, '');
	children = children || [];
	
	if(node.attributes){
		
		elementProps = Object.entries(node.attributes).reduce((result, [key, value]) => {
			var name = value.nodeName;
			var val = value.nodeValue;
			
			name = camelCaseAttrMap[name.replace(/[-:]/, '')] || name;
			
			if (name === 'style') {
				val = createStyleJsonFromString(val);
			} else if (name === 'class') {
				name = 'className';
			} else if (name === 'for') {
				name = 'htmlFor';
			} else if (name.startsWith('on')) {
				val = Function(val);
			} else if(name === 'pagelayer-editable'){
				isRichText = val;
			} else if(name === 'pagelayer-group-holder'){
				isGroupHolder = val;
			}

			if (booleanAttrs.includes(name) && (val || '') === '') {
				val = name;
			}

			result[name] = val;
			
			return result;
			
		}, elementProps);
	}
	
	// TODO: also pass el.atts
	if(isRichText){
		var eleProps = {
			tagName: localName,
			_props: props,
			propsName: isRichText,
			value: node.innerHTML
		}
		
		elementProps = {...elementProps, ...eleProps};
		return createElement(wp.PagelayerComponents['rich_text'], elementProps);
	}
	
	if(isGroupHolder){
		
		var eleProps = {
			TagName: localName,
			plTag: isGroupHolder,
			_props: props,
		};
		
		elementProps = {...elementProps, ...eleProps};
		var RenderGroupBlock = wp.PagelayerBlocks['addGroupBlock'];
		
		return createElement(RenderGroupBlock, elementProps);
	}
	
	const allChildren = data != null ? [data,].concat(children) : children;
	
	return createElement.apply( null, [localName, elementProps].concat(allChildren) );
}

// Boolean HTML attributes, copied from https://meiert.com/en/blog/boolean-attributes-of-html/,
// on the form React expects.
const booleanAttrs = [
	'allowFullScreen',
	'allowpaymentrequest',
	'async',
	'autoFocus',
	'autoPlay',
	'checked',
	'controls',
	'default',
	'disabled',
	'formNoValidate',
	'hidden',
	'ismap',
	'itemScope',
	'loop',
	'multiple',
	'muted',
	'nomodule',
	'noValidate',
	'open',
	'playsinline',
	'readOnly',
	'required',
	'reversed',
	'selected',
	'truespeed',
];

export function createStyleJsonFromString(styleString){
	
	styleString = styleString || '';
	const styles = styleString.split(/;(?!base64)/);
	var jsonStyles = {};
	
	for(let i = 0; i < styles.length; ++i){
		
		let singleStyle, key, value;
		singleStyle = styles[i].split(':');
		if (singleStyle.length > 2) {
			singleStyle[1] = singleStyle.slice(1).join(':');
		}

		key = singleStyle[0];
		value = singleStyle[1];
		
		if (typeof value === 'string'){
			value = value.trim();
		}

		if (key != null && value != null && key.length > 0 && value.length > 0) {
			
			// There are two ways to declare css keys in react first is lower case string and second is camel case
			// key = key.toLowerCase(); // This is first way
			
			// We use camel case way to create css
			// Don't camelCase CSS custom properties
			if(key.indexOf('--') !== 0) {
				key = key
					.trim()
					.split('-')
					.map((word, index) => {
						if (index === 0) {
							return word;
						}
						return word.charAt(0).toUpperCase() + word.slice(1);
					})
					.join('');
			}
				
			jsonStyles[key] = value;
		}
	}
	
	return jsonStyles;
}

Youez - 2016 - github.com/yon3zu
LinuXploit