Hvala
Vse o PHPju
Ustvaril
publikum
, jul 24 2005 17:05
Odgovorov v temi: 1931
#1283
Objavljeno 18 september 2006 - 08:08
Mam težavico pri 4. uri PHP v 24h.
Učim se primerjalne operaterje in mi reče, da mi boo prierjalni operaterji vrnili vrednost false ali true.
Ampak če napišem npr.<?
$x=3;
$x<5;
?>
mi ne vrne nič.žVem, da bi verjetno moral dati nekje nek ukaz "print ali kaj podobnega, ampak v knjigi je tole malce čudno opisano, nočem pa preskočiti koraka, saj bo to uporabno pri ukazih "if" in "while".
V tej knjigi sem našel ogromno napak :ok:
zato se ne obremenjuj z nečim, če ti ne dela pravilno
#1286
Objavljeno 19 september 2006 - 18:26
Ima kdo mogoce kaksno idejo, katero funkcijo bi uporabil, da bi mi PHP prikazal datoteke ki so na strezniku.
Torej imam recimo na pandela.com datoteke. Kako bi naredil, da bi mi PHP prikazal datoteke, ki jih imam "hostane" gor?
Gledal sem tukaj vendar nic ne najdem:
http://www.php.net/m...d.variables.php
Torej imam recimo na pandela.com datoteke. Kako bi naredil, da bi mi PHP prikazal datoteke, ki jih imam "hostane" gor?
Gledal sem tukaj vendar nic ne najdem:
http://www.php.net/m...d.variables.php
#1292
Objavljeno 20 september 2006 - 13:15
Ti torej želiš to? http://www.racunalni...pic.php?t=34592
#1298
Objavljeno 20 september 2006 - 21:39
Prilepljeno z neostikom
index.php:
gd.php:
tekst.php:
Preglej tam v index.php, kaj sem ti napisal zraven v komentarje, ker ti bo prišlo prav. Pa kodo lahko poljubno spremeniš. Aja pa s tem gd.php lahko počneš čudo stvari s slikami.
LP
index.php:
<?
if(isset($_POST["obdelaj"])){
$tekst = $_POST["t"];
require_once("./gd.php");
$gd = new GD ( "./crna.jpg" );//To je ime slike, na katero se bo potem shranil tekst
$gd->Add_TTF_Text($tekst, 26, "#ff0000", 10, 35, "./ds-digi.ttf");//ds-digi.ttf je ime pisave, ki mora biti zraven teh datotek. Ime lahko tudi spremenis.
$gd->Save("./slika.jpg");//Ime slike, ki se bo nato shranila
echo "<b>Obdelana slika:</b><br><img src="slika.jpg" border="0">";
}else{
?>
<form name="form1" method="post" action="">
<font face="Arial, Helvetica, sans-serif">Vpiši tekst za na sliko:
<input name="t" type="text" id="t" size="40">
<br>
<input name="obdelaj" type="submit" id="obdelaj" value="V redu">
</font>
</form>
<?
}
?>gd.php:
<?php
class GD {
var $Image;
var $Width;
var $Height;
function GD ($location) {
$ImageInfo = @getimagesize( $location ) or die( "NAPAKA [01]: Fotografija <b>$location</b> ne obstaja!" );
$this->Width = $ImageInfo[0];
$this->Height = $ImageInfo[1];
switch ( $ImageInfo[2] ) {
case 1: $this->Image = imagecreatefromgif( $location ); break;
case 2: $this->Image = imagecreatefromjpeg( $location ); break;
case 3: $this->Image = imagecreatefrompng( $location ); break;
default: die( "NAPAKA [02]: Skripta ne podpira tega tipa fotografij!" );
}
}
function Resize ($sizeX, $sizeY) {
$org = round( $this->Width / $this->Height, 2 );
$new = round( $sizeX / $sizeY, 2 );
if ( $new > $org ) {
$sizeX = round( $this->Width / ($this->Height / $sizeY), 0 );
$sizeY = $sizeY;
} else
if ( $new < $org ) {
$sizeX = $sizeX;
$sizeY = round( $this->Height / ($this->Width / $sizeX), 0 );
}
$resized = imagecreatetruecolor( $sizeX, $sizeY );
imagecopyresampled( $resized, $this->Image, 0, 0, 0, 0, $sizeX, $sizeY, $this->Width, $this->Height );
$this->Image = $resized;
$this->Width = $sizeX;
$this->Height = $sizeY;
}
function Make_Color ($color) {
$rgb = array();
if ( is_array( $color ) && count($color) == 3 ) {
$rgb["r"] = $color[0];
$rgb["g"] = $color[1];
$rgb["b"] = $color[2];
}
else
if ( preg_match('/^#?([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i', $color, $results) ) {
$rgb["r"] = hexdec( $results[1] );
$rgb["g"] = hexdec( $results[2] );
$rgb["b"] = hexdec( $results[3] );
}
else
die( "NAPAKA [03]: Podana barva je napaèna!" );
foreach ( array("r","g","b") as $value ) {
if ( !array_key_exists( $value, $rgb ) || $rgb[$value] < 0 || $rgb[$value] > 255 || !is_numeric( $rgb[$value] ) )
die ( "NAPAKA [04]: Barva <b>$rgb[$value]</b> je napaèna!" );
}
return $rgb;
}
function Add_Border ($width, $color) {
$rgb = $this->Make_Color( $color );
$allocate = imagecolorallocate( $this->Image, $rgb["r"], $rgb["g"], $rgb["b"] );
if ( $width < 1 )
die ( "NAPAKA [05]: Podaj pravilno širino okvirja!" );
$sizeX = $this->Width + ( 2 * $width );
$sizeY = $this->Height + ( 2 * $width );
$new_image = imagecreatetruecolor( $sizeX, $sizeY );
imagefill( $new_image, 0, 0, $allocate );
imagecopyresampled($new_image, $this->Image, $width, $width, 0, 0, $this->Width, $this->Height, $this->Width, $this->Height);
$this->Image = $new_image;
$this->Width = $sizeX;
$this->Height = $sizeY;
}
function Add_Text ($text, $font, $color, $x, $y) {
if ($font < 1 || $font > 5)
die ( "NAPAKA [06]: Font <b>$font_size</b> neobstaja. Izberi možnost med 1 in 5!" );
$rgb = $this->Make_Color( $color );
$allocate = imagecolorallocate( $this->Image, $rgb["r"], $rgb["g"], $rgb["b"] );
$text_width = imagefontwidth( $font ) * strlen( $text );
$text_height = imagefontheight( $font );
if ( $x==TOP && $y==LEFT ) {
$x = 0;
$y = 0;
} else
if ( $x==TOP && $y==RIGHT ) {
$x = intval($this->Width - $text_width);
$y = 0;
} else
if ( $x==TOP && $y==CENTER ) {
$x = intval( ($this->Width - $text_width) / 2 );
$y = 0;
} else
if ( $x==BOTTOM && $y==LEFT ) {
$x = 0;
$y = intval( $this->Height - $text_height );
} else
if ( $x==BOTTOM && $y==RIGHT ) {
$x = intval( $this->Width - $text_width );
$y = intval( $this->Height - $text_height );
} else
if ( $x==BOTTOM && $y==CENTER ) {
$x = intval( ($this->Width - $text_width) / 2 );
$y = intval( $this->Height - $text_height );
}
if ( is_int($x) && is_int($y) ) {
if ( ($x + $text_width) > $this->Width )
die ( "NAPAKA [08.w]: Tekst je predolg!" );
if ( ($y + $text_height) > $this->Height )
die ( "NAPAKA [08.h]: Tekst je prenizko!" );
imagestring( $this->Image, $font, $x, $y, $text, $allocate);
} else
die( "NAPAKA [07]: Vpiši pravilno pozicijo teksta!" );
}
function Add_TTF_Text ($text, $size, $color, $x, $y, $font = "./tahoma.ttf") {
if ( !is_file( $font ) )
die ( "NAPAKA [09]: Font <b>$font</b> ne obstaja!" );
$rgb = $this->Make_Color( $color );
$allocate = imagecolorallocate( $this->Image, $rgb["r"], $rgb["g"], $rgb["b"] );
imagettftext($this->Image, $size, 0, $x, $y, $allocate, $font, $text );
}
function Save ($location, $quality=100) {
imagejpeg( $this->Image, $location, $quality );
imagedestroy( $this->Image );
}
}
?>tekst.php:
<?php
$tekst = $_POST["tekst"];
$slika = $_POST["slika"];
$shrani = $_POST["shrani"];
$pisava = $_POST["velikostp"];
require_once("./gd.php");
$gd = new GD ( $slika );
$gd->Add_Border(1,"#000000");
$gd->Add_TTF_Text($tekst, $pisava, "#000000", 20, 20, "./visitor2.ttf");
$gd->Save("./".$shrani."_txt.jpg");
$predogled = $shrani."_txt.jpg";
?>
<img src="<? echo $predogled; ?>">Preglej tam v index.php, kaj sem ti napisal zraven v komentarje, ker ti bo prišlo prav. Pa kodo lahko poljubno spremeniš. Aja pa s tem gd.php lahko počneš čudo stvari s slikami.
LP
Dodaj odgovor
1 član(ov) bere to temo
0 članov, 1 gostov, 0 anonimnih uporabnikov








