Skip to content

Commit

Permalink
Replaced hard-coded number "10000" with constant "FIRST_USER_CAT" (th…
Browse files Browse the repository at this point in the history
…read ID 78848).
  • Loading branch information
eenemeenemuu committed Sep 7, 2016
1 parent 6ce3f3f commit afbe843
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Expand Up @@ -22,6 +22,7 @@ Changelog
[S] = Security fix (issues that are related to security)
*********************************************

2016-09-06 [O] Replaced hard-coded number "10000" with constant "FIRST_USER_CAT" (thread ID 78848) {eenemeenemuu}
2016-07-19 [A] Added new options to "sort order of albums" (thread ID 78795) {eenemeenemuu}
2016-05-24 [B] Correct possible failure to get update when curl must be used {ron4mac}
2016-05-24 [C] Set table width to 100% on update.php {eenemeenemuu}
Expand Down
2 changes: 1 addition & 1 deletion bridge/udb_base.inc.php
Expand Up @@ -530,7 +530,7 @@ function list_users_query (&$user_count)
// This is the way we collect the data without a direct join to the forum's user table
// This query determines which users we need to collect usernames of - ie just those which have albums with pics
// and are on the page we are looking at
$sql = "SELECT category - 10000 AS user_id "
$sql = "SELECT category - ".FIRST_USER_CAT." AS user_id "
. "FROM {$CONFIG['TABLE_ALBUMS']} AS a "
. "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.aid = a.aid "
. "WHERE ((ISNULL(approved) OR approved='YES') "
Expand Down
2 changes: 1 addition & 1 deletion catmgr.php
Expand Up @@ -609,7 +609,7 @@ function verify_children($parent, $cid)

$description = $superCage->post->getEscaped('description');

cpg_db_query("INSERT INTO {$CONFIG['TABLE_CATEGORIES']} (pos, parent, name, description) VALUES (10000, $parent, '$name', '$description')");
cpg_db_query("INSERT INTO {$CONFIG['TABLE_CATEGORIES']} (pos, parent, name, description) VALUES (".FIRST_USER_CAT.", $parent, '$name', '$description')");

//insert in categorymap
$cid = cpg_db_last_insert_id();
Expand Down
10 changes: 5 additions & 5 deletions include/functions.inc.php
Expand Up @@ -3202,17 +3202,17 @@ function cpg_get_system_thumb_list($search_folder = 'images/')
* @return array
**/

function& cpg_get_system_thumb($filename, $user = 10001)
function& cpg_get_system_thumb($filename, $user = FIRST_USER_CAT)
{
global $CONFIG;

// Correct user_id
if ($user < 10000) {
$user += 10000;
if ($user < FIRST_USER_CAT) {
$user += FIRST_USER_CAT;
}

if ($user == 10000) {
$user = 10001;
if ($user == FIRST_USER_CAT) {
$user = FIRST_USER_CAT + 1;
}

// Get image data for thumb
Expand Down
2 changes: 1 addition & 1 deletion index.php
Expand Up @@ -939,7 +939,7 @@ function list_cat_albums($cat, $catdata)
return '';
}

$cat_owner_id = ($cat > 10000)?(10000 - $cat):(10001);
$cat_owner_id = ($cat > FIRST_USER_CAT)?(FIRST_USER_CAT - $cat):(FIRST_USER_CAT + 1);
$cpg_nopic_data = cpg_get_system_thumb('nopic.jpg', $cat_owner_id);
$cpg_privatepic_data = cpg_get_system_thumb('private.jpg', $cat_owner_id);

Expand Down
2 changes: 1 addition & 1 deletion sidebar.php
Expand Up @@ -315,7 +315,7 @@ function get_tree_album_data($category,$dtree_parent) {
$pic_filter = ' '.str_replace('p.',$CONFIG['TABLE_PICTURES'].'.',$FORBIDDEN_SET);
}
if ($category == USER_GAL_CAT) {
$sql = "SELECT DISTINCT user_id, user_name FROM {$CONFIG['TABLE_USERS']}, {$CONFIG['TABLE_ALBUMS']} WHERE 10000 + {$CONFIG['TABLE_USERS']}.user_id = {$CONFIG['TABLE_ALBUMS']}.category ORDER BY user_name ASC";
$sql = "SELECT DISTINCT user_id, user_name FROM {$CONFIG['TABLE_USERS']}, {$CONFIG['TABLE_ALBUMS']} WHERE ".FIRST_USER_CAT." + {$CONFIG['TABLE_USERS']}.user_id = {$CONFIG['TABLE_ALBUMS']}.category ORDER BY user_name ASC";
$result = cpg_db_query($sql);
if (($cat_count = $result->numRows()) > 0) {
$rowset = cpg_db_fetch_rowset($result);
Expand Down
1 change: 1 addition & 0 deletions update.php
Expand Up @@ -484,6 +484,7 @@ function update_tables()
$sql_query = fread(fopen($db_update, 'r'), filesize($db_update));
// Update table prefix
$sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query);
//$sql_query = str_replace('{FIRST_USER_CAT}', FIRST_USER_CAT, $sql_query);

$sql_query = remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, ';');
Expand Down

0 comments on commit afbe843

Please sign in to comment.