Changeset 1992 for trunk/include


Ignore:
Timestamp:
May 1, 2007, 3:57:52 PM (18 years ago)
Author:
rub
Message:

Issue 0000684: History [Search] - Add a thumbnail display

o Display choice can be selected
o Display choice is saved on on cookie
o Small improvement picture link (hoverbox on all the link, alt&title on classic mode)
o New cookie functions and use

Enhance computing method of script_basename function.

http://forum.phpwebgallery.net/viewtopic.php?pid=58258#p58258

Merge BSF 1988:1989 into branch-1_7

Location:
trunk/include
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r1989 r1992  
    2626
    2727include_once( PHPWG_ROOT_PATH .'include/functions_user.inc.php' );
     28include_once( PHPWG_ROOT_PATH .'include/functions_cookie.inc.php' );
    2829include_once( PHPWG_ROOT_PATH .'include/functions_session.inc.php' );
    2930include_once( PHPWG_ROOT_PATH .'include/functions_category.inc.php' );
  • trunk/include/functions_rate.inc.php

    r1903 r1992  
    55// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    7 // | branch        : BSF (Best So Far)
    8 // | file          : $RCSfile$
     7// | file          : $Id$
    98// | last update   : $Date$
    109// | last modifier : $Author$
     
    6059    $anonymous_id = implode ('.', $ip_components);
    6160
    62     if (isset($_COOKIE['pwg_anonymous_rater']))
    63     {
    64       if ($anonymous_id != $_COOKIE['pwg_anonymous_rater'])
    65       { // client has changed his IP adress or he's trying to fool us
     61    $save_anonymous_id = pwg_get_cookie_var('anonymous_rater', $anonymous_id);
     62
     63    if ($anonymous_id != $save_anonymous_id)
     64    { // client has changed his IP adress or he's trying to fool us
     65      $query = '
     66SELECT element_id
     67FROM '.RATE_TABLE.'
     68WHERE user_id = '.$user['id'].'
     69  AND anonymous_id = \''.$anonymous_id.'\'
     70;';
     71      $already_there = array_from_query($query, 'element_id');
     72
     73      if (count($already_there) > 0)
     74      {
    6675        $query = '
    67 SELECT element_id
    68   FROM '.RATE_TABLE.'
    69   WHERE user_id = '.$user['id'].'
    70     AND anonymous_id = \''.$anonymous_id.'\'
    71 ;';
    72         $already_there = array_from_query($query, 'element_id');
    73 
    74         if (count($already_there) > 0)
    75         {
    76           $query = '
    7776DELETE
    78   FROM '.RATE_TABLE.'
    79   WHERE user_id = '.$user['id'].'
    80     AND anonymous_id = \''.$_COOKIE['pwg_anonymous_rater'].'\'
    81     AND element_id NOT IN ('.implode(',', $already_there).')
    82 ;';
    83            pwg_query($query);
    84          }
    85 
    86          $query = '
    87 UPDATE
    88   '.RATE_TABLE.'
    89   SET anonymous_id = \'' .$anonymous_id.'\'
    90   WHERE user_id = '.$user['id'].'
    91     AND anonymous_id = \'' . $_COOKIE['pwg_anonymous_rater'].'\'
     77FROM '.RATE_TABLE.'
     78WHERE user_id = '.$user['id'].'
     79  AND anonymous_id = \''.$save_anonymous_id.'\'
     80  AND element_id NOT IN ('.implode(',', $already_there).')
    9281;';
    9382         pwg_query($query);
     83       }
    9484
    95          setcookie(
    96             'pwg_anonymous_rater',
    97             $anonymous_id,
    98             strtotime('+10 years'),
    99             cookie_path()
    100            );
    101       } // end client changed ip
    102     } // end client has cookie
    103     else
    104     {
    105       setcookie(
    106           'pwg_anonymous_rater',
    107           $anonymous_id,
    108           strtotime('+10 years'),
    109           cookie_path()
    110           );
    111     }
     85       $query = '
     86UPDATE
     87'.RATE_TABLE.'
     88SET anonymous_id = \'' .$anonymous_id.'\'
     89WHERE user_id = '.$user['id'].'
     90  AND anonymous_id = \'' . $save_anonymous_id.'\'
     91;';
     92       pwg_query($query);
     93    } // end client changed ip
     94
     95  pwg_get_cookie_var('anonymous_rater', $anonymous_id);
    11296  } // end anonymous user
     97
    11398  $query = '
    11499DELETE
  • trunk/include/functions_session.inc.php

    r1900 r1992  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
    6 // +-----------------------------------------------------------------------+
    7 // | branch        : BSF (Best So Far)
    8 // | file          : $RCSfile$
     5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     6// +-----------------------------------------------------------------------+
     7// | file          : $Id$
    98// | last update   : $Date$
    109// | last modifier : $Author$
     
    7675}
    7776
    78 // cookie_path returns the path to use for the PhpWebGallery cookie.
    79 // If PhpWebGallery is installed on :
    80 // http://domain.org/meeting/gallery/category.php
    81 // cookie_path will return : "/meeting/gallery"
    82 function cookie_path()
    83 {
    84   if ( isset($_SERVER['REDIRECT_SCRIPT_NAME']) and
    85        !empty($_SERVER['REDIRECT_SCRIPT_NAME']) )
    86   {
    87     $scr = $_SERVER['REDIRECT_SCRIPT_NAME'];
    88   }
    89   else if ( isset($_SERVER['REDIRECT_URL']) )
    90   { // mod_rewrite is activated for upper level directories. we must set the
    91     // cookie to the path shown in the browser otherwise it will be discarded.
    92     if ( isset($_SERVER['PATH_INFO']) and !empty($_SERVER['PATH_INFO']) )
    93     {
    94       $idx = strpos( $_SERVER['REDIRECT_URL'], $_SERVER['PATH_INFO'] );
    95       if ($idx !== false)
    96       {
    97         $scr = substr($_SERVER['REDIRECT_URL'], 0, $idx);
    98       }
    99       else
    100       {//this should never happen
    101         $scr='//';
    102       }
    103     }
    104     else
    105     {
    106       $scr = $_SERVER['REDIRECT_URL'];
    107     }
    108   }
    109   else
    110   {
    111     $scr = $_SERVER['SCRIPT_NAME'];
    112   }
    113   $scr = substr($scr,0,strrpos( $scr,'/'));
    114 
    115   // add a trailing '/' if needed
    116   $scr .= ($scr{strlen($scr)-1} == '/') ? '' : '/';
    117  
    118   if ( substr(PHPWG_ROOT_PATH,0,3)=='../')
    119   { // this is maybe a plugin inside pwg directory
    120     // TODO - what if it is an external script outside PWG ?
    121     $scr = $scr.PHPWG_ROOT_PATH;
    122     while (1)
    123     {
    124       $new = preg_replace('#[^/]+/\.\.(/|$)#', '', $scr);
    125       if ($new==$scr)
    126       {
    127         break;
    128       }
    129       $scr=$new;
    130     }
    131   }
    132   return $scr;
    133 }
    134 
    13577/**
    13678 * returns true; used when the session_start() function is called
Note: See TracChangeset for help on using the changeset viewer.