From 15e6994d74f117d646f9718d0a1053f25b7d8359 Mon Sep 17 00:00:00 2001
From: "Difrex(Denis Zheleztsov)" Новые сообщения
\n";
+ if ( defined($msgs) ) {
+ my @msg_list = split /\n/, $msgs;
+ while (<@msg_list>) {
+ my $mes_hash = $_;
+ open my $m, "<", "./msg/$mes_hash"
+ or die "Cannot open message: $!\n";
+
+ my @mes;
+ while (<$m>) {
+ push( @mes, $_ );
+ }
+ close $m;
+
+ my $count = 7;
+ my $post;
+ while ( $count < @mes ) {
+ $post .= $mes[$count];
+ $count++;
+ }
+
+ chomp( $mes[2] );
+ chomp( $mes[1] );
+ chomp( $mes[3] );
+ chomp( $mes[5] );
+ chomp( $mes[6] );
+
+ # Make data
+ my %data = (
+ hash => $mes_hash,
+ time => $mes[2],
+ echo => $mes[1],
+ from_user => $mes[3],
+ to_user => $mes[5],
+ subg => $mes[6],
+ post => "$post",
+ read => 0,
+ );
+
+ # Write message to DB
+ $db->write(%data);
+
+ # $new_messages .= "$post
Новых сообщений нет
"; + # } + $render .= $t->foot(); + + return $render; +} + +1; diff --git a/II/Send.pm b/II/Send.pm new file mode 100644 index 0000000..4e4319c --- /dev/null +++ b/II/Send.pm @@ -0,0 +1,41 @@ +package II::Send; + +use HTTP::Request::Common qw(POST); +use LWP::UserAgent; +use II::DB; +use Data::Dumper; + +sub new { + my $class = shift; + + my $self = { + _config => shift, + _echo => shift, + _base64 => shift, + }; + + bless $self, $class; + return $self; +} + +sub send { + my ($self, $hash) = @_; + my $config = $self->{_config}; + my $echo = $self->{_echo}; + my $base64 = $self->{_base64}; + + # Push message to server + my $host = $config->{host}; + my $auth = $config->{key}; + $host .= "u/point"; + my $ua = LWP::UserAgent->new(); + my $response = $ua->post( $host, { 'pauth' => $auth, 'tmsg' => $base64 } ); + print Dumper($response); + + my $db = II::DB->new(); + if ($response->{_rc} == 200) { + $db->update_out($hash); + } +} + +1; diff --git a/II/T.pm b/II/T.pm new file mode 100644 index 0000000..5fb2100 --- /dev/null +++ b/II/T.pm @@ -0,0 +1,169 @@ +package II::T; + +use HTML::Template; +use Data::Dumper; + +sub new { + my $class = shift; + my $self = {}; + bless $self, $class; + return $self; +} + +sub head { + my ( $self, $title ) = @_; + my $t = HTML::Template->new( filename => 't/head.html' ); + + $t->param( TITLE => $title ); + + return $t->output; +} + +sub index { + my ( $self, $echoareas ) = @_; + my $i = HTML::Template->new( filename => 't/index.html' ); + + my $index = '/g; + $pre = 1; + } + elsif ( ( $line =~ /^====/ ) and ( $pre == 1 ) ) { + $line =~ s/====/<\/pre>\n====/g; + $pre = 0; + } + $txt .= $line; + } + close $fh; + return $txt; +} + +sub foot { + my ($self) = @_; + + my $f = HTML::Template->new( filename => 't/foot.html' ); + + return $f->output(); +} + +1; diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..34a050c --- /dev/null +++ b/config.ini @@ -0,0 +1,7 @@ +[auth] +key = you_auth_key +nick = you_nick + +[node] +host = http://your_ii_node.ii +echoareas = im.100 diff --git a/ii.sql b/ii.sql new file mode 100644 index 0000000000000000000000000000000000000000..2453b766f4fdc4316c2bdb38b7b1732b535fdd64 GIT binary patch literal 1793024 zcmeI!Ww52yp`hX2fTI#uhI@}6Gh&ai2k*bj_z_DDh7X1e8LU2H z#9%P}O@qON@6?6$=3p?GvWC|`$B=*i@V}q?8;g7}e2QUn4TcTg9}InC$a_uy`f>bW z!zY??=9!0{xX$=pcHM8x*h9u2c*yvFyiT~!nwyUrIeOHH(IeN`aMXzT{&94^5%bTt z_wMtJSa0Leqt+R<`G`$7UvHz4n{PW}gHhX#7`f%>P1f7EyEYoN@#qm7Z&F)sxZ%Ph z<{PuyUSsDQvDL`U*Iakx=JPMT%mN+T $!Tqo~>u2+G2TBp>>by6K)C)Nq|sXDff zt7GcuI;xJWBkJ%vtPZV1YJ82WgX^F=u*TK_wSVnb`_|sISM6E*)E>2a?N+ 9lfu9mH(YnfWAmaHXe@mj1Ftwn0#TBzo#1#5wt zzvioXYwnt-=BzntM17(@UbEHgHEYdM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5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RsOLf#Ex}%!h-)@cZiCx~J~0yXwxmqi(NT>$dt_-BO>eo9m{!v2LjA>$ %2O*&Z=|j>^iePGZ+l}c=KuX={mj6s8j2dI=N1& z6YGRJzCKmQ)v tv^J|vYNOh?HmnV5{aUxyskLiV ztygQ+nzcr)UL$L@TD4ZGm20J1u~w+%Yq?ssmdW+)=A~V ti)V zO;(fEBsFnOUK7?tH9-xlp*5ri)yuHI)nDqb_2>Fi{h>ar-`5}OclF!)P5rulS-+~E z*U#z~_0#%E{kVQG7!3XBnjhBp>w|i~zE|I^Z`XI~TlHRjv)=8VbDF &bee9 fQQgy;t9=Z`XI~yY;<#zdoq%*AME4_2c@{U@-inb3dt{*3ata z^^5vt{i=Rlzp3BW@9OvU(Yk-AKh~e>&-Iu3YyE97n6O8ia7YcUVKuxas7_2cQB7Qv z)TA|8O Su32iii`L?`L@ilM*HX1iEnCag3blN#SS!`awMwm8tJUf?veu|IYpohp zYu7rpZmn1A*9NswZCD%ECbem8R-4xrHM+K}t!nF ZC^Xoj x4S7PO6jZlsdIetJCYuI;+mEbL!%{q%N(?>WaFmF0ZTWn!2_ws_W{?y1s6x8|$XJ zxjt97)U9<}-ClRpoppEJRrl1r_4&HL9;gTFp?bK!P> $Q5lzEp44m+P&1yWXk$>WunyeWuQ>^XmM%U| new(); +my $config = $c->load(); + +my $GET = II::Get->new($config); +my $render = II::Render->new(); + +my $echo = sub { + my $env = shift; + + my $req = Plack::Request->new($env); + + my $query = $req->param('echo'); + + my $echo_messages = $render->echo_mes($query); + + return [ 200, [ 'Content-type' => 'text/html' ], ["$echo_messages"], ]; +}; + +my $thread = sub { + my $env = shift; + + my $req = Plack::Request->new($env); + + my $subg = $req->param('subg'); + my $echo = $req->param('echo'); + + my $thread = $render->thread( $subg, $echo ); + + return [ 200, [ 'Content-type' => 'text/html' ], ["$thread"], ]; +}; + +my $get = sub { + my $msgs = $GET->get_echo(); + my $new_mes = $render->new_mes($msgs); + return [ 200, [ 'Content-type' => 'text/html' ], ["$new_mes"], ]; +}; + +my $root = sub { + my $index = $render->index($config); + return [ 200, [ 'Content-type' => 'text/html' ], [$index], ]; +}; + +my $me = sub { + my $messages = $render->to_me($config); + return [ 200, [ 'Content-type' => 'text/html' ], [$messages], ]; +}; + +my $tree = sub { + my $subges = $render->tree($config); + return [ 200, [ 'Content-type' => 'text/html' ], ['Дерево'], ]; +}; + +my $new = sub { + my $env = shift; + + my $req = Plack::Request->new($env); + my $echo = $req->param('echo'); + + my $send = $render->send_new($echo); + return [ 200, [ 'Content-type' => 'text/html' ], [$send], ]; +}; + +my $send = sub { + my $env = shift; + + my $req = Plack::Request->new($env); + my $hash = $req->param('hash'); + my $send = $render->send($hash); + + return [ 200, [ 'Content-type' => 'text/html' ], [$send], ]; +}; + +my $enc = sub { + my $env = shift; + + my $req = Plack::Request->new($env); + + # Get parameters + my $echo = $req->param('echo'); + my $to = $req->param('to'); + my $post = $req->param('post'); + my $subg = $req->param('subg'); + my $hash = $req->param('hash'); + my $time = time(); + + print Dumper($config); + my $data = { + echo => $echo, + to => $to, + from => $config->{nick}, + subg => $subg, + post => $post, + time => $time, + hash => $hash, + }; + + my $enc = II::Enc->new( $config, $data ); + $enc->encode() == 0 or die "$!\n"; + + return [ 302, [ 'Location' => '/out' ], [], ]; +}; + +my $out = sub { + my $out = $render->out(); + + return [ 200, [ 'Content-type' => 'text/html' ], [$out], ]; +}; + +# Push message to server +my $push = sub { + my $env = shift; + + my $req = Plack::Request->new($env); + + my $echo = $req->param('echo'); + my $base64 = $req->param('base64'); + my $hash = $req->param('hash'); + + my $s = II::Send->new( $config, $echo, $base64 ); + $s->send($hash); + + my $db = II::DB->new(); + $db->update_out($hash); + + return [ 302, [ 'Location' => "/e?echo=$echo" ], [], ]; +}; + +builder { + mount '/' => $root; + mount '/e' => $echo; + mount '/s' => $thread; + mount '/me' => $me; + mount '/tree' => $tree; + mount '/get/' => $get; + mount '/send' => $send; + mount '/enc' => $enc; + mount '/out' => $out; + mount '/push' => $push; + mount '/new' => $new; +}; diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..0a3677c --- /dev/null +++ b/run.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Debug server +plackup iiplc.app + +# Production +# starman -l 127.0.0.1:5000 run.pl whatever diff --git a/t/foot.html b/t/foot.html new file mode 100644 index 0000000..691287b --- /dev/null +++ b/t/foot.html @@ -0,0 +1,2 @@ + +