diff --git a/src/admin/groups.php b/src/admin/groups.php index b733750..18c45e5 100644 --- a/src/admin/groups.php +++ b/src/admin/groups.php @@ -1,494 +1,494 @@ - Helps administrating groups - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$gl_root_path = './../'; - -// Now include necessary include files! -include($gl_root_path . 'include/functions_common.php'); -include($gl_root_path . 'include/functions_frontendhelpers.php'); -include($gl_root_path . 'include/functions_filters.php'); - -// Set PAGE to be ADMINPAGE! -define('IS_ADMINPAGE', true); -$content['IS_ADMINPAGE'] = true; -InitPhpLogCon(); -InitSourceConfigs(); -InitFrontEndDefaults(); // Only in WebFrontEnd -InitFilterHelpers(); // Helpers for frontend filtering! - -// Init admin langauge file now! -IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); -// --- - -// --- BEGIN Custom Code - -// Only if the user is an admin! -if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) - DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] ); - -if ( isset($_GET['op']) ) -{ - if ($_GET['op'] == "add") - { - // Set Mode to add - $content['ISEDITORNEWGROUP'] = "true"; - $content['GROUP_FORMACTION'] = "addnewgroup"; - $content['GROUP_SENDBUTTON'] = $content['LN_GROUP_ADD']; - - //PreInit these values - $content['groupname'] = ""; - $content['groupdescription'] = ""; - } - else if ($_GET['op'] == "adduser" && isset($_GET['id']) ) - { - //PreInit these values - $content['GROUPID'] = intval( DB_RemoveBadChars($_GET['id']) ); - - // Set Mode to add - $content['ISADDUSER'] = "true"; - $content['GROUP_FORMACTION'] = "adduser"; - $content['GROUP_SENDBUTTON'] = $content['LN_GROUP_ADDUSER']; - - // --- Get Groupname - $sqlquery = "SELECT " . - DB_GROUPS . ".groupname " . - " FROM " . DB_GROUPS . - " WHERE " . DB_GROUPS . ".id = " . $content['GROUPID']; - $result = DB_Query($sqlquery); - $tmparray = DB_GetSingleRow($result, true); - - if ( isset($tmparray) ) - { - // Copy Groupname - $content['GROUPNAME'] = $tmparray['groupname']; - - // --- Get Group Members - $sqlquery = "SELECT " . - DB_GROUPMEMBERS. ".userid " . - " FROM " . DB_GROUPMEMBERS . - " WHERE " . DB_GROUPMEMBERS . ".groupid = " . $content['GROUPID']; - $result = DB_Query($sqlquery); - $tmparray = DB_GetAllRows($result, true); - if ( count($tmparray) > 0 ) - { - // Add UserID's to where clause! - foreach ($tmparray as $datarow) - { - if ( isset($whereclause) ) - $whereclause .= ", " . $datarow['userid']; - else - $whereclause = " WHERE " . DB_USERS . ".id NOT IN (" . $datarow['userid']; - } - // Finish whereclause - $whereclause .= ") "; - } - else - $whereclause = ""; - // --- - - // --- Create LIST of Users which are available for selection - $sqlquery = "SELECT " . - DB_USERS. ".ID as userid, " . - DB_USERS. ".username " . - " FROM " . DB_USERS . - " LEFT OUTER JOIN (" . DB_GROUPMEMBERS . - ") ON (" . - DB_GROUPMEMBERS . ".userid=" . DB_USERS . ".ID) " . - $whereclause . - " ORDER BY " . DB_USERS . ".username"; - $result = DB_Query($sqlquery); - $content['SUBUSERS'] = DB_GetAllRows($result, true); - - if ( count($content['SUBUSERS']) <= 0 ) - { - // Disable FORM: - $content['ISADDUSER'] = false; - - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERRORNOMOREUSERS'], $content['GROUPNAME'] ); - } - } - else - { - // Disable FORM: - $content['ISADDUSER'] = false; - - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] ); - } - // --- - } - else if ($_GET['op'] == "removeuser" && isset($_GET['id']) ) - { - //PreInit these values - $content['GROUPID'] = intval( DB_RemoveBadChars($_GET['id']) ); - - // Set Mode to add - $content['ISREMOVEUSER'] = "true"; - $content['GROUP_FORMACTION'] = "removeuser"; - $content['GROUP_SENDBUTTON'] = $content['LN_GROUP_USERDELETE']; - - // --- Get Groupname - $sqlquery = "SELECT " . - DB_GROUPS . ".groupname " . - " FROM " . DB_GROUPS . - " WHERE " . DB_GROUPS . ".id = " . $content['GROUPID']; - $result = DB_Query($sqlquery); - $tmparray = DB_GetSingleRow($result, true); - - if ( isset($tmparray) ) - { - // Copy Groupname - $content['GROUPNAME'] = $tmparray['groupname']; - - // --- Get Group Members - $sqlquery = "SELECT " . - DB_GROUPMEMBERS. ".userid, " . - DB_USERS. ".username " . - " FROM " . DB_GROUPMEMBERS . - " INNER JOIN (" . DB_USERS . - ") ON (" . - DB_GROUPMEMBERS . ".userid=" . DB_USERS . ".ID) " . - " WHERE " . DB_GROUPMEMBERS . ".groupid = " . $content['GROUPID']; - $result = DB_Query($sqlquery); - $content['SUBRMUSERS'] = DB_GetAllRows($result, true); - if ( count($content['SUBRMUSERS']) <= 0 ) - { - // Disable FORM: - $content['ISREMOVEUSER'] = false; - - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERRORNOUSERSINGROUP'], $content['GROUPNAME'] ); - } - } - else - { - // Disable FORM: - $content['ISREMOVEUSER'] = false; - - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] ); - } - - } - else if ($_GET['op'] == "edit") - { - // Set Mode to edit - $content['ISEDITORNEWGROUP'] = "true"; - $content['GROUP_FORMACTION'] = "editgroup"; - $content['GROUP_SENDBUTTON'] = $content['LN_GROUP_EDIT']; - - if ( isset($_GET['id']) ) - { - //PreInit these values - $content['GROUPID'] = DB_RemoveBadChars($_GET['id']); - - $sqlquery = "SELECT * " . - " FROM " . DB_GROUPS . - " WHERE ID = " . $content['GROUPID']; - - $result = DB_Query($sqlquery); - $myuser = DB_GetSingleRow($result, true); - if ( isset($myuser['groupname']) ) - { - $content['GROUPID'] = $myuser['ID']; - $content['groupname'] = $myuser['groupname']; - $content['groupdescription'] = $myuser['groupdescription']; - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] ); - } - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_INVALIDGROUP']; - } - } - else if ($_GET['op'] == "delete") - { - if ( isset($_GET['id']) ) - { - //PreInit these values - $content['GROUPID'] = DB_RemoveBadChars($_GET['id']); - - // Get GroupInfo - $result = DB_Query("SELECT groupname FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID'] ); - $myrow = DB_GetSingleRow($result, true); - if ( !isset($myrow['groupname']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['USERID'] ); - } - else - { - // --- Ask for deletion first! - if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") ) - { - // This will print an additional secure check which the user needs to confirm and exit the script execution. - PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_GROUP_WARNDELETEGROUP'], $myrow['groupname'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); - } - // --- - - // do the delete! - $result = DB_Query( "DELETE FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID'] ); - if ($result == FALSE) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_DELGROUP'], $content['USERID'] ); - } - else - DB_FreeQuery($result); - - // TODO: DELETE GROUP SETTINGS, GROUP MEMBERSHIP ... - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_ERROR_HASBEENDEL'], $myrow['groupname'] ) , "groups.php" ); - } - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_INVALIDGROUP']; - } - } -} - -if ( isset($_POST['op']) ) -{ - if ( isset ($_POST['id']) ) { $content['GROUPID'] = intval( DB_RemoveBadChars($_POST['id']) ); } else {$content['GROUPID'] = ""; } - if ( isset ($_POST['groupname']) ) { $content['groupname'] = DB_RemoveBadChars($_POST['groupname']); } else {$content['groupname'] = ""; } - if ( isset ($_POST['groupdescription']) ) { $content['groupdescription'] = DB_RemoveBadChars($_POST['groupdescription']); } else {$content['groupdescription'] = ""; } - - // Check mandotary values - if ( $content['groupname'] == "" ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_GROUPEMPTY']; - } - - if ( !isset($content['ISERROR']) ) - { - // Everything was alright, so we go to the next step! - if ( $_POST['op'] == "addnewgroup" ) - { - $result = DB_Query("SELECT groupname FROM " . DB_GROUPS . " WHERE groupname = '" . $content['groupname'] . "'"); - $myrow = DB_GetSingleRow($result, true); - if ( isset($myrow['groupname']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_GROUPNAMETAKEN']; - } - else - { - // Add new Group now! - $result = DB_Query("INSERT INTO " . DB_GROUPS . " (groupname, groupdescription) - VALUES ( '" . $content['groupname'] . "', - '" . $content['groupdescription'] . "' )"); - DB_FreeQuery($result); - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_HASBEENADDED'], $content['groupname'] ) , "groups.php" ); - } - } - else if ( $_POST['op'] == "editgroup" ) - { - $result = DB_Query("SELECT ID FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID']); - $myrow = DB_GetSingleRow($result, true); - if ( !isset($myrow['ID']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] ); - } - else - { - // Edit the User now! - $result = DB_Query("UPDATE " . DB_GROUPS . " SET - groupname = '" . $content['groupname'] . "', - groupdescription = '" . $content['groupdescription'] . "' - WHERE ID = " . $content['GROUPID']); - DB_FreeQuery($result); - - // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_ERROR_HASBEENEDIT'], $content['groupname']) , "groups.php" ); - } - } - else if ( $_POST['op'] == "adduser" ) - { - if ( isset($_POST['userid']) ) - { - // Copy UserID - $content['USERID'] = intval( DB_RemoveBadChars($_POST['userid']) ); - - $result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE id = " . $content['USERID']); - $myrow = DB_GetSingleRow($result, true); - if ( isset($myrow['username']) ) - { - // Add Groupmembership now! - $result = DB_Query("INSERT INTO " . DB_GROUPMEMBERS . " (groupid, userid, is_member) - VALUES ( " . $content['GROUPID'] . ", - " . $content['USERID'] . ", - 1 )"); - DB_FreeQuery($result); - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_USERHASBEENADDEDGROUP'], $myrow['username'], $content['groupname'] ) , "groups.php" ); - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); - } - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_USERIDMISSING']; - } - } - else if ( $_POST['op'] == "removeuser" ) - { - if ( isset($_POST['userid']) ) - { - // Copy UserID - $content['USERID'] = intval( DB_RemoveBadChars($_POST['userid']) ); - - $result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE id = " . $content['USERID']); - $myrow = DB_GetSingleRow($result, true); - if ( isset($myrow['username']) ) - { - // remove user from group - $result = DB_Query( "DELETE FROM " . DB_GROUPMEMBERS . " WHERE userid = " . $content['USERID'] . " AND groupid = " . $content['GROUPID']); - if ($result == FALSE) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_REMUSERFROMGROUP'], $myrow['username'], $content['groupname'] ); - } - else - DB_FreeQuery($result); - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_USERHASBEENREMOVED'], $myrow['username'], $content['groupname'] ) , "groups.php" ); - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); - } - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_USERIDMISSING']; - } - } - } -} - -if ( !isset($_POST['op']) && !isset($_GET['op']) ) -{ - // Default Mode = List Groups - $content['LISTGROUPS'] = "true"; - - // Read all Groupentries - $sqlquery = "SELECT ID, " . - " groupname, " . - " groupdescription " . - " FROM " . DB_GROUPS. - " ORDER BY ID "; - $result = DB_Query($sqlquery); - $content['GROUPS'] = DB_GetAllRows($result, true); - - if ( count($content['GROUPS']) > 0 ) - { - // --- Process Groups - for($i = 0; $i < count($content['GROUPS']); $i++) - { - // --- Set CSS Class - if ( $i % 2 == 0 ) - $content['GROUPS'][$i]['cssclass'] = "line1"; - else - $content['GROUPS'][$i]['cssclass'] = "line2"; - // --- - - // --- Read all Memberentries for this group - $sqlquery = "SELECT " . - DB_USERS. ".username, " . - DB_GROUPMEMBERS . ".userid, " . - DB_GROUPMEMBERS . ".groupid, " . - DB_GROUPMEMBERS . ".is_member " . - " FROM " . DB_GROUPMEMBERS . - " INNER JOIN (" . DB_USERS . - ") ON (" . - DB_GROUPMEMBERS . ".userid=" . DB_USERS . ".ID) " . - " WHERE " . DB_GROUPMEMBERS . ".groupid = " . $content['GROUPS'][$i]['ID'] . - " ORDER BY " . DB_USERS . ".username"; - $result = DB_Query($sqlquery); - $content['GROUPS'][$i]['USERS'] = DB_GetAllRows($result, true); - - if ( count($content['GROUPS'][$i]['USERS']) > 0 ) - { - // Enable Groupmembers - $content['GROUPS'][$i]['GROUPMEMBERS'] = true; - - // Process Groups - $subUserCount = count($content['GROUPS'][$i]['USERS']); - for($j = 0; $j < $subUserCount; $j++) - $content['GROUPS'][$i]['USERS'][$j]['seperator'] = ", "; - $content['GROUPS'][$i]['USERS'][$subUserCount-1]['seperator'] = ""; // last one is empty - } - // --- - } - // --- - } - else - $content['EMPTYGROUPS'] = "true"; -} -// --- END Custom Code - -// --- BEGIN CREATE TITLE -$content['TITLE'] = InitPageTitle(); -$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_GROUPOPT']; -// --- END CREATE TITLE - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "admin/admin_groups.html"); -$page -> output(); -// --- - + Helps administrating groups + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './../'; + +// Now include necessary include files! +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); +include($gl_root_path . 'include/functions_filters.php'); + +// Set PAGE to be ADMINPAGE! +define('IS_ADMINPAGE', true); +$content['IS_ADMINPAGE'] = true; +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! + +// Init admin langauge file now! +IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); +// --- + +// --- BEGIN Custom Code + +// Only if the user is an admin! +if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) + DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] ); + +if ( isset($_GET['op']) ) +{ + if ($_GET['op'] == "add") + { + // Set Mode to add + $content['ISEDITORNEWGROUP'] = "true"; + $content['GROUP_FORMACTION'] = "addnewgroup"; + $content['GROUP_SENDBUTTON'] = $content['LN_GROUP_ADD']; + + //PreInit these values + $content['groupname'] = ""; + $content['groupdescription'] = ""; + } + else if ($_GET['op'] == "adduser" && isset($_GET['id']) ) + { + //PreInit these values + $content['GROUPID'] = intval( DB_RemoveBadChars($_GET['id']) ); + + // Set Mode to add + $content['ISADDUSER'] = "true"; + $content['GROUP_FORMACTION'] = "adduser"; + $content['GROUP_SENDBUTTON'] = $content['LN_GROUP_ADDUSER']; + + // --- Get Groupname + $sqlquery = "SELECT " . + DB_GROUPS . ".groupname " . + " FROM " . DB_GROUPS . + " WHERE " . DB_GROUPS . ".id = " . $content['GROUPID']; + $result = DB_Query($sqlquery); + $tmparray = DB_GetSingleRow($result, true); + + if ( isset($tmparray) ) + { + // Copy Groupname + $content['GROUPNAME'] = $tmparray['groupname']; + + // --- Get Group Members + $sqlquery = "SELECT " . + DB_GROUPMEMBERS. ".userid " . + " FROM " . DB_GROUPMEMBERS . + " WHERE " . DB_GROUPMEMBERS . ".groupid = " . $content['GROUPID']; + $result = DB_Query($sqlquery); + $tmparray = DB_GetAllRows($result, true); + if ( count($tmparray) > 0 ) + { + // Add UserID's to where clause! + foreach ($tmparray as $datarow) + { + if ( isset($whereclause) ) + $whereclause .= ", " . $datarow['userid']; + else + $whereclause = " WHERE " . DB_USERS . ".id NOT IN (" . $datarow['userid']; + } + // Finish whereclause + $whereclause .= ") "; + } + else + $whereclause = ""; + // --- + + // --- Create LIST of Users which are available for selection + $sqlquery = "SELECT " . + DB_USERS. ".ID as userid, " . + DB_USERS. ".username " . + " FROM " . DB_USERS . + " LEFT OUTER JOIN (" . DB_GROUPMEMBERS . + ") ON (" . + DB_GROUPMEMBERS . ".userid=" . DB_USERS . ".ID) " . + $whereclause . + " ORDER BY " . DB_USERS . ".username"; + $result = DB_Query($sqlquery); + $content['SUBUSERS'] = DB_GetAllRows($result, true); + + if ( count($content['SUBUSERS']) <= 0 ) + { + // Disable FORM: + $content['ISADDUSER'] = false; + + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERRORNOMOREUSERS'], $content['GROUPNAME'] ); + } + } + else + { + // Disable FORM: + $content['ISADDUSER'] = false; + + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] ); + } + // --- + } + else if ($_GET['op'] == "removeuser" && isset($_GET['id']) ) + { + //PreInit these values + $content['GROUPID'] = intval( DB_RemoveBadChars($_GET['id']) ); + + // Set Mode to add + $content['ISREMOVEUSER'] = "true"; + $content['GROUP_FORMACTION'] = "removeuser"; + $content['GROUP_SENDBUTTON'] = $content['LN_GROUP_USERDELETE']; + + // --- Get Groupname + $sqlquery = "SELECT " . + DB_GROUPS . ".groupname " . + " FROM " . DB_GROUPS . + " WHERE " . DB_GROUPS . ".id = " . $content['GROUPID']; + $result = DB_Query($sqlquery); + $tmparray = DB_GetSingleRow($result, true); + + if ( isset($tmparray) ) + { + // Copy Groupname + $content['GROUPNAME'] = $tmparray['groupname']; + + // --- Get Group Members + $sqlquery = "SELECT " . + DB_GROUPMEMBERS. ".userid, " . + DB_USERS. ".username " . + " FROM " . DB_GROUPMEMBERS . + " INNER JOIN (" . DB_USERS . + ") ON (" . + DB_GROUPMEMBERS . ".userid=" . DB_USERS . ".ID) " . + " WHERE " . DB_GROUPMEMBERS . ".groupid = " . $content['GROUPID']; + $result = DB_Query($sqlquery); + $content['SUBRMUSERS'] = DB_GetAllRows($result, true); + if ( count($content['SUBRMUSERS']) <= 0 ) + { + // Disable FORM: + $content['ISREMOVEUSER'] = false; + + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERRORNOUSERSINGROUP'], $content['GROUPNAME'] ); + } + } + else + { + // Disable FORM: + $content['ISREMOVEUSER'] = false; + + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] ); + } + + } + else if ($_GET['op'] == "edit") + { + // Set Mode to edit + $content['ISEDITORNEWGROUP'] = "true"; + $content['GROUP_FORMACTION'] = "editgroup"; + $content['GROUP_SENDBUTTON'] = $content['LN_GROUP_EDIT']; + + if ( isset($_GET['id']) ) + { + //PreInit these values + $content['GROUPID'] = DB_RemoveBadChars($_GET['id']); + + $sqlquery = "SELECT * " . + " FROM " . DB_GROUPS . + " WHERE ID = " . $content['GROUPID']; + + $result = DB_Query($sqlquery); + $myuser = DB_GetSingleRow($result, true); + if ( isset($myuser['groupname']) ) + { + $content['GROUPID'] = $myuser['ID']; + $content['groupname'] = $myuser['groupname']; + $content['groupdescription'] = $myuser['groupdescription']; + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] ); + } + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_INVALIDGROUP']; + } + } + else if ($_GET['op'] == "delete") + { + if ( isset($_GET['id']) ) + { + //PreInit these values + $content['GROUPID'] = DB_RemoveBadChars($_GET['id']); + + // Get GroupInfo + $result = DB_Query("SELECT groupname FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID'] ); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['groupname']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['USERID'] ); + } + else + { + // --- Ask for deletion first! + if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") ) + { + // This will print an additional secure check which the user needs to confirm and exit the script execution. + PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_GROUP_WARNDELETEGROUP'], $myrow['groupname'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); + } + // --- + + // do the delete! + $result = DB_Query( "DELETE FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID'] ); + if ($result == FALSE) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_DELGROUP'], $content['USERID'] ); + } + else + DB_FreeQuery($result); + + // TODO: DELETE GROUP SETTINGS, GROUP MEMBERSHIP ... + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_ERROR_HASBEENDEL'], $myrow['groupname'] ) , "groups.php" ); + } + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_INVALIDGROUP']; + } + } +} + +if ( isset($_POST['op']) ) +{ + if ( isset ($_POST['id']) ) { $content['GROUPID'] = intval( DB_RemoveBadChars($_POST['id']) ); } else {$content['GROUPID'] = ""; } + if ( isset ($_POST['groupname']) ) { $content['groupname'] = DB_RemoveBadChars($_POST['groupname']); } else {$content['groupname'] = ""; } + if ( isset ($_POST['groupdescription']) ) { $content['groupdescription'] = DB_RemoveBadChars($_POST['groupdescription']); } else {$content['groupdescription'] = ""; } + + // Check mandotary values + if ( $content['groupname'] == "" ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_GROUPEMPTY']; + } + + if ( !isset($content['ISERROR']) ) + { + // Everything was alright, so we go to the next step! + if ( $_POST['op'] == "addnewgroup" ) + { + $result = DB_Query("SELECT groupname FROM " . DB_GROUPS . " WHERE groupname = '" . $content['groupname'] . "'"); + $myrow = DB_GetSingleRow($result, true); + if ( isset($myrow['groupname']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_GROUPNAMETAKEN']; + } + else + { + // Add new Group now! + $result = DB_Query("INSERT INTO " . DB_GROUPS . " (groupname, groupdescription) + VALUES ( '" . $content['groupname'] . "', + '" . $content['groupdescription'] . "' )"); + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_HASBEENADDED'], $content['groupname'] ) , "groups.php" ); + } + } + else if ( $_POST['op'] == "editgroup" ) + { + $result = DB_Query("SELECT ID FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID']); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['ID']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] ); + } + else + { + // Edit the User now! + $result = DB_Query("UPDATE " . DB_GROUPS . " SET + groupname = '" . $content['groupname'] . "', + groupdescription = '" . $content['groupdescription'] . "' + WHERE ID = " . $content['GROUPID']); + DB_FreeQuery($result); + + // Done redirect! + RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_ERROR_HASBEENEDIT'], $content['groupname']) , "groups.php" ); + } + } + else if ( $_POST['op'] == "adduser" ) + { + if ( isset($_POST['userid']) ) + { + // Copy UserID + $content['USERID'] = intval( DB_RemoveBadChars($_POST['userid']) ); + + $result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE id = " . $content['USERID']); + $myrow = DB_GetSingleRow($result, true); + if ( isset($myrow['username']) ) + { + // Add Groupmembership now! + $result = DB_Query("INSERT INTO " . DB_GROUPMEMBERS . " (groupid, userid, is_member) + VALUES ( " . $content['GROUPID'] . ", + " . $content['USERID'] . ", + 1 )"); + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_USERHASBEENADDEDGROUP'], $myrow['username'], $content['groupname'] ) , "groups.php" ); + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); + } + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_USERIDMISSING']; + } + } + else if ( $_POST['op'] == "removeuser" ) + { + if ( isset($_POST['userid']) ) + { + // Copy UserID + $content['USERID'] = intval( DB_RemoveBadChars($_POST['userid']) ); + + $result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE id = " . $content['USERID']); + $myrow = DB_GetSingleRow($result, true); + if ( isset($myrow['username']) ) + { + // remove user from group + $result = DB_Query( "DELETE FROM " . DB_GROUPMEMBERS . " WHERE userid = " . $content['USERID'] . " AND groupid = " . $content['GROUPID']); + if ($result == FALSE) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_REMUSERFROMGROUP'], $myrow['username'], $content['groupname'] ); + } + else + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_USERHASBEENREMOVED'], $myrow['username'], $content['groupname'] ) , "groups.php" ); + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); + } + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_GROUP_ERROR_USERIDMISSING']; + } + } + } +} + +if ( !isset($_POST['op']) && !isset($_GET['op']) ) +{ + // Default Mode = List Groups + $content['LISTGROUPS'] = "true"; + + // Read all Groupentries + $sqlquery = "SELECT ID, " . + " groupname, " . + " groupdescription " . + " FROM " . DB_GROUPS. + " ORDER BY ID "; + $result = DB_Query($sqlquery); + $content['GROUPS'] = DB_GetAllRows($result, true); + + if ( count($content['GROUPS']) > 0 ) + { + // --- Process Groups + for($i = 0; $i < count($content['GROUPS']); $i++) + { + // --- Set CSS Class + if ( $i % 2 == 0 ) + $content['GROUPS'][$i]['cssclass'] = "line1"; + else + $content['GROUPS'][$i]['cssclass'] = "line2"; + // --- + + // --- Read all Memberentries for this group + $sqlquery = "SELECT " . + DB_USERS. ".username, " . + DB_GROUPMEMBERS . ".userid, " . + DB_GROUPMEMBERS . ".groupid, " . + DB_GROUPMEMBERS . ".is_member " . + " FROM " . DB_GROUPMEMBERS . + " INNER JOIN (" . DB_USERS . + ") ON (" . + DB_GROUPMEMBERS . ".userid=" . DB_USERS . ".ID) " . + " WHERE " . DB_GROUPMEMBERS . ".groupid = " . $content['GROUPS'][$i]['ID'] . + " ORDER BY " . DB_USERS . ".username"; + $result = DB_Query($sqlquery); + $content['GROUPS'][$i]['USERS'] = DB_GetAllRows($result, true); + + if ( count($content['GROUPS'][$i]['USERS']) > 0 ) + { + // Enable Groupmembers + $content['GROUPS'][$i]['GROUPMEMBERS'] = true; + + // Process Groups + $subUserCount = count($content['GROUPS'][$i]['USERS']); + for($j = 0; $j < $subUserCount; $j++) + $content['GROUPS'][$i]['USERS'][$j]['seperator'] = ", "; + $content['GROUPS'][$i]['USERS'][$subUserCount-1]['seperator'] = ""; // last one is empty + } + // --- + } + // --- + } + else + $content['EMPTYGROUPS'] = "true"; +} +// --- END Custom Code + +// --- BEGIN CREATE TITLE +$content['TITLE'] = InitPageTitle(); +$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_GROUPOPT']; +// --- END CREATE TITLE + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "admin/admin_groups.html"); +$page -> output(); +// --- + ?> \ No newline at end of file diff --git a/src/admin/result.php b/src/admin/result.php index aa894b6..adf271f 100644 --- a/src/admin/result.php +++ b/src/admin/result.php @@ -1,87 +1,87 @@ - Shows ... - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$gl_root_path = './../'; - -// Now include necessary include files! -include($gl_root_path . 'include/functions_common.php'); -include($gl_root_path . 'include/functions_frontendhelpers.php'); -include($gl_root_path . 'include/functions_filters.php'); - -// Include LogStream facility -// include($gl_root_path . 'classes/logstream.class.php'); - -// Set PAGE to be ADMINPAGE! -define('IS_ADMINPAGE', true); -$content['IS_ADMINPAGE'] = true; - -InitPhpLogCon(); -InitSourceConfigs(); -InitFrontEndDefaults(); // Only in WebFrontEnd -InitFilterHelpers(); // Helpers for frontend filtering! - -// Init admin langauge file now! -IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); - -// Hardcoded atm -$content['REDIRSECONDS'] = 2; -// *** *** // - -// --- CONTENT Vars -if ( isset($_GET['redir']) ) -{ - $content['EXTRA_METATAGS'] = ''; - $content['SZREDIR'] = urldecode($_GET['redir']); -} -else -{ - $_GET['redir'] = "index.php"; -} - -if ( isset($_GET['msg']) ) - $content['SZMSG'] = urldecode($_GET['msg']); -else - $content['SZMSG'] = $content["LN_ADMIN_UNKNOWNSTATE"]; - -$content['TITLE'] = "phpLogCon - Redirecting to '" . $content['SZREDIR'] . "' in 5 seconds"; // Title of the Page -// --- - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "admin/result.html"); -$page -> output(); -// --- - + Shows ... + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './../'; + +// Now include necessary include files! +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); +include($gl_root_path . 'include/functions_filters.php'); + +// Include LogStream facility +// include($gl_root_path . 'classes/logstream.class.php'); + +// Set PAGE to be ADMINPAGE! +define('IS_ADMINPAGE', true); +$content['IS_ADMINPAGE'] = true; + +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! + +// Init admin langauge file now! +IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); + +// Hardcoded atm +$content['REDIRSECONDS'] = 2; +// *** *** // + +// --- CONTENT Vars +if ( isset($_GET['redir']) ) +{ + $content['EXTRA_METATAGS'] = ''; + $content['SZREDIR'] = urldecode($_GET['redir']); +} +else +{ + $_GET['redir'] = "index.php"; +} + +if ( isset($_GET['msg']) ) + $content['SZMSG'] = urldecode($_GET['msg']); +else + $content['SZMSG'] = $content["LN_ADMIN_UNKNOWNSTATE"]; + +$content['TITLE'] = "phpLogCon - Redirecting to '" . $content['SZREDIR'] . "' in 5 seconds"; // Title of the Page +// --- + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "admin/result.html"); +$page -> output(); +// --- + ?> \ No newline at end of file diff --git a/src/admin/searches.php b/src/admin/searches.php index 7e3128e..69cf644 100644 --- a/src/admin/searches.php +++ b/src/admin/searches.php @@ -1,330 +1,330 @@ - Helps administrating custom searches - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$gl_root_path = './../'; - -// Now include necessary include files! -include($gl_root_path . 'include/functions_common.php'); -include($gl_root_path . 'include/functions_frontendhelpers.php'); -include($gl_root_path . 'include/functions_filters.php'); - -// Set PAGE to be ADMINPAGE! -define('IS_ADMINPAGE', true); -$content['IS_ADMINPAGE'] = true; -InitPhpLogCon(); -InitSourceConfigs(); -InitFrontEndDefaults(); // Only in WebFrontEnd -InitFilterHelpers(); // Helpers for frontend filtering! - -// Init admin langauge file now! -IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); -// --- - -// --- BEGIN Custom Code -if ( isset($_GET['op']) ) -{ - if ($_GET['op'] == "add") - { - // Set Mode to add - $content['ISEDITORNEWSEARCH'] = "true"; - $content['SEARCH_FORMACTION'] = "addnewsearch"; - $content['SEARCH_SENDBUTTON'] = $content['LN_SEARCH_ADD']; - - //PreInit these values - $content['DisplayName'] = ""; - $content['SearchQuery'] = ""; - $content['userid'] = null; - $content['CHECKED_ISUSERONLY'] = ""; - $content['SEARCHID'] = ""; - - // --- Check if groups are available - $content['SUBGROUPS'] = GetGroupsForSelectfield(); - if ( is_array($content['SUBGROUPS']) ) - $content['ISGROUPSAVAILABLE'] = true; - else - $content['ISGROUPSAVAILABLE'] = false; - } - else if ($_GET['op'] == "edit") - { - // Set Mode to edit - $content['ISEDITORNEWSEARCH'] = "true"; - $content['SEARCH_FORMACTION'] = "editsearch"; - $content['SEARCH_SENDBUTTON'] = $content['LN_SEARCH_EDIT']; - - if ( isset($_GET['id']) ) - { - //PreInit these values - $content['SEARCHID'] = DB_RemoveBadChars($_GET['id']); - - $sqlquery = "SELECT * " . - " FROM " . DB_SEARCHES . - " WHERE ID = " . $content['SEARCHID']; - - $result = DB_Query($sqlquery); - $mysearch = DB_GetSingleRow($result, true); - if ( isset($mysearch['DisplayName']) ) - { - $content['SEARCHID'] = $mysearch['ID']; - $content['DisplayName'] = $mysearch['DisplayName']; - $content['SearchQuery'] = $mysearch['SearchQuery']; - if ( $mysearch['userid'] != null ) - $content['CHECKED_ISUSERONLY'] = "checked"; - else - $content['CHECKED_ISUSERONLY'] = ""; - - // --- Check if groups are available - $content['SUBGROUPS'] = GetGroupsForSelectfield(); - if ( is_array($content['SUBGROUPS']) ) - { - // Process All Groups - for($i = 0; $i < count($content['SUBGROUPS']); $i++) - { - if ( $mysearch['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $mysearch['groupid'] ) - $content['SUBGROUPS'][$i]['group_selected'] = "selected"; - else - $content['SUBGROUPS'][$i]['group_selected'] = ""; - } - - // Enable Group Selection - $content['ISGROUPSAVAILABLE'] = true; - } - else - $content['ISGROUPSAVAILABLE'] = false; - // --- - } - else - { - $content['ISEDITORNEWSEARCH'] = false; - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] ); - } - } - else - { - $content['ISEDITORNEWSEARCH'] = false; - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID']; - } - } - else if ($_GET['op'] == "delete") - { - if ( isset($_GET['id']) ) - { - //PreInit these values - $content['SEARCHID'] = DB_RemoveBadChars($_GET['id']); - - // Get UserInfo - $result = DB_Query("SELECT DisplayName FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID'] ); - $myrow = DB_GetSingleRow($result, true); - if ( !isset($myrow['DisplayName']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] ); - } - - // --- Ask for deletion first! - if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") ) - { - // This will print an additional secure check which the user needs to confirm and exit the script execution. - PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_SEARCH_WARNDELETESEARCH'], $myrow['DisplayName'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); - } - // --- - - // do the delete! - $result = DB_Query( "DELETE FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID'] ); - if ($result == FALSE) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_DELSEARCH'], $content['SEARCHID'] ); - } - else - DB_FreeQuery($result); - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_HASBEENDEL'], $myrow['DisplayName'] ) , "searches.php" ); - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID']; - } - } -} - -if ( isset($_POST['op']) ) -{ - if ( isset ($_POST['id']) ) { $content['SEARCHID'] = intval(DB_RemoveBadChars($_POST['id'])); } else {$content['SEARCHID'] = -1; } - if ( isset ($_POST['DisplayName']) ) { $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); } else {$content['DisplayName'] = ""; } - if ( isset ($_POST['SearchQuery']) ) { $content['SearchQuery'] = DB_RemoveBadChars($_POST['SearchQuery']); } else {$content['SearchQuery'] = ""; } - - // User & Group handeled specially - if ( isset ($_POST['isuseronly']) ) - { - $content['userid'] = $content['SESSION_USERID']; - $content['groupid'] = "null"; // Either user or group not both! - } - else - { - $content['userid'] = "null"; - if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 ) - $content['groupid'] = intval($_POST['groupid']); - else - $content['groupid'] = "null"; - } - - // --- Check mandotary values - if ( $content['DisplayName'] == "" ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_DISPLAYNAMEEMPTY']; - } - else if ( $content['SearchQuery'] == "" ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_SEARCHQUERYEMPTY']; - } - // --- - - if ( !isset($content['ISERROR']) ) - { - // Everything was alright, so we go to the next step! - if ( $_POST['op'] == "addnewsearch" ) - { - // Add custom search now! - $sqlquery = "INSERT INTO " . DB_SEARCHES . " (DisplayName, SearchQuery, userid, groupid) - VALUES ('" . $content['DisplayName'] . "', - '" . $content['SearchQuery'] . "', - " . $content['userid'] . ", - " . $content['groupid'] . " - )"; - $result = DB_Query($sqlquery); - DB_FreeQuery($result); - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENADDED'], $content['DisplayName'] ) , "searches.php" ); - } - else if ( $_POST['op'] == "editsearch" ) - { - $result = DB_Query("SELECT ID FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID']); - $myrow = DB_GetSingleRow($result, true); - if ( !isset($myrow['ID']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] ); - } - else - { - // Edit the Search Entry now! - $result = DB_Query("UPDATE " . DB_SEARCHES . " SET - DisplayName = '" . $content['DisplayName'] . "', - SearchQuery = '" . $content['SearchQuery'] . "', - userid = " . $content['userid'] . ", - groupid = " . $content['groupid'] . " - WHERE ID = " . $content['SEARCHID']); - DB_FreeQuery($result); - - // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENEDIT'], $content['DisplayName']) , "searches.php" ); - } - } - } -} - -if ( !isset($_POST['op']) && !isset($_GET['op']) ) -{ - // Default Mode = List Searches - $content['LISTSEARCHES'] = "true"; - - // Copy Search array for further modifications - $content['SEARCHES'] = $content['Search']; - - $i = 0; // Help counter! - foreach ($content['SEARCHES'] as &$mySearch ) - { - $mySearch['SearchQuery_Display'] = strlen($mySearch['SearchQuery']) > 25 ? substr($mySearch['SearchQuery'], 0, 25) . " ..." : $mySearch['SearchQuery']; - - // Allow EDIT - $mySearch['ActionsAllowed'] = true; - - // --- Set Image for Type - if ( $mySearch['userid'] != null ) - { - $mySearch['SearchTypeImage'] = $content["MENU_ADMINUSERS"]; - $mySearch['SearchTypeText'] = $content["LN_GEN_USERONLY"]; - } - else if ( $mySearch['groupid'] != null ) - { - $mySearch['SearchTypeImage'] = $content["MENU_ADMINGROUPS"]; - $mySearch['SearchTypeText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $mySearch['groupname'] ); - - // Check if is ADMIN User, deny if normal user! - if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) - $mySearch['ActionsAllowed'] = false; - } - else - { - $mySearch['SearchTypeImage'] = $content["MENU_GLOBAL"]; - $mySearch['SearchTypeText'] = $content["LN_GEN_GLOBAL"]; - - // Check if is ADMIN User, deny if normal user! - if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) - $mySearch['ActionsAllowed'] = false; - } - // --- - - // --- Set CSS Class - if ( $i % 2 == 0 ) - $mySearch['cssclass'] = "line1"; - else - $mySearch['cssclass'] = "line2"; - $i++; - // --- - } - // --- -} -// --- END Custom Code - -// --- BEGIN CREATE TITLE -$content['TITLE'] = InitPageTitle(); -$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_SEARCHOPT']; -// --- END CREATE TITLE - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "admin/admin_searches.html"); -$page -> output(); -// --- - + Helps administrating custom searches + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './../'; + +// Now include necessary include files! +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); +include($gl_root_path . 'include/functions_filters.php'); + +// Set PAGE to be ADMINPAGE! +define('IS_ADMINPAGE', true); +$content['IS_ADMINPAGE'] = true; +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! + +// Init admin langauge file now! +IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); +// --- + +// --- BEGIN Custom Code +if ( isset($_GET['op']) ) +{ + if ($_GET['op'] == "add") + { + // Set Mode to add + $content['ISEDITORNEWSEARCH'] = "true"; + $content['SEARCH_FORMACTION'] = "addnewsearch"; + $content['SEARCH_SENDBUTTON'] = $content['LN_SEARCH_ADD']; + + //PreInit these values + $content['DisplayName'] = ""; + $content['SearchQuery'] = ""; + $content['userid'] = null; + $content['CHECKED_ISUSERONLY'] = ""; + $content['SEARCHID'] = ""; + + // --- Check if groups are available + $content['SUBGROUPS'] = GetGroupsForSelectfield(); + if ( is_array($content['SUBGROUPS']) ) + $content['ISGROUPSAVAILABLE'] = true; + else + $content['ISGROUPSAVAILABLE'] = false; + } + else if ($_GET['op'] == "edit") + { + // Set Mode to edit + $content['ISEDITORNEWSEARCH'] = "true"; + $content['SEARCH_FORMACTION'] = "editsearch"; + $content['SEARCH_SENDBUTTON'] = $content['LN_SEARCH_EDIT']; + + if ( isset($_GET['id']) ) + { + //PreInit these values + $content['SEARCHID'] = DB_RemoveBadChars($_GET['id']); + + $sqlquery = "SELECT * " . + " FROM " . DB_SEARCHES . + " WHERE ID = " . $content['SEARCHID']; + + $result = DB_Query($sqlquery); + $mysearch = DB_GetSingleRow($result, true); + if ( isset($mysearch['DisplayName']) ) + { + $content['SEARCHID'] = $mysearch['ID']; + $content['DisplayName'] = $mysearch['DisplayName']; + $content['SearchQuery'] = $mysearch['SearchQuery']; + if ( $mysearch['userid'] != null ) + $content['CHECKED_ISUSERONLY'] = "checked"; + else + $content['CHECKED_ISUSERONLY'] = ""; + + // --- Check if groups are available + $content['SUBGROUPS'] = GetGroupsForSelectfield(); + if ( is_array($content['SUBGROUPS']) ) + { + // Process All Groups + for($i = 0; $i < count($content['SUBGROUPS']); $i++) + { + if ( $mysearch['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $mysearch['groupid'] ) + $content['SUBGROUPS'][$i]['group_selected'] = "selected"; + else + $content['SUBGROUPS'][$i]['group_selected'] = ""; + } + + // Enable Group Selection + $content['ISGROUPSAVAILABLE'] = true; + } + else + $content['ISGROUPSAVAILABLE'] = false; + // --- + } + else + { + $content['ISEDITORNEWSEARCH'] = false; + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] ); + } + } + else + { + $content['ISEDITORNEWSEARCH'] = false; + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID']; + } + } + else if ($_GET['op'] == "delete") + { + if ( isset($_GET['id']) ) + { + //PreInit these values + $content['SEARCHID'] = DB_RemoveBadChars($_GET['id']); + + // Get UserInfo + $result = DB_Query("SELECT DisplayName FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID'] ); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['DisplayName']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] ); + } + + // --- Ask for deletion first! + if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") ) + { + // This will print an additional secure check which the user needs to confirm and exit the script execution. + PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_SEARCH_WARNDELETESEARCH'], $myrow['DisplayName'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); + } + // --- + + // do the delete! + $result = DB_Query( "DELETE FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID'] ); + if ($result == FALSE) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_DELSEARCH'], $content['SEARCHID'] ); + } + else + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_HASBEENDEL'], $myrow['DisplayName'] ) , "searches.php" ); + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID']; + } + } +} + +if ( isset($_POST['op']) ) +{ + if ( isset ($_POST['id']) ) { $content['SEARCHID'] = intval(DB_RemoveBadChars($_POST['id'])); } else {$content['SEARCHID'] = -1; } + if ( isset ($_POST['DisplayName']) ) { $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); } else {$content['DisplayName'] = ""; } + if ( isset ($_POST['SearchQuery']) ) { $content['SearchQuery'] = DB_RemoveBadChars($_POST['SearchQuery']); } else {$content['SearchQuery'] = ""; } + + // User & Group handeled specially + if ( isset ($_POST['isuseronly']) ) + { + $content['userid'] = $content['SESSION_USERID']; + $content['groupid'] = "null"; // Either user or group not both! + } + else + { + $content['userid'] = "null"; + if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 ) + $content['groupid'] = intval($_POST['groupid']); + else + $content['groupid'] = "null"; + } + + // --- Check mandotary values + if ( $content['DisplayName'] == "" ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_DISPLAYNAMEEMPTY']; + } + else if ( $content['SearchQuery'] == "" ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_SEARCHQUERYEMPTY']; + } + // --- + + if ( !isset($content['ISERROR']) ) + { + // Everything was alright, so we go to the next step! + if ( $_POST['op'] == "addnewsearch" ) + { + // Add custom search now! + $sqlquery = "INSERT INTO " . DB_SEARCHES . " (DisplayName, SearchQuery, userid, groupid) + VALUES ('" . $content['DisplayName'] . "', + '" . $content['SearchQuery'] . "', + " . $content['userid'] . ", + " . $content['groupid'] . " + )"; + $result = DB_Query($sqlquery); + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENADDED'], $content['DisplayName'] ) , "searches.php" ); + } + else if ( $_POST['op'] == "editsearch" ) + { + $result = DB_Query("SELECT ID FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID']); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['ID']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] ); + } + else + { + // Edit the Search Entry now! + $result = DB_Query("UPDATE " . DB_SEARCHES . " SET + DisplayName = '" . $content['DisplayName'] . "', + SearchQuery = '" . $content['SearchQuery'] . "', + userid = " . $content['userid'] . ", + groupid = " . $content['groupid'] . " + WHERE ID = " . $content['SEARCHID']); + DB_FreeQuery($result); + + // Done redirect! + RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENEDIT'], $content['DisplayName']) , "searches.php" ); + } + } + } +} + +if ( !isset($_POST['op']) && !isset($_GET['op']) ) +{ + // Default Mode = List Searches + $content['LISTSEARCHES'] = "true"; + + // Copy Search array for further modifications + $content['SEARCHES'] = $content['Search']; + + $i = 0; // Help counter! + foreach ($content['SEARCHES'] as &$mySearch ) + { + $mySearch['SearchQuery_Display'] = strlen($mySearch['SearchQuery']) > 25 ? substr($mySearch['SearchQuery'], 0, 25) . " ..." : $mySearch['SearchQuery']; + + // Allow EDIT + $mySearch['ActionsAllowed'] = true; + + // --- Set Image for Type + if ( $mySearch['userid'] != null ) + { + $mySearch['SearchTypeImage'] = $content["MENU_ADMINUSERS"]; + $mySearch['SearchTypeText'] = $content["LN_GEN_USERONLY"]; + } + else if ( $mySearch['groupid'] != null ) + { + $mySearch['SearchTypeImage'] = $content["MENU_ADMINGROUPS"]; + $mySearch['SearchTypeText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $mySearch['groupname'] ); + + // Check if is ADMIN User, deny if normal user! + if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) + $mySearch['ActionsAllowed'] = false; + } + else + { + $mySearch['SearchTypeImage'] = $content["MENU_GLOBAL"]; + $mySearch['SearchTypeText'] = $content["LN_GEN_GLOBAL"]; + + // Check if is ADMIN User, deny if normal user! + if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) + $mySearch['ActionsAllowed'] = false; + } + // --- + + // --- Set CSS Class + if ( $i % 2 == 0 ) + $mySearch['cssclass'] = "line1"; + else + $mySearch['cssclass'] = "line2"; + $i++; + // --- + } + // --- +} +// --- END Custom Code + +// --- BEGIN CREATE TITLE +$content['TITLE'] = InitPageTitle(); +$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_SEARCHOPT']; +// --- END CREATE TITLE + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "admin/admin_searches.html"); +$page -> output(); +// --- + ?> \ No newline at end of file diff --git a/src/admin/sources.php b/src/admin/sources.php index 656fbea..125ae6d 100644 --- a/src/admin/sources.php +++ b/src/admin/sources.php @@ -1,576 +1,576 @@ - Helps administrating phplogcon datasources - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$gl_root_path = './../'; - -// Now include necessary include files! -include($gl_root_path . 'include/functions_common.php'); -include($gl_root_path . 'include/functions_frontendhelpers.php'); -include($gl_root_path . 'include/functions_filters.php'); - -// Set PAGE to be ADMINPAGE! -define('IS_ADMINPAGE', true); -$content['IS_ADMINPAGE'] = true; -InitPhpLogCon(); -InitSourceConfigs(); -InitFrontEndDefaults(); // Only in WebFrontEnd -InitFilterHelpers(); // Helpers for frontend filtering! - -// Init admin langauge file now! -IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); -// --- - -// --- BEGIN Custom Code - -if ( isset($_GET['op']) ) -{ - if ($_GET['op'] == "add") - { - // Set Mode to add - $content['ISEDITORNEWSOURCE'] = "true"; - $content['SOURCE_FORMACTION'] = "addnewsource"; - $content['SOURCE_SENDBUTTON'] = $content['LN_SOURCES_ADD']; - - //PreInit these values - $content['Name'] = ""; - $content['SourceType'] = SOURCE_DISK; - CreateSourceTypesList($content['SourceType']); - - // Init View List! - $content['SourceViewID'] = 'SYSLOG'; - $content['VIEWS'] = $content['Views']; - foreach ( $content['VIEWS'] as $myView ) - { - if ( $myView['ID'] == $content['SourceViewID'] ) - $content['VIEWS'][ $myView['ID'] ]['selected'] = "selected"; - else - $content['VIEWS'][ $myView['ID'] ]['selected'] = ""; - } - - // SOURCE_DISK specific - $content['SourceLogLineType'] = ""; - CreateLogLineTypesList($content['SourceLogLineType']); - $content['SourceDiskFile'] = "/var/log/syslog"; - - // SOURCE_DB specific - $content['SourceDBType'] = DB_MYSQL; - CreateDBTypesList($content['SourceDBType']); - $content['SourceDBName'] = "phplogcon"; - $content['SourceDBTableType'] = "monitorware"; - $content['SourceDBServer'] = "localhost"; - $content['SourceDBTableName'] = "systemevents"; - $content['SourceDBUser'] = "user"; - $content['SourceDBPassword'] = ""; - $content['SourceDBEnableRowCounting'] = "false"; - $content['SourceDBEnableRowCounting_true'] = ""; - $content['SourceDBEnableRowCounting_false'] = "checked"; - - // General stuff - $content['userid'] = null; - $content['CHECKED_ISUSERONLY'] = ""; - $content['SOURCEID'] = ""; - - // --- Check if groups are available - $content['SUBGROUPS'] = GetGroupsForSelectfield(); - if ( is_array($content['SUBGROUPS']) ) - $content['ISGROUPSAVAILABLE'] = true; - else - $content['ISGROUPSAVAILABLE'] = false; - } - else if ($_GET['op'] == "edit") - { - // Set Mode to edit - $content['ISEDITORNEWSOURCE'] = "true"; - $content['SOURCE_FORMACTION'] = "editsource"; - $content['SOURCE_SENDBUTTON'] = $content['LN_SOURCES_EDIT']; - - if ( isset($_GET['id']) ) - { - //PreInit these values - $content['SOURCEID'] = DB_RemoveBadChars($_GET['id']); - - // Check if exists - if ( is_numeric($content['SOURCEID']) && isset($content['Sources'][ $content['SOURCEID'] ]) ) - { - // Get Source reference - $mysource = $content['Sources'][ $content['SOURCEID'] ]; - - // Copy basic properties - $content['Name'] = $mysource['Name']; - $content['SourceType'] = $mysource['SourceType']; - CreateSourceTypesList($content['SourceType']); - - // Init View List! - $content['SourceViewID'] = $mysource['ViewID']; - $content['VIEWS'] = $content['Views']; - foreach ( $content['VIEWS'] as $myView ) - { - if ( $myView['ID'] == $content['SourceViewID'] ) - $content['VIEWS'][ $myView['ID'] ]['selected'] = "selected"; - else - $content['VIEWS'][ $myView['ID'] ]['selected'] = ""; - } - - // SOURCE_DISK specific - $content['SourceLogLineType'] = $mysource['LogLineType']; - CreateLogLineTypesList($content['SourceLogLineType']); - $content['SourceDiskFile'] = $mysource['DiskFile']; - - // SOURCE_DB specific - $content['SourceDBType'] = $mysource['DBType']; - CreateDBTypesList($content['SourceDBType']); - $content['SourceDBName'] = $mysource['DBName']; - $content['SourceDBTableType'] = $mysource['DBTableType']; - $content['SourceDBServer'] = $mysource['DBServer']; - $content['SourceDBTableName'] = $mysource['DBTableName']; - $content['SourceDBUser'] = $mysource['DBUser']; - $content['SourceDBPassword'] = $mysource['DBPassword']; - $content['SourceDBEnableRowCounting'] = $mysource['DBEnableRowCounting']; - if ( $content['SourceDBEnableRowCounting'] == 1 ) - { - $content['SourceDBEnableRowCounting_true'] = "checked"; - $content['SourceDBEnableRowCounting_false'] = ""; - } - else - { - $content['SourceDBEnableRowCounting_true'] = ""; - $content['SourceDBEnableRowCounting_false'] = "checked"; - } - - if ( $mysource['userid'] != null ) - $content['CHECKED_ISUSERONLY'] = "checked"; - else - $content['CHECKED_ISUSERONLY'] = ""; - - // --- Check if groups are available - $content['SUBGROUPS'] = GetGroupsForSelectfield(); - if ( is_array($content['SUBGROUPS']) ) - { - // Process All Groups - for($i = 0; $i < count($content['SUBGROUPS']); $i++) - { - if ( $mysource['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $mysource['groupid'] ) - $content['SUBGROUPS'][$i]['group_selected'] = "selected"; - else - $content['SUBGROUPS'][$i]['group_selected'] = ""; - } - - // Enable Group Selection - $content['ISGROUPSAVAILABLE'] = true; - } - else - $content['ISGROUPSAVAILABLE'] = false; - // --- - } - else - { - $content['ISEDITORNEWSOURCE'] = false; - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID']; - } - } - else - { - $content['ISEDITORNEWSEARCH'] = false; - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID']; - } - } - else if ($_GET['op'] == "delete") - { - if ( isset($_GET['id']) ) - { - //PreInit these values - $content['SOURCEID'] = DB_RemoveBadChars($_GET['id']); - - // Get UserInfo - $result = DB_Query("SELECT Name FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID'] ); - $myrow = DB_GetSingleRow($result, true); - if ( !isset($myrow['Name']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_IDNOTFOUND'], $content['SOURCEID'] ); - } - - // --- Ask for deletion first! - if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") ) - { - // This will print an additional secure check which the user needs to confirm and exit the script execution. - PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_SOURCES_WARNDELETESEARCH'], $myrow['Name'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); - } - // --- - - // do the delete! - $result = DB_Query( "DELETE FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID'] ); - if ($result == FALSE) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_DELSOURCE'], $content['SOURCEID'] ); - } - else - DB_FreeQuery($result); - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_HASBEENDEL'], $myrow['Name'] ) , "sources.php" ); - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID']; - } - } -} - -if ( isset($_POST['op']) ) -{ - // Read parameters first! - if ( isset($_POST['id']) ) { $content['SOURCEID'] = intval(DB_RemoveBadChars($_POST['id'])); } else {$content['SOURCEID'] = -1; } - if ( isset($_POST['Name']) ) { $content['Name'] = DB_RemoveBadChars($_POST['Name']); } else {$content['Name'] = ""; } - if ( isset($_POST['SourceType']) ) { $content['SourceType'] = DB_RemoveBadChars($_POST['SourceType']); } - if ( isset($_POST['SourceViewID']) ) { $content['SourceViewID'] = DB_RemoveBadChars($_POST['SourceViewID']); } - - if ( isset($content['SourceType']) ) - { - // Disk Params - if ( $content['SourceType'] == SOURCE_DISK ) - { - if ( isset($_POST['SourceLogLineType']) ) { $content['SourceLogLineType'] = DB_RemoveBadChars($_POST['SourceLogLineType']); } - if ( isset($_POST['SourceDiskFile']) ) { $content['SourceDiskFile'] = DB_RemoveBadChars($_POST['SourceDiskFile']); } - } - // DB Params - else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO ) - { - if ( isset($_POST['SourceDBType']) ) { $content['SourceDBType'] = DB_RemoveBadChars($_POST['SourceDBType']); } - if ( isset($_POST['SourceDBName']) ) { $content['SourceDBName'] = DB_RemoveBadChars($_POST['SourceDBName']); } - if ( isset($_POST['SourceDBTableType']) ) { $content['SourceDBTableType'] = DB_RemoveBadChars($_POST['SourceDBTableType']); } - if ( isset($_POST['SourceDBServer']) ) { $content['SourceDBServer'] = DB_RemoveBadChars($_POST['SourceDBServer']); } - if ( isset($_POST['SourceDBTableName']) ) { $content['SourceDBTableName'] = DB_RemoveBadChars($_POST['SourceDBTableName']); } - if ( isset($_POST['SourceDBUser']) ) { $content['SourceDBUser'] = DB_RemoveBadChars($_POST['SourceDBUser']); } - if ( isset($_POST['SourceDBPassword']) ) { $content['SourceDBPassword'] = DB_RemoveBadChars($_POST['SourceDBPassword']); } else {$content['SourceDBPassword'] = ""; } - if ( isset($_POST['SourceDBEnableRowCounting']) ) { $content['SourceDBEnableRowCounting'] = DB_RemoveBadChars($_POST['SourceDBEnableRowCounting']); } - // Extra Check for this property - if ( $_SESSION['SourceDBEnableRowCounting'] != "true" ) - $_SESSION['SourceDBEnableRowCounting'] = "false"; - - } - } - - // User & Group handeled specially - if ( isset ($_POST['isuseronly']) ) - { - $content['userid'] = $content['SESSION_USERID']; - $content['groupid'] = "null"; // Either user or group not both! - } - else - { - $content['userid'] = "null"; - if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 ) - $content['groupid'] = intval($_POST['groupid']); - else - $content['groupid'] = "null"; - } - - // --- Check mandotary values - if ( $content['Name'] == "" ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_NAMEOFTHESOURCE'] ); - } - else if ( !isset($content['SourceType']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_SOURCETYPE'] ); - } - else if ( !isset($content['SourceViewID']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_VIEW'] ); - } - else - { - // Disk Params - if ( $content['SourceType'] == SOURCE_DISK ) - { - if ( !isset($content['SourceLogLineType']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_LOGLINETYPE'] ); - } - else if ( !isset($content['SourceDiskFile']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_SYSLOGFILE'] ); - } - // Check if file is accessable! - else if ( !is_file($content['SourceDiskFile']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_NOTAVALIDFILE'], $content['SourceDiskFile'] ); - } - } - // DB Params - else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO ) - { - if ( !isset($content['SourceDBType']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DATABASETYPEOPTIONS'] ); - } - else if ( !isset($content['SourceDBName']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBNAME'] ); - } - else if ( !isset($content['SourceDBTableType']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBTABLETYPE'] ); - } - else if ( !isset($content['SourceDBServer']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBSERVER'] ); - } - else if ( !isset($content['SourceDBTableName']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBTABLENAME'] ); - } - else if ( !isset($content['SourceDBUser']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBUSER'] ); - } - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_UNKNOWNSOURCE'], $content['SourceDBType'] ); - } - } - - // --- Now ADD/EDIT do the processing! - if ( !isset($content['ISERROR']) ) - { - // Everything was alright, so we go to the next step! - if ( $_POST['op'] == "addnewsource" ) - { - // Add custom search now! - if ( $content['SourceType'] == SOURCE_DISK ) - { - $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, ViewID, LogLineType, DiskFile, userid, groupid) - VALUES ('" . $content['Name'] . "', - " . $content['SourceType'] . ", - '" . $content['SourceViewID'] . "', - '" . $content['SourceLogLineType'] . "', - '" . $content['SourceDiskFile'] . "', - " . $content['userid'] . ", - " . $content['groupid'] . " - )"; - } - else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO ) - { - $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, userid, groupid) - VALUES ('" . $content['Name'] . "', - " . $content['SourceType'] . ", - '" . $content['SourceViewID'] . "', - '" . $content['SourceDBTableType'] . "', - " . $content['SourceDBType'] . ", - '" . $content['SourceDBServer'] . "', - '" . $content['SourceDBName'] . "', - '" . $content['SourceDBUser'] . "', - '" . $content['SourceDBPassword'] . "', - '" . $content['SourceDBTableName'] . "', - " . $content['SourceDBEnableRowCounting'] . ", - " . $content['userid'] . ", - " . $content['groupid'] . " - )"; - } - - $result = DB_Query($sqlquery); - DB_FreeQuery($result); - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCE_HASBEENADDED'], $content['Name'] ) , "sources.php" ); - } - else if ( $_POST['op'] == "editsource" ) - { - $result = DB_Query("SELECT ID FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID']); - $myrow = DB_GetSingleRow($result, true); - if ( !isset($myrow['ID']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_IDNOTFOUND'], $content['SOURCEID'] ); - } - else - { - // Edit the Search Entry now! - if ( $content['SourceType'] == SOURCE_DISK ) - { - $sqlquery = "UPDATE " . DB_SOURCES . " SET - Name = '" . $content['Name'] . "', - SourceType = " . $content['SourceType'] . ", - ViewID = '" . $content['SourceViewID'] . "', - LogLineType = '" . $content['SourceLogLineType'] . "', - DiskFile = '" . $content['SourceDiskFile'] . "', - userid = " . $content['userid'] . ", - groupid = " . $content['groupid'] . " - WHERE ID = " . $content['SOURCEID']; - } - else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO ) - { - $sqlquery = "UPDATE " . DB_SOURCES . " SET - Name = '" . $content['Name'] . "', - SourceType = " . $content['SourceType'] . ", - ViewID = '" . $content['SourceViewID'] . "', - DBTableType = '" . $content['SourceDBTableType'] . "', - DBType = " . $content['SourceDBType'] . ", - DBServer = '" . $content['SourceDBServer'] . "', - DBName = '" . $content['SourceDBName'] . "', - DBUser = '" . $content['SourceDBUser'] . "', - DBPassword = '" . $content['SourceDBPassword'] . "', - DBTableName = '" . $content['SourceDBTableName'] . "', - DBEnableRowCounting = " . $content['SourceDBEnableRowCounting'] . ", - userid = " . $content['userid'] . ", - groupid = " . $content['groupid'] . " - WHERE ID = " . $content['SOURCEID']; - } - - $result = DB_Query($sqlquery); - DB_FreeQuery($result); - - // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCES_HASBEENEDIT'], $content['Name']) , "sources.php" ); - } - } - } -} - -if ( !isset($_POST['op']) && !isset($_GET['op']) ) -{ - // Default Mode = List Searches - $content['LISTSOURCES'] = "true"; - - // Copy Sources array for further modifications - $content['SOURCES'] = $content['Sources']; - - // --- Process Sources - $i = 0; // Help counter! - foreach ($content['SOURCES'] as &$mySource ) - { - // --- Set Image for Type - // NonNUMERIC are config files Sources, can not be editied - if ( is_numeric($mySource['ID']) ) - { - // Allow EDIT - $mySource['ActionsAllowed'] = true; - - if ( $mySource['userid'] != null ) - { - $mySource['SourcesAssignedToImage'] = $content["MENU_ADMINUSERS"]; - $mySource['SourcesAssignedToText'] = $content["LN_GEN_USERONLY"]; - } - else if ( $mySource['groupid'] != null ) - { - $mySource['SourcesAssignedToImage'] = $content["MENU_ADMINGROUPS"]; - $mySource['SourcesAssignedToText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $mySource['groupname'] ); - - // Check if is ADMIN User, deny if normal user! - if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) - $mySource['ActionsAllowed'] = false; - } - else - { - $mySource['SourcesAssignedToImage'] = $content["MENU_GLOBAL"]; - $mySource['SourcesAssignedToText'] = $content["LN_GEN_GLOBAL"]; - - // Check if is ADMIN User, deny if normal user! - if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) - $mySource['ActionsAllowed'] = false; - } - } - else - { - // Disallow EDIT - $mySource['ActionsAllowed'] = false; - - $mySource['SourcesAssignedToImage'] = $content["MENU_INTERNAL"]; - $mySource['SourcesAssignedToText'] = $content["LN_GEN_CONFIGFILE"]; - } - // --- - - // --- Set SourceType - if ( $mySource['SourceType'] == SOURCE_DISK ) - { - $mySource['SourcesTypeImage'] = $content["MENU_SOURCE_DISK"]; - $mySource['SourcesTypeText'] = $content["LN_SOURCES_DISK"]; - } - else if ( $mySource['SourceType'] == SOURCE_DB ) - { - $mySource['SourcesTypeImage'] = $content["MENU_SOURCE_DB"]; - $mySource['SourcesTypeText'] = $content["LN_SOURCES_DB"]; - } - else if ( $mySource['SourceType'] == SOURCE_PDO ) - { - $mySource['SourcesTypeImage'] = $content["MENU_SOURCE_PDO"]; - $mySource['SourcesTypeText'] = $content["LN_SOURCES_PDO"]; - } - // --- - - // --- Set CSS Class - if ( $i % 2 == 0 ) - $mySource['cssclass'] = "line1"; - else - $mySource['cssclass'] = "line2"; - $i++; - // --- - } - // --- -// print_r ( $content['SOURCES'] ); -} -// --- END Custom Code - -// --- BEGIN CREATE TITLE -$content['TITLE'] = InitPageTitle(); -$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_SOURCEOPT']; -// --- END CREATE TITLE - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "admin/admin_sources.html"); -$page -> output(); -// --- - + Helps administrating phplogcon datasources + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './../'; + +// Now include necessary include files! +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); +include($gl_root_path . 'include/functions_filters.php'); + +// Set PAGE to be ADMINPAGE! +define('IS_ADMINPAGE', true); +$content['IS_ADMINPAGE'] = true; +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! + +// Init admin langauge file now! +IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); +// --- + +// --- BEGIN Custom Code + +if ( isset($_GET['op']) ) +{ + if ($_GET['op'] == "add") + { + // Set Mode to add + $content['ISEDITORNEWSOURCE'] = "true"; + $content['SOURCE_FORMACTION'] = "addnewsource"; + $content['SOURCE_SENDBUTTON'] = $content['LN_SOURCES_ADD']; + + //PreInit these values + $content['Name'] = ""; + $content['SourceType'] = SOURCE_DISK; + CreateSourceTypesList($content['SourceType']); + + // Init View List! + $content['SourceViewID'] = 'SYSLOG'; + $content['VIEWS'] = $content['Views']; + foreach ( $content['VIEWS'] as $myView ) + { + if ( $myView['ID'] == $content['SourceViewID'] ) + $content['VIEWS'][ $myView['ID'] ]['selected'] = "selected"; + else + $content['VIEWS'][ $myView['ID'] ]['selected'] = ""; + } + + // SOURCE_DISK specific + $content['SourceLogLineType'] = ""; + CreateLogLineTypesList($content['SourceLogLineType']); + $content['SourceDiskFile'] = "/var/log/syslog"; + + // SOURCE_DB specific + $content['SourceDBType'] = DB_MYSQL; + CreateDBTypesList($content['SourceDBType']); + $content['SourceDBName'] = "phplogcon"; + $content['SourceDBTableType'] = "monitorware"; + $content['SourceDBServer'] = "localhost"; + $content['SourceDBTableName'] = "systemevents"; + $content['SourceDBUser'] = "user"; + $content['SourceDBPassword'] = ""; + $content['SourceDBEnableRowCounting'] = "false"; + $content['SourceDBEnableRowCounting_true'] = ""; + $content['SourceDBEnableRowCounting_false'] = "checked"; + + // General stuff + $content['userid'] = null; + $content['CHECKED_ISUSERONLY'] = ""; + $content['SOURCEID'] = ""; + + // --- Check if groups are available + $content['SUBGROUPS'] = GetGroupsForSelectfield(); + if ( is_array($content['SUBGROUPS']) ) + $content['ISGROUPSAVAILABLE'] = true; + else + $content['ISGROUPSAVAILABLE'] = false; + } + else if ($_GET['op'] == "edit") + { + // Set Mode to edit + $content['ISEDITORNEWSOURCE'] = "true"; + $content['SOURCE_FORMACTION'] = "editsource"; + $content['SOURCE_SENDBUTTON'] = $content['LN_SOURCES_EDIT']; + + if ( isset($_GET['id']) ) + { + //PreInit these values + $content['SOURCEID'] = DB_RemoveBadChars($_GET['id']); + + // Check if exists + if ( is_numeric($content['SOURCEID']) && isset($content['Sources'][ $content['SOURCEID'] ]) ) + { + // Get Source reference + $mysource = $content['Sources'][ $content['SOURCEID'] ]; + + // Copy basic properties + $content['Name'] = $mysource['Name']; + $content['SourceType'] = $mysource['SourceType']; + CreateSourceTypesList($content['SourceType']); + + // Init View List! + $content['SourceViewID'] = $mysource['ViewID']; + $content['VIEWS'] = $content['Views']; + foreach ( $content['VIEWS'] as $myView ) + { + if ( $myView['ID'] == $content['SourceViewID'] ) + $content['VIEWS'][ $myView['ID'] ]['selected'] = "selected"; + else + $content['VIEWS'][ $myView['ID'] ]['selected'] = ""; + } + + // SOURCE_DISK specific + $content['SourceLogLineType'] = $mysource['LogLineType']; + CreateLogLineTypesList($content['SourceLogLineType']); + $content['SourceDiskFile'] = $mysource['DiskFile']; + + // SOURCE_DB specific + $content['SourceDBType'] = $mysource['DBType']; + CreateDBTypesList($content['SourceDBType']); + $content['SourceDBName'] = $mysource['DBName']; + $content['SourceDBTableType'] = $mysource['DBTableType']; + $content['SourceDBServer'] = $mysource['DBServer']; + $content['SourceDBTableName'] = $mysource['DBTableName']; + $content['SourceDBUser'] = $mysource['DBUser']; + $content['SourceDBPassword'] = $mysource['DBPassword']; + $content['SourceDBEnableRowCounting'] = $mysource['DBEnableRowCounting']; + if ( $content['SourceDBEnableRowCounting'] == 1 ) + { + $content['SourceDBEnableRowCounting_true'] = "checked"; + $content['SourceDBEnableRowCounting_false'] = ""; + } + else + { + $content['SourceDBEnableRowCounting_true'] = ""; + $content['SourceDBEnableRowCounting_false'] = "checked"; + } + + if ( $mysource['userid'] != null ) + $content['CHECKED_ISUSERONLY'] = "checked"; + else + $content['CHECKED_ISUSERONLY'] = ""; + + // --- Check if groups are available + $content['SUBGROUPS'] = GetGroupsForSelectfield(); + if ( is_array($content['SUBGROUPS']) ) + { + // Process All Groups + for($i = 0; $i < count($content['SUBGROUPS']); $i++) + { + if ( $mysource['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $mysource['groupid'] ) + $content['SUBGROUPS'][$i]['group_selected'] = "selected"; + else + $content['SUBGROUPS'][$i]['group_selected'] = ""; + } + + // Enable Group Selection + $content['ISGROUPSAVAILABLE'] = true; + } + else + $content['ISGROUPSAVAILABLE'] = false; + // --- + } + else + { + $content['ISEDITORNEWSOURCE'] = false; + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID']; + } + } + else + { + $content['ISEDITORNEWSEARCH'] = false; + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID']; + } + } + else if ($_GET['op'] == "delete") + { + if ( isset($_GET['id']) ) + { + //PreInit these values + $content['SOURCEID'] = DB_RemoveBadChars($_GET['id']); + + // Get UserInfo + $result = DB_Query("SELECT Name FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID'] ); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['Name']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_IDNOTFOUND'], $content['SOURCEID'] ); + } + + // --- Ask for deletion first! + if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") ) + { + // This will print an additional secure check which the user needs to confirm and exit the script execution. + PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_SOURCES_WARNDELETESEARCH'], $myrow['Name'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); + } + // --- + + // do the delete! + $result = DB_Query( "DELETE FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID'] ); + if ($result == FALSE) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_DELSOURCE'], $content['SOURCEID'] ); + } + else + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_HASBEENDEL'], $myrow['Name'] ) , "sources.php" ); + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID']; + } + } +} + +if ( isset($_POST['op']) ) +{ + // Read parameters first! + if ( isset($_POST['id']) ) { $content['SOURCEID'] = intval(DB_RemoveBadChars($_POST['id'])); } else {$content['SOURCEID'] = -1; } + if ( isset($_POST['Name']) ) { $content['Name'] = DB_RemoveBadChars($_POST['Name']); } else {$content['Name'] = ""; } + if ( isset($_POST['SourceType']) ) { $content['SourceType'] = DB_RemoveBadChars($_POST['SourceType']); } + if ( isset($_POST['SourceViewID']) ) { $content['SourceViewID'] = DB_RemoveBadChars($_POST['SourceViewID']); } + + if ( isset($content['SourceType']) ) + { + // Disk Params + if ( $content['SourceType'] == SOURCE_DISK ) + { + if ( isset($_POST['SourceLogLineType']) ) { $content['SourceLogLineType'] = DB_RemoveBadChars($_POST['SourceLogLineType']); } + if ( isset($_POST['SourceDiskFile']) ) { $content['SourceDiskFile'] = DB_RemoveBadChars($_POST['SourceDiskFile']); } + } + // DB Params + else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO ) + { + if ( isset($_POST['SourceDBType']) ) { $content['SourceDBType'] = DB_RemoveBadChars($_POST['SourceDBType']); } + if ( isset($_POST['SourceDBName']) ) { $content['SourceDBName'] = DB_RemoveBadChars($_POST['SourceDBName']); } + if ( isset($_POST['SourceDBTableType']) ) { $content['SourceDBTableType'] = DB_RemoveBadChars($_POST['SourceDBTableType']); } + if ( isset($_POST['SourceDBServer']) ) { $content['SourceDBServer'] = DB_RemoveBadChars($_POST['SourceDBServer']); } + if ( isset($_POST['SourceDBTableName']) ) { $content['SourceDBTableName'] = DB_RemoveBadChars($_POST['SourceDBTableName']); } + if ( isset($_POST['SourceDBUser']) ) { $content['SourceDBUser'] = DB_RemoveBadChars($_POST['SourceDBUser']); } + if ( isset($_POST['SourceDBPassword']) ) { $content['SourceDBPassword'] = DB_RemoveBadChars($_POST['SourceDBPassword']); } else {$content['SourceDBPassword'] = ""; } + if ( isset($_POST['SourceDBEnableRowCounting']) ) { $content['SourceDBEnableRowCounting'] = DB_RemoveBadChars($_POST['SourceDBEnableRowCounting']); } + // Extra Check for this property + if ( $_SESSION['SourceDBEnableRowCounting'] != "true" ) + $_SESSION['SourceDBEnableRowCounting'] = "false"; + + } + } + + // User & Group handeled specially + if ( isset ($_POST['isuseronly']) ) + { + $content['userid'] = $content['SESSION_USERID']; + $content['groupid'] = "null"; // Either user or group not both! + } + else + { + $content['userid'] = "null"; + if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 ) + $content['groupid'] = intval($_POST['groupid']); + else + $content['groupid'] = "null"; + } + + // --- Check mandotary values + if ( $content['Name'] == "" ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_NAMEOFTHESOURCE'] ); + } + else if ( !isset($content['SourceType']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_SOURCETYPE'] ); + } + else if ( !isset($content['SourceViewID']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_VIEW'] ); + } + else + { + // Disk Params + if ( $content['SourceType'] == SOURCE_DISK ) + { + if ( !isset($content['SourceLogLineType']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_LOGLINETYPE'] ); + } + else if ( !isset($content['SourceDiskFile']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_SYSLOGFILE'] ); + } + // Check if file is accessable! + else if ( !is_file($content['SourceDiskFile']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_NOTAVALIDFILE'], $content['SourceDiskFile'] ); + } + } + // DB Params + else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO ) + { + if ( !isset($content['SourceDBType']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DATABASETYPEOPTIONS'] ); + } + else if ( !isset($content['SourceDBName']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBNAME'] ); + } + else if ( !isset($content['SourceDBTableType']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBTABLETYPE'] ); + } + else if ( !isset($content['SourceDBServer']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBSERVER'] ); + } + else if ( !isset($content['SourceDBTableName']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBTABLENAME'] ); + } + else if ( !isset($content['SourceDBUser']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBUSER'] ); + } + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_UNKNOWNSOURCE'], $content['SourceDBType'] ); + } + } + + // --- Now ADD/EDIT do the processing! + if ( !isset($content['ISERROR']) ) + { + // Everything was alright, so we go to the next step! + if ( $_POST['op'] == "addnewsource" ) + { + // Add custom search now! + if ( $content['SourceType'] == SOURCE_DISK ) + { + $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, ViewID, LogLineType, DiskFile, userid, groupid) + VALUES ('" . $content['Name'] . "', + " . $content['SourceType'] . ", + '" . $content['SourceViewID'] . "', + '" . $content['SourceLogLineType'] . "', + '" . $content['SourceDiskFile'] . "', + " . $content['userid'] . ", + " . $content['groupid'] . " + )"; + } + else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO ) + { + $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, userid, groupid) + VALUES ('" . $content['Name'] . "', + " . $content['SourceType'] . ", + '" . $content['SourceViewID'] . "', + '" . $content['SourceDBTableType'] . "', + " . $content['SourceDBType'] . ", + '" . $content['SourceDBServer'] . "', + '" . $content['SourceDBName'] . "', + '" . $content['SourceDBUser'] . "', + '" . $content['SourceDBPassword'] . "', + '" . $content['SourceDBTableName'] . "', + " . $content['SourceDBEnableRowCounting'] . ", + " . $content['userid'] . ", + " . $content['groupid'] . " + )"; + } + + $result = DB_Query($sqlquery); + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCE_HASBEENADDED'], $content['Name'] ) , "sources.php" ); + } + else if ( $_POST['op'] == "editsource" ) + { + $result = DB_Query("SELECT ID FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID']); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['ID']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_IDNOTFOUND'], $content['SOURCEID'] ); + } + else + { + // Edit the Search Entry now! + if ( $content['SourceType'] == SOURCE_DISK ) + { + $sqlquery = "UPDATE " . DB_SOURCES . " SET + Name = '" . $content['Name'] . "', + SourceType = " . $content['SourceType'] . ", + ViewID = '" . $content['SourceViewID'] . "', + LogLineType = '" . $content['SourceLogLineType'] . "', + DiskFile = '" . $content['SourceDiskFile'] . "', + userid = " . $content['userid'] . ", + groupid = " . $content['groupid'] . " + WHERE ID = " . $content['SOURCEID']; + } + else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO ) + { + $sqlquery = "UPDATE " . DB_SOURCES . " SET + Name = '" . $content['Name'] . "', + SourceType = " . $content['SourceType'] . ", + ViewID = '" . $content['SourceViewID'] . "', + DBTableType = '" . $content['SourceDBTableType'] . "', + DBType = " . $content['SourceDBType'] . ", + DBServer = '" . $content['SourceDBServer'] . "', + DBName = '" . $content['SourceDBName'] . "', + DBUser = '" . $content['SourceDBUser'] . "', + DBPassword = '" . $content['SourceDBPassword'] . "', + DBTableName = '" . $content['SourceDBTableName'] . "', + DBEnableRowCounting = " . $content['SourceDBEnableRowCounting'] . ", + userid = " . $content['userid'] . ", + groupid = " . $content['groupid'] . " + WHERE ID = " . $content['SOURCEID']; + } + + $result = DB_Query($sqlquery); + DB_FreeQuery($result); + + // Done redirect! + RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCES_HASBEENEDIT'], $content['Name']) , "sources.php" ); + } + } + } +} + +if ( !isset($_POST['op']) && !isset($_GET['op']) ) +{ + // Default Mode = List Searches + $content['LISTSOURCES'] = "true"; + + // Copy Sources array for further modifications + $content['SOURCES'] = $content['Sources']; + + // --- Process Sources + $i = 0; // Help counter! + foreach ($content['SOURCES'] as &$mySource ) + { + // --- Set Image for Type + // NonNUMERIC are config files Sources, can not be editied + if ( is_numeric($mySource['ID']) ) + { + // Allow EDIT + $mySource['ActionsAllowed'] = true; + + if ( $mySource['userid'] != null ) + { + $mySource['SourcesAssignedToImage'] = $content["MENU_ADMINUSERS"]; + $mySource['SourcesAssignedToText'] = $content["LN_GEN_USERONLY"]; + } + else if ( $mySource['groupid'] != null ) + { + $mySource['SourcesAssignedToImage'] = $content["MENU_ADMINGROUPS"]; + $mySource['SourcesAssignedToText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $mySource['groupname'] ); + + // Check if is ADMIN User, deny if normal user! + if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) + $mySource['ActionsAllowed'] = false; + } + else + { + $mySource['SourcesAssignedToImage'] = $content["MENU_GLOBAL"]; + $mySource['SourcesAssignedToText'] = $content["LN_GEN_GLOBAL"]; + + // Check if is ADMIN User, deny if normal user! + if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) + $mySource['ActionsAllowed'] = false; + } + } + else + { + // Disallow EDIT + $mySource['ActionsAllowed'] = false; + + $mySource['SourcesAssignedToImage'] = $content["MENU_INTERNAL"]; + $mySource['SourcesAssignedToText'] = $content["LN_GEN_CONFIGFILE"]; + } + // --- + + // --- Set SourceType + if ( $mySource['SourceType'] == SOURCE_DISK ) + { + $mySource['SourcesTypeImage'] = $content["MENU_SOURCE_DISK"]; + $mySource['SourcesTypeText'] = $content["LN_SOURCES_DISK"]; + } + else if ( $mySource['SourceType'] == SOURCE_DB ) + { + $mySource['SourcesTypeImage'] = $content["MENU_SOURCE_DB"]; + $mySource['SourcesTypeText'] = $content["LN_SOURCES_DB"]; + } + else if ( $mySource['SourceType'] == SOURCE_PDO ) + { + $mySource['SourcesTypeImage'] = $content["MENU_SOURCE_PDO"]; + $mySource['SourcesTypeText'] = $content["LN_SOURCES_PDO"]; + } + // --- + + // --- Set CSS Class + if ( $i % 2 == 0 ) + $mySource['cssclass'] = "line1"; + else + $mySource['cssclass'] = "line2"; + $i++; + // --- + } + // --- +// print_r ( $content['SOURCES'] ); +} +// --- END Custom Code + +// --- BEGIN CREATE TITLE +$content['TITLE'] = InitPageTitle(); +$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_SOURCEOPT']; +// --- END CREATE TITLE + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "admin/admin_sources.html"); +$page -> output(); +// --- + ?> \ No newline at end of file diff --git a/src/admin/users.php b/src/admin/users.php index 09331e4..20f91a1 100644 --- a/src/admin/users.php +++ b/src/admin/users.php @@ -1,383 +1,383 @@ - Helps administrating users - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$gl_root_path = './../'; - -// Now include necessary include files! -include($gl_root_path . 'include/functions_common.php'); -include($gl_root_path . 'include/functions_frontendhelpers.php'); -include($gl_root_path . 'include/functions_filters.php'); - -// Set PAGE to be ADMINPAGE! -define('IS_ADMINPAGE', true); -$content['IS_ADMINPAGE'] = true; -InitPhpLogCon(); -InitSourceConfigs(); -InitFrontEndDefaults(); // Only in WebFrontEnd -InitFilterHelpers(); // Helpers for frontend filtering! - -// Init admin langauge file now! -IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); -// --- - -// --- BEGIN Custom Code - -// Only if the user is an admin! -if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) - DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] ); - -if ( isset($_GET['miniop']) && $_GET['miniop'] == "setisadmin" ) -{ - if ( isset($_GET['id']) && isset($_GET['newval']) ) - { - //PreInit these values - $content['USERID'] = intval(DB_RemoveBadChars($_GET['id'])); - $iNewVal = intval(DB_RemoveBadChars($_GET['newval'])); - - // --- handle special case - if ( $content['USERID'] == $content['SESSION_USERID'] && (!isset($_GET['verify']) || $_GET['verify'] != "yes") && $iNewVal == 0) - { - // This will print an additional secure check which the user needs to confirm and exit the script execution. - PrintSecureUserCheck( $content['LN_USER_WARNREMOVEADMIN'], $content['LN_DELETEYES'], $content['LN_DELETENO'] ); - } - // --- - - // Perform SQL Query! - $sqlquery = "SELECT * " . - " FROM " . DB_USERS . - " WHERE ID = " . $content['USERID']; - $result = DB_Query($sqlquery); - $myuser = DB_GetSingleRow($result, true); - if ( isset($myuser['username']) ) - { - // Update is_admin setting! - $result = DB_Query("UPDATE " . DB_USERS . " SET - is_admin = $iNewVal - WHERE ID = " . $content['USERID']); - DB_FreeQuery($result); - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); - } - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = "Error setting is_admin flat, invalid ID, User not found"; - } -} - - -if ( isset($_GET['op']) ) -{ - if ($_GET['op'] == "add") - { - // Set Mode to add - $content['ISEDITORNEWUSER'] = "true"; - $content['USER_FORMACTION'] = "addnewuser"; - $content['USER_SENDBUTTON'] = $content['LN_USER_ADD']; - - //PreInit these values - $content['USERNAME'] = ""; - $content['PASSWORD1'] = ""; - $content['PASSWORD2'] = ""; - } - else if ($_GET['op'] == "edit") - { - // Set Mode to edit - $content['ISEDITORNEWUSER'] = "true"; - $content['USER_FORMACTION'] = "edituser"; - $content['USER_SENDBUTTON'] = $content['LN_USER_EDIT']; - - if ( isset($_GET['id']) ) - { - //PreInit these values - $content['USERID'] = DB_RemoveBadChars($_GET['id']); - - $sqlquery = "SELECT * " . - " FROM " . DB_USERS . - " WHERE ID = " . $content['USERID']; - - $result = DB_Query($sqlquery); - $myuser = DB_GetSingleRow($result, true); - if ( isset($myuser['username']) ) - { - $content['USERID'] = $myuser['ID']; - $content['USERNAME'] = $myuser['username']; - - // Set is_admin flag - if ( $myuser['is_admin'] == 1 ) - $content['CHECKED_ISADMIN'] = "checked"; - else - $content['CHECKED_ISADMIN'] = ""; - - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); - } - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_USER_ERROR_INVALIDID']; - } - } - else if ($_GET['op'] == "delete") - { - if ( isset($_GET['id']) ) - { - //PreInit these values - $content['USERID'] = DB_RemoveBadChars($_GET['id']); - - if ( !isset($_SESSION['SESSION_USERNAME']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_USER_ERROR_INVALIDSESSIONS']; - } - else - { - // Get UserInfo - $result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE ID = " . $content['USERID'] ); - $myrow = DB_GetSingleRow($result, true); - if ( !isset($myrow['username']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); - } - - if ( $_SESSION['SESSION_USERNAME'] == $myrow['username'] ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_DONOTDELURSLF'], $content['USERID'] ); - } - else - { - // --- Ask for deletion first! - if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") ) - { - // This will print an additional secure check which the user needs to confirm and exit the script execution. - PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_USER_WARNDELETEUSER'], $myrow['username'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); - } - // --- - - // do the delete! - $result = DB_Query( "DELETE FROM " . DB_USERS . " WHERE ID = " . $content['USERID'] ); - if ($result == FALSE) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_DELUSER'], $content['USERID'] ); - } - else - DB_FreeQuery($result); - - // TODO: DELETE PERSONAL SETTINGS, GROUP MEMBERSHIP ... - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENDEL'], $myrow['username'] ) , "users.php" ); - } - } - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_USER_ERROR_INVALIDID']; - } - } -} - -if ( isset($_POST['op']) ) -{ - if ( isset ($_POST['id']) ) { $content['USERID'] = DB_RemoveBadChars($_POST['id']); } else {$content['USERID'] = ""; } - if ( isset ($_POST['username']) ) { $content['USERNAME'] = DB_RemoveBadChars($_POST['username']); } else {$content['USERNAME'] = ""; } - if ( isset ($_POST['password1']) ) { $content['PASSWORD1'] = DB_RemoveBadChars($_POST['password1']); } else {$content['PASSWORD1'] = ""; } - if ( isset ($_POST['password2']) ) { $content['PASSWORD2'] = DB_RemoveBadChars($_POST['password2']); } else {$content['PASSWORD2'] = ""; } - if ( isset ($_POST['isadmin']) ) { $content['ISADMIN'] = 1; } else {$content['ISADMIN'] = 0; } - - - // Check mandotary values - if ( $content['USERNAME'] == "" ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_USER_ERROR_USEREMPTY']; - } - - if ( !isset($content['ISERROR']) ) - { - // Everything was alright, so we go to the next step! - if ( $_POST['op'] == "addnewuser" ) - { - $result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE username = '" . $content['USERNAME'] . "'"); - $myrow = DB_GetSingleRow($result, true); - if ( isset($myrow['username']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_USER_ERROR_USERNAMETAKEN']; - } - else - { - // Check if Password is set! - if ( strlen($content['PASSWORD1']) <= 0 || - $content['PASSWORD1'] != $content['PASSWORD2'] ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_USER_ERROR_PASSSHORT']; - } - - if ( !isset($content['ISERROR']) ) - { - // Create passwordhash now :)! - $content['PASSWORDHASH'] = md5( $content['PASSWORD1'] ); - - // Add new User now! - $result = DB_Query("INSERT INTO " . DB_USERS . " (username, password, is_admin) - VALUES ('" . $content['USERNAME'] . "', - '" . $content['PASSWORDHASH'] . "', - " . $content['ISADMIN'] . ")"); - DB_FreeQuery($result); - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENADDED'], $content['USERNAME'] ) , "users.php" ); - } - } - } - else if ( $_POST['op'] == "edituser" ) - { - $result = DB_Query("SELECT ID FROM " . DB_USERS . " WHERE ID = " . $content['USERID']); - $myrow = DB_GetSingleRow($result, true); - if ( !isset($myrow['ID']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); - } - else - { - - // Check if Password is enabled - if ( isset($content['PASSWORD1']) && strlen($content['PASSWORD1']) > 0 ) - { - if ( $content['PASSWORD1'] != $content['PASSWORD2'] ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_USER_ERROR_PASSSHORT']; - } - - if ( !isset($content['ISERROR']) ) - { - // Create passwordhash now :)! - $content['PASSWORDHASH'] = md5( $content['PASSWORD1'] ); - - // Edit the User now! - $result = DB_Query("UPDATE " . DB_USERS . " SET - username = '" . $content['USERNAME'] . "', - password = '" . $content['PASSWORDHASH'] . "', - is_admin = " . $content['ISADMIN'] . " - WHERE ID = " . $content['USERID']); - DB_FreeQuery($result); - } - } - else - { - // Edit the User now! - $result = DB_Query("UPDATE " . DB_USERS . " SET - username = '" . $content['USERNAME'] . "', - is_admin = " . $content['ISADMIN'] . " - WHERE ID = " . $content['USERID']); - DB_FreeQuery($result); - } - - // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENEDIT'], $content['USERNAME']) , "users.php" ); - } - } - } -} - -if ( !isset($_POST['op']) && !isset($_GET['op']) ) -{ - // Default Mode = List Users - $content['LISTUSERS'] = "true"; - - // Read all Serverentries - $sqlquery = "SELECT ID, " . - " username, " . - " is_admin " . - " FROM " . DB_USERS . - " ORDER BY ID "; - $result = DB_Query($sqlquery); - $content['USERS'] = DB_GetAllRows($result, true); - - // --- Process Users - for($i = 0; $i < count($content['USERS']); $i++) - { - // --- Set Image for IsClanMember - if ( $content['USERS'][$i]['is_admin'] == 1 ) - { - $content['USERS'][$i]['is_isadmin_string'] = $content['MENU_SELECTION_ENABLED']; - $content['USERS'][$i]['set_isadmin'] = 0; - } - else - { - $content['USERS'][$i]['is_isadmin_string'] = $content['MENU_SELECTION_DISABLED']; - $content['USERS'][$i]['set_isadmin'] = 1; - } - // --- - - // --- Set CSS Class - if ( $i % 2 == 0 ) - $content['USERS'][$i]['cssclass'] = "line1"; - else - $content['USERS'][$i]['cssclass'] = "line2"; - // --- - } - // --- -} -// --- END Custom Code - -// --- BEGIN CREATE TITLE -$content['TITLE'] = InitPageTitle(); -$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_USEROPT']; -// --- END CREATE TITLE - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "admin/admin_users.html"); -$page -> output(); -// --- - + Helps administrating users + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './../'; + +// Now include necessary include files! +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); +include($gl_root_path . 'include/functions_filters.php'); + +// Set PAGE to be ADMINPAGE! +define('IS_ADMINPAGE', true); +$content['IS_ADMINPAGE'] = true; +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! + +// Init admin langauge file now! +IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); +// --- + +// --- BEGIN Custom Code + +// Only if the user is an admin! +if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) + DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] ); + +if ( isset($_GET['miniop']) && $_GET['miniop'] == "setisadmin" ) +{ + if ( isset($_GET['id']) && isset($_GET['newval']) ) + { + //PreInit these values + $content['USERID'] = intval(DB_RemoveBadChars($_GET['id'])); + $iNewVal = intval(DB_RemoveBadChars($_GET['newval'])); + + // --- handle special case + if ( $content['USERID'] == $content['SESSION_USERID'] && (!isset($_GET['verify']) || $_GET['verify'] != "yes") && $iNewVal == 0) + { + // This will print an additional secure check which the user needs to confirm and exit the script execution. + PrintSecureUserCheck( $content['LN_USER_WARNREMOVEADMIN'], $content['LN_DELETEYES'], $content['LN_DELETENO'] ); + } + // --- + + // Perform SQL Query! + $sqlquery = "SELECT * " . + " FROM " . DB_USERS . + " WHERE ID = " . $content['USERID']; + $result = DB_Query($sqlquery); + $myuser = DB_GetSingleRow($result, true); + if ( isset($myuser['username']) ) + { + // Update is_admin setting! + $result = DB_Query("UPDATE " . DB_USERS . " SET + is_admin = $iNewVal + WHERE ID = " . $content['USERID']); + DB_FreeQuery($result); + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); + } + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = "Error setting is_admin flat, invalid ID, User not found"; + } +} + + +if ( isset($_GET['op']) ) +{ + if ($_GET['op'] == "add") + { + // Set Mode to add + $content['ISEDITORNEWUSER'] = "true"; + $content['USER_FORMACTION'] = "addnewuser"; + $content['USER_SENDBUTTON'] = $content['LN_USER_ADD']; + + //PreInit these values + $content['USERNAME'] = ""; + $content['PASSWORD1'] = ""; + $content['PASSWORD2'] = ""; + } + else if ($_GET['op'] == "edit") + { + // Set Mode to edit + $content['ISEDITORNEWUSER'] = "true"; + $content['USER_FORMACTION'] = "edituser"; + $content['USER_SENDBUTTON'] = $content['LN_USER_EDIT']; + + if ( isset($_GET['id']) ) + { + //PreInit these values + $content['USERID'] = DB_RemoveBadChars($_GET['id']); + + $sqlquery = "SELECT * " . + " FROM " . DB_USERS . + " WHERE ID = " . $content['USERID']; + + $result = DB_Query($sqlquery); + $myuser = DB_GetSingleRow($result, true); + if ( isset($myuser['username']) ) + { + $content['USERID'] = $myuser['ID']; + $content['USERNAME'] = $myuser['username']; + + // Set is_admin flag + if ( $myuser['is_admin'] == 1 ) + $content['CHECKED_ISADMIN'] = "checked"; + else + $content['CHECKED_ISADMIN'] = ""; + + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); + } + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_USER_ERROR_INVALIDID']; + } + } + else if ($_GET['op'] == "delete") + { + if ( isset($_GET['id']) ) + { + //PreInit these values + $content['USERID'] = DB_RemoveBadChars($_GET['id']); + + if ( !isset($_SESSION['SESSION_USERNAME']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_USER_ERROR_INVALIDSESSIONS']; + } + else + { + // Get UserInfo + $result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE ID = " . $content['USERID'] ); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['username']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); + } + + if ( $_SESSION['SESSION_USERNAME'] == $myrow['username'] ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_DONOTDELURSLF'], $content['USERID'] ); + } + else + { + // --- Ask for deletion first! + if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") ) + { + // This will print an additional secure check which the user needs to confirm and exit the script execution. + PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_USER_WARNDELETEUSER'], $myrow['username'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); + } + // --- + + // do the delete! + $result = DB_Query( "DELETE FROM " . DB_USERS . " WHERE ID = " . $content['USERID'] ); + if ($result == FALSE) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_DELUSER'], $content['USERID'] ); + } + else + DB_FreeQuery($result); + + // TODO: DELETE PERSONAL SETTINGS, GROUP MEMBERSHIP ... + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENDEL'], $myrow['username'] ) , "users.php" ); + } + } + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_USER_ERROR_INVALIDID']; + } + } +} + +if ( isset($_POST['op']) ) +{ + if ( isset ($_POST['id']) ) { $content['USERID'] = DB_RemoveBadChars($_POST['id']); } else {$content['USERID'] = ""; } + if ( isset ($_POST['username']) ) { $content['USERNAME'] = DB_RemoveBadChars($_POST['username']); } else {$content['USERNAME'] = ""; } + if ( isset ($_POST['password1']) ) { $content['PASSWORD1'] = DB_RemoveBadChars($_POST['password1']); } else {$content['PASSWORD1'] = ""; } + if ( isset ($_POST['password2']) ) { $content['PASSWORD2'] = DB_RemoveBadChars($_POST['password2']); } else {$content['PASSWORD2'] = ""; } + if ( isset ($_POST['isadmin']) ) { $content['ISADMIN'] = 1; } else {$content['ISADMIN'] = 0; } + + + // Check mandotary values + if ( $content['USERNAME'] == "" ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_USER_ERROR_USEREMPTY']; + } + + if ( !isset($content['ISERROR']) ) + { + // Everything was alright, so we go to the next step! + if ( $_POST['op'] == "addnewuser" ) + { + $result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE username = '" . $content['USERNAME'] . "'"); + $myrow = DB_GetSingleRow($result, true); + if ( isset($myrow['username']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_USER_ERROR_USERNAMETAKEN']; + } + else + { + // Check if Password is set! + if ( strlen($content['PASSWORD1']) <= 0 || + $content['PASSWORD1'] != $content['PASSWORD2'] ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_USER_ERROR_PASSSHORT']; + } + + if ( !isset($content['ISERROR']) ) + { + // Create passwordhash now :)! + $content['PASSWORDHASH'] = md5( $content['PASSWORD1'] ); + + // Add new User now! + $result = DB_Query("INSERT INTO " . DB_USERS . " (username, password, is_admin) + VALUES ('" . $content['USERNAME'] . "', + '" . $content['PASSWORDHASH'] . "', + " . $content['ISADMIN'] . ")"); + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENADDED'], $content['USERNAME'] ) , "users.php" ); + } + } + } + else if ( $_POST['op'] == "edituser" ) + { + $result = DB_Query("SELECT ID FROM " . DB_USERS . " WHERE ID = " . $content['USERID']); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['ID']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] ); + } + else + { + + // Check if Password is enabled + if ( isset($content['PASSWORD1']) && strlen($content['PASSWORD1']) > 0 ) + { + if ( $content['PASSWORD1'] != $content['PASSWORD2'] ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_USER_ERROR_PASSSHORT']; + } + + if ( !isset($content['ISERROR']) ) + { + // Create passwordhash now :)! + $content['PASSWORDHASH'] = md5( $content['PASSWORD1'] ); + + // Edit the User now! + $result = DB_Query("UPDATE " . DB_USERS . " SET + username = '" . $content['USERNAME'] . "', + password = '" . $content['PASSWORDHASH'] . "', + is_admin = " . $content['ISADMIN'] . " + WHERE ID = " . $content['USERID']); + DB_FreeQuery($result); + } + } + else + { + // Edit the User now! + $result = DB_Query("UPDATE " . DB_USERS . " SET + username = '" . $content['USERNAME'] . "', + is_admin = " . $content['ISADMIN'] . " + WHERE ID = " . $content['USERID']); + DB_FreeQuery($result); + } + + // Done redirect! + RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENEDIT'], $content['USERNAME']) , "users.php" ); + } + } + } +} + +if ( !isset($_POST['op']) && !isset($_GET['op']) ) +{ + // Default Mode = List Users + $content['LISTUSERS'] = "true"; + + // Read all Serverentries + $sqlquery = "SELECT ID, " . + " username, " . + " is_admin " . + " FROM " . DB_USERS . + " ORDER BY ID "; + $result = DB_Query($sqlquery); + $content['USERS'] = DB_GetAllRows($result, true); + + // --- Process Users + for($i = 0; $i < count($content['USERS']); $i++) + { + // --- Set Image for IsClanMember + if ( $content['USERS'][$i]['is_admin'] == 1 ) + { + $content['USERS'][$i]['is_isadmin_string'] = $content['MENU_SELECTION_ENABLED']; + $content['USERS'][$i]['set_isadmin'] = 0; + } + else + { + $content['USERS'][$i]['is_isadmin_string'] = $content['MENU_SELECTION_DISABLED']; + $content['USERS'][$i]['set_isadmin'] = 1; + } + // --- + + // --- Set CSS Class + if ( $i % 2 == 0 ) + $content['USERS'][$i]['cssclass'] = "line1"; + else + $content['USERS'][$i]['cssclass'] = "line2"; + // --- + } + // --- +} +// --- END Custom Code + +// --- BEGIN CREATE TITLE +$content['TITLE'] = InitPageTitle(); +$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_USEROPT']; +// --- END CREATE TITLE + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "admin/admin_users.html"); +$page -> output(); +// --- + ?> \ No newline at end of file diff --git a/src/admin/views.php b/src/admin/views.php index eb50457..6ef2444 100644 --- a/src/admin/views.php +++ b/src/admin/views.php @@ -1,577 +1,577 @@ - Helps administrating custom user views - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$gl_root_path = './../'; - -// Now include necessary include files! -include($gl_root_path . 'include/functions_common.php'); -include($gl_root_path . 'include/functions_frontendhelpers.php'); -include($gl_root_path . 'include/functions_filters.php'); - -// Set PAGE to be ADMINPAGE! -define('IS_ADMINPAGE', true); -$content['IS_ADMINPAGE'] = true; -InitPhpLogCon(); -InitSourceConfigs(); -InitFrontEndDefaults(); // Only in WebFrontEnd -InitFilterHelpers(); // Helpers for frontend filtering! - -// Init admin langauge file now! -IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); -// --- - -// --- BEGIN Custom Code - -// Only if the user is an admin! -//if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) -// DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] ); - -if ( isset($_GET['op']) ) -{ - if ($_GET['op'] == "add") - { - // Set Mode to add - $content['ISEDITORNEWVIEW'] = "true"; - $content['VIEW_FORMACTION'] = "addnewview"; - $content['VIEW_SENDBUTTON'] = $content['LN_VIEWS_ADD']; - - //PreInit these values - $content['DisplayName'] = ""; - $content['userid'] = null; - $content['CHECKED_ISUSERONLY'] = ""; - $content['VIEWID'] = ""; - - // --- Check if groups are available - $content['SUBGROUPS'] = GetGroupsForSelectfield(); - if ( is_array($content['SUBGROUPS']) ) - $content['ISGROUPSAVAILABLE'] = true; - else - $content['ISGROUPSAVAILABLE'] = false; - // --- - } - else if ($_GET['op'] == "edit") - { - // Set Mode to edit - $content['ISEDITORNEWVIEW'] = "true"; - $content['VIEW_FORMACTION'] = "editview"; - $content['VIEW_SENDBUTTON'] = $content['LN_VIEWS_EDIT']; - - - // Copy Views array for further modifications - $content['VIEWS'] = $content['Views']; - - // View must be loaded as well already! - if ( isset($_GET['id']) && isset($content['VIEWS'][$_GET['id']]) ) - { - //PreInit these values - $content['VIEWID'] = DB_RemoveBadChars($_GET['id']); - if ( isset($content['VIEWS'][ $content['VIEWID'] ]) ) - { - $myview = $content['VIEWS'][ $content['VIEWID'] ]; - - $content['DisplayName'] = $myview['DisplayName'] ; - $content['userid'] = $myview['userid']; - $content['Columns'] = $myview['Columns']; - if ( $content['userid'] != null ) - $content['CHECKED_ISUSERONLY'] = "checked"; - else - $content['CHECKED_ISUSERONLY'] = ""; - - // --- Check if groups are available - $content['SUBGROUPS'] = GetGroupsForSelectfield(); - if ( is_array($content['SUBGROUPS']) ) - { - // Process All Groups - for($i = 0; $i < count($content['SUBGROUPS']); $i++) - { - if ( $myview['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $myview['groupid'] ) - $content['SUBGROUPS'][$i]['group_selected'] = "selected"; - else - $content['SUBGROUPS'][$i]['group_selected'] = ""; - } - - // Enable Group Selection - $content['ISGROUPSAVAILABLE'] = true; - } - else - $content['ISGROUPSAVAILABLE'] = false; - // --- - } - else - { - $content['ISEDITORNEWVIEW'] = false; - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] ); - } - } - else - { - $content['ISEDITORNEWVIEW'] = false; - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_INVALIDID'], isset($_GET['id']) ? $_GET['id'] : "" ); - } - } - else if ($_GET['op'] == "delete") - { - if ( isset($_GET['id']) ) - { - //PreInit these values - $content['VIEWID'] = DB_RemoveBadChars($_GET['id']); - - // Get UserInfo - $result = DB_Query("SELECT DisplayName FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID'] ); - $myrow = DB_GetSingleRow($result, true); - if ( !isset($myrow['DisplayName']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] ); - } - - // --- Ask for deletion first! - if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") ) - { - // This will print an additional secure check which the user needs to confirm and exit the script execution. - PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_VIEWS_WARNDELETEVIEW'], $myrow['DisplayName'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); - } - // --- - - // do the delete! - $result = DB_Query( "DELETE FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID'] ); - if ($result == FALSE) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_DELSEARCH'], $content['VIEWID'] ); - } - else - DB_FreeQuery($result); - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_HASBEENDEL'], $myrow['DisplayName'] ) , "views.php" ); - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_INVALIDID']; - } - } -} - -// --- Additional work todo for the edit view -if ( isset($content['ISEDITORNEWVIEW']) && $content['ISEDITORNEWVIEW'] ) -{ - // If Columns are send using POST we use them, otherwise we try to use from the view itself, if available - if ( isset($_POST['Columns']) ) - $AllColumns = $_POST['Columns']; - else if ( isset($content['Columns']) ) - $AllColumns = $content['Columns']; - - - // Read Columns from FORM data! - if ( isset($AllColumns) ) - { - // --- Read Columns from Formdata - if ( is_array($AllColumns) ) - { - // Copy columns ID's - foreach ($AllColumns as $myColKey) - $content['SUBCOLUMNS'][$myColKey]['ColFieldID'] = $myColKey; - } - else // One element only - $content['SUBCOLUMNS'][$AllColumns]['ColFieldID'] = $AllColumns; - // --- - - // --- Process Columns for display - $i = 0; // Help counter! - foreach ($content['SUBCOLUMNS'] as $key => &$myColumn ) - { - // Set Fieldcaption - if ( isset($fields[$key]) && isset($content[ $fields[$key]['FieldCaptionID'] ]) ) - $myColumn['ColCaption'] = $content[ $fields[$key]['FieldCaptionID'] ]; - else - $myColumn['ColCaption'] = $key; - - // --- Set CSS Class - if ( $i % 2 == 0 ) - $myColumn['colcssclass'] = "line1"; - else - $myColumn['colcssclass'] = "line2"; - $i++; - // --- - } - // --- - } - - // --- Copy fields data array - $content['FIELDS'] = $fields; - - // removed already added fields - if ( isset($content['SUBCOLUMNS']) ) - { - foreach ($content['SUBCOLUMNS'] as $key => &$myColumn ) - { - if ( isset($content['FIELDS'][$key]) ) - unset($content['FIELDS'][$key]); - } - } - - // set fieldcaption - foreach ($content['FIELDS'] as $key => &$myField ) - { - // Set Fieldcaption - if ( isset($content[ $myField['FieldCaptionID'] ]) ) - $myField['FieldCaption'] = $content[ $myField['FieldCaptionID'] ]; - else - $myField['FieldCaption'] = $key; - } - // --- -} -// --- - -// --- Process POST Form Data -if ( isset($_POST['op']) ) -{ - if ( isset ($_POST['id']) ) { $content['VIEWID'] = DB_RemoveBadChars($_POST['id']); } else {$content['VIEWID'] = ""; } - if ( isset ($_POST['DisplayName']) ) { $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); } else {$content['DisplayName'] = ""; } - - // User & Group handeled specially - if ( isset ($_POST['isuseronly']) ) - { - $content['userid'] = $content['SESSION_USERID']; - $content['groupid'] = "null"; // Either user or group not both! - } - else - { - $content['userid'] = "null"; - if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 ) - $content['groupid'] = intval($_POST['groupid']); - else - $content['groupid'] = "null"; - } - - // --- Check mandotary values - if ( $content['DisplayName'] == "" ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_DISPLAYNAMEEMPTY']; - } - // --- - - if ( !isset($content['ISERROR']) ) - { - // Check subop's first! - if ( isset($_POST['subop']) ) - { - // Get NewColID - $szColId = DB_RemoveBadChars($_POST['newcolumn']); - - // Add a new Column into our list! - if ( $_POST['subop'] == $content['LN_VIEWS_ADDCOLUMN'] && isset($_POST['newcolumn']) ) - { - // Add New entry into columnlist - $content['SUBCOLUMNS'][$szColId]['ColFieldID'] = $szColId; - - // Set Fieldcaption - if ( isset($content[ $fields[$szColId]['FieldCaptionID'] ]) ) - $content['SUBCOLUMNS'][$szColId]['ColCaption'] = $content[ $fields[$szColId]['FieldCaptionID'] ]; - else - $content['SUBCOLUMNS'][$szColId]['ColCaption'] = $szColId; - - // Set CSSClass - $content['SUBCOLUMNS'][$szColId]['colcssclass'] = count($content['SUBCOLUMNS']) % 2 == 0 ? "line1" : "line2"; - - // Remove from fields list as well - if ( isset($content['FIELDS'][$szColId]) ) - unset($content['FIELDS'][$szColId]); - - } - } - else if ( isset($_POST['subop_delete']) ) - { - // Get Column ID - $szColId = DB_RemoveBadChars($_POST['subop_delete']); - - // Remove Entry from Columnslist - if ( isset($content['SUBCOLUMNS'][$szColId]) ) - unset($content['SUBCOLUMNS'][$szColId]); - - // Add removed entry to field list - $content['FIELDS'][$szColId] = $szColId; - - // Set Fieldcaption - if ( isset($fields[$szColId]) && isset($content[ $fields[$szColId]['FieldCaptionID'] ]) ) - $content['FIELDS'][$szColId]['FieldCaption'] = $content[ $fields[$szColId]['FieldCaptionID'] ]; - else - $content['FIELDS'][$szColId]['FieldCaption'] = $szColId; - } - else if ( isset($_POST['subop_moveup']) ) - { - // Get Column ID - $szColId = DB_RemoveBadChars($_POST['subop_moveup']); - - // --- Move Entry one UP in Columnslist - // Find the entry in the array - $iArrayNum = 0; - foreach ($content['SUBCOLUMNS'] as $key => &$myColumn ) - { - if ( $key == $szColId ) - break; - - $iArrayNum++; - } - - // If found move up - if ( $iArrayNum > 0 ) - { - // Extract Entry from the array - $EntryTwoMove = array_slice($content['SUBCOLUMNS'], $iArrayNum, 1); - - // Unset Entry from the array - unset( $content['SUBCOLUMNS'][$szColId] ); - - // Splice the array order! - array_splice($content['SUBCOLUMNS'], $iArrayNum-1, 0, $EntryTwoMove); - } - // --- - } - else if ( isset($_POST['subop_movedown']) ) - { - // Get Column ID - $szColId = DB_RemoveBadChars($_POST['subop_movedown']); - - // --- Move Entry one DOWN in Columnslist - // Find the entry in the array - $iArrayNum = 0; - foreach ($content['SUBCOLUMNS'] as $key => &$myColumn ) - { - if ( $key == $szColId ) - break; - - $iArrayNum++; - } - - // If found move down - if ( $iArrayNum < count($content['SUBCOLUMNS']) ) - { - // Extract Entry from the array - $EntryTwoMove = array_slice($content['SUBCOLUMNS'], $iArrayNum, 1); - - // Unset Entry from the array - unset( $content['SUBCOLUMNS'][$szColId] ); - - // Splice the array order! - array_splice($content['SUBCOLUMNS'], $iArrayNum+1, 0, $EntryTwoMove); - } - // --- - } - else // Now SUBOP means normal processing! - { - // Everything was alright, so we go to the next step! - if ( $_POST['op'] == "addnewview" ) - { - // Create Columnlist comma seperated! - if ( isset($_POST['Columns']) && is_array($_POST['Columns']) ) - { - // Copy columns ID's - foreach ($_POST['Columns'] as $myColKey) - { - if ( isset($content['Columns']) ) - $content['Columns'] .= ", " . $myColKey; - else - $content['Columns'] = $myColKey; - } - - // Add custom search now! - $sqlquery = "INSERT INTO " . DB_VIEWS. " (DisplayName, Columns, userid, groupid) - VALUES ('" . $content['DisplayName'] . "', - '" . $content['Columns'] . "', - " . $content['userid'] . ", - " . $content['groupid'] . " - )"; - $result = DB_Query($sqlquery); - DB_FreeQuery($result); - - // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_HASBEENADDED'], $content['DisplayName'] ) , "views.php" ); - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_NOCOLUMNS']; - } - } - else if ( $_POST['op'] == "editview" ) - { - $result = DB_Query("SELECT ID FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID']); - $myrow = DB_GetSingleRow($result, true); - if ( !isset($myrow['ID']) ) - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] ); - } - else - { - // Create Columnlist comma seperated! - if ( isset($_POST['Columns']) && is_array($_POST['Columns']) ) - { - // Copy columns ID's - unset($content['Columns']); - foreach ($_POST['Columns'] as $myColKey) - { - if ( isset($content['Columns']) ) - $content['Columns'] .= ", " . $myColKey; - else - $content['Columns'] = $myColKey; - } - - - // Edit the Search Entry now! - $result = DB_Query("UPDATE " . DB_VIEWS . " SET - DisplayName = '" . $content['DisplayName'] . "', - Columns = '" . $content['Columns'] . "', - userid = " . $content['userid'] . ", - groupid = " . $content['groupid'] . " - WHERE ID = " . $content['VIEWID']); - DB_FreeQuery($result); - - // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_HASBEENEDIT'], $content['DisplayName']) , "views.php" ); - } - else - { - $content['ISERROR'] = true; - $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_NOCOLUMNS']; - } - } - } - } - } -} - -if ( !isset($_POST['op']) && !isset($_GET['op']) ) -{ - // Default Mode = List Searches - $content['LISTVIEWS'] = "true"; - - // Copy Views array for further modifications - $content['VIEWS'] = $content['Views']; - - // --- Process Views - $i = 0; // Help counter! - foreach ($content['VIEWS'] as &$myView ) - { - // So internal Views can not be edited but seen - if ( is_numeric($myView['ID']) ) - { - $myView['ActionsAllowed'] = true; - - // --- Set Image for Type - if ( $myView['userid'] != null ) - { - $myView['ViewTypeImage'] = $content["MENU_ADMINUSERS"]; - $myView['ViewTypeText'] = $content["LN_GEN_USERONLY"]; - } - else if ( $myView['groupid'] != null ) - { - $myView['ViewTypeImage'] = $content["MENU_ADMINGROUPS"]; - $myView['ViewTypeText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $myView['groupname'] ); - - // Check if is ADMIN User, deny if normal user! - if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) - $myView['ActionsAllowed'] = false; - } - else - { - $myView['ViewTypeImage'] = $content["MENU_GLOBAL"]; - $myView['ViewTypeText'] = $content["LN_GEN_GLOBAL"]; - - // Check if is ADMIN User, deny if normal user! - if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) - $myView['ActionsAllowed'] = false; - } - // --- - } - else - { - $myView['ActionsAllowed'] = false; - - $myView['ViewTypeImage'] = $content["MENU_INTERNAL"]; - $myView['ViewTypeText'] = $content["LN_GEN_INTERNAL"]; - } - - // --- Add DisplayNames to columns - $iBegin = true; - foreach ($myView['Columns'] as $myCol ) - { - // Get Fieldcaption - if ( isset($fields[$myCol]) && isset($content[ $fields[$myCol]['FieldCaptionID'] ]) ) - $myView['COLUMNS'][$myCol]['FieldCaption'] = $content[ $fields[$myCol]['FieldCaptionID'] ]; - else - $myView['COLUMNS'][$myCol]['FieldCaption'] = $myCol; - - if ( $iBegin ) - { - $myView['COLUMNS'][$myCol]['FieldCaptionSeperator'] = ""; - $iBegin = false; - } - else - $myView['COLUMNS'][$myCol]['FieldCaptionSeperator'] = ", "; - - } - // --- - - // --- Set CSS Class - if ( $i % 2 == 0 ) - $myView['cssclass'] = "line1"; - else - $myView['cssclass'] = "line2"; - $i++; - // --- - } - // --- -} -// --- END Custom Code - -// --- BEGIN CREATE TITLE -$content['TITLE'] = InitPageTitle(); -$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_VIEWSOPT']; -// --- END CREATE TITLE - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "admin/admin_views.html"); -$page -> output(); -// --- - + Helps administrating custom user views + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './../'; + +// Now include necessary include files! +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); +include($gl_root_path . 'include/functions_filters.php'); + +// Set PAGE to be ADMINPAGE! +define('IS_ADMINPAGE', true); +$content['IS_ADMINPAGE'] = true; +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! + +// Init admin langauge file now! +IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' ); +// --- + +// --- BEGIN Custom Code + +// Only if the user is an admin! +//if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) +// DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] ); + +if ( isset($_GET['op']) ) +{ + if ($_GET['op'] == "add") + { + // Set Mode to add + $content['ISEDITORNEWVIEW'] = "true"; + $content['VIEW_FORMACTION'] = "addnewview"; + $content['VIEW_SENDBUTTON'] = $content['LN_VIEWS_ADD']; + + //PreInit these values + $content['DisplayName'] = ""; + $content['userid'] = null; + $content['CHECKED_ISUSERONLY'] = ""; + $content['VIEWID'] = ""; + + // --- Check if groups are available + $content['SUBGROUPS'] = GetGroupsForSelectfield(); + if ( is_array($content['SUBGROUPS']) ) + $content['ISGROUPSAVAILABLE'] = true; + else + $content['ISGROUPSAVAILABLE'] = false; + // --- + } + else if ($_GET['op'] == "edit") + { + // Set Mode to edit + $content['ISEDITORNEWVIEW'] = "true"; + $content['VIEW_FORMACTION'] = "editview"; + $content['VIEW_SENDBUTTON'] = $content['LN_VIEWS_EDIT']; + + + // Copy Views array for further modifications + $content['VIEWS'] = $content['Views']; + + // View must be loaded as well already! + if ( isset($_GET['id']) && isset($content['VIEWS'][$_GET['id']]) ) + { + //PreInit these values + $content['VIEWID'] = DB_RemoveBadChars($_GET['id']); + if ( isset($content['VIEWS'][ $content['VIEWID'] ]) ) + { + $myview = $content['VIEWS'][ $content['VIEWID'] ]; + + $content['DisplayName'] = $myview['DisplayName'] ; + $content['userid'] = $myview['userid']; + $content['Columns'] = $myview['Columns']; + if ( $content['userid'] != null ) + $content['CHECKED_ISUSERONLY'] = "checked"; + else + $content['CHECKED_ISUSERONLY'] = ""; + + // --- Check if groups are available + $content['SUBGROUPS'] = GetGroupsForSelectfield(); + if ( is_array($content['SUBGROUPS']) ) + { + // Process All Groups + for($i = 0; $i < count($content['SUBGROUPS']); $i++) + { + if ( $myview['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $myview['groupid'] ) + $content['SUBGROUPS'][$i]['group_selected'] = "selected"; + else + $content['SUBGROUPS'][$i]['group_selected'] = ""; + } + + // Enable Group Selection + $content['ISGROUPSAVAILABLE'] = true; + } + else + $content['ISGROUPSAVAILABLE'] = false; + // --- + } + else + { + $content['ISEDITORNEWVIEW'] = false; + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] ); + } + } + else + { + $content['ISEDITORNEWVIEW'] = false; + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_INVALIDID'], isset($_GET['id']) ? $_GET['id'] : "" ); + } + } + else if ($_GET['op'] == "delete") + { + if ( isset($_GET['id']) ) + { + //PreInit these values + $content['VIEWID'] = DB_RemoveBadChars($_GET['id']); + + // Get UserInfo + $result = DB_Query("SELECT DisplayName FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID'] ); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['DisplayName']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] ); + } + + // --- Ask for deletion first! + if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") ) + { + // This will print an additional secure check which the user needs to confirm and exit the script execution. + PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_VIEWS_WARNDELETEVIEW'], $myrow['DisplayName'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); + } + // --- + + // do the delete! + $result = DB_Query( "DELETE FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID'] ); + if ($result == FALSE) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_DELSEARCH'], $content['VIEWID'] ); + } + else + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_HASBEENDEL'], $myrow['DisplayName'] ) , "views.php" ); + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_INVALIDID']; + } + } +} + +// --- Additional work todo for the edit view +if ( isset($content['ISEDITORNEWVIEW']) && $content['ISEDITORNEWVIEW'] ) +{ + // If Columns are send using POST we use them, otherwise we try to use from the view itself, if available + if ( isset($_POST['Columns']) ) + $AllColumns = $_POST['Columns']; + else if ( isset($content['Columns']) ) + $AllColumns = $content['Columns']; + + + // Read Columns from FORM data! + if ( isset($AllColumns) ) + { + // --- Read Columns from Formdata + if ( is_array($AllColumns) ) + { + // Copy columns ID's + foreach ($AllColumns as $myColKey) + $content['SUBCOLUMNS'][$myColKey]['ColFieldID'] = $myColKey; + } + else // One element only + $content['SUBCOLUMNS'][$AllColumns]['ColFieldID'] = $AllColumns; + // --- + + // --- Process Columns for display + $i = 0; // Help counter! + foreach ($content['SUBCOLUMNS'] as $key => &$myColumn ) + { + // Set Fieldcaption + if ( isset($fields[$key]) && isset($content[ $fields[$key]['FieldCaptionID'] ]) ) + $myColumn['ColCaption'] = $content[ $fields[$key]['FieldCaptionID'] ]; + else + $myColumn['ColCaption'] = $key; + + // --- Set CSS Class + if ( $i % 2 == 0 ) + $myColumn['colcssclass'] = "line1"; + else + $myColumn['colcssclass'] = "line2"; + $i++; + // --- + } + // --- + } + + // --- Copy fields data array + $content['FIELDS'] = $fields; + + // removed already added fields + if ( isset($content['SUBCOLUMNS']) ) + { + foreach ($content['SUBCOLUMNS'] as $key => &$myColumn ) + { + if ( isset($content['FIELDS'][$key]) ) + unset($content['FIELDS'][$key]); + } + } + + // set fieldcaption + foreach ($content['FIELDS'] as $key => &$myField ) + { + // Set Fieldcaption + if ( isset($content[ $myField['FieldCaptionID'] ]) ) + $myField['FieldCaption'] = $content[ $myField['FieldCaptionID'] ]; + else + $myField['FieldCaption'] = $key; + } + // --- +} +// --- + +// --- Process POST Form Data +if ( isset($_POST['op']) ) +{ + if ( isset ($_POST['id']) ) { $content['VIEWID'] = DB_RemoveBadChars($_POST['id']); } else {$content['VIEWID'] = ""; } + if ( isset ($_POST['DisplayName']) ) { $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); } else {$content['DisplayName'] = ""; } + + // User & Group handeled specially + if ( isset ($_POST['isuseronly']) ) + { + $content['userid'] = $content['SESSION_USERID']; + $content['groupid'] = "null"; // Either user or group not both! + } + else + { + $content['userid'] = "null"; + if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 ) + $content['groupid'] = intval($_POST['groupid']); + else + $content['groupid'] = "null"; + } + + // --- Check mandotary values + if ( $content['DisplayName'] == "" ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_DISPLAYNAMEEMPTY']; + } + // --- + + if ( !isset($content['ISERROR']) ) + { + // Check subop's first! + if ( isset($_POST['subop']) ) + { + // Get NewColID + $szColId = DB_RemoveBadChars($_POST['newcolumn']); + + // Add a new Column into our list! + if ( $_POST['subop'] == $content['LN_VIEWS_ADDCOLUMN'] && isset($_POST['newcolumn']) ) + { + // Add New entry into columnlist + $content['SUBCOLUMNS'][$szColId]['ColFieldID'] = $szColId; + + // Set Fieldcaption + if ( isset($content[ $fields[$szColId]['FieldCaptionID'] ]) ) + $content['SUBCOLUMNS'][$szColId]['ColCaption'] = $content[ $fields[$szColId]['FieldCaptionID'] ]; + else + $content['SUBCOLUMNS'][$szColId]['ColCaption'] = $szColId; + + // Set CSSClass + $content['SUBCOLUMNS'][$szColId]['colcssclass'] = count($content['SUBCOLUMNS']) % 2 == 0 ? "line1" : "line2"; + + // Remove from fields list as well + if ( isset($content['FIELDS'][$szColId]) ) + unset($content['FIELDS'][$szColId]); + + } + } + else if ( isset($_POST['subop_delete']) ) + { + // Get Column ID + $szColId = DB_RemoveBadChars($_POST['subop_delete']); + + // Remove Entry from Columnslist + if ( isset($content['SUBCOLUMNS'][$szColId]) ) + unset($content['SUBCOLUMNS'][$szColId]); + + // Add removed entry to field list + $content['FIELDS'][$szColId] = $szColId; + + // Set Fieldcaption + if ( isset($fields[$szColId]) && isset($content[ $fields[$szColId]['FieldCaptionID'] ]) ) + $content['FIELDS'][$szColId]['FieldCaption'] = $content[ $fields[$szColId]['FieldCaptionID'] ]; + else + $content['FIELDS'][$szColId]['FieldCaption'] = $szColId; + } + else if ( isset($_POST['subop_moveup']) ) + { + // Get Column ID + $szColId = DB_RemoveBadChars($_POST['subop_moveup']); + + // --- Move Entry one UP in Columnslist + // Find the entry in the array + $iArrayNum = 0; + foreach ($content['SUBCOLUMNS'] as $key => &$myColumn ) + { + if ( $key == $szColId ) + break; + + $iArrayNum++; + } + + // If found move up + if ( $iArrayNum > 0 ) + { + // Extract Entry from the array + $EntryTwoMove = array_slice($content['SUBCOLUMNS'], $iArrayNum, 1); + + // Unset Entry from the array + unset( $content['SUBCOLUMNS'][$szColId] ); + + // Splice the array order! + array_splice($content['SUBCOLUMNS'], $iArrayNum-1, 0, $EntryTwoMove); + } + // --- + } + else if ( isset($_POST['subop_movedown']) ) + { + // Get Column ID + $szColId = DB_RemoveBadChars($_POST['subop_movedown']); + + // --- Move Entry one DOWN in Columnslist + // Find the entry in the array + $iArrayNum = 0; + foreach ($content['SUBCOLUMNS'] as $key => &$myColumn ) + { + if ( $key == $szColId ) + break; + + $iArrayNum++; + } + + // If found move down + if ( $iArrayNum < count($content['SUBCOLUMNS']) ) + { + // Extract Entry from the array + $EntryTwoMove = array_slice($content['SUBCOLUMNS'], $iArrayNum, 1); + + // Unset Entry from the array + unset( $content['SUBCOLUMNS'][$szColId] ); + + // Splice the array order! + array_splice($content['SUBCOLUMNS'], $iArrayNum+1, 0, $EntryTwoMove); + } + // --- + } + else // Now SUBOP means normal processing! + { + // Everything was alright, so we go to the next step! + if ( $_POST['op'] == "addnewview" ) + { + // Create Columnlist comma seperated! + if ( isset($_POST['Columns']) && is_array($_POST['Columns']) ) + { + // Copy columns ID's + foreach ($_POST['Columns'] as $myColKey) + { + if ( isset($content['Columns']) ) + $content['Columns'] .= ", " . $myColKey; + else + $content['Columns'] = $myColKey; + } + + // Add custom search now! + $sqlquery = "INSERT INTO " . DB_VIEWS. " (DisplayName, Columns, userid, groupid) + VALUES ('" . $content['DisplayName'] . "', + '" . $content['Columns'] . "', + " . $content['userid'] . ", + " . $content['groupid'] . " + )"; + $result = DB_Query($sqlquery); + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_HASBEENADDED'], $content['DisplayName'] ) , "views.php" ); + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_NOCOLUMNS']; + } + } + else if ( $_POST['op'] == "editview" ) + { + $result = DB_Query("SELECT ID FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID']); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['ID']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] ); + } + else + { + // Create Columnlist comma seperated! + if ( isset($_POST['Columns']) && is_array($_POST['Columns']) ) + { + // Copy columns ID's + unset($content['Columns']); + foreach ($_POST['Columns'] as $myColKey) + { + if ( isset($content['Columns']) ) + $content['Columns'] .= ", " . $myColKey; + else + $content['Columns'] = $myColKey; + } + + + // Edit the Search Entry now! + $result = DB_Query("UPDATE " . DB_VIEWS . " SET + DisplayName = '" . $content['DisplayName'] . "', + Columns = '" . $content['Columns'] . "', + userid = " . $content['userid'] . ", + groupid = " . $content['groupid'] . " + WHERE ID = " . $content['VIEWID']); + DB_FreeQuery($result); + + // Done redirect! + RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_HASBEENEDIT'], $content['DisplayName']) , "views.php" ); + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_NOCOLUMNS']; + } + } + } + } + } +} + +if ( !isset($_POST['op']) && !isset($_GET['op']) ) +{ + // Default Mode = List Searches + $content['LISTVIEWS'] = "true"; + + // Copy Views array for further modifications + $content['VIEWS'] = $content['Views']; + + // --- Process Views + $i = 0; // Help counter! + foreach ($content['VIEWS'] as &$myView ) + { + // So internal Views can not be edited but seen + if ( is_numeric($myView['ID']) ) + { + $myView['ActionsAllowed'] = true; + + // --- Set Image for Type + if ( $myView['userid'] != null ) + { + $myView['ViewTypeImage'] = $content["MENU_ADMINUSERS"]; + $myView['ViewTypeText'] = $content["LN_GEN_USERONLY"]; + } + else if ( $myView['groupid'] != null ) + { + $myView['ViewTypeImage'] = $content["MENU_ADMINGROUPS"]; + $myView['ViewTypeText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $myView['groupname'] ); + + // Check if is ADMIN User, deny if normal user! + if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) + $myView['ActionsAllowed'] = false; + } + else + { + $myView['ViewTypeImage'] = $content["MENU_GLOBAL"]; + $myView['ViewTypeText'] = $content["LN_GEN_GLOBAL"]; + + // Check if is ADMIN User, deny if normal user! + if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 ) + $myView['ActionsAllowed'] = false; + } + // --- + } + else + { + $myView['ActionsAllowed'] = false; + + $myView['ViewTypeImage'] = $content["MENU_INTERNAL"]; + $myView['ViewTypeText'] = $content["LN_GEN_INTERNAL"]; + } + + // --- Add DisplayNames to columns + $iBegin = true; + foreach ($myView['Columns'] as $myCol ) + { + // Get Fieldcaption + if ( isset($fields[$myCol]) && isset($content[ $fields[$myCol]['FieldCaptionID'] ]) ) + $myView['COLUMNS'][$myCol]['FieldCaption'] = $content[ $fields[$myCol]['FieldCaptionID'] ]; + else + $myView['COLUMNS'][$myCol]['FieldCaption'] = $myCol; + + if ( $iBegin ) + { + $myView['COLUMNS'][$myCol]['FieldCaptionSeperator'] = ""; + $iBegin = false; + } + else + $myView['COLUMNS'][$myCol]['FieldCaptionSeperator'] = ", "; + + } + // --- + + // --- Set CSS Class + if ( $i % 2 == 0 ) + $myView['cssclass'] = "line1"; + else + $myView['cssclass'] = "line2"; + $i++; + // --- + } + // --- +} +// --- END Custom Code + +// --- BEGIN CREATE TITLE +$content['TITLE'] = InitPageTitle(); +$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_VIEWSOPT']; +// --- END CREATE TITLE + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "admin/admin_views.html"); +$page -> output(); +// --- + ?> \ No newline at end of file diff --git a/src/lang/de/admin.php b/src/lang/de/admin.php new file mode 100644 index 0000000..a3391a6 --- /dev/null +++ b/src/lang/de/admin.php @@ -0,0 +1,211 @@ + www.phplogcon.org <- + * ----------------------------------------------------------------- + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution. + ********************************************************************* +*/ +global $content; + +// Global Stuff +$content['LN_ADMINMENU_HOMEPAGE'] = "Back to Show Events"; +$content['LN_ADMINMENU_GENOPT'] = "General Options"; +$content['LN_ADMINMENU_SOURCEOPT'] = "Sources Options"; +$content['LN_ADMINMENU_VIEWSOPT'] = "Views Options"; +$content['LN_ADMINMENU_SEARCHOPT'] = "Search Options"; +$content['LN_ADMINMENU_USEROPT'] = "User Options"; +$content['LN_ADMINMENU_GROUPOPT'] = "Group Options"; +$content['LN_ADMIN_CENTER'] = "Admin center"; +$content['LN_ADMIN_UNKNOWNSTATE'] = "Unknown State"; +$content['LN_ADMIN_ERROR_NOTALLOWED'] = "You are not allowed to access this page with your user level."; +$content['LN_DELETEYES'] = "Yes"; +$content['LN_DELETENO'] = "No"; +$content['LN_GEN_ACTIONS'] = "Available Actions"; +$content['LN_ADMIN_SEND'] = "Send changes"; +$content['LN_GEN_USERONLY'] = "User only"; +$content['LN_GEN_GROUPONLY'] = "Group only"; +$content['LN_GEN_GLOBAL'] = "Global"; +$content['LN_GEN_USERONLY_LONG'] = "For me only
(Only available to your user)"; +$content['LN_GEN_GROUPONLY_LONG'] = "For this group
(Only available to the selected group)"; +$content['LN_GEN_GROUPONLYNAME'] = "Group '%1'"; + + +// General Options +$content['LN_ADMIN_GLOBFRONTEND'] = "Global frontend options"; +$content['LN_ADMIN_USERFRONTEND'] = "User specific frontend options"; +$content['LN_ADMIN_MISC'] = "Miscellaneous Options"; +$content['LN_GEN_SHOWDEBUGMSG'] = "Show Debug messages"; +$content['LN_GEN_DEBUGGRIDCOUNTER'] = "Show Debug Gridcounter"; +$content['LN_GEN_SHOWPAGERENDERSTATS'] = "Show Pagerenderstats"; +$content['LN_GEN_ENABLEGZIP'] = "Enable GZIP Compressed Output"; +$content['LN_GEN_DEBUGUSERLOGIN'] = "Debug Userlogin"; +$content['LN_GEN_WEBSTYLE'] = "Default selected style"; +$content['LN_GEN_SELLANGUAGE'] = "Default selected language"; +$content['LN_GEN_PREPENDTITLE'] = "Prepend this string in title"; +$content['LN_GEN_USETODAY'] = "Use Today and Yesterday in timefields"; +$content['LN_GEN_DETAILPOPUPS'] = "Use Popup to display the full messagedetails"; +$content['LN_GEN_MSGCHARLIMIT'] = "Character limit of the message in main view"; +$content['LN_GEN_ENTRIESPERPAGE'] = "Number of entries per page"; +$content['LN_GEN_AUTORELOADSECONDS'] = "Enable autoreload after seconds"; +$content['LN_GEN_IPADRRESOLVE'] = "Resolve IP Addresses using DNS"; +$content['LN_GEN_CUSTBTNCAPT'] = "Custom search caption"; +$content['LN_GEN_CUSTBTNSRCH'] = "Custom search string"; +$content['LN_GEN_SUCCESSFULLYSAVED'] = "The configuration Values have been successfully saved"; +$content['LN_GEN_INTERNAL'] = "Internal"; +$content['LN_GEN_DISABLED'] = "Function disabled"; +$content['LN_GEN_CONFIGFILE'] = "Configuration File"; +$content['LN_GEN_ACCESSDENIED'] = "Access denied to this function"; + +// User Center +$content['LN_USER_CENTER'] = "User Options"; +$content['LN_USER_ID'] = "ID"; +$content['LN_USER_NAME'] = "Username"; +$content['LN_USER_ADD'] = "Add User"; +$content['LN_USER_EDIT'] = "Edit User"; +$content['LN_USER_DELETE'] = "Delete User"; +$content['LN_USER_PASSWORD1'] = "Password"; +$content['LN_USER_PASSWORD2'] = "Confirm Password"; +$content['LN_USER_ERROR_IDNOTFOUND'] = "Error, User with ID '%1' , was not found"; +$content['LN_USER_ERROR_DONOTDELURSLF'] = "Error, you can not DELETE YOURSELF!"; +$content['LN_USER_ERROR_DELUSER'] = "Deleting of the user with id '%1' failed!"; +$content['LN_USER_ERROR_INVALIDID'] = "Error, invalid ID, User not found"; +$content['LN_USER_ERROR_HASBEENDEL'] = "The User '%1' has been successfully deleted!"; +$content['LN_USER_ERROR_USEREMPTY'] = "Error, Username was empty"; +$content['LN_USER_ERROR_USERNAMETAKEN'] = "Error, this Username is already taken!"; +$content['LN_USER_ERROR_PASSSHORT'] = "Error, Password was to short, or did not match"; +$content['LN_USER_ERROR_HASBEENADDED'] = "User '%1' has been successfully added"; +$content['LN_USER_ERROR_HASBEENEDIT'] = "User '%1' has been successfully edited"; +$content['LN_USER_ISADMIN'] = "Is Admin?"; +$content['LN_USER_ADDEDIT'] = "Add/Edit User"; +$content['LN_USER_WARNREMOVEADMIN'] = "You are about to revoke your own administrative priviledges. Are you sure to remove your admin status?"; +$content['LN_USER_WARNDELETEUSER'] = "Are you sure that you want to delete the User '%1'? All his personal settings will be deleted as well."; +$content['LN_USER_ERROR_INVALIDSESSIONS'] = "Invalid User Session."; +$content['LN_USER_'] = ""; + +// Group center +$content['LN_GROUP_CENTER'] = "Group Center"; +$content['LN_GROUP_ID'] = "ID"; +$content['LN_GROUP_NAME'] = "Groupname"; +$content['LN_GROUP_DESCRIPTION'] = "Groupdescription"; +$content['LN_GROUP_TYPE'] = "Grouptype"; +$content['LN_GROUP_ADD'] = "Add Group"; +$content['LN_GROUP_EDIT'] = "Edit Group"; +$content['LN_GROUP_DELETE'] = "Delete Group"; +$content['LN_GROUP_NOGROUPS'] = "No groups have been added yet"; +$content['LN_GROUP_ADDEDIT'] = "Add/Edit Group"; +$content['LN_GROUP_ERROR_GROUPEMPTY'] = "The groupname cannot be empty."; +$content['LN_GROUP_ERROR_GROUPNAMETAKEN'] = "The groupname has already been taken."; +$content['LN_GROUP_HASBEENADDED'] = "The group '%1' has been successfully added."; +$content['LN_GROUP_ERROR_IDNOTFOUND'] = "The group with ID '%1' could not be found."; +$content['LN_GROUP_ERROR_HASBEENEDIT'] = "The group '%1' has been successfully edited."; +$content['LN_GROUP_ERROR_INVALIDGROUP'] = "Error, invalid ID, Group not found"; +$content['LN_GROUP_WARNDELETEGROUP'] = "Are you sure that you want to delete the Group '%1'? All Groupsettings will be deleted as well."; +$content['LN_GROUP_ERROR_DELGROUP'] = "Deleting of the group with id '%1' failed!"; +$content['LN_GROUP_ERROR_HASBEENDEL'] = "The Group '%1' has been successfully deleted!"; +$content['LN_GROUP_MEMBERS'] = "Groupmembers: "; +$content['LN_GROUP_ADDUSER'] = "Add User to Group"; +$content['LN_GROUP_ERROR_USERIDMISSING'] = "The userid is missing."; +$content['LN_GROUP_USERHASBEENADDEDGROUP'] = "The User '%1' has been successfully added to group '%2'"; +$content['LN_GROUP_ERRORNOMOREUSERS'] = "There are no more available users who can be added to the group '%1'"; +$content['LN_GROUP_USER_ADD'] = "Add User to the group"; +$content['LN_GROUP_USERDELETE'] = "Remove a User from the group"; +$content['LN_GROUP_ERRORNOUSERSINGROUP'] = "There are no users to remove in this the group '%1'"; +$content['LN_GROUP_ERROR_REMUSERFROMGROUP'] = "The user '%1' could not be removed from the group '%2'"; +$content['LN_GROUP_USERHASBEENREMOVED'] = "The user '%1' has been successfully removed from the group '%2'"; +$content['LN_GROUP_'] = ""; + +// Custom Searches center +$content['LN_SEARCH_CENTER'] = "Custom Searches"; +$content['LN_SEARCH_ADD'] = "Add new Custom Search"; +$content['LN_SEARCH_ID'] = "ID"; +$content['LN_SEARCH_NAME'] = "Search Name"; +$content['LN_SEARCH_QUERY'] = "Search Query"; +$content['LN_SEARCH_TYPE'] = "Assigned to"; +$content['LN_SEARCH_EDIT'] = "Edit Custom Search"; +$content['LN_SEARCH_DELETE'] = "Delete Custom Search"; +$content['LN_SEARCH_ADDEDIT'] = "Add / Edit a Custom Search"; +$content['LN_SEARCH_SELGROUPENABLE'] = ">> Select Group to enable <<"; +$content['LN_SEARCH_ERROR_DISPLAYNAMEEMPTY'] = "The DisplayName cannot be empty."; +$content['LN_SEARCH_ERROR_SEARCHQUERYEMPTY'] = "The SearchQuery cannot be empty."; +$content['LN_SEARCH_HASBEENADDED'] = "The Custom Search '%1' has been successfully added."; +$content['LN_SEARCH_ERROR_IDNOTFOUND'] = "Could not find a search with ID '%1'."; +$content['LN_SEARCH_ERROR_INVALIDID'] = "Invalid search ID."; +$content['LN_SEARCH_HASBEENEDIT'] = "The Custom Search '%1' has been successfully edited."; +$content['LN_SEARCH_WARNDELETESEARCH'] = "Are you sure that you want to delete the Custom Search '%1'? This cannot be undone!"; +$content['LN_SEARCH_ERROR_DELSEARCH'] = "Deleting of the Custom Search with id '%1' failed!"; +$content['LN_SEARCH_ERROR_HASBEENDEL'] = "The Custom Search '%1' has been successfully deleted!"; +$content['LN_SEARCH_'] = ""; + +// Custom Searches center +$content['LN_VIEWS_CENTER'] = "Views Options"; +$content['LN_VIEWS_ID'] = "ID"; +$content['LN_VIEWS_NAME'] = "View Name"; +$content['LN_VIEWS_COLUMNS'] = "View Columns"; +$content['LN_VIEWS_TYPE'] = "Assigned to"; +$content['LN_VIEWS_ADD'] = "Add new View"; +$content['LN_VIEWS_EDIT'] = "Edit View"; +$content['LN_VIEWS_ERROR_IDNOTFOUND'] = "A View with ID '%1' could not be found."; +$content['LN_VIEWS_ERROR_INVALIDID'] = "The View with ID '%1' is not a valid View."; +$content['LN_VIEWS_WARNDELETEVIEW'] = "Are you sure that you want to delete the View '%1'? This cannot be undone!"; +$content['LN_VIEWS_ERROR_DELSEARCH'] = "Deleting of the View with id '%1' failed!"; +$content['LN_VIEWS_ERROR_HASBEENDEL'] = "The View '%1' has been successfully deleted!"; +$content['LN_VIEWS_ADDEDIT'] = "Add / Edit a View"; +$content['LN_VIEWS_COLUMNLIST'] = "Configured Columns"; +$content['LN_VIEWS_ADDCOLUMN'] = "Add Column into list"; +$content['LN_VIEWS_ERROR_DISPLAYNAMEEMPTY'] = "The DisplayName cannot be empty."; +$content['LN_VIEWS_COLUMN'] = "Column"; +$content['LN_VIEWS_COLUMN_REMOVE'] = "Remove Column"; +$content['LN_VIEWS_HASBEENADDED'] = "The Custom View '%1' has been successfully added."; +$content['LN_VIEWS_ERROR_NOCOLUMNS'] = "You need to add at least one column in order to add a new Custom View."; +$content['LN_VIEWS_HASBEENEDIT'] = "The Custom Search '%1' has been successfully edited."; +$content['LN_VIEWS_'] = ""; + +$content['LN_SOURCES_CENTER'] = "Sources Options"; +$content['LN_SOURCES_EDIT'] = "Edit Source"; +$content['LN_SOURCES_DELETE'] = "Delete Source"; +$content['LN_SOURCES_ID'] = "ID"; +$content['LN_SOURCES_NAME'] = "Source Name"; +$content['LN_SOURCES_TYPE'] = "Source Type"; +$content['LN_SOURCES_ASSIGNTO'] = "Assigned To"; +$content['LN_SOURCES_DISK'] = "Diskfile"; +$content['LN_SOURCES_DB'] = "MySQL Database"; +$content['LN_SOURCES_PDO'] = "PDO Datasource"; +$content['LN_SOURCES_ADD'] = "Add new Source"; +$content['LN_SOURCES_ADDEDIT'] = "Add / Edit a Source"; +$content['LN_SOURCES_TYPE'] = "Source Type"; +$content['LN_SOURCES_DISKTYPEOPTIONS'] = "Diskfile related Options"; +$content['LN_SOURCES_ERROR_MISSINGPARAM'] = "The paramater '%1' is missing."; +$content['LN_SOURCES_ERROR_NOTAVALIDFILE'] = "Failed to open the syslog file '%1'! Check if the file exists and phplogcon has sufficient rights to it"; +$content['LN_SOURCES_ERROR_UNKNOWNSOURCE'] = "Unknown Source '%1' detected"; +$content['LN_SOURCE_HASBEENADDED'] = "The new Source '%1' has been successfully added."; +$content['LN_SOURCES_EDIT'] = "Edit Source"; +$content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID'] = "The Source-ID is invalid or could not be found."; +$content['LN_SOURCES_ERROR_IDNOTFOUND'] = "The Source-ID could not be found in the database."; +$content['LN_SOURCES_HASBEENEDIT'] = "The Source '%1' has been successfully edited."; +$content['LN_SOURCES_WARNDELETESEARCH'] = "Are you sure that you want to delete the Source '%1'? This cannot be undone!"; +$content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' failed!"; +$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!"; +$content['LN_SOURCES_'] = ""; + + +?> \ No newline at end of file diff --git a/src/lang/de/main.php b/src/lang/de/main.php index 1f9ed04..50ed8bb 100644 --- a/src/lang/de/main.php +++ b/src/lang/de/main.php @@ -56,6 +56,7 @@ $content['LN_GEN_SOURCE_DB'] = "Datenbank"; $content['LN_GEN_DB_INFORMIX'] = "IBM Informix Dynamic Server"; $content['LN_GEN_DB_SQLITE'] = "SQLite 2"; $content['LN_GEN_SELECTVIEW'] = "Select View"; + $content['LN_GEN_CRITERROR_UNKNOWNTYPE'] = "The source type '%1' is not supported by phpLogCon yet. This is a critical error, please fix your configuration."; // Topmenu Entries $content['LN_MENU_SEARCH'] = "Suchen"; @@ -172,4 +173,77 @@ $content['LN_DETAIL_BACKTOLIST'] = "Back to Listview"; $content['LN_LOGIN_ERRWRONGPASSWORD'] = "Wrong username or password!"; $content['LN_LOGIN_USERPASSMISSING'] = "Username or password not given"; + // Install Site + $content['LN_INSTALL_TITLETOP'] = "Installing phpLogCon Version %1 - Step %2"; + $content['LN_INSTALL_TITLE'] = "Installer Step %1"; + $content['LN_INSTALL_ERRORINSTALLED'] = 'phpLogCon is already configured!

If you want to reconfigure phpLogCon, either delete the current config.php or replace it with an empty file.

Click here to return to pgpLogCon start page.'; + $content['LN_INSTALL_FILEORDIRNOTWRITEABLE'] = "At least one file or directory (or more) is not writeable, please check the file permissions (chmod 666)!"; + $content['LN_INSTALL_SAMPLECONFIGMISSING'] = "The sample configuration file '%1' is missing. You have not fully uploaded phplogcon."; + $content['LN_INSTALL_ERRORCONNECTFAILED'] = "Database connect to '%1' failed! Please check Servername, Port, User and Password!"; + $content['LN_INSTALL_ERRORACCESSDENIED'] = "Cannot use the database '%1'! If the database does not exists, create it or check user access permissions!"; + $content['LN_INSTALL_ERRORINVALIDDBFILE'] = "Error, invalid Database definition file (to short!), the file name is '%1'! Please check if the file was correctly uploaded."; + $content['LN_INSTALL_ERRORINSQLCOMMANDS'] = "Error, invalid Database definition file (no sql statements found!), the file name is '%1'!
Please check if the file was not correctly uploaded, or contact the phpLogCon forums for assistance!"; + $content['LN_INSTALL_MISSINGUSERNAME'] = "Username needs to be specified"; + $content['LN_INSTALL_PASSWORDNOTMATCH'] = "Either the password does not match or is to short!"; + $content['LN_INSTALL_FAILEDTOOPENSYSLOGFILE'] = "Failed to open the syslog file '%1'! Check if the file exists and phplogcon has sufficient rights to it
"; + $content['LN_INSTALL_FAILEDCREATECFGFILE'] = "Coult not create the configuration file in '%1'! Please verify the file permissions!"; + $content['LN_INSTALL_FAILEDREADINGFILE'] = "Error reading the file '%1'! Please verify if the file exists!"; + $content['LN_INSTALL_ERRORREADINGDBFILE'] = "Error reading the default database definition file in '%1'! Please verify if the file exists!"; + $content['LN_INSTALL_STEP1'] = "Step 1 - Prerequisites"; + $content['LN_INSTALL_STEP2'] = "Step 2 - Verify File Permissions"; + $content['LN_INSTALL_STEP3'] = "Step 3 - Basic Configuration"; + $content['LN_INSTALL_STEP4'] = "Step 4 - Create Tables"; + $content['LN_INSTALL_STEP5'] = "Step 5 - Check SQL Results"; + $content['LN_INSTALL_STEP6'] = "Step 6 - Creating the Main Useraccount"; + $content['LN_INSTALL_STEP7'] = "Step 7 - Create the first source for syslog messages"; + $content['LN_INSTALL_STEP8'] = "Step 8 - Done"; + $content['LN_INSTALL_STEP1_TEXT'] = 'Before you start installing phpLogCon, the Installer setup has to check a few things first.
You may have to correct some file permissions first.

Click on to start the Test!'; + $content['LN_INSTALL_STEP2_TEXT'] = "The following file permissions have been checked. Verify the results below!
You may use the configure.sh script from the contrib folder to set the permissions for you."; + $content['LN_INSTALL_STEP3_TEXT'] = "In this step, you configure the basic configurations for phpLogCon."; + $content['LN_INSTALL_STEP4_TEXT'] = 'If you reached this step, the database connection has been successfully verified!

The next step will be to create the necessary database tables used by the phpLogCon User System. This might take a while!
WARNING, if you have an existing phpLogCon installation in this database with the same tableprefix, all your data will be OVERWRITTEN! Make sure you are using a fresh database, or you want to overwrite your old phpLogCon database.

Click on to start the creation of the tables'; + $content['LN_INSTALL_STEP5_TEXT'] = "Tables have been created. Check the List below for possible Error's"; + $content['LN_INSTALL_STEP6_TEXT'] = "You are now about to create the initial phpLogCon User Account.
This will be the first administrative user, which will be needed to login into phpLogCon and access the Admin Center!"; + $content['LN_INSTALL_STEP8_TEXT'] = 'Congratulations! You have successfully installed phpLogCon :)!

Click here to go to your installation.'; + $content['LN_INSTALL_PROGRESS'] = "Install Progress: "; + $content['LN_INSTALL_FRONTEND'] = "Frontend Options"; + $content['LN_INSTALL_NUMOFSYSLOGS'] = "Number of syslog messages per page"; + $content['LN_INSTALL_MSGCHARLIMIT'] = "Message character limit for the main view"; + $content['LN_INSTALL_SHOWDETAILPOP'] = "Show message details popup"; + $content['LN_INSTALL_AUTORESOLVIP'] = "Automatically resolved IP Addresses (inline)"; + $content['LN_INSTALL_USERDBOPTIONS'] = "User Database Options"; + $content['LN_INSTALL_ENABLEUSERDB'] = "Enable User Database"; + $content['LN_INSTALL_SUCCESSSTATEMENTS'] = "Successfully executed statements:"; + $content['LN_INSTALL_FAILEDSTATEMENTS'] = "Failed statements:"; + $content['LN_INSTALL_STEP5_TEXT_NEXT'] = "You can now proceed to the next step adding the first phpLogCon Admin User!"; + $content['LN_INSTALL_STEP5_TEXT_FAILED'] = "At least one statement failed,see error reasons below"; + $content['LN_INSTALL_ERRORMSG'] = "Error Message"; + $content['LN_INSTALL_SQLSTATEMENT'] = "SQL Statement"; + $content['LN_INSTALL_CREATEUSER'] = "Create User Account"; + $content['LN_INSTALL_PASSWORD'] = "Password"; + $content['LN_INSTALL_PASSWORDREPEAT'] = "Repeat Password"; + $content['LN_INSTALL_SUCCESSCREATED'] = "Successfully created User"; + $content['LN_INSTALL_RECHECK'] = "ReCheck"; + $content['LN_INSTALL_FINISH'] = "Finish!"; + $content['LN_INSTALL_'] = ""; + + // Converter Site + $content['LN_CONVERT_TITLE'] = "Configuration Converter Step %1"; + $content['LN_CONVERT_NOTALLOWED'] = "Login"; + $content['LN_CONVERT_ERRORINSTALLED'] = 'phpLogCon is not allowed to convert your settings into the user database.

If you want to convert your convert your settings, add the variable following into your config.php:
$CFG[\'UserDBConvertAllowed\'] = true;

Click here to return to pgpLogCon start page.'; + $content['LN_CONVERT_STEP1'] = "Step 1 - Informations"; + $content['LN_CONVERT_STEP2'] = "Step 2 - Create Tables"; + $content['LN_CONVERT_STEP3'] = "Step 3 - Check SQL Results"; + $content['LN_CONVERT_STEP4'] = "Step 4 - Creating the Main Useraccount"; + $content['LN_CONVERT_STEP5'] = "Step 5 - Import Settings into UserDB"; + $content['LN_CONVERT_TITLETOP'] = "Converting phpLogCon configuration settings - Step "; + $content['LN_CONVERT_STEP1_TEXT'] = 'This script allows you to import your existing configuration from the config.php file. This includes frontend settings, data sources, custom views and custom searches. Do only perform this conversion if you did install phpLogCon without the UserDB System, and decided to enable it now.

ANY EXISTING INSTANCE OF A USERDB WILL BE OVERWRITTEN!

to start the first conversion step!'; + $content['LN_CONVERT_STEP2_TEXT'] = 'The database connection has been successfully verified!

The next step will be to create the necessary database tables for the phpLogCon User System. This might take a while!
WARNING, if you have an existing phpLogCon installation in this database with the same tableprefix, all your data will be OVERWRITTEN!
Make sure you are using a fresh database, or you want to overwrite your old phpLogCon database.

Click on to start the creation of the tables'; + $content['LN_CONVERT_STEP5_TEXT'] = ' to start the last step of the conversion. In this step, your existing configuration from the config.php will be imported into the database.'; + $content['LN_CONVERT_STEP6'] = "Step 8 - Done"; + $content['LN_CONVERT_STEP6_TEXT'] = 'Congratulations! You have successfully converted your existing phpLogCon installation :)!

Important! Don\'t forget to REMOVE THE VARIABLES $CFG[\'UserDBConvertAllowed\'] = true; from your config.php file!

You can click here to get to your phpLogConinstallation.'; + $content['LN_CONVERT_PROCESS'] = "Conversion Progress:"; + $content['LN_CONVERT_ERROR_SOURCEIMPORT'] = "Critical Error while importing the sources into the database, the SourceType '%1' is not supported by this phpLogCon Version."; + $content['LN_CONVERT_'] = ""; + $content['LN_CONVERT_'] = ""; + $content['LN_CONVERT_'] = ""; ?> \ No newline at end of file diff --git a/src/lang/en/admin.php b/src/lang/en/admin.php index 364021f..a3391a6 100644 --- a/src/lang/en/admin.php +++ b/src/lang/en/admin.php @@ -155,7 +155,6 @@ $content['LN_SEARCH_WARNDELETESEARCH'] = "Are you sure that you want to delete t $content['LN_SEARCH_ERROR_DELSEARCH'] = "Deleting of the Custom Search with id '%1' failed!"; $content['LN_SEARCH_ERROR_HASBEENDEL'] = "The Custom Search '%1' has been successfully deleted!"; $content['LN_SEARCH_'] = ""; -$content['LN_SEARCH_'] = ""; // Custom Searches center $content['LN_VIEWS_CENTER'] = "Views Options"; @@ -180,7 +179,6 @@ $content['LN_VIEWS_HASBEENADDED'] = "The Custom View '%1' has been successfully $content['LN_VIEWS_ERROR_NOCOLUMNS'] = "You need to add at least one column in order to add a new Custom View."; $content['LN_VIEWS_HASBEENEDIT'] = "The Custom Search '%1' has been successfully edited."; $content['LN_VIEWS_'] = ""; -$content['LN_VIEWS_'] = ""; $content['LN_SOURCES_CENTER'] = "Sources Options"; $content['LN_SOURCES_EDIT'] = "Edit Source"; @@ -208,7 +206,6 @@ $content['LN_SOURCES_WARNDELETESEARCH'] = "Are you sure that you want to delete $content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' failed!"; $content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!"; $content['LN_SOURCES_'] = ""; -$content['LN_SOURCES_'] = ""; ?> \ No newline at end of file diff --git a/src/lang/pt_BR/admin.php b/src/lang/pt_BR/admin.php new file mode 100644 index 0000000..a3391a6 --- /dev/null +++ b/src/lang/pt_BR/admin.php @@ -0,0 +1,211 @@ + www.phplogcon.org <- + * ----------------------------------------------------------------- + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution. + ********************************************************************* +*/ +global $content; + +// Global Stuff +$content['LN_ADMINMENU_HOMEPAGE'] = "Back to Show Events"; +$content['LN_ADMINMENU_GENOPT'] = "General Options"; +$content['LN_ADMINMENU_SOURCEOPT'] = "Sources Options"; +$content['LN_ADMINMENU_VIEWSOPT'] = "Views Options"; +$content['LN_ADMINMENU_SEARCHOPT'] = "Search Options"; +$content['LN_ADMINMENU_USEROPT'] = "User Options"; +$content['LN_ADMINMENU_GROUPOPT'] = "Group Options"; +$content['LN_ADMIN_CENTER'] = "Admin center"; +$content['LN_ADMIN_UNKNOWNSTATE'] = "Unknown State"; +$content['LN_ADMIN_ERROR_NOTALLOWED'] = "You are not allowed to access this page with your user level."; +$content['LN_DELETEYES'] = "Yes"; +$content['LN_DELETENO'] = "No"; +$content['LN_GEN_ACTIONS'] = "Available Actions"; +$content['LN_ADMIN_SEND'] = "Send changes"; +$content['LN_GEN_USERONLY'] = "User only"; +$content['LN_GEN_GROUPONLY'] = "Group only"; +$content['LN_GEN_GLOBAL'] = "Global"; +$content['LN_GEN_USERONLY_LONG'] = "For me only
(Only available to your user)"; +$content['LN_GEN_GROUPONLY_LONG'] = "For this group
(Only available to the selected group)"; +$content['LN_GEN_GROUPONLYNAME'] = "Group '%1'"; + + +// General Options +$content['LN_ADMIN_GLOBFRONTEND'] = "Global frontend options"; +$content['LN_ADMIN_USERFRONTEND'] = "User specific frontend options"; +$content['LN_ADMIN_MISC'] = "Miscellaneous Options"; +$content['LN_GEN_SHOWDEBUGMSG'] = "Show Debug messages"; +$content['LN_GEN_DEBUGGRIDCOUNTER'] = "Show Debug Gridcounter"; +$content['LN_GEN_SHOWPAGERENDERSTATS'] = "Show Pagerenderstats"; +$content['LN_GEN_ENABLEGZIP'] = "Enable GZIP Compressed Output"; +$content['LN_GEN_DEBUGUSERLOGIN'] = "Debug Userlogin"; +$content['LN_GEN_WEBSTYLE'] = "Default selected style"; +$content['LN_GEN_SELLANGUAGE'] = "Default selected language"; +$content['LN_GEN_PREPENDTITLE'] = "Prepend this string in title"; +$content['LN_GEN_USETODAY'] = "Use Today and Yesterday in timefields"; +$content['LN_GEN_DETAILPOPUPS'] = "Use Popup to display the full messagedetails"; +$content['LN_GEN_MSGCHARLIMIT'] = "Character limit of the message in main view"; +$content['LN_GEN_ENTRIESPERPAGE'] = "Number of entries per page"; +$content['LN_GEN_AUTORELOADSECONDS'] = "Enable autoreload after seconds"; +$content['LN_GEN_IPADRRESOLVE'] = "Resolve IP Addresses using DNS"; +$content['LN_GEN_CUSTBTNCAPT'] = "Custom search caption"; +$content['LN_GEN_CUSTBTNSRCH'] = "Custom search string"; +$content['LN_GEN_SUCCESSFULLYSAVED'] = "The configuration Values have been successfully saved"; +$content['LN_GEN_INTERNAL'] = "Internal"; +$content['LN_GEN_DISABLED'] = "Function disabled"; +$content['LN_GEN_CONFIGFILE'] = "Configuration File"; +$content['LN_GEN_ACCESSDENIED'] = "Access denied to this function"; + +// User Center +$content['LN_USER_CENTER'] = "User Options"; +$content['LN_USER_ID'] = "ID"; +$content['LN_USER_NAME'] = "Username"; +$content['LN_USER_ADD'] = "Add User"; +$content['LN_USER_EDIT'] = "Edit User"; +$content['LN_USER_DELETE'] = "Delete User"; +$content['LN_USER_PASSWORD1'] = "Password"; +$content['LN_USER_PASSWORD2'] = "Confirm Password"; +$content['LN_USER_ERROR_IDNOTFOUND'] = "Error, User with ID '%1' , was not found"; +$content['LN_USER_ERROR_DONOTDELURSLF'] = "Error, you can not DELETE YOURSELF!"; +$content['LN_USER_ERROR_DELUSER'] = "Deleting of the user with id '%1' failed!"; +$content['LN_USER_ERROR_INVALIDID'] = "Error, invalid ID, User not found"; +$content['LN_USER_ERROR_HASBEENDEL'] = "The User '%1' has been successfully deleted!"; +$content['LN_USER_ERROR_USEREMPTY'] = "Error, Username was empty"; +$content['LN_USER_ERROR_USERNAMETAKEN'] = "Error, this Username is already taken!"; +$content['LN_USER_ERROR_PASSSHORT'] = "Error, Password was to short, or did not match"; +$content['LN_USER_ERROR_HASBEENADDED'] = "User '%1' has been successfully added"; +$content['LN_USER_ERROR_HASBEENEDIT'] = "User '%1' has been successfully edited"; +$content['LN_USER_ISADMIN'] = "Is Admin?"; +$content['LN_USER_ADDEDIT'] = "Add/Edit User"; +$content['LN_USER_WARNREMOVEADMIN'] = "You are about to revoke your own administrative priviledges. Are you sure to remove your admin status?"; +$content['LN_USER_WARNDELETEUSER'] = "Are you sure that you want to delete the User '%1'? All his personal settings will be deleted as well."; +$content['LN_USER_ERROR_INVALIDSESSIONS'] = "Invalid User Session."; +$content['LN_USER_'] = ""; + +// Group center +$content['LN_GROUP_CENTER'] = "Group Center"; +$content['LN_GROUP_ID'] = "ID"; +$content['LN_GROUP_NAME'] = "Groupname"; +$content['LN_GROUP_DESCRIPTION'] = "Groupdescription"; +$content['LN_GROUP_TYPE'] = "Grouptype"; +$content['LN_GROUP_ADD'] = "Add Group"; +$content['LN_GROUP_EDIT'] = "Edit Group"; +$content['LN_GROUP_DELETE'] = "Delete Group"; +$content['LN_GROUP_NOGROUPS'] = "No groups have been added yet"; +$content['LN_GROUP_ADDEDIT'] = "Add/Edit Group"; +$content['LN_GROUP_ERROR_GROUPEMPTY'] = "The groupname cannot be empty."; +$content['LN_GROUP_ERROR_GROUPNAMETAKEN'] = "The groupname has already been taken."; +$content['LN_GROUP_HASBEENADDED'] = "The group '%1' has been successfully added."; +$content['LN_GROUP_ERROR_IDNOTFOUND'] = "The group with ID '%1' could not be found."; +$content['LN_GROUP_ERROR_HASBEENEDIT'] = "The group '%1' has been successfully edited."; +$content['LN_GROUP_ERROR_INVALIDGROUP'] = "Error, invalid ID, Group not found"; +$content['LN_GROUP_WARNDELETEGROUP'] = "Are you sure that you want to delete the Group '%1'? All Groupsettings will be deleted as well."; +$content['LN_GROUP_ERROR_DELGROUP'] = "Deleting of the group with id '%1' failed!"; +$content['LN_GROUP_ERROR_HASBEENDEL'] = "The Group '%1' has been successfully deleted!"; +$content['LN_GROUP_MEMBERS'] = "Groupmembers: "; +$content['LN_GROUP_ADDUSER'] = "Add User to Group"; +$content['LN_GROUP_ERROR_USERIDMISSING'] = "The userid is missing."; +$content['LN_GROUP_USERHASBEENADDEDGROUP'] = "The User '%1' has been successfully added to group '%2'"; +$content['LN_GROUP_ERRORNOMOREUSERS'] = "There are no more available users who can be added to the group '%1'"; +$content['LN_GROUP_USER_ADD'] = "Add User to the group"; +$content['LN_GROUP_USERDELETE'] = "Remove a User from the group"; +$content['LN_GROUP_ERRORNOUSERSINGROUP'] = "There are no users to remove in this the group '%1'"; +$content['LN_GROUP_ERROR_REMUSERFROMGROUP'] = "The user '%1' could not be removed from the group '%2'"; +$content['LN_GROUP_USERHASBEENREMOVED'] = "The user '%1' has been successfully removed from the group '%2'"; +$content['LN_GROUP_'] = ""; + +// Custom Searches center +$content['LN_SEARCH_CENTER'] = "Custom Searches"; +$content['LN_SEARCH_ADD'] = "Add new Custom Search"; +$content['LN_SEARCH_ID'] = "ID"; +$content['LN_SEARCH_NAME'] = "Search Name"; +$content['LN_SEARCH_QUERY'] = "Search Query"; +$content['LN_SEARCH_TYPE'] = "Assigned to"; +$content['LN_SEARCH_EDIT'] = "Edit Custom Search"; +$content['LN_SEARCH_DELETE'] = "Delete Custom Search"; +$content['LN_SEARCH_ADDEDIT'] = "Add / Edit a Custom Search"; +$content['LN_SEARCH_SELGROUPENABLE'] = ">> Select Group to enable <<"; +$content['LN_SEARCH_ERROR_DISPLAYNAMEEMPTY'] = "The DisplayName cannot be empty."; +$content['LN_SEARCH_ERROR_SEARCHQUERYEMPTY'] = "The SearchQuery cannot be empty."; +$content['LN_SEARCH_HASBEENADDED'] = "The Custom Search '%1' has been successfully added."; +$content['LN_SEARCH_ERROR_IDNOTFOUND'] = "Could not find a search with ID '%1'."; +$content['LN_SEARCH_ERROR_INVALIDID'] = "Invalid search ID."; +$content['LN_SEARCH_HASBEENEDIT'] = "The Custom Search '%1' has been successfully edited."; +$content['LN_SEARCH_WARNDELETESEARCH'] = "Are you sure that you want to delete the Custom Search '%1'? This cannot be undone!"; +$content['LN_SEARCH_ERROR_DELSEARCH'] = "Deleting of the Custom Search with id '%1' failed!"; +$content['LN_SEARCH_ERROR_HASBEENDEL'] = "The Custom Search '%1' has been successfully deleted!"; +$content['LN_SEARCH_'] = ""; + +// Custom Searches center +$content['LN_VIEWS_CENTER'] = "Views Options"; +$content['LN_VIEWS_ID'] = "ID"; +$content['LN_VIEWS_NAME'] = "View Name"; +$content['LN_VIEWS_COLUMNS'] = "View Columns"; +$content['LN_VIEWS_TYPE'] = "Assigned to"; +$content['LN_VIEWS_ADD'] = "Add new View"; +$content['LN_VIEWS_EDIT'] = "Edit View"; +$content['LN_VIEWS_ERROR_IDNOTFOUND'] = "A View with ID '%1' could not be found."; +$content['LN_VIEWS_ERROR_INVALIDID'] = "The View with ID '%1' is not a valid View."; +$content['LN_VIEWS_WARNDELETEVIEW'] = "Are you sure that you want to delete the View '%1'? This cannot be undone!"; +$content['LN_VIEWS_ERROR_DELSEARCH'] = "Deleting of the View with id '%1' failed!"; +$content['LN_VIEWS_ERROR_HASBEENDEL'] = "The View '%1' has been successfully deleted!"; +$content['LN_VIEWS_ADDEDIT'] = "Add / Edit a View"; +$content['LN_VIEWS_COLUMNLIST'] = "Configured Columns"; +$content['LN_VIEWS_ADDCOLUMN'] = "Add Column into list"; +$content['LN_VIEWS_ERROR_DISPLAYNAMEEMPTY'] = "The DisplayName cannot be empty."; +$content['LN_VIEWS_COLUMN'] = "Column"; +$content['LN_VIEWS_COLUMN_REMOVE'] = "Remove Column"; +$content['LN_VIEWS_HASBEENADDED'] = "The Custom View '%1' has been successfully added."; +$content['LN_VIEWS_ERROR_NOCOLUMNS'] = "You need to add at least one column in order to add a new Custom View."; +$content['LN_VIEWS_HASBEENEDIT'] = "The Custom Search '%1' has been successfully edited."; +$content['LN_VIEWS_'] = ""; + +$content['LN_SOURCES_CENTER'] = "Sources Options"; +$content['LN_SOURCES_EDIT'] = "Edit Source"; +$content['LN_SOURCES_DELETE'] = "Delete Source"; +$content['LN_SOURCES_ID'] = "ID"; +$content['LN_SOURCES_NAME'] = "Source Name"; +$content['LN_SOURCES_TYPE'] = "Source Type"; +$content['LN_SOURCES_ASSIGNTO'] = "Assigned To"; +$content['LN_SOURCES_DISK'] = "Diskfile"; +$content['LN_SOURCES_DB'] = "MySQL Database"; +$content['LN_SOURCES_PDO'] = "PDO Datasource"; +$content['LN_SOURCES_ADD'] = "Add new Source"; +$content['LN_SOURCES_ADDEDIT'] = "Add / Edit a Source"; +$content['LN_SOURCES_TYPE'] = "Source Type"; +$content['LN_SOURCES_DISKTYPEOPTIONS'] = "Diskfile related Options"; +$content['LN_SOURCES_ERROR_MISSINGPARAM'] = "The paramater '%1' is missing."; +$content['LN_SOURCES_ERROR_NOTAVALIDFILE'] = "Failed to open the syslog file '%1'! Check if the file exists and phplogcon has sufficient rights to it"; +$content['LN_SOURCES_ERROR_UNKNOWNSOURCE'] = "Unknown Source '%1' detected"; +$content['LN_SOURCE_HASBEENADDED'] = "The new Source '%1' has been successfully added."; +$content['LN_SOURCES_EDIT'] = "Edit Source"; +$content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID'] = "The Source-ID is invalid or could not be found."; +$content['LN_SOURCES_ERROR_IDNOTFOUND'] = "The Source-ID could not be found in the database."; +$content['LN_SOURCES_HASBEENEDIT'] = "The Source '%1' has been successfully edited."; +$content['LN_SOURCES_WARNDELETESEARCH'] = "Are you sure that you want to delete the Source '%1'? This cannot be undone!"; +$content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' failed!"; +$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!"; +$content['LN_SOURCES_'] = ""; + + +?> \ No newline at end of file diff --git a/src/lang/pt_BR/main.php b/src/lang/pt_BR/main.php index 167efc3..0c869c3 100644 --- a/src/lang/pt_BR/main.php +++ b/src/lang/pt_BR/main.php @@ -61,6 +61,7 @@ $content['LN_GEN_DB_INFORMIX'] = "IBM Informix Dynamic Server"; $content['LN_GEN_DB_SQLITE'] = "SQLite 2"; $content['LN_GEN_SELECTVIEW'] = "Visão"; $content['LN_GEN_CRITERROR_UNKNOWNTYPE'] = "The source type '%1' is not supported by phpLogCon yet. This is a critical error, please fix your configuration."; + $content['LN_GEN_CRITERROR_UNKNOWNTYPE'] = "The source type '%1' is not supported by phpLogCon yet. This is a critical error, please fix your configuration."; // Topmenu Entries $content['LN_MENU_SEARCH'] = "Search"; @@ -177,4 +178,77 @@ $content['LN_DETAIL_BACKTOLIST'] = "Voltar para a lista"; $content['LN_LOGIN_ERRWRONGPASSWORD'] = "Wrong username or password!"; $content['LN_LOGIN_USERPASSMISSING'] = "Username or password not given"; + // Install Site + $content['LN_INSTALL_TITLETOP'] = "Installing phpLogCon Version %1 - Step %2"; + $content['LN_INSTALL_TITLE'] = "Installer Step %1"; + $content['LN_INSTALL_ERRORINSTALLED'] = 'phpLogCon is already configured!

If you want to reconfigure phpLogCon, either delete the current config.php or replace it with an empty file.

Click here to return to pgpLogCon start page.'; + $content['LN_INSTALL_FILEORDIRNOTWRITEABLE'] = "At least one file or directory (or more) is not writeable, please check the file permissions (chmod 666)!"; + $content['LN_INSTALL_SAMPLECONFIGMISSING'] = "The sample configuration file '%1' is missing. You have not fully uploaded phplogcon."; + $content['LN_INSTALL_ERRORCONNECTFAILED'] = "Database connect to '%1' failed! Please check Servername, Port, User and Password!"; + $content['LN_INSTALL_ERRORACCESSDENIED'] = "Cannot use the database '%1'! If the database does not exists, create it or check user access permissions!"; + $content['LN_INSTALL_ERRORINVALIDDBFILE'] = "Error, invalid Database definition file (to short!), the file name is '%1'! Please check if the file was correctly uploaded."; + $content['LN_INSTALL_ERRORINSQLCOMMANDS'] = "Error, invalid Database definition file (no sql statements found!), the file name is '%1'!
Please check if the file was not correctly uploaded, or contact the phpLogCon forums for assistance!"; + $content['LN_INSTALL_MISSINGUSERNAME'] = "Username needs to be specified"; + $content['LN_INSTALL_PASSWORDNOTMATCH'] = "Either the password does not match or is to short!"; + $content['LN_INSTALL_FAILEDTOOPENSYSLOGFILE'] = "Failed to open the syslog file '%1'! Check if the file exists and phplogcon has sufficient rights to it
"; + $content['LN_INSTALL_FAILEDCREATECFGFILE'] = "Coult not create the configuration file in '%1'! Please verify the file permissions!"; + $content['LN_INSTALL_FAILEDREADINGFILE'] = "Error reading the file '%1'! Please verify if the file exists!"; + $content['LN_INSTALL_ERRORREADINGDBFILE'] = "Error reading the default database definition file in '%1'! Please verify if the file exists!"; + $content['LN_INSTALL_STEP1'] = "Step 1 - Prerequisites"; + $content['LN_INSTALL_STEP2'] = "Step 2 - Verify File Permissions"; + $content['LN_INSTALL_STEP3'] = "Step 3 - Basic Configuration"; + $content['LN_INSTALL_STEP4'] = "Step 4 - Create Tables"; + $content['LN_INSTALL_STEP5'] = "Step 5 - Check SQL Results"; + $content['LN_INSTALL_STEP6'] = "Step 6 - Creating the Main Useraccount"; + $content['LN_INSTALL_STEP7'] = "Step 7 - Create the first source for syslog messages"; + $content['LN_INSTALL_STEP8'] = "Step 8 - Done"; + $content['LN_INSTALL_STEP1_TEXT'] = 'Before you start installing phpLogCon, the Installer setup has to check a few things first.
You may have to correct some file permissions first.

Click on to start the Test!'; + $content['LN_INSTALL_STEP2_TEXT'] = "The following file permissions have been checked. Verify the results below!
You may use the configure.sh script from the contrib folder to set the permissions for you."; + $content['LN_INSTALL_STEP3_TEXT'] = "In this step, you configure the basic configurations for phpLogCon."; + $content['LN_INSTALL_STEP4_TEXT'] = 'If you reached this step, the database connection has been successfully verified!

The next step will be to create the necessary database tables used by the phpLogCon User System. This might take a while!
WARNING, if you have an existing phpLogCon installation in this database with the same tableprefix, all your data will be OVERWRITTEN! Make sure you are using a fresh database, or you want to overwrite your old phpLogCon database.

Click on to start the creation of the tables'; + $content['LN_INSTALL_STEP5_TEXT'] = "Tables have been created. Check the List below for possible Error's"; + $content['LN_INSTALL_STEP6_TEXT'] = "You are now about to create the initial phpLogCon User Account.
This will be the first administrative user, which will be needed to login into phpLogCon and access the Admin Center!"; + $content['LN_INSTALL_STEP8_TEXT'] = 'Congratulations! You have successfully installed phpLogCon :)!

Click here to go to your installation.'; + $content['LN_INSTALL_PROGRESS'] = "Install Progress: "; + $content['LN_INSTALL_FRONTEND'] = "Frontend Options"; + $content['LN_INSTALL_NUMOFSYSLOGS'] = "Number of syslog messages per page"; + $content['LN_INSTALL_MSGCHARLIMIT'] = "Message character limit for the main view"; + $content['LN_INSTALL_SHOWDETAILPOP'] = "Show message details popup"; + $content['LN_INSTALL_AUTORESOLVIP'] = "Automatically resolved IP Addresses (inline)"; + $content['LN_INSTALL_USERDBOPTIONS'] = "User Database Options"; + $content['LN_INSTALL_ENABLEUSERDB'] = "Enable User Database"; + $content['LN_INSTALL_SUCCESSSTATEMENTS'] = "Successfully executed statements:"; + $content['LN_INSTALL_FAILEDSTATEMENTS'] = "Failed statements:"; + $content['LN_INSTALL_STEP5_TEXT_NEXT'] = "You can now proceed to the next step adding the first phpLogCon Admin User!"; + $content['LN_INSTALL_STEP5_TEXT_FAILED'] = "At least one statement failed,see error reasons below"; + $content['LN_INSTALL_ERRORMSG'] = "Error Message"; + $content['LN_INSTALL_SQLSTATEMENT'] = "SQL Statement"; + $content['LN_INSTALL_CREATEUSER'] = "Create User Account"; + $content['LN_INSTALL_PASSWORD'] = "Password"; + $content['LN_INSTALL_PASSWORDREPEAT'] = "Repeat Password"; + $content['LN_INSTALL_SUCCESSCREATED'] = "Successfully created User"; + $content['LN_INSTALL_RECHECK'] = "ReCheck"; + $content['LN_INSTALL_FINISH'] = "Finish!"; + $content['LN_INSTALL_'] = ""; + + // Converter Site + $content['LN_CONVERT_TITLE'] = "Configuration Converter Step %1"; + $content['LN_CONVERT_NOTALLOWED'] = "Login"; + $content['LN_CONVERT_ERRORINSTALLED'] = 'phpLogCon is not allowed to convert your settings into the user database.

If you want to convert your convert your settings, add the variable following into your config.php:
$CFG[\'UserDBConvertAllowed\'] = true;

Click here to return to pgpLogCon start page.'; + $content['LN_CONVERT_STEP1'] = "Step 1 - Informations"; + $content['LN_CONVERT_STEP2'] = "Step 2 - Create Tables"; + $content['LN_CONVERT_STEP3'] = "Step 3 - Check SQL Results"; + $content['LN_CONVERT_STEP4'] = "Step 4 - Creating the Main Useraccount"; + $content['LN_CONVERT_STEP5'] = "Step 5 - Import Settings into UserDB"; + $content['LN_CONVERT_TITLETOP'] = "Converting phpLogCon configuration settings - Step "; + $content['LN_CONVERT_STEP1_TEXT'] = 'This script allows you to import your existing configuration from the config.php file. This includes frontend settings, data sources, custom views and custom searches. Do only perform this conversion if you did install phpLogCon without the UserDB System, and decided to enable it now.

ANY EXISTING INSTANCE OF A USERDB WILL BE OVERWRITTEN!

to start the first conversion step!'; + $content['LN_CONVERT_STEP2_TEXT'] = 'The database connection has been successfully verified!

The next step will be to create the necessary database tables for the phpLogCon User System. This might take a while!
WARNING, if you have an existing phpLogCon installation in this database with the same tableprefix, all your data will be OVERWRITTEN!
Make sure you are using a fresh database, or you want to overwrite your old phpLogCon database.

Click on to start the creation of the tables'; + $content['LN_CONVERT_STEP5_TEXT'] = ' to start the last step of the conversion. In this step, your existing configuration from the config.php will be imported into the database.'; + $content['LN_CONVERT_STEP6'] = "Step 8 - Done"; + $content['LN_CONVERT_STEP6_TEXT'] = 'Congratulations! You have successfully converted your existing phpLogCon installation :)!

Important! Don\'t forget to REMOVE THE VARIABLES $CFG[\'UserDBConvertAllowed\'] = true; from your config.php file!

You can click here to get to your phpLogConinstallation.'; + $content['LN_CONVERT_PROCESS'] = "Conversion Progress:"; + $content['LN_CONVERT_ERROR_SOURCEIMPORT'] = "Critical Error while importing the sources into the database, the SourceType '%1' is not supported by this phpLogCon Version."; + $content['LN_CONVERT_'] = ""; + $content['LN_CONVERT_'] = ""; + $content['LN_CONVERT_'] = ""; ?> \ No newline at end of file diff --git a/src/login.php b/src/login.php index 81b811b..75180b1 100644 --- a/src/login.php +++ b/src/login.php @@ -1,111 +1,111 @@ - File to login users in PhpLogCon - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$gl_root_path = './'; - -// Now include necessary include files! -include($gl_root_path . 'include/functions_common.php'); -include($gl_root_path . 'include/functions_frontendhelpers.php'); -//include($gl_root_path . 'include/functions_filters.php'); - -// To avoid infinite redirects! -define('IS_NOLOGINPAGE', true); -$content['IS_NOLOGINPAGE'] = true; -InitPhpLogCon(); -// --- // - -// --- BEGIN Custom Code - -// Set Defaults -$content['uname'] = ""; -$content['pass'] = ""; - -// Set Referer -if ( isset($_GET['referer']) ) - $szRedir = $_GET['referer']; -else if ( isset($_POST['referer']) ) - $szRedir = $_POST['referer']; -else - $szRedir = "index.php"; // Default - -if ( isset($_POST['op']) && $_POST['op'] == "login" ) -{ - // Perform login! - if ( $_POST['op'] == "login" ) - { - if ( - (isset($_POST['uname']) && strlen($_POST['uname']) > 0) - && - (isset($_POST['pass']) && strlen($_POST['pass']) > 0) - ) - { - // Set Username and password - $content['uname'] = DB_RemoveBadChars($_POST['uname']); - $content['pass'] = DB_RemoveBadChars($_POST['pass']); - - if ( !CheckUserLogin( $content['uname'], $content['pass']) ) - { - $content['ISERROR'] = "true"; - $content['ERROR_MSG'] = $content['LN_LOGIN_ERRWRONGPASSWORD']; - } - else - RedirectPage( urldecode($szRedir) ); - } - else - { - $content['ISERROR'] = "true"; - $content['ERROR_MSG'] = $content['LN_LOGIN_USERPASSMISSING']; - } - } -} -else if ( isset($_GET['op']) && $_GET['op'] == "logoff" ) -{ - // logoff in this case - DoLogOff(); -} -// --- END Custom Code - -// --- CONTENT Vars -$content['REDIR_LOGIN'] = $szRedir; -$content['TITLE'] = "phpLogCon - User Login"; // Title of the Page -// --- - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "login.html"); -$page -> output(); -// --- - + File to login users in PhpLogCon + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './'; + +// Now include necessary include files! +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); +//include($gl_root_path . 'include/functions_filters.php'); + +// To avoid infinite redirects! +define('IS_NOLOGINPAGE', true); +$content['IS_NOLOGINPAGE'] = true; +InitPhpLogCon(); +// --- // + +// --- BEGIN Custom Code + +// Set Defaults +$content['uname'] = ""; +$content['pass'] = ""; + +// Set Referer +if ( isset($_GET['referer']) ) + $szRedir = $_GET['referer']; +else if ( isset($_POST['referer']) ) + $szRedir = $_POST['referer']; +else + $szRedir = "index.php"; // Default + +if ( isset($_POST['op']) && $_POST['op'] == "login" ) +{ + // Perform login! + if ( $_POST['op'] == "login" ) + { + if ( + (isset($_POST['uname']) && strlen($_POST['uname']) > 0) + && + (isset($_POST['pass']) && strlen($_POST['pass']) > 0) + ) + { + // Set Username and password + $content['uname'] = DB_RemoveBadChars($_POST['uname']); + $content['pass'] = DB_RemoveBadChars($_POST['pass']); + + if ( !CheckUserLogin( $content['uname'], $content['pass']) ) + { + $content['ISERROR'] = "true"; + $content['ERROR_MSG'] = $content['LN_LOGIN_ERRWRONGPASSWORD']; + } + else + RedirectPage( urldecode($szRedir) ); + } + else + { + $content['ISERROR'] = "true"; + $content['ERROR_MSG'] = $content['LN_LOGIN_USERPASSMISSING']; + } + } +} +else if ( isset($_GET['op']) && $_GET['op'] == "logoff" ) +{ + // logoff in this case + DoLogOff(); +} +// --- END Custom Code + +// --- CONTENT Vars +$content['REDIR_LOGIN'] = $szRedir; +$content['TITLE'] = "phpLogCon - User Login"; // Title of the Page +// --- + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "login.html"); +$page -> output(); +// --- + ?> \ No newline at end of file