forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: terrorhawk on April 18, 2006, 10:18:51 pm

Title: read out login info
Post by: terrorhawk on April 18, 2006, 10:18:51 pm
Hello i just update my old 1.3.1 coppermine to 1.4.4.
i use a own made cms system as main page that is outside the coppermine root.
with 1.3.1 it was easy to get the use details but i have no iedee how to get this info from 1.4.4

here is my old code

Code: [Select]
function cpgGetMicroTime()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}
$time_start = cpgGetMicroTime();

function getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
// Include config and functions files
require 'public_html/cgi-din/album/include/config.inc.php';
require 'public_html/cgi-din/album/include/functions.inc.php';

$CONFIG['TABLE_PICTURES'] = $CONFIG['TABLE_PREFIX'] . "pictures";
$CONFIG['TABLE_ALBUMS'] = $CONFIG['TABLE_PREFIX'] . "albums";
$CONFIG['TABLE_COMMENTS'] = $CONFIG['TABLE_PREFIX'] . "comments";
$CONFIG['TABLE_CATEGORIES'] = $CONFIG['TABLE_PREFIX'] . "categories";
$CONFIG['TABLE_CONFIG'] = $CONFIG['TABLE_PREFIX'] . "config";
$CONFIG['TABLE_USERGROUPS'] = $CONFIG['TABLE_PREFIX'] . "usergroups";
$CONFIG['TABLE_VOTES'] = $CONFIG['TABLE_PREFIX'] . "votes";
$CONFIG['TABLE_USERS'] = $CONFIG['TABLE_PREFIX'] . "users";
$CONFIG['TABLE_BANNED'] = $CONFIG['TABLE_PREFIX'] . "banned";
$CONFIG['TABLE_ONLINE'] = $CONFIG['TABLE_PREFIX']."online";
// User DB system
if (defined('UDB_INTEGRATION')) require 'bridge/' . UDB_INTEGRATION . '.inc.php';
// Connect to database
cpg_db_connect() || die("<b>Coppermine critical error</b>:<br />Unable to connect to database !<br /><br />MySQL said: <b>" . mysql_error() . "</b>");
// Retrieve DB stored configuration
$results = db_query("SELECT * FROM {$CONFIG['TABLE_CONFIG']}");
while ($row = mysql_fetch_array($results)) {
    $CONFIG[$row['name']] = $row['value'];
} // while
mysql_free_result($results);
// Set error logging level
if ($CONFIG['debug_mode']) {
    error_reporting (E_ALL);
} else {
    error_reporting (E_ALL ^ E_NOTICE);
}
// Parse cookie stored user profile
user_get_profile();
// Authenticate
if (defined('UDB_INTEGRATION')) {
    udb_authenticate();
} else {
    if (!isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_uid']) || !isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_pass'])) {
        $cookie_uid = 0;
        $cookie_pass = '*';
    } else {
        $cookie_uid = (int)$HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_uid'];
        $cookie_pass = substr(addslashes($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_pass']), 0, 32);
    }

    $sql = "SELECT * " . "FROM {$CONFIG['TABLE_USERS']}, {$CONFIG['TABLE_USERGROUPS']} " . "WHERE user_group = group_id " . "AND user_id='$cookie_uid'" . "AND user_active = 'YES' " . "AND user_password != '' " . "AND BINARY MD5(user_password) = '$cookie_pass'";
    $results = db_query($sql);

    if (mysql_num_rows($results)) {
        $USER_DATA = mysql_fetch_array($results);

        $USER_ID = (int)$USER_DATA['user_id'];
        $USER_NAME = $USER_DATA['user_name'];
        $USER_EMAIL = $USER_DATA['user_email'];
        $USER_PASSWORD = $USER_DATA['user_password'];
       unset($USER_DATA['user_password']);

  $USER_Login = 1 ;
        $USER_GROUP = $USER_DATA['group_name'];
        $USER_GROUP_SET = '(' . $USER_DATA['group_id'] . ')';
        $USER_IS_ADMIN = (int)$USER_DATA['has_admin_access'];
        $USER_CAN_SEND_ECARDS = (int)$USER_DATA['can_send_ecards'];
        $USER_CAN_RATE_PICTURES = (int)$USER_DATA['can_rate_pictures'];
        $USER_CAN_POST_COMMENTS = (int)$USER_DATA['can_post_comments'];
        $USER_CAN_UPLOAD_PICTURES = (int)$USER_DATA['can_upload_pictures'];
        $USER_CAN_CREATE_ALBUMS = (int)$USER_DATA['can_create_albums'];


        mysql_free_result($results);
    } else {
        $results = db_query("SELECT * FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = 3");
        if (!mysql_num_rows($results)) die('<b>Coppermine critical error</b>:<br />The group table does not contain the Anonymous group !');
        $USER_DATA = mysql_fetch_array($results);
        $USER_ID = 0;
        $USER_NAME = 'Anonymous';
        $USER_Login = 0 ;
        $USER_GROUP = $USER_DATA['group_name'];
        $USER_GROUP_SET = '(' . $USER_DATA['group_id'] . ')';
        $USER_IS_ADMIN = 0;
        $USER_CAN_SEND_ECARDS = (int)$USER_DATA['can_send_ecards'];
        $USER_CAN_RATE_PICTURES = (int)$USER_DATA['can_rate_pictures'];
        $USER_CAN_POST_COMMENTS = (int)$USER_DATA['can_post_comments'];
        $USER_CAN_UPLOAD_PICTURES = (int)$USER_DATA['can_upload_pictures'];
        $USER_CAN_CREATE_ALBUMS = 0;

       
 mysql_free_result($results);
    }
}

now is the big question how do i get this to work again?

i still have encrypted passwords OFF