• [Mod] Star Rating 5 0 5 1
Currently:  

Author Topic: [Mod] Star Rating  (Read 149891 times)

0 Members and 1 Guest are viewing this topic.

Offline uksoreeyes

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.myleeneklass.com
[Mod] Star Rating
« Reply #30 on: April 24, 2003, 10:42:38 PM »
Thanks again V@no, made a slight change by adding an alt tag to show the actual rating when a user hovers over the stars. I also removed the <b></b> tags as they don't seem to be getting used. I added the star rating to top 10 images by votes

Open top.php

Top 10 images by rating with alt text.

find:
Code: [Select]
$register_array['image_rating_number_'.$i] = "<b>".$top_list[$i]['image_rating']."</b> (".$top_list[$i]['image_votes']." ".$lang['votes'].")";
replace with:
Code: [Select]
$register_array['image_rating_number_'.$i] = "<img src=\"".TEMPLATE_PATH."/images/".floor($top_list[$i]['image_rating']).".gif\" alt=\"Rating: ".$top_list[$i]['image_rating']." (".$top_list[$i]['image_votes']." ".$lang['votes'].")\"> "."(".$top_list[$i]['image_votes']." ".$lang['votes'].")";
Top 10 images by votes with alt text.

find:
Code: [Select]
$register_array['image_votes_number_'.$i] = "<b>".$top_list[$i]['image_rating']."</b> (".$top_list[$i]['image_votes']." ".$lang['votes'].")";
replace with:
Code: [Select]
$register_array['image_votes_number_'.$i] = "<img src=\"".TEMPLATE_PATH."/images/".floor($top_list[$i]['image_rating']).".gif\" alt=\"Rating: ".$top_list[$i]['image_rating']." (".$top_list[$i]['image_votes']." ".$lang['votes'].")\"> "."(".$top_list[$i]['image_votes']." ".$lang['votes'].")";
This is a great Mod if u would like to see my top images with the stars go here: http://www.myleeneklass.com/top.php

Offline andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[Mod] Star Rating
« Reply #31 on: May 12, 2003, 09:17:13 AM »
Have anyidea got below error?

Fatal error: Call to undefined function: get_potd_image() in /home/httpd/html/bullroad/gallery/includes/page_header.php on line 152
What's wrong, huh?

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
[Mod] Star Rating
« Reply #32 on: May 12, 2003, 11:37:21 AM »
this error has nothing to do with this mod (?).
it seems it can not find get_potd_image function ;) that is "Picture Of The Day" MOD
if it happend after u installed "Stars" MOD, then check again the installation, u might missed closing bracket ( } ) or quote, or semicolon.


P.S. this MOD can be done with just two lines of code, and do exactly same thing, plus it wont be restricted to max rating 5 ;) D:

in /includes/functions.php find:
Code: [Select]
"image_rating" => $image_row['image_rating'], add after:
Code: [Select]
"image_rating_round" => round($image_row['image_rating']),
then, in templates add this:
Code: [Select]
<img src="{template_image_url}/{image_rating_round}.gif">
that's it :D. just make sure your images are named as 1.gif, 2.gif ... 5.gif, 6.gif, 10.gif ... 10000.gif whatever number is max u want to show :D
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 andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[Mod] Star Rating
« Reply #33 on: May 12, 2003, 12:14:09 PM »
Thanks for help.

i had do all you mention as above.

BUT still failed on below message

Fatal error: Call to undefined function: get_potd_image() in /home/httpd/html/bullroad/gallery/includes/page_header.php on line 152



below is /includes/functions.php

  $site_template->register_vars(array(
    "image_id" => $image_row['image_id'],
    "user_id" => $image_row['user_id'],
    "user_name" => $user_name,
    "user_name_link" => $user_name_link,
    "image_name" => $image_row['image_name'],
    "image_description" => $description,
    "image_keywords" => $keywords,
    "image_date" => format_date($config['date_format']." ".$config['time_format'],$image_row['image_date']),
    "image_is_new" => $is_new,
    "lang_new" => $lang['new'],
    "image_active" => $image_row['image_active'],
    "cat_id" => $image_row['cat_id'],
    "cat_name" => $image_row['cat_name'],
    "cat_url" => $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$image_row['cat_id']),
    "image_downloads" => $image_row['image_downloads'],
    "image_votes" => $image_row['image_votes'],
    "image_rating" => $image_row['image_rating'],
    "image_rating_round" => round($image_row['image_rating']),
    "image_hits" => $image_row['image_hits'],
    "allow_comments" => $image_row['image_allow_comments'],
    "lang_comments" => $lang['comments'],
    "image_comments" => $num_comments,
    "lightbox_button" => $lightbox_button,
    "postcard_button" => $postcard_button,
    "download_button" => $download_button,
    "download_zip_button" => $download_zip_button,
    "image_download_url" => $image_row['image_download_url'],
    "allow_download" => $allow_download,
    "url_download" => $site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']),
    "image_file_size" => $file_size,
    "image" => get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view),
    "thumbnail" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link),
    "thumbnail_openwindow" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, 1),
    "image_file_name" => $image_row['image_media_file'],
    "thumbnail_file_name" => $image_row['image_thumb_file']
  ));



Below is my /templates/4waters/thumbnail_bit.html
==============================

<!-- you wish detail page in a small javascript open window, use {thumbnail_openwindow} -->
{thumbnail}<br />
<b>{image_name}</b> {if image_is_new}<sup class="new">{lang_new}</sup>{endif image_is_new} ({user_name_link})
<br />
<a href="{cat_url}">{cat_name}</a><br />
{if allow_comments}{lang_comments} {image_comments}{endif allow_comments}<br />
<img src="{template_image_url}/{image_rating_round}.gif">
{lightbox_button}

Below this is my previous test, but fail too.
============================================

<!-- you wish detail page in a small javascript open window, use {thumbnail_openwindow} -->
{thumbnail}<br />
<b>{image_name}</b> {if image_is_new}<sup class="new">{lang_new}</sup>{endif image_is_new} ({user_name_link})
<br />
<a href="{cat_url}">{cat_name}</a><br />
{if allow_comments}{lang_comments} {image_comments}{endif allow_comments}<br />
<img src="{template_lang_image_url}/{rating_pic}" alt="{lang_rating} {image_rating} ({image_votes} {lang_votes})" /><br />
{lightbox_button}


I am also tried this below on /templates/4waters/potd_image.html when I got above fail.
===============================

<table width="150" border="0" cellspacing="0" cellpadding="0">
  <tr><td class="head2" height="20" align="center"><img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_potd_title}</td></tr>
  <tr><td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td></tr>
  <tr><td align="center" class="row1">{thumbnail}<br><b>{image_name}<br>
<img src="{template_image_url}/{image_rating_round}.gif">      </b></td></tr>
  <tr><td align="center" class="row1">{lang_potd_type}</td></tr>
  <tr><td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td></tr>
</table>

Do I done any wrong?
What's wrong, huh?

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
[Mod] Star Rating
« Reply #34 on: May 12, 2003, 12:17:41 PM »
and the problem is....?
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 andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[Mod] Star Rating
« Reply #35 on: May 12, 2003, 12:19:10 PM »
sorry for miss answer I had edited.  :oops:

===========================
BUT still failed on below message

Fatal error: Call to undefined function: get_potd_image() in /home/httpd/html/bullroad/gallery/includes/page_header.php on line 152
===========================
What's wrong, huh?

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
[Mod] Star Rating
« Reply #36 on: May 12, 2003, 12:24:36 PM »
ok, but did u install Photo Of The Day  mod?
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 andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[Mod] Star Rating
« Reply #37 on: May 12, 2003, 12:30:24 PM »
Yes I did install the Photo Of the Day mod before I mod this Star Rate mode.

P/s: Photo Of the Day mod work perfectly, no error.

So which 1 I had made a mistake on above scripts?
What's wrong, huh?

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
[Mod] Star Rating
« Reply #38 on: May 12, 2003, 12:40:22 PM »
Quote from: andersen
P/s: Photo Of the Day mod work perfectly, no error.

So which 1 I had made a mistake on above scripts?

sorry, but I have no clue...hope u have backup of what u changed, try to restore whatever u did when installing this "Stars" MOD, see if the error gone, and try again.
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 andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[Mod] Star Rating
« Reply #39 on: May 12, 2003, 01:04:18 PM »
Actually I had rename the

/includes/functions.php to "functions-backup.php"
/templates/4waters/thumbnail_bit.html  to "thumbnail_bit-backup.html"

before I modify the Star rating mod.

when I rename back to "*-backup.php", everthing back to original.


one more information wish to provide as  /includes/functions.php


if ($image_row['image_rating'] == '5.00') {  
     $rating_pic = "5.gif";  
  } elseif ($image_row['image_rating'] >= '4.00') {  
     $rating_pic = "4.gif";  
  } elseif ($image_row['image_rating'] >= '3.00') {  
     $rating_pic = "3.gif";  
  } elseif ($image_row['image_rating'] >= '2.00') {  
     $rating_pic = "2.gif";  
  } elseif ($image_row['image_rating'] >= '1.00') {  
     $rating_pic = "1.gif";  
  } else {  
     $rating_pic = "0.gif";  
  }  
  $site_template->register_vars(array(
     "rating_pic" => $rating_pic,  
     "lang_rating" => $lang['rating'],
     "lang_votes" => $lang['votes']
  ));

any thing wrong?
What's wrong, huh?

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
[Mod] Star Rating
« Reply #40 on: May 12, 2003, 01:14:38 PM »
Quote from: andersen
any thing wrong?

looks ok. does it work after restore? please, be more discribing whats goin on when do "this and that", so I dont have to ask this kind of questions, that make the thread less usefull.
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 andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[Mod] Star Rating
« Reply #41 on: May 13, 2003, 11:09:47 AM »
Ok, This thread will made my explain very detail. I had restore back everthing to original. From a 4Image with 100% (for me) fine. Now I am start again for my "star rating mod" as below. (I am doing step by step on real time installation now too..)

I open my includes/functions.php

searching below information:-

else {
    $keywords = REPLACE_EMPTY;
  }

  if (!check_permission("auth_readcomment", $image_row['cat_id'])) {
    $image_row['image_allow_comments'] = 0;
  }

  $num_comments = ($image_row['image_allow_comments'] == 1) ? $image_row['image_comments'] : "";


change to

   $keywords = REPLACE_EMPTY;
  }

  if (!check_permission("auth_readcomment", $image_row['cat_id'])) {
    $image_row['image_allow_comments'] = 0;
  }

if ($image_row['image_rating'] == '5.00') {  
     $rating_pic = "5.gif";  
  } elseif ($image_row['image_rating'] >= '4.00') {  
     $rating_pic = "4.gif";  
  } elseif ($image_row['image_rating'] >= '3.00') {  
     $rating_pic = "3.gif";  
  } elseif ($image_row['image_rating'] >= '2.00') {  
     $rating_pic = "2.gif";  
  } elseif ($image_row['image_rating'] >= '1.00') {  
     $rating_pic = "1.gif";  
  } else {  
     $rating_pic = "0.gif";  
  }  
  $site_template->register_vars(array(
     "rating_pic" => $rating_pic,  
     "lang_rating" => $lang['rating'],
     "lang_votes" => $lang['votes']
  ));

  $num_comments = ($image_row['image_allow_comments'] == 1) ? $image_row['image_comments'] : "";


AND ALSO

"image_votes" => $image_row['image_votes'],
    "image_rating" => $image_row['image_rating'],
    "image_hits" => $image_row['image_hits'],


Change to

"image_votes" => $image_row['image_votes'],
    "image_rating" => $image_row['image_rating'],
    "image_rating_round" => round($image_row['image_rating']),
    "image_hits" => $image_row['image_hits'],


I save it and re-upload to my server in includes/

Then I open this templates/4waters/thumnail_bit.html as below

<!-- you wish detail page in a small javascript open window, use {thumbnail_openwindow} -->
{thumbnail}<br />
<b>{image_name}</b> {if image_is_new}<sup class="new">{lang_new}</sup>{endif image_is_new} ({user_name_link})
<br />
<a href="{cat_url}">{cat_name}</a><br />
{if allow_comments}{lang_comments} {image_comments}{endif allow_comments}<br />
{lightbox_button}


Then I change it to

<!-- you wish detail page in a small javascript open window, use {thumbnail_openwindow} -->
{thumbnail}<br />
<b>{image_name}</b> {if image_is_new}<sup class="new">{lang_new}</sup>{endif image_is_new} ({user_name_link})
<br />
<a href="{cat_url}">{cat_name}</a><br><img src="{template_image_url}/{image_rating_round}.gif"><br />
{if allow_comments}{lang_comments} {image_comments}{endif allow_comments}<br />
{lightbox_button}


save it to /templates/4waters/

Last, I run on my index.php. the result is......

Fatal error: Call to undefined function: get_potd_image() in /home/httpd/html/bullroad/gallery/includes/page_header.php on line 152


I hope it is detail enough. Do I done wrong anything step?

Please... headache ---> Andersen /_\
What's wrong, huh?

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
[Mod] Star Rating
« Reply #42 on: May 13, 2003, 11:18:26 AM »
hmm...seems that u didnt overwrite /includes/page_header.php with new file from the package...
what is on line 152 in it?
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 andersen

  • Newbie
  • *
  • Posts: 34
    • View Profile
[Mod] Star Rating
« Reply #43 on: May 13, 2003, 12:08:41 PM »
Do I missing something at below?

includes/page_header.php


<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: page_header.php                                      *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7                                                  *
 *                                                                        *
 *    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.                              *
 *                                                                        *
 *************************************************************************/
if (!defined('ROOT_PATH')) {
  die("Security violation");
}

// Cache Templates
$template_list = 'header,footer,category_dropdown_form,user_logininfo,user_loginform';
if (isset($templates_used) && $templates_used != "") {
  $template_list = $template_list.",".$templates_used;
}
$site_template->cache_templates($template_list);

//-----------------------------------------------------
//--- Register Global Vars ----------------------------
//-----------------------------------------------------
$total_images = 0;
$total_categories = 0;
$auth_cat_sql['auth_viewcat']['IN'] = 0;
$auth_cat_sql['auth_viewcat']['NOTIN'] = 0;
if (!empty($cat_cache)) {
  foreach ($cat_cache as $key => $val) {
    if (check_permission("auth_viewcat", $key)) {
      $total_categories++;
      if (isset($val['num_images'])) {
        $total_images += $val['num_images'];
      }
      else {
        $cat_cache[$key]['num_images'] = 0;
      }
      $auth_cat_sql['auth_viewcat']['IN'] .= ", ".$key;
    }
    else {
      $auth_cat_sql['auth_viewcat']['NOTIN'] .= ", ".$key;
    }
  }
}

$site_template->register_vars(array(
  "media_url" => MEDIA_PATH,
  "thumb_url" => THUMB_PATH,
  "icon_url" => ICON_PATH,
  "template_url" => TEMPLATE_PATH,
  "template_image_url" => TEMPLATE_PATH."/images",
  "template_lang_image_url" => TEMPLATE_PATH."/images_".$config['language_dir'],
  "site_name" => $config['site_name'],
  "site_email" => $config['site_email'],
  "self" => $site_sess->url($self_url),
  "self_full" => $site_sess->url($script_url."/".$self_url),
  "script_version" => SCRIPT_VERSION,
  "cp_link" => ($user_info['user_level'] != ADMIN) ? "" : "\n<p align=\"center\">[<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php")."\">Control Panel</a>]</p>\n",
  "total_categories" => $total_categories,
  "total_images" => $total_images,
  "url_new_images" => $site_sess->url(ROOT_PATH."search.php?search_new_images=1"),
  "url_top_images" => $site_sess->url(ROOT_PATH."top.php"),
  "url_top_cat_images" => $site_sess->url(ROOT_PATH."top.php".(($cat_id && preg_match("/categories.php/", $self_url)) ? "?".URL_CAT_ID."=".$cat_id : "")),
  "url_register" => (!empty($url_register)) ? $site_sess->url($url_register) : $site_sess->url(ROOT_PATH."register.php"),
  "url_search" => $site_sess->url(ROOT_PATH."search.php"),
  "url_lightbox" => $site_sess->url(ROOT_PATH."lightbox.php"),
  "url_control_panel" => (!empty($url_control_panel)) ? $site_sess->url($url_control_panel) : $site_sess->url(ROOT_PATH."member.php?action=editprofile"),
  "url_categories" => $site_sess->url(ROOT_PATH."categories.php"),
  "url_home" => $site_sess->url(ROOT_PATH."index.php"),
  "url_login" => (!empty($url_login)) ? $site_sess->url($url_login) : $site_sess->url(ROOT_PATH."login.php"),
  "url_logout" => (!empty($url_logout)) ? $site_sess->url($url_logout) : $site_sess->url(ROOT_PATH."logout.php"),
  "url_member" => (!empty($url_member)) ? $site_sess->url($url_member) : $site_sess->url(ROOT_PATH."member.php"),
  "url_upload" => (!empty($url_upload)) ? $site_sess->url($url_upload) : $site_sess->url(ROOT_PATH."member.php?action=uploadform"),
  "url_lost_password" => (!empty($url_lost_password)) ? $site_sess->url($url_lost_password) : $site_sess->url(ROOT_PATH."member.php?action=lostpassword")
));

if (!empty($additional_urls)) {
  $register_array = array();
  foreach ($additional_urls as $key => $val) {
    $register_array[$key] = $site_sess->url($val);
  }
  $site_template->register_vars($register_array);
}

// Replace Globals in $lang
$lang = $site_template->parse_array($lang);

$site_template->register_vars(array(
  "lang_site_stats" => $lang['site_stats'],
  "lang_registered_user" => $lang['registered_user'],
  "lang_random_image" => $lang['random_image'],
  "lang_categories" => $lang['categories'],
  "lang_sub_categories" => $lang['sub_categories'],
  "lang_new_images" => $lang['new_images'],
  "lang_top_images" => $lang['top_images'],
  "lang_search" => $lang['search'],
  "lang_advanced_search" => $lang['advanced_search'],
  "lang_lightbox" => $lang['lightbox'],
  "lang_register" => $lang['register'],
  "lang_control_panel" => $lang['control_panel'],
  "lang_login" => $lang['login'],
  "lang_auto_login" => $lang['lang_auto_login'],
  "lang_logout" => $lang['logout'],
  "lang_lost_password" => $lang['lost_password'],
  "lang_user_name" => $lang['user_name'],
  "lang_password" => $lang['password'],
  "lang_go" => $lang['go'],
  "lang_images_per_page" => $lang['images_per_page'],
  "lang_user_online" => $lang['user_online'],
  "lang_user_online_detail" => $lang['user_online_detail'],
  "charset" => $lang['charset'],
  "direction" => $lang['direction']
));

//-----------------------------------------------------
//--- Category Dropdown -------------------------------
//-----------------------------------------------------
$category_dropdown_selfjump = get_category_dropdown($cat_id, 1);
$site_template->register_vars("category_dropdown_selfjump", $category_dropdown_selfjump);
$category_dropdown_form = $site_template->parse_template("category_dropdown_form");
$site_template->register_vars(array("category_dropdown_form" => $category_dropdown_form));

$site_template->un_register_vars("category_dropdown_selfjump");
unset($category_dropdown_selfjump);
unset($category_dropdown_form);

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

//-----------------------------------------------------
//--- Photo Of The Day --------------------------------
//-----------------------------------------------------

$potd_image = (defined("SHOW_POTD_IMAGE") && SHOW_POTD_IMAGE == 0) ? "" : get_potd_image();
$site_template->register_vars("potd_image", $potd_image);
$site_template->register_vars(array("lang_potd_title" => $lang['potd_title']));
switch (POTD_SELECT_MODE) {
    case "by_rating"    : $site_template->register_vars(array("lang_potd_type" => $lang['potd_type_rating'])); break;
    case "by_votes"     : $site_template->register_vars(array("lang_potd_type" => $lang['potd_type_votes'])); break;
    case "by_comments"  : $site_template->register_vars(array("lang_potd_type" => $lang['potd_type_comments'])); break;
    case "by_downloads" : $site_template->register_vars(array("lang_potd_type" => $lang['potd_type_downloads'])); break;
    case "by_hits"      : $site_template->register_vars(array("lang_potd_type" => $lang['potd_type_hits'])); break;
}
unset($potd_image);

//--- End Photo Of The Day ----------------------------

//-----------------------------------------------------
//--- Set Paging Vars ---------------------------------
//-----------------------------------------------------
if (isset($HTTP_POST_VARS['setperpage'])) {
  $setperpage = intval($HTTP_POST_VARS['setperpage']);
  if ($setperpage) {
    $site_sess->set_session_var("perpage", $setperpage);
    $session_info['perpage'] = $setperpage;
  }
}

if (isset($session_info['perpage'])) {
  $perpage = $session_info['perpage'];
}
else {
  $perpage = ceil($config['default_image_rows'] * $config['image_cells']);
}

//-----------------------------------------------------
//--- Set Perpage Dropdown ----------------------------
//-----------------------------------------------------
$setperpage_dropdown = "\n<select name=\"setperpage\" class=\"setperpageselect\">\n";
for($i = 1; $i <= $config['custom_row_steps']; $i++) {
  $setvalue = $config['image_cells'] * $i;
  $setperpage_dropdown .= "<option value=\"".$setvalue."\"";
    if ($setvalue == $perpage) {
    $setperpage_dropdown .= " selected=\"selected\"";
  }
  $setperpage_dropdown .= ">";
  $setperpage_dropdown .= $setvalue;
  $setperpage_dropdown .= "</option>\n";
}
$setperpage_dropdown .= "</select>\n";
if ($cat_id != 0) {
  $setperpage_dropdown .= "<input type=\"hidden\" name=\"cat_id\" value=\"".$cat_id."\" />\n";
}
if (isset($show_result) && $show_result == 1) {
  $setperpage_dropdown .= "<input type=\"hidden\" name=\"show_result\" value=\"1\" />\n";
}
$site_template->register_vars("setperpage_dropdown", $setperpage_dropdown);
$setperpage_dropdown_form = $site_template->parse_template("setperpage_dropdown_form");
$site_template->register_vars("setperpage_dropdown_form", $setperpage_dropdown_form);

$site_template->un_register_vars("setperpage_dropdown");
unset($setperpage_dropdown);
unset($setperpage_dropdown_form);

//-----------------------------------------------------
//--- Add & Delete from Lists -------------------------
//-----------------------------------------------------
if ($action == "addtolightbox" && $id) {
  if ($user_info['user_level'] >= USER) {
    $msg = (add_to_lightbox($id)) ? $lang['lightbox_add_success'] : $lang['lightbox_add_error'];
  }
  else {
    $msg = $lang['lightbox_register'];
  }
}
if ($action == "removefromlightbox" && $id) {
  if ($user_info['user_level'] >= USER) {
    $msg = (remove_from_lightbox($id)) ? $lang['lightbox_remove_success'] : $lang['lightbox_remove_error'];
  }
  else {
    $msg = $lang['lightbox_register'];
  }
}
if ($action == "clearlightbox") {
  if ($user_info['user_level'] >= USER) {
    $msg = (clear_lightbox()) ? $lang['lightbox_delete_success'] : $lang['lightbox_delete_error'];
  }
  else {
    $msg = $lang['lightbox_register'];
  }
}

//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------
if ($action == "rateimage" && $id) {
  $rating = intval($HTTP_POST_VARS['rating']);
  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
  if ($rating && $rating <= MAX_RATING && $id) {
    if (!isset($session_info['rated_imgs'])) {
      $session_info['rated_imgs'] = $site_sess->get_session_var("rated_imgs");
    }    
    $split_list = array();
    if (!empty($session_info['rated_imgs'])) {
      $split_list = explode(" ", $session_info['rated_imgs']);
    }
    if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
      $session_info['rated_imgs'] .= " ".$id;
      $session_info['rated_imgs'] = trim($session_info['rated_imgs']);
      $site_sess->set_session_var("rated_imgs", $session_info['rated_imgs']);
      $cookie_rated[] = $id;
      $cookie_expire = time() + 60 * 60 * 24 * 4;
      setcookie($cookie_name.'rated', serialize($cookie_rated), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
      update_image_rating($id, $rating);
      $msg = $lang['voting_success'];
    }
    else {
      $msg = $lang['already_voted'];
    }
  }
  else {
    $msg = $lang['voting_error'];
  }
}

//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------
if (isset($main_template) && $main_template) {
  $header = $site_template->parse_template("header");
  $footer = $site_template->parse_template("footer");
  $site_template->register_vars(array(
    "header" => $header,
    "footer" => $footer
  ));
  unset($header);
  unset($footer);
}

//-----------------------------------------------------
//--- User Box ----------------------------------------
//-----------------------------------------------------
if ($user_info['user_level'] >= USER) {
  $site_template->register_vars("lang_loggedin_msg", preg_replace("/".$site_template->start."loggedin_user_name".$site_template->end."/siU", $user_info['user_name'], $lang['lang_loggedin_msg']));
  $user_box = $site_template->parse_template("user_logininfo");
  $site_template->register_vars(array(
    "user_box" => $user_box,
    "user_loggedin" => 1,
    "user_loggedout" => 0,
    "is_admin" => ($user_info['user_level'] == ADMIN) ? 1 : 0
  ));  
  $site_template->un_register_vars("user_logininfo");
  unset($user_box);
}
else {
  $user_box = $site_template->parse_template("user_loginform");
  $site_template->register_vars(array(
    "user_box" => $user_box,
    "user_loggedin" => 0,
    "user_loggedout" => 1,
    "is_admin" => 0
  ));
  $site_template->un_register_vars("user_loginform");
  unset($user_box);
}
?>
What's wrong, huh?

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
[Mod] Star Rating
« Reply #44 on: May 13, 2003, 10:58:35 PM »
Quote from: V@no
what is on line 152 in it?

and your answer is....? :roll:

P.S. Please dont post code from entire file, also next time please use [ code ] ... [ /code ] tags to show PIECE of code.

[EDITED]
this doesnt come with default page_header.php:
Code: [Select]
//-----------------------------------------------------
//--- Photo Of The Day --------------------------------
//-----------------------------------------------------

$potd_image = (defined("SHOW_POTD_IMAGE") && SHOW_POTD_IMAGE == 0) ? "" : get_potd_image();
$site_template->register_vars("potd_image", $potd_image);
$site_template->register_vars(array("lang_potd_title" => $lang['potd_title']));
switch (POTD_SELECT_MODE) {
case "by_rating" : $site_template->register_vars(array("lang_potd_type" => $lang['potd_type_rating'])); break;
case "by_votes" : $site_template->register_vars(array("lang_potd_type" => $lang['potd_type_votes'])); break;
case "by_comments" : $site_template->register_vars(array("lang_potd_type" => $lang['potd_type_comments'])); break;
case "by_downloads" : $site_template->register_vars(array("lang_potd_type" => $lang['potd_type_downloads'])); break;
case "by_hits" : $site_template->register_vars(array("lang_potd_type" => $lang['potd_type_hits'])); break;
}
unset($potd_image);

//--- End Photo Of The Day ----------------------------
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)