| 1 | #!perl -w | ||
| 2 | # | ||
| 3 | # CGI::Bus::upws - User Personal WorkSpace | ||
| 4 | # | ||
| 5 | # admiral | ||
| 6 | # | ||
| 7 | # | ||
| 8 | |||
| 9 | package CGI::Bus::upws; | ||
| 10 | require 5.000; | ||
| 11 | use strict; | ||
| 12 | use CGI::Carp qw(fatalsToBrowser warningsToBrowser); | ||
| 13 | use CGI::Bus::Base; | ||
| 14 | use vars qw(@ISA); | ||
| 15 | @ISA =qw(CGI::Bus::Base); | ||
| 16 | |||
| 17 | my %img =(-logo =>'portal.gif' # portal world1 | ||
| 18 | ,'Home' =>'small/burst.gif' | ||
| 19 | ,'Overview'=>'small/movie.gif' | ||
| 20 | ,'Index' =>'small/comp1.gif' | ||
| 21 | ,'Search' =>'small/index.gif' | ||
| 22 | ,'USites' =>'small/image2.gif' | ||
| 23 | ,-usite =>'small/image2.gif' | ||
| 24 | ,-udir =>'small/blank.gif' # dir2 blank | ||
| 25 | ,'USFHomes'=>'small/dir.gif' | ||
| 26 | ,'USFHome' =>'small/dir.gif' | ||
| 27 | ,'Setup' =>'small/patch.gif' | ||
| 28 | ,_blank =>'small/dir.gif' # generic dir | ||
| 29 | ,_top =>'small/back.gif' # back transfer | ||
| 30 | ,_parent =>'small/back.gif' # _top | ||
| 31 | ,-href =>'small/text.gif' # doc text generic forward blank | ||
| 32 | ,-hgen =>'small/generic.gif' | ||
| 33 | ,-host =>'small/comp2.gif' # comp2 comp1 | ||
| 34 | ,-hcgi =>'small/binary.gif' # doc | ||
| 35 | ,'Logout' =>'small/key.gif' | ||
| 36 | ,'Login' =>'small/key.gif' | ||
| 37 | ); | ||
| 38 | |||
| 39 | 1; | ||
| 40 | |||
| 41 | |||
| 42 | ####################### | ||
| 43 | |||
| 44 | |||
| 45 | sub _img { | ||
| 46 | $_[0]->parent->{-iurl} && $img{$_[1]} | ||
| 47 | ? ('<img src="' .$_[0]->parent->{-iurl} .'/' .$img{$_[1]} | ||
| 48 | # .'" alt="" border=0 title="' .(defined($_[2]) ? $_[2] : $_[0]->lng(1,$_[1])) .'" />') | ||
| 49 | .'" alt="" border=0 title="' .$_[0]->lng(1, defined($_[2]) ? $_[2] : $_[1]) .'" />') | ||
| 50 | : '' | ||
| 51 | } | ||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | sub urls { # urls array | ||
| 56 | my $s =shift; | ||
| 57 | my $g =$s->cgi; | ||
| 58 | my $l =[]; | ||
| 59 | my $hu=$s->udata->paramj('upws_urlh'); | ||
| 60 | my $hf=$s->udata->paramj('upws_frmurls'); | ||
| 61 | $hf=scalar(@$hf) if $hf; | ||
| 62 | my $ht; | ||
| 63 | push @$l, $g->a({-href=>$hu, -title=>$s->lng(1, 'Home')} | ||
| 64 | ,$s->_img('Home') .$s->lng(0, 'Home')) | ||
| 65 | if $hu; | ||
| 66 | push @$l, $g->a({-href=>$s->qurl('', '_run'=>'RIGHT') | ||
| 67 | ,-title=>$s->lng(1, 'Overview')} | ||
| 68 | ,$s->_img('Overview') .$s->lng(0, 'Overview')) | ||
| 69 | if $hf; | ||
| 70 | push @$l, $g->a({-href=>$s->{-index} | ||
| 71 | ,-title=>$s->lng(1, 'Index')} | ||
| 72 | ,$s->_img('Index') .$s->lng(0, 'Index')) | ||
| 73 | if $s->{-index} && !ref($s->{-index}); | ||
| 74 | push @$l, @{$s->{-index}} | ||
| 75 | if $s->{-index} && ref($s->{-index}); | ||
| 76 | push @$l, @{$s->{-indexes}} | ||
| 77 | if $s->{-indexes}; | ||
| 78 | #push @$l, $g->a({-href=>$s->{-search} && !ref($s->{-search}) | ||
| 79 | # ? $s->{-search} | ||
| 80 | # : $s->qurl('', '_run'=>'SEARCH') | ||
| 81 | # ,-title=>$s->lng(0, 'Search')} | ||
| 82 | # ,$s->_img('Search') .$s->lng(0, 'Search')) | ||
| 83 | # if $s->{-searchms} ? !$s->parent->uguest : $s->{-search}; | ||
| 84 | if ($s->{-search}) { | ||
| 85 | my $url = $s->{-search} && !ref($s->{-search}) | ||
| 86 | ? $s->{-search} | ||
| 87 | : $s->qurl('', '_run'=>'SEARCH'); | ||
| 88 | my $lgn = $s->{-searchms} && $s->parent->uguest | ||
| 89 | && $s->url !~/\/_*(search|guest)\//i; | ||
| 90 | push @$l, $g->a({-href =>$lgn ?$s->qurl('','_login'=>1,'_run'=>$url) :$url | ||
| 91 | ,-target=>$lgn ? '_parent' : ($s->qparam('_target') ||'RIGHT') | ||
| 92 | ,-title =>$s->lng(0, 'Search')} | ||
| 93 | ,$s->_img('Search') .$s->lng(0, 'Search')) | ||
| 94 | } | ||
| 95 | push @$l, $g->a({-href=>$s->qurl('', '_run'=>'USITES') | ||
| 96 | ,-title=>$s->lng(1, 'USites', $s->{-uspfile} ? join(', ', @{$s->{-uspfile}}) : '')} | ||
| 97 | ,$s->_img('USites') .$s->lng(0, 'USites')) | ||
| 98 | if $s->{-usurl}; | ||
| 99 | if ($s->parent->urfcnd && $s->{-uspurf}) { | ||
| 100 | $s->_usdflt if !$s->{-uspath}; | ||
| 101 | my ($hu, $ho) =('',$s->{-uspurf}); | ||
| 102 | if (!$s->parent->uguest) {$hu =$s->usfhome; $ho =$s->usohome($hu)} | ||
| 103 | push @$l, $g->a({-href=> $ho =~/^\w{3,5}:\/\// ? $ho : (($s->{-uspurf} ||$s->{-usurl}) ."/$ho") | ||
| 104 | ,-target=>'_blank' | ||
| 105 | ,-title =>$s->lng(1, 'USFHomes')} | ||
| 106 | ,$s->_img('USFHomes') .$s->lng(0, 'USFHomes') .' ') | ||
| 107 | if $hu; | ||
| 108 | push @$l, $g->a({-href=> $hu =~/^\w{3,5}:\/\// ? $hu : (($s->{-uspurf} ||$s->{-usurl}) ."/$hu") | ||
| 109 | ,-target=>'_blank' | ||
| 110 | ,-title =>$s->lng(1, 'USFHome')} | ||
| 111 | ,$s->_img('USFHome') .$s->lng(0, 'USFHome') .' ') | ||
| 112 | if $hu; | ||
| 113 | } | ||
| 114 | push @$l, @{ref($s->{-urlst}) eq 'CODE' ? &{$s->{-urlst}}($s) : $s->{-urlst}} | ||
| 115 | if $s->{-urlst}; | ||
| 116 | push @$l, '' | ||
| 117 | if scalar(@$l) >2; | ||
| 118 | push @$l, @{$s->parent->udata->paramj('upws_urls') ||[]}; | ||
| 119 | push @$l, @{ref ($s->{-urls}) eq 'CODE' ? &{$s->{-urls}}($s) : $s->{-urls}} | ||
| 120 | if $s->{-urls}; | ||
| 121 | $l | ||
| 122 | } | ||
| 123 | |||
| 124 | |||
| 125 | |||
| 126 | sub urltop { # topmost url to open first | ||
| 127 | my $s =shift; | ||
| 128 | my $u =$s->urls->[0]; | ||
| 129 | if ($u =~/ +href *= *"([^"\s>]+)"/i) { $u =$1 } | ||
| 130 | elsif ($u =~/^([^|]+)\|+(.+)$/) { $u =$2 } | ||
| 131 | $u !~/^([\/]|\w+:\/\/)/ ? $s->burl($u) : $u | ||
| 132 | } | ||
| 133 | |||
| 134 | |||
| 135 | |||
| 136 | sub scrbot { # print bottom of the screen | ||
| 137 | my $s =shift; | ||
| 138 | my $p =$s->parent; | ||
| 139 | my $r =join(';<br />', map {$p->htmlescape($_)} @{$p->pushmsg}); | ||
| 140 | $r ='<span style="font-size: smaller;"><hr />' .$r .'</span>' if $r; | ||
| 141 | $s->print->text($r); | ||
| 142 | } | ||
| 143 | |||
| 144 | |||
| 145 | |||
| 146 | sub scrtop { # top screen (top frameset) | ||
| 147 | my $s =shift; | ||
| 148 | my $ft=0; # top frame | ||
| 149 | $s->print->httpheader({-target=>'_parent', -expires=>undef}); | ||
| 150 | $s->print('<html><head><title>' | ||
| 151 | .$s->server_name() | ||
| 152 | .' - ' | ||
| 153 | .$s->lng(0,'WorkSpace') | ||
| 154 | .'</title></head>'); | ||
| 155 | $s->print("<frameset cols=\"15%,*\" name=\"TOP\">\n"); | ||
| 156 | $s->print("<frame name=\"LEFT\" src=\"" | ||
| 157 | .$s->qurl('', '_run'=>'LEFT') .'"' | ||
| 158 | .' onfocus="{var e; try {self.document.title = self.LEFT.document.title;} catch(e){}};"' | ||
| 159 | ." target=\"RIGHT\" />\n"); | ||
| 160 | #$s->print("<frameset rows=\"0%,*\">\n") if $ft; # 5% | ||
| 161 | #$s->print("<frame name=\"TOPR\" src=\"" | ||
| 162 | # .$s->qurl('', '_run'=>'TOPR') .'"' | ||
| 163 | # ." target=\"RIGHT\" />\n") if $ft; | ||
| 164 | $s->print('<frame name="RIGHT" src="' | ||
| 165 | .($s->qrun || $s->urltop) .'"' | ||
| 166 | .' onfocus ="{var e; try {self.document.title = (self.RIGHT.document && self.RIGHT.document.title) || "' | ||
| 167 | .$s->parent->htmlescape($s->parent->set('-htmlstart')->{-title} || '') | ||
| 168 | .'" || self.RIGHT.location.href || ""} catch(e) {}};";' | ||
| 169 | ." />\n"); | ||
| 170 | #(self.RIGHT && self.RIGHT.document && self.RIGHT.document.title) | ||
| 171 | #' onfocus ="self.document.title = self.RIGHT.document.title || self.RIGHT.location.href;"' | ||
| 172 | #' onfocus ="self.document.title = self.RIGHT.document.title +" - " +self.RIGHT.location.href;"' | ||
| 173 | # onfocus ="self.parent.status = self.RIGHT.document.title;" | ||
| 174 | # onfocus ="self.status = self.RIGHT.document.title;" | ||
| 175 | # self.RIGHT.contentWindow.location.href | ||
| 176 | $s->print("</frameset>\n") if $ft; | ||
| 177 | $s->print("</frameset>\n"); | ||
| 178 | $s->print("</html>\n"); | ||
| 179 | } | ||
| 180 | |||
| 181 | |||
| 182 | sub scrleft { # left screen (urls) | ||
| 183 | my $s =shift; | ||
| 184 | my $p =$s->parent; | ||
| 185 | my $tf=$s->qparam('_target'); | ||
| 186 | |||
| 187 | $s->print()->htpgstart(undef, $p->hmerge($p->{-htpnstart},-target=>$tf||'RIGHT',-class=>'PaneLeft')); | ||
| 188 | |||
| 189 | { my $li=$s->{-logo}; | ||
| 190 | my $lt=$tf ? 1 : 0; | ||
| 191 | $li =$img{-logo} && $p->{-iurl} ? $s->_img('-logo','') | ||
| 192 | :$ENV{SERVER_SOFTWARE} =~/Apache/i ? $s->_img('-logo','') | ||
| 193 | :$ENV{SERVER_SOFTWARE} =~/IIS/i ? '/web.gif' | ||
| 194 | :undef | ||
| 195 | if !defined($li); | ||
| 196 | $li =$s->a({-href => $lt ? $s->qurl : $s->qurl('', '_run'=>'LEFT','_target'=>'RIGHT') | ||
| 197 | ,-target=> $lt ? '_self' : '_parent'} | ||
| 198 | ,!$li ? $s->_img('-logo','') | ||
| 199 | : $li =~/</ ? $li | ||
| 200 | : '<img src="' .$li .'" alt="" border=0 />' | ||
| 201 | ) | ||
| 202 | if (!defined($li) && $img{-logo} && $p->{-iurl}) | ||
| 203 | || ($li && $li !~/<a /i); | ||
| 204 | $s->print($li) if $li; | ||
| 205 | } | ||
| 206 | |||
| 207 | $s->print($p->strong($s->user), '<br />'); | ||
| 208 | #$s->print()->strong($s->a({-href=>$s->uauth->authurl($s->qurl), -target=>'_parent'}, $s->user))->br; | ||
| 209 | $s->print('<NOBR>'); | ||
| 210 | if ($s->uguest) { | ||
| 211 | $s->print()->a({-href =>$s->uauth->authurl($s->qurl) | ||
| 212 | || $s->qurl('','_run'=>'LOGIN') | ||
| 213 | ,-target=>'_parent' #'_top' # _parent | ||
| 214 | ,-title =>$s->lng(1,'Login')} | ||
| 215 | ,$s->_img('Login') .$s->lng(0,'Login') .'...')->br->br; | ||
| 216 | } | ||
| 217 | |||
| 218 | my $l =$s->urls; | ||
| 219 | my $d ='1'; | ||
| 220 | foreach my $e (@$l) { | ||
| 221 | next if ($e||'') eq ($d||''); | ||
| 222 | if ($e =~/^ *$/ || $e =~/^<\w/i) { | ||
| 223 | $s->print((!$e ||$e =~/<img\s|<hr|<br/i ? '' : $s->_img('-hgen')) .$e ."<br />\n"); | ||
| 224 | } | ||
| 225 | elsif ($e =~/^([^|]+)(\|.+){0,1}?\|(_blank|_top|_parent)\|(.+)$/i) { | ||
| 226 | my ($c,$i,$t,$u) =($1,$2,$3,$4); | ||
| 227 | $t =lc($t); | ||
| 228 | if ($i) { | ||
| 229 | $i =($i !~/\// ? $u .'/' : '') .substr($i,1); | ||
| 230 | $s->print()->a({-href=>$u, -target=>$t, -title=>"$c|$t|$u"}, $s->_img($t,"$c|$t|$u")) | ||
| 231 | ->a({-href=>$i||$u, -title=>$i||$e}, $s->htmlescape($c)) | ||
| 232 | ->a({-href=>$u, -target=>$t, -title=>"$c|$t|$u"}, $p->{-iurl} ? '' : $t eq '_blank' ? '...' : '!') | ||
| 233 | ->br | ||
| 234 | } | ||
| 235 | else { | ||
| 236 | $s->print()->a({-href=>$u, -target=>$t, -title=>$e} | ||
| 237 | ,$s->_img($t,$e) | ||
| 238 | .$s->htmlescape($c) | ||
| 239 | .($p->{-iurl} ? '' : $t eq '_blank' ? '...' : '!')) | ||
| 240 | ->br | ||
| 241 | } | ||
| 242 | } | ||
| 243 | elsif ($e =~/^([^|]+)\|+(.+)$/) { | ||
| 244 | my ($c,$u) =($1, $2); | ||
| 245 | $s->print()->a({-href=>$u,-title=>$c} | ||
| 246 | , $s->_img($u !~m{\w/\w}i ? '-host' : $u =~m{\.(cgi|pl|php|asp)\b}i ? '-hcgi' : '-href', $c) | ||
| 247 | . $s->htmlescape($c))->br; | ||
| 248 | } | ||
| 249 | else { | ||
| 250 | $s->print()->a({-href=>$e,-title=>$e}, $s->_img('-href',$e) .$s->htmlescape($e))->br; | ||
| 251 | } | ||
| 252 | $d =$e; | ||
| 253 | } | ||
| 254 | |||
| 255 | if (!$s->parent->uguest) { | ||
| 256 | $s->print()->br if $l->[$#{$l}]; | ||
| 257 | $s->print()->a({-href=> $s->qurl('','_run'=>'SETUP') | ||
| 258 | ,-title=>$s->lng(1,'Setup', $s->parent->user)} | ||
| 259 | ,$s->_img('Setup') .$s->lng(0,'Setup'))->br; | ||
| 260 | $s->print()->a({-href =>$s->qurl('','_run'=>'LOGOUT') | ||
| 261 | ,-target=>'_parent' #'_top' # _parent | ||
| 262 | ,-title =>$s->lng(1,'Logout')} | ||
| 263 | ,$s->_img('Logout') .$s->lng(0,'Logout') .'!')->br | ||
| 264 | if $s->parent->uauth->signget; | ||
| 265 | } | ||
| 266 | $s->print('</NOBR>'); | ||
| 267 | $s->scrbot; | ||
| 268 | $s->print()->htpgend; | ||
| 269 | } | ||
| 270 | |||
| 271 | |||
| 272 | |||
| 273 | sub scrtopr { # top right screen (frame) | ||
| 274 | my $s =shift; | ||
| 275 | $s->print->htpgstart(undef, $s->parent->hmerge($s->parent->{-htpnstart}, -class=>'PaneLeft')); | ||
| 276 | $s->print->startform(-action=>$s->qurl, -acceptcharset=>$s->parent->{-httpheader} ?$s->parent->{-httpheader}->{-charset} :undef); | ||
| 277 | $s->print->htpfend(); | ||
| 278 | } | ||
| 279 | |||
| 280 | |||
| 281 | |||
| 282 | sub scrright { # right screen (frameset) | ||
| 283 | my $s =shift; | ||
| 284 | my $d =$s->udata->param; | ||
| 285 | $d =$s->udata->paramj if !$d->{'upws_frmurls'} || !scalar(@{$d->{'upws_frmurls'}}); | ||
| 286 | |||
| 287 | if ($d->{'upws_frmurls'} | ||
| 288 | && $s->parent->ishtml($d->{'upws_frmurls'}->[0])) { | ||
| 289 | $s->print->httpheader; | ||
| 290 | $s->print(join("\n", @{$d->{'upws_frmurls'}})); | ||
| 291 | return(1) | ||
| 292 | } | ||
| 293 | |||
| 294 | if (!$d->{upws_frmrows} && !$d->{upws_frmcols} | ||
| 295 | && $d->{upws_frmurls} && scalar(@{$d->{upws_frmurls}})) { | ||
| 296 | my $r =scalar(@{$d->{upws_frmurls}}); | ||
| 297 | $d->{upws_frmrows} = (int(100/$r) .'%,') x $r; | ||
| 298 | chop($d->{upws_frmrows}) | ||
| 299 | } | ||
| 300 | |||
| 301 | $s->print->httpheader; | ||
| 302 | $s->print("<frameset" | ||
| 303 | .($d->{upws_frmrows} ? (' rows="' .$d->{upws_frmrows} .'"') :'') | ||
| 304 | .($d->{upws_frmcols} ? (' cols="' .$d->{upws_frmcols} .'"') :'') | ||
| 305 | .">\n"); | ||
| 306 | if ($d->{upws_frmurls}) { | ||
| 307 | foreach my $e (@{$d->{upws_frmurls}}) { | ||
| 308 | $s->print("<frame src=\"" | ||
| 309 | .$e | ||
| 310 | ."\">\n"); | ||
| 311 | } | ||
| 312 | } | ||
| 313 | $s->print("</frameset>\n"); | ||
| 314 | $s->print("</html>\n"); | ||
| 315 | |||
| 316 | } | ||
| 317 | |||
| 318 | |||
| 319 | |||
| 320 | |||
| 321 | |||
| 322 | sub search { # search screen | ||
| 323 | my $s =shift; | ||
| 324 | my $p =$s->parent; | ||
| 325 | my $g =$p->cgi; | ||
| 326 | $p->print->htpgstart(undef, {-class=>'PaneList'}); | ||
| 327 | $p->print->startform(-action=>$s->qurl, -class=>'PaneList'); | ||
| 328 | $p->print->hidden('_run' =>'SEARCH'); | ||
| 329 | $s->print('<table width="100%" class="PaneList"><tr><td>'); | ||
| 330 | $s->print->h1($s->lng(0, 'Search')); | ||
| 331 | $s->print('</td><td align="left" valign="bottom">') | ||
| 332 | ->text($s->lng(1, 'Search', $s->parent->surl)); | ||
| 333 | $s->print('</td>'); | ||
| 334 | $s->print('</tr></table>'); | ||
| 335 | $s->print->htmltextfield(-name=>'query', -asize=>70, -class=>'PaneList') | ||
| 336 | ->submit(-name =>'search', -class=>'PaneList' | ||
| 337 | ,-value=>$s->lng(0, 'Search') | ||
| 338 | ,-title=>$s->lng(1, 'Search')) | ||
| 339 | ->br; | ||
| 340 | $s->print->popup_menu(-name=>'querysort', -class=>'PaneList' | ||
| 341 | ,-values=>['write','hitcount','vpath','docauthor'] | ||
| 342 | ,-labels=>{'write' =>'Chronologically' | ||
| 343 | ,'hitcount' =>'Ranked' | ||
| 344 | ,'vpath' =>'by Name' | ||
| 345 | ,'docauthor'=>'by Author' | ||
| 346 | } | ||
| 347 | ,-default=>'write'); | ||
| 348 | $s->print->popup_menu(-name=>'querymarg', -class=>'PaneList' | ||
| 349 | ,-values=>[128,256,512,1024,2048] | ||
| 350 | ,-labels=>{128 =>'128 max' | ||
| 351 | ,256 =>'256 max' | ||
| 352 | ,512 =>'512 max' | ||
| 353 | ,1024=>'1024 max' | ||
| 354 | ,2048=>'2048 max' | ||
| 355 | } | ||
| 356 | ,-default=>256); | ||
| 357 | # $s->print->a({-href=> | ||
| 358 | # -e ($ENV{windir} .'/help/ix/htm/ixqrylan.htm') | ||
| 359 | # ? '/help/microsoft/windows/ix/htm/ixqrylan.htm' | ||
| 360 | # : '/help/microsoft/windows/isconcepts.chm' # .'::/ismain-concepts_30.htm' | ||
| 361 | # }, '?') | ||
| 362 | # if $s->{-searchms} && $^O eq 'MSWin32'; | ||
| 363 | |||
| 364 | $p->print->endform->text("\n"); | ||
| 365 | |||
| 366 | if (defined($s->qparam('query')) && $s->qparam('query') ne '') { | ||
| 367 | if ($s->{-searchms} && $^O eq 'MSWin32' && ($ENV{SERVER_SOFTWARE}||'') =~/IIS/) { | ||
| 368 | # Search MSDN for 'ixsso.Query'; See also: | ||
| 369 | # Q248187 "HOWTO: Impersonate a User from Active Server Pages" | ||
| 370 | # advapi32.dll: LogonUser, ImpersonateLoggedOnUser, ImpersonateSelf(int4(2)), RevertToSelf | ||
| 371 | # 'Platform SDK: Security': 'Client/Server Access Control Functions' | ||
| 372 | # "Replace a process level token" right | ||
| 373 | if ($p->url !~/\/_*(login|auth|a|ntlm|search|guest)\//i | ||
| 374 | && !$ENV{REMOTE_USER}) { | ||
| 375 | $p->print->h1('Authentication required') | ||
| 376 | } elsif ($p->{-cache}->{-RevertToSelf}) { | ||
| 377 | $p->print->h1('Impersonation required') | ||
| 378 | } else { | ||
| 379 | eval('use Win32::OLE; Win32::OLE->Option("Warn"=>0)'); | ||
| 380 | my $oq =Win32::OLE->CreateObject("ixsso.Query"); | ||
| 381 | my $ou =Win32::OLE->CreateObject("ixsso.util"); | ||
| 382 | my $qs =[]; | ||
| 383 | my $qt =[]; | ||
| 384 | $oq->{Query} =$s->qparam('query') =~/^(@\w|\{\s*prop\s+name\s+=)/i | ||
| 385 | ? $s->qparam('query') | ||
| 386 | : ('@contents ' .$s->qparam('query')); | ||
| 387 | $oq->{Catalog} ='Web'; | ||
| 388 | $oq->{MaxRecords} =$p->qparam('querymarg') ||256; | ||
| 389 | $oq->{MaxRecords} =4096 if $oq->{MaxRecords} >4096; | ||
| 390 | $oq->{SortBy} =$p->qparam('querysort') ||'write'; | ||
| 391 | $oq->{SortBy} .=$oq->{SortBy} =~/^(write|hitcount)$/i | ||
| 392 | ? '[d],docauthor[a]' : '[a],write[d]'; | ||
| 393 | $oq->{Columns} ='vpath,path,filename,hitcount,write,doctitle,docauthor,characterization'; | ||
| 394 | $oq->{LocaleID} =1049 if $p->lngname =~/ru/i; | ||
| 395 | push @$qs, $p->fpath | ||
| 396 | if $p->fpath && ($p->fpath ne $p->ppath); | ||
| 397 | push @$qs, $p->ppath | ||
| 398 | if !(grep {$p->ppath eq $_} ($ENV{PATH_TRANSLATED}, '.')); | ||
| 399 | push @$qs, $s->{-uspath} | ||
| 400 | if $s->{-uspath} ||($s->{-usurl} && $s->_usdflt); | ||
| 401 | foreach my $e (@$qs) { | ||
| 402 | push @$qt, [$e =~/^(.+?)[\\\/][^\\\/]+$/ ? $1 : $e, ''] | ||
| 403 | } | ||
| 404 | foreach my $e ('c:', 'd:') { | ||
| 405 | push @$qt, [$e => ''] if !grep {lc($_->[0]) eq $e} @$qt | ||
| 406 | } | ||
| 407 | foreach my $e ($p->furl, $s->{-usurl}, $p->purl) { | ||
| 408 | next if !$e; | ||
| 409 | if ($e =~/^\w{3,5}\:\/\/[^\/]+(.*)$/) {$e =$1}; | ||
| 410 | push @$qs, $e if $e; | ||
| 411 | } | ||
| 412 | |||
| 413 | &{$s->{-searchms}}($s, $oq, $ou, $qs, $qt) if ref($s->{-searchms}); | ||
| 414 | $qs =[]; # !!! | ||
| 415 | foreach my $e (@$qs) { # optional, to narrow search | ||
| 416 | $e =~s/\//\\/g if $e !~/^[\\\/]/; | ||
| 417 | $ou->AddScopeToQuery($oq, $e, 'deep') | ||
| 418 | } | ||
| 419 | |||
| 420 | $p->pushmsg(map {$_ . ' = ' .(!defined($oq->{$_}) ? 'null' | ||
| 421 | : $oq->{$_} =~/\D/ ? '\'' . $oq->{$_} .'\'' | ||
| 422 | : $oq->{$_})} | ||
| 423 | qw (Catalog Query MaxRecords SortBy Columns LocaleID)) | ||
| 424 | if ($p->{-debug}||0) >1; | ||
| 425 | $p->pushmsg(map {'AddScopeToQuery = ' .$_} @$qs) | ||
| 426 | if ($p->{-debug}||0) >1; | ||
| 427 | $p->pushmsg(map {'Translate = \'' .$_->[0] .'\' -> \'' .$_->[1] .'\''} @$qt) | ||
| 428 | if ($p->{-debug}||0) >2; | ||
| 429 | |||
| 430 | my $ol =$oq->CreateRecordset('sequential'); # 'nonsequential' | ||
| 431 | |||
| 432 | if ($ol->{EOF}) { | ||
| 433 | $p->print('No records found'); | ||
| 434 | } | ||
| 435 | my ($rcf, $rct, $rcd) =(0, 0, 0); | ||
| 436 | while (!$ol->{EOF}) { | ||
| 437 | my $vp =$ol->{vPath}->{Value}; | ||
| 438 | $rcf +=1; | ||
| 439 | if (!$vp) { | ||
| 440 | $rct +=1; | ||
| 441 | my $rp =$ol->{Path}->{Value}; | ||
| 442 | $rp ='' if !defined($rp); | ||
| 443 | $rp =~s/\\/\//g; | ||
| 444 | foreach my $e (@$qt) { | ||
| 445 | next if !$e->[0] || lc(substr($rp, 0, length($e->[0]))) ne lc($e->[0]); | ||
| 446 | $vp =$e->[1] .substr($rp, length($e->[0])); | ||
| 447 | last; | ||
| 448 | } | ||
| 449 | } | ||
| 450 | if ($vp) { | ||
| 451 | $rcd +=1; | ||
| 452 | my $vt =$p->htmlescape($ol->{DocTitle}->{Value}); | ||
| 453 | $vt = ($vt ? '$vt' .' ' : '') | ||
| 454 | . '(' .$p->htmlescape($ol->{DocAuthor}->{Value}) .')' | ||
| 455 | if $ol->{DocAuthor}->{Value}; | ||
| 456 | $vt = ($vt ? $vt .' (' : '') | ||
| 457 | . $p->htmlescape($vp) .')'; | ||
| 458 | print $g->a({-href=>$vp||$ol->{Path}->{Value} | ||
| 459 | ,-title=>$ol->{HitCount}->{Value} | ||
| 460 | .': ' .$ol->{Path} ->{Value}} | ||
| 461 | , $vt) | ||
| 462 | , $ol->{Characterization}->{Value} | ||
| 463 | ? '<br />' .$p->htmlescape($ol->{Characterization}->{Value}) | ||
| 464 | : '' | ||
| 465 | , "<br /><br />\n" | ||
| 466 | } | ||
| 467 | if (!eval {$ol->MoveNext; 1}) { | ||
| 468 | $p->print('Bad query'); | ||
| 469 | last | ||
| 470 | } | ||
| 471 | } | ||
| 472 | $p->pushmsg("Records fetched = $rcd / found = $rcf, vpathgen = $rct / max = " .($oq->{MaxRecords}||'null') .', user = "' .($ENV{REMOTE_USER}||'Guest') .'" / "' .(eval{Win32::LoginName}||'') .'"'); | ||
| 473 | }} | ||
| 474 | elsif (ref($s->{-search})) { | ||
| 475 | &{$s->{-search}}($s) | ||
| 476 | } | ||
| 477 | } | ||
| 478 | $s->scrbot; | ||
| 479 | $p->print->htpgend; | ||
| 480 | } | ||
| 481 | |||
| 482 | |||
| 483 | |||
| 484 | |||
| 485 | sub _usdflt { # Users Sites Defaults | ||
| 486 | my $s =shift; | ||
| 487 | if (!$s->{-uspath}) { # users sites dir | ||
| 488 | foreach my $d ($^O eq 'MSWin32' | ||
| 489 | ? ('c:/share/users','d:/share/users' | ||
| 490 | ,'c:/share/home','d:/share/home' | ||
| 491 | ,'c:/users','d:/users','c:/home','d:/home') | ||
| 492 | : ('/share/users','/share/home','/users','/home')) { | ||
| 493 | next if !-d $d; | ||
| 494 | $s->{-uspath} =$d; | ||
| 495 | my $dn =($d =~/^(\/|\w:\/)(.+)/ ? $2 : $d); | ||
| 496 | $s->{-usurl} =~s/\$_/$dn/ if $s->{-usurl}; | ||
| 497 | $s->{-usurl} =$s->surl($dn) if !$s->{-usurl}; | ||
| 498 | $s->{-uspurf} =~s/\$_/$dn/ if $s->{-uspurf}; | ||
| 499 | $s->{-uspurl} =~s/\$_/$dn/ if $s->{-uspurl}; | ||
| 500 | last; | ||
| 501 | } | ||
| 502 | } | ||
| 503 | $s->{-usudir} =['users','home',''] # users subdirs | ||
| 504 | if !$s->{-usudir}; | ||
| 505 | $s->{-uspdir} =['pub',''] | ||
| 506 | if !$s->{-uspdir}; # publish subdirs | ||
| 507 | $s->{-uspfile}=['index.url','index.html','index.htm' | ||
| 508 | ,'default.url','default.html','default.htm'] # publish files | ||
| 509 | if !$s->{-uspfile}; | ||
| 510 | $s->{-uspath} | ||
| 511 | } | ||
| 512 | |||
| 513 | |||
| 514 | sub _usjt { # join trim | ||
| 515 | my $r =''; | ||
| 516 | shift if ref($_[0]); | ||
| 517 | foreach my $e (@_) { | ||
| 518 | $r .='/' .$e if $e ne ''; | ||
| 519 | } | ||
| 520 | substr($r,1); | ||
| 521 | } | ||
| 522 | |||
| 523 | |||
| 524 | sub _usdirscn { # Users Sites Collect Dirs | ||
| 525 | my ($s,$o,$d) =@_; # options, subdir | ||
| 526 | my $j; # jump trigger | ||
| 527 | if (!defined($d)) { | ||
| 528 | $s->_usdflt; | ||
| 529 | $s->{-ushref} =[]; | ||
| 530 | $s->{-ushome} =''; | ||
| 531 | $d =''; | ||
| 532 | } | ||
| 533 | $o ='' if !defined($o); | ||
| 534 | my $un=$s->parent->user; | ||
| 535 | if (1) { # publish subdirs & files | ||
| 536 | foreach my $e (@{$s->{-uspdir}}) { | ||
| 537 | $j =1 if $d && $e && -d _usjt($s->{-uspath},$d,$e); | ||
| 538 | foreach my $f (@{$s->{-uspfile}}) { | ||
| 539 | my $n =_usjt($s->{-uspath},$d,$e,$f); | ||
| 540 | next if !-f $n; | ||
| 541 | # $s->print('f: ' .$n .'<br />'); | ||
| 542 | $j =1; | ||
| 543 | my $u =($n =~/\.url$/ ? [$s->fut->fload(-a=>$n)]->[0] | ||
| 544 | : _usjt($d,$e,$f)); | ||
| 545 | push @{$s->{-ushref}}, [$u,$d]; | ||
| 546 | # print ' ', $s->cgi->a({-href => $u =~/^\w{3,5}:\/\// ? $u : ($s->{-usurl} .'/' .$u)}, '.'), ' '; | ||
| 547 | } | ||
| 548 | } | ||
| 549 | } | ||
| 550 | if ($o !~/u/) { # users subdirs | ||
| 551 | foreach my $e (@{$s->{-usudir}}) { | ||
| 552 | next if $e eq ''; | ||
| 553 | next if !-d _usjt($s->{-uspath},$d,$e); | ||
| 554 | $j =1; | ||
| 555 | foreach my $u (eval {sort $s->fut->globn(_usjt($s->{-uspath},$d,$e,'*'))}) { | ||
| 556 | my $n =_usjt($s->{-uspath},$d,$e,$u); | ||
| 557 | # $s->print('u: ' .$n .'<br />'); | ||
| 558 | next if !-d $n; | ||
| 559 | # print ', '; | ||
| 560 | $s->_usdirscn($o .'u',_usjt($d,$e,$u)); | ||
| 561 | return($s->{-ushome}) if $s->{-ushome} && $o =~/!/; | ||
| 562 | if (lc($un) eq lc($u)) { | ||
| 563 | return($s->{-ushome} =_usjt($d,$e,$u)) if $o =~/!/; | ||
| 564 | foreach my $h (@{$s->{-uspdir}}) { | ||
| 565 | next if !-d _usjt($n,$h); | ||
| 566 | $s->{-ushome} =_usjt($d,$e,$u,$h); | ||
| 567 | last | ||
| 568 | } | ||
| 569 | } | ||
| 570 | } | ||
| 571 | } | ||
| 572 | } | ||
| 573 | if (!$j && $o !~/u/) { # scan subdirs | ||
| 574 | my $sub =$s->{-usfirst}; | ||
| 575 | local $_; | ||
| 576 | foreach my $a (0,1) { | ||
| 577 | foreach my $e (eval {sort $s->fut->globn(_usjt($s->{-uspath},$d,'*'))}) { | ||
| 578 | $_ =$e; | ||
| 579 | next if $a ==0 ? ($sub && !&$sub($_)) : (!$sub ||&$sub($_)); | ||
| 580 | my $n =_usjt($s->{-uspath},$d,$e); | ||
| 581 | # $s->print('l: ' .$n .'<br />'); | ||
| 582 | next if !-d $n; | ||
| 583 | # print '. '; | ||
| 584 | $s->_usdirscn($o,_usjt($d,$e)); | ||
| 585 | return($s->{-ushome}) if $s->{-ushome} && $o =~/!/; | ||
| 586 | if (lc($un) eq lc($e)) { | ||
| 587 | return($s->{-ushome} =_usjt($d,$e)) if $o =~/!/; | ||
| 588 | foreach my $h (@{$s->{-uspdir}}) { | ||
| 589 | next if !-d _usjt($n,$h); | ||
| 590 | $s->{-ushome} =_usjt($d,$e,$h); | ||
| 591 | last | ||
| 592 | } | ||
| 593 | } | ||
| 594 | }} | ||
| 595 | } | ||
| 596 | $s->{-ushref}; | ||
| 597 | } | ||
| 598 | |||
| 599 | |||
| 600 | sub uscollect { # Users Sites Collect | ||
| 601 | my $s =shift; | ||
| 602 | $s->_usdflt; | ||
| 603 | my $dc =$s->_usdirscn; | ||
| 604 | my $ds =[]; | ||
| 605 | my $op =''; | ||
| 606 | my $lv =0; | ||
| 607 | my @ops; | ||
| 608 | #print ' /'; | ||
| 609 | my $ug=$s->parent->uglist({}); | ||
| 610 | foreach my $k (keys %$ug) { | ||
| 611 | if ($ug->{$k} =~/^[^,-]+[,-]+ *(.*)/) {$ug->{$k} =$1} | ||
| 612 | $ug->{lc($k)} =$ug->{$k} | ||
| 613 | } | ||
| 614 | #print '/ '; | ||
| 615 | foreach my $r (@$dc) { | ||
| 616 | my ($np, $nu) =($r->[1] =~/^(.*?)[\\\/]*([^\\\/]+)$/ ? ($1,$2) : ('',$r->[1])); | ||
| 617 | if ($np ne $op) { | ||
| 618 | my @nps =split /[\\\/]/, $np; | ||
| 619 | $lv =0; | ||
| 620 | for (my $i =0; $i <scalar(@nps); $i++) { | ||
| 621 | my $tp =join('/',@ops[0..($#ops <$i ? $#ops : $i)]); | ||
| 622 | if (length($tp) >0 && $#ops >=$i && substr($np,0,length($tp)) eq $tp) {} | ||
| 623 | elsif(grep {lc($_) eq lc($nps[$i])} @{$s->{-usudir}}) {} | ||
| 624 | elsif(grep {lc($_) eq lc($nps[$i])} @{$s->{-uspdir}}) {} | ||
| 625 | # elsif($i <$#nps | ||
| 626 | # ||($i !=($#ops +1)) | ||
| 627 | # ||(length($op) >0 && substr($np,0,length($op)) ne $op)) { | ||
| 628 | else { | ||
| 629 | push @$ds, [$lv # nest level | ||
| 630 | ,$nps[$i] # name | ||
| 631 | ,$ug->{$nps[$i]} ||$ug->{lc($nps[$i])} ||$nps[$i] # label | ||
| 632 | ,'' # URL | ||
| 633 | ,'' # fdir | ||
| 634 | ,substr($np,0,length($tp)) #hier | ||
| 635 | ]; | ||
| 636 | # print ' / '; | ||
| 637 | } | ||
| 638 | $lv +=1 | ||
| 639 | } | ||
| 640 | $op =$np; | ||
| 641 | @ops =(@nps,$nu); | ||
| 642 | } | ||
| 643 | else { | ||
| 644 | @ops =((split /[\\\/]/, $np), $nu) | ||
| 645 | } | ||
| 646 | push @$ds, [$lv # nest level | ||
| 647 | ,$nu # name | ||
| 648 | ,$ug->{$nu} ||$ug->{lc($nu)} ||$nu # label | ||
| 649 | # ,$r->[0] =~/^\w{3,5}:\/\// ? $r->[0] : (($s->{-usurl} ||$s->{-uspurl} ||$s->{-uspurf}) .'/' .$r->[0]) | ||
| 650 | ,$r->[0] | ||
| 651 | ,@$r # fdir, hier | ||
| 652 | ]; | ||
| 653 | # print ' . '; | ||
| 654 | } | ||
| 655 | $s->{-ushref} =$ds; | ||
| 656 | } | ||
| 657 | |||
| 658 | |||
| 659 | |||
| 660 | sub scrusites { # Users Sites Display | ||
| 661 | my $s =shift; | ||
| 662 | my $p =$s->parent; | ||
| 663 | my $us=shift; | ||
| 664 | $us =$us ||$p->qparam('USITES') ||''; | ||
| 665 | $us =~s/[^\w\-_\.]/-/gi; | ||
| 666 | my $ha={-align=>'left',-valign=>'top'}; | ||
| 667 | my $hl={-align=>'left',-valign=>'top',-colspan=>10}; | ||
| 668 | my $lv =0; | ||
| 669 | my $lr =2; | ||
| 670 | |||
| 671 | $p->print->htpgstart(undef, {-class=>'PaneList'}); | ||
| 672 | $p->print->startform(-action=>$s->qurl); | ||
| 673 | |||
| 674 | $p->print->hidden('_run' =>'USITES'); | ||
| 675 | $p->print->hidden('USITES' =>$us); | ||
| 676 | $s->_usdflt; | ||
| 677 | local $s->{-uspfile} =[map {m/^(.+?)(\.[^\.]+)$/ ? "$1$us$2" : $_} @{$s->{-uspfile}}] | ||
| 678 | if $us; | ||
| 679 | $p->print->text('<table width="100%"><tr><td>'); | ||
| 680 | $p->print->h1($p->htmlescape($s->lng(0, 'USites') .($us ? " - $us" :''))); | ||
| 681 | #my $tf =$p->fut->mkdir($p->tpath('upws')) ."/usites$us.pl"; | ||
| 682 | my $tf =$p->fut->mkdir($p->dpath('upws')) ."/usites$us.pl"; | ||
| 683 | if (!-f $tf || $p->param('refresh')) { | ||
| 684 | $s->uscollect; | ||
| 685 | $p->fut->fdumpstore($tf, $s->{-ushref}); | ||
| 686 | $p->udata->store('upws_usphome'=>$s->{-ushome}) if !$p->uguest; | ||
| 687 | } | ||
| 688 | else { | ||
| 689 | $s->{-ushref} =$p->fut->fdumpload($tf); | ||
| 690 | $s->{-ushome} =$p->udata->param('upws_usphome'); | ||
| 691 | } | ||
| 692 | $p->print->text('</td>'); | ||
| 693 | $p->print->td({-valign=>'top',-align=>'right'} | ||
| 694 | ,$p->uguest ? '' : | ||
| 695 | ($p->submit(-name=>'refresh', -class=>'PaneList' | ||
| 696 | ,-value=>$s->lng(0, 'Refresh') | ||
| 697 | ,-title=>$s->lng(1, 'Refresh')) | ||
| 698 | .($s->{-ushome} | ||
| 699 | ? ('<br />' | ||
| 700 | .$p->cgi->a({-href=>($s->{-usurl} ||$s->{-uspurf} ||$s->{-uspurl}) | ||
| 701 | .'/' .$s->usohome($s->{-ushome}) | ||
| 702 | }, $s->_img('-usite','USFHomes')) | ||
| 703 | .$p->cgi->a({-href=>($s->{-uspurf} ||$s->{-uspurl} ||$s->{-usurl}) | ||
| 704 | .'/' .$s->usohome($s->{-ushome}) | ||
| 705 | ,-target => '_blank' | ||
| 706 | }, $s->_img('USFHome','USFHomes')) | ||
| 707 | .$p->cgi->a({-href=>($s->{-usurl} ||$s->{-uspurf} ||$s->{-uspurl}) | ||
| 708 | .'/' .$s->{-ushome} | ||
| 709 | }, $s->_img('-usite','USFHome')) | ||
| 710 | .$p->cgi->a({-href=>($s->{-uspurf} ||$s->{-uspurl} ||$s->{-usurl}) | ||
| 711 | .'/' .$s->{-ushome} | ||
| 712 | ,-target => '_blank' | ||
| 713 | }, $s->_img('USFHome') .$s->{-ushome})) | ||
| 714 | : '')) | ||
| 715 | ) | ||
| 716 | ->text('</tr><tr>') | ||
| 717 | ->td($hl,$p->htmlescape($s->lng(1, 'USites', join(', ',@{$s->{-uspfile}})))) | ||
| 718 | ->text('</tr></table>'); | ||
| 719 | |||
| 720 | $p->print->endform; | ||
| 721 | $p->print->text("<table>\n"); | ||
| 722 | foreach my $r (@{$s->{-ushref}}) { | ||
| 723 | $p->print('<tr>'); | ||
| 724 | $p->print('<td> </td>' x $r->[0]); | ||
| 725 | if ($r->[3]) { | ||
| 726 | $p->print->td($hl | ||
| 727 | , '<nobr>' .$p->a({-href=> $r->[3] =~/^\w{3,5}:\/\// | ||
| 728 | ? $r->[3] : ($s->{-usurl} ||$s->{-uspurl} ||$s->{-uspurf}) .'/' .$r->[3]} | ||
| 729 | , $s->_img('-usite','Index') .$p->htmlescape($r->[2])) .'</nobr>'); | ||
| 730 | } | ||
| 731 | else { | ||
| 732 | $p->print->th($hl, '<nobr>' .$s->_img('-udir') .$p->htmlescape($r->[2]) .'</nobr>'); | ||
| 733 | } | ||
| 734 | $p->print('</tr>'); | ||
| 735 | $lv =$r->[0]; | ||
| 736 | } | ||
| 737 | $p->print->text("</table>\n"); | ||
| 738 | $s->scrbot; | ||
| 739 | $p->print->htpgend; | ||
| 740 | } | ||
| 741 | |||
| 742 | |||
| 743 | |||
| 744 | sub usfhome { # User's files home link | ||
| 745 | my $s =shift; | ||
| 746 | my $p =$s->parent; | ||
| 747 | return '' if $p->uguest; | ||
| 748 | my $r =$p->udata->param('upws_usfhome'); | ||
| 749 | if (!defined($r) ||scalar(@_)) { | ||
| 750 | $s->{-ushome} =undef; | ||
| 751 | $s->_usdirscn('!'); | ||
| 752 | $r=$s->{-ushome}; | ||
| 753 | $r='' if !defined($r); | ||
| 754 | $p->udata->store('upws_usfhome'=> $r); | ||
| 755 | } | ||
| 756 | elsif (!$s->{-uspath}) { | ||
| 757 | $s->_usdflt | ||
| 758 | } | ||
| 759 | $r | ||
| 760 | } | ||
| 761 | |||
| 762 | |||
| 763 | sub usohome { # User's office home | ||
| 764 | my ($s,$u) =@_; | ||
| 765 | $u =$s->usfhome if !defined($u); | ||
| 766 | foreach my $e (@{$s->{-usudir}}) { | ||
| 767 | next if !$e || $u !~/^(.+?)[\\\/]\Q$e\E([\\\/][^\\\/]+|)([\\\/][^\\\/]+|)[\\\/]*$/i; | ||
| 768 | return $1 .($3 ||'') | ||
| 769 | } | ||
| 770 | $u ='' | ||
| 771 | } | ||
| 772 | |||
| 773 | |||
| 774 | sub scrsetup { # setup screen | ||
| 775 | my $s =shift; | ||
| 776 | $s->die("Prohibited\n") if $s->uguest; | ||
| 777 | my $g =$s->cgi; | ||
| 778 | my $d =$s->udata->param; | ||
| 779 | my $u0=$s->parent->user; | ||
| 780 | my $un=$g->param('user'); | ||
| 781 | my $ua=$s->parent->uadmin([]); | ||
| 782 | my $aa=$s->parent->uadmin(); | ||
| 783 | my $wr=$g->param('save'); | ||
| 784 | my $rd=!$g->param('_run1') ||$g->param('read'); | ||
| 785 | my $ha={-align=>'left',-valign=>'top'}; | ||
| 786 | my $hd={-align=>'left',-valign=>'top',-colspan=>3}; | ||
| 787 | |||
| 788 | if ($un && $s->parent->uadmin($un)) { | ||
| 789 | $s->parent->set('-cache')->{-user} =$un; | ||
| 790 | $s->udata->load; | ||
| 791 | $d =$s->udata->param; | ||
| 792 | } | ||
| 793 | |||
| 794 | $s->print->htpgstart(undef, $s->parent->hmerge($s->parent->{-htpnstart}, -class=>'PaneForm')); | ||
| 795 | $s->print->startform(-action=>$s->qurl); | ||
| 796 | |||
| 797 | $s->print->hidden('_run' =>'SETUP'); | ||
| 798 | $s->print->hidden('_run1'=>'SETUP'); | ||
| 799 | $s->print('<table width="100%" class="PaneForm"><tr><td>'); | ||
| 800 | $s->print->h1($s->lng(0, 'Setup') .' - ' .$s->parent->user); | ||
| 801 | if (!$aa && !scalar(@$ua)) { | ||
| 802 | $s->print($s->lng(1, 'Setup', $s->parent->user) .'</td>') | ||
| 803 | ->td({-valign=>'top',-align=>'right',-class=>'PaneForm'} | ||
| 804 | ,$g->submit(-name =>'save', -class=>'PaneForm' | ||
| 805 | ,-value=>$s->lng(0, 'Save') | ||
| 806 | ,-title=>$s->lng(1, 'Save'))) | ||
| 807 | } | ||
| 808 | else { | ||
| 809 | $s->print('</td><td align="left" valign="bottom" class="PaneForm">' | ||
| 810 | .$s->lng(1, 'Setup', $s->parent->user) .'</td>'); | ||
| 811 | } | ||
| 812 | $s->print('</tr></table>'); | ||
| 813 | |||
| 814 | foreach my $p (qw(upws_urlh upws_frmrows upws_frmcols upws_usfhome urole)) { | ||
| 815 | if ($wr) {$d->{$p} =$g->param($p)} | ||
| 816 | elsif ($rd) {$g->param($p, defined($d->{$p}) ? $d->{$p} : '')} | ||
| 817 | } | ||
| 818 | if ($wr) { | ||
| 819 | $d->{'upws_urls'} =[split / *\r*\n\r* */, $g->param('upws_urls')]; | ||
| 820 | $d->{'upws_frmurls'} =[split / *\r*\n\r* */, $g->param('upws_frmurls')]; | ||
| 821 | $d->{'uauth_managed'} =[split / *, */, $g->param('uauth_managed')] | ||
| 822 | if $aa; | ||
| 823 | $d->{'uauth_groups'} =[split / *, */, $g->param('uauth_groups')] | ||
| 824 | if $aa && $s->parent->uauth->set('-udata'); | ||
| 825 | } | ||
| 826 | elsif ($rd) { | ||
| 827 | foreach my $p (qw(upws_urls upws_frmurls uauth_managed uauth_groups)) { | ||
| 828 | $g->param($p, '') | ||
| 829 | } | ||
| 830 | $g->param('upws_urls', join("\n", @{$d->{'upws_urls'}})) if $d->{'upws_urls'}; | ||
| 831 | $g->param('upws_frmurls', join("\n", @{$d->{'upws_frmurls'}})) if $d->{'upws_frmurls'}; | ||
| 832 | $g->param('uauth_managed', join(",", @{$d->{'uauth_managed'}})) if $d->{'uauth_managed'} && $aa; | ||
| 833 | $g->param('uauth_groups', join(",", @{$d->{'uauth_groups'}})) if $d->{'uauth_groups'} && $aa; | ||
| 834 | } | ||
| 835 | if ($wr) { | ||
| 836 | $s->udata->store; | ||
| 837 | $s->pushmsg('Data Saved') | ||
| 838 | } | ||
| 839 | elsif ($rd) { | ||
| 840 | $s->pushmsg('Data Loaded') | ||
| 841 | } | ||
| 842 | |||
| 843 | $s->print("<table class=\"PaneForm\">\n"); | ||
| 844 | $s->print('<tr>'); | ||
| 845 | if (scalar(@$ua)) { | ||
| 846 | unshift @$ua, $u0; | ||
| 847 | $s->print->th($ha, $s->lng(0, 'User')); | ||
| 848 | $s->print->td($hd, $g->popup_menu(-name=>'user', -class=>'PaneForm' | ||
| 849 | ,-values=>$ua | ||
| 850 | ,-labels=>$s->uglist({},37) | ||
| 851 | ,-default=>($un||$u0)) | ||
| 852 | . $g->submit(-name=>'read', -class=>'PaneForm' | ||
| 853 | ,-value=>$s->lng(0, 'Read') | ||
| 854 | ,-title=>$s->lng(1, 'Read')) | ||
| 855 | . $g->submit(-name=>'save', -class=>'PaneForm' | ||
| 856 | ,-value=>$s->lng(0, 'Save') | ||
| 857 | ,-title=>$s->lng(1, 'Save'))); | ||
| 858 | $s->print("</tr>\n<tr>"); | ||
| 859 | } | ||
| 860 | if ($aa) { | ||
| 861 | $s->print->th($ha, $s->lng(0, 'Managed')); | ||
| 862 | $s->print->td($hd, $s->htmltextfield(-name=>'uauth_managed', -asize=>70, -class=>'PaneForm') | ||
| 863 | . $s->htmlddlb('',{-name=>'uauth_managed_', -class=>'PaneForm'} | ||
| 864 | ,sub{$_[0]->uglist({})}, ["\tuauth_managed"=>' ']) | ||
| 865 | . $s->_ssfcmt('Managed') | ||
| 866 | ); | ||
| 867 | $s->print("</tr>\n<tr>"); | ||
| 868 | if ($s->parent->uauth->set('-udata')) { | ||
| 869 | $s->print->th($ha, $s->lng(0, 'Groups')); | ||
| 870 | $s->print->td($hd, $s->htmltextfield(-name=>'uauth_groups', -asize=>70, -class=>'PaneForm') | ||
| 871 | . $s->htmlddlb('',{-name=>'uauth_groups_', -class=>'PaneForm'} | ||
| 872 | ,sub{$_[0]->uglist({})}, ["\tuauth_groups"=>' ']) | ||
| 873 | . $s->_ssfcmt('Groups') | ||
| 874 | ); | ||
| 875 | $s->print("</tr>\n<tr>"); | ||
| 876 | } | ||
| 877 | } | ||
| 878 | $s->print->th($ha, $s->lng(0, 'FavoriteURLs')); | ||
| 879 | $s->print->td($hd, $s->htmltextarea(-name=>'upws_urls', -cols=>58, -arows=>4, -wrap=>'off', -class=>'PaneForm') | ||
| 880 | .$s->_ssfcmt('FavoriteURLs')); | ||
| 881 | $s->print("</tr>\n<tr>"); | ||
| 882 | $s->print->th($ha, $s->lng(0, 'HomeURL')); | ||
| 883 | $s->print->td($hd, $s->htmltextfield(-name=>'upws_urlh', -asize=>70, -class=>'PaneForm') | ||
| 884 | .$s->_ssfcmt('HomeURL')); | ||
| 885 | $s->print("</tr>\n<tr>"); | ||
| 886 | $s->print->th($ha, $s->lng(0, 'FramesetURLs')); | ||
| 887 | $s->print->td($hd, $s->htmltextarea(-name=>'upws_frmurls', -cols=>58, -arows=>4, -wrap=>'off', -class=>'PaneForm') | ||
| 888 | .$s->_ssfcmt('FramesetURLs')); | ||
| 889 | $s->print("</tr>\n<tr>"); | ||
| 890 | $s->print->th($ha, '..' .$s->lng(0, 'FramesetRows')); | ||
| 891 | $s->print->td($ha, $s->htmltextfield(-name=>'upws_frmrows', -class=>'PaneForm') | ||
| 892 | .$s->_ssfcmt('FramesetRows')); | ||
| 893 | #$s->print("</tr>\n<tr>"); # -asize=>70 | ||
| 894 | $s->print->th($ha, '..' .$s->lng(0, 'FramesetCols')); | ||
| 895 | $s->print->td($ha, $s->htmltextfield(-name=>'upws_frmcols', -class=>'PaneForm') | ||
| 896 | .$s->_ssfcmt('FramesetCols')); | ||
| 897 | $s->print("</tr>\n<tr>"); | ||
| 898 | |||
| 899 | if ($s->{-uspurf}) { | ||
| 900 | $s->print("</tr>\n<tr>"); | ||
| 901 | $s->print->th($ha, $s->lng(0, 'USFHome')); | ||
| 902 | $s->param('upws_usfhome',$s->usfhome(1)) if $s->param('upws_usfhome_'); | ||
| 903 | $s->print->td($hd, $s->htmltextfield(-name=>'upws_usfhome', -asize=>70, -class=>'PaneForm') | ||
| 904 | .$s->submit(-name=>'upws_usfhome_', -value=>'<-', -title=>$s->lng(1, 'Refresh'), -class=>'PaneForm') | ||
| 905 | .$s->_ssfcmt('USFHome')); | ||
| 906 | } | ||
| 907 | |||
| 908 | $s->print("</tr>\n<tr>"); | ||
| 909 | $s->print->th($ha, $s->lng(0, 'PrimaryRole')); | ||
| 910 | $s->print->td($hd, $s->popup_menu(-name=>'urole', -values=>['',@{$s->ugroups}], -class=>'PaneForm') | ||
| 911 | .$s->_ssfcmt('PrimaryRole')); | ||
| 912 | |||
| 913 | $s->print("</tr>\n<tr>"); | ||
| 914 | $s->print->th($ha, ''); | ||
| 915 | $s->print->td($hd, $g->submit(-name=>'save', -class=>'PaneForm' | ||
| 916 | ,-value=>$s->lng(0, 'Save') | ||
| 917 | ,-title=>$s->lng(1, 'Save'))); | ||
| 918 | $s->print("</tr>\n"); | ||
| 919 | $s->print("</table>\n"); | ||
| 920 | $s->scrbot; | ||
| 921 | $s->print->htpfend; | ||
| 922 | } | ||
| 923 | |||
| 924 | |||
| 925 | sub _ssfcmt { | ||
| 926 | '<span style="font-size: smaller;"><br />' .$_[0]->lng(1, $_[1]) .'</span>' | ||
| 927 | } | ||
| 928 | |||
| 929 | |||
| 930 | sub evaluate { # execute workspace | ||
| 931 | my $s =shift; | ||
| 932 | my $c =$s->qparam('login') ? 'LOGIN' | ||
| 933 | :$s->qparam('logout') ? 'LOGOUT' | ||
| 934 | :$s->qparam('usites') ? 'USITES' | ||
| 935 | :$s->qparam('search') ? 'SEARCH' | ||
| 936 | :$s->qparam('query') ? 'SEARCH' | ||
| 937 | :($s->qrun ||''); | ||
| 938 | $s->userauthopt() if $c ne 'LOGIN'; | ||
| 939 | if ($c eq 'LEFT') { $s->scrleft } | ||
| 940 | elsif ($c eq 'TOPR') { $s->scrtopr } | ||
| 941 | elsif ($c eq 'RIGHT') { $s->scrright } | ||
| 942 | elsif ($c eq 'SETUP') { $s->scrsetup } | ||
| 943 | elsif ($c eq 'LOGIN') { $s->parent->userauth($s->qurl)} | ||
| 944 | elsif ($c eq 'LOGOUT') { $s->parent->uauth->logout($s->qurl)} | ||
| 945 | elsif ($c eq 'USITES') { $s->scrusites} | ||
| 946 | elsif ($c eq 'SEARCH') { $s->search } | ||
| 947 | else { $s->scrtop } | ||
| 948 | } | ||
| 949 | |||
| 950 |