Skip to content

Commit

Permalink
Improve compatibility with PHP5.4/5.5, fixes #109
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernat Arlandis committed Apr 15, 2014
1 parent 302ae47 commit a803cce
Show file tree
Hide file tree
Showing 51 changed files with 128 additions and 147 deletions.
2 changes: 1 addition & 1 deletion Popup.php
Expand Up @@ -309,7 +309,7 @@

if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
{
list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
list($where, $ustring) = explode("#@@#",getWhereCondition($currentModule));
$url_string .="&query=true".$ustring;
}

Expand Down
6 changes: 4 additions & 2 deletions Smarty/templates/EditViewUI.tpl
Expand Up @@ -746,11 +746,13 @@ alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.{$fldname}.valu
<br>{'LBL_IMG_FORMATS'|@getTranslatedString:$MODULE}
<input name="{$fldname}_hidden" type="hidden" value="{$maindata[3].0.name}" />
{else}
<input name="{$fldname}" type="file" value="{$maindata[3].0.name}" tabindex="{$vt_tab}" onchange="validateFilename(this);" /><br>{'LBL_IMG_FORMATS'|@getTranslatedString:$MODULE}
<input name="{$fldname}_hidden" type="hidden" value="{$maindata[3].0.name}" />
<input name="{$fldname}" type="file" value="" tabindex="{$vt_tab}" onchange="validateFilename(this);" /><br>{'LBL_IMG_FORMATS'|@getTranslatedString:$MODULE}
<input name="{$fldname}_hidden" type="hidden" value="" />
{/if}
<input type="hidden" name="id" value=""/>
{if isset($maindata[3].0.name) }
{$maindata[3].0.name}
{/if}
</td>
{elseif $uitype eq 103}
<td width="20%" class="dvtCellLabel" align=right>
Expand Down
4 changes: 2 additions & 2 deletions adodb/adodb-xmlschema.inc.php
Expand Up @@ -1308,7 +1308,7 @@ class adoSchema {
function adoSchema( &$db ) {
// Initialize the environment
$this->mgq = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
//set_magic_quotes_runtime(0);

$this->db =& $db;
$this->debug = $this->db->debug;
Expand Down Expand Up @@ -2197,7 +2197,7 @@ function getSQL( $format = NULL, $sqlArray = NULL ) {
* @deprecated adoSchema now cleans up automatically.
*/
function Destroy() {
set_magic_quotes_runtime( $this->mgq );
//set_magic_quotes_runtime( $this->mgq );
unset( $this );
}
}
Expand Down
4 changes: 2 additions & 2 deletions adodb/adodb-xmlschema03.inc.php
Expand Up @@ -1407,7 +1407,7 @@ class adoSchema {
function adoSchema( &$db ) {
// Initialize the environment
$this->mgq = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
//set_magic_quotes_runtime(0);

$this->db =& $db;
$this->debug = $this->db->debug;
Expand Down Expand Up @@ -2369,7 +2369,7 @@ function getSQL( $format = NULL, $sqlArray = NULL ) {
* @deprecated adoSchema now cleans up automatically.
*/
function Destroy() {
set_magic_quotes_runtime( $this->mgq );
//set_magic_quotes_runtime( $this->mgq );
unset( $this );
}
}
Expand Down
22 changes: 8 additions & 14 deletions cron/class.phpmailer.php
Expand Up @@ -1431,20 +1431,14 @@ function RFCDate() {
* @return mixed
*/
function ServerVar($varName) {
global $HTTP_SERVER_VARS;
global $HTTP_ENV_VARS;

if(!isset($_SERVER))
{
$_SERVER = $HTTP_SERVER_VARS;
if(!isset($_SERVER["REMOTE_ADDR"]))
$_SERVER = $HTTP_ENV_VARS; // must be Apache
}

if(isset($_SERVER[$varName]))
return $_SERVER[$varName];
else
return "";
$vars = $_SERVER;
if(!isset($vars["REMOTE_ADDR"])) {
$vars = $_ENV; // must be Apache
}
if(isset($vars[$varName]))
return $vars[$varName];
else
return "";
}

/**
Expand Down
4 changes: 2 additions & 2 deletions data/CRMEntity.php
Expand Up @@ -853,7 +853,7 @@ function process_list_query($query, $row_offset, $limit = -1, $max_per_page = -1
//$this->db->println("here is the bug");


$list[] = clone($this); //added by Richie to support PHP5
$list[] = clone $this; //added by Richie to support PHP5
}
}

Expand Down Expand Up @@ -891,7 +891,7 @@ function process_full_list_query($query) {
//data gets overridden hence all the rows that come in bear the same value. This in turn
//provides a wrong display of the Dashboard graphs. The data is erroneously shown for a specific month alone
//Added by Richie
$list[] = clone($this); //added by Richie to support PHP5
$list[] = clone $this; //added by Richie to support PHP5
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/ChartUtils.php
Expand Up @@ -370,7 +370,7 @@ public static function generateChartDataFromReports($queryResult, $groupbyField,

if ($fieldDetails != '') {
list($tablename, $colname, $module_field, $fieldname, $single) = explode(":", $fieldDetails);
list($module, $field) = split("_", $module_field);
list($module, $field) = explode("_", $module_field);
$dateField = false;
if ($single == 'D') {
$dateField = true;
Expand Down
5 changes: 3 additions & 2 deletions include/HTTP_Session/Session.php
Expand Up @@ -511,7 +511,8 @@ function isNew()
*/
function register($name)
{
return session_register($name);
$_SESSION[$name] = $GLOBALS[$name];
return true;
}

/**
Expand All @@ -528,7 +529,7 @@ function register($name)
*/
function unregister($name)
{
return session_unregister($name);
return $_SESSION[$name];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion include/ListView/ListViewPagging.php
Expand Up @@ -41,7 +41,7 @@
$where = '(' . getUnifiedWhere($list_query,$currentModule,$searchValue) . ')';
$url_string .= '&query=true&globalSearch=true&globalSearchText='.$searchValue;
}else{
list($where, $ustring) = split('#@@#', getWhereCondition($currentModule));
list($where, $ustring) = explode('#@@#', getWhereCondition($currentModule));
$url_string .= "&query=true$ustring";
}
}
Expand Down
27 changes: 9 additions & 18 deletions include/install/resources/utils.php
Expand Up @@ -958,15 +958,14 @@ class Common_Install_Wizard_Utils {

public static $recommendedDirectives = array (
'safe_mode' => 'Off',
'display_errors' => 'On',
'display_errors' => 'Off',
'file_uploads' => 'On',
'register_globals' => 'On',
'register_globals' => 'Off',
'output_buffering' => 'On',
'max_execution_time' => '600',
'memory_limit' => '32',
'error_reporting' => 'E_WARNING & ~E_NOTICE',
'allow_call_time_pass_reference' => 'On',
'log_errors' => 'Off',
'error_reporting' => 'E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT',
'allow_call_time_pass_reference' => 'Off',
'short_open_tag' => 'On'
);

Expand Down Expand Up @@ -1079,9 +1078,6 @@ class Common_Install_Wizard_Utils {
}';

function getRecommendedDirectives() {
if(version_compare(PHP_VERSION, '5.3.0') >= 0) {
self::$recommendedDirectives['error_reporting'] = 'E_WARNING & ~E_NOTICE & ~E_DEPRECATED';
}
return self::$recommendedDirectives;
}

Expand Down Expand Up @@ -1154,8 +1150,8 @@ static function getCurrentDirectiveValue() {
$directiveValues = array();
if (ini_get('safe_mode') == '1' || stripos(ini_get('safe_mode'), 'On') > -1)
$directiveValues['safe_mode'] = 'On';
if (ini_get('display_errors') != '1' || stripos(ini_get('display_errors'), 'Off') > -1)
$directiveValues['display_errors'] = 'Off';
if (ini_get('display_errors') == '1' || stripos(ini_get('display_errors'), 'On') > -1)
$directiveValues['display_errors'] = 'On';
if (ini_get('file_uploads') != '1' || stripos(ini_get('file_uploads'), 'Off') > -1)
$directiveValues['file_uploads'] = 'Off';
if (ini_get('register_globals') == '1' || stripos(ini_get('register_globals'), 'On') > -1)
Expand All @@ -1166,16 +1162,11 @@ static function getCurrentDirectiveValue() {
$directiveValues['max_execution_time'] = ini_get('max_execution_time');
if (ini_get('memory_limit') < 32)
$directiveValues['memory_limit'] = ini_get('memory_limit');
$errorReportingValue = E_WARNING & ~E_NOTICE;
if(version_compare(PHP_VERSION, '5.3.0') >= 0) {
$errorReportingValue = E_WARNING & ~E_NOTICE & ~E_DEPRECATED;
}
$errorReportingValue = self::$recommendedDirectives['error_reporting'];
if (ini_get('error_reporting') != $errorReportingValue)
$directiveValues['error_reporting'] = 'NOT RECOMMENDED';
if (ini_get('allow_call_time_pass_reference') != '1' || stripos(ini_get('allow_call_time_pass_reference'), 'Off') > -1)
$directiveValues['allow_call_time_pass_reference'] = 'Off';
if (ini_get('log_errors') == '1' || stripos(ini_get('log_errors'), 'On') > -1)
$directiveValues['log_errors'] = 'On';
if (ini_get('allow_call_time_pass_reference') == '1' || stripos(ini_get('allow_call_time_pass_reference'), 'On') > -1)
$directiveValues['allow_call_time_pass_reference'] = 'On';
if (ini_get('short_open_tag') != '1' || stripos(ini_get('short_open_tag'), 'Off') > -1)
$directiveValues['short_open_tag'] = 'Off';

Expand Down
2 changes: 1 addition & 1 deletion include/nusoap/class.soap_transport_http.php
Expand Up @@ -932,7 +932,7 @@ function usePersistentConnection(){
*/
function parseCookie($cookie_str) {
$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
$data = split(';', $cookie_str);
$data = explode(';', $cookie_str);
$value_str = $data[0];

$cookie_param = 'domain=';
Expand Down
2 changes: 1 addition & 1 deletion include/nusoap/nusoap.php
Expand Up @@ -2927,7 +2927,7 @@ function usePersistentConnection(){
*/
function parseCookie($cookie_str) {
$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
$data = split(';', $cookie_str);
$data = explode(';', $cookie_str);
$value_str = $data[0];

$cookie_param = 'domain=';
Expand Down
14 changes: 7 additions & 7 deletions include/utils/CommonUtils.php
Expand Up @@ -1392,13 +1392,13 @@ function getProductImages($id) {
* It acceps the File lists,modulename,id and the mode as arguments
* It returns the array details of the upload
*/
function SaveImage($_FILES, $module, $id, $mode) {
function SaveImage($files, $module, $id, $mode) {
global $log, $root_directory;
$log->debug("Entering SaveImage(" . $_FILES . "," . $module . "," . $id . "," . $mode . ") method ...");
$log->debug("Entering SaveImage(" . $files . "," . $module . "," . $id . "," . $mode . ") method ...");
global $adb;
$uploaddir = $root_directory . "test/" . $module . "/"; //set this to which location you need to give the contact image
$log->info("The Location to Save the Contact Image is " . $uploaddir);
$file_path_name = $_FILES['imagename']['name'];
$file_path_name = $files['imagename']['name'];
if (isset($_REQUEST['imagename_hidden'])) {
$file_name = vtlib_purify($_REQUEST['imagename_hidden']);
} else {
Expand All @@ -1415,13 +1415,13 @@ function SaveImage($_FILES, $module, $id, $mode) {
$encode_field_values = "";
$errormessage = "";

$move_upload_status = move_uploaded_file($_FILES["imagename"]["tmp_name"], $uploaddir . $image_name_val);
$move_upload_status = move_uploaded_file($files["imagename"]["tmp_name"], $uploaddir . $image_name_val);
$image_error = "false";

//if there is an error in the uploading of image

$filetype = $_FILES['imagename']['type'];
$filesize = $_FILES['imagename']['size'];
$filetype = $files['imagename']['type'];
$filesize = $files['imagename']['size'];

$filetype_array = explode("/", $filetype);

Expand All @@ -1431,7 +1431,7 @@ function SaveImage($_FILES, $module, $id, $mode) {
//checking the uploaded image is if an image type or not
if (!$move_upload_status) { //if any error during file uploading
$log->debug("Error is present in uploading Contact Image.");
$errorCode = $_FILES['imagename']['error'];
$errorCode = $files['imagename']['error'];
if ($errorCode == 4) {
$errorcode = "no-image";
$saveimage = "false";
Expand Down
2 changes: 1 addition & 1 deletion include/utils/InventoryUtils.php
Expand Up @@ -590,7 +590,7 @@ function saveInventoryProductDetails(&$focus, $module, $update_prod_stock='false

$sub_prod_str = $_REQUEST['subproduct_ids'.$i];
if (!empty($sub_prod_str)) {
$sub_prod = split(":",$sub_prod_str);
$sub_prod = explode(":",$sub_prod_str);
for($j=0;$j<count($sub_prod);$j++){
$query ="insert into vtiger_inventorysubproductrel(id, sequence_no, productid) values(?,?,?)";
$qparams = array($focus->id,$prod_seq,$sub_prod[$j]);
Expand Down
4 changes: 2 additions & 2 deletions include/utils/utils.php
Expand Up @@ -3236,7 +3236,7 @@ function getMigrationCharsetFlag() {
/** Function to convert a given time string to Minutes */
function ConvertToMinutes($time_string)
{
$interval = split(' ', $time_string);
$interval = explode(' ', $time_string);
$interval_minutes = intval($interval[0]);
$interval_string = strtolower($interval[1]);
if($interval_string == 'hour' || $interval_string == 'hours')
Expand Down Expand Up @@ -5005,7 +5005,7 @@ function getSelectAllQuery($input,$module) {
$query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,$module);
$where = '';
if($input['query'] == 'true') {
list($where, $ustring) = split("#@@#",getWhereCondition($module, $input));
list($where, $ustring) = explode("#@@#",getWhereCondition($module, $input));
if(isset($where) && $where != '') {
$query .= " AND " .$where;
}
Expand Down
4 changes: 2 additions & 2 deletions index.php
Expand Up @@ -23,7 +23,7 @@
global $display;
global $category;

if(version_compare(phpversion(), '5.2.0') < 0 or version_compare(phpversion(), '5.4.0','ge') > 0) {
if(version_compare(phpversion(), '5.2.0') < 0 or version_compare(phpversion(), '5.6.0','ge') > 0) {
insert_charset_header();
$serverPhpVersion = phpversion();
require_once('phpversionfail.php');
Expand Down Expand Up @@ -72,7 +72,7 @@ function stripslashes_checkstrings($value){
if(isset($_REQUEST['view'])) {
//setcookie("view",$_REQUEST['view']);
$view = $_REQUEST["view"];
session_register("view");
$_SESSION['view'] = $view;
}


Expand Down
2 changes: 1 addition & 1 deletion log4php.debug/appenders/LoggerAppenderSyslog.php
Expand Up @@ -55,7 +55,7 @@ function LoggerAppenderSyslog($name)

function activateOptions()
{
define_syslog_variables();
//define_syslog_variables();
$this->closed = false;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/Accounts/MailerExport.php
Expand Up @@ -109,7 +109,7 @@ function getStdContactFlds(&$queryFields, $adb, $valueArray)
}
}
// now add the standard fields
getStdContactFlds(&$queryFields, $adb, $valueArray);
getStdContactFlds($queryFields, $adb, $valueArray);
// get the list of fields
$fieldList="";
foreach ($queryFields as $myField)
Expand Down
4 changes: 2 additions & 2 deletions modules/Calendar/Appointment.php
Expand Up @@ -141,7 +141,7 @@ function readAppointment($userid, &$from_datetime, &$to_datetime, $view)
for($j = $from; $j <= $to; $j=$j+(60*60*24))
{

$obj = &new Appointment();
$obj = new Appointment();
$temp_start = date("Y-m-d",$j);
$endTime = strtotime($temp_start. ' '. $result['time_start']);
if($endTime > $windowTo) {
Expand Down Expand Up @@ -187,7 +187,7 @@ function readAppointment($userid, &$from_datetime, &$to_datetime, $view)
$a = 0;
while ( $a < $n )
{
$obj = &new Appointment();
$obj = new Appointment();
$result = $adb->fetchByAssoc($r);
list($obj->temphour,$obj->tempmin) = explode(":",$result["time_start"]);
$obj->readResult($result,$view);
Expand Down
6 changes: 3 additions & 3 deletions modules/Calendar/DetailView.php
Expand Up @@ -33,7 +33,7 @@
{
echo '<b><font color=red>'. $mod_strings{"LBL_NOTIFICATION_ERROR"}.'</font></b><br>';
}
session_unregister('mail_send_error');
unset($_SESSION['mail_send_error']);

$focus = CRMEntity::getInstance($currentModule);
$smarty = new vtigerCRM_Smarty();
Expand Down Expand Up @@ -133,8 +133,8 @@
$format = 'am/pm';
else
$format = $current_user->hour_format;
list($stdate,$sttime) = split(' ',$finaldata['date_start']);
list($enddate,$endtime) = split(' ',$finaldata['due_date']);
list($stdate,$sttime) = explode(' ',$finaldata['date_start']);
list($enddate,$endtime) = explode(' ',$finaldata['due_date']);
$time_arr = getaddEventPopupTime($sttime,$endtime,$format);
$data['starthr'] = $time_arr['starthour'];
$data['startmin'] = $time_arr['startmin'];
Expand Down
2 changes: 1 addition & 1 deletion modules/Calendar/ListView.php
Expand Up @@ -131,7 +131,7 @@
if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
{

list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
list($where, $ustring) = explode("#@@#",getWhereCondition($currentModule));
// we have a query
$url_string .="&query=true".$ustring;
$log->info("Here is the where clause for the list view: $where");
Expand Down
6 changes: 3 additions & 3 deletions modules/Calendar/RepeatEvents.php
Expand Up @@ -19,8 +19,8 @@ class Calendar_RepeatEvents {
*/
static function mktime($fulldateString) {
$splitpart = self::splittime($fulldateString);
$datepart = split('-', $splitpart[0]);
$timepart = split(':', $splitpart[1]);
$datepart = explode('-', $splitpart[0]);
$timepart = explode(':', $splitpart[1]);
return mktime($timepart[0], $timepart[1], 0, $datepart[1], $datepart[2], $datepart[0]);
}
/**
Expand All @@ -46,7 +46,7 @@ static function formattime($timeInYMDHIS) {
* Split full timing into date and time part.
*/
static function splittime($fulltiming) {
return split(' ', $fulltiming);
return explode(' ', $fulltiming);
}
/**
* Calculate the time interval to create repeated event entries.
Expand Down

0 comments on commit a803cce

Please sign in to comment.