$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_password, cat_hide
$cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;
cat_unhide($cat_id);
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) { redirect($url);}
$txt_clickstream = get_category_path($cat_id,1).$config['category_separator'].format_text($image_row['image_name'], 2).$config['category_separator'];include(ROOT_PATH."includes/catpass.php");
$user_access = get_permission();
if (!$cat_id || !isset($cat_cache[$cat_id]) || !check_permission("auth_viewcat", $cat_id)) { redirect("index.php");}
include(ROOT_PATH."includes/catpass.php");
function check_permission($type, $cat_id = 0) {
function cat_unhide($cat_id, $save = 1){ global $cat_cache, $site_sess, $user_info, $site_db, $cat_parent_cache; if (!isset($cat_cache[$cat_id])) return; if (isset($cat_cache[$cat_id]['auth_viewcat_backup'])) $cat_cache[$cat_id]['auth_viewcat'] = $cat_cache[$cat_id]['auth_viewcat_backup']; $cat_subcat_ids = get_auth_subcat_ids($cat_id, $cat_id, $cat_parent_cache); if (isset($cat_subcat_ids[$cat_id])) { foreach ($cat_subcat_ids[$cat_id] as $key2 => $val2) { if ($cat_cache[$val2]['auth_viewcat'] < $cat_cache[$cat_id]['auth_viewcat'] && (!$cat_cache[$val2]['cat_hide'] || ($cat_cache[$val2]['cat_hide'] && isset($user_info['cat_hide'][$val2])))) { $cat_cache[$val2]['auth_viewcat'] = $cat_cache[$cat_id]['auth_viewcat']; } } } if ($cat_cache[$cat_id]['cat_hide']) { if (isset($user_info['cat_hide'][$cat_id])) return; $user_info['cat_hide'][$cat_id] = ""; if (!$save) return; if ($user_info['cat_hide_db']) { $sql = "UPDATE ".USERS_TABLE." SET cat_hide = '".implode("|", array_keys($user_info['cat_hide']))."' WHERE ".get_user_table_field("", "user_id")." = ".$user_info['user_id']; $site_db->query($sql); } else { $site_sess->set_session_var("cathide", implode("|", array_keys($user_info['cat_hide']))); } } else { if ($cat_cache[$cat_id]['cat_parent_id'] != 0) {//uncomment next line if you want unhide parent category when opened child category.// cat_unhide($cat_cache[$cat_id]['cat_parent_id'], $save); } } }function cat_pass_check($cat_id){ global $user_info, $site_sess, $cat_cache; if ($user_info['user_level'] == ADMIN) return true; if (isset($cat_cache[$cat_id]['cat_password_id'])) $cat_id = $cat_cache[$cat_id]['cat_password_id']; if (!isset($cat_cache[$cat_id]['cat_password']) || !$cat_cache[$cat_id]['cat_password']) return true; return (isset($user_info['cat_password'][$cat_id]) && $cat_cache[$cat_id]['cat_password'] == $user_info['cat_password'][$cat_id]) ? true : false;}function check_permission($type, $cat_id = 0) { global $user_info, $cat_cache; if (!_check_permission($type, $cat_id) && $cat_cache[$cat_id][$type] != 999) { return false; } if ($type != "auth_viewcat") { return true; } if ($user_info['user_level'] != ADMIN && $cat_cache[$cat_id][$type] == 999) { return false; } return true;}function _check_permission($type, $cat_id = 0) {
if ($val['auth_viewcat'] != AUTH_ALL) {
if ($val['cat_hide'] && !isset($user_info['cat_hide'][$key])) { $cat_cache[$key]['auth_viewcat_backup'] = $val['auth_viewcat']; $cat_cache[$key]['auth_viewcat'] = $val['auth_viewcat'] = 999; } if ($val['auth_viewcat'] != AUTH_ALL || $val['cat_password']) {
foreach ($cat_subcat_ids[$key] as $key2 => $val2) {
if (!$cat_cache[$val2]['cat_password'] && $cat_cache[$key]['cat_password']) //all subcategories also should obbey cat password from parent { $cat_cache[$val2]['cat_password'] = $cat_cache[$key]['cat_password']; $cat_cache[$val2]['cat_password_id'] = (isset($cat_cache[$key]['cat_password_id'])) ? $cat_cache[$key]['cat_password_id'] : $key; } if ($val['auth_viewcat'] == 999) { if ($cat_cache[$val2]['cat_hide'] && isset($user_info['cat_hide'][$val2]) && $cat_cache[$val2]['auth_viewcat'] < $cat_cache[$key]['auth_viewcat']) { $cat_cache[$val2]['auth_viewcat'] = $cat_cache[$key]['auth_viewcat_backup']; continue; } $cat_cache[$val2]['auth_viewcat_backup'] = $cat_cache[$key]['auth_viewcat_backup']; }
if (!check_permission($type, $key)) {
if (!check_permission($type, $key) || !cat_pass_check($key)) {
if (check_permission("auth_viewcat", $key)) {
if (check_permission("auth_viewcat", $key) && cat_pass_check($key)) {
$user_info = $site_sess->return_user_info();
$user_info['cat_password_db'] = true; //set to false to use only sessions to store passwords$user_info['cat_hide_db'] = true; //set to false to use only sessions to store visited hidden categoriesif ($user_info['user_level'] == GUEST || !isset($user_info['cat_password']) || ($user_info['user_level'] != GUEST && !$user_info['cat_password_db'])){ $cat_pass = trim($site_sess->get_session_var("catpass")); $user_info['cat_password_db'] = false;}else{ $cat_pass = $user_info['cat_password']; $user_info['cat_password_db'] = true;}$user_info['cat_password'] = array();$cat_pass = explode("|", $cat_pass);foreach($cat_pass as $key){ $val = explode(",", $key); if (count($val) > 1 && $val[0] = (int)$val[0]) $user_info['cat_password'][$val[0]] = $val[1];}if ($user_info['user_level'] == GUEST || !isset($user_info['cat_hide']) || ($user_info['user_level'] != GUEST && !$user_info['cat_hide_db'])){ $cat_hide = trim($site_sess->get_session_var("cathide")); $user_info['cat_hide_db'] = false;}else{ $cat_hide = $user_info['cat_hide']; $user_info['cat_hide_db'] = true;}$user_info['cat_hide'] = array();$cat_hide = explode("|", $cat_hide);foreach($cat_hide as $key){ if ($key = (int)$key) $user_info['cat_hide'][$key] = "";}
$auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];
$cat_password = un_htmlspecialchars(trim($HTTP_POST_VARS['cat_password'])); $cat_hide = intval($HTTP_POST_VARS['cat_hide']);
$sql = "INSERT INTO ".CATEGORIES_TABLE." (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment) VALUES ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
$sql = "INSERT INTO ".CATEGORIES_TABLE." (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_password, cat_hide) VALUES ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment, '$cat_password', $cat_hide)";
show_table_separator($permission_headline, 2);
show_radio_row($lang['cat_hide'], "cat_hide", 0); show_input_row($lang['cat_password'], "cat_password", "", $textinput_size);
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, cat_password = '$cat_password', cat_hide = $cat_hide
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_password, cat_hide
show_input_row($lang['field_hits'], "cat_hits", $cat_row['cat_hits'], 5);
show_radio_row($lang['cat_hide'], "cat_hide", $cat_row['cat_hide']); show_input_row($lang['cat_password'], "cat_password", $cat_row['cat_password'], $textinput_size);
show_text_link($lang['add_subcategory'], "categories.php?action=addcat&cat_parent_id=".$cats['cat_id']);
if ($cats['cat_hide'] || $cats['cat_password']) { echo " <b>("; if ($cats['cat_hide']) { echo $lang['cat_hidden']; } if ($cats['cat_password']) { echo (($cats['cat_hide']) ? ", " : "").$lang['cat_password2']; } echo ")</b>"; }
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_hide, cat_password
$lang['cat_hide'] = "Hidden";$lang['cat_password'] = "Category password";$lang['cat_password_msg'] = "This category is password protected.<br />Please enter the password";$lang['cat_password_error'] = "You have entered incorrect password";$lang['cat_hidden'] = "hidden";$lang['cat_password2'] = "password";
$user_info['cat_password_db'] = true; //set to false to use only sessions to store passwords
$user_info['cat_password_db'] = false; //set to false to use only sessions to store passwords
$user_info['cat_hide_db'] = true; //set to false to use only sessions to store visited hidden categories
$user_info['cat_hide_db'] = false; //set to false to use only sessions to store visited hidden categories
// cat_unhide($cat_cache[$cat_id]['cat_parent_id'], $save);
cat_unhide($cat_cache[$cat_id]['cat_parent_id'], $save);
if (!$cat_cache[$val2]['cat_password'] && $cat_cache[$key]['cat_password']) //all subcategories also should obbey cat password from parent
if (!cat_pass_check($key)) { $cat_cache[$val2]['auth_viewcat'] = ADMIN; continue; }
$cat_cache[$val2]['cat_password'] = $cat_cache[$key]['cat_password']; $cat_cache[$val2]['cat_password_id'] = (isset($cat_cache[$key]['cat_password_id'])) ? $cat_cache[$key]['cat_password_id'] : $key;
// $cat_cache[$val2]['cat_password'] = $cat_cache[$key]['cat_password'];// $cat_cache[$val2]['cat_password_id'] = (isset($cat_cache[$key]['cat_password_id'])) ? $cat_cache[$key]['cat_password_id'] : $key;
//define("PRINT_STATS", 1);//define("PRINT_QUERIES", 1);//define('PRINT_CACHE_MESSAGES', 1);