From 65bfeccfd49a9bf2fb728aa6313fbb854b583191 Mon Sep 17 00:00:00 2001
From: Oldperl <44996956+oldperl@users.noreply.github.com>
Date: Mon, 29 Jul 2019 12:43:27 +0000
Subject: [PATCH] formating and svn-admin
---
conlite/includes/functions.str.php | 571 ++++++++++++-------------
data/config/production/config.misc.php | 4 +-
2 files changed, 273 insertions(+), 302 deletions(-)
diff --git a/conlite/includes/functions.str.php b/conlite/includes/functions.str.php
index b521816..29af7d9 100644
--- a/conlite/includes/functions.str.php
+++ b/conlite/includes/functions.str.php
@@ -1,4 +1,5 @@
have_perm_area_action("str_tplcfg", "str_tplcfg")) {
$iIdtplcfg = (int) $iIdtplcfg;
- } else {
+ } else {
$iIdtplcfg = 0;
}
$bVisible = (int) $bVisible;
- if (! (($bVisible == 0 || $bVisible == 1) && $perm->have_perm_area_action('str', "str_makevisible")) ) {
+ if (!(($bVisible == 0 || $bVisible == 1) && $perm->have_perm_area_action('str', "str_makevisible"))) {
$bVisible = 0;
}
$bPublic = (int) $bPublic;
- if (! (($bPublic == 0 || $bPublic == 1) && $perm->have_perm_area_action('str', "str_makepublic")) ) {
+ if (!(($bPublic == 0 || $bPublic == 1) && $perm->have_perm_area_action('str', "str_makepublic"))) {
$bPublic = 1;
}
- $sql = "SELECT idcat FROM ".$cfg["tab"]["cat"]." WHERE parentid='0' AND postid='0' AND idclient='".Contenido_Security::toInteger($client)."'";
+ $sql = "SELECT idcat FROM " . $cfg["tab"]["cat"] . " WHERE parentid='0' AND postid='0' AND idclient='" . Contenido_Security::toInteger($client) . "'";
$db->query($sql);
$db->next_record();
$tmp_id = $db->f("idcat");
@@ -150,65 +149,64 @@ function strNewTree($catname, $catalias = '', $bVisible = 0, $bPublic = 1, $iIdt
if (!$tmp_id) {
//********** Entry in 'cat'-table ************
- $sql = "INSERT INTO ".$cfg["tab"]["cat"]." (idcat, preid, postid, idclient, author, created, lastmodified) VALUES('".Contenido_Security::toInteger($tmp_newid)."', '0', '0',
- '".Contenido_Security::toInteger($client)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat"] . " (idcat, preid, postid, idclient, author, created, lastmodified) VALUES('" . Contenido_Security::toInteger($tmp_newid) . "', '0', '0',
+ '" . Contenido_Security::toInteger($client) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
//********* enter name of cat in 'cat_lang'-table ******
foreach ($a_languages as $tmp_lang) {
if ($tmp_lang == $lang) {
- $sql = "INSERT INTO ".$cfg["tab"]["cat_lang"]." (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
- VALUES('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"]))."', '".Contenido_Security::toInteger($tmp_newid)."', '".Contenido_Security::toInteger($tmp_lang)."',
- '".clHtmlSpecialChars($catname, ENT_QUOTES)."', '".Contenido_Security::toInteger($bVisible)."', '".Contenido_Security::toInteger($bPublic)."', '0',
- '".clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat_lang"] . " (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
+ VALUES('" . Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"])) . "', '" . Contenido_Security::toInteger($tmp_newid) . "', '" . Contenido_Security::toInteger($tmp_lang) . "',
+ '" . clHtmlSpecialChars($catname, ENT_QUOTES) . "', '" . Contenido_Security::toInteger($bVisible) . "', '" . Contenido_Security::toInteger($bPublic) . "', '0',
+ '" . clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
} else {
- $sql = "INSERT INTO ".$cfg["tab"]["cat_lang"]." (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
- VALUES('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"]))."', '".Contenido_Security::toInteger($tmp_newid)."', '".Contenido_Security::toInteger($tmp_lang)."',
- '".clHtmlSpecialChars($catname, ENT_QUOTES)."', '".Contenido_Security::toInteger($bVisible)."', '".Contenido_Security::toInteger($bPublic)."', '0',
- '".clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat_lang"] . " (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
+ VALUES('" . Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"])) . "', '" . Contenido_Security::toInteger($tmp_newid) . "', '" . Contenido_Security::toInteger($tmp_lang) . "',
+ '" . clHtmlSpecialChars($catname, ENT_QUOTES) . "', '" . Contenido_Security::toInteger($bVisible) . "', '" . Contenido_Security::toInteger($bPublic) . "', '0',
+ '" . clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
}
}
} else {
//********** Entry in 'cat'-table ************
- $sql = "UPDATE ".$cfg["tab"]["cat"]." SET postid='$tmp_newid' WHERE idcat='".Contenido_Security::toInteger($tmp_id)."'";
+ $sql = "UPDATE " . $cfg["tab"]["cat"] . " SET postid='$tmp_newid' WHERE idcat='" . Contenido_Security::toInteger($tmp_id) . "'";
$db->query($sql);
//********** Entry in 'cat'-table ************
- $sql = "INSERT INTO ".$cfg["tab"]["cat"]." (idcat, preid, postid, idclient, author, created, lastmodified) VALUES('".Contenido_Security::toInteger($tmp_newid)."', '".Contenido_Security::toInteger($tmp_id)."',
- '0', '".Contenido_Security::toInteger($client)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat"] . " (idcat, preid, postid, idclient, author, created, lastmodified) VALUES('" . Contenido_Security::toInteger($tmp_newid) . "', '" . Contenido_Security::toInteger($tmp_id) . "',
+ '0', '" . Contenido_Security::toInteger($client) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
//********* enter name of cat in 'cat_lang'-table ******
foreach ($a_languages as $tmp_lang) {
if ($tmp_lang == $lang) {
- $sql = "INSERT INTO ".$cfg["tab"]["cat_lang"]." (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
- VALUES('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"]))."', '".Contenido_Security::toInteger($tmp_newid)."', '".Contenido_Security::toInteger($tmp_lang)."',
- '".clHtmlSpecialChars($catname, ENT_QUOTES)."', '".Contenido_Security::toInteger($bVisible)."', '".Contenido_Security::toInteger($bPublic)."', '0',
- '".clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat_lang"] . " (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
+ VALUES('" . Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"])) . "', '" . Contenido_Security::toInteger($tmp_newid) . "', '" . Contenido_Security::toInteger($tmp_lang) . "',
+ '" . clHtmlSpecialChars($catname, ENT_QUOTES) . "', '" . Contenido_Security::toInteger($bVisible) . "', '" . Contenido_Security::toInteger($bPublic) . "', '0',
+ '" . clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
} else {
- $sql = "INSERT INTO ".$cfg["tab"]["cat_lang"]." (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
- VALUES('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"]))."', '".Contenido_Security::toInteger($tmp_newid)."', '".Contenido_Security::toInteger($tmp_lang)."',
- '".clHtmlSpecialChars($catname, ENT_QUOTES)."', '".Contenido_Security::toInteger($bVisible)."', '".Contenido_Security::toInteger($bPublic)."', '0',
- '".clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat_lang"] . " (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
+ VALUES('" . Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"])) . "', '" . Contenido_Security::toInteger($tmp_newid) . "', '" . Contenido_Security::toInteger($tmp_lang) . "',
+ '" . clHtmlSpecialChars($catname, ENT_QUOTES) . "', '" . Contenido_Security::toInteger($bVisible) . "', '" . Contenido_Security::toInteger($bPublic) . "', '0',
+ '" . clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
}
}
}
// set correct rights for element
- cInclude ("includes", "functions.rights.php");
+ cInclude("includes", "functions.rights.php");
foreach ($a_languages as $tmp_lang) {
createRightsForElement("str", $tmp_newid, $tmp_lang);
createRightsForElement("con", $tmp_newid, $tmp_lang);
}
-
}
/* Search for default template */
- $templateCollection = new cApiTemplateCollection("defaulttemplate = '1' AND idclient = '".Contenido_Security::toInteger($client)."'");
+ $templateCollection = new cApiTemplateCollection("defaulttemplate = '1' AND idclient = '" . Contenido_Security::toInteger($client) . "'");
if ($template = $templateCollection->next()) {
$idtpl = $template->get("idtpl");
@@ -217,29 +215,27 @@ function strNewTree($catname, $catalias = '', $bVisible = 0, $bPublic = 1, $iIdt
}
/* Assign template, if default template exists */
- $catCollection = new cApiCategoryLanguageCollection("idcat = '".Contenido_Security::toInteger($tmp_newid)."'");
+ $catCollection = new cApiCategoryLanguageCollection("idcat = '" . Contenido_Security::toInteger($tmp_newid) . "'");
while ($cat = $catCollection->next()) {
$cat->assignTemplate($idtpl);
}
-
} else {
- //2008-06-25 timo.trautmann also set default template if it is selcted by user and there is no default template
- if ($iIdtplcfg > 0) {
- $idtpl = $iIdtplcfg;
+ //2008-06-25 timo.trautmann also set default template if it is selcted by user and there is no default template
+ if ($iIdtplcfg > 0) {
+ $idtpl = $iIdtplcfg;
- $catCollection = new cApiCategoryLanguageCollection("idcat = '$tmp_newid'");
+ $catCollection = new cApiCategoryLanguageCollection("idcat = '$tmp_newid'");
- while ($cat = $catCollection->next()) {
- $cat->assignTemplate($idtpl);
- }
- }
+ while ($cat = $catCollection->next()) {
+ $cat->assignTemplate($idtpl);
+ }
+ }
}
return ($tmp_newid);
}
-
/**
* Creates a new category.
*
@@ -265,7 +261,7 @@ function strNewCategory($tmp_parentid, $catname, $remakeTree = true, $catalias =
global $auth;
global $tmp_area;
- $db2= new DB_ConLite;
+ $db2 = new DB_ConLite;
if (trim($catname) == "") {
return;
@@ -278,17 +274,17 @@ function strNewCategory($tmp_parentid, $catname, $remakeTree = true, $catalias =
if ($perm->have_perm_area_action("str_tplcfg", "str_tplcfg")) {
$iIdtplcfg = (int) $iIdtplcfg;
- } else {
+ } else {
$iIdtplcfg = 0;
}
$bVisible = (int) $bVisible;
- if (! (($bVisible == 0 || $bVisible == 1) && $perm->have_perm_area_action('str', "str_makevisible")) ) {
+ if (!(($bVisible == 0 || $bVisible == 1) && $perm->have_perm_area_action('str', "str_makevisible"))) {
$bVisible = 0;
}
$bPublic = (int) $bPublic;
- if (! (($bPublic == 0 || $bPublic == 1) && $perm->have_perm_area_action('str', "str_makepublic")) ) {
+ if (!(($bPublic == 0 || $bPublic == 1) && $perm->have_perm_area_action('str', "str_makepublic"))) {
$bPublic = 1;
}
@@ -300,16 +296,16 @@ function strNewCategory($tmp_parentid, $catname, $remakeTree = true, $catalias =
$remakeCatTable = true;
$remakeStrTable = true;
- $sql = "SELECT idcat FROM ".$cfg["tab"]["cat"]." WHERE parentid='".Contenido_Security::toInteger($tmp_parentid)."' AND postid=0";
+ $sql = "SELECT idcat FROM " . $cfg["tab"]["cat"] . " WHERE parentid='" . Contenido_Security::toInteger($tmp_parentid) . "' AND postid=0";
$db->query($sql);
$db->next_record();
$tmp_id = $db->f("idcat");
if (!$tmp_id) {
//********** Entry in 'cat'-table ************
- $sql = "INSERT INTO ".$cfg["tab"]["cat"]." (idcat, parentid, preid, postid, idclient, author, created, lastmodified) VALUES('".Contenido_Security::toInteger($tmp_newid)."',
- '".Contenido_Security::toInteger($tmp_parentid)."', '0', '0', '".Contenido_Security::toInteger($client)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."',
- '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat"] . " (idcat, parentid, preid, postid, idclient, author, created, lastmodified) VALUES('" . Contenido_Security::toInteger($tmp_newid) . "',
+ '" . Contenido_Security::toInteger($tmp_parentid) . "', '0', '0', '" . Contenido_Security::toInteger($client) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "',
+ '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
//********* enter name of cat in 'cat_lang'-table ******
@@ -317,52 +313,51 @@ function strNewCategory($tmp_parentid, $catname, $remakeTree = true, $catalias =
foreach ($a_languages as $tmp_lang) {
if ($tmp_lang == $lang) {
- $sql = "INSERT INTO ".$cfg["tab"]["cat_lang"]." (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
- VALUES('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"]))."', '".Contenido_Security::toInteger($tmp_newid)."', '".Contenido_Security::toInteger($tmp_lang)."',
- '".clHtmlSpecialChars($catname, ENT_QUOTES)."', '".Contenido_Security::toInteger($bVisible)."', '".Contenido_Security::toInteger($bPublic)."', '0',
- '".clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat_lang"] . " (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
+ VALUES('" . Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"])) . "', '" . Contenido_Security::toInteger($tmp_newid) . "', '" . Contenido_Security::toInteger($tmp_lang) . "',
+ '" . clHtmlSpecialChars($catname, ENT_QUOTES) . "', '" . Contenido_Security::toInteger($bVisible) . "', '" . Contenido_Security::toInteger($bPublic) . "', '0',
+ '" . clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
} else {
- $sql = "INSERT INTO ".$cfg["tab"]["cat_lang"]." (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
- VALUES('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"]))."', '".Contenido_Security::toInteger($tmp_newid)."', '".Contenido_Security::toInteger($tmp_lang)."',
- '".clHtmlSpecialChars($catname, ENT_QUOTES)."', '".Contenido_Security::toInteger($bVisible)."', '".Contenido_Security::toInteger($bPublic)."', '0',
- '".clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat_lang"] . " (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
+ VALUES('" . Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"])) . "', '" . Contenido_Security::toInteger($tmp_newid) . "', '" . Contenido_Security::toInteger($tmp_lang) . "',
+ '" . clHtmlSpecialChars($catname, ENT_QUOTES) . "', '" . Contenido_Security::toInteger($bVisible) . "', '" . Contenido_Security::toInteger($bPublic) . "', '0',
+ '" . clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
}
}
} else {
//********** Entry in 'cat'-table ************
- $sql = "UPDATE ".$cfg["tab"]["cat"]." SET postid='$tmp_newid', lastmodified = '".date("Y-m-d H:i:s")."' WHERE idcat='".Contenido_Security::toInteger($tmp_id)."'";
+ $sql = "UPDATE " . $cfg["tab"]["cat"] . " SET postid='$tmp_newid', lastmodified = '" . date("Y-m-d H:i:s") . "' WHERE idcat='" . Contenido_Security::toInteger($tmp_id) . "'";
$db->query($sql);
//********** Entry in 'cat'-table ************
- $sql = "INSERT INTO ".$cfg["tab"]["cat"]." (idcat, parentid, preid, postid, idclient, author, created, lastmodified) VALUES('".Contenido_Security::toInteger($tmp_newid)."',
- '".Contenido_Security::toInteger($tmp_parentid)."', '".Contenido_Security::toInteger($tmp_id)."', '0', '".Contenido_Security::toInteger($client)."',
- '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat"] . " (idcat, parentid, preid, postid, idclient, author, created, lastmodified) VALUES('" . Contenido_Security::toInteger($tmp_newid) . "',
+ '" . Contenido_Security::toInteger($tmp_parentid) . "', '" . Contenido_Security::toInteger($tmp_id) . "', '0', '" . Contenido_Security::toInteger($client) . "',
+ '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
//********* enter name of cat in 'cat_lang'-table ******
$a_languages[] = $lang;
foreach ($a_languages as $tmp_lang) {
if ($tmp_lang == $lang) {
- $sql = "INSERT INTO ".$cfg["tab"]["cat_lang"]." (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
- VALUES('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"]))."', '".Contenido_Security::toInteger($tmp_newid)."', '".Contenido_Security::toInteger($tmp_lang)."',
- '".clHtmlSpecialChars($catname, ENT_QUOTES)."', '".Contenido_Security::toInteger($bVisible)."', '".Contenido_Security::toInteger($bPublic)."', '0',
- '".clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat_lang"] . " (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
+ VALUES('" . Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"])) . "', '" . Contenido_Security::toInteger($tmp_newid) . "', '" . Contenido_Security::toInteger($tmp_lang) . "',
+ '" . clHtmlSpecialChars($catname, ENT_QUOTES) . "', '" . Contenido_Security::toInteger($bVisible) . "', '" . Contenido_Security::toInteger($bPublic) . "', '0',
+ '" . clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
} else {
- $sql = "INSERT INTO ".$cfg["tab"]["cat_lang"]." (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
- VALUES('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"]))."', '".Contenido_Security::toInteger($tmp_newid)."', '".Contenido_Security::toInteger($tmp_lang)."',
- '".clHtmlSpecialChars($catname, ENT_QUOTES)."', '".Contenido_Security::toInteger($bVisible)."', '".Contenido_Security::toInteger($bPublic)."', '0',
- '".clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES)."', '".Contenido_Security::escapeDB($auth->auth['uname'], $db)."', '".date("Y-m-d H:i:s")."', '".date("Y-m-d H:i:s")."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat_lang"] . " (idcatlang, idcat, idlang, name, visible, public, idtplcfg, urlname, author, created, lastmodified)
+ VALUES('" . Contenido_Security::toInteger($db->nextid($cfg["tab"]["cat_lang"])) . "', '" . Contenido_Security::toInteger($tmp_newid) . "', '" . Contenido_Security::toInteger($tmp_lang) . "',
+ '" . clHtmlSpecialChars($catname, ENT_QUOTES) . "', '" . Contenido_Security::toInteger($bVisible) . "', '" . Contenido_Security::toInteger($bPublic) . "', '0',
+ '" . clHtmlSpecialChars(capiStrCleanURLCharacters($catalias), ENT_QUOTES) . "', '" . Contenido_Security::escapeDB($auth->auth['uname'], $db) . "', '" . date("Y-m-d H:i:s") . "', '" . date("Y-m-d H:i:s") . "')";
$db->query($sql);
}
}
-
}
// set correct rights for element
- cInclude ("includes", "functions.rights.php");
+ cInclude("includes", "functions.rights.php");
foreach ($a_languages as $tmp_lang) {
copyRightsForElement("str", $tmp_parentid, $tmp_newid, $tmp_lang);
copyRightsForElement("con", $tmp_parentid, $tmp_newid, $tmp_lang);
@@ -382,47 +377,45 @@ function strNewCategory($tmp_parentid, $catname, $remakeTree = true, $catalias =
}
/* Assign template, if default template exists */
- $catCollection = new cApiCategoryLanguageCollection("idcat = '".Contenido_Security::toInteger($tmp_newid)."'");
+ $catCollection = new cApiCategoryLanguageCollection("idcat = '" . Contenido_Security::toInteger($tmp_newid) . "'");
while ($cat = $catCollection->next()) {
$cat->assignTemplate($idtpl);
}
} else {
- //2008-06-25 timo.trautmann also set default template if it is selcted by user and there is no default template
- if ($iIdtplcfg > 0) {
- $idtpl = $iIdtplcfg;
+ //2008-06-25 timo.trautmann also set default template if it is selcted by user and there is no default template
+ if ($iIdtplcfg > 0) {
+ $idtpl = $iIdtplcfg;
- $catCollection = new cApiCategoryLanguageCollection("idcat = '".Contenido_Security::toInteger($tmp_newid)."'");
+ $catCollection = new cApiCategoryLanguageCollection("idcat = '" . Contenido_Security::toInteger($tmp_newid) . "'");
- while ($cat = $catCollection->next()) {
+ while ($cat = $catCollection->next()) {
$cat->assignTemplate($idtpl);
- }
- }
+ }
+ }
}
return($tmp_newid);
}
-
function strOrderedPostTreeList($idcat, $poststring) {
global $db;
global $client;
global $lang;
global $cfg;
- $sql = "SELECT idcat FROM ".$cfg["tab"]["cat"]." WHERE parentid=0 AND preid='".Contenido_Security::toInteger($idcat)."' AND idcat!=0";
+ $sql = "SELECT idcat FROM " . $cfg["tab"]["cat"] . " WHERE parentid=0 AND preid='" . Contenido_Security::toInteger($idcat) . "' AND idcat!=0";
$db->query($sql);
if ($db->next_record()) {
$tmp_idcat = $db->f("idcat");
- $poststring = $poststring.",".$tmp_idcat;
+ $poststring = $poststring . "," . $tmp_idcat;
$poststring = strOrderedPostTreeList($tmp_idcat, $poststring);
}
return $poststring;
}
-
/**
* Remakes the category tree structure in category tree table.
*
@@ -440,68 +433,67 @@ function strRemakeTreeTable() {
$remakeStrTable = true;
$poststring = "";
- $sql = "SELECT idcat FROM ".$cfg["tab"]["cat"]." WHERE idclient = '".$client."'";
+ $sql = "SELECT idcat FROM " . $cfg["tab"]["cat"] . " WHERE idclient = '" . $client . "'";
$db->query($sql);
$idcats = array();
while ($db->next_record()) {
$idcats[] = $db->f("idcat");
}
-
- $sql = "DELETE FROM ".$cfg["tab"]["cat_tree"]." WHERE idcat IN ('".implode("', '",$idcats)."')"; // empty 'cat_tree'-table
+
+ $sql = "DELETE FROM " . $cfg["tab"]["cat_tree"] . " WHERE idcat IN ('" . implode("', '", $idcats) . "')"; // empty 'cat_tree'-table
$db->query($sql);
- $sql = "DELETE FROM ".$cfg["tab"]["cat"]." WHERE idcat='0'";
+ $sql = "DELETE FROM " . $cfg["tab"]["cat"] . " WHERE idcat='0'";
$db->query($sql);
- $sql = "DELETE FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat='0'";
+ $sql = "DELETE FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat='0'";
$db->query($sql);
- $sql = "SELECT idcat, parentid, preid, postid FROM ".$cfg["tab"]["cat"]." WHERE idclient = '".$client."' ORDER BY parentid ASC, preid ASC, postid ASC";
-
- $db->query($sql);
-
- // build cat_tree
+ $sql = "SELECT idcat, parentid, preid, postid FROM " . $cfg["tab"]["cat"] . " WHERE idclient = '" . $client . "' ORDER BY parentid ASC, preid ASC, postid ASC";
+
+ $db->query($sql);
+
+ // build cat_tree
$aCategories = array();
- while($db->next_record()) {
-
- if ($db->f('parentid') == 0) {
+ while ($db->next_record()) {
+
+ if ($db->f('parentid') == 0) {
$aCategories[0][$db->f('idcat')] = array(
- 'idcat' => $db->f('idcat'),
- 'parentid' => $db->f('parentid'),
- 'preid' => $db->f('preid'),
- 'postid' => $db->f('postid')
- );
- } else {
- $aCategories[$db->f('parentid')][$db->f('idcat')] = array(
- 'idcat' => $db->f('idcat'),
- 'parentid' => $db->f('parentid'),
- 'preid' => $db->f('preid'),
- 'postid' => $db->f('postid')
- );
- }
-
+ 'idcat' => $db->f('idcat'),
+ 'parentid' => $db->f('parentid'),
+ 'preid' => $db->f('preid'),
+ 'postid' => $db->f('postid')
+ );
+ } else {
+ $aCategories[$db->f('parentid')][$db->f('idcat')] = array(
+ 'idcat' => $db->f('idcat'),
+ 'parentid' => $db->f('parentid'),
+ 'preid' => $db->f('preid'),
+ 'postid' => $db->f('postid')
+ );
+ }
}
-
+
$iNextTreeId = $db->nextid($cfg["tab"]["cat_tree"]);
-
+
// build INSERT statement
- $sInsertQuery = "INSERT INTO ".$cfg["tab"]["cat_tree"]." (idtree, idcat, level) VALUES ";
+ $sInsertQuery = "INSERT INTO " . $cfg["tab"]["cat_tree"] . " (idtree, idcat, level) VALUES ";
$sInsertQuery = recCats($aCategories[0], $sInsertQuery, $iNextTreeId, $aCategories);
- $sInsertQuery = rtrim($sInsertQuery, " ,");
-
- // lock db table and execute INSERT query
+ $sInsertQuery = rtrim($sInsertQuery, " ,");
+
+ // lock db table and execute INSERT query
$db->lock($cfg["tab"]["cat_tree"]);
$db->query($sInsertQuery);
$db->nextid('cat_tree');
dbUpdateSequence($cfg["tab"]["sequence"], $cfg["tab"]["cat_tree"], $db);
$db->unlock($cfg["tab"]["cat_tree"]);
-
}
function sort_pre_post($arr) {
$firstElement = null;
foreach ($arr as $row) {
- if ($row['preid'] == 0) $firstElement = $row['idcat'];
+ if ($row['preid'] == 0)
+ $firstElement = $row['idcat'];
}
$curId = $firstElement;
@@ -514,27 +506,25 @@ function sort_pre_post($arr) {
return $array;
}
-
-function recCats ($aCats, $sInsertQuery, &$iNextTreeId, &$aAllCats, $iLevel = 0) {
- if (is_array($aCats)) {
- $aCats = sort_pre_post($aCats);
- foreach ($aCats as $aCat) {
- $sInsertQuery .= "(" . (int) $iNextTreeId . ", ".(int) $aCat['idcat'].", ". (int) $iLevel ."), ";
- $iNextTreeId++;
- if (is_array($aAllCats[$aCat['idcat']])) {
- $iSubLevel = $iLevel + 1;
- $sInsertQuery = recCats($aAllCats[$aCat['idcat']], $sInsertQuery, $iNextTreeId, $aAllCats, $iSubLevel);
- }
- }
- }
- return $sInsertQuery;
+function recCats($aCats, $sInsertQuery, &$iNextTreeId, &$aAllCats, $iLevel = 0) {
+ if (is_array($aCats)) {
+ $aCats = sort_pre_post($aCats);
+ foreach ($aCats as $aCat) {
+ $sInsertQuery .= "(" . (int) $iNextTreeId . ", " . (int) $aCat['idcat'] . ", " . (int) $iLevel . "), ";
+ $iNextTreeId++;
+ if (is_array($aAllCats[$aCat['idcat']])) {
+ $iSubLevel = $iLevel + 1;
+ $sInsertQuery = recCats($aAllCats[$aCat['idcat']], $sInsertQuery, $iNextTreeId, $aAllCats, $iSubLevel);
+ }
+ }
+ }
+ return $sInsertQuery;
}
-
function strNextDeeper($tmp_idcat, $ignore_lang = false) {
global $cfg, $db_str, $lang;
- $sql = "SELECT idcat FROM ".$cfg["tab"]["cat"]." WHERE parentid='".Contenido_Security::toInteger($tmp_idcat)."' AND preid='0'";
+ $sql = "SELECT idcat FROM " . $cfg["tab"]["cat"] . " WHERE parentid='" . Contenido_Security::toInteger($tmp_idcat) . "' AND preid='0'";
$db_str->query($sql);
if ($db_str->next_record()) {
$midcat = $db_str->f("idcat");
@@ -545,7 +535,7 @@ function strNextDeeper($tmp_idcat, $ignore_lang = false) {
//******deeper element exists
/* Check for language dependent part */
- $sql = "SELECT idcatlang FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat='".Contenido_Security::toInteger($midcat)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
+ $sql = "SELECT idcatlang FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat='" . Contenido_Security::toInteger($midcat) . "' AND idlang='" . Contenido_Security::toInteger($lang) . "'";
$db_str->query($sql);
if ($db_str->next_record()) {
return $midcat;
@@ -558,7 +548,6 @@ function strNextDeeper($tmp_idcat, $ignore_lang = false) {
}
}
-
/**
* Checks, if passed category cotains any articles
*
@@ -570,10 +559,10 @@ function strHasArticles($tmp_idcat) {
global $lang;
$sql = "SELECT b.idartlang AS idartlang FROM
- ".$cfg["tab"]["cat_art"]." AS a,
- ".$cfg["tab"]["art_lang"]." AS b
- WHERE a.idcat='".Contenido_Security::toInteger($tmp_idcat)."' AND
- a.idart = b.idart AND b.idlang = '".Contenido_Security::toInteger($lang)."'";
+ " . $cfg["tab"]["cat_art"] . " AS a,
+ " . $cfg["tab"]["art_lang"] . " AS b
+ WHERE a.idcat='" . Contenido_Security::toInteger($tmp_idcat) . "' AND
+ a.idart = b.idart AND b.idlang = '" . Contenido_Security::toInteger($lang) . "'";
$db_str->query($sql);
@@ -584,16 +573,15 @@ function strHasArticles($tmp_idcat) {
}
}
-
function strNextPost($tmp_idcat) {
global $db;
global $cfg;
- $sql = "SELECT idcat FROM ".$cfg["tab"]["cat"]." WHERE preid='".Contenido_Security::toInteger($tmp_idcat)."'";
+ $sql = "SELECT idcat FROM " . $cfg["tab"]["cat"] . " WHERE preid='" . Contenido_Security::toInteger($tmp_idcat) . "'";
$db->query($sql);
if ($db->next_record()) { //******post element exists
$tmp_idcat = $db->f("idcat");
- $sql = "SELECT parentid FROM ".$cfg["tab"]["cat"]." WHERE idcat='".Contenido_Security::toInteger($tmp_idcat)."'";
+ $sql = "SELECT parentid FROM " . $cfg["tab"]["cat"] . " WHERE idcat='" . Contenido_Security::toInteger($tmp_idcat) . "'";
$db->query($sql);
if ($db->next_record()) { //******parent from post must not be 0
$tmp_parentid = $db->f("parentid");
@@ -614,16 +602,16 @@ function strNextBackwards($tmp_idcat) {
global $db;
global $cfg;
- $sql = "SELECT parentid FROM ".$cfg["tab"]["cat"]." WHERE idcat='".Contenido_Security::toInteger($tmp_idcat)."'";
+ $sql = "SELECT parentid FROM " . $cfg["tab"]["cat"] . " WHERE idcat='" . Contenido_Security::toInteger($tmp_idcat) . "'";
$db->query($sql);
if ($db->next_record()) { //******parent exists
$tmp_idcat = $db->f("parentid");
if ($tmp_idcat != 0) {
- $sql = "SELECT idcat FROM ".$cfg["tab"]["cat"]." WHERE preid='".Contenido_Security::toInteger($tmp_idcat)."'";
+ $sql = "SELECT idcat FROM " . $cfg["tab"]["cat"] . " WHERE preid='" . Contenido_Security::toInteger($tmp_idcat) . "'";
$db->query($sql);
if ($db->next_record()) { //******parent has post
$tmp_idcat = $db->f("idcat");
- $sql = "SELECT parentid FROM ".$cfg["tab"]["cat"]." WHERE idcat='".Contenido_Security::toInteger($tmp_idcat)."'";
+ $sql = "SELECT parentid FROM " . $cfg["tab"]["cat"] . " WHERE idcat='" . Contenido_Security::toInteger($tmp_idcat) . "'";
$db->query($sql);
if ($db->next_record()) { //******parent from post must not be 0
$tmp_parentid = $db->f("parentid");
@@ -649,38 +637,36 @@ function strNextBackwards($tmp_idcat) {
/**
* Hotfix recursive call more than 200 times exit script on hosteurope Timo.Trautmann (strRemakeTreeTableFindNext)
* @deprecated
- **/
-function strRemakeTreeTableFindNext($tmp_idcat,$tmp_level) {
+ * */
+function strRemakeTreeTableFindNext($tmp_idcat, $tmp_level) {
global $db;
global $cfg;
//************* Insert Element in 'cat_tree'-table **************
- $sql = "INSERT INTO ".$cfg["tab"]["cat_tree"]." (idtree, idcat, level) VALUES ('".$db->nextid($cfg["tab"]["cat_tree"])."', '".Contenido_Security::toInteger($tmp_idcat)."', '".Contenido_Security::toInteger($tmp_level)."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat_tree"] . " (idtree, idcat, level) VALUES ('" . $db->nextid($cfg["tab"]["cat_tree"]) . "', '" . Contenido_Security::toInteger($tmp_idcat) . "', '" . Contenido_Security::toInteger($tmp_level) . "')";
$db->query($sql);
//************* dig deeper, if possible ******
$tmp = strNextDeeperAll($tmp_idcat, true);
foreach ($tmp as $iCurIdCat) {
- if (count(strNextDeeperAll($iCurIdCat, true)) > 0 ) {
- strRemakeTreeTableFindNext($iCurIdCat, ($tmp_level+1));
+ if (count(strNextDeeperAll($iCurIdCat, true)) > 0) {
+ strRemakeTreeTableFindNext($iCurIdCat, ($tmp_level + 1));
} else {
- $sql = "INSERT INTO ".$cfg["tab"]["cat_tree"]." (idtree, idcat, level) VALUES ('".$db->nextid($cfg["tab"]["cat_tree"])."', '".Contenido_Security::toInteger($iCurIdCat)."', '".Contenido_Security::toInteger($tmp_level+1)."')";
+ $sql = "INSERT INTO " . $cfg["tab"]["cat_tree"] . " (idtree, idcat, level) VALUES ('" . $db->nextid($cfg["tab"]["cat_tree"]) . "', '" . Contenido_Security::toInteger($iCurIdCat) . "', '" . Contenido_Security::toInteger($tmp_level + 1) . "')";
$db->query($sql);
}
}
}
-
-
/**
- Hotfix recursive call more than 200 times exit script on hosteurope Timo.Trautmann
-**/
+ Hotfix recursive call more than 200 times exit script on hosteurope Timo.Trautmann
+ * */
function strNextDeeperAll($tmp_idcat, $ignore_lang = false) {
global $cfg, $db_str, $db_str2, $lang;
$aCats = array();
$bLoop = true;
- $sql = "SELECT idcat FROM ".$cfg["tab"]["cat"]." WHERE parentid='".Contenido_Security::toInteger($tmp_idcat)."' and preid = 0";
+ $sql = "SELECT idcat FROM " . $cfg["tab"]["cat"] . " WHERE parentid='" . Contenido_Security::toInteger($tmp_idcat) . "' and preid = 0";
#echo $sql.'
';
$db_str->query($sql);
@@ -693,7 +679,7 @@ function strNextDeeperAll($tmp_idcat, $ignore_lang = false) {
} else {
//******deeper element exists
/* Check for language dependent part */
- $sql = "SELECT idcatlang FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat='".Contenido_Security::toInteger($midcat)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
+ $sql = "SELECT idcatlang FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat='" . Contenido_Security::toInteger($midcat) . "' AND idlang='" . Contenido_Security::toInteger($lang) . "'";
$db_str2->query($sql);
if ($db_str2->next_record()) {
@@ -701,7 +687,7 @@ function strNextDeeperAll($tmp_idcat, $ignore_lang = false) {
}
}
- $sql = "SELECT preid, postid, idcat FROM ".$cfg["tab"]["cat"]." WHERE parentid='".Contenido_Security::toInteger($tmp_idcat)."' and preid = ".Contenido_Security::toInteger($midcat)."";
+ $sql = "SELECT preid, postid, idcat FROM " . $cfg["tab"]["cat"] . " WHERE parentid='" . Contenido_Security::toInteger($tmp_idcat) . "' and preid = " . Contenido_Security::toInteger($midcat) . "";
$db_str->query($sql);
if (!$db_str->next_record()) {
$bLoop = false;
@@ -711,7 +697,6 @@ function strNextDeeperAll($tmp_idcat, $ignore_lang = false) {
return $aCats;
}
-
/**
* Renders the category tree a HTML table
*
@@ -727,23 +712,22 @@ function strShowTreeTable() {
global $lngStr;
echo "
".$tmp_id." | ".$tmp_name." | ".$tmp_level." | "; - echo "url("main.php?action=20&idcat=$tmp_id")."\">".$lngStr["actions"]["20"]." | "; - echo "url("main.php?action=30&idcat=$tmp_id")."\">".$lngStr["actions"]["30"]." | "; + echo "
" . $tmp_id . " | " . $tmp_name . " | " . $tmp_level . " | "; + echo "url("main.php?action=20&idcat=$tmp_id") . "\">" . $lngStr["actions"]["20"] . " | "; + echo "url("main.php?action=30&idcat=$tmp_id") . "\">" . $lngStr["actions"]["30"] . " | "; echo "