fixes for PHP 7

Dieser Commit ist enthalten in:
oldperl 2017-01-12 19:58:01 +00:00
Ursprung 60783a9957
Commit ef7df8a507
4 geänderte Dateien mit 210 neuen und 192 gelöschten Zeilen

Datei anzeigen

@ -1953,23 +1953,32 @@ function checkMySQLConnectivity() {
global $contenido_host, $contenido_database, $contenido_user, $contenido_password, $cfg; global $contenido_host, $contenido_database, $contenido_user, $contenido_password, $cfg;
if ($cfg["database_extension"] == "mysqli") { if ($cfg["database_extension"] == "mysqli") {
if (($iPos = strpos($contenido_host, ":")) !== false) { if (function_exists("mysqli_connect")) {
list($sHost, $sPort) = explode(":", $contenido_host); if (($iPos = strpos($contenido_host, ":")) !== false) {
list($sHost, $sPort) = explode(":", $contenido_host);
$res = @mysqli_connect($sHost, $contenido_user, $contenido_password, "", $sPort); $res = mysqli_connect($sHost, $contenido_user, $contenido_password, "", $sPort);
} else {
$res = mysqli_connect($contenido_host, $contenido_user, $contenido_password);
}
} else { } else {
$res = @mysqli_connect($contenido_host, $contenido_user, $contenido_password); $res = NULL;
} }
} else { } else {
$res = @mysql_connect($contenido_host, $contenido_user, $contenido_password); if(function_exists("mysql_connect")) {
$res = mysql_connect($contenido_host, $contenido_user, $contenido_password);
} else {
$res = NULL;
}
} }
$selectDb = false; $selectDb = false;
if ($res) { if ($res) {
if ($cfg["database_extension"] == "mysqli") { if ($cfg["database_extension"] == "mysqli") {
$selectDb = @mysqli_select_db($res, $contenido_database); $selectDb = mysqli_select_db($res, $contenido_database);
} else { } else {
$selectDb = @mysql_select_db($contenido_database, $res); $selectDb = mysql_select_db($contenido_database, $res);
} }
} }

Datei anzeigen

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Project: * Project:
* Contenido Content Management System * Contenido Content Management System
@ -18,211 +19,188 @@
* *
* $Id: include.lay_edit_form.php 312 2014-06-18 11:01:08Z oldperl $: * $Id: include.lay_edit_form.php 312 2014-06-18 11:01:08Z oldperl $:
*/ */
if (!defined('CON_FRAMEWORK')) {
if(!defined('CON_FRAMEWORK')) { die('Illegal call');
die('Illegal call');
} }
cInclude("external", "edit_area/class.edit_area.php"); cInclude("external", "edit_area/class.edit_area.php");
if (!isset($idlay)) $idlay = 0; if (!isset($idlay))
$idlay = 0;
$page = new cPage; $page = new cPage;
$layout = new cApiLayout(); $layout = new cApiLayout();
if ($idlay != 0) if ($idlay != 0) {
{ $layout->loadByPrimaryKey($idlay);
$layout->loadByPrimaryKey($idlay);
} }
if ($action == "lay_new") if ($action == "lay_new") {
{ if (!$perm->have_perm_area_action_anyitem($area, $action)) {
if (!$perm->have_perm_area_action_anyitem($area, $action)) $notification->displayNotification("error", i18n("Permission denied"));
{ } else {
$notification->displayNotification("error", i18n("Permission denied")); $layouts = new cApiLayoutCollection;
} else { $layout = $layouts->create(i18n("-- New Layout --"));
$layouts = new cApiLayoutCollection; }
$layout = $layouts->create(i18n("-- New Layout --")); } elseif ($action == "lay_delete") {
} if (!$perm->have_perm_area_action_anyitem($area, $action)) {
} elseif ($action == "lay_delete") $notification->displayNotification("error", i18n("Permission denied"));
{ } else {
if (!$perm->have_perm_area_action_anyitem($area, $action)) $errno = layDeleteLayout($idlay);
{ $layout->virgin = true;
$notification->displayNotification("error", i18n("Permission denied")); $sMsg = $notification->returnNotification("info", i18n("Layout deleted"));
} else { }
$errno = layDeleteLayout($idlay);
$layout->virgin = true;
$sMsg = $notification->returnNotification("info", i18n("Layout deleted"));
}
} }
if ($refreshtemplates != "") if ($refreshtemplates != "") {
{ /* Update all templates for containers with mode fixed and mandatory */
/* Update all templates for containers with mode fixed and mandatory */ $sql = "SELECT idtpl FROM " . $cfg["tab"]["tpl"] . " WHERE idlay = '" . Contenido_Security::toInteger($idlay) . "'";
$sql = "SELECT idtpl FROM ".$cfg["tab"]["tpl"]." WHERE idlay = '".Contenido_Security::toInteger($idlay)."'"; $db->query($sql);
$db->query($sql);
$fillTemplates = array();
$fillTemplates = array();
while ($db->next_record()) {
while ($db->next_record()) $fillTemplates[] = $db->f("idtpl");
{ }
$fillTemplates[] = $db->f("idtpl");
} foreach ($fillTemplates as $fillTemplate) {
tplAutoFillModules($fillTemplate);
foreach ($fillTemplates as $fillTemplate) }
{
tplAutoFillModules($fillTemplate);
}
} }
if (!$layout->virgin) if (!$layout->virgin) {
{ $msg = "";
$msg = "";
$tpl->reset(); $tpl->reset();
$idlay = $layout->get("idlay"); $idlay = $layout->get("idlay");
$code = $layout->getLayout(); $code = $layout->getLayout();
$name = $layout->get("name"); $name = $layout->get("name");
$description = $layout->get("description"); $description = $layout->get("description");
/* Search for duplicate containers */
tplPreparseLayout($idlay);
$ret = tplBrowseLayoutForContainers($idlay);
if (strlen($ret) != 0)
{
$containers = explode("&", $ret);
$types = array();
foreach ($containers as $value)
{
if ($value != "") {
$container[$value] = 0;
/* Search for old-style CMS_CONTAINER[x] */
$container[$value] += substr_count($code,"CMS_CONTAINER[$value]");
/* Search for the new-style containers */ /* Search for duplicate containers */
$count = preg_match_all("/<container( +)id=\\\\\"$value\\\\\"(.*)>(.*)<\/container>/i", addslashes($code), $matches); tplPreparseLayout($idlay);
$ret = tplBrowseLayoutForContainers($idlay);
$container[$value] += $count; if (strlen($ret) != 0) {
$containers = explode("&", $ret);
if (is_array(tplGetContainerTypes($idlay, $value))) {
$types = array_merge($types, tplGetContainerTypes($idlay, $value));
}
}
}
$types = array_unique($types);
$layout->setProperty("layout", "used-types", implode($types, ";"));
$msg = "";
foreach ($container as $key => $value)
{
if ($value > 1)
{
$msg .= sprintf(i18n("Container %s was defined %s times"), $key, $value)."<br>";
}
}
}
/* Try to validate html */ $types = array();
if (getEffectiveSetting("layout", "htmlvalidator", "true") == "true" && $code !== "")
{ foreach ($containers as $value) {
$v = new cHTMLValidator; if ($value != "") {
$v->validate($code); $container[$value] = 0;
/* Search for old-style CMS_CONTAINER[x] */
$container[$value] += substr_count($code, "CMS_CONTAINER[$value]");
/* Search for the new-style containers */
$count = preg_match_all("/<container( +)id=\\\\\"$value\\\\\"(.*)>(.*)<\/container>/i", addslashes($code), $matches);
$container[$value] += $count;
if (is_array(tplGetContainerTypes($idlay, $value))) {
$types = array_merge($types, tplGetContainerTypes($idlay, $value));
}
}
}
$types = array_unique($types);
$layout->setProperty("layout", "used-types", implode($types, ";"));
$msg = "";
foreach ($container as $key => $value) {
if ($value > 1) {
$msg .= sprintf(i18n("Container %s was defined %s times"), $key, $value) . "<br>";
}
}
}
/* Try to validate html */
if (getEffectiveSetting("layout", "htmlvalidator", "true") == "true" && $code !== "") {
$v = new cHTMLValidator;
$v->validate($code);
if (!$v->tagExists("body") && !$v->tagExists("BODY")) {
$msg .= sprintf(i18n("The body tag does not exist in the layout. This is a requirement for the in-site editing."));
$msg .= "<br>";
}
if (!$v->tagExists("head") && !$v->tagExists("HEAD")) {
$msg .= sprintf(i18n("The head tag does not exist in the layout. This is a requirement for the in-site editing."));
$msg .= "<br>";
}
foreach ($v->missingNodes as $value) {
$idqualifier = "";
$attr = array();
if ($value["name"] != "") {
$attr["name"] = "name '" . $value["name"] . "'";
}
if ($value["id"] != "") {
$attr["id"] = "id '" . $value["id"] . "'";
}
$idqualifier = implode(", ", $attr);
if ($idqualifier != "") {
$idqualifier = "($idqualifier)";
}
$msg .= sprintf(i18n("Tag '%s' %s has no end tag (start tag is on line %s char %s)"), $value["tag"], $idqualifier, $value["line"], $value["char"]);
$msg .= "<br>";
}
}
if ($msg != "") {
$notification->displayNotification("warning", $msg);
}
$form = new UI_Table_Form("module");
$form->addHeader(i18n("Edit Layout"));
$form->setWidth("100%");
$form->setVar("area", $area);
$form->setVar("action", "lay_edit");
$form->setVar("frame", $frame);
$form->setVar("idlay", $idlay);
$tb_name = new cHTMLTextbox("layname", $name, 60);
$ta_description = new cHTMLTextarea("description", $description, 100, 10);
$ta_description->setStyle("font-family: monospace;width: 100%;");
$ta_description->updateAttributes(array("wrap" => "off"));
$ta_code = new cHTMLTextarea("code", clHtmlSpecialChars($code), 100, 20, 'code');
$ta_code->setStyle("font-family: monospace;width: 100%;");
$ta_code->updateAttributes(array("wrap" => "off"));
$cb_refresh = new cHTMLCheckbox("refreshtemplates", i18n("On save, apply default modules to new containers"));
$form->add(i18n("Name"), $tb_name);
$form->add(i18n("Description"), $ta_description);
$form->add(i18n("Code"), $ta_code);
$form->add(i18n("Options"), $cb_refresh);
if (!$v->tagExists("body") && !$v->tagExists("BODY"))
{
$msg .= sprintf(i18n("The body tag does not exist in the layout. This is a requirement for the in-site editing."));
$msg .= "<br>";
}
if (!$v->tagExists("head") && !$v->tagExists("HEAD"))
{
$msg .= sprintf(i18n("The head tag does not exist in the layout. This is a requirement for the in-site editing."));
$msg .= "<br>";
}
foreach ($v->missingNodes as $value)
{
$idqualifier = "";
$attr = array();
if ($value["name"] != "")
{
$attr["name"] = "name '".$value["name"]."'";
}
if ($value["id"] != "")
{
$attr["id"] = "id '".$value["id"]."'";
}
$idqualifier = implode(", ",$attr);
if ($idqualifier != "")
{
$idqualifier = "($idqualifier)";
}
$msg .= sprintf(i18n("Tag '%s' %s has no end tag (start tag is on line %s char %s)"), $value["tag"], $idqualifier, $value["line"],$value["char"]);
$msg .= "<br>";
}
}
if ($msg != "")
{
$notification->displayNotification("warning", $msg);
}
$form = new UI_Table_Form("module");
$form->addHeader(i18n("Edit Layout"));
$form->setWidth("100%");
$form->setVar("area", $area);
$form->setVar("action", "lay_edit");
$form->setVar("frame", $frame);
$form->setVar("idlay", $idlay);
$tb_name = new cHTMLTextbox("layname", $name, 60);
$ta_description = new cHTMLTextarea("description", $description,100, 10);
$ta_description->setStyle("font-family: monospace;width: 100%;");
$ta_description->updateAttributes(array("wrap" => "off"));
$ta_code = new cHTMLTextarea("code", clHtmlSpecialChars($code), 100,20, 'code');
$ta_code->setStyle("font-family: monospace;width: 100%;");
$ta_code->updateAttributes(array("wrap" => "off"));
$cb_refresh = new cHTMLCheckbox("refreshtemplates", i18n("On save, apply default modules to new containers"));
$form->add(i18n("Name"),$tb_name);
$form->add(i18n("Description"),$ta_description);
$form->add(i18n("Code"),$ta_code);
$form->add(i18n("Options"), $cb_refresh);
# Set static pointers # Set static pointers
$tpl->set('s', 'ACTION', $sess->url("main.php?area=$area&frame=$frame&action=lay_edit")); $tpl->set('s', 'ACTION', $sess->url("main.php?area=$area&frame=$frame&action=lay_edit"));
$tpl->set('s', 'IDLAY', $idlay); $tpl->set('s', 'IDLAY', $idlay);
$tpl->set('s', 'DESCR', $description); $tpl->set('s', 'DESCR', $description);
$tpl->set('s', 'CLASS', 'code_sfullwidth'); $tpl->set('s', 'CLASS', 'code_sfullwidth');
$tpl->set('s', 'NAME', clHtmlSpecialChars($name)); $tpl->set('s', 'NAME', clHtmlSpecialChars($name));
# Set dynamic pointers # Set dynamic pointers
$tpl->set('d', 'CAPTION', i18n("Code").':'); $tpl->set('d', 'CAPTION', i18n("Code") . ':');
$tpl->set('d', 'VALUE', clHtmlSpecialChars($code)); $tpl->set('d', 'VALUE', clHtmlSpecialChars($code));
$tpl->set('d', 'CLASS', 'code_fullwidth'); $tpl->set('d', 'CLASS', 'code_fullwidth');
$tpl->set('d', 'NAME', 'code'); $tpl->set('d', 'NAME', 'code');
$tpl->next(); $tpl->next();
$oEditArea = new EditArea('code', 'html', substr(strtolower($belang), 0, 2), true, $cfg); $oEditArea = new EditArea('code', 'html', substr(strtolower($belang), 0, 2), true, $cfg);
$page->addScript('editarea', $oEditArea->renderScript()); $page->addScript('editarea', $oEditArea->renderScript());
$sScript = '<script type="text/javascript"> $sScript = '<script type="text/javascript">
if (document.getElementById(\'scroll\')) { if (document.getElementById(\'scroll\')) {
document.getElementById(\'scroll\').onmousedown = resizer.triggerClickOn; document.getElementById(\'scroll\').onmousedown = resizer.triggerClickOn;
@ -231,11 +209,9 @@ if (!$layout->virgin)
document.getElementById(\'scroll\').style.paddingBottom=\'5px\'; document.getElementById(\'scroll\').style.paddingBottom=\'5px\';
} }
</script>'; </script>';
$page->setContent($form->render().$sScript);
$page->setSubnav("idlay=$idlay", "lay");
$page->setContent($form->render() . $sScript);
$page->setSubnav("idlay=$idlay", "lay");
} else { } else {
unset($idlay); unset($idlay);
$page->setContent($sMsg); $page->setContent($sMsg);
@ -248,7 +224,7 @@ if (stripslashes($_REQUEST['idlay'])) {
if (left_bottom) { if (left_bottom) {
var href = left_bottom.location.href; var href = left_bottom.location.href;
href = href.replace(/&idlay[^&]*/, ''); href = href.replace(/&idlay[^&]*/, '');
left_bottom.location.href = href+'&idlay='+'".$_REQUEST['idlay']."'; left_bottom.location.href = href+'&idlay='+'" . $_REQUEST['idlay'] . "';
} }
</script>"; </script>";

Datei anzeigen

@ -29,7 +29,7 @@ define('CL_BACKUP_START_IMG_OFF', $cfg['path']['contenido_html'] . $cfg['path'][
$aMessage = array(); $aMessage = array();
$bNoBackup = false; $bNoBackup = false;
$bFinalStep = false; $bFinalStep = false;
echo CL_BACKUP_PATH;
// check backup path // check backup path
if (!is_dir(CL_BACKUP_PATH) || !is_writable(CL_BACKUP_PATH)) { if (!is_dir(CL_BACKUP_PATH) || !is_writable(CL_BACKUP_PATH)) {
$notification->displayNotification("error", i18n("Backupfolder missing or not writable!")); $notification->displayNotification("error", i18n("Backupfolder missing or not writable!"));

Datei anzeigen

@ -194,11 +194,10 @@ function logMessage($msg, $PC_writeDir, $PC_useLog, $PC_debug) {
} }
function lTrimZeros($number) { function lTrimZeros($number) {
while ($number[0] == '0') { while ($number[0] == '0') {
$number = substr($number, 1); $number = substr($number, 1);
} }
return $number; return (is_numeric($number))?$number:0;
} }
function parseElement($element, &$targetArray, $numberOfElements) { function parseElement($element, &$targetArray, $numberOfElements) {
@ -436,6 +435,7 @@ class cCronJob {
protected $_sCronDir; protected $_sCronDir;
protected $_sLogDir; protected $_sLogDir;
private $_bUseLog; private $_bUseLog;
private $_iMaxLogFileSize = 1024;
public function __construct() { public function __construct() {
$this->_sJobDir = cRegistry::getConfigValue('path', 'conlite') . cRegistry::getConfigValue('path', 'cronjobs'); $this->_sJobDir = cRegistry::getConfigValue('path', 'conlite') . cRegistry::getConfigValue('path', 'cronjobs');
@ -467,8 +467,41 @@ class cCronJob {
if ($sMsg[strlen($sMsg) - 1] != "\n") { if ($sMsg[strlen($sMsg) - 1] != "\n") {
$sMsg .= "\r\n"; $sMsg .= "\r\n";
} }
$this->_rotateLogFiles($logfile);
file_put_contents($logfile, $sMsg, FILE_APPEND); file_put_contents($logfile, $sMsg, FILE_APPEND);
} }
private function _rotateLogFiles($sLogFile) {
if (file_exists($sLogFile) &&
filesize($sLogFile) >= $this->_iMaxLogFileSize * 1024) {
// rotate
$path_info = pathinfo($sLogFile);
$base_directory = $path_info['dirname'];
$base_name = $path_info['basename'];
$num_map = array();
foreach (new DirectoryIterator($base_directory) as $fInfo) {
if ($fInfo->isDot() || !$fInfo->isFile()) {
continue;
}
if (preg_match('/^' . $base_name . '\.?([0-9]*)$/', $fInfo->getFilename(), $matches)) {
$num = $matches[1];
$file2move = $fInfo->getFilename();
if ($num == '') {
$num = 0;
}
$num_map[$num] = $file2move;
}
}
krsort($num_map);
foreach ($num_map as $num => $file2move) {
$targetN = $num + 1;
if($targetN > 10) {
unlink($base_directory . DIRECTORY_SEPARATOR . $file2move);
continue;
}
rename($base_directory . DIRECTORY_SEPARATOR . $file2move, $base_directory . DIRECTORY_SEPARATOR .$base_name . '.' . $targetN);
}
}
}
} }
?> ?>