Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Kaip padaryti, kad teksta automatiškai keltu į kita eilute?

Parašė PyccKuu· 2011 Geg. 22 23:05:52
#8

Rašomas laukelije.

Va visas kodas:


 
<?php
  if (!defined("DATALIFEENGINE"))
  {
    die("Hacking Attemp!");
  }
 
$utf8 = iconv('windows-1251', 'utf-8', $ansi);
 
  $dirdem=ROOT_DIR.'/uploads/demotivation/';
 $tpl->load_template('demgen.tpl');
if (isset($_FILES["file"])){
$myfile = $_FILES["file"]["tmp_name"];
$font = str_replace ( "\\", "/", getcwd () )."/arial.ttf";
$font1 = $font;
$headerSize = 33.5;
$textSize = 24.0;
 $imageMargin = 20;
  $spacing = 16;
  $borderPad = 16;
$srcFile = $myfile;
 $header = ( $_POST["head"]);
  $text = ($_POST["text"]);
 if( !file_exists( $srcFile ) ){
    echo "Paveiksliukas nerastas\n";
    exit;
  }
  $img = imagecreatefromjpeg( $srcFile );
  list($w, $h) = getimagesize( $srcFile );
 
  $ha1 = imagettfbbox($headerSize, 0, $font1, $header );
  $ha2 = imagettfbbox($textSize, 0,$font, $text );
 
  $wt1 = $ha1[2]-$ha1[0];
  $ht1 = $ha1[1]-$ha1[7];
  $wt2 = $ha2[2]-$ha2[0];
  $ht2 = $ha2[1]-$ha2[7];
 
  $fw = $w + 8 + $imageMargin * 2 + $borderPad * 2;
  $fh = $h + 8 + $imageMargin * 2 + $borderPad * 2 + $ht1 + $ht2 + $spacing * 3;
  $fon = imagecreatetruecolor($fw, $fh);
 
  $white = imagecolorallocate( $fon, 255, 255, 255 );
  $black = imagecolorallocate( $fon,   97,   161,   23 );
  imagefill( $fon, 0, 0, $black );
 
  imagecopy( $fon, $img, $imageMargin + $borderPad + 4, $imageMargin + $borderPad + 4, 0, 0, $w, $h );
 
  imagerectangle( $fon, $imageMargin + $borderPad + 4 - 3, $imageMargin + $borderPad + 4 - 3,
           $imageMargin + $borderPad + $w + 4 + 2, $imageMargin + $borderPad + $h + 4 + 2, $white );
  imagerectangle( $fon, $imageMargin + $borderPad + 4 - 4, $imageMargin + $borderPad + 4 - 4,
           $imageMargin + $borderPad + $w + 4 + 3, $imageMargin + $borderPad + $h + 4 + 3, $white );
 
  imagettftext( $fon, $headerSize, 0,
    ($fw - $wt1) / 2, $imageMargin + $borderPad*2 + 8 + $h + $ht1 + $spacing,
    $white, $font1, $header );
 
  imagettftext( $fon, $textSize, 0,
    ($fw - $wt2) / 2, $imageMargin + $borderPad*2 + 8 + $h + $ht1 + $ht2 + $spacing*2,
    $white, $font, $text );
 $ts=$dirdem.time();
 $ts1='/uploads/demotivation/'.time();
  imagejpeg( $fon, $ts."_demotiv.jpg", 98 );
  imagecolordeallocate( $fon, $black );
  imagecolordeallocate( $fon, $white );
  imagedestroy( $fon );
 $output=$ts1."_demotiv.jpg";
 $wdr= <<<HTML
<center>
<img src="http://{$_SERVER['HTTP_HOST']}{$output}"><br>
     <form enctype="multipart/form-data">
       <tr><td width="120" height="30"><span style="font-size: xx-small;">» Tiesioginė nuoroda:</span></td><td><input type="text" name="head" value="http://{$_SERVER['HTTP_HOST']}{$output}" style="border:1px solid #ccc;height:16px;width:300px;padding-left:5px;"></td></tr>
	<tr><td width="120" height="40"><span style="font-size: xx-small;">» Forumo kodas:</span></td><td><input type="text" name="head"  value="[img]http://{$_SERVER['HTTP_HOST']}{$output}[/img]" style="border:1px solid #ccc;height:16px;width:300px;padding-left:5px;"></td></tr> 
	<tr><td width="120" height="30"><span style="font-size: xx-small;">» <span style="border-bottom: 1px dotted black;">HTML</span> Kodas:</span></td><td><input type="text" name="head" value="&lt;img src=&quot;http://{$_SERVER['HTTP_HOST']}{$output}&quot;&gt;" style="border:1px solid #ccc;height:16px;width:300px;padding-left:5px;"></td></tr> 
</form>
</center>
<span style="border-bottom: 1px dotted black;">HTML</span>;
} else {
$wdr = <<<HTML
<center>
     <form  method="post" enctype="multipart/form-data">
<tr><td width="120" height="40"><span style="font-size: xx-small;">» <b>Nuotrauka:</b></span></td><td><input type="file" name="file"></td></tr>
<tr><td width="120" height="30"><span style="font-size: xx-small;">» <b>Pavadinimas:</b></span></td><td><input type="text" value="Įveskite pavadinimą..." onblur="if(this.value=='') this.value='Įveskite pavadinimą...';" onfocus="if(this.value=='Įveskite pavadinimą...') this.value='';" name="head" style="border:1px solid #ccc;height:16px;width:165px;padding-left:5px;"></td></tr>
<tr><td width="120" height="30"><span style="font-size: xx-small;">» <b>Aprašymas:</b></span></td><td><input type="text" value="Įveskite aprašymą..." onblur="if(this.value=='') this.value='Įveskite aprašymą...';" onfocus="if(this.value=='Įveskite aprašymą...') this.value='';" name="text" style="border:1px solid #ccc;height:16px;width:165px;padding-left:5px;" value=""></td></tr>
</table><br>
<center><input type="submit" name="submit" value="Patvirtinti" style="border:1px solid #ccc;height:22px;width:200px;padding-left:5px;"></center>
</form>
</center>
<span style="border-bottom: 1px dotted black;">HTML</span>;
 
}
$tpl->set('{cnt}', $wdr);
 
    $tpl->compile('content');
    $tpl->clear();
?>
 


Čia datalaifo modulis :)