Welcome to Geeklog Monday, November 29 2021 @ 09:24 am EST

Geeklog Forums

PHP Blocks and 4images


Status: offline

rav

Forum User
Chatty
Registered: 14/01/03
Posts: 37
The geeklog & 4images integration worked perfectly, and I've been running it on my site since the day it was posted. I was wondering if anyone had any plans to do a "random photo block" for the 4images gallery. I've been poking around myself, but frankly, I'm still new to GL & PHP, and while eventually, I might be able to figure it out, I'm sure it would not be as good compared to most blocks/plugin's I've seen.
 Quote

Status: offline

nurseryboy

Forum User
Chatty
Registered: 04/09/02
Posts: 43
Hello, Yes, I have created a random image block for 4images. I have been using it on my site for a while, and it seems to be working just fine. You can download the code here. Just unzip, copy the code from the file into lib-custom, and create a block in GL that calls the new function. That should be it Smile
 Quote

Status: offline

rav

Forum User
Chatty
Registered: 14/01/03
Posts: 37
OMG, so awesome! Thanks!!!
 Quote

Status: offline

nurseryboy

Forum User
Chatty
Registered: 04/09/02
Posts: 43
No problem Smile
 Quote

Status: offline

rav

Forum User
Chatty
Registered: 14/01/03
Posts: 37
That worked perfectly. Thank you very much! After playing around with it for a few hours, I noticed that it didn't seem all that random (same photo kept coming back up, more often than not. I only have about 34 images currently, but the same image would load 9 out of 10 times. I took a lil peek at your code, and read up on the rand() mysql fuction in an attempt to understand what you were doing. I cam accross this: <b>As of MySQL 3.23.52, MySQL changed the way RAND() functions, such that you MUST supply a SEED to get an actual random number. If you do not, each new connection will return close to the same number as the previous new connection. An example to test this would be to run the follow command multiple times in a row. mysql -u username -p -e'select rand()' A basic way to seed this would be to run RAND(NOW()).</b> So I added the NOW() function to the RAND() and it totaly cured it for me. It seems much more random now, and I'm seeing images that were not showing up before. Once again, thanks for the block, I know I couldn't have done it, but maybe this lil tweak will help others Smile
 Quote

Status: offline

nurseryboy

Forum User
Chatty
Registered: 04/09/02
Posts: 43
Ok, cool. Thanks for finding that out. I will add it to the code right away. I'm glad it is working fine for you too. Have a great day!
 Quote

Anonymous

Anonymous
I like this block.... The RAND(NOW()) function did not work for me. I kept getting the same image every time. I found this in a post on mysql.com: MD5(RAND()) This worked every time for me. Hope this helps....
 Quote

All times are EST. The time is now 09:24 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content