If someone could help me with this JUpload MOD to 1.4.3 Stand alone stable. Everything seems to be working but the cookie stuff. The core code is totaly different in 1.4.3.
1.3.5
functions.inc.php before JUpload MOD
function user_get_profile()
{
global $CONFIG, $USER, $HTTP_COOKIE_VARS;
if (isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_data'])) {
$USER = @unserialize(@base64_decode($HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_data']));
}
if (!isset($USER['ID']) || strlen($USER['ID']) != 32) {
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
srand($seed);
$USER=array('ID' => md5(uniqid(rand(),1)));
} else {
$USER['ID'] = addslashes($USER['ID']);
}
if (!isset($USER['am'])) $USER['am'] = 1;
}
1.3.5
functions.inc.php WITH JUpload MOD
function user_get_profile()
{
global $CONFIG, $USER, $HTTP_COOKIE_VARS;
if (isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_data'])) {
$USER = @unserialize(@base64_decode($HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_data']));
} else if (isset($_GET["cookie"])) {
//JUpload Modification Mark Stralka 7/25/2004
//if a parameter named "cookie" is passed, try to parse it into the the $USER object and
//set the cookie values.
$USER = @unserialize(@base64_decode($_GET["cookie"]));
$HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_uid'] = $USER[$CONFIG['cookie_name'].'_uid'];
$HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_data'] = $USER[$CONFIG['cookie_name'].'_data'];
$HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_pass'] = $USER[$CONFIG['cookie_name'].'_pass'];
}
if (!isset($USER['ID']) || strlen($USER['ID']) != 32) {
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
srand($seed);
$USER=array('ID' => md5(uniqid(rand(),1)));
} else {
$USER['ID'] = addslashes($USER['ID']);
}
if (!isset($USER['am'])) $USER['am'] = 1;
}
1.4.3
functions.inc.php before JUpload MOD
function user_get_profile()
{
global $CONFIG, $USER;
if (isset($_COOKIE[$CONFIG['cookie_name'].'_data'])) {
$USER = @unserialize(@base64_decode($_COOKIE[$CONFIG['cookie_name'].'_data']));
}
if (!isset($USER['ID']) || strlen($USER['ID']) != 32) {
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
srand($seed);
$USER=array('ID' => md5(uniqid(rand(),1)));
} else {
$USER['ID'] = addslashes($USER['ID']);
}
if (!isset($USER['am'])) $USER['am'] = 1;
}
1.4.3
functions.inc.php WITH JUpload MOD
function user_get_profile()
{
global $CONFIG, $USER;
if (isset($_COOKIE[$CONFIG['cookie_name'].'_data'])) {
$USER = @unserialize(@base64_decode($_COOKIE[$CONFIG['cookie_name'].'_data']));
} else if (isset($_GET["cookie"])) {
//JUpload Modification Mark Stralka 7/25/2004
//if a parameter named "cookie" is passed, try to parse it into the the $USER object and
//set the cookie values.
$USER = @unserialize(@base64_decode($_GET["cookie"]));
$_COOKIE[$CONFIG['cookie_name'].'_uid'] = $USER[$CONFIG['cookie_name'].'_uid'];
$_COOKIE[$CONFIG['cookie_name'].'_data'] = $USER[$CONFIG['cookie_name'].'_data'];
$_COOKIE[$CONFIG['cookie_name'].'_pass'] = $USER[$CONFIG['cookie_name'].'_pass'];
}
if (!isset($USER['ID']) || strlen($USER['ID']) != 32) {
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
srand($seed);
$USER=array('ID' => md5(uniqid(rand(),1)));
} else {
$USER['ID'] = addslashes($USER['ID']);
}
if (!isset($USER['am'])) $USER['am'] = 1;
}
Now I am not sure if I applied this right or if the $USER[$CONFIG['cookie_name'].'_uid']; and other two peramiters even work to push to cookie. Now the authentification() function is totaly different from 1.3.5 and 1.4.3 and is causing me some confusion.
1.3.5
init.inc.php
// 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']} WHERE 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_assoc($results);
//unset($USER_DATA['user_password']);
$USER_DATA['user_password'] = '********';
$USER_DATA = $USER_DATA + cpgGetUserData($USER_DATA['user_group'], explode(',', $USER_DATA['user_group_list']));
define('USER_ID', (int)$USER_DATA['user_id']);
define('USER_NAME', $USER_DATA['user_name']);
define('USER_GROUP', $USER_DATA['group_name']);
define('USER_GROUP_SET', '(' . implode(',', $USER_DATA['groups']) . ')');
define('USER_IS_ADMIN', (int)$USER_DATA['has_admin_access']);
define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
define('USER_CAN_CREATE_ALBUMS', (int)$USER_DATA['can_create_albums']);
define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);
mysql_free_result($results);
} else {
$USER_DATA = cpgGetUserData(3, array(3));
define('USER_ID', 0);
define('USER_NAME', 'Anonymous');
define('USER_GROUP', $USER_DATA['group_name']);
define('USER_GROUP_SET', '(' . $USER_DATA['group_id'] . ')');
define('USER_IS_ADMIN', 0);
define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
define('USER_CAN_CREATE_ALBUMS', 0);
define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);
mysql_free_result($results);
}
}
1.4.3
init.inc.php
// Authenticate
$cpg_udb->authenticate();
So now lets follow the authenticate function on the 1.4.3 and see what it is doing.
1.4.3
udb_base.inc.php
function authenticate()
{
global $USER_DATA;
if (!($auth = $this->session_extraction()) && !($auth = $this->cookie_extraction())) {
$this->load_guest_data();
} else {
list ($id, $cookie_pass) = $auth;
$f = $this->field;
if (isset($this->usergroupstable)){
$sql = "SELECT u.{$f['user_id']} AS id, u.{$f['username']} AS username, u.{$f['password']} AS password, ug.{$f['usertbl_group_id']} AS group_id ".
"FROM {$this->usertable} AS u, {$this->usergroupstable} AS ug ".
"WHERE u.{$f['user_id']}=ug.{$f['user_id']} AND u.{$f['user_id']}='$id'";
} else {
$sql = "SELECT u.{$f['user_id']} AS id, u.{$f['username']} AS username, u.{$f['password']} AS password, u.{$f['usertbl_group_id']}+100 AS group_id ".
"FROM {$this->usertable} AS u INNER JOIN {$this->groupstable} AS g ON u.{$f['usertbl_group_id']}=g.{$f['grouptbl_group_id']} ".
"WHERE u.{$f['user_id']}='$id'";
}
$result = cpg_db_query($sql, $this->link_id);
if (mysql_num_rows($result)){
$row = mysql_fetch_assoc($result);
mysql_free_result($result);
$db_pass = $this->udb_hash_db($row['password']);
if ($db_pass === $cookie_pass) {
$this->load_user_data($row);
} else {
$this->load_guest_data();
}
} else {
$this->load_guest_data();
}
}
$user_group_set = '(' . implode(',', $USER_DATA['groups']) . ')';
$USER_DATA = array_merge($USER_DATA, $this->get_user_data($USER_DATA['groups'][0], $USER_DATA['groups'], $this->guestgroup));
if ($this->use_post_based_groups){
$USER_DATA['has_admin_access'] = (in_array($USER_DATA['groups'][0] - 100,$this->admingroups)) ? 1 : 0;
} else {
$USER_DATA['has_admin_access'] = ($USER_DATA['groups'][0] == 1) ? 1 : 0;
}
$USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access'];
// avoids a template error
if (!$USER_DATA['user_id']) $USER_DATA['can_create_albums'] = 0;
// For error checking
$CONFIG['TABLE_USERS'] = '**ERROR**';
define('USER_ID', $USER_DATA['user_id']);
define('USER_NAME', addslashes($USER_DATA['user_name']));
define('USER_GROUP', $USER_DATA['group_name']);
define('USER_GROUP_SET', $user_group_set);
define('USER_IS_ADMIN', $USER_DATA['has_admin_access']);
define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
define('USER_CAN_CREATE_ALBUMS', (int)$USER_DATA['can_create_albums']);
define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);
$this->session_update();
}
So everything changed. Now I have no idea what is going on right here" list ($id, $cookie_pass) = $auth; " . So basicaly I need to know how to apply the idea of what they where doing here:
} else if (isset($_GET["cookie"])) {
//JUpload Modification Mark Stralka 7/25/2004
//if a parameter named "cookie" is passed, try to parse it into the the $USER object and
//set the cookie values.
$USER = @unserialize(@base64_decode($_GET["cookie"]));
$HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_uid'] = $USER[$CONFIG['cookie_name'].'_uid'];
$HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_data'] = $USER[$CONFIG['cookie_name'].'_data'];
$HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_pass'] = $USER[$CONFIG['cookie_name'].'_pass'];
to the 1.4.3.
If anyone can help me in this it would be much appreciated.