Changeset 25614
- Timestamp:
- Nov 21, 2013, 11:02:44 AM (11 years ago)
- Location:
- trunk/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_rate.inc.php
r19703 r25614 23 23 24 24 /** 25 * rate a picture by a user 25 * @package functions\rate 26 */ 27 28 29 /** 30 * Rate a picture by the current user. 26 31 * 27 * @param int image identifier28 * @param intrate29 * @return void32 * @param int $image_id 33 * @param float $rate 34 * @return array as return by update_rating_score() 30 35 */ 31 36 function rate_picture($image_id, $rate) … … 121 126 122 127 123 /* update images.rating_score field 124 * we use a bayesian average (http://en.wikipedia.org/wiki/Bayesian_average) with 125 C = average number of rates per item 126 m = global average rate (all rates) 127 128 * param int $element_id optional, otherwise applies to all 129 * @return array(rating_score, count) if element_id is specified 128 /** 129 * Update images.rating_score field. 130 * We use a bayesian average (http://en.wikipedia.org/wiki/Bayesian_average) with 131 * C = average number of rates per item 132 * m = global average rate (all rates) 133 * 134 * @param int|false $element_id if false applies to all 135 * @return array (score, average, count) values are null if $element_id is false 130 136 */ 131 137 function update_rating_score($element_id = false) -
trunk/include/functions_session.inc.php
r20281 r25614 22 22 // +-----------------------------------------------------------------------+ 23 23 24 // The function generate_key creates a string with pseudo random characters. 25 // the size of the string depends on the $conf['session_id_size']. 26 // Characters used are a-z A-Z and numerical values. Examples : 27 // "Er4Tgh6", "Rrp08P", "54gj" 28 // input : none (using global variable) 29 // output : $key 30 function generate_key($size) 31 { 32 global $conf; 33 34 $md5 = md5(substr(microtime(), 2, 6)); 35 $init = ''; 36 for ( $i = 0; $i < strlen( $md5 ); $i++ ) 37 { 38 if ( is_numeric( $md5[$i] ) ) $init.= $md5[$i]; 39 } 40 $init = substr( $init, 0, 8 ); 41 mt_srand( $init ); 42 $key = ''; 43 for ( $i = 0; $i < $size; $i++ ) 44 { 45 $c = mt_rand( 0, 2 ); 46 if ( $c == 0 ) $key .= chr( mt_rand( 65, 90 ) ); 47 else if ( $c == 1 ) $key .= chr( mt_rand( 97, 122 ) ); 48 else $key .= mt_rand( 0, 9 ); 49 } 50 return $key; 51 } 24 /** 25 * @package functions\session 26 */ 27 52 28 53 29 if (isset($conf['session_save_handler']) … … 55 31 and defined('PHPWG_INSTALLED')) 56 32 { 57 session_set_save_handler('pwg_session_open', 33 session_set_save_handler( 34 'pwg_session_open', 58 35 'pwg_session_close', 59 36 'pwg_session_read', … … 62 39 'pwg_session_gc' 63 40 ); 64 if ( function_exists('ini_set') ) 41 42 if (function_exists('ini_set')) 65 43 { 66 44 ini_set('session.use_cookies', $conf['session_use_cookies']); … … 69 47 ini_set('session.cookie_httponly', 1); 70 48 } 49 71 50 session_name($conf['session_name']); 72 51 session_set_cookie_params(0, cookie_path()); … … 74 53 } 75 54 76 /** 77 * returns true; used when the session_start() function is called 78 * 79 * @params not use but useful for php engine 55 56 /** 57 * Generates a pseudo random string. 58 * Characters used are a-z A-Z and numerical values. 59 * 60 * @param int $size 61 * @return string 62 */ 63 function generate_key($size) 64 { 65 global $conf; 66 67 $md5 = md5(substr(microtime(), 2, 6)); 68 $init = ''; 69 for ( $i = 0; $i < strlen( $md5 ); $i++ ) 70 { 71 if ( is_numeric( $md5[$i] ) ) $init.= $md5[$i]; 72 } 73 $init = substr( $init, 0, 8 ); 74 mt_srand( $init ); 75 $key = ''; 76 for ( $i = 0; $i < $size; $i++ ) 77 { 78 $c = mt_rand( 0, 2 ); 79 if ( $c == 0 ) $key .= chr( mt_rand( 65, 90 ) ); 80 else if ( $c == 1 ) $key .= chr( mt_rand( 97, 122 ) ); 81 else $key .= mt_rand( 0, 9 ); 82 } 83 return $key; 84 } 85 86 /** 87 * Called by PHP session manager, always return true. 88 * 89 * @param string $path 90 * @param sring $name 91 * @return true 80 92 */ 81 93 function pwg_session_open($path, $name) … … 85 97 86 98 /** 87 * returns true; used when the session is closed (unset($_SESSION)) 88 * 99 * Called by PHP session manager, always return true. 100 * 101 * @return true 89 102 */ 90 103 function pwg_session_close() … … 93 106 } 94 107 108 /** 109 * Returns a hash from current user IP 110 * 111 * @return string 112 */ 95 113 function get_remote_addr_session_hash() 96 114 { … … 113 131 114 132 /** 115 * this function returns 116 * a string corresponding to the value of the variable save in the session 117 * or an empty string when the variable doesn't exist 118 * 119 * @param string session id 133 * Called by PHP session manager, retrieves data stored in the sessions table. 134 * 135 * @param string $session_id 136 * @return string 120 137 */ 121 138 function pwg_session_read($session_id) … … 139 156 140 157 /** 141 * returns true; writes set a variable in the active session 142 * 143 * @param string session id 144 * @data string value of date to be saved 158 * Called by PHP session manager, writes data in the sessions table. 159 * 160 * @param string $session_id 161 * @param sring $data 162 * @return true 145 163 */ 146 164 function pwg_session_write($session_id, $data) … … 156 174 157 175 /** 158 * returns true; delete the active session 159 * 160 * @param string session id 176 * Called by PHP session manager, deletes data in the sessions table. 177 * 178 * @param string $session_id 179 * @return true 161 180 */ 162 181 function pwg_session_destroy($session_id) … … 172 191 173 192 /** 174 * returns true; delete expired sessions 175 * called each time a session is closed. 193 * Called by PHP session manager, garbage collector for expired sessions. 194 * 195 * @return true 176 196 */ 177 197 function pwg_session_gc() … … 189 209 } 190 210 191 192 /** 193 * persistently stores a variable for the current session194 * currently we use standard php sessions but it might change195 * @ return boolean true on success196 * @ see pwg_get_session_var, pwg_unset_session_var211 /** 212 * Persistently stores a variable for the current session. 213 * 214 * @param string $var 215 * @param mixed $value 216 * @return bool 197 217 */ 198 218 function pwg_set_session_var($var, $value) … … 205 225 206 226 /** 207 * retrieves the value of a persistent variable for the current session 208 * currently we use standard php sessions but it might change 227 * Retrieves the value of a persistent variable for the current session. 228 * 229 * @param string $var 230 * @param mixed $default 209 231 * @return mixed 210 * @see pwg_set_session_var, pwg_unset_session_var211 232 */ 212 233 function pwg_get_session_var($var, $default = null) … … 220 241 221 242 /** 222 * deletes a persistent variable for the current session223 * currently we use standard php sessions but it might change224 * @ return boolean true on success225 * @ see pwg_set_session_var, pwg_get_session_var243 * Deletes a persistent variable for the current session. 244 * 245 * @param string $var 246 * @return bool 226 247 */ 227 248 function pwg_unset_session_var($var)
Note: See TracChangeset
for help on using the changeset viewer.