[r1081]: branches / 2.5.4 / cgi-bin / yabb2 / Sources / LivePreview.pm Maximize Restore History

Download this file

LivePreview.pm    230 lines (214 with data), 8.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# $Date: 2013-06-25 15:33:13 +0000 (Tue, 25 Jun 2013) $
#-------------------------------------------------------------------#
# LivePreview.pm #
#-------------------------------------------------------------------#
# Ajax LivePreview 4 YaBB25 #
# Version 0.3.7 beta #
# by Carsten Dalgaard #
#-------------------------------------------------------------------#
# Copyright: 2013 'Carsten Dalgaard' - All Rights Reserved #
# Released: May 11, 2013 #
# e-mail: post@carsten-dalgaard.dk #
#-------------------------------------------------------------------#
# Any redistribution of this script without the expressed written #
# consent of 'Carsten Dalgaard' is strictly prohibited. Copying #
# any of the code contained within this script and claiming it as #
# your own is also prohibited. #
#-------------------------------------------------------------------#
# By using this script you agree to indemnify 'Carsten Dalgaard' #
# from any liability that might arise from its use. #
#-------------------------------------------------------------------#
# You may not remove any of these header notices. #
#-------------------------------------------------------------------#
use CGI::Carp qw(fatalsToBrowser);
our $VERSION = '2.5.4';
$livepreviewpmver = 'YaBB 2.5.4 $Revision: 1081 $';
if ( $action eq 'detailedversion' ) { return 1; }
use URI::Escape;
LoadCensorList();
sub DoLiveMessage {
guard();
$displayname = $FORM{'musername'};
$FORM{'message'} =~ s/\r//gsm;
$message = $FORM{'message'};
uri_unescape($message);
$message =~ s/\[ch8203\]//igsm;
$message =~ s/\​//igsm;
FromChars($message);
ToHTML($message);
my $mess = $message;
$message =~ s/\cM//gsm;
$message =~ s/\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]/\[$1$2\]/gsm;
$message =~ s/\[\/([^\]\[]{0,30})\n([^\]\[]{0,30})\]/\[\/$1$2\]/gsm;
$message =~ s/\t/ \  \  \ /gsm;
$message =~ s/\n/<br \/>/gsm;
$message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/gsm;
wrap();
if ( $FORM{'nschecked'} == 1 ) { $ns = 'NS'; }
if ($enable_ubbc) {
if ( !$yyYaBBCloaded ) { require Sources::YaBBC; }
DoUBBC();
$message =~ s/ style="display:none"/ style="display:inline"/gsm;
}
wrap2();
ToChars($message);
$message = Censor($message);
$csubject = $FORM{'subject'};
uri_unescape($csubject);
$csubject =~ s/[\r\n]//gsm;
FromChars($csubject);
$convertstr = $csubject;
$convertcut = $set_subjectMaxLength + ( $csubject =~ /^Re: /sm ? 4 : 0 );
CountChars();
$csubject = $convertstr;
ToHTML($csubject);
ToChars($csubject);
$csubject = Censor($csubject);
liveimage_resize();
$myname = $FORM{'guestname'};
uri_unescape($myname);
$myname =~ s/[\r\n]//gsm;
FromChars($myname);
ToHTML($myname);
ToChars($myname);
$myname = Censor($myname);
print "Content-type: application/x-www-form-urlencoded\n\n"
or croak 'cannot print head';
print qq~$csubject|$message|$myname~ or croak 'cannot print';
$message = $mess;
exit;
}
sub DoLiveIM {
$subjdate = timeformat($date);
$FORM{'message'} =~ s/\r//gxsm;
$message = $FORM{'message'};
uri_unescape($message);
$message =~ s/\[ch8203\]//igsm;
$message =~ s/\&#8203;//igsm;
FromChars($message);
ToHTML($message);
my $mess = $message;
$message =~ s/\cM//gsm;
$message =~ s/\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]/\[$1$2\]/gsm;
$message =~ s/\[\/([^\]\[]{0,30})\n([^\]\[]{0,30})\]/\[\/$1$2\]/gsm;
$message =~ s/\t/ \&nbsp; \&nbsp; \&nbsp;/gsm;
$message =~ s/\n/<br \/>/gsm;
$message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/gsm;
wrap();
if ( $FORM{'nschecked'} == 1 ) { $ns = 'NS'; }
if ($enable_ubbc) {
if ( !$yyYaBBCloaded ) { require Sources::YaBBC; }
$displayname = ${ $uid . $tmpmusername }{'realname'};
DoUBBC();
$message =~ s/ style="display:none"/ style="display:inline"/gsm;
}
wrap2();
ToChars($message);
$message = Censor($message);
$csubject = $FORM{'subject'};
uri_unescape($csubject);
$csubject =~ s/[\r\n]//gsm;
FromChars($csubject);
$convertstr = $csubject;
$convertcut = $set_subjectMaxLength + ( $csubject =~ /^Re: /sm ? 4 : 0 );
CountChars();
$csubject = $convertstr;
ToHTML($csubject);
ToChars($csubject);
$csubject = Censor($csubject);
$icon = $FORM{'icon'};
CheckIcon();
get_micon();
$msgimg = qq~$micon{$icon}~;
$css = q~windowbg~;
LoadLanguage('InstantMessage');
get_template('MyMessage');
$liveipimg = qq~<img src="$imagesdir/$IM_ip" alt="" />~;
$livemip = $inmes_txt{'511'};
$messageblock = $myIM_liveprev_b;
$messageblock =~ s/({|<)yabb css(}|>)/$css/gsm;
$messageblock =~ s/({|<)yabb msgimg(}|>)/$msgimg/gsm;
$messageblock =~ s/({|<)yabb subjdate(}|>)/$subjdate/gsm;
$messageblock =~ s/({|<)yabb csubject(}|>)/$csubject/gsm;
$messageblock =~ s/({|<)yabb message(}|>)/$message/gsm;
$messageblock =~ s/({|<)yabb my_sig(}|>)/$my_sig/gsm;
$messageblock =~ s/({|<)yabb my_attach(}|>)/$my_attach/gsm;
$messageblock =~ s/({|<)yabb my_showIP(}|>)/$liveipimg $livemip/gsm;
liveimage_resize();
print "Content-type: application/x-www-form-urlencoded\n\n"
or croak 'cannot print head';
print qq~$messageblock\n~ or croak 'cannot print messageblock';
$message = $mess;
exit;
}
sub DoLiveCal {
guard();
LoadLanguage('EventCal');
$FORM{'message'} =~ s/\r//gxsm;
$message = $FORM{'message'};
uri_unescape($message);
$message =~ s/\[ch8203\]//igsm;
$message =~ s/\&#8203;//igsm;
FromChars($message);
ToHTML($message);
my $mess = $message;
$message =~ s/\cM//gsm;
$message =~ s/\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]/\[$1$2\]/gsm;
$message =~ s/\[\/([^\]\[]{0,30})\n([^\]\[]{0,30})\]/\[\/$1$2\]/gsm;
$message =~ s/\t/ \&nbsp; \&nbsp; \&nbsp;/gsm;
$message =~ s/\n/<br \/>/gsm;
$message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/gsm;
wrap();
if ( $FORM{'nschecked'} == 1 ) { $ns = 'NS'; }
if ($enable_ubbc) {
if ( !$yyYaBBCloaded ) { require Sources::YaBBC; }
$displayname = ${ $uid . $tmpmusername }{'realname'};
DoUBBC();
$message =~ s/ style="display:none"/ style="display:inline"/gsm;
}
wrap2();
ToChars($message);
$message = Censor($message);
liveimage_resize();
CountChars();
$myname = $FORM{'guestname'};
uri_unescape($myname);
$myname =~ s/[\r\n]//gsm;
FromChars($myname);
ToHTML($myname);
ToChars($myname);
$myname = Censor($myname);
$d_year = $FORM{'cal_year'};
$d_mon = $FORM{'cal_mon'};
$d_day = $FORM{'cal_day'};
$my_icontxt = $FORM{'icon_txt'};
$txt_icon = $var_cal{$my_icontxt};
$my_caltype = $FORM{'cal_type'};
get_micon();
if ( $my_caltype == 2 ) { $mycal_type = $cal_icon{'eventprivate'}; }
else { $mycal_type = q{}; }
$mybtime = stringtotime(qq~$d_mon/$d_day/$d_year~);
$mybtimein = timeformat($mybtime);
$cdate = dtonly($mybtimein);
print "Content-type: application/x-www-form-urlencoded\n\n"
or croak 'cannot print head';
print qq~$message|$myname|$cdate|$txt_icon|$mycal_type~
or croak 'cannot print message';
$message = $mess;
exit;
}
sub liveimage_resize {
my ($resize_num);
*check_image_resize = sub {
my @x = @_;
$resize_num++;
$x[0] = "post_liveimg_resize_$resize_num";
return qq~"$x[0]"$x[1]~;
};
$messageblock =~
s/"(post_liveimg_resize)"([^>]*>)/ check_image_resize($1,$2) /gesm;
$message =~
s/"(post_liveimg_resize)"([^>]*>)/ check_image_resize($1,$2) /gesm;
return;
}
1;