diff --git a/ajax/ajax_accountSave.php b/ajax/ajax_accountSave.php index 87761656..34895957 100644 --- a/ajax/ajax_accountSave.php +++ b/ajax/ajax_accountSave.php @@ -25,7 +25,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php'; +require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Init.php'; SP_Util::checkReferer('POST'); diff --git a/ajax/ajax_appMgmtData.php b/ajax/ajax_appMgmtData.php index ed07d2d8..0ab3e219 100644 --- a/ajax/ajax_appMgmtData.php +++ b/ajax/ajax_appMgmtData.php @@ -24,7 +24,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; +require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); diff --git a/ajax/ajax_appMgmtSave.php b/ajax/ajax_appMgmtSave.php index af45e783..a4365043 100644 --- a/ajax/ajax_appMgmtSave.php +++ b/ajax/ajax_appMgmtSave.php @@ -25,7 +25,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; +require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); diff --git a/ajax/ajax_backup.php b/ajax/ajax_backup.php index 3341e4aa..b8abf3e0 100644 --- a/ajax/ajax_backup.php +++ b/ajax/ajax_backup.php @@ -24,7 +24,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php'; +require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Init.php'; SP_Util::checkReferer('POST'); diff --git a/ajax/ajax_checkLdap.php b/ajax/ajax_checkLdap.php index 7432eae6..f3724d2b 100644 --- a/ajax/ajax_checkLdap.php +++ b/ajax/ajax_checkLdap.php @@ -24,7 +24,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php'; +require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Init.php'; SP_Util::checkReferer('POST'); @@ -48,7 +48,7 @@ if (!$frmLdapServer || !$frmLdapBase || !$frmLdapBindUser || !$frmLdapBindPass) SP_Common::printJSON(_('Los parámetros de LDAP no están configurados')); } -$resCheckLdap = SP_LDAP::checkLDAPConn($frmLdapServer, $frmLdapBindUser, $frmLdapBindPass, $frmLdapBase, $frmLdapGroup); +$resCheckLdap = SP_Ldap::checkLDAPConn($frmLdapServer, $frmLdapBindUser, $frmLdapBindPass, $frmLdapBase, $frmLdapGroup); if ($resCheckLdap === false) { SP_Common::printJSON(_('Error de conexión a LDAP') . ';;' . _('Revise el registro de eventos para más detalles')); diff --git a/ajax/ajax_checkUpds.php b/ajax/ajax_checkUpds.php index dc209f19..08760160 100644 --- a/ajax/ajax_checkUpds.php +++ b/ajax/ajax_checkUpds.php @@ -24,7 +24,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php'; +require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Init.php'; SP_Util::checkReferer('GET'); diff --git a/ajax/ajax_configSave.php b/ajax/ajax_configSave.php index 751e9830..43a77630 100644 --- a/ajax/ajax_configSave.php +++ b/ajax/ajax_configSave.php @@ -25,7 +25,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; +require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); diff --git a/ajax/ajax_doLogin.php b/ajax/ajax_doLogin.php index d87b2bf2..a5f80323 100644 --- a/ajax/ajax_doLogin.php +++ b/ajax/ajax_doLogin.php @@ -25,7 +25,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; +require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); diff --git a/ajax/ajax_eventlog.php b/ajax/ajax_eventlog.php index 07811d96..e19f4461 100644 --- a/ajax/ajax_eventlog.php +++ b/ajax/ajax_eventlog.php @@ -24,7 +24,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; +require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); @@ -32,7 +32,7 @@ if (!SP_Init::isLoggedIn()) { SP_Util::logout(); } -SP_ACL::checkUserAccess('eventlog') || SP_Html::showCommonError('unavailable'); +SP_Acl::checkUserAccess('eventlog') || SP_Html::showCommonError('unavailable'); $start = SP_Common::parseParams('p', 'start', 0); $clear = SP_Common::parseParams('p', 'clear', 0); diff --git a/ajax/ajax_files.php b/ajax/ajax_files.php index 22c41fae..c20488e9 100644 --- a/ajax/ajax_files.php +++ b/ajax/ajax_files.php @@ -26,7 +26,7 @@ // TODO: comprobar permisos para eliminar archivos define('APP_ROOT', '..'); -require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; +require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); diff --git a/ajax/ajax_getContent.php b/ajax/ajax_getContent.php index 1a69c8b5..6ce777c3 100644 --- a/ajax/ajax_getContent.php +++ b/ajax/ajax_getContent.php @@ -24,7 +24,7 @@ * */ define('APP_ROOT', '..'); -require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php'; +require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Init.php'; SP_Util::checkReferer('POST'); @@ -53,41 +53,41 @@ switch ($action) { SP_Html::getTemplate('search', $tplvars); break; case "accnew": - SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); + SP_Acl::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); SP_Users::checkUserUpdateMPass() || SP_Html::showCommonError('updatempass'); SP_Html::getTemplate('accounts', $tplvars); break; case "acccopy": - SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); + SP_Acl::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); SP_Users::checkUserUpdateMPass() || SP_Html::showCommonError('updatempass'); SP_Html::getTemplate('accounts', $tplvars); break; case "accedit": - SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); + SP_Acl::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); SP_Users::checkUserUpdateMPass() || SP_Html::showCommonError('updatempass'); SP_Html::getTemplate('accounts', $tplvars); break; case "acceditpass": - SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); + SP_Acl::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); SP_Users::checkUserUpdateMPass() || SP_Html::showCommonError('updatempass'); SP_Html::getTemplate('editpass', $tplvars); break; case "accview": - SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); + SP_Acl::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); SP_Html::getTemplate('accounts', $tplvars); break; case "accviewhistory": - SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); + SP_Acl::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); SP_Html::getTemplate('accounts', $tplvars); break; case "accdelete": - SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); + SP_Acl::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); SP_Html::getTemplate('accounts', $tplvars); break; @@ -97,14 +97,14 @@ switch ($action) { case "usersmenu": echo '
'; echo ''; $activeTab = 0; - if (SP_ACL::checkUserAccess("users")) { + if (SP_Acl::checkUserAccess("users")) { $arrUsersTableProp = array( 'tblId' => 'tblUsers', 'header' => '', @@ -151,7 +151,7 @@ switch ($action) { echo '
'; } - if (SP_ACL::checkUserAccess("groups")) { + if (SP_Acl::checkUserAccess("groups")) { $arrGroupsTableProp = array( 'tblId' => 'tblGroups', 'header' => '', @@ -183,7 +183,7 @@ switch ($action) { echo ''; } - if (SP_ACL::checkUserAccess("profiles")) { + if (SP_Acl::checkUserAccess("profiles")) { $arrProfilesTableProp = array( 'tblId' => 'tblProfiles', 'header' => '', @@ -230,13 +230,13 @@ switch ($action) { case "appmgmtmenu": echo '
'; echo ''; $activeTab = 0; - if (SP_ACL::checkUserAccess("categories")) { + if (SP_Acl::checkUserAccess("categories")) { $arrCategoriesTableProp = array( 'tblId' => 'tblCategories', 'header' => '', @@ -268,7 +268,7 @@ switch ($action) { echo '
'; } - if (SP_ACL::checkUserAccess("customers")) { + if (SP_Acl::checkUserAccess("customers")) { $arrCustomersTableProp = array( 'tblId' => 'tblCustomers', 'header' => '', @@ -316,23 +316,23 @@ switch ($action) { case "configmenu": echo '
'; echo ''; $tplvars['activeTab'] = 0; $tplvars['onCloseAction'] = $action; - if (SP_ACL::checkUserAccess("config")) { + if (SP_Acl::checkUserAccess("config")) { echo '
'; SP_Html::getTemplate('config', $tplvars); echo '
'; } - if (SP_ACL::checkUserAccess("masterpass")) { + if (SP_Acl::checkUserAccess("masterpass")) { $tplvars['activeTab']++; echo '
'; @@ -340,7 +340,7 @@ switch ($action) { echo '
'; } - if (SP_ACL::checkUserAccess("backup")) { + if (SP_Acl::checkUserAccess("backup")) { $tplvars['activeTab']++; echo '
'; @@ -348,7 +348,7 @@ switch ($action) { echo '
'; } - if (SP_ACL::checkUserAccess("config")) { + if (SP_Acl::checkUserAccess("config")) { $tplvars['activeTab']++; echo '
'; @@ -356,7 +356,7 @@ switch ($action) { echo '
'; } - if (SP_ACL::checkUserAccess("config")) { + if (SP_Acl::checkUserAccess("config")) { $tplvars['activeTab']++; echo '
'; @@ -381,7 +381,7 @@ switch ($action) { . * */ define('APP_ROOT', '..'); require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; SP_Util::checkReferer('POST'); if (!SP_Init::isLoggedIn()) { SP_Common::printJSON(_('La sesión no se ha iniciado o ha caducado'), 10); } if (SP_Util::demoIsEnabled()) { SP_Common::printJSON(_('Ey, esto es una DEMO!!')); } $sk = SP_Common::parseParams('p', 'sk', false); if (!$sk || !SP_Common::checkSessionKey($sk)) { SP_Common::printJSON(_('CONSULTA INVÁLIDA')); } $res = SP_Import::doImport($_FILES["inFile"]); if (isset($res['error']) && is_array($res['error'])) { foreach ($res['error'] as $error) { $errors [] = $error['description']; $errors [] = $error['hint']; error_log($error['hint']); } $out = implode('\n\n', $errors); SP_Common::printJSON($out); } else if (is_array($res['ok'])) { $out = implode('\n\n', $res['ok']); SP_Common::printJSON($out, 0); } \ No newline at end of file +. * */ define('APP_ROOT', '..'); require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); if (!SP_Init::isLoggedIn()) { SP_Common::printJSON(_('La sesión no se ha iniciado o ha caducado'), 10); } if (SP_Util::demoIsEnabled()) { SP_Common::printJSON(_('Ey, esto es una DEMO!!')); } $sk = SP_Common::parseParams('p', 'sk', false); if (!$sk || !SP_Common::checkSessionKey($sk)) { SP_Common::printJSON(_('CONSULTA INVÁLIDA')); } $res = SP_Import::doImport($_FILES["inFile"]); if (isset($res['error']) && is_array($res['error'])) { foreach ($res['error'] as $error) { $errors [] = $error['description']; $errors [] = $error['hint']; error_log($error['hint']); } $out = implode('\n\n', $errors); SP_Common::printJSON($out); } else if (is_array($res['ok'])) { $out = implode('\n\n', $res['ok']); SP_Common::printJSON($out, 0); } \ No newline at end of file diff --git a/ajax/ajax_migrate.php b/ajax/ajax_migrate.php index 17dcc5f8..c4fca2f1 100644 --- a/ajax/ajax_migrate.php +++ b/ajax/ajax_migrate.php @@ -1 +1 @@ -. * */ define('APP_ROOT', '..'); require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; SP_Util::checkReferer('POST'); if (!SP_Init::isLoggedIn()) { SP_Common::printJSON(_('La sesión no se ha iniciado o ha caducado'), 10); } if (SP_Util::demoIsEnabled()) { SP_Common::printJSON(_('Ey, esto es una DEMO!!')); } $sk = SP_Common::parseParams('p', 'sk', false); if (!$sk || !SP_Common::checkSessionKey($sk)) { SP_Common::printJSON(_('CONSULTA INVÁLIDA')); } $frmDBUser = SP_Common::parseParams('p', 'dbuser'); $frmDBPass = SP_Common::parseParams('p', 'dbpass'); $frmDBName = SP_Common::parseParams('p', 'dbname'); $frmDBHost = SP_Common::parseParams('p', 'dbhost'); $frmMigrateEnabled = SP_Common::parseParams('p', 'chkmigrate', 0, false, 1); if (!$frmMigrateEnabled) { SP_Common::printJSON(_('Confirmar la importación de cuentas')); } if (!$frmDBUser) { SP_Common::printJSON(_('Es necesario un usuario de conexión')); } if (!$frmDBPass) { SP_Common::printJSON(_('Es necesaria una clave de conexión')); } if (!$frmDBName) { SP_Common::printJSON(_('Es necesario el nombre de la BBDD')); } if (!$frmDBHost) { SP_Common::printJSON(_('Es necesario un nombre de host')); } $options['dbhost'] = $frmDBHost; $options['dbname'] = $frmDBName; $options['dbuser'] = $frmDBUser; $options['dbpass'] = $frmDBPass; $res = SP_Migrate::migrate($options); if (is_array($res['error'])) { foreach ($res['error'] as $error) { $errors [] = $error['description']; $errors [] = $error['hint']; error_log($error['hint']); } $out = implode('
', $errors); SP_Common::printJSON($out); } else if (is_array($res['ok'])) { $out = implode('
', $res['ok']); SP_Common::printJSON($out, 0); } \ No newline at end of file +. * */ define('APP_ROOT', '..'); require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); if (!SP_Init::isLoggedIn()) { SP_Common::printJSON(_('La sesión no se ha iniciado o ha caducado'), 10); } if (SP_Util::demoIsEnabled()) { SP_Common::printJSON(_('Ey, esto es una DEMO!!')); } $sk = SP_Common::parseParams('p', 'sk', false); if (!$sk || !SP_Common::checkSessionKey($sk)) { SP_Common::printJSON(_('CONSULTA INVÁLIDA')); } $frmDBUser = SP_Common::parseParams('p', 'dbuser'); $frmDBPass = SP_Common::parseParams('p', 'dbpass'); $frmDBName = SP_Common::parseParams('p', 'dbname'); $frmDBHost = SP_Common::parseParams('p', 'dbhost'); $frmMigrateEnabled = SP_Common::parseParams('p', 'chkmigrate', 0, false, 1); if (!$frmMigrateEnabled) { SP_Common::printJSON(_('Confirmar la importación de cuentas')); } if (!$frmDBUser) { SP_Common::printJSON(_('Es necesario un usuario de conexión')); } if (!$frmDBPass) { SP_Common::printJSON(_('Es necesaria una clave de conexión')); } if (!$frmDBName) { SP_Common::printJSON(_('Es necesario el nombre de la BBDD')); } if (!$frmDBHost) { SP_Common::printJSON(_('Es necesario un nombre de host')); } $options['dbhost'] = $frmDBHost; $options['dbname'] = $frmDBName; $options['dbuser'] = $frmDBUser; $options['dbpass'] = $frmDBPass; $res = SP_Migrate::migrate($options); if (is_array($res['error'])) { foreach ($res['error'] as $error) { $errors [] = $error['description']; $errors [] = $error['hint']; error_log($error['hint']); } $out = implode('
', $errors); SP_Common::printJSON($out); } else if (is_array($res['ok'])) { $out = implode('
', $res['ok']); SP_Common::printJSON($out, 0); } \ No newline at end of file diff --git a/ajax/ajax_passReset.php b/ajax/ajax_passReset.php index 9a0eb9d9..5a40f5a5 100644 --- a/ajax/ajax_passReset.php +++ b/ajax/ajax_passReset.php @@ -24,7 +24,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; +require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); diff --git a/ajax/ajax_search.php b/ajax/ajax_search.php index 42b000e4..22d6c967 100644 --- a/ajax/ajax_search.php +++ b/ajax/ajax_search.php @@ -24,7 +24,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php'; +require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Init.php'; SP_Util::checkReferer('POST'); @@ -144,11 +144,11 @@ foreach ($resQuery as $account) { $objAccount->accountOtherUserEdit = $account->account_otherUserEdit; $objAccount->accountOtherGroupEdit = $account->account_otherGroupEdit; - $accView = (SP_ACL::checkAccountAccess("accview", $objAccount->getAccountDataForACL()) && SP_ACL::checkUserAccess("accview")); - $accViewPass = (SP_ACL::checkAccountAccess("accviewpass", $objAccount->getAccountDataForACL()) && SP_ACL::checkUserAccess("accviewpass")); - $accEdit = (SP_ACL::checkAccountAccess("accedit", $objAccount->getAccountDataForACL()) && SP_ACL::checkUserAccess("accedit")); - $accCopy = (SP_ACL::checkAccountAccess("accview", $objAccount->getAccountDataForACL()) && SP_ACL::checkUserAccess("accnew")); - $accDel = (SP_ACL::checkAccountAccess("accdelete", $objAccount->getAccountDataForACL()) && SP_ACL::checkUserAccess("accdelete")); + $accView = (SP_Acl::checkAccountAccess("accview", $objAccount->getAccountDataForACL()) && SP_Acl::checkUserAccess("accview")); + $accViewPass = (SP_Acl::checkAccountAccess("accviewpass", $objAccount->getAccountDataForACL()) && SP_Acl::checkUserAccess("accviewpass")); + $accEdit = (SP_Acl::checkAccountAccess("accedit", $objAccount->getAccountDataForACL()) && SP_Acl::checkUserAccess("accedit")); + $accCopy = (SP_Acl::checkAccountAccess("accview", $objAccount->getAccountDataForACL()) && SP_Acl::checkUserAccess("accnew")); + $accDel = (SP_Acl::checkAccountAccess("accdelete", $objAccount->getAccountDataForACL()) && SP_Acl::checkUserAccess("accdelete")); $show = ($accView || $accViewPass || $accEdit || $accCopy || $accDel); diff --git a/ajax/ajax_sendRequest.php b/ajax/ajax_sendRequest.php index f68ad25b..b603771a 100644 --- a/ajax/ajax_sendRequest.php +++ b/ajax/ajax_sendRequest.php @@ -24,7 +24,7 @@ * */ define('APP_ROOT', '..'); -require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; +require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); diff --git a/ajax/ajax_usrpass.php b/ajax/ajax_usrpass.php index 5eb1b9f2..760f2f83 100644 --- a/ajax/ajax_usrpass.php +++ b/ajax/ajax_usrpass.php @@ -24,7 +24,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; +require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('GET'); @@ -40,7 +40,7 @@ if ( ! $userId ) { $strError = '
'._('No tiene permisos para realizar esta operación').'
'; -SP_ACL::checkUserAccess("acceditpass",$userId) || die ($strError); +SP_Acl::checkUserAccess("acceditpass",$userId) || die ($strError); ?> diff --git a/ajax/ajax_viewpass.php b/ajax/ajax_viewpass.php index cfb68cf6..0a38b2fe 100644 --- a/ajax/ajax_viewpass.php +++ b/ajax/ajax_viewpass.php @@ -24,7 +24,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'init.php'; +require_once APP_ROOT.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR.'Init.php'; SP_Util::checkReferer('POST'); @@ -52,7 +52,7 @@ if ($isHistory && !$account->checkAccountMPass()){ $accountData = $account->getAccountPass($isHistory); -if (!SP_ACL::checkAccountAccess("accviewpass", $account->getAccountDataForACL()) || !SP_ACL::checkUserAccess("accviewpass")) { +if (!SP_Acl::checkAccountAccess("accviewpass", $account->getAccountDataForACL()) || !SP_Acl::checkUserAccess("accviewpass")) { SP_Common::printJSON(_('No tiene permisos para acceder a esta cuenta')); } diff --git a/css/css.php b/css/css.php index 61736985..a0240676 100644 --- a/css/css.php +++ b/css/css.php @@ -24,7 +24,7 @@ */ define('APP_ROOT', '..'); -require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php'; +require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Init.php'; $cssFiles = array( array('href' => 'css/reset.css', 'min' => true), diff --git a/inc/account.class.php b/inc/Account.class.php similarity index 100% rename from inc/account.class.php rename to inc/Account.class.php diff --git a/inc/acl.class.php b/inc/Acl.class.php similarity index 99% rename from inc/acl.class.php rename to inc/Acl.class.php index d86519df..bc4291b6 100644 --- a/inc/acl.class.php +++ b/inc/Acl.class.php @@ -29,7 +29,7 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' /** * Esta clase es la encargada de calcular las access lists de acceso a usuarios. */ -class SP_ACL +class SP_Acl { static $accountCacheUserGroupsId; diff --git a/inc/auth.class.php b/inc/Auth.class.php similarity index 93% rename from inc/auth.class.php rename to inc/Auth.class.php index 18217f00..c3ebc35a 100644 --- a/inc/auth.class.php +++ b/inc/Auth.class.php @@ -43,7 +43,7 @@ class SP_Auth */ public static function authUserLDAP($userLogin, $userPass) { - if (!SP_Util::ldapIsAvailable() || !SP_Util::ldapIsEnabled() || !SP_LDAP::checkLDAPParams()) { + if (!SP_Util::ldapIsAvailable() || !SP_Util::ldapIsEnabled() || !SP_Ldap::checkLDAPParams()) { return false; } @@ -52,14 +52,14 @@ class SP_Auth // Conectamos al servidor realizamos la conexión con el usuario proxy try { - SP_LDAP::ldapConnect(); - SP_LDAP::ldapBind(); - SP_LDAP::getUserDN($userLogin); + SP_Ldap::ldapConnect(); + SP_Ldap::ldapBind(); + SP_Ldap::getUserDN($userLogin); } catch (Exception $e) { return false; } - $userDN = SP_LDAP::$ldapSearchData[0]['dn']; + $userDN = SP_Ldap::$ldapSearchData[0]['dn']; // Mapeo de los atributos $attribsMap = array( 'groupMembership' => 'group', @@ -71,10 +71,10 @@ class SP_Auth // Realizamos la conexión con el usuario real y obtenemos los atributos try { - SP_LDAP::ldapBind($userDN, $userPass); - $attribs = SP_LDAP::getLDAPAttr($attribsMap); + SP_Ldap::ldapBind($userDN, $userPass); + $attribs = SP_Ldap::getLDAPAttr($attribsMap); } catch (Exception $e) { - return ldap_errno(SP_LDAP::getConn()); + return ldap_errno(SP_Ldap::getConn()); } // Comprobamos si la cuenta está bloqueada o expirada @@ -101,7 +101,7 @@ class SP_Auth } // Comprobamos que el usuario está en el grupo indicado buscando en los atributos del grupo } else { - $ldapGroupAccess = SP_LDAP::searchUserInGroup($userDN); + $ldapGroupAccess = SP_Ldap::searchUserInGroup($userDN); } if ($ldapGroupAccess == false) { diff --git a/inc/backup.class.php b/inc/Backup.class.php similarity index 100% rename from inc/backup.class.php rename to inc/Backup.class.php diff --git a/inc/category.class.php b/inc/Category.class.php similarity index 100% rename from inc/category.class.php rename to inc/Category.class.php diff --git a/inc/common.class.php b/inc/Common.class.php similarity index 100% rename from inc/common.class.php rename to inc/Common.class.php diff --git a/inc/config.class.php b/inc/Config.class.php similarity index 100% rename from inc/config.class.php rename to inc/Config.class.php diff --git a/inc/crypt.class.php b/inc/Crypt.class.php similarity index 100% rename from inc/crypt.class.php rename to inc/Crypt.class.php diff --git a/inc/customer.class.php b/inc/Customer.class.php similarity index 100% rename from inc/customer.class.php rename to inc/Customer.class.php diff --git a/inc/db.class.php b/inc/DB.class.php similarity index 100% rename from inc/db.class.php rename to inc/DB.class.php diff --git a/inc/files.class.php b/inc/Files.class.php similarity index 100% rename from inc/files.class.php rename to inc/Files.class.php diff --git a/inc/groups.class.php b/inc/Groups.class.php similarity index 100% rename from inc/groups.class.php rename to inc/Groups.class.php diff --git a/inc/html.class.php b/inc/Html.class.php similarity index 100% rename from inc/html.class.php rename to inc/Html.class.php diff --git a/inc/import.class.php b/inc/Import.class.php similarity index 98% rename from inc/import.class.php rename to inc/Import.class.php index f6481777..33954b39 100644 --- a/inc/import.class.php +++ b/inc/Import.class.php @@ -280,11 +280,11 @@ class SP_Import $xml = self::readXMLFile(); if ( $xml->Meta->Generator == 'KeePass' ){ - SP_KeePassImport::addKeepassAccounts($xml); + SP_KeepassImport::addKeepassAccounts($xml); } else if ($xmlApp = self::parseFileHeader()){ switch ($xmlApp) { case 'keepassx_database': - SP_KeePassXImport::addKeepassXAccounts($xml); + SP_KeepassXImport::addKeepassXAccounts($xml); break; case 'revelationdata': error_log('REVELATION'); diff --git a/inc/init.php b/inc/Init.php similarity index 95% rename from inc/init.php rename to inc/Init.php index 05283950..0c8b824e 100644 --- a/inc/init.php +++ b/inc/Init.php @@ -100,15 +100,27 @@ class SP_Init $_SERVER['PHP_AUTH_PW'] = strip_tags($password); } - self::setPaths(); - // Establecer el modo debug si una sesión de xdebug está activa - if (!defined('DEBUG') || !DEBUG) { - if (isset($_COOKIE['XDEBUG_SESSION'])) { - define('DEBUG', true); - } + if (isset($_COOKIE['XDEBUG_SESSION']) && (!defined('DEBUG') || !DEBUG)) { + define('DEBUG', true); } + // Establecer el nivel de logging + if (defined('DEBUG') && DEBUG) { +// error_log('sysPass DEBUG'); + error_reporting(E_ALL); + ini_set('display_errors', 'On'); + } else { + error_reporting(E_ALL & ~(E_DEPRECATED | E_STRICT | E_NOTICE)); + ini_set('display_errors', 'Off'); + } + + // Iniciar la sesión de PHP + self::startSession(); + + // Establecer las rutas de la aplicación + self::setPaths(); + // Cargar el lenguaje self::selectLang(); @@ -123,7 +135,7 @@ class SP_Init self::checkInstalled(); // Comprobar si la Base de datos existe - if (!db::checkDatabaseExist()) { + if (!DB::checkDatabaseExist()) { self::initError(_('Error en la verificación de la base de datos')); } @@ -202,8 +214,8 @@ class SP_Init */ public static function sysPassAutoload($classname) { - $class = str_replace("sp_", '', strtolower($classname)); - $classfile = dirname(__FILE__) . DIRECTORY_SEPARATOR . $class . ".class.php"; + $class = str_ireplace('sp_', '', $classname); + $classfile = dirname(__FILE__) . DIRECTORY_SEPARATOR . $class . '.class.php'; if (is_readable($classfile)) { require $classfile; @@ -474,24 +486,6 @@ class SP_Init */ private static function initSession() { - // Evita que javascript acceda a las cookis de sesion de PHP - ini_set('session.cookie_httponly', '1;'); - - // Si la sesión no puede ser iniciada, devolver un error 500 - if (session_start() === false) { - - SP_Log::wrLogInfo(_('Sesion'), _('La sesión no puede ser inicializada')); - - header('HTTP/1.1 500 Internal Server Error'); - $errors[] = array( - 'type' => 'critical', - 'description' => _('La sesión no puede ser inicializada'), - 'hint' => _('Consulte con el administrador')); - - SP_Html::render('error', $errors); - exit(); - } - $sessionLifeTime = self::getSessionLifeTime(); // Regenerar el Id de sesión periódicamente para evitar fijación @@ -619,6 +613,29 @@ class SP_Init list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } + + /** + * Iniciar la sesión PHP + */ + private static function startSession(){ + // Evita que javascript acceda a las cookies de sesion de PHP + ini_set('session.cookie_httponly', '1'); + + // Si la sesión no puede ser iniciada, devolver un error 500 + if (session_start() === false) { + + SP_Log::wrLogInfo(_('Sesion'), _('La sesión no puede ser inicializada')); + + header('HTTP/1.1 500 Internal Server Error'); + $errors[] = array( + 'type' => 'critical', + 'description' => _('La sesión no puede ser inicializada'), + 'hint' => _('Consulte con el administrador')); + + SP_Html::render('error', $errors); + exit(); + } + } } // Empezar a calcular el tiempo y memoria utilizados @@ -626,4 +643,4 @@ $memInit = memory_get_usage(); $time_start = SP_Init::microtime_float(); // Inicializar sysPass -SP_Init::init(); +SP_Init::init(); \ No newline at end of file diff --git a/inc/installer.class.php b/inc/Installer.class.php similarity index 100% rename from inc/installer.class.php rename to inc/Installer.class.php diff --git a/inc/keepassimport.class.php b/inc/KeepassImport.class.php similarity index 99% rename from inc/keepassimport.class.php rename to inc/KeepassImport.class.php index 34856aac..8089edd0 100644 --- a/inc/keepassimport.class.php +++ b/inc/KeepassImport.class.php @@ -29,7 +29,7 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' /** * Esta clase es la encargada de importar cuentas desde KeePass */ -class SP_KeePassImport +class SP_KeepassImport { /** diff --git a/inc/keepassximport.class.php b/inc/KeepassXImport.class.php similarity index 99% rename from inc/keepassximport.class.php rename to inc/KeepassXImport.class.php index 7b3d5273..4eb1c3a7 100644 --- a/inc/keepassximport.class.php +++ b/inc/KeepassXImport.class.php @@ -29,7 +29,7 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' /** * Esta clase es la encargada de importar cuentas desde KeePassX */ -class SP_KeePassXImport +class SP_KeepassXImport { /** diff --git a/inc/ldap.class.php b/inc/Ldap.class.php similarity index 99% rename from inc/ldap.class.php rename to inc/Ldap.class.php index a03ae5f7..7d010d2a 100644 --- a/inc/ldap.class.php +++ b/inc/Ldap.class.php @@ -29,7 +29,7 @@ defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo' /** * Esta clase es la encargada de realizar la autentificación de usuarios de sysPass. */ -class SP_LDAP +class SP_Ldap { // Variabla que contiene los datos de una búsqueda public static $ldapSearchData; diff --git a/inc/log.class.php b/inc/Log.class.php similarity index 100% rename from inc/log.class.php rename to inc/Log.class.php diff --git a/inc/migrate.class.php b/inc/Migrate.class.php similarity index 100% rename from inc/migrate.class.php rename to inc/Migrate.class.php diff --git a/inc/profiles.class.php b/inc/Profiles.class.php similarity index 100% rename from inc/profiles.class.php rename to inc/Profiles.class.php diff --git a/inc/Template.class.php b/inc/Template.class.php new file mode 100644 index 00000000..f685d895 --- /dev/null +++ b/inc/Template.class.php @@ -0,0 +1,159 @@ +addTemplate($file); + + if(!empty($vars)){ + $this->setVars($vars); + } + } + + /** + * Overloading para añadir nuevas variables en al array de variables dela plantilla + * pasadas como atributos dinámicos de la clase + * + * @param string $name Nombre del atributo + * @param string $value Valor del atributo + * @return null + */ + public function __set($name, $value) { + $this->vars[$name] = $value; + return null; + } + + /** + * Overloadig para controlar la devolución de atributos dinámicos. + * + * @param string $name Nombre del atributo + * @return null + * @throws InvalidArgumentException + */ + public function __get($name) { + if (!isset($this->vars[$name])) { + throw new InvalidArgumentException('No es posible obtener la variable "' . $name . '"'); + } + return null; + } + + /** + * Overloading para comprobar si el atributo solicitado está declarado como variable + * en el array de variables de la plantilla. + * + * @param string $name Nombre del atributo + * @return bool + */ + public function __isset($name) { + return isset($this->vars[$name]); + } + + /** + * Overloading para eliminar una variable del array de variables de la plantilla pasado como + * atributo dinámico de la clase + * + * @param string $name Nombre del atributo + * @return $this + * @throws InvalidArgumentException + */ + public function __unset($name) { + if (!isset($this->vars[$name])) { + throw new InvalidArgumentException('No es posible destruir la variable "' . $name . '"'); + } + + unset($this->vars[$name]); + return $this; + } + + /** + * Mostrar la plantilla solicitada. + * La salida se almacena en buffer y se devuelve el contenido + * + * @return string Con el contenido del buffer de salida + */ + public function render() { + extract($this->vars); + + ob_start(); + + foreach ( $this->file as $template) { + include $template; + } + + return ob_get_clean(); + } + + /** + * Comprobar si un archivo de plantilla existe y se puede leer + * + * @param string $file Con el nombre del archivo + * @throws InvalidArgumentException + */ + private function checkTemplate($file){ + $template = __DIR__ . DIRECTORY_SEPARATOR . 'tpl' . DIRECTORY_SEPARATOR . $file; + + if (!is_file($template) || !is_readable($template)) { + throw new InvalidArgumentException('No es posible obtener la plantilla "' . $file .'"'); + } + + $this->setTemplate($template); + } + + /** + * Añadir un nuevo archivo de plantilla al array de plantillas de la clase. + * + * @param string $file Con el nombre del archivo + */ + private function setTemplate($file){ + $this->file[] = $file; + } + + /** + * Establecer los atributos de la clase a partir de un array. + * + * @param array $vars Con los atributos de la clase + */ + private function setVars(&$vars){ + foreach ($vars as $name => $value) { + $this->$name = $value; + } + } + + /** + * Añadir una nueva plantilla al array de plantillas de la clase + * + * @param string $file Con el nombre del archivo de plantilla + */ + public function addTemplate($file){ + if (!is_null($file) && $this->checkTemplate($file)){ + $this->setTemplate($file); + } + } +} \ No newline at end of file diff --git a/inc/upgrade.class.php b/inc/Upgrade.class.php similarity index 100% rename from inc/upgrade.class.php rename to inc/Upgrade.class.php diff --git a/inc/users.class.php b/inc/Users.class.php similarity index 100% rename from inc/users.class.php rename to inc/Users.class.php diff --git a/inc/util.class.php b/inc/Util.class.php similarity index 98% rename from inc/util.class.php rename to inc/Util.class.php index 21f87d41..a37f909b 100644 --- a/inc/util.class.php +++ b/inc/Util.class.php @@ -537,7 +537,10 @@ class SP_Util } flush(); - ob_start('ob_gzhandler'); + + if(self::checkZlib() || !ob_start('ob_gzhandler')){ + ob_start(); + } foreach ($files as $file) { $filePath = $path . $file['href']; @@ -674,4 +677,15 @@ class SP_Util array_walk($array, function(&$value, $index) {$value = str_replace(array("'", '"'), "\\'", $value);}); return $array; } + + /** + * Comprobar si la salida comprimida en con zlib está activada. + * No es compatible con ob_gzhandler() + * + * @return bool + */ + public static function checkZlib() + { + return self::boolval(ini_get('zlib.output_compression')); + } } \ No newline at end of file diff --git a/inc/tpl/accounts.php b/inc/tpl/accounts.php index b28a30ef..9fdb7c8e 100644 --- a/inc/tpl/accounts.php +++ b/inc/tpl/accounts.php @@ -104,7 +104,7 @@ $gotData = (isset($accountData) && is_object($accountData)); if ($data['id'] > 0) { // Comprobar permisos de acceso - SP_ACL::checkAccountAccess($action, $account->getAccountDataForACL()) || SP_Html::showCommonError('noaccpermission'); + SP_Acl::checkAccountAccess($action, $account->getAccountDataForACL()) || SP_Html::showCommonError('noaccpermission'); $changesHash = $account->calcChangesHash(); $chkUserEdit = ($accountData->account_otherUserEdit) ? 'checked' : ''; @@ -132,28 +132,28 @@ $categoriesSelProp = array("name" => "categoryId", "attribs" => ""); $isModified = ($gotData && $accountData->account_dateEdit && $accountData->account_dateEdit <> '0000-00-00 00:00:00'); -$showHistory = (($action == 'accview' || $action == 'accviewhistory') && SP_ACL::checkUserAccess("accviewhistory") && ($isModified || $action == 'accviewhistory')); +$showHistory = (($action == 'accview' || $action == 'accviewhistory') && SP_Acl::checkUserAccess("accviewhistory") && ($isModified || $action == 'accviewhistory')); $showDetails = ($action == 'accview' || $action == 'accviewhistory' || $action == 'accdelete'); $showPass = ($action == "accnew" || $action == 'acccopy'); $showFiles = (($action == "accedit" || $action == "accview" || $action == "accviewhistory") - && (SP_Util::fileIsEnabled() && SP_ACL::checkUserAccess("accfiles"))); + && (SP_Util::fileIsEnabled() && SP_Acl::checkUserAccess("accfiles"))); $showViewPass = (($action == "accview" || $action == "accviewhistory") - && (SP_ACL::checkAccountAccess("accviewpass", $account->getAccountDataForACL()) && SP_ACL::checkUserAccess("accviewpass"))); + && (SP_Acl::checkAccountAccess("accviewpass", $account->getAccountDataForACL()) && SP_Acl::checkUserAccess("accviewpass"))); $showSave = ($action == "accedit" || $action == "accnew" || $action == "acccopy"); $showEdit = ($action == "accview" - && SP_ACL::checkAccountAccess("accedit", $account->getAccountDataForACL()) - && SP_ACL::checkUserAccess("accedit") + && SP_Acl::checkAccountAccess("accedit", $account->getAccountDataForACL()) + && SP_Acl::checkUserAccess("accedit") && !$account->accountIsHistory); $showEditPass = ($action == "accedit" - && SP_ACL::checkAccountAccess("acceditpass", $account->getAccountDataForACL()) - && SP_ACL::checkUserAccess("acceditpass") + && SP_Acl::checkAccountAccess("acceditpass", $account->getAccountDataForACL()) + && SP_Acl::checkUserAccess("acceditpass") && !$account->accountIsHistory); $showDelete = ($action == "accdelete" - && SP_ACL::checkAccountAccess("accdelete", $account->getAccountDataForACL()) - && SP_ACL::checkUserAccess("accdelete")); + && SP_Acl::checkAccountAccess("accdelete", $account->getAccountDataForACL()) + && SP_Acl::checkUserAccess("accdelete")); $showRestore = ($action == "accviewhistory" - && SP_ACL::checkAccountAccess("accedit", $account->getAccountDataForACL($account->accountParentId)) - && SP_ACL::checkUserAccess("accedit")); + && SP_Acl::checkAccountAccess("accedit", $account->getAccountDataForACL($account->accountParentId)) + && SP_Acl::checkUserAccess("accedit")); $filesDelete = ($action == 'accedit') ? 1 : 0; $skey = SP_Common::getSessionKey(true); $maxFileSize = round(SP_Config::getValue('files_allowed_size') / 1024, 1); diff --git a/inc/tpl/backup.php b/inc/tpl/backup.php index 356a8b38..00aab66b 100644 --- a/inc/tpl/backup.php +++ b/inc/tpl/backup.php @@ -29,7 +29,7 @@ $action = $data['action']; $activeTab = $data['activeTab']; $onCloseAction = $data['onCloseAction']; -SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); +SP_Acl::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); $siteName = SP_Html::getAppInfo('appname'); $backupDir = SP_Init::$SERVERROOT . '/backup'; diff --git a/inc/tpl/config.php b/inc/tpl/config.php index 4b11887f..33ae0fa1 100644 --- a/inc/tpl/config.php +++ b/inc/tpl/config.php @@ -29,7 +29,7 @@ $action = $data['action']; $activeTab = $data['activeTab']; $onCloseAction = $data['onCloseAction']; -SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); +SP_Acl::checkUserAccess($action) || SP_Html::showCommonError('unavailable'); $arrLangAvailable = array( 'Español' => 'es_ES', diff --git a/inc/tpl/editpass.php b/inc/tpl/editpass.php index 153aadba..fe287e33 100644 --- a/inc/tpl/editpass.php +++ b/inc/tpl/editpass.php @@ -29,7 +29,7 @@ $account->accountId = $data['id']; $account->lastAction = $data['lastaction']; $accountData = $account->getAccount(); -(!SP_ACL::checkAccountAccess("acceditpass", $account->getAccountDataForACL()) || !SP_ACL::checkUserAccess("acceditpass")) && SP_Html::showCommonError('noaccpermission'); +(!SP_Acl::checkAccountAccess("acceditpass", $account->getAccountDataForACL()) || !SP_Acl::checkUserAccess("acceditpass")) && SP_Html::showCommonError('noaccpermission'); ?>
diff --git a/inc/tpl/main.php b/inc/tpl/main.php index 45c3712c..bda9e92a 100644 --- a/inc/tpl/main.php +++ b/inc/tpl/main.php @@ -59,7 +59,7 @@ $chpass = ( ! isset($_SESSION['uisldap']) || $_SESSION['uisldap'] == 0 ) ? ' "js/jquery.js", "min" => false),