1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

plzz help me to solve this...its very urgent to compleate my final sem project...

Discussion in 'PHP' started by sriducati, Nov 30, 2009.

  1. #1
    <?php
    ini_set('display_errors', 0);
    ini_set('error_reporting', E_NONE);
    $mt = microtime();
    $mt = str_replace("0.", "", $mt);
    $mt = str_replace("-", "", $mt);
    $mt = str_replace(" ", "", $mt);
    foreach (glob("temp/*.gif") as $filename)
    {
    		@unlink($filename);
    }
    if (stripslashes($text == ""))
    {
    		(stripslashes($text = "this one's for you"));
    } // button text
    if (isset($_REQUEST['smiley']) && ($_REQUEST['smiley']) !== '')
    {
    		$button = ($_REQUEST['smiley']);
    }
    else
    {
    		$button = 'grey';
    }
    $im_info = getimagesize("s/$button.gif"); // button size
    $buttonwidth = "$im_info[0]";
    $buttonheigth = "$im_info[1]";
    if (isset($width) || isset($heigth))
    { // size change expected?
    		$ima = imagecreatefromgif("s/$button.gif"); // open input gif
    		$im = imagecreatetruecolor($buttonwidth, $buttonheigth); // create img in desired size
    		$uglybg = ImageColorAllocate($im, 0xf4, 0xb2, 0xe5);
    		ImageRectangle($im, 0, 0, $buttonwidth, $buttonheigth, $uglybg);
    		$dummy = imagecopyresized($im, $ima, 0, 0, 0, 0, $buttonwidth, $buttonheigth, $im_info[0], $im_info[1]);
    		if ($dummy == "")
    		{
    				ImageDestroy($im); // if it didn't work, create default below instead
    		}
    		else
    		{
    				;
    		}
    		ImageDestroy($ima);
    		ImageColorTransparent($im, $uglybg);
    }
    else
    {
    		$im = imagecreatefromgif("s/$button.gif"); // open input gif
    }
    if ($im == "")
    {
    		$im = imagecreate($buttonwidth, $buttonheigth); // if input gif not found,
    		$rblue = ImageColorAllocate($im, 200, 222, 200); // create a default box
    		ImageRectangle($im, 0, 0, 200, 100, $rblue);
    }
    if ($id !== 'copyright')
    {
    		$text = "[iAG] Decoded";
    }
    $path = getCWD();
    $x = 0;
    $y = 3;
    $width = 184;
    if (isset($_REQUEST['font']) && ($_REQUEST['font']) !== '')
    {
    		$font = "" . $path . "/" . $_REQUEST['font'] . "";
    }
    else
    {
    		$font = "$path/font/arialbd.ttf";
    }
    $textSize = 10;
    if (isset($_REQUEST['fup']) && ($_REQUEST['fup']) !== '')
    {
    		$fup = ($_REQUEST['fup']);
    		$textSize = $textSize + $fup;
    }
    $tx = imagecreate(184, 34);
    $trans = ImageColorAllocate($tx, 200, 222, 200);
    imagecolortransparent($tx, $trans);
    if (isset($_REQUEST['color']) && ($_REQUEST['color']) !== '')
    {
    		$color = ($_REQUEST['color']);
    }
    else
    {
    		$color = '0000FF';
    }
    $color = hexColorAlloc($tx, $color);
    imageTextWrapped($tx, $x, $y, $width, $font, $color, $text, $textSize, $align = "c");
    imagecopymerge($im, $tx, 186 / 2 - 184 / 2, 5, 0, 0, 184, 34, 100);
    ImageGIF($im, "temp/$mt.gif", 100); // send button to browser
    ImageDestroy($im); // free the used memory
    echo "<img src='temp/$mt.gif' alt='Smiley Signmaker ©'>";
    function hexColorAlloc($im, $hex)
    {
    		$a = hexdec(substr($hex, 0, 2));
    		$b = hexdec(substr($hex, 2, 2));
    		$c = hexdec(substr($hex, 4, 2));
    		return ImageColorAllocate($im, $a, $b, $c);
    }
    //A function for pixel precise text Wrapping
    function imageTextWrapped(&$img, $x, $y, $width, $font, $color, $text, $textSize, $align = "l")
    {
    		//Recalculate X and Y to have the proper top/left coordinates instead of TTF base-point
    		$y += $textSize;
    		$dimensions = imagettfbbox($textSize, 0, $font, " "); //use a custom string to get a fixed height.
    		$x -= $dimensions[4] - $dimensions[0];
    		$text = str_replace("\r", '', $text); //Remove windows line-breaks
    		$srcLines = split("\n", $text); //Split text into "lines"
    		$dstLines = array(); // The destination lines array.
    		foreach ($srcLines as $currentL)
    		{
    				$line = '';
    				$words = split(" ", $currentL); //Split line into words.
    				foreach ($words as $word)
    				{
    						$dimensions = imagettfbbox($textSize, 0, $font, $line . $word);
    						$lineWidth = $dimensions[4] - $dimensions[0]; // get the length of this line, if the word is to be included
    						if ($lineWidth > $width && !empty($line))
    						{ // check if it is too big if the word was added, if so, then move on.
    								$dstLines[] = ' ' . trim($line); //Add the line like it was without spaces.
    								$line = '';
    						}
    						$line .= $word . ' ';
    				}
    				$dstLines[] = ' ' . trim($line); //Add the line when the line ends.
    		}
    		//Calculate lineheight by common characters.
    		$dimensions = imagettfbbox($textSize, 0, $font, "MXQJPmxqjp123"); //use a custom string to get a fixed height.
    		$lineHeight = $dimensions[1] - $dimensions[5]; // get the heightof this line
    		$align = strtolower(substr($align, 0, 1)); //Takes the first letter and converts to lower string. Support for Left, left and l etc.
    		if (count($dstLines) > 2)
    		{
    				echo "<strong>Sorry,<br /> Your text exceeds the size of this sign.<br /> Please shorten your message or try a smaller font size and try again!</strong><br />";
    		}
    		else
    		{
    				foreach ($dstLines as $nr => $line)
    				{
    						if ($align != "l")
    						{
    								$dimensions = imagettfbbox($textSize, 0, $font, $line);
    								$lineWidth = $dimensions[4] - $dimensions[0]; // get the length of this line
    								if ($align == "r")
    								{ //If the align is Right
    										$locX = $x + $width - $lineWidth;
    								}
    								else
    								{ //If the align is Center
    										$locX = $x + ($width / 2) - ($lineWidth / 2);
    								}
    						}
    						else
    						{ //if the align is Left
    								$locX = $x;
    						}
    						$locY = $y + ($nr * $lineHeight);
    						//Print the line.
    						if (count($dstLines) < 2)
    						{
    								$locY = $locY + 8;
    						}
    						imagettftext($img, $textSize, 0, $locX, $locY, $color, $font, $line);
    				}
    		}
    }
    ?>
    Code (markup):

    this code displays a "text" on an image ...
    but i wanna display 2 texts "text1" and "text2" on an image ...by providing two
    i/p fields to a user....plzz guyzzzzz help me to solve this ...am pretty sure you can....plz help me..:mad::mad:
     
    Last edited by a moderator: Nov 30, 2009
    sriducati, Nov 30, 2009 IP
  2. sriducati

    sriducati Peon

    Messages:
    287
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ho am shoked....not even a single programmer here?who can solve the problem?.
     
    sriducati, Dec 1, 2009 IP
  3. ham

    ham Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    There's a lot of programmers that could solve the problem, but it would take some time to dig into your code. Can you narrow down to where the error/problem is to a certain area of your code?
     
    ham, Dec 3, 2009 IP
  4. ankit_frenz

    ankit_frenz Active Member

    Messages:
    1,111
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    63
    #4
    Common this is not a spoon feed form....if you have already one working filed than whats the problem in making two?
    nobody is going to do your homework for you. Do it yourself..we dont want future tech geeks to be dependent on others for small things.
     
    ankit_frenz, Dec 3, 2009 IP
  5. Xexi

    Xexi Well-Known Member

    Messages:
    91
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    100
    #5
    ^^This!

    Plus what if your teacher knows how to google?

    My CPP teacher in college bragged how he would google our midterms/finals and two students were removed from the class and most likely received a more severe punishment from the Dean of Academic Affairs!

    Cheating just isn't worth it!
     
    Xexi, Dec 3, 2009 IP