Jump to content

Random Avatar Folosind Php


gaby

Recommended Posts

Ce inseamna random avatar?

La fiecare refresh (afisare) a unei pagini avatarul dumneavoastra se va schimba cu un altul.

Pentru inceput va trebui sa creati un folder pe hostul dumneavoastra, spre exemplu Avatar.

Apoi creati un fisier index.php care sa contina urmatoarele linii:

<?php
$folder = '';
$exts = 'jpg jpeg png gif';
$files = array(); $i = -1;
if ('' == $folder) $folder = './';
$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
foreach($exts as $ext) {
if (preg_match('/\.'.$ext.'$/i', $file, $test)) {
$files[] = $file;
++$i;
} } }
closedir($handle);
mt_srand((double)microtime()*1000000);
$rand = mt_rand(0, $i);
header('Location: '.$folder.$files[$rand]);
?>[/html]

Creati un fisier [b].htaccess[/b] care sa contina urmatoarele linii:

[code]RewriteEngine ON

RewriteRule ^poza.gif/$ index.php
RewriteRule ^poza.gif$ index.php[/code]

[color=red]index.php[/color] precum si fisierul [color=orange].htaccess[/color] creat mai devreme trebuie punse in folder-ul creat (in exemplul meu [b]Avatar[/b]).

Puneti imaginile (avatarelel) in folder-ul creat ([b]Avatar [/b]in exemplul meu).

Dupa aceea redenumiti folder-ul ([b]Avatar[/b]) in [color=red][b]avatar.jpg[/b][/color] (spre exemplu).

[b][color=red]*[/color][/b]Nota: Acest script nu functioneaza pe host-uri ce nu au [b]mod_rewrite[/b] [color=red]activat[/color]. ilive.ro si evonet.ro din cate stiu au mod_rewrite activat !

:pct:

Te-ai inregistrat? Ne-ar placea sa te prezinti.

Cum pot sustine forumul?
Cumpara de la eMag folosind acest link.
--------------------
oG2BN9d.gifse1WdXd.gifQG6MtmI.gifRHYjDzD.gifG5p1wui.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.