Improvemenet name file support

This commit is contained in:
Marco Antonio Nina
2014-10-21 15:35:39 -04:00
parent ff3e14b674
commit 78b73256f2
2 changed files with 230 additions and 202 deletions

View File

@@ -5309,7 +5309,8 @@ class G
return $arrayData; return $arrayData;
} }
public static function buildFrom($configuration, $from = '') { public static function buildFrom($configuration, $from = '')
{
if (!isset($configuration['MESS_FROM_NAME'])) { if (!isset($configuration['MESS_FROM_NAME'])) {
$configuration['MESS_FROM_NAME'] = ''; $configuration['MESS_FROM_NAME'] = '';
} }
@@ -5352,215 +5353,234 @@ class G
* *
* *
*/ */
public function verifyInputDocExtension($InpDocAllowedFiles, $filesName, $filesTmpName){ public function verifyInputDocExtension($InpDocAllowedFiles, $filesName, $filesTmpName)
$allowedTypes = explode(", ", $InpDocAllowedFiles); {
$flag = 0; $allowedTypes = explode(", ", $InpDocAllowedFiles);
$res = new stdclass(); $flag = 0;
$res = new stdclass();
if (!extension_loaded('fileinfo')) { if (!extension_loaded('fileinfo')) {
$dtype = explode(".", $filesName); $dtype = explode(".", $filesName);
foreach ($allowedTypes as $types => $val) { foreach ($allowedTypes as $types => $val) {
if((preg_match('/^\*\.?[a-z]{2,8}$/', $val)) || ($val == '*.*')){ if ((preg_match('/^\*\.?[a-z]{2,8}$/', $val)) || ($val == '*.*')) {
$allowedDocTypes = substr($val, 2); $allowedDocTypes = substr($val, 2);
if(($dtype[count($dtype) -1]) == $allowedDocTypes || $allowedDocTypes == '*'){ if (($dtype[count($dtype) -1]) == $allowedDocTypes || $allowedDocTypes == '*') {
$res->status = true; $res->status = true;
return $res; return $res;
break; break;
} else { } else {
$flag = 1; $flag = 1;
} }
} else { } else {
$res->status = false; $res->status = false;
$res->message = G::LoadTranslation('ID_UPLOAD_ERR_WRONG_ALLOWED_EXTENSION_FORMAT' ); $res->message = G::LoadTranslation('ID_UPLOAD_ERR_WRONG_ALLOWED_EXTENSION_FORMAT' );
return $res; return $res;
} }
} }
} else { } else {
$finfo = new finfo(FILEINFO_MIME_TYPE); $finfo = new finfo(FILEINFO_MIME_TYPE);
$finfo_ = $finfo->file($filesTmpName); $finfo_ = $finfo->file($filesTmpName);
$docType = explode("/", $finfo_); $docType = explode("/", $finfo_);
foreach ($allowedTypes as $types => $val) { foreach ($allowedTypes as $types => $val) {
if((preg_match('/^\*\.?[a-z]{2,8}$/', $val)) || ($val == '*.*')){ if ((preg_match('/^\*\.?[a-z]{2,8}$/', $val)) || ($val == '*.*')) {
$allowedDocTypes = substr($val, 2); $allowedDocTypes = substr($val, 2);
$dtype = explode(".", $filesName); $dtype = explode(".", $filesName);
switch($allowedDocTypes){ switch($allowedDocTypes){
case '*': case '*':
$res->status = true; $res->status = true;
return $res; return $res;
break; break;
case 'xls': case 'xls':
if($docType[1] == 'vnd.ms-excel' || ($dtype[count($dtype) - 1] == 'xls' && $docType[1] == 'plain')){ if($docType[1] == 'vnd.ms-excel' || ($dtype[count($dtype) - 1] == 'xls' && $docType[1] == 'plain')){
$res->status = true; $res->status = true;
return $res; return $res;
} else { } else {
$flag = 1; $flag = 1;
} }
break; break;
case 'doc': case 'doc':
if($docType[1] == 'msword' || ($dtype[count($dtype) - 1] == 'doc' && $docType[1] == 'html')){ if($docType[1] == 'msword' || ($dtype[count($dtype) - 1] == 'doc' && $docType[1] == 'html')){
$res->status = true; $res->status = true;
return $res; return $res;
} else { } else {
$flag = 1; $flag = 1;
} }
break; break;
case 'ppt': case 'ppt':
if($docType[1] != 'vnd.ms-office'){ if ($docType[1] != 'vnd.ms-office') {
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
break; break;
case 'docx': case 'docx':
case 'pptx': case 'pptx':
case 'xlsx': case 'xlsx':
if($docType[1] != 'zip'){ if ($docType[1] != 'zip') {
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
break; break;
case 'exe': case 'exe':
case 'wmv': case 'wmv':
if($docType[1] != 'octet-stream'){ if($docType[1] != 'octet-stream'){
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
break; break;
case 'jpg': case 'jpg':
if ($docType[1] != 'jpeg'){ if ($docType[1] != 'jpeg'){
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
break; break;
case 'mp3': case 'mp3':
if ($docType[1] != 'mpeg'){ if ($docType[1] != 'mpeg'){
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
break; break;
case 'rar': case 'rar':
if ($docType[1] != 'x-rar'){ if ($docType[1] != 'x-rar'){
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
break; break;
case 'txt': case 'txt':
case 'pm': case 'pm':
if ($docType[1] != 'plain'){ if ($docType[1] != 'plain'){
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
break; break;
case 'htm': case 'htm':
case 'html': case 'html':
if ($docType[1] != 'html'){ if ($docType[1] != 'html'){
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
break; break;
case 'po': case 'po':
if ($docType[1] != 'x-po'){ if ($docType[1] != 'x-po'){
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
break; break;
case 'pdf': case 'pdf':
case 'png': case 'png':
case 'jpeg': case 'jpeg':
case 'gif': case 'gif':
case 'zip': case 'zip':
case 'mp4': case 'mp4':
if ($docType[1] != $allowedDocTypes){ if ($docType[1] != $allowedDocTypes){
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
break; break;
default: default:
if(($dtype[count($dtype) - 1]) != $allowedDocTypes){ if(($dtype[count($dtype) - 1]) != $allowedDocTypes){
$flag = 1; $flag = 1;
} else { } else {
$res->status = true; $res->status = true;
return $res; return $res;
} }
} }
} else { } else {
$res->status = false; $res->status = false;
$res->message = G::LoadTranslation('ID_UPLOAD_ERR_WRONG_ALLOWED_EXTENSION_FORMAT' ); $res->message = G::LoadTranslation('ID_UPLOAD_ERR_WRONG_ALLOWED_EXTENSION_FORMAT' );
return $res; return $res;
} }
} }
} }
if( $flag == 1){ if ( $flag == 1) {
$res->status = false; $res->status = false;
$res->message = G::LoadTranslation('ID_UPLOAD_ERR_NOT_ALLOWED_EXTENSION' ) . ' ' . $filesName; $res->message = G::LoadTranslation('ID_UPLOAD_ERR_NOT_ALLOWED_EXTENSION' ) . ' ' . $filesName;
return $res; return $res;
} }
} }
/** /**
* Get the actual browser. * Get the actual browser.
*/ */
public function getActualBrowser(){ public function getActualBrowser ()
$browser=array("TRIDENT","IE","OPERA","MOZILLA","NETSCAPE","FIREFOX","SAFARI","CHROME"); {
$info['browser'] = "OTHER"; $browser=array("TRIDENT","IE","OPERA","MOZILLA","NETSCAPE","FIREFOX","SAFARI","CHROME");
$info['browser'] = "OTHER";
foreach($browser as $parent){
if($parent == 'TRIDENT'){ foreach ($browser as $parent) {
$parent = "RV"; if( $parent == 'TRIDENT') {
} $parent = "RV";
$s = strpos(strtoupper($_SERVER['HTTP_USER_AGENT']), $parent); }
$f = $s + strlen($parent); $s = strpos(strtoupper($_SERVER['HTTP_USER_AGENT']), $parent);
$version = substr($_SERVER['HTTP_USER_AGENT'], $f, 15); $f = $s + strlen($parent);
$version = preg_replace('/[^0-9,.]/','',$version); $version = substr($_SERVER['HTTP_USER_AGENT'], $f, 15);
if ($s){ $version = preg_replace('/[^0-9,.]/','',$version);
$info['browser'] = $parent; if ($s) {
$info['version'] = $version; $info['browser'] = $parent;
} $info['version'] = $version;
} }
}
$info['browser'] = ($info['browser']=='RV')? 'IE':$info['browser']; $info['browser'] = ($info['browser']=='RV')? 'IE':$info['browser'];
return $info; return $info;
} }
/** /*
* Check the browser compativility * Check the browser compativility
*/ */
public function checkBrowserCompatibility($browser = null, $version = null){ public function checkBrowserCompatibility($browser = null, $version = null)
if($browser == null || $version == null){ {
$info = G::getActualBrowser(); if ($browser == null || $version == null) {
$browser = $info['browser']; $info = G::getActualBrowser();
$version = $info['version']; $browser = $info['browser'];
} $version = $info['version'];
if ((($browser== 'IE') && (($version >= 8) && ($version <= 11))) || }
(($browser== 'CHROME') && ($version >= 26)) || if ((($browser== 'IE') && (($version >= 8) && ($version <= 11))) ||
(($browser== 'FIREFOX') && ($version >= 20)) (($browser== 'CHROME') && ($version >= 26)) ||
){ (($browser== 'FIREFOX') && ($version >= 20))
return true; ) {
} return true;
return false; }
return false;
} }
/*
* $string - The string to sanitize.
* $lowercase - Force the string to lowercase?
* $alpha - If set to *true*, will remove all non-alphanumeric characters.
*/
public function sanitizeString ($string, $lowercase = true, $alpha = false)
{
$strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
"}", "\\", "|", ";", ":", "\"", "'", "&#8216;", "&#8217;", "&#8220;", "&#8221;", "&#8211;", "&#8212;",
"—", "–", ",", "<", ".", ">", "/", "?");
$clean = trim(str_replace($strip, "", strip_tags($string)));
$clean = preg_replace('/\s+/', "-", $clean);
$clean = ($alpha) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ;
$clean = ($force_lowercase) ? (function_exists('mb_strtolower')) ? mb_strtolower($clean, 'UTF-8') : strtolower($clean) : $clean;
return $clean;
}
} }
/** /**

View File

@@ -1399,13 +1399,21 @@ class adminProxy extends HttpProxyController
//Database server Version (MySQL version) //Database server Version (MySQL version)
$installer = new Installer(); $installer = new Installer();
$systemInfo = $installer->getSystemInfo(); $systemInfo = $installer->getSystemInfo();
$params['dbVersion'] = mysql_get_server_info();//$systemInfo->mysql->version; try {
$params['dbVersion'] = mysql_get_server_info();
} catch (Exception $e) {
$params['dbVersion'] = '';
}
//PHP Version //PHP Version
$params['php'] = $systemInfo->php->version; $params['php'] = $systemInfo->php->version;
//Apache - IIS Version //Apache - IIS Version
$params['apache'] = apache_get_version(); try {
$params['apache'] = apache_get_version();
} catch (Exception $e) {
$params['apache'] = '';
}
//Installed Plugins (license info?) //Installed Plugins (license info?)
$arrayAddon = array (); $arrayAddon = array ();
@@ -1472,7 +1480,7 @@ class adminProxy extends HttpProxyController
//Country/city (Timezone) //Country/city (Timezone)
$params["Timezone"] = (defined('TIME_ZONE') && TIME_ZONE != "Unknown") ? TIME_ZONE : date_default_timezone_get(); $params["Timezone"] = (defined('TIME_ZONE') && TIME_ZONE != "Unknown") ? TIME_ZONE : date_default_timezone_get();
$support = PATH_DATA_SITE . SYS_SYS . '-' . date('YmdHis') . '.spm'; $support = PATH_DATA_SITE . G::sanitizeString($licenseManager->info['FIRST_NAME'] . '-' . $licenseManager->info['LAST_NAME'] . '-' . SYS_SYS . '-' . date('YmdHis'), false, false) . '.spm';
file_put_contents($support, serialize($params)); file_put_contents($support, serialize($params));
G::streamFile($support, true); G::streamFile($support, true);
G::rm_dir($support); G::rm_dir($support);