Changeset 1992 for trunk/include
- Timestamp:
- May 1, 2007, 3:57:52 PM (18 years ago)
- Location:
- trunk/include
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r1989 r1992 26 26 27 27 include_once( PHPWG_ROOT_PATH .'include/functions_user.inc.php' ); 28 include_once( PHPWG_ROOT_PATH .'include/functions_cookie.inc.php' ); 28 29 include_once( PHPWG_ROOT_PATH .'include/functions_session.inc.php' ); 29 30 include_once( PHPWG_ROOT_PATH .'include/functions_category.inc.php' ); -
trunk/include/functions_rate.inc.php
r1903 r1992 5 5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | 6 6 // +-----------------------------------------------------------------------+ 7 // | branch : BSF (Best So Far) 8 // | file : $RCSfile$ 7 // | file : $Id$ 9 8 // | last update : $Date$ 10 9 // | last modifier : $Author$ … … 60 59 $anonymous_id = implode ('.', $ip_components); 61 60 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 = ' 66 SELECT element_id 67 FROM '.RATE_TABLE.' 68 WHERE 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 { 66 75 $query = ' 67 SELECT element_id68 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 = '77 76 DELETE 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'].'\' 77 FROM '.RATE_TABLE.' 78 WHERE user_id = '.$user['id'].' 79 AND anonymous_id = \''.$save_anonymous_id.'\' 80 AND element_id NOT IN ('.implode(',', $already_there).') 92 81 ;'; 93 82 pwg_query($query); 83 } 94 84 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 = ' 86 UPDATE 87 '.RATE_TABLE.' 88 SET anonymous_id = \'' .$anonymous_id.'\' 89 WHERE 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); 112 96 } // end anonymous user 97 113 98 $query = ' 114 99 DELETE -
trunk/include/functions_session.inc.php
r1900 r1992 3 3 // | PhpWebGallery - a PHP based picture gallery | 4 4 // | 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$ 9 8 // | last update : $Date$ 10 9 // | last modifier : $Author$ … … 76 75 } 77 76 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.php81 // cookie_path will return : "/meeting/gallery"82 function cookie_path()83 {84 if ( isset($_SERVER['REDIRECT_SCRIPT_NAME']) and85 !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 the91 // 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 else100 {//this should never happen101 $scr='//';102 }103 }104 else105 {106 $scr = $_SERVER['REDIRECT_URL'];107 }108 }109 else110 {111 $scr = $_SERVER['SCRIPT_NAME'];112 }113 $scr = substr($scr,0,strrpos( $scr,'/'));114 115 // add a trailing '/' if needed116 $scr .= ($scr{strlen($scr)-1} == '/') ? '' : '/';117 118 if ( substr(PHPWG_ROOT_PATH,0,3)=='../')119 { // this is maybe a plugin inside pwg directory120 // 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 135 77 /** 136 78 * returns true; used when the session_start() function is called
Note: See TracChangeset
for help on using the changeset viewer.