F.A.Q. - style i grafika - LOGO LOSOWE. Inne logo po ka?dym od?wie?aniu strony
DuroneK - 26-01-2008, 14:45 Temat postu: LOGO LOSOWE. Inne logo po każdym od¶wieżaniu strony Witam, jak zrobić logo/nagłówek, aby po kazdym od¶wieżeniu strony zmieniał się obrazek.
Tzn mam kilka nagłówków i chcialbym aby sie zmienialy po kazdej odsłonie strony.
Jaki¶ kod ? czy moze przemo ma ukryt± funkcje o ktorej nie wiem ?
ORI - 26-01-2008, 15:13
DuroneK, nie ma ale ja mam zrobie to z avatarem, podejrzewam ze z logiem da sie tak samo zrobic. Info tutaj: http://www.phpbb2.pl/foru...?t=5014&start=0
DuroneK - 26-01-2008, 15:47
wystarczy ze wkleje to :
<?php
unset($files);
for ($i = 1; $i <=16; $i++) {
$files[] = 'avatary/' . $i . '.jpg';
}
header('Content-type: image/jpeg');
$rand = rand(0, count($files) - 1);
header('Cache-Control: no-store, no-cache, no-transform, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0, max-age=0', false);
header('Expires: Mon, 22 Aug 2005 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Pragma: no-cache');
echo file_get_contents($files[$rand]);
?>
??? bo nie ogarniam tego.
GradCP - 26-01-2008, 15:58
Szukaj! - losowe logo było wielokrotnie!
http://www.przemo.org/php...ght,losowe+logo
DuroneK - 26-01-2008, 16:15
GradCP, niestety nie dziala to z tamtego postu
GradCP - 26-01-2008, 16:22
A mnie działało jak to instalowałem niedawno... Poczytaj dobrze jak to się robi i wtedy, to zrób.
A jak mimo, to nie działa, to użyj wyszukiwarki - znajdzie kolejne tematy ;/.
DuroneK - 26-01-2008, 16:26
GradCP, nie musisz byc niegrzeczny
Skoro pisze , że nie działa to tak jest. Przeszukałem już cał± szukajke i szczerze mowi±c mało znalazłem
overall_header wyglada u mnie tak , a raczej jego fragment:
Kod: | <td><a href="{U_INDEX_PORTAL}"><img src="templates/FIsubSilver/images/logo.php" border="0" alt="{L_INDEX_PORTAL}" vspace="1" /></a></td> |
a plik logo.php tak :
Kod: | <?php
$images = array(
'1' => 'templates/FIsubSilver/images/naglowek1.jpg',
'2' => 'templates/FIsubSilver/images/naglowek2.jpg',
'3' => 'templates/FIsubSilver/images/naglowek3.jpg',
'4' => 'templates/FIsubSilver/images/naglowek4.jpg'
);
$number = rand(0, count($images)-1));
$ext = strtolower(ltrim(strrchr($images[$number], '.'), '.'));
switch($ext)
{
case 'jpeg':
case 'jpg':
$img = imagecreatefromjpeg($images[$number]);
header('Content-type: image/jpeg');
imagejpeg($img);
break;
case 'gif':
$img = imagecreatefromgif($images[$number]);
header('Content-type: image/gif');
imagegif($img);
break;
case 'png':
$img = imagecreatefrompng($images[$number]);
header('Content-type: image/png');
imagepng($img);
break;
}
?> |
wiec ?
GradCP - 26-01-2008, 17:49
Jak Ci tamto rozwi±zanie nie działało, to było znaleĽć inne - mnie znalezienie drugiego zajęło dwie minuty --'
Najpierw odwiedĽ overall_header.tpl
Zamień tam standardowe:
Kod: |
<img src="templates/TWÓJ_STYL/images/logo_phpBB.gif" border="0" alt="{L_INDEX_PORTAL}" vspace="1" />
|
na
Kod: |
<img src="templates/TWÓJ_STYL/images/logo/logo.php" border="0" alt="{L_INDEX_PORTAL}" vspace="1" />
|
Zapisz i zamknij. Teraz wejdĽ w twój_styl/images i stwórz tam folder logo. Do niego wrzuć grafiki - o nazwach np. top, top1, top2, top3 itd. oraz stwórz tam plik logo.php z takim kodem:
Kod: |
<?php
$folder = '.';
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
$extList['png'] = 'image/png';
$img = null;
if (substr($folder,-1) != '/') {
$folder = $folder.'/';
}
if (isset($_GET['img'])) {
$imageInfo = pathinfo($_GET['img']);
if (
isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
file_exists( $folder.$imageInfo['basename'] )
) {
$img = $folder.$imageInfo['basename'];
}
} else {
$fileList = array();
$handle = opendir($folder);
while ( false !== ( $file = readdir($handle) ) ) {
$file_info = pathinfo($file);
if (
isset( $extList[ strtolower( $file_info['extension'] ) ] )
) {
$fileList[] = $file;
}
}
closedir($handle);
if (count($fileList) > 0) {
$imageNumber = time() % count($fileList);
$img = $folder.$fileList[$imageNumber];
}
}
if ($img!=null) {
$imageInfo = pathinfo($img);
$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
header ($contentType);
readfile($img);
} else {
if ( function_exists('imagecreate') ) {
header ("Content-type: image/png");
$im = @imagecreate (100, 100)
or die ("Cannot initialize new GD image stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 0,0,0);
imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color);
imagepng ($im);
imagedestroy($im);
}
}
?>
|
Amen.
DuroneK - 26-01-2008, 17:57
i to działa
punkt dla ciebie
|
|
|