Jump to content

Problem Validation on PrestaShop Addons: "automatic declination"


Recommended Posts

I am trying to publish a payment form on PrestaShop Addons. But I get the automatic message:

"The use of smarty templates is mandatory to display HTML. Your PHP code should not contain HTML."

 

post-416237-0-53193300-1492701602_thumb.jpg

Online validation (https://validator.prestashop.com) does not detect any problems, maybe it's the code (/controllers/front/validation.php):

if (!$authorized)
   die($this->module->l('This payment method is not available.', 'validation'));
Edited by Arteinfo (see edit history)
Link to comment
Share on other sites

 

I am trying to publish a payment form on PrestaShop Addons. But I get the automatic message:

 

"The use of smarty templates is mandatory to display HTML. Your PHP code should not contain HTML."

 

attachicon.gifcarta-docenti.jpg

Online validation (https://validator.prestashop.com) does not detect any problems, maybe it's the code (/controllers/front/validation.php):

if (!$authorized)
   die($this->module->l('This payment method is not available.', 'validation'));

 

It's not this code.

Link to comment
Share on other sites

  • 3 months later...
Hello,

 

I have the same problem. Can you tell me if this was due to a similar code?

 



array(
'type' => 'html',
'label' => $this->l('Maximum size'),
'name' => 'SIZE',
'required' => true,
'html_content' => '<input type="number" class="fixed-width-xl" min="10" max="90" onchange="changeSize();" id="SIZE" name="SIZE" value="'.Tools::getValue('SIZE', Configuration::get('SIZE')).'">'
),

Link to comment
Share on other sites

  • 3 months later...
  • 5 months later...

Hi,

I have the same problem, so I created this simple script for testing purpose.

You should put this script into your_prestashop_install/modules/ and change the $rootPath   = './azon'; with your module folder path.

Thanks,
Andrei D.

 

<?php
function scanDirRecursive($directory, $regex=null, $get="file", $useFullPath=false,  &$dirs=[], &$files=[]) {
	$iterator               = new DirectoryIterator ($directory);
	foreach($iterator as $info) {
		$fileDirName        = $info->getFilename();

		if ($info->isFile () && !preg_match("#^\..*?#", $fileDirName)) {
			if($get == 'file' || $get == 'both'){
				if($regex) {
					if(preg_match($regex, $fileDirName)) {
						if ($useFullPath) {
							$files[] = $directory . DIRECTORY_SEPARATOR . $fileDirName;
						}
						else {
							$files[] = $fileDirName;
						}
					}
				}else{
					if($useFullPath){
						$files[]   = $directory . DIRECTORY_SEPARATOR . $fileDirName;
					}else{
						$files[]   = $fileDirName;
					}
				}
			}
		}else if ($info->isDir()  && !$info->isDot()) {
			$fullPathName   = $directory . DIRECTORY_SEPARATOR . $fileDirName;
			if($get == 'dir' || $get == 'both') {
				$dirs[]     = ($useFullPath) ? $fullPathName : $fileDirName;
			}
			scanDirRecursive($fullPathName, $regex, $get, $useFullPath, $dirs, $files);
		}
	}

	if($get == 'dir') {
		return $dirs;
	}else if($get == 'file'){
		return $files;
	}
	return ['dirs' => $dirs, 'files' => $files];
}

$rootPath   = './azon';
$regex      = "#(\.php$)#";
$php_files    = scanDirRecursive($rootPath, $regex, 'file', true);

$html_tags = array( "a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr" );

foreach( $php_files as $file ){
	
	$file_content = file_get_contents( $file );
	
	if( trim($file_content) != "" ){
		
		echo "<h2>" . ( $file ) . "</h2>";
		
		foreach( $html_tags as $html_tag ){
			$pos = strpos( $file_content, "<" . $html_tag );
			
			if( $pos != false ){
				var_dump( "<pre>", htmlspecialchars( substr($file_content, $pos, ( strpos($file_content, PHP_EOL, $pos) ) - $pos) )  , "</pre>" ) ;  
			}
		}
	}
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...