Attached Files |
273-Get_rid_of_ereg_functions_usage_because_slow_and_deprecated-Dmitry-20100211-v1-CORE.patch [^] (2,374 bytes) 2010-02-11 16:21
[Show Content]
Index: core/units/fck/fck_tp.php
===================================================================
--- core/units/fck/fck_tp.php (revision 13152)
+++ core/units/fck/fck_tp.php (working copy)
@@ -107,8 +107,8 @@
$size = ($size < 1)? 1:$size;// round( $iFileSize / 1024 ) ;
}
- eregi("(\.[a-zA-Z0-9]{1,10})$", $v, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
+ preg_match('/' . REGEX_FILE_EXENTION . '/i', $v, $regs);
+ $ext = strtolower( ltrim($regs[1], ".") );
if (in_array($ext, $a_ext))
{
$icon = $ext;
Index: core/units/helpers/fck_helper.php
===================================================================
--- core/units/helpers/fck_helper.php (revision 13152)
+++ core/units/helpers/fck_helper.php (working copy)
@@ -54,8 +54,8 @@
function IsAllowedExtension($folder, $file_name)
{
$base_folder = $this->getBaseFolder($folder);
- eregi("(\.[a-zA-Z0-9]{1,10})$", $file_name, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
+ preg_match('/' . REGEX_FILE_EXENTION . '/i', $file_name, $regs);
+ $ext = strtolower( ltrim($regs[1], ".") );
if (isset($this->Config['DeniedExtensions'][$folder])) {
if (in_array($ext, $this->Config['DeniedExtensions'][$folder])) {
return false;
@@ -146,8 +146,8 @@
{
$a_ext = Array('ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js','mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip');
- eregi("(\.[a-zA-Z0-9]{1,10})$", $v, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
+ preg_match('/' . REGEX_FILE_EXENTION . '/i', $v, $regs);
+ $ext = strtolower( ltrim($regs[1], ".") );
if (in_array($ext, $a_ext))
{
$icon = $ext;
Index: core/kernel/constants.php
===================================================================
--- core/kernel/constants.php (revision 13152)
+++ core/kernel/constants.php (working copy)
@@ -74,6 +74,7 @@
// common usage regular expressions
define('REGEX_EMAIL_USER', '[-a-zA-Z0-9!\#$%&*+\/=?^_`{|}~.]+');
define('REGEX_EMAIL_DOMAIN', '[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\.[a-zA-Z]{2,6}');
+ define('REGEX_FILE_EXENTION', '\.[a-zA-Z0-9]{1,10}$');
define('ALLOW_DEFAULT_SETTINGS', '_USE_DEFAULT_USER_DATA_'); //Allow persistent vars to take data from default user's persistent data
define('XML_NO_TEXT_NODES', 1); // Normal mode for XMLHelper
273-Get_rid_of_ereg_functions_usage_because_slow_and_deprecated-Dmitry-20100211-v1-In-Commerce.patch [^] (5,976 bytes) 2010-02-11 19:08
[Show Content]
Index: in-commerce/units/orders/orders_item.php
===================================================================
--- in-commerce/units/orders/orders_item.php (revision 13152)
+++ in-commerce/units/orders/orders_item.php (working copy)
@@ -333,34 +333,34 @@
// Innocent until proven guilty
$cc_valid = true;
- // Get rid of any non-digits
- $value = ereg_replace("[^[:digit:]]", '', $value);
+ // Get rid of any non-digits
+ $value = preg_replace('/[^\d]/', '', $value);
// Perform card-specific checks, if applicable
switch( $this->GetDBField($cardtype_field) )
{
case 2: // MasterCard
- $cc_valid = ereg("^5[1-5].{14}$", $value);
+ $cc_valid = preg_match('/^5[1-5].{14}$/', $value);
break;
case 1: // Visa
- $cc_valid = ereg("^4.{15}$|^4.{12}$", $value);
+ $cc_valid = preg_match('/^4.{15}$|^4.{12}$/', $value);
break;
case 3: // American Express
- $cc_valid = ereg("^3[47].{13}$", $value);
+ $cc_valid = preg_match('/^3[47].{13}$', $value);
break;
case 4: // Discover
- $cc_valid = ereg("^6011.{12}$", $value);
+ $cc_valid = preg_match('/^6011.{12}$/', $value);
break;
case 5: // Diners Club
- $cc_valid = ereg("^30[0-5].{11}$|^3[68].{12}$", $value);
+ $cc_valid = preg_match('/^30[0-5].{11}$|^3[68].{12}$/', $value);
break;
case 6: // JBC
- $cc_valid = ereg("^3.{15}$|^2131|1800.{11}$", $value);
+ $cc_valid = preg_match('/^3.{15}$|^2131|1800.{11}$/', $value);
break;
default:
Index: in-commerce/units/products/products_event_handler.php
===================================================================
--- in-commerce/units/products/products_event_handler.php (revision 13152)
+++ in-commerce/units/products/products_event_handler.php (working copy)
@@ -631,8 +631,7 @@
$send_params['from_name']=$my_name;
$send_params['message']=$my_message;
- if (eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $friend_email))
- {
+ if (preg_match('/'.REGEX_EMAIL_USER.'@'.REGEX_EMAIL_DOMAIN.'/', $friend_email)) {
$user_id = $this->Application->RecallVar('user_id');
$email_event = &$this->Application->EmailEventUser('PRODUCT.SUGGEST', $user_id, $send_params);
$email_event = &$this->Application->EmailEventAdmin('PRODUCT.SUGGEST');
Index: in-commerce/units/shipping_quote_engines/usps.php
===================================================================
--- in-commerce/units/shipping_quote_engines/usps.php (revision 13152)
+++ in-commerce/units/shipping_quote_engines/usps.php (working copy)
@@ -675,7 +675,7 @@
function PhoneClean($phone)
{
- $res = ereg_replace("[(]|[)]|[\-]|[ ]|[#]|[\.]|[a-z](.*)|[A-Z](.*)", "", $phone);
+ $res = preg_replace('/[(]|[)]|[\-]|[ ]|[#]|[\.]|[a-z](.*)/isg', '', $phone); // i case-insensative, s treat string as a single line, g replace globally
if ( strlen($res) > 10 ) $res = substr($res, 0, 10);
return $res != '' ? $res : $phone;
}
Index: in-commerce/units/gateways/gw_classes/paybox.php
===================================================================
--- in-commerce/units/gateways/gw_classes/paybox.php (revision 13152)
+++ in-commerce/units/gateways/gw_classes/paybox.php (working copy)
@@ -69,7 +69,7 @@
$params['PBX_REFUSE'] = $this->Application->HREF($tag_params['cancel_template'],'',Array('pass'=>'m'));
$txt_amount = sprintf("%.2f", $item_data['TotalAmount']);
- $params['PBX_TOTAL'] = eregi_replace("[.,]", '', $txt_amount);
+ $params['PBX_TOTAL'] = str_ireplace( Array('.', ','), '', $txt_amount);
$params['PBX_CMD'] = $this->Application->GetSID().','.MD5($item_data['OrderId']);
/*$params['order_id'] = $item_data['OrderId'];
@@ -96,8 +96,8 @@
$ret = implode("\n", $rets);
- $ret = eregi_replace("^.*\!\!", '', $ret);
- $ret = chop($ret, '!');
+ $ret = preg_replace('/^(.*)!!/is', '', $ret);
+ $ret = rtrim($ret, '!');
return '</form>'.$ret.'<form>';
}
Index: in-commerce/units/gateways/gw_classes/ideal_nl.php
===================================================================
--- in-commerce/units/gateways/gw_classes/ideal_nl.php (revision 13152)
+++ in-commerce/units/gateways/gw_classes/ideal_nl.php (working copy)
@@ -77,7 +77,7 @@
$fields['a'] = 'fetch';
$fields['partnerid'] = $gw_params['partner_id'];
$txt_amount = sprintf("%.2f", $item_data['TotalAmount']);
- $fields['amount'] = eregi_replace("[.,]", '', $txt_amount);
+ $fields['amount'] = str_ireplace( Array('.', ','), '', $txt_amount);
$fields['bank_id'] = $this->Application->GetVar('ideal_nl_bank_id');
$fields['description'] = 'Invoice #'.$item_data['OrderNumber'];
Index: in-commerce/units/gateways/gw_classes/atosorigin.php
===================================================================
--- in-commerce/units/gateways/gw_classes/atosorigin.php (revision 13152)
+++ in-commerce/units/gateways/gw_classes/atosorigin.php (working copy)
@@ -66,8 +66,9 @@
$params['automatic_response_url'] = $this->Application->BaseURL('/in-commerce/units/gateways/gw_classes/notify_scripts').'atosorigin_notify.php';
$txt_amount = sprintf("%.2f", $item_data['TotalAmount']);
- $params['amount'] = eregi_replace("[.,]", '', $txt_amount);
- $params['caddie'] = $this->Application->GetSID().','.MD5($item_data['OrderId']);
+
+ $params['amount'] = str_ireplace( Array('.', ','), '', $txt_amount);
+ $params['caddie'] = $this->Application->GetSID() . ',' . MD5($item_data['OrderId']);
$params['order_id'] = $item_data['OrderId'];
$params['customer_ip_address'] = $_SERVER['REMOTE_ADDR'];
$params['customer_id'] = $item_data['PortalUserId'];
@@ -92,8 +93,8 @@
$ret = $rets[0];
- $ret = eregi_replace("^.*\!\!", '', $ret);
- $ret = chop($ret, '!');
+ $ret = preg_replace('/^(.*)!!/isg', '', $ret);
+ $ret = rtrim($ret, '!');
return '</form>'.$ret.'<form>';
}
273-Get_rid_of_ereg_functions_usage_because_slow_and_deprecated-Dmitry-20100314-v2-CORE.patch [^] (2,618 bytes) 2010-03-14 23:00
[Show Content]
Index: core/units/fck/fck_tp.php
===================================================================
--- core/units/fck/fck_tp.php (revision 13213)
+++ core/units/fck/fck_tp.php (working copy)
@@ -107,12 +107,13 @@
$size = ($size < 1)? 1:$size;// round( $iFileSize / 1024 ) ;
}
- eregi("(\.[a-zA-Z0-9]{1,10})$", $v, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
- if (in_array($ext, $a_ext))
- {
+ preg_match('/(' . REGEX_FILE_EXENTION . ')$/i', $v, $regs);
+ $ext = strtolower( ltrim($regs[1], ".") );
+
+ if (in_array($ext, $a_ext)) {
$icon = $ext;
- } else {
+ }
+ else {
$icon = 'default.icon';
}
Index: core/units/helpers/fck_helper.php
===================================================================
--- core/units/helpers/fck_helper.php (revision 13213)
+++ core/units/helpers/fck_helper.php (working copy)
@@ -54,8 +54,8 @@
function IsAllowedExtension($folder, $file_name)
{
$base_folder = $this->getBaseFolder($folder);
- eregi("(\.[a-zA-Z0-9]{1,10})$", $file_name, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
+ preg_match('/(' . REGEX_FILE_EXENTION . ')$/i', $file_name, $regs);
+ $ext = strtolower( ltrim($regs[1], ".") );
if (isset($this->Config['DeniedExtensions'][$folder])) {
if (in_array($ext, $this->Config['DeniedExtensions'][$folder])) {
return false;
@@ -146,12 +146,13 @@
{
$a_ext = Array('ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js','mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip');
- eregi("(\.[a-zA-Z0-9]{1,10})$", $v, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
- if (in_array($ext, $a_ext))
- {
+ preg_match('/(' . REGEX_FILE_EXENTION . ')$/i', $v, $regs);
+ $ext = strtolower( ltrim($regs[1], '.') );
+
+ if (in_array($ext, $a_ext)) {
$icon = $ext;
- } else {
+ }
+ else {
$icon = 'default.icon';
}
return $icon;
Index: core/kernel/constants.php
===================================================================
--- core/kernel/constants.php (revision 13213)
+++ core/kernel/constants.php (working copy)
@@ -74,6 +74,7 @@
// common usage regular expressions
define('REGEX_EMAIL_USER', '[-a-zA-Z0-9!\#$%&*+\/=?^_`{|}~.]+');
define('REGEX_EMAIL_DOMAIN', '[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\.[a-zA-Z]{2,6}');
+ define('REGEX_FILE_EXENTION', '\.[a-zA-Z0-9]{1,10}');
define('ALLOW_DEFAULT_SETTINGS', '_USE_DEFAULT_USER_DATA_'); //Allow persistent vars to take data from default user's persistent data
define('XML_NO_TEXT_NODES', 1); // Normal mode for XMLHelper
273-Get_rid_of_ereg_functions_usage_because_slow_and_deprecated-Dmitry-20100314-v2-In-Commerce.patch [^] (5,906 bytes) 2010-03-15 00:10
[Show Content]
Index: in-commerce/units/orders/orders_item.php
===================================================================
--- in-commerce/units/orders/orders_item.php (revision 13213)
+++ in-commerce/units/orders/orders_item.php (working copy)
@@ -306,34 +306,34 @@
// Innocent until proven guilty
$cc_valid = true;
- // Get rid of any non-digits
- $value = ereg_replace("[^[:digit:]]", '', $value);
+ // Get rid of any non-digits
+ $value = preg_replace('/[^\d]/', '', $value);
// Perform card-specific checks, if applicable
switch( $this->GetDBField($cardtype_field) )
{
case 2: // MasterCard
- $cc_valid = ereg("^5[1-5].{14}$", $value);
+ $cc_valid = preg_match('/^5[1-5].{14}$/', $value);
break;
case 1: // Visa
- $cc_valid = ereg("^4.{15}$|^4.{12}$", $value);
+ $cc_valid = preg_match('/^4.{15}$|^4.{12}$/', $value);
break;
case 3: // American Express
- $cc_valid = ereg("^3[47].{13}$", $value);
+ $cc_valid = preg_match('/^3[47].{13}$', $value);
break;
case 4: // Discover
- $cc_valid = ereg("^6011.{12}$", $value);
+ $cc_valid = preg_match('/^6011.{12}$/', $value);
break;
case 5: // Diners Club
- $cc_valid = ereg("^30[0-5].{11}$|^3[68].{12}$", $value);
+ $cc_valid = preg_match('/^30[0-5].{11}$|^3[68].{12}$/', $value);
break;
case 6: // JBC
- $cc_valid = ereg("^3.{15}$|^2131|1800.{11}$", $value);
+ $cc_valid = preg_match('/^3.{15}$|^2131|1800.{11}$/', $value);
break;
default:
Index: in-commerce/units/products/products_event_handler.php
===================================================================
--- in-commerce/units/products/products_event_handler.php (revision 13213)
+++ in-commerce/units/products/products_event_handler.php (working copy)
@@ -631,8 +631,7 @@
$send_params['from_name']=$my_name;
$send_params['message']=$my_message;
- if (eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $friend_email))
- {
+ if (preg_match('/'.REGEX_EMAIL_USER.'@'.REGEX_EMAIL_DOMAIN.'/', $friend_email)) {
$user_id = $this->Application->RecallVar('user_id');
$email_event = &$this->Application->EmailEventUser('PRODUCT.SUGGEST', $user_id, $send_params);
$email_event = &$this->Application->EmailEventAdmin('PRODUCT.SUGGEST');
Index: in-commerce/units/shipping_quote_engines/usps.php
===================================================================
--- in-commerce/units/shipping_quote_engines/usps.php (revision 13213)
+++ in-commerce/units/shipping_quote_engines/usps.php (working copy)
@@ -675,7 +675,7 @@
function PhoneClean($phone)
{
- $res = ereg_replace("[(]|[)]|[\-]|[ ]|[#]|[\.]|[a-z](.*)|[A-Z](.*)", "", $phone);
+ $res = preg_replace('/[(]|[)]|[\-]|[ ]|[#]|[\.]|[a-z](.*)|[A-Z](.*)/g', '', $phone);
if ( strlen($res) > 10 ) $res = substr($res, 0, 10);
return $res != '' ? $res : $phone;
}
Index: in-commerce/units/gateways/gw_classes/paybox.php
===================================================================
--- in-commerce/units/gateways/gw_classes/paybox.php (revision 13213)
+++ in-commerce/units/gateways/gw_classes/paybox.php (working copy)
@@ -69,7 +69,7 @@
$params['PBX_REFUSE'] = $this->Application->HREF($tag_params['cancel_template'],'',Array('pass'=>'m'));
$txt_amount = sprintf("%.2f", $item_data['TotalAmount']);
- $params['PBX_TOTAL'] = eregi_replace("[.,]", '', $txt_amount);
+ $params['PBX_TOTAL'] = str_replace( Array('.', ','), '', $txt_amount);
$params['PBX_CMD'] = $this->Application->GetSID().','.MD5($item_data['OrderId']);
/*$params['order_id'] = $item_data['OrderId'];
@@ -96,8 +96,8 @@
$ret = implode("\n", $rets);
- $ret = eregi_replace("^.*\!\!", '', $ret);
- $ret = chop($ret, '!');
+ $ret = preg_replace('/^(.*)!!/is', '', $ret);
+ $ret = rtrim($ret, '!');
return '</form>'.$ret.'<form>';
}
Index: in-commerce/units/gateways/gw_classes/ideal_nl.php
===================================================================
--- in-commerce/units/gateways/gw_classes/ideal_nl.php (revision 13213)
+++ in-commerce/units/gateways/gw_classes/ideal_nl.php (working copy)
@@ -77,7 +77,7 @@
$fields['a'] = 'fetch';
$fields['partnerid'] = $gw_params['partner_id'];
$txt_amount = sprintf("%.2f", $item_data['TotalAmount']);
- $fields['amount'] = eregi_replace("[.,]", '', $txt_amount);
+ $fields['amount'] = str_replace( Array('.', ','), '', $txt_amount);
$fields['bank_id'] = $this->Application->GetVar('ideal_nl_bank_id');
$fields['description'] = 'Invoice #'.$item_data['OrderNumber'];
Index: in-commerce/units/gateways/gw_classes/atosorigin.php
===================================================================
--- in-commerce/units/gateways/gw_classes/atosorigin.php (revision 13213)
+++ in-commerce/units/gateways/gw_classes/atosorigin.php (working copy)
@@ -66,8 +66,9 @@
$params['automatic_response_url'] = $this->Application->BaseURL('/in-commerce/units/gateways/gw_classes/notify_scripts').'atosorigin_notify.php';
$txt_amount = sprintf("%.2f", $item_data['TotalAmount']);
- $params['amount'] = eregi_replace("[.,]", '', $txt_amount);
- $params['caddie'] = $this->Application->GetSID().','.MD5($item_data['OrderId']);
+
+ $params['amount'] = str_replace( Array('.', ','), '', $txt_amount);
+ $params['caddie'] = $this->Application->GetSID() . ',' . MD5($item_data['OrderId']);
$params['order_id'] = $item_data['OrderId'];
$params['customer_ip_address'] = $_SERVER['REMOTE_ADDR'];
$params['customer_id'] = $item_data['PortalUserId'];
@@ -92,8 +93,8 @@
$ret = $rets[0];
- $ret = eregi_replace("^.*\!\!", '', $ret);
- $ret = chop($ret, '!');
+ $ret = preg_replace('/^(.*)!!/isg', '', $ret);
+ $ret = rtrim($ret, '!');
return '</form>'.$ret.'<form>';
}
273-Get_rid_of_ereg_functions_usage_because_slow_and_deprecated-Dmitry-20100315-v3-CORE.patch [^] (12,687 bytes) 2010-03-15 15:01
[Show Content]
Index: core/units/fck/fck_tp.php
===================================================================
--- core/units/fck/fck_tp.php (revision 13152)
+++ core/units/fck/fck_tp.php (working copy)
@@ -14,7 +14,7 @@
defined('FULL_PATH') or die('restricted access!');
- class FckTagProcessor extends kDBTagProcessor {
+ class FckTagProcessor extends kDBTagProcessor {
function ReadFolders($files_dir)
@@ -107,12 +107,11 @@
$size = ($size < 1)? 1:$size;// round( $iFileSize / 1024 ) ;
}
- eregi("(\.[a-zA-Z0-9]{1,10})$", $v, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
- if (in_array($ext, $a_ext))
- {
+ $ext = strtolower( pathinfo($v, PATHINFO_EXTENSION) );
+ if (in_array($ext, $a_ext)) {
$icon = $ext;
- } else {
+ }
+ else {
$icon = 'default.icon';
}
Index: core/units/helpers/fck_helper.php
===================================================================
--- core/units/helpers/fck_helper.php (revision 13152)
+++ core/units/helpers/fck_helper.php (working copy)
@@ -22,17 +22,18 @@
{
parent::kHelper();
- $this->Config['AllowedExtensions']['Files'] = array('jpg','gif','jpeg','png','swf','fla','jpg','gif','jpeg','png','avi','mpg','mpeg','zip','rar','arj','gz','tar','doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','odt') ;
- $this->Config['DeniedExtensions']['Files'] = array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg') ;
- $this->Config['AllowedExtensions']['Images'] = array('jpg','gif','jpeg','png', 'bmp') ;
- $this->Config['DeniedExtensions']['Images'] = array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
- $this->Config['AllowedExtensions']['Flash'] = array('swf','fla') ;
- $this->Config['DeniedExtensions']['Flash'] = array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg') ;
- $this->Config['AllowedExtensions']['Media'] = array('asf','asx','avi','wav','wax','wma','wm','wmv','m3u','mp2v','mpg','mpeg','m1v','mp2','mp3','mpa','mpe','mpv2','mp4','mid','midi','rmi','qt','aif','aifc','aiff','mov','flv','rm','svcd','swf','vcd') ;
- $this->Config['DeniedExtensions']['Media'] = array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
- $this->Config['AllowedExtensions']['Documents'] = array('doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','zip','odt') ;
- $this->Config['DeniedExtensions']['Documents'] = array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
-
+ $this->Config['AllowedExtensions']['Files'] = Array('jpg','gif','jpeg','png','swf','fla','jpg','gif','jpeg','png','avi','mpg','mpeg','zip','rar','arj','gz','tar','doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','odt');
+ $this->Config['DeniedExtensions']['Files'] = Array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
+ $this->Config['AllowedExtensions']['Images'] = Array('jpg','gif','jpeg','png', 'bmp');
+ $this->Config['DeniedExtensions']['Images'] = Array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
+ $this->Config['AllowedExtensions']['Flash'] = Array('swf','fla');
+ $this->Config['DeniedExtensions']['Flash'] = Array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
+ $this->Config['AllowedExtensions']['Media'] = Array('asf','asx','avi','wav','wax','wma','wm','wmv','m3u','mp2v','mpg','mpeg','m1v','mp2','mp3','mpa','mpe','mpv2','mp4','mid','midi','rmi','qt','aif','aifc','aiff','mov','flv','rm','svcd','swf','vcd');
+ $this->Config['DeniedExtensions']['Media'] = Array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
+ $this->Config['AllowedExtensions']['Documents'] = Array('doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','zip','odt');
+ $this->Config['DeniedExtensions']['Documents'] = Array('php','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg');
+
+ $this->Config['ExtensionIcons'] = Array('ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js','mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip');
}
function CreateFolder($folder = '')
@@ -53,9 +54,8 @@
function IsAllowedExtension($folder, $file_name)
{
- $base_folder = $this->getBaseFolder($folder);
- eregi("(\.[a-zA-Z0-9]{1,10})$", $file_name, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
+ $base_folder = $this->getBaseFolder($folder);
+ $ext = strtolower( pathinfo($file_name, PATHINFO_EXTENSION) );
if (isset($this->Config['DeniedExtensions'][$folder])) {
if (in_array($ext, $this->Config['DeniedExtensions'][$folder])) {
return false;
@@ -71,7 +71,7 @@
function getBaseFolder($folder)
{
- $end = strpos("/", $folder);
+ $end = strpos('/', $folder);
if ($end) {
return substr($folder, 0, $end);
}
@@ -93,7 +93,6 @@
return $aFolders;
}
-
function ReadFiles($files_dir)
{
$aFiles = array();
@@ -108,25 +107,26 @@
return $aFiles;
}
-
function PrintFolders()
{
$order_by = $this->Application->GetVar('order_by');
$sort_by = $this->Application->GetVar('sort_by');
$folder = $this->Application->GetVar('folder');
- $files_dir = WRITEABLE."/user_files/".$folder."/";
- $aFolders = $this->ReadFolders($files_dir);
- $ret = '';
+ $files_dir = WRITEABLE . '/user_files/' . $folder . '/';
+ $aFolders = $this->ReadFolders($files_dir);
$order_by = $this->Application->GetVar('order_by');
$sort_by = $this->Application->GetVar('sort_by');
natcasesort($aFolders);
+
+ $ret = '';
foreach ($aFolders as $k => $v) {
$ret .= '<folder2 path="'.$folder."/".$v.'">'.$v.'</folder2>'."\n";
}
-
+
if ($sort_by == 'name' && $order_by == '_desc') {
$aFolders = array_reverse($aFolders);
}
+
foreach ($aFolders as $k => $v) {
$ret .= '<folder path="'.$folder."/".$v.'">'.$v.'</folder>'."\n";
}
@@ -143,18 +143,9 @@
}
function CheckIconType($v)
- {
- $a_ext = Array('ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js','mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip');
-
- eregi("(\.[a-zA-Z0-9]{1,10})$", $v, $regs);
- $ext = strtolower(ltrim($regs[1],"."));
- if (in_array($ext, $a_ext))
- {
- $icon = $ext;
- } else {
- $icon = 'default.icon';
- }
- return $icon;
+ {
+ $ext = strtolower( pathinfo($v, PATHINFO_EXTENSION) );
+ return ($ext && in_array($ext, $this->Config['ExtensionIcons']))? $ext : 'default.icon';
}
function GetXmlString($size,$url,$icon,$date,$file_name)
@@ -168,14 +159,14 @@
$sort_by = $this->Application->GetVar('sort_by');
$folder = $this->Application->GetVar('folder');
- $files_dir = WRITEABLE . "/user_files/" . $folder."/";
- $files_url = BASE_PATH . str_replace(DIRECTORY_SEPARATOR, '/', WRITEBALE_BASE) . "/user_files/" . $folder . "/";
+ $files_dir = WRITEABLE . '/user_files/' . $folder . '/';
+ $files_url = BASE_PATH . str_replace(DIRECTORY_SEPARATOR, '/', WRITEBALE_BASE) . '/user_files/' . $folder . '/';
$aFiles = $this->ReadFiles($files_dir);
$ret = '';
$date_format = "m/d/Y h:i A";
natcasesort($aFiles);
if ($sort_by == 'name' && $order_by == '_desc') {
- $aFiles = array_reverse($aFiles,TRUE);
+ $aFiles = array_reverse($aFiles, TRUE);
}
foreach ($aFiles as $k => $v)
@@ -221,17 +212,11 @@
}
function UploadFile()
- {
- $Extensions['Allowed']['Files'] = array('jpg','gif','jpeg','png','swf','fla','jpg','gif','jpeg','png','avi','mpg','mpeg','zip','rar','arj','gz','tar','doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','odt') ;
- $Extensions['Allowed']['Images'] = array('jpg','gif','jpeg','png', 'bmp') ;
- $Extensions['Allowed']['Flash'] = array('swf','fla') ;
- $Extensions['Allowed']['Media'] = array('asf','asx','avi','wav','wax','wma','wm','wmv','m3u','mp2v','mpg','mpeg','m1v','mp2','mp3','mpa','mpe','mpv2','mp4','mid','midi','rmi','qt','aif','aifc','aiff','mov','flv','rm','svcd','swf','vcd') ;
- $Extensions['Allowed']['Documents'] = array('doc','pdf','ppt','rdp','swf','swt','txt','vsd','xls','csv','zip','odt') ;
-
+ {
$upload_dir = $this->Application->GetVar('upload_dir');
- $type = explode("/",$upload_dir);
+ $type = explode('/', $upload_dir);
$type = $type[0];
- $sServerDir = WRITEABLE."/user_files/".$upload_dir."/";
+ $sServerDir = WRITEABLE . '/user_files/' . $upload_dir . '/';
$aUpFile = $_FILES['NewFile'];
$sFileName = $aUpFile['name'];
@@ -240,46 +225,49 @@
$sErrorNumber = 0;
if ( isset( $_FILES['NewFile'] ) && !is_null( $_FILES['NewFile']['tmp_name'] ) )
{
- if (in_array($sExtension,$Extensions['Allowed'][$type]))
+ if (in_array($sExtension, $this->Config['AllowedExtensions'][$type]))
{
-
if (!$aUpFile['error']) {
$iCounter = 0 ;
while ( true )
{
- $sFilePath = $sServerDir . $sFileName ;
+ $sFilePath = $sServerDir . $sFileName;
if ( is_file( $sFilePath ) )
{
$iCounter++ ;
- $sFileName = $this->RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ;
- $sErrorNumber = '201' ;
+ $sFileName = $this->RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension;
+ $sErrorNumber = '201';
}
else
{
// Turn off all error reporting.
error_reporting( 0 ) ;
+
// Enable error tracking to catch the error.
- ini_set( 'track_errors', '1' ) ;
- move_uploaded_file( $aUpFile['tmp_name'], $sFilePath ) ;
- $sErrorMsg = $php_errormsg ;
+ ini_set( 'track_errors', '1' );
+
+ move_uploaded_file( $aUpFile['tmp_name'], $sFilePath );
+ $sErrorMsg = $php_errormsg;
+
// Restore the configurations.
- ini_restore( 'track_errors' ) ;
- ini_restore( 'error_reporting' ) ;
+ ini_restore( 'track_errors' );
+ ini_restore( 'error_reporting' );
- if ( is_file( $sFilePath ) )
- {
- $oldumask = umask(0) ;
- chmod( $sFilePath, 0666 ) ;
- umask( $oldumask ) ;
+ if ( is_file( $sFilePath ) ) {
+ $oldumask = umask(0);
+ chmod( $sFilePath, 0666 );
+ umask( $oldumask );
}
break ;
}
}
}
- } else {
+ }
+ else {
$sErrorNumber = '203';
}
- } else {
+ }
+ else {
$sErrorNumber = '202' ;
}
echo '<script type="text/javascript">' ;
Index: core/admin_templates/browser/frmresourceslist.tpl
===================================================================
--- core/admin_templates/browser/frmresourceslist.tpl (revision 13152)
+++ core/admin_templates/browser/frmresourceslist.tpl (working copy)
@@ -502,11 +502,11 @@
<td>
<table id="context_menu" cellpadding="0" cellspacing="0">
<tr style="height:18px;" onmouseover="document.getElementById('rename').bgColor = '#8f8f73'; document.getElementById('rename_dot').bgColor = '#737357';" onmouseout="document.getElementById('rename').bgColor = '#FFFFFF'; document.getElementById('rename_dot').bgColor = '#E3E3C7';">
- <td id="rename_dot" bgcolor="#E3E3C7" align="center" valign="middle" width="15"><img src="images/blackpix.gif" style="width: 5; height: 5" /></td>
+ <td id="rename_dot" bgcolor="#E3E3C7" align="center" valign="middle" width="15"><img src="img/browser/blackpix.gif" style="width: 5; height: 5" /></td>
<td id="rename" align="left" style="font-size: 11px; font-family: 'Microsoft Sans Serif' , Arial, Helvetica, Verdana" onclick="RenameFromContextMenu();"> <a href="javascript:do_nothing()" style="text-decoration: none; color: #000000">Rename</a> </td>
</tr>
<tr style="height:18px;" onmouseover="document.getElementById('delete').bgColor = '#8f8f73'; document.getElementById('delete_dot').bgColor = '#737357';" onmouseout="document.getElementById('delete').bgColor = '#FFFFFF'; document.getElementById('delete_dot').bgColor = '#E3E3C7';">
- <td id="delete_dot" bgcolor="#E3E3C7" align="center" valign="middle" width="15"><img src="images/blackpix.gif" style="width: 5; height: 5" /></td>
+ <td id="delete_dot" bgcolor="#E3E3C7" align="center" valign="middle" width="15"><img src="img/browser/blackpix.gif" style="width: 5; height: 5" /></td>
<td id="delete" align="left" style="font-size: 11px; font-family: 'Microsoft Sans Serif' , Arial, Helvetica, Verdana" onclick="DeleteFromContextMenu();">
<a href="javascript:do_nothing()" style="text-decoration: none; color: #000000">Delete</a>
<input type="hidden" value="" id="context_menu_file">
273-Get_rid_of_ereg_functions_usage_because_slow_and_deprecated-Dmitry-20100315-v3-In-Commerce.patch [^] (5,977 bytes) 2010-03-15 15:12
[Show Content]
Index: in-commerce/units/orders/orders_item.php
===================================================================
--- in-commerce/units/orders/orders_item.php (revision 13152)
+++ in-commerce/units/orders/orders_item.php (working copy)
@@ -333,34 +333,34 @@
// Innocent until proven guilty
$cc_valid = true;
- // Get rid of any non-digits
- $value = ereg_replace("[^[:digit:]]", '', $value);
+ // Get rid of any non-digits
+ $value = preg_replace('/[^\d]/', '', $value);
// Perform card-specific checks, if applicable
switch( $this->GetDBField($cardtype_field) )
{
case 2: // MasterCard
- $cc_valid = ereg("^5[1-5].{14}$", $value);
+ $cc_valid = preg_match('/^5[1-5].{14}$/', $value);
break;
case 1: // Visa
- $cc_valid = ereg("^4.{15}$|^4.{12}$", $value);
+ $cc_valid = preg_match('/^4.{15}$|^4.{12}$/', $value);
break;
case 3: // American Express
- $cc_valid = ereg("^3[47].{13}$", $value);
+ $cc_valid = preg_match('/^3[47].{13}$/', $value);
break;
case 4: // Discover
- $cc_valid = ereg("^6011.{12}$", $value);
+ $cc_valid = preg_match('/^6011.{12}$/', $value);
break;
case 5: // Diners Club
- $cc_valid = ereg("^30[0-5].{11}$|^3[68].{12}$", $value);
+ $cc_valid = preg_match('/^30[0-5].{11}$|^3[68].{12}$/', $value);
break;
case 6: // JBC
- $cc_valid = ereg("^3.{15}$|^2131|1800.{11}$", $value);
+ $cc_valid = preg_match('/^3.{15}$|^2131|1800.{11}$/', $value);
break;
default:
Index: in-commerce/units/products/products_event_handler.php
===================================================================
--- in-commerce/units/products/products_event_handler.php (revision 13152)
+++ in-commerce/units/products/products_event_handler.php (working copy)
@@ -631,8 +631,7 @@
$send_params['from_name']=$my_name;
$send_params['message']=$my_message;
- if (eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $friend_email))
- {
+ if (preg_match('/'.REGEX_EMAIL_USER.'@'.REGEX_EMAIL_DOMAIN.'/', $friend_email)) {
$user_id = $this->Application->RecallVar('user_id');
$email_event = &$this->Application->EmailEventUser('PRODUCT.SUGGEST', $user_id, $send_params);
$email_event = &$this->Application->EmailEventAdmin('PRODUCT.SUGGEST');
Index: in-commerce/units/shipping_quote_engines/usps.php
===================================================================
--- in-commerce/units/shipping_quote_engines/usps.php (revision 13152)
+++ in-commerce/units/shipping_quote_engines/usps.php (working copy)
@@ -675,8 +675,10 @@
function PhoneClean($phone)
{
- $res = ereg_replace("[(]|[)]|[\-]|[ ]|[#]|[\.]|[a-z](.*)|[A-Z](.*)", "", $phone);
- if ( strlen($res) > 10 ) $res = substr($res, 0, 10);
+ $res = preg_replace('/[(]|[)]|[\-]|[ ]|[#]|[\.]|[a-z](.*)|[A-Z](.*)/g', '', $phone);
+ if ( strlen($res) > 10 ) {
+ $res = substr($res, 0, 10);
+ }
return $res != '' ? $res : $phone;
}
Index: in-commerce/units/gateways/gw_classes/paybox.php
===================================================================
--- in-commerce/units/gateways/gw_classes/paybox.php (revision 13152)
+++ in-commerce/units/gateways/gw_classes/paybox.php (working copy)
@@ -69,7 +69,7 @@
$params['PBX_REFUSE'] = $this->Application->HREF($tag_params['cancel_template'],'',Array('pass'=>'m'));
$txt_amount = sprintf("%.2f", $item_data['TotalAmount']);
- $params['PBX_TOTAL'] = eregi_replace("[.,]", '', $txt_amount);
+ $params['PBX_TOTAL'] = str_replace( Array('.', ','), '', $txt_amount);
$params['PBX_CMD'] = $this->Application->GetSID().','.MD5($item_data['OrderId']);
/*$params['order_id'] = $item_data['OrderId'];
@@ -96,8 +96,8 @@
$ret = implode("\n", $rets);
- $ret = eregi_replace("^.*\!\!", '', $ret);
- $ret = chop($ret, '!');
+ $ret = preg_replace('/^(.*)!!/is', '', $ret);
+ $ret = rtrim($ret, '!');
return '</form>'.$ret.'<form>';
}
Index: in-commerce/units/gateways/gw_classes/ideal_nl.php
===================================================================
--- in-commerce/units/gateways/gw_classes/ideal_nl.php (revision 13152)
+++ in-commerce/units/gateways/gw_classes/ideal_nl.php (working copy)
@@ -77,7 +77,7 @@
$fields['a'] = 'fetch';
$fields['partnerid'] = $gw_params['partner_id'];
$txt_amount = sprintf("%.2f", $item_data['TotalAmount']);
- $fields['amount'] = eregi_replace("[.,]", '', $txt_amount);
+ $fields['amount'] = str_replace( Array('.', ','), '', $txt_amount);
$fields['bank_id'] = $this->Application->GetVar('ideal_nl_bank_id');
$fields['description'] = 'Invoice #'.$item_data['OrderNumber'];
Index: in-commerce/units/gateways/gw_classes/atosorigin.php
===================================================================
--- in-commerce/units/gateways/gw_classes/atosorigin.php (revision 13152)
+++ in-commerce/units/gateways/gw_classes/atosorigin.php (working copy)
@@ -66,8 +66,9 @@
$params['automatic_response_url'] = $this->Application->BaseURL('/in-commerce/units/gateways/gw_classes/notify_scripts').'atosorigin_notify.php';
$txt_amount = sprintf("%.2f", $item_data['TotalAmount']);
- $params['amount'] = eregi_replace("[.,]", '', $txt_amount);
- $params['caddie'] = $this->Application->GetSID().','.MD5($item_data['OrderId']);
+
+ $params['amount'] = str_replace( Array('.', ','), '', $txt_amount);
+ $params['caddie'] = $this->Application->GetSID() . ',' . MD5($item_data['OrderId']);
$params['order_id'] = $item_data['OrderId'];
$params['customer_ip_address'] = $_SERVER['REMOTE_ADDR'];
$params['customer_id'] = $item_data['PortalUserId'];
@@ -92,8 +93,8 @@
$ret = $rets[0];
- $ret = eregi_replace("^.*\!\!", '', $ret);
- $ret = chop($ret, '!');
+ $ret = preg_replace('/^(.*)!!/is', '', $ret);
+ $ret = rtrim($ret, '!');
return '</form>'.$ret.'<form>';
}
|