4images Forum & Community
4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: Jan-Hendrik on May 19, 2003, 03:09:19 PM
-
Hello,
i want to use the User ID in "member.php?action=editprofile".
If i add {user_id}, it show only "1".
Please help.
cu
Jan-Hendrik
*sorry for my native english*
---------------------------------------------------------------------------
Hallo,
ich würde gerne die User ID im "member.php?action=editprofile" ausgeben.
Wenn ich {user_id} verwende, steht dort immer eine "1".
Weiss jemand weiter?
cu
Jan-Hendrik
-
what do u mean? do u want to display user_id on the edit profile page?
-
yes, i will add an mod that allow user images in profile,
so i need the {user_id} in edit_profile;
i'll include a link (like: upload_your_picture_now)
...and for that link i need the {user_id}...
(the mod rename all pics to {user_id}.jpg and is running now,
but i can't give the variable {user_id} to the mod)
-
ah meinst du soetwas wie user bild?
-
ja, meine ich... es funzt auch soweit.
hab durch zufall ein script gefunden, das den upload macht und die datei nach beliebiger eingabe unbenennt... so hab ich dann getestet und muss nur noch die user_id an das script übergeben... (bloss da steht nur immer eine 1)... und im profil wird die geschichte dann ganz easy mit {user_id}.jpg ausgelesen...
-
then, u dont even need the {user_id} in the code just take user's id from $user_info['user_id']
in this case u can privent someone send and image with wrong user_id...
-
then, u dont even need the {user_id} in the code just take user's id from $user_info['user_id']
in this case u can privent someone send and image with wrong user_id...
??? not clear for me...
i add "user_id" => $user_info['user_id'],
to where in member.php?
-
no, I mean, for example, when user click at your link, it will open page to upload an image, right?
ok, he chosed the file to upload, pressed upload button.
then, u already have user_id in $user_info['user_id'] variable, no need send it along with the file.
so, in the code, u can load ID like:
$user_id = $user_info['user_id'];
instead of
$user_id = $HTTP_POST_VARS['user_id'];
-
the problem is the script is a third party mod, so i need database accept...
so... can you tell me, how i can include database accept and security valiation to read out user id in the script?
-
ah, IC now.
well, with all details I have about what u are trying to do, I can say just search for $site_template->register_vars
in member.php (u'll find many of them, but u only need one or two, I dont witch ones, because I dont know where exactly do u want it to be showed)
and add
"user_id" => $user_info['user_id'],
-
gib uns mal den code, wo der die user ID hinpacken muss.
-
gib uns mal den code, wo der die user ID hinpacken muss.
Ok, here the code...
include($config);
$language = "$configpath"."/"."$languagefile";
$functions = "$configpath"."/functions.inc.php";
$layout = "$configpath"."/layout.inc.php";
include($functions);
$itypes = gdcheck(&$chk);
if(!$itypes)
{
$scriptaction = "info";
}
if($scriptaction == "modulinfo")
{
phpinfo(8);
$scriptaction = "info";
}
if($gdversion == 0)
{
$scriptaction = "info";
}
$servermaxsize = get_cfg_var("upload_max_filesize");
if(!isset($DEFAULTS) && $standalone)
{
echo "<html>\n <head>\n <title> $title </title>\n $charset\n <link rel=\"STYLESHEET\" type=\"text/css\" href=\""."$configpath"."/script.css\">\n </head>\n <body scroll=\"auto\">";
}
if(!isset($thumbdir) || $thumbdir == "")
{
$thumbdir = "$picdir";
}
$tempfile = "$picdir"."upl_file.tmp.";
$tempthumb = "$thumbdir"."upl_file.tmp"."$nameaddon".".";
if($scriptaction == "")
{
include($language);
include("$layout");
echo $template;
}
elseif($scriptaction == "upload")
{
if($uplfile_name != "")
{
gmfilename($uplfile_name, &$filename, &$extension);
if($extension == jpg && $chk[1] == 1 || $extension == png && $chk[2] == 1 || $extension == gif && $chk[3] == 1)
{
if($newname != "")
{
$filename = "$newname";
}
if(validfilename($filename))
{
if($uplfile_size < $size)
{
$original = "$picdir$filename"."."."$extension";
$thumbnail = "$thumbdir$filename$nameaddon"."."."$extension";
if(!file_exists($original))
{
copy($uplfile, "$original");
copy($uplfile, "$thumbnail");
imgresize("$thumbnail", $extension, $thumbwidth, $thumbheight);
if($resize == 2)
{
imgresize("$original", $extension, $picwidth, $picheight);
}
include($language);
$extended = "<font color=\"#006600\"><b>$msg[17]</b></font><br />";
include("$layout");
echo $template;
echo "<br /><img src=\"$thumbnail\"><br /><img src=\"$original\"><br />";
}
else
{
$tempfile .= $extension;
$tempthumb .= $extension;
copy($uplfile, "$tempfile");
copy($uplfile, "$tempthumb");
$thumbnail = "$thumbdir$filename$nameaddon"."."."$extension";
include($language);
$extended = "<font color=\"#ff0000\"><b>$msg[5]</b></font><br /><br />";
$extended .= "<font class=\"scriptmainfont\">$msg[6]</font>";
include("$layout");
echo $errtemplate;
echo "<font class=\"scriptmainfont\"><br /><br /><b>$msg[51]</b>:<br /></font><img src=\"$tempthumb\">";
}
}
else
{
include($language);
$extended = "<font color=\"#ff0000\"><b>$msg[18]</b></font><br />";
include("$layout");
echo $template;
}
}
else
{
include($language);
$extended = "<font color=\"#ff0000\"><b>$msg[58]</b></font><br />";
include("$layout");
echo $template;
}
}
else
{
include($language);
$extended = "<font color=\"#ff0000\"><b>$msg[19]</b></font><br />";
include("$layout");
echo $template;
}
}
else
{
include($language);
$extended = "<font color=\"#ff0000\"><b>$msg[22]</b></font><br />";
include("$layout");
echo $template;
}
}
elseif($scriptaction == "overwrite")
{
gmfilename($uplfile_name, &$filename, &$extension);
if($new_name != "")
{
$filename = "$new_name";
}
if(validfilename($filename))
{
$original = "$picdir$filename"."."."$extension";
$thumbnail = "$thumbdir$filename$nameaddon"."."."$extension";
$tempfile .= $extension;
$tempthumb .= $extension;
copy($tempfile, "$original");
if(file_exists($tempfile))
{
unlink($tempfile);
}
copy($tempthumb, "$thumbnail");
if(file_exists($tempthumb))
{
unlink($tempthumb);
}
imgresize("$thumbnail", $extension, $thumbwidth, $thumbheight);
if($resize == 2)
{
imgresize("$original", $extension, $picwidth, $picheight);
}
include($language);
$extended = "<font color=\"#006600\"><b>$msg[15]</b></font><br />";
include("$layout");
echo $template;
echo "<br /><img src=\"$thumbnail\"><br /><img src=\"$original\">";
}
else
{
include($language);
$extended = "<font color=\"#ff0000\"><b>$msg[58]</b></font><br />";
include("$layout");
echo $template;
}
}
elseif($scriptaction == "rename")
{
if($newname != "")
{
gmfilename($uplfile_name, &$filename, &$extension);
$tempfile .= $extension;
$tempthumb .= $extension;
if($newname != "")
{
$filename = "$newname";
}
if(validfilename($filename))
{
$original = "$picdir$filename"."."."$extension";
$thumbnail = "$thumbdir$filename$nameaddon"."."."$extension";
if(!file_exists($original))
{
rename($tempfile, $original);
rename($tempthumb, $thumbnail);
imgresize("$thumbnail", $extension, $thumbwidth, $thumbheight);
if($resize == 2)
{
imgresize("$original", $extension, $picwidth, $picheight);
}
include($language);
$extended = "<font color=\"#006600\"><b>$msg[16]</b></font><br />";
include("$layout");
echo $template;
echo "<br /><img src=\"$thumbnail\"><br /><img src=\"$original\">";
}
else
{
include($language);
$extended = "<font color=\"#ff0000\"><b>$msg[5]</b></font><br />";
$extended .= "<font class=\"scriptmainfont\">$msg[6]</font>";
include("$layout");
echo $errtemplate;
echo "<font class=\"scriptmainfont\"><br /><br /><b>$msg[51]: </b>:<br /></font><img src=\"$tempthumb\">";
}
}
else
{
include($language);
$extended = "<font color=\"#ff0000\"><b>$msg[58]</b></font><br />";
include("$layout");
echo $template;
}
}
else
{
gmfilename($uplfile_name, &$filename, &$extension);
include($language);
$extended = "<font color=\"#ff0000\"><b>$msg[20]</b></font><br /><br />";
$extended .= "<font class=\"scriptmainfont\">$msg[6]</font>";
$thumbnail = "$thumbdir$filename$nameaddon"."."."$extension";
include("$layout");
echo $errtemplate;
}
}
elseif($scriptaction == "leave")
{
gmfilename($uplfile_name, &$filename, &$extension);
$tempfile .= $extension;
$tempthumb .= $extension;
if(file_exists($tempfile))
{
unlink($tempfile);
}
if(file_exists($tempthumb))
{
unlink($tempthumb);
}
include($language);
$extended = "<font color=\"#006600\"><b>$msg[14]</b></font><br />";
include("$layout");
echo $template;
}
elseif($scriptaction == "info")
{
include($language);
gdcheckoutput();
}
if(!isset($DEFAULTS) && $standalone != 0)
{
echo "\n\n </body>\n</html>";
}
functions.inc.php
function gmfilename($uplfile_name, $filename, $extension)
{
$f_name = explode(".",$uplfile_name);
$parts = count($f_name);
$last = $parts - 1;
$filename = "$f_name[0]";
if($parts > 2)
{
for($i = 1; $i < $parts - 1; $i++)
{
$filename .= ".$f_name[$i]";
}
}
$extension = strtolower($f_name[$last]);
if(($extension == jpe || $extension == jpg || $extension == jpeg))
{
$extension = "jpg";
}
return(1);
}
function validfilename($filename)
{
$prohib = array("*", "<", ">", ":", ";", "|", "/", "\\", "'", "\"");
$pl = count($prohib);
for($i = 0; $i < $pl; $i++)
{
if(stristr($filename, $prohib[$i]))
{
return(0);
}
}
return(1);
}
function imgresize($sourcefile, $extension, $newx, $newy)
{
global $extension;
global $quality;
global $gdversion;
gdcheck(&$chk);
if($extension == jpg)
{
if(function_exists(imagejpeg) && $chk[1] == 1)
{
$imgptr = imagecreatefromjpeg("$sourcefile");
if($imgptr)
{
imggetsize($imgptr, &$x, &$y);
imgnewsize($x, $y, &$newx, &$newy);
if(function_exists(imagecreatetruecolor) && $gdversion == 2)
{
$destptr = imagecreatetruecolor($newx, $newy);
}
else
{
$destptr = imagecreate($newx, $newy);
}
imagecopyresized($destptr, $imgptr, 0, 0, 0, 0, $newx, $newy, $x, $y);
imagejpeg($destptr, $sourcefile, $quality);
imagedestroy($imgptr);
imagedestroy($destptr);
}
else
{
echo "$msg[53]";
}
}
else
{
echo "$msg[54]";
}
}
elseif($extension == png)
{
if(function_exists(imagepng) && $chk[2] == 1)
{
$imgptr = imagecreatefrompng("$sourcefile");
if($imgptr)
{
imggetsize($imgptr, &$x, &$y);
imgnewsize($x, $y, &$newx, &$newy);
if(function_exists(imagecreatetruecolor) && $gdversion == 2)
{
$destptr = imagecreatetruecolor($newx, $newy);
}
else
{
$destptr = imagecreate($newx, $newy);
}
imagecopyresized($destptr, $imgptr, 0, 0, 0, 0, $newx, $newy, $x, $y);
imagepng($destptr, $sourcefile, $quality);
imagedestroy($imgptr);
imagedestroy($destptr);
}
else
{
echo "$msg[53]";
}
}
else
{
echo "$msg[55]";
}
}
elseif($extension == gif)
{
if(function_exists(imagegif) && $chk[3] == 1)
{
$imgptr = imagecreatefromgif("$sourcefile");
if($imgptr)
{
imggetsize($imgptr, &$x, &$y);
imgnewsize($x, $y, &$newx, &$newy);
if(function_exists(imagecreatetruecolor) && $gdversion == 2)
{
$destptr = imagecreatetruecolor($newx, $newy);
}
else
{
$destptr = imagecreate($newx, $newy);
}
imagecopyresized($destptr, $imgptr, 0, 0, 0, 0, $newx, $newy, $x, $y);
imagegif($destptr, $sourcefile, $quality);
imagedestroy($imgptr);
imagedestroy($destptr);
}
else
{
echo "$msg[53]";
}
}
else
{
echo "$msg[56]";
}
}
else
{
$error = "$msg[57]";
echo "$error";
}
}
function imggetsize($imgptr, $x, $y)
{
$x = imagesx($imgptr);
$y = imagesy($imgptr);
}
function imgnewsize($x, $y, $newx, $newy)
{
global $resizemode;
if($resizemode == 1)
{
if($x > $y)
{
$verh = $x / $y;
$newy = $newx / $verh;
}
else
{
$verh = $y / $x;
$newy = $newx * $verh;
}
}
elseif($resizemode == 2)
{
if($x > $y)
{
$verh = $x / $y;
$newx = $newy * $verh;
}
else
{
$verh = $y / $x;
$newx = $newy / $verh;
}
}
}
function gdcheck($chk)
{
global $gdversion;
if(extension_loaded("gd"))
{
$chk[0] = 1;
if(ImageTypes() & IMG_JPG)
{
$chk[1] = 1;
$itypes = "*.jpe, *.jgeg, *.jpg";
}
else
{
$chk[1] = 0;
}
if(ImageTypes() & IMG_PNG)
{
$chk[2] = 1;
$itypes .= ", *.png";
}
else
{
$chk[2] = 0;
}
if(ImageTypes() & IMG_GIF)
{
$chk[3] = 1;
$itypes .= ", *.gif";
}
else
{
$chk[3] = 0;
}
if(function_exists(imagecreatetruecolor) & $gdversion == 2)
{
$chk[4] = 1;
}
else
{
$chk[4] = 0;
}
}
else
{
$chk[0] = 0;
$chk[1] = 0;
$chk[2] = 0;
$chk[3] = 0;
$chk[4] = 0;
}
return($itypes);
}
function gdcheckoutput()
{
global $servermaxsize, $PHP_SELF, $gdversion, $msg, $size, $color, $scriptaction, $copyright, $htmlstart, $htmlend, $scriptversion;
gdcheck(&$chk);
$maxsize = get_cfg_var("upload_max_filesize");
$phpversion = phpversion();
echo "$htmlstart<font class=\"scriptmainfont\"><table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\" bordercolor=\"$color[0]\" class=\"scriptmainfont\"><tr><td><b> $msg[24]</b><br /> </td><td><b>$msg[41]:</b> $phpversion</td></tr>";
if($gdversion != 0)
{
if($chk[0] == 1)
{
echo "<tr><td>$msg[25] </td><td><font color=\"#006600\"><b>$msg[36]</b></font></td></tr>";
if($gdversion == 1)
{
echo "<tr><td>$msg[40] </td><td><font color=\"#006600\"><b>< 2.0</b></font></td></tr>";
}
elseif($gdversion == 2)
{
echo "<tr><td>$msg[40] </td><td><font color=\"#006600\"><b>>= 2.0</b></font></td></tr>";
}
else
{
echo "<tr><td>$msg[40] </td><td><font color=\"#ff0000\"><b>?</b></font></td></tr>";
}
}
else
{
echo "<tr><td>$msg[25] </td><td><font color=\"#ff0000\"><b>$msg[37]</b></font></td></tr>";
$supporterr .= "<li>$msg[34]</li>";
}
if($chk[1] == 1) // 3.0.7
{
echo "<tr><td>$msg[26] </td><td><font color=\"#006600\"><b>$msg[36]</b></font></td></tr>";
}
else
{
echo "<tr><td>$msg[26] </td><td><font color=\"#ff0000\"><b>$msg[37]</b></font></td></tr>";
}
if($chk[2] == 1)
{
echo "<tr><td>$msg[27] </td><td><font color=\"#006600\"><b>$msg[36]</b></font></td></tr>";
}
else
{
echo "<tr><td>$msg[27] </td><td><font color=\"#ff0000\"><b>$msg[37]</b></font></td></tr>";
}
if($chk[3] == 1)
{
echo "<tr><td>$msg[28] </td><td><font color=\"#006600\"><b>$msg[36]</b></font></td></tr>";
}
else
{
echo "<tr><td>$msg[28] </td><td><font color=\"#ff0000\"><b>$msg[37]</b></font></td></tr>";
}
if($chk[4] == 1)
{
echo "<tr><td>$msg[29] </td><td><font color=\"#006600\"><b>$msg[36]</b></font></td></tr>";
}
else
{
echo "<tr><td>$msg[29] </td><td><font color=\"#ff0000\"><b>$msg[37]</b></font></td></tr>";
}
if(get_cfg_var("file_uploads") == 1)
{
echo "<tr><td>$msg[30] </td><td><font color=\"#006600\"><b>$msg[38]</b></font></td></tr>";
echo "<tr><td>$msg[31] </td><td><font color=\"#006600\"><b>$maxsize</b></font></td></tr>";
echo "<tr><td>$msg[32] </td><td><font color=\"#006600\"><b>$size Bytes</b></font></td></tr>";
}
else
{
echo "<tr><td>$msg[30] </td><td><font color=\"#ff0000\"><b>$msg[39]</b></font></td></tr>";
$supporterr .= "<li>$msg[35]</li>";
}
}
elseif($chk[0] == 1)
{
echo "<tr><td>$msg[25] </td><td><font color=\"#006600\"><b>$msg[36]</b></font></td></tr>";
$gdv = gdversioncheck();
echo "<tr><td>$msg[40] </td><td><font color=\"#006600\"><b>$gdv</b></font></td></tr>";
}
else
{
echo "<tr><td>$msg[25] </td><td><font color=\"#ff0000\"><b>$msg[37]</b></font></td></tr>";
$supporterr .= "<li>$msg[34]</li>";
}
if(get_cfg_var("file_uploads") == 1)
{
echo "<tr><td>$msg[30] </td><td><font color=\"#006600\"><b>$msg[38]</b></font></td></tr>";
echo "<tr><td>$msg[31] </td><td><font color=\"#006600\"><b>$maxsize</b></font></td></tr>";
echo "<tr><td>$msg[32] </td><td><font color=\"#006600\"><b>$size Bytes</b></font></td></tr>";
}
else
{
echo "<tr><td>$msg[30] </td><td><font color=\"#ff0000\"><b>$msg[39]</b></font></td></tr>";
$supporterr .= "<li>$msg[35]</li>";
}
echo "</table><br />";
if(isset($supporterr))
{
echo "<br /><font color=\"#ff0000\"><b>$msg[33]</b></font><ul>$supporterr</ul>";
}
if($gdversion == 0)
{
echo "<br /><b>$msg[42]</b><br /><br />";
if($gdv == ">= 2.0")
{
echo "$msg[43]<br /><ul><li><b>\$gdversion = 2:</b></li></ul>$msg[49]";
}
elseif($gdv == "< 2.0")
{
echo "$msg[43]<br /><ul><li><b>\$gdversion = 1;</b></li></ul>$msg[49]";
}
elseif($msg[50] == "x")
{
echo "$msg[46]<br /><ul><li>$msg[47]</li><li>$msg[48]</li></ul><br />$msg[49]";
}
else
{
echo "$msg[44]<br /><a href=\"$PHP_SELF?&scriptaction=modulinfo&msg[50]=x&#module_gd\" class=\"script\">$msg[45]</a>";
}
}
echo "</font>$htmlend";
}
function gdversioncheck()
{
ob_start();
phpinfo(8);
$infocnt = ob_get_contents();
ob_end_clean();
$infocnt = strip_tags($infocnt);
$infocnt = stristr($infocnt, "gd version");
$infocnt = stristr($infocnt, "version");
$end = strpos($infocnt," ");
$infocnt = substr($infocnt, 0, $end);
$infocnt = substr($infocnt, 7);
//if(version_compare("2.0", "$infocnt") == 1) // Version >= 4.1.0
if(my_version_compare("2.0", "$infocnt") == 1)
{
return("< 2.0");
}
else
{
return(">= 2.0");
}
}
function my_version_compare($vnumb1, $vnumb2)
{
$v_numbers1 = explode(".", $vnumb1);
$numbers1 = count($v_numbers1);
$v_numbers2 = explode(".", $vnumb2);
$numbers2 = count($v_numbers2);
if($numbers1 > $numbers2)
{
$max = $numbers1;
}
else
{
$max = $numbers2;
}
for($i = 0; $i < $max; $i++)
{
if(!isset($v_numbers1[$i]))
{
$v_numbers1[$i] = 0;
}
if(!isset($v_numbers2[$i]))
{
$v_numbers2[$i] = 0;
}
if($v_numbers1[$i] < $v_numbers2[$i])
{
return(-1);
}
elseif($v_numbers1[$i] > $v_numbers2[$i])
{
return(1);
}
elseif($i == ($max - 1) && $v_numbers1[$i] == $v_numbers2[$i])
{
return(0);
}
}
}
-
...the code before is running :)
all what i need is the user id in the edit_profile
(like: Hey Testperson, your User Id is: {user_id})
...then i use a link to open a popup window...
<a href="" onclick="window.open('user/upnresize.php?user_get_id={user_id} ', '_profile',
'HEIGHT=100,resizable=yes,scrollbars=no,WIDTH=500');return false;" target="_profile">
Insert your personal picture now</a>
the popup goes here:
<form method=\"POST\" action=\"$PHP_SELF\" enctype=\"multipart/form-data\">
<input type=\"file\" name=\"uplfile_name\" value=\"$uplfile_name\">
<input type=\"hidden\" name=\"new_name\" value=\"$user_get_id\">
<input type=\"hidden\" name=\"scriptaction\" value=\"overwrite\">
<button name=\"upload\" type=\"submit\">$msg[12]</button>
</form>
cu
jan-hendrik
-
hmmm ich find da irgendwie gerade net so durch, aber v@no hat doch eigentlich die Lösung schon gesagt du kannst in deinem PHP Dateien keine {} verwenden!!!
-
ich hab {} ja auch in der template angewandt...
aber warum kann man die user id nicht auslesen?
müsste doch irgendwie funktionieren, oder?
ich habe versucht diese auszulesen, bekomme aber immer nur eine 1...
wenn ich wüsste wie man z.B. dem User anzeigen könnte (z.B.Deine User ID ist: XX), dann wäre mir schon unendlich geholfen, den rest bekomme ich dann hin... und das fertige ergebnis kann ich dann ja hier posten (ich hab soweit alles, nur muss ich momentan noch mit einem input tag die user id per hand eingeben, und das will ich nicht), wenn ich aber die user id im edit_profile auslesen könnte, dann kann jeder user ohne aufwand ein eigenes profil image einbinden... und genau das ist mein ziel. wenn es irgendwie anders geht, bin ich natürlich auch dankbar für eine fertige lösung.