TRForumcu.NeT (Arşiv Ana sayfa) => SMF

Konu: Rastgele Resim Eklenti Göster

Sayfa: [ 1 ]

Gondolin 22.06.2008 14:42:22

Notice: Undefined index: codeselectall in /home/trforum/public_html/forum/Sources/Subs.php(1222) : runtime-created function on line 30

Notice: Undefined index: codeselectall in /home/trforum/public_html/forum/Sources/Subs.php(1222) : runtime-created function on line 30

Notice: Undefined index: codedivider in /home/trforum/public_html/forum/Sources/Subs.php(1222) : runtime-created function on line 31

Notice: Undefined index: codecopytoclipboard in /home/trforum/public_html/forum/Sources/Subs.php(1222) : runtime-created function on line 31

Notice: Undefined index: codecopytoclipboard in /home/trforum/public_html/forum/Sources/Subs.php(1222) : runtime-created function on line 31

Notice: Undefined index: codeselectall in /home/trforum/public_html/forum/Sources/Subs.php(1222) : runtime-created function on line 30

Notice: Undefined index: codeselectall in /home/trforum/public_html/forum/Sources/Subs.php(1222) : runtime-created function on line 30

Notice: Undefined index: codedivider in /home/trforum/public_html/forum/Sources/Subs.php(1222) : runtime-created function on line 31

Notice: Undefined index: codecopytoclipboard in /home/trforum/public_html/forum/Sources/Subs.php(1222) : runtime-created function on line 31

Notice: Undefined index: codecopytoclipboard in /home/trforum/public_html/forum/Sources/Subs.php(1222) : runtime-created function on line 31
Bu ipucumuz aslında bir SSI fonksiyonu. ssi_randomAttachPic() şeklinde çağırılıyor ve  eklentiler arasından rastgele bir resim eklentisi gösteriyor.

SSI.php

Bul:

Kod:  
?>

Değiştir:

Kod:  
function ssi_randomAttachPic()
{
   global $modSettings, $scripturl, $db_prefix;

   //Find max.
   $dbresult = db_query("
SELECT ID_ATTACH
FROM {$db_prefix}attachments
ORDER BY ID_ATTACH DESC
LIMIT 1", __FILE__, __LINE__);

   $max = mysql_fetch_assoc($dbresult);
   $check = 0;

   while($check == 0) {

//Random it.
$idpic = rand(1, $max['ID_ATTACH']);

// Find the pictures.
$request = db_query("
    SELECT ID_ATTACH, ID_MEMBER, filename, width, height
    FROM {$db_prefix}attachments
    WHERE ID_MEMBER = '0' AND width <> 0 AND ID_ATTACH = $idpic
    LIMIT 1", __FILE__, __LINE__);
$return = array();
while ($row = mysql_fetch_assoc($request))
{

    //Fix for the width.
    if($row['width'] > 50)
  $width = '50';
    else
  $width = $row['width'];

    //Build up the array.
    $return[] = array(
  'id' => $row['ID_ATTACH'],
  'filename' => $row['filename'],
  'image' => '<img src="' . $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=image" alt="" border="0" height="' . $width . '" width="' . $width . '" />',
    );
}

mysql_free_result($request);

//Did you find what you search for?
if(!empty($return) || empty($max))
    $check = 1;
   }
   
   //Output it! Rather simple, yeah? :P   
   foreach ($return as $attach) {
   echo $attach['image'];
   }
}

?>



Tamamiyle [SiNaN] yapımıdır.


Sayfa: [ 1 ]