concat inferno
This commit is contained in:
77
lib/Dojo.pm
77
lib/Dojo.pm
@@ -6,42 +6,55 @@ use Dojo::Model::Users;
|
||||
use Dojo::Model::Data;
|
||||
|
||||
# This method will run once at server start
|
||||
sub startup {
|
||||
my $self = shift;
|
||||
my $config = $self->plugin('Config'); #Config hash dojo.conf
|
||||
$self->plugin('PODRenderer') if $config->{perldoc}; #doc
|
||||
$self->secrets(['Mojojojo jojo']); #cookies
|
||||
sub startup {
|
||||
my $self = shift;
|
||||
my $config = $self->plugin('Config'); #Config hash dojo.conf
|
||||
$self->plugin('PODRenderer') if $config->{perldoc}; #doc
|
||||
$self->secrets(['Mojojojo jojo']); #cookies
|
||||
|
||||
$self->helper(dbv => sub { state $dbv = Dojo::Model::Vuelo->new });
|
||||
$self->helper(dbg => sub { state $dbg = Dojo::Model::Users->new });
|
||||
$self->helper(ddtt => sub { state $ddtt = Dojo::Model::Data->new });
|
||||
$self->defaults({%Dojo::Conf::def});
|
||||
$self->helper(dbv => sub { state $dbv = Dojo::Model::Vuelo->new });
|
||||
$self->helper(dbg => sub { state $dbg = Dojo::Model::Users->new });
|
||||
$self->helper(ddtt => sub { state $ddtt = Dojo::Model::Data->new });
|
||||
$self->defaults({%Dojo::Conf::def});
|
||||
my $r = $self->routes; #router
|
||||
|
||||
# user ========================================================================
|
||||
$r->any('/home')->to('home#home');
|
||||
$r->any('/cal')->to('home#cal');
|
||||
$r->any('/event/:id'=> [id => qr/\d+/])->to('home#event');
|
||||
$r->any('/pod')->to('home#podcast');
|
||||
$r->any('/store')->to('home#store');
|
||||
$r->any('/tv')->to('home#tv');
|
||||
$r->any('/contact')->to('home#contact');
|
||||
$r->any('/contact2')->to('home#contact2');
|
||||
$r->any('/pang')->to('home#pang');
|
||||
$r->any('/tst')->to('home#tst');
|
||||
# =============================================================================
|
||||
|
||||
# json ========================================================================
|
||||
$r->any('/json/:dreq')->to('data#simple');
|
||||
# =============================================================================
|
||||
|
||||
# candy =======================================================================
|
||||
$r->any('/json/candy/:command')->to('data#candy');
|
||||
# =============================================================================
|
||||
|
||||
my $r = $self->routes; #router
|
||||
# admin =======================================================================
|
||||
$r->any('/admin/home')->to('home#admin_home');
|
||||
$r->any('/admin/radio')->to('home#admin_radio');
|
||||
$r->any('/admin/eventos')->to('home#admin_eventos');
|
||||
$r->any('/admin/eventos/:type'=> [type=>['e','p','c']])->to('home#admin_eventos');
|
||||
$r->any('/admin/mensajes')->to('home#admin_mensajes');
|
||||
$r->any('/admin/json/:dreq/:id')->to('home#admin_json');
|
||||
# =============================================================================
|
||||
|
||||
$r->any('/home')->to('home#home');
|
||||
$r->any('/cal')->to('home#cal');
|
||||
$r->any('/event/:id'=> [id => qr/\d+/])->to('home#event');
|
||||
#$r->any('/radio')->to('home#radio');
|
||||
$r->any('/pod')->to('home#podcast');
|
||||
$r->any('/store')->to('home#store');
|
||||
$r->any('/tv')->to('home#tv');
|
||||
$r->any('/contact')->to('home#contact');
|
||||
$r->any('/contact2')->to('home#contact2');
|
||||
$r->any('/pang')->to('home#pang');
|
||||
$r->any('/tst')->to('home#tst');
|
||||
|
||||
$r->any('/json/:dreq')->to('data#simple');
|
||||
$r->any('/json/candy/:command')->to('data#candy');
|
||||
|
||||
$r->any('/admin/:section'=> {section =>'home'})->to('home#admin');
|
||||
$r->any('/admin/json/:dreq/:id/')->to('data#admin');
|
||||
# login =======================================================================
|
||||
$r->any('/login')->to('users#login');
|
||||
$r->any('/logout')->to('users#logout');
|
||||
|
||||
$r->any('/login')->to('users#login');
|
||||
$r->any('/logout')->to('users#logout');
|
||||
|
||||
my $logged_in = $r->under('/')->to('users#is_logged');
|
||||
$logged_in->get('/radio')->to('home#radio');
|
||||
my $logged_in = $r->under('/')->to('users#is_logged');
|
||||
$logged_in->get('/radio')->to('home#radio');
|
||||
# =============================================================================
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,146 +16,202 @@ sub tst{
|
||||
my $x = [get_names("public/home/cal/img/")];
|
||||
log("@$x");
|
||||
$c->stash( ilist => $x);
|
||||
$c->dbv->tst;
|
||||
|
||||
}
|
||||
|
||||
sub home {
|
||||
my $c = shift;
|
||||
$c->stash((load_module("home/home"))[0]);
|
||||
$c->stash( map{ $_->{nombre} => $_->{contenido}} @{$c->dbv->mod});
|
||||
}
|
||||
|
||||
sub pang {
|
||||
my $c = shift;
|
||||
my ($v,$w)=load_module("home/pang");
|
||||
$c->stash($v);
|
||||
$c->stash( $c->dbv->pang($w) );
|
||||
}
|
||||
|
||||
sub cal {
|
||||
my $c = shift;
|
||||
$c->stash((load_module("home/cal"))[0]);
|
||||
my ($data,$block)=$c->dbv->cal;
|
||||
my %hdata;
|
||||
map{ push @{ $hdata{$_->{bid}} },$_; }(@$data);
|
||||
$c->stash( r=>\%hdata, b=>$block);
|
||||
}
|
||||
|
||||
sub event{
|
||||
my $c = shift;
|
||||
$c->stash((load_module("home/event"))[0]);
|
||||
$c->stash(%{($c->dbv->event($c->param("id")))->[0]});
|
||||
$c->stash(layout=> "defaultContact");
|
||||
}
|
||||
|
||||
sub contact{
|
||||
my $c = shift;
|
||||
if ($c->param("mup")){
|
||||
$c->flash(mname => $c->param("mname"));
|
||||
$c->redirect_to('contact2');
|
||||
}else{
|
||||
$c->stash((load_module("home/contact"))[0]);
|
||||
# User ========================================================================
|
||||
sub home {
|
||||
my $c = shift;
|
||||
$c->stash((load_module("home/home"))[0]);
|
||||
$c->stash( $c->dbv->mod) ;
|
||||
}
|
||||
}
|
||||
|
||||
sub contact2{
|
||||
my $c = shift;
|
||||
$c->redirect_to("home") unless $c->flash('mname');
|
||||
$c->stash( mname=>$c->flash('mname'));
|
||||
$c->stash((load_module("home/contact2"))[0]);
|
||||
}
|
||||
sub pang {
|
||||
my $c = shift;
|
||||
my ($v,$w)=load_module("home/pang");
|
||||
$c->stash($v);
|
||||
$c->stash( $c->dbv->md_to_hash(@{$w->{'md'}}) );
|
||||
}
|
||||
|
||||
sub store{
|
||||
my $c = shift;
|
||||
$c->stash((load_module("home/store"))[0]);
|
||||
$c->stash( r=>$c->dbv->store);
|
||||
$c->stash(layout=> "defaultContact");
|
||||
}
|
||||
sub cal {
|
||||
my $c = shift;
|
||||
$c->stash((load_module("home/cal"))[0]);
|
||||
my $data=$c->dbv->calendar_events;
|
||||
my $block=$c->dbv->calendar_monthblock;
|
||||
my %hdata;
|
||||
map{ push @{ $hdata{$_->{bid}} },$_; }(@$data);
|
||||
$c->stash( r=>\%hdata, b=>$block);
|
||||
}
|
||||
|
||||
sub tv{
|
||||
my $c = shift;
|
||||
$c->stash( merge_hash(
|
||||
(load_module("home/tv"))[0],
|
||||
(load_module("home/tv/trans"))[0]
|
||||
));
|
||||
my ($series,$table)=$c->dbv->tv;
|
||||
$c->stash( series=>$series, table=>$table);
|
||||
$c->stash(layout=> "defaultContact");
|
||||
}
|
||||
sub event{
|
||||
my $c = shift;
|
||||
$c->stash((load_module("home/event"))[0]);
|
||||
$c->stash(layout=> "defaultContact");
|
||||
$c->stash($c->dbv->event($c->param("id")));
|
||||
}
|
||||
|
||||
sub contact{
|
||||
my $c = shift;
|
||||
if ($c->param("mup")){
|
||||
$c->flash(mname => $c->param("mname"));
|
||||
$c->redirect_to('contact2');
|
||||
}else{
|
||||
$c->stash((load_module("home/contact"))[0]);
|
||||
}
|
||||
}
|
||||
|
||||
sub contact2{
|
||||
my $c = shift;
|
||||
$c->redirect_to("home") unless $c->flash('mname');
|
||||
$c->stash( mname=>$c->flash('mname'));
|
||||
$c->stash((load_module("home/contact2"))[0]);
|
||||
}
|
||||
|
||||
sub store{
|
||||
my $c = shift;
|
||||
$c->stash((load_module("home/store"))[0]);
|
||||
$c->stash( r=>$c->dbv->store);
|
||||
$c->stash(layout=> "defaultContact");
|
||||
}
|
||||
|
||||
sub tv{
|
||||
my $c = shift;
|
||||
$c->stash( merge_hash(
|
||||
(load_module("home/tv"))[0],
|
||||
(load_module("home/tv/trans"))[0]
|
||||
));
|
||||
$c->stash( videos=>$c->dbv->tv_videos, table=>$c->dbv->tv_series);
|
||||
$c->stash(layout=> "defaultContact");
|
||||
}
|
||||
|
||||
sub podcast{
|
||||
my $c = shift;
|
||||
$c->stash((load_module("home/podcast"))[0]);
|
||||
$c->stash(layout=> "defaultContact");
|
||||
$c->stash( t=>$c->dbv->podcast_txt, pod=>$c->dbv->podcast_infoHash);
|
||||
}
|
||||
|
||||
sub radio{
|
||||
my $c=shift;
|
||||
$c->stash((load_module("home/radio"))[0]);
|
||||
$c->stash(layout=> "defaultContact");
|
||||
$c->stash($c->dbv->mod);
|
||||
$c->stash($c->dbv->conf_radio);
|
||||
$c->stash(nick=>$c->session("nick"));
|
||||
}
|
||||
#==============================================================================
|
||||
|
||||
sub podcast{
|
||||
my $c = shift;
|
||||
$c->stash((load_module("home/podcast"))[0]);
|
||||
|
||||
my ($txt,$h)=$c->dbv->podcast;
|
||||
$c->stash( t=>$txt, pod=>$h,);
|
||||
$c->stash(layout=> "defaultContact");
|
||||
}
|
||||
|
||||
sub radio{
|
||||
my $c=shift;
|
||||
$c->stash((load_module("home/radio"))[0]);
|
||||
$c->stash(%{($c->dbv->radio)->[0]});
|
||||
$c->stash($Dojo::Conf::radio);
|
||||
$c->stash(nick=>$c->session("nick"));
|
||||
}
|
||||
|
||||
sub admin{
|
||||
my $c=shift;
|
||||
if (($c->param("hup") // " " )=~/Cambiar/){
|
||||
$c->dbv->umod($c->param('link'),$c->param('update'));
|
||||
# Admin =======================================================================
|
||||
sub admin_home{
|
||||
my $c=shift;
|
||||
$c->dbv->umod($c->param('link'),$c->param('update'))
|
||||
if (($c->param("hup") // " " )=~/Cambiar/);
|
||||
$c->stash((load_module("home/admin/home"))[0]);
|
||||
$c->stash(template=>"home/admin/home");
|
||||
$c->stash(layout=>"admin");
|
||||
$c->stash( $c->dbv->mod);
|
||||
}
|
||||
### ¡¡aqui me quede!! puedo hacerlo mas facil con router!!!! ###
|
||||
if ( $c->param("update") // 0 ) ==1 ){
|
||||
if ($c->param("id") // 1 ) == 0) ){
|
||||
$c->dbv->eup($c) if (($c->param("eup") // " " )=~/Aceptar/)
|
||||
elsif(($c->param("cup") // " " )=~/Aceptar/){ $c->dbv->cup($c); }
|
||||
elsif(($c->param("pup") // " " )=~/Aceptar/){ $c->dbv->pup($c); }
|
||||
|
||||
else{
|
||||
elsif(($c->param("eup") // " " )=~/Aceptar/){ $c->dbv->ech($c); }
|
||||
elsif(($c->param("cup") // " " )=~/Aceptar/){ $c->dbv->cch($c); }
|
||||
elsif(($c->param("pup") // " " )=~/Aceptar/){ $c->dbv->pch($c); }
|
||||
elsif(($c->param("edel") // " " )=~/Eliminar/){ $c->dbv->edel($c); }
|
||||
elsif(($c->param("cdel") // " " )=~/Eliminar/){ $c->dbv->cdel($c); }
|
||||
elsif(($c->param("pdel") // " " )=~/Eliminar/){ $c->dbv->pdel($c); };
|
||||
}
|
||||
if ($c->param("section")=~/home/){
|
||||
my $v=(load_module("home/admin"))[0];
|
||||
my ($x,$w)= load_module("home/admin/home");
|
||||
$c->stash( merge_hash($x,$v) );
|
||||
$c->stash(apend => ["home/admin/home"]);
|
||||
$c->stash( map{ $_->{nombre} => $_->{contenido}} @{$c->dbv->mod});
|
||||
}
|
||||
elsif ( $c->param("section")=~/radio/ ){
|
||||
sub admin_radio{
|
||||
my $c=shift;
|
||||
$c->dbv->umod($c->param('link'),'rmod')
|
||||
if (($c->param("hup") // " " )=~/Cambiar/);
|
||||
$c->stash($c->dbv->mod);
|
||||
$c->stash($c->dbv->conf_radio);
|
||||
$c->stash( merge_hash(
|
||||
(load_module("home/admin"))[0],
|
||||
(load_module("home/admin/radio"))[0],
|
||||
(load_module("home/admin/candySwitch"))[0],
|
||||
));
|
||||
$c->stash(apend => ["home/admin/radio","home/admin/candySwitch"]);
|
||||
$c->stash(%{($c->dbv->radio)->[0]});
|
||||
$c->stash($Dojo::Conf::radio);
|
||||
}
|
||||
elsif ( $c->param("section")=~/mensajes/ ){
|
||||
$c->stash(merge_hash(
|
||||
(load_module("home/admin"))[0],
|
||||
(load_module("home/admin/mensajes"))[0]
|
||||
));
|
||||
$c->stash(apend => ["home/admin/mensajes"]);
|
||||
my $h = $c->dbv->rmsg;
|
||||
$c->stash( h=>$h );
|
||||
|
||||
}
|
||||
elsif ( $c->param("section")=~/event/ ){
|
||||
$c->stash(merge_hash(
|
||||
(load_module("home/admin"))[0],
|
||||
(load_module("home/admin/event"))[0]
|
||||
));
|
||||
$c->stash(apend => ["home/admin/event"]);
|
||||
$c->stash( $c->dbv->admevent );
|
||||
$c->stash(apend => ["home/admin/candySwitch"]);
|
||||
$c->stash(template=>"home/admin/radio");
|
||||
$c->stash(layout=>"admin");
|
||||
}
|
||||
|
||||
}
|
||||
sub admin_mensajes{
|
||||
my $c=shift;
|
||||
$c->stash((load_module("home/admin/mensajes"))[0]);
|
||||
$c->stash( h=>$c->dbv->msg_heads);
|
||||
$c->stash(template=>"home/admin/mensajes");
|
||||
$c->stash(layout=>"admin");
|
||||
}
|
||||
|
||||
sub admin_eventos{
|
||||
my $c=shift;
|
||||
if ( (my $t=$c->param('type') // "") =~/[ecp]/){
|
||||
my $id=$c->param('id');
|
||||
my $req=$c->param('req');
|
||||
if ( $req eq "Eliminar"){
|
||||
$c->dbv->event_del($id) if ($t eq 'e');
|
||||
$c->dbv->course_del($id) if ($t eq 'c');
|
||||
$c->dbv->place_del($id) if ($t eq 'p');
|
||||
}
|
||||
elsif( $req eq "Aceptar"){
|
||||
if($t eq 'e'){
|
||||
my @list=map{$c->param($_)}qw/eplace yini mini dini yend mend dend cost promo pen ecourse eimg een id/;
|
||||
$c->dbv->event_up(@list) if ($id ==0);
|
||||
$c->dbv->event_ch(@list) if ($id >0);
|
||||
}
|
||||
if($t eq 'c'){
|
||||
my @list=map{$c->param($_)}qw/cname csubjects cservices cen id/;
|
||||
$c->dbv->course_up(@list) if ($id ==0);
|
||||
$c->dbv->course_ch(@list) if ($id >0);
|
||||
}
|
||||
if($t eq 'p'){
|
||||
my @list=map{$c->param($_)}qw/pname paddr pobs pto pst pco plat plng pen id/;
|
||||
$c->dbv->place_up(@list) if ($id ==0);
|
||||
$c->dbv->place_ch(@list) if ($id >0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$c->redirect_to("/admin/eventos");
|
||||
}
|
||||
|
||||
|
||||
|
||||
$c->stash(
|
||||
courses=>$c->dbv->courses,
|
||||
places=>$c->dbv->places,
|
||||
months=>$c->dbv->months,
|
||||
events=>$c->dbv->events,
|
||||
img=>$c->dbv->eimgList,
|
||||
);
|
||||
$c->stash((load_module("home/admin/event"))[0]);
|
||||
$c->stash(template=>"home/admin/event");
|
||||
$c->stash(layout=>"admin");
|
||||
}
|
||||
|
||||
sub admin_json{
|
||||
my $c=shift;
|
||||
my $id = $c->param('id');
|
||||
my $req = $c->param('dreq');
|
||||
my $json = "304";
|
||||
$json = $c->dbv->msg($id) if $req=~/mensaje/;
|
||||
$json = $c->dbv->course($id) if $req=~/course/;
|
||||
$json = $c->dbv->place($id) if $req=~/place/;
|
||||
$json = $c->dbv->eventa($id) if $req=~/event/;
|
||||
$c->render(json=>$json);
|
||||
}
|
||||
|
||||
|
||||
# if (($c->param("id") // " " ) eq "0") {
|
||||
# $c->dbv->eup if (($c->param("eup") // " " ) =~/Aceptar/);
|
||||
# $c->dbv->cup if (($c->param("cup") // " " ) =~/Aceptar/);
|
||||
# $c->dbv->pup if (($c->param("pup") // " " ) =~/Aceptar/);
|
||||
# }
|
||||
# else{
|
||||
# if (($c->param("cup") // " " )=~/Aceptar/){ $c->dbv->cch; }
|
||||
# elsif (($c->param("eup") // " " )=~/Aceptar/){ $c->dbv->ech; }
|
||||
# elsif (($c->param("pup") // " " )=~/Aceptar/){ $c->dbv->pch; }
|
||||
# elsif (($c->param("edel") // " " )=~/Eliminar/){ $c->dbv->edel; }
|
||||
# elsif (($c->param("cdel") // " " )=~/Eliminar/){ $c->dbv->cdel; }
|
||||
# elsif (($c->param("pdel") // " " )=~/Eliminar/){ $c->dbv->pdel; }
|
||||
#}};
|
||||
#}
|
||||
#}
|
||||
#==============================================================================
|
||||
|
||||
1;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package Dojo::Model::Vuelo;
|
||||
use Mojo::File 'path';
|
||||
use Mojo::JSON qw(decode_json encode_json);
|
||||
use Dojo::Support qw{ dmph merge_hash load_module get_names};
|
||||
use Dojo::Support qw{ log dmph merge_hash load_module get_names};
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
|
||||
use File::Basename;
|
||||
use Text::Markdown qw{ markdown };
|
||||
@@ -12,128 +14,150 @@ use Dojo::Conf;
|
||||
sub new { bless {}, shift };
|
||||
|
||||
|
||||
sub mod{
|
||||
my $q="select nombre,contenido from casa;";
|
||||
return \@{_read($q)};
|
||||
}
|
||||
# Read vdg user ===============================================================
|
||||
sub mod{
|
||||
my $q="select nombre,contenido from casa;";
|
||||
my %h=map{ $_->{nombre} => $_->{contenido}}@{_read($q)};
|
||||
return %h;
|
||||
}
|
||||
|
||||
sub pang{
|
||||
my ($c,$q)=@_;
|
||||
return {map { basename($_,".md") => load_md("public/$_")}@{$q->{md}}};
|
||||
}
|
||||
sub cal {
|
||||
my $block=_read (path("public/home/cal/q1Block.q")->slurp);
|
||||
my $data=_read (path("public/home/cal/q3Event.q")->slurp);
|
||||
return ($data,$block);
|
||||
}
|
||||
sub md_to_hash{
|
||||
my ($self,@filelist)=@_;
|
||||
return {map { basename($_,".md") => load_md("public/$_")}@filelist};
|
||||
}
|
||||
|
||||
sub event{
|
||||
my ($self,$id)=@_;
|
||||
return _read (path("public/home/event/qEvent.q")->slurp,$id);
|
||||
}
|
||||
sub calendar_monthblock {
|
||||
return _read (path("public/home/cal/q1Block.q")->slurp);
|
||||
}
|
||||
sub calendar_events {
|
||||
return _read (path("public/home/cal/q3Event.q")->slurp);
|
||||
}
|
||||
|
||||
sub store{
|
||||
return _read (path("public/home/store/qStore.q")->slurp);
|
||||
}
|
||||
sub event{
|
||||
my ($self,$id)=@_;
|
||||
return shift @{ _read (path("public/home/event/qEvent.q")->slurp,$id)};
|
||||
}
|
||||
sub store{
|
||||
return _read (path("public/home/store/qStore.q")->slurp);
|
||||
}
|
||||
sub tv_videos{
|
||||
return _read (path("public/home/tv/qSeries.q")->slurp); #group,name
|
||||
}
|
||||
sub tv_series{
|
||||
return _read (path("public/home/tv/qTable.q")->slurp); #name,order,group
|
||||
}
|
||||
sub podcast_txt{
|
||||
return path("public/home/podcast/text.txt")->slurp;
|
||||
}
|
||||
sub podcast_infoHash{
|
||||
return decode_json path("public/home/podcast/jsonPod.json")->slurp;
|
||||
}
|
||||
sub conf_radio{
|
||||
return $Dojo::Conf::radio;
|
||||
}
|
||||
#==============================================================================
|
||||
|
||||
sub tv{
|
||||
my $series = _read (path("public/home/tv/qSeries.q")->slurp); #group,name
|
||||
my $table = _read (path("public/home/tv/qTable.q")->slurp); #name,order,group
|
||||
return ($series,$table);
|
||||
}
|
||||
# Read vdg admin ==============================================================
|
||||
sub msg_heads{
|
||||
my ($self,@bind)=@_;
|
||||
my @empty;
|
||||
my $q= path("public/home/admin/mensajes/qEntries.q")->slurp;
|
||||
my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::MSGDB.":".Dojo::Conf::MSGDB_H,Dojo::Conf::MSGDB_UR,Dojo::Conf::MSGDB_URP);
|
||||
return \@empty unless($dbh);
|
||||
my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind);
|
||||
#((col1=>d1,col2=>d1),(col1=>d2,col2=>d2))
|
||||
$dbh->disconnect();
|
||||
return $h;
|
||||
}
|
||||
|
||||
sub podcast{
|
||||
my $txt = path("public/home/podcast/text.txt")->slurp;
|
||||
my $hash = decode_json path("public/home/podcast/jsonPod.json")->slurp;
|
||||
return ($txt,$hash);
|
||||
}
|
||||
sub msg{
|
||||
my ($c,@bind)=@_;
|
||||
my @empty;
|
||||
my $q= path("public/home/admin/mensajes/json/qGetInfo.q")->slurp;
|
||||
my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::MSGDB.":".Dojo::Conf::MSGDB_H,Dojo::Conf::MSGDB_UR,Dojo::Conf::MSGDB_URP);
|
||||
return \@empty unless($dbh);
|
||||
my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind);
|
||||
#((col1=>d1,col2=>d1),(col1=>d2,col2=>d2))
|
||||
$dbh->disconnect();
|
||||
return shift @$h;
|
||||
}
|
||||
sub courses{ return _read("select nombre as name, id from curso;")}
|
||||
sub course { return shift @{_read(path("public/home/admin/event/json/qCourse.q")->slurp,pop)}}
|
||||
sub places { return _read("select nombre as name, id from lugar;")}
|
||||
sub place { return shift @{_read(path("public/home/admin/event/json/qPlace.q")->slurp,pop)}}
|
||||
sub months { return _read("select nombre as name, id from mes;")};
|
||||
sub events { return _read(path("public/home/admin/event/qEprev.q")->slurp)}
|
||||
sub eventa { return shift @{_read(path("public/home/admin/event/json/qEvent.q")->slurp,pop)}}
|
||||
sub eimgList{ return [get_names("public/home/cal/img/")] }
|
||||
#==============================================================================
|
||||
# Write vdg admin ==============================================================
|
||||
sub umod{
|
||||
my $c=shift;
|
||||
my $q="update casa set contenido = ? where nombre = ? ;";
|
||||
return _write($q,@_);
|
||||
}
|
||||
|
||||
sub radio{
|
||||
my $q="select contenido as rmod from casa where nombre='rmod';";
|
||||
return _read($q);
|
||||
}
|
||||
sub event_del { return _write("delete from evento where id = ?;",pop);}
|
||||
sub course_del{ return _write("delete from curso where id = ?;",pop); }
|
||||
sub place_del { return _write("delete from lugar where id = ?;",pop); }
|
||||
|
||||
sub event_up{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/add/qEup.q")->slurp,@bind);
|
||||
}
|
||||
sub course_up{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/add/qCup.q")->slurp,@bind);
|
||||
}
|
||||
sub place_up{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/add/qPup.q")->slurp,@bind);
|
||||
}
|
||||
sub event_ch{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/change/qEup.q")->slurp,@bind);
|
||||
}
|
||||
sub course_ch{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/change/qCup.q")->slurp,@bind);
|
||||
}
|
||||
sub place_ch{
|
||||
my ($self,@bind)=@_;
|
||||
return _write(path("public/home/admin/event/change/qPup.q")->slurp,@bind);
|
||||
}
|
||||
|
||||
|
||||
sub umod{
|
||||
my $c=shift;
|
||||
my $q="update casa set contenido = ? where nombre = ? ;";
|
||||
return _write($q,@_);
|
||||
}
|
||||
# admin =================================0
|
||||
sub urmod{
|
||||
my $c=shift;
|
||||
my $q="update casa set contenido = ? where nombre = ? ;";
|
||||
return _write($q,@_);
|
||||
}
|
||||
sub rmsg{
|
||||
my @empty;
|
||||
my $q= path("public/home/admin/mensajes/qEntries.q")->slurp;
|
||||
my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::MSGDB.":".Dojo::Conf::MSGDB_H,Dojo::Conf::MSGDB_UR,Dojo::Conf::MSGDB_URP);
|
||||
return \@empty unless($dbh);
|
||||
my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind);
|
||||
#((col1=>d1,col2=>d1),(col1=>d2,col2=>d2))
|
||||
$dbh->disconnect();
|
||||
return $h;
|
||||
}
|
||||
sub rmsgid{
|
||||
my ($c,@bind)=@_;
|
||||
my @empty;
|
||||
my $q= path("public/home/admin/mensajes/json/qGetInfo.q")->slurp;
|
||||
my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::MSGDB.":".Dojo::Conf::MSGDB_H,Dojo::Conf::MSGDB_UR,Dojo::Conf::MSGDB_URP);
|
||||
return \@empty unless($dbh);
|
||||
my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind);
|
||||
#((col1=>d1,col2=>d1),(col1=>d2,col2=>d2))
|
||||
$dbh->disconnect();
|
||||
return $h;
|
||||
}
|
||||
sub admevent{
|
||||
my $h = {
|
||||
ecourse=>_read("select nombre as name, id from curso;"),
|
||||
eplace =>_read("select nombre as name, id from lugar;"),
|
||||
emini =>_read("select nombre as name, id from mes;"),
|
||||
ilist => [get_names("public/home/cal/img/")],
|
||||
eprev =>_read(path("public/home/admin/event/qEprev.q")->slurp),
|
||||
};
|
||||
return $h
|
||||
}
|
||||
# json ======
|
||||
sub ecourse{
|
||||
my ($c,@id)=@_;
|
||||
return _read(path("public/home/admin/event/json/qEvent.q")->slurp,@id);
|
||||
}
|
||||
sub qcourse{
|
||||
my ($c,@id)=@_;
|
||||
return _read(path("public/home/admin/event/json/qCourse.q")->slurp,@id);
|
||||
}
|
||||
sub qplace{
|
||||
my ($c,@id)=@_;
|
||||
return _read(path("public/home/admin/event/json/qPlace.q")->slurp,@id);
|
||||
}
|
||||
#============
|
||||
#Change =====
|
||||
|
||||
|
||||
#============
|
||||
#==============================================================================
|
||||
|
||||
#ayudas =====================================
|
||||
sub tst{
|
||||
|
||||
my $c=shift;
|
||||
my $d=$c->param('n');
|
||||
log("------log-------");
|
||||
log("$d");
|
||||
log("------log-------");
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub _read{
|
||||
my ($q,@bind)=@_;
|
||||
my (@empty,$arr);
|
||||
my @empty;
|
||||
my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::VUELODB.":".Dojo::Conf::VUELODB_H,Dojo::Conf::VUELODB_UR,Dojo::Conf::VUELODB_URP);
|
||||
return \@empty unless($dbh);
|
||||
#$dbh->do(qq{SET NAMES 'utf8'});
|
||||
my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind);
|
||||
#((col1=>d1,col2=>d1),(col1=>d2,col2=>d2))
|
||||
$dbh->disconnect();
|
||||
#((col1=>d1,col2=>d1),(col1=>d2,col2=>d2))
|
||||
return $h;
|
||||
}
|
||||
|
||||
sub _write{
|
||||
my $q=shift;
|
||||
my ($q,@bind)=@_;
|
||||
my (@empty);
|
||||
my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::VUELODB.":".Dojo::Conf::VUELODB_H,Dojo::Conf::VUELODB_UW,Dojo::Conf::VUELODB_UWP);
|
||||
return 0 unless($dbh);
|
||||
my $h=$dbh->do($q,{ Slice => {} },@_);
|
||||
my $h=$dbh->do($q,{ Slice => {} },@bind);
|
||||
$dbh->disconnect();
|
||||
log("db write: $h");
|
||||
return $h;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ use Mojo::Log;
|
||||
|
||||
sub log{
|
||||
my $log = Mojo::Log->new;
|
||||
$log->debug(shift);
|
||||
$log->debug("============ ".shift." ===========");
|
||||
}
|
||||
sub get_names{
|
||||
my $dir = shift;
|
||||
|
||||
Reference in New Issue
Block a user