Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Server problem for print function (Read 5383 times)
Dandello
Forum Administrator
*****
Offline


I love YaBB 2.7!

Posts: 1759
Location: The Land of YaBB
Joined: Feb 12th, 2014
Gender: Female
Re: Server problem for print function
Reply #9 - Nov 22nd, 2014 at 5:50am
Print Post  
Switching the 'open window' command to javascript should solve most of the problem with bots and blocking guest access via the mod will help. (And I'll get onto adding the permissions section for the other print function soon.)
  

Perfection is not possible. Excellence, however, is excellent.
Back to top
WWW  
IP Logged
 
Red Barchetta
New Member
*
Offline



Posts: 46
Location: Miami, FL. USA
Joined: Oct 4th, 2014
Gender: Male
Re: Server problem for print function
Reply #8 - Nov 22nd, 2014 at 1:15am
Print Post  
Just a quick note, but remember that IIS does not use .htaccess, so it will have no effect when YABB is running on a Windows IIS server.
  

Florida Classics and Muscle Car Automotive Forum Administrator
Back to top
WWW  
IP Logged
 
Dandello
Forum Administrator
*****
Offline


I love YaBB 2.7!

Posts: 1759
Location: The Land of YaBB
Joined: Feb 12th, 2014
Gender: Female
Re: Server problem for print function
Reply #7 - Nov 13th, 2014 at 11:31pm
Print Post  
Some experimental fixes:

In Languages/English/Main.lng add just above the 1; at the bottom
Code (Perl)
Select All
$maintxt{'printpage'} = 'Print this page'; 



In Sources/Display.pm find:
Code (Perl)
Select All
    $template_print =
qq~$menusep<a href="$scripturl?action=print;num=$viewnum" target="_blank">$img{'print'}</a>~;
 


replace with
Code (Perl)
Select All
    $template_print =
qq~$menusep<a indow'))">$img{'print'}</a>~;
 



Find:
Code (Perl)
Select All
            $template_print_post =
qq~$menusep<a href="$scripturl?action=print;num=$viewnum;post=$postnum" target="_blank">$img{'printp'}</a>~;
 


Replace with:
Code (Perl)
Select All
                $template_print_post =
qq~$menusep<a stnum','printwindow'))">$img{'printp'}</a>~; 



In Sources/InstantMessage.pm find:
Code (Perl)
Select All
    $showIM_link .= qq~
            $menusep<a href="$scripturl?action=imprint;caller=$INFO{'caller'};id=$messageid" target="_blank">$img{'print_im'}</a>
        ~;
 


Replace with:
Code (Perl)
Select All
    $showIM_link .= qq~
            $menusep<a r'};id=$messageid','printwindow'))">$img{'print_im'}</a>
        ~; 



In Sources/Printpage.pm find
Code (Perl)
Select All
function printPage() {
    if (window.print) {
        agree = confirm('$maintxt{773}');
        if (agree) window.print();
    }
}
 


Remove it. (twice)
Find
Code (HTML)
Select All
<body onload="printPage()"> 


Replace with
Code (HTML)
Select All
<body> 

(twice)

Find:
Code (Perl)
Select All
</table>
<br />~;

    $output .= qq~ 


Replace with:
Code (Perl)
Select All
</table>
<form><p style="text-align:center"><input type="button" value=" $maintxt{'printpage'} " onclick="window.print();" /></p></form>
~;

    $output .= qq~ 



Find:
Code (Perl)
Select All
<br />~;
    }

    $output .= qq~ 


Replace with:
Code (Perl)
Select All
<br />
~;
    }

    $output .= qq~
<form><p style="text-align:center"><input type="button" value=" $maintxt{'printpage'} " onclick="window.print();" /></p></form>
 



These changes use javascript to create the 'printable window' and also uses a button to call the actual print function. (One of the things I'm pretty sure was happening was the server was waiting for a browser response on a function that was automatically loaded but a bot couldn't respond to - and so long as it was waiting, CPU resources were being eaten up.)

I would like to have the printable window autoclose after printing but the 'window.close' function doesn't work properly in Chrome/Safari.
  

Perfection is not possible. Excellence, however, is excellent.
Back to top
WWW  
IP Logged
 
Dandello
Forum Administrator
*****
Offline


I love YaBB 2.7!

Posts: 1759
Location: The Land of YaBB
Joined: Feb 12th, 2014
Gender: Female
Re: Server problem for print function
Reply #6 - Nov 13th, 2014 at 8:13pm
Print Post  
Okay - the actual Print function is javascript. BUT, calling the printable page generates a new page which has to be closed by hand even after the print job has finished.

So I see a couple of problems - one is that the page can be generated by bots and the other is that it doesn't close when the print job is done.
  

Perfection is not possible. Excellence, however, is excellent.
Back to top
WWW  
IP Logged
 
Dandello
Forum Administrator
*****
Offline


I love YaBB 2.7!

Posts: 1759
Location: The Land of YaBB
Joined: Feb 12th, 2014
Gender: Female
Re: Server problem for print function
Reply #5 - Nov 13th, 2014 at 6:53pm
Print Post  
Okay - so we also need a method of detecting if there's a printer or have a timeout on the process (or javascript intercept of some nature ).

I should have the Print Post permissions ready in a few hours as well.
  

Perfection is not possible. Excellence, however, is excellent.
Back to top
WWW  
IP Logged
 
pyragony54
God Member
*****
Offline


I Love YaBB!

Posts: 664
Location: Йошкар-Ола
Joined: May 25th, 2014
Gender: Male
Re: Server problem for print function
Reply #4 - Nov 13th, 2014 at 6:33pm
Print Post  
Yes, but that will not stop the problem. The CPU then sends continuously the printer information and that makes them until a message comes from the printer. Eventually increases the load on the CPU to 100%. It then helps only a restart of Apache and I'm sometimes up to 10 times a day.
  

Bad manners keep people but the only reason for a kind of privilege, because no skin them on the mouth.
Back to top
 
IP Logged
 
Dandello
Forum Administrator
*****
Offline


I love YaBB 2.7!

Posts: 1759
Location: The Land of YaBB
Joined: Feb 12th, 2014
Gender: Female
Re: Server problem for print function
Reply #3 - Nov 13th, 2014 at 4:07pm
Print Post  
I'm in the process of fine-tuning the code for disabling Print Post. Print Topic has been part of YaBB for a long time but Print Post is a newer function and I can see bots hammering at all the links in a topic. And it's not just that they're opening hundreds of pages - they're also hammering the ErrorLog when those pages throw errors.

Adding the additional ErrorLog Security will help block the fast repeat offenders using .htaccess to stop them before they hit the cgi-bin. (It's a "three strikes you're out" mechanism - 3 errors in an inhumanly fast time and the IP gets blocked.)
  

Perfection is not possible. Excellence, however, is excellent.
Back to top
WWW  
IP Logged
 
pyragony54
God Member
*****
Offline


I Love YaBB!

Posts: 664
Location: Йошкар-Ола
Joined: May 25th, 2014
Gender: Male
Re: Server problem for print function
Reply #2 - Nov 13th, 2014 at 2:54pm
Print Post  
thank Dandello. I'm going tonight with the night express from northern Germany to southern Germany. Look at me then tomorrow morning. Could help. It is important that you can turn off the print function for guests. 

I think I will not be there the only one who could have the problem.

My house is almost finished and in two to three weeks, I have more time for YaBB.
  

Bad manners keep people but the only reason for a kind of privilege, because no skin them on the mouth.
Back to top
 
IP Logged
 
Dandello
Forum Administrator
*****
Offline


I love YaBB 2.7!

Posts: 1759
Location: The Land of YaBB
Joined: Feb 12th, 2014
Gender: Female
Re: Server problem for print function
Reply #1 - Nov 13th, 2014 at 5:14am
Print Post  
I suggest you add ErrorLog Security to block the repeat offenders.

I'll look at creating some Admin print options - like members only and/or disabling Print Post.
  

Perfection is not possible. Excellence, however, is excellent.
Back to top
WWW  
IP Logged
 
pyragony54
God Member
*****
Offline


I Love YaBB!

Posts: 664
Location: Йошкар-Ола
Joined: May 25th, 2014
Gender: Male
Server problem for print function
Nov 13th, 2014 at 3:48am
Print Post  
I think the pictures say it all already. Our server operator has already threatened with dismissal. Our CPU usage constantly increased to 100% and we had no explanation why. In the early versions YaBB this was not the case. After a few days of observation, I had the declaration by constantly monitoring and comparing the error log. It is the print function. Somehow spambots press the Print function and a few hundred times in a row and within seconds. This drives the CPU utilization on the top. They also automatically falls not decrease even if the spammer disappears. I have only then restart Apache.

The print function must be revised fastest and brooks no delay. Well, it would also be able to disable this feature in the Admin Center.
  

Bild2_010.jpg (Attachment deleted | 37 Downloads )
Bild4_001.jpg (Attachment deleted | 36 Downloads )

Bad manners keep people but the only reason for a kind of privilege, because no skin them on the mouth.
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint