示例#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;
}
function _delete($aid)
{
    if (_delete_check($aid) === false) {
        return false;
    }
    $table = GetTable('archivos');
    $cols = GetCols('archivos');
    list($conn) = Getdb();
    $sql = "DELETE FROM {$table} WHERE {$cols['aid']}={$aid};";
    $rs = $conn->Execute($sql);
    //event_loger()
    if ($rs === false) {
        return false;
    }
    return true;
}
function _insert_update($data, $insert = true)
{
    list($conn) = Getdb();
    $table = GetTable('secciones');
    $cols = GetCols('secciones');
    $dat = prepare_data_for_ADODB_replace($data, $table);
    $result = $conn->Replace($table, $dat, array($cols['sid']), false);
    switch ($insert) {
        case true:
            switch ($result) {
                case 2:
                    $ret = true;
                    break;
                case 1:
                    $ret = "Warning: Data Corruption!";
                    break;
                case 0:
                    $ret = false;
                    break;
            }
            break;
        case false:
            switch ($result) {
                case 2:
                    $ret = "Warning: New data inserted!!";
                    break;
                case 1:
                    $ret = true;
                    break;
                case 0:
                    $ret = false;
                    break;
            }
            break;
    }
    return $ret;
}
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;
}
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']);
}
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);
}
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 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);
        }
    }
}
示例#10
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>";
                }
            }
        }
    }
}
示例#11
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;
}
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 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;
}
function eventos($accion)
{
    $miArray = lastNEntriesAction($accion, 25);
    $Rows = devuelveRows($miArray);
    $col_id = 'did';
    switch ($accion) {
        case "solicitud":
            $col = GetCols('recursos');
            $col_id = $col['rid'];
            $Cols = array(array("dbname" => $col['rid'], "label" => "id del recurso", "width" => "45px", "sortable" => false), array("dbname" => $col['uid'], "label" => "Id del usuario", "width" => "45px", "sortable" => false), array("dbname" => $col['razon'], "label" => "razon", "width" => "200px", "sortable" => false));
            break;
        case "verdoc":
            $col = GetCols('documentos');
            $col_id = $col['did'];
            $Cols = array(array("dbname" => $col['did'], "label" => "id del documento", "width" => "290px", "sortable" => false));
            break;
        case "verrsc":
            $col = GetCols('recursos');
            $col_id = $col['rid'];
            $Cols = array(array("dbname" => $col['rid'], "label" => "id del recurso", "width" => "45px", "sortable" => false), array("dbname" => $col['uid'], "label" => "Id del usuario", "width" => "45px", "sortable" => false), array("dbname" => $col['restringido'], "label" => "Restringido", "width" => "200px", "sortable" => false));
            break;
        case "conceder":
            $col = GetCols('recursos');
            $col_id = $col['rid'];
            $Cols = array(array("dbname" => $col['rid'], "label" => "id del recurso", "width" => "45px", "sortable" => false), array("dbname" => $col['uid'], "label" => "Id del usuario", "width" => "45px", "sortable" => false));
            break;
        case "registro":
            $col = GetCols('usuarios');
            $col_id = $col['uid'];
            $Cols = array(array("dbname" => $col['uid'], "label" => "id del usuario", "width" => "45px", "sortable" => false), array("dbname" => $col['uname'], "label" => "Nombre", "width" => "45px", "sortable" => false), array("dbname" => $col['apellidos'], "label" => "Apellidos", "width" => "200px", "sortable" => false));
            break;
        case "editar":
            $col = GetCols('usuarios');
            $col_id = $col['uid'];
            $Cols = array(array("dbname" => $col['uid'], "label" => "id del usuario", "width" => "45px", "sortable" => false), array("dbname" => $col['uname'], "label" => "Nombre", "width" => "45px", "sortable" => false), array("dbname" => $col['apellidos'], "label" => "Apellidos", "width" => "200px", "sortable" => false));
            break;
    }
    $opciones = array();
    $acciones = array();
    $evento = new Lister("admEventos", $Rows, 25, $Cols, $col_id, $opciones, "dg-admeventos.css");
    $evento->table = "";
    $evento->where = "";
    $evento->GeneralActions = $acciones;
    if ($sf != "") {
        $docuList->SetSort($sf, $up);
    }
    if ($start != "") {
        $docuList->SetStart($start);
    }
    return $evento->render2();
}