elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Perl Tk] Mysql Manager 0.6
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Perl Tk] Mysql Manager 0.6  (Leído 1,516 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Perl Tk] Mysql Manager 0.6
« en: 14 Abril 2012, 19:49 pm »

Nueva version Tk de un Mysql manager que hice hace tiempo.

Código
  1. #!usr/bin/perl
  2. #Mysql Manager 0.6
  3. #Version Tk
  4. #Coded By Doddy H
  5. #Modules
  6. #ppm install http://www.bribes.org/perl/ppm/Scalar-List-Utils.ppd
  7. #ppm install http://www.bribes.org/perl/ppm/Storable.ppd
  8. #ppm install http://www.bribes.org/perl/ppm/DBI.ppd
  9. #ppm install http://theoryx5.uwinnipeg.ca/ppms/DBD-mysql.ppd
  10.  
  11. use Tk;
  12. use Tk::ROText;
  13. use Tk::PNG;
  14. use DBI;
  15.  
  16. if ( $^O eq 'MSWin32' ) {
  17.    use Win32::Console;
  18.    Win32::Console::Free();
  19. }
  20.  
  21. my $color_fondo = "black";
  22. my $color_texto = "orange";
  23.  
  24. my $nave =
  25.  MainWindow->new( -background => $color_fondo, -foreground => $color_texto );
  26.  
  27. $nave->title("Mysql Manager 0.6 || Coded By Doddy H");
  28. $nave->geometry("210x160+20+20");
  29. $nave->resizable( 0, 0 );
  30.  
  31. $nave->Label(
  32.    -text       => "Host : ",
  33.    -font       => "Impact1",
  34.    -background => $color_fondo,
  35.    -foreground => $color_texto
  36. )->place( -x => 10, -y => 10 );
  37. my $host = $nave->Entry(
  38.    -width      => 22,
  39.    -text       => "localhost",
  40.    -background => $color_fondo,
  41.    -foreground => $color_texto
  42. )->place( -x => 60, -y => 13 );
  43.  
  44. $nave->Label(
  45.    -text       => "User : ",
  46.    -font       => "Impact1",
  47.    -background => $color_fondo,
  48.    -foreground => $color_texto
  49. )->place( -x => 10, -y => 40 );
  50. my $user = $nave->Entry(
  51.    -width      => 22,
  52.    -text       => "root",
  53.    -background => $color_fondo,
  54.    -foreground => $color_texto
  55. )->place( -x => 60, -y => 43 );
  56.  
  57. $nave->Label(
  58.    -text       => "Pass : ",
  59.    -font       => "Impact1",
  60.    -background => $color_fondo,
  61.    -foreground => $color_texto
  62. )->place( -x => 10, -y => 70 );
  63. my $pass = $nave->Entry(
  64.    -width      => 22,
  65.    -background => $color_fondo,
  66.    -foreground => $color_texto
  67. )->place( -x => 60, -y => 73 );
  68.  
  69. $nave->Button(
  70.    -text             => "Connect",
  71.    -width            => 13,
  72.    -command          => \&now,
  73.    -background       => $color_fondo,
  74.    -foreground       => $color_texto,
  75.    -activebackground => "orange"
  76. )->place( -x => 60, -y => 120 );
  77.  
  78. MainLoop;
  79.  
  80. sub now {
  81.  
  82.    my $host = $host->get;
  83.    my $user = $user->get;
  84.    my $pass = $pass->get;
  85.  
  86.    $info = "dbi:mysql::" . $host . ":3306";
  87.  
  88.    if ( my $enter = DBI->connect( $info, $user, $pass, { PrintError => 0 } ) )
  89.    {
  90.  
  91.        $nave->destroy;
  92.  
  93.        my $man = MainWindow->new(
  94.            -background => $color_fondo,
  95.            -foreground => $color_texto
  96.        );
  97.        $man->title("Mysql Manager 0.6 || Coded By Doddy H");
  98.        $man->geometry("650x320+20+20");
  99.        $man->resizable( 0, 0 );
  100.  
  101.        $man->Label(
  102.            -text       => "Query : ",
  103.            -font       => "Impact1",
  104.            -background => $color_fondo,
  105.            -foreground => $color_texto
  106.        )->place( -x => 73, -y => 20 );
  107.        my $ac = $man->Entry(
  108.            -width      => 60,
  109.            -background => $color_fondo,
  110.            -foreground => $color_texto
  111.        )->place( -x => 135, -y => 23 );
  112.        $man->Button(
  113.            -width            => 8,
  114.            -text             => "Execute",
  115.            -command          => \&tes,
  116.            -background       => $color_fondo,
  117.            -foreground       => $color_texto,
  118.            -activebackground => "orange"
  119.        )->place( -x => 510, -y => 23 );
  120.        my $out = $man->Scrolled(
  121.            "ROText",
  122.            -width      => 74,
  123.            -height     => 15,
  124.            -background => $color_fondo,
  125.            -foreground => $color_texto
  126.        )->place( -x => 60, -y => 73 );
  127.  
  128.        $man->bind( "<Key-Return>" => sub { &tes } );
  129.  
  130.        sub tes {
  131.            my $ac = $ac->get;
  132.            $re = $enter->prepare($ac);
  133.            $re->execute();
  134.            my $total = $re->rows();
  135.  
  136.            my @columnas = @{ $re->{NAME} };
  137.  
  138.            if ( $total eq "-1" ) {
  139.                $out->insert( "end", "\n[-] Query Error\n" );
  140.                next;
  141.            }
  142.            else {
  143.                $out->insert( "end", "\n[+] Result of the query\n" );
  144.                if ( $total eq 0 ) {
  145.                    $out->insert( "end", "\n[+] Not rows returned\n\n" );
  146.                }
  147.                else {
  148.                    $out->insert( "end",
  149.                        "\n[+] Rows returned : " . $total . "\n\n" );
  150.                    for (@columnas) {
  151.                        $out->insert( "end", $_ . "\t" );
  152.                    }
  153.                    $out->insert( "end", "\n\n" );
  154.                    while ( @row = $re->fetchrow_array ) {
  155.                        for (@row) {
  156.                            $out->insert( "end", $_ . "\t" );
  157.                        }
  158.                        $out->insert( "end", "\n" );
  159.                    }
  160.                }
  161.            }
  162.        }
  163.    }
  164.    else {
  165.        $man->Dialog(
  166.            -title            => "Error",
  167.            -buttons          => ["OK"],
  168.            -text             => "Error",
  169.            -background       => $color_fondo,
  170.            -foreground       => $color_texto,
  171.            -activebackground => $color_texto
  172.        )->Show();
  173.    }
  174. }
  175.  
  176. # ¿ The End ?
  177.  
  178.  


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Perl] Mysql Manager
Scripting
BigBear 0 1,592 Último mensaje 7 Octubre 2011, 01:14 am
por BigBear
[Perl] Manager
Scripting
BigBear 0 1,525 Último mensaje 9 Octubre 2011, 17:50 pm
por BigBear
[Perl] FTP Manager
Scripting
BigBear 0 1,546 Último mensaje 14 Octubre 2011, 15:25 pm
por BigBear
[Perl] USB Manager 0.2
Scripting
BigBear 0 1,544 Último mensaje 3 Diciembre 2011, 16:34 pm
por BigBear
[Perl] Mysql Manager 0.5
Scripting
BigBear 0 1,423 Último mensaje 14 Abril 2012, 19:49 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines