Fixed some PHP 5.3 incompatible Codeparts

This commit is contained in:
Andreas Österreicher
2018-01-15 18:00:41 +01:00
parent 75894104cc
commit c54bb2303d
5 changed files with 73 additions and 58 deletions
+10 -1
View File
@@ -15,8 +15,17 @@ class DocumentLib
$this->ci =& get_instance();
exec('unoconv --version', $ret_arr);
if(isset($ret_arr[0]))
$this->unoconv_version = explode(' ', $ret_arr[0])[1];
{
$hlp = explode(' ', $ret_arr[0]);
if(isset($hlp[1]))
{
$this->unoconv_version = $hlp[1];
}
else
show_error('Could not get Unoconv Version');
}
else
show_error('Unoconv not found - Please install Unoconv');
}
+27 -25
View File
@@ -11,16 +11,16 @@ class ExtensionsLib
const SQL_FILE_EXTENSION = '.sql'; // SQL scripts file extension
const FILE_INPUT_NAME = 'extension'; // name of the HTTP parameter containing the archive data
const ARCHIVE_EXTENSIONS = array('.tgz', '.tbz2'); // accepted file extensions for an uploaded extension
const EXTENSION_JSON_NAME = 'extension.json'; // file that contains extension data
const UPLOAD_PATH = APPPATH.'tmp/'; // temporary directory to store the upload file and checks the archive
const EXTENSIONS_PATH = APPPATH.'extensions/'; // directory where all the extensions are
const EXTENSIONS_DIR_NAME = 'extensions'; // name of the directories where will be created the symlinks
private $ARCHIVE_EXTENSIONS = array('.tgz', '.tbz2'); // accepted file extensions for an uploaded extension
private $UPLOAD_PATH; // temporary directory to store the upload file and checks the archive
private $EXTENSIONS_PATH; // directory where all the extensions are
// Directories that are part of the extension archive
const SOFTLINK_TARGET_DIRECTORIES = array('config', 'controllers', 'helpers', 'hooks', 'libraries', 'models', 'views', 'widgets');
private $SOFTLINK_TARGET_DIRECTORIES = array('config', 'controllers', 'helpers', 'hooks', 'libraries', 'models', 'views', 'widgets');
private $_errorOccurred; // boolean, true if an error occurred while installing an extension
private $_currentInstalledExtensionVersion; // contains the version of the current installation of an extension
@@ -29,9 +29,11 @@ class ExtensionsLib
* Class constructor
*/
public function __construct()
{
{
$this->UPLOAD_PATH = APPPATH.'tmp/';
$this->EXTENSIONS_PATH = APPPATH.'extensions/';
// Get code igniter instance
$this->ci =& get_instance();
$this->ci =& get_instance();
// Loads message configurationx
$this->ci->config->load('message');
@@ -60,7 +62,7 @@ class ExtensionsLib
$this->_printInfo('WARNING!!! Please do not change page or stop this procedure before it is finished');
$this->_loadUploadLibrary(); // loads CI upload library
$this->_loadUploadLibrary(); // loads CI upload library
$uploadData = $this->_uploadExtension(); // perform the upload of the file and returns info about it
@@ -99,7 +101,7 @@ class ExtensionsLib
{
// Loads and executes neede SQL scripts
$this->_loadSQLs(
ExtensionsLib::UPLOAD_PATH.$extensionJson->name.'/'.ExtensionsLib::SQL_DIRECTORY,
$this->UPLOAD_PATH.$extensionJson->name.'/'.ExtensionsLib::SQL_DIRECTORY,
$extensionJson
);
}
@@ -157,7 +159,7 @@ class ExtensionsLib
$extensionName = $result->retval[0]->name; // extension name
$this->_delSoftLinks($extensionName); // not to be checked, could fail if the extension is disabled
// remove the extension from the extensions installation directory
$delExtension = $this->_rrm(ExtensionsLib::EXTENSIONS_PATH.$extensionName);
$delExtension = $this->_rrm($this->EXTENSIONS_PATH.$extensionName);
// Select all the version of this extension
$this->ci->ExtensionsModel->addSelect('extension_id');
@@ -215,7 +217,7 @@ class ExtensionsLib
$this->ci->load->library(
'upload',
array(
'upload_path' => ExtensionsLib::UPLOAD_PATH,
'upload_path' => $this->UPLOAD_PATH,
'allowed_types' => '*',
'overwrite' => true
)
@@ -237,7 +239,7 @@ class ExtensionsLib
$uploadData = $this->ci->upload->data(); // retrives data about the uploaded file
// Checks the file extension
$uploadedFileExtension = '.'.pathinfo($uploadData['full_path'], PATHINFO_EXTENSION);
if (!in_array($uploadedFileExtension, ExtensionsLib::ARCHIVE_EXTENSIONS))
if (!in_array($uploadedFileExtension, $this->ARCHIVE_EXTENSIONS))
{
$this->_printFailure('file extension must be tgz OR tbz2');
@@ -251,7 +253,7 @@ class ExtensionsLib
{
// Returns the extension name and the full path of the uploaded file
$_uploadExtension = new stdClass();
$_uploadExtension->extensionName = str_replace(ExtensionsLib::ARCHIVE_EXTENSIONS, '', $uploadData['file_name']);
$_uploadExtension->extensionName = str_replace($this->ARCHIVE_EXTENSIONS, '', $uploadData['file_name']);
$_uploadExtension->fullPath = $uploadData['full_path'];
}
}
@@ -279,7 +281,7 @@ class ExtensionsLib
// Extracts the uploaded file
$pd = new PharData($uploadPath);
$pd->extractTo(ExtensionsLib::UPLOAD_PATH, null, true);
$pd->extractTo($this->UPLOAD_PATH, null, true);
}
catch (UnexpectedValueException $uva)
{
@@ -342,10 +344,10 @@ class ExtensionsLib
$this->_printStart('Checking extension file system structure');
// Checks if the root directory of this archive has the same name of the extension
if (is_dir(ExtensionsLib::UPLOAD_PATH.$extensionName))
if (is_dir($this->UPLOAD_PATH.$extensionName))
{
// Checks if file extension.json exists inside the uploaded archive
if (!file_exists(ExtensionsLib::UPLOAD_PATH.$extensionName.'/'.ExtensionsLib::EXTENSION_JSON_NAME))
if (!file_exists($this->UPLOAD_PATH.$extensionName.'/'.ExtensionsLib::EXTENSION_JSON_NAME))
{
$this->_errorOccurred = true;
$this->_printFailure('missing extension.json');
@@ -371,7 +373,7 @@ class ExtensionsLib
// Decodes extension.json
$extensionJson = json_decode(
file_get_contents(ExtensionsLib::UPLOAD_PATH.$extensionName.'/'.ExtensionsLib::EXTENSION_JSON_NAME)
file_get_contents($this->UPLOAD_PATH.$extensionName.'/'.ExtensionsLib::EXTENSION_JSON_NAME)
);
// Checks if the parameter name of the extension.json has the same value of the extension name
@@ -608,10 +610,10 @@ class ExtensionsLib
{
$this->_printStart('Moving the upload extension from upload folder to extension folder');
$this->_printMessage('Current extension directory: '.ExtensionsLib::UPLOAD_PATH.$extensionName);
$this->_printMessage('Directory where it will be moved: '.ExtensionsLib::EXTENSIONS_PATH.$extensionName);
$this->_printMessage('Current extension directory: '.$this->UPLOAD_PATH.$extensionName);
$this->_printMessage('Directory where it will be moved: '.$this->EXTENSIONS_PATH.$extensionName);
if (rename(ExtensionsLib::UPLOAD_PATH.$extensionName.'/', ExtensionsLib::EXTENSIONS_PATH.$extensionName))
if (rename($this->UPLOAD_PATH.$extensionName.'/', $this->EXTENSIONS_PATH.$extensionName))
{
$this->_printSuccess(true);
}
@@ -652,7 +654,7 @@ class ExtensionsLib
{
$_delSoftLinks = false;
foreach (ExtensionsLib::SOFTLINK_TARGET_DIRECTORIES as $key => $targetDirectory)
foreach ($this->SOFTLINK_TARGET_DIRECTORIES as $key => $targetDirectory)
{
if (file_exists(APPPATH.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName))
{
@@ -700,10 +702,10 @@ class ExtensionsLib
private function _addSoftLinks($extensionName)
{
$_addSoftLinks = false;
$extensionPath = ExtensionsLib::EXTENSIONS_PATH.$extensionName.'/';
$extensionPath = $this->EXTENSIONS_PATH.$extensionName.'/';
// For every target directory
foreach (ExtensionsLib::SOFTLINK_TARGET_DIRECTORIES as $key => $targetDirectory)
foreach ($this->SOFTLINK_TARGET_DIRECTORIES as $key => $targetDirectory)
{
// If destination of the symlink does not exist
if (!file_exists(APPPATH.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName))
@@ -746,9 +748,9 @@ class ExtensionsLib
$this->_printMessage('Removing the extracted data from the upload directory');
if ($uploadData != null
&& isset($uploadData->extensionName)
&& file_exists(ExtensionsLib::UPLOAD_PATH.$uploadData->extensionName))
&& file_exists($this->UPLOAD_PATH.$uploadData->extensionName))
{
$this->_rrm(ExtensionsLib::UPLOAD_PATH.$uploadData->extensionName);
$this->_rrm($this->UPLOAD_PATH.$uploadData->extensionName);
}
// If the upload of the file is a success and the extension name is present and no previous installation were found
+13 -13
View File
@@ -10,29 +10,29 @@ class LogLib
const DEBUG = 'debug';
const ERROR = 'error';
const INFO = 'info';
const CALLER_PREFIX = '[';
const CALLER_POSTFIX = ']';
const CLASS_POSTFIX = '->';
const LINE_SEPARATOR = ':';
/**
* format
*/
private function format($class, $function, $line)
{
$formatted = LogLib::CALLER_PREFIX;
if (!is_null($class) && $class != '')
{
$formatted .= $class.LogLib::CLASS_POSTFIX;
}
$formatted .= $function.LogLib::LINE_SEPARATOR.$line.LogLib::CALLER_POSTFIX.' ';
return $formatted;
}
/**
* getCaller
*/
@@ -44,20 +44,20 @@ class LogLib
$class = '';
$function = '';
$line = '';
if (isset(debug_backtrace()[$classIndex]['class']) && debug_backtrace()[$classIndex]['class'] != '')
$backtrace_arr = debug_backtrace();
if (isset($backtrace_arr[$classIndex]['class']) && $backtrace_arr[$classIndex]['class'] != '')
{
$class = debug_backtrace()[$classIndex]['class'];
$class = $backtrace_arr[$classIndex]['class'];
}
if (isset(debug_backtrace()[$functionIndex]['function']) && debug_backtrace()[$functionIndex]['function'] != '')
if (isset($backtrace_arr[$functionIndex]['function']) && $backtrace_arr[$functionIndex]['function'] != '')
{
$function = debug_backtrace()[$functionIndex]['function'];
$function = $backtrace_arr[$functionIndex]['function'];
}
if (isset(debug_backtrace()[$lineIndex]['line']) && debug_backtrace()[$lineIndex]['line'] != '')
if (isset($backtrace_arr[$lineIndex]['line']) && $backgrace_arr[$lineIndex]['line'] != '')
{
$line = debug_backtrace()[$lineIndex]['line'];
$line = $backtrace_arr[$lineIndex]['line'];
}
return $this->format($class, $function, $line);
+11 -10
View File
@@ -351,7 +351,7 @@ abstract class REST_Controller extends CI_Controller {
self::HTTP_INTERNAL_SERVER_ERROR => 'INTERNAL SERVER ERROR',
self::HTTP_NOT_IMPLEMENTED => 'NOT IMPLEMENTED'
];
/**
* Extend this function to apply additional checking early on in the process
*
@@ -361,7 +361,7 @@ abstract class REST_Controller extends CI_Controller {
protected function early_checks()
{
}
/**
* Constructor for the REST API
*
@@ -385,7 +385,8 @@ abstract class REST_Controller extends CI_Controller {
}
// Check to see if this is CI 3.x
if (explode('.', CI_VERSION, 2)[0] < 3)
$ci_version_number = explode('.', CI_VERSION, 2);
if ($ci_version_number[0] < 3)
{
throw new Exception('REST Server requires CodeIgniter 3.x');
}
@@ -528,7 +529,7 @@ abstract class REST_Controller extends CI_Controller {
{
$this->_allow = $this->_detect_api_key();
}
// Only allow ajax requests
if ($this->input->is_ajax_request() === FALSE && $this->config->item('rest_ajax_only'))
{
@@ -607,7 +608,7 @@ abstract class REST_Controller extends CI_Controller {
//$controller_method = $object_called . '_' . $this->request->method;
// CamelCase compliant
$controller_method = $this->request->method.ucfirst($object_called);
// Do we want to log this method (if allowed by config)?
$log_method = !(isset($this->methods[$controller_method]['log']) && $this->methods[$controller_method]['log'] === FALSE);
@@ -737,7 +738,7 @@ abstract class REST_Controller extends CI_Controller {
// Set the format header
$this->output->set_content_type($this->_supported_formats[$this->response->format], strtolower($this->config->item('charset')));
$output = $this->format->factory($data)->{'to_' . $this->response->format}();
// An array must be parsed as a string, so as not to cause an array to string error
// Json is the most appropriate form for such a datatype
if ($this->response->format === 'array')
@@ -967,7 +968,7 @@ abstract class REST_Controller extends CI_Controller {
$this->rest->level = NULL;
$this->rest->user_id = NULL;
$this->rest->ignore_limits = FALSE;
// Find the key from server or arguments
if (($key = isset($this->_args[$api_key_variable]) ? $this->_args[$api_key_variable] : $this->input->server($key_name)))
{
@@ -1899,7 +1900,7 @@ abstract class REST_Controller extends CI_Controller {
], self::HTTP_UNAUTHORIZED);
}
}
/**
* Prepares for basic authentication
*
@@ -1977,7 +1978,7 @@ abstract class REST_Controller extends CI_Controller {
preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches);
$digest = (empty($matches[1]) || empty($matches[2])) ? [] : array_combine($matches[1], $matches[2]);
// For digest authentication the library function should return
// For digest authentication the library function should return
// already stored password for that username, even if it is hashed
$username = $this->_check_login($digest['username'], TRUE);
// If there no password
@@ -2154,4 +2155,4 @@ abstract class REST_Controller extends CI_Controller {
->get($this->config->item('rest_access_table'))
->num_rows() > 0;
}
}
}
@@ -88,10 +88,11 @@ class MessageToken_model extends CI_Model
// If no errors occurred
if ($msgs)
{
$msgs_result = $msgs->result();
// If at least a record is present
if (count($msgs->result()) > 0)
if (count($msgs_result) > 0)
{
$msg = $msgs->result()[0];
$msg = $msgs_result[0];
$msgStatusResult = false; // pessimistic expectation
@@ -133,7 +134,7 @@ class MessageToken_model extends CI_Model
}
}
return success($msgs->result());
return success($msgs_result);
}
else
{
@@ -193,7 +194,8 @@ class MessageToken_model extends CI_Model
// If data are present
if (is_array($result->result()) && count($result->result()) > 0)
{
$person = $result->result()[0];
$personresults = $result->result();
$person = $personresults[0];
// If it is an employee
if ($person->mitarbeiter_uid != null)
@@ -236,13 +238,14 @@ class MessageToken_model extends CI_Model
$result = $this->db->query($sql, array($oe_kurzbz));
if ($result) // If no errors occurred
{
$result_arr = $result->result();
// If data are present
if (is_array($result->result())
&& count($result->result()) > 0
&& is_object($result->result()[0])
&& isset($result->result()[0]->oe_kurzbz))
if (is_array($result_arr)
&& count($result_arr) > 0
&& is_object($result_arr[0])
&& isset($result_arr[0]->oe_kurzbz))
{
return success($result->result()[0]->oe_kurzbz);
return success($result_arr[0]->oe_kurzbz);
}
else
{