Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nouvelle fonction plxUtils::sanitizePhp() #565

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/lib/class.plx.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ public function editStatique($content) {
# Génération du nom du fichier de la page statique
$filename = PLX_ROOT.$this->aConf['racine_statiques'].$content['id'].'.'.$this->aStats[ $content['id'] ]['url'].'.php';
# On écrit le fichier
if(plxUtils::write($content['content'],$filename))
if(plxUtils::write(plxUtils::sanitizePhp($content['content']),$filename))
return plxMsg::Info(L_SAVE_SUCCESSFUL);
else
return plxMsg::Error(L_SAVE_ERR.' '.$filename);
Expand Down
24 changes: 23 additions & 1 deletion core/lib/class.plx.utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,8 @@ public static function strCheck($str) {
**/
public static function cdataCheck($str) {
$str = str_ireplace('!CDATA', '!CDATA', $str);
return str_replace(']]>', ']]>', $str);
$str = str_replace(']]>', ']]>', $str);
return self::sanitizePhp($str);
}

/**
Expand Down Expand Up @@ -1494,4 +1495,25 @@ public static function printLinkCss($file, $admin=false) {
}
}

/**
* Remove Php opening and closing tags
*
* Deprecated !
* @param String $content
* @return array|string|string[]
* @author Pedro "P3ter" CADETE, Moritz Huppert
*/
public static function sanitizePhpTags(String $content) {
return str_ireplace(array("<?php","<?", "?>"), "", $content);;
}

/**
* Remove critical functions from PHP
* @param String $content
* @return String
* @author Jean-Pierre Pourrez aka bazooka07
**/
public static function sanitizePhp(String $content) {
return preg_replace('#\b(fsockopen|proc_open|system|exec|chroot|shell_exec|socket\w*)\b\([^)]*?\)\s*;#', '/* $1() not allowed here */;' . PHP_EOL, $content);
}
}