fixes PHP 7.3; setup updates for PHP >= 7,0

Dieser Commit ist enthalten in:
Oldperl 2019-07-23 11:00:58 +00:00
Ursprung b72e0d30f5
Commit 450ad630b5
2 geänderte Dateien mit 802 neuen und 807 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Project:
* Contenido Content Management System
@ -27,8 +28,7 @@
* }}
*
*/
if(!defined('CON_FRAMEWORK')) {
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
@ -153,10 +153,8 @@ class Version {
*
*/
public static $iDisplayNotification;
protected $_bPathError = false;
/**
* The Version object constructor, initializes class variables
*
@ -183,7 +181,7 @@ class Version {
self::$iDisplayNotification++;
// Look if versioning is allowed, default is false
if(function_exists('getEffectiveSetting')) {
if (function_exists('getEffectiveSetting')) {
$this->bVersionCreatActive = getEffectiveSetting('versioning', 'activated', 'true');
$this->sAlternativePath = getEffectiveSetting('versioning', 'path');
} else {
@ -191,14 +189,13 @@ class Version {
$this->sAlternativePath = "";
}
if($this->bVersionCreatActive == "true"){
if(!is_dir($this->sAlternativePath) ){
if ($this->bVersionCreatActive == "true") {
if (!is_dir($this->sAlternativePath)) {
// Alternative Path is not true or is not exist, we use the frontendpath
if($this->sAlternativePath !="" AND self::$iDisplayNotification < 2){
if ($this->sAlternativePath != "" AND self::$iDisplayNotification < 2) {
$oNotification = new Contenido_Notification();
$sNotification = i18n('Alternative path %s does not exist. Version was saved in frondendpath.');
$oNotification->displayNotification("warning", sprintf($sNotification, $this->sAlternativePath));
}
$this->sAlternativePath = "";
@ -224,7 +221,7 @@ class Version {
$bDelete = true;
while(count($this->aRevisionFiles) >= $sVar AND $bDelete AND (int) $sVar > 0) {
while (count($this->aRevisionFiles) >= $sVar AND $bDelete AND (int) $sVar > 0) {
$iIndex = end(array_keys($this->aRevisionFiles));
$bDelete = $this->deleteFile($this->getFirstRevision());
unset($this->aRevisionFiles[$iIndex]);
@ -238,20 +235,20 @@ class Version {
protected function _checkPaths() {
$aPath = array('', '/css', '/js', '/layout', '/module', '/templates');
$sFrontEndPath = "";
if($this->sAlternativePath == "") {
if ($this->sAlternativePath == "") {
$sFrontEndPath = $this->aCfgClient[$this->iClient]["path"]["frontend"] . "version";
} else {
$sFrontEndPath = $this->sAlternativePath . "/" . $this->iClient;
}
if(is_dir($sFrontEndPath) && is_writable($sFrontEndPath)) {
if (is_dir($sFrontEndPath) && is_writable($sFrontEndPath)) {
foreach ($aPath as $sSubPath) {
if(!is_dir($sFrontEndPath.$sSubPath)){
mkdir($sFrontEndPath.$sSubPath, 0777);
chmod ($sFrontEndPath.$sSubPath, 0777);
if (!is_dir($sFrontEndPath . $sSubPath)) {
mkdir($sFrontEndPath . $sSubPath, 0777);
chmod($sFrontEndPath . $sSubPath, 0777);
}
}
} else {
trigger_error("Version path ".$sFrontEndPath." not writable in ".__FILE__." on line ".__LINE__, E_USER_WARNING);
trigger_error("Version path " . $sFrontEndPath . " not writable in " . __FILE__ . " on line " . __LINE__, E_USER_WARNING);
$this->_bPathError = true;
return false;
}
@ -268,7 +265,6 @@ class Version {
*/
public function setData($sKey, $sValue) {
$this->aBodyData[$sKey] = $sValue;
}
/**
@ -277,7 +273,7 @@ class Version {
* @return string returns content of xml file
*/
public function createNewXml() {
$oXW = new xmlWriter();
$oXW = new cXmlWriter();
$oXW->openMemory();
$oXW->setIndent(true);
$oXW->startDocument('1.0', 'UTF-8');
@ -286,7 +282,7 @@ class Version {
$oXW->writeAttribute('xml:lang', 'de');
$oXW->startElement('head');
$oXW->writeElement('version_id', $this->iIdentity.'_'.$this->iVersion);
$oXW->writeElement('version_id', $this->iIdentity . '_' . $this->iVersion);
$oXW->writeElement('type', $this->sType);
$oXW->writeElement('date', date("Y-m-d H:i:s"));
$oXW->writeElement('author', $this->sAuthor);
@ -314,32 +310,32 @@ class Version {
* @return void
*/
public function createNewVersion() {
if($this->_bPathError) return false;
if ($this->_bPathError)
return false;
$bCreate = false;
if($this->bVersionCreatActive == "true"){
if ($this->bVersionCreatActive == "true") {
try { // Get version Name
$sRevisionName = $this->getRevision();
// Create xml version file
$sXmlFile = $this->createNewXml();
if(!is_dir($this->getFilePath())){
if (!is_dir($this->getFilePath())) {
$bCreate = mkdir($this->getFilePath(), 0777);
chmod ($this->getFilePath(), 0777);
chmod($this->getFilePath(), 0777);
}
$sHandle = fopen($this->getFilePath().$sRevisionName.'.xml', "w");
$sHandle = fopen($this->getFilePath() . $sRevisionName . '.xml', "w");
fputs($sHandle, $sXmlFile);
$bCreate = fclose($sHandle);
if($bCreate == false){
if ($bCreate == false) {
throw new Exception('Couldnt Create New Version');
}
} catch(Exception $e) {
} catch (Exception $e) {
$bCreate = false;
echo '<br>Some error occured: ' . $e->getMessage() . ': ' . $e->getFile() . ' at line '.$e->getLine() . ' ('.$e->getTraceAsString().')';
echo '<br>Some error occured: ' . $e->getMessage() . ': ' . $e->getFile() . ' at line ' . $e->getLine() . ' (' . $e->getTraceAsString() . ')';
}
}
return $bCreate;
@ -360,7 +356,7 @@ class Version {
if ($dh = opendir($sDir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..'){
if ($file != '.' && $file != '..') {
$aData = explode('.', $file);
$aValues = explode('_', $aData[0]);
if ($aValues[0] > $this->iRevisionNumber) {
@ -387,21 +383,21 @@ class Version {
$sDir = $this->getFilePath();
$bDelet = false;
if (is_dir($sDir) AND $sFirstFile =="") {
if (is_dir($sDir) AND $sFirstFile == "") {
if ($dh = opendir($sDir)) {
while (($sFile = readdir($dh)) !== false) {
if($sFile != "." && $sFile !=".."){
if ($sFile != "." && $sFile != "..") {
// Delete the files
$bDelete = unlink($sDir.$sFile);
$bDelete = unlink($sDir . $sFile);
}
}
// if the files be cleared, the delete the folder
$bDelete = rmdir($sDir);
}
} else if($sFirstFile !="") {
} else if ($sFirstFile != "") {
$bDelete = unlink($sDir . $sFirstFile);
}
if($bDelete){
if ($bDelete) {
return true;
} else {
return false;
@ -414,12 +410,12 @@ class Version {
* @return string returns path to revision file
*/
public function getFilePath() {
if($this->sAlternativePath =="") {
if ($this->sAlternativePath == "") {
$sFrontEndPath = $this->aCfgClient[$this->iClient]["path"]["frontend"] . "version/";
} else {
$sFrontEndPath = $this->sAlternativePath . "/" . $this->iClient . "/";
}
return $sFrontEndPath . $this->sType.'/'. $this->iIdentity. '/';
return $sFrontEndPath . $this->sType . '/' . $this->iIdentity . '/';
}
/**
@ -437,7 +433,7 @@ class Version {
* @return integer returns number of Revison File
*/
private function getRevision() {
$this->iVersion = ($this->iRevisionNumber +1 ).'_'.$this->dActualTimestamp;
$this->iVersion = ($this->iRevisionNumber + 1 ) . '_' . $this->dActualTimestamp;
return $this->iVersion;
}
@ -454,7 +450,7 @@ class Version {
// to take first element, we use right sort
ksort($aKey);
foreach($aKey as $value){
foreach ($aKey as $value) {
return $sFirstRevision = $value;
}
return $sFirstRevision;
@ -476,10 +472,10 @@ class Version {
*/
public function getFormatTimestamp() {
$aTimes = array();
if(count($this->dTimestamp) > 0){
if (count($this->dTimestamp) > 0) {
krsort($this->dTimestamp);
foreach($this->dTimestamp as $iKey=>$sTimeValue){
$aTimes[$this->aRevisionFiles[$iKey]] = date('d.m.Y H:i:s', $sTimeValue). " - Revision: " .$iKey;
foreach ($this->dTimestamp as $iKey => $sTimeValue) {
$aTimes[$this->aRevisionFiles[$iKey]] = date('d.m.Y H:i:s', $sTimeValue) . " - Revision: " . $iKey;
}
}
@ -509,19 +505,19 @@ class Version {
$oForm = new UI_Table_Form("lay_history");
$aMessage = array();
// if exists xml files
if(count($this->dTimestamp) > 0) {
if (count($this->dTimestamp) > 0) {
foreach($this->aVarForm as $sKey=>$sValue) {
$oForm ->setVar($sKey, $sValue);
foreach ($this->aVarForm as $sKey => $sValue) {
$oForm->setVar($sKey, $sValue);
}
$aMessage = $this->getMessages();
$oForm ->addHeader(i18n($sAddHeader));
$oForm ->add(i18n($sLabelOfSelectBox), $this->getSelectBox($this->getFormatTimestamp(), $sIdOfSelectBox));
$oForm ->setActionButton("clearhistory", "images/but_delete.gif", $aMessage["alt"], "c", "history_truncate");
$oForm ->setConfirm("clearhistory", $aMessage["alt"], $aMessage["popup"]);
$oForm ->setActionButton("submit", "images/but_refresh.gif", i18n("Refresh"), "s");
$oForm->addHeader(i18n($sAddHeader));
$oForm->add(i18n($sLabelOfSelectBox), $this->getSelectBox($this->getFormatTimestamp(), $sIdOfSelectBox));
$oForm->setActionButton("clearhistory", "images/but_delete.gif", $aMessage["alt"], "c", "history_truncate");
$oForm->setConfirm("clearhistory", $aMessage["alt"], $aMessage["popup"]);
$oForm->setActionButton("submit", "images/but_refresh.gif", i18n("Refresh"), "s");
return $oForm ->render().'<div style="margin-top:20px;"></div>';
return $oForm->render() . '<div style="margin-top:20px;"></div>';
} else {
return '';
}
@ -531,34 +527,33 @@ class Version {
* Messagebox for build selectBox. Dynamic allocation for type.
* return array the attributes alt and poput returns
*/
private function getMessages(){
private function getMessages() {
$aMessage = array();
switch($this->sType){
switch ($this->sType) {
case 'layout':
$aMessage["alt"] = i18n("Clear layout history");
$aMessage["popup"] = i18n("Do you really want to clear layout history?")."<br><br>".i18n("Note: This only affects the current layout.");
$aMessage["popup"] = i18n("Do you really want to clear layout history?") . "<br><br>" . i18n("Note: This only affects the current layout.");
break;
case 'module':
$aMessage["alt"] = i18n("Clear module history");
$aMessage["popup"] = i18n("Do you really want to clear module history?")."<br><br>".i18n("Note: This only affects the current module.");
$aMessage["popup"] = i18n("Do you really want to clear module history?") . "<br><br>" . i18n("Note: This only affects the current module.");
break;
case 'css':
$aMessage["alt"] = i18n("Clear style history");
$aMessage["popup"] = i18n("Do you really want to clear style history?")."<br><br>".i18n("Note: This only affects the current style.");
$aMessage["popup"] = i18n("Do you really want to clear style history?") . "<br><br>" . i18n("Note: This only affects the current style.");
break;
case 'js':
$aMessage["alt"] = i18n("Clear Java-Script history");
$aMessage["popup"] = i18n("Do you really want to clear Java-Script history?")."<br><br>".i18n("Note: This only affects the current Java-Script.");
$aMessage["popup"] = i18n("Do you really want to clear Java-Script history?") . "<br><br>" . i18n("Note: This only affects the current Java-Script.");
break;
case 'templates':
$aMessage["alt"] = i18n("Clear HTML-Template history");
$aMessage["popup"] = i18n("Do you really want to clear HTML-Template history?")."<br><br>".i18n("Note: This only the affects current HTML-Template.");
$aMessage["popup"] = i18n("Do you really want to clear HTML-Template history?") . "<br><br>" . i18n("Note: This only the affects current HTML-Template.");
break;
default:
$aMessage["alt"] = i18n("Clear history");
$aMessage["popup"] = i18n("Do you really want to clear history?")."<br><br>".i18n("Note: This only affects the current history.");
$aMessage["popup"] = i18n("Do you really want to clear history?") . "<br><br>" . i18n("Note: This only affects the current history.");
break;
}
return $aMessage;
}
@ -576,7 +571,7 @@ class Version {
$oSelectMenue = new cHTMLSelectElement($sIdOfSelectBox);
$oSelectMenue->autoFill($aTempVesions);
if($sSelected !=""){
if ($sSelected != "") {
$oSelectMenue->setDefault($sSelected);
}
@ -594,7 +589,7 @@ class Version {
* @return string HTML Code of Textarea
*/
public function getTextarea($sName, $sInitValue, $iWidth, $iHeight, $sId = "") {
if($sId !="") {
if ($sId != "") {
$oHTMLTextarea = new cHTMLTextarea($sName, $sInitValue, $iWidth, $iHeight, $sId);
} else {
$oHTMLTextarea = new cHTMLTextarea($sName, $sInitValue, $iWidth, $iHeight);
@ -604,7 +599,6 @@ class Version {
$oHTMLTextarea->updateAttributes(array("wrap" => "off"));
return $oHTMLTextarea->render();
}
/**
@ -632,7 +626,7 @@ class Version {
* @return void
*/
public function displayNotification($sOutPut) {
if($sOutPut !="") {
if ($sOutPut != "") {
print $sOutPut;
}
}
@ -644,12 +638,13 @@ class Version {
*
*/
public function setBodyNodeDescription($sDesc) {
if($sDesc != ""){
if ($sDesc != "") {
$this->sDescripion = clHtmlEntities($sDesc);
$this->setData("description", $this->sDescripion);
}
}
} // end of class
}
// end of class
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Project:
* Contenido Content Management System
@ -25,12 +26,11 @@
* }}
*
*/
if(!defined('CON_FRAMEWORK')) {
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
class VersionImport extends Version {
class VersionImport extends Version {
/**
* The name of modul
@ -134,25 +134,26 @@ if(!defined('CON_FRAMEWORK')) {
$this->aCfgClient = $aCfgClient;
$this->oDB = $oDB;
if(!is_object($this->oDB))
if (!is_object($this->oDB))
$this->oDB = new DB_ConLite;
// folder layout
$this->sType = "module";
if(isset($_SESSION["dbprefix"])){
$this->sTableName = $_SESSION["dbprefix"]."_mod_history";
if (isset($_SESSION["dbprefix"])) {
$this->sTableName = $_SESSION["dbprefix"] . "_mod_history";
} else {
$this->sTableName = $this->aCfg['sql']['sqlprefix']."_mod_history";
$this->sTableName = $this->aCfg['sql']['sqlprefix'] . "_mod_history";
}
// init class member
$this->aCreateVesion = array();
// Init class members with table con_history
$this->getModuleHistoryTable();
}
} // end of constructor
// end of constructor
/**
* Creats xml files from table mod_history if exists any rows. After create a version it will be delete the current row.
@ -161,17 +162,17 @@ if(!defined('CON_FRAMEWORK')) {
* @return void
*/
public function CreateHistoryVersion() {
if($this->getRows() > 0) {
if ($this->getRows() > 0) {
// Sort the version files true
ksort($this->aCreateVersion);
// All array read
foreach( $this->aCreateVersion as $sKey=>$sLevelOne) {
foreach($sLevelOne as $sKey2=>$sLevelTwo) {
foreach ($this->aCreateVersion as $sKey => $sLevelOne) {
foreach ($sLevelOne as $sKey2 => $sLevelTwo) {
if (is_array($this->aCfgClient[$sKey])) {
parent::__construct($aCfg, $this->aCfgClient, $this->oDB, $sKey, $sArea, $iFrame);
foreach($sLevelTwo as $sKey3=>$sLevelThree) {
foreach ($sLevelTwo as $sKey3 => $sLevelThree) {
$this->iIdentity = $sKey2;
$this->sName = Contenido_Security::unFilter($sLevelThree["name"]);
$this->sModType = Contenido_Security::unFilter($sLevelThree["type"]);
@ -193,7 +194,7 @@ if(!defined('CON_FRAMEWORK')) {
$this->createBodyXML();
if($this->createNewVersion()) {
if ($this->createNewVersion()) {
$this->deleteRows($sLevelThree["idmodhistory"]);
}
}
@ -203,12 +204,11 @@ if(!defined('CON_FRAMEWORK')) {
}
if($this->getRows() == 0) {
if ($this->getRows() == 0) {
$this->dropTable();
}
}
/**
* Function reads rows variables from table con_mod and init with the class members.
*
@ -217,20 +217,21 @@ if(!defined('CON_FRAMEWORK')) {
private function getModuleHistoryTable() {
$sSql = "";
$sSql = "SELECT *
FROM ". $this->sTableName;
FROM " . $this->sTableName;
$this->oDB->query($sSql);
// save mod_history in three dimension array
while($this->oDB->next_record()) {
$this->aCreateVersion[$this->oDB->f("idclient")][$this->oDB->f("idmod")][$this->oDB->f("idmodhistory")] =
array("idmodhistory"=>$this->oDB->f("idmodhistory"), "idmod"=>$this->oDB->f("idmod"),
"idclient"=>$this->oDB->f("idclient"), "name"=>$this->oDB->f("name"),
"type"=>$this->oDB->f("type"), "description"=>$this->oDB->f("description"),
"input"=>$this->oDB->f("input"), "output"=>$this->oDB->f("output"),
"template"=>$this->oDB->f("template"), "changedby"=>$this->oDB->f("changedby"),
"changed"=>$this->oDB->f("changed"));
while ($this->oDB->next_record()) {
$this->aCreateVersion[$this->oDB->f("idclient")][$this->oDB->f("idmod")][$this->oDB->f("idmodhistory")] = array("idmodhistory" => $this->oDB->f("idmodhistory"), "idmod" => $this->oDB->f("idmod"),
"idclient" => $this->oDB->f("idclient"), "name" => $this->oDB->f("name"),
"type" => $this->oDB->f("type"), "description" => $this->oDB->f("description"),
"input" => $this->oDB->f("input"), "output" => $this->oDB->f("output"),
"template" => $this->oDB->f("template"), "changedby" => $this->oDB->f("changedby"),
"changed" => $this->oDB->f("changed"));
}
} // end of function
}
// end of function
/**
* Set with the body nodes of xml file
@ -250,7 +251,6 @@ if(!defined('CON_FRAMEWORK')) {
$this->setData("Static", $this->sStatic);
$this->setData("PackageGuid", $this->sPackageGuid);
$this->setData("PackageData", $this->sPackageData);
}
/**
@ -261,7 +261,7 @@ if(!defined('CON_FRAMEWORK')) {
private function getRows() {
$sSqlCount = "";
$iAnz = 0;
$sSqlCount = "SELECT * FROM ". $this->sTableName;
$sSqlCount = "SELECT * FROM " . $this->sTableName;
$this->oDB->query($sSqlCount);
$iAnz = $this->oDB->num_rows();
@ -275,7 +275,7 @@ if(!defined('CON_FRAMEWORK')) {
*/
public function dropTable() {
$sSqlDropTable = "";
$sSqlDropTable = "DROP TABLE IF EXISTS ". $this->sTableName;
$sSqlDropTable = "DROP TABLE IF EXISTS " . $this->sTableName;
$this->oDB->query($sSqlDropTable);
}
@ -286,11 +286,11 @@ if(!defined('CON_FRAMEWORK')) {
*/
public function deleteRows($iModHistory) {
$iModHistory = Contenido_Security::unFilter($iModHistory);
$sSql2 = "DELETE FROM ". $this->sTableName .
" WHERE idmodhistory = ". $iModHistory;
$sSql2 = "DELETE FROM " . $this->sTableName .
" WHERE idmodhistory = " . $iModHistory;
$this->oDB->query($sSql2);
}
}
?>