Author Topic: Random pictures  (Read 229638 times)

0 Members and 1 Guest are viewing this topic.

Offline TaijovuNeji

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: Random pictures
« Reply #120 on: December 04, 2008, 03:41:18 AM »
One more question: How do I put the image in the center??
This command not works: align="center" .. why? o.O

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Random pictures
« Reply #121 on: December 04, 2008, 04:26:03 AM »
that is something you can do in thumbnail_bit.html template
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TaijovuNeji

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: Random pictures
« Reply #122 on: January 02, 2009, 07:06:37 PM »
But now shows this error message: Parse error: syntax error, unexpected '}' in /home/dungeonm/public_html/galeriadm/includes/template.php(101) : eval()'d code on line 3

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Random pictures
« Reply #123 on: January 02, 2009, 11:45:50 PM »
With the amount of information you've proved the only possible answer you could get is:
that error indicates that you did something wrong in a template file.

if you used PHP code in template, then number of { is mismatched with number of }
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TaijovuNeji

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: Random pictures
« Reply #124 on: January 11, 2009, 03:57:57 PM »
So, you can take a look in de index.php for me?
The code:

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: index.php                                            *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    * 
 *              Web: http://www.4homepages.de                             * 
 *    Scriptversion: 1.7.6                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

$templates_used 'home,category_bit,whos_online,thumbnail_bit';
$main_template 'home';

define('GET_CACHES'1);
define('ROOT_PATH''./');
define('GET_USER_ONLINE'1);
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$user_access get_permission();

if (isset(
$HTTP_GET_VARS['template']) || isset($HTTP_POST_VARS['template'])) {
  
$template = (isset($HTTP_GET_VARS['template'])) ? get_basefile(stripslashes($HTTP_GET_VARS['template'])) : get_basefile(stripslashes($HTTP_POST_VARS['template']));
  if (!
file_exists(TEMPLATE_PATH."/".$template.".".$site_template->template_extension)) {
    
$template "";
  }
  else {
    
$main_template $template;
  }
}
else {
  
$template "";
}
include(
ROOT_PATH.'includes/page_header.php');

if (!empty(
$template)) {
  
$clickstream "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].str_replace("_"" "ucfirst($template));
  
$site_template->register_vars("clickstream"$clickstream);
  
$site_template->print_template($site_template->parse_template($main_template));
  include(
ROOT_PATH.'includes/page_footer.php');
}

$cache_id create_cache_id(
  
'page.index',
  array(
    
$user_info[$user_table_fields['user_id']],
    isset(
$user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 08) : 0,
    
$config['template_dir'],
    
$config['language_dir']
  )
);

if (!
$cache_page_index || !$content get_cache_file($cache_id)) {
// Always append session id if cache is enabled
if ($cache_page_index) {
  
$old_session_mode $site_sess->mode;
  
$site_sess->mode 'get';
}

ob_start();

//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
$categories get_categories(0);
if (!
$categories)  {
  
$categories $lang['no_categories'];
}
$site_template->register_vars("categories"$categories);
unset(
$categories);

//-----------------------------------------------------
//--- Show New Images ---------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"has_rss"   => true,
  
"rss_title" => "RSS Feed: ".format_text($config['site_name'], 2)." (".str_replace(':'''$lang['new_images']).")",
  
"rss_url"   => $script_url."/rss.php?action=images"
));

$imgtable_width ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((
substr($config['image_table_width'], -1)) == "%") {
  
$imgtable_width .= "%";
}

$additional_sql "";
if (!empty(
$additional_image_fields)) {
  foreach (
$additional_image_fields as $key => $val) {
    
$additional_sql .= ", i.".$key;
  }
}

$num_new_images $config['image_cells'];
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT 
$num_new_images";
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$new_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
$new_images .= $lang['no_new_images'];
  
$new_images .= "</td></tr></table>";
}
else  {
  
$new_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  
$count 0;
  
$bgcounter 0;
  while (
$image_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$new_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    
show_image($image_row);
    
$new_images .= $site_template->parse_template("thumbnail_bit");
    
$new_images .= "\n</td>\n";
    
$count++;
    if (
$count == $config['image_cells']) {
      
$new_images .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['image_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$new_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      
$new_images .= "</tr>\n";
    }
  }
  
$new_images .= "</table>\n";
// end else

$site_template->register_vars("new_images"$new_images);
unset(
$new_images);

//------------------------------------
//------- Random Images --------------
//------------------------------------
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN ("
.get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT 
$num_new_images";
// end new
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
  
$random_images .= "</td></tr></table>";
}
else  {
  
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  
$count 0;
  
$bgcounter 0;
  while (
$image_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    
show_image($image_row);
    
$random_images .= $site_template->parse_template("thumbnail_bit");
    
$random_images .= "\n</td>\n";
    
$count++;
    if (
$count == $config['image_cells']) {
      
$random_images .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['image_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      
$random_images .= "</tr>\n";
    }
  }
  
$random_images .= "</table>\n";
// end else


$site_template->register_vars("random_images"$random_images);
unset(
$random_images);

//----- End Random Images---------


//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream
));
$site_template->print_template($site_template->parse_template($main_template));

$content ob_get_contents();
ob_end_clean();

if (
$cache_page_index) {
  
// Reset session mode
  
$site_sess->mode $old_session_mode;

  
save_cache_file($cache_id$content);
}

// end if get_cache_file()

echo $content;

include(
ROOT_PATH.'includes/page_footer.php');
?>
   
What did I do wrong?
« Last Edit: January 13, 2009, 04:10:49 AM by TaijovuNeji »

Offline jorge05r

  • Pre-Newbie
  • Posts: 6
    • View Profile
    • Portfolio of Jorge Linares
Random Images: How to show images from "x" category
« Reply #125 on: January 14, 2009, 12:29:20 AM »
I searched the forum before asking this question but didn't find anything specific.

Here's the site http://itouchwallpapers.com/ , see where I have the random images section?

I have a mod which it shows "random images" but I would like the random images from 2 categories only. How could I make the random images mod show only two specific categories and not from all images/photos from the site?
Web/Print Designer experience w/ Joomla, Wordpress, Oscommerce, 4Images, Psd to xhtml/css and many more services.
VISIT MY PORTFOLIO

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Random Images: How to show images from "x" category
« Reply #126 on: January 14, 2009, 02:23:26 AM »
Hello and welcome to 4images forum.

In includes/functions.php find:
Code: [Select]
  if (!empty($random_image_cache[$category_id])) {
Insert above:
Code:  [Select]  [Expand]
  srand((float)microtime() * 1000000);
  $category_id = array_rand(array(1, 2));

Replace numbers 1 and 2 with your category IDs
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline jorge05r

  • Pre-Newbie
  • Posts: 6
    • View Profile
    • Portfolio of Jorge Linares
Re: Random Images: How to show images from "x" category
« Reply #127 on: January 16, 2009, 10:02:05 PM »
Thank you!

Sorry if I didn't explain myself better. I meant the "random images" addon on the center of the page which is currently showing 4 random images (the box below categories) This only worked for the random images box on the left column.

This is the code I used to display "random images on main page" posted by you http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513
Web/Print Designer experience w/ Joomla, Wordpress, Oscommerce, 4Images, Psd to xhtml/css and many more services.
VISIT MY PORTFOLIO

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Random pictures
« Reply #128 on: January 17, 2009, 01:35:28 AM »
This is a perfect example, why we are trying encourage people reply to the appropriate topics, instead of starting new ones.

Replace
Code: [Select]
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")

with
Code: [Select]
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (1,2)

P.S.
Topics merged.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TaijovuNeji

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: Random pictures
« Reply #129 on: January 19, 2009, 04:57:40 PM »
Sorry to boder you.. but can you take a look in my gallery?
The link: www.dungeonmakers.com.br/galeriadm
The random imagens not appear.. why? O.o

Offline KurtW

  • 4images Guru
  • *******
  • Posts: 2.778
    • View Profile
    • Malediven-Bilder ~~Dreams~~
Re: Random pictures
« Reply #130 on: January 19, 2009, 05:50:05 PM »
Sorry to boder you.. but can you take a look in my gallery?
The link: www.dungeonmakers.com.br/galeriadm
The random imagens not appear.. why? O.o

Hi TaijovuNeji,

do you have read the copyright notice in the footer.html  :?:

Quote
    Please note that the following copyright notice
    MUST be displayed on each and every page output
    by 4images. You may alter the font, colour etc. but
    you CANNOT remove it, nor change it so that it be,
    to all intents and purposes, invisible. The hyperlink
    http://www.4homepages.de must also remain intact.
    These conditions are part of the licence this software
    is released under. See the Licence.txt file for
    more information.


Kurt


Offline TaijovuNeji

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: Random pictures
« Reply #131 on: January 22, 2009, 03:44:21 AM »
man! O.o .. I didn't read that O.O .. I will put the copyright back.. sorry for this

But anybody can help me?

Offline yesme

  • Jr. Member
  • **
  • Posts: 61
  • Yes for 4images!
    • View Profile
Re: Random pictures
« Reply #132 on: February 18, 2009, 03:38:36 PM »
I am so sorry if I have asked the similar question to the rest of 4images users but this thread is too long. After checked one page to one page, and tried the scripts/codes the results seems not right. Now I am getting confused with this thread whether to display random image in the left menu or the main section?

Then I decided to ask you all here,

May I know how to get multiple random images e.g 3 random images in the left menu?

I am using version 1.7.6

p.s I have tried V@no's plugin but didnt work as my imagination.

Thanks.
Love 4images! @--^-----

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Random pictures
« Reply #133 on: February 18, 2009, 04:24:18 PM »
This topic is more about non-4images pages or external sites.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline yesme

  • Jr. Member
  • **
  • Posts: 61
  • Yes for 4images!
    • View Profile
Re: Random pictures
« Reply #134 on: February 18, 2009, 04:26:53 PM »
I have tried just now with these codes:

Code: [Select]
//-----------------------------------------------------
//--- Random Image ------------------------------------
//-----------------------------------------------------
$random_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image();
$random_image2 = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image();
$site_template->register_vars("random_image", $random_image);
$site_template->register_vars("random_image2", $random_image2);
unset($random_image);
unset($random_image2);

Am I right? Are these codes suppose displays random image at a one time together?
Love 4images! @--^-----