[vhffs-dev] [1056] Ajout de getavatar ?\195?\160 la partie public pour ?\195? \169viter un script not found

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1056
Author:   beuss
Date:     2007-11-01 21:58:32 +0000 (Thu, 01 Nov 2007)

Log Message:
-----------
Ajout de getavatar ?\195?\160 la partie public pour ?\195?\169viter un script not found

Modified Paths:
--------------
    trunk/vhffs-public/Makefile.am

Added Paths:
-----------
    trunk/vhffs-public/getavatar.pl


Modified: trunk/vhffs-public/Makefile.am
===================================================================
--- trunk/vhffs-public/Makefile.am	2007-11-01 17:00:52 UTC (rev 1055)
+++ trunk/vhffs-public/Makefile.am	2007-11-01 21:58:32 UTC (rev 1056)
@@ -5,6 +5,7 @@
 nobase_public_SCRIPTS = \
 	allgroups.pl \
 	allwebsites.pl \
+	getavatar.pl \
 	group.pl \
 	index.pl \
 	lastgroups.pl \

Copied: trunk/vhffs-public/getavatar.pl (from rev 1054, trunk/vhffs-panel/getavatar.pl)
===================================================================
--- trunk/vhffs-public/getavatar.pl	                        (rev 0)
+++ trunk/vhffs-public/getavatar.pl	2007-11-01 21:58:32 UTC (rev 1056)
@@ -0,0 +1,127 @@
+#!%PERL% -w
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+use CGI;
+use GD;
+use GD::Text::Wrap;
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Main;
+use Vhffs::Object;
+use Vhffs::Panel::Avatar;
+
+#Get some basics informations with CGI
+my $cgi;
+my $oid;
+my $code;
+my $vhffs;
+my $gd;
+my $wp;
+my $black;
+my $white;
+my $blue;
+my $path;
+my $buf;
+my $object;
+
+$cgi 		= new CGI;
+$cgi->charset('utf-8');
+$vhffs		= init Vhffs::Main;	
+$oid 		= $cgi->param( "oid" );
+
+$object = Vhffs::Object::get_by_oid( $vhffs , $oid );
+
+$path = Vhffs::Panel::Avatar::exists_avatar( $vhffs , $object );
+
+if( ! ( defined $oid ) )
+{
+	print CGI->header( -type=>"text/html", -charset=>"utf-8" );
+	print "oid error";
+	exit 1;
+}
+
+$gd = GD::Image->new(70,100);
+$white = $gd->colorAllocate(255,255,255);
+$black = $gd->colorAllocate(  0,  0,  0);
+$blue  = $gd->colorAllocate(127,127,255);
+
+#print "No colours: $black ", $gd->colorsTotal, "\n";
+    
+
+# Assume the user has set FONT_PATH or TTF_FONT_PATH
+#$wp->font_path('/usr/share/fonts/ttfonts');
+print CGI->header( -type=>"image/png" );
+
+binmode STDOUT ;
+
+if( $vhffs->get_config->get_panel->{'users_avatars'} ne 'yes' && $vhffs->get_config->get_panel->{'groups_avatars'} ne 'yes' )
+{
+	$wp = GD::Text::Wrap->new($gd,
+		width       => 70,
+		line_space  => 0,
+		color       => $black, 
+		text        => "This platform does not support avatar",
+	);
+	$wp->set_font(gdLargeFont, 14);
+	$wp->set(align => 'center');
+	$wp->draw(0,5);
+	$wp->set(para_space => 10, preserve_nl => 0);
+	print STDOUT $gd->png();
+}
+else
+{
+	if( defined $path )
+	{
+		open FORIG , "$path";
+		while( read( FORIG , $buf , 1024 ) )
+		{
+			print STDOUT $buf;
+		}
+		close( FORIG );
+	}
+	else
+	{
+		$wp = GD::Text::Wrap->new($gd,
+			width       => 70,
+			line_space  => 0,
+			color       => $black, 
+			text        => "No avatar",
+		);
+		$wp->set_font(gdLargeFont, 14);
+		$wp->set(align => 'center');
+		$wp->draw(0,5);
+		$wp->set(para_space => 10, preserve_nl => 0);
+		print STDOUT $gd->png();
+	}
+}
+
+close STDOUT;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/