Update of /cvsroot/mxbb/mx_smartor/album_mod/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23033/album_mod/includes Added Files: Tag: core28x album_acp_functions.php album_bbcode.php album_constants.php album_exif_info.php album_functions.php album_hierarchy_auth.php album_hierarchy_debug.php album_hierarchy_functions.php album_hierarchy_sql.php album_image_class.php album_integration.php album_nuffimage_box.php clown_album_functions.php Log Message: upgrade to 2.0.1 gold --- NEW FILE: album_constants.php --- <?php /** * * @package Mx-Publisher Module - mx_smartor * @version $Id: album_constants.php,v 1.1.2.1 2008/03/12 22:34:25 orynider Exp $ * @copyright (c) 2003 [sma...@ho..., Smartor] mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ /*************************************************************************** * * MODIFICATION: * -inserted few extra session handlings * -inserted SP table constant * -inserted medium thumb path constant * ***************************************************************************/ if ( !defined('IN_PORTAL') ) { die('Hacking attempt'); } // ------------------------------------------------------------------------- // Extend User Style with module lang and images // Usage: $mx_user->extend(LANG, IMAGES) // Switches: // - LANG: MX_LANG_MAIN (default), MX_LANG_ADMIN, MX_LANG_ALL, MX_LANG_NONE // - IMAGES: MX_IMAGES (default), MX_IMAGES_NONE // ------------------------------------------------------------------------- $mx_user->extend(MX_LANG_NONE, MX_IMAGES); // Album Tables !defined('ALBUM_TABLE') ? define('ALBUM_TABLE', $mx_table_prefix.'smartor_album') : false; !defined('ALBUM_CAT_TABLE') ? define('ALBUM_CAT_TABLE', $mx_table_prefix.'smartor_album_cat') : false; !defined('ALBUM_CONFIG_TABLE') ? define('ALBUM_CONFIG_TABLE', $mx_table_prefix.'smartor_album_config') : false; !defined('ALBUM_COMMENT_TABLE') ? define('ALBUM_COMMENT_TABLE', $mx_table_prefix.'smartor_album_comment') : false; !defined('ALBUM_RATE_TABLE') ? define('ALBUM_RATE_TABLE', $mx_table_prefix.'smartor_album_rate') : false; !defined('ALBUM_SP_CONFIG_TABLE') ? define('ALBUM_SP_CONFIG_TABLE', $mx_table_prefix.'smartor_album_sp_config') : false; define('PAGE_ALBUM', -50); // for Session Handling define('PAGE_ALBUM_PERSONAL', -51); define('PAGE_ALBUM_PICTURE', -52); define('PAGE_ALBUM_SEARCH', -53); define('PERSONAL_GALLERY', 0); // pic_cat_id <- do NOT change this value define('ALBUM_NAV_ARROW',' » '); define('ALBUM_DATA_ALREADY_READ', -127); define('ALBUM_ROOT_CATEGORY', -1); define('ALBUM_PUBLIC_GALLERY', 0); // Special album jumpbox/selection values define('ALBUM_JUMPBOX_SEPERATOR', -99999900); define('ALBUM_JUMPBOX_DELETE', -99999901); define('ALBUM_JUMPBOX_USERS_GALLERY', -99999902); define('ALBUM_JUMPBOX_PUBLIC_GALLERY', -99999903); // Permission rights defined flags define('ALBUM_AUTH_VIEW', 1); define('ALBUM_AUTH_UPLOAD', 2); define('ALBUM_AUTH_CREATE_PERSONAL', 2); define('ALBUM_AUTH_RATE', 4); define('ALBUM_AUTH_COMMENT', 8); define('ALBUM_AUTH_EDIT', 16); define('ALBUM_AUTH_DELETE', 32); define('ALBUM_AUTH_MODERATOR', 64); define('ALBUM_AUTH_MANAGE_PERSONAL_CATEGORIES', 128); // Special 'predefined' combinations define('ALBUM_AUTH_ALL', 255); define('ALBUM_AUTH_VIEW_AND_UPLOAD', 3); // Used to indicate if you are going to read both public & personal album categories define('ALBUM_READ_ALL_CATEGORIES', 512); define('ALBUM_CREATE_CAT_ID_LIST', 1024); // Select/jumpbox defined flags define('ALBUM_SELECTBOX_INCLUDE_ALL', 1); define('ALBUM_SELECTBOX_INCLUDE_ROOT', 2); define('ALBUM_SELECTBOX_DELETING', 4); define('ALBUM_SELECTBOX_ALL', 7); // all three options define('ALBUM_VIEW_ALL', 'all'); define('ALBUM_VIEW_ALL_PICS', 'allpics'); define('ALBUM_VIEW_LIST', 'list'); define('ALBUM_VIEW_NORMAL', ''); define('ALBUM_LISTTYPE_PICTURES', 'pic'); define('ALBUM_LISTTYPE_COMMENTS', 'comment'); define('ALBUM_LISTTYPE_RATINGS', 'rating'); define('ALBUM_INCLUDE_PARENT_ID', true); define('ALBUM_EXCLUDE_PARENT_ID', false); // User Levels for Album system <- do NOT change these values define('ALBUM_ANONYMOUS', -1); define('ALBUM_GUEST', -1); define('ALBUM_USER', 0); define('ALBUM_ADMIN', 1); define('ALBUM_MOD', 2); define('ALBUM_PRIVATE', 3); !defined('PAGE_ALBUM') ? define('PAGE_ALBUM', -502) : false; //Redefine some GD constants !defined('IMAGETYPE_PNG') ? define('IMAGETYPE_PNG', 3) : false; !defined('IMAGETYPE_JPEG') ? define('IMAGETYPE_JPEG', 2) : false; !defined('IMAGETYPE_GIF') ? define('IMAGETYPE_GIF', 1) : false; !defined('IMG_PNG') ? define('IMG_PNG', IMAGETYPE_PNG) : false; !defined('IMG_JPG') ? define('IMG_JPG', IMAGETYPE_JPEG) : false; !defined('IMG_GIF') ? define('IMG_GIF', IMAGETYPE_GIF) : false; // Path (trailing slash required) define('ALBUM_UPLOAD_PATH', $module_root_path . 'upload/'); define('ALBUM_OTF_PATH', $module_root_path . 'upload/otf/'); define('ALBUM_JUPLOAD_PATH', $module_root_path . 'upload/jupload/'); define('ALBUM_CACHE_PATH', $module_root_path . 'upload/cache/'); define('ALBUM_MED_CACHE_PATH', $module_root_path . 'upload/med_cache/'); define('ALBUM_WM_CACHE_PATH', $module_root_path . 'upload/wm_cache/'); define('ALBUM_WM_FILE', $module_root_path . 'album_mod/mark_fap.png'); ?> --- NEW FILE: album_hierarchy_functions.php --- <?php /** * * @package Mx-Publisher Module - mx_smartor * @version $Id: album_hierarchy_functions.php,v 1.1.2.1 2008/03/12 22:34:26 orynider Exp $ * @copyright (c) 2003 [bla...@ya..., idl...@sl...] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * * some of the code was taken from phpbb forum (generate_smilies function) */ /*************************************************************************** * * This mod is strongly based on the Forum Hiearchy Category Mod by Ptirhiik * A lot of credit goes to Ptirhiik * And some small part of this code is copyrighted by Ptirhiik. * ***************************************************************************/ [...1727 lines suppressed...] 'LAST_COMMENT_OVER_COLOR' => $overColor, 'LAST_COMMENT_OUT_COLOR' => $outColor ) ); } if ($album_config['show_index_last_pic'] == 1 && $indexes[$i] == 6) { $template->assign_vars(array( 'COL6' => $rowClass, 'LAST_PIC_OVER_COLOR' => $overColor, 'LAST_PIC_OUT_COLOR' => $outColor ) ); } $toggle = !$toggle; } } ?> --- NEW FILE: album_hierarchy_sql.php --- <?php /** * * @package Mx-Publisher Module - mx_smartor * @version $Id: album_hierarchy_sql.php,v 1.1.2.1 2008/03/12 22:34:26 orynider Exp $ * @copyright (c) 2002-2006 [Smartor, Volodymyr (CLowN) Skoryk, IdleVoid, Jon Ohlsson] mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ /*************************************************************************** * album_hierarchy_sql.php * ------------------------------------------------ * begin : Friday, June 12, 2004 * copyright : (C) 2004 IdleVoid * email : idl...@sl... * file version : 1.2.0 * release : 2.0.0 ****************************************************************************/ [...2105 lines suppressed...] 'THUMBNAIL' => $thumbnail_file, 'PIC_PREVIEW' => $pic_preview, 'DESC' => $commentsrow[$i]['pic_desc'], 'COMMENT_TEXT' => $commentsrow[$i]['comment_text'], 'PIC_ID' => $commentsrow[$i]['pic_id'], 'TITLE' => '<a href = "' . mx_append_sid(this_smartor_mxurl("smartor_mode=album_showpage&pic_id=" . $commentsrow[$i]['pic_id'])) . '">' . $commentsrow[$i]['pic_title'] . '</a>', 'POSTER' => $poster, 'TIME' => create_date2($board_config['default_dateformat'], $commentsrow[$i]['comment_time'], $board_config['board_timezone']), 'VIEW' => $commentsrow[$i]['pic_view_count'], 'RATING' => ($album_config['rate'] == 1) ? ( '<a href="'. mx_append_sid(this_smartor_mxurl("smartor_mode=album_showpage&pic_id=" . $commentsrow[$i]['pic_id'])) . '" ' . $image_rating_link_style .'>' . $lang['Rating'] . '</a>: ' . $image_rating . '<br />') : '', 'COMMENTS' => ($album_config['comment'] == 1) ? ( '<a href="' . mx_append_sid(this_smartor_mxurl("smartor_mode=album_showpage&pic_id=" . $commentsrow[$i]['pic_id'])) . '">' . $lang['Comments'] . '</a>: ' . $image_comment . '<br />') : '', 'IP' => ($userdata['user_level'] == ADMIN) ? $lang['IP_Address'] . ': <a href="http://whois.sc/' . decode_ip($commentsrow[$i]['pic_user_ip']) . '" target="_blank">' . decode_ip($commentsrow[$i]['pic_user_ip']) .'</a><br />' : '' ) ); } } } ?> --- NEW FILE: album_acp_functions.php --- <?php if ( !defined('IN_PORTAL') ) { die('Hacking attempt'); } if (!defined('IN_ADMIN')) { die('Can only be used from the album ACP'); } //------------------------------------------------------------------------ // This file is included in the admin/admin_album_config_extended.php // which is the new ACP for the ablum. // // The file contains all the helper functions nedded for the ACP //------------------------------------------------------------------------ //------------------------------------------------------------------------ // this little helper function basicly does the template generation // NOTE : the $config_box_generation_function is defined in the // $album_config_tabs array that exists in all of the admin_album_config_* // files. It is just a function 'pointer' to the actual generator function //------------------------------------------------------------------------ function build_config_box($config_data) { global $template; $function = $config_data['generate_function']; $template->set_filenames(array('configuration_box' => $config_data['template_file'])); build_subtab_box($config_data); if (!empty($function)) { $function($config_data); } $template->assign_var_from_handle('CONFIGURATION_BOX', 'configuration_box'); } function build_sub_config_box($config_data) { global $template; $selected_subtab = $config_data['selected_subtab']; $function = (!empty($selected_subtab['generate_function'])) ? $selected_subtab['generate_function'] : $config_data['generate_function']; $template->set_filenames(array('sub_configuration_box' => $selected_subtab['template_file'])); if (!empty($function)) { $function($config_data); } $template->assign_var_from_handle('SUB_CONFIGURATION_BOX', 'sub_configuration_box'); } function build_subtab_box($config_data) //, $selected_subtab) { global $template; $selected_index = 0; $selected_subtab = get_selected_tab_from_config($config_data); if (0 == count($selected_subtab)) { return; } build_sub_config_box($config_data); for ($i = 0; $i < count($config_data['sub_config']); $i++) { if ($config_data['sub_config'][$i]['selection'] == $selected_subtab['selection']) { $selected_index = $i; } $template->assign_block_vars('subtab_row', array( 'TAB_SELECT_NAME' => $config_data['sub_config'][$i]['selection'], 'L_TAB_TITLE' => $config_data['sub_config'][$i]['title'], 'TAB_LINKS' => ($config_data['sub_config'][$i]['selection'] == $selected_subtab['selection']) ? 'tab_links' : 'tab_links_unsel', 'TAB_CLASS' => ($config_data['sub_config'][$i]['selection'] == $selected_subtab['selection']) ? 'tab_headers' : 'tab_headers_unsel' ) ); $template->assign_vars(array( 'L_CONFIGURATION_BOX' => $config_data['sub_config'][$selected_index]['title'] ) ); } } function get_selected_tab_from_config($config_data) { return $config_data['selected_subtab']; } function get_config_table($selection) { global $album_config_tabs; for ($i = 0; $i < count($album_config_tabs); $i++) { if ( 0 == strcasecmp($album_config_tabs[$i]['selection'],$selection) ) { return $album_config_tabs[$i]['config_table_name']; } } return ''; } function is_valid_config_tab($config_array) { // these two array holds the minimum required fields for an config tab array // if there are other that's accepted just don't remove these // NOTE : the order of the keys are not important $valid_config_keys = array( 0 => 'order',1 => 'selection',2 => 'title',3 => 'detail',4 => 'sub_config',5 => 'config_table_name',6 => 'generate_function',7 => 'template_file'); $valid_sub_config_keys = array( 0 => 'order',1 => 'selection',2=> 'title',3 => 'detail',4 => 'template_file'); if (count($config_array) == 0) { return false; } for ($outer = 0; $outer < count($valid_config_keys); $outer++) { // does the key exists ? if (@!array_key_exists($valid_config_keys[$outer],$config_array)) { return false; } if (strcasecmp($valid_config_keys[$outer], 'sub_config') == 0) { // check each sub_config in the config array for ($inner = 0; $inner < count($config_array['sub_config']); $inner++) { // and check eacj key in each sub_config array for ($i = 0; $i < count($valid_sub_config_keys); $i++) { // does the key exists ? if (@!array_key_exists($valid_sub_config_keys[$i],$config_array['sub_config'][$inner])) { return false; } } } } } return true; } function remove_config_array($config_array, $index) { $temp_array = array(); for($i = 0; $i < count($config_array); $i++) { if ($i != $index) { $temp_array[] = $config_array[$i]; } } return $temp_array; } ?> --- NEW FILE: album_functions.php --- <?php /** * * @package Mx-Publisher Module - mx_smartor * @version $Id: album_functions.php,v 1.1.2.1 2008/03/12 22:34:25 orynider Exp $ * @copyright (c) 2003 [sma...@ho..., Smartor] mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ // ------------------------------------ // All common functions are here! // ------------------------------------ // You cannot call this file directly from your browser // if ( !defined('IN_PORTAL') ) { die('Hacking attempt'); } if(!function_exists(create_date)) { function create_date($format, $gmepoch, $tz) { return phpBB2::create_date($format, $gmepoch, $tz); } if(!function_exists(create_date2)) { function create_date2($format, $gmepoch, $tz) { return create_date($format, $gmepoch, $tz); } } if(!function_exists(decode_ip)) { function decode_ip($int_ip) { return phpBB2::decode_ip($int_ip); } } // ---------------------------------------------------------------------------- // This function will return the access data of the current user for a category // Default returning value is "0" (means NOT AUTHORISED) // // All $*_check must be "1" or "0" // // $passed_auth must be a full row from ALBUM_CAT_TABLE. This function still works without // ... but $passed_auth will make it worked very much faster (because this function is often // called in a loop) // function album_user_access($cat_id, $passed_auth = 0, $view_check, $upload_check, $rate_check, $comment_check, $edit_check, $delete_check) { global $db, $album_config, $userdata; // -------------------------------- // Force to check moderator status // -------------------------------- $moderator_check = 1; // -------------------------------- // Here the array which this function would return. Now we initiate it! // -------------------------------- $album_user_access = array( 'view' => 0, 'upload' => 0, 'rate' => 0, 'comment' => 0, 'edit' => 0, 'delete' => 0, 'moderator' => 0 ); $album_user_access_keys = array_keys($album_user_access); // // END initiation $album_user_access // // -------------------------------- // Check $cat_id // -------------------------------- if ($cat_id == PERSONAL_GALLERY) { $personal_gallery_access = personal_gallery_access(1,1); if ($personal_gallery_access['view']) { $album_user_access['view'] = 1; } if ($personal_gallery_access['upload']) { $album_user_access['upload'] = 1; $album_user_access['rate'] = 1; $album_user_access['comment'] = 1; $album_user_access['edit'] = 1; $album_user_access['delete'] = 1; if ($userdata['session_logged_in']) { if ($userdata['user_level'] == ADMIN) { $album_user_access['moderator'] = 1; } } } return $album_user_access; } else if ($cat_id < 0) { mx_message_die(GENERAL_ERROR, 'Bad cat_id arguments for function album_user_access()'); } // // END check $cat_id // // -------------------------------- // If the current user is an ADMIN (ALBUM_ADMIN == ADMIN) // -------------------------------- if ($userdata['user_level'] == ADMIN) { for ($i = 0; $i < count($album_user_access); $i++) { $album_user_access[$album_user_access_keys[$i]] = 1; // Authorised All } // // Function EXIT here // return $album_user_access; } // // END check ADMIN // // -------------------------------- // if this is a GUEST, we will ignore some checking // -------------------------------- if (!$userdata['session_logged_in']) { $edit_check = 0; $delete_check = 0; $moderator_check = 0; } // // END check GUEST // // -------------------------------- // check if RATE or COMMENT are turned off by Album Config, so we can ignore them // -------------------------------- if ($album_config['rate'] == 0) { $rate_check = 0; } if ($album_config['comment'] == 0) { $comment_check = 0; } // // END Check RATE & COMMENT // // -------------------------------- // The array that list all access type this function will look for (except MODERATOR) // -------------------------------- $access_type = array(); if ($view_check != 0) { $access_type[] = 'view'; } if ($upload_check != 0) { $access_type[] = 'upload'; } if ($rate_check != 0) { $access_type[] = 'rate'; } if ($comment_check != 0) { $access_type[] = 'comment'; } if ($edit_check != 0) { $access_type[] = 'edit'; } if ($delete_check != 0) { $access_type[] = 'delete'; } // // END generating array $access_type // // -------------------------------- // If everything is empty // -------------------------------- if( empty($access_type) and (!$moderator_check) ) { // // Function EXIT here // return $album_user_access; } // // END check empty // // -------------------------------- // Generate the SQL query based on $access_type and $moderator_check // -------------------------------- $sql = 'SELECT cat_id'; for ($i = 0; $i < count($access_type); $i++) { $sql .= ', cat_'. $access_type[$i] .'_level, cat_'. $access_type[$i] .'_groups'; } if ($moderator_check) { $sql .= ', cat_moderator_groups'; } $sql .= " FROM ". ALBUM_CAT_TABLE ." WHERE cat_id = '$cat_id'"; // // END SQL query generating // // -------------------------------- // Query the $sql then Fetchrow if $passed_auth == 0 // -------------------------------- if( !is_array($passed_auth) ) { if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not query Album Category information' ,'' , __LINE__, __FILE__, $sql); } $thiscat = $db->sql_fetchrow($result); } else { $thiscat = $passed_auth; } // // END Query and Fetchrow // // -------------------------------- // Maybe the access level is not PRIVATE or the groups list is empty // ... so we can skip some queries ;) // -------------------------------- $groups_access = array(); for ($i = 0; $i < count($access_type); $i++) { switch ($thiscat['cat_'. $access_type[$i] .'_level']) { case ALBUM_GUEST: $album_user_access[$access_type[$i]] = 1; break; case ALBUM_USER: if ($userdata['session_logged_in']) { $album_user_access[$access_type[$i]] = 1; } break; case ALBUM_PRIVATE: if( ($thiscat['cat_'. $access_type[$i] .'_groups'] != '') and ($userdata['session_logged_in']) ) { $groups_access[] = $access_type[$i]; } break; case ALBUM_MOD: // this will be checked later break; case ALBUM_ADMIN: // ADMIN already returned before at the checking code // at the top of this function. So this user cannot be authorised $album_user_access[$access_type[$i]] = 0; break; default: $album_user_access[$access_type[$i]] = 0; } } // // END Check Access Level // // -------------------------------- // We can return now if $groups_access is empty AND $moderator_check == 0 // -------------------------------- if( ($moderator_check == 1) and ($thiscat['cat_moderator_groups'] != '') ) { // We can merge them now $groups_access[] = 'moderator'; } if (empty($groups_access)) { // // Function EXIT here // return $album_user_access; } // -------------------------------- // Now we have the list of usergroups have PRIVATE/MODERATOR access // So we will check if this user is in these usergroups or not... // -------------------------------- // upto (6 + 1) loops maximum when this user logged in and All Levels // are set to PRIVATE and this function was called to check all. // So avoiding PRIVATE will speed up your album. However, these queries are very fast for ($i = 0; $i < count($groups_access); $i++) { $sql = "SELECT group_id, user_id FROM ". USER_GROUP_TABLE ." WHERE user_id = '". $userdata['user_id'] ."' AND user_pending = 0 AND group_id IN (". $thiscat['cat_'. $groups_access[$i] .'_groups'] .")"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not query User-Group information' ,'' , __LINE__, __FILE__, $sql); } if( $db->sql_numrows($result) > 0 ) { $album_user_access[$groups_access[$i]] = 1; } } // // END check PRIVATE/MODERATOR groups // // -------------------------------- // If $moderator_check was called and this user is a MODERATOR he // will be authorised for all accesses which were not set to ADMIN // -------------------------------- if( ($album_user_access['moderator'] == 1) and ($moderator_check == 1) ) { for ($i = 0; $i < count($album_user_access); $i++) { if( $thiscat['cat_'. $album_user_access_keys[$i] .'_level'] != ALBUM_ADMIN ) { $album_user_access[$album_user_access_keys[$i]] = 1; } } } // // END Moderator // // -------------------------------- // Return result... // -------------------------------- return $album_user_access; } // // END function album_user_access() // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // This function will check the access (VIEW, UPLOAD) of current user on // any personal galleries function personal_gallery_access($check_view, $check_upload) { global $db, $userdata, $album_config; // This array will contain the result $personal_gallery_access = array( 'view' => 0, 'upload' => 0, ); // -------------------------------- // Who can create personal gallery? // -------------------------------- if ($check_upload) { switch ($album_config['personal_gallery']) { case ALBUM_USER: if ($userdata['session_logged_in']) { $personal_gallery_access['upload'] = 1; } break; case ALBUM_PRIVATE: if( ($userdata['session_logged_in']) and ($userdata['user_level'] == ADMIN) ) { $personal_gallery_access['upload'] = 1; } else if(!empty($album_config['personal_gallery_private']) and $userdata['session_logged_in']) { $sql = "SELECT group_id, user_id FROM ". USER_GROUP_TABLE ." WHERE user_id = '". $userdata['user_id'] ."' AND user_pending = 0 AND group_id IN (". $album_config['personal_gallery_private'] .")"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not query User-Group information' ,'' , __LINE__, __FILE__, $sql); } if( $db->sql_numrows($result) > 0 ) { $personal_gallery_access['upload'] = 1; } } break; case ALBUM_ADMIN: if( ($userdata['session_logged_in']) and ($userdata['user_level'] == ADMIN) ) { $personal_gallery_access['upload'] = 1; } break; } } // -------------------------------- // Who can view other personal gallery? // -------------------------------- if ($check_view) { switch ($album_config['personal_gallery_view']) { case ALBUM_GUEST: $personal_gallery_access['view'] = 1; break; case ALBUM_USER: if ($userdata['session_logged_in']) { $personal_gallery_access['view'] = 1; } break; case ALBUM_PRIVATE: if( ($userdata['session_logged_in']) and ($userdata['user_level'] == ADMIN) ) { $personal_gallery_access['view'] = 1; } else if(!empty($album_config['personal_gallery_private']) and $userdata['session_logged_in']) { $sql = "SELECT group_id, user_id FROM ". USER_GROUP_TABLE ." WHERE user_id = '". $userdata['user_id'] ."' AND user_pending = 0 AND group_id IN (". $album_config['personal_gallery_private'] .")"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not query User-Group information' ,'' , __LINE__, __FILE__, $sql); } if( $db->sql_numrows($result) > 0 ) { $personal_gallery_access['view'] = 1; } } break; } } return $personal_gallery_access; } // // END function personal_gallery_access() // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Build up the array similar to $thiscat array // function init_personal_gallery_cat($user_id = 0) { global $userdata, $db, $lang; if ($user_id == 0) { $user_id = $userdata['user_id']; } $sql = "SELECT COUNT(pic_id) AS count FROM ". ALBUM_TABLE ." WHERE pic_cat_id = ". PERSONAL_GALLERY ." AND pic_user_id = ". $user_id; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not count pics for this personal gallery', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $count = $row['count']; if ($user_id != $userdata['user_id']) { $sql = "SELECT user_id, username FROM ". USERS_TABLE ." WHERE user_id = $user_id"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not obtain user information', '', __LINE__, __FILE__, $sql); } $user_row = $db->sql_fetchrow($result); $username = $user_row['username']; } else { $username = $userdata['username']; } $thiscat = array( 'cat_id' => 0, 'cat_title' => sprintf($lang['Personal_Gallery_Of_User'], $username), 'cat_desc' => '', 'cat_order' => 0, 'count' => $count, 'cat_view_level' => $album_config['personal_gallery_view'], 'cat_upload_level' => $album_config['personal_gallery'], 'cat_rate_level' => $album_config['personal_gallery_view'], 'cat_comment_level' => $album_config['personal_gallery_view'], 'cat_edit_level' => $album_config['personal_gallery'], 'cat_delete_level' => $album_config['personal_gallery'], 'cat_view_groups' => $album_config['personal_gallery_private'], 'cat_upload_groups' => $album_config['personal_gallery_private'], 'cat_rate_groups' => $album_config['personal_gallery_private'], 'cat_comment_groups' => $album_config['personal_gallery_private'], 'cat_edit_groups' => $album_config['personal_gallery_private'], 'cat_delete_groups' => $album_config['personal_gallery_private'], 'cat_delete_groups' => $album_config['personal_gallery_private'], 'cat_moderator_groups' => '', 'cat_approval' => 0 ); return $thiscat; } // // END function init_personal_gallery_cat() // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // You must keep my copyright notice with its original content visible // Do NOT modify anything!!! function album_end() { global $album_config; echo '<div align="center" style="font-family: Verdana; font-size: 10px; letter-spacing: -1px">Powered by Photo Album Addon 2' . $album_config['album_version'] . ' © 2002, 2003 <a href="http://smartor.is-root.com" target="_blank">Smartor</a></div>'; } //--- Multiple File Upload - BEGIN // ---------------------------------------------------------------- // check if the file at index $index was uploaded // ---------------------------------------------------------------- function was_file_uploaded($files_array, $index) { if ( @phpversion() < '4.2.0' ) { return ( (empty($files_array['tmp_name'][$index]) || $files_array['tmp_name'][$index] == 'none') || $files_array['size'][$index] == 0 ) ? false : true; } else { return ( ((empty($files_array['tmp_name'][$index]) || $files_array['tmp_name'][$index] == 'none') || $files_array['size'][$index] == 0) || $files_array['error'][$index] == 4) ? false : true; } } // ---------------------------------------------------------------- // check if the file has exceeded the maximum allowed file upload // set in php.ini // ---------------------------------------------------------------- function file_uploaded_exceeds_max_size($files_array, $index) { // for some bizar reason I can't get the next few lines to work right 'error' is always = 0 if (@phpversion() >= '4.2.0') { // UPLOAD_ERR_INI_SIZE == 1 (was first defined in 4.3.0, so 1 here instead) return ($files_array['error'][$index] == 1) ? true : false; } else { // earlier version of PHP (before 4.2.0) the error associated array didn't exist // so we need to TRY to check if the file was too big // the rule is the following (not fool proof): // // if 'name' isn't empty BUT 'tmp_name' and 'size' are empty (or for size = 0) // then we must have exceeded our max file size (or another error occured) return ( !empty($files_array['name'][$index]) && ( (empty($files_array['tmp_name'][$index]) || $files_array['tmp_name'][$index] == 'none') && $files_array['size'][$index] == 0 ) ) ? true : false; } } // ---------------------------------------------------------------- // generates a picture title, depending on the parameter supplied // ---------------------------------------------------------------- function generate_picture_title($file_name, $pic_title, $pic_filetype) { global $album_config; static $counter = 1; // if the user didn't supply a picture title then generate it from the // picture filename..and clean it up (remove trailing space, underscores and propercase it) if ( empty($pic_title) ) { // remove file extension, // NOTE : were do a lowecase of the filename, to ensure that extension with in BIG or misc cApS get removed also $pic_title = str_replace($pic_filetype, '', strtolower($file_name)); // remove underscores '_' and traling spaces $pic_title = trim(str_replace('_', ' ', $pic_title)); if ($album_config['propercase_pic_title'] == 1) { // convert the first character in each word to upper case and the rest to lower case $pic_title = ucwords(strtolower($pic_title)); } /* else { // convert only the first character in a string to upper case, the rest to lower case $pic_title = ucfirst(strtolower($pic_title)); } */ } else { if ($album_config['propercase_pic_title'] == 1) { // convert the first character in each word to upper case and the rest to lower case $pic_title = ucwords(strtolower($pic_title)); } /* else { // convert only the first character in a string to upper case, the rest to lower case $pic_title = ucfirst(strtolower($pic_title)); } */ switch ($counter) { case ($counter < 10): $pic_title .= ' - 00' . $counter; break; case (($counter >= 10) && ($counter < 100)): $pic_title .= ' - 0' . $counter; break; default: $pic_title .= ' - ' . $counter; break; } $counter++; } return $pic_title; } //--- Multiple File Upload - END function generate_single_pic_title($file_name, $pic_title, $pic_filetype) { global $album_config; // if the user didn't supply a picture title then generate it from the // picture filename and clean it up (remove trailing space, underscores and propercase it) if ( empty($pic_title) ) { // remove file extension, // NOTE : were do a lowecase of the filename, to ensure that extension with in BIG or misc cApS get removed also $pic_title = str_replace($pic_filetype, '', strtolower($file_name)); // remove underscores '_' and traling spaces $pic_title = trim(str_replace('_', ' ', $pic_title)); if ($album_config['propercase_pic_title'] == 1) { // convert the first character in each word to upper case and the rest to lower case $pic_title = ucwords(strtolower($pic_title)); } /* else { // convert only the first character in a string to upper case, the rest to lower case $pic_title = ucfirst(strtolower($pic_title)); } */ } else { if ($album_config['propercase_pic_title'] == 1) { // convert the first character in each word to upper case and the rest to lower case $pic_title = ucwords(strtolower($pic_title)); } /* else { // convert only the first character in a string to upper case, the rest to lower case $pic_title = ucfirst(strtolower($pic_title)); } */ } return $pic_title; } //to have smilies window popup function generate_smilies_album($mode, $page_id) //borrowed from phpbbforums...modified to work with album { global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path, $mx_root_path; global $user_ip, $session_length, $starttime; global $userdata; // Vars needed for CH 2.1.4 global $config, $user, $censored_words, $icons, $navigation, $themes, $smilies; $inline_columns = 4; $inline_rows = 5; $window_columns = 8; if ($mode == 'window') { //$userdata = session_pagestart( $user_ip, $page_id ); //init_userprefs( $userdata ); $gen_simple_header = true; $page_title = "Smilies"; if ( !$is_block) { include($mx_root_path . 'includes/page_header.'.$phpEx); } $template->set_filenames(array( 'smiliesbody' => 'album_posting_smilies.tpl') ); } $sql = "SELECT emoticon, code, smile_url FROM " . SMILIES_TABLE . " ORDER BY smilies_id"; if ($result = $db->sql_query($sql)) { $num_smilies = 0; $rowset = array(); while ($row = $db->sql_fetchrow($result)) { if (empty($rowset[$row['smile_url']])) { $rowset[$row['smile_url']]['code'] = str_replace("'", "\\'", str_replace('\\', '\\\\', $row['code'])); $rowset[$row['smile_url']]['emoticon'] = $row['emoticon']; $num_smilies++; } } if ($num_smilies) { $smilies_count = ($mode == 'inline') ? min(19, $num_smilies) : $num_smilies; $smilies_split_row = ($mode == 'inline') ? $inline_columns - 1 : $window_columns - 1; $s_colspan = 0; $row = 0; $col = 0; while (list($smile_url, $data) = @each($rowset)) { if (!$col) { $template->assign_block_vars('smilies_row', array()); } $template->assign_block_vars('smilies_row.smilies_col', array( 'SMILEY_CODE' => $data['code'], 'SMILEY_IMG' => $phpbb_root_path . $board_config['smilies_path'] . '/' . $smile_url, 'SMILEY_DESC' => $data['emoticon']) ); $s_colspan = max($s_colspan, $col + 1); if ($col == $smilies_split_row) { if ( ($mode == 'inline') && ($row == $inline_rows - 1) ) { break; } $col = 0; $row++; } else { $col++; } } if ( ($mode == 'inline') && ($num_smilies > $inline_rows * $inline_columns) ) { $template->assign_block_vars('switch_smilies_extra', array()); $template->assign_vars(array( 'L_MORE_SMILIES' => $lang['More_emoticons'], 'U_MORE_SMILIES' => mx_append_sid($phpbb_root_path . "posting.$phpEx?mode=smilies")) ); } $template->assign_vars(array( 'L_EMOTICONS' => $lang['Emoticons'], 'L_CLOSE_WINDOW' => $lang['Close_window'], 'S_SMILIES_COLSPAN' => $s_colspan) ); } } if ($mode == 'window') { $template->pparse('smiliesbody'); if ( !$is_block) { include($mx_root_path . 'includes/page_tail.'.$phpEx); } } } if (!function_exists(setFlag)) { function setFlag($flags, $flag) { return $flags | $flag; } } if (!function_exists(clearFlag)) { function clearFlag($flags, $flag) { return ($flags & ~$flag); } } if (!function_exists(checkFlag)) { function checkFlag($flags, $flag) { return (($flags & $flag) == $flag) ? true : false; } } function mx_album_assign_var_from_handle($varname, $handle) { if (!$this->loadfile($handle)) { die("Template->assign_var_from_handle(): Couldn't load template file for handle $handle"); } // Compile it, with the "no echo statements" option on. $_str = ""; $code = $this->compile($this->uncompiled_code[$handle], true, '_str'); // evaluate the variable assignment. eval($code); // assign the value of the generated variable to the given varname. $this->assign_var($varname, $_str); return true; } function mx_album_uploadfilename($UploadFile) { $UploadFileNameTmp = explode(".", $UploadFile); $y = count($UploadFileNameTmp) - 1; $r = ""; for ($a = 0; $y > $a; $a++) { $r .= ".".$UploadFileNameTmp[$a]; } return $r; } function mx_album_uploadfiletype($UploadFile) { $UploadFileTypeTmp = explode(".", $UploadFile); $y = count($UploadFileTypeTmp) - 1; $r = $UploadFileTypeTmp[$y];; return $r; } // +------------------------------------------------------+ // | Powered by Photo Album 2.x.x (c) 2002-2003 Smartor | // +------------------------------------------------------+ ?> --- NEW FILE: album_exif_info.php --- <?php /*************************************************************************** * exif_info.php * --------------- * begin : 03/18/2005 * copyright : Pgh-Biker * email : * * version : 1.0.0 ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ // define('IN_PHPBB', true); // $phpbb_root_path = './'; define('IN_PORTAL', true); global $board_config; function make_exif($xkey, $xval) { global $board_config; $exif_info = array( // 'FILE_FileName' => 'File Name', 'FILE_FileDateTime' => 'File Date and Time', 'FILE_FileSize' => array( 'Name' => 'File Size', 'Units' => ' bytes' ), // 'FILE_MimeType' => 'Mime Type', 'COMPUTED_Height' => array( 'Name' => 'Image Height', 'Units' => ' pixels' ), 'COMPUTED_Width' => array( 'Name' => 'Image Width', 'Units' => ' pixels' ), 'COMPUTED_ApertureFNumber' => 'Aperture F Number', 'COMPUTED_UserComment' => 'User Comment', 'IFD0_ImageDescription' => 'Image Description', 'IFD0_Make' => 'Camera Make (Manufacturer)', 'IFD0_Model' => 'Camera Model', 'IFD0_XResolution' => array( 'Name' => 'X Resolution', 'Units' => ' Pixels per' ), 'IFD0_YResolution' => array( 'Name' => 'Y Resolution', 'Units' => ' Pixels per' ), 'IFD0_ResolutionUnit' => array( 'Name' => 'Resolution Unit', 2 => ' Inch', 3 => ' Centimeter' ), 'IFD0_Software' => 'Software or Firmware', 'IFD0_Artist' => 'Artist', 'IFD0_Copyright' => 'Copyright', 'EXIF_ExposureTime' => array( 'Name' => 'Exposure Time', 'Units' => ' seconds' ), // 'EXIF_FNumber' => 'F Number', 'EXIF_ExposureProgram' => array( 'Name' => 'Exposure Program', 0 => 'Not defined', 1 => 'Manual', 2 => 'Normal program', 3 => 'Aperture priority', 4 => 'Shutter priority', 5 => 'Creative program (biased toward depth of field)', 6 => 'Action program (biased toward fast shutter speed)', 7 => 'Portrait mode (for closeup photos with the background out of focus)', 8 => 'Landscape mode (for landscape photos with the background in focus)' ), 'EXIF_ISOSpeedRatings' => 'ISO Speed Ratings', 'EXIF_DateTimeOriginal' => 'Date and Time of Original', 'EXIF_DateTimeDigitized' => 'Date and Time when Digitized', 'EXIF_ExposureBiasValue' => array( 'Name' => 'APEX Exposure Bias Value', 'Units' => ' EV' ), 'EXIF_MaxApertureValue' => 'APEX Maximum Aperture Value', 'EXIF_MeteringMode' => array( 'Name' => 'Metering Mode', 0 => 'Unknown', 1 => 'Average', 2 => 'Center Weighted Average', 3 => 'Spot', 4 => 'Multi Spot', 5 => 'Pattern', 6 => 'Partial', 255 => 'Other' ), 'EXIF_LightSource' => array( 'Name' => 'Light Source', 0 => 'Unknown', 1 => 'Daylight', 2 => 'Fluorescent', 3 => 'Tungsten (incandescent light)', 4 => 'Flash', 9 => 'Fine weather', 10 => 'Cloudy weather', 11 => 'Shade', 12 => 'Daylight fluorescent (D 5700 7100K)', 13 => 'Day white fluorescent (N 4600 5400K)', 14 => 'Cool white fluorescent (W 3900 4500K)', 15 => 'White fluorescent (WW 3200 3700K)', 17 => 'Standard light A', 18 => 'Standard light B', 19 => 'Standard light C', 20 => 'D55', 21 => 'D65', 22 => 'D75', 23 => 'D50', 24 => 'ISO studio tungsten', 255 => 'Other' ), 'EXIF_Flash' => array( 'Name' => 'Flash Mode', 0 => 'Flash did not fire', 1 => 'Flash fired', 5 => 'Strobe return light not detected', 7 => 'Strobe return light detected', 9 => 'Flash fired, compulsory flash mode', 13 => 'Flash fired, compulsory flash mode, return light not detected', 15 => 'Flash fired, compulsory flash mode, return light detected', 16 => 'Flash did not fire, compulsory flash suppression mode', 24 => 'Flash did not fire, auto mode', 25 => 'Flash fired, auto mode', 29 => 'Flash fired, auto mode, return light not detected', 31 => 'Flash fired, auto mode, return light detected', 32 => 'No flash function', 65 => 'Flash fired, red-eye reduction mode', 69 => 'Flash fired, red-eye reduction mode, return light not detected', 71 => 'Flash fired, red-eye reduction mode, return light detected', 73 => 'Flash fired, compulsory flash mode, red-eye reduction mode', 77 => 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected', 79 => 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected', 89 => 'Flash fired, auto mode, red-eye reduction mode', 93 => 'Flash fired, auto mode, return light not detected, red-eye reduction mode', 95 => 'Flash fired, auto mode, return light detected, red-eye reduction mode' ), 'EXIF_FocalLength' => array( 'Name' => 'Focal Length', 'Units' => 'mm' ), 'EXIF_SensingMethod' => array( 'Name' => 'Sensing Method', 1 => 'Not defined', 2 => 'One-chip colour area sensor', 3 => 'Two-chip colour area sensor', 4 => 'Three-chip colour area sensor', 5 => 'Colour sequential area sensor', 7 => 'Trilinear sensor', 8 => 'Colour sequential linear sensor' ), 'EXIF_CustomRendered' => array( 'Name' => 'Custom Renderd Mode', 0 => 'Normal Process', 1 => 'Custom Process', ), 'EXIF_ExposureMode' => array( 'Name' => 'Exposure Mode', 0 => 'Auto exposure', 1 => 'Manual exposure', 2 => 'Auto bracket' ), 'EXIF_WhiteBalance' => array( 'Name' => 'White Balance', 0 => 'Auto white balance', 1 => 'Manual white balance' ), 'EXIF_DigitalZoomRatio' => array( 'Name' => 'Digital Zoom Ratio', 'Units' => ' ( Zero = Digital Zoom Not Used )' ), 'EXIF_FocalLengthIn35mmFilm' => array( 'Name' => 'Equivalent Focal Length In 35mm Film', 'Units' => 'mm' ), 'EXIF_SceneCaptureType' => array( 'Name' => 'Scene Capture Type', 0 => 'Standard', 1 => 'Landscape', 2 => 'Portrait', 3 => 'Night scene' ), 'EXIF_GainControl' => array( 'Name' => 'Gain Control', 0 => 'None', 1 => 'Low gain up', 2 => 'High gain up', 3 => 'Low gain down', 4 => 'High gain down' ), 'EXIF_Contrast' => array( 'Name' => 'Contrast', 0 => 'Normal', 1 => 'Soft', 2 => 'Hard' ), 'EXIF_Saturation' => array( 'Name' => 'Saturation', 0 => 'Normal', 1 => 'Low saturation', 2 => 'High saturation' ), 'EXIF_Sharpness' => array( 'Name' => 'Sharpness', 0 => 'Normal', 1 => 'Soft', 2 => 'Hard' ), 'EXIF_SubjectDistanceRange' => array( 'Name' => 'Subject Distance Range', 0 => 'Unknown', 1 => 'Macro', 2 => 'Close view', 3 => 'Distant view' ), ); $i = 0; $rexif = array(); while (!empty($xkey[$i]) ) { if ( ereg("([0-9]{1,})/([0-9]{1,})", $xval[$i], $num) ) { if ( $num[1] > 1 ) $xval[$i] = round( ($num[1] / $num[2]), 6); } if ( is_array($exif_info[$xkey[$i]]) && $xkey[$i] != 'IFD0_ResolutionUnit' ) { if ( isset($exif_info[$xkey[$i]]['Units']) ) { if ( $xkey[$i+2] == 'IFD0_ResolutionUnit' ) { $rexif[$exif_info[$xkey[$i]]['Name']] = ($xval[$i] . $exif_info[$xkey[$i]]['Units'] . $exif_info[$xkey[$i+2]][$xval[$i+2]]); } else if ( $xkey[$i+1] == 'IFD0_ResolutionUnit' ) { $rexif[$exif_info[$xkey[$i]]['Name']] = ($xval[$i] . $exif_info[$xkey[$i]]['Units'] . $exif_info[$xkey[$i+1]][$xval[$i+1]]); } else { $rexif[$exif_info[$xkey[$i]]['Name']] = ($xval[$i] . $exif_info[$xkey[$i]]['Units']); } } else { $rexif[$exif_info[$xkey[$i]]['Name']] = $exif_info[$xkey[$i]][$xval[$i]]; } } else if ( isset($exif_info[$xkey[$i]]) && $xkey[$i] != 'IFD0_ResolutionUnit' ) { $rexif[$exif_info[$xkey[$i]]] = $xval[$i]; if ( $xkey[$i] == 'FILE_FileDateTime' ) { $rexif[$exif_info[$xkey[$i]]] = create_date('Y:m:d H:i:s', $xval[$i], $board_config['board_timezone']); } } $i++; } return $rexif; } $template->assign_block_vars('switch_exif_enabled.exif_switch', array()); $i = 0; $xkey = array(); $xval = array(); while (list($xk1,$xv1) = each($xif)) { $xkey[$i] = $xk1; $xval[$i] = $xv1; if (is_array($xif[$xk1])) { while (list($xk2,$xv2) = each($xif[$xk1])) { $xkey[$i] = $xk1.'_'.$xk2; $xval[$i] = $xv2; $i++; } } else { $i++; } } $exif = make_exif($xkey, $xval); $i = 0; $key = array(); $val = array(); while (list($k1,$v1) = each($exif)) { $key[$i] = $k1; $val[$i] = $v1; $i++; } $x = intval(($i/2)+.5); for ($n = 0; $n < $x; $n++) { $template->assign_block_vars('switch_exif_enabled.exif_switch.exif_data', array( 'EXIFc1' => (!empty($key[$n])) ? $key[$n].':' : '', 'EXIFd1' => ' '.$val[$n], 'EXIFc2' => (!empty($key[$n+$x])) ? $key[$n+$x].':' : '', 'EXIFd2' => ' '.$val[$n+$x] ) ); } ?> --- NEW FILE: album_hierarchy_auth.php --- <?php /*************************************************************************** * album_hierarchy_auth.php * ------------------------------------------------ * begin : Friday, June 12, 2004 * copyright : (C) 2004 IdleVoid * email : idl...@sl... * file version : 1.0.7 * release : 1.3.0 ****************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ /*************************************************************************** * * This mod is strongly based on the Forum Hiearchy Category Mod by Ptirhiik * Alot of credit goes to Ptirhiik * And some small part of this code is copyrighted by Ptirhiik. * ***************************************************************************/ if ( !defined('IN_PORTAL') ) { die('Hacking attempt'); } // Album Data Structure description // indexes : // - id : the category id : ie ALBUM_ROOT_CATEGORY, 1, 20, 12 and so on // - idx : array index // $album_data['keys'][id] => idx, returns the key value for the sub, parent, id and data array // $album_data['auth'][id] => auth_value array : ie album_tree_data['auth'][id]['auth_view'], // $album_data['sub'][id] => array of sub-level ids, // $album_data['parent'][idx] => parent id, // $album_data['id'][idx] => value of the row id : cat_id for cats // $album_data['personal'][idx] => list of db table row which indicated if it's personal category, // $album_data['data'][idx] => db table row, // -------------------------------------------------------------------------------------------------- // ------------------------------------------------------------------------ // generate the album category hierarchy // authentication data for the tree // ------------------------------------------------------------------------ function album_create_user_auth($user_id) { global $album_data; // read the user auth if requiered if (empty ($album_data['auth'])) { $album_data['auth'] = array (); for ($idx = 0; $idx < count($album_data['data']); $idx ++) { $cat = $album_data['data'][$idx]; $cat_id = $cat['cat_id']; // check all access rights for current user //$album_user_access = album_user_access($cat_id, $cat, 1, 1, 1, 1, 1, 1); $album_user_access = album_permissions($user_id, $cat_id, ALBUM_AUTH_ALL, $cat); if (!empty ($album_user_access)) { reset($album_user_access); while (list ($key, $data) = each($album_user_access)) { $album_data['auth'][$cat_id][$key] = $data; } } } } return $album_data['auth']; } // ------------------------------------------------------------------------ // Builds the array of authentication row ids // where authentication means where $auth_key was // fullfiled // ------------------------------------------------------------------------ // Authentication data structure // // - id : the category id : ie ALBUM_ROOT_CATEGORY, 1, 20, 12 and so on // - auth_id : array index // - idx : array in the album_data array structure // // $keys['keys'][id] => returns , // $keys['id'][auth_id] => id (used by $album_data ), // $keys['real_level'][auth_id] => level in this auth-tree (root=-1), // $keys['level'][auth_id] => level adjust for display (sub-level=parent level under certain conditions) // $keys['idx'][auth_id] => idx (used by $album_data) // -------------------------------------------------------------------------------------------------- function album_get_auth_keys($cur_cat_id = ALBUM_ROOT_CATEGORY, $auth_key = ALBUM_AUTH_VIEW, $all = false, $level = -1, $max = -1) { global $album_data, $album_config; $keys = array (); $last_i = -1; /* if ($album_config['album_debug_mode'] != '0') { // define('ALBUM_HIERARCHY_DEBUG_ENABLED', true); } else { // define('ALBUM_HIERARCHY_DEBUG_ENABLED', false); } */ // add the level if ( ($max < ALBUM_ROOT_CATEGORY + 1) || ($level < $max) || (($level == $max) && ($album_data['parent'][$album_data['keys'][$cur_cat_id]] == ALBUM_ROOT_CATEGORY)) ) { if ($cur_cat_id == ALBUM_ROOT_CATEGORY || album_check_permission($album_data['auth'][$cur_cat_id], $auth_key) || $all) { // if child of cat, align the level on the parent one $orig_level = $level; // store this level $last_i ++; $keys['keys'][$cur_cat_id] = $last_i; $keys['id'][$last_i] = $cur_cat_id; $keys['real_level'][$last_i] = $orig_level; $keys['level'][$last_i] = $level; $keys['idx'][$last_i] = (isset ($album_data['keys'][$cur_cat_id]) ? $album_data['keys'][$cur_cat_id] : ALBUM_ROOT_CATEGORY); // get sub-levels for ($i = 0; $i < count($album_data['sub'][$cur_cat_id]); $i ++) { $subkeys = array (); $subkeys = album_get_auth_keys($album_data['sub'][$cur_cat_id][$i], $auth_key, $all, $orig_level +1, $max); // add sub-levels for ($j = 0; $j < count($subkeys['id']); $j ++) { $last_i ++; $keys['keys'][$subkeys['id'][$j]] = $last_i; $keys['id'][$last_i] = $subkeys['id'][$j]; $keys['real_level'][$last_i] = $subkeys['real_level'][$j]; $keys['level'][$last_i] = $subkeys['level'][$j]; $keys['idx'][$last_i] = $subkeys['idx'][$j]; } // for( $j = 0..... } // for($i = 0..... } // if ($cur_cat_id == ALBUM_ROOT.... } // if (($max < 0 ..... //if ($level <= ALBUM_ROOT_CATEGORY && ALBUM_HIERARCHY_DEBUG_ENABLED == true) if ($level <= ALBUM_ROOT_CATEGORY && $album_config['album_debug_mode'] != '0') { album_debug('album_get_auth_keys = %s', $keys); } return $keys; } // ------------------------------------------------------------------------ // Check the permissions for public and personal galleries // If we are checking a personal gallery and it doesn't exists // the function will then validate it by calling 'personal_gallery_access' // if the gallery exists or its a public gallery then we use the code in // album_user_access. After these calls, some more checks are done in this // function. // ------------------------------------------------------------------------ function album_permissions($user_id, $cat_id, $permission_checks, $catdata = 0) { global $db, $lang, $userdata, $album_config, $album_data; $moderator_check = 1; if (album_is_debug_enabled() == true) { if (!defined('ALBUM_AUTH_VIEW') || !defined('ALBUM_AUTH_UPLOAD') || !defined('ALBUM_AUTH_DELETE') ) { album_debug("album_permissions : The defined authentication constants are NOT found !!!"); } } $view_check = (int) checkFlag($permission_checks, ALBUM_AUTH_VIEW); $upload_check = (int) checkFlag($permission_checks, ALBUM_AUTH_UPLOAD); $rate_check = (int) checkFlag($permission_checks, ALBUM_AUTH_RATE); $comment_check = (int) checkFlag($permission_checks, ALBUM_AUTH_COMMENT); $edit_check = (int) checkFlag($permission_checks, ALBUM_AUTH_EDIT); $delete_check = (int) checkFlag($permission_checks, ALBUM_AUTH_DELETE); // ------------------------------------------------------------------------ // if we are checkinfg the personal gallery cateogry management permission // we need to do these also : view and upload // ------------------------------------------------------------------------ if ( checkFlag($permission_checks, ALBUM_AUTH_MANAGE_PERSONAL_CATEGORIES) == true) { $view_check = 1; $upload_check = 1; } // ------------------------------------------------------------------------ // did we pass some category data or not ? // ------------------------------------------------------------------------ if (!is_array($catdata)) { $sql = "SELECT * FROM ". ALBUM_CAT_TABLE ." WHERE cat_id = '$cat_id'"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not query Album Category information for authentication' ,'' , __LINE__, __FILE__, $sql); } // ------------------------------------------------------------------------ // did we find the category or not ? // ------------------------------------------------------------------------ if ($db->sql_numrows($result) == 0) { // ------------------------------------------------------------------------ // is it a personal gallery ? // ------------------------------------------------------------------------ if ($user_id != ALBUM_PUBLIC_GALLERY) { $AH_thiscat = init_personal_gallery_cat($user_id); $album_permission = personal_gallery_access(1,1); //$view_check, $upload_check); } else { mx_message_die(GENERAL_ERROR, $lang['Category_not_exist'] ,'' , __LINE__, __FILE__, $sql); } } else { $AH_thiscat = $db->sql_fetchrow($result); } } else { $AH_thiscat = $catdata; // ------------------------------------------------------------------------ // it is the root category of a non existing personal gallery // ------------------------------------------------------------------------ if ($AH_thiscat['cat_user_id'] != 0 && $AH_thiscat['cat_id'] == 0) { $album_permission = personal_gallery_access(1,1); //$view_check, $upload_check); } } // ------------------------------------------------------------------------ // if we set our $AH_thiscat and not our permission array then we must // authenticate it // ------------------------------------------------------------------------ if (album_is_debug_enabled() == true) { album_debug('album_permissions : before album_user_access : %s(id=%d), $album_permission = %s',$AH_thiscat['cat_title'],$AH_thiscat['cat_id'], $album_permission); } if (empty($album_permission)) { $album_permission = personal_gallery_access(1,1); //$view_check, $upload_check); } if (!empty($AH_thiscat) && !is_array($album_permission)) { $album_permission = album_user_access($cat_id, $AH_thiscat, $view_check, $upload_check, $rate_check, $comment_check, $edit_check, $delete_check); } if (album_is_debug_enabled() == true) { album_debug('album_permissions : after album_user_access : %s(id=%d), $album_permission = %s',$AH_thiscat['cat_title'],$AH_thiscat['cat_id'], $album_permission); } // ------------------------------------------------------------------------ // as default nobody can manage the galleries (personal galleries that is) // check is done later, but only for personal galleries, so its not possible // to manage the categories in the public galleries, only in the ACP // ------------------------------------------------------------------------ $album_permission['manage'] = 0; // ------------------------------------------------------------------------ // $album_permission should now hold our permission stuff for either a personal // gallery or a public gallery. // lets now do some more authentication for the personal galleries // ------------------------------------------------------------------------ if ($AH_thiscat['cat_user_id'] != 0) { if (album_is_debug_enabled() == true) { album_Debug('$album_config[\'personal_gallery\'] = %d', $album_config['personal_gallery']); } switch ($album_config['personal_gallery']) { case ALBUM_USER: // ------------------------------------------------------------------------ // are we checking a non existing personal gallery ? // ------------------------------------------------------------------------ if (empty($AH_thiscat) || $AH_thiscat['cat_id'] == 0 || $cat_id == ALBUM_ROOT_CATEGORY) { // ------------------------------------------------------------------------ // if the admin has set the creation of personal galleries to 'registered users' // then filter out all other users then the current logged in user (and NON ADMIN) // ------------------------------------------------------------------------ if ($userdata['user_id'] != $AH_thiscat['cat_user_id'] && $userdata['user_level'] != ADMIN) { $album_permission['upload'] = 0; } // ------------------------------------------------------------------------ // set the other permissions to the same value of the upload // for this non exsting personal gallery, // ------------------------------------------------------------------------ $album_permission['rate'] = $album_permission['upload']; $album_permission['edit'] = $album_permission['upload']; $album_permission['delete'] = $album_permission['upload']; $album_permission['comment'] = $album_permission['upload']; } break; case ALBUM_ADMIN: // ------------------------------------------------------------------------ // Only admins can upload images to users personal gallery // ------------------------------------------------------------------------ if ($userdata['user_level'] != ADMIN) { $album_permission['upload'] = 0; } break; default: // NOTHING; } // ------------------------------------------------------------------------ // we need to check the upload permission again to full fill all the // permission criterias // ------------------------------------------------------------------------ switch ($AH_thiscat['cat_upload_level']) { case ALBUM_PRIVATE: // ------------------------------------------------------------------------ // make sure the owner of the personal gallery can upload to his personal gallery // it the permission is set to pri... [truncated message content] |