Jump to content

Tanis

Members
  • Posts

    31
  • Joined

  • Last visited

Everything posted by Tanis

  1. <?$x = 0;$text=$_GET["text"];$im = imagecreatetruecolor( 20*strlen($text), 20 );imagealphablending( $im, false );imagesavealpha( $im, true );$col = imagecolorallocate( $im, 0, 0, 0, 127 );imagefilledrectangle( $im, 0, 0, 20*strlen($text), 20, $col );for ($i = 0; $i < strlen($text); ++$i){$letter = $text[$i];$filename = "http://www.habbground.com/goodies/letters/$letter.png";$image = imagecreatefromPNG($filename);imagecopyresampled($im, $image, $x, 0, 0, 0, 20, 20, 20, 20);$x = $x+20;}header('Content-type: image/png');imagealphablending( $im, false );imagesavealpha( $im, true );imagePNG($im);imageDestroy($im);?> There were some issues with images I had too.PS- sorry about the really long delay, I lost my link to the thread
  2. Neither of those worked, but I tried taking out another part, and it's working now!Thanks for all your guys' help!
  3. Sorry, I should have been more clear.After adding in the debug code, I discovered the problem and fixed it.I now get the properly generated text, but the text/image still has the black background.
  4. I added in the transparency code, ending up with <?$x = 0;$text=$_GET["text"];$im = imagecreatetruecolor( 20*strlen($text), 20 );imagealphablending( $im, false );$col = imagecolorallocate( $im, 0, 0, 0, 127 );imagefilledrectangle( $im, 0, 0, 20*strlen($text), 20, $col );imagealphablending( $im, true );for ($i = 0; $i < strlen($text); ++$i){$letter = $text[$i];$filename = "http://www.habbground.com/goodies/letters/$letter.png";$image = imagecreatefromPNG($filename);imagecopyresampled($im, $image, $x, 0, 0, 0, 20, 20, 20, 20);$x = $x+20;}header('Content-type: image/png');imagealphablending( $im, false );imagesavealpha( $im, true );imagePNG($im);imageDestroy($im);?> And it still has a black background.
  5. It should be working... outputting the variables returnedtext: ABCDEletter: Afilename: http://www.habbground.com/goodies/letters/A.pngletter: Bfilename: http://www.habbground.com/goodies/letters/B.pngletter: Cfilename: http://www.habbground.com/goodies/letters/C.pngletter: Dfilename: http://www.habbground.com/goodies/letters/D.pngletter: Efilename: http://www.habbground.com/goodies/letters/E.pngCopy/pasting the links returns an image.
  6. <?$x = 0;$text=$_GET["text"];$im = imagecreatetruecolor( 20*strlen($text), 20 );for ($i = 0; $i < strlen($text); ++$i){$letter = $text[$i];$filename = "http://www.habbground.com/goodies/letters/$letter.png";$image = imagecreatefromPNG($filename);imagecopyresampled($im, $image, $x, 0, 0, 0, 20, 20, 20, 20);$x = $x+20;}header('Content-type: image/png');imagePNG($im);imageDestroy($im);?> Returns a totally black image (varying in size depending on the # of letters inputted).
  7. I know WHY its black, i just need to know how to change it.Although it would be ok if the user could simply input a background color (in hex), it would be much better if there was a way to make the image transparent.
  8. Works now, but how do i change the background color so its transparent instead of black?
  9. hehe, backwards it is...Well now that those two things are fixed, all I'm getting is a black box...http://www.habbground.com/txtst.php?text=ABCDE
  10. Alright, changed it to <?0 = $x;$text=$_GET["text"];for ($i = 0; $i < strlen($text); ++$i){$letter = $text{$i};$filename = "/goodies/letters/$letter.gif";$im = imagecreatetruecolor(20, 20);$image = imagecreatefromGIF($filename);imagecopyresampled($im, $image, $x, 0, 0, 0, 20, 20, 20, 20);$x = $x+20;}header('Content-type: image/gif');imageGIF($im);imageDestroy($im);?> and it doesn't output anything.What am I missing (most likely something really obvious)?
  11. But in imagecopyresampled, $width is in the destniation image width spot, so wouldn't you want the width of the destination img increase by 20 for each additional letter?
  12. So far i've got: <?$width = 20;$height = 20;$text=$_GET["text"];for ($i = 0; $i < strlen($text); ++$i){$letter = $text{$i};$filename = "/goodies/letters/$letter.gif";$x = $width-20;$im = imagecreatetruecolor($width, 20);$image = imagecreatefromGIF($filename);imagecopyresampled($im, $image, $x, 0, 0, 0, $width, 20, 20, 20);$width = $width+20;}header('Content-type: image/gif');imageGIF($im);imageDestroy($im);?> But to no avail...All I get is a big black box (good thing is that it changes by 20 pixels for every letter you have)PS- Each source image is 20x20.View- clickyI tried removing $im = imagecreatetruecolor($width, 20); but that just returned http://www.habbground.com/txtst.php?text=ABCDE
  13. Okay, but say the user inputs "Blue"How would I make it so each letter of the variable (that blue is stored in) gets added to the image, and how would i make sure the image is the right size, no matter how many letter there are?
  14. But how do you merge multiple images with imagecopyresampled?All I can see on the reference page is manipulating one image, and copying it to a new file.
  15. Yes, the png file is in the right spot...Strange as it may sound, it's now working, I tried it before adding in the buffer stuff, and it worked :)Anyways, how would I go about making it so the user inputs two colors, and both colors in the image are changed?Finally (rather off-topic), my other question, is there a way to have a text generator where if the user inputs ABC, one image is generated using the images a.png, b.png, and c.png? (I know the answer is yes, I just don't know how)
  16. Good news- No longer displays an error.Bad news- only displays "http://www.habbground.com/hbt.php?color=FFFFFF&color2=000000&submit=Submit"
  17. I still get the same thing after removing<html><head><title>Test 2</title></head><body></body>and</html>
  18. Current code- <html><head><title>Test 2</title></head><body><?PHPini_set("display_errors", 1);error_reporting(E_ALL);$phpHex = '525d63';$phpColor = hex2int($phpHex);$newColor = hex2int(validHexColor($_REQUEST['color'],$phpHex));$im = imageCreateFromPNG('img.png');$phpCIndex = imageColorExact($im,$phpColor['r'],$phpColor['g'],$phpColor['b']);imageColorSet($im,$phpCIndex,$newColor['r'],$newColor['g'],$newColor['b']);header('Content-type: image/png');if ($im = imageCreateFromPNG('img.png')) echo 'OK';else echo 'FALSE';imagePNG($im);imageDestroy($im); /** * @param $hex string 6-digit hexadecimal color * @return array 3 elements 'r', 'g', & 'b' = int color values * @desc Converts a 6 digit hexadecimal number into an array of * 3 integer values ('r' => red value, 'g' => green, 'b' => blue) */function hex2int($hex) { return array( 'r' => hexdec(substr($hex, 0, 2)), // 1st pair of digits 'g' => hexdec(substr($hex, 2, 2)), // 2nd pair 'b' => hexdec(substr($hex, 4, 2)) // 3rd pair );}/** * @param $input string 6-digit hexadecimal string to be validated * @param $default string default color to be returned if $input isn't valid * @return string the validated 6-digit hexadecimal color * @desc returns $input if it is a valid hexadecimal color, * otherwise returns $default (which defaults to black) */function validHexColor($input = '000000', $default = '000000') { // A valid Hexadecimal color is exactly 6 characters long // and eigher a digit or letter from a to f return (eregi('^[0-9a-f]{6}$', $input)) ? $input : $default;}?></body></html> Which, after sending FFFFFF and 000000 for the colors gives me "The image “http://www.habbground.com/hbt.php?color=FFFFFF&color2=000000&submit=Submit” cannot be displayed, because it contains errors."
  19. Sorry for the delay...Anyways, yes its in the same directory as the image.Adding if ($im = imageCreateFromPNG('img.png')) echo 'OK';else echo 'FALSE'; changed absolutely nothing.
  20. Neither worked.First solution changed nothing.Changing to text/html only made the error go away. The image didn't get shown.
  21. I'm using firefox, and thats all I'm getting.
  22. Hey guys, I'm having some problems with image manipulation...I have a script where you type in a hex color into a form, you hit send, and then tall of once color of in the image is changed to the color that was inputed. <?PHP$phpHex = '525d63';$phpColor = hex2int($phpHex);$newColor = hex2int(validHexColor($_REQUEST['color'],$phpHex)) ;$im = imageCreateFromPNG('img.png');$phpCIndex = imageColorExact($im,$phpColor['r'],$phpColor['g'],$phpColor['b']);imageColorSet($im,$phpCIndex,$newColor['r'],$newColor['g'],$newColor['b']);header('Content-type: image/png');imagePNG($im);imageDestroy($im); /** * @param $hex string 6-digit hexadecimal color * @return array 3 elements 'r', 'g', & 'b' = int color values * @desc Converts a 6 digit hexadecimal number into an array of * 3 integer values ('r' => red value, 'g' => green, 'b' => blue) */function hex2int($hex) { return array( 'r' => hexdec(substr($hex, 0, 2)), // 1st pair of digits 'g' => hexdec(substr($hex, 2, 2)), // 2nd pair 'b' => hexdec(substr($hex, 4, 2)) // 3rd pair );}/** * @param $input string 6-digit hexadecimal string to be validated * @param $default string default color to be returned if $input isn't valid * @return string the validated 6-digit hexadecimal color * @desc returns $input if it is a valid hexadecimal color, * otherwise returns $default (which defaults to black) */function validHexColor($input = '000000', $default = '000000') { // A valid Hexadecimal color is exactly 6 characters long // and eigher a digit or letter from a to f return (eregi('^[0-9a-f]{6}$', $input)) ? $input : $default ;}?> For some reason, whenever you hit submit, you get the message "The image “http://www.mysite.com/hbt.php?color=[yourcolor]” cannot be displayed, because it contains errors." Where [yourcolor] is replaced by the color you inputed.Any ideas on whats wrong?Also, how would I make it so the user inputs two colors, and two colors on the image are changed?Finally, is there a way to have a text generator, where if the user inputs ABC, one image is generated, using the images a.png, b.png, and c.png? (I know the answer is yes, i just dont know how )Thanks!!
  23. The header file is-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><link rel="stylesheet" type="text/css" href="/udm4-php/udm-resources/udm-style.php" media="screen, projection" /><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><style type="text/css">body { margin-top: 0; margin-bottom: 0; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; background: #000000; color: #C7C7C7;}#header { margin: 20px; padding: 10px; height: 200px;}#left { position: absolute; left: 15px; top: 340px; width: 180px;}#center { top: 0; margin-left: 215px; margin-right: 180px; width: 580px;}#right { position: absolute; right: 15px; top: 340px; width: 180px;}</style><div id="header"><center><img src="http://www.habbground.com/needbanner.jpg"></center></div><div id="center"><table border="0" cellspacing="0" cellpadding="0"><tr><td width="580" height="50" background="/pics/top.png"></td></tr><tr><td width="580" background="/pics/middle.jpg"> So, nothing with sessions there.As for checking for whats in the session, I'm not actually putting anything in the sessions, or checking whats in the sessions, I'm just setting the session, then checking to see if its set.
  24. Hey guys, heres the deal.I have a login script on my site, which allows users to login in perfectly fine.Only problem is, when they view a secure page, they get the "Not authorized" messsage (not a 505, just the one I created).Login form code: <H1><font face="Verdana" size="4" color="#C7C7C7">Staff Login:</font></H1><form method='post' action ='/staff/login.php'><font color="#C7C7C7">Username: <input type='text' name='username'><br><font color="#C7C7C7">Password: <input type='password' name='password'><br><input type='submit' name='login' value='Login'></form> Login page code (login.php): <html><head><title>Logging in...</title></head><body><?phpsession_start();//--==login==--$login = $_POST['login'];if (isset($login)) {$username = $_POST['username'];$password = $_POST['password'];$isauth = false;$logcon = mysql_connect ('Host','User','Pass');if (!$logcon) {die("Could Not Connect To MySQL");}mysql_select_db("DB", $logcon) or die("Could Not Connect To DB because: ". mysql_error());$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";$result = mysql_query($query, $logcon); while ($row = mysql_fetch_array($result)) { if ($row['username'] === $username) { $isauth = true; $run = $row['username']; $group = $row['group']; } } if ($isauth) { if ($group == "admin") { $_SESSION['adminlogged'] = $run; echo "<font face='arial'><b>Thank you for logging in, " . $run . "</b></font><meta http-equiv='Refresh' content='5;url=/staff/adminpage.php'>"; } elseif ($group == "usrv") { $_SESSION['usrvlogged'] = $run; echo "<font face='arial'><b>Thank you for logging in, " . $run . "</b></font><meta http-equiv='Refresh' content='5;url=/rarevalues/USA/reporter.php'>"; } elseif ($group == "ukrv") { $_SESSION['ukrvlogged'] = $run; echo "<font face='arial'><b>Thank you for logging in, " . $run . "</b></font><meta http-equiv='Refresh' content='5;url=/rarevalues/UK/reporter.php'>"; } elseif ($group == "aurv") { $_SESSION['aurvlogged'] = $run; echo "<font face='arial'><b>Thank you for logging in, " . $run . "</b></font><meta http-equiv='Refresh' content='5;url=/AU/reporter.php'>"; } elseif ($group == "carv") { $_SESSION['carvlogged'] = $run; echo "<font face='arial'><b>Thank you for logging in, " . $run . "</b></font><meta http-equiv='Refresh' content='5;url=/rarevalues/CA/reporter.php'>"; } elseif ($group == "dj") { $_SESSION['djlogged'] = $run; echo "<font face='arial'><b>Thank you for logging in, " . $run . "</b></font><meta http-equiv='Refresh' content='5;url=/DJpage.php'>"; } else { echo "Error: Please contact your web admin and ask about your group"; } } else { echo "<font face='arial'><b>Incorrect Username or Password.</b></font><meta http-equiv='Refresh' content='5;url=/'>"; } mysql_close($logcon);}else {echo "<font face='arial'><b>Oops! You have accessed this page incorrectly.</b></font>";}?> </body></html> Finally, example of a secure page (each group has a page similar to it): <?phpinclude("http://www.habbground.com/headinclude.php");?><title>HG Administration!</title></head><?phpsession_start();if ( isset( $_SESSION['adminlogged'] ) ) { echo "<center><font color=#C7C7C7><a href='http://www.habbothunder.com/fwc/'>Visitor Counter Control Panel</a><br>Username is *removed*, password is *removed*<br><font color='red'>~~~!!!!WARNING!!!!~~~</font><br>DO NOT CHANGE ANY SETTINGS WITHOUT PERMISSION FROM *removed*!!!!<br><br><img src='/divide.jpg'><br><br><font size='4'><a href='/rarevalues/reporter/reporter.php'>Reporter Page</a></font><br><br><img src='/divide.jpg'><br><br><form action='/news/cutenews/' method=post><br> Username:<input type=text name=username><br> Password:<input type=password name=password><br><input type=hidden name=action value=dologin><input type=submit value='Login'><br></form><br><br><img src='/divide.jpg'><br><br>Email login coming soon...";}else { echo "You are not authorized to view this page.";}include("http://www.habbground.com/footerinclude.php");?> Can anyone figure out whats wrong?
×
×
  • Create New...