From 29d83f0af0567bcb17da4ce9fe44b32f19405f68 Mon Sep 17 00:00:00 2001 From: cookie Date: Fri, 15 Dec 2006 22:52:56 +0000 Subject: [PATCH] user koennen eigene bilder hochladen git-svn-id: svn://svn.cccv.de/engel-system@211 29ba0400-6e00-0410-a75a-ca02368028f8 --- DB/change_db_to_v211.sql | 18 ++++ www-ssl/inc/ShowUserPicture.php | 3 +- www-ssl/inc/funktion_user.php | 37 ++++++-- www-ssl/nonpublic/einstellungen.php | 128 +++++++++++++++++++++------- 4 files changed, 146 insertions(+), 40 deletions(-) create mode 100644 DB/change_db_to_v211.sql diff --git a/DB/change_db_to_v211.sql b/DB/change_db_to_v211.sql new file mode 100644 index 00000000..bee3cd9e --- /dev/null +++ b/DB/change_db_to_v211.sql @@ -0,0 +1,18 @@ +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_PictureNoShow', 'DE', 'Das Foto ist nicht freigegeben'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_PictureNoShow', 'EN', 'The photo isnot free at the moment'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_PictureShow', 'DE', 'Das Foto ist freigegeben'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_PictureShow', 'EN', 'The photo is free at the moment'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('delete', 'DE', 'löschen'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('delete', 'EN', 'delete'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_del_OK', 'DE', 'Bild wurde erfolgreich gelöscht.'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_del_OK', 'EN', 'Picture was deleted successfully.'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_del_KO', 'DE', 'Bild wurde nicht erfolgreich gelöscht.'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_del_KO', 'EN', 'Picture was not deleted successfully.'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('upload', 'DE', 'hochladen'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('upload', 'EN', 'upload'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_send_OK', 'DE', 'Die Datei wurde erfolgreich hochgeladen.'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_send_OK', 'EN', 'The file was uploaded successfully'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_send_KO', 'DE', 'Beim Hochladen ist ein Fehler aufgetreten.'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_send_KO', 'EN', 'An error was detected. Please try again!'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_PictureUpload', 'DE', 'Hier kannst Du ein Foto von Dir hochladen!'); +INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('pub_einstellungen_PictureUpload', 'EN', 'Feel free to upload a picture of yourself.'); diff --git a/www-ssl/inc/ShowUserPicture.php b/www-ssl/inc/ShowUserPicture.php index 218b2a24..f8185c3e 100644 --- a/www-ssl/inc/ShowUserPicture.php +++ b/www-ssl/inc/ShowUserPicture.php @@ -22,8 +22,9 @@ if( mysql_num_rows($res) == 1) header( "HTTP/1.0 403 Forbidden"); die( "403 Forbidden"); } + // ist das bild sichtbar? - if( mysql_result($res, 0, "show")=="N" ) + if( (mysql_result($res, 0, "show")=="N") AND ($_SESSION['UID']!=$_GET["UID"]) ) { $SQL= "SELECT * FROM `UserPicture` WHERE `UID`='-1'"; $res = mysql_query( $SQL, $con); diff --git a/www-ssl/inc/funktion_user.php b/www-ssl/inc/funktion_user.php index 9a1433fd..ac8744cf 100755 --- a/www-ssl/inc/funktion_user.php +++ b/www-ssl/inc/funktion_user.php @@ -58,21 +58,40 @@ function ReplaceSmilies($eckig) { } +function GetPicturShow($UID) +{ + global $con; + + $SQL= "SELECT `show` FROM `UserPicture` WHERE `UID`='$UID'"; + $res = mysql_query( $SQL, $con); + if( mysql_num_rows($res) == 1) + return mysql_result( $res, 0, 0); + else + return ""; +} + + /* Parameter: [] */ -function displayavatar($UID, $height="30") +function displayPictur($UID, $height="30") +{ + if( $height > 0) + return( "\"picture"); + else + return( "\"picture"); +} + + +/* Parameter: + + [] */ +function displayavatar( $UID, $height="30") { global $con; - // ist ein foto hinterlegt? - $SQL= "SELECT * FROM `UserPicture` WHERE `UID`='$UID' AND `show`='Y'"; - $res = mysql_query( $SQL, $con); - if( mysql_num_rows($res) == 1) - if( $height > 0) - return( " \"picture"); - else - return( " \"picture"); + if( GetPicturShow($UID) == 'Y') + return " ". displayPictur( $UID, $height); // show avator $asql = "select * from User where UID = $UID"; diff --git a/www-ssl/nonpublic/einstellungen.php b/www-ssl/nonpublic/einstellungen.php index eaec09fb..5e94dbb4 100755 --- a/www-ssl/nonpublic/einstellungen.php +++ b/www-ssl/nonpublic/einstellungen.php @@ -3,6 +3,7 @@ $title = "Himmel"; $header = "Deine persönlichen Einstellungen"; include ("./inc/header.php"); include ("./inc/crypt.php"); +include ("./inc/funktion_user.php"); if (!IsSet($_POST["action"])) { @@ -103,35 +104,60 @@ if (!IsSet($_POST["action"])) "> -
-
-
- -
- - - - - - - - -

-
-    - -
- "> -
+\n
\n
\n\n"; + echo Get_Text('pub_einstellungen_PictureUpload')."
"; + echo "
\n"; + echo "\t\n"; + echo "\t\n"; + echo "\t(max ". get_cfg_var("post_max_size"). "Byte)
\n"; + echo "\t\n"; + echo "
\n"; + } -"; + echo displayPictur($_SESSION['UID'], 0); + echo "
\n"; + echo "\t\n"; + echo "\t\n"; + echo "
\n"; + break; + case 'N': + echo Get_Text('pub_einstellungen_PictureNoShow'). "
"; + echo displayPictur($_SESSION['UID'], 0); + echo "
\n"; + echo "\t\n"; + echo "\t\n"; + echo "
\n"; + echo "
\n
\n
\n\n"; + case '': + echo "
\n
\n
\n\n"; + echo Get_Text(22). "
"; + echo "\n
\n"; + echo "\t\n"; + echo "\t\n"; + echo "\t\t\n\t\t\t\n\t\t\n"; + echo "\t\t\n"; + echo "\t\t\t\n\t\t\n"; + echo "\t
". Get_Text(23). "
\n"; + echo "\t\t\t\t  \n"; + echo "\t\t\t\t\n"; + echo "\t\t\t
\n"; + echo "\t\n"; + echo "
\n"; + break; + } //CASE } else { @@ -194,11 +220,10 @@ case 'avatar': $chsql="UPDATE `User` SET `Avatar`='". $_POST["eAvatar"]. "' WHERE `UID`='". $_SESSION['UID']. "' LIMIT 1"; $Erg = mysql_query($chsql, $con); $_SESSION['Avatar']=$_POST["eAvatar"]; - if ($Erg==1) { + if ($Erg==1) Print_Text(34); - } else { + else Print_Text(29); - } break; case 'setUserData': @@ -235,6 +260,49 @@ case 'setUserData': } break; +case 'sendPicture': + if( $_FILES["file"]["size"] > 0) + { + if( ($_FILES["file"]["type"] == "image/jpeg") || + ($_FILES["file"]["type"] == "image/png") || + ($_FILES["file"]["type"] == "image/gif") ) + { + $data = addslashes(fread(fopen($_FILES["file"]["tmp_name"], "r"), filesize($_FILES["file"]["tmp_name"]))); + + if( GetPicturShow( $_SESSION['UID']) == "") + $SQL = "INSERT INTO `UserPicture` ". + "( `UID`,`Bild`, `ContentType`, `show`) ". + "VALUES ('". $_SESSION['UID']. "', '$data', '". $_FILES["file"]["type"]. "', 'N')"; + else + $SQL = "UPDATE `UserPicture` SET ". + "`Bild`='$data', ". + "`ContentType`='". $_FILES["file"]["type"]. "', ". + "`show`='N' ". + "WHERE `UID`='". $_SESSION['UID']. "'"; + + $res = mysql_query( $SQL, $con); + if( $res) + Print_Text("pub_einstellungen_send_OK"); + else + Print_Text("pub_einstellungen_send_KO"); + + echo "
('" . $_FILES["file"]["name"] . "', MIME-Type: " . $_FILES["file"]["type"]. ", " . $_FILES["file"]["size"]. " Byte)
"; + } + else + Print_Text("pub_einstellungen_send_KO"); + } + else + Print_Text("pub_einstellungen_send_KO"); + break; + +case 'delPicture': + $chsql="DELETE FROM `UserPicture` WHERE `UID`='". $_SESSION['UID']. "' LIMIT 1"; + $Erg = mysql_query($chsql, $con); + if ($Erg==1) + Print_Text("pub_einstellungen_del_OK"); + else + Print_Text("pub_einstellungen_del_KO"); + Break; } } include ("./inc/footer.php");