diff --git a/.actions/portal_actions.php b/.actions/portal_actions.php index 5cf241b..65271e9 100644 --- a/.actions/portal_actions.php +++ b/.actions/portal_actions.php @@ -1,100 +1,98 @@ query('SELECT * FROM ' . TBL_USER . ' WHERE userUsername = "' . $_POST['userName'] . '" AND userPasswordCrypt = "' . md5($_POST['passWord']) . '" AND userDelete = "N";'); + if ($result->num_rows === 0) + { + /* Fehlerhafte Benutzeranmeldung */ + $arrError[] = 'login_001'; + fnc_writeLog('00000001', array($_SERVER['REMOTE_ADDR'], $_POST['userName']), 0); + } + else + { + $dat_user = $result->fetch_assoc(); + if ($dat_user['userActive'] === 'N') { - /* Nur nicht gelöschte Benutzer */ - $result = $db -> query ( 'SELECT * FROM ' . TBL_USER . ' WHERE userUsername = "' . $_POST[ 'userName' ] . '" AND userPasswordCrypt = "' . md5 ( $_POST[ 'passWord' ] ) . '" AND userDelete = "N";' ); - if ( $result -> num_rows === 0 ) - { - /* Fehlerhafte Benutzeranmeldung */ - $arrError[ ] = 'login_001'; - fnc_writeLog ( '00000001' , array ( $_SERVER[ 'REMOTE_ADDR' ] , $_POST[ 'userName' ] ) , 0 ); - } - else - { - $dat_user = $result -> fetch_assoc ( ); - if ( $dat_user[ 'userActive' ] === 'N' ) - { - /* User ist deaktiviert */ - $arrError[ ] = 'login_002'; - fnc_writeLog ( '00000002' , array ( ) , $dat_user[ 'userId' ] ); - } - else - { - /* Anmeldung erfolgreich und Prüfung, ob Passwort geändert werden muss */ - /* Bearbeitungsrechte abfragen */ - $editingRights = $db -> query ( 'SELECT * FROM ' . TBL_RIGHTS . ' WHERE userId = "' . $dat_user[ 'userId' ] . '";' ); - - $_SESSION[ 'sess_userId' ] = $dat_user[ 'userId' ]; - $_SESSION[ 'sess_loginDate' ] = date( 'YmdHis' ); - $_SESSION[ 'sess_loginStatus' ] = ( $dat_user[ 'userPasswordOrgCrypt' ] === $dat_user[ 'userPasswordCrypt' ] ) - ? 'changePW' - : 'loggedIn'; - $_SESSION[ 'sess_sessionId' ] = session_id( ); - $_SESSION[ 'sess_sessionName' ] = session_name( ); - $_SESSION[ 'sess_loginLang' ] = 'de'; - $_SESSION[ 'sess_portalRightsType' ] = $dat_user[ 'userPortalRightsType' ]; - $_SESSION[ 'sess_portalRights' ] = explode ( ';' , $dat_user[ 'userPortalRights' ] ); - while ( $singleRights = $editingRights -> fetch_assoc ( ) ) - { - $_SESSION[ 'sess_' . $singleRights[ 'rightsPrefix' ] . 'Type' ] = $singleRights[ 'rightsType' ]; - $_SESSION[ 'sess_' . $singleRights[ 'rightsPrefix' ] ] = $singleRights[ 'rights' ]; - } - - if ( $dat_user[ 'userPasswordOrgCrypt' ] === $dat_user[ 'userPasswordCrypt' ] ) - { - $_GET[ 'siteId' ] = 'changePW'; - fnc_writeLog ( '00000005' , array ( ) , $dat_user[ 'userId' ] ); - } - else - { - $_GET[ 'siteId' ] = '1'; - fnc_writeLog ( '00000003' , array ( ) , $dat_user[ 'userId' ] ); - } - - header( 'Location: index.php?siteId=' . $_GET[ 'siteId' ] ); - die( ); - } - } + /* User ist deaktiviert */ + $arrError[] = 'login_002'; + fnc_writeLog('00000002', array(), $dat_user['userId']); } - - /* Abmelden */ - if ( isset ( $_GET[ 'siteId' ] ) && $_GET[ 'siteId' ] === 'logout' ) + else { - if ( isset ( $_SESSION[ 'sess_userId' ] ) ) - { - fnc_writeLog ( '00000004' , array ( ) , $_SESSION[ 'sess_userId' ] ); - } - session_destroy( ); - header( 'Location: index.php?siteId=login' ); - die( ); - } - - /* Passwort ändern */ - if ( isset ( $_POST[ 'formAction' ] ) && $_POST[ 'formAction' ] === 'changePW' ) - { - if ( $_POST[ 'newPassWord' ] !== $_POST[ 'passWordRepeat' ] ) - { - $arrError[ ] = 'pw_001'; - } - else - { - $result = $db -> query ( 'SELECT * FROM ' . TBL_USER . ' WHERE userUsername = "' . $_POST[ 'userName' ] . '" AND userPasswordOrg = "' . $_POST[ 'passWord' ] . '" AND userDelete = "N";' ); - if ( $result -> num_rows === 0 ) - { - $arrError[ ] = 'login_001'; - } - else - { - $_SESSION[ 'sess_loginStatus' ] = 'loggedIn'; - $user = $result -> fetch_assoc ( ); - $db -> query ( 'UPDATE ' . TBL_USER . ' SET userPasswordCrypt = "' . md5 ( $_POST[ 'newPassWord' ] ) . '" WHERE userId = "' . $user[ 'userId' ] . '" LIMIT 1;' ); - fnc_writeLog ( '00000016' , array ( fnc_getUsernameById ( $user[ 'userId' ] ) ) , $_SESSION[ 'sess_userId' ] ); - header( 'Location:index.php?siteId=1' ); - die( ); - } - } - } + /* Anmeldung erfolgreich und Prüfung, ob Passwort geändert werden muss */ + /* Bearbeitungsrechte abfragen */ + $editingRights = $db->query('SELECT * FROM ' . TBL_RIGHTS . ' WHERE userId = "' . $dat_user['userId'] . '";'); -?> \ No newline at end of file + $_SESSION['sess_userId'] = $dat_user['userId']; + $_SESSION['sess_loginDate'] = date('YmdHis'); + $_SESSION['sess_loginStatus'] = ($dat_user['userPasswordOrgCrypt'] === $dat_user['userPasswordCrypt']) + ? 'changePW' + : 'loggedIn'; + $_SESSION['sess_sessionId'] = session_id(); + $_SESSION['sess_sessionName'] = session_name(); + $_SESSION['sess_loginLang'] = 'de'; + $_SESSION['sess_portalRightsType'] = $dat_user['userPortalRightsType']; + $_SESSION['sess_portalRights'] = explode(';', $dat_user['userPortalRights']); + while ($singleRights = $editingRights->fetch_assoc()) + { + $_SESSION['sess_' . $singleRights['rightsPrefix'] . 'Type'] = $singleRights['rightsType']; + $_SESSION['sess_' . $singleRights['rightsPrefix']] = $singleRights['rights']; + } + + if ($dat_user['userPasswordOrgCrypt'] === $dat_user['userPasswordCrypt']) + { + $_GET['siteId'] = 'changePW'; + fnc_writeLog('00000005', array(), $dat_user['userId']); + } + else + { + $_GET['siteId'] = '1'; + fnc_writeLog('00000003', array(), $dat_user['userId']); + } + + header('Location: index.php?siteId=' . $_GET['siteId']); + die(); + } + } +} + +/* Abmelden */ +if (isset ($_GET['siteId']) && $_GET['siteId'] === 'logout') +{ + if (isset ($_SESSION['sess_userId'])) + { + fnc_writeLog('00000004', array(), $_SESSION['sess_userId']); + } + session_destroy(); + header('Location: index.php?siteId=login'); + die(); +} + +/* Passwort ändern */ +if (isset ($_POST['formAction']) && $_POST['formAction'] === 'changePW') +{ + if ($_POST['newPassWord'] !== $_POST['passWordRepeat']) + { + $arrError[] = 'pw_001'; + } + else + { + $result = $db->query('SELECT * FROM ' . TBL_USER . ' WHERE userUsername = "' . $_POST['userName'] . '" AND userPasswordOrg = "' . $_POST['passWord'] . '" AND userDelete = "N";'); + if ($result->num_rows === 0) + { + $arrError[] = 'login_001'; + } + else + { + $_SESSION['sess_loginStatus'] = 'loggedIn'; + $user = $result->fetch_assoc(); + $db->query('UPDATE ' . TBL_USER . ' SET userPasswordCrypt = "' . md5($_POST['newPassWord']) . '" WHERE userId = "' . $user['userId'] . '" LIMIT 1;'); + fnc_writeLog('00000016', array(fnc_getUsernameById($user['userId'])), $_SESSION['sess_userId']); + header('Location:index.php?siteId=1'); + die(); + } + } +} \ No newline at end of file diff --git a/.actions/usermanagement_actions.php b/.actions/usermanagement_actions.php index 7c41a0a..0c91de5 100644 --- a/.actions/usermanagement_actions.php +++ b/.actions/usermanagement_actions.php @@ -1,151 +1,149 @@ query('UPDATE ' . TBL_USER . ' SET userActive = "N" , userActiveUser = "' . $_SESSION['sess_userId'] . '" , userActiveTS = NOW( ) WHERE userId = "' . $_POST['userId'] . '" LIMIT 1;'); + fnc_writeLog('00000011', array(fnc_getUsernameById($_POST['userId'])), $_SESSION['sess_userId']); + header('Location:index.php?siteId=' . $_POST['siteId']); + die(); +} + +if (isset ($_POST['formAction']) && $_POST['formAction'] === 'enableUser') +{ + $db->query('UPDATE ' . TBL_USER . ' SET userActive = "Y" WHERE userId = "' . $_POST['userId'] . '" LIMIT 1;'); + fnc_writeLog('00000012', array(fnc_getUsernameById($_POST['userId'])), $_SESSION['sess_userId']); + header('Location:index.php?siteId=' . $_POST['siteId']); + die(); +} + +if (isset ($_POST['formAction']) && $_POST['formAction'] === 'deleteUser') +{ + $db->query('UPDATE ' . TBL_USER . ' SET userDelete = "Y" , userDeleteUser = "' . $_SESSION['sess_userId'] . '" , userDeleteTS = NOW( ) WHERE userId = "' . $_POST['userId'] . '" LIMIT 1;'); + fnc_writeLog('00000014', array(fnc_getUsernameById($_POST['userId'])), $_SESSION['sess_userId']); + header('Location:index.php?siteId=' . $_POST['siteId']); + die(); +} + +if (isset ($_POST['formAction']) && $_POST['formAction'] === 'resetPW') +{ + $status = fnc_sendEmailToUser('00000015', $_POST['userId'], $_SESSION['sess_userId']); + if ($status === 'OK') + { + $db->query('UPDATE ' . TBL_USER . ' SET userPasswordCrypt = "' . $_POST['userPasswordOrgCrypt'] . '" WHERE userId = "' . $_POST['userId'] . '" LIMIT 1;'); + fnc_writeLog('00000015', array(fnc_getUsernameById($_POST['userId'])), $_SESSION['sess_userId']); + header('Location:index.php?siteId=' . $_POST['siteId']); + die(); + } + else + { + $arrError[] = 'mail_001'; + } + die(); +} + +if (isset ($_POST['formAction']) && $_POST['formAction'] === 'createUser') +{ + if (!isset ($_POST['user_portalRightsType'])) + { + $_POST['user_portalRightsType'] = 'DEF'; + } + $userPortalRights = ($_POST['user_portalRightsType'] === 'ALL' || !isset ($_POST['user_portalRights'])) + ? '' + : implode(';', $_POST['user_portalRights']); + + if (!fnc_validateEmailAddress($_POST['userEmail'])) + { + $arrError[] = 'mail_002'; + } + if (!fnc_checkUniqueEmailAddress($_POST['userEmail'])) + { + $arrError[] = 'mail_003'; + } + + if (isset ($arrError) && !empty ($arrError)) + { + $_GET['siteId'] = $_POST['siteId']; + $_GET['todoId'] = $_POST['todoId']; + } + else + { + $userName = fnc_generateUniqueUsername($_POST['userLastname'], $_POST['userFirstname']); + $passWord = fnc_generatePW(); + $crypt = md5($passWord); + $insert = $db->query('INSERT INTO ' . TBL_USER . ' ( userUsername , userEmail , userPhone , userPasswordCrypt , userPasswordOrgCrypt , userPasswordOrg , userFirstname , userLastname , userCreateUser , userActive , userDelete , userPortalRightsType , userPortalRights ) VALUES ( "' . $userName . '" , "' . $_POST['userEmail'] . '" , "' . $_POST['userPhone'] . '" , "' . $crypt . '" , "' . $crypt . '" , "' . $passWord . '" , "' . $_POST['userFirstname'] . '" , "' . $_POST['userLastname'] . '" , "' . $_SESSION['sess_userId'] . '" , "Y" , "N" , "' . $_POST['user_portalRightsType'] . '" , "' . $userPortalRights . '" );'); + $userId = $db->insert_id; + + foreach ($vC['portal']['website']['prefix'] as $website) { - $db -> query ( 'UPDATE ' . TBL_USER . ' SET userActive = "N" , userActiveUser = "' . $_SESSION[ 'sess_userId' ] . '" , userActiveTS = NOW( ) WHERE userId = "' . $_POST[ 'userId' ] . '" LIMIT 1;' ); - fnc_writeLog ( '00000011' , array ( fnc_getUsernameById ( $_POST[ 'userId' ] ) ) , $_SESSION[ 'sess_userId' ] ); - header( 'Location:index.php?siteId=' . $_POST[ 'siteId' ] ); - die( ); + if (!isset ($_POST['user' . $website . 'RightsType'])) + { + $_POST['user' . $website . 'RightsType'] = 'DEF'; + } + $userWebsiteRights = ($_POST['user_' . $website . 'RightsType'] === 'ALL' || !isset ($_POST['user_' . $website . 'Rights'])) + ? '' + : implode(';', $_POST['user' . $website . 'Rights']); + + $db->query('INSERT INTO ' . TBL_RIGHTS . ' SET userId = "' . $userId . '" , rightsPrefix = "' . $website . '" , rightsType = "' . $_POST['user_' . $website . 'RightsType'] . '" , rights = "' . $userWebsiteRights . '";'); } - if ( isset ( $_POST[ 'formAction' ] ) && $_POST[ 'formAction' ] === 'enableUser' ) - { - $db -> query ( 'UPDATE ' . TBL_USER . ' SET userActive = "Y" WHERE userId = "' . $_POST[ 'userId' ] . '" LIMIT 1;' ); - fnc_writeLog ( '00000012' , array ( fnc_getUsernameById ( $_POST[ 'userId' ] ) ) , $_SESSION[ 'sess_userId' ] ); - header( 'Location:index.php?siteId=' . $_POST[ 'siteId' ] ); - die( ); - } + fnc_sendEmailToUser('00000010', $userId, $_SESSION['sess_userId']); + fnc_writeLog('00000010', array(fnc_getUsernameById($userId)), $_SESSION['sess_userId']); + header('Location:index.php?siteId=' . $_POST['siteId']); + die (); + } +} - if ( isset ( $_POST[ 'formAction' ] ) && $_POST[ 'formAction' ] === 'deleteUser' ) - { - $db -> query ( 'UPDATE ' . TBL_USER . ' SET userDelete = "Y" , userDeleteUser = "' . $_SESSION[ 'sess_userId' ] . '" , userDeleteTS = NOW( ) WHERE userId = "' . $_POST[ 'userId' ] . '" LIMIT 1;' ); - fnc_writeLog ( '00000014' , array ( fnc_getUsernameById ( $_POST[ 'userId' ] ) ) , $_SESSION[ 'sess_userId' ] ); - header( 'Location:index.php?siteId=' . $_POST[ 'siteId' ] ); - die( ); - } +if (isset ($_POST['formAction']) && $_POST['formAction'] === 'editUser') +{ + if (!isset ($_POST['user_portalRightsType'])) + { + $_POST['user_portalRightsType'] = 'DEF'; + } + $userPortalRights = ($_POST['user_portalRightsType'] === 'ALL' || !isset ($_POST['user_portalRights'])) + ? '' + : implode(';', $_POST['user_portalRights']); - if ( isset ( $_POST[ 'formAction' ] ) && $_POST[ 'formAction' ] === 'resetPW' ) + if (!fnc_validateEmailAddress($_POST['userEmail'])) + { + $arrError[] = 'mail_002'; + } + if (!fnc_checkUniqueEmailAddress($_POST['userEmail'], $_POST['userId'])) + { + $arrError[] = 'mail_003'; + } + + if (isset ($arrError) && !empty ($arrError)) + { + $_GET['siteId'] = $_POST['siteId']; + $_GET['todoId'] = $_POST['todoId']; + $_GET['userId'] = $_POST['userId']; + } + else + { + $db->query('UPDATE ' . TBL_USER . ' SET userLastname = "' . $_POST['userLastname'] . '" , userFirstname = "' . $_POST['userFirstname'] . '" , userEmail = "' . $_POST['userEmail'] . '" , userPhone = "' . $_POST['userPhone'] . '" , userPortalRightsType = "' . $_POST['user_portalRightsType'] . '" , userPortalRights = "' . $userPortalRights . '" WHERE userId = "' . $_POST['userId'] . '" LIMIT 1;'); + + foreach ($vC['portal']['website']['prefix'] as $website) { - $status = fnc_sendEmailToUser ( '00000015' , $_POST[ 'userId' ] , $_SESSION[ 'sess_userId' ] ); - if ( $status === 'OK' ) - { - $db -> query ( 'UPDATE ' . TBL_USER . ' SET userPasswordCrypt = "' . $_POST[ 'userPasswordOrgCrypt' ] . '" WHERE userId = "' . $_POST[ 'userId' ] . '" LIMIT 1;' ); - fnc_writeLog ( '00000015' , array ( fnc_getUsernameById ( $_POST[ 'userId' ] ) ) , $_SESSION[ 'sess_userId' ] ); - header( 'Location:index.php?siteId=' . $_POST[ 'siteId' ] ); - die( ); - } + if (!isset ($_POST['user_' . $website . 'RightsType'])) + { + $_POST['user_' . $website . 'RightsType'] = 'DEF'; + } + $userWebsiteRights = ($_POST['user_' . $website . 'RightsType'] === 'ALL' || !isset ($_POST['user_' . $website . 'Rights'])) + ? '' + : implode(';', $_POST['user_' . $website . 'Rights']); + $rights = $db->query('SELECT * FROM ' . TBL_RIGHTS . ' WHERE userId = "' . $_POST['userId'] . '" AND rightsPrefix = "' . $website . '";'); + if ($rights->num_rows === 0) + { + $db->query('INSERT INTO ' . TBL_RIGHTS . ' SET userId = "' . $_POST['userId'] . '" , rightsPrefix = "' . $website . '" , rightsType = "' . $_POST['user' . $website . 'RightsType'] . '" , rights = "' . $userWebsiteRights . '";'); + } else - { - $arrError[ ] = 'mail_001'; - } - die( ); - } - - if ( isset ( $_POST[ 'formAction' ] ) && $_POST[ 'formAction' ] === 'createUser' ) - { - if ( ! isset ( $_POST[ 'user_portalRightsType' ] ) ) - { - $_POST[ 'user_portalRightsType' ] = 'DEF'; - } - $userPortalRights = ( $_POST[ 'user_portalRightsType' ] === 'ALL' || ! isset ( $_POST[ 'user_portalRights' ] ) ) - ? '' - : implode ( ';' , $_POST[ 'user_portalRights' ] ); - - if ( ! fnc_validateEmailAddress ( $_POST[ 'userEmail' ] ) ) - { - $arrError[ ] = 'mail_002'; - } - if ( ! fnc_checkUniqueEmailAddress ( $_POST[ 'userEmail' ] ) ) - { - $arrError[ ] = 'mail_003'; - } - - if ( isset ( $arrError ) && ! empty ( $arrError ) ) - { - $_GET[ 'siteId' ] = $_POST[ 'siteId' ]; - $_GET[ 'todoId' ] = $_POST[ 'todoId' ]; - } - else - { - $userName = fnc_generateUniqueUsername ( $_POST[ 'userLastname' ] , $_POST[ 'userFirstname' ] ); - $passWord = fnc_generatePW ( ); - $crypt = md5 ( $passWord ); - $insert = $db -> query ( 'INSERT INTO ' . TBL_USER . ' ( userUsername , userEmail , userPhone , userPasswordCrypt , userPasswordOrgCrypt , userPasswordOrg , userFirstname , userLastname , userCreateUser , userActive , userDelete , userPortalRightsType , userPortalRights ) VALUES ( "' . $userName . '" , "' . $_POST[ 'userEmail' ] . '" , "' . $_POST[ 'userPhone' ] . '" , "' . $crypt . '" , "' . $crypt . '" , "' . $passWord . '" , "' . $_POST[ 'userFirstname' ] . '" , "' . $_POST[ 'userLastname' ] . '" , "' . $_SESSION[ 'sess_userId' ] . '" , "Y" , "N" , "' . $_POST[ 'user_portalRightsType' ] . '" , "' . $userPortalRights . '" );' ); - $userId = $db -> insert_id; - - foreach ( $vC[ 'portal' ][ 'website' ][ 'prefix' ] as $website ) - { - if ( ! isset ( $_POST[ 'user' . $website . 'RightsType' ] ) ) - { - $_POST[ 'user' . $website . 'RightsType' ] = 'DEF'; - } - $userWebsiteRights = ( $_POST[ 'user_' . $website . 'RightsType' ] === 'ALL' || ! isset ( $_POST[ 'user_' . $website . 'Rights' ] ) ) - ? '' - : implode ( ';' , $_POST[ 'user' . $website . 'Rights' ] ); - - $db -> query ( 'INSERT INTO ' . TBL_RIGHTS . ' SET userId = "' . $userId . '" , rightsPrefix = "' . $website . '" , rightsType = "' . $_POST[ 'user_' . $website . 'RightsType' ] . '" , rights = "' . $userWebsiteRights . '";' ); - } - - fnc_sendEmailToUser ( '00000010' , $userId , $_SESSION[ 'sess_userId' ] ); - fnc_writeLog ( '00000010' , array ( fnc_getUsernameById ( $userId ) ) , $_SESSION[ 'sess_userId' ] ); - header( 'Location:index.php?siteId=' . $_POST[ 'siteId' ] ); - die ( ); - } - } - - if ( isset ( $_POST[ 'formAction' ] ) && $_POST[ 'formAction' ] === 'editUser' ) - { - if ( ! isset ( $_POST[ 'user_portalRightsType' ] ) ) - { - $_POST[ 'user_portalRightsType' ] = 'DEF'; - } - $userPortalRights = ( $_POST[ 'user_portalRightsType' ] === 'ALL' || ! isset ( $_POST[ 'user_portalRights' ] ) ) - ? '' - : implode ( ';' , $_POST[ 'user_portalRights' ] ); - - if ( ! fnc_validateEmailAddress ( $_POST[ 'userEmail' ] ) ) - { - $arrError[ ] = 'mail_002'; - } - if ( ! fnc_checkUniqueEmailAddress ( $_POST[ 'userEmail' ] , $_POST[ 'userId' ] ) ) - { - $arrError[ ] = 'mail_003'; - } - - if ( isset ( $arrError ) && ! empty ( $arrError ) ) - { - $_GET[ 'siteId' ] = $_POST[ 'siteId' ]; - $_GET[ 'todoId' ] = $_POST[ 'todoId' ]; - $_GET[ 'userId' ] = $_POST[ 'userId' ]; - } - else - { - $db -> query ( 'UPDATE ' . TBL_USER . ' SET userLastname = "' . $_POST[ 'userLastname' ] . '" , userFirstname = "' . $_POST[ 'userFirstname' ] . '" , userEmail = "' . $_POST[ 'userEmail' ] . '" , userPhone = "' . $_POST[ 'userPhone' ] . '" , userPortalRightsType = "' . $_POST[ 'user_portalRightsType' ] . '" , userPortalRights = "' . $userPortalRights . '" WHERE userId = "' . $_POST[ 'userId' ] . '" LIMIT 1;' ); - - foreach ( $vC[ 'portal' ][ 'website' ][ 'prefix' ] as $website ) - { - if ( ! isset ( $_POST[ 'user_' . $website . 'RightsType' ] ) ) - { - $_POST[ 'user_' . $website . 'RightsType' ] = 'DEF'; - } - $userWebsiteRights = ( $_POST[ 'user_' . $website . 'RightsType' ] === 'ALL' || ! isset ( $_POST[ 'user_' . $website . 'Rights' ] ) ) - ? '' - : implode ( ';' , $_POST[ 'user_' . $website . 'Rights' ] ); - $rights = $db -> query ( 'SELECT * FROM ' . TBL_RIGHTS . ' WHERE userId = "' . $_POST[ 'userId' ] . '" AND rightsPrefix = "' . $website . '";' ); - if ( $rights -> num_rows === 0 ) - { - $db -> query ( 'INSERT INTO ' . TBL_RIGHTS . ' SET userId = "' . $_POST[ 'userId' ] . '" , rightsPrefix = "' . $website . '" , rightsType = "' . $_POST[ 'user' . $website . 'RightsType' ] . '" , rights = "' . $userWebsiteRights . '";' ); - } - else - { - $db -> query ( 'UPDATE ' . TBL_RIGHTS . ' SET rightsType = "' . $_POST[ 'user_' . $website . 'RightsType' ] . '" , rights = "' . $userWebsiteRights . '" WHERE userId = "' . $_POST[ 'userId' ] . '" AND rightsPrefix = "' . $website . '";' ); - } - } - - fnc_writeLog ( '00000013' , array ( fnc_getUsernameById ( $_POST[ 'userId' ] ) ) , $_SESSION[ 'sess_userId' ] ); - header( 'Location:index.php?siteId=' . $_POST[ 'siteId' ] ); - die ( ); - } + { + $db->query('UPDATE ' . TBL_RIGHTS . ' SET rightsType = "' . $_POST['user_' . $website . 'RightsType'] . '" , rights = "' . $userWebsiteRights . '" WHERE userId = "' . $_POST['userId'] . '" AND rightsPrefix = "' . $website . '";'); + } } -?> \ No newline at end of file + fnc_writeLog('00000013', array(fnc_getUsernameById($_POST['userId'])), $_SESSION['sess_userId']); + header('Location:index.php?siteId=' . $_POST['siteId']); + die (); + } +} \ No newline at end of file diff --git a/.classes/generic/renderClass.php b/.classes/generic/renderClass.php index 8d82682..5d1aa9c 100644 --- a/.classes/generic/renderClass.php +++ b/.classes/generic/renderClass.php @@ -1,468 +1,464 @@ _pathTpl = $pathTpl; + } + + public function setConfig($config) + { + $this->_config = $config; + if (isset ($this->_config['portal']['website'])) { - private $_editable = false; - private $_tplElements = array ( ); - private $_data = array ( ); - private $_db = null; - private $_html = null; - - public $_renderSearch = array ( "\r\n" , "\n" , "\r" , "\t" ); - public $_renderReplace = ''; - - public $_pathTpl = PATH_PORTAL_TPL; - public $_config = array ( ); - public $_layout = ''; - public $_template = ''; - public $_langArray = array ( ); - public $_textsFromConfig = true; - public $_navpath = array ( ); - public $_postData = null; - public $_errors = null; - public $_tpl = null; - public $_subTemplate = ''; - public $_siteId = ''; - public $_dataParameter = array ( ); - public $_website = array ( ); - public $_webkey = 0; - public $_modrewrite = false; - public $_specialSite = false; - - public function setPathTpl ( $pathTpl ) - { - $this -> _pathTpl = $pathTpl; - } - - public function setConfig ( $config ) - { - $this -> _config = $config; - if ( isset ( $this -> _config[ 'portal' ][ 'website' ] ) ) - { - $this -> setWebsite ( $this -> _config[ 'portal' ][ 'website' ] ); - } - } - - public function setLayout ( $layout ) - { - $this -> _layout = $layout; - } - - public function setTemplate ( $template ) - { - $this -> _template = $template; - } - - public function setEditable ( $editable ) - { - $this -> _editable = $editable; - } - - public function setSubTemplate ( $subtemplate ) - { - $this -> _subTemplate = $subtemplate; - } - - public function setTplElements ( $tplElements ) - { - $this -> _tplElements = $tplElements; - } - - public function setSiteId ( $siteId ) - { - $this -> _siteId = $siteId; - } - - public function setDataParameter ( $dataParameter ) - { - $this -> _dataParameter = $dataParameter; - } - - public function setLang ( $langArray ) - { - $this -> _langArray = $langArray; - } - - public function setTextsFromConfig ( $fromConfig ) - { - $this -> _textsFromConfig = $fromConfig; - } - - public function setWebkey ( $_webkey ) - { - $this -> _webkey = $_webkey; - } - - private function setWebsite ( $website ) - { - $return_array = array ( ); - $tmp_array = array_flip ( $website[ 'navId' ] ); - foreach ( $tmp_array as $key => $value ) - { - foreach ( $website as $tmp_key => $tmp_value ) - { - $return_array[ $key ][ $tmp_key ] = $website[ $tmp_key ][ $value ]; - } - } - $this -> _website = $return_array; - } - - public function setData ( $data ) - { - $this -> _data = $data; - } - - public function setNavpath ( $navpath ) - { - $this -> _navpath = $navpath; - } - - public function setDb ( $db ) - { - $this -> _db = $db; - } - - public function setErrors ( $errors ) - { - $this -> _errors = $errors; - } - - public function setPostData ( $postData ) - { - $this -> _postData = $postData; - } - - public function setSpecialSite ( $specialSite ) - { - $this -> _specialSite = $specialSite; - } - - public function output ( ) - { - $html = $this -> readTemplate ( ); - echo $html -> saveHTML ( ); - } - - public function applySortRules ( $tpl , $node , $xpath ) - { - $elements = $xpath -> query ( ".//*[@data-sortable]" , $node ); - foreach ( $elements as $sortNode ) - { - $sortImg = $tpl -> createElement ( 'img' ); - $sortText = $sortNode -> firstChild; - $href = $this -> _postData; - if ( $sortNode -> getAttribute ( 'data-sortable' ) === $this -> _postData[ 'orderBy' ] ) - { - if ( $this -> _postData[ 'orderDir' ] === 'ASC' ) - { - $sortImg -> setAttributeNode ( new DOMAttr ( 'src' , PATH_IMG . 'icon-sortup.png' ) ); - $href[ 'orderDir' ] = 'DESC'; - } - else - { - $sortImg -> setAttributeNode ( new DOMAttr ( 'src' , PATH_IMG . 'icon-sortdown.png' ) ); - $href[ 'orderDir' ] = 'ASC'; - } - } - else - { - $sortImg -> setAttributeNode ( new DOMAttr ( 'src' , PATH_IMG . 'icon-sortwo.png' ) ); - $href[ 'orderBy' ] = $sortNode -> getAttribute ( 'data-sortable' ); - } - - $newLink = ''; - foreach ( $href as $key => $value ) - { - $newLink .= '&' . $key . '=' . $value; - } - - $sortNode -> setAttribute ( 'href' , $sortNode -> getAttribute ( 'href' ) . '?' . substr ( $newLink , 1 ) ); - $sortNode -> replaceChild ( $sortImg , $sortText ); - $sortNode -> appendChild ( new DOMText ( $sortText -> nodeValue ) ); - } - } - - public function applyFunction ( $name , $data , $tpl , $node , $prefix ) - { - switch ( $name ) - { - case 'createNavigationRights' : - $rights = renderFunctionsClass :: createNavigationRights ( $data , $tpl , $node ); - break; - default : - break; - } - } - - private function readTemplate ( ) - { - $html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_' . $this -> _template . '.php' ); - $html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html ); - $html = str_replace ( array ( 'PHP_ROOT_PATH/' , 'PHP_SITE_PATH/' ) , array ( PATH_ROOT , PATH_SITE ) , $html ); - $tpl = new DOMDocument ( ); - $tpl -> preserveWhitespace = false; - $tpl -> formatOutput = false; - $tpl -> loadHTML ( $html ); - $this -> _tpl = $tpl; - - if ( $this -> _template === 'portal' ) - { - if ( ! isset ( $this -> _data [ 'keyvisual' ] ) ) - { - if ( file_exists ( PATH_IMG . $this -> _layout . '/keyvisual_' . $this -> _siteId . '.jpg' ) ) - { - $this -> _data[ 'keyvisual' ][ ] = array ( 'id' => $this -> _siteId , 'path' => PATH_IMG . $this -> _layout . '/' , 'navId' => '' , 'src' => 'keyvisual_' . $this -> _siteId . '.jpg' , 'title' => null ); - } - else - { - $this -> _data[ 'keyvisual' ][ ] = array ( 'id' => 0 , 'path' => PATH_IMG . $this -> _layout . '/' , 'navId' => '' , 'src' => 'keyvisual_0.jpg', 'title' => null ); - } - } + $this->setWebsite($this->_config['portal']['website']); + } + } - $this -> _data [ 'headline_main' ] = $this -> _langArray [ 'portal' ][ 'headline_main' ]; - $this -> _data [ 'headline_site' ] = $this -> _langArray [ 'headline' ][ $this -> _siteId ]; - } - - foreach ( $this -> _data as $id => $content ) - { - $tmp_content = null; - switch ( $id ) - { - case 'headline_main' : - $tmp_content = $this -> _tpl -> createDocumentFragment ( ); - $tmp_content -> appendChild ( new DOMText ( $content ) ); - break; - - case 'headline_site' : - $tmp_content = $this -> _tpl -> createDocumentFragment ( ); - - foreach ( $content as $arrHeadline ) - { - $headline = $this -> _tpl -> createElement ( 'h1' ); - $headline -> setAttributeNode ( new DOMAttr ( 'class' , $arrHeadline[ 1 ] ) ); - $headline -> appendChild ( new DOMText ( $arrHeadline[ 0 ] ) ); - $tmp_content -> appendChild ( $headline ); - } - break; - - case 'sub_content' : - $tmp_content = renderPopupClass :: createPopup ( $content ); - break; - - case 'content' : - case 'login' : - $tmp_content = ( is_null ( $content[ 'siteContents' ] ) ) - ? null - : $this -> getPageContents ( $content[ 'siteContents' ] ); - break; - - case 'keyvisual' : - $tmp_content = $this -> _tpl -> createDocumentFragment( ); - foreach ( $content as $img_data ) - { - $tmp_content -> appendChild ( renderImageClass :: createImage ( $img_data , false , $id ) ); - } - break; - - case 'navi_main' : - case 'navi_special' : - case 'navi_sub' : - case 'navi_last' : - $tmp_content = renderNavigationClass :: createNavigation ( $content ); - break; - - case 'spielbericht_gespielt' : - case 'spielbericht_abgesagt' : - case 'spielbericht_pokal' : - case 'spielbericht_spielfrei' : - case 'uebersicht' : - $tmp_content = renderSpecialContentClass :: createSpecialContent ( $id , $content , ( ( $id === 'uebersicht' ) ? 'spielbericht_gespielt' : $id ) ); - break; - - case 'widget' : - $tmp_content = renderWidgetClass :: createWidget ( $content ); - break; - - default : - break; - } - - if ( ! is_null ( $tmp_content ) ) - { - if ( in_array ( $id , array ( 'uebersicht' , 'spielbericht' , 'spielbericht_gespielt' , 'spielbericht_abgesagt' , 'spielbericht_pokal' , 'spielbericht_spielfrei' , 'widget' ) ) ) - { - $node = $tpl -> getElementById ( 'content' ); - } - else if ( in_array ( $id , array ( 'keyvisual' ) ) ) - { - $node = $tpl -> getElementById ( $id ); - $node -> setAttributeNode ( new DOMAttr ( 'data-editable' , $id ) ); - $node -> setAttributeNode ( new DOMAttr ( 'id' , $id . '_' . $content[ 0 ][ 'id' ] ) ); - } - else - { - $node = $tpl -> getElementById ( $id ); - } - $node -> appendChild ( $tmp_content ); - } - } - - if ( $this -> _editable === true ) - { - /* Editor Layer einbinden */ - $html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_editor.php' ); - $html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html ); - $html = str_replace ( array ( 'PHP_ROOT_PATH/' , 'PHP_SITE_PATH' ) , array ( PATH_ROOT , PATH_SITE ) , $html ); - $editor = new DOMDocument ( ); - $editor -> preserveWhitespace = false; - $editor -> formatOutput = false; - $editor -> loadHTML ( $html ); - $eCont = $editor -> getElementById ( 'editor_layer' ); - $new_node = $tpl -> importNode ( $eCont , true ); - $body = $tpl -> getElementsByTagName( 'body' ) -> item( 0 ); - $body -> insertBefore ( $new_node , $body -> firstChild ); - - /* Editor Elemente einbinden - Nur für Standardseiten */ - if ( ! $this -> _specialSite ) - { - $html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_elements.php' ); - $html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html ); - $html = str_replace ( array ( 'PHP_ROOT_PATH/' , 'PHP_SITE_PATH' ) , array ( PATH_ROOT , PATH_SITE ) , $html ); - $elements = new DOMDocument ( ); - $elements -> preserveWhitespace = false; - $elements -> formatOutput = false; - $elements -> loadHTML ( $html ); - $eCont = $elements -> getElementById ( 'editor_elements' ); - $eCont = $tpl -> importNode ( $eCont , true ); - $elemCont = $tpl -> getElementById ( 'element_content' ); - foreach ( $this -> _website[ $this -> _webkey ][ 'contentElems' ] as $subTpl ) - { - $node = renderSpecialContentClass :: createSpecialContent ( $subTpl , array ( 0 => array ( 'content' => 'text' ) ) , null ); - $node -> setAttribute( 'class' , $node -> getAttribute( 'class' ) . ' elem_button' ); - $node -> setAttributeNode ( new DOMAttr ( 'data-editable' , $subTpl ) ); - $new_node = $tpl -> importNode ( $node , true ); - $elemCont -> appendChild ( $new_node ); - } - $body = $tpl -> getElementsByTagName( 'body' ) -> item( 0 ); - $body -> insertBefore ( $eCont , $body -> firstChild ); - } - - $head = $tpl -> getElementsByTagName( 'head' ) -> item( 0 ); - - /* Editor CSS ( lokal ) einbinden */ - $css = $this -> _tpl -> createElement ( 'link' ); - $css -> setAttributeNode ( new DOMAttr ( 'href' , PATH_CSS . $this -> _layout . '_editor.css' ) ); - $css -> setAttributeNode ( new DOMAttr ( 'type' , 'text/css' ) ); - $css -> setAttributeNode ( new DOMAttr ( 'rel' , 'stylesheet' ) ); - $head -> appendChild ( $css ); - - /* Editor JS - Variablen einbinden */ - $data = 'var userId = "' . $_SESSION[ 'sess_userId' ] . '";' . "\n"; - $data .= 'var sessLang = "' . $_SESSION[ 'sess_loginLang' ] . '";' . "\n"; - $data .= 'var navigationId = "' . $this -> _siteId . '";' . "\n"; - $data .= 'var pathMed = "' . PATH_MED . '";' . "\n"; - $data .= 'var stdKeyvisual = "' . PATH_MED . $this -> _website[ $this -> _webkey ][ 'prefix' ] . '/sample_keyvis.jpg";' . "\n"; - $data .= 'var stdImage = "' . PATH_MED . $this -> _website[ $this -> _webkey ][ 'prefix' ] . '/sample_image.jpg";' . "\n"; - - foreach ( $this -> _website[ $this -> _webkey ] as $var => $value ) - { - if ( is_array( $value ) ) - { - $data .= 'var ' . $var . ' = ' . json_encode ( $value ) . ';' . "\n"; - continue; - } - $data .= 'var ' . $var . ' = "' . $value . '";' . "\n"; - } - - $data .= ( $this -> _specialSite ) - ? 'var specialSite = true;' - : 'var specialSite = false;'; - - $js = $this -> _tpl -> createElement ( 'script' ); - $js -> setAttributeNode ( new DOMAttr ( 'type' , 'text/javascript' ) ); - $js -> appendChild ( new DOMCdataSection ( utf8_encode ( $data ) ) ); - $head -> appendChild ( $js ); - - /* Editor Sprachdatei ( remote ) einbinden */ - $js = $this -> _tpl -> createElement ( 'script' ); - $js -> setAttributeNode ( new DOMAttr ( 'type' , 'text/javascript' ) ); - $js -> setAttributeNode ( new DOMAttr ( 'src' , $this -> _website[ $this -> _webkey ][ 'editorUrl' ] . 'v' . $this -> _website[ $this -> _webkey ][ 'editorVersion' ] . '/js/lang.js.php?lang=' . $_SESSION[ 'sess_loginLang' ] ) ); - $head -> appendChild ( $js ); - - /* Editor JS ( remote ) einbinden */ - $js = $this -> _tpl -> createElement ( 'script' ); - $js -> setAttributeNode ( new DOMAttr ( 'type' , 'text/javascript' ) ); - $js -> setAttributeNode ( new DOMAttr ( 'src' , $this -> _website[ $this -> _webkey ][ 'editorUrl' ] . 'v' . $this -> _website[ $this -> _webkey ][ 'editorVersion' ] . '/js/editor.js' ) ); - $head -> appendChild ( $js ); - - $js = $this -> _tpl -> createElement ( 'script' ); - $js -> setAttributeNode ( new DOMAttr ( 'type' , 'text/javascript' ) ); - $js -> setAttributeNode ( new DOMAttr ( 'src' , $this -> _website[ $this -> _webkey ][ 'editorUrl' ] . 'v' . $this -> _website[ $this -> _webkey ][ 'editorVersion' ] . '/js/ckeditor/ckeditor.js' ) ); - $head -> appendChild ( $js ); - - } - - /* Nicht benötigte Elemente entfernen */ - foreach ( $this -> _tplElements as $element ) - { - if ( ! isset ( $this -> _data [ $element ] ) ) - { - $oldNode = $tpl -> getElementById ( $element ); - $oldNode -> parentNode -> removeChild ( $oldNode ); - } - } - - return $tpl; - } - - private function getPageContents ( $content ) - { - $arrContent = explode ( ';' , $content ); - - $tbl_prefix = ( $this -> _webkey !== 0 ) - ? $this -> _website[ $this -> _webkey ][ 'prefix' ] - : 'portal'; + private function setWebsite($website) + { + $return_array = array(); + $tmp_array = array_flip($website['navId']); + foreach ($tmp_array as $key => $value) + { + foreach ($website as $tmp_key => $tmp_value) + { + $return_array[$key][$tmp_key] = $website[$tmp_key][$value]; + } + } + $this->_website = $return_array; + } - $new_node = $this -> _tpl -> createDocumentFragment ( ); - - foreach ( $arrContent as $singleContent ) - { - $tmp_content = explode ( '_' , $singleContent ); - $tmp_result = $this -> _db -> query ( 'SELECT * FROM ' . $tbl_prefix . '_content_' . $tmp_content [ 0 ] . ' WHERE id = "' . $tmp_content [ 1 ] . '";' ); - $tmp_data = $tmp_result -> fetch_assoc ( ); - - switch ( $tmp_content[ 0 ] ) - { - case 'form' : - $new_node = renderFormClass :: createForm ( $tmp_data ); - break; - - default : - $node = renderSpecialContentClass :: createSpecialContent ( $tmp_content[ 0 ] , array ( $tmp_data ) , $tmp_content[ 0 ] ); - - if ( $this -> _editable ) - { - $node -> setAttributeNode ( new DOMAttr ( 'data-editable' , $tmp_content[ 0 ] ) ); - $node -> setAttributeNode ( new DOMAttr ( 'id' , 'content_' . $tmp_content[ 0 ] . '_' . $tmp_content[ 1 ] ) ); - } - - $new_node -> appendChild ( $node ); - break; - - } - } - - return $new_node; + public function setLayout($layout) + { + $this->_layout = $layout; + } + + public function setTemplate($template) + { + $this->_template = $template; + } + + public function setEditable($editable) + { + $this->_editable = $editable; + } + + public function setSubTemplate($subtemplate) + { + $this->_subTemplate = $subtemplate; + } + + public function setTplElements($tplElements) + { + $this->_tplElements = $tplElements; + } + + public function setSiteId($siteId) + { + $this->_siteId = $siteId; + } + + public function setDataParameter($dataParameter) + { + $this->_dataParameter = $dataParameter; + } + + public function setLang($langArray) + { + $this->_langArray = $langArray; + } + + public function setTextsFromConfig($fromConfig) + { + $this->_textsFromConfig = $fromConfig; + } + + public function setWebkey($_webkey) + { + $this->_webkey = $_webkey; + } + + public function setData($data) + { + $this->_data = $data; + } + + public function setNavpath($navpath) + { + $this->_navpath = $navpath; + } + + public function setDb($db) + { + $this->_db = $db; + } + + public function setErrors($errors) + { + $this->_errors = $errors; + } + + public function setPostData($postData) + { + $this->_postData = $postData; + } + + public function setSpecialSite($specialSite) + { + $this->_specialSite = $specialSite; + } + + public function output() + { + $html = $this->readTemplate(); + echo $html->saveHTML(); + } + + private function readTemplate() + { + $html = file_get_contents($this->_pathTpl . $this->_layout . '/tpl_' . $this->_template . '.php'); + $html = str_replace($this->_renderSearch, $this->_renderReplace, $html); + $html = str_replace(array('PHP_ROOT_PATH/', 'PHP_SITE_PATH/'), array(PATH_ROOT, PATH_SITE), $html); + $tpl = new DOMDocument (); + $tpl->preserveWhitespace = false; + $tpl->formatOutput = false; + $tpl->loadHTML($html); + $this->_tpl = $tpl; + + if ($this->_template === 'portal') + { + if (!isset ($this->_data ['keyvisual'])) + { + if (file_exists(PATH_IMG . $this->_layout . '/keyvisual_' . $this->_siteId . '.jpg')) + { + $this->_data['keyvisual'][] = array('id' => $this->_siteId, 'path' => PATH_IMG . $this->_layout . '/', 'navId' => '', 'src' => 'keyvisual_' . $this->_siteId . '.jpg', 'title' => null); } + else + { + $this->_data['keyvisual'][] = array('id' => 0, 'path' => PATH_IMG . $this->_layout . '/', 'navId' => '', 'src' => 'keyvisual_0.jpg', 'title' => null); + } + } + + $this->_data ['headline_main'] = $this->_langArray ['portal']['headline_main']; + $this->_data ['headline_site'] = $this->_langArray ['headline'][$this->_siteId]; } -?> \ No newline at end of file + foreach ($this->_data as $id => $content) + { + $tmp_content = null; + switch ($id) + { + case 'headline_main' : + $tmp_content = $this->_tpl->createDocumentFragment(); + $tmp_content->appendChild(new DOMText ($content)); + break; + + case 'headline_site' : + $tmp_content = $this->_tpl->createDocumentFragment(); + + foreach ($content as $arrHeadline) + { + $headline = $this->_tpl->createElement('h1'); + $headline->setAttributeNode(new DOMAttr ('class', $arrHeadline[1])); + $headline->appendChild(new DOMText ($arrHeadline[0])); + $tmp_content->appendChild($headline); + } + break; + + case 'sub_content' : + $tmp_content = renderPopupClass:: createPopup($content); + break; + + case 'content' : + case 'login' : + $tmp_content = (is_null($content['siteContents'])) + ? null + : $this->getPageContents($content['siteContents']); + break; + + case 'keyvisual' : + $tmp_content = $this->_tpl->createDocumentFragment(); + foreach ($content as $img_data) + { + $tmp_content->appendChild(renderImageClass:: createImage($img_data, false, $id)); + } + break; + + case 'navi_main' : + case 'navi_special' : + case 'navi_sub' : + case 'navi_last' : + $tmp_content = renderNavigationClass:: createNavigation($content); + break; + + case 'spielbericht_gespielt' : + case 'spielbericht_abgesagt' : + case 'spielbericht_pokal' : + case 'spielbericht_spielfrei' : + case 'uebersicht' : + $tmp_content = renderSpecialContentClass:: createSpecialContent($id, $content, (($id === 'uebersicht') ? 'spielbericht_gespielt' : $id)); + break; + + case 'widget' : + $tmp_content = renderWidgetClass:: createWidget($content); + break; + + default : + break; + } + + if (!is_null($tmp_content)) + { + if (in_array($id, array('uebersicht', 'spielbericht', 'spielbericht_gespielt', 'spielbericht_abgesagt', 'spielbericht_pokal', 'spielbericht_spielfrei', 'widget'))) + { + $node = $tpl->getElementById('content'); + } + else if (in_array($id, array('keyvisual'))) + { + $node = $tpl->getElementById($id); + $node->setAttributeNode(new DOMAttr ('data-editable', $id)); + $node->setAttributeNode(new DOMAttr ('id', $id . '_' . $content[0]['id'])); + } + else + { + $node = $tpl->getElementById($id); + } + $node->appendChild($tmp_content); + } + } + + if ($this->_editable === true) + { + /* Editor Layer einbinden */ + $html = file_get_contents($this->_pathTpl . $this->_layout . '/tpl_editor.php'); + $html = str_replace($this->_renderSearch, $this->_renderReplace, $html); + $html = str_replace(array('PHP_ROOT_PATH/', 'PHP_SITE_PATH'), array(PATH_ROOT, PATH_SITE), $html); + $editor = new DOMDocument (); + $editor->preserveWhitespace = false; + $editor->formatOutput = false; + $editor->loadHTML($html); + $eCont = $editor->getElementById('editor_layer'); + $new_node = $tpl->importNode($eCont, true); + $body = $tpl->getElementsByTagName('body')->item(0); + $body->insertBefore($new_node, $body->firstChild); + + /* Editor Elemente einbinden - Nur für Standardseiten */ + if (!$this->_specialSite) + { + $html = file_get_contents($this->_pathTpl . $this->_layout . '/tpl_elements.php'); + $html = str_replace($this->_renderSearch, $this->_renderReplace, $html); + $html = str_replace(array('PHP_ROOT_PATH/', 'PHP_SITE_PATH'), array(PATH_ROOT, PATH_SITE), $html); + $elements = new DOMDocument (); + $elements->preserveWhitespace = false; + $elements->formatOutput = false; + $elements->loadHTML($html); + $eCont = $elements->getElementById('editor_elements'); + $eCont = $tpl->importNode($eCont, true); + $elemCont = $tpl->getElementById('element_content'); + foreach ($this->_website[$this->_webkey]['contentElems'] as $subTpl) + { + $node = renderSpecialContentClass:: createSpecialContent($subTpl, array(0 => array('content' => 'text')), null); + $node->setAttribute('class', $node->getAttribute('class') . ' elem_button'); + $node->setAttributeNode(new DOMAttr ('data-editable', $subTpl)); + $new_node = $tpl->importNode($node, true); + $elemCont->appendChild($new_node); + } + $body = $tpl->getElementsByTagName('body')->item(0); + $body->insertBefore($eCont, $body->firstChild); + } + + $head = $tpl->getElementsByTagName('head')->item(0); + + /* Editor CSS ( lokal ) einbinden */ + $css = $this->_tpl->createElement('link'); + $css->setAttributeNode(new DOMAttr ('href', PATH_CSS . $this->_layout . '_editor.css')); + $css->setAttributeNode(new DOMAttr ('type', 'text/css')); + $css->setAttributeNode(new DOMAttr ('rel', 'stylesheet')); + $head->appendChild($css); + + /* Editor JS - Variablen einbinden */ + $data = 'var userId = "' . $_SESSION['sess_userId'] . '";' . "\n"; + $data .= 'var sessLang = "' . $_SESSION['sess_loginLang'] . '";' . "\n"; + $data .= 'var navigationId = "' . $this->_siteId . '";' . "\n"; + $data .= 'var pathMed = "' . PATH_MED . '";' . "\n"; + $data .= 'var stdKeyvisual = "' . PATH_MED . $this->_website[$this->_webkey]['prefix'] . '/sample_keyvis.jpg";' . "\n"; + $data .= 'var stdImage = "' . PATH_MED . $this->_website[$this->_webkey]['prefix'] . '/sample_image.jpg";' . "\n"; + + foreach ($this->_website[$this->_webkey] as $var => $value) + { + if (is_array($value)) + { + $data .= 'var ' . $var . ' = ' . json_encode($value) . ';' . "\n"; + continue; + } + $data .= 'var ' . $var . ' = "' . $value . '";' . "\n"; + } + + $data .= ($this->_specialSite) + ? 'var specialSite = true;' + : 'var specialSite = false;'; + + $js = $this->_tpl->createElement('script'); + $js->setAttributeNode(new DOMAttr ('type', 'text/javascript')); + $js->appendChild(new DOMCdataSection (utf8_encode($data))); + $head->appendChild($js); + + /* Editor Sprachdatei ( remote ) einbinden */ + $js = $this->_tpl->createElement('script'); + $js->setAttributeNode(new DOMAttr ('type', 'text/javascript')); + $js->setAttributeNode(new DOMAttr ('src', $this->_website[$this->_webkey]['editorUrl'] . '' . $this->_website[$this->_webkey]['editorVersion'] . '/js/lang.js.php?lang=' . $_SESSION['sess_loginLang'])); + $head->appendChild($js); + + /* Editor JS ( remote ) einbinden */ + $js = $this->_tpl->createElement('script'); + $js->setAttributeNode(new DOMAttr ('type', 'text/javascript')); + $js->setAttributeNode(new DOMAttr ('src', $this->_website[$this->_webkey]['editorUrl'] . '' . $this->_website[$this->_webkey]['editorVersion'] . '/js/editor.js')); + $head->appendChild($js); + + $js = $this->_tpl->createElement('script'); + $js->setAttributeNode(new DOMAttr ('type', 'text/javascript')); + $js->setAttributeNode(new DOMAttr ('src', $this->_website[$this->_webkey]['editorUrl'] . '' . $this->_website[$this->_webkey]['editorVersion'] . '/js/ckeditor/ckeditor.js')); + $head->appendChild($js); + + } + + /* Nicht benötigte Elemente entfernen */ + foreach ($this->_tplElements as $element) + { + if (!isset ($this->_data [$element])) + { + $oldNode = $tpl->getElementById($element); + $oldNode->parentNode->removeChild($oldNode); + } + } + + return $tpl; + } + + private function getPageContents($content) + { + $arrContent = explode(';', $content); + + $tbl_prefix = ($this->_webkey !== 0) + ? $this->_website[$this->_webkey]['prefix'] + : 'portal'; + + $new_node = $this->_tpl->createDocumentFragment(); + + foreach ($arrContent as $singleContent) + { + $tmp_content = explode('_', $singleContent); + $tmp_result = $this->_db->query('SELECT * FROM ' . $tbl_prefix . '_content_' . $tmp_content [0] . ' WHERE id = "' . $tmp_content [1] . '";'); + $tmp_data = $tmp_result->fetch_assoc(); + + switch ($tmp_content[0]) + { + case 'form' : + $new_node = renderFormClass:: createForm($tmp_data); + break; + + default : + $node = renderSpecialContentClass:: createSpecialContent($tmp_content[0], array($tmp_data), $tmp_content[0]); + + if ($this->_editable) + { + $node->setAttributeNode(new DOMAttr ('data-editable', $tmp_content[0])); + $node->setAttributeNode(new DOMAttr ('id', 'content_' . $tmp_content[0] . '_' . $tmp_content[1])); + } + + $new_node->appendChild($node); + break; + + } + } + + return $new_node; + } + + public function applySortRules($tpl, $node, $xpath) + { + $elements = $xpath->query(".//*[@data-sortable]", $node); + foreach ($elements as $sortNode) + { + $sortImg = $tpl->createElement('img'); + $sortText = $sortNode->firstChild; + $href = $this->_postData; + if ($sortNode->getAttribute('data-sortable') === $this->_postData['orderBy']) + { + if ($this->_postData['orderDir'] === 'ASC') + { + $sortImg->setAttributeNode(new DOMAttr ('src', PATH_IMG . 'icon-sortup.png')); + $href['orderDir'] = 'DESC'; + } + else + { + $sortImg->setAttributeNode(new DOMAttr ('src', PATH_IMG . 'icon-sortdown.png')); + $href['orderDir'] = 'ASC'; + } + } + else + { + $sortImg->setAttributeNode(new DOMAttr ('src', PATH_IMG . 'icon-sortwo.png')); + $href['orderBy'] = $sortNode->getAttribute('data-sortable'); + } + + $newLink = ''; + foreach ($href as $key => $value) + { + $newLink .= '&' . $key . '=' . $value; + } + + $sortNode->setAttribute('href', $sortNode->getAttribute('href') . '?' . substr($newLink, 1)); + $sortNode->replaceChild($sortImg, $sortText); + $sortNode->appendChild(new DOMText ($sortText->nodeValue)); + } + } + + public function applyFunction($name, $data, $tpl, $node, $prefix) + { + switch ($name) + { + case 'createNavigationRights' : + $rights = renderFunctionsClass::createNavigationRights($data, $tpl, $node); + break; + default : + break; + } + } +} \ No newline at end of file diff --git a/.classes/generic/renderClass_abstract.php b/.classes/generic/renderClass_abstract.php index 2bb6356..70e50aa 100644 --- a/.classes/generic/renderClass_abstract.php +++ b/.classes/generic/renderClass_abstract.php @@ -1,25 +1,23 @@ \ No newline at end of file + /** + * Konstruktor + */ + public function __construct() + { + + } + + /** + * Destruktor + */ + public function __destruct() + { + + } + +} \ No newline at end of file diff --git a/.classes/generic/renderFormClass.php b/.classes/generic/renderFormClass.php index ed8adc3..4193cb7 100644 --- a/.classes/generic/renderFormClass.php +++ b/.classes/generic/renderFormClass.php @@ -1,107 +1,105 @@ _tpl->createDocumentFragment(); + $node = $this->_tpl->createElement('form'); + $node->setAttributeNode(new DOMAttr ('action', $formData['action'])); + $node->setAttributeNode(new DOMAttr ('method', $formData['method'])); + $node->setAttributeNode(new DOMAttr ('class', $formData['class'])); + + if (!is_null($this->_errors)) { - private $_formData = array ( ); - - public function createForm ( $formData ) - { - $arrFields = explode ( ';' , $formData[ 'content' ] ); - $fieldCounter = 0; - - $new_node = $this -> _tpl -> createDocumentFragment ( ); - $node = $this -> _tpl -> createElement ( 'form' ); - $node -> setAttributeNode ( new DOMAttr ( 'action' , $formData[ 'action' ] ) ); - $node -> setAttributeNode ( new DOMAttr ( 'method' , $formData[ 'method' ] ) ); - $node -> setAttributeNode ( new DOMAttr ( 'class' , $formData[ 'class' ] ) ); + foreach ($this->_errors as $error) + { + $errorNode = $this->_tpl->createElement('p'); + $errorNode->setAttributeNode(new DOMAttr ('class', 'error')); + $errorNode->appendChild(new DOMText ($this->_langArray['error'][$error])); + $node->appendChild($errorNode); + } - if ( ! is_null ( $this -> _errors ) ) - { - foreach ( $this -> _errors as $error ) - { - $errorNode = $this -> _tpl -> createElement ( 'p' ); - $errorNode -> setAttributeNode ( new DOMAttr ( 'class' , 'error' ) ); - $errorNode -> appendChild ( new DOMText ( $this -> _langArray[ 'error' ][ $error ] ) ); - $node -> appendChild ( $errorNode ); - } - - } - - foreach ( $arrFields as $singleField ) - { - $arrData = explode ( ':' , $singleField ); - $arrDefinition = explode ( '_' , $arrData[ 0 ] ); - $arrValue = explode ( '_' , $arrData[ 1 ] ); - - /* Inputs */ - if ( $arrDefinition[ 0 ] === 'input' && ( $arrDefinition[ 1 ] !== 'hidden' && $arrDefinition[ 1 ] !== 'submit' ) ) - { - $tmp_div = $this -> _tpl -> createElement ( 'div' ); - ++$fieldCounter; - if ( $fieldCounter % 2 === 1 ) - { - $tmp_div -> setAttributeNode ( new DOMAttr ( 'class' , 'left' ) ); - } - } - - $tmp_node = $this -> _tpl -> createElement ( $arrDefinition[ 0 ] ); - - if ( $arrDefinition[ 0 ] === 'input' ) - { - $tmp_node -> setAttributeNode ( new DOMAttr ( 'type' , $arrDefinition[ 1 ] ) ); - $tmp_node -> setAttributeNode ( new DOMAttr ( 'id' , $arrValue[ 0 ] ) ); - $tmp_node -> setAttributeNode ( new DomAttr ( 'name' , $arrValue[ 0 ] ) ); - $tmp_node -> setAttributeNode ( new DomAttr ( 'autocomplete' , 'off' ) ); - - if ( $arrDefinition[ 1 ] !== 'hidden' && $arrDefinition[ 1 ] !== 'submit' && isset ( $this -> _postData[ $arrValue[ 0 ] ] ) ) - { - $tmp_node -> setAttributeNode ( new DomAttr ( 'value' , $this -> _postData[ $arrValue[ 0 ] ] ) ); - } - } - - if ( $arrDefinition[ 1 ] === 'submit' && isset ( $this -> _langArray[ 'form' ][ $arrValue[ 0 ] ] ) ) - { - $tmp_node -> setAttributeNode ( new DOMAttr ( 'value' , $this -> _langArray[ 'form' ][ $arrValue[ 0 ] ] ) ); - } - elseif ( isset ( $arrValue[ 1 ] ) ) - { - $tmp_node -> setAttributeNode ( new DOMAttr ( 'value' , $arrValue[ 1 ] ) ); - } - elseif ( isset ( $this -> _langArray[ 'formText' ][ $arrValue[ 0 ] ] ) ) - { - $tmp_node -> appendChild ( new DOMText ( $this -> _langArray[ 'formText' ][ $arrValue[ 0 ] ] ) ); - } - - if ( $arrDefinition[ 0 ] === 'input'&& ( $arrDefinition[ 1 ] !== 'hidden' && $arrDefinition[ 1 ] !== 'submit' ) ) - { - $tmp_div -> appendChild ( $tmp_node ); - - $tmp_node = $this -> _tpl -> createElement ( 'label' ); - $tmp_node -> setAttributeNode ( new DOMAttr ( 'for' , $arrValue[ 0 ] ) ); - $tmp_node -> appendChild ( new DOMText ( $this -> _langArray[ 'form' ][ $arrValue[ 0 ] ] ) ); - $tmp_div -> appendChild ( $tmp_node ); - - $node -> appendChild ( $tmp_div ); - if ( $fieldCounter % 2 === 0 ) - { - $tmp_br = $this -> _tpl -> createElement ( 'br' ); - $tmp_br -> setAttributeNode ( new DOMAttr ( 'class' , 'fix' ) ); - $node -> appendChild ( $tmp_br ); - } - - } - else - { - $node -> appendChild ( $tmp_node ); - } - - } - $new_node -> appendChild ( $node ); - - return $new_node; - } - - } -?> \ No newline at end of file + foreach ($arrFields as $singleField) + { + $arrData = explode(':', $singleField); + $arrDefinition = explode('_', $arrData[0]); + $arrValue = explode('_', $arrData[1]); + + /* Inputs */ + if ($arrDefinition[0] === 'input' && ($arrDefinition[1] !== 'hidden' && $arrDefinition[1] !== 'submit')) + { + $tmp_div = $this->_tpl->createElement('div'); + ++$fieldCounter; + if ($fieldCounter % 2 === 1) + { + $tmp_div->setAttributeNode(new DOMAttr ('class', 'left')); + } + } + + $tmp_node = $this->_tpl->createElement($arrDefinition[0]); + + if ($arrDefinition[0] === 'input') + { + $tmp_node->setAttributeNode(new DOMAttr ('type', $arrDefinition[1])); + $tmp_node->setAttributeNode(new DOMAttr ('id', $arrValue[0])); + $tmp_node->setAttributeNode(new DomAttr ('name', $arrValue[0])); + $tmp_node->setAttributeNode(new DomAttr ('autocomplete', 'off')); + + if ($arrDefinition[1] !== 'hidden' && $arrDefinition[1] !== 'submit' && isset ($this->_postData[$arrValue[0]])) + { + $tmp_node->setAttributeNode(new DomAttr ('value', $this->_postData[$arrValue[0]])); + } + } + + if ($arrDefinition[1] === 'submit' && isset ($this->_langArray['form'][$arrValue[0]])) + { + $tmp_node->setAttributeNode(new DOMAttr ('value', $this->_langArray['form'][$arrValue[0]])); + } + elseif (isset ($arrValue[1])) + { + $tmp_node->setAttributeNode(new DOMAttr ('value', $arrValue[1])); + } + elseif (isset ($this->_langArray['formText'][$arrValue[0]])) + { + $tmp_node->appendChild(new DOMText ($this->_langArray['formText'][$arrValue[0]])); + } + + if ($arrDefinition[0] === 'input' && ($arrDefinition[1] !== 'hidden' && $arrDefinition[1] !== 'submit')) + { + $tmp_div->appendChild($tmp_node); + + $tmp_node = $this->_tpl->createElement('label'); + $tmp_node->setAttributeNode(new DOMAttr ('for', $arrValue[0])); + $tmp_node->appendChild(new DOMText ($this->_langArray['form'][$arrValue[0]])); + $tmp_div->appendChild($tmp_node); + + $node->appendChild($tmp_div); + if ($fieldCounter % 2 === 0) + { + $tmp_br = $this->_tpl->createElement('br'); + $tmp_br->setAttributeNode(new DOMAttr ('class', 'fix')); + $node->appendChild($tmp_br); + } + + } + else + { + $node->appendChild($tmp_node); + } + + } + $new_node->appendChild($node); + + return $new_node; + } + + +} \ No newline at end of file diff --git a/.classes/generic/renderFunctionsClass.php b/.classes/generic/renderFunctionsClass.php index b5a9902..159dc2a 100644 --- a/.classes/generic/renderFunctionsClass.php +++ b/.classes/generic/renderFunctionsClass.php @@ -1,89 +1,87 @@ _navData = $navData; - $this -> _subtpl = $tpl; - $this -> _node = $node; - $this -> _prefix = renderFunctionsClass :: getNavigationPrefix ( ); - - $node = renderFunctionsClass :: getNavigationNode ( 0 ); - if ( $node !== false ) - { - $this -> _node -> appendChild ( $node ); - } +class renderFunctionsClass extends renderClass_abstract +{ + private $_navData = array(); + private $_subtpl = null; + private $_node = null; + private $_websiteIds = array(); + private $_prefix = ''; - return $this -> _node; - } - - private function getNavigationPrefix ( ) - { - foreach ( $this -> _navData[ 0 ] as $tmp_data ) - { - foreach ( $tmp_data as $key => $value ) - { - if ( strpos ( $key , '_' ) !== false ) - { - return substr ( $key , 0 , strpos ( $key , '_' ) + 1 ); - } - else - { - return ''; - } - } - } - } - - private function getNavigationNode ( $navStart ) - { - if ( ! isset ( $this -> _navData[ $navStart ] ) || count ( $this -> _navData [ $navStart ] ) == 0 ) - { - return false; - } - $newNode = $this -> _subtpl -> createElement ( 'ul' ); - foreach ( $this -> _navData [ $navStart ] AS $key => $value ) - { - $newLi = $this -> _subtpl -> createElement ( 'li' ); - - $input = $this -> _subtpl -> createElement ( 'input' ); - $input -> setAttributeNode ( new DOMAttr ( 'type' , 'checkbox' ) ); - $input -> setAttributeNode ( new DOMAttr ( 'name' , str_replace ( '_outer' , '' , $this -> _node -> getAttribute ( 'id' ) . '[ ]' ) ) ); - $input -> setAttributeNode ( new DOMAttr ( 'value' , $this -> _prefix . $value[ $this -> _prefix . 'navId' ] ) ); - $input -> setAttributeNode ( new DOMAttr ( 'id' , $this -> _prefix . $value[ $this -> _prefix . 'navId' ] ) ); - if ( $this -> _prefix === 'portal_' && array_key_exists ( $value[ $this -> _prefix . 'navId' ] , $this -> _website ) ) - { - $input -> setAttributeNode ( new DOMAttr ( 'data-referer' , $this -> _website[ $value[ $this -> _prefix . 'navId' ] ][ 'prefix' ] . 'Rights' ) ); - } - $label = $this -> _subtpl -> createElement ( 'label' ); - $label -> setAttributeNode ( new DOMAttr ( 'for' , $this -> _prefix . $value[ $this -> _prefix . 'navId' ] ) ); - $label -> appendChild ( new DOMText ( $value[ $this -> _prefix . 'navName' ] ) ); - - $newLi -> appendChild ( $input ); - $newLi -> appendChild ( $label ); - - $sub_node = renderFunctionsClass :: getNavigationNode ( $value [ $this -> _prefix . 'navId' ] ); - if ( $sub_node !== false ) - { - $newLi -> setAttributeNode ( new DOMAttr ( 'class' , 'hasChild' ) ); - $newLi -> appendChild ( $sub_node ); - } - $newNode -> appendChild ( $newLi ); - - } - - unset ( $this -> _navData [ $navStart ] ); - - return $newNode; - - } + public function createNavigationRights($navData, $tpl, $node) + { + $this->_navData = $navData; + $this->_subtpl = $tpl; + $this->_node = $node; + $this->_prefix = renderFunctionsClass::getNavigationPrefix(); + + $node = renderFunctionsClass::getNavigationNode(0); + if ($node !== false) + { + $this->_node->appendChild($node); } -?> \ No newline at end of file + return $this->_node; + } + + private function getNavigationPrefix() + { + foreach ($this->_navData[0] as $tmp_data) + { + foreach ($tmp_data as $key => $value) + { + if (strpos($key, '_') !== false) + { + return substr($key, 0, strpos($key, '_') + 1); + } + else + { + return ''; + } + } + } + } + + private function getNavigationNode($navStart) + { + if (!isset ($this->_navData[$navStart]) || count($this->_navData [$navStart]) == 0) + { + return false; + } + $newNode = $this->_subtpl->createElement('ul'); + foreach ($this->_navData [$navStart] AS $key => $value) + { + $newLi = $this->_subtpl->createElement('li'); + + $input = $this->_subtpl->createElement('input'); + $input->setAttributeNode(new DOMAttr ('type', 'checkbox')); + $input->setAttributeNode(new DOMAttr ('name', str_replace('_outer', '', $this->_node->getAttribute('id') . '[ ]'))); + $input->setAttributeNode(new DOMAttr ('value', $this->_prefix . $value[$this->_prefix . 'navId'])); + $input->setAttributeNode(new DOMAttr ('id', $this->_prefix . $value[$this->_prefix . 'navId'])); + if ($this->_prefix === 'portal_' && array_key_exists($value[$this->_prefix . 'navId'], $this->_website)) + { + $input->setAttributeNode(new DOMAttr ('data-referer', $this->_website[$value[$this->_prefix . 'navId']]['prefix'] . 'Rights')); + } + $label = $this->_subtpl->createElement('label'); + $label->setAttributeNode(new DOMAttr ('for', $this->_prefix . $value[$this->_prefix . 'navId'])); + $label->appendChild(new DOMText ($value[$this->_prefix . 'navName'])); + + $newLi->appendChild($input); + $newLi->appendChild($label); + + $sub_node = renderFunctionsClass:: getNavigationNode($value [$this->_prefix . 'navId']); + if ($sub_node !== false) + { + $newLi->setAttributeNode(new DOMAttr ('class', 'hasChild')); + $newLi->appendChild($sub_node); + } + $newNode->appendChild($newLi); + + } + + unset ($this->_navData [$navStart]); + + return $newNode; + + } +} \ No newline at end of file diff --git a/.classes/generic/renderImageClass.php b/.classes/generic/renderImageClass.php index b77562e..8da59b3 100644 --- a/.classes/generic/renderImageClass.php +++ b/.classes/generic/renderImageClass.php @@ -1,37 +1,35 @@ _imgData = $imgData; - $new_node = $this -> _tpl -> createDocumentFragment ( ); - $node = $this -> _tpl -> createElement ( 'img' ); - - $node -> setAttributeNode ( new DOMAttr ( 'src' , $this -> _imgData[ 'path' ] . $this -> _imgData[ 'navId' ] . $this -> _imgData[ 'src' ] ) ); - if ( ! is_null ( $imgData[ 'title' ] ) && $imgData[ 'title' ] !== '' ) - { - $node -> setAttributeNode ( new DOMAttr ( 'title' , $this -> _imgData[ 'title' ] ) ); - } - - if ( isset ( $imgData[ 'id' ] ) && $isEditable ) - { - $node -> setAttributeNode ( new DOMAttr ( 'data-editable' , $type ) ); - $node -> setAttributeNode ( new DOMAttr ( 'id' , $type . '_' . $this -> _imgData[ 'id' ] ) ); - } - else if ( $isEditable ) - { - $node -> setAttributeNode ( new DOMAttr ( 'data-editable' , $type ) ); - $node -> setAttributeNode ( new DOMAttr ( 'id' , $type . '_0' ) ); - } - - $new_node -> appendChild ( $node ); +class renderImageClass extends renderClass_abstract +{ + private $_imgData = array(); - return $new_node; - } - + public function createImage($imgData, $isEditable, $type) + { + $this->_imgData = $imgData; + $new_node = $this->_tpl->createDocumentFragment(); + $node = $this->_tpl->createElement('img'); + + $node->setAttributeNode(new DOMAttr ('src', $this->_imgData['path'] . $this->_imgData['navId'] . $this->_imgData['src'])); + if (!is_null($imgData['title']) && $imgData['title'] !== '') + { + $node->setAttributeNode(new DOMAttr ('title', $this->_imgData['title'])); } -?> \ No newline at end of file + if (isset ($imgData['id']) && $isEditable) + { + $node->setAttributeNode(new DOMAttr ('data-editable', $type)); + $node->setAttributeNode(new DOMAttr ('id', $type . '_' . $this->_imgData['id'])); + } + else if ($isEditable) + { + $node->setAttributeNode(new DOMAttr ('data-editable', $type)); + $node->setAttributeNode(new DOMAttr ('id', $type . '_0')); + } + + $new_node->appendChild($node); + + return $new_node; + } + +} \ No newline at end of file diff --git a/.classes/generic/renderNavigationClass.php b/.classes/generic/renderNavigationClass.php index c28bb16..ef002ce 100644 --- a/.classes/generic/renderNavigationClass.php +++ b/.classes/generic/renderNavigationClass.php @@ -1,109 +1,108 @@ _navData = $navData; - $this -> _node = $this -> _tpl -> createDocumentFragment ( ); - $navKeys = array_keys ( $navData ); - $firstKey = $navKeys[ 0 ]; - $this -> _firstKey = $firstKey; - $this -> _prefix = renderNavigationClass :: getNavigationPrefix ( ); - - $node = renderNavigationClass :: getNavigationNode ( $this -> _firstKey ); - if ( $node !== false ) - { - $this -> _node -> appendChild ( $node ); - } +class renderNavigationClass extends renderClass_abstract +{ + private $_navData = array(); + private $_node = null; + private $_prefix = ''; + private $_firstKey = 0; - return $this -> _node; - } - - private function getNavigationPrefix ( ) - { - foreach ( $this -> _navData[ $this -> _firstKey ][ 0 ] as $key => $value ) - { - if ( strpos ( $key , '_' ) !== false ) - { - return substr ( $key , 0 , strpos ( $key , '_' ) + 1 ); - } - else - { - return ''; - } - } - } - - private function getNavigationNode ( $navStart ) - { - if ( ! isset ( $this -> _navData[ $navStart ] ) || count ( $this -> _navData [ $navStart ] ) == 0 ) - { - return false; - } - - $newNode = $this -> _tpl -> createElement ( 'ul' ); - foreach ( $this -> _navData [ $navStart ] AS $key => $value ) - { - if ( $this -> _textsFromConfig ) - { - if ( array_key_exists ( $value [ $this -> _prefix . 'navId' ] , $this -> _website ) ) - { - $navTitle = $this -> _website[ $value [ $this -> _prefix . 'navId' ] ][ 'names' ]; - } - else - { - $navTitle = $this -> _langArray [ 'navi' ][ 'site_' . $value [ $this -> _prefix . 'navId' ] ]; - } - } - else - { - $navTitle = $value[ $this -> _prefix . 'navName' ]; - } - if ( $this -> _modrewrite ) - { - $navHref = $value[ $this -> _prefix . 'navLink' ]; - } - else - { - $navHref = ( ! isset ( $value[ $this -> _prefix . 'navType' ] ) || ( isset ( $value[ $this -> _prefix . 'navType' ] ) && $value[ $this -> _prefix . 'navType' ] === 'html' ) ) - ? $value [ $this -> _prefix . 'navTarget' ] - : 'javascript:void( 0 );'; - } - - $newLi = $this -> _tpl -> createElement ( 'li' ); - $newHref = $this -> _tpl -> createElement ( 'a' ); - if ( in_array ( $value[ $this -> _prefix . 'navId' ] , $this -> _navpath ) ) - { - $newHref -> setAttributeNode ( new DOMAttr ( 'class' , 'active' ) ); - } - $newHref -> appendChild ( new DOMText ( $navTitle ) ); - $newHref -> setAttributeNode ( new DOMAttr ( 'href' , $navHref ) ); - if ( isset ( $value[ $this -> _prefix . 'navType' ] ) && $value[ $this -> _prefix . 'navType' ] === 'js' ) - { - $newHref -> setAttributeNode ( new DOMAttr ( 'onclick' , $value[ $this -> _prefix . 'navTarget' ] ) ); - } - $newLi -> appendChild ( $newHref ); - - $sub_node = renderNavigationClass :: getNavigationNode ( $value[ $this -> _prefix . 'navId' ] ); - if ( $sub_node !== false ) - { - $newLi -> appendChild ( $sub_node ); - } - $newNode -> appendChild ( $newLi ); - - } - - unset ( $this -> _navData [ $navStart ] ); - - return $newNode; - - } + public function createNavigation($navData) + { + $this->_navData = $navData; + $this->_node = $this->_tpl->createDocumentFragment(); + $navKeys = array_keys($navData); + $firstKey = $navKeys[0]; + $this->_firstKey = $firstKey; + $this->_prefix = renderNavigationClass:: getNavigationPrefix(); + + $node = renderNavigationClass:: getNavigationNode($this->_firstKey); + if ($node !== false) + { + $this->_node->appendChild($node); } -?> \ No newline at end of file + return $this->_node; + } + + private function getNavigationPrefix() + { + foreach ($this->_navData[$this->_firstKey][0] as $key => $value) + { + if (strpos($key, '_') !== false) + { + return substr($key, 0, strpos($key, '_') + 1); + } + else + { + return ''; + } + } + return ''; + } + + private function getNavigationNode($navStart) + { + if (!isset ($this->_navData[$navStart]) || count($this->_navData [$navStart]) == 0) + { + return false; + } + + $newNode = $this->_tpl->createElement('ul'); + foreach ($this->_navData [$navStart] AS $key => $value) + { + if ($this->_textsFromConfig) + { + if (array_key_exists($value [$this->_prefix . 'navId'], $this->_website)) + { + $navTitle = $this->_website[$value [$this->_prefix . 'navId']]['names']; + } + else + { + $navTitle = $this->_langArray ['navi']['site_' . $value [$this->_prefix . 'navId']]; + } + } + else + { + $navTitle = $value[$this->_prefix . 'navName']; + } + if ($this->_modrewrite) + { + $navHref = $value[$this->_prefix . 'navLink']; + } + else + { + $navHref = (!isset ($value[$this->_prefix . 'navType']) || (isset ($value[$this->_prefix . 'navType']) && $value[$this->_prefix . 'navType'] === 'html')) + ? $value [$this->_prefix . 'navTarget'] + : 'javascript:void( 0 );'; + } + + $newLi = $this->_tpl->createElement('li'); + $newHref = $this->_tpl->createElement('a'); + if (in_array($value[$this->_prefix . 'navId'], $this->_navpath)) + { + $newHref->setAttributeNode(new DOMAttr ('class', 'active')); + } + $newHref->appendChild(new DOMText ($navTitle)); + $newHref->setAttributeNode(new DOMAttr ('href', $navHref)); + if (isset ($value[$this->_prefix . 'navType']) && $value[$this->_prefix . 'navType'] === 'js') + { + $newHref->setAttributeNode(new DOMAttr ('onclick', $value[$this->_prefix . 'navTarget'])); + } + $newLi->appendChild($newHref); + + $sub_node = renderNavigationClass:: getNavigationNode($value[$this->_prefix . 'navId']); + if ($sub_node !== false) + { + $newLi->appendChild($sub_node); + } + $newNode->appendChild($newLi); + + } + + unset ($this->_navData [$navStart]); + + return $newNode; + + } +} \ No newline at end of file diff --git a/.classes/generic/renderPopupClass.php b/.classes/generic/renderPopupClass.php index 9deea1b..6d639fa 100644 --- a/.classes/generic/renderPopupClass.php +++ b/.classes/generic/renderPopupClass.php @@ -1,278 +1,276 @@ _subTemplate !== '') { - private $_imgData = array ( ); - - public function createPopup ( $popupData ) + $html = file_get_contents($this->_pathTpl . $this->_layout . '/tpl_' . $this->_template . '_' . $this->_subTemplate . '.php'); + $html = str_replace($this->_renderSearch, $this->_renderReplace, $html); + $subTpl = new DOMDocument (); + $subTpl->preserveWhitespace = false; + $subTpl->formatOutput = true; + $subTpl->loadHTML($html); + $subCont = $subTpl->getElementById('sub_content')->firstChild; + + $xpath = new DOMXpath ($subTpl); + + /* Textersetzungen */ + foreach ($this->_langArray [$this->_template] as $key => $value) + { + $replaces = $xpath->query("//*[starts-with( . , '%" . $key . "%' )]"); + foreach ($replaces as $replace) { - if ( $this -> _subTemplate !== '' ) - { - $html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_' . $this -> _template . '_' . $this -> _subTemplate . '.php' ); - $html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html ); - $subTpl = new DOMDocument ( ); - $subTpl -> preserveWhitespace = false; - $subTpl -> formatOutput = true; - $subTpl -> loadHTML ( $html ); - $subCont = $subTpl -> getElementById ( 'sub_content' ) -> firstChild; - - $xpath = new DOMXpath ( $subTpl ); - - /* Textersetzungen */ - foreach ( $this -> _langArray [ $this -> _template ] as $key => $value ) - { - $replaces = $xpath -> query ( "//*[starts-with( . , '%" . $key . "%' )]" ); - foreach ( $replaces as $replace ) - { - if ( $replace -> firstChild -> nodeType === 3 ) - { - $replace -> replaceChild ( new DOMCdataSection ( $value ) , $replace -> firstChild ); - } - } - } - - /* Funktionen */ - if ( isset ( $popupData[ 'functions' ] ) && ! empty ( $popupData[ 'functions' ] ) ) - { - foreach ( $popupData[ 'functions' ] as $function ) - { - if ( $function[ 'position' ] === 'userWebsiteRights' ) - { - $node = $subTpl -> getElementById ( 'websiteRights' ) -> cloneNode ( true ); - $node -> firstChild -> nodeValue = $node -> firstChild -> nodeValue . ': ' . $this -> _website[ $function[ 'key' ] ][ 'names' ]; - $node -> removeAttribute ( 'id' ); - $node -> setAttributeNode ( new DOMAttr ( 'id' , $function[ 'prefix' ] . 'Rights' ) ); - - $newNode = $subTpl -> getElementById ( 'websiteRights' ) -> parentNode -> insertBefore ( $node , $subTpl -> getElementById ( 'websiteRights' ) ); - - /* Elemente ersetzen */ - $arr_replaces = array ( 'for' , 'id' , 'name' , 'onclick' ); - foreach ( $arr_replaces as $str_replace ) - { - $replaces = $xpath -> query ( ".//*[contains(@" . $str_replace . " , 'Website')]" , $newNode ); - foreach ( $replaces as $replace ) - { - $attribute = $replace -> getAttribute ( $str_replace ); - $replace -> removeAttribute ( $str_replace ); - $replace -> setAttributeNode ( new DOMAttr ( $str_replace , str_replace ( 'Website' , $function[ 'prefix' ] , $attribute ) ) ); - } - } - - $elem = $xpath -> query ( ".//*[@id='user" . $function[ 'prefix' ] . "Rights_outer']" , $newNode ); - $node = $elem -> item( 0 ); - } - else - { - $node = $subTpl -> getElementById ( $function[ 'position' ] . '_outer' ); - } - - if ( ! is_null ( $node ) ) - { - $this -> applyFunction ( $function[ 'name' ] , $function[ 'data' ] , $subTpl , $node , $function[ 'prefix' ] ); - } - } - - $node = $subTpl -> getElementById ( 'websiteRights' ); - $node -> parentNode -> removeChild ( $node ); - } - - /* Headerdaten */ - if ( isset ( $popupData[ 'header' ] ) && ! empty ( $popupData[ 'header' ] ) ) - { - $header_node = $subTpl -> getElementById ( 'sub_content_header' ); - foreach ( $popupData[ 'header' ] as $key => $value ) - { - $replaces = $xpath -> query ( ".//*[@id='" . $key . "']" , $header_node ); - foreach ( $replaces as $replaceNode ) - { - switch ( $replaceNode -> tagName ) - { - case 'select' : - foreach ( $value as $optionValue => $optionName ) - { - $option = $subTpl -> createElement ( 'option' ); - $option -> setAttributeNode ( new DOMAttr ( 'value' , $optionValue ) ); - if ( isset ( $this -> _postData[ $key ] ) && $this -> _postData[ $key ] == $optionValue ) - { - $option -> setAttributeNode ( new DOMAttr ( 'selected' , 'selected' ) ); - } - $option -> appendChild ( new DOMText ( $optionName ) ); - $replaceNode -> appendChild ( $option ); - } - break; - case 'input' : - $replaceNode -> setAttributeNode ( new DOMAttr ( 'value' , $value ) ); - $replaceNode -> setAttributeNode ( new DOMAttr ( 'autocomplete' , 'off' ) ); - default : - break; - } - } - } - } - - $this -> applySortRules ( $subTpl , $subCont , $xpath); - - /* Ausgabedaten */ - if ( isset ( $popupData[ 'main' ] ) && ! empty ( $popupData[ 'main' ] ) ) - { - $main = $subTpl -> getElementById ( 'sub_content_main' ); - $subNode = $main -> firstChild; - - $testArray = $popupData[ 'main' ][ 0 ]; - - /* Datenfelder */ - $arr_mainKeys = array ( ); - foreach ( $testArray as $key => $value ) - { - $elements = $xpath -> query ( "//*[@data-name='" . $key . "']" , $main ); - if ( $elements -> length !== 0 ) - { - $arr_mainKeys[ ] = $key; - } - } - - /* Eingabefelder */ - $arr_mainInputs = array ( ); - foreach ( $testArray as $key => $value ) - { - $elements = $xpath -> query ( "//form//*[@name='" . $key . "' or @name='" . $key . "[ ]']" , $main ); - if ( $elements -> length !== 0 ) - { - $arr_mainInputs[ ] = $key; - } - } - - /* Hauptdaten */ - foreach ( $popupData[ 'main' ] as $dataArray ) - { - $dataNode = $main -> firstChild -> cloneNode ( true ); - - /* Schaltflächen ( Links ) für die Bearbeitung in den Übersichtsseiten */ - foreach ( $this -> _dataParameter as $key => $new_parameter ) - { - $data_navigation = $xpath -> query ( ".//*[@data-navigation='" . $key . "']//a" , $dataNode ); - if ( $data_navigation -> length !== 0 ) - { - foreach ( $data_navigation as $navigation_item ) - { - if ( $navigation_item -> hasAttribute ( 'href' ) ) - { - $navigation_item -> setAttribute ( 'href' , $navigation_item -> getAttribute ( 'href' ) . '&' . $new_parameter . '=' . $dataArray[ $new_parameter ] ); - } - } - - } - } - - /* Spezielle Regeln anwenden */ - switch ( $this -> _template ) - { - /* Aktive - inaktive Elemente Unterscheiden */ - case 'usermanagement' : - if ( isset ( $dataArray[ 'userActive' ] ) && $dataArray[ 'userActive' ] === 'Y') - { - $dataNode -> setAttributeNode ( new DOMAttr ( 'class' , 'data_active' ) ); - } - else - { - $dataNode -> setAttributeNode ( new DOMAttr ( 'class' , 'data_inactive' ) ); - } - break; - default : - break; - } - - /* Werte zuweisen */ - foreach ( $arr_mainKeys as $key => $value ) - { - $elements = $xpath -> query ( ".//*[@data-name='" . $value . "']" , $dataNode ); - if ( $elements -> item( 0 ) -> hasChildNodes( ) ) - { - $elements -> item( 0 ) -> removeChild ( $elements -> item( 0 ) -> firstChild ); - } - /* TODO : Warum ist ein utf8_encode nötig? Evtl Server - Konfig */ - // $elements -> item( 0 ) -> appendChild ( new DOMText ( ( mb_detect_encoding ( $dataArray[ $value ] ) === 'UTF-8' ) ? $dataArray[ $value ] : utf8_encode ( $dataArray[ $value ] ) ) ); - $elements -> item( 0 ) -> appendChild ( new DOMText ( $dataArray[ $value ] ) ); - } - - foreach ( $arr_mainInputs as $key => $value ) - { - $elements = $xpath -> query ( ".//form//*[@name='" . $value . "' or @name='" . $value . "[ ]']" , $dataNode ); - foreach ( $elements as $element ) - { - switch ( $element -> tagName ) - { - case 'input' : - if ( $element -> hasAttribute ( 'type' ) ) - { - switch ( $element -> getAttribute ( 'type' ) ) - { - case 'text' : - case 'hidden' : - $element -> removeAttribute ( 'value' ); - $element -> setAttributeNode ( new DOMAttr ( 'value' , $dataArray[ $value ] ) ); - break; - case 'radio' : - if ( $element -> hasAttribute ( 'id' ) && $element -> getAttribute ( 'id' ) === ( $value . '_' . $dataArray[ $value ] ) ) - { - $element -> setAttributeNode ( new DOMAttr ( 'checked' , 'checked' ) ); - } - break; - case 'checkbox' : - if ( is_array ( $dataArray[ $value ] ) ) - { - if ( $element -> hasAttribute ( 'id' ) && in_array ( $element -> getAttribute ( 'id' ) , $dataArray[ $value ] ) ) - { - $element -> setAttributeNode ( new DOMAttr ( 'checked' , 'checked' ) ); - } - } - break; - default : - break; - } - } - else - { - $element -> removeAttribute ( 'value' ); - $element -> setAttributeNode ( new DOMAttr ( 'value' , $dataArray[ $value ] ) ); - } - break; - default : - break; - } - } - } - $main -> appendChild ( $dataNode ); - } - - $subNode -> parentNode -> removeChild ( $subNode ); - } - else - { - /* TODO : Keine Daten */ - $oldNode = $subTpl -> getElementById ( 'sub_content_main' ); - $oldNode -> parentNode -> removeChild ( $oldNode ); - } - } - - /* Fehlermeldungen */ - if ( ! is_null ( $this -> _errors ) ) - { - $main = $subTpl -> getElementById ( 'sub_content_main' ); - $subNode = $main -> firstChild; - foreach ( $this -> _errors as $error ) - { - $errorNode = $subTpl -> createElement ( 'p' ); - $errorNode -> setAttributeNode ( new DOMAttr ( 'class' , 'error' ) ); - $errorNode -> appendChild ( new DOMText ( $this -> _langArray[ 'error' ][ $error ] ) ); - $main -> insertBefore ( $errorNode , $subNode); - } - } - - $new_node = $this -> _tpl -> importNode ( $subCont , true ); - return $new_node; + if ($replace->firstChild->nodeType === 3) + { + $replace->replaceChild(new DOMCdataSection ($value), $replace->firstChild); + } } - + } + + /* Funktionen */ + if (isset ($popupData['functions']) && !empty ($popupData['functions'])) + { + foreach ($popupData['functions'] as $function) + { + if ($function['position'] === 'userWebsiteRights') + { + $node = $subTpl->getElementById('websiteRights')->cloneNode(true); + $node->firstChild->nodeValue = $node->firstChild->nodeValue . ': ' . $this->_website[$function['key']]['names']; + $node->removeAttribute('id'); + $node->setAttributeNode(new DOMAttr ('id', $function['prefix'] . 'Rights')); + + $newNode = $subTpl->getElementById('websiteRights')->parentNode->insertBefore($node, $subTpl->getElementById('websiteRights')); + + /* Elemente ersetzen */ + $arr_replaces = array('for', 'id', 'name', 'onclick'); + foreach ($arr_replaces as $str_replace) + { + $replaces = $xpath->query(".//*[contains(@" . $str_replace . " , 'Website')]", $newNode); + foreach ($replaces as $replace) + { + $attribute = $replace->getAttribute($str_replace); + $replace->removeAttribute($str_replace); + $replace->setAttributeNode(new DOMAttr ($str_replace, str_replace('Website', $function['prefix'], $attribute))); + } + } + + $elem = $xpath->query(".//*[@id='user" . $function['prefix'] . "Rights_outer']", $newNode); + $node = $elem->item(0); + } + else + { + $node = $subTpl->getElementById($function['position'] . '_outer'); + } + + if (!is_null($node)) + { + $this->applyFunction($function['name'], $function['data'], $subTpl, $node, $function['prefix']); + } + } + + $node = $subTpl->getElementById('websiteRights'); + $node->parentNode->removeChild($node); + } + + /* Headerdaten */ + if (isset ($popupData['header']) && !empty ($popupData['header'])) + { + $header_node = $subTpl->getElementById('sub_content_header'); + foreach ($popupData['header'] as $key => $value) + { + $replaces = $xpath->query(".//*[@id='" . $key . "']", $header_node); + foreach ($replaces as $replaceNode) + { + switch ($replaceNode->tagName) + { + case 'select' : + foreach ($value as $optionValue => $optionName) + { + $option = $subTpl->createElement('option'); + $option->setAttributeNode(new DOMAttr ('value', $optionValue)); + if (isset ($this->_postData[$key]) && $this->_postData[$key] == $optionValue) + { + $option->setAttributeNode(new DOMAttr ('selected', 'selected')); + } + $option->appendChild(new DOMText ($optionName)); + $replaceNode->appendChild($option); + } + break; + case 'input' : + $replaceNode->setAttributeNode(new DOMAttr ('value', $value)); + $replaceNode->setAttributeNode(new DOMAttr ('autocomplete', 'off')); + default : + break; + } + } + } + } + + $this->applySortRules($subTpl, $subCont, $xpath); + + /* Ausgabedaten */ + if (isset ($popupData['main']) && !empty ($popupData['main'])) + { + $main = $subTpl->getElementById('sub_content_main'); + $subNode = $main->firstChild; + + $testArray = $popupData['main'][0]; + + /* Datenfelder */ + $arr_mainKeys = array(); + foreach ($testArray as $key => $value) + { + $elements = $xpath->query("//*[@data-name='" . $key . "']", $main); + if ($elements->length !== 0) + { + $arr_mainKeys[] = $key; + } + } + + /* Eingabefelder */ + $arr_mainInputs = array(); + foreach ($testArray as $key => $value) + { + $elements = $xpath->query("//form//*[@name='" . $key . "' or @name='" . $key . "[ ]']", $main); + if ($elements->length !== 0) + { + $arr_mainInputs[] = $key; + } + } + + /* Hauptdaten */ + foreach ($popupData['main'] as $dataArray) + { + $dataNode = $main->firstChild->cloneNode(true); + + /* Schaltflächen ( Links ) für die Bearbeitung in den Übersichtsseiten */ + foreach ($this->_dataParameter as $key => $new_parameter) + { + $data_navigation = $xpath->query(".//*[@data-navigation='" . $key . "']//a", $dataNode); + if ($data_navigation->length !== 0) + { + foreach ($data_navigation as $navigation_item) + { + if ($navigation_item->hasAttribute('href')) + { + $navigation_item->setAttribute('href', $navigation_item->getAttribute('href') . '&' . $new_parameter . '=' . $dataArray[$new_parameter]); + } + } + + } + } + + /* Spezielle Regeln anwenden */ + switch ($this->_template) + { + /* Aktive - inaktive Elemente Unterscheiden */ + case 'usermanagement' : + if (isset ($dataArray['userActive']) && $dataArray['userActive'] === 'Y') + { + $dataNode->setAttributeNode(new DOMAttr ('class', 'data_active')); + } + else + { + $dataNode->setAttributeNode(new DOMAttr ('class', 'data_inactive')); + } + break; + default : + break; + } + + /* Werte zuweisen */ + foreach ($arr_mainKeys as $key => $value) + { + $elements = $xpath->query(".//*[@data-name='" . $value . "']", $dataNode); + if ($elements->item(0)->hasChildNodes()) + { + $elements->item(0)->removeChild($elements->item(0)->firstChild); + } + /* TODO : Warum ist ein utf8_encode nötig? Evtl Server - Konfig */ + // $elements -> item( 0 ) -> appendChild ( new DOMText ( ( mb_detect_encoding ( $dataArray[ $value ] ) === 'UTF-8' ) ? $dataArray[ $value ] : utf8_encode ( $dataArray[ $value ] ) ) ); + $elements->item(0)->appendChild(new DOMText ($dataArray[$value])); + } + + foreach ($arr_mainInputs as $key => $value) + { + $elements = $xpath->query(".//form//*[@name='" . $value . "' or @name='" . $value . "[ ]']", $dataNode); + foreach ($elements as $element) + { + switch ($element->tagName) + { + case 'input' : + if ($element->hasAttribute('type')) + { + switch ($element->getAttribute('type')) + { + case 'text' : + case 'hidden' : + $element->removeAttribute('value'); + $element->setAttributeNode(new DOMAttr ('value', $dataArray[$value])); + break; + case 'radio' : + if ($element->hasAttribute('id') && $element->getAttribute('id') === ($value . '_' . $dataArray[$value])) + { + $element->setAttributeNode(new DOMAttr ('checked', 'checked')); + } + break; + case 'checkbox' : + if (is_array($dataArray[$value])) + { + if ($element->hasAttribute('id') && in_array($element->getAttribute('id'), $dataArray[$value])) + { + $element->setAttributeNode(new DOMAttr ('checked', 'checked')); + } + } + break; + default : + break; + } + } + else + { + $element->removeAttribute('value'); + $element->setAttributeNode(new DOMAttr ('value', $dataArray[$value])); + } + break; + default : + break; + } + } + } + $main->appendChild($dataNode); + } + + $subNode->parentNode->removeChild($subNode); + } + else + { + /* TODO : Keine Daten */ + $oldNode = $subTpl->getElementById('sub_content_main'); + $oldNode->parentNode->removeChild($oldNode); + } } -?> \ No newline at end of file + /* Fehlermeldungen */ + if (!is_null($this->_errors)) + { + $main = $subTpl->getElementById('sub_content_main'); + $subNode = $main->firstChild; + foreach ($this->_errors as $error) + { + $errorNode = $subTpl->createElement('p'); + $errorNode->setAttributeNode(new DOMAttr ('class', 'error')); + $errorNode->appendChild(new DOMText ($this->_langArray['error'][$error])); + $main->insertBefore($errorNode, $subNode); + } + } + + $new_node = $this->_tpl->importNode($subCont, true); + return $new_node; + } + +} \ No newline at end of file diff --git a/.classes/generic/renderSpecialContentClass.php b/.classes/generic/renderSpecialContentClass.php index 3f7a412..5c2ea24 100644 --- a/.classes/generic/renderSpecialContentClass.php +++ b/.classes/generic/renderSpecialContentClass.php @@ -1,60 +1,58 @@ _pathTpl . $this->_layout . '/tpl_' . $this->_template . '_' . $id . '.php'); + $html = str_replace($this->_renderSearch, $this->_renderReplace, $html); + $subTpl = new DOMDocument (); + $subTpl->preserveWhitespace = false; + $subTpl->formatOutput = true; + $subTpl->loadHTML($html); + + $xpath = new DOMXpath ($subTpl); + $subCont = $xpath->query(".//*[contains(concat(' ', @class, ' '), ' " . $id . " ')]")->item(0); + + foreach ($popupData as $singleData) { - public function createSpecialContent ( $id , $popupData , $type ) + $tmp_node = $subCont->firstChild->cloneNode(true); + if (isset ($singleData['id'])) + { + $subCont->setAttributeNode(new DOMAttr ('id', $type . '_' . $singleData['id'])); + } + + foreach ($singleData as $key => $data) + { + $nodeList = $xpath->query(".//*[contains(concat(' ', @class, ' '), ' " . $key . " ')]", $tmp_node); + if ($nodeList->length !== 0) { - $html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_' . $this -> _template . '_' . $id . '.php' ); - $html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html ); - $subTpl = new DOMDocument ( ); - $subTpl -> preserveWhitespace = false; - $subTpl -> formatOutput = true; - $subTpl -> loadHTML ( $html ); - - $xpath = new DOMXpath ( $subTpl ); - $subCont = $xpath -> query ( ".//*[contains(concat(' ', @class, ' '), ' " . $id . " ')]" ) -> item( 0 ); - - foreach ( $popupData as $singleData ) + + foreach ($nodeList as $node) + { + switch ($key) { - $tmp_node = $subCont -> firstChild -> cloneNode ( true ); - if ( isset ( $singleData[ 'id' ] ) ) - { - $subCont -> setAttributeNode ( new DOMAttr ( 'id' , $type . '_' . $singleData[ 'id' ] ) ); - } - - foreach ( $singleData as $key => $data ) - { - $nodeList = $xpath -> query ( ".//*[contains(concat(' ', @class, ' '), ' " . $key . " ')]" , $tmp_node ); - if ( $nodeList -> length !== 0 ) - { - - foreach ( $nodeList as $node ) - { - switch ( $key ) - { - case 'link' : - $node -> setAttributeNode ( new DOMAttr ( 'href' , $data ) ); - break; - - default : - $node -> appendChild ( new DOMCdataSection ( $data ) ); - break; - } - } - - } - } - - $subCont -> appendChild ( $tmp_node ); + case 'link' : + $node->setAttributeNode(new DOMAttr ('href', $data)); + break; + + default : + $node->appendChild(new DOMCdataSection ($data)); + break; } - - $subCont -> removeChild ( $subCont -> firstChild ); - - - $new_node = $this -> _tpl -> importNode ( $subCont , true ); - return $new_node; + } + } - + } + + $subCont->appendChild($tmp_node); } -?> \ No newline at end of file + $subCont->removeChild($subCont->firstChild); + + + $new_node = $this->_tpl->importNode($subCont, true); + return $new_node; + } + +} \ No newline at end of file diff --git a/.classes/generic/renderWidgetClass.php b/.classes/generic/renderWidgetClass.php index b79adc7..e2dba1e 100644 --- a/.classes/generic/renderWidgetClass.php +++ b/.classes/generic/renderWidgetClass.php @@ -1,34 +1,32 @@ _pathTpl . $this->_layout . '/tpl_' . $this->_template . '_widget_' . $widgetData['tpl'] . '.php'); + $html = str_replace($this->_renderSearch, $this->_renderReplace, $html); + + foreach ($widgetData as $key => $value) { - - public function createWidget ( $widgetData ) - { - $html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_' . $this -> _template . '_widget_' . $widgetData[ 'tpl' ] . '.php' ); - $html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html ); - - foreach ( $widgetData as $key => $value ) - { - $html = str_replace ( '%%' . $key . '%%' , $value , $html ); - } - - $subTpl = new DOMDocument ( ); - $subTpl -> preserveWhitespace = false; - $subTpl -> formatOutput = true; - $subTpl -> loadHTML ( $html ); - - $xpath = new DOMXpath ( $subTpl ); - $subCont = $xpath -> query ( ".//*[contains(concat(' ', @class, ' '), ' " . $widgetData[ 'tpl' ] . " ')]" ) -> item( 0 ); - - if ( isset ( $widgetData[ 'id' ] ) ) - { - $subCont -> setAttributeNode ( new DOMAttr ( 'id' , 'widget_' . $widgetData[ 'id' ] ) ); - } - - $new_node = $this -> _tpl -> importNode ( $subCont , true ); - return $new_node; - } + $html = str_replace('%%' . $key . '%%', $value, $html); } -?> \ No newline at end of file + $subTpl = new DOMDocument (); + $subTpl->preserveWhitespace = false; + $subTpl->formatOutput = true; + $subTpl->loadHTML($html); + + $xpath = new DOMXpath ($subTpl); + $subCont = $xpath->query(".//*[contains(concat(' ', @class, ' '), ' " . $widgetData['tpl'] . " ')]")->item(0); + + if (isset ($widgetData['id'])) + { + $subCont->setAttributeNode(new DOMAttr ('id', 'widget_' . $widgetData['id'])); + } + + $new_node = $this->_tpl->importNode($subCont, true); + return $new_node; + } +} \ No newline at end of file diff --git a/.classes/rendering/viewClass.php b/.classes/rendering/viewClass.php index 4a3253d..4b9297e 100644 --- a/.classes/rendering/viewClass.php +++ b/.classes/rendering/viewClass.php @@ -1,135 +1,139 @@ _config = $config; + if (isset ($this->_config['portal']['website'])) { - private $_config = array( ); - private $_prefix = ''; - private $_pathTpl = ''; - private $_template = ''; - private $_siteId = 0; - private $_editable = false; - private $_webkey = 0; - private $_website = array( ); - private $_navpath = array( ); - private $_data = array( ); - private $_param = null; - private $_specialSite = false; - private $_formdata = array( ); - private $_error = array( ); - private $_lang = array( ); - - public function setConfig( $config ) - { - $this -> _config = $config; - if ( isset ( $this -> _config[ 'portal' ][ 'website' ] ) ) - { - $this -> setWebsite ( $this -> _config[ 'portal' ][ 'website' ] ); - } - } - - private function setWebsite( $website ) - { - $return_array = array ( ); - $tmp_array = array_flip ( $website[ 'navId' ] ); - foreach ( $tmp_array as $key => $value ) - { - foreach ( $website as $tmp_key => $tmp_value ) - { - $return_array[ $key ][ $tmp_key ] = $website[ $tmp_key ][ $value ]; - } - } - $this -> _website = $return_array; - } - - public function setPrefix( $prefix ) - { - $this -> _prefix = $prefix; - } - - public function setPathTpl( $pathTpl ) - { - if ( is_dir ( $pathTpl . $this -> _prefix ) ) - { - $this -> _pathTpl = $pathTpl . $this -> _prefix . '/'; - } - else - { - throw new Exception( 'Template Path does not exist' ); - } - } - - public function setTemplate( $template ) - { - if ( file_exists ( $this -> _pathTpl . 'tpl_' . $template . '.php' ) ) - { - $this -> _template = $this -> _pathTpl . 'tpl_' . $template . '.php'; - } - else - { - throw new Exception( 'Template "' . $this -> _pathTpl . 'tpl_' . $template . '.php" does not exist' ); - } - } - - public function setSiteId( $siteId ) - { - $this -> _siteId = $siteId; - } - - public function setEditable( $editable ) - { - $this -> _editable = $editable; - } - - public function setErrors( $error ) - { - $this -> _error = $error; - } - - public function setWebkey( $webkey ) - { - $this -> _webkey = $webkey; - } - - public function setNavpath( $navpath ) - { - $this -> _navpath = $navpath; - } - - public function setData( $data , $param = null ) - { - $this -> _data = $data; - $this -> _param = $param; - } - - public function setSpecialSite( $specialSite ) - { - $this -> _specialSite = $specialSite; - } - - public function setFormdata( $formdata ) - { - $this -> _formdata = $formdata; - } - - public function setError( $error ) - { - $this -> _error = $error; - } - - public function setLang( $lang ) - { - $this -> _lang = $lang; - } - - public function output( ) - { - ob_start( ); - require $this -> _template; - return ob_get_clean( ); - } - + $this->setWebsite($this->_config['portal']['website']); } + } -?> \ No newline at end of file + private function setWebsite($website) + { + $return_array = array(); + $tmp_array = array_flip($website['navId']); + foreach ($tmp_array as $key => $value) + { + foreach ($website as $tmp_key => $tmp_value) + { + $return_array[$key][$tmp_key] = $website[$tmp_key][$value]; + } + } + $this->_website = $return_array; + } + + public function setPrefix($prefix) + { + $this->_prefix = $prefix; + } + + public function setPathTpl($pathTpl) + { + if (is_dir($pathTpl . '/' . $this->_prefix)) + { + $this->_pathTpl = $pathTpl . $this->_prefix . '/'; + } + else + { + echo '
'; + var_dump($this->_pathTpl = $pathTpl . $this->_prefix . '/'); + echo ''; + //throw new Exception('Template Path does not exist'); + } + } + + public function setTemplate($template) + { + if (file_exists($this->_pathTpl . 'tpl_' . $template . '.php')) + { + $this->_template = $this->_pathTpl . 'tpl_' . $template . '.php'; + } + else + { + echo '
'; + var_dump($this->_template = $this->_pathTpl . 'tpl_' . $template . '.php'); + echo ''; + //throw new Exception('Template "' . $this->_pathTpl . 'tpl_' . $template . '.php" does not exist'); + } + } + + public function setSiteId($siteId) + { + $this->_siteId = $siteId; + } + + public function setEditable($editable) + { + $this->_editable = $editable; + } + + public function setErrors($error) + { + $this->_error = $error; + } + + public function setWebkey($webkey) + { + $this->_webkey = $webkey; + } + + public function setNavpath($navpath) + { + $this->_navpath = $navpath; + } + + public function setData($data, $param = null) + { + $this->_data = $data; + $this->_param = $param; + } + + public function setSpecialSite($specialSite) + { + $this->_specialSite = $specialSite; + } + + public function setFormdata($formdata) + { + $this->_formdata = $formdata; + } + + public function setError($error) + { + $this->_error = $error; + } + + public function setLang($lang) + { + $this->_lang = $lang; + } + + public function output() + { + ob_start(); + require $this->_template; + return ob_get_clean(); + } + +} \ No newline at end of file diff --git a/.classes/rendering/viewClass_abstract.php b/.classes/rendering/viewClass_abstract.php index 96d7e5c..ddd0fc0 100644 --- a/.classes/rendering/viewClass_abstract.php +++ b/.classes/rendering/viewClass_abstract.php @@ -1,34 +1,32 @@ _instance = $this; - } - - /** - * Destruktor - */ - public function __destruct( ) - { - } - - public function getInstance( ) - { - if ( ! isset( self::$_instance ) ) - { - $class = __CLASS__; - $instance = new $class; - } - return self::$_instance; - } - - } +class viewClass_abstract +{ + protected static $_instance = null; -?> \ No newline at end of file + /** + * Konstruktor + */ + public function __construct() + { + $this->_instance = $this; + } + + /** + * Destruktor + */ + public function __destruct() + { + } + + public function getInstance() + { + if (!isset(self::$_instance)) + { + $class = __CLASS__; + self::$_instance = new $class; + } + return self::$_instance; + } + +} \ No newline at end of file diff --git a/.config/config_global.php b/.config/config_global.php index f4e4035..57808bd 100644 --- a/.config/config_global.php +++ b/.config/config_global.php @@ -1,52 +1,132 @@ 'image/jpeg' , - 'png' => 'image/png' , - 'gif' => 'image/gif' - ); - - /* Weitere Includes */ - include_once ( PATH_CNF . 'config_version.php' ); - include_once ( PATH_INC . 'global_header.php' ); +/** + * Umgebung definieren + */ +$environment = getenv('ENVIRONMENT'); +if ($environment === false) +{ + $tmpPath = __DIR__; + $found = false; + while ($tmpPath != '/') + { + $htFile = $tmpPath . '/.htaccess'; + if (is_file($htFile) && is_readable($htFile)) + { + $htContent = file($htFile); + foreach ($htContent as $line => $text) + { + if (strpos($text, 'SetEnv') !== false && strpos($text, 'ENVIRONMENT') !== false) + { + $found = true; + $environment = trim(str_replace(array('SetEnv', 'ENVIRONMENT'), '', $text)); + break; + } + } + } + if ($found) + { + break; + } + $tmpPath = dirname($tmpPath); + } +} -?> \ No newline at end of file +define('ENVIRONMENT', $environment); + +if (isset($_SERVER['HTTPS'])) +{ + define('SCHEME', 'https'); +} +else +{ + define('SCHEME', 'http'); +} + +if (ENVIRONMENT === 'local') +{ + define('HOST_URL', SCHEME . '://192.168.178.66/svj/'); + define('PATH_PREFIX', '/svj'); +} +elseif (ENVIRONMENT === 'testing') +{ + define('HOST_URL', SCHEME . '://'); +} +elseif (ENVIRONMENT === 'production') +{ + define('HOST_URL', SCHEME . '://www.svj-fussball.de/'); + define('PATH_PREFIX', ''); +} +else +{ + die('Umgebungsvariable ist nicht gesetzt!'); +} +define('ADMIN_URL', HOST_URL . 'administrator'); + +/** + * Pfade definieren + */ +define('PATH_ROOT', dirname(__DIR__) . '/'); +define('PATH_SITE', PATH_PREFIX . '/administrator'); +define('PATH_ACT', PATH_ROOT . '.actions/'); +define('PATH_CLS', PATH_ROOT . '.classes/'); +define('PATH_CNF', PATH_ROOT . '.config/'); +define('PATH_FNC', PATH_ROOT . '.functions/'); +define('PATH_INC', PATH_ROOT . '.includes/'); +define('PATH_LANG', PATH_ROOT . '.lang/'); + + +/** + * Relative URLs für die Templates definieren + */ +define('HTML_IMG', PATH_PREFIX . '/images/'); +define('HTML_CSS', PATH_PREFIX . '/css/'); +define('PATH_CSS', PATH_SITE . '/css/'); +define('PATH_IMG', PATH_SITE . '/images/'); +define('PATH_JS', PATH_SITE . '/js/'); +define('PATH_MED', PATH_PREFIX . '/media/'); + +define('PATH_PORTAL_TPL', PATH_ROOT . 'administrator/templates/'); +define('PATH_WEBSITE_TPL', PATH_ROOT . 'templates/'); + + +/** + * Datenbank konfigurieren + */ +define('DB_TYPE', 'mysqli'); +define('DB_HOST', 'localhost'); +define('DB_NAME', 'c9svj'); +define('DB_USER', 'c9svj'); +define('DB_PASS', 'rXzmeEM@3'); + + +/** + * Tabellennamen definieren + */ +define('TBL_NAVI', 'navi'); +define('TBL_CONTENT', 'content'); +define('TBL_HEAD', 'content_headline'); +define('TBL_IMAGE', 'content_image'); +define('TBL_TEXT', 'content_text'); +define('TBL_TEXTIMAGE', 'content_textimage'); + +define('TBL_LOG', 'portal_log'); +define('TBL_RIGHTS', 'portal_rights'); +define('TBL_USER', 'portal_user'); + + +/** + * Mimetypes + */ +$vC['mimetypes'] = array +( + 'jpg' => 'image/jpeg', + 'png' => 'image/png', + 'gif' => 'image/gif' +); + +/** + * Weitere Includes + */ +include_once(PATH_CNF . 'config_version.php'); +include_once(PATH_INC . 'global_header.php'); \ No newline at end of file diff --git a/.config/config_svjf.php b/.config/config_svjf.php index 83fe6ab..1d88203 100644 --- a/.config/config_svjf.php +++ b/.config/config_svjf.php @@ -1,21 +1,26 @@ 'content' , 'uebersicht' => 'uebersicht' , 'spielbericht' => 'spielbericht' , 'turnier' => 'turnier' , 'widget' => 'widget' ); - $svjf[ 'host' ] = 'svj-fussball.de'; - $svjf[ 'fussballde' ] = '01M9R8HJO8000000VS541L4KVSEIO2C1'; - $svjf[ 'editorUrl' ] = $vC[ 'portal' ][ 'arrHost' ][ 'scheme' ] . '://steinle.no-ip.biz/rist_editors/'; - $svjf[ 'editorVersion' ] = '1.0'; - $svjf[ 'webserviceUrl' ] = $vC[ 'portal' ][ 'hostUrl' ] . '/webservices/remote_data.php'; - $svjf[ 'grid' ] = 24; - $svjf[ 'gridCount' ] = 40; - $svjf[ 'dimOrig' ] = array ( 'width' => 2560 , 'height' => 2560 ); - $svjf[ 'dimKeyvisual' ] = array ( 'width' => 864 , 'height' => 288 ); - $svjf[ 'dimImage' ] = array ( 'width' => 312 , 'height' => 234 ); - $svjf[ 'imageTypes' ] = array ( 'image/png' , 'image/jpeg' , 'image/gif' ); - $svjf[ 'keyvisualThumb' ] = array ( 'width' => 216 , 'height' => 72 ); - $svjf[ 'imageThumb' ] = array ( 'width' => 216 , 'height' => 324 ); - $svjf[ 'contentElems' ] = array ( 'subline' , 'text' , 'textimage' ); - -?> \ No newline at end of file +$svjf['names'] = 'SVJ-Fussball'; +$svjf['tpl'] = 'svjf'; +$svjf['host'] = 'svj-fussball.de'; +$svjf['fussballde'] = '01M9R8HJO8000000VS541L4KVSEIO2C1'; +if (ENVIRONMENT === 'local') +{ + $svjf['editorUrl'] = $vC['portal']['arrHost']['scheme'] . '://csteinle.ddns.net/rist-editors/'; + $svjf['editorVersion'] = '1.0.0'; +} +elseif (ENVIRONMENT === 'production') +{ + $svjf['editorUrl'] = $vC['portal']['arrHost']['scheme'] . '://rist-editors.ri-st.de/'; + $svjf['editorVersion'] = '1.0.0'; +} +$svjf['webserviceUrl'] = $vC['portal']['hostUrl'] . '/webservices/remote_data.php'; +$svjf['grid'] = 24; +$svjf['gridCount'] = 40; +$svjf['dimOrig'] = array('width' => 2560, 'height' => 2560); +$svjf['dimKeyvisual'] = array('width' => 864, 'height' => 288); +$svjf['dimImage'] = array('width' => 312, 'height' => 234); +$svjf['imageTypes'] = array('image/png', 'image/jpeg', 'image/gif'); +$svjf['keyvisualThumb'] = array('width' => 216, 'height' => 72); +$svjf['imageThumb'] = array('width' => 216, 'height' => 324); +$svjf['contentElems'] = array('subline', 'text', 'textimage'); \ No newline at end of file diff --git a/.config/config_version.php b/.config/config_version.php index 445b952..ea1b683 100644 --- a/.config/config_version.php +++ b/.config/config_version.php @@ -1,45 +1,49 @@ $value ) - { - $vC[ 'portal' ][ 'website' ][ $key ][ ] = $value; - } - } - - /* E-Mail Versand */ - $vC[ 'portal' ][ 'mail' ][ 'type' ] = 'smtp'; /* sendmail || smtp || mail */ - - /* Nur ausfüllen, falls 'type' === 'smtp' */ - $vC[ 'portal' ][ 'mail' ][ 'smtpAuth' ] = true; /* true || false */ - $vC[ 'portal' ][ 'mail' ][ 'smtpHost' ] = 'mail.arcor.de'; - $vC[ 'portal' ][ 'mail' ][ 'smtpUser' ] = 'christiansteinle'; - $vC[ 'portal' ][ 'mail' ][ 'smtpPass' ] = 'lmaa2dw'; - - $vC[ 'portal' ][ 'mail' ][ 'from' ] = 'noreply@svj-fussball.de'; - $vC[ 'portal' ][ 'mail' ][ 'fromName' ] = 'noreply SVJ'; - $vC[ 'portal' ][ 'mail' ][ 'returnPath' ] = 'christiansteinle@arocr.de'; - $vC[ 'portal' ][ 'mail' ][ 'html' ] = false; /* true || false */ - $vC[ 'portal' ][ 'mail' ][ 'charset' ] = 'UTF-8'; - - -?> \ No newline at end of file +/** + * Portal - Definitionen + */ +$vC['portal']['name'] = 'SVJ Fussball'; +$vC['portal']['hostUrl'] = ADMIN_URL; +$vC['portal']['arrHost'] = parse_url($vC['portal']['hostUrl']); +$vC['portal']['adminUserId'] = 3; +$vC['portal']['languages'] = array('de'); +$vC['portal']['address'] = 'informal'; /* formal || informal */ +$vC['portal']['layout'] = 'cs_l1'; +$vC['portal']['tplElements'] = array('login', 'navi_main', 'content'); +$vC['portal']['imgQuality'] = 90; + +/** + * Websitebearbeitung - Definitionen + */ +$vC['portal']['website']['navId'] = array('20'); +$vC['portal']['website']['prefix'] = array('svjf'); + +foreach ($vC['portal']['website']['prefix'] as $config) +{ + include_once(PATH_CNF . 'config_' . $config . '.php'); + + foreach ($$config as $key => $value) + { + $vC['portal']['website'][$key][] = $value; + } +} + +/** + * E-Mail Versand + */ +$vC['portal']['mail']['type'] = 'smtp'; /* sendmail || smtp || mail */ + +/** + * Nur ausfüllen, falls 'type' === 'smtp' + */ +$vC['portal']['mail']['smtpAuth'] = true; /* true || false */ +$vC['portal']['mail']['smtpHost'] = 'mail.arcor.de'; +$vC['portal']['mail']['smtpUser'] = 'christiansteinle'; +$vC['portal']['mail']['smtpPass'] = 'lmaa2dw'; + +$vC['portal']['mail']['from'] = 'noreply@svj-fussball.de'; +$vC['portal']['mail']['fromName'] = 'noreply SVJ'; +$vC['portal']['mail']['returnPath'] = 'christiansteinle@arocr.de'; +$vC['portal']['mail']['html'] = false; /* true || false */ +$vC['portal']['mail']['charset'] = 'UTF-8'; \ No newline at end of file diff --git a/.functions/fnc_portal.php b/.functions/fnc_portal.php index 744567b..4f2dc76 100644 --- a/.functions/fnc_portal.php +++ b/.functions/fnc_portal.php @@ -1,430 +1,431 @@ 0 ) - ? '( ' . $prefix . '_navPosition = "' . implode ( '" OR ' . $prefix . '_navPosition = "' , $navPositions ) . '" )' - : ''; - $str_filter .= ( $onlyActive ) - ? ( $str_filter === '' ) - ? $prefix . '_navActive = "Y"' - : ' AND ' . $prefix . '_navActive = "Y"' - : ''; - $str_filter = ( $str_filter !== '' ) - ? ' WHERE ' . $str_filter - : ''; +function fnc_getNavigationArray($prefix, $onlyActive = true, $navPositions = array(), $namesFromConfig = array()) +{ + global $db; + $return = array(); - $navi = $db -> query - ( - 'SELECT + $str_filter = (count($navPositions) > 0) + ? '( ' . $prefix . '_navPosition = "' . implode('" OR ' . $prefix . '_navPosition = "', $navPositions) . '" )' + : ''; + $str_filter .= ($onlyActive) + ? ($str_filter === '') + ? $prefix . '_navActive = "Y"' + : ' AND ' . $prefix . '_navActive = "Y"' + : ''; + $str_filter = ($str_filter !== '') + ? ' WHERE ' . $str_filter + : ''; + + $navi = $db->query + ( + 'SELECT * FROM - ' . $prefix . '_' . TBL_NAVI . - $str_filter . ' + ' . $prefix . '_' . TBL_NAVI . + $str_filter . ' ORDER BY ' . $prefix . '_navStart ASC , ' . $prefix . '_navSort ASC;' - ); - while ( $dat_navi = $navi -> fetch_assoc( ) ) - { - if ( ! empty( $namesFromConfig ) ) - { - $dat_navi[ $prefix . '_navName' ] = $namesFromConfig[ 'site_' . $dat_navi[ $prefix . '_navId' ] ]; - } - $return[ $dat_navi[ $prefix . '_navStart' ] ][ ] = $dat_navi; - } - - return $return; - } - - function fnc_getSingleNavigationArrays ( $prefix , $navArray , $params , $pathWay ) + ); + while ($dat_navi = $navi->fetch_assoc()) + { + if (!empty($namesFromConfig)) { - $i = 0; - - foreach ( $params[ 'navLevel' ] as $key => $depth ) - { - if ( $params[ 'navDepth' ][ $key ] ) - { - if ( isset ( $pathWay[ $i ] ) && isset ( $navArray[ $pathWay[ $i ] ] ) ) - { - $return[ $key ][ $pathWay[ $i ] ] = $navArray[ $pathWay[ $i ] ]; - ++$i; - while ( $i < $depth ) - { - foreach ( $return[ $key ] as $subArray ) - { - foreach ( $subArray as $navPoint ) - { - if ( isset ( $navArray[ $navPoint[ $prefix . '_navId' ] ] ) ) - { - $return[ $key ][ $navPoint[ $prefix . '_navId' ] ] = $navArray[ $navPoint[ $prefix . '_navId' ] ]; - } - } - } - ++$i; - } - } - else - { - if ( ! isset ( $return[ $key ] ) ) - { - $return[ $key ] = null; - } - } - } - else - { - /* Nur die aktuelle Unternavigation */ - while ( $i < $depth && isset ( $pathWay [ $i ] ) ) - { - if ( isset ( $navArray[ $pathWay[ $i ] ] ) ) - { - $return[ $key ][ $pathWay[ $i ] ] = $navArray[ $pathWay[ $i ] ]; - } - else - { - if ( ! isset ( $return[ $key ] ) ) - { - $return[ $key ] = null; - } - } - ++$i; - } - } - } + $dat_navi[$prefix . '_navName'] = $namesFromConfig['site_' . $dat_navi[$prefix . '_navId']]; + } + $return[$dat_navi[$prefix . '_navStart']][] = $dat_navi; + } - return $return; - } - - function fnc_getPortalNavigationArray ( $prefix , $navArray , $rightsArray ) + return $return; +} + +function fnc_getSingleNavigationArrays($prefix, $navArray, $params, $pathWay) +{ + $i = 0; + + foreach ($params['navLevel'] as $key => $depth) + { + if ($params['navDepth'][$key]) { - foreach ( $navArray as $navStart => $navLevels ) + if (isset ($pathWay[$i]) && isset ($navArray[$pathWay[$i]])) + { + $return[$key][$pathWay[$i]] = $navArray[$pathWay[$i]]; + ++$i; + while ($i < $depth) { - if ( $navStart > 0 ) + foreach ($return[$key] as $subArray) + { + foreach ($subArray as $navPoint) { - if ( ! in_array ( $prefix . '_' . $navStart , $rightsArray ) && ! in_array( $navStart , $rightsArray )) - { - unset ( $navArray[ $navStart ] ); - } + if (isset ($navArray[$navPoint[$prefix . '_navId']])) + { + $return[$key][$navPoint[$prefix . '_navId']] = $navArray[$navPoint[$prefix . '_navId']]; + } } + } + ++$i; } - foreach ( $navArray as $key => $navLevels ) + } + else + { + if (!isset ($return[$key])) { - foreach ( $navLevels as $subKey => $navPoint ) - { - if ( intval( $navPoint[ $prefix . '_navId' ] ) > 1 && ( ! in_array ( $prefix . '_' . $navPoint[ $prefix . '_navId' ] , $rightsArray ) ) && ! in_array( $navPoint[ $prefix . '_navId'] , $rightsArray ) ) - { - unset ( $navArray[ $key ][ $subKey ] ); - } - } - + $return[$key] = null; } - return ( $navArray ); + } } - - function fnc_createPathHome ( $prefix , $navActive ) + else { - global $db; - - $navi = $db -> query - ( - 'SELECT + /* Nur die aktuelle Unternavigation */ + while ($i < $depth && isset ($pathWay [$i])) + { + if (isset ($navArray[$pathWay[$i]])) + { + $return[$key][$pathWay[$i]] = $navArray[$pathWay[$i]]; + } + else + { + if (!isset ($return[$key])) + { + $return[$key] = null; + } + } + ++$i; + } + } + } + + return $return; +} + +function fnc_getPortalNavigationArray($prefix, $navArray, $rightsArray) +{ + foreach ($navArray as $navStart => $navLevels) + { + if ($navStart > 0) + { + if (!in_array($prefix . '_' . $navStart, $rightsArray) && !in_array($navStart, $rightsArray)) + { + unset ($navArray[$navStart]); + } + } + } + foreach ($navArray as $key => $navLevels) + { + foreach ($navLevels as $subKey => $navPoint) + { + if (intval($navPoint[$prefix . '_navId']) > 1 && (!in_array($prefix . '_' . $navPoint[$prefix . '_navId'], $rightsArray)) && !in_array($navPoint[$prefix . '_navId'], $rightsArray)) + { + unset ($navArray[$key][$subKey]); + } + } + + } + return ($navArray); +} + +function fnc_createPathHome($prefix, $navActive) +{ + global $db; + + $navi = $db->query + ( + 'SELECT * FROM ' . $prefix . '_' . TBL_NAVI . ' WHERE ' . $prefix . '_navId = "' . $navActive . '";' - ); - $arr_navi = $navi -> fetch_assoc ( ); - if ( $arr_navi[ $prefix . '_navStart' ] !== '0' && !is_null($arr_navi) ) - { - $return = fnc_createPathHome ( $prefix , $arr_navi[ $prefix . '_navStart' ] ); - } - else - { - $return[ ] = '0'; - } - $return[ ] = $navActive; - - return $return; - } - - function fnc_getNavType ( $prefix , $navActive ) - { - global $db; - - $navi = $db -> query - ( - 'SELECT + ); + $arr_navi = $navi->fetch_assoc(); + if ($arr_navi[$prefix . '_navStart'] !== '0' && !is_null($arr_navi)) + { + $return = fnc_createPathHome($prefix, $arr_navi[$prefix . '_navStart']); + } + else + { + $return[] = '0'; + } + $return[] = $navActive; + + return $return; +} + +function fnc_getNavType($prefix, $navActive) +{ + global $db; + + $navi = $db->query + ( + 'SELECT * FROM ' . $prefix . '_' . TBL_NAVI . ' WHERE ' . $prefix . '_navId = "' . $navActive . '";' - ); - $navPoint = $navi -> fetch_assoc ( ); - - if ( $navPoint[ $prefix . '_specialSite' ] === 'Y' ) - { - return $navPoint[ $prefix . '_specialType' ]; - } - else - { - return false; - } - } - function fnc_getUsernameById ( $userId ) - { - global $db; - $return = ''; - - $user = $db -> query - ( - 'SELECT + ); + $navPoint = $navi->fetch_assoc(); + + if ($navPoint[$prefix . '_specialSite'] === 'Y') + { + return $navPoint[$prefix . '_specialType']; + } + else + { + return false; + } +} + +function fnc_getUsernameById($userId) +{ + global $db; + $return = ''; + + $user = $db->query + ( + 'SELECT * FROM ' . TBL_USER . ' WHERE userId = "' . $userId . '";' - ); - if ( $user -> num_rows > 0 ) - { - $dat_user = $user -> fetch_assoc ( ); - $return = $dat_user[ 'userLastname' ] . ', ' . $dat_user[ 'userFirstname' ]; - } - - return $return; - } + ); + if ($user->num_rows > 0) + { + $dat_user = $user->fetch_assoc(); + $return = $dat_user['userLastname'] . ', ' . $dat_user['userFirstname']; + } - function fnc_getTimeByTS ( $timeStamp ) - { - $time = new DateTime ( $timeStamp ); - - return $time -> format ( 'd.m.Y - H:i:s' ); - } - - function fnc_generatePW ( $length = 8 ) - { - $passWord = ''; - - $pool = "qwertzupasdfghkyxcvbnm"; - $pool .= "23456789"; - $pool .= "WERTZUPLKJHGFDSAYXCVBNM"; - $pool .= "!§$%&/()="; - - srand ( ( double ) microtime ( ) * 1000000 ); - - for ( $i = 0 ; $i < $length ; $i++ ) - { - $passWord .= substr ( $pool , ( rand ( ) % ( strlen ( $pool ) ) ) , 1 ); - } - - return $passWord; - } - - function fnc_generateUniqueUsername ( $lastName , $firstName ) - { - global $db; - - $username = mb_strtolower ( substr ( $firstName , 0 , 1 ) , 'UTF-8' ) . mb_strtolower ( $lastName , 'UTF-8' ); - $count = $db -> query - ( - 'SELECT + return $return; +} + +function fnc_getTimeByTS($timeStamp) +{ + $time = new DateTime ($timeStamp); + + return $time->format('d.m.Y - H:i:s'); +} + +function fnc_generatePW($length = 8) +{ + $passWord = ''; + + $pool = "qwertzupasdfghkyxcvbnm"; + $pool .= "23456789"; + $pool .= "WERTZUPLKJHGFDSAYXCVBNM"; + $pool .= "!�$%&/()="; + + srand(( double )microtime() * 1000000); + + for ($i = 0; $i < $length; $i++) + { + $passWord .= substr($pool, (rand() % (strlen($pool))), 1); + } + + return $passWord; +} + +function fnc_generateUniqueUsername($lastName, $firstName) +{ + global $db; + + $username = mb_strtolower(substr($firstName, 0, 1), 'UTF-8') . mb_strtolower($lastName, 'UTF-8'); + $count = $db->query + ( + 'SELECT * FROM ' . TBL_USER . ' WHERE userUsername = "' . $username . '" OR userUsername LIKE "' . $username . '_%";' - ); - - if ( $count -> num_rows !== 0 ) - { - $username .= '_' . $count -> num_rows; - } - - return $username; - } - - function fnc_writeLog ( $entry , $params , $userId ) - { - global $db; - - $log = $db -> query - ( - 'INSERT INTO + ); + + if ($count->num_rows !== 0) + { + $username .= '_' . $count->num_rows; + } + + return $username; +} + +function fnc_writeLog($entry, $params, $userId) +{ + global $db; + + $db->query + ( + 'INSERT INTO ' . TBL_LOG . ' ( logEntry , logParams , logUser ) VALUES - ( "' . $entry . '" , "' . implode ( '::' , $params ) . '" , "' . $userId . '" );' - ); - } - - function fnc_readLog ( $entry , $params ) + ( "' . $entry . '" , "' . implode('::', $params) . '" , "' . $userId . '" );' + ); +} + +function fnc_readLog($entry, $params) +{ + if ($params !== '') + { + $arr_params = explode('::', $params); + foreach ($arr_params as $key => $value) { - if ( $params !== '' ) - { - $arr_params = explode ( '::' , $params ); - foreach ( $arr_params as $key => $value ) - { - $entry = str_replace ( '%' . $key . '%' , $value , $entry ); - } - } - return $entry; + $entry = str_replace('%' . $key . '%', $value, $entry); } - - function fnc_sendEmailToUser ( $mailId , $userId , $sessionUserId ) - { - global $db; - global $vC; - global $lang; - - $result = $db -> query - ( - 'SELECT + } + return $entry; +} + +function fnc_sendEmailToUser($mailId, $userId, $sessionUserId) +{ + global $db; + global $vC; + global $lang; + + $result = $db->query + ( + 'SELECT * FROM ' . TBL_USER . ' WHERE userId = "' . $userId . '" LIMIT 1;' - ); - $recipient = $result -> fetch_assoc ( ); - - $result = $db -> query - ( - 'SELECT + ); + $recipient = $result->fetch_assoc(); + + $result = $db->query + ( + 'SELECT * FROM ' . TBL_USER . ' WHERE userId = "' . $sessionUserId . '" LIMIT 1;' - ); - $sender = $result -> fetch_assoc ( ); - - $mailSubj = $lang[ 'mail' ][ 'subj' ][ $mailId ]; - $mailBody = $lang[ 'mail' ][ 'body' ][ $mailId ]; - - foreach ( $recipient as $key => $value ) - { - $mailBody = str_replace ( '%' . $key . '%' , $value , $mailBody ); - } - foreach ( $sender as $key => $value ) - { - $mailBody = str_replace ( '%sess_' . $key . '%' , $value , $mailBody ); - } - - require_once ( PATH_CLS . 'phpmailer/PHPMailerAutoload.php' ); - $mail = new PHPMailer; - - if ( $vC[ 'portal' ][ 'mail' ][ 'type' ] === 'smtp' ) - { - $mail -> isSMTP( ); - $mail -> Host = $vC[ 'portal' ][ 'mail' ][ 'smtpHost' ]; - $mail -> SMTPAuth = $vC[ 'portal' ][ 'mail' ][ 'smtpAuth' ]; - $mail -> Username = $vC[ 'portal' ][ 'mail' ][ 'smtpUser' ]; - $mail -> Password = $vC[ 'portal' ][ 'mail' ][ 'smtpPass' ]; - } - - $mail -> From = $vC[ 'portal' ][ 'mail' ][ 'from' ]; - $mail -> FromName = $vC[ 'portal' ][ 'mail' ][ 'fromName' ]; - $mail -> ReturnPath = $vC[ 'portal' ][ 'mail' ][ 'returnPath' ]; - $mail -> CharSet = $vC[ 'portal' ][ 'mail' ][ 'charset' ]; - $mail -> addAddress ( $recipient[ 'userEmail' ] , $recipient[ 'userFirstname' ] . ' ' . $recipient[ 'userLastname' ] ); - $mail -> isHTML ( $vC[ 'portal' ][ 'mail' ][ 'html' ] ); - - $mail -> Subject = $mailSubj; - $mail -> Body = $mailBody; - - if ( ! $mail -> send( ) ) - { - $return = $mail -> ErrorInfo; - } - else - { - $return = 'OK'; - } - return $return; - } - - function fnc_validateEmailAddress ( $emailAddress ) - { - if ( filter_var ( $emailAddress , FILTER_VALIDATE_EMAIL ) === false ) - { - return false; - } - return true; - } - - function fnc_checkUniqueEmailAddress ( $emailAddress , $userId = '' ) - { - global $db; - $return = false; - - if ( $userId !== '' ) - { - $count = $db -> query - ( - 'SELECT + ); + $sender = $result->fetch_assoc(); + + $mailSubj = $lang['mail']['subj'][$mailId]; + $mailBody = $lang['mail']['body'][$mailId]; + + foreach ($recipient as $key => $value) + { + $mailBody = str_replace('%' . $key . '%', $value, $mailBody); + } + foreach ($sender as $key => $value) + { + $mailBody = str_replace('%sess_' . $key . '%', $value, $mailBody); + } + + require_once(PATH_CLS . 'phpmailer/PHPMailerAutoload.php'); + $mail = new PHPMailer; + + if ($vC['portal']['mail']['type'] === 'smtp') + { + $mail->isSMTP(); + $mail->Host = $vC['portal']['mail']['smtpHost']; + $mail->SMTPAuth = $vC['portal']['mail']['smtpAuth']; + $mail->Username = $vC['portal']['mail']['smtpUser']; + $mail->Password = $vC['portal']['mail']['smtpPass']; + } + + $mail->From = $vC['portal']['mail']['from']; + $mail->FromName = $vC['portal']['mail']['fromName']; + $mail->ReturnPath = $vC['portal']['mail']['returnPath']; + $mail->CharSet = $vC['portal']['mail']['charset']; + $mail->addAddress($recipient['userEmail'], $recipient['userFirstname'] . ' ' . $recipient['userLastname']); + $mail->isHTML($vC['portal']['mail']['html']); + + $mail->Subject = $mailSubj; + $mail->Body = $mailBody; + + if (!$mail->send()) + { + $return = $mail->ErrorInfo; + } + else + { + $return = 'OK'; + } + return $return; +} + +function fnc_validateEmailAddress($emailAddress) +{ + if (filter_var($emailAddress, FILTER_VALIDATE_EMAIL) === false) + { + return false; + } + return true; +} + +function fnc_checkUniqueEmailAddress($emailAddress, $userId = '') +{ + global $db; + $return = false; + + if ($userId !== '') + { + $count = $db->query + ( + 'SELECT * FROM ' . TBL_USER . ' WHERE userId != "' . $userId . '" AND userEmail = "' . $emailAddress . '";' - ); - } - else - { - $count = $db -> query - ( - 'SELECT + ); + } + else + { + $count = $db->query + ( + 'SELECT * FROM ' . TBL_USER . ' WHERE userEmail = "' . $emailAddress . '";' - ); - } - if ( $count -> num_rows === 0 ) - { - $return = true; - } - return $return; - } - - function fnc_getSiteContents ( $contentParts , $prefix ) + ); + } + if ($count->num_rows === 0) + { + $return = true; + } + return $return; +} + +function fnc_getSiteContents($contentParts, $prefix) +{ + global $db; + $return = array(); + + $siteContents = explode(';', $contentParts); + foreach ($siteContents as $tmp_content) + { + if ($tmp_content === '') { - global $db; - $return = array( ); - - $siteContents = explode ( ';' , $contentParts ); - foreach ( $siteContents as $tmp_content ) - { - if ( $tmp_content === '' ) - { - continue; - } - $tmp_data = explode ( '_' , $tmp_content ); - - $id = end ( $tmp_data ); - unset ( $tmp_data[ count ( $tmp_data ) - 1 ] ); - $table = implode( '_' , $tmp_data ); - - if( $table === '' ) - { - continue; - } - - if ( $table === 'textimage' ) - { - $tmp_content = $db -> query - ( - 'SELECT + continue; + } + $tmp_data = explode('_', $tmp_content); + + $id = end($tmp_data); + unset ($tmp_data[count($tmp_data) - 1]); + $table = implode('_', $tmp_data); + + if ($table === '') + { + continue; + } + + if ($table === 'textimage') + { + $tmp_content = $db->query + ( + 'SELECT * , ' . $prefix . '_' . TBL_TEXTIMAGE . '.id AS text_image_id FROM ' . $prefix . '_' . TBL_TEXTIMAGE . ', @@ -435,31 +436,30 @@ ' . $prefix . '_' . TBL_TEXTIMAGE . '.content_image_id = ' . $prefix . '_' . TBL_IMAGE . '.id and ' . $prefix . '_' . TBL_TEXTIMAGE . '.id = ' . $id . ' LIMIT 1;' - ); - } - else - { - $tmp_content = $db -> query - ( - 'SELECT + ); + } + else + { + $tmp_content = $db->query + ( + 'SELECT * FROM ' . $prefix . '_content_' . $table . ' WHERE id = ' . $id . ';' - ); - } - - if ( $tmp_content -> num_rows === 0 ) - { - continue; - } - - $singleContent = $tmp_content -> fetch_assoc( ); - $singleContent[ 'type' ] = $table; - $return[ ] = $singleContent; - - } - return $return; + ); } -?> \ No newline at end of file + + if ($tmp_content->num_rows === 0) + { + continue; + } + + $singleContent = $tmp_content->fetch_assoc(); + $singleContent['type'] = $table; + $return[] = $singleContent; + + } + return $return; +} \ No newline at end of file diff --git a/.functions/fnc_webservices.php b/.functions/fnc_webservices.php index fedd60c..669275b 100644 --- a/.functions/fnc_webservices.php +++ b/.functions/fnc_webservices.php @@ -1,219 +1,216 @@ query('SELECT * FROM ' . $tblPrefix . '_' . TBL_NAVI . ' WHERE ' . $tblPrefix . '_navId = "' . $navId . '";'); + if ($result->num_rows !== 0) { - global $db; - - $return = $navId; - - if ( $navId !== '0' ) - { - $result = $db -> query ( 'SELECT * FROM ' . $tblPrefix . '_' . TBL_NAVI . ' WHERE ' . $tblPrefix . '_navId = "' . $navId . '";' ); - if ( $result -> num_rows !== 0 ) - { - $navPoint = $result -> fetch_assoc( ); - $return .= ' ' . fnc_getNavPathArray ( $tblPrefix , $navPoint[ $tblPrefix . '_navStart' ] ); - } - } - - return $return; + $navPoint = $result->fetch_assoc(); + $return .= ' ' . fnc_getNavPathArray($tblPrefix, $navPoint[$tblPrefix . '_navStart']); + } + } + + return $return; +} + +function fnc_buildUniqueLinkName($tblPrefix, $navStart, $navName) +{ + global $db; + + $search = array('ä', 'ö', 'ü', 'ß', ' ', '.', '/'); + $replace = array('ae', 'oe', 'ue', 'ss', '_', '', ''); + $ent = array_keys(get_html_translation_table(ENT_HTML5)); + + $return = str_replace($search, $replace, mb_strtolower($navName, mb_detect_encoding($navName))); + $return = str_replace($ent, '', $return); + + $result = $db->query('SELECT * FROM ' . $tblPrefix . '_' . TBL_NAVI . ' WHERE ' . $tblPrefix . '_navStart = "' . $navStart . '" AND ( ' . $tblPrefix . '_navLink = "' . $return . '" OR ' . $tblPrefix . '_navLink REGEXP "' . $return . '\_[0-9]" );'); + $count = $result->num_rows; + + $return = ($count > 0) + ? $return . '_' . $count + : $return; + + return $return; +} + +function fnc_buildUniqueFileName($prefix, $navId, $fileName, $fileExt) +{ + $search = array('ä', 'ö', 'ü', 'ß', ' ', '/'); + $replace = array('ae', 'oe', 'ue', 'ss', '_', ''); + $ent = array_keys(get_html_translation_table(ENT_HTML5)); + + $return = str_replace($search, $replace, mb_strtolower($fileName, mb_detect_encoding($fileName))); + $return = str_replace($ent, '', $return); + + $result = glob(PATH_MED . $prefix . '/' . $navId . '/' . $return . '*_orig.' . $fileExt); + $count = count($result); + $return = ($count > 0) + ? $return . '_' . $count + : $return; + + $return .= '.' . $fileExt; + + return $return; +} + +function fnc_checkOrigResize($filePath, $fileName_orig, $fileName_temp, $fileExt, $newSize) +{ + global $vC; + list ($width, $height) = getimagesize($filePath . $fileName_temp); + + if ($width > $newSize['width'] || $height > $newSize['height']) + { + if ($newSize['width'] / $width < $newSize['height'] / $height) + { + $newWidth = $newSize['width']; + $newHeight = $height * $newSize['width'] / $width; + } + else + { + $newWidth = $width * $newSize['height'] / $height; + $newHeight = $newSize['height']; + } + $newImage = imagecreatetruecolor($newWidth, $newHeight); + + if ($fileExt === 'jpg') + { + $origImg = imagecreatefromjpeg($filePath . $fileName_temp); + } + else if ($fileExt === 'png') + { + $origImg = imagecreatefrompng($filePath . $fileName_temp); + } + else if ($fileExt === 'gif') + { + $origImg = imagecreatefromgif($filePath . $fileName_temp); + } + else + { + return false; } - function fnc_buildUniqueLinkName ( $tblPrefix , $navStart , $navName ) - { - global $db; - - $return = false; - $search = array ( 'ä' , 'ö' , 'ü' , 'ß' , ' ' , '.' , '/' ); - $replace = array ( 'ae' , 'oe' , 'ue' , 'ss' , '_' , '' , '' ); - $ent = array_keys( get_html_translation_table( ENT_HTML5 ) ); - - $return = str_replace ( $search , $replace , mb_strtolower( $navName , mb_detect_encoding ( $navName ) ) ); - $return = str_replace ( $ent , '' , $return ); - - $result = $db -> query ( 'SELECT * FROM ' . $tblPrefix . '_' . TBL_NAVI . ' WHERE ' . $tblPrefix . '_navStart = "' . $navStart . '" AND ( ' . $tblPrefix . '_navLink = "' . $return . '" OR ' . $tblPrefix . '_navLink REGEXP "' . $return . '\_[0-9]" );' ); - $count = $result -> num_rows; + $return = imagecopyresampled($newImage, $origImg, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); - $return = ( $count > 0 ) - ? $return . '_' . $count - : $return; - - return $return; + if ($return === true) + { + if ($fileExt === 'jpg') + { + $return = imagejpeg($newImage, $filePath . $fileName_orig, $vC['portal']['imgQuality']); + } + else if ($fileExt === 'png') + { + $return = imagepng($newImage, $filePath . $fileName_orig); + } + else if ($fileExt === 'gif') + { + $return = imagegif($newImage, $filePath . $fileName_orig); + } } - function fnc_buildUniqueFileName ( $prefix , $navId , $fileName , $fileExt ) + unlink($filePath . $fileName_temp); + return $return; + } + else + { + rename($filePath . $fileName_temp, $filePath . $fileName_orig); + } + + return true; +} + +function fnc_buildImage($filePath, $fileName, $fileExt, $newSize, $previewParams) +{ + global $vC; + + list ($width, $height) = getimagesize($filePath . $fileName); + $newImage = imagecreatetruecolor($newSize['width'], $newSize['height']); + + if ($fileExt === 'jpg') + { + $origImg = imagecreatefromjpeg($filePath . $fileName); + } + else if ($fileExt === 'png') + { + $origImg = imagecreatefrompng($filePath . $fileName); + } + else if ($fileExt === 'gif') + { + $origImg = imagecreatefromgif($filePath . $fileName); + } + else + { + return false; + } + + $return = imagecopyresampled($newImage, $origImg, 0, 0, $previewParams['previewLeft'] * ($width / $newSize['width']), $previewParams['previewTop'] * ($width / $newSize['width']), $newSize['width'], $newSize['height'], $width * ($previewParams['previewWidth'] / $newSize['width']), $newSize['height'] * ($width / $newSize['width']) * ($previewParams['previewWidth'] / $newSize['width'])); + + if ($return === true) + { + if ($fileExt === 'jpg') { - $return = false; - $search = array ( 'ä' , 'ö' , 'ü' , 'ß' , ' ' , '/' ); - $replace = array ( 'ae' , 'oe' , 'ue' , 'ss' , '_' , '' ); - $ent = array_keys( get_html_translation_table( ENT_HTML5 ) ); - - $return = str_replace ( $search , $replace , mb_strtolower( $fileName , mb_detect_encoding ( $fileName ) ) ); - $return = str_replace ( $ent , '' , $return ); - - $result = glob ( PATH_MED . $prefix . '/' . $navId . '/' . $return . '*_orig.' . $fileExt ); - $count = count ( $result ); - $return = ( $count > 0 ) - ? $return . '_' . $count - : $return; - - $return .= '.' . $fileExt; - - return $return; + $return = imagejpeg($newImage, $filePath . str_replace('_orig', '', $fileName), $vC['portal']['imgQuality']); } - - function fnc_checkOrigResize ( $filePath , $fileName_orig , $fileName_temp , $fileExt , $newSize ) + else if ($fileExt === 'png') { - global $vC; - list ( $width , $height ) = getimagesize( $filePath . $fileName_temp ); - - if ( $width > $newSize[ 'width' ] || $height > $newSize[ 'height' ] ) - { - if ( $newSize[ 'width' ] / $width < $newSize[ 'height' ] / $height ) - { - $newWidth = $newSize[ 'width' ]; - $newHeight = $height * $newSize[ 'width' ] / $width; - } - else - { - $newWidth = $width * $newSize[ 'height' ] / $height; - $newHeight = $newSize[ 'height' ]; - } - $newImage = imagecreatetruecolor ( $newWidth , $newHeight ); - - if ( $fileExt === 'jpg' ) - { - $origImg = imagecreatefromjpeg( $filePath . $fileName_temp ); - } - else if ( $fileExt === 'png' ) - { - $origImg = imagecreatefrompng( $filePath . $fileName_temp ); - } - else if ( $fileExt === 'gif' ) - { - $origImg = imagecreatefromgif( $filePath . $fileName_temp ); - } - else - { - return false; - } - - $return = imagecopyresampled( $newImage , $origImg , 0 , 0 , 0 , 0 , $newWidth , $newHeight , $width , $height ); - - if ( $return === true ) - { - if ( $fileExt === 'jpg' ) - { - $return = imagejpeg( $newImage , $filePath . $fileName_orig , $vC[ 'portal' ][ 'imgQuality' ] ); - } - else if ( $fileExt === 'png' ) - { - $return = imagepng( $newImage , $filePath . $fileName_orig ); - } - else if ( $fileExt === 'gif' ) - { - $return = imagegif( $newImage , $filePath . $fileName_orig ); - } - } - - unlink ( $filePath . $fileName_temp ); - return $return; - } - else - { - rename ( $filePath . $fileName_temp , $filePath . $fileName_orig ); - } - - return true; + $return = imagepng($newImage, $filePath . str_replace('_orig', '', $fileName)); } - - function fnc_buildImage ( $filePath , $fileName , $fileExt , $newSize , $previewParams ) + else if ($fileExt === 'gif') { - global $vC; - - list ( $width , $height ) = getimagesize( $filePath . $fileName ); - $newImage = imagecreatetruecolor ( $newSize[ 'width' ] , $newSize[ 'height' ] ); - - if ( $fileExt === 'jpg' ) - { - $origImg = imagecreatefromjpeg( $filePath . $fileName ); - } - else if ( $fileExt === 'png' ) - { - $origImg = imagecreatefrompng( $filePath . $fileName ); - } - else if ( $fileExt === 'gif' ) - { - $origImg = imagecreatefromgif( $filePath . $fileName ); - } - else - { - return false; - } - - $return = imagecopyresampled( $newImage , $origImg , 0 , 0 , $previewParams[ 'previewLeft' ] * ( $width / $newSize[ 'width' ] ) , $previewParams[ 'previewTop' ] * ( $width / $newSize[ 'width' ] ) , $newSize[ 'width' ] , $newSize[ 'height' ] , $width * ( $previewParams[ 'previewWidth' ] / $newSize[ 'width' ] ) , $newSize[ 'height' ] * ( $width / $newSize[ 'width' ] ) * ( $previewParams[ 'previewWidth' ] / $newSize[ 'width' ] ) ); - - if ( $return === true ) - { - if ( $fileExt === 'jpg' ) - { - $return = imagejpeg( $newImage , $filePath . str_replace ( '_orig' , '' , $fileName ) , $vC[ 'portal' ][ 'imgQuality' ] ); - } - else if ( $fileExt === 'png' ) - { - $return = imagepng( $newImage , $filePath . str_replace ( '_orig' , '' , $fileName ) ); - } - else if ( $fileExt === 'gif' ) - { - $return = imagegif( $newImage , $filePath . str_replace ( '_orig' , '' , $fileName ) ); - } - } - - return $return; + $return = imagegif($newImage, $filePath . str_replace('_orig', '', $fileName)); } - - function fnc_buildThumbnail ( $filePath , $fileName , $fileExt , $newSize ) + } + + return $return; +} + +function fnc_buildThumbnail($filePath, $fileName, $fileExt, $newSize) +{ + global $vC; + + list ($width, $height) = getimagesize($filePath . $fileName); + $newImage = imagecreatetruecolor($newSize['width'], $newSize['height']); + + if ($fileExt === 'jpg') + { + $origImg = imagecreatefromjpeg($filePath . $fileName); + } + else if ($fileExt === 'png') + { + $origImg = imagecreatefrompng($filePath . $fileName); + } + else if ($fileExt === 'gif') + { + $origImg = imagecreatefromgif($filePath . $fileName); + } + else + { + return false; + } + + $return = imagecopyresampled($newImage, $origImg, 0, 0, 0, 0, $newSize['width'], $newSize['height'], $width, $height); + + if ($return === true) + { + if ($fileExt === 'jpg') { - global $vC; - - list ( $width , $height ) = getimagesize( $filePath . $fileName ); - $newImage = imagecreatetruecolor ( $newSize[ 'width' ] , $newSize[ 'height' ] ); - - if ( $fileExt === 'jpg' ) - { - $origImg = imagecreatefromjpeg( $filePath . $fileName ); - } - else if ( $fileExt === 'png' ) - { - $origImg = imagecreatefrompng( $filePath . $fileName ); - } - else if ( $fileExt === 'gif' ) - { - $origImg = imagecreatefromgif( $filePath . $fileName ); - } - else - { - return false; - } - - $return = imagecopyresampled( $newImage , $origImg , 0 , 0 , 0 , 0 , $newSize[ 'width' ] , $newSize[ 'height' ] , $width , $height ); - - if ( $return === true ) - { - if ( $fileExt === 'jpg' ) - { - $return = imagejpeg( $newImage , $filePath . str_replace ( '.' . $fileExt , '_thumb.' . $fileExt , $fileName ) , $vC[ 'portal' ][ 'imgQuality' ] ); - } - else if ( $fileExt === 'png' ) - { - $return = imagepng( $newImage , $filePath . str_replace ( '.' . $fileExt , '_thumb.' . $fileExt , $fileName ) ); - } - else if ( $fileExt === 'gif' ) - { - $return = imagegif( $newImage , $filePath . str_replace ( '.' . $fileExt , '_thumb.' . $fileExt , $fileName ) ); - } - } - - return $return; + $return = imagejpeg($newImage, $filePath . str_replace('.' . $fileExt, '_thumb.' . $fileExt, $fileName), $vC['portal']['imgQuality']); } -?> \ No newline at end of file + else if ($fileExt === 'png') + { + $return = imagepng($newImage, $filePath . str_replace('.' . $fileExt, '_thumb.' . $fileExt, $fileName)); + } + else if ($fileExt === 'gif') + { + $return = imagegif($newImage, $filePath . str_replace('.' . $fileExt, '_thumb.' . $fileExt, $fileName)); + } + } + + return $return; +} \ No newline at end of file diff --git a/.helpers/berichte2chronik.php b/.helpers/berichte2chronik.php index d7aeb71..714e68f 100644 --- a/.helpers/berichte2chronik.php +++ b/.helpers/berichte2chronik.php @@ -1,79 +1,77 @@ set_charset ( 'utf8' ); +$siteId = 20; +$saisonStart = array(2013, 2012, 2011, 2010, 2009); +$bereichArray = array('Frauen', 'Herren'); +$chronikIds = array(array(36, 42), array(48, 54)); +$teams = array(array(1, 2), array(1, 2)); +$teamNames = array(array('Verbandsliga', 'Bezirksliga'), array('Kreisliga A Alb', 'Reserve')); +$navPoints = array('Spielberichte', 'Tabelle', 'Mannschaft'); +$navSpecial = array('Y', 'Y', 'N'); +$navType = array('uebersicht', 'widget', null); - $yearOrder = 1; - - foreach ( $saisonStart as $startYear ) + +define('PATH_ROOT', '../'); +include_once(PATH_ROOT . '.config/config_global.php'); +include_once(PATH_FNC . 'fnc_portal.php'); + +$db = new mysqli (DB_HOST, DB_USER, DB_PASS, DB_NAME); +$db->set_charset('utf8'); + +$yearOrder = 1; + +foreach ($saisonStart as $startYear) +{ + $startDate = $startYear . '-08-01'; + $endDate = ($startYear + 1) . '-07-31'; + + foreach ($bereichArray as $key => $bereich) + { + foreach ($teams[$key] as $teamKey => $nummer) { - $startDate = $startYear . '-08-01'; - $endDate = ( $startYear + 1 ) . '-07-31'; + $berichte = $db->query('SELECT * FROM berichte WHERE Datum >= "' . $startDate . '" AND Datum <= "' . $endDate . '" AND Bereich = "' . $bereich . '" AND Nummer = "' . $nummer . '" ORDER BY Datum DESC;'); + $count = $berichte->num_rows; + $i = 0; + $teamName = $teamNames[$key][$teamKey]; + $chronikId = $chronikIds[$key][$teamKey]; - foreach ( $bereichArray as $key => $bereich ) + if ($count > 0) + { + $insertTeam = $db->query('INSERT INTO svjf_navi VALUES ( NULL , "' . $chronikId . '" , "' . $db->real_escape_string($teamName . ' ' . $startYear . '/' . ($startYear + 1)) . '" , "" , "' . mb_strtolower($teamName, 'UTF-8') . '_' . $startYear . '" , "Y" , "' . $yearOrder . '" , "N" , NULL );'); + $teamId = $db->insert_id; + $updateTeam = $db->query('UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $teamId . '" WHERE svjf_navId = "' . $teamId . '";'); + + foreach ($navPoints as $navKey => $navPoint) { - foreach ( $teams[ $key ] as $teamKey => $nummer ) - { - $berichte = $db -> query ( 'SELECT * FROM berichte WHERE Datum >= "' . $startDate . '" AND Datum <= "' . $endDate . '" AND Bereich = "' . $bereich . '" AND Nummer = "' . $nummer . '" ORDER BY Datum DESC;' ); - $count = $berichte -> num_rows; - $i = 0; - $teamName = $teamNames[ $key ][ $teamKey ]; - $chronikId = $chronikIds[ $key ][ $teamKey ]; - - if ( $count > 0 ) - { - $insertTeam = $db -> query ( 'INSERT INTO svjf_navi VALUES ( NULL , "' . $chronikId . '" , "' . $db -> real_escape_string ( $teamName . ' ' . $startYear . '/' . ( $startYear + 1 ) ) . '" , "" , "' . mb_strtolower ( $teamName , 'UTF-8' ) . '_' . $startYear . '" , "Y" , "' . $yearOrder . '" , "N" , NULL );' ); - $teamId = $db -> insert_id; - $updateTeam = $db -> query ( 'UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $teamId . '" WHERE svjf_navId = "' . $teamId . '";' ); - - foreach ( $navPoints as $navKey => $navPoint ) - { - $insertAreas = $db -> query ( 'INSERT INTO svjf_navi VALUES ( NULL , "' . $teamId . '" , "' . $navPoint . '" , "" , "' . mb_strtolower ( $navPoint , 'UTF-8' ) . '" , "Y" , "' . ( $navKey + 1 ) . '" , "' . $navSpecial[ $navKey ] . '" , "' . $navType[ $navKey ] . '" );' ); - $newNavStart = $db -> insert_id; - $updateAreas = $db -> query ( 'UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $newNavStart . '" WHERE svjf_navId = "' . $newNavStart . '";' ); - - if ( $navPoint = 'Spielberichte' ) - { - while ( $bericht = $berichte -> fetch_assoc ( ) ) - { - foreach ( $bericht as $tmp_key => $value ) - { - $bericht[ $tmp_key ] = $db -> real_escape_string ( $value ); - } - $insert = $db -> query ( 'INSERT INTO svjf_navi VALUES ( NULL , "' . $newNavStart . '" , "' . ( $count - $i ) . '. Spieltag" , "" , "spieltag_' . ( $count - $i ) . '" , "Y" , "' . ( $i + 1 ) . '" , "Y" , "spielbericht" );' ); - $navId = $db -> insert_id; - $update = $db -> query ( 'UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $navId . '" WHERE svjf_navId = "' . $navId . '";' ); - $insert = $db -> query ( 'INSERT INTO svjf_spielbericht VALUES ( "' . $navId . '" , "' . $bericht[ 'Head' ] . '" , "' . $bericht[ 'Heim' ] . '" , "' . $bericht[ 'ErgH' ] . '" , "' . $bericht[ 'ErgG' ] . '" , "' . $bericht[ 'HalbH' ] . '" , "' . $bericht[ 'HalbG' ] . '" , "' . $bericht[ 'Gegner' ] . '" , "' . $bericht[ 'Text' ] . '" , "' . $bericht[ 'Bild' ] . '" , "' . $bericht[ 'Spieler' ] . '" , "' . $bericht[ 'Tore' ] . '" , "' . $bericht[ 'Besonderes' ] . '" , "' . $bericht[ 'Vorschau' ] . '" , "' . $bericht[ 'Datum' ] . '" );' ); - - $i++; - } - } - else - { - /* TODO: svjf_content und andere Parts schreiben */ - } - } + $insertAreas = $db->query('INSERT INTO svjf_navi VALUES ( NULL , "' . $teamId . '" , "' . $navPoint . '" , "" , "' . mb_strtolower($navPoint, 'UTF-8') . '" , "Y" , "' . ($navKey + 1) . '" , "' . $navSpecial[$navKey] . '" , "' . $navType[$navKey] . '" );'); + $newNavStart = $db->insert_id; + $updateAreas = $db->query('UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $newNavStart . '" WHERE svjf_navId = "' . $newNavStart . '";'); - } + if ($navPoint = 'Spielberichte') + { + while ($bericht = $berichte->fetch_assoc()) + { + foreach ($bericht as $tmp_key => $value) + { + $bericht[$tmp_key] = $db->real_escape_string($value); + } + $insert = $db->query('INSERT INTO svjf_navi VALUES ( NULL , "' . $newNavStart . '" , "' . ($count - $i) . '. Spieltag" , "" , "spieltag_' . ($count - $i) . '" , "Y" , "' . ($i + 1) . '" , "Y" , "spielbericht" );'); + $navId = $db->insert_id; + $update = $db->query('UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $navId . '" WHERE svjf_navId = "' . $navId . '";'); + $insert = $db->query('INSERT INTO svjf_spielbericht VALUES ( "' . $navId . '" , "' . $bericht['Head'] . '" , "' . $bericht['Heim'] . '" , "' . $bericht['ErgH'] . '" , "' . $bericht['ErgG'] . '" , "' . $bericht['HalbH'] . '" , "' . $bericht['HalbG'] . '" , "' . $bericht['Gegner'] . '" , "' . $bericht['Text'] . '" , "' . $bericht['Bild'] . '" , "' . $bericht['Spieler'] . '" , "' . $bericht['Tore'] . '" , "' . $bericht['Besonderes'] . '" , "' . $bericht['Vorschau'] . '" , "' . $bericht['Datum'] . '" );'); + + $i++; } + } + else + { + /* TODO: svjf_content und andere Parts schreiben */ + } } - - $yearOrder++; + + } } - -?> \ No newline at end of file + } + + $yearOrder++; +} \ No newline at end of file diff --git a/.helpers/einzelne_berichte2navPoint.php b/.helpers/einzelne_berichte2navPoint.php index e1b3268..0581ad0 100644 --- a/.helpers/einzelne_berichte2navPoint.php +++ b/.helpers/einzelne_berichte2navPoint.php @@ -1,37 +1,36 @@ 2011 , 'end' => 2012 ); - $bereich = 'Frauen'; - $nummer = '1'; - $newNavStart = '277'; - $siteId = '20'; - - - $startDate = $saison[ 'start' ] . '-08-01'; - $endDate = $saison[ 'end' ] . '-07-31'; - - define ( 'PATH_ROOT' , '../' ); - include_once ( PATH_ROOT . '.config/config_global.php' ); - include_once ( PATH_FNC . 'fnc_portal.php' ); - - $db = new mysqli ( DB_HOST , DB_USER , DB_PASS , DB_NAME ); - $db -> set_charset ( 'utf8' ); +$saison = array('start' => 2011, 'end' => 2012); +$bereich = 'Frauen'; +$nummer = '1'; +$newNavStart = '277'; +$siteId = '20'; - $berichte = $db -> query ( 'SELECT * FROM berichte WHERE Datum >= "' . $startDate . '" AND Datum <= "' . $endDate . '" AND Bereich = "' . $bereich . '" AND Nummer = "' . $nummer . '" ORDER BY Datum DESC;' ); - $count = $berichte -> num_rows; - $i = 0; - - while ( $bericht = $berichte -> fetch_assoc ( ) ) - { - foreach ( $bericht as $key => $value ) - { - $bericht[ $key ] = $db -> real_escape_string ( $value ); - } - $insert = $db -> query ( 'INSERT INTO svjf_navi VALUES ( NULL , "' . $newNavStart . '" , "' . ( $count - $i ) . '. Spieltag" , "" , "spieltag_' . ( $count - $i ) . '" , "Y" , "' . ( $i + 1 ) . '" , "Y" , "spielbericht" );' ); - $navId = $db -> insert_id; - $update = $db -> query ( 'UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $navId . '" WHERE svjf_navId = "' . $navId . '";' ); - $insert = $db -> query ( 'INSERT INTO svjf_spielbericht VALUES ( "' . $navId . '" , "' . $bericht[ 'Head' ] . '" , "' . $bericht[ 'Heim' ] . '" , "' . $bericht[ 'ErgH' ] . '" , "' . $bericht[ 'ErgG' ] . '" , "' . $bericht[ 'HalbH' ] . '" , "' . $bericht[ 'HalbG' ] . '" , "' . $bericht[ 'Gegner' ] . '" , "' . $bericht[ 'Text' ] . '" , "' . $bericht[ 'Bild' ] . '" , "' . $bericht[ 'Spieler' ] . '" , "' . $bericht[ 'Tore' ] . '" , "' . $bericht[ 'Besonderes' ] . '" , "' . $bericht[ 'Vorschau' ] . '" , "' . $bericht[ 'Datum' ] . '" );' ); - - $i++; - } -?> \ No newline at end of file + +$startDate = $saison['start'] . '-08-01'; +$endDate = $saison['end'] . '-07-31'; + +define('PATH_ROOT', '../'); +include_once(PATH_ROOT . '.config/config_global.php'); +include_once(PATH_FNC . 'fnc_portal.php'); + +$db = new mysqli (DB_HOST, DB_USER, DB_PASS, DB_NAME); +$db->set_charset('utf8'); + +$berichte = $db->query('SELECT * FROM berichte WHERE Datum >= "' . $startDate . '" AND Datum <= "' . $endDate . '" AND Bereich = "' . $bereich . '" AND Nummer = "' . $nummer . '" ORDER BY Datum DESC;'); +$count = $berichte->num_rows; +$i = 0; + +while ($bericht = $berichte->fetch_assoc()) +{ + foreach ($bericht as $key => $value) + { + $bericht[$key] = $db->real_escape_string($value); + } + $insert = $db->query('INSERT INTO svjf_navi VALUES ( NULL , "' . $newNavStart . '" , "' . ($count - $i) . '. Spieltag" , "" , "spieltag_' . ($count - $i) . '" , "Y" , "' . ($i + 1) . '" , "Y" , "spielbericht" );'); + $navId = $db->insert_id; + $update = $db->query('UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $navId . '" WHERE svjf_navId = "' . $navId . '";'); + $insert = $db->query('INSERT INTO svjf_spielbericht VALUES ( "' . $navId . '" , "' . $bericht['Head'] . '" , "' . $bericht['Heim'] . '" , "' . $bericht['ErgH'] . '" , "' . $bericht['ErgG'] . '" , "' . $bericht['HalbH'] . '" , "' . $bericht['HalbG'] . '" , "' . $bericht['Gegner'] . '" , "' . $bericht['Text'] . '" , "' . $bericht['Bild'] . '" , "' . $bericht['Spieler'] . '" , "' . $bericht['Tore'] . '" , "' . $bericht['Besonderes'] . '" , "' . $bericht['Vorschau'] . '" , "' . $bericht['Datum'] . '" );'); + + $i++; +} \ No newline at end of file diff --git a/.helpers/fehlende_content_elemente.php b/.helpers/fehlende_content_elemente.php index 88fd8ac..3e4f717 100644 --- a/.helpers/fehlende_content_elemente.php +++ b/.helpers/fehlende_content_elemente.php @@ -1,69 +1,67 @@ set_charset( 'utf8' ); +/* Array mit NavIds */ +$nav_ids = array(); - $r_navi = $db -> query - ( - 'SELECT +define('PATH_ROOT', '../'); +include_once(PATH_ROOT . '.config/config_global.php'); + +$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); +$db->set_charset('utf8'); + +$r_navi = $db->query +( + 'SELECT * FROM ' . $prefix . TBL_NAVI . ' WHERE ' . $prefix . 'specialType = "content";' - ); - - while( $navi = $r_navi -> fetch_assoc( ) ) - { - $r_content = $db -> query - ( - 'SELECT +); + +while ($navi = $r_navi->fetch_assoc()) +{ + $r_content = $db->query + ( + 'SELECT * FROM - ' . $prefix . TBL_CONTENT . ' + ' . $prefix . TBL_CONTENT . ' WHERE - siteId = "' . $navi[ $prefix . 'navId' ] . '";' - ); - - if ( $r_content -> num_rows === 0 ) - { - $head = $db -> query - ( - 'INSERT INTO + siteId = "' . $navi[$prefix . 'navId'] . '";' + ); + + if ($r_content->num_rows === 0) + { + $head = $db->query + ( + 'INSERT INTO ' . $prefix . TBL_HEAD . ' ( content ) VALUES - ( "' . $navi[ $prefix . 'navName' ] . '" );' - ); - $h_id = $db -> insert_id; - $text = $db -> query - ( - 'INSERT INTO + ( "' . $navi[$prefix . 'navName'] . '" );' + ); + $h_id = $db->insert_id; + $text = $db->query + ( + 'INSERT INTO ' . $prefix . TBL_TEXT . ' ( content ) VALUES ( "Hier fehlt ein sinnvoller neuer Text" );' - ); - $t_id = $db -> insert_id; - - $cont = $db -> query - ( - 'INSERT INTO + ); + $t_id = $db->insert_id; + + $cont = $db->query + ( + 'INSERT INTO ' . $prefix . TBL_CONTENT . ' ( siteId , siteContents ) VALUES - ( "' . $navi[ $prefix . 'navId' ] . '" , "headline_' . $h_id . ';text_' . $t_id . '" );' - ); - } - } - -?> \ No newline at end of file + ( "' . $navi[$prefix . 'navId'] . '" , "headline_' . $h_id . ';text_' . $t_id . '" );' + ); + } +} \ No newline at end of file diff --git a/.helpers/jugend_teams.php b/.helpers/jugend_teams.php index 83a7435..56a1218 100644 --- a/.helpers/jugend_teams.php +++ b/.helpers/jugend_teams.php @@ -1,36 +1,34 @@ array ( 'A SGM Mähringen/Jungingen/Lehr' , 'B SGM Jungingen/Lehr/Mähringen' , 'C SGM Lehr/Jungingen/Mähringen' , 'D1/2 SVJ Jg. 2001/2002' , 'E1/2 SVJ Jg. 2003' , 'E3/4 SVJ Jg. 2004' , 'F1 SVJ Jg. 2005' , 'F2/3 SVJ Jg. 2006' , 'Bambini SG Lehr/Mähringen ab 2007' , 'Bambini SV Jungingen ab 2007' ) , 14 => array ( 'B SV Jungingen Jg. 1997/1998' , 'D SV Jungingen Jg. 2001/02' , 'E SV Jungingen bis Jg. 2003' ) ); - define ( 'PATH_ROOT' , '../' ); - include_once ( PATH_ROOT . '.config/config_global.php' ); - $db = new mysqli ( DB_HOST , DB_USER , DB_PASS , DB_NAME ); - $db -> set_charset ( 'utf8' ); +$siteId = 20; +$prefix = 'svjf'; +$navArray = array(13 => array('A SGM Mähringen/Jungingen/Lehr', 'B SGM Jungingen/Lehr/Mähringen', 'C SGM Lehr/Jungingen/Mähringen', 'D1/2 SVJ Jg. 2001/2002', 'E1/2 SVJ Jg. 2003', 'E3/4 SVJ Jg. 2004', 'F1 SVJ Jg. 2005', 'F2/3 SVJ Jg. 2006', 'Bambini SG Lehr/Mähringen ab 2007', 'Bambini SV Jungingen ab 2007'), 14 => array('B SV Jungingen Jg. 1997/1998', 'D SV Jungingen Jg. 2001/02', 'E SV Jungingen bis Jg. 2003')); +define('PATH_ROOT', '../'); +include_once(PATH_ROOT . '.config/config_global.php'); +$db = new mysqli (DB_HOST, DB_USER, DB_PASS, DB_NAME); +$db->set_charset('utf8'); - $i = 1; - foreach ( $navArray as $navStart => $navArray ) - { - foreach ( $navArray as $navName ) - { - $navLink = createLinkFromName ( $navName ); - $insert = $db -> query ( 'INSERT INTO ' . $prefix . '_navi VALUES ( NULL , "' . $navStart . '" , "' . $navName . '" , "" , "' . $navLink . '" , "Y" , "' . $i . '" , "N" , NULL );' ); - $navId = $db -> insert_id; - $update = $db -> query ( 'UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $navId . '" WHERE svjf_navId = "' . $navId . '";' ); - - ++$i; - } - } - - function createLinkFromName ( $name ) - { - $search = array ( 'ä' , 'ö' , 'ü' , '.' , ' ' ); - $replace = array ( 'ae' , 'oe' , 'ue' , '' , '_' ); - - $newName = mb_strtolower ( $name , 'UTF-8' ); - $link = str_replace ( $search , $replace , $newName ); - - return $link; - } - -?> \ No newline at end of file +$i = 1; +foreach ($navArray as $navStart => $navArray) +{ + foreach ($navArray as $navName) + { + $navLink = createLinkFromName($navName); + $insert = $db->query('INSERT INTO ' . $prefix . '_navi VALUES ( NULL , "' . $navStart . '" , "' . $navName . '" , "" , "' . $navLink . '" , "Y" , "' . $i . '" , "N" , NULL );'); + $navId = $db->insert_id; + $update = $db->query('UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $navId . '" WHERE svjf_navId = "' . $navId . '";'); + + ++$i; + } +} + +function createLinkFromName($name) +{ + $search = array('ä', 'ö', 'ü', '.', ' '); + $replace = array('ae', 'oe', 'ue', '', '_'); + + $newName = mb_strtolower($name, 'UTF-8'); + $link = str_replace($search, $replace, $newName); + + return $link; +} \ No newline at end of file diff --git a/.helpers/team_untermenu.php b/.helpers/team_untermenu.php index 1bb4488..40481f1 100644 --- a/.helpers/team_untermenu.php +++ b/.helpers/team_untermenu.php @@ -1,39 +1,37 @@ set_charset ( 'utf8' ); +$siteId = 20; +$prefix = 'svjf'; +$navArray = array(7, 8, 10, 11); +$newArray = array('Spielberichte', 'Tabelle', 'Mannschaft', 'Aktuelles', 'Training'); - foreach ( $navArray as $navStart ) - { - $i = 1; - foreach ( $newArray as $navName ) - { - $navLink = createLinkFromName ( $navName ); - - $insert = $db -> query ( 'INSERT INTO ' . $prefix . '_navi VALUES ( NULL , "' . $navStart . '" , "' . $navName . '" , "" , "' . $navLink . '" , "Y" , "' . $i . '" , "N" , NULL );' ); - $navId = $db -> insert_id; - $update = $db -> query ( 'UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $navId . '" WHERE svjf_navId = "' . $navId . '";' ); - - ++$i; - } - } - - function createLinkFromName ( $name ) - { - $search = array ( 'ä' , 'ö' , 'ü' , '.' , ' ' ); - $replace = array ( 'ae' , 'oe' , 'ue' , '' , '_' ); - - $newName = mb_strtolower ( $name , 'UTF-8' ); - $link = str_replace ( $search , $replace , $newName ); - - return $link; - } - -?> \ No newline at end of file +define('PATH_ROOT', '../'); +include_once(PATH_ROOT . '.config/config_global.php'); +$db = new mysqli (DB_HOST, DB_USER, DB_PASS, DB_NAME); +$db->set_charset('utf8'); + +foreach ($navArray as $navStart) +{ + $i = 1; + foreach ($newArray as $navName) + { + $navLink = createLinkFromName($navName); + + $insert = $db->query('INSERT INTO ' . $prefix . '_navi VALUES ( NULL , "' . $navStart . '" , "' . $navName . '" , "" , "' . $navLink . '" , "Y" , "' . $i . '" , "N" , NULL );'); + $navId = $db->insert_id; + $update = $db->query('UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $navId . '" WHERE svjf_navId = "' . $navId . '";'); + + ++$i; + } +} + +function createLinkFromName($name) +{ + $search = array('ä', 'ö', 'ü', '.', ' '); + $replace = array('ae', 'oe', 'ue', '', '_'); + + $newName = mb_strtolower($name, 'UTF-8'); + $link = str_replace($search, $replace, $newName); + + return $link; +} \ No newline at end of file diff --git a/.helpers/update_user_table.php b/.helpers/update_user_table.php index 05c2f65..313ae1b 100644 --- a/.helpers/update_user_table.php +++ b/.helpers/update_user_table.php @@ -1,37 +1,33 @@ set_charset ( 'utf8' ); - - $users = $db -> query ( 'SELECT * FROM users;' ); - - while ( $dat_user = $users -> fetch_assoc ( ) ) - { - $update = ''; - - if ( $dat_user [ 'userUsername' ] === '' ) - { - $update .= 'userUsername = "' . mb_strtolower ( substr ( $dat_user [ 'userFirstname' ] , 0 , 1 ) . $dat_user [ 'userLastname' ] ) . '"'; - } - if ( $dat_user [ 'userPasswordOrg' ] === '' ) - { - $update .= ( $update === '' ) - ? '' - : ' , '; - $newPassword = fnc_generatePW ( ); - $update .= 'userPasswordOrgCrypt = "' . md5 ( $newPassword ) . '" , userPasswordOrg = "' . $newPassword . '"'; - } - - if ( $update !== '' ) - { - $user_update = $db -> query ( 'UPDATE users SET ' . $update . ' WHERE userId = "' . $dat_user [ 'userId' ] . '" LIMIT 1;' ); - } - } +define('PATH_ROOT', '../'); +include_once(PATH_ROOT . '.config/config_global.php'); +include_once(PATH_FNC . 'fnc_portal.php'); +$db = new mysqli (DB_HOST, DB_USER, DB_PASS, DB_NAME); +$db->set_charset('utf8'); +$users = $db->query('SELECT * FROM users;'); -?> \ No newline at end of file +while ($dat_user = $users->fetch_assoc()) +{ + $update = ''; + + if ($dat_user ['userUsername'] === '') + { + $update .= 'userUsername = "' . mb_strtolower(substr($dat_user ['userFirstname'], 0, 1) . $dat_user ['userLastname']) . '"'; + } + if ($dat_user ['userPasswordOrg'] === '') + { + $update .= ($update === '') + ? '' + : ' , '; + $newPassword = fnc_generatePW(); + $update .= 'userPasswordOrgCrypt = "' . md5($newPassword) . '" , userPasswordOrg = "' . $newPassword . '"'; + } + + if ($update !== '') + { + $user_update = $db->query('UPDATE users SET ' . $update . ' WHERE userId = "' . $dat_user ['userId'] . '" LIMIT 1;'); + } +} \ No newline at end of file diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..8eb2dd0 --- /dev/null +++ b/.htaccess @@ -0,0 +1,16 @@ +
'; + var_dump($pathWay); + var_dump($arr_rights); -?> \ No newline at end of file + echo ''; + } + + } + } +} \ No newline at end of file diff --git a/.includes/website_rights.php b/.includes/website_rights.php index 02a8e70..98bae98 100644 --- a/.includes/website_rights.php +++ b/.includes/website_rights.php @@ -1,44 +1,42 @@ \ No newline at end of file + foreach ($arr_rights as $navRight) + { + $navId = str_replace($prefix . '_', '', $navRight); + if (in_array($navId, $pathWay)) + { + $editable = true; + break; + } + } + + } + } + } +} \ No newline at end of file diff --git a/.lang/informal/lang_de.php b/.lang/informal/lang_de.php index 57c8c31..f4dd37d 100644 --- a/.lang/informal/lang_de.php +++ b/.lang/informal/lang_de.php @@ -1,12 +1,11 @@ \ No newline at end of file + +/* Überschreiben der formellen Anreden mit informellen */ + +/* Formulare */ +$lang['formText']['login'] = 'Bitte gib Deine Benutzerdaten hier ein:'; +$lang['formText']['pwRepeat'] = 'Gib hier Dein neues Passwort ein und wiederhole die Eingabe zur Bestätigung:'; + +/* Mailtexte */ +$lang['mail']['body']['00000010'] = 'Hallo %userFirstname% %userLastname%,' . "\n\n" . '%sess_userFirstname% %sess_userLastname% hat Dir einen Zugang auf ' . $vC['portal']['hostUrl'] . ' eingerichtet. Deine Benutzerdaten lauten:' . "\n" . 'Anmeldename: %userUsername%' . "\n" . 'Password: %userPasswordOrg%' . "\n\n" . 'Bei der ersten Anmeldung am Portal mußt Du aus Sicherheitsgründen Dein Passwort ändern.' . "\n\n"; +$lang['mail']['body']['00000015'] = 'Hallo %userFirstname% %userLastname%,' . "\n\n" . 'Dein Passwort auf ' . $vC ['portal']['hostUrl'] . ' wurde von %sess_userFirstname% %sess_userLastname% zurückgesetzt. Es lautet:' . "\n" . '%userPasswordOrg%' . "\n\n" . 'Bei der ersten Anmeldung am Portal mußt Du aus Sicherheitsgründen Dein Passwort ändern.' . "\n\n"; \ No newline at end of file diff --git a/.lang/lang_de.php b/.lang/lang_de.php index c010582..f277a63 100644 --- a/.lang/lang_de.php +++ b/.lang/lang_de.php @@ -1,146 +1,148 @@ Hinweis:

+