Proyecto

General

Perfil

Descargar (33,4 KB) Estadísticas
| Rama: | Revisión:
{
Adtos 1.0 Software de gesti?n de Aulas Tecnol?gicas

Programaci?n: Manuel Narv?ez Mart?nez <mnarvaez007@gmail.com>
Dise?o gr?fico: Ana Mar?a Zamora Moreno
Desarrollado con Lazarus 0.9.26

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit globales;
{$mode objfpc}{$H+}
interface

uses unix,textomensajes, Classes,SysUtils,StrUtils,Graphics,Forms,Controls,Types,IniFiles;
type
TEstadoActividadEquipo=(eApagado,eEncendiendo,eEncendido,eUsuario,eApagando,eAveriado);

EDialogos = (Aceptar,SiNo);
TDialogo=Record
mensaje:string;
ClaseDialogo:Edialogos;
respuesta:integer;
end;

TDistribucion=Record
numColumnas:integer;
ancho:integer;
alto:integer;
altura:integer;
izquierda:integer;
sepH:array of integer;
tamano_fuente:integer;
end;
TPersonal=record
ancho:integer;
alto:integer;
tamano_fuente:integer;
end;
TDatosNuevosEquipos=record
miHost:String;
Ip:string;
usuarioActivo:String;
mac:String;
curso:String;
dominio:String;
estadoActividad:TEstadoActividadEquipo;
end;
Tmiclase=record
NombreAula:string;
icono:integer;
//para los equipos
Host:array of string;
UsuariosActivo:array of string;
tipo_equipo:array of integer;//alumno 0 profesor 1
IP:array of string;//ips de los equipos
MAC:array of string;//mac de los equipo
Dominio:array of string;//dominios de los equipos;
EstadoActividad:array of TEstadoActividadEquipo;

end;
TGrupoEquipos=record
Dominio:string;
Host:string;
IP:string;//ips de los equipos
MAC:string;//mac de los equipo
curso:string;
end;
TGruposDeEquipos=record
NumeroEquipos:integer;
Nombre:String;
Dominio:array of string;
Host:array of string;
IP: array of string;//ips de los equipos
MAC:array of string;//mac de los equipo
curso:array of string;
end;
TEquiposMAula=Array of Array[0..35] of TDatosNuevosEquipos;
const

DIR_SETUP_ADTOS:string='/etc/adtosadmin.conf';
ROJO_COLOR:Tcolor=$7B61FF;
VERDE_COLOR:Tcolor=$66FFCC;
BLANCO_COLOR:TColor=$E5E5E5;
AZUL_COLOR:TColor=$FF6666;
MORADO_COLOR:TColor=$CC0099;
PUERTO_ROOT:INTEGER=37999;
PUERTO_USUARIO:integer=38000;
PUERTO_VNC:integer=5988;
PUERTO_CONSULTA:integer=38255;
SLEEP_MINIMO:integer=50;
SLEEP_BAJO :integer=100;
SLEEP_MEDIO:integer=250;
SLEEP_ALTO :integer=500;
SLEEP_MAXIMO :integer=1000;
var
g_comando_consulta:integer=0;
g_pantalla_proceso:integer=6;
g_botonProcesoMarcado:integer;
g_primara_revision_hecha:Boolean=false;
g_contador_refresco_centro:integer;
g_proceso_realizado:Boolean=false;
g_revisionCentro_actualizada:Boolean=false;
g_carpeta_enviar_path_root:string;
g_tipo_comando:integer=-1;
g_listadominios:array of string;
g_GruposEquipos:Array of TGruposDeEquipos;
g_NumGrupos:integer=0;
g_numero_equipos_registrados:integer=48;
g_EquiposDominio:array of TGrupoEquipos;

g_verNombreCursos:Boolean=false;
g_equiposAulas:Array of Array[0..35] of TDatosNuevosEquipos;
g_EstadoAulasCentro:Array of ansiString;
g_contraServidores:String='';
g_DestinosLibres:Boolean=true;
g_ComandosLibres:Boolean=true;
g_ordenes_root:array of String;
g_procesos_root:array of String;
g_comandoRootEjecutar:String='';
g_mostrarNombreUsuario:Boolean=true;
g_velocidad_red:Integer=1;
g_factor_velocidad:integer=0;
g_cambiando_menu:Boolean=false;
g_tipoAula:integer=10;
g_Distribuciones:Array[0..11] of TDistribucion;
g_Escritorio:string='gdm';
g_ExploradorArchivos:string='nautilus';
g_archivo_configuracion_adtos:string='/etc/adtosadmin.conf';
g_nombreAplicacion1:string='';
g_mensaje_prioridad:string;
g_mensaje_asunto:string;
g_mensaje_texto:string;
g_archivo_mensaje:String;
g_archivo_nombre:string;
g_archivo_nombre_root:String;
g_archivo_path:string;
g_archivo_path_root:string;
g_carpeta_destino_root:string='/tmp';
g_carpeta_mensaje:String;
g_carpeta_enviar_path:string;
g_MostrandoPantalla:integer=0;
g_IniciadaSesion:boolean=false;
g_PanelCanon:boolean=false;
g_Display:string='0';
g_apagando:boolean=false;
g_NombreAdministrador:string;
g_EspecialidaAdministrador:string;
g_NombreAplicacion:array[0..8] of string;
g_ComandoAplicacion:array[0..8] of string;
g_AsignaAdministrador:array[0..7] of string;
g_DisenoClase:integer=0;
g_num_diseno:integer=48;
g_num_servidores_aula:integer=48;
g_num_ord_pantalla:integer;
g_sepT:integer;
g_respuestas_recibidas:array of integer;
g_tiempoRecogida:integer=5;
TipoDialogo:Tdialogo;
Function Mensaje(texto:string;clase:edialogos):integer;
Function NumeroNombreOrdenador(num:integer):string;
Function HallarDatosUsuario(const S :string):string;
Function HallarDato(Cmd:string):string;
Function NumOrdLet(num:integer):string;
procedure OrdenesAula(orden:string;comandos:array of const);
function RGB(R, G, B: Byte): TColor;
procedure CrearArchivos(NumRec:Integer;NomArchivo:string);
procedure Ejecutar(cmd:string);
procedure DimensionBMP( sArchivo: string; var wAncho, wAlto: Word );
procedure DimensionJPG( sArchivo: string; var wAncho, wAlto: Word );
procedure DimensionPNG( sArchivo: string; var wAncho, wAlto: Word );
function LeerPalabraMotorola( F: TFileStream ): Word;
function tiempo(value:integer):string;
function GetToken(Cadena:string; Separador:char; Token:integer):string;
function HallaTipoAula(numf:integer):integer;
function NumeroOrdenadorePantalla(tipo_aula,numero_ordenadores:integer):integer;
procedure cargaDistribuciones();
function compruebaPasswordRoot(password:String):Boolean;
function EncriptaXOR(cadena,clave : string) : string;
procedure hallaEquiposDominio();
Function LeerFicheroCursos():Boolean;
procedure CrearGruposDominio();
procedure cargarGruposDominios(var grupo: TGruposDeEquipos);
procedure cargaDominios(mdominio:String);
Function quitaEspacios(texto:String):String;
Function poneEspacios(texto:String):String;
function ReplaceAll(const Subject: String;const OldPatterns, NewPatterns: array of String; IgnoreCase: Boolean): String;
implementation

uses globales1,dialogos;
{ TOrdenes }
Function quitaEspacios(texto:String):String;
var
mitexto1,mitexto:String;
begin
result:=ReplaceAll(texto,[' ', '?'],['&#','$a'],false);
//mitexto:=StringReplace(texto,' ','&#', [rfReplaceAll]);
//mitexto1:=StringReplace(mitexto,'?','&a#', [rfReplaceAll]);
(*mitexto:=StringReplace(mitexto,'?','&e#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&i#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&o#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&u#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&A#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&E#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&I#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&O#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&U#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&n#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&?#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&?#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&!#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&#', [rfReplaceAll]);
mitexto:=StringReplace(mitexto,'?','&#', [rfReplaceAll]); *)
//result:=mitexto1;
writeln(result);

end;

function ReplaceAll(const Subject: String;
const OldPatterns, NewPatterns: array of String;
IgnoreCase: Boolean): String;
var
ReplaceFlags: TReplaceFlags;
NewPattern: String;
I: Integer;
begin
ReplaceFlags := [rfReplaceAll];
if IgnoreCase then
Include(ReplaceFlags, rfIgnoreCase);
Result := Subject;
for I := Low(OldPatterns) to High(OldPatterns) do
begin
if I <= High(NewPatterns) then
NewPattern := NewPatterns[I]
else
NewPattern := '';
Result := StringReplace(Result, OldPatterns[I], NewPattern, ReplaceFlags);
end;
end;
Function poneEspacios(texto:String):String;
var
mitexto:String;
begin
mitexto:=StringReplace(texto,'&#',' ', [rfReplaceAll])
end;
procedure cargaDominios(mdominio:String);
var
nuevod : boolean;
numerodominios,i:integer;
begin
nuevod:=true;
numerodominios:=Length(g_listadominios);
////writeln('Numero dominios ',numerodominios);
if numerodominios=0 then
begin
SetLength(g_listadominios,numerodominios+1);
g_listadominios[numerodominios]:=mdominio;
exit;
end;
for i:=0 to numerodominios-1 do
begin
if mdominio =g_listadominios[i] then
begin
nuevod:=false;
break
end;
end;
if nuevod then
begin
SetLength(g_listadominios,numerodominios+1);
g_listadominios[numerodominios]:=mdominio
end;
end;
procedure cargarGruposDominios(var grupo: TGruposDeEquipos);
var
j,i: integer;
mdominio:String;
begin
SetLength(grupo.Host,g_numero_equipos_registrados);
SetLength(grupo.IP,g_numero_equipos_registrados);
SetLength(grupo.MAC,g_numero_equipos_registrados);
SetLength(grupo.Dominio,g_numero_equipos_registrados);
SetLength(grupo.Curso,g_numero_equipos_registrados);
mdominio:=grupo.Nombre;
////writeln('numero registrados ',g_numero_equipos_registrados);
j:=0;
for i:=0 to g_numero_equipos_registrados -1 do
begin
////writeln('host ',g_EquiposDominio[i].Host,' dominio ',g_EquiposDominio[i].Dominio);
if (Trim(g_EquiposDominio[i].Host)<>'') and ((g_EquiposDominio[i].Dominio=mdominio) or (mdominio='Todos')) then
begin
grupo.Host[j]:=g_EquiposDominio[i].Host;
grupo.IP[j]:=g_EquiposDominio[i].IP;
grupo.MAC[j]:=g_EquiposDominio[i].MAC;
grupo.Dominio[j]:=g_EquiposDominio[i].Dominio;
////writeln('-------->host ',g_EquiposDominio[i].Host,' dominio ',g_EquiposDominio[i].Dominio);
grupo.curso[j]:=g_EquiposDominio[i].curso;

inc(j);
end
end;
SetLength(grupo.Host,j);
SetLength(grupo.IP,j);
SetLength(grupo.MAC,j);
SetLength(grupo.Dominio,j);
SetLength(grupo.Curso,j);
grupo.NumeroEquipos:=j;

end;
procedure CrearGruposDominio();
var
i,j:integer;
nombre:string;
begin
g_NumGrupos:=Length(g_listadominios);
SetLength(g_GruposEquipos,g_NumGrupos);
for i:=0 to g_NumGrupos -1 do
begin
g_GruposEquipos[i].Nombre:=g_listadominios[i];
cargarGruposDominios(g_GruposEquipos[i]);
end;

end;
Function LeerFicheroCursos():Boolean;
var
Mifichero1:TMemIniFile;
migrupo,j,i:integer;
posgrupo:string;
numgru:integer;
begin
try
result:=true;
Mifichero1 := TMemIniFile.Create('/var/lib/adtos/grupos.ini');
try
with Mifichero1 do
begin
g_NumGrupos:=ReadInteger('Grupos','Numero_Grupos',0);
setlength(g_GruposEquipos,g_NumGrupos);
if g_NumGrupos=0 then
begin
result:=false;
exit;
end;
for i:=0 to high(g_GruposEquipos) do
begin
g_GruposEquipos[i].nombre:=ReadString('Grupo_'+inttostr(i),'Nombre','');
g_GruposEquipos[i].NumeroEquipos:=ReadInteger('Grupo_'+inttostr(i),'Numero_Equipos',48);
setlength(g_GruposEquipos[i].Host,g_GruposEquipos[i].NumeroEquipos);
setlength(g_GruposEquipos[i].IP,g_GruposEquipos[i].NumeroEquipos);
setlength(g_GruposEquipos[i].MAC,g_GruposEquipos[i].NumeroEquipos);
setlength(g_GruposEquipos[i].Dominio,g_GruposEquipos[i].NumeroEquipos);
setlength(g_GruposEquipos[i].Curso,g_GruposEquipos[i].NumeroEquipos);
for j:=0 to g_GruposEquipos[i].NumeroEquipos-1 do
begin
g_GruposEquipos[i].Host[j]:=ReadString('Grupo_'+inttostr(i),'Host_'+inttostr(j),'');
g_GruposEquipos[i].IP[j]:=ReadString('Grupo_'+inttostr(i),'IP_'+inttostr(j),'');
g_GruposEquipos[i].MAC[j]:=ReadString('Grupo_'+inttostr(i),'MAC_'+inttostr(j),'');
g_GruposEquipos[i].Dominio[j]:=ReadString('Grupo_'+inttostr(i),'Dominio_'+inttostr(j),'');
g_GruposEquipos[i].curso[j]:=ReadString('Grupo_'+inttostr(i),'Curso_'+inttostr(j),'');
end;

end;
end;
finally
Mifichero1.free;
end;
except
// Mensaje(MEN_ERROR_GRUPOS,aceptar);
end;
end;
procedure hallaEquiposDominio;
var
Mifichero:TMemIniFile;
i:integer;
nmord:string;
dominio,curso:string;
begin
try
if FileExists('/etc/adtosadmin.conf') then
begin
Mifichero:= TMemIniFile.create('/etc/adtosadmin.conf');
With Mifichero do
begin
nmord:=ReadString('Centro','Numero aulas','48');
//writeln('Numero aulas ',nmord);
g_num_servidores_aula:=strtoint(nmord);
g_tipoAula :=9;
if g_num_servidores_aula >54 then g_tipoAula :=10;
g_numero_equipos_registrados:=ReadInteger('Centro','numero equipos registrados',g_num_servidores_aula);
//sgED.RowCount:= g_numero_equipos_registrados+1;
SetLength(g_EquiposDominio, g_numero_equipos_registrados);
////writeln('numero registrados: ', g_numero_equipos_registrados);
for i:=0 to g_numero_equipos_registrados -1 do
begin
g_EquiposDominio[i].Host:=ReadString('Nombre','Aula '+ NumOrdLet(i),'');
g_EquiposDominio[i].IP:=ReadString('IP','Aula '+ NumOrdLet(i),'');
g_EquiposDominio[i].MAC:=ReadString('MAC','Aula '+ NumOrdLet(i),'');
g_EquiposDominio[i].curso:=ReadString('Curso','Aula '+ NumOrdLet(i),'');
g_EquiposDominio[i].Dominio:=ReadString('Dominio','Aula '+ NumOrdLet(i),'general');
cargaDominios( g_EquiposDominio[i].Dominio);
end;
Free;
end;
end;

except
begin
//Mensaje(MEN_ERROR_AULA,aceptar);
end
end;
end;
function EncriptaXOR(cadena,clave : string) : string;
var
i : integer;
begin
result:='';
for i:=1 to length(cadena) do
result:=result+chr(ord(cadena[i]) xor ord(clave[(i mod length(clave))+1]));
end;

function compruebaPasswordRoot(password:String):Boolean;
const
GENERA_PASSWORD:STRING=' mkpasswd -H md5 %s -S %s ';

HALLA_SALT:String='cat /etc/shadow | grep "^root:" | head -n 1| cut -f3 -d"$"';
HALLA_PASSWORD:String='cat /etc/shadow | grep "^root:" | cut -f4 -d"$" |cut -f1 -d":"';
HALLA_NUMERO:String='cat /etc/shadow | grep "^root:" | cut -f2 -d"$"';
var
clavecorrecta:Boolean;
passwordRoot:String;
passwordGenerado:String;
salt:String;
orden:String;
numero:String;
ordenpasw:String;
begin
try
clavecorrecta:=false;
passwordRoot:=HallarDato(HALLA_PASSWORD);
salt:=HallarDato(HALLA_SALT);
numero:=HallarDato(HALLA_NUMERO);
ordenpasw:='perl -e '+ QuotedStr('print crypt("%s","\$%s\$%s"), "\n"');
ordenpasw:=Format(ordenpasw,[password,numero,salt]);
passwordRoot:='$'+numero+'$'+salt+'$'+passwordRoot;
orden:=Format(GENERA_PASSWORD,[password,salt]);
passwordGenerado:=HallarDato(ordenpasw);
if passwordGenerado = passwordRoot then
clavecorrecta:=true
else
clavecorrecta:=false ;
Result:=clavecorrecta;
except
Result:=false;;
end;
end;

function NumeroOrdenadorePantalla(tipo_aula,numero_ordenadores:integer):integer;
begin
result:=12;
case tipo_aula of

10:
begin
if numero_ordenadores<=7 then
result:=14
else
result:=(((numero_ordenadores-1) div 7+1 )*7);
end;
8:
begin
if numero_ordenadores<=5 then
result:=10
else
result:=(((numero_ordenadores-1) div 5+1 )*5);
end;
7,11:
begin
if numero_ordenadores<=8 then
result:=16
else
result:=(((numero_ordenadores-1) div 8+1 )*8);
end;
5,9:
begin
if numero_ordenadores<=6 then
result:=12
else
result:=(((numero_ordenadores-1) div 6+1 )*6);
end;
4:
begin
if numero_ordenadores<=3 then
result:=6
else
result:=(((numero_ordenadores-1) div 3+1 )*3);
end;
3,6:
begin
if numero_ordenadores<=4 then
result:=8
else
result:=(((numero_ordenadores-1) div 4+1 )*4);
end;
// 2 columnas
0,1,2:
begin
if numero_ordenadores<=2 then
result:=4
else
result:=(((numero_ordenadores-1) div 2+1 )*2);
end;
end;
end;

function HallaTipoAula(numf:integer):integer;
begin
if numf=2 then
result:=2
else
result:=4;
end;
procedure cargaDistribuciones();
begin
//1x1
g_Distribuciones[0].numColumnas:=1;
g_Distribuciones[0].ancho:=66;
g_Distribuciones[0].alto:=61;
g_Distribuciones[0].altura:=503;
g_Distribuciones[0].izquierda:=448;
setlength(g_Distribuciones[0].sepH,g_Distribuciones[0].numColumnas);
g_Distribuciones[0].sepH[0]:=186;
g_Distribuciones[0].tamano_fuente:=10;

// 1x2 columnas de dos equipos
g_Distribuciones[1].numColumnas:=2;
g_Distribuciones[1].ancho:=66;
g_Distribuciones[1].alto:=61;
g_Distribuciones[1].altura:=503;
g_Distribuciones[1].izquierda:=470;
setlength(g_Distribuciones[1].sepH,g_Distribuciones[1].numColumnas);
g_Distribuciones[1].sepH[1]:=120;
g_Distribuciones[1].sepH[0]:=210;
g_Distribuciones[1].tamano_fuente:=10;

// 2x1 columnas de un equipos
g_Distribuciones[2].numColumnas:=2;
g_Distribuciones[2].ancho:=66;
g_Distribuciones[2].alto:=61;
g_Distribuciones[2].altura:=503;
g_Distribuciones[2].izquierda:=448;
setlength(g_Distribuciones[2].sepH,g_Distribuciones[2].numColumnas);
g_Distribuciones[2].sepH[1]:=100;
g_Distribuciones[2].sepH[0]:=276;
g_Distribuciones[2].tamano_fuente:=10;

// 2x2 columnas de dos equipos
g_Distribuciones[3].numColumnas:=4;
g_Distribuciones[3].ancho:=66;
g_Distribuciones[3].alto:=61;
g_Distribuciones[3].altura:=503;
g_Distribuciones[3].izquierda:=450;
setlength(g_Distribuciones[3].sepH,g_Distribuciones[3].numColumnas);
g_Distribuciones[3].sepH[3]:=20;
g_Distribuciones[3].sepH[2]:=100;
g_Distribuciones[3].sepH[1]:=270;
g_Distribuciones[3].sepH[0]:=350;
g_Distribuciones[3].tamano_fuente:=10;

// 3x1 tres columnas de un equipo
g_Distribuciones[4].numColumnas:=3;
g_Distribuciones[4].ancho:=66;
g_Distribuciones[4].alto:=61;
g_Distribuciones[4].altura:=503;
g_Distribuciones[4].izquierda:=450;
setlength(g_Distribuciones[4].sepH,g_Distribuciones[4].numColumnas);
g_Distribuciones[4].sepH[2]:=20;
g_Distribuciones[4].sepH[1]:=185;
g_Distribuciones[4].sepH[0]:=350;
g_Distribuciones[4].tamano_fuente:=10;

// 3x2 tres columnas de dos equipos
g_Distribuciones[5].numColumnas:=6;
g_Distribuciones[5].ancho:=55;
g_Distribuciones[5].alto:=50;
g_Distribuciones[5].altura:=523;
g_Distribuciones[5].izquierda:=440;
setlength(g_Distribuciones[5].sepH,g_Distribuciones[5].numColumnas);
g_Distribuciones[5].sepH[5]:=5;
g_Distribuciones[5].sepH[4]:=75;
g_Distribuciones[5].sepH[3]:=160;
g_Distribuciones[5].sepH[2]:=230;
g_Distribuciones[5].sepH[1]:=315;
g_Distribuciones[5].sepH[0]:=385;
g_Distribuciones[5].tamano_fuente:=6;

// 4x1 cuatro columnas de un equipo
g_Distribuciones[6].numColumnas:=4;
g_Distribuciones[6].ancho:=66;
g_Distribuciones[6].alto:=61;
g_Distribuciones[6].altura:=503;
g_Distribuciones[6].izquierda:=450;
setlength(g_Distribuciones[6].sepH,g_Distribuciones[6].numColumnas);
g_Distribuciones[6].sepH[3]:=20;
g_Distribuciones[6].sepH[2]:=130;
g_Distribuciones[6].sepH[1]:=240;
g_Distribuciones[6].sepH[0]:=350;
g_Distribuciones[6].tamano_fuente:=10;
// 4x2 cuatro columnas de dos equipos
g_Distribuciones[7].numColumnas:=8;
g_Distribuciones[7].ancho:=40;
g_Distribuciones[7].alto:=37;
g_Distribuciones[7].altura:=533;
g_Distribuciones[7].izquierda:=443;
setlength(g_Distribuciones[7].sepH,g_Distribuciones[7].numColumnas);
g_Distribuciones[7].sepH[7]:=15;
g_Distribuciones[7].sepH[6]:=67;
g_Distribuciones[7].sepH[5]:=130;
g_Distribuciones[7].sepH[4]:=184;
g_Distribuciones[7].sepH[3]:=245;
g_Distribuciones[7].sepH[2]:=297;
g_Distribuciones[7].sepH[1]:=360;
g_Distribuciones[7].sepH[0]:=412;
g_Distribuciones[7].tamano_fuente:=6;

// 5x1 cinco columnas de un equipo
g_Distribuciones[8].numColumnas:=5;
g_Distribuciones[8].ancho:=55;
g_Distribuciones[8].alto:=50;
g_Distribuciones[8].altura:=533;
g_Distribuciones[8].izquierda:=443;
setlength(g_Distribuciones[8].sepH,g_Distribuciones[8].numColumnas);
g_Distribuciones[8].sepH[4]:=21;
g_Distribuciones[8].sepH[3]:=107;
g_Distribuciones[8].sepH[2]:=193;
g_Distribuciones[8].sepH[1]:=279;
g_Distribuciones[8].sepH[0]:=365;
g_Distribuciones[8].tamano_fuente:=6;

// 6x1 seis columnas de un equipos
g_Distribuciones[9].numColumnas:=6;
g_Distribuciones[9].ancho:=55;
g_Distribuciones[9].alto:=50;
g_Distribuciones[9].altura:=520;
g_Distribuciones[9].izquierda:=453;
setlength(g_Distribuciones[9].sepH,g_Distribuciones[9].numColumnas);
g_Distribuciones[9].sepH[5]:=8;
g_Distribuciones[9].sepH[4]:=81;
g_Distribuciones[9].sepH[3]:=154;
g_Distribuciones[9].sepH[2]:=227;
g_Distribuciones[9].sepH[1]:=300;
g_Distribuciones[9].sepH[0]:=374;
g_Distribuciones[9].tamano_fuente:=6;

// 7x1 siete columnas de un equipo
g_Distribuciones[10].numColumnas:=7;
g_Distribuciones[10].ancho:=55;
g_Distribuciones[10].alto:=50;
g_Distribuciones[10].altura:=520;
g_Distribuciones[10].izquierda:=454;
setlength(g_Distribuciones[10].sepH,g_Distribuciones[10].numColumnas);
g_Distribuciones[10].sepH[6]:=8;
g_Distribuciones[10].sepH[5]:=69;
g_Distribuciones[10].sepH[4]:=130;
g_Distribuciones[10].sepH[3]:=191;
g_Distribuciones[10].sepH[2]:=252;
g_Distribuciones[10].sepH[1]:=313;
g_Distribuciones[10].sepH[0]:=374;
g_Distribuciones[10].tamano_fuente:=6;

// 8x1 cinco columnas de 1 equipos
g_Distribuciones[11].numColumnas:=8;
g_Distribuciones[11].ancho:=40;
g_Distribuciones[11].alto:=37;
g_Distribuciones[11].altura:=540;
g_Distribuciones[11].izquierda:=443;
setlength(g_Distribuciones[11].sepH,g_Distribuciones[11].numColumnas);
g_Distribuciones[11].sepH[7]:=5;
g_Distribuciones[11].sepH[6]:=60;
g_Distribuciones[11].sepH[5]:=115;
g_Distribuciones[11].sepH[4]:=170;
g_Distribuciones[11].sepH[3]:=225;
g_Distribuciones[11].sepH[2]:=280;
g_Distribuciones[11].sepH[1]:=335;
g_Distribuciones[11].sepH[0]:=390;
g_Distribuciones[11].tamano_fuente:=6;
end;

procedure Ejecutar(cmd:string);
begin
fpsystem(cmd);
end;

function HallarDato(Cmd:string):String;
var
file1: TextFile;
s,t: ansistring;
n: longint;
j:integer;
begin
j:=0;
n:=popen(file1, Cmd, 'r');
if n=-1 then
begin
result:='';
Mensaje(MEN_ERROR_HALLAR_DATO,Aceptar);
Exit;
end;
t:='';
while not eof(file1) do begin
Readln(File1,s);
t:=t+s+Chr(10);
inc(j);
end;
pclose(file1);
result := trim(t);
end;
function RGB(R, G, B: Byte): TColor;
begin
Result := TColor(R or (G shl 8) or (B shl 16));
end;

procedure OrdenesAula(orden:string;comandos:array of const);
var
miorden:string;
begin
miorden:=format(orden,comandos);
fpsystem(miorden)
end;

Function NumOrdLet(num:integer):string;
var
letraord:string;
begin
num:=succ(num);
letraord:=ifthen(num<10,'0'+inttostr(num),inttostr(num));
result:=letraord;
end;

Function NumeroNombreOrdenador(num:integer):string;
begin
result:=equipoServidorAula[num].IP;
end;

Function Mensaje(texto:string;clase:edialogos):integer;
begin
tipodialogo.mensaje:=texto;;
tipodialogo.clasedialogo:=clase;
Tfrmdialogos.Create(nil).ShowModal;
result:=tipodialogo.respuesta;
frmdialogos.Free;
end;


Function HallarDatosUsuario(const S :string):string;
begin
result:=getenvironmentvariable(S);
end;

procedure CrearArchivos(NumRec:Integer;NomArchivo:string);
var
Corriente:TResourceStream;
NombreRecurso,NombreArchivo:string;
begin
if not fileexists(NomArchivo) then
begin
NombreArchivo:=NomArchivo;
NombreRecurso:='#'+inttostr(NumRec);
Corriente:=TResourceStream.Create( hInstance,NombreRecurso,RT_RCDATA );
try
Corriente.Seek(0,soFromBeginning);
corriente.SaveToFile(NombreArchivo);
finally
Corriente.Free;
end;
end;
end;

procedure DimensionBMP( sArchivo: string; var wAncho, wAlto: Word );
var
miImagen:Tbitmap;
begin
miImagen:=Tbitmap.create;
try
miImagen.LoadFromFile(sArchivo);
wAncho:=miImagen.Width;
wAlto:=miImagen.Height;
finally
miImagen.Free;
end;
end;

procedure DimensionJPG( sArchivo: string; var wAncho, wAlto: Word );
const
ValidSig: array[0..1] of Byte = ($FF, $D8);
Parameterless = [$01, $D0, $D1, $D2, $D3, $D4, $D5, $D6, $D7];
var
Sig: array[0..1] of byte;
F: TFileStream;
x: integer;
Seg: byte;
Dummy: array[0..15] of byte;
Len: word;
iLongitudLinea: LongInt;
begin
FillChar( Sig, SizeOf( Sig ), #0 );
F := TFileStream.Create( sArchivo, fmOpenRead );
try
iLongitudLinea := F.Read( Sig[0], SizeOf( Sig ) );
for x := Low( Sig ) to High( Sig ) do
if Sig[x] <> ValidSig[x] then
iLongitudLinea := 0;
if iLongitudLinea > 0 then
begin
iLongitudLinea := F.Read( Seg, 1 );
while ( Seg = $FF ) and ( iLongitudLinea > 0 ) do
begin
iLongitudLinea := F.Read( Seg, 1 );
if Seg <> $FF then
begin
if ( Seg = $C0 ) or ( Seg = $C1 ) then
begin
iLongitudLinea := F.Read( Dummy[0], 3 );
wAlto := LeerPalabraMotorola( F );
wAncho := LeerPalabraMotorola( F );
end
else
begin
if not ( Seg in Parameterless ) then
begin
Len := LeerPalabraMotorola( F );
F.Seek( Len - 2, 1 );
F.read( Seg, 1 );
end
else
Seg := $FF;
end;
end;
end;
end;
finally
F.Free;
end;
end;

procedure DimensionPNG( sArchivo: string; var wAncho, wAlto: Word );
type
TPNGSig = array[0..7] of Byte;
const
ValidSig: TPNGSig = (137,80,78,71,13,10,26,10);
var
Sig: TPNGSig;
F: TFileStream;
x: Integer;
begin
FillChar( Sig, SizeOf( Sig ), #0 );
F := TFileStream.Create( sArchivo, fmOpenRead );
try
F.read( Sig[0], SizeOf( Sig ) );
for x := Low( Sig ) to High( Sig ) do
if Sig[x] <> ValidSig[x] then
Exit;
F.Seek( 18, 0 );
wAncho := LeerPalabraMotorola( F );
F.Seek( 22, 0 );
wAlto := LeerPalabraMotorola( F );
finally
F.Free;
end;
end;

function LeerPalabraMotorola( F: TFileStream ): Word;
type
TPalabraMotorola = record
case Byte of
0: ( Value: Word );
1: ( Byte1, Byte2: Byte );
end;
var
MW: TPalabraMotorola;
begin
F.Read( MW.Byte2, SizeOf( Byte ) );
F.Read( MW.Byte1, SizeOf( Byte ) );
Result := MW.Value;
end;

function GetToken(Cadena:string; Separador:char; Token:integer):string;
var
Posicion:integer;
begin
while Token > 1 do begin
Delete(Cadena,1,Pos(Separador,Cadena));
Dec(Token);
end;
Posicion:=Pos(Separador,Cadena);
if Posicion=0
then result:=cadena
else Result:=Copy(Cadena,1,Posicion-Length(Separador));
end;


function tiempo(value:integer):string;
var
minutos,segundos:string;
nminutos,nsegundos:integer;
begin
nminutos:=value div 60;
if nminutos<10 then
minutos:='0'+inttostr(nminutos)
else
minutos:=inttostr(nminutos);
nsegundos:=value mod 60;
if nsegundos <10 then
segundos:='0'+inttostr(nsegundos)
else
segundos:=inttostr(nsegundos);
result:=minutos+':'+segundos;
end;


end.
(42-42/57)