~ubuntu-branches/ubuntu/wily/torrus/wily-proposed

« back to all changes in this revision

Viewing changes to perllib/Torrus/Renderer.pm

  • Committer: Package Import Robot
  • Author(s): Marc Haber
  • Date: 2011-11-06 17:15:40 UTC
  • mto: (6.1.1 experimental) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: package-import@ubuntu.com-20111106171540-myc0auwqqio8bmhl
Tags: upstream-2.01
ImportĀ upstreamĀ versionĀ 2.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#  Copyright (C) 2002  Stanislav Sinyagin
 
1
#  Copyright (C) 2002-2011  Stanislav Sinyagin
2
2
#
3
3
#  This program is free software; you can redistribute it and/or modify
4
4
#  it under the terms of the GNU General Public License as published by
14
14
#  along with this program; if not, write to the Free Software
15
15
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
16
16
 
17
 
# $Id: Renderer.pm,v 1.10 2007/04/18 16:05:19 ssinyagin Exp $
18
17
# Stanislav Sinyagin <ssinyagin@yahoo.com>
19
18
 
20
19
package Torrus::Renderer;
31
30
 
32
31
use Torrus::Renderer::HTML;
33
32
use Torrus::Renderer::RRDtool;
 
33
use Torrus::Renderer::Frontpage;
 
34
use Torrus::Renderer::AdmInfo;
 
35
use Torrus::Renderer::RPC;
34
36
 
35
37
# Inherit methods from these modules
36
38
use base qw(Torrus::Renderer::HTML
37
39
            Torrus::Renderer::RRDtool
38
40
            Torrus::Renderer::Frontpage
39
 
            Torrus::Renderer::AdmInfo);
 
41
            Torrus::Renderer::AdmInfo
 
42
            Torrus::Renderer::RPC);
40
43
 
41
44
sub new
42
45
{
234
237
 
235
238
    Debug('Clearing renderer cache');
236
239
    my $cursor = $self->{'db'}->cursor( -Write => 1 );
 
240
    sleep(1);
237
241
    while( my ($key, $val) = $self->{'db'}->next( $cursor ) )
238
242
    {
239
243
        my($t_render, $t_expires, $filename, $mime_type) =  split(':', $val);
241
245
        unlink $Torrus::Global::cacheDir.'/'.$filename;
242
246
        $self->{'db'}->c_del( $cursor );
243
247
    }
244
 
    undef $cursor;
 
248
    $self->{'db'}->c_close($cursor);
245
249
    Debug('Renderer cache cleared');
246
250
}
247
251
 
256
260
{
257
261
    my( $txt )= @_;
258
262
 
 
263
    # Remove spaces in the head and tail.
 
264
    $txt =~ s/^\s+//om;
 
265
    $txt =~ s/\s+$//om;
 
266
 
259
267
    # Unscreen special characters
260
 
    $txt =~ s/{COLON}/:/gm;
261
 
    $txt =~ s/{SEMICOL}/;/gm;
262
 
    $txt =~ s/{PERCENT}/%/gm;
 
268
    $txt =~ s/{COLON}/:/ogm;
 
269
    $txt =~ s/{SEMICOL}/;/ogm;
 
270
    $txt =~ s/{PERCENT}/%/ogm;
263
271
 
264
 
    $txt =~ s/\&/\&amp\;/gm;
265
 
    $txt =~ s/\</\&lt\;/gm;
266
 
    $txt =~ s/\>/\&gt\;/gm;
267
 
    $txt =~ s/\'/\&apos\;/gm;
268
 
    $txt =~ s/\"/\&quot\;/gm;
 
272
    $txt =~ s/\&/\&amp\;/ogm;
 
273
    $txt =~ s/\</\&lt\;/ogm;
 
274
    $txt =~ s/\>/\&gt\;/ogm;
 
275
    $txt =~ s/\'/\&apos\;/ogm;
 
276
    $txt =~ s/\"/\&quot\;/ogm;
269
277
 
270
278
    return $txt;
271
279
}