.
*
*/
define('APP_ROOT', '..');
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'init.php';
SP_Util::checkReferer('POST');
if (!SP_Init::isLoggedIn()) {
SP_Util::logout();
}
SP_Util::checkReload();
if (SP_Common::parseParams('p', 'action', '', true)) {
$action = $tplvars['action'] = SP_Common::parseParams('p', 'action');
$itemId = $tplvars['id'] = SP_Common::parseParams('p', 'id', 0);
$tplvars['lastaction'] = filter_var(SP_Common::parseParams('p', 'lastAction', 'accsearch', false, false, false), FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
} else {
die('
' . _('Parámetros incorrectos') . '
');
}
switch ($action) {
case "accsearch":
SP_Account::$accountSearchTxt = SP_Common::parseParams('s', 'accountSearchTxt');
SP_Account::$accountSearchCustomer = SP_Common::parseParams('s', 'accountSearchCustomer');
SP_Account::$accountSearchCategory = SP_Common::parseParams('s', 'accountSearchCategory', 0);
SP_Account::$accountSearchOrder = SP_Common::parseParams('s', 'accountSearchOrder', 0);
SP_Account::$accountSearchKey = SP_Common::parseParams('s', 'accountSearchKey', 0);
SP_Html::getTemplate('search', $tplvars);
break;
case "accnew":
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_Users::checkUserUpdateMPass() || SP_Html::showCommonError('updatempass');
SP_Html::getTemplate('accounts', $tplvars);
break;
case "accedit":
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_Users::checkUserUpdateMPass() || SP_Html::showCommonError('updatempass');
SP_Html::getTemplate('editpass', $tplvars);
break;
case "accview":
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_Html::getTemplate('accounts', $tplvars);
break;
case "accdelete":
SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable');
SP_Html::getTemplate('accounts', $tplvars);
break;
case "accrequest":
SP_Html::getTemplate('request', $tplvars);
break;
case "usersmenu":
echo '';
echo '
';
$activeTab = 0;
if (SP_ACL::checkUserAccess("users")) {
$arrUsersTableProp = array(
'tblId' => 'tblUsers',
'header' => '',
'tblHeaders' => array(
_('Nombre'),
_('Login'),
_('Perfil'),
_('Grupo'),
_('Propiedades')),
'tblRowSrc' => array(
'user_name',
'user_login',
'userprofile_name',
'usergroup_name', array(
'user_isAdminApp' => array('img_file' => 'check_blue.png', 'img_title' => _('Admin Aplicación')),
'user_isAdminAcc' => array('img_file' => 'check_orange.png', 'img_title' => _('Admin Cuentas')),
'user_isLdap' => array('img_file' => 'ldap.png', 'img_title' => _('Usuario de LDAP')),
'user_isDisabled' => array('img_file' => 'disabled.png', 'img_title' => _('Deshabilitado'))
)
),
'tblRowSrcId' => 'user_id',
'frmId' => 'frm_tblusers',
'onCloseAction' => $action,
'actionId' => 1,
'newActionId' => 2,
'activeTab' => $activeTab++,
'actions' => array(
'new' => array('title' => _('Nuevo Usuario'), 'action' => 'appMgmtData'),
'view' => array('title' => _('Ver Detalles de Usuario'), 'action' => 'appMgmtData'),
'edit' => array('title' => _('Editar Usuario'), 'action' => 'appMgmtData'),
'del' => array('title' => _('Eliminar Usuario'), 'action' => 'appMgmtSave'),
'pass' => array('title' => _('Cambiar Clave de Usuario'), 'action' => 'usrUpdPass')
)
);
echo '
';
$startTime = microtime();
$users = SP_Users::getUsers();
if ($users) {
SP_Html::getQueryTable($arrUsersTableProp, $users);
SP_Html::printQueryInfoBar(count($users), $startTime);
}
echo '
';
}
if (SP_ACL::checkUserAccess("groups")) {
$arrGroupsTableProp = array(
'tblId' => 'tblGroups',
'header' => '',
'tblHeaders' => array(_('Nombre'), _('Descripción')),
'tblRowSrc' => array('usergroup_name', 'usergroup_description'),
'tblRowSrcId' => 'usergroup_id',
'frmId' => 'frm_tblgroups',
'onCloseAction' => $action,
'actionId' => 3,
'newActionId' => 4,
'activeTab' => $activeTab++,
'actions' => array(
'new' => array('title' => _('Nuevo Grupo'), 'action' => 'appMgmtData'),
'edit' => array('title' => _('Editar Grupo'), 'action' => 'appMgmtData'),
'del' => array('title' => _('Eliminar Grupo'), 'action' => 'appMgmtSave')
)
);
echo '
';
$startTime = microtime();
$groups = SP_Groups::getGroups();
if ($groups) {
SP_Html::getQueryTable($arrGroupsTableProp, $groups);
SP_Html::printQueryInfoBar(count($groups), $startTime);
}
echo '
';
}
if (SP_ACL::checkUserAccess("profiles")) {
$arrProfilesTableProp = array(
'tblId' => 'tblProfiles',
'header' => '',
'tblHeaders' => array(_('Nombre')),
'tblRowSrc' => array('userprofile_name'),
'tblRowSrcId' => 'userprofile_id',
'frmId' => 'frm_tblprofiles',
'onCloseAction' => $action,
'actionId' => 5,
'newActionId' => 6,
'activeTab' => $activeTab++,
'actions' => array(
'new' => array('title' => _('Nuevo Perfil'), 'action' => 'appMgmtData'),
'edit' => array('title' => _('Editar Perfil'), 'action' => 'appMgmtData'),
'del' => array('title' => _('Eliminar Perfil'), 'action' => 'appMgmtSave')
)
);
echo '
';
$startTime = microtime();
$profiles = SP_Profiles::getProfiles();
if ($profiles) {
SP_Html::getQueryTable($arrProfilesTableProp, $profiles);
SP_Html::printQueryInfoBar(count($profiles), $startTime);
}
echo '
';
}
echo '
';
echo '';
break;
case "appmgmtmenu":
echo '';
echo '
';
$activeTab = 0;
if (SP_ACL::checkUserAccess("categories")) {
$arrCategoriesTableProp = array(
'tblId' => 'tblCategories',
'header' => '',
'tblHeaders' => array(_('Nombre'), _('Descripción')),
'tblRowSrc' => array('category_name', 'category_description'),
'tblRowSrcId' => 'category_id',
'frmId' => 'frm_tblcategories',
'onCloseAction' => $action,
'actionId' => 9,
'newActionId' => 10,
'activeTab' => $activeTab++,
'actions' => array(
'new' => array('title' => _('Nueva Categoría'), 'action' => 'appMgmtData'),
'edit' => array('title' => _('Editar Categoría'), 'action' => 'appMgmtData'),
'del' => array('title' => _('Eliminar Categoría'), 'action' => 'appMgmtSave')
)
);
echo '
';
$startTime = microtime();
$categories = SP_Category::getCategories();
if ($categories !== false) {
SP_Html::getQueryTable($arrCategoriesTableProp, $categories);
SP_Html::printQueryInfoBar(count($categories), $startTime);
}
echo '
';
}
if (SP_ACL::checkUserAccess("customers")) {
$arrCustomersTableProp = array(
'tblId' => 'tblCustomers',
'header' => '',
'tblHeaders' => array(_('Nombre'), _('Descripción')),
'tblRowSrc' => array('customer_name', 'customer_description'),
'tblRowSrcId' => 'customer_id',
'frmId' => 'frm_tblcustomers',
'onCloseAction' => $action,
'actionId' => 7,
'newActionId' => 8,
'activeTab' => $activeTab++,
'actions' => array(
'new' => array('title' => _('Nuevo Cliente'), 'action' => 'appMgmtData'),
'edit' => array('title' => _('Editar Cliente'), 'action' => 'appMgmtData'),
'del' => array('title' => _('Eliminar Cliente'), 'action' => 'appMgmtSave')
)
);
echo '
';
$startTime = microtime();
$customers = SP_Customer::getCustomers();
if ($customers !== false) {
SP_Html::getQueryTable($arrCustomersTableProp, $customers);
SP_Html::printQueryInfoBar(count($customers), $startTime);
}
echo '
';
}
echo '
';
echo '';
break;
case "configmenu":
echo '';
echo '
';
$tplvars['activeTab'] = 0;
$tplvars['onCloseAction'] = $action;
if (SP_ACL::checkUserAccess("config")) {
echo '
';
SP_Html::getTemplate('config', $tplvars);
echo '
';
}
if (SP_ACL::checkUserAccess("masterpass")) {
$tplvars['activeTab']++;
echo '
';
SP_Html::getTemplate('masterpass', $tplvars);
echo '
';
}
if (SP_ACL::checkUserAccess("backup")) {
$tplvars['activeTab']++;
echo '
';
SP_Html::getTemplate('backup', $tplvars);
echo '
';
}
if (SP_ACL::checkUserAccess("config")) {
$tplvars['activeTab']++;
echo '
';
SP_Html::getTemplate('migrate', $tplvars);
echo '
';
}
echo '
';
echo '';
break;
case "eventlog":
SP_ACL::checkUserAccess($action) || SP_Html::showCommonError('unavailable');
SP_Html::getTemplate('eventlog', $tplvars);
break;
}
if (isset($_SESSION["uisadminapp"]) && SP_Config::getValue('debug')) {
$time_stop = SP_Init::microtime_float();
$time = ($time_stop - $time_start);
$memEnd = memory_get_usage();
$debugTxt[] = "";
$debugTxt[] = "
DEBUG INFO
";
$debugTxt[] = "
";
$debugTxt[] = "- RENDER -> " . $time . " sec
";
$debugTxt[] = "- MEM -> Init: " . ($memInit / 1000) . " KB - End: " . ($memEnd / 1000) . " KB - Total: " . (($memEnd - $memInit) / 1000) . " KB
";
$debugTxt[] = "- SESSION:";
$debugTxt[] = "
" . print_r($_SESSION, true) . "
";
$debugTxt[] = " - CONFIG:
";
$debugTxt[] = "" . print_r(SP_Config::getKeys(true), true) . "
";
$debugTxt[] = " ";
$debugTxt[] = "
";
foreach ($debugTxt as $out) {
echo $out;
}
}
// Se comprueba si hay actualizaciones.
// Es necesario que se haga al final de obtener el contenido ya que la
// consulta ajax detiene al resto si se ejecuta antes
if ($_SESSION['uisadminapp'] && SP_Config::getValue('checkupdates') === true && !SP_Common::parseParams('s', 'UPDATED', false, true)) {
echo '';
}