Nes

 view release on metacpan or  search on metacpan

lib/Nes.pm  view on Meta::CPAN

    return @cookies;
  }

  sub get {
    my $self  = shift;
    my ( $name, $pass ) = @_;
    
    return if !$self->{'c_get'}{$name};
    $pass = '' if !$pass;

    my $key = $self->{'CFG'}{'private_key'} . $pass;
    require Crypt::CBC;
    my $cipher = Crypt::CBC->new(
      -key    => $key,
      -cipher => 'Blowfish'
    );
    my $text = '';
    eval { $text = $cipher->decrypt_hex( $self->{'c_get'}{$name} ); };

    return $text;
  }

  sub create {
    my $self  = shift;
    my ( $name, $value, $expiration, $path, $domain, $pass ) = @_;
    $pass = '' if !$pass;

    my $expires = &utl::expires($expiration);
    my $key     = $self->{'CFG'}{'private_key'} . $pass;

    require Crypt::CBC;
    my $cipher = Crypt::CBC->new(
      -key    => $key,
      -cipher => 'Blowfish'
    );

    $value = $cipher->encrypt_hex($value);
    $path = '/' if !$path;

lib/Nes.pm  view on Meta::CPAN

    $self->{'user'}           = '';
    $self->get;
    
    return $self;
  }

  sub get {
    my $self  = shift;
    my ($pass) = @_ || '';

    my $key = $self->{'CFG'}{'private_key'} . $pass;
    $self->{'sess'} = $self->SUPER::get( $self->{'session_prefix'}, $key );
    return if !$self->{'sess'};

    my ( $session_name, $expire, $user, $refuse ) = split( /::/, $self->{'sess'} );

    return if time > $expire;
    return if $session_name ne $self->{'session_prefix'};
    
    $self->{'session_ok'} = 1;
    $self->{'user'} = $user;   
    
    return $user;
  }

  sub create {
    my $self  = shift;
    my ( $user, $expiration, $pass ) = @_;
    $pass = '' if !$pass;

    my $key = $self->{'CFG'}{'private_key'} . $pass;
    my $expire  = time +  utl::expires_time( $expiration );
    my $refuse  = $self->get_key( 10 + int rand 10 );
    my $value   = $self->{'session_prefix'} . '::' . $expire . '::' . $user . '::' . $refuse;
    my $path    = '/';

    $self->{'cookies'}->create( $self->{'session_prefix'}, $value, $expiration, $path,'',$key );

    return;
  }
  

lib/Nes/Obj/multi_step.pod  view on Meta::CPAN

Text to show if error data.

=item msg_ok_data

Text to show if success data.

=item referer

Check referer.

=item private_key

Private key to crypt data.

=item show_captcha

1 show captcha, 0 not

=item table_width

Width table form.

lib/Nes/Setting.pm  view on Meta::CPAN

      nes_dir        => $nes_dir,              # default: /cgi-bin/nes
      plugin_dir     => $nes_dir . '/plugin',
      obj_dir        => $nes_dir . '/obj',
      plugin_top_dir => $nes_top_dir . '/plugin',
      obj_top_dir    => $nes_top_dir . '/obj',     
      obj_form       => $nes_top_dir . '/obj/Nes/form',
      img_dir        => $nes_dir . '/images',
      time_zone      => 'Europe/Madrid',       # * sin implementar *
      locale         => '',                    # es_ES.utf8
      session_prefix => 'NESSESSION',
      private_key    => 'ChangeIt',            # Change private key 
      DB_base        => '',                    # Change in you .nes.cfg             
      DB_user        => '',                    # Change in you .nes.cfg 
      DB_pass        => '',                    # Change in you .nes.cfg 
      DB_driver      => 'mysql',               # Change in you .nes.cfg 
      DB_host        => 'localhost',           # Change in you .nes.cfg 
      DB_port        => '3306',                # Change in you .nes.cfg 
      php_cline      => '/usr/bin/php',
      php_cgi_cline  => '/usr/bin/php-cgi',
      perl_cline     => '/usr/bin/perl',
      python_cline   => '/usr/bin/python',

lib/Nes/Setting.pm  view on Meta::CPAN

    $instance = $self;
    
    while (1) {
      my $file = $level . '/' . $file_name;
       
      $self->load_cfg($file);
      $level =~ s/[\/\\][^\/\\]*$//;
      last if $level !~ /$self->{'top_dir'}/;
    }

    warn "Change the private_key in $file_name" if $self->{'private_key'} =~ /ChangeIt/i;

    return $self;
  }

  sub load_cfg {
    my $class      = shift;
    my $self       = Nes::Setting::get_obj();
    my ($file) = @_;
    
    if ( -e $file ) {

lib/Nes/Singleton.pod  view on Meta::CPAN


If you call to out method in myscript1, the tags of myscript2 never be replaced. 
If you not call to out method in last script, the Tags never be replaced.

The routine use of the add method is in creating plugin.

=head1 .nes.cfg

You .nes.cfg contains:

    private_key   = pass3
    myscript_var1 = 50

Then you can access:

    use Nes;
    my $nes    = Nes::Singleton->new('template.nhtml');
    my $config = $nes->{'CFG'};

    my $var  = $config->{'myscript_var1'};
    my $pkey = $config->{'private_key'};

    # Global configuration
    my $pdir = $config->{'plugin_top_dir'};

=head1 Session

    my $nes     = Nes::Singleton->new();
    my $session = $nes->{'session'};

    # Create session:

lib/Nes/Tutorial.es.pod  view on Meta::CPAN


    set_nes_site --dir_cfg=/var/www/nes_tutorial

Con esto hemos creado un archivo .htaccess con la configuración
para que las plantillas Nes se pueden ejecutar en este directorio.

El archivo .nes.cfg sirve para configurar Nes y también para tu propio
script o aplicación Perl. Hay un valor que necesita ser cambiado,
de lo contrario Nes lanzará una advertencia:

    private_key

Es una contraseña utilizada para cifrar los datos tales como cookies, 
así que es muy importante dar un valor a private_key.

Cera un arcivo en /var/www/nes_tutorial con el nombre .nes.cfg, con
el siguiente contenido.

/var/www/nes_tutorial/.nes.cfg:

    private_key      = ChangeIt
    nes_tutorial_var = test variable

Cambia 'ChangeIt' por la contraseña que tu quieras. Y con esto 
nes_tutorial está preparado para funcionar.

=head1 Crear la primera plantilla Nes

Las plantillas Nes tienen la extensión .nhtml, cualquier archivo con esta 
extensión en el directorio nes_tutorial, será tratada como una plantilla de Nes.

lib/Nes/Tutorial.pod  view on Meta::CPAN


    set_nes_site --dir_cfg=/var/www/nes_tutorial

With this we have created a file .htaccess with the configuration
because Nes templates can execute in this directory.

The .nes.cfg file serve to configure Nes and also for your own
Perl script or application. There is a value that needs to be changed,
otherwise Nes release a warning:

    private_key

It is a password used to encrypt data such as cookies, so it is very 
important to give a value to private_key.

Create a file in /var/www/nes_tutorial with the name .nes.cfg, with the
following content.

/var/www/nes_tutorial/.nes.cfg:

    private_key      = ChangeIt
    nes_tutorial_var = test variable

Change 'changeit' with the password you want. And with this 
nes_tutorial is ready to work.

=head1 Create first Nes Template

Nes templates have the extension .nhtml, any file with this extension, 
in nes_tutorial directory, will be treated as a Nes template.

lib/Nes/nes.cfg.pod  view on Meta::CPAN


    {: * cfg_myscript_var1 :}
    {: * cfg_obj_top_dir :}

=head1 DESCRIPTION

The .nes.cfg is placed in the directory where you installed your 
nhtml templates, it overwrites Setting and the plugins configuration.
Level rises, until the root directory of the Web, to read .nes.cfg files.  

private_key value that is used to encrypt data, if not changed the script
to launch a warning each time you run Nes.

=head1 Variables

    tmp_dir        # Temporary directory.
    tmp_suffix     # Suffix of the temporary files. 
    tmp_clear      # Delete temporary files or 0 and does not delete
                   # time suffix: s: seconds,
                   # m: minutes h: hours d: days, M: months, y: years
                   # 24h is 24 hours. 
    top_dir        # Root directory of your site.
    nes_dir        # Directory of Nes.
    nes_top_dir    # Absolute path to the Nes directory.
    plugin_dir     # Directory of the Plugin, top_dir relative.
    obj_dir        # Directory of the Object, top_dir relative.
    plugin_top_dir # Absolute path to the Plugin directory.
    obj_top_dir    # Absolute path to the Object directory.
    time_zone      # *** unimplemented ***
    locale         # locale, ej.: es_ES.utf8
    session_prefix # Name cookie used for user session.
    private_key    # Private key used to encrypt data.
    DB_base        # Database name.
    DB_user        # Database user.
    DB_pass        # Database password.
    DB_driver      # Database driver, default 'mysql' 
    DB_host        # Database host, default 'localhost'
    DB_port        # Database port, default '3306' 
    php_cline      # Command line for PHP CLI
    php_cgi_cline  # Command line for PHP CGI
    perl_cline     # Command line for Perl
    shell_cline    # Command line for Shell

lib/Nes/nes.cfg.pod  view on Meta::CPAN

    # all files included in all nhtml directory.
    auto_load_plugin_all_last

=head1 Use in your script

You can use .nes.cfg to add configuration variables to your script. We 
recommend using a notation that clearly distinguishes Nes variables, 
for example using prefixes the name of your application, 
.nes.cfg content:
    
    private_key   = pass
    myscript_var1 = 50

You can access these variables from the nhtml template as:

    {: * cfg_myscript_var1 :}

And from Perl:

    use Nes;
    my $nes    = Nes::Singleton->new();

share/cgi-bin/obj/Nes/form/multi_step.pl  view on Meta::CPAN


my $vars       = multi_step->new;
my $nes        = Nes::Singleton->new();
my $cfg        = $nes->{'CFG'};
my $nes_env    = $nes->{'top_container'}->{'nes_env'};
my $remote     = $nes->{'query'}->{'q'}{'_'.$vars->{'form_name'}.'_ip'};   
my $send       = $nes->{'query'}->{'q'}{'_'.$vars->{'form_name'}.'_send'};
my $q_step     = $nes->{'query'}->{'q'}{'_'.$vars->{'form_name'}.'_step'} || 1;
my $q_err      = $nes->{'query'}->{'q'}{'_'.$vars->{'form_name'}.'_err'};
my $q_autho    = $nes->{'query'}->{'q'}{'_'.$vars->{'form_name'}.'_autho'};
my $key        = $vars->{'private_key'} || $nes->{'CFG'}{'private_key'};
my %data;
my $vars_error;
my $return_fields_error;
$vars->{'latest'}       = $#{$vars->{'steps'}}+1+$vars->{'show_captcha'};
$vars->{'show_captcha'} = 0 if $q_autho;
$vars->{'autho'}        = $q_autho;

my $error_referer   = $vars->{'referer'} && $ENV{'HTTP_REFERER'} !~ /$vars->{'referer'}/;
my $captcha_ok      = check_captcha();
   $captcha_ok      = 1 if !$vars->{'show_captcha'};

share/cgi-bin/obj/Nes/form/multi_step.pl  view on Meta::CPAN

      $nes->{'container'}->{'content_obj'}->location( $vars->{'out_page'}, "302 Found" ) if $vars->{'out_page'};
     
    }    
    
  } else {
    go_next_step();
  }
  
}

$vars->{'private_key'} = ''; # For safety, do not show
$nes->add(%$vars);
# end.

sub send_data {
  
  $vars->{'error_handler'} = 0;
  require "$vars->{'script_handler'}";
  my $handler = \&{$vars->{'function_handler'}};
  $return_fields_error = $handler->(\%data);
  if ( ref $return_fields_error ne 'HASH' && $return_fields_error ) { 

share/cgi-bin/obj/Nes/form/multi_step.pm  view on Meta::CPAN

    
    $self->{'to_database'}       = 'INSERT';
    $self->{'to_where'}          = undef;
    $self->{'to_limit'}          = '0'; # for safety, requires explicit mention
    $self->{'to_table'}          = undef;
    $self->{'to_fields_assort'}  = undef;
    
    $self->{'msg_error_data'}    = '';
    $self->{'msg_ok_data'}       = 'Ok data.';
    $self->{'referer'}           = '';
    $self->{'private_key'}       = '';
    $self->{'show_captcha'}      = 1;
    $self->{'table_width'}       = '95%';
    $self->{'submit_begin'}      = '<center>';
    $self->{'submit_end'}        = '</center>';
    $self->{'span_error'}        = '&nbsp;';
    $self->{'form_expire'}       = $expire.'s';
    $self->{'form_name'}         = 'multi_sf';
    $self->{'captcha_name'}      = 'multi_sc';
    $self->{'captcha_end'}       = '<br><br>';
    $self->{'captcha_begin'}     = '';

share/examples/hello_nes/.nes.cfg  view on Meta::CPAN

# config file
private_key = ChangeIt

# debug only for your eyes, put your IP
debug_info_only_from_ip = 
debug_info_save_to_log  = 
debug_info_show_in_out  = 1
debug_info_template     = {: * nes_this_dir :}/debug_info.txt 

share/examples/nesblog/.nes.cfg  view on Meta::CPAN

# Nes config file 

# uncomment and change ChangeIt
#private_key = ChangeIt

# nesblog config
miniblog_item_dir = ./items

# database configuration
#DB_base    = ChangeIt
#DB_user    = ChangeIt
#DB_pass    = ChangeIt
#DB_driver  = mysql
#DB_host    = localhost

share/examples/nesblog/en/items/Help.nhtml  view on Meta::CPAN

      order deny,allow
      deny from all
    &lt;/FilesMatch&gt;</pre>
<p>
</p>
<hr />
<h2><a name="_nes_cfg_configuration_files">.nes.cfg configuration files</a></h2>
<p>The .nes.cfg is placed in the directory where you installed your 
nhtml templates, it overwrites Setting and the plugins configuration.
Level rises, until the root directory of the Web, to read .nes.cfg files.</p>
<p>private_key value that is used to encrypt data, if not changed the script
to launch a warning each time you run Nes.</p>

<p>
</p>
<h2><a name="_nes_cfg_variables">.nes.cfg variables</a></h2>
<pre>
    tmp_dir        # Temporary directory.
    tmp_suffix     # Suffix of the temporary files. 
    tmp_clear      # If delete the temporary files or 0 and does not delete
                   # time suffix: s: seconds,

share/examples/nesblog/en/items/Help.nhtml  view on Meta::CPAN

    top_dir        # Root directory of your site.
    nes_dir        # Directory of Nes.
    nes_top_dir    # Absolute path to the Nes directory.
    plugin_dir     # Directory of the Plugin, top_dir relative.
    obj_dir        # Directory of the Object, top_dir relative.
    plugin_top_dir # Absolute path to the Plugin directory.
    obj_top_dir    # Absolute path to the Object directory.
    time_zone      # *** unimplemented ***
    locale         # locale, ej.: es_ES.utf8
    session_prefix # Name cookie used for user session.
    private_key    # Private key used to encrypt data.
    DB_base        # Database name.
    DB_user        # Database user.
    DB_pass        # Database password.
    DB_driver      # Database driver, default 'mysql' 
    DB_host        # Database host, default 'localhost'
    DB_port        # Database port, default '3306' 
    php_cline      # Command line for PHP CLI
    php_cgi_cline  # Command line for PHP CGI
    perl_cline     # Command line for Perl
    shell_cline    # Command line for Shell

share/examples/nesblog/en/items/Help.nhtml  view on Meta::CPAN

    # all files included in all nhtml directory, eg.:
    auto_load_plugin_all_last</pre>
<p>
</p>
<h2><a name="use_in_your_script">Use in your script</a></h2>
<p>You can use .nes.cfg to add configuration variables to your script. We 
recommend using a notation that clearly distinguishes Nes variables, 
for example using prefixes the name of your application:</p>
<pre>
    .nes.cfg
        private_key = pass3
        myscript_var1 = 50
        myscript_var2 = 60  
        myscript_var3 = 70</pre>

<p>You can access these variables from the nhtml template as:</p>
<pre>
 &#123;: * cfg_myscript_var1 :&#125;</pre>
<p>And from Perl:</p>
<pre>
    use Nes;

share/examples/nesblog/en/items/Nes configuration file.nhtml  view on Meta::CPAN

<h2><a href="#">Configuration file</a></h2>
<h3>Setting.pm</h3>
<p>
This file is loaded configuration Nes. It is recommended not to change 
their values and do it in the file .nes.cfg. private_key value that 
is used to encrypt data, if not changed the script to launch a warning 
each time you run Nes.
</p>
<h3>Variables</h3>
<p>
<pre>
tmp_dir        # Temporary directory.
tmp_suffix     # Suffix of the temporary files. 
tmp_clear      # If delete the temporary files or 0 and does not delete
               # time suffix: s: seconds,

share/examples/nesblog/en/items/Nes configuration file.nhtml  view on Meta::CPAN

top_dir        # Root directory of your site.
nes_dir        # Directory of Nes.
nes_top_dir    # Absolute path to the Nes directory.
plugin_dir     # Directory of the Plugin, top_dir relative.
obj_dir        # Directory of the Object, top_dir relative.
plugin_top_dir # Absolute path to the Plugin directory.
obj_top_dir    # Absolute path to the Object directory.
time_zone      # *** unimplemented ***
locale         # locale, ej.: es_ES.utf8
session_prefix # Name cookie used for user session.
private_key    # Private key used to encrypt data.
DB_base        # Database name.
DB_user        # Database user.
DB_pass        # Database password.
DB_driver      # Database driver, default 'mysql' 
DB_host        # Database host, default 'localhost'
DB_port        # Database port, default '3306' 
php_cline      # Command line for PHP CLI
php_cgi_cline  # Command line for PHP CGI
perl_cline     # Command line for Perl
shell_cline    # Command line for Shell

share/examples/nesblog/en/items/Nes configuration file.nhtml  view on Meta::CPAN

<h3>.nes.cfg</h3>
<p>
The .nes.cfg is placed in the directory where you installed your 
nhtml templates, it overwrites Setting and the plugins configuration.
Level rises, until the root directory of the Web, to read .nes.cfg files.   
</p>

<h3>Example</h3>
<pre>    
/html/nhtml/.nes.cfg
    private_key = pass1
    mi_var1     = 10
    mi_var2     = 20
    
/html/.nes.cfg
    private_key = pass2
    mi_var2     = 30 
    mi_var3     = 40   
    
/.nes.cfg
    private_key = pass3
    mi_var1     = 50
    mi_var2     = 60  
    mi_var3     = 70
    
The value of the variables for the executable files in:     

/html/nhtml/file.nhtml
    private_key = pass1  # prevailing values of this level
    mi_var1     = 10     # prevailing values of this level
    mi_var2     = 20     # prevailing values of this level
    mi_var3     = 40     # defined in /html/.nes.cfg
                         # ignored mi_var3 of /.nes.cfg 
    
/html/file.nhtml
    private_key = pass2  # prevailing values of this level
    mi_var1     = 50     # defined in /.nes.cfg
    mi_var2     = 30     # prevailing values of this level
    mi_var3     = 40     # prevailing values of this level
    
/file.nhtml
    private_key = pass3  # prevailing values of this level
    mi_var1     = 50     # prevailing values of this level
    mi_var2     = 60     # prevailing values of this level
    mi_var3     = 70     # prevailing values of this level
     
</pre> 
<p>
<h3>Use in your script</h3>
You can use .nes.cfg to add configuration variables to your script. We 
recommend using a notation that clearly distinguishes Nes variables, 
for example using prefixes the name of your application:
<pre>    
.nes.cfg
    private_key = pass3
    myscript_var1 = 50
    myscript_var2 = 60  
    myscript_var3 = 70

</pre> 
You can access these variables from the nhtml template as:
<pre>    
 &#123;: * cfg_myscript_var1 :&#125;

</pre> 

share/examples/nesblog/en/items/Singleton.nhtml  view on Meta::CPAN

</pre>
<p>If you call to out method in myscript1, the tags of myscript2 never be replaced. 
If you not call to out method in last script, the Tags never be replaced.</p>
<p>The routine use of the add method is in creating plugin.</p>
<p>
</p>
<hr />
<h2><a name="_nes_cfg">.nes.cfg</a></h2>
<p>You .nes.cfg contains:</p>
<pre>
    private_key   = pass3
    myscript_var1 = 50
    
</pre>
<p>Then you can access:</p>
<pre>
    use Nes;
    my $nes    = Nes::Singleton-&gt;new('template.nhtml');
    my $config = $nes-&gt;{'CFG'};

    my $var  = $nes-&gt;{'myscript_var1'};
    my $pkey = $nes-&gt;{'private_key'};

    # Global configuration
    my $pdir = $nes-&gt;{'plugin_top_dir'};
    
</pre>
<hr />
<h2><a name="session">Session</a></h2>
<pre>
    my $nes     = Nes::Singleton-&gt;new();
    my $session = $nes-&gt;{'session'};

share/examples/nesblog/en/items/Tutorial.nhtml  view on Meta::CPAN

    set_nes_site</pre>
<p>Configured:</p>
<pre id="comment">
    set_nes_site --dir_cfg=/var/www/nes_tutorial</pre>
<p>With this we have created a file .htaccess with the configuration
because Nes templates can execute in this directory.</p>
<p>The .nes.cfg file serve to configure Nes and also for your own
Perl script or application. There is a value that needs to be changed,
otherwise Nes release a warning:</p>
<pre id="comment">
    private_key</pre>
<p>It is a password used to encrypt data such as cookies, so it is very 
important to give a value to private_key.</p>
<p>Create a file in /var/www/nes_tutorial with the name .nes.cfg, with the
following content.</p>
<p>/var/www/nes_tutorial/.nes.cfg:</p>
<pre id="comment">
    private_key      = ChangeIt
    nes_tutorial_var = test variable</pre>
<p>Change 'changeit' with the password you want. And with this 
nes_tutorial is ready to work.</p>
<p>
</p>

<hr />
<br><h3><a name="create_first_nes_template">Create first Nes Template</a></h3>
<p>Nes templates have the extension .nhtml, any file with this extension, 
in nes_tutorial directory, will be treated as a Nes template.</p>

share/examples/tutorial/.nes.cfg  view on Meta::CPAN


private_key      = sdfg234tfgw34
nes_tutorial_var = test variable

# debug only for your eyes, put your IP
debug_info_only_from_ip = 
debug_info_save_to_log  = 
debug_info_show_in_out  = 1
debug_info_template     = {: * nes_this_dir :}/debug_info.txt 

# load debug_info.pl for all templates of this dir
auto_load_plugin_all_last = {: * cfg_plugin_top_dir :}/debug_info.pl

share/examples/tutorial/index.html  view on Meta::CPAN

    set_nes_site</pre>
<p>Configured:</p>
<pre>
    set_nes_site --dir_cfg=/var/www/nes_tutorial</pre>
<p>With this we have created a file .htaccess with the configuration
because Nes templates can execute in this directory.</p>
<p>The .nes.cfg file serve to configure Nes and also for your own
Perl script or application. There is a value that needs to be changed,
otherwise Nes release a warning:</p>
<pre>
    private_key</pre>
<p>It is a password used to encrypt data such as cookies, so it is very 
important to give a value to private_key.</p>
<p>Create a file in /var/www/nes_tutorial with the name .nes.cfg, with the
following content.</p>
<p>/var/www/nes_tutorial/.nes.cfg:</p>
<pre>
    private_key      = ChangeIt
    nes_tutorial_var = test variable</pre>
<p>Change 'changeit' with the password you want. And with this 
nes_tutorial is ready to work.</p>
<p>
</p>
<hr />
<h1><a name="create_first_nes_template">Create first Nes Template</a></h1>
<p>Nes templates have the extension .nhtml, any file with this extension, 
in nes_tutorial directory, will be treated as a Nes template.</p>
<p>Create a file named 'nes_01.nhtml' in 'nes_tutorial' with following 

t/.nes.cfg  view on Meta::CPAN

# config file
private_key = Change



( run in 0.374 second using v1.01-cache-2.11-cpan-a5abf4f5562 )