[ Index ] |
|
Code source de Mantis 1.1.0rc3 |
1 <?php 2 # Mantis - a php based bugtracking system 3 4 # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 5 # Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net 6 7 # Mantis is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation, either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # Mantis is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with Mantis. If not, see <http://www.gnu.org/licenses/>. 19 20 # -------------------------------------------------------- 21 # $Id: rss_api.php,v 1.1.4.1 2007-10-13 22:35:42 giallu Exp $ 22 # -------------------------------------------------------- 23 24 ### RSS API ### 25 26 # -------------------- 27 # Calculates a key to be used for RSS authentication based on user name, cookie and password. 28 # if the user changes his user name or password, then the key becomes invalid. 29 function rss_calculate_key( $p_user_id = null ) { 30 if ( $p_user_id === null ) { 31 $t_user_id = auth_get_current_user_id(); 32 } else { 33 $t_user_id = $p_user_id; 34 } 35 36 $t_seed = config_get_global( 'rss_key_seed' ); 37 38 $t_username = user_get_field( $t_user_id, 'username' ); 39 $t_password = user_get_field( $t_user_id, 'password' ); 40 $t_cookie = user_get_field( $t_user_id, 'cookie_string' ); 41 42 return md5( $t_seed . $t_username . $t_cookie . $t_password ); 43 } 44 45 # -------------------- 46 # Given the user name and the rss key, this method attempts to login the user. If successful, it 47 # return true, otherwise, returns false. 48 function rss_login( $p_username, $p_key ) { 49 if ( ( $p_username === null ) || ( $p_key === null ) ) { 50 return false; 51 } 52 53 $t_user_id = user_get_id_by_name( $p_username ); 54 55 $t_correct_key = rss_calculate_key( $t_user_id ); 56 if ( $p_key != $t_correct_key ) { 57 return false; 58 } 59 60 if ( !auth_attempt_script_login( $p_username ) ) { 61 return false; 62 } 63 64 return true; 65 } 66 67 # -------------------- 68 function rss_get_issues_feed_url( $p_project_id = null, $p_username = null, $p_filter_id = null, $p_relative = true ) { 69 if ( $p_username === null ) { 70 $t_username = current_user_get_field( 'username' ); 71 } else { 72 $t_username = $p_username; 73 } 74 75 if ( $p_project_id === null ) { 76 $t_project_id = helper_get_current_project(); 77 } else { 78 $t_project_id = (integer)$p_project_id; 79 } 80 81 $t_user_id = user_get_id_by_name( $t_username ); 82 83 if ( $p_relative ) { 84 $t_url = config_get( 'path' ); 85 } else { 86 $t_url = ''; 87 } 88 89 if ( $t_username == config_get( 'anonymous_account' ) ) { 90 $t_url .= 'issues_rss.php?'; 91 92 if ( $t_project_id == ALL_PROJECTS ) { 93 $t_url .= 'project_id=' . $t_project_id; 94 } 95 } else { 96 $t_url .= 'issues_rss.php?username=' . $t_username . '&key=' . rss_calculate_key( $t_user_id ); 97 98 if ( $t_project_id != ALL_PROJECTS ) { 99 $t_url .= '&project_id=' . $t_project_id; 100 } 101 } 102 103 if ( $p_filter_id !== null ) { 104 $t_url .= '&filter_id=' . $p_filter_id; 105 } 106 107 return $t_url; 108 } 109 110 # -------------------- 111 function rss_get_news_feed_url( $p_project_id = null, $p_username = null, $p_relative = true ) { 112 if ( $p_username === null ) { 113 $t_username = current_user_get_field( 'username' ); 114 } else { 115 $t_username = $p_username; 116 } 117 118 if ( $p_project_id === null ) { 119 $t_project_id = helper_get_current_project(); 120 } else { 121 $t_project_id = (integer)$p_project_id; 122 } 123 124 if ( $p_relative ) { 125 $t_rss_link = ''; 126 } else { 127 $t_rss_link = config_get( 'path' ); 128 } 129 130 $t_user_id = user_get_id_by_name( $t_username ); 131 132 // If we have a logged in user then they can be given a 'proper' feed, complete with auth string. 133 if ( $t_username == config_get( 'anonymous_account' ) ) { 134 $t_rss_link .= "news_rss.php?"; 135 136 if ( $t_project_id != ALL_PROJECTS ) { 137 $t_rss_link .= "news_rss.php?project_id=" . $t_project_id; 138 } 139 } else { 140 $t_rss_link .= "news_rss.php?username=" . $t_username . "&key=" . rss_calculate_key( $t_user_id ); 141 142 if ( $t_project_id != ALL_PROJECTS ) { 143 $t_rss_link .= "&project_id=" . $t_project_id; 144 } 145 } 146 147 return $t_rss_link; 148 } 149 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 09:42:17 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |