Author Topic: Seeing Top images by votes (with the image on homepage)  (Read 12998 times)

0 Members and 1 Guest are viewing this topic.

Offline hybridtuning

  • Newbie
  • *
  • Posts: 13
    • View Profile
Seeing Top images by votes (with the image on homepage)
« on: August 14, 2002, 06:16:51 PM »
has anyone done this or is it possable?

Seeing the top 3-5 images by votes on my homepage, (the image and the number of votes) than the user can click on the image and it takes them to that image in the 4images section ?

-T

Offline hybridtuning

  • Newbie
  • *
  • Posts: 13
    • View Profile
guess not
« Reply #1 on: August 15, 2002, 08:15:54 AM »
guess this isnt possable.. i tried a few things but i could not get it to work, i do have the radom image on the homepage, but i cat seem to get the top voted images to work

Offline Alan @ ArtScans

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • http://www.qcs-software.com
Seeing Top images by votes (with the image on homepage)
« Reply #2 on: August 15, 2002, 09:17:50 AM »
Hi,

It is possible to do this - I'll post the code tonight.

Thanks,
Alan.
Alan Wagstaff,
Software Development Manager, SDT
QCS Software

Offline hybridtuning

  • Newbie
  • *
  • Posts: 13
    • View Profile
great
« Reply #3 on: August 15, 2002, 10:56:12 PM »
thats great!!! i will await for the code, or you can email me at info@hybridtuning.com

thank you

-toby

Offline Alan @ ArtScans

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • http://www.qcs-software.com
Seeing Top images by votes (with the image on homepage)
« Reply #4 on: August 16, 2002, 12:20:14 AM »
Hi,

Sorry got snowed down with network problems today, and didn't get a chance to write the code.  However, the code you'll need is already in 4images\index.php - just needs a bit of editing.  

Look for the block that displays the new images.  If you still want 4images to display the new images on the homepage, as well as the top votes images, copy the entire block of code, and paste it below it.  Otherwise, just edit the new images code itself.

First of all, add the line
Code: [Select]
$top_votes_max=3;
at the top of the new block of code you have just pasted.  Set this value to however many images you want to display.

Next, find the line that reads
Code: [Select]
ORDER BY i.image_date DESC
To ...
Code: [Select]
ORDER BY i.image_votes DESC

That's the basic principle behind it - that will get you started.  You should really edit the templates, etc as well, make it look more professional.

My apologies for not writing it fully as promised, but we've had a few major disasters here today.

Thanks,
Alan.
Alan Wagstaff,
Software Development Manager, SDT
QCS Software

Offline hybridtuning

  • Newbie
  • *
  • Posts: 13
    • View Profile
Not Sure
« Reply #5 on: August 16, 2002, 12:41:28 AM »
Well I want this on the homepage of my site not the homepage of 4images? is that possable?

Offline hybridtuning

  • Newbie
  • *
  • Posts: 13
    • View Profile
ok
« Reply #6 on: August 16, 2002, 01:09:59 AM »
ok i got it to work.. but becuase i have the radom image and the top voted images now on the homepage i get an error about loading the header, and a db error on the radom part.. any suggestions? and how can it display the # of votes ?

http://www.hybridtuning.com/test.php

Offline hybridtuning

  • Newbie
  • *
  • Posts: 13
    • View Profile
got it but
« Reply #7 on: August 16, 2002, 08:17:54 AM »
got it to work but not i got this error

Code: [Select]

Warning: Cannot add header information - headers already sent by (output started at /usr/local/plesk/apache/vhosts/hybridtuning.com/httpdocs/index2.php:8) in /usr/local/plesk/apache/vhosts/hybridtuning.com/httpdocs/gallery/includes/sessions.php on line 52

Warning: Cannot add header information - headers already sent by (output started at /usr/local/plesk/apache/vhosts/hybridtuning.com/httpdocs/index2.php:8) in /usr/local/plesk/apache/vhosts/hybridtuning.com/httpdocs/gallery/includes/sessions.php on line 52

Warning: Cannot add header information - headers already sent by (output started at /usr/local/plesk/apache/vhosts/hybridtuning.com/httpdocs/index2.php:8) in /usr/local/plesk/apache/vhosts/hybridtuning.com/httpdocs/gallery/includes/sessions.php on line 52


the voteing images are a include page and so is the random on the left.
you can see it at

http://www.hybridtuning.com/index2.php

Offline Alan @ ArtScans

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • http://www.qcs-software.com
Seeing Top images by votes (with the image on homepage)
« Reply #8 on: August 16, 2002, 01:03:06 PM »
Hi,

Sorry, I didn't relize you wanted it on your website homepage, I assumed that you wanted it on your 4images homepage.

The code to display the mods will need to be extracted from index.php, and placed in a seperate file, as index.php is attempting to send sessions cookies, but cannot as your webpage has already sent some text (that's the "headers" it's talking about).

Doing this will then bring further problems, as the extracted code relies upon the 4images database classes, etc which may also try to start sessions.

I'll try and take a look at it today at some point, and post a new file tonight.

Thanks,
Alan.
Alan Wagstaff,
Software Development Manager, SDT
QCS Software

Offline hybridtuning

  • Newbie
  • *
  • Posts: 13
    • View Profile
here is the code that i have
« Reply #9 on: August 16, 2002, 06:48:57 PM »
Code: [Select]

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

$main_template 'votes';
define&#40;'ROOT_PATH', 'gallery/'&#41;;
include&#40;ROOT_PATH.'global.php'&#41;;
require&#40;ROOT_PATH.'includes/sessions.php'&#41;;



if &#40;isset&#40;$HTTP_GET_VARS['template'&#93;&#41; || isset&#40;$HTTP_POST_VARS['template'&#93;&#41;&#41; &#123;
  
$template = &#40;isset&#40;$HTTP_GET_VARS['template'&#93;&#41;&#41; ? stripslashes&#40;trim&#40;$HTTP_GET_VARS['template'&#93;&#41;&#41; &#58; stripslashes&#40;trim&#40;$HTTP_POST_VARS['template'&#93;&#41;&#41;;
  
if &#40;!file_exists&#40;TEMPLATE_PATH."/".$template.".".$site_template->template_extension&#41;&#41; &#123;
    
$template "";
  &
#125;
  
else &#123;
    
$main_template $template;
  &
#125;
&#125;
else &#123;
  
$template "";
&
#125;

if &#40;!empty&#40;$template&#41;&#41; &#123;
  
$clickstream "<a href=\"".$site_sess->url&#40;ROOT_PATH."index.php"&#41;."\">".$lang['home'&#93;."</a>".$config['category_separator'&#93;.str_replace&#40;"_", " ", ucfirst&#40;$template&#41;&#41;;
  
$site_template->register_vars&#40;"clickstream", $clickstream&#41;;
  
$site_template->print_template&#40;$site_template->parse_template&#40;$main_template&#41;&#41;;

&#125;



//-----------------------------------------------------
//--- Show New Images ---------------------------------
//-----------------------------------------------------
$top_votes_max=2;
$imgtable_width ceil&#40;intval&#40;$config['image_table_width'&#93;&#41; / $config['image_cells'&#93;&#41;;
if &#40;&#40;substr&#40;$config['image_table_width'&#93;, -1&#41;&#41; == "%"&#41; &#123;
  
$imgtable_width .= "%";
&
#125;

$cat_id_sql 0;
foreach &
#40;$cat_cache as $key => $val&#41; &#123;
  
if &#40;!check_permission&#40;"auth_viewcat", $key&#41;&#41; &#123;
    
$cat_id_sql .= ", ".$key;
  &
#125;
&#125;

$additional_sql "";
if &
#40;!empty&#40;$additional_image_fields&#41;&#41; &#123;
  
foreach &#40;$additional_image_fields as $key => $val&#41; &#123;
    
$additional_sql .= ", i.".$key;
  &
#125;
&#125;

$num_new_images $config['image_cells'&#93;;
$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.", u.user_name, c.cat_name 
        FROM "
.IMAGES_TABLE." i,  ".USERS_TABLE." u,  ".CATEGORIES_TABLE." c 
        WHERE i.image_active = 1 AND u.user_id = i.user_id AND c.cat_id = i.cat_id AND i.cat_id NOT IN &#40;
$cat_id_sql&#41; 
        ORDER BY i.image_votes DESC 
        LIMIT 
$num_new_images";
$result $site_db->query&#40;$sql&#41;;
$num_rows $site_db->get_numrows&#40;$result&#41;;

if &#40;!$num_rows&#41;  &#123;
  
$new_images "<table width=\"".$config['image_table_width'&#93;."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding'&#93;."\" cellspacing=\"".$config['image_table_cellspacing'&#93;."\"><tr class=\"imagerow1\"><td>";
  
$new_images .= $lang['no_new_images'&#93;;
  
$new_images .= "</td></tr></table>";
&
#125;
else  &#123;
  
$new_images "<table width=\"".$config['image_table_width'&#93;."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding'&#93;."\" cellspacing=\"".$config['image_table_cellspacing'&#93;."\">";
  
$count 0;
  
$bgcounter 0;
  while &
#40;$image_row = $site_db->fetch_array&#40;$result&#41;&#41;&#123;
    
if &#40;$count == 0&#41; &#123;
      
$row_bg_number = &#40;$bgcounter++ % 2 == 0&#41; ? 1 &#58; 2;
      
$new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    &
#125;
    
$new_images .= "<td width=\"".$imgtable_width."\" valign=\"bottom\">\n";

    
show_image&#40;$image_row&#41;;
    
$new_images .= $site_template->parse_template&#40;"thumbnail_bit2"&#41;;
    
$new_images .= "\n</td>\n";
    
$count++;
    if &
#40;$count == $config['image_cells'&#93;&#41; &#123;
      
$new_images .= "</tr>\n";
      
$count 0;
    &
#125;
  
&#125; // end while

  
if &#40;$count > 0&#41;  &#123;
    
$leftover = &#40;$config['image_cells'&#93; - $count&#41;;
    
if &#40;$leftover >= 1&#41; &#123;
      
for &#40;$f = 0; $f < $leftover; $f++&#41; &#123;
        
$new_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;</td>\n";
      &
#125;
      
$new_images .= "</tr>\n";
    &
#125;
  
&#125;
  
$new_images .= "</table>\n";
&
#125; // end else

$site_template->register_vars&#40;"new_images", $new_images&#41;;
unset&#40;$new_images&#41;;

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars&#40;array&#40;
  
"msg" => $msg,
  
"clickstream" => $clickstream
&#41;&#41;;
$site_template->print_template&#40;$site_template->parse_template&#40;$main_template&#41;&#41;;

?>


Offline hybridtuning

  • Newbie
  • *
  • Posts: 13
    • View Profile
working but
« Reply #10 on: August 17, 2002, 07:07:10 AM »
i got it working using a iframe on the homepage.. and doing the popup thumbnails.. heres is another questions.. how can I display the number of votes?

http://www.hybridtuning.com
-Toby
info@hybridtuning.com

Offline dj9live

  • Newbie
  • *
  • Posts: 22
    • View Profile
Seeing Top images by votes (with the image on homepage)
« Reply #11 on: August 22, 2002, 01:22:35 PM »
could you tell me how i get this work like your page? so what must i do to get the best voted pics on a html page outside the 4images tool

thnx

kai

Offline hybridtuning

  • Newbie
  • *
  • Posts: 13
    • View Profile
here is the code that i used to make it work.
« Reply #12 on: August 26, 2002, 06:11:36 PM »
Here is the showvotes.php file i saved this in my root directory

Code: [Select]

<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File&#58; index.php                                            *
 *        Copyright&#58; &#40;C&#41; 2002 Jan Sorgalla                                *
 *            Email&#58; jan@4homepages.de                                    *
 *              Web&#58; http&#58;//www.4homepages.de                             *
 *    Scriptversion&#58; 1.6.1                                                *
 *                                                                        *
 *    Never released without support from&#58; Nicky &#40;http&#58;//www.nicky.net&#41;   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen &#40;Lizenz.txt&#41; für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    &#40;Licence.txt&#41; for further information.                              *
 *                                                                        *
 *************************************************************************/
$templates_used 'thumbnail_bit2';
$main_template 'votes';
define&#40;'GET_CACHES', 1&#41;;
define&#40;'ROOT_PATH', 'gallery/'&#41;;
define&#40;'GET_USER_ONLINE', 1&#41;;
include&#40;ROOT_PATH.'global.php'&#41;;
require&#40;ROOT_PATH.'includes/sessions.php'&#41;;

$user_access get_permission&#40;&#41;;

if &#40;isset&#40;$HTTP_GET_VARS['template'&#93;&#41; || isset&#40;$HTTP_POST_VARS['template'&#93;&#41;&#41; &#123;
  
$template = &#40;isset&#40;$HTTP_GET_VARS['template'&#93;&#41;&#41; ? stripslashes&#40;trim&#40;$HTTP_GET_VARS['template'&#93;&#41;&#41; &#58; stripslashes&#40;trim&#40;$HTTP_POST_VARS['template'&#93;&#41;&#41;;
  
if &#40;!file_exists&#40;TEMPLATE_PATH."/".$template.".".$site_template->template_extension&#41;&#41; &#123;
    
$template "";
  &
#125;
  
else &#123;
    
$main_template $template;
  &
#125;
&#125;
else &#123;
  
$template "";
&
#125;


if &#40;!empty&#40;$template&#41;&#41; &#123;
  
$clickstream "<a href=\"".$site_sess->url&#40;ROOT_PATH."index.php"&#41;."\">".$lang['home'&#93;."</a>".$config['category_separator'&#93;.str_replace&#40;"_", " ", ucfirst&#40;$template&#41;&#41;;
  
$site_template->register_vars&#40;"clickstream", $clickstream&#41;;
  
$site_template->print_template&#40;$site_template->parse_template&#40;$main_template&#41;&#41;;

&#125;



//-----------------------------------------------------
//--- Show New Images ---------------------------------
//-----------------------------------------------------
$imgtable_width ceil&#40;intval&#40;$config['image_table_width'&#93;&#41; / $config['image_cells'&#93;&#41;;
if &#40;&#40;substr&#40;$config['image_table_width'&#93;, -1&#41;&#41; == "%"&#41; &#123;
  
$imgtable_width .= "%";
&
#125;

$cat_id_sql 0;
foreach &
#40;$cat_cache as $key => $val&#41; &#123;
  
if &#40;!check_permission&#40;"auth_viewcat", $key&#41;&#41; &#123;
    
$cat_id_sql .= ", ".$key;
  &
#125;
&#125;

$additional_sql "";
if &
#40;!empty&#40;$additional_image_fields&#41;&#41; &#123;
  
foreach &#40;$additional_image_fields as $key => $val&#41; &#123;
    
$additional_sql .= ", i.".$key;
  &
#125;
&#125;

$num_new_images $config['image_cells'&#93;;
$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.", u.user_name, c.cat_name 
        FROM "
.IMAGES_TABLE." i,  ".USERS_TABLE." u,  ".CATEGORIES_TABLE." c 
        WHERE i.image_active = 1 AND u.user_id = i.user_id AND c.cat_id = i.cat_id AND i.cat_id NOT IN &#40;
$cat_id_sql&#41; 
        ORDER BY i.image_votes DESC 
        LIMIT 
$num_new_images";
$result $site_db->query&#40;$sql&#41;;
$num_rows $site_db->get_numrows&#40;$result&#41;;

if &#40;!$num_rows&#41;  &#123;
  
$new_images "<table width=\"".$config['image_table_width'&#93;."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding'&#93;."\" cellspacing=\"".$config['image_table_cellspacing'&#93;."\"><tr class=\"imagerow1\"><td>";
  
$new_images .= $lang['no_new_images'&#93;;
  
$new_images .= "</td></tr></table>";
&
#125;
else  &#123;
  
$new_images "<table width=\"".$config['image_table_width'&#93;."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding'&#93;."\" cellspacing=\"".$config['image_table_cellspacing'&#93;."\">";
  
$count 0;
  
$bgcounter 0;
  while &
#40;$image_row = $site_db->fetch_array&#40;$result&#41;&#41;&#123;
    
if &#40;$count == 0&#41; &#123;
      
$row_bg_number = &#40;$bgcounter++ % 2 == 0&#41; ? 1 &#58; 2;
      
$new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    &
#125;
    
$new_images .= "<td width=\"".$imgtable_width."\" valign=\"bottom\">\n";

    
show_image&#40;$image_row&#41;;
    
$new_images .= $site_template->parse_template&#40;"thumbnail_bit2"&#41;;
    
$new_images .= "\n</td>\n";
    
$count++;
    if &
#40;$count == $config['image_cells'&#93;&#41; &#123;
      
$new_images .= "</tr>\n";
      
$count 0;
    &
#125;
  
&#125; // end while

  
if &#40;$count > 0&#41;  &#123;
    
$leftover = &#40;$config['image_cells'&#93; - $count&#41;;
    
if &#40;$leftover >= 1&#41; &#123;
      
for &#40;$f = 0; $f < $leftover; $f++&#41; &#123;
        
$new_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;</td>\n";
      &
#125;
      
$new_images .= "</tr>\n";
    &
#125;
  
&#125;
  
$new_images .= "</table>\n";
&
#125; // end else

$site_template->register_vars&#40;"new_images", $new_images&#41;;
unset&#40;$new_images&#41;;

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars&#40;array&#40;
  
"msg" => $msg,
  
"clickstream" => $clickstream,
  
"lang_rating" => $lang['rating'&#93;,
  
"lang_votes" => $lang['votes'&#93;
&#41;&#41;;
$site_template->print_template&#40;$site_template->parse_template&#40;$main_template&#41;&#41;;

?>




here is the template (thumbnail_bit2) which has to be saved into the template directory of 4images

Code: [Select]

<script language="JavaScript" type="text/javascript">
<!--
  function opendetailwindow() {
    window.open('','detailwindow','toolbar=yes,scrollbars=yes,resizable=yes,width=700,height=500');
  }
 
  function right(e) {
    if (navigator.appName == 'Netscape' && (e.which == 2 || e.which == 3)) {
      alert('© Copyright by {site_name}');
      return false;
    }
    else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button==2 || event.button == 3)) {
      alert('© Copyright by {site_name}');
      return false;
    }
    return true;
  }
  document.onmousedown=right;
  if (document.layers) window.captureEvents(Event.MOUSEDOWN);
  window.onmousedown=right;
// -->
</script>
<script language="JavaScript">

<!--
function reqWin(desktopURL){
        desktop =window.open(desktopURL,"name","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=700,height=500,resizable=yes");
        }
// -->

</script>
<!-- you wish detail page in a small javascript open window, use {thumbnail_openwindow} -->
<style>
a { color:#666666; text-decoration:none; } /* Link Defaults: Dark Blue, Gray Hover */
a:link { color:#666666; font size:10;}
a:visited { color:#666666; }
a:hover { background-color:#eeeeee; color:#FF6600; }
a img { border:none; }
</style>
<table width="100" height="100" border="0" cellpadding="5" cellspacing="0">
<tr>
    <td width="100" height="100" align="center" valign="middle" bgcolor="#F3F3F3">{thumbnail_openwindow}</td>
  </tr>
  <tr>
    <td height="10" align="center" valign="middle" bgcolor="#F3F3F3"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Rating
      {image_rating}{image_votes}</font></td>
  </tr>
</table>



i used a iframe on my index.php to include the showvotes.php, and thats it..

-T