[ Index ] |
|
Code source de PHP NUKE 7.9 |
1 <?php 2 /*************************************************************************** 3 * avatar_manage.php 4 * ------------------- 5 * begin : Thursday, Apr 25, 2002 6 * 7 ***************************************************************************/ 8 /*************************************************************************** 9 * phpbb2 forums port version 2.1 (c) 2003 - Nuke Cops (http://nukecops.com) 10 * 11 * Ported by Paul Laudanski (Zhen-Xjell) to phpbb2 standalone 2.0.4. Test 12 * and debugging completed by the Elite Nukers at Nuke Cops: ArtificialIntel, 13 * Chatserv, MikeM, sixonetonoffun, Zhen-Xjell. Thanks to some heavy debug 14 * work by AI in Nuke 6.5. 15 * 16 * You run this package at your sole risk. Nuke Cops and affiliates cannot 17 * be held liable if anything goes wrong. You are advised to test this 18 * package on a development system. Backup everything before implementing 19 * in a production environment. If something goes wrong, you can always 20 * backout and restore your backups. 21 * 22 * Installing and running this also means you agree to the terms of the AUP 23 * found at Nuke Cops. 24 * 25 * This is version 2.1 of the phpbb2 forum port for PHP-Nuke. Work is based 26 * on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based 27 * on the phpbb2 standalone version 2.0.3. Our version 2.1 from Nuke Cops is 28 * now reflecting phpbb2 standalone 2.0.4 that fixes some major SQL 29 * injection exploits. 30 ***************************************************************************/ 31 /*************************************************************************** 32 * This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002 33 * by Tom Nitzschner (tom@toms-home.com) 34 * http://bbtonuke.sourceforge.net (or http://www.toms-home.com) 35 * 36 * As always, make a backup before messing with anything. All code 37 * release by me is considered sample code only. It may be fully 38 * functual, but you use it at your own risk, if you break it, 39 * you get to fix it too. No waranty is given or implied. 40 * 41 * Updated to allow propper avatar management by: 42 * copland007@thewebworks.com (http://www.thewebworks.com/) 43 * 44 * Please post all questions/request about this port on http://bbtonuke.sourceforge.net first, 45 * then on my site. All original header code and copyright messages will be maintained 46 * to give credit where credit is due. If you modify this, the only requirement is 47 * that you also maintain all original copyright messages. All my work is released 48 * under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information. 49 * 50 ***************************************************************************/ 51 52 /*************************************************************************** 53 * 54 * This program is free software; you can redistribute it and/or modify 55 * it under the terms of the GNU General Public License as published by 56 * the Free Software Foundation; either version 2 of the License, or 57 * (at your option) any later version. 58 * 59 ***************************************************************************/ 60 define('IN_PHPBB', 1); 61 if( !empty($setmodules) ) 62 { 63 $file = basename(__FILE__); 64 $module['General']['Avatar_Management'] = "$file"; 65 return; 66 } 67 68 69 $root_path = "./../../../"; 70 $phpbb_root_path = './../'; 71 require ($phpbb_root_path . 'extension.inc'); 72 include($phpbb_root_path . 'config.'.$phpEx); 73 require('pagestart.' . $phpEx); 74 75 //include($root_path . 'includes/constants.'.$phpEx); 76 //include($root_path . 'includes/db.'.$phpEx); 77 78 79 // Any mode passed? 80 if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) 81 { 82 $mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; 83 $target = ( isset($HTTP_GET_VARS['target']) ) ? $HTTP_GET_VARS['target'] : $HTTP_POST_VARS['target']; 84 } 85 else 86 { 87 $mode = ""; 88 } 89 90 // Read in the board config to maintain dynamic 91 $config_result = $db->sql_query("select config_name,config_value from ". CONFIG_TABLE .""); 92 while ($config_row = $db->sql_fetchrow($config_result)) 93 { 94 $board_config[$config_row[config_name]] = $config_row[config_value]; 95 } 96 97 // Select all avatars and usernames that have an uploaded avatar currently 98 $sql = "SELECT user_id, username, user_avatar FROM " . USERS_TABLE . " 99 WHERE user_avatar_type = " . USER_AVATAR_UPLOAD . " AND user_avatar IS NOT NULL"; 100 101 if(!$result = $db->sql_query($sql)) 102 { 103 $error = $db->sql_error(); 104 die("Could not get avatar information! $error[code] : $error[message]"); 105 } 106 107 // Create a hash to keep track of all the user that is using the uploaded avatar 108 while ($avatar_rowset = $db->sql_fetchrow($result)) 109 { 110 $avatar_usage[$avatar_rowset[user_avatar]] = $avatar_rowset[username]; 111 } 112 113 // This is the variable that points to the path of the avatars 114 // You may need to ajust this to meet your needs ;) 115 $real_avatar_dir = $phpbb_root_path . '../../' . $board_config['avatar_path']; 116 117 echo '<h1>Avatar Management</h1> 118 119 <p>The table below shows all currently stored uploaded avatars. These are only the avatars which were selected to be 120 uploaded by users, this will not show avatars currently in the gallery. If any of the listed avatars are no longer used 121 by any user an option to delete it will appear. This is a permanent delete, once you have selected to delete an 122 avatar it will be removed from the server and no longer be available. You will be prompted for confirmation (requires 123 Javascript).</p>'; 124 125 switch( $mode ) 126 { 127 case "delete": 128 echo '<table cellpadding=4 cellspacing=1 border=0 class=forumline>'; 129 if ( unlink($real_avatar_dir.'/'.$target) ) 130 { 131 print "<tr><td>Success, $target deleted!</td></tr><tr><td><a href=\"./admin_avatar.php\">Continue</a></td></tr></table>"; 132 } 133 else 134 { 135 print "<tr><td>FAILED to delete $target!</td></tr><tr><td><a href=javascript:history.go(-1)>Go Back</a></td></tr></table>"; 136 } 137 break; 138 139 default: 140 echo '<style> 141 <!-- 142 td.avatar_listing { font-family: Verdana; font-size: xx-small; text-align: center; } 143 th.avatar_listing { font-family: Verdana; font-size: x-small; text-align: center; font-weight: bold; 144 background-color: #cccccc; } 145 --> 146 </style> 147 148 <table cellpadding=4 cellspacing=1 border=0 class=forumline> 149 <tr> 150 <th class=avatar_listing width=40%>Avatar</th> 151 <th class=avatar_listing width=20%>Size</th> 152 <th class=avatar_listing width=20%>Usage</th> 153 <th class=avatar_listing width=20%>Edit user</th> 154 </tr>'; 155 156 $alt1 = '#CCCCFF'; 157 $alt2 = '#EEEEEE'; 158 $alter = $alt2; 159 160 // This is where we go through the avatar directory and report whether they are not 161 // used or if they are used, by who. 162 if ($avatar_dir = @opendir($real_avatar_dir)) 163 { 164 while( $file = @readdir($avatar_dir) ) 165 { 166 // This is where the script will filter out any file that doesn't match the patterns 167 if( $file != "." && $file != ".." && ereg("\.(gif|jpg|jpeg|png)$",$file) ) 168 { 169 $stats = stat($real_avatar_dir.'/'.$file); 170 171 // Alternating row colows code 172 if ($alter == $alt1) { $alter = $alt2; } 173 elseif ($alter == $alt2) { $alter = $alt1; } 174 if (isset($avatar_usage[$file]) ) 175 { 176 // Since we need to supply a link with a valid sid later in html, let's build it now 177 $av_id = $avatar_usage[$file]; 178 $sql = "SELECT user_id FROM " . USERS_TABLE . " 179 WHERE username = '$av_id'"; 180 if(!$result = $db->sql_query($sql)) 181 { 182 $error = $db->sql_error(); 183 die("Could not get user information! $error[code] : $error[message]"); 184 } 185 $av_uid = $db->sql_fetchrow($result); 186 $avatar_uid = $av_uid['user_id']; 187 $edit_url = append_sid("./admin_users.php?mode=edit&u=$avatar_uid"); 188 // Bingo, someone is using this avatar 189 print "<tr><td class=avatar_listing bgcolor=$alter><img src=$real_avatar_dir/$file><br>$file</td> 190 <td class=avatar_listing bgcolor=$alter>$stats[7] Bytes</td> 191 <td class=avatar_listing bgcolor=$alter>$avatar_usage[$file]</td> 192 <td class=avatar_listing bgcolor=$alter> 193 <a href=\"$edit_url\"> Edit $avatar_usage[$file]</a></td></tr>\n"; 194 195 } 196 else 197 { 198 // Not used, safe to display delete link for admin 199 $delete_html = append_sid("$PHP_SELF?mode=delete&target=$file"); 200 print "<tr><td class=avatar_listing bgcolor=$alter><img src=$real_avatar_dir/$file><br>$file</td> 201 <td class=avatar_listing bgcolor=$alter>$stats[7] Bytes</td> 202 <td class=avatar_listing bgcolor=$alter>Not Used<br><a href=$delete_html onClick=\"if(confirm('Are you sure you want to delete: $file ?')) return true; else return false;\">Delete</a></td> 203 <td class=avatar_listing bgcolor=$alter> </td> 204 </tr>\n"; 205 } 206 } 207 } 208 } 209 else 210 { 211 // If we made it to this else there was a problem trying to read the avatar directory 212 // If you see this error message check this variable: 213 // $real_avatar_dir -> This may be set incorrectly for your site. 214 print "Avatar directory unavailable!"; 215 } 216 217 echo '</table>'; 218 break; 219 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 11:11:59 2007 | par Balluche grâce à PHPXref 0.7 |