Author Topic: Picture of the month  (Read 5410 times)

0 Members and 1 Guest are viewing this topic.

Offline masterred

  • Sr. Member
  • ****
  • Posts: 494
    • View Profile
Picture of the month
« on: December 11, 2007, 10:50:43 AM »
hi

i have one problem with this MOD  dont show me the links

what this wrong in this MOD


Quote
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: potm.php                                             *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.8                                                  *
 *                                                                        *
 *    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.                              *
 *                                                                        *
 *************************************************************************/

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

$main_template = 'potm';                                   // template name
include(ROOT_PATH.'includes/page_header.php');
     
global $cat_id, $site_db, $site_sess, $HTTP_COOKIE_VARS, $site_template, $lang, $user_table_fields; 

//-----------------------------------------------------
//--- Parameters --------------------------------------
//-----------------------------------------------------
$potm_public = 1;                                       // access for all visitors (true 1) only members ( false 0)
$potm_nop = 8;                                          // number of pictures for monthly voting
$potm_top = 3;                                          // after vote show top X images of this month vote
$potm_lw  = 12;                                         // show last x 'photo of the month' winners
$potm_table = "450";                                    // table witdt or use with %
$potm_selection = 3;                                    // selection of picturey by
                                                        // 0 - hits
                                                        // 1 - votes
                                                        // 2 - rating
                                                        // 3 - by date, latest pictures
                                                        // 4 - automatically choose one of the three above

//-----------------------------------------------------
//--- Init --------------------------------------------
//-----------------------------------------------------


if ($user_info['user_level'] < $potm_public * -1 ){   
  show_error_page($lang['no_permission']);
  exit;
}

$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
if (isset($HTTP_COOKIE_VARS[$cookie_name.'potm']))
{
   $cookie_date = unserialize(stripslashes($_COOKIE[$cookie_name.'potm'])) ;
}

//-----------------------------------------------------
//--- Check Date --------------------------------------
//-----------------------------------------------------

$datum = date("Y-m") . "-01";
if ( $config['potm_date'] != $datum )
{
   if ( $potm_selection == 4 )
      $potm_selection = date("m") % 4;
   if ( $potm_selection == 0 )
      $sql_add = "hits";
   elseif ( $potm_selection == 1 ) 
       $sql_add = "votes";
   elseif ( $potm_selection == 2 )
       $sql_add = "rating";
   else
       $sql_add = "date"; 
   $sql = "UPDATE ".IMAGES_TABLE."
          SET image_potm =  1
          WHERE image_potm_date = '".$config['potm_date']."'
          ORDER BY image_potm_votes DESC
          LIMIT 1";
   $site_db->query($sql);
   $sql = "UPDATE ".IMAGES_TABLE."
          SET image_potm_date =  '0000-00-00', image_potm_votes = 0
          WHERE image_potm_date = '".$config['potm_date']."' AND image_potm = 0";
   $site_db->query($sql);
   $sql = "UPDATE ".IMAGES_TABLE."
          SET image_potm_date =  '".$datum."'
          WHERE image_potm = 0
          ORDER BY image_".$sql_add." DESC
          LIMIT ".$potm_nop;
   $site_db->query($sql);
   $sql = "UPDATE ".SETTINGS_TABLE."
          SET setting_value =  '".$datum."'
          WHERE setting_name = 'potm_date'";
   $site_db->query($sql);
}

//-----------------------------------------------------
//--- Voting ------------------------------------------
//-----------------------------------------------------

if ( $action == "potm_voting" ){
  if ( $cookie_date != $datum )
  { 
        $sql = "UPDATE ".IMAGES_TABLE."
        SET image_potm_votes = image_potm_votes + 1
        WHERE image_id = ".$id;
     $site_db->query($sql);
     $sql_datum = "AND i.image_potm_date = '".$datum."'";
   $nop = $potm_top;
     $potm_description = $lang['potm_top_title'];
     $cookie_value = isset($HTTP_COOKIE_VARS[$cookie_name.'potm']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'potm'])) : array();
     $cookie_potm_rated = $datum;
     $cookie_expire = mktime(0,0,0,date("m") + 1, 1, date("Y") );
     setcookie($cookie_name.'potm', serialize($cookie_potm_rated), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
   }
   else
   {
        show_error_page($lang['potm_no_permission']);
        exit;
   }
   $sql_order = "i.image_potm_votes DESC, i.image_hits";
   $nop = $potm_top;
}

//-----------------------------------------------------
//--- Leaders of current Vote -------------------------
//-----------------------------------------------------

if ( $action == "locv" ){
  if ( $cookie_date == $datum )
  {
     $sql_order = "i.image_potm_votes DESC, i.image_hits";
     $sql_datum = "AND i.image_potm = 0 AND i.image_potm_date = '".$datum."'";
     $nop = $potm_top;
     $potm_description = $lang['potm_locv'];
  }
  else
  {
     show_error_page($lang['potm_no_permission']);
     exit;
  }
}

//-----------------------------------------------------
//--- Show candidates ---------------------------------
//-----------------------------------------------------

if ( $action == "" ){
    if ( $cookie_date != $datum )
    {
      $sql_datum = "AND i.image_potm = 0 AND i.image_potm_date = '".$datum."'";
      $sql_order = "i.image_name, i.image_hits ASC";
      $nop = $potm_lw;
    }
    else
    {   
      $sql_order = "i.image_potm_votes DESC, i.image_hits";
      $sql_datum = "AND i.image_potm = 0";
      $nop = $potm_top;
      $potm_description = $lang['potm_locv'];
    }
}

//-----------------------------------------------------
//--- Last Winner -------------------------------------
//-----------------------------------------------------

if ( $action == "lw" ){
  if ( $cookie_date != $datum )
    $potm_menu_link = "<a href=\"".$site_sess->url(ROOT_PATH."potm.php")."\">{lang_potm_vote_menu}</a>";
  $nop = $potm_lw;
  $sql_datum = "AND i.image_potm = 1";
  $sql_order = "i.image_potm_date DESC, i.image_hits";
  $potm_description = $lang['potm_winners_title'];
}
else {
  $potm_menu_link = "<a href=\"".$site_sess->url(ROOT_PATH."potm.php?action=lw")."\">{lang_potm_lastwinners}</a>";
}
if ( $cookie_date == $datum )
  $potm_menu_link .= "<br><br><a href=\"".$site_sess->url(ROOT_PATH."potm.php?action=locv")."\">{lang_potm_locv}</a>";


//-----------------------------------------------------
//--- Menu --------------------------------------------
//-----------------------------------------------------

$cat_match_sql = ($cat_id && check_permission("auth_viewcat", $cat_id)) ? "AND i.cat_id = '$cat_id' " : "";
 
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");

$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file, i.image_media_file, i.image_thumb_file, i.image_rating, i.image_votes, i.image_comments, c.cat_name, u.user_name, i.image_downloads, i.image_hits, i.image_potm, i.image_potm_date, i.image_potm_votes
        FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c, ".USERS_TABLE." u
        WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id AND i.user_id = u.user_id $cat_match_sql ".$sql_datum."
        ORDER BY " . $sql_order ."
        LIMIT $nop";
$result = $site_db->query($sql);
$potm_list = array();
$i = 1;
while ($row = $site_db->fetch_array($result))
{
  $potm_list[$i] = $row;
  $i++;
}
$site_db->free_result();



$potm_menu = "<table width=".$potm_table." border=\"0\" cellpadding=\"3\" cellspacing=\"0\">\n<form method=\"post\" action=\"{self}\">";

for ($i = 1; $i <= $nop; $i++) {
  if (isset($potm_list[$i])) {
    if (empty($potm_list[$i]['image_thumb_file'])) {
      $thumb_file = ICON_PATH."/".get_file_extension($potm_list[$i]['image_media_file']).".gif";
    }
    else
    {
      $thumb_file = (is_remote($potm_list[$i]['image_thumb_file'])) ? $potm_list[$i]['image_thumb_file'] : THUMB_PATH."/".$potm_list[$i]['cat_id']."/".$potm_list[$i]['image_thumb_file'];
    }
    $potm_menu .= "<tr class=\"row". (($i % 2) == 1 ? "1" : "2") ."\">\n<td width=100 align=\"center\" valign=\"center\">";
    $potm_menu .= (check_permission("auth_viewimage", $potm_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$potm_list[$i]['image_id'])."\"><img src=\"".$thumb_file."\" border=\"1\" align=\"center\" alt=\"".$lang['clickhere']." &quot;".$potm_list[$i]['image_name']."&quot;\"/></a>" : "<img src=\"".$thumb_file."\" width=\"$new_width\" height=\"$new_height\" border=\"1\" align=\"center\" alt=\"".$potm_list[$i]['image_name']."\" />";
    $potm_menu .= "</td><td>";
    $potm_menu .= (check_permission("auth_viewimage", $potm_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$potm_list[$i]['image_id'])."\">".$potm_list[$i]['image_name']."</a>" : ($potm_list[$i]['image_name']);
    $potm_menu .= "<br>{lang_top_user}: " . "<a href=\"".$site_sess->url((!empty($url_show_profile)) ? preg_replace("/{user_id}/", $potm_list[$i]['user_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$potm_list[$i]['user_id'])."\">".htmlspecialchars($potm_list[$i]['user_name'])."</a>";
    $potm_menu .= "<br>{lang_top_category}: " . "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$potm_list[$i]['cat_id'])."\">".$potm_list[$i]['cat_name']."</a>";
    if ( $action != "" )
    {
      $potm_menu .= "<br>".$lang['hits']." ".$potm_list[$i]['image_hits'];
      $potm_menu .= "<br>".$lang['rating']." ".$potm_list[$i]['image_rating'];
    }
    $potm_menu .= "<br>".$lang['comments']." ".$potm_list[$i]['image_comments'];
    $potm_menu .= "</td><td>\n"; 
    if ( $action == "" && $cookie_date != $datum )
       $potm_menu .= "<input type=\"radio\" name=\"id\" value=\"" .$potm_list[$i]['image_id']. "\" onclick=\"this.form.submit()\"/>{lang_potm_vote}\n";
    else if ( $action == "lw" )
         {
            $datum_array = explode("-",$potm_list[$i]['image_potm_date']);
            $potm_menu .= "<b>".$lang['potm_winner']."<br>".$lang['month_array'][(int)$datum_array[1]-1]." ".$datum_array[0]."</b>";
         }
         else
            $potm_menu .= "<br>{lang_potm_votes} " . $potm_list[$i]['image_potm_votes'];

  }
  $potm_menu .= "</td>";
  if ( $action == "" && $cookie_date != $datum ) {
     $potm_menu .= "<input type=\"hidden\" name=\"action\" value=\"potm_voting\"></tr>";
  }
}
$potm_menu .= "</form></table>";

//-----------------------------------------------------
//--- Template vars -----------------------------------
//-----------------------------------------------------

$site_template->register_vars(array(
"potm_menu" => $potm_menu,
"potm_menu_link" => $potm_menu_link,
"lang_potm_title" => $lang['potm_title'],
"lang_potm_vote" => $lang['potm_vote'],
"lang_potm_votes" => $lang['potm_votes'],
"lang_potm_vote_menu" => $lang['potm_vote_menu'],
"lang_potm_lastwinners" => $lang['potm_lastwinners'],
"lang_top_category" => $lang['top_category'],
"lang_top_user" => $lang['top_user'],
"lang_potm_description" => $potm_description,
"lang_potm_locv" => $lang['potm_locv']
));

unset($action);

//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------

$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator']. $lang['potm_link'];
$title = $config['site_name'];

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "clickstream" => $clickstream,
  "title" => $title
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>


this is the language

Quote
//-----------------------------------------------------
//--- Photo of the month ------------------------------
//-----------------------------------------------------

$lang['potm_link'] = "Photo of the month";
$lang['potm_title'] = "Vote for photo of the month";
$lang['potm'] = "potm";
$lang['potm_vote'] = "Vote";
$lang['potm_votes'] = "Votes:";
$lang['potm_lastwinners'] = "Winners of the last months";
$lang['potm_vote_menu'] = "Back to vote";
$lang['potm_winner'] = "Winner of the month";
$lang['potm_top_title'] = "Leading photos";
$lang['potm_winners_title'] = "Winners of the last months";
$lang['potm_no_permission'] = "You have already voted. You can vote only once a month.";
$lang['potm_locv'] = "Leading photos of current vote";

If these language descriptions are missing in the file add them as well:
$lang['top_user'] = "User";
$lang['top_category'] = "Category";
$lang['month_array'] = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

reference site

http://www.foto-kocher.biz/potm.php
this work fine, and my gallery dont show the links or the language

zip MOD

http://www.koebs.org/Download/MOD_potm.zip

4images v1.7.4

please help me
Apache/2.2.21 (Win32)
PHP/5.3.5
Mysql Version: 5.5.19
4images Version: 1.7.?



Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: Picture of the month
« Reply #1 on: December 11, 2007, 11:05:46 AM »
please reply to the mod thread.

this one is closed.
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi