Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/bridge/vbulletin3gamma.inc.php,v $
15
  $Revision: 1.6 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:13 $
18
**********************************************/
19
// ------------------------------------------------------------------------- //
20
// vBulletin 3.0 Integration for Coppermine
21
// ------------------------------------------------------------------------- //
22
 
23
// ------------------------------------------------------------------------- //
24
// Modify the values below according to your Board installation
25
// ------------------------------------------------------------------------- //
26
// database configuration
27
define('VB_CUST_NO', 'xxxxxxxx'); // Your vBulletin license number (NOT your customer number)
28
define('VB_DB_NAME', 'forum'); // The name of the database used by the board
29
define('VB_BD_HOST', 'localhost'); // The name of the database server
30
define('VB_DB_USERNAME', 'username'); // The username to use to connect to the database
31
define('VB_DB_PASSWORD', 'password'); // The password to use to connect to the database
32
 
33
// The web path to your vBulletin Board directory
34
// In this example http://yoursite_name.com/vbulletin3/
35
define('VB_WEB_PATH', '/vbulletin3/');
36
// ------------------------------------------------------------------------- //
37
// Nothing to edit below this line
38
// ------------------------------------------------------------------------- //
39
// Prefix and names for the database tables
40
define('VB_TABLE_PREFIX', ''); // Leave empty, not supported by vBulletin 2.3
41
define('VB_USER_TABLE', 'user'); // The members table
42
define('VB_SESSION_TABLE', 'session'); // The sessions table
43
define('VB_GROUP_TABLE', 'usergroup'); // The groups table
44
 
45
// Group definitions (default values used by the board)
46
define('VB_VALIDATING_GROUP', 3);
47
define('VB_GUEST_GROUP', 1);
48
define('VB_MEMBERS_GROUP', 2);
49
define('VB_ADMIN_GROUP', 6);
50
// Authenticate a user using cookies
51
function udb_authenticate()
52
{
53
    global $HTTP_COOKIE_VARS, $USER_DATA, $UDB_DB_LINK_ID, $UDB_DB_NAME_PREFIX, $CONFIG;
54
    global $HTTP_SERVER_VARS, $HTTP_X_FORWARDED_FOR, $HTTP_PROXY_USER, $REMOTE_ADDR;
55
    // For error checking
56
    $CONFIG['TABLE_USERS'] = '**ERROR**';
57
    // Permissions for a default group
58
    $default_group = array('group_id' => VB_GUEST_GROUP,
59
        'group_name' => 'Unknown',
60
        'has_admin_access' => 0,
61
        'can_send_ecards' => 0,
62
        'can_rate_pictures' => 0,
63
        'can_post_comments' => 0,
64
        'can_upload_pictures' => 0,
65
        'can_create_albums' => 0,
66
        'pub_upl_need_approval' => 1,
67
        'priv_upl_need_approval' => 1,
68
        );
69
    // get first 50 chars
70
    $HTTP_USER_AGENT = substr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 0, 50);
71
    $REMOTE_ADDR = substr($HTTP_SERVER_VARS['REMOTE_ADDR'], 0, 50);
72
 
73
    if (is_array($HTTP_COOKIE_VARS)) {
74
        $sessionhash = isset($HTTP_COOKIE_VARS['sessionhash']) ? $HTTP_COOKIE_VARS['sessionhash'] : '';
75
        $bbuserid = isset($HTTP_COOKIE_VARS['bbuserid']) ? $HTTP_COOKIE_VARS['bbuserid'] : 0;
76
        $bbpassword = isset($HTTP_COOKIE_VARS['bbpassword']) ? $HTTP_COOKIE_VARS['bbpassword'] : '';
77
    }
78
 
79
    $got_user = 0;
80
 
81
    if ($bbuserid && $bbpassword) {
82
        // If userid and password exist in cookies we use them to login
83
        $sql = "SELECT userid as user_id, username as user_name, usergroupid as mgroup, password " . "FROM " . $UDB_DB_NAME_PREFIX . VB_TABLE_PREFIX . VB_USER_TABLE . " " . "WHERE userid='" . addslashes($bbuserid) . "'";
84
        $result = db_query($sql, $UDB_DB_LINK_ID);
85
        if (mysql_num_rows($result)) {
86
            $USER_DATA = mysql_fetch_array($result);
87
            if (md5($USER_DATA['password'] . VB_CUST_NO) == $bbpassword) {
88
                $got_user = 1;
89
            }
90
        }
91
    } elseif ($sessionhash) {
92
        // session hash exists
93
        // validate it:
94
        if ($HTTP_SERVER_VARS['HTTP_CLIENT_IP'])
95
        {
96
            $alt_ip =  $HTTP_SERVER_VARS['HTTP_CLIENT_IP'];
97
        }
98
        else if ($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'] AND preg_match('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'], $matches))
99
        {
100
            $alt_ip = $matches[0];
101
        }
102
        else if ($HTTP_SERVER_VARS['HTTP_FROM'])
103
        {
104
            $alt_ip = $HTTP_SERVER_VARS['HTTP_FROM'];
105
        }
106
        else
107
        {
108
            $alt_ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
109
        }
110
        $idhash = md5($HTTP_SERVER_VARS['HTTP_USER_AGENT'] . $alt_ip );
111
 
112
        $sql = "SELECT sessionhash,userid,host,useragent,styleid " . "FROM " . $UDB_DB_NAME_PREFIX . VB_TABLE_PREFIX . VB_SESSION_TABLE . " " . "WHERE sessionhash='" . addslashes(trim($sessionhash)) . "' " . " AND host='" . addslashes(substr($HTTP_SERVER_VARS['REMOTE_ADDR'], 0, 15)) . "' " . "  AND idhash='" . addslashes($idhash) . "'";
113
 
114
        $result = db_query($sql, $UDB_DB_LINK_ID);
115
 
116
        if (mysql_num_rows($result)) {
117
            // session hash exists
118
            $session_data = mysql_fetch_array($result);
119
            mysql_free_result($result);
120
 
121
            $sql = "SELECT userid as user_id, username as user_name, usergroupid as mgroup " . "FROM " . $UDB_DB_NAME_PREFIX . VB_TABLE_PREFIX . VB_USER_TABLE . " " . "WHERE userid='" . $session_data['userid'] . "'";
122
            $result = db_query($sql, $UDB_DB_LINK_ID);
123
            if (mysql_num_rows($result)) {
124
                $USER_DATA = mysql_fetch_array($result);
125
                $got_user = 1;
126
            }
127
        }
128
    }
129
 
130
    if ($got_user) {
131
        mysql_free_result($result);
132
 
133
        define('USER_ID', (int)$USER_DATA['user_id']);
134
        define('USER_NAME', $USER_DATA['user_name']);
135
        // Retrieve group information
136
        $sql = "SELECT * " . "FROM {$CONFIG['TABLE_USERGROUPS']} " . "WHERE group_id = '{$USER_DATA['mgroup']}'";
137
        $result = db_query($sql);
138
        if (mysql_num_rows($result)) {
139
            $USER_DATA2 = mysql_fetch_array($result);
140
        } else {
141
            $USER_DATA2 = $default_group;
142
        }
143
 
144
        $USER_DATA = array_merge($USER_DATA, $USER_DATA2);
145
 
146
        define('USER_GROUP', $USER_DATA['group_name']);
147
        define('USER_GROUP_SET', '(' . $USER_DATA['group_id'] . ')');
148
        define('USER_IS_ADMIN', ($USER_DATA['mgroup'] == VB_ADMIN_GROUP));
149
        define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
150
        define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
151
        define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
152
        define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
153
        define('USER_CAN_CREATE_ALBUMS', (int)$USER_DATA['can_create_albums']);
154
        mysql_free_result($result);
155
    } else {
156
        $result = db_query("SELECT * FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = " . VB_GUEST_GROUP);
157
        if (!mysql_num_rows($result)) {
158
            $USER_DATA = $default_group;
159
        } else {
160
            $USER_DATA = mysql_fetch_array($result);
161
        }
162
        define('USER_ID', 0);
163
        define('USER_NAME', 'Anonymous');
164
        define('USER_GROUP_SET', '(' . VB_GUEST_GROUP . ')');
165
        define('USER_IS_ADMIN', 0);
166
        define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
167
        define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
168
        define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
169
        define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
170
        define('USER_CAN_CREATE_ALBUMS', 0);
171
        mysql_free_result($result);
172
    }
173
}
174
// Retrieve the name of a user
175
function udb_get_user_name($uid)
176
{
177
    global $UDB_DB_LINK_ID, $UDB_DB_NAME_PREFIX, $CONFIG;
178
 
179
    $sql = "SELECT username as user_name " . "FROM " . $UDB_DB_NAME_PREFIX . VB_TABLE_PREFIX . VB_USER_TABLE . " " . "WHERE userid = '$uid'";
180
 
181
    $result = db_query($sql, $UDB_DB_LINK_ID);
182
 
183
    if (mysql_num_rows($result)) {
184
        $row = mysql_fetch_array($result);
185
        mysql_free_result($result);
186
        return $row['user_name'];
187
    } else {
188
        return '';
189
    }
190
}
191
// Redirect
192
function udb_redirect($target)
193
{
194
    header('Location: ' . VB_WEB_PATH . $target);
195
    exit;
196
}
197
// Register
198
function udb_register_page()
199
{
200
    $target = 'register.php';
201
    udb_redirect($target);
202
}
203
// Login
204
function udb_login_page()
205
{
206
    $target = 'login.php';
207
    udb_redirect($target);
208
}
209
// Logout
210
function udb_logout_page()
211
{
212
    $target = 'login.php?&do=logout';
213
    udb_redirect($target);
214
}
215
// Edit users
216
function udb_edit_users()
217
{
218
    $target = 'admincp/index.php';
219
    udb_redirect($target);
220
}
221
// Get user information
222
function udb_get_user_infos($uid)
223
{
224
    global $CONFIG, $UDB_DB_NAME_PREFIX, $UDB_DB_LINK_ID;
225
    global $lang_register_php;
226
 
227
    $sql = "SELECT username as user_name, usergroupid as mgroup, email as user_email, joindate as user_regdate, " . "homepage as user_website " . "FROM " . $UDB_DB_NAME_PREFIX . VB_TABLE_PREFIX . VB_USER_TABLE . " " . "WHERE userid = '$uid'";
228
    $result = db_query($sql, $UDB_DB_LINK_ID);
229
 
230
    if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_register_php['err_unk_user'], __FILE__, __LINE__);
231
    $user_data = mysql_fetch_array($result);
232
    mysql_free_result($result);
233
 
234
    $user_data['group_name'] = '';
235
    $user_data['user_occupation'] = '';
236
    $user_data['user_location'] = '';
237
    $user_data['user_interests'] = '';
238
 
239
    $sql = "SELECT group_name " . "FROM {$CONFIG['TABLE_USERGROUPS']} " . "WHERE group_id = {$user_data['mgroup']} ";
240
    $result = db_query($sql);
241
 
242
    if (mysql_num_rows($result)) {
243
        $row = mysql_fetch_array($result);
244
        $user_data['group_name'] = $row['group_name'];
245
    }
246
    mysql_free_result($result);
247
 
248
    return $user_data;
249
}
250
// Edit user profile
251
function udb_edit_profile($uid)
252
{
253
    $target = 'usercp.php';
254
    udb_redirect($target);
255
}
256
// Query used to list users
257
function udb_list_users_query(&$user_count)
258
{
259
    global $CONFIG, $FORBIDDEN_SET;
260
 
261
        if ($FORBIDDEN_SET != "") $forbidden = "AND $FORBIDDEN_SET";
262
    $sql = "SELECT (category - " . FIRST_USER_CAT . ") as user_id," . "  '???' as user_name," . "  COUNT(DISTINCT a.aid) as alb_count," . "  COUNT(DISTINCT pid) as pic_count," . "  MAX(pid) as thumb_pid " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.aid = a.aid " . "WHERE approved = 'YES' AND category > " . FIRST_USER_CAT . " $forbidden GROUP BY category " . "ORDER BY category ";
263
    $result = db_query($sql);
264
 
265
    $user_count = mysql_num_rows($result);
266
 
267
    return $result;
268
}
269
 
270
function udb_list_users_retrieve_data($result, $lower_limit, $count)
271
{
272
    global $CONFIG, $UDB_DB_NAME_PREFIX, $UDB_DB_LINK_ID;
273
 
274
    mysql_data_seek($result, $lower_limit);
275
 
276
    $rowset = array();
277
    $i = 0;
278
    $user_id_set = '';
279
 
280
    while (($row = mysql_fetch_array($result)) && ($i++ < $count)) {
281
        $user_id_set .= $row['user_id'] . ',';
282
        $rowset[] = $row;
283
    }
284
    mysql_free_result($result);
285
 
286
    $user_id_set = '(' . substr($user_id_set, 0, -1) . ')';
287
    $sql = "SELECT userid as user_id, username as user_name " . "FROM " . $UDB_DB_NAME_PREFIX . VB_TABLE_PREFIX . VB_USER_TABLE . " " . "WHERE userid IN $user_id_set";
288
    $result = db_query($sql, $UDB_DB_LINK_ID);
289
    while ($row = mysql_fetch_array($result)) {
290
        $name[$row['user_id']] = $row['user_name'];
291
    }
292
    for($i = 0; $i < count($rowset); $i++) {
293
        $rowset[$i]['user_name'] = empty($name[$rowset[$i]['user_id']]) ? '???' : $name[$rowset[$i]['user_id']];
294
    }
295
 
296
    return $rowset;
297
}
298
// Group table synchronisation
299
function udb_synchronize_groups()
300
{
301
    global $CONFIG, $UDB_DB_NAME_PREFIX, $UDB_DB_LINK_ID;
302
 
303
    $result = db_query("SELECT usergroupid, title FROM " . $UDB_DB_NAME_PREFIX . VB_TABLE_PREFIX . VB_GROUP_TABLE . " WHERE 1", $UDB_DB_LINK_ID);
304
    while ($row = mysql_fetch_array($result)) {
305
        $VB_groups[$row['usergroupid']] = $row['title'];
306
    }
307
    mysql_free_result($result);
308
 
309
    $result = db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE 1");
310
    while ($row = mysql_fetch_array($result)) {
311
        $cpg_groups[$row['group_id']] = $row['group_name'];
312
    }
313
    mysql_free_result($result);
314
    // Scan Coppermine groups that need to be deleted
315
    foreach($cpg_groups as $c_group_id => $c_group_name) {
316
        if ((!isset($VB_groups[$c_group_id]))) {
317
            db_query("DELETE FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = '" . $c_group_id . "' LIMIT 1");
318
            unset($cpg_groups[$c_group_id]);
319
        }
320
    }
321
    // Scan vBulletin Board groups that need to be created inside Coppermine table
322
    foreach($VB_groups as $i_group_id => $i_group_name) {
323
        if ((!isset($cpg_groups[$i_group_id]))) {
324
            db_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']} (group_id, group_name) VALUES ('$i_group_id', '" . addslashes($i_group_name) . "')");
325
            $cpg_groups[$i_group_id] = $i_group_name;
326
        }
327
    }
328
    // Update Group names
329
    foreach($VB_groups as $i_group_id => $i_group_name) {
330
        if ($cpg_groups[$i_group_id] != $i_group_name) {
331
            db_query("UPDATE {$CONFIG['TABLE_USERGROUPS']} SET group_name = '" . addslashes($i_group_name) . "' WHERE group_id = '$i_group_id' LIMIT 1");
332
        }
333
    }
334
}
335
// Retrieve the album list used in gallery admin mode
336
function udb_get_admin_album_list()
337
{
338
    global $CONFIG, $UDB_DB_NAME_PREFIX, $UDB_DB_LINK_ID, $FORBIDDEN_SET;
339
 
340
    if (UDB_CAN_JOIN_TABLES) {
341
        $sql = "SELECT aid, CONCAT('(', username, ') ', a.title) AS title " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "INNER JOIN " . $UDB_DB_NAME_PREFIX . VB_TABLE_PREFIX . VB_USER_TABLE . " AS u ON category = (" . FIRST_USER_CAT . " + userid) " . "ORDER BY title";
342
        return $sql;
343
    } else {
344
        $sql = "SELECT aid, IF(category > " . FIRST_USER_CAT . ", CONCAT('* ', title), CONCAT(' ', title)) AS title " . "FROM {$CONFIG['TABLE_ALBUMS']} " . "ORDER BY title";
345
        return $sql;
346
    }
347
}
348
 
349
function udb_util_filloptions()
350
{
351
    global $albumtbl, $picturetbl, $categorytbl, $lang_util_php, $CONFIG, $UDB_DB_NAME_PREFIX, $UDB_DB_LINK_ID;
352
 
353
    $usertbl = $UDB_DB_NAME_PREFIX.VB_TABLE_PREFIX.VB_USER_TABLE;
354
 
355
    if (UDB_CAN_JOIN_TABLES) {
356
 
357
        $query = "SELECT aid, category, IF(username IS NOT NULL, CONCAT('(', username, ') ', a.title), CONCAT(' - ', a.title)) AS title " . "FROM $albumtbl AS a " . "LEFT JOIN $usertbl AS u ON category = (" . FIRST_USER_CAT . " + userid) " . "ORDER BY category, title";
358
        $result = db_query($query, $UDB_DB_LINK_ID);
359
        // $num=mysql_numrows($result);
360
        echo '<select size="1" name="albumid">';
361
 
362
        while ($row = mysql_fetch_array($result)) {
363
            $sql = "SELECT name FROM $categorytbl WHERE cid = " . $row["category"];
364
            $result2 = db_query($sql);
365
            $row2 = mysql_fetch_array($result2);
366
 
367
            print "<option value=\"" . $row["aid"] . "\">" . $row2["name"] . $row["title"] . "</option>\n";
368
        }
369
 
370
        print '</select> (3)';
371
        print '&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="'.$lang_util_php['submit_form'].'" class="submit" /> (4)';
372
        print '</form>';
373
 
374
    } else {
375
 
376
        // Query for list of public albums
377
 
378
        $public_albums = db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE category < " . FIRST_USER_CAT . " ORDER BY title");
379
 
380
        if (mysql_num_rows($public_albums)) {
381
            $public_result = db_fetch_rowset($public_albums);
382
        } else {
383
            $public_result = array();
384
        }
385
 
386
        // Initialize $merged_array
387
        $merged_array = array();
388
 
389
        // Count the number of albums returned.
390
        $end = count($public_result);
391
 
392
        // Cylce through the User albums.
393
        for($i=0;$i<$end;$i++) {
394
 
395
            //Create a new array sow we may sort the final results.
396
            $merged_array[$i]['id'] = $public_result[$i]['aid'];
397
            $merged_array[$i]['album_name'] = $public_result[$i]['title'];
398
 
399
            // Query the database to get the category name.
400
            $vQuery = "SELECT name, parent FROM " . $CONFIG['TABLE_CATEGORIES'] . " WHERE cid='" . $public_result[$i]['category'] . "'";
401
            $vRes = mysql_query($vQuery);
402
            $vRes = mysql_fetch_array($vRes);
403
            if (isset($merged_array[$i]['username_category'])) {
404
                $merged_array[$i]['username_category'] = (($vRes['name']) ? '(' . $vRes['name'] . ') ' : '').$merged_array[$i]['username_category'];
405
            } else {
406
                $merged_array[$i]['username_category'] = (($vRes['name']) ? '(' . $vRes['name'] . ') ' : '');
407
            }
408
 
409
        }
410
 
411
        // We transpose and divide the matrix into columns to prepare it for use in array_multisort().
412
        foreach ($merged_array as $key => $row) {
413
           $aid[$key] = $row['id'];
414
           $title[$key] = $row['album_name'];
415
           $album_lineage[$key] = $row['username_category'];
416
        }
417
 
418
        // We sort all columns in descending order and plug in $album_menu at the end so it is sorted by the common key.
419
        array_multisort($album_lineage, SORT_ASC, $title, SORT_ASC, $aid, SORT_ASC, $merged_array);
420
 
421
        // Query for list of user albums
422
 
423
        $user_albums = db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE category >= " . FIRST_USER_CAT . " ORDER BY aid");
424
        if (mysql_num_rows($user_albums)) {
425
            $user_albums_list = db_fetch_rowset($user_albums);
426
        } else {
427
            $user_albums_list = array();
428
        }
429
 
430
        // Query for list of user IDs and names
431
 
432
        $user_album_ids_and_names = db_query("SELECT (userid + ".FIRST_USER_CAT.") as id, CONCAT('(', username, ') ') as name FROM $usertbl ORDER BY name ASC",$UDB_DB_LINK_ID);
433
 
434
        if (mysql_num_rows($user_album_ids_and_names)) {
435
            $user_album_ids_and_names_list = db_fetch_rowset($user_album_ids_and_names);
436
        } else {
437
            $user_album_ids_and_names_list = array();
438
        }
439
 
440
        // Glue what we've got together.
441
 
442
        // Initialize $udb_i as a counter.
443
        if (count($merged_array)) {
444
            $udb_i = count($merged_array);
445
        } else {
446
            $udb_i = 0;
447
        }
448
 
449
        //Begin a set of nested loops to merge the various query results.
450
        foreach ($user_albums_list as $aq) {
451
            foreach ($user_album_ids_and_names_list as $uq) {
452
                if ($aq['category'] == $uq['id']) {
453
                    $merged_array[$udb_i]['id']= $aq['category'];
454
                    $merged_array[$udb_i]['album_name']= $aq['title'];
455
                    $merged_array[$udb_i]['username_category']= $uq['name'];
456
                    $udb_i++;
457
                }
458
            }
459
        }
460
 
461
        // The user albums and public albums have been merged into one list. Print the dropdown.
462
        echo '<select size="1" name="albumid">';
463
 
464
        foreach ($merged_array as $menu_item) {
465
 
466
            echo "<option value=\"" . $menu_item['id'] . "\">" . (isset($menu_item['username_category']) ? $menu_item['username_category'] : '') . $menu_item['album_name'] . "</option>\n";
467
 
468
        }
469
 
470
        // Close list, etc.
471
        print '</select> (3)';
472
        print '&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="'.$lang_util_php['submit_form'].'" class="submit" /> (4)';
473
        print '</form>';
474
 
475
    }
476
 
477
}
478
 
479
// ------------------------------------------------------------------------- //
480
// Define wheter we can join tables or not in SQL queries (same host & same db or user)
481
define('UDB_CAN_JOIN_TABLES', (VB_BD_HOST == $CONFIG['dbserver'] && (VB_DB_NAME == $CONFIG['dbname'] || VB_DB_USERNAME == $CONFIG['dbuser'])));
482
// Connect to vBulletin Board Database if necessary
483
$UDB_DB_LINK_ID = 0;
484
$UDB_DB_NAME_PREFIX = VB_DB_NAME ? '`' . VB_DB_NAME . '`.' : '';
485
if (!UDB_CAN_JOIN_TABLES) {
486
    $UDB_DB_LINK_ID = @mysql_connect(VB_BD_HOST, VB_DB_USERNAME, VB_DB_PASSWORD);
487
    if (!$UDB_DB_LINK_ID) die("<b>Coppermine critical error</b>:<br />Unable to connect to vBulletin Board database !<br /><br />MySQL said: <b>" . mysql_error() . "</b>");
488
}
489
 
490
?>