Пример #1
0
function topNentriesAction($accion, $total, $parametro)
{
    global $cmd;
    list($conn) = Getdb();
    $table = GetTable('eventos');
    $columns = GetCols('eventos');
    $sql = "SELECT *, count(*) as total FROM {$table} WHERE {$columns['suceso']} like '{$cmd[$accion]}@%' and  {$columns['suceso']} like '%@" . base64_encode($parametro) . "%' group by {$columns['suceso']} ORDER BY total desc limit {$total}";
    $rs = $conn->Execute($sql);
    $data = $rs->GetRows();
    return $data;
}
Пример #2
0
function vwDelVar($name)
{
    list($db) = Getdb();
    $tables = GetTables();
    $table = $tables['t']['vars'];
    $cols = $tables['c']['vars'];
    $session_id = "'" . session_id() . "'";
    $sql = "DELETE FROM {$table}\n\t\t\t\t WHERE\t {$cols['session_id']}='" . session_id() . "' AND\n\t\t\t\t\t\t\t {$cols['name']}='" . trim($name) . "';";
    $rs = $db->Execute($sql);
    if (!$rs) {
        return false;
    }
    return true;
}
function _delete($sid)
{
    if (_delete_check($sid) === false) {
        return false;
    }
    $table = GetTable['secciones'];
    $cols = GetCols['secciones'];
    list($conn) = Getdb();
    $sql = "DELETE FROM {$table} WHERE {$cols['sid']}={$aid};";
    $rs = $conn->Execute($sql);
    //event_loger()
    if ($rs === false) {
        return false;
    }
    return true;
}
function _delete($uid)
{
    if (_delete_check($uid) === false) {
        return false;
    }
    $table = GetTable('usuarios');
    $cols = GetCols('usuarios');
    list($conn) = Getdb();
    $sql = "DELETE FROM {$table} WHERE {$cols['uid']}={$uid};";
    $rs = $conn->Execute($sql);
    //event_loger()
    if ($rs === false) {
        return false;
    }
    $table = GetTable('autorizaciones');
    $cols = GetCols('autorizaciones');
    $sql = "DELETE FROM {$table} WHERE {$cols['uid']}={$uid};";
    $rs = $conn->Execute($sql);
    return true;
}
Пример #5
0
function render_usuario_showprefs($param)
{
    $id = vwSessionGetVar('uid');
    list($db) = Getdb();
    $tblUsuarios = GetTable('usuarios');
    $colUsuarios = GetCols('usuarios');
    $sql = "SELECT {$colUsuarios['preferencias']} from {$tblUsuarios} where {$colUsuarios['uid']}=" . $id;
    $rs = $db->Execute($sql);
    if ($rs === false) {
        // Error
        die($sql);
    }
    $z = $rs->FetchRow();
    $preferencias = compact($z);
    if (trim($preferencias) == "") {
        $preferencias = "Items=25\nNotify=false";
    }
    $pref = explode("\n", $preferencias);
    list($notify) = explode("=", $pref[2]);
    $notify = $notify == "true" ? true : false;
    list($items) = explode("=", $pref[1]);
    if ($items < 5) {
        $items = 25;
    }
    $resultado = SmartyInit();
    $resultado->assign("accion", $mensaje);
    $resultado->assign("items", $items);
    $resultado->assign("notify", $notify);
    $resultado->assign("uidz", vwSessionGetVar('uid'));
    $plantilla = "usuarios/usrprefs.tpl";
    $salida = $resultado->fetch($plantilla);
    return $salida;
}
Пример #6
0
function DelOldRsc($rid)
{
    global $rsc_dir, $prev_dir;
    $aid = $param['rid'];
    list($db) = Getdb();
    $tbl = GetTable('recursos');
    $col = GetCols('recursos');
    $sql = "Select * from {$tbl} WHERE {$col['rid']}={$rid}";
    $resultado = $db->Execute($sql);
    if ($db->ErrorNo() != 0) {
        $mensaje = "Ha ocurrido un error al leer un viejo registro";
        print_r($mensaje);
        die;
    }
    $datos = $resultado->FetchRow();
    $datos = fromdbtocms($datos, 'recursos');
    $type = returnMedia($datos['archivo']);
    if ($type['preview'] == true) {
        if ($type['extension'] == ".jpg" || $type['extension'] == ".png") {
            $datos['archivo'] = basename($datos['archivo'], '.jpg');
            $datos['archivo'] = basename($datos['archivo'], '.png');
        }
        DeleteFile($prev_dir . $datos['did'] . "/" . $datos['archivo'] . ".jpg");
    }
    DeleteFile($rsc_dir . $datos['did'] . "/" . $datos['archivo']);
}
Пример #7
0
function render_admin_delseccion($param)
{
    $aid = $param['sid'];
    list($db) = Getdb();
    $tbl = GetTable('secciones');
    $col = GetCols('secciones');
    $sidcol = $col['sid'];
    $sql = "DELETE FROM {$tbl} WHERE {$sidcol}='{$aid}'";
    $resultado = $db->Execute($sql);
    if ($db->ErrorNo() != 0) {
        $mensaje = "Ha ocurrido un error al borrar la seccion";
    } else {
        $mensaje = "La seccion ha sido borrada correctamente";
    }
    /* $resultado= SmartyInit();
    		$plantilla="mensaje.tpl";
    		$resultado->assign("mensaje",$mensaje);
    		$salida=$resultado->fetch($plantilla);
    		return $salida; */
    $url = vwSessionGetVar('urlantigua');
    vwSessionDelVar('urlantigua');
    return render_msg($mensaje, 3, $url);
}
Пример #8
0
 function renderPagerRow()
 {
     $row = SmartyInit();
     $CurrentUrl = CurrentUrl();
     if (!(strpos($CurrentUrl, "start=") === false)) {
         $CurrentUrl = substr($CurrentUrl, 0, strpos($CurrentUrl, "start=") - 1);
     }
     if (strpos($CurrentUrl, "?") === false) {
         $CurrentUrl .= "?";
     } else {
         if (strpos($CurrentUrl, "&", strlen($CurrentUrl) - 1) === false) {
             $CurrentUrl .= "&";
         }
     }
     list($db) = Getdb();
     $rs = $db->Execute($this->sql);
     if (!($rs === false)) {
         $this->total = $rs->PO_RecordCount($this->table, $this->where);
     } else {
         return null;
     }
     $perpage = $this->rows;
     if ($perpage >= $this->total) {
         $PageArray[] = array('Page' => 1, 'start' => 0, 'Selected' => 1);
     } else {
         if ($start <= 0) {
             $start = 1;
         }
         $TotalPaginas = 1 + floor($this->total / $perpage);
         $PaginaActual = 1 + floor($this->start / $perpage);
         $PageArray = array();
         for ($paginas = 1; $paginas < $TotalPaginas + 1; $paginas++) {
             $PageArray[] = array('Page' => $paginas, 'start' => $paginas > 1 ? ($paginas - 1) * $perpage : 0, 'Selected' => $paginas == $PaginaActual ? 1 : 0);
         }
     }
     $row->assign('Paginas', $PageArray);
     $row->assign('baseurl', $CurrentUrl);
     $Pager = $row->fetch("freeLister_pager.tpl");
     return $Pager;
 }
Пример #9
0
function cbzRecursos($obj, $valor)
{
    list($db) = Getdb();
    $tbl = GetTable('recursos');
    $col = GetCols('recursos');
    $sql = "SELECT * FROM {$tbl} WHERE {$col['did']}={$valor}";
    $rs = $db->Execute($sql);
    if ($db->ErrorNo() != 0) {
        $param['ruta'] = "error";
        $param['mensaje'] = "Ha ocurrido leer el archivo de la base de datos.";
        render($param);
        die;
    }
    $aux = $rs->GetRows();
    foreach ($aux as $value) {
        if (trim($value[$col['url']]) != "") {
            $total['url'] = $total['url'] + 1;
        } else {
            $media = returnMedia($value[$col['archivo']]);
            $total[$media] = $total[$media] + 1;
        }
    }
    $output = "";
    if (trim($media) != "") {
        foreach ($total as $k => $v) {
            if ($v > 0) {
                $output = $output . '<img src="smallicons/' . $k . '.png">' . "{$v}&nbsp;";
            }
        }
    }
    if (trim($output) == "") {
        return "";
    } else {
        return array('nombre' => "recursos", 'valor' => $output);
    }
}
function render_user_vermis($param)
{
    require_once "lister.php";
    $sf = vwVarFromInput('sf');
    $start = vwVarFromInput('start');
    $up = vwVarFromInput('up');
    list($db) = Getdb();
    $tbl = GetTable('autorizaciones');
    $col = GetCols('autorizaciones');
    $sql = "Select * from {$tbl}";
    $Cols = array(array("dbname" => $col['autid'], "label" => "id", "width" => "45px", "sortable" => false), array("dbname" => $col['rid'], "label" => "Recurso", "width" => "70px", "sortable" => false, "dropdown" => true, "dropcall" => array("funcion" => "cbzRecursos", "valor" => $col['rid'])), array("dbname" => $col['estado'], "label" => "Estado", "width" => "45px", "sortable" => false, 'dropdown' => true, 'dropcall' => array("funcion" => "cbzEstados", "valor" => $col['estado'])), array("dbname" => $col['razon'], "label" => "Nombre", "width" => "200px", "sortable" => true));
    $opciones = array(array("funcion" => "cbautorizacionUsrDelete", "valor" => "{$col['autid']}"), array("funcion" => "cbautorizacionUsrEditar", "valor" => "{$col['autid']}"));
    $acciones = array();
    $archivList = new Lister("admAutorizaciones", $sql, 25, $Cols, $col['autid'], $opciones, "dg-admautorizaciones.css");
    $archivList->table = "{$tbl}";
    $archivList->where = "";
    $archivList->GeneralActions = $acciones;
    if ($sf != "") {
        $archivList->SetSort($sf, $up);
    }
    if ($start != "") {
        $archivList->SetStart($start);
    }
    $listado = $archivList->render();
    if ($listado === null || trim($listado) == "") {
        $aux = cbautorizacionAdmAdd();
        $listado = "<br><center><a link href='{$aux['url']}'>{$aux['etiqueta']}</a></center>";
    }
    $resultado = SmartyInit();
    $plantilla = "autorizacion/listarautorizacion.tpl";
    $resultado->assign("listado", $listado);
    $salida = $resultado->fetch($plantilla);
    vwSessionSetVar('urlantigua', CurrentUrl());
    return $salida;
}
Пример #11
0
function importar()
{
    list($db) = Getdb();
    $tbl = GetTable('recursos');
    $col = GetCols('recursos');
    $tbl2 = GetTable('documentos');
    $col2 = GetCols('documentos');
    $sqlGet = "SELECT * FROM RecImportar WHERE Archivo<>''";
    $resultado = $db->Execute($sql);
    if ($db->ErrorNo() != 0) {
        $mensaje = "Ha ocurrido un error al leer de la base de datos comprobando los datos<br />{$sql}";
        return $mensaje;
    }
    $items = $rs->GetRows();
    foreach ($items as $item) {
        $sql2 = "SELECT * from {$tbl2} WHERE {$col2['idantiguo']}={$item['idAntiguo']}";
        $rs2 = $db->Execute($sql);
        if ($db->ErrorNo() != 0) {
            $mensaje = "Ha ocurrido un error al leer de la base de datos comprobando los datos<br />{$sql}";
            return $mensaje;
        }
        $doc = $rs2->FetchRow();
        $did = $doc[$col2['did']];
        if (trim($did) != "") {
            $test1 = ImportResource($item['Archivo'] . ".sxw", "sxw", $did);
            $tit1 = "Transcripcion {$item['Archivo']}.sxw";
            $rest1 = "S";
            $test2 = ImportResource($item['Archivo'] . ".rtf", "rtf", $did);
            $tit2 = "Transcripcion {$item['Archivo']}.rtf";
            $rest2 = "S";
            $test3 = ImportResource($item['Archivo'] . ".pdf", "pdf", $did);
            $tit3 = "Transcripcion {$item['Archivo']}.pdf";
            $rest3 = "N";
            $se1 = array($col['did'] => $did, $col['titulo'] => "'" . htmlentities($tit1, ENT_QUOTES) . "'", $col['restringido'] => "'" . $rest1 . "'", $col['archivo'] => "'{$item['Archivo']}.sxw'");
            $se2 = array($col['did'] => $did, $col['titulo'] => "'" . htmlentities($tit2, ENT_QUOTES) . "'", $col['restringido'] => "'" . $rest2 . "'", $col['archivo'] => "'{$item['Archivo']}.rtf'");
            $se3 = array($col['did'] => $did, $col['titulo'] => "'" . htmlentities($tit3, ENT_QUOTES) . "'", $col['restringido'] => "'" . $rest3 . "'", $col['archivo'] => "'{$item['Archivo']}.pdf'");
            $resultado = $db->Replace($tbl, $se1, array(), false);
            $resultado = $db->Replace($tbl, $se2, array(), false);
            $resultado = $db->Replace($tbl, $se3, array(), false);
        }
    }
}
Пример #12
0
function importMassRsc()
{
    $tblDoc = GetTable('documentos');
    $colDoc = GetCols('documentos');
    $tblRec = GetTable('recursos');
    $colRec = GetCols('recursos');
    list($db) = Getdb();
    $z = array("sxw" => ".sxw", "rtf" => ".rtf", "pdf" => ".pdf");
    $sql = 'SELECT * FROM `RecImportar` where Archivo<>""';
    $rs = $db->Execute($sql);
    if ($rs === false) {
        die("Error Fatal");
    }
    $Recursos = $rs->GetRows();
    foreach ($Recursos as $recurso) {
        foreach ($z as $k => $v) {
            if (file_exists("importar/{$k}/{$recurso['Archivo']}{$v}")) {
                $sql2 = "SELECT * from {$tblDoc} WHERE {$colDoc['idantiguo']}={$recurso['IdAntiguo']}";
                $did = "";
                $rs2 = $db->Execute($sql2);
                if (!($rs2 === false)) {
                    $doc = $rs2->FetchRow();
                    $did = $doc[$colDoc['did']];
                }
                if (trim($did) != "") {
                    _startRsc($did);
                    $restringido = "'N'";
                    if ($k != "pdf") {
                        $restringido = "'s'";
                    }
                    $aux = mportResource("{$recurso['Archivo']}{$v}", $k, $did);
                    $x = $db->Replace($tblRec, array($colRec['titulo'] => "'Documento {$recurso['Archivo']}{$v}'", $colRec['did'] => $did, $colRec['restringido'] => $restringido, $colRec['archivo'] => "'{$recurso['Archivo']}{$v}'"), array(), false);
                    echo "{$recurso['Archivo']}{$v} importado<br>";
                }
            }
        }
    }
}
Пример #13
0
function csvToTbl($table, $destination)
{
    $tbl = GetTable($table);
    $col = array_values(GetCols($table));
    $csv = file($destination . "{$table}.csv");
    list($db) = Getdb();
    $rs = $db->Execute("DELETE FROM {$tbl}");
    foreach ($csv as $linea) {
        $campos = explode(';', $linea);
        $aux = array();
        $auxFld = -1;
        foreach ($campos as $v) {
            $auxFld++;
            $fld = $col[$auxFld];
            $registro[$fld] = base64_decode($v);
        }
        $result = $db->Replace($tbl, $registro, array(), false);
    }
    return true;
}
Пример #14
0
function render_user_verrsc($param)
{
    $tbl = GetTable('recursos');
    $col = GetCols('recursos');
    list($db) = Getdb();
    $rid = $param['rid'];
    $rs = $db->Execute("SELECT * from {$tbl} WHERE {$col['rid']}={$rid}");
    if ($db->ErrorNo() != 0) {
        $param['ruta'] = "error";
        $param['mensaje'] = "Ha ocurrido leer el archivo de la base de datos.";
        render($param);
        die;
    }
    $recurso = $rs->FetchRow();
    $recurso = fromdbtocms($recurso, 'recursos');
    $ul = vwSessionGetVar('UserLevel');
    $recurso["uid"] = vwSessionGetVar("uid");
    if ($ul < 1) {
        $param['ruta'] = "error";
        $param['mensaje'] = "No tiene nivel para acceder a los recursos. Registrese.";
        render($param);
        die;
    } else {
        if ($ul < 500) {
            if ($recurso['restringido'] == "S") {
                $tbl = GetTable('autorizaciones');
                $col = GetCols('autorizaciones');
                list($db) = Getdb();
                $rid = $param['rid'];
                $sql = "SELECT * FROM {$tbl} where {$col['rid']}={$valor} AND {$col['uid']}=" . vwSessionGetVar('uid') . " ORDER BY {$col['resolucion']} desc";
                $rs = $db->Execute($sql);
                if ($db->ErrorNo() != 0) {
                    $param['ruta'] = "error";
                    $param['mensaje'] = "Ha ocurrido leer el archivo de la base de datos.";
                    render($param);
                    die;
                }
                $aut = $rs->FetchRow();
                $aut = fromdbtocms($aut, 'autorizaciones');
                if ($aut['estado'] != 'C') {
                    $param['ruta'] = "error";
                    $param['mensaje'] = "No dispone de autorizacion para descargar el recurso.";
                    render($param);
                    die;
                }
            }
        }
        eventoRecursos($recurso, "verrsc");
        outputFile($recurso['archivo'], $recurso['did']);
        die;
    }
    die;
}
function GetUserByUnamez($uname)
{
    list($conn) = Getdb();
    $table = GetTable('usuarios');
    $cols = GetCols('usuarios');
    $select = "SELECT * from {$table} WHERE {$cols['uname']}='{$uname}'";
    $rs = $conn->Execute($select);
    $items = $rs->PO_RecordCount($table, " {$cols['uname']}='{$uname}'") + 0;
    switch ($items) {
        case 0:
            return false;
        case 1:
            $item = $rs->FetchRow();
            return $item;
        default:
            return false;
    }
    return false;
}
function _denegar($autid)
{
    $table = GetTable('autorizaciones');
    $cols = GetCols('autorizaciones');
    list($conn) = Getdb();
    $data = array('autid' => $autid, 'estado' => "'D'", 'resolucion' => $conn->DBTimeStamp(time()));
    $data = fromcmstodb($data, 'autorizaciones');
    $rs = $conn->Replace($table, $data, array($cols['autid']), false);
    return $rs;
}
Пример #17
0
function MakeSessionTable($name = "sessions")
{
    global $ADODB_SESSION_DRIVER, $ADODB_SESSION_USER, $ADODB_SESSION_PWD, $ADODB_SESSION_DB, $ADODB_SESS_DEBUG, $ADODB_SESSION_CONNECT, $ADODB_SESSION_EXPIRE_NOTIFY;
    //require_once("session.conf.inc.php");
    switch ($ADODB_SESSION_DRIVER) {
        case 'mysql':
            $sql = "CREATE TABLE {$name}\n\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\tSESSKEY char(32) not null,\n\t\t\t\t\t\t\t\t\t\t\t\tEXPIRY int(11) unsigned not null,\n\t\t\t\t\t\t\t\t\t\t\t\tEXPIREREF varchar(64),\n\t\t\t\t\t\t\t\t\t\t\t\tDATA text not null,\n\t\t\t\t\t\t\t\t\t\t\t\tprimary key (SESSKEY));";
            break;
        default:
            my_fatal_error();
            die;
    }
    list($conn) = Getdb();
    $conn->Execute($sql);
    if ($conn->ErrorNo() != 0) {
        my_fatal_error();
        die;
    }
    return true;
}
function render_admin_listarestadisticas($param)
{
    require_once "lister.php";
    $sf = vwVarFromInput('sf');
    $start = vwVarFromInput('start');
    $up = vwVarFromInput('up');
    list($db) = Getdb();
    // Recursos
    $tbl = GetTable('recursos');
    $col = GetCols('recursos');
    $sql = "Select * from {$tbl}";
    $Cols = array(array("dbname" => $col['rid'], "label" => "id", "width" => "45px", "sortable" => false), array("dbname" => $col['nombre'], "label" => "Nombre", "width" => "200px", "sortable" => false), array("dbname" => $col['acceso'], "label" => "Nº Accesos", "width" => "45px", "sortable" => true), array("dbname" => $col['solicitud'], "label" => "Nº Solicitudes", "width" => "45px", "sortable" => true, "sort" => "D"));
    $opciones = array();
    $acciones = array();
    $recurList = new Lister("admRecursos", $sql, 25, $Cols, $col['rid'], $opciones, "dg-admrecursos.css");
    $recurList->table = "{$tbl}";
    $recurList->where = "";
    $recurList->GeneralActions = $acciones;
    if ($sf != "") {
        $recurList->SetSort($sf, $up);
    }
    if ($start != "") {
        $recurList->SetStart($start);
    }
    $listadoRecur = $recurList->render();
    if ($listadoRecur === null || trim($listadoRecur) == "") {
        $listadoRecur = "<br><center>No hay estadisticas a mostrar</a></center>";
    }
    //Documentos
    $tbl = GetTable('documentos');
    $col = GetCols('documentos');
    $sql = "Select * from {$tbl}";
    $Cols = array(array("dbname" => $col['did'], "label" => "id", "width" => "45px", "sortable" => false), array("dbname" => $col['visitas'], "label" => "Visitas", "width" => "45px", "sortable" => true, "sort" => "D"), array("dbname" => $col['signatura'], "label" => "Signatura", "width" => "200px", "sortable" => false));
    $opciones = array();
    $acciones = array();
    $docuList = new Lister("admDocumentos", $sql, 25, $Cols, $col['did'], $opciones, "dg-admdocumentos.css");
    $docuList->table = "{$tbl}";
    $docuList->where = "";
    $docuList->GeneralActions = $acciones;
    if ($sf != "") {
        $docuList->SetSort($sf, $up);
    }
    if ($start != "") {
        $docuList->SetStart($start);
    }
    $listadoDocu = $docuList->render();
    //****************
    if ($listadoDocu === null || trim($listadoDocu) == "") {
        $listadoDocu = "<br><center>No hay estadisticas a mostrar</a></center>";
    }
    ///********
    $listadoRegistros = eventos('registro');
    $listadoVerdoc = eventos('verdoc');
    $listadoVerrsc = eventos('verrsc');
    $listadoSolicitudes = eventos('solicitud');
    $listadoEdicion = eventos('editar');
    $listadoConceder = eventos('conceder');
    ///********
    $resultado = SmartyInit();
    $plantilla = "estadisticas/listarestadisticas.tpl";
    $resultado->assign("listadoRecur", $listadoRecur);
    $resultado->assign("listadoDocu", $listadoDocu);
    $resultado->assign("listadoRegistros", $listadoRegistros);
    $resultado->assign("listadoVerdoc", $listadoVerdoc);
    $resultado->assign("listadoVerrsc", $listadoVerrsc);
    $resultado->assign("listadoSolicitudes", $listadoSolicitudes);
    $resultado->assign("listadoConceder", $listadoConceder);
    $resultado->assign("listadoEdicion", $listadoEdicion);
    $salida = $resultado->fetch($plantilla);
    vwSessionSetVar('urlantigua', CurrentUrl());
    return $salida;
}