<?php
// www.bcoos.net 2006-09 1.0.2 GPL
##################################################################################
# Friend Finder for e-xoops  Version 3.02 beta                                 #
#                                                                                #
# Script design  : PhpMeet  :   Copyright 2002 Jeremy Ross-webmaster@phprank.com #
# Created 15/01/02              Last Modified 15/01/02                           #
# Scripts Home              :   http://www.jrscripts.com                         #
#                                                                                #
# Xoops-RC2 French Version  :   jokerman@free.fr                                 #
# Web Home                     :   http://www.webetfric.com                      #
#                                                                                #
# Xoops-RC2 English Version :          Neon@neon.qldgamers.com                   #
# Web Home                  :   http://neon.qldgamers.com                        #
#                                                                                #
#                 Redesigned and new improvemends by                             #
#        eagle81 Manuel Caballero       Manuel@dancepartner.net                  #
#                    http://www.dancepartner.net                                 #
#                             2002-09-12                                         #
##################################################################################
// ORIGINAL FILE INFO
include_once("../../mainfile.php");
include_once(XOOPS_ROOT_PATH."/header.php");
include_once(XOOPS_ROOT_PATH."/modules/friendfinder/header.php");
include_once(XOOPS_ROOT_PATH."/modules/friendfinder/cache/config.php");
include_once(XOOPS_ROOT_PATH."/class/upload.class.php");
global $dateformat, $autoactive, $imagesize, $heightunit, $weightunit, $XoopsTheme,$db;
$xoopsOption['show_rblock'] =1;
$username=$xoopsUser->uname("E");
        OpenTable();
//************************************************************
$sql = "SELECT * FROM ".$db->prefix("friendfinder")." WHERE user = '$username'";
$result = $db->query($sql);
while ($i = $db->fetchArray($result))
 {
$imgname = $i[imgname];
$imgtime = $i[imgtime];
$id = $i[id];
$img = $i[pic];
}
if ($page == update) {
if ( !empty($_FILES['image']['name']) ) {
	$upload = new Upload();
	$upload->setAllowedMimeTypes(".gif|.jpg|.jpeg|.png");
	$upload->setUploadPath(XOOPS_ROOT_PATH."/modules/friendfinder/members/uploads");
	$upload->setDestinationFileName("image");
	$upload->setFileName($xoopsUser->uid());
	$result = $upload->doUpload();
	
	if ($result) {
		$pic = $upload->FileName.".".$upload->getFileExtension();
	} else {
		$errors = $upload->getUploadErrors();
		$errorstring = "";
		$errorstring .= "<strong>::Errors occured::</strong><br />\n";
		while(list($filename,$values) = each($errors)) {
			$errorstring .= "File: " . $filename . "<br />";
			$count = count($values);
			for($i=0; $i<$count; $i++) { $errorstring .= "==>" . $values[$i] . "<br />"; }
		}
		redirect_header("index.php", 3, $errorstring);
		exit();
	}
}
$sql2 = "UPDATE ".$db->prefix("friendfinder")." SET imgtime='$time', imgname='$file1_name', pic='$pic' WHERE user = '$username'";
$db->query($sql2);
redirect_header("index.php",4,_TEXTUPLOADSUCCESS."");
} else {
echo "<center>"._TEXTPICCURRENT."<br><img src='members/uploads/$img' border=0><br><br></center>";
echo "<center><form action=pic.php?page=update&username=$username method=post enctype='multipart/form-data'>
Foto:";
$upload = new Upload();
$upload->printFormField("image");
echo"<input type=submit class=\"button\" value=\""._TEXTPICBUTTON."\"></form></center>";
}
include_once "admin/foot.php";
//************************************************************
        CloseTable();
include_once("../../footer.php");
?>
