Index: /tags/release-1_7_0RC1/about.php =================================================================== --- /tags/release-1_7_0RC1/about.php (revision 1826) +++ /tags/release-1_7_0RC1/about.php (revision 1826) @@ -0,0 +1,70 @@ +set_filenames( + array( + 'about'=>'about.tpl', + 'about_content' => get_language_filepath('about.html') + ) + ); +if ( isset( $themeconf['About']) and $themeconf['About']!=='' ) +{ + $template->assign_block_vars( + 'theme', + array( + 'ABOUT' => l10n($themeconf['About']), + ) + ); +} +$template->assign_vars( + array( + 'U_HOME' => make_index_url(), + ) + ); + +$template->assign_var_from_handle('ABOUT_MESSAGE', 'about_content'); + +$template->parse('about'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); +?> Index: /tags/release-1_7_0RC1/action.php =================================================================== --- /tags/release-1_7_0RC1/action.php (revision 1826) +++ /tags/release-1_7_0RC1/action.php (revision 1826) @@ -0,0 +1,201 @@ + restriction) +$query=' +SELECT id + FROM '.CATEGORIES_TABLE.' + INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON category_id = id + WHERE image_id = '.$_GET['id'].' +'.get_sql_condition_FandF( + array('forbidden_categories' => 'category_id'), + ' AND' + ).' + LIMIT 1 +;'; +if ( mysql_num_rows(pwg_query($query))<1 ) +{ + do_error(401, 'Access denied'); +} + +include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); +$file=''; +switch ($_GET['part']) +{ + case 't': + $file = get_thumbnail_path($element_info); + break; + case 'e': + $file = get_element_path($element_info); + break; + case 'i': + $file = get_image_path($element_info); + break; + case 'h': + if ( $user['enabled_high']!='true' ) + { + do_error(401, 'Access denied h'); + } + $file = get_high_path($element_info); + break; +} + +if ( empty($file) ) +{ + do_error(404, 'Requested file not found'); +} + +if ($_GET['part'] == 'h') { + $is_high = true; + pwg_log($_GET['id'], $is_high); +} + +$http_headers = array(); + +$ctype = null; +if (!url_is_remote($file)) +{ + if ( !@is_readable($file) ) + { + do_error(404, "Requested file not found - $file"); + } + $http_headers[] = 'Content-Length: '.@filesize($file); + if ( function_exists('mime_content_type') ) + { + $ctype = mime_content_type($file); + } + + $gmt_mtime = gmdate('D, d M Y H:i:s', filemtime($file)).' GMT'; + $http_headers[] = 'Last-Modified: '.$gmt_mtime; + + // following lines would indicate how the client should handle the cache + /* $max_age=300; + $http_headers[] = 'Expires: '.gmdate('D, d M Y H:i:s', time()+$max_age).' GMT'; + // HTTP/1.1 only + $http_headers[] = 'Cache-Control: private, must-revalidate, max-age='.$max_age;*/ + + if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) + { + set_status_header(304); + foreach ($http_headers as $header) + { + header( $header ); + } + exit(); + } +} + +if (!isset($ctype)) +{ // give it a guess + $ctype = guess_mime_type( get_extension($file) ); +} + +$http_headers[] = 'Content-Type: '.$ctype; + +if (!isset($_GET['view'])) +{ + $http_headers[] = 'Content-Disposition: attachment; filename="' + .basename($file).'";'; + $http_headers[] = 'Content-Transfer-Encoding: binary'; +} +else +{ + $http_headers[] = 'Content-Disposition: inline; filename="' + .basename($file).'";'; +} + +foreach ($http_headers as $header) +{ + header( $header ); +} + +// Looking at the safe_mode configuration for execution time +if (ini_get('safe_mode') == 0) +{ + @set_time_limit(0); +} + +@readfile($file); + +?> Index: /tags/release-1_7_0RC1/admin.php =================================================================== --- /tags/release-1_7_0RC1/admin.php (revision 1826) +++ /tags/release-1_7_0RC1/admin.php (revision 1826) @@ -0,0 +1,187 @@ +'.l10n('PhpWebGallery Administration').''; +$page['body_id'] = 'theAdminPage'; +include(PHPWG_ROOT_PATH.'include/page_header.php'); + +$template->set_filenames(array('admin' => 'admin.tpl')); + +$template->assign_vars( + array( + 'U_SITE_MANAGER'=> $link_start.'site_manager', + 'U_HISTORY_STAT'=> $link_start.'stats', + 'U_HISTORY_SEARCH'=> $link_start.'history', + 'U_FAQ'=> $link_start.'help', + 'U_SITES'=> $link_start.'remote_site', + 'U_MAINTENANCE'=> $link_start.'maintenance', + 'U_NOTIFICATION_BY_MAIL'=> $link_start.'notification_by_mail', + 'U_ADVANCED_FEATURE'=> $link_start.'advanced_feature', + 'U_CONFIG_GENERAL'=> $conf_link.'general', + 'U_CONFIG_COMMENTS'=> $conf_link.'comments', + 'U_CONFIG_DISPLAY'=> $conf_link.'default', + 'U_CATEGORIES'=> $link_start.'cat_list', + 'U_MOVE'=> $link_start.'cat_move', + 'U_CAT_UPLOAD'=> $opt_link.'upload', + 'U_CAT_COMMENTS'=> $opt_link.'comments', + 'U_CAT_VISIBLE'=> $opt_link.'visible', + 'U_CAT_STATUS'=> $opt_link.'status', + 'U_CAT_OPTIONS'=> $link_start.'cat_options', + 'U_CAT_UPDATE'=> $link_start.'site_update&site=1', + 'U_WAITING'=> $link_start.'waiting', + 'U_COMMENTS'=> $link_start.'comments', + 'U_RATING'=> $link_start.'rating', + 'U_CADDIE'=> $link_start.'element_set&cat=caddie', + 'U_TAGS'=> $link_start.'tags', + 'U_THUMBNAILS'=> $link_start.'thumbnail', + 'U_USERS'=> $link_start.'user_list', + 'U_GROUPS'=> $link_start.'group_list', + 'U_RETURN'=> make_index_url(), + 'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php', + 'L_ADMIN' => $lang['admin'], + 'L_ADMIN_HINT' => $lang['hint_admin'] + ) + ); +if ($conf['ws_access_control']) // Do we need to display ws_checker +{ + $template->assign_block_vars( + 'web_services', + array( + 'U_WS_CHECKER'=> $link_start.'ws_checker', + ) + ); +} +if ($conf['allow_random_representative']) +{ + $template->assign_block_vars( + 'representative', + array( + 'URL' => $opt_link.'representative' + ) + ); +} + +// required before plugin page inclusion +$plugin_menu_links = array( + array( + 'NAME' => l10n('admin'), + 'URL' => $link_start.'plugins' + ) + ); +$plugin_menu_links = trigger_event('get_admin_plugin_menu_links', + $plugin_menu_links ); + + +include(PHPWG_ROOT_PATH.'admin/'.$page['page'].'.php'); + +//------------------------------------------------------------- content display +foreach ($plugin_menu_links as $menu_item) +{ + $template->assign_block_vars('plugin_menu.menu_item', $menu_item); +} + +// +-----------------------------------------------------------------------+ +// | errors & infos | +// +-----------------------------------------------------------------------+ + +if (count($page['errors']) != 0) +{ + foreach ($page['errors'] as $error) + { + $template->assign_block_vars('errors.error',array('ERROR'=>$error)); + } +} + +if (count($page['infos']) != 0) +{ + foreach ($page['infos'] as $info) + { + $template->assign_block_vars('infos.info',array('INFO'=>$info)); + } +} + +$template->parse('admin'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); + +// +-----------------------------------------------------------------------+ +// | order permission refreshment | +// +-----------------------------------------------------------------------+ + +$query = ' +UPDATE '.USER_CACHE_TABLE.' + SET need_update = \'true\' +;'; +pwg_query($query); +?> Index: /tags/release-1_7_0RC1/admin/advanced_feature.php =================================================================== --- /tags/release-1_7_0RC1/admin/advanced_feature.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/advanced_feature.php (revision 1826) @@ -0,0 +1,117 @@ + l10n('???'), + 'URL' => $start_url.'???' + ));*/ + +array_push($advanced_features, + array + ( + 'CAPTION' => l10n('Elements_not_linked'), + 'URL' => get_root_url().'admin.php?page=element_set&cat=not_linked' + )); + +array_push($advanced_features, + array + ( + 'CAPTION' => l10n('Duplicates'), + 'URL' => get_root_url().'admin.php?page=element_set&cat=duplicates' + )); + +//$advanced_features is array of array composed of CAPTION & URL +$advanced_features = + trigger_event('get_admin_advanced_features_links', $advanced_features); + +// +-----------------------------------------------------------------------+ +// | Template init | +// +-----------------------------------------------------------------------+ + +$template->set_filenames(array('advanced_feature'=>'admin/advanced_feature.tpl')); + +$start_url = get_root_url().'admin.php?page=advanced_feature&action='; + +$template->assign_vars( + array + ( + 'U_HELP' => get_root_url().'popuphelp.php?page=advanced_feature' + )); + +// advanced_features +if (count($advanced_features) > 0) +{ + foreach ($advanced_features as $advanced_feature) + { + $template->assign_block_vars('advanced_features.advanced_feature', $advanced_feature); + } +} + +// +-----------------------------------------------------------------------+ +// | Sending html code | +// +-----------------------------------------------------------------------+ + +$template->assign_var_from_handle('ADMIN_CONTENT', 'advanced_feature'); + +?> Index: /tags/release-1_7_0RC1/admin/cat_list.php =================================================================== --- /tags/release-1_7_0RC1/admin/cat_list.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/cat_list.php (revision 1826) @@ -0,0 +1,335 @@ + $id, 'rank' => ++$current_rank)); + } + $fields = array('primary' => array('id'), 'update' => array('rank')); + mass_updates(CATEGORIES_TABLE, $fields, $datas); + + update_global_rank(@$_GET['parent_id']); +} + +// +-----------------------------------------------------------------------+ +// | initialization | +// +-----------------------------------------------------------------------+ + +$categories = array(); + +$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list'; +$navigation = ''; +$navigation.= $lang['home']; +$navigation.= ''; + +// +-----------------------------------------------------------------------+ +// | virtual categories management | +// +-----------------------------------------------------------------------+ +// request to delete a virtual category / not for an adviser +if (isset($_GET['delete']) and is_numeric($_GET['delete']) and !is_adviser()) +{ + delete_categories(array($_GET['delete'])); + array_push($page['infos'], $lang['cat_virtual_deleted']); + ordering(); + update_global_rank(); +} +// request to add a virtual category +else if (isset($_POST['submitAdd'])) +{ + $output_create = create_virtual_category( + $_POST['virtual_name'], + @$_GET['parent_id'] + ); + + if (isset($output_create['error'])) + { + array_push($page['errors'], $output_create['error']); + } + else + { + array_push($page['infos'], $output_create['info']); + } +} +// save manual category ordering +else if (isset($_POST['submitOrder'])) +{ + asort($_POST['catOrd'], SORT_NUMERIC); + save_categories_order(array_keys($_POST['catOrd'])); + + array_push( + $page['infos'], + l10n('Categories manual order was saved') + ); +} +// sort categories alpha-numerically +else if (isset($_POST['submitOrderAlphaNum'])) +{ + $query = ' +SELECT id, name + FROM '.CATEGORIES_TABLE.' + WHERE id_uppercat '. + (!isset($_GET['parent_id']) ? 'IS NULL' : '= '.$_GET['parent_id']).' +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_assoc($result)) + { + $categories[ $row['id'] ] = strtolower($row['name']); + } + + asort($categories, SORT_REGULAR); + save_categories_order(array_keys($categories)); + + array_push( + $page['infos'], + l10n('Categories ordered alphanumerically') + ); +} + +// +-----------------------------------------------------------------------+ +// | Cache management | +// +-----------------------------------------------------------------------+ +$query = ' +SELECT * + FROM '.CATEGORIES_TABLE; +if (!isset($_GET['parent_id'])) +{ + $query.= ' + WHERE id_uppercat IS NULL'; +} +else +{ + $query.= ' + WHERE id_uppercat = '.$_GET['parent_id']; +} +$query.= ' + ORDER BY rank ASC +;'; +$result = pwg_query($query); +while ($row = mysql_fetch_assoc($result)) +{ + $categories[$row['rank']] = $row; + $categories[$row['rank']]['nb_subcats'] = 0; +} + +// +-----------------------------------------------------------------------+ +// | Navigation path | +// +-----------------------------------------------------------------------+ + +if (isset($_GET['parent_id'])) +{ + $navigation.= $conf['level_separator']; + + $current_category = get_cat_info($_GET['parent_id']); + + $navigation.= get_cat_display_name( + $current_category['name'], + $base_url.'&parent_id=', + false + ); +} +// +-----------------------------------------------------------------------+ +// | template initialization | +// +-----------------------------------------------------------------------+ +$template->set_filenames(array('categories'=>'admin/cat_list.tpl')); + +$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_list'; +if (isset($_GET['parent_id'])) +{ + $form_action.= '&parent_id='.$_GET['parent_id']; +} + +$template->assign_vars(array( + 'CATEGORIES_NAV'=>$navigation, + 'F_ACTION'=>$form_action, + + 'L_ADD_VIRTUAL'=>$lang['cat_add'], + 'L_SUBMIT'=>$lang['submit'], + 'L_STORAGE'=>$lang['storage'], + 'L_NB_IMG'=>$lang['pictures'], + 'L_MOVE_UP'=>$lang['up'], + 'L_EDIT'=>$lang['edit'], + 'L_DELETE'=>$lang['delete'], + )); + +$tpl = array('cat_first','cat_last'); +// +-----------------------------------------------------------------------+ +// | Categories display | +// +-----------------------------------------------------------------------+ + +$categories = array(); + +$query = ' +SELECT id, name, dir, rank, nb_images, status + FROM '.CATEGORIES_TABLE; +if (!isset($_GET['parent_id'])) +{ + $query.= ' + WHERE id_uppercat IS NULL'; +} +else +{ + $query.= ' + WHERE id_uppercat = '.$_GET['parent_id']; +} +$query.= ' + ORDER BY rank ASC +;'; +$result = pwg_query($query); +while ($row = mysql_fetch_array($result)) +{ + $categories[$row['id']] = $row; + // by default, let's consider there is no sub-categories. This will be + // calculated after. + $categories[$row['id']]['nb_subcats'] = 0; +} + +if (count($categories) > 0) +{ + $query = ' +SELECT id_uppercat, COUNT(*) AS nb_subcats + FROM '. CATEGORIES_TABLE.' + WHERE id_uppercat IN ('.implode(',', array_keys($categories)).') + GROUP BY id_uppercat +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $categories[$row['id_uppercat']]['nb_subcats'] = $row['nb_subcats']; + } + + $template->assign_block_vars('categories', array()); +} + +foreach ($categories as $category) +{ + // TODO : not used anymore ? + //$images_folder = PHPWG_ROOT_PATH.'template/'; + //$images_folder.= $user['template'].'/admin/images'; + + $base_url = PHPWG_ROOT_PATH.'admin.php?page='; + $cat_list_url = $base_url.'cat_list'; + + $self_url = $cat_list_url; + if (isset($_GET['parent_id'])) + { + $self_url.= '&parent_id='.$_GET['parent_id']; + } + + $template->assign_block_vars( + 'categories.category', + array( + 'NAME' => $category['name'], + 'ID' => $category['id'], + 'RANK' => $category['rank']*10, + + 'U_JUMPTO' => make_index_url( + array( + 'category' => $category['id'], + 'cat_name' => $category['name'], + ) + ), + + 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], + 'U_EDIT' => $base_url.'cat_modify&cat_id='.$category['id'], + ) + ); + + if (empty($category['dir'])) + { + $template->assign_block_vars( + 'categories.category.delete', + array( + 'URL'=>$self_url.'&delete='.$category['id'] + ) + ); + $template->assign_block_vars( + 'categories.category.virtual', + array( + 'CLASS' => 'virtual_cat', + ) + ); + } + + if ($category['nb_images'] > 0) + { + $template->assign_block_vars( + 'categories.category.elements', + array( + 'URL'=>$base_url.'element_set&cat='.$category['id'] + ) + ); + } + + if ('private' == $category['status']) + { + $template->assign_block_vars( + 'categories.category.permissions', + array( + 'URL'=>$base_url.'cat_perm&cat='.$category['id'] + ) + ); + } +} +// Add a link to Page bottom only if needed (10 or more categories) +if ( isset($category['rank']) and $category['rank'] > 9 ) +{ + $template->assign_block_vars('eop_link', array('ICON'=>'Displayed')); +} +// +-----------------------------------------------------------------------+ +// | sending html code | +// +-----------------------------------------------------------------------+ +$template->assign_var_from_handle('ADMIN_CONTENT', 'categories'); +?> Index: /tags/release-1_7_0RC1/admin/cat_modify.php =================================================================== --- /tags/release-1_7_0RC1/admin/cat_modify.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/cat_modify.php (revision 1826) @@ -0,0 +1,533 @@ +set_filenames( array('categories'=>'admin/cat_modify.tpl') ); + +//--------------------------------------------------------- form criteria check +if (isset($_POST['submit'])) +{ + $data = + array( + 'id' => $_GET['cat_id'], + 'name' => @$_POST['name'], + 'commentable' => $_POST['commentable'], + 'uploadable' => + isset($_POST['uploadable']) ? $_POST['uploadable'] : 'false', + 'comment' => + $conf['allow_html_descriptions'] ? + @$_POST['comment'] : strip_tags(@$_POST['comment']) + ); + + mass_updates( + CATEGORIES_TABLE, + array( + 'primary' => array('id'), + 'update' => array_diff(array_keys($data), array('id')) + ), + array($data) + ); + + set_cat_visible(array($_GET['cat_id']), $_POST['visible']); + set_cat_status(array($_GET['cat_id']), $_POST['status']); + + if (isset($_POST['parent'])) + { + move_categories( + array($_GET['cat_id']), + $_POST['parent'] + ); + } + + $image_order = ''; + if ( !isset($_POST['image_order_default']) ) + { + for ($i=1; $i<=3; $i++) + { + if ( !empty($_POST['order_field_'.$i]) ) + { + if (! empty($image_order) ) + { + $image_order .= ','; + } + $image_order .= $_POST['order_field_'.$i]; + if ($_POST['order_direction_'.$i]=='DESC') + { + $image_order .= ' DESC'; + } + } + } + } + $image_order = empty($image_order) ? 'null' : "'$image_order'"; + $query = ' +UPDATE '.CATEGORIES_TABLE.' SET image_order='.$image_order.' +WHERE '; + if (isset($_POST['image_order_subcats'])) + { + $query .= 'uppercats REGEXP \'(^|,)'.$_GET['cat_id'].'(,|$)\''; + } + else + { + $query .= 'id='.$_GET['cat_id'].';'; + } + pwg_query($query); + + array_push($page['infos'], $lang['editcat_confirm']); +} +else if (isset($_POST['set_random_representant'])) +{ + set_random_representant(array($_GET['cat_id'])); +} +else if (isset($_POST['delete_representant'])) +{ + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET representative_picture_id = NULL + WHERE id = '.$_GET['cat_id'].' +;'; + pwg_query($query); +} +else if (isset($_POST['submitAdd'])) +{ + $output_create = create_virtual_category( + $_POST['virtual_name'], + (0 == $_POST['parent'] ? null : $_POST['parent']) + ); + + if (isset($output_create['error'])) + { + array_push($page['errors'], $output_create['error']); + } + else + { + // Virtual category creation succeeded + // + // Add the information in the information list + array_push($page['infos'], $output_create['info']); + + // Link the new category to the current category + associate_categories_to_categories( + array($_GET['cat_id']), + array($output_create['id']) + ); + + // information + array_push( + $page['infos'], + sprintf( + l10n('Category elements associated to the following categories: %s'), + '
'; print_r($_POST); echo ''; + $result = pwg_query('SELECT param FROM '.CONFIG_TABLE); + while ($row = mysql_fetch_array($result)) + { + if (isset($_POST[$row['param']])) + { + $value = $_POST[$row['param']]; + + if ('gallery_title' == $row['param']) + { + if (!$conf['allow_html_descriptions']) + { + $value = strip_tags($value); + } + } + + $query = ' +UPDATE '.CONFIG_TABLE.' + SET value = \''. str_replace("\'", "''", $value).'\' + WHERE param = \''.$row['param'].'\' +;'; + pwg_query($query); + } + } + array_push($page['infos'], $lang['conf_confirmation']); + } + + //------------------------------------------------------ $conf reinitialization + load_conf_from_db(); +} + +//----------------------------------------------------- template initialization +$template->set_filenames( array('config'=>'admin/configuration.tpl') ); + +$action = PHPWG_ROOT_PATH.'admin.php?page=configuration'; +$action.= '§ion='.$page['section']; + +$template->assign_vars( + array( + 'L_YES'=>$lang['yes'], + 'L_NO'=>$lang['no'], + 'L_SUBMIT'=>$lang['submit'], + 'L_RESET'=>$lang['reset'], + + 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=configuration', + + 'F_ACTION'=>$action + )); + +$html_check='checked="checked"'; + +switch ($page['section']) +{ + case 'general' : + { + $lock_yes = ($conf['gallery_locked']==true)?'checked="checked"':''; + $lock_no = ($conf['gallery_locked']==false)?'checked="checked"':''; + + $template->assign_block_vars( + 'general', + array( + 'GALLERY_LOCKED_YES'=>$lock_yes, + 'GALLERY_LOCKED_NO'=>$lock_no, + ($conf['rate']==true?'RATE_YES':'RATE_NO')=>$html_check, + ($conf['rate_anonymous']==true + ? 'RATE_ANONYMOUS_YES' : 'RATE_ANONYMOUS_NO')=>$html_check, + 'CONF_GALLERY_TITLE' => $conf['gallery_title'], + 'CONF_PAGE_BANNER' => $conf['page_banner'], + 'CONF_GALLERY_URL' => $conf['gallery_url'], + )); + + foreach( $general_checkboxes as $checkbox) + { + $template->merge_block_vars( + 'general', + array( + strtoupper($checkbox) => ($conf[$checkbox]==true)?$html_check:'' + ) + ); + } + break; + } + case 'comments' : + { + $template->assign_block_vars( + 'comments', + array( + 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], + )); + + foreach( $comments_checkboxes as $checkbox) + { + $template->merge_block_vars( + 'comments', + array( + strtoupper($checkbox) => ($conf[$checkbox]==true)?$html_check:'' + ) + ); + } + break; + } + case 'default' : + { + $show_yes = ($conf['show_nb_comments']==true)?'checked="checked"':''; + $show_no = ($conf['show_nb_comments']==false)?'checked="checked"':''; + $hits_yes = ($conf['show_nb_hits']==true)?'checked="checked"':''; + $hits_no = ($conf['show_nb_hits']==false)?'checked="checked"':''; + $expand_yes = ($conf['auto_expand']==true)?'checked="checked"':''; + $expand_no = ($conf['auto_expand']==false)?'checked="checked"':''; + + $template->assign_block_vars( + 'default', + array( + 'NB_IMAGE_LINE'=>$conf['nb_image_line'], + 'NB_ROW_PAGE'=>$conf['nb_line_page'], + 'CONF_RECENT'=>$conf['recent_period'], + 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], + 'MAXWIDTH'=>$conf['default_maxwidth'], + 'MAXHEIGHT'=>$conf['default_maxheight'], + 'EXPAND_YES'=>$expand_yes, + 'EXPAND_NO'=>$expand_no, + 'SHOW_COMMENTS_YES'=>$show_yes, + 'SHOW_COMMENTS_NO'=>$show_no, + 'SHOW_HITS_YES'=>$hits_yes, + 'SHOW_HITS_NO'=>$hits_no, + )); + + $blockname = 'default.language_option'; + + foreach (get_languages() as $language_code => $language_name) + { + if (isset($_POST['submit'])) + { + $selected = + $_POST['default_language'] == $language_code + ? 'selected="selected"' : ''; + } + else if ($conf['default_language'] == $language_code) + { + $selected = 'selected="selected"'; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE'=> $language_code, + 'CONTENT' => $language_name, + 'SELECTED' => $selected + )); + } + + $blockname = 'default.template_option'; + + foreach (get_pwg_themes() as $pwg_template) + { + if (isset($_POST['submit'])) + { + $selected = + $_POST['default_template'] == $pwg_template + ? 'selected="selected"' : ''; + } + else if ($conf['default_template'] == $pwg_template) + { + $selected = 'selected="selected"'; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE'=> $pwg_template, + 'CONTENT' => $pwg_template, + 'SELECTED' => $selected + ) + ); + } + + + break; + } +} +//----------------------------------------------------------- sending html code +$template->assign_var_from_handle('ADMIN_CONTENT', 'config'); +?> Index: /tags/release-1_7_0RC1/admin/element_set.php =================================================================== --- /tags/release-1_7_0RC1/admin/element_set.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/element_set.php (revision 1826) @@ -0,0 +1,230 @@ + 0) + { + $query = ' +DELETE + FROM '.CADDIE_TABLE.' + WHERE element_id IN ('.implode(',', $_POST['selection']).') + AND user_id = '.$user['id'].' +;'; + pwg_query($query); + } + else + { + // TODO : add error + } + break; + } + case 'add_selected' : + { + if (isset($_POST['selection']) and count($_POST['selection']) > 0) + { + fill_caddie($_POST['selection']); + } + else + { + // TODO : add error + } + break; + } + } + } + else + { + // TODO : add error + } +} + +// +-----------------------------------------------------------------------+ +// | initialize info about category | +// +-----------------------------------------------------------------------+ + +// To element_set_(global|unit).php, we must provide the elements id of the +// managed category in $page['cat_elements_id'] array. + +if (is_numeric($_GET['cat'])) +{ + $cat_infos = get_cat_info($_GET['cat']); + $page['title'] = + get_cat_display_name( + $cat_infos['name'], + PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id=', + false + ); + + $query = ' +SELECT image_id + FROM '.IMAGE_CATEGORY_TABLE.' + WHERE category_id = '.$_GET['cat'].' +;'; + $page['cat_elements_id'] = array_from_query($query, 'image_id'); +} +else if ('caddie' == $_GET['cat']) +{ + $page['title'] = $lang['caddie']; + + $query = ' +SELECT element_id + FROM '.CADDIE_TABLE.' + WHERE user_id = '.$user['id'].' +;'; + $page['cat_elements_id'] = array_from_query($query, 'element_id'); +} +else if ('not_linked' == $_GET['cat']) +{ + $page['title'] = l10n('Elements_not_linked'); + + // we are searching elements not linked to any virtual category + $query = ' +SELECT id + FROM '.CATEGORIES_TABLE.' + WHERE dir IS NULL +;'; + $virtual_categories = array_from_query($query, 'id'); + + $query = ' +SELECT DISTINCT(image_id) + FROM '.IMAGE_CATEGORY_TABLE.' +;'; + $all_elements = array_from_query($query, 'image_id'); + + $query = ' +SELECT DISTINCT(image_id) + FROM '.IMAGE_CATEGORY_TABLE.' + WHERE category_id IN ('.implode(',', $virtual_categories).') +;'; + $linked_to_virtual = array_from_query($query, 'image_id'); + + $page['cat_elements_id'] = array_diff($all_elements, $linked_to_virtual); +} +else if ('duplicates' == $_GET['cat']) +{ + $page['title'] = l10n('Duplicates'); + + // we are searching related elements twice or more to physical categories + // 1 - Retrieve Files + $query = ' +SELECT DISTINCT(file) + FROM '.IMAGES_TABLE.' + GROUP BY file +HAVING COUNT(DISTINCT storage_category_id) > 1 +;'; + + $duplicate_files = array_from_query($query, 'file'); + $duplicate_files[]='Nofiles'; + // 2 - Retrives related picture ids + $query = ' +SELECT id, file + FROM '.IMAGES_TABLE.' +WHERE file IN (\''.implode("','", $duplicate_files).'\') +ORDER BY file, id +;'; + + $page['cat_elements_id'] = array_from_query($query, 'id'); + $page['cat_elements_id'][] = 0; +} +// +-----------------------------------------------------------------------+ +// | first element to display | +// +-----------------------------------------------------------------------+ + +// $page['start'] contains the number of the first element in its +// category. For exampe, $page['start'] = 12 means we must show elements #12 +// and $page['nb_images'] next elements + +if (!isset($_GET['start']) + or !is_numeric($_GET['start']) + or $_GET['start'] < 0 + or (isset($_GET['display']) and 'all' == $_GET['display'])) +{ + $page['start'] = 0; +} +else +{ + $page['start'] = $_GET['start']; +} + +// +-----------------------------------------------------------------------+ +// | open specific mode | +// +-----------------------------------------------------------------------+ + +$_GET['mode'] = !empty($_GET['mode']) ? $_GET['mode'] : 'global'; + +switch ($_GET['mode']) +{ + case 'global' : + { + include(PHPWG_ROOT_PATH.'admin/element_set_global.php'); + break; + } + case 'unit' : + { + include(PHPWG_ROOT_PATH.'admin/element_set_unit.php'); + break; + } +} +?> Index: /tags/release-1_7_0RC1/admin/element_set_global.php =================================================================== --- /tags/release-1_7_0RC1/admin/element_set_global.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/element_set_global.php (revision 1826) @@ -0,0 +1,405 @@ +'; +// print_r($_POST); +// echo ''; +// exit(); + + switch ($_POST['target']) + { + case 'all' : + { + $collection = $page['cat_elements_id']; + break; + } + case 'selection' : + { + if (!isset($_POST['selection']) or count($_POST['selection']) == 0) + { + array_push($page['errors'], l10n('Select at least one picture')); + } + else + { + $collection = $_POST['selection']; + } + break; + } + } + + if (isset($_POST['add_tags']) and count($collection) > 0) + { + add_tags($_POST['add_tags'], $collection); + } + + if (isset($_POST['del_tags']) and count($collection) > 0) + { + $query = ' +DELETE + FROM '.IMAGE_TAG_TABLE.' + WHERE image_id IN ('.implode(',', $collection).') + AND tag_id IN ('.implode(',', $_POST['del_tags']).') +;'; + pwg_query($query); + } + + if ($_POST['associate'] != 0 and count($collection) > 0) + { + associate_images_to_categories( + $collection, + array($_POST['associate']) + ); + } + + if ($_POST['dissociate'] != 0 and count($collection) > 0) + { + // physical links must not be broken, so we must first retrieve image_id + // which create virtual links with the category to "dissociate from". + $query = ' +SELECT id + FROM '.IMAGE_CATEGORY_TABLE.' + INNER JOIN '.IMAGES_TABLE.' ON image_id = id + WHERE category_id = '.$_POST['dissociate'].' + AND id IN ('.implode(',', $collection).') + AND category_id != storage_category_id +;'; + $dissociables = array_from_query($query, 'id'); + + $query = ' +DELETE + FROM '.IMAGE_CATEGORY_TABLE.' + WHERE category_id = '.$_POST['dissociate'].' + AND image_id IN ('.implode(',', $dissociables).') +'; + pwg_query($query); + + update_category($_POST['dissociate']); + } + + $datas = array(); + $dbfields = array('primary' => array('id'), 'update' => array()); + + $formfields = array('author', 'name', 'date_creation'); + foreach ($formfields as $formfield) + { + if ($_POST[$formfield.'_action'] != 'leave') + { + array_push($dbfields['update'], $formfield); + } + } + + // updating elements is useful only if needed... + if (count($dbfields['update']) > 0 and count($collection) > 0) + { + $query = ' +SELECT id + FROM '.IMAGES_TABLE.' + WHERE id IN ('.implode(',', $collection).') +;'; + $result = pwg_query($query); + + while ($row = mysql_fetch_array($result)) + { + $data = array(); + $data['id'] = $row['id']; + + if ('set' == $_POST['author_action']) + { + $data['author'] = $_POST['author']; + + if ('' == $data['author']) + { + unset($data['author']); + } + } + + if ('set' == $_POST['name_action']) + { + $data['name'] = $_POST['name']; + + if ('' == $data['name']) + { + unset($data['name']); + } + } + + if ('set' == $_POST['date_creation_action']) + { + $data['date_creation'] = + $_POST['date_creation_year'] + .'-'.$_POST['date_creation_month'] + .'-'.$_POST['date_creation_day'] + ; + } + + array_push($datas, $data); + } + // echo '
'; print_r($datas); echo ''; + mass_updates(IMAGES_TABLE, $dbfields, $datas); + } +} + +// +-----------------------------------------------------------------------+ +// | template init | +// +-----------------------------------------------------------------------+ +$template->set_filenames( + array('element_set_global' => 'admin/element_set_global.tpl')); + +$base_url = PHPWG_ROOT_PATH.'admin.php'; + +// $form_action = $base_url.'?page=element_set_global'; + +$template->assign_vars( + array( + 'CATEGORIES_NAV'=>$page['title'], + + 'L_SUBMIT'=>$lang['submit'], + + 'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')), + + 'U_UNIT_MODE' + => + $base_url + .get_query_string_diff(array('mode','display')) + .'&mode=unit', + + 'F_ACTION'=>$base_url.get_query_string_diff(array()), + ) + ); + +// +-----------------------------------------------------------------------+ +// | caddie options | +// +-----------------------------------------------------------------------+ + +if ('caddie' == $_GET['cat']) +{ + $template->assign_block_vars('in_caddie', array()); +} +else +{ + $template->assign_block_vars('not_in_caddie', array()); +} + +// +-----------------------------------------------------------------------+ +// | global mode form | +// +-----------------------------------------------------------------------+ + +// Virtualy associate a picture to a category +$blockname = 'associate_option'; + +$template->assign_block_vars( + $blockname, + array('SELECTED' => '', + 'VALUE'=> 0, + 'OPTION' => '------------' + )); + +$query = ' +SELECT id,name,uppercats,global_rank + FROM '.CATEGORIES_TABLE.' +;'; +display_select_cat_wrapper($query, array(), $blockname, true); + +// Dissociate from a category : categories listed for dissociation can +// only represent virtual links. Links to physical categories can't be +// broken +$blockname = 'dissociate_option'; + +$template->assign_block_vars( + $blockname, + array('SELECTED' => '', + 'VALUE'=> 0, + 'OPTION' => '------------' + )); + +if (count($page['cat_elements_id']) > 0) +{ + $query = ' +SELECT DISTINCT(category_id) AS id, c.name, uppercats, global_rank + FROM '.IMAGE_CATEGORY_TABLE.' AS ic, + '.CATEGORIES_TABLE.' AS c, + '.IMAGES_TABLE.' AS i + WHERE ic.image_id IN ('.implode(',', $page['cat_elements_id']).') + AND ic.category_id = c.id + AND ic.image_id = i.id + AND ic.category_id != i.storage_category_id +;'; + display_select_cat_wrapper($query, array(), $blockname, true); +} + +$all_tags = get_all_tags(); + +if (count($all_tags) == 0) +{ + $add_tag_selection = + '
'. + l10n('No tag defined. Use Administration>Pictures>Tags'). + '
'; +} +else +{ + $add_tag_selection = get_html_tag_selection( + $all_tags, + 'add_tags' + ); +} + +// add tags +$template->assign_vars( + array( + 'ADD_TAG_SELECTION' => $add_tag_selection, + ) + ); + +if (count($page['cat_elements_id']) > 0) +{ + // remove tags + $tags = get_common_tags($page['cat_elements_id'], -1); + usort($tags, 'name_compare'); + + $template->assign_vars( + array( + 'DEL_TAG_SELECTION' => get_html_tag_selection($tags, 'del_tags'), + ) + ); +} +// creation date +$day = +empty($_POST['date_creation_day']) ? date('j') : $_POST['date_creation_day']; +get_day_list('date_creation_day', $day); + +if (!empty($_POST['date_creation_month'])) +{ + $month = $_POST['date_creation_month']; +} +else +{ + $month = date('n'); +} +get_month_list('date_creation_month', $month); + +if (!empty($_POST['date_creation_year'])) +{ + $year = $_POST['date_creation_year']; +} +else +{ + $year = date('Y'); +} +$template->assign_vars(array('DATE_CREATION_YEAR_VALUE'=>$year)); + +// +-----------------------------------------------------------------------+ +// | global mode thumbnails | +// +-----------------------------------------------------------------------+ + +// how many items to display on this page +if (!empty($_GET['display'])) +{ + if ('all' == $_GET['display']) + { + $page['nb_images'] = count($page['cat_elements_id']); + } + else + { + $page['nb_images'] = intval($_GET['display']); + } +} +else +{ + $page['nb_images'] = 20; +} + +if (count($page['cat_elements_id']) > 0) +{ + $nav_bar = create_navigation_bar( + $base_url.get_query_string_diff(array('start')), + count($page['cat_elements_id']), + $page['start'], + $page['nb_images'] + ); + $template->assign_vars(array('NAV_BAR' => $nav_bar)); + + $query = ' +SELECT id,path,tn_ext + FROM '.IMAGES_TABLE.' + WHERE id IN ('.implode(',', $page['cat_elements_id']).') + '.$conf['order_by'].' + LIMIT '.$page['start'].', '.$page['nb_images'].' +;'; + //echo ''.$query.''; + $result = pwg_query($query); + + // template thumbnail initialization + if (mysql_num_rows($result) > 0) + { + $template->assign_block_vars('thumbnails', array()); + } + + while ($row = mysql_fetch_assoc($result)) + { + $src = get_thumbnail_url($row); + + $template->assign_block_vars( + 'thumbnails.thumbnail', + array( + 'ID' => $row['id'], + 'SRC' => $src, + 'ALT' => 'TODO', + 'TITLE' => 'TODO' + ) + ); + } +} + +//----------------------------------------------------------- sending html code +$template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_global'); +?> Index: /tags/release-1_7_0RC1/admin/element_set_unit.php =================================================================== --- /tags/release-1_7_0RC1/admin/element_set_unit.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/element_set_unit.php (revision 1826) @@ -0,0 +1,278 @@ + array('id'), + 'update' => array('name','author','comment','date_creation') + ), + $datas + ); + + array_push($page['infos'], l10n('Picture informations updated')); +} + +// +-----------------------------------------------------------------------+ +// | template init | +// +-----------------------------------------------------------------------+ + +$template->set_filenames( + array('element_set_unit' => 'admin/element_set_unit.tpl')); + +$base_url = PHPWG_ROOT_PATH.'admin.php'; + +// $form_action = $base_url.'?page=element_set_global'; + +$template->assign_vars( + array( + 'CATEGORIES_NAV'=>$page['title'], + + 'L_SUBMIT'=>$lang['submit'], + + 'U_ELEMENTS_PAGE' + =>$base_url.get_query_string_diff(array('display','start')), + + 'U_GLOBAL_MODE' + => + $base_url + .get_query_string_diff(array('mode','display')) + .'&mode=global', + + 'F_ACTION'=>$base_url.get_query_string_diff(array()), + ) + ); + +// +-----------------------------------------------------------------------+ +// | global mode thumbnails | +// +-----------------------------------------------------------------------+ + +// how many items to display on this page +if (!empty($_GET['display'])) +{ + if ('all' == $_GET['display']) + { + $page['nb_images'] = count($page['cat_elements_id']); + } + else + { + $page['nb_images'] = intval($_GET['display']); + } +} +else +{ + $page['nb_images'] = 5; +} + + + +if (count($page['cat_elements_id']) > 0) +{ + $nav_bar = create_navigation_bar( + $base_url.get_query_string_diff(array('start')), + count($page['cat_elements_id']), + $page['start'], + $page['nb_images'] + ); + $template->assign_vars(array('NAV_BAR' => $nav_bar)); + + // tags + $all_tags = get_all_tags(); + + $element_ids = array(); + + $query = ' +SELECT id,path,tn_ext,name,date_creation,comment,author,file + FROM '.IMAGES_TABLE.' + WHERE id IN ('.implode(',', $page['cat_elements_id']).') + '.$conf['order_by'].' + LIMIT '.$page['start'].', '.$page['nb_images'].' +;'; + $result = pwg_query($query); + + while ($row = mysql_fetch_assoc($result)) + { + // echo '
'; print_r($row); echo ''; + array_push($element_ids, $row['id']); + + $src = get_thumbnail_url($row); + + $query = ' +SELECT tag_id + FROM '.IMAGE_TAG_TABLE.' + WHERE image_id = '.$row['id'].' +;'; + $selected_tags = array_from_query($query, 'tag_id'); + + // creation date + if (!empty($row['date_creation'])) + { + list($year,$month,$day) = explode('-', $row['date_creation']); + } + else + { + list($year,$month,$day) = array('','',''); + } + + if (count($all_tags) > 0) + { + $tag_selection = get_html_tag_selection( + $all_tags, + 'tags-'.$row['id'], + $selected_tags + ); + } + else + { + $tag_selection = + '
'. + l10n('No tag defined. Use Administration>Pictures>Tags'). + '
'; + } + + $template->assign_block_vars( + 'element', + array( + 'LEGEND' => + !empty($row['name']) ? + $row['name'] : get_name_from_file($row['file']), + 'U_EDIT' => + PHPWG_ROOT_PATH.'admin.php?page=picture_modify'. + '&image_id='.$row['id'], + 'ID' => $row['id'], + 'FILENAME' => $row['path'], + 'TN_SRC' => $src, + 'NAME' => @$row['name'], + 'AUTHOR' => @$row['author'], + 'DESCRIPTION' => @$row['comment'], + 'DATE_CREATION_YEAR' => $year, + + 'TAG_SELECTION' => $tag_selection, + ) + ); + + get_day_list('element.date_creation_day', $day); + get_month_list('element.date_creation_month', $month); + } + + $template->assign_vars(array('IDS_LIST' => implode(',', $element_ids))); +} + +// +-----------------------------------------------------------------------+ +// | sending html code | +// +-----------------------------------------------------------------------+ + +$template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_unit'); +?> Index: /tags/release-1_7_0RC1/admin/group_list.php =================================================================== --- /tags/release-1_7_0RC1/admin/group_list.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/group_list.php (revision 1826) @@ -0,0 +1,213 @@ +set_filenames(array('group_list' => 'admin/group_list.tpl')); + +$template->assign_vars( + array( + 'F_ADD_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=group_list', + 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=group_list', + ) + ); + +// +-----------------------------------------------------------------------+ +// | group list | +// +-----------------------------------------------------------------------+ + +$query = ' +SELECT id, name, is_default + FROM '.GROUPS_TABLE.' + ORDER BY id ASC +;'; +$result = pwg_query($query); + +$admin_url = PHPWG_ROOT_PATH.'admin.php?page='; +$perm_url = $admin_url.'group_perm&group_id='; +$del_url = $admin_url.'group_list&delete='; +$members_url = $admin_url.'user_list&group='; +$toggle_is_default_url = $admin_url.'group_list&toggle_is_default='; + +$num = 0; +while ($row = mysql_fetch_array($result)) +{ + $query = ' +SELECT COUNT(*) + FROM '.USER_GROUP_TABLE.' + WHERE group_id = '.$row['id'].' +;'; + list($counter) = mysql_fetch_row(pwg_query($query)); + + $template->assign_block_vars( + 'group', + array( + 'CLASS' => ($num++ % 2 == 1) ? 'row2' : 'row1', + 'NAME' => $row['name'], + 'IS_DEFAULT' => (get_boolean($row['is_default']) ? ' ['.l10n('is_default_group').']' : ''), + 'MEMBERS' => sprintf(l10n('%d members'), $counter), + 'U_MEMBERS' => $members_url.$row['id'], + 'U_DELETE' => $del_url.$row['id'], + 'U_PERM' => $perm_url.$row['id'], + 'U_ISDEFAULT' => $toggle_is_default_url.$row['id'] + ) + ); +} + +// +-----------------------------------------------------------------------+ +// | sending html code | +// +-----------------------------------------------------------------------+ + +$template->assign_var_from_handle('ADMIN_CONTENT', 'group_list'); + +?> Index: /tags/release-1_7_0RC1/admin/group_perm.php =================================================================== --- /tags/release-1_7_0RC1/admin/group_perm.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/group_perm.php (revision 1826) @@ -0,0 +1,191 @@ + 0) +{ + // if you forbid access to a category, all sub-categories become + // automatically forbidden + $subcats = get_subcat_ids($_POST['cat_true']); + $query = ' +DELETE + FROM '.GROUP_ACCESS_TABLE.' + WHERE group_id = '.$page['group'].' + AND cat_id IN ('.implode(',', $subcats).') +;'; + pwg_query($query); +} +else if (isset($_POST['trueify']) + and isset($_POST['cat_false']) + and count($_POST['cat_false']) > 0) +{ + $uppercats = get_uppercat_ids($_POST['cat_false']); + $private_uppercats = array(); + + $query = ' +SELECT id + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', $uppercats).') + AND status = \'private\' +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + array_push($private_uppercats, $row['id']); + } + + // retrying to authorize a category which is already authorized may cause + // an error (in SQL statement), so we need to know which categories are + // accesible + $authorized_ids = array(); + + $query = ' +SELECT cat_id + FROM '.GROUP_ACCESS_TABLE.' + WHERE group_id = '.$page['group'].' +;'; + $result = pwg_query($query); + + while ($row = mysql_fetch_array($result)) + { + array_push($authorized_ids, $row['cat_id']); + } + + $inserts = array(); + $to_autorize_ids = array_diff($private_uppercats, $authorized_ids); + foreach ($to_autorize_ids as $to_autorize_id) + { + array_push( + $inserts, + array( + 'group_id' => $page['group'], + 'cat_id' => $to_autorize_id + ) + ); + } + + mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $inserts); +} + +// +-----------------------------------------------------------------------+ +// | template init | +// +-----------------------------------------------------------------------+ + +$template->set_filenames( + array( + 'group_perm' => 'admin/group_perm.tpl', + 'double_select' => 'admin/double_select.tpl' + ) + ); + +$template->assign_vars( + array( + 'TITLE' => + sprintf( + l10n('Manage permissions for group "%s"'), + get_groupname($page['group'] + ) + ), + 'L_CAT_OPTIONS_TRUE'=>$lang['authorized'], + 'L_CAT_OPTIONS_FALSE'=>$lang['forbidden'], + 'L_CAT_OPTIONS_INFO'=>$lang['permuser_info'], + + 'F_ACTION' => + PHPWG_ROOT_PATH. + 'admin.php?page=group_perm&group_id='. + $page['group'] + ) + ); + +// only private categories are listed +$query_true = ' +SELECT id,name,uppercats,global_rank + FROM '.CATEGORIES_TABLE.' INNER JOIN '.GROUP_ACCESS_TABLE.' ON cat_id = id + WHERE status = \'private\' + AND group_id = '.$page['group'].' +;'; +display_select_cat_wrapper($query_true,array(),'category_option_true'); + +$result = pwg_query($query_true); +$authorized_ids = array(); +while ($row = mysql_fetch_array($result)) +{ + array_push($authorized_ids, $row['id']); +} + +$query_false = ' +SELECT id,name,uppercats,global_rank + FROM '.CATEGORIES_TABLE.' + WHERE status = \'private\''; +if (count($authorized_ids) > 0) +{ + $query_false.= ' + AND id NOT IN ('.implode(',', $authorized_ids).')'; +} +$query_false.= ' +;'; +display_select_cat_wrapper($query_false,array(),'category_option_false'); + +// +-----------------------------------------------------------------------+ +// | html code display | +// +-----------------------------------------------------------------------+ + +$template->assign_var_from_handle('DOUBLE_SELECT', 'double_select'); +$template->assign_var_from_handle('ADMIN_CONTENT', 'group_perm'); + +?> Index: /tags/release-1_7_0RC1/admin/help.php =================================================================== --- /tags/release-1_7_0RC1/admin/help.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/help.php (revision 1826) @@ -0,0 +1,42 @@ +set_filenames( + array( + 'help_content' => get_language_filepath('help.html') + ) + ); + +$template->assign_var_from_handle('ADMIN_CONTENT', 'help_content'); +?> Index: /tags/release-1_7_0RC1/admin/history.php =================================================================== --- /tags/release-1_7_0RC1/admin/history.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/history.php (revision 1826) @@ -0,0 +1,483 @@ +$_POST: +// '; print_r($_POST); echo ''; +// echo '$_GET: +// '; print_r($_GET); echo ''; + +// +-----------------------------------------------------------------------+ +// | functions | +// +-----------------------------------------------------------------------+ + +// +-----------------------------------------------------------------------+ +// | initialization | +// +-----------------------------------------------------------------------+ + +if (!defined('PHPWG_ROOT_PATH')) +{ + die('Hacking attempt!'); +} + +include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); + +if (isset($_GET['start']) and is_numeric($_GET['start'])) +{ + $page['start'] = $_GET['start']; +} +else +{ + $page['start'] = 0; +} + +// +-----------------------------------------------------------------------+ +// | Check Access and exit when user status is not ok | +// +-----------------------------------------------------------------------+ + +check_status(ACCESS_ADMINISTRATOR); + +// +-----------------------------------------------------------------------+ +// | Build search criteria and redirect to results | +// +-----------------------------------------------------------------------+ + +$errors = array(); +$search = array(); + +if (isset($_POST['submit'])) +{ + // dates + if (!empty($_POST['start_year'])) + { + $search['fields']['date-after'] = sprintf( + '%d-%02d-%02d', + $_POST['start_year'], + $_POST['start_month'], + $_POST['start_day'] + ); + } + + if (!empty($_POST['end_year'])) + { + $search['fields']['date-before'] = sprintf( + '%d-%02d-%02d', + $_POST['end_year'], + $_POST['end_month'], + $_POST['end_day'] + ); + } + + $search['fields']['pictures'] = $_POST['pictures']; + $search['fields']['high'] = $_POST['high']; + + // echo '
'; print_r($search); echo ''; + + if (!empty($search)) + { + // register search rules in database, then they will be available on + // thumbnails page and picture page. + $query =' +INSERT INTO '.SEARCH_TABLE.' + (rules) + VALUES + (\''.serialize($search).'\') +;'; + pwg_query($query); + + $search_id = mysql_insert_id(); + + redirect( + PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id + ); + } + else + { + array_push($errors, $lang['search_one_clause_at_least']); + } +} + +// +-----------------------------------------------------------------------+ +// | template init | +// +-----------------------------------------------------------------------+ + +$template->set_filenames(array('history'=>'admin/history.tpl')); + +$base_url = PHPWG_ROOT_PATH.'admin.php?page=history'; + +$template->assign_vars( + array( + 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=history', + + 'F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=history' + ) + ); + +$template->assign_vars( + array( + 'TODAY_DAY' => date('d', time()), + 'TODAY_MONTH' => date('m', time()), + 'TODAY_YEAR' => date('Y', time()), + ) + ); + +// +-----------------------------------------------------------------------+ +// | history lines | +// +-----------------------------------------------------------------------+ + +if (isset($_GET['search_id']) + and $page['search_id'] = (int)$_GET['search_id']) +{ + // what are the lines to display in reality ? + $query = ' +SELECT rules + FROM '.SEARCH_TABLE.' + WHERE id = '.$page['search_id'].' +;'; + list($serialized_rules) = mysql_fetch_row(pwg_query($query)); + + $page['search'] = unserialize($serialized_rules); + + // echo '
'; print_r($page['search']); echo ''; + + $clauses = array(); + + if (isset($page['search']['fields']['date-after'])) + { + array_push( + $clauses, + "date >= '".$page['search']['fields']['date-after']."'" + ); + } + + if (isset($page['search']['fields']['date-before'])) + { + array_push( + $clauses, + "date <= '".$page['search']['fields']['date-before']."'" + ); + } + + if (isset($page['search']['fields']['pictures'])) + { + $clause = null; + + if ($page['search']['fields']['pictures'] == 'no') + { + $clause = 'image_id IS NULL'; + } + + if ($page['search']['fields']['pictures'] == 'only') + { + $clause = 'image_id IS NOT NULL'; + } + + if (isset($clause)) + { + array_push($clauses, $clause); + } + } + + if (isset($page['search']['fields']['high'])) + { + $clause = null; + + if ($page['search']['fields']['high'] == 'no') + { + $clause = "is_high IS NULL or is_high = 'false'"; + } + + if ($page['search']['fields']['high'] == 'only') + { + $clause = "is_high = 'true'"; + } + + if (isset($clause)) + { + array_push($clauses, $clause); + } + } + + $clauses = prepend_append_array_items($clauses, '(', ')'); + + $where_separator = + implode( + "\n AND ", + $clauses + ); + + $query = ' +SELECT COUNT(*) + FROM '.HISTORY_TABLE.' + WHERE '.$where_separator.' +'; + + list($page['nb_lines']) = mysql_fetch_row(pwg_query($query)); + + $query = ' +SELECT + date, + time, + user_id, + IP, + section, + category_id, + tag_ids, + image_id, + is_high + FROM '.HISTORY_TABLE.' + WHERE '.$where_separator.' + LIMIT '.$page['start'].', '.$conf['nb_logs_page'].' +;'; + + $result = pwg_query($query); + $history_lines = $user_ids = $category_ids = $image_ids = array(); + while ($row = mysql_fetch_assoc($result)) + { + $user_ids[$row['user_id']] = 1; + + if (isset($row['category_id'])) + { + $category_ids[$row['category_id']] = 1; + } + + if (isset($row['image_id'])) + { + $image_ids[$row['image_id']] = 1; + } + + array_push( + $history_lines, + $row + ); + } + + // prepare reference data (users, tags, categories...) + if (count($user_ids) > 0) + { + $query = ' +SELECT '.$conf['user_fields']['id'].' AS id + , '.$conf['user_fields']['username'].' AS username + FROM '.USERS_TABLE.' + WHERE id IN ('.implode(',', array_keys($user_ids)).') +;'; + $result = pwg_query($query); + + $username_of = array(); + while ($row = mysql_fetch_array($result)) + { + $username_of[$row['id']] = $row['username']; + } + } + + if (count($category_ids) > 0) + { + $query = ' +SELECT id, uppercats + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', array_keys($category_ids)).') +;'; + $uppercats_of = simple_hash_from_query($query, 'id', 'uppercats'); + + $name_of_category = array(); + + foreach ($uppercats_of as $category_id => $uppercats) + { + $name_of_category[$category_id] = get_cat_display_name_cache( + $uppercats + ); + } + } + + if (count($image_ids) > 0) + { + $query = ' +SELECT id, IF(name IS NULL, file, name) AS label + FROM '.IMAGES_TABLE.' + WHERE id IN ('.implode(',', array_keys($image_ids)).') +;'; + $label_of_image = simple_hash_from_query($query, 'id', 'label'); + } + + $i = 0; + + foreach ($history_lines as $line) + { + $template->assign_block_vars( + 'detail', + array( + 'DATE' => $line['date'], + 'TIME' => $line['time'], + 'USER' => isset($username_of[$line['user_id']]) + ? $username_of[$line['user_id']] + : $line['user_id'] + , + 'IP' => $line['IP'], + 'IMAGE' => isset($line['image_id']) + ? ( isset($label_of_image[$line['image_id']]) + ? $label_of_image[$line['image_id']] + : 'deleted '.$line['image_id']) + : $line['image_id'], + 'SECTION' => $line['section'], + 'CATEGORY' => isset($line['category_id']) + ? ( isset($name_of_category[$line['category_id']]) + ? $name_of_category[$line['category_id']] + : 'deleted '.$line['category_id'] ) + : '', + 'TAGS' => $line['tag_ids'], + 'T_CLASS' => ($i++ % 2) ? 'row1' : 'row2', + ) + ); + + if (isset($line['image_id'])) + { + if ($line['is_high'] == 'true') + { + $template->assign_block_vars('detail.high', array()); + } + else + { + $template->assign_block_vars('detail.no_high', array()); + } + } + } +} + +// $groups_string = preg_replace( +// '/(\d+)/e', +// "\$groups['$1']", +// implode( +// ', ', +// $local_user['groups'] +// ) +// ); + +// +-----------------------------------------------------------------------+ +// | navigation bar | +// +-----------------------------------------------------------------------+ + +if (isset($page['search_id'])) +{ + $navbar = create_navigation_bar( + PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start')), + $page['nb_lines'], + $page['start'], + $conf['nb_logs_page'] + ); + + $template->assign_block_vars( + 'navigation', + array( + 'NAVBAR' => $navbar + ) + ); +} + +// +-----------------------------------------------------------------------+ +// | filter form | +// +-----------------------------------------------------------------------+ + +$form = array(); + +if (isset($page['search'])) +{ + if (isset($page['search']['fields']['date-after'])) + { + $tokens = explode('-', $page['search']['fields']['date-after']); + + $form['start_year'] = (int)$tokens[0]; + $form['start_month'] = (int)$tokens[1]; + $form['start_day'] = (int)$tokens[2]; + } + + if (isset($page['search']['fields']['date-before'])) + { + $tokens = explode('-', $page['search']['fields']['date-before']); + + $form['end_year'] = (int)$tokens[0]; + $form['end_month'] = (int)$tokens[1]; + $form['end_day'] = (int)$tokens[2]; + } + + $form['pictures'] = $page['search']['fields']['pictures']; + $form['high'] = $page['search']['fields']['high']; +} +else +{ + // by default, at page load, we want the selected date to be the current + // date + $form['start_year'] = $form['end_year'] = date('Y'); + $form['start_month'] = $form['end_month'] = date('n'); + $form['start_day'] = $form['end_day'] = date('j'); + $form['pictures'] = 'yes'; + $form['high'] = 'yes'; +} + +// start date +get_day_list('start_day', @$form['start_day']); +get_month_list('start_month', @$form['start_month']); +// end date +get_day_list('end_day', @$form['end_day']); +get_month_list('end_month', @$form['end_month']); + +$template->assign_vars( + array( + 'START_YEAR' => @$form['start_year'], + 'END_YEAR' => @$form['end_year'], + ) + ); + +foreach (array('pictures', 'high') as $block) +{ + foreach (array('yes', 'no', 'only') as $item) + { + $selected = ''; + + if ($item == $form[$block]) + { + $selected = 'selected="selected"'; + } + + $template->assign_block_vars( + $block.'_option', + array( + 'VALUE' => $item, + 'CONTENT' => l10n($item), + 'SELECTED' => $selected, + ) + ); + } +} + +// +-----------------------------------------------------------------------+ +// | html code display | +// +-----------------------------------------------------------------------+ + +$template->assign_var_from_handle('ADMIN_CONTENT', 'history'); +?> Index: /tags/release-1_7_0RC1/admin/images/index.php =================================================================== --- /tags/release-1_7_0RC1/admin/images/index.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/images/index.php (revision 1826) @@ -0,0 +1,35 @@ + Index: /tags/release-1_7_0RC1/admin/include/functions.php =================================================================== --- /tags/release-1_7_0RC1/admin/include/functions.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/include/functions.php (revision 1826) @@ -0,0 +1,2060 @@ + $id) + { + if ($num == 0) + { + $query.= ' + WHERE '; + } + else + { + $query.= ' + OR '; + } + $query.= 'uppercats REGEXP \'(^|,)'.$id.'(,|$)\''; + } + } + else + { + $query.= ' + WHERE id IN ('.wordwrap(implode(', ', $ids), 80, "\n").')'; + } + } + $query.= ' +;'; + $cat_ids = array_unique(array_from_query($query, 'id')); + + if (count($cat_ids) == 0) + { + return false; + } + + // calculate informations about categories retrieved + $query = ' +SELECT category_id, + COUNT(image_id) AS nb_images, + MAX(date_available) AS date_last + FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id + WHERE category_id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").') + GROUP BY category_id +;'; + $result = pwg_query($query); + $datas = array(); + $query_ids = array(); + while ( $row = mysql_fetch_array( $result ) ) + { + array_push($query_ids, $row['category_id']); + + array_push( + $datas, + array( + 'id' => $row['category_id'], + 'date_last' => $row['date_last'], + 'nb_images' => $row['nb_images'] + ) + ); + } + // if all links between a category and elements have disappeared, no line + // is returned but the update must be done ! + foreach (array_diff($cat_ids, $query_ids) as $id) + { + array_push($datas, array('id' => $id, 'nb_images' => 0)); + } + + $fields = array('primary' => array('id'), + 'update' => array('date_last', 'nb_images')); + mass_updates(CATEGORIES_TABLE, $fields, $datas); + + // representative pictures + if (count($cat_ids) > 0) + { + // find all categories where the setted representative is not possible : + // the picture does not exist + $query = ' +SELECT c.id + FROM '.CATEGORIES_TABLE.' AS c LEFT JOIN '.IMAGES_TABLE.' AS i + ON c.representative_picture_id = i.id + WHERE representative_picture_id IS NOT NULL + AND c.id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").') + AND i.id IS NULL +;'; + $wrong_representant = array_from_query($query, 'id'); + + if ($conf['allow_random_representative']) + { + if (count($wrong_representant) > 0) + { + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET representative_picture_id = NULL + WHERE id IN ('.wordwrap(implode(', ', $wrong_representant), 80, "\n").') +;'; + pwg_query($query); + } + } + else + { + $to_null = array(); + $to_rand = array(); + + if (count($wrong_representant) > 0) + { + // among the categories with an unknown representant, we dissociate + // categories containing pictures and categories containing no + // pictures. Indeed, the representant must set to NULL if no picture + // in the category and set to a random picture otherwise. + $query = ' +SELECT id + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.wordwrap(implode(', ', $wrong_representant), 80, "\n").') + AND nb_images = 0 +;'; + $to_null = array_from_query($query, 'id'); + $to_rand = array_diff($wrong_representant, $to_null); + } + + if (count($to_null) > 0) + { + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET representative_picture_id = NULL + WHERE id IN ('.wordwrap(implode(', ', $to_null), 80, "\n").') +;'; + pwg_query($query); + } + + // If the random representant is not allowed, we need to find + // categories with elements and with no representant. Those categories + // must be added to the list of categories to set to a random + // representant. + $query = ' +SELECT id + FROM '.CATEGORIES_TABLE.' + WHERE representative_picture_id IS NULL + AND nb_images != 0 + AND id IN ('.wordwrap(implode(', ', $cat_ids), 80, "\n").') +;'; + $to_rand = + array_unique( + array_merge( + $to_rand, + array_from_query($query, 'id') + ) + ); + + if (count($to_rand) > 0) + { + set_random_representant($to_rand); + } + } + } +} + +function date_convert_back( $date ) +{ + // date arrives at this format : YYYY-MM-DD + // It must be transformed in DD/MM/YYYY + if ( $date != '' ) + { + list($year,$month,$day) = explode( '-', $date ); + return $day.'/'.$month.'/'.$year; + } + else + { + return ''; + } +} + +/** + * returns an array containing sub-directories which can be a category, + * recursive by default + * + * directories nammed "thumbnail", "pwg_high" or "pwg_representative" are + * omitted + * + * @param string $basedir + * @return array + */ +function get_fs_directories($path, $recursive = true) +{ + $dirs = array(); + + if (is_dir($path)) + { + if ($contents = opendir($path)) + { + while (($node = readdir($contents)) !== false) + { + if (is_dir($path.'/'.$node) + and $node != '.' + and $node != '..' + and $node != '.svn' + and $node != 'thumbnail' + and $node != 'pwg_high' + and $node != 'pwg_representative') + { + array_push($dirs, $path.'/'.$node); + if ($recursive) + { + $dirs = array_merge($dirs, get_fs_directories($path.'/'.$node)); + } + } + } + } + } + + return $dirs; +} + +/** + * inserts multiple lines in a table + * + * @param string table_name + * @param array dbfields + * @param array inserts + * @return void + */ +function mass_inserts($table_name, $dbfields, $datas) +{ + if (count($datas) != 0) + { + $first = true; + + $query = 'SHOW VARIABLES LIKE \'max_allowed_packet\';'; + list(, $packet_size) = mysql_fetch_row(pwg_query($query)); + $packet_size = $packet_size - 2000; // The last list of values MUST not exceed 2000 character*/ + $query = ''; + + foreach ($datas as $insert) + { + if (strlen($query) >= $packet_size) + { + $query .= ' +;'; + pwg_query($query); + $first = true; + } + + if ($first) + { + $query = ' + INSERT INTO '.$table_name.' + ('.implode(',', $dbfields).') + VALUES'; + $first = false; + } + else + { + $query .= ' + , '; + } + + $query .= '('; + foreach ($dbfields as $field_id => $dbfield) + { + if ($field_id > 0) + { + $query .= ','; + } + + if (!isset($insert[$dbfield]) or $insert[$dbfield] === '') + { + $query .= 'NULL'; + } + else + { + $query .= "'".$insert[$dbfield]."'"; + } + } + $query .= ')'; + } + + $query .= ' +;'; + pwg_query($query); + } +} + +/** + * updates multiple lines in a table + * + * @param string table_name + * @param array dbfields + * @param array datas + * @return void + */ +function mass_updates($tablename, $dbfields, $datas) +{ + if (count($datas) != 0) + { + // depending on the MySQL version, we use the multi table update or N + // update queries + $query = 'SELECT VERSION() AS version;'; + list($mysql_version) = mysql_fetch_array(pwg_query($query)); + if (count($datas) < 10 or version_compare($mysql_version, '4.0.4') < 0) + { + // MySQL is prior to version 4.0.4, multi table update feature is not + // available + foreach ($datas as $data) + { + $query = ' + UPDATE '.$tablename.' + SET '; + $is_first = true; + foreach ($dbfields['update'] as $key) + { + if (!$is_first) + { + $query.= ",\n "; + } + $query.= $key.' = '; + if (isset($data[$key]) and $data[$key] != '') + { + $query.= '\''.$data[$key].'\''; + } + else + { + $query.= 'NULL'; + } + $is_first = false; + } + $query.= ' + WHERE '; + + $is_first = true; + foreach ($dbfields['primary'] as $key) + { + if (!$is_first) + { + $query.= ' AND '; + } + $query.= $key.' = \''.$data[$key].'\''; + $is_first = false; + } + $query.= ' + ;'; + pwg_query($query); + } + } + else + { + // creation of the temporary table + $query = ' + SHOW FULL COLUMNS FROM '.$tablename.' +;'; + $result = pwg_query($query); + $columns = array(); + $all_fields = array_merge($dbfields['primary'], $dbfields['update']); + while ($row = mysql_fetch_array($result)) + { + if (in_array($row['Field'], $all_fields)) + { + $column = $row['Field']; + $column.= ' '.$row['Type']; + if (!isset($row['Null']) or $row['Null'] == '') + { + $column.= ' NOT NULL'; + } + if (isset($row['Default'])) + { + $column.= " default '".$row['Default']."'"; + } + if (isset($row['Collation']) and $row['Collation'] != 'NULL') + { + $column.= " collate '".$row['Collation']."'"; + } + array_push($columns, $column); + } + } + + $temporary_tablename = $tablename.'_'.micro_seconds(); + + $query = ' + CREATE TABLE '.$temporary_tablename.' + ( + '.implode(",\n", $columns).', + PRIMARY KEY ('.implode(',', $dbfields['primary']).') + ) +;'; + pwg_query($query); + mass_inserts($temporary_tablename, $all_fields, $datas); + // update of images table by joining with temporary table + $query = ' + UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2 + SET '. + implode( + "\n , ", + array_map( + create_function('$s', 'return "t1.$s = t2.$s";'), + $dbfields['update'] + ) + ).' + WHERE '. + implode( + "\n AND ", + array_map( + create_function('$s', 'return "t1.$s = t2.$s";'), + $dbfields['primary'] + ) + ).' + ;'; + pwg_query($query); + $query = ' + DROP TABLE '.$temporary_tablename.' +;'; + pwg_query($query); + } + } +} + +/** + * updates the global_rank of categories under the given id_uppercat + * + * @param int id_uppercat + * @return void + */ +function update_global_rank($id_uppercat = 'all') +{ + $query = ' +SELECT id,rank + FROM '.CATEGORIES_TABLE.' +;'; + $result = pwg_query($query); + $ranks_array = array(); + while ($row = mysql_fetch_array($result)) + { + $ranks_array[$row['id']] = $row['rank']; + } + + // which categories to update ? + $uppercats_array = array(); + + $query = ' +SELECT id,uppercats + FROM '.CATEGORIES_TABLE; + if (is_numeric($id_uppercat)) + { + $query.= ' + WHERE uppercats REGEXP \'(^|,)'.$id_uppercat.'(,|$)\' + AND id != '.$id_uppercat.' +'; + } + $query.= ' +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $uppercats_array[$row['id']] = $row['uppercats']; + } + + $datas = array(); + foreach ($uppercats_array as $id => $uppercats) + { + array_push( + $datas, + array( + 'id' => $id, + 'global_rank' => preg_replace( + '/(\d+)/e', + "\$ranks_array['$1']", + str_replace(',', '.', $uppercats) + ), + ) + ); + } + + mass_updates( + CATEGORIES_TABLE, + array( + 'primary' => array('id'), + 'update' => array('global_rank') + ), + $datas + ); +} + +/** + * change the visible property on a set of categories + * + * @param array categories + * @param string value + * @return void + */ +function set_cat_visible($categories, $value) +{ + if (!in_array($value, array('true', 'false'))) + { + return false; + } + + // unlocking a category => all its parent categories become unlocked + if ($value == 'true') + { + $uppercats = get_uppercat_ids($categories); + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET visible = \'true\' + WHERE id IN ('.implode(',', $uppercats).') +;'; + pwg_query($query); + } + // locking a category => all its child categories become locked + if ($value == 'false') + { + $subcats = get_subcat_ids($categories); + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET visible = \'false\' + WHERE id IN ('.implode(',', $subcats).') +;'; + pwg_query($query); + } +} + +/** + * change the status property on a set of categories : private or public + * + * @param array categories + * @param string value + * @return void + */ +function set_cat_status($categories, $value) +{ + if (!in_array($value, array('public', 'private'))) + { + return false; + } + + // make public a category => all its parent categories become public + if ($value == 'public') + { + $uppercats = get_uppercat_ids($categories); + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET status = \'public\' + WHERE id IN ('.implode(',', $uppercats).') +;'; + pwg_query($query); + } + // make a category private => all its child categories become private + if ($value == 'private') + { + $subcats = get_subcat_ids($categories); + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET status = \'private\' + WHERE id IN ('.implode(',', $subcats).') +;'; + pwg_query($query); + } +} + +/** + * returns all uppercats category ids of the given category ids + * + * @param array cat_ids + * @return array + */ +function get_uppercat_ids($cat_ids) +{ + if (!is_array($cat_ids) or count($cat_ids) < 1) + { + return array(); + } + + $uppercats = array(); + + $query = ' +SELECT uppercats + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', $cat_ids).') +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $uppercats = array_merge($uppercats, + explode(',', $row['uppercats'])); + } + $uppercats = array_unique($uppercats); + + return $uppercats; +} + +/** + * set a new random representant to the categories + * + * @param array categories + */ +function set_random_representant($categories) +{ + $datas = array(); + foreach ($categories as $category_id) + { + $query = ' +SELECT image_id + FROM '.IMAGE_CATEGORY_TABLE.' + WHERE category_id = '.$category_id.' + ORDER BY RAND() + LIMIT 0,1 +;'; + list($representative) = mysql_fetch_array(pwg_query($query)); + + array_push( + $datas, + array( + 'id' => $category_id, + 'representative_picture_id' => $representative, + ) + ); + } + + mass_updates( + CATEGORIES_TABLE, + array( + 'primary' => array('id'), + 'update' => array('representative_picture_id') + ), + $datas + ); +} + +/** + * order categories (update categories.rank and global_rank database fields) + * + * the purpose of this function is to give a rank for all categories + * (insides its sub-category), even the newer that have none at te + * beginning. For this, ordering function selects all categories ordered by + * rank ASC then name ASC for each uppercat. + * + * @returns void + */ +function ordering() +{ + $current_rank = 0; + $current_uppercat = ''; + + $query = ' +SELECT id, if(id_uppercat is null,\'\',id_uppercat) AS id_uppercat + FROM '.CATEGORIES_TABLE.' + ORDER BY id_uppercat,rank,name +;'; + $result = pwg_query($query); + $datas = array(); + while ($row = mysql_fetch_array($result)) + { + if ($row['id_uppercat'] != $current_uppercat) + { + $current_rank = 0; + $current_uppercat = $row['id_uppercat']; + } + $data = array('id' => $row['id'], 'rank' => ++$current_rank); + array_push($datas, $data); + } + + $fields = array('primary' => array('id'), 'update' => array('rank')); + mass_updates(CATEGORIES_TABLE, $fields, $datas); +} + +/** + * returns the fulldir for each given category id + * + * @param array cat_ids + * @return array + */ +function get_fulldirs($cat_ids) +{ + if (count($cat_ids) == 0) + { + return array(); + } + + // caching directories of existing categories + $query = ' +SELECT id, dir + FROM '.CATEGORIES_TABLE.' + WHERE dir IS NOT NULL +;'; + $result = pwg_query($query); + $cat_dirs = array(); + while ($row = mysql_fetch_array($result)) + { + $cat_dirs[$row['id']] = $row['dir']; + } + + // caching galleries_url + $query = ' +SELECT id, galleries_url + FROM '.SITES_TABLE.' +;'; + $result = pwg_query($query); + $galleries_url = array(); + while ($row = mysql_fetch_array($result)) + { + $galleries_url[$row['id']] = $row['galleries_url']; + } + + // categories : id, site_id, uppercats + $categories = array(); + + $query = ' +SELECT id, uppercats, site_id + FROM '.CATEGORIES_TABLE.' + WHERE id IN ( +'.wordwrap(implode(', ', $cat_ids), 80, "\n").') +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + array_push($categories, $row); + } + + // filling $cat_fulldirs + $cat_fulldirs = array(); + foreach ($categories as $category) + { + $uppercats = str_replace(',', '/', $category['uppercats']); + $cat_fulldirs[$category['id']] = $galleries_url[$category['site_id']]; + $cat_fulldirs[$category['id']].= preg_replace('/(\d+)/e', + "\$cat_dirs['$1']", + $uppercats); + } + + return $cat_fulldirs; +} + +/** + * returns an array with all file system files according to + * $conf['file_ext'] + * + * @param string $path + * @param bool recursive + * @return array + */ +function get_fs($path, $recursive = true) +{ + global $conf; + + // because isset is faster than in_array... + if (!isset($conf['flip_picture_ext'])) + { + $conf['flip_picture_ext'] = array_flip($conf['picture_ext']); + } + if (!isset($conf['flip_file_ext'])) + { + $conf['flip_file_ext'] = array_flip($conf['file_ext']); + } + + $fs['elements'] = array(); + $fs['thumbnails'] = array(); + $fs['representatives'] = array(); + $subdirs = array(); + + if (is_dir($path)) + { + if ($contents = opendir($path)) + { + while (($node = readdir($contents)) !== false) + { + if (is_file($path.'/'.$node)) + { + $extension = get_extension($node); + +// if (in_array($extension, $conf['picture_ext'])) + if (isset($conf['flip_picture_ext'][$extension])) + { + if (basename($path) == 'thumbnail') + { + array_push($fs['thumbnails'], $path.'/'.$node); + } + else if (basename($path) == 'pwg_representative') + { + array_push($fs['representatives'], $path.'/'.$node); + } + else + { + array_push($fs['elements'], $path.'/'.$node); + } + } +// else if (in_array($extension, $conf['file_ext'])) + else if (isset($conf['flip_file_ext'][$extension])) + { + array_push($fs['elements'], $path.'/'.$node); + } + } + else if (is_dir($path.'/'.$node) + and $node != '.' + and $node != '..' + and $node != 'pwg_high' + and $recursive) + { + array_push($subdirs, $node); + } + } + } + closedir($contents); + + foreach ($subdirs as $subdir) + { + $tmp_fs = get_fs($path.'/'.$subdir); + + $fs['elements'] = array_merge($fs['elements'], + $tmp_fs['elements']); + + $fs['thumbnails'] = array_merge($fs['thumbnails'], + $tmp_fs['thumbnails']); + + $fs['representatives'] = array_merge($fs['representatives'], + $tmp_fs['representatives']); + } + } + return $fs; +} + +/** + * stupidly returns the current microsecond since Unix epoch + */ +function micro_seconds() +{ + $t1 = explode(' ', microtime()); + $t2 = explode('.', $t1[0]); + $t2 = $t1[1].substr($t2[1], 0, 6); + return $t2; +} + +/** + * synchronize base users list and related users list + * + * compares and synchronizes base users table (USERS_TABLE) with its child + * tables (USER_INFOS_TABLE, USER_ACCESS, USER_CACHE, USER_GROUP) : each + * base user must be present in child tables, users in child tables not + * present in base table must be deleted. + * + * @return void + */ +function sync_users() +{ + global $conf; + + $query = ' +SELECT '.$conf['user_fields']['id'].' AS id + FROM '.USERS_TABLE.' +;'; + $base_users = array_from_query($query, 'id'); + + $query = ' +SELECT user_id + FROM '.USER_INFOS_TABLE.' +;'; + $infos_users = array_from_query($query, 'user_id'); + + // users present in $base_users and not in $infos_users must be added + $to_create = array_diff($base_users, $infos_users); + + if (count($to_create) > 0) + { + $inserts = array(); + + list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); + + foreach ($to_create as $user_id) + { + $insert = array(); + $insert['user_id'] = $user_id; + $insert['status'] = 'normal'; + $insert['template'] = $conf['default_template']; + $insert['nb_image_line'] = $conf['nb_image_line']; + $insert['nb_line_page'] = $conf['nb_line_page']; + $insert['language'] = $conf['default_language']; + $insert['recent_period'] = $conf['recent_period']; + $insert['expand'] = boolean_to_string($conf['auto_expand']); + $insert['show_nb_comments'] = + boolean_to_string($conf['show_nb_comments']); + $insert['show_nb_hits'] = + boolean_to_string($conf['show_nb_hits']); + $insert['maxwidth'] = $conf['default_maxwidth']; + $insert['maxheight'] = $conf['default_maxheight']; + $insert['registration_date'] = $dbnow; + + array_push($inserts, $insert); + } + + mass_inserts(USER_INFOS_TABLE, + array_keys($inserts[0]), + $inserts); + } + + // users present in user related tables must be present in the base user + // table + $tables = array( + USER_MAIL_NOTIFICATION_TABLE, + USER_FEED_TABLE, + USER_INFOS_TABLE, + USER_ACCESS_TABLE, + USER_CACHE_TABLE, + USER_CACHE_CATEGORIES_TABLE, + USER_GROUP_TABLE + ); + + foreach ($tables as $table) + { + $query = ' +SELECT user_id + FROM '.$table.' +;'; + $to_delete = array_diff( + array_from_query($query, 'user_id'), + $base_users + ); + + if (count($to_delete) > 0) + { + $query = ' +DELETE + FROM '.$table.' + WHERE user_id in ('.implode(',', $to_delete).') +;'; + pwg_query($query); + } + } +} + +/** + * updates categories.uppercats field based on categories.id + + * categories.id_uppercat + * + * @return void + */ +function update_uppercats() +{ + $uppercat_ids = array(); + + $query = ' +SELECT id, id_uppercat + FROM '.CATEGORIES_TABLE.' +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $uppercat_ids[$row['id']] = + !empty($row['id_uppercat']) ? $row['id_uppercat'] : 'NULL'; + } + + // uppercats array associates a category id to the list of uppercats id. + $uppercats = array(); + + foreach (array_keys($uppercat_ids) as $id) + { + $uppercats[$id] = array(); + + $uppercat = $id; + + while ($uppercat != 'NULL') + { + array_push($uppercats[$id], $uppercat); + $uppercat = $uppercat_ids[$uppercat]; + } + } + + $datas = array(); + + foreach ($uppercats as $id => $list) + { + array_push( + $datas, + array( + 'id' => $id, + 'uppercats' => implode(',', array_reverse($list)) + ) + ); + } + + $fields = array('primary' => array('id'), 'update' => array('uppercats')); + mass_updates(CATEGORIES_TABLE, $fields, $datas); +} + +/** + * update images.path field + * + * @return void + */ +function update_path() +{ + $query = ' +SELECT DISTINCT(storage_category_id) + FROM '.IMAGES_TABLE.' +;'; + $cat_ids = array_from_query($query, 'storage_category_id'); + $fulldirs = get_fulldirs($cat_ids); + + foreach ($cat_ids as $cat_id) + { + $query = ' +UPDATE '.IMAGES_TABLE.' + SET path = CONCAT(\''.$fulldirs[$cat_id].'\',\'/\',file) + WHERE storage_category_id = '.$cat_id.' +;'; + pwg_query($query); + } +} + +/** + * update images.average_rate field + * param int $element_id optional, otherwise applies to all + * @return void + */ +function update_average_rate( $element_id=-1 ) +{ + $query = ' +SELECT element_id, + ROUND(AVG(rate),2) AS average_rate + FROM '.RATE_TABLE; + if ( $element_id != -1 ) + { + $query .= ' WHERE element_id=' . $element_id; + } + $query .= ' GROUP BY element_id;'; + + $result = pwg_query($query); + + $datas = array(); + + while ($row = mysql_fetch_array($result)) + { + array_push( + $datas, + array( + 'id' => $row['element_id'], + 'average_rate' => $row['average_rate'] + ) + ); + } + + mass_updates( + IMAGES_TABLE, + array( + 'primary' => array('id'), + 'update' => array('average_rate') + ), + $datas + ); + + $query=' +SELECT id FROM '.IMAGES_TABLE .' + LEFT JOIN '.RATE_TABLE.' ON id=element_id + WHERE element_id IS NULL AND average_rate IS NOT NULL'; + if ( $element_id != -1 ) + { + $query .= ' AND id=' . $element_id; + } + $to_update = array_from_query( $query, 'id'); + + if ( !empty($to_update) ) + { + $query=' +UPDATE '.IMAGES_TABLE .' + SET average_rate=NULL + WHERE id IN (' . implode(',',$to_update) . ')'; + pwg_query($query); + } +} + +/** + * change the parent category of the given categories. The categories are + * supposed virtual. + * + * @param array category identifiers + * @param int parent category identifier + * @return void + */ +function move_categories($category_ids, $new_parent = -1) +{ + global $page; + + if (count($category_ids) == 0) + { + return; + } + + $new_parent = $new_parent < 1 ? 'NULL' : $new_parent; + + $categories = array(); + + $query = ' +SELECT id, id_uppercat, status, uppercats + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', $category_ids).') +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + $categories[$row['id']] = + array( + 'parent' => empty($row['id_uppercat']) ? 'NULL' : $row['id_uppercat'], + 'status' => $row['status'], + 'uppercats' => $row['uppercats'] + ); + } + + // is the movement possible? The movement is impossible if you try to move + // a category in a sub-category or itself + if ('NULL' != $new_parent) + { + $query = ' +SELECT uppercats + FROM '.CATEGORIES_TABLE.' + WHERE id = '.$new_parent.' +;'; + list($new_parent_uppercats) = mysql_fetch_row(pwg_query($query)); + + foreach ($categories as $category) + { + // technically, you can't move a category with uppercats 12,125,13,14 + // into a new parent category with uppercats 12,125,13,14,24 + if (preg_match('/^'.$category['uppercats'].'/', $new_parent_uppercats)) + { + array_push( + $page['errors'], + l10n('You cannot move a category in its own sub category') + ); + return; + } + } + } + + $tables = + array( + USER_ACCESS_TABLE => 'user_id', + GROUP_ACCESS_TABLE => 'group_id' + ); + + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET id_uppercat = '.$new_parent.' + WHERE id IN ('.implode(',', $category_ids).') +;'; + pwg_query($query); + + update_uppercats(); + ordering(); + update_global_rank(); + + // status and related permissions management + if ('NULL' == $new_parent) + { + $parent_status = 'public'; + } + else + { + $query = ' +SELECT status + FROM '.CATEGORIES_TABLE.' + WHERE id = '.$new_parent.' +;'; + list($parent_status) = mysql_fetch_row(pwg_query($query)); + } + + if ('private' == $parent_status) + { + foreach ($categories as $cat_id => $category) + { + switch ($category['status']) + { + case 'public' : + { + set_cat_status(array($cat_id), 'private'); + break; + } + case 'private' : + { + $subcats = get_subcat_ids(array($cat_id)); + + foreach ($tables as $table => $field) + { + $query = ' +SELECT '.$field.' + FROM '.$table.' + WHERE cat_id = '.$cat_id.' +;'; + $category_access = array_from_query($query, $field); + + $query = ' +SELECT '.$field.' + FROM '.$table.' + WHERE cat_id = '.$new_parent.' +;'; + $parent_access = array_from_query($query, $field); + + $to_delete = array_diff($parent_access, $category_access); + + if (count($to_delete) > 0) + { + $query = ' +DELETE FROM '.$table.' + WHERE '.$field.' IN ('.implode(',', $to_delete).') + AND cat_id IN ('.implode(',', $subcats).') +;'; + pwg_query($query); + } + } + break; + } + } + } + } + + array_push( + $page['infos'], + sprintf( + l10n('%d categories moved'), + count($categories) + ) + ); +} + +/** + * create a virtual category + * + * @param string category name + * @param int parent category id + * @return array with ('info' and 'id') or ('error') key + */ +function create_virtual_category($category_name, $parent_id=null) +{ + global $conf; + + // is the given category name only containing blank spaces ? + if (preg_match('/^\s*$/', $category_name)) + { + return array('error' => l10n('cat_error_name')); + } + + $parent_id = !empty($parent_id) ? $parent_id : 'NULL'; + + $query = ' +SELECT MAX(rank) + FROM '.CATEGORIES_TABLE.' + WHERE id_uppercat '.(is_numeric($parent_id) ? '= '.$parent_id : 'IS NULL').' +;'; + list($current_rank) = mysql_fetch_array(pwg_query($query)); + + $insert = array( + 'name' => $category_name, + 'rank' => ++$current_rank, + 'commentable' => boolean_to_string($conf['newcat_default_commentable']), + 'uploadable' => 'false', + ); + + if ($parent_id != 'NULL') + { + $query = ' +SELECT id, uppercats, global_rank, visible, status + FROM '.CATEGORIES_TABLE.' + WHERE id = '.$parent_id.' +;'; + $parent = mysql_fetch_array(pwg_query($query)); + + $insert{'id_uppercat'} = $parent{'id'}; + $insert{'global_rank'} = $parent{'global_rank'}.'.'.$insert{'rank'}; + + // at creation, must a category be visible or not ? Warning : if the + // parent category is invisible, the category is automatically create + // invisible. (invisible = locked) + if ('false' == $parent['visible']) + { + $insert{'visible'} = 'false'; + } + else + { + $insert{'visible'} = boolean_to_string($conf['newcat_default_visible']); + } + + // at creation, must a category be public or private ? Warning : if the + // parent category is private, the category is automatically create + // private. + if ('private' == $parent['status']) + { + $insert{'status'} = 'private'; + } + else + { + $insert{'status'} = $conf['newcat_default_status']; + } + } + else + { + $insert{'visible'} = boolean_to_string($conf['newcat_default_visible']); + $insert{'status'} = $conf['newcat_default_status']; + $insert{'global_rank'} = $insert{'rank'}; + } + + // we have then to add the virtual category + mass_inserts( + CATEGORIES_TABLE, + array( + 'site_id', 'name', 'id_uppercat', 'rank', 'commentable', + 'uploadable', 'visible', 'status', 'global_rank', + ), + array($insert) + ); + + $inserted_id = mysql_insert_id(); + + $query = ' +UPDATE + '.CATEGORIES_TABLE.' + SET uppercats = \''. + (isset($parent) ? $parent{'uppercats'}.',' : ''). + $inserted_id. + '\' + WHERE id = '.$inserted_id.' +;'; + pwg_query($query); + + return array( + 'info' => l10n('cat_virtual_added'), + 'id' => $inserted_id, + ); +} + +/** + * Set tags to an image. Warning: given tags are all tags associated to the + * image, not additionnal tags. + * + * @param array tag ids + * @param int image id + * @return void + */ +function set_tags($tags, $image_id) +{ + $query = ' +DELETE + FROM '.IMAGE_TAG_TABLE.' + WHERE image_id = '.$image_id.' +;'; + pwg_query($query); + + if (count($tags) > 0) + { + $inserts = array(); + foreach ($tags as $tag_id) + { + array_push( + $inserts, + array( + 'tag_id' => $tag_id, + 'image_id' => $image_id + ) + ); + } + mass_inserts( + IMAGE_TAG_TABLE, + array_keys($inserts[0]), + $inserts + ); + } +} + +/** + * Add new tags to a set of images. + * + * @param array tag ids + * @param array image ids + * @return void + */ +function add_tags($tags, $images) +{ + if (count($tags) == 0 or count($tags) == 0) + { + return; + } + + // we can't insert twice the same {image_id,tag_id} so we must first + // delete lines we'll insert later + $query = ' +DELETE + FROM '.IMAGE_TAG_TABLE.' + WHERE image_id IN ('.implode(',', $images).') + AND tag_id IN ('.implode(',', $tags).') +;'; + pwg_query($query); + + $inserts = array(); + foreach ($images as $image_id) + { + foreach ($tags as $tag_id) + { + array_push( + $inserts, + array( + 'image_id' => $image_id, + 'tag_id' => $tag_id, + ) + ); + } + } + mass_inserts( + IMAGE_TAG_TABLE, + array_keys($inserts[0]), + $inserts + ); +} + +function tag_id_from_tag_name($tag_name) +{ + global $page; + + if (isset($page['tag_id_from_tag_name_cache'][$tag_name])) + { + return $page['tag_id_from_tag_name_cache'][$tag_name]; + } + + // does the tag already exists? + $query = ' +SELECT id + FROM '.TAGS_TABLE.' + WHERE name = \''.$tag_name.'\' +;'; + $existing_tags = array_from_query($query, 'id'); + + if (count($existing_tags) == 0) + { + mass_inserts( + TAGS_TABLE, + array('name', 'url_name'), + array( + array( + 'name' => $tag_name, + 'url_name' => str2url($tag_name), + ) + ) + ); + + $page['tag_id_from_tag_name_cache'][$tag_name] = mysql_insert_id(); + } + else + { + $page['tag_id_from_tag_name_cache'][$tag_name] = $existing_tags[0]; + } + + return $page['tag_id_from_tag_name_cache'][$tag_name]; +} + +function set_tags_of($tags_of) +{ + if (count($tags_of) > 0) + { + $query = ' +DELETE + FROM '.IMAGE_TAG_TABLE.' + WHERE image_id IN ('.implode(',', array_keys($tags_of)).') +;'; + pwg_query($query); + + $inserts = array(); + + foreach ($tags_of as $image_id => $tag_ids) + { + foreach ($tag_ids as $tag_id) + { + array_push( + $inserts, + array( + 'image_id' => $image_id, + 'tag_id' => $tag_id, + ) + ); + } + } + + mass_inserts( + IMAGE_TAG_TABLE, + array_keys($inserts[0]), + $inserts + ); + } +} + +/** + * Do maintenance on all PWG tables + * + * @return nono + */ +function do_maintenance_all_tables() +{ + global $prefixeTable; + + $all_tables = array(); + + // List all tables + $query = 'SHOW TABLES LIKE \''.$prefixeTable.'%\';'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + array_push($all_tables, $row[0]); + } + + // Repair all tables + $query = 'REPAIR TABLE '.implode(', ', $all_tables).';'; + pwg_query($query); + + // Re-Order all tables + foreach ($all_tables as $table_name) + { + $all_primary_key = array(); + + $query = 'DESC '.$table_name.';'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + if ($row['Key'] == 'PRI') + { + array_push($all_primary_key, $row['Field']); + } + } + + if (count($all_primary_key) != 0) + { + $query = 'ALTER TABLE '.$table_name.' ORDER BY '.implode(', ', $all_primary_key).';'; + pwg_query($query); + } + } + + // Optimize all tables + $query = 'OPTIMIZE TABLE '.implode(', ', $all_tables).';'; + pwg_query($query); + +} + +/** + * Associate a list of images to a list of categories. + * + * The function will not duplicate links + * + * @param array images + * @param array categories + * @return void + */ +function associate_images_to_categories($images, $categories) +{ + if (count($images) == 0 + or count($categories) == 0) + { + return false; + } + + $query = ' +DELETE + FROM '.IMAGE_CATEGORY_TABLE.' + WHERE image_id IN ('.implode(',', $images).') + AND category_id IN ('.implode(',', $categories).') +;'; + pwg_query($query); + + $inserts = array(); + foreach ($categories as $category_id) + { + foreach ($images as $image_id) + { + array_push( + $inserts, + array( + 'image_id' => $image_id, + 'category_id' => $category_id, + ) + ); + } + } + + mass_inserts( + IMAGE_CATEGORY_TABLE, + array_keys($inserts[0]), + $inserts + ); + + update_category($categories); +} + +/** + * Associate images associated to a list of source categories to a list of + * destination categories. + * + * @param array sources + * @param array destinations + * @return void + */ +function associate_categories_to_categories($sources, $destinations) +{ + if (count($sources) == 0) + { + return false; + } + + $query = ' +SELECT image_id + FROM '.IMAGE_CATEGORY_TABLE.' + WHERE category_id IN ('.implode(',', $sources).') +;'; + $images = array_from_query($query, 'image_id'); + + associate_images_to_categories($images, $destinations); +} + +/** + * Create an XML file with PhpWebGallery informations about a list of + * pictures. + * + * The goal of the export feature is to make easier the reading of + * informations related to pictures outside of PhpWebGallery. + * + * @param array image_ids + */ +function export_pwg_data($image_ids) +{ + global $conf; + + if (count($image_ids) == 0) + { + return; + } + + $fp = fopen($conf['export_file'], 'w'); + $xml_string = '
'. + l10n('No tag defined. Use Administration>Pictures>Tags'). + '
'; +} + +$template->assign_vars( + array( + 'U_SYNC' => + PHPWG_ROOT_PATH.'admin.php?page=picture_modify'. + '&image_id='.$_GET['image_id']. + (isset($_GET['cat_id']) ? '&cat_id='.$_GET['cat_id'] : ''). + '&sync_metadata=1', + + 'PATH'=>$row['path'], + + 'TN_SRC' => get_thumbnail_url($row), + + 'NAME' => + isset($_POST['name']) ? + stripslashes($_POST['name']) : @$row['name'], + + 'DIMENSIONS' => @$row['width'].' * '.@$row['height'], + + 'FILESIZE' => @$row['filesize'].' KB', + + 'REGISTRATION_DATE' => + format_date($row['date_available'], 'mysql_datetime', false), + + 'AUTHOR' => isset($_POST['author']) ? $_POST['author'] : @$row['author'], + + 'CREATION_DATE' => $date, + + 'TAG_SELECTION' => $tag_selection, + + 'DESCRIPTION' => + isset($_POST['description']) ? + stripslashes($_POST['description']) : @$row['comment'], + + 'F_ACTION' => + PHPWG_ROOT_PATH.'admin.php' + .get_query_string_diff(array('sync_metadata')) + ) + ); + +// creation date +unset($day, $month, $year); + +if (isset($_POST['date_creation_action']) + and 'set' == $_POST['date_creation_action']) +{ + foreach (array('day', 'month', 'year') as $varname) + { + $$varname = $_POST['date_creation_'.$varname]; + } +} +else if (isset($row['date_creation']) and !empty($row['date_creation'])) +{ + list($year, $month, $day) = explode('-', $row['date_creation']); +} +else +{ + list($year, $month, $day) = array('', 0, 0); +} +get_day_list('date_creation_day', $day); +get_month_list('date_creation_month', $month); +$template->assign_vars(array('DATE_CREATION_YEAR_VALUE' => $year)); + +$query = ' +SELECT category_id, uppercats + FROM '.IMAGE_CATEGORY_TABLE.' AS ic + INNER JOIN '.CATEGORIES_TABLE.' AS c + ON c.id = ic.category_id + WHERE image_id = '.$_GET['image_id'].' +;'; +$result = pwg_query($query); + +if (mysql_num_rows($result) > 1) +{ + $template->assign_block_vars('links', array()); +} + +while ($row = mysql_fetch_array($result)) +{ + $name = + get_cat_display_name_cache( + $row['uppercats'], + PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id=', + false + ); + + if ($row['category_id'] == $storage_category_id) + { + $template->assign_vars(array('STORAGE_CATEGORY' => $name)); + } + else + { + $template->assign_block_vars('links.category', array('NAME' => $name)); + } +} + +// jump to link +// +// 1. find all linked categories that are reachable for the current user. +// 2. if a category is available in the URL, use it if reachable +// 3. if URL category not available or reachable, use the first reachable +// linked category +// 4. if no category reachable, no jumpto link + +$query = ' +SELECT category_id + FROM '.IMAGE_CATEGORY_TABLE.' + WHERE image_id = '.$_GET['image_id'].' +;'; + +$authorizeds = array_diff( + array_from_query($query, 'category_id'), + explode( + ',', + calculate_permissions($user['id'], $user['status']) + ) + ); + +if (isset($_GET['cat_id']) + and in_array($_GET['cat_id'], $authorizeds)) +{ + $url_img = make_picture_url( + array( + 'image_id' => $_GET['image_id'], + 'image_file' => $image_file, + 'category' => $_GET['cat_id'], + ) + ); +} +else +{ + foreach ($authorizeds as $category) + { + $url_img = make_picture_url( + array( + 'image_id' => $_GET['image_id'], + 'image_file' => $image_file, + 'category' => $category, + ) + ); + break; + } +} + +if (isset($url_img)) +{ + $template->assign_block_vars( + 'jumpto', + array( + 'URL' => $url_img + ) + ); +} + +// associate to another category ? +$query = ' +SELECT id,name,uppercats,global_rank + FROM '.CATEGORIES_TABLE.' + INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = category_id + WHERE image_id = '.$_GET['image_id'].' + AND id != '.$storage_category_id.' +;'; +display_select_cat_wrapper($query, array(), 'associated_option'); + +$result = pwg_query($query); +$associateds = array($storage_category_id); +while ($row = mysql_fetch_array($result)) +{ + array_push($associateds, $row['id']); +} +$query = ' +SELECT id,name,uppercats,global_rank + FROM '.CATEGORIES_TABLE.' + WHERE id NOT IN ('.implode(',', $associateds).') +;'; +display_select_cat_wrapper($query, array(), 'dissociated_option'); + +// representing +$query = ' +SELECT id,name,uppercats,global_rank + FROM '.CATEGORIES_TABLE.' + WHERE representative_picture_id = '.$_GET['image_id'].' +;'; +display_select_cat_wrapper($query, array(), 'elected_option'); + +$query = ' +SELECT id,name,uppercats,global_rank + FROM '.CATEGORIES_TABLE.' + WHERE representative_picture_id != '.$_GET['image_id'].' + OR representative_picture_id IS NULL +;'; +display_select_cat_wrapper($query, array(), 'dismissed_option'); + +//----------------------------------------------------------- sending html code + +$template->assign_var_from_handle('ADMIN_CONTENT', 'picture_modify'); +?> Index: /tags/release-1_7_0RC1/admin/plugin.php =================================================================== --- /tags/release-1_7_0RC1/admin/plugin.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/plugin.php (revision 1826) @@ -0,0 +1,67 @@ + Index: /tags/release-1_7_0RC1/admin/plugins.php =================================================================== --- /tags/release-1_7_0RC1/admin/plugins.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/plugins.php (revision 1826) @@ -0,0 +1,259 @@ +set_filenames(array('plugins' => 'admin/plugins.tpl')); + +$num=0; +foreach( $fs_plugins as $plugin_id => $fs_plugin ) +{ + $display_name = $fs_plugin['name']; + if ( !empty($fs_plugin['uri']) ) + { + $display_name=''.$display_name.''; + } + $template->assign_block_vars( 'plugins.plugin', + array( + 'NAME' => $display_name, + 'VERSION' => $fs_plugin['version'], + 'DESCRIPTION' => $fs_plugin['description'], + 'CLASS' => ($num++ % 2 == 1) ? 'row2' : 'row1', + ) + ); + + + $action_url = $my_base_url.'&plugin='.$plugin_id; + if ( isset($db_plugins_by_id[$plugin_id]) ) + { // already in the database + // MAYBE TODO HERE: check for the version and propose upgrade action + switch ($db_plugins_by_id[$plugin_id]['state']) + { + case 'active': + $template->assign_block_vars( 'plugins.plugin.action', + array( + 'U_ACTION' => $action_url . '&action=deactivate', + 'L_ACTION' => l10n('Deactivate'), + ) + ); + break; + case 'inactive': + $template->assign_block_vars( 'plugins.plugin.action', + array( + 'U_ACTION' => $action_url . '&action=activate', + 'L_ACTION' => l10n('Activate'), + ) + ); + $template->assign_block_vars( 'plugins.plugin.action', + array( + 'U_ACTION' => $action_url . '&action=uninstall', + 'L_ACTION' => l10n('Uninstall'), + ) + ); + break; + } + } + else + { + $template->assign_block_vars( 'plugins.plugin.action', + array( + 'U_ACTION' => $action_url . '&action=install', + 'L_ACTION' => l10n('Install'), + ) + ); + } +} + +$missing_plugin_ids = array_diff( + array_keys($db_plugins_by_id), array_keys($fs_plugins) + ); +foreach( $missing_plugin_ids as $plugin_id ) +{ + $template->assign_block_vars( 'plugins.plugin', + array( + 'NAME' => $plugin_id, + 'VERSION' => $db_plugins_by_id[$plugin_id]['version'], + 'DESCRIPTION' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !", + 'CLASS' => ($num++ % 2 == 1) ? 'row2' : 'row1', + ) + ); + $action_url = $my_base_url.'&plugin='.$plugin_id; + $template->assign_block_vars( 'plugins.plugin.action', + array( + 'U_ACTION' => $action_url . '&action=uninstall', + 'L_ACTION' => l10n('Uninstall'), + ) + ); + +} + +$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins'); +?> Index: /tags/release-1_7_0RC1/admin/profile.php =================================================================== --- /tags/release-1_7_0RC1/admin/profile.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/profile.php (revision 1826) @@ -0,0 +1,46 @@ +set_filename('profile', 'admin/profile.tpl'); +$template->assign_var_from_handle('ADMIN_CONTENT', 'profile'); +?> Index: /tags/release-1_7_0RC1/admin/rating.php =================================================================== --- /tags/release-1_7_0RC1/admin/rating.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/rating.php (revision 1826) @@ -0,0 +1,288 @@ + '.$conf['guest_id']; + } + elseif ($_GET['users'] == 'guest') + { + $page['user_filter'] = ' AND r.user_id = '.$conf['guest_id']; + } +} + +if (isset($_GET['del']) and !is_adviser()) +{ + $del_params = urldecode( $_GET['del'] ); + parse_str($del_params, $vars); + if ( !is_numeric($vars['e']) or !is_numeric($vars['u']) ) + { + die('Hacking attempt'); + } + $query = ' +DELETE FROM '. RATE_TABLE .' +WHERE element_id=' . $vars['e'] . ' +AND user_id=' . $vars['u'] . ' +AND anonymous_id=\'' . $vars['a'] . '\' +;'; + pwg_query($query); + update_average_rate( $vars['e'] ); +} + +$users = array(); +$query = ' +SELECT '.$conf['user_fields']['username'].' as username, '.$conf['user_fields']['id'].' as id + FROM '.USERS_TABLE.' +;'; +$result = pwg_query($query); +while ($row = mysql_fetch_array($result)) +{ + $users[$row['id']]=$row['username']; +} + + +$query = 'SELECT COUNT(DISTINCT(i.id)) +FROM '.RATE_TABLE.' AS r, '.IMAGES_TABLE.' AS i +WHERE r.element_id=i.id'. $page['user_filter'] . +';'; +list($nb_images) = mysql_fetch_row(pwg_query($query)); + + +// +-----------------------------------------------------------------------+ +// | template init | +// +-----------------------------------------------------------------------+ + +$template->set_filenames(array('rating'=>'admin/rating.tpl')); + +$template->assign_vars( + array( + 'NAVBAR' => create_navigation_bar( + PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start','del')), + $nb_images, + $start, + $elements_per_page + ) + ) + ); + + +$template->assign_vars( + array( + 'F_ACTION' => PHPWG_ROOT_PATH.'admin.php', + 'DISPLAY' => $elements_per_page, + 'NB_ELEMENTS' => $nb_images + ) + ); + +$available_order_by= array( + array(l10n('Rate date'), 'recently_rated DESC'), + array(l10n('Average rate'), 'average_rate DESC'), + array(l10n('Number of rates'), 'nb_rates DESC'), + array(l10n('Sum of rates'), 'sum_rates DESC'), + array(l10n('Controversy'), 'std_rates DESC'), + array(l10n('File name'), 'file DESC'), + array(l10n('Creation date'), 'date_creation DESC'), + array(l10n('Post date'), 'date_available DESC'), + + ); + +for ($i=0; $i'; print_r($_POST); echo ''; + $template->assign_vars( + array( + 'ADVISER_YES' => 'true' == (isset($_POST['adviser']) and $_POST['adviser']) ? 'checked="checked"' : '', + 'ADVISER_NO' => 'false' == (isset($_POST['adviser']) and $_POST['adviser']) ? 'checked="checked"' : '', + 'NB_IMAGE_LINE' => $_POST['nb_image_line'], + 'NB_LINE_PAGE' => $_POST['nb_line_page'], + 'MAXWIDTH' => $_POST['maxwidth'], + 'MAXHEIGHT' => $_POST['maxheight'], + 'RECENT_PERIOD' => $_POST['recent_period'], + 'EXPAND_YES' => 'true' == $_POST['expand'] ? 'checked="checked"' : '', + 'EXPAND_NO' => 'false' == $_POST['expand'] ? 'checked="checked"' : '', + 'SHOW_NB_COMMENTS_YES' => + 'true' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', + 'SHOW_NB_COMMENTS_NO' => + 'false' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', + 'SHOW_NB_HITS_YES' => + 'true' == $_POST['show_nb_hits'] ? 'checked="checked"' : '', + 'SHOW_NB_HITS_NO' => + 'false' == $_POST['show_nb_hits'] ? 'checked="checked"' : '', + 'ENABLED_HIGH_YES' => 'true' == $_POST['enabled_high'] ? 'checked="checked"' : '', + 'ENABLED_HIGH_NO' => 'false' == $_POST['enabled_high'] ? 'checked="checked"' : '', + )); +} +else +{ + $template->assign_vars( + array( + 'NB_IMAGE_LINE' => $conf['nb_image_line'], + 'NB_LINE_PAGE' => $conf['nb_line_page'], + 'MAXWIDTH' => @$conf['default_maxwidth'], + 'MAXHEIGHT' => @$conf['default_maxheight'], + 'RECENT_PERIOD' => $conf['recent_period'], + )); +} + +$blockname = 'template_option'; + +foreach (get_pwg_themes() as $pwg_template) +{ + if (isset($_POST['pref_submit'])) + { + $selected = $_POST['template']==$pwg_template ? 'selected="selected"' : ''; + } + else if ($conf['default_template'] == $pwg_template) + { + $selected = 'selected="selected"'; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE'=> $pwg_template, + 'CONTENT' => $pwg_template, + 'SELECTED' => $selected + )); +} + +$blockname = 'language_option'; + +foreach (get_languages() as $language_code => $language_name) +{ + if (isset($_POST['pref_submit'])) + { + $selected = $_POST['language']==$language_code ? 'selected="selected"':''; + } + else if ($conf['default_language'] == $language_code) + { + $selected = 'selected="selected"'; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE'=> $language_code, + 'CONTENT' => $language_name, + 'SELECTED' => $selected + )); +} + +$blockname = 'pref_status_option'; + +foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) +{ + if (isset($_POST['pref_submit'])) + { + $selected = $_POST['status'] == $status ? 'selected="selected"' : ''; + } + else if ('normal' == $status) + { + $selected = 'selected="selected"'; + } + else + { + $selected = ''; + } + + // Only status <= can be assign + if (is_autorize_status(get_access_type_status($status))) + { + $template->assign_block_vars( + $blockname, + array( + 'VALUE' => $status, + 'CONTENT' => $lang['user_status_'.$status], + 'SELECTED' => $selected + )); + } +} + +// associate +$blockname = 'associate_option'; + +$template->assign_block_vars( + $blockname, + array( + 'VALUE'=> -1, + 'CONTENT' => '------------', + 'SELECTED' => '' + )); + +foreach ($groups as $group_id => $group_name) +{ + if (isset($_POST['pref_submit'])) + { + $selected = $_POST['associate'] == $group_id ? 'selected="selected"' : ''; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE' => $group_id, + 'CONTENT' => $group_name, + 'SELECTED' => $selected + )); +} + +// dissociate +$blockname = 'dissociate_option'; + +$template->assign_block_vars( + $blockname, + array( + 'VALUE'=> -1, + 'CONTENT' => '------------', + 'SELECTED' => '' + )); + +foreach ($groups as $group_id => $group_name) +{ + if (isset($_POST['pref_submit'])) + { + $selected = $_POST['dissociate'] == $group_id ? 'selected="selected"' : ''; + } + else + { + $selected = ''; + } + + $template->assign_block_vars( + $blockname, + array( + 'VALUE' => $group_id, + 'CONTENT' => $group_name, + 'SELECTED' => $selected + )); +} + +// +-----------------------------------------------------------------------+ +// | navigation bar | +// +-----------------------------------------------------------------------+ + +$url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start')); + +$navbar = create_navigation_bar( + $url, + count($page['filtered_users']), + $start, + $conf['users_page'] + ); + +$template->assign_vars(array('NAVBAR' => $navbar)); + +// +-----------------------------------------------------------------------+ +// | user list | +// +-----------------------------------------------------------------------+ + +$profile_url = get_root_url().'admin.php?page=profile&user_id='; +$perm_url = get_root_url().'admin.php?page=user_perm&user_id='; + +foreach ($page['filtered_users'] as $num => $local_user) +{ + // simulate LIMIT $start, $conf['users_page'] + if ($num < $start) + { + continue; + } + if ($num >= $start + $conf['users_page']) + { + break; + } + + $groups_string = preg_replace( + '/(\d+)/e', + "\$groups['$1']", + implode( + ', ', + $local_user['groups'] + ) + ); + + if (isset($_POST['pref_submit']) + and isset($_POST['selection']) + and in_array($local_user['id'], $_POST['selection'])) + { + $checked = 'checked="checked"'; + } + else + { + $checked = ''; + } + + $template->assign_block_vars( + 'user', + array( + 'CLASS' => ($num % 2 == 1) ? 'row2' : 'row1', + 'ID' => $local_user['id'], + 'CHECKED' => $checked, + 'U_PROFILE' => $profile_url.$local_user['id'], + 'U_PERM' => $perm_url.$local_user['id'], + 'USERNAME' => $local_user['username'], + 'STATUS' => $lang['user_status_'.$local_user['status']].(($local_user['adviser'] == 'true') ? ' ['.$lang['adviser'].']' : ''), + 'EMAIL' => get_email_address_as_display_text($local_user['email']), + 'GROUPS' => $groups_string, + 'PROPERTIES' => (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) ? $lang['is_high_enabled'] : $lang['is_high_disabled'] + ) + ); +} + +// +-----------------------------------------------------------------------+ +// | html code display | +// +-----------------------------------------------------------------------+ + +$template->assign_var_from_handle('ADMIN_CONTENT', 'user_list'); +?> Index: /tags/release-1_7_0RC1/admin/user_perm.php =================================================================== --- /tags/release-1_7_0RC1/admin/user_perm.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/user_perm.php (revision 1826) @@ -0,0 +1,231 @@ + 0) +{ + // if you forbid access to a category, all sub-categories become + // automatically forbidden + $subcats = get_subcat_ids($_POST['cat_true']); + $query = ' +DELETE FROM '.USER_ACCESS_TABLE.' + WHERE user_id = '.$page['user'].' + AND cat_id IN ('.implode(',', $subcats).') +;'; + pwg_query($query); +} +else if (isset($_POST['trueify']) + and isset($_POST['cat_false']) + and count($_POST['cat_false']) > 0) +{ + $uppercats = get_uppercat_ids($_POST['cat_false']); + $private_uppercats = array(); + + $query = ' +SELECT id + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', $uppercats).') + AND status = \'private\' +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + array_push($private_uppercats, $row['id']); + } + + // retrying to authorize a category which is already authorized may cause + // an error (in SQL statement), so we need to know which categories are + // accesible + $authorized_ids = array(); + + $query = ' +SELECT cat_id + FROM '.USER_ACCESS_TABLE.' + WHERE user_id = '.$page['user'].' +;'; + $result = pwg_query($query); + + while ($row = mysql_fetch_array($result)) + { + array_push($authorized_ids, $row['cat_id']); + } + + $inserts = array(); + $to_autorize_ids = array_diff($private_uppercats, $authorized_ids); + foreach ($to_autorize_ids as $to_autorize_id) + { + array_push($inserts, array('user_id' => $page['user'], + 'cat_id' => $to_autorize_id)); + } + + mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $inserts); +} + +// +-----------------------------------------------------------------------+ +// | template init | +// +-----------------------------------------------------------------------+ + +$template->set_filenames( + array( + 'user_perm' => 'admin/user_perm.tpl', + 'double_select' => 'admin/double_select.tpl' + ) + ); + +$template->assign_vars( + array( + 'TITLE' => + sprintf( + l10n('Manage permissions for user "%s"'), + get_username($page['user'] + ) + ), + 'L_CAT_OPTIONS_TRUE'=>$lang['authorized'], + 'L_CAT_OPTIONS_FALSE'=>$lang['forbidden'], + + 'F_ACTION' => + PHPWG_ROOT_PATH. + 'admin.php?page=user_perm'. + '&user_id='.$page['user'] + ) + ); + + +// retrieve category ids authorized to the groups the user belongs to +$group_authorized = array(); + +$query = ' +SELECT DISTINCT cat_id, c.uppercats, c.global_rank + FROM '.USER_GROUP_TABLE.' AS ug + INNER JOIN '.GROUP_ACCESS_TABLE.' AS ga + ON ug.group_id = ga.group_id + INNER JOIN '.CATEGORIES_TABLE.' AS c + ON c.id = ga.cat_id + WHERE ug.user_id = '.$page['user'].' +;'; +$result = pwg_query($query); + +if (mysql_num_rows($result) > 0) +{ + $template->assign_block_vars('groups', array()); + + $cats = array(); + while ($row = mysql_fetch_array($result)) + { + array_push($cats, $row); + array_push($group_authorized, $row['cat_id']); + } + usort($cats, 'global_rank_compare'); + + foreach ($cats as $category) + { + $template->assign_block_vars( + 'groups.category', + array( + 'NAME' => get_cat_display_name_cache($category['uppercats'], null, false) + ) + ); + } +} + +// only private categories are listed +$query_true = ' +SELECT id,name,uppercats,global_rank + FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_ACCESS_TABLE.' ON cat_id = id + WHERE status = \'private\' + AND user_id = '.$page['user']; +if (count($group_authorized) > 0) +{ + $query_true.= ' + AND cat_id NOT IN ('.implode(',', $group_authorized).')'; +} +$query_true.= ' +;'; +display_select_cat_wrapper($query_true,array(),'category_option_true'); + +$result = pwg_query($query_true); +$authorized_ids = array(); +while ($row = mysql_fetch_array($result)) +{ + array_push($authorized_ids, $row['id']); +} + +$query_false = ' +SELECT id,name,uppercats,global_rank + FROM '.CATEGORIES_TABLE.' + WHERE status = \'private\''; +if (count($authorized_ids) > 0) +{ + $query_false.= ' + AND id NOT IN ('.implode(',', $authorized_ids).')'; +} +if (count($group_authorized) > 0) +{ + $query_false.= ' + AND id NOT IN ('.implode(',', $group_authorized).')'; +} +$query_false.= ' +;'; +display_select_cat_wrapper($query_false,array(),'category_option_false'); + +// +-----------------------------------------------------------------------+ +// | sending html code | +// +-----------------------------------------------------------------------+ + +$template->assign_var_from_handle('DOUBLE_SELECT', 'double_select'); +$template->assign_var_from_handle('ADMIN_CONTENT', 'user_perm'); +?> Index: /tags/release-1_7_0RC1/admin/waiting.php =================================================================== --- /tags/release-1_7_0RC1/admin/waiting.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/waiting.php (revision 1826) @@ -0,0 +1,219 @@ + 0) + { + $query = ' +UPDATE '.WAITING_TABLE.' + SET validated = \'true\' + WHERE id IN ('.implode(',', $to_validate).') +;'; + pwg_query($query); + + array_push( + $page['infos'], + sprintf( + l10n('%d waiting pictures validated'), + count($to_validate) + ) + ); + } + + if (count($to_reject) > 0) + { + // The uploaded element was refused, we have to delete its reference in + // the database and to delete the element as well. + $query = ' +SELECT id, storage_category_id, file, tn_ext + FROM '.WAITING_TABLE.' + WHERE id IN ('.implode(',', $to_reject).') +;'; + $result = pwg_query($query); + while($row = mysql_fetch_array($result)) + { + $dir = get_complete_dir($row['storage_category_id']); + unlink($dir.$row['file']); + $element_info = array( + 'path' => $dir.$row['file'], + 'tn_ext' => + (isset($row['tn_ext']) and $row['tn_ext']!='') ? $row['tn_ext']:'jpg' + ); + $tn_path = get_thumbnail_path( $element_info ); + + if ( @is_file($tn_path) ) + { + unlink( $tn_path ); + } + } + + $query = ' +DELETE + FROM '.WAITING_TABLE.' + WHERE id IN ('.implode(',', $to_reject).') +;'; + pwg_query($query); + + array_push( + $page['infos'], + sprintf( + l10n('%d waiting pictures rejected'), + count($to_reject) + ) + ); + } +} + +//----------------------------------------------------- template initialization +$template->set_filenames(array('waiting'=>'admin/waiting.tpl')); +$template->assign_vars(array( + 'F_ACTION'=>str_replace( '&', '&', $_SERVER['REQUEST_URI']) + )); + +//---------------------------------------------------------------- form display +$cat_names = array(); +$list = array(); + +$query = 'SELECT * FROM '.WAITING_TABLE; +$query.= " WHERE validated = 'false'"; +$query.= ' ORDER BY storage_category_id'; +$query.= ';'; +$result = pwg_query( $query ); +$i = 0; +while ( $row = mysql_fetch_array( $result ) ) +{ + if ( !isset( $cat_names[$row['storage_category_id']] ) ) + { + $cat = get_cat_info( $row['storage_category_id'] ); + $cat_names[$row['storage_category_id']] = array(); + $cat_names[$row['storage_category_id']]['dir'] = + PHPWG_ROOT_PATH.get_complete_dir( $row['storage_category_id'] ); + $cat_names[$row['storage_category_id']]['display_name'] = + get_cat_display_name($cat['name']); + } + $preview_url = PHPWG_ROOT_PATH.$cat_names[$row['storage_category_id']]['dir'].$row['file']; + $class='row1'; + if ( $i++ % 2== 0 ) $class='row2'; + + $template->assign_block_vars( + 'picture', + array( + 'WAITING_CLASS'=>$class, + 'CATEGORY_IMG'=>$cat_names[$row['storage_category_id']]['display_name'], + 'ID_IMG'=>$row['id'], + 'DATE_IMG' => date('Y-m-d H:i:s', $row['date']), + 'FILE_TITLE'=>$row['file'], + 'FILE_IMG' => + (strlen($row['file']) > 10) ? + (substr($row['file'], 0, 10)).'...' : $row['file'], + 'PREVIEW_URL_IMG'=>$preview_url, + 'UPLOAD_EMAIL'=>get_email_address_as_display_text($row['mail_address']), + 'UPLOAD_USERNAME'=>$row['username'] + ) + ); + + // is there an existing associated thumnail ? + if ( !empty( $row['tn_ext'] )) + { + $thumbnail = $conf['prefix_thumbnail']; + $thumbnail.= get_filename_wo_extension( $row['file'] ); + $thumbnail.= '.'.$row['tn_ext']; + $url = $cat_names[$row['storage_category_id']]['dir']; + $url.= 'thumbnail/'.$thumbnail; + + $template->assign_block_vars( + 'picture.thumbnail', + array( + 'PREVIEW_URL_TN_IMG' => $url, + 'FILE_TN_IMG' => + (strlen($thumbnail) > 10) ? + (substr($thumbnail, 0, 10)).'...' : $thumbnail, + 'FILE_TN_TITLE' => $thumbnail + ) + ); + } + + array_push($list, $row['id']); +} + +$template->assign_vars( + array( + 'LIST' => implode(',', $list) + ) + ); + +//----------------------------------------------------------- sending html code +$template->assign_var_from_handle('ADMIN_CONTENT', 'waiting'); +?> Index: /tags/release-1_7_0RC1/admin/ws_checker.php =================================================================== --- /tags/release-1_7_0RC1/admin/ws_checker.php (revision 1826) +++ /tags/release-1_7_0RC1/admin/ws_checker.php (revision 1826) @@ -0,0 +1,354 @@ + $id) + { + $next_less_1 = (isset($result[$k + 1]))? $result[$k + 1] - 1:-1; + if ( $id == $next_less_1 and end($serial)=='-' ) + { // nothing to do + } + elseif ( $id == $next_less_1 ) + { + $serial[]=$id; + $serial[]='-'; + } + else + { + $serial[]=$id; // end serie or non serie + } + } + $null = array_shift($serial); // remove first value + $list .= array_shift($serial); // add the real first one + $separ = ','; + foreach ($serial as $id) + { + $list .= ($id=='-') ? '' : $separ . $id; + $separ = ($id=='-') ? '-':','; // add comma except if hyphen + } + } + return $list; +} + +// +-----------------------------------------------------------------------+ +// | Check Access and exit when user status is not ok | +// +-----------------------------------------------------------------------+ +check_status(ACCESS_ADMINISTRATOR); + +// accepted queries +$req_type_list = official_req(); + +//--------------------------------------------------------- update informations + +// Is a new access required? + +if (isset($_POST['wsa_submit'])) +{ +// Check $_post (Some values are commented - maybe a future use) +$add_partner = htmlspecialchars( $_POST['add_partner'], ENT_QUOTES); +$add_target = check_target( $_POST['add_target']) ; +$add_end = ( is_numeric($_POST['add_end']) ) ? $_POST['add_end']:0; +$add_request = htmlspecialchars( $_POST['add_request'], ENT_QUOTES); +$add_limit = ( is_numeric($_POST['add_limit']) ) ? $_POST['add_limit']:1; +$add_comment = htmlspecialchars( $_POST['add_comment'], ENT_QUOTES); +if ( strlen($add_partner) < 8 ) +{ // TODO What? Complete with some MD5... +} + $query = ' +INSERT INTO '.WEB_SERVICES_ACCESS_TABLE.' +( `name` , `access` , `start` , `end` , `request` , `limit` , `comment` ) +VALUES (' . " + '$add_partner', '$add_target', + NOW(), + ADDDATE( NOW(), INTERVAL $add_end DAY), + '$add_request', '$add_limit', '$add_comment' );"; + + pwg_query($query); + + $template->assign_block_vars( + 'update_result', + array( + 'UPD_ELEMENT'=> $lang['ws_adding_legend'].$lang['ws_success_upd'], + ) + ); +} + +// Next, Update selected access +if (isset($_POST['wsu_submit'])) +{ + $upd_end = ( is_numeric($_POST['upd_end']) ) ? $_POST['upd_end']:0; + $settxt = ' end = ADDDATE(NOW(), INTERVAL '. $upd_end .' DAY)'; + + if ((isset($_POST['selection'])) and (trim($settxt) != '')) + { + $uid = (int) $_POST['selection']; + $query = ' + UPDATE '.WEB_SERVICES_ACCESS_TABLE.' + SET '.$settxt.' + WHERE id = '.$uid.'; '; + pwg_query($query); + $template->assign_block_vars( + 'update_result', + array( + 'UPD_ELEMENT'=> $lang['ws_update_legend'].$lang['ws_success_upd'], + ) + ); + } else { + $template->assign_block_vars( + 'update_result', + array( + 'UPD_ELEMENT'=> $lang['ws_update_legend'].$lang['ws_failed_upd'], + ) + ); + } +} +// Next, Delete selected access + +if (isset($_POST['wsX_submit'])) +{ + if ((isset($_POST['delete_confirmation'])) + and (isset($_POST['selection']))) + { + $uid = (int) $_POST['selection']; + $query = 'DELETE FROM '.WEB_SERVICES_ACCESS_TABLE.' + WHERE id = '.$uid.'; '; + pwg_query($query); + $template->assign_block_vars( + 'update_result', + array( + 'UPD_ELEMENT'=> $lang['ws_delete_legend'].$lang['ws_success_upd'], + ) + ); + } else { + $template->assign_block_vars( + 'update_result', + array( + 'UPD_ELEMENT'=> $lang['Not selected / Not confirmed'] + .$lang['ws_failed_upd'], + ) + ); + } +} + + + +$template->assign_vars( + array( + 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=web_service', + ) + ); + +// Build where +$where = ''; +$order = ' ORDER BY `id` DESC' ; + +$query = ' +SELECT * + FROM '.WEB_SERVICES_ACCESS_TABLE.' +WHERE 1=1 ' +.$where. +' ' +.$order. +';'; +$result = pwg_query($query); +$acc_list = mysql_num_rows($result); +$result = pwg_query($query); +// +-----------------------------------------------------------------------+ +// | template init | +// +-----------------------------------------------------------------------+ + +$template->set_filenames( + array( + 'ws_checker' => 'admin/ws_checker.tpl' + ) + ); + +$selected = 'selected="selected"'; +$num=0; +if ( $acc_list > 0 ) +{ + $template->assign_block_vars( + 'acc_list', array() ); +} + +// Access List +while ($row = mysql_fetch_array($result)) +{ + $num++; + $template->assign_block_vars( + 'acc_list.access', + array( + 'CLASS' => ($num % 2 == 1) ? 'row1' : 'row2', + 'ID' => $row['id'], + 'NAME' => + (is_adviser()) ? '*********' : $row['name'], + 'TARGET' => $row['access'], + 'END' => $row['end'], + 'REQUEST' => $row['request'], + 'LIMIT' => $row['limit'], + 'COMMENT' => $row['comment'], + 'SELECTED' => '', + ) + ); +} + +$template->assign_block_vars( + 'add_request', + array( + 'VALUE'=> '', + 'CONTENT' => '', + 'SELECTED' => $selected, + ) +); +foreach ($req_type_list as $value) { + + $template->assign_block_vars( + 'add_request', + array( + 'VALUE'=> $value, + 'CONTENT' => $value, + 'SELECTED' => '', + ) + ); +} + +foreach ($conf['ws_allowed_limit'] as $value) { + $template->assign_block_vars( + 'add_limit', + array( + 'VALUE'=> $value, + 'CONTENT' => $value, + 'SELECTED' => ($conf['ws_allowed_limit'][0] == $value) ? $selected:'', + ) + ); +} + +// Postponed Start Date +// By default 0, 1, 2, 3, 5, 7, 14 or 30 days +foreach ($conf['ws_postponed_start'] as $value) { + $template->assign_block_vars( + 'add_start', + array( + 'VALUE'=> $value, + 'CONTENT' => $value, + 'SELECTED' => ($conf['ws_postponed_start'][0] == $value) ? $selected:'', + ) + ); +} + +// Durations (Allowed Web Services Period) +// By default 10, 5, 2, 1 year(s) or 6, 3, 1 month(s) or 15, 10, 7, 5, 1, 0 day(s) +foreach ($conf['ws_durations'] as $value) { + $template->assign_block_vars( + 'add_end', + array( + 'VALUE'=> $value, + 'CONTENT' => $value, + 'SELECTED' => ($conf['ws_durations'][3] == $value) ? $selected:'', + ) + ); + if ( $acc_list > 0 ) + { + $template->assign_block_vars( + 'acc_list.upd_end', + array( + 'VALUE'=> $value, + 'CONTENT' => $value, + 'SELECTED' => ($conf['ws_durations'][3] == $value) ? $selected:'', + ) + ); + } +} + +//----------------------------------------------------------- sending html code + +$template->assign_var_from_handle('ADMIN_CONTENT', 'ws_checker'); + +include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php'); +?> Index: /tags/release-1_7_0RC1/category.php =================================================================== --- /tags/release-1_7_0RC1/category.php (revision 1826) +++ /tags/release-1_7_0RC1/category.php (revision 1826) @@ -0,0 +1,61 @@ + Index: /tags/release-1_7_0RC1/comments.php =================================================================== --- /tags/release-1_7_0RC1/comments.php (revision 1826) +++ /tags/release-1_7_0RC1/comments.php (revision 1826) @@ -0,0 +1,458 @@ + 'DESC', + 'ascending' => 'ASC' + ); + +// sort_by : database fields proposed for sorting comments list +$sort_by = array( + 'date' => 'comment date', + 'image_id' => 'picture' + ); + +// items_number : list of number of items to display per page +$items_number = array(5,10,20,50,'all'); + +// since when display comments ? +// +$since_options = array( + 1 => array('label' => l10n('today'), + 'clause' => 'date > SUBDATE(CURDATE(), INTERVAL 1 DAY)'), + 2 => array('label' => sprintf(l10n('last %d days'), 7), + 'clause' => 'date > SUBDATE(CURDATE(), INTERVAL 7 DAY)'), + 3 => array('label' => sprintf(l10n('last %d days'), 30), + 'clause' => 'date > SUBDATE(CURDATE(), INTERVAL 30 DAY)'), + 4 => array('label' => l10n('the beginning'), + 'clause' => '1=1') // stupid but generic + ); + +$page['since'] = isset($_GET['since']) ? $_GET['since'] : 4; + +// on which field sorting +// +$page['sort_by'] = 'date'; +// if the form was submitted, it overloads default behaviour +if (isset($_GET['sort_by'])) +{ + $page['sort_by'] = $_GET['sort_by']; +} + +// order to sort +// +$page['sort_order'] = $sort_order['descending']; +// if the form was submitted, it overloads default behaviour +if (isset($_GET['sort_order'])) +{ + $page['sort_order'] = $sort_order[$_GET['sort_order']]; +} + +// number of items to display +// +$page['items_number'] = 10; +if (isset($_GET['items_number'])) +{ + $page['items_number'] = $_GET['items_number']; +} + +$page['where_clauses'] = array(); + +// which category to filter on ? +if (isset($_GET['cat']) and 0 != $_GET['cat']) +{ + $page['where_clauses'][] = + 'category_id IN ('.implode(',', get_subcat_ids(array($_GET['cat']))).')'; +} + +// search a particular author +if (isset($_GET['author']) and !empty($_GET['author'])) +{ + $page['where_clauses'][] = 'com.author = \''.$_GET['author'].'\''; +} + +// search a substring among comments content +if (isset($_GET['keyword']) and !empty($_GET['keyword'])) +{ + // fors some odd reason comment content is htmlspecialchars in the database + $keyword = addslashes( + htmlspecialchars( stripslashes($_GET['keyword']), ENT_QUOTES) + ); + $page['where_clauses'][] = + '('. + implode(' AND ', + array_map( + create_function( + '$s', + 'return "content LIKE \'%$s%\'";' + ), + preg_split('/[\s,;]+/', $keyword) + ) + ). + ')'; +} + +$page['where_clauses'][] = $since_options[$page['since']]['clause']; + +// which status to filter on ? +if ( !is_admin() ) +{ + $page['where_clauses'][] = 'validated="true"'; +} + +$page['where_clauses'][] = get_sql_condition_FandF + ( + array + ( + 'forbidden_categories' => 'category_id', + 'visible_categories' => 'category_id', + 'visible_images' => 'ic.image_id' + ), + '', true + ); + +// +-----------------------------------------------------------------------+ +// | comments management | +// +-----------------------------------------------------------------------+ +if (isset($_GET['delete']) and is_numeric($_GET['delete']) + and !is_adviser() ) +{// comments deletion + check_status(ACCESS_ADMINISTRATOR); + $query = ' +DELETE FROM '.COMMENTS_TABLE.' + WHERE id='.$_GET['delete'].' +;'; + pwg_query($query); +} + +if (isset($_GET['validate']) and is_numeric($_GET['validate']) + and !is_adviser() ) +{ // comments validation + check_status(ACCESS_ADMINISTRATOR); + $query = ' +UPDATE '.COMMENTS_TABLE.' + SET validated = \'true\' + , validation_date = NOW() + WHERE id='.$_GET['validate'].' +;'; + pwg_query($query); +} + +// +-----------------------------------------------------------------------+ +// | page header and options | +// +-----------------------------------------------------------------------+ + +$title= l10n('title_comments'); +$page['body_id'] = 'theCommentsPage'; +include(PHPWG_ROOT_PATH.'include/page_header.php'); + +$template->set_filenames(array('comments'=>'comments.tpl')); +$template->assign_vars( + array( + 'L_COMMENT_TITLE' => $title, + + 'F_ACTION'=>PHPWG_ROOT_PATH.'comments.php', + 'F_KEYWORD'=>@htmlentities(stripslashes($_GET['keyword'])), + 'F_AUTHOR'=>@htmlentities(stripslashes($_GET['author'])), + + 'U_HOME' => make_index_url(), + ) + ); + +// +-----------------------------------------------------------------------+ +// | form construction | +// +-----------------------------------------------------------------------+ + +// Search in a particular category +$blockname = 'category'; + +$template->assign_block_vars( + $blockname, + array('SELECTED' => '', + 'VALUE'=> 0, + 'OPTION' => '------------' + )); + +$query = ' +SELECT id,name,uppercats,global_rank + FROM '.CATEGORIES_TABLE.' +'.get_sql_condition_FandF + ( + array + ( + 'forbidden_categories' => 'id', + 'visible_categories' => 'id' + ), + 'WHERE' + ).' +;'; +display_select_cat_wrapper($query, array(@$_GET['cat']), $blockname, true); + +// Filter on recent comments... +$blockname = 'since_option'; + +foreach ($since_options as $id => $option) +{ + $selected = ($id == $page['since']) ? 'selected="selected"' : ''; + + $template->assign_block_vars( + $blockname, + array('SELECTED' => $selected, + 'VALUE'=> $id, + 'CONTENT' => $option['label'] + )); +} + +// Sort by +$blockname = 'sort_by_option'; + +foreach ($sort_by as $key => $value) +{ + $selected = ($key == $page['sort_by']) ? 'selected="selected"' : ''; + + $template->assign_block_vars( + $blockname, + array('SELECTED' => $selected, + 'VALUE'=> $key, + 'CONTENT' => l10n($value) + )); +} + +// Sorting order +$blockname = 'sort_order_option'; + +foreach (array_keys($sort_order) as $option) +{ + $selected = ($option == $page['sort_order']) ? 'selected="selected"' : ''; + + $template->assign_block_vars( + $blockname, + array('SELECTED' => $selected, + 'VALUE'=> $option, + 'CONTENT' => l10n($option) + )); +} + +// Number of items +$blockname = 'items_number_option'; + +foreach ($items_number as $option) +{ + $selected = ($option == $page['items_number']) ? 'selected="selected"' : ''; + + $template->assign_block_vars( + $blockname, + array('SELECTED' => $selected, + 'VALUE'=> $option, + 'CONTENT' => is_numeric($option) ? $option : l10n($option) + )); +} + +// +-----------------------------------------------------------------------+ +// | navigation bar | +// +-----------------------------------------------------------------------+ + +if (isset($_GET['start']) and is_numeric($_GET['start'])) +{ + $start = $_GET['start']; +} +else +{ + $start = 0; +} + +$query = ' +SELECT COUNT(DISTINCT(id)) + FROM '.IMAGE_CATEGORY_TABLE.' AS ic + INNER JOIN '.COMMENTS_TABLE.' AS com + ON ic.image_id = com.image_id + WHERE '.implode(' + AND ', $page['where_clauses']).' +;'; +list($counter) = mysql_fetch_row(pwg_query($query)); + +$url = PHPWG_ROOT_PATH + .'comments.php' + .get_query_string_diff(array('start','delete','validate')); + +$navbar = create_navigation_bar($url, + $counter, + $start, + $page['items_number'], + ''); + +$template->assign_vars(array('NAVBAR' => $navbar)); + +// +-----------------------------------------------------------------------+ +// | last comments display | +// +-----------------------------------------------------------------------+ + +$comments = array(); +$element_ids = array(); +$category_ids = array(); + +$query = ' +SELECT com.id AS comment_id + , com.image_id + , ic.category_id + , com.author + , com.date + , com.content + , com.id AS comment_id + , com.validated + FROM '.IMAGE_CATEGORY_TABLE.' AS ic + INNER JOIN '.COMMENTS_TABLE.' AS com + ON ic.image_id = com.image_id + WHERE '.implode(' + AND ', $page['where_clauses']).' + GROUP BY comment_id + ORDER BY '.$page['sort_by'].' '.$page['sort_order']; +if ('all' != $page['items_number']) +{ + $query.= ' + LIMIT '.$start.','.$page['items_number']; +} +$query.= ' +;'; +$result = pwg_query($query); +while ($row = mysql_fetch_assoc($result)) +{ + array_push($comments, $row); + array_push($element_ids, $row['image_id']); + array_push($category_ids, $row['category_id']); +} + +if (count($comments) > 0) +{ + // retrieving element informations + $elements = array(); + $query = ' +SELECT id, name, file, path, tn_ext + FROM '.IMAGES_TABLE.' + WHERE id IN ('.implode(',', $element_ids).') +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_assoc($result)) + { + $elements[$row['id']] = $row; + } + + // retrieving category informations + $categories = array(); + $query = ' +SELECT id, name, uppercats + FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', $category_ids).') +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_assoc($result)) + { + $categories[$row['id']] = $row; + } + + foreach ($comments as $comment) + { + if (!empty($elements[$comment['image_id']]['name'])) + { + $name=$elements[$comment['image_id']]['name']; + } + else + { + $name=get_name_from_file($elements[$comment['image_id']]['file']); + } + + // source of the thumbnail picture + $thumbnail_src = get_thumbnail_url( $elements[$comment['image_id']] ); + + // link to the full size picture + $url = make_picture_url( + array( + 'category' => $comment['category_id'], + 'cat_name' => $categories[ $comment['category_id']] ['name'], + 'image_id' => $comment['image_id'], + 'image_file' => $elements[$comment['image_id']]['file'], + ) + ); + + $author = $comment['author']; + if (empty($comment['author'])) + { + $author = l10n('guest'); + } + + $template->assign_block_vars( + 'comment', + array( + 'U_PICTURE' => $url, + 'TN_SRC' => $thumbnail_src, + 'ALT' => $name, + 'AUTHOR' => $author, + 'DATE'=>format_date($comment['date'],'mysql_datetime',true), + 'CONTENT'=>trigger_event('render_comment_content',$comment['content']), + )); + + if ( is_admin() ) + { + $url = get_root_url().'comments.php'.get_query_string_diff(array('delete','validate')); + $template->assign_block_vars( + 'comment.action_delete', + array( + 'U_DELETE' => add_url_params($url, + array('delete'=>$comment['comment_id']) + ), + )); + if ($comment['validated'] != 'true') + { + $template->assign_block_vars( + 'comment.action_validate', + array( + 'U_VALIDATE' => add_url_params($url, + array('validate'=>$comment['comment_id']) + ), + )); + } + } + } +} +// +-----------------------------------------------------------------------+ +// | html code display | +// +-----------------------------------------------------------------------+ +$template->assign_block_vars('title',array()); +$template->parse('comments'); +include(PHPWG_ROOT_PATH.'include/page_tail.php'); +?> Index: /tags/release-1_7_0RC1/doc/COPYING =================================================================== --- /tags/release-1_7_0RC1/doc/COPYING (revision 1826) +++ /tags/release-1_7_0RC1/doc/COPYING (revision 1826) @@ -0,0 +1,345 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + +
'. var_export($items, true) . ''); + if (count($items)==1) + {// only one year exists so bail out to year view + list($y) = array_keys($items); + $page['chronology_date'][CYEAR] = $y; + return false; + } + + global $lang, $template; + foreach ( $items as $year=>$year_data) + { + $chronology_date = array( $year ); + $url = duplicate_index_url( array('chronology_date'=>$chronology_date) ); + + $nav_bar = ''.$year.''; + $nav_bar .= ' ('.$year_data['nb_images'].')'; + $nav_bar .= '
');
+ if ($page['section']=='recent_cats')
+ {
+ $name = get_cat_display_name_cache($category['uppercats'], null, false);
+ }
+ else
+ {
+ $name = $category['name'];
+ }
+
+ $icon_ts = get_icon($category['max_date_last'], $category['is_child_date_last']);
+
+ $template->assign_block_vars(
+ 'categories.category',
+ array(
+ 'SRC' => $thumbnail_src_of[$category['representative_picture_id']],
+ 'ALT' => $category['name'],
+ 'TITLE' => $lang['hint_category'],
+ 'ICON' => $icon_ts,
+
+ 'URL' => make_index_url(
+ array(
+ 'category' => $category['id'],
+ 'cat_name' => $category['name'],
+ )
+ ),
+ 'CAPTION_NB_IMAGES' => get_display_images_count
+ (
+ $category['nb_images'],
+ $category['count_images'],
+ $category['count_categories']
+ ),
+ 'DESCRIPTION' => @$comment,
+ 'NAME' => $name,
+ )
+ );
+ }
+
+ $template->assign_var_from_handle('CATEGORIES', 'mainpage_categories');
+ }
+ else
+ {
+ $template->set_filename( 'thumbnails', 'thumbnails.tpl');
+ // first line
+ $template->assign_block_vars('thumbnails.line', array());
+ // current row displayed
+ $row_number = 0;
+
+ if ($page['section']=='recent_cats')
+ {
+ $old_level_separator = $conf['level_separator'];
+ $conf['level_separator'] = ' ';
+ $debug.= '['.$time.', ';
+ $debug.= $page['count_queries'].' queries] : '.$string;
+ $debug.= " '.nl2br(htmlentities($args['content'])).'
';
+ }
+
+ foreach ($categories as $category)
+ {
+ $template->assign_block_vars(
+ 'thumbnails.line.thumbnail',
+ array(
+ 'IMAGE' => $thumbnail_src_of[ $category['representative_picture_id'] ],
+ 'IMAGE_ALT' => $category['name'],
+ 'IMAGE_TITLE' => $lang['hint_category'],
+
+ 'U_IMG_LINK' => make_index_url(
+ array(
+ 'category' => $category['id'],
+ 'cat_name' => $category['name'],
+ )
+ ),
+ 'CLASS' => 'thumbCat',
+ )
+ );
+ if ($page['section']=='recent_cats')
+ {
+ $name = get_cat_display_name_cache($category['uppercats'], null, false);
+ }
+ else
+ {
+ $name = $category['name'];
+ $template->merge_block_vars(
+ 'thumbnails.line.thumbnail',
+ array(
+ 'IMAGE_TS' => get_icon($category['max_date_last'], $category['is_child_date_last']),
+ )
+ );
+ }
+ $template->assign_block_vars(
+ 'thumbnails.line.thumbnail.category_name',
+ array(
+ 'NAME' => $name
+ )
+ );
+
+ // create a new line ?
+ if (++$row_number == $user['nb_image_line'])
+ {
+ $template->assign_block_vars('thumbnails.line', array());
+ $row_number = 0;
+ }
+ }
+
+ if ( isset($old_level_separator) )
+ {
+ $conf['level_separator']=$old_level_separator;
+ }
+
+ $template->assign_var_from_handle('CATEGORIES', 'thumbnails');
+ unset( $template->_tpldata['thumbnails.'] );//maybe write a func for that
+ }
+}
+?>
Index: /tags/release-1_7_0RC1/include/category_default.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/category_default.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/category_default.inc.php (revision 1826)
@@ -0,0 +1,196 @@
+ 0)
+{
+ $query = '
+SELECT *
+ FROM '.IMAGES_TABLE.'
+ WHERE id IN ('.implode(',', $selection).')
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_assoc($result))
+ {
+ $row['rank'] = $page['rank_of'][ $row['id'] ];
+
+ array_push($pictures, $row);
+ }
+
+ usort($pictures, 'rank_compare');
+}
+
+// template thumbnail initialization
+$template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',));
+if (count($pictures) > 0)
+{
+ // first line
+ $template->assign_block_vars('thumbnails.line', array());
+ // current row displayed
+ $row_number = 0;
+}
+
+trigger_action('loc_begin_index_thumbnails', $pictures);
+
+foreach ($pictures as $row)
+{
+ $thumbnail_url = get_thumbnail_url($row);
+
+ // message in title for the thumbnail
+ $thumbnail_title = $row['file'];
+ if (isset($row['filesize']))
+ {
+ $thumbnail_title .= ' : '.$row['filesize'].' KB';
+ }
+
+ // link on picture.php page
+ $url = duplicate_picture_url(
+ array(
+ 'image_id' => $row['id'],
+ 'image_file' => $row['file']
+ ),
+ array('start')
+ );
+
+ $template->assign_block_vars(
+ 'thumbnails.line.thumbnail',
+ array(
+ 'IMAGE' => $thumbnail_url,
+ 'IMAGE_ALT' => $row['file'],
+ 'IMAGE_TITLE' => $thumbnail_title,
+ 'IMAGE_TS' => get_icon($row['date_available']),
+
+ 'U_IMG_LINK' => $url,
+
+ 'CLASS' => 'thumbElmt',
+ )
+ );
+ if ($user['show_nb_hits']
+ and isset($page['category'])
+ and $conf['show_nb_hits'])
+ {
+ $template->assign_block_vars(
+ 'thumbnails.line.thumbnail.nb_hits',
+ array(
+ 'HITS'=> l10n_dec('%d hit', '%d hits', $row['hit']),
+ 'CLASS'=> set_span_class($row['hit']) . ' nb-hits',
+ )
+ );
+
+ }
+
+ if ($conf['show_thumbnail_caption'])
+ {
+ // name of the picture
+ if (isset($row['name']) and $row['name'] != '')
+ {
+ $name = $row['name'];
+ }
+ else
+ {
+ $name = str_replace('_', ' ', get_filename_wo_extension($row['file']));
+ }
+
+ switch ($page['section'])
+ {
+ case 'best_rated' :
+ {
+ $name = '('.$row['average_rate'].') '.$name;
+ break;
+ }
+ case 'most_visited' :
+ {
+ $name = '('.$row['hit'].') '.$name;
+ break;
+ }
+ case 'search' :
+ {
+ $name = replace_search($name, $page['search']);
+ break;
+ }
+ }
+
+ $template->assign_block_vars(
+ 'thumbnails.line.thumbnail.element_name',
+ array(
+ 'NAME' => $name
+ )
+ );
+ }
+
+ if ($user['show_nb_comments']
+ and isset($page['category'])
+ and $page['cat_commentable'])
+ {
+ $query = '
+SELECT COUNT(*) AS nb_comments
+ FROM '.COMMENTS_TABLE.'
+ WHERE image_id = '.$row['id'].'
+ AND validated = \'true\'
+;';
+ $row = mysql_fetch_array(pwg_query($query));
+ $template->assign_block_vars(
+ 'thumbnails.line.thumbnail.nb_comments',
+ array(
+ 'NB_COMMENTS'=> l10n_dec('%d comment', '%d comments',
+ $row['nb_comments']),
+ 'CLASS'=> set_span_class($row['nb_comments']) . ' nb-comments',
+ )
+ );
+ }
+
+ //plugins need to add/modify sth in this loop ?
+ trigger_action('loc_index_thumbnail', $row, 'thumbnails.line.thumbnail' );
+
+ // create a new line ?
+ if (++$row_number == $user['nb_image_line'])
+ {
+ $template->assign_block_vars('thumbnails.line', array());
+ $row_number = 0;
+ }
+}
+
+trigger_action('loc_end_index_thumbnails', $pictures);
+$template->assign_var_from_handle('THUMBNAILS', 'thumbnails');
+
+pwg_debug('end include/category_default.inc.php');
+?>
Index: /tags/release-1_7_0RC1/include/common.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/common.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/common.inc.php (revision 1826)
@@ -0,0 +1,259 @@
+= 5.1.0RC1
+ 'hash_hmac', //(hash) - enabled by default as of PHP 5.1.2
+ ) as $func)
+{
+ if (!function_exists($func))
+ {
+ include_once(PHPWG_ROOT_PATH . 'include/php_compat/'.$func.'.php');
+ }
+}
+
+include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
+@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
+include(PHPWG_ROOT_PATH . 'include/constants.php');
+include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
+include(PHPWG_ROOT_PATH . 'include/template.php');
+
+// Database connection
+mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
+or die ( "Could not connect to database server" );
+mysql_select_db( $cfgBase )
+or die ( "Could not connect to database" );
+
+//
+// Setup gallery wide options, if this fails then we output a CRITICAL_ERROR
+// since basic gallery information is not available
+//
+load_conf_from_db();
+load_plugins();
+
+include(PHPWG_ROOT_PATH.'include/user.inc.php');
+
+
+// language files
+include_once(get_language_filepath('common.lang.php'));
+if (defined('IN_ADMIN') and IN_ADMIN)
+{
+ include_once(get_language_filepath('admin.lang.php'));
+}
+trigger_action('loading_lang');
+@include_once(get_language_filepath('local.lang.php'));
+
+// only now we can set the localized username of the guest user (and not in
+// include/user.inc.php)
+if ($user['is_the_guest'])
+{
+ $user['username'] = $lang['guest'];
+}
+
+// template instance
+$template = new Template(PHPWG_ROOT_PATH.'template/'.$user['template'], $user['theme'] );
+
+if ($conf['gallery_locked'])
+{
+ $header_msgs[] = $lang['gallery_locked_message'];
+
+ if ( script_basename() != 'identification' and !is_admin() )
+ {
+ echo $lang['gallery_locked_message']
+ .'.';
+ exit();
+ }
+}
+
+if ($user['is_the_guest'] and !$conf['guest_access']
+ and !in_array( script_basename(),
+ // Array of basename without file extention
+ array('identification',
+ 'password',
+ 'register'
+ )
+ )
+ )
+{
+ redirect (get_absolute_root_url(false).'identification.php');
+}
+
+if ($conf['check_upgrade_feed']
+ and defined('PHPWG_IN_UPGRADE')
+ and PHPWG_IN_UPGRADE)
+{
+
+ // retrieve already applied upgrades
+ $query = '
+SELECT id
+ FROM '.UPGRADE_TABLE.'
+;';
+ $applied = array_from_query($query, 'id');
+
+ // retrieve existing upgrades
+ $existing = get_available_upgrade_ids();
+
+ // which upgrades need to be applied?
+ if (count(array_diff($existing, $applied)) > 0)
+ {
+ $header_msgs[] = 'Some database upgrades are missing, '
+ .'upgrade now';
+ }
+}
+
+if (is_adviser())
+{
+ $header_msgs[] = $lang['adviser_mode_enabled'];
+}
+
+if (count($header_msgs) > 0)
+{
+ $template->assign_block_vars('header_msgs',array());
+ foreach ($header_msgs as $header_msg)
+ {
+ $template->assign_block_vars('header_msgs.header_msg',
+ array('HEADER_MSG'=>$header_msg));
+ }
+}
+
+if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
+{
+ include(PHPWG_ROOT_PATH.'include/functions_filter.inc.php');
+ include(PHPWG_ROOT_PATH.'include/filter.inc.php');
+}
+else
+{
+ // global variable for filter
+ $filter = array();
+ $filter['enabled'] = false;
+}
+
+if (isset($conf['header_notes']))
+{
+ $header_notes = array_merge($header_notes, $conf['header_notes']);
+}
+
+// default event handlers
+add_event_handler('render_comment_content', 'parse_comment_content');
+trigger_action('init');
+?>
Index: /tags/release-1_7_0RC1/include/config_default.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/config_default.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/config_default.inc.php (revision 1826)
@@ -0,0 +1,680 @@
+ 'PWG website',
+// 'http://forum.phpwebgallery.net' => 'PWG forum',
+// 'http://phpwebgallery.net/doc' => 'PWG wiki'
+// );
+//
+// Advenced use:
+// You can also used special options. Instead to pass a string like parameter value
+// you can pass a array with different optional parameter values
+// $conf['links'] = array(
+// 'http://phpwebgallery.net' => array('label' => 'PWG website', 'new_window' => false, 'eval_visible' => 'return true;'),
+// 'http://forum.phpwebgallery.net' => array('label' => 'For ADMIN', 'new_window' => true, 'eval_visible' => 'return is_admin();'),
+// 'http://phpwebgallery.net/doc' => array('label' => 'For Guest', 'new_window' => true, 'eval_visible' => 'return $user[\'is_the_guest\'];'),
+// 'http://download.gna.org/phpwebgallery/' =>
+// array('label' => 'PopUp', 'new_window' => true,
+// 'nw_name' => 'PopUp', 'nw_features' => 'width=800,height=450,location=no,status=no,toolbar=no,scrollbars=no,menubar=no'),
+// );
+// Parameters:
+// 'label':
+// Label to display for the link, must be defined
+// 'new_window':
+// If true open link on tab/window
+// [Default value is true if it's not defined]
+// 'nw_name':
+// Name use when new_window is true
+// [Default value is '' if it's not defined]
+// 'nw_features':
+// features use when new_window is true
+// [Default value is '' if it's not defined]
+// 'eval_visible':
+// It's php code witch must return if the link is visible or not
+// [Default value is true if it's not defined]
+//
+// Equivalence:
+// $conf['links'] = array(
+// 'http://phpwebgallery.net' => 'PWG website',
+// );
+// $conf['links'] = array(
+// 'http://phpwebgallery.net' => array('label' => 'PWG website', 'new_window' => false, 'visible' => 'return true;'),
+// );
+//
+// If the array is empty, the "Links" box won't be displayed on the main
+// page.
+$conf['links'] = array();
+
+// random_index_redirect: list of 'internal' links to use when no section is defined on index.php.
+// An example is the best than a long explanation :
+//
+// for each link is associated a php condition
+// '' condition is equivalent to 'return true;'
+// $conf['random_index_redirect'] = array(
+// PHPWG_ROOT_PATH.'index.php?/best_rated' => 'return true;',
+// PHPWG_ROOT_PATH.'index.php?/recent_pics' => 'return $user[\'is_the_guest\'];',
+// PHPWG_ROOT_PATH.'random.php' => '',
+// PHPWG_ROOT_PATH.'index.php?/categories' => '',
+// );
+$conf['random_index_redirect'] = array();
+
+// List of notes to display on all header page
+// example $conf['header_notes'] = array('Test', 'Hello');
+$conf['header_notes'] = array();
+
+// show_thumbnail_caption : on thumbnails page, show thumbnail captions ?
+$conf['show_thumbnail_caption'] = true;
+
+// show_picture_name_on_title : on picture presentation page, show picture
+// name ?
+$conf['show_picture_name_on_title'] = true;
+
+// subcatify: display thumbnails representing a category a different way
+// than thumbnails representing a picture.
+$conf['subcatify'] = true;
+
+// allow_random_representative : do you wish PhpWebGallery to search among
+// categories elements a new representative at each reload ?
+//
+// If false, an element is randomly or manually chosen to represent its
+// category and remains the representative as long as an admin does not
+// change it.
+//
+// Warning : setting this parameter to true is CPU consuming. Each time you
+// change the value of this parameter from false to true, an administrator
+// must update categories informations in screen [Admin > General >
+// Maintenance].
+$conf['allow_random_representative'] = false;
+
+// allow_html_descriptions : authorize administrators to use HTML in
+// category and element description.
+$conf['allow_html_descriptions'] = true;
+
+// prefix_thumbnail : string before filename. Thumbnail's prefix must only
+// contain characters among : a to z (case insensitive), "-" or "_".
+$conf['prefix_thumbnail'] = 'TN-';
+
+// users_page: how many users to display in screen
+// Administration>Identification>Users?
+$conf['users_page'] = 20;
+
+// mail_options: only set it true if you have a send mail warning with
+// "options" parameter missing on mail() function execution.
+$conf['mail_options'] = false;
+
+// send_bcc_mail_webmaster: send bcc mail to webmaster. Set true for debug
+// or test.
+$conf['send_bcc_mail_webmaster'] = false;
+
+// enabled_format_email:
+// on true email will be formatted with name and address
+// on false email will be only address
+// There are webhosting wich not allow email formatted (Lycos, ...)
+$conf['enabled_format_email'] = true;
+
+// default_email_format:
+// Define the default email format use to send email
+// Value could be text/plain or text/html
+$conf['default_email_format'] = 'text/plain';
+
+// check_upgrade_feed: check if there are database upgrade required. Set to
+// true, a message will strongly encourage you to upgrade your database if
+// needed.
+//
+// This configuration parameter is set to true in BSF branch and to false
+// elsewhere.
+$conf['check_upgrade_feed'] = true;
+
+// rate_items: available rates for a picture
+$conf['rate_items'] = array(0,1,2,3,4,5);
+
+// Define default method to use ('http' or 'html' in order to do redirect)
+$conf['default_redirect_method'] = 'http';
+
+// +-----------------------------------------------------------------------+
+// | metadata |
+// +-----------------------------------------------------------------------+
+
+// show_iptc: Show IPTC metadata on picture.php if asked by user
+$conf['show_iptc'] = false;
+
+// show_iptc_mapping : is used for showing IPTC metadata on picture.php
+// page. For each key of the array, you need to have the same key in the
+// $lang array. For example, if my first key is 'iptc_keywords' (associated
+// to '2#025') then you need to have $lang['iptc_keywords'] set in
+// language/$user['language']/common.lang.php. If you don't have the lang
+// var set, the key will be simply displayed
+//
+// To know how to associated iptc_field with their meaning, use
+// tools/metadata.php
+$conf['show_iptc_mapping'] = array(
+ 'iptc_keywords' => '2#025',
+ 'iptc_caption_writer' => '2#122',
+ 'iptc_byline_title' => '2#085',
+ 'iptc_caption' => '2#120'
+ );
+
+// use_iptc: Use IPTC data during database synchronization with files
+// metadata
+$conf['use_iptc'] = false;
+
+// use_iptc_mapping : in which IPTC fields will PhpWebGallery find image
+// information ? This setting is used during metadata synchronisation. It
+// associates a phpwebgallery_images column name to a IPTC key
+$conf['use_iptc_mapping'] = array(
+ 'keywords' => '2#025',
+ 'date_creation' => '2#055',
+ 'author' => '2#122',
+ 'name' => '2#005',
+ 'comment' => '2#120'
+ );
+
+// show_exif: Show EXIF metadata on picture.php (table or line presentation
+// avalaible)
+$conf['show_exif'] = true;
+
+// show_exif_fields : in EXIF fields, you can choose to display fields in
+// sub-arrays, for example ['COMPUTED']['ApertureFNumber']. for this, add
+// 'COMPUTED;ApertureFNumber' in $conf['show_exif_fields']
+//
+// The key displayed in picture.php will be $lang['exif_field_Make'] for
+// example and if it exists. For compound fields, only take into account the
+// last part : for key 'COMPUTED;ApertureFNumber', you need
+// $lang['exif_field_ApertureFNumber']
+//
+// for PHP version newer than 4.1.2 :
+// $conf['show_exif_fields'] = array('CameraMake','CameraModel','DateTime');
+//
+$conf['show_exif_fields'] = array(
+ 'Make',
+ 'Model',
+ 'DateTimeOriginal',
+ 'COMPUTED;ApertureFNumber'
+ );
+
+// use_exif: Use EXIF data during database synchronization with files
+// metadata
+$conf['use_exif'] = true;
+
+// use_exif_mapping: same behaviour as use_iptc_mapping
+$conf['use_exif_mapping'] = array(
+ 'date_creation' => 'DateTimeOriginal'
+ );
+
+// +-----------------------------------------------------------------------+
+// | sessions |
+// +-----------------------------------------------------------------------+
+
+// session_use_cookies: specifies to use cookie to store
+// the session id on client side
+$conf['session_use_cookies'] = true;
+
+// session_use_only_cookies: specifies to only use cookie to store
+// the session id on client side
+$conf['session_use_only_cookies'] = true;
+
+// session_use_trans_sid: do not use transparent session id support
+$conf['session_use_trans_sid'] = false;
+
+// session_name: specifies the name of the session which is used as cookie name
+$conf['session_name'] = 'pwg_id';
+
+// session_save_handler: comment the line below
+// to use file handler for sessions.
+$conf['session_save_handler'] = 'db';
+
+// authorize_remembering : permits user to stay logged for a long time. It
+// creates a cookie on client side.
+$conf['authorize_remembering'] = true;
+
+// remember_me_name: specifies the name of the cookie used to stay logged
+$conf['remember_me_name'] = 'pwg_remember';
+
+// remember_me_length : time of validity for "remember me" cookies, in
+// seconds.
+$conf['remember_me_length'] = 5184000;
+
+// session_length : time of validity for normal session, in seconds.
+$conf['session_length'] = 3600;
+
+// +-----------------------------------------------------------------------+
+// | debug |
+// +-----------------------------------------------------------------------+
+
+// show_queries : for debug purpose, show queries and execution times
+$conf['show_queries'] = false;
+
+// show_gt : display generation time at the bottom of each page
+$conf['show_gt'] = true;
+
+// debug_l10n : display a warning message each time an unset language key is
+// accessed
+$conf['debug_l10n'] = false;
+
+// die_on_sql_error: if an SQL query fails, should everything stop?
+$conf['die_on_sql_error'] = true;
+
+// +-----------------------------------------------------------------------+
+// | authentication |
+// +-----------------------------------------------------------------------+
+
+// apache_authentication : use Apache authentication as reference instead of
+// users table ?
+$conf['apache_authentication'] = false;
+
+// users_table: which table is the reference for users? Can be a different
+// table than PhpWebGallery table
+//
+// If you decide to use another table than the default one, you need to
+// prepare your database by deleting some datas :
+//
+// delete from phpwebgallery_user_access;
+// delete from phpwebgallery_user_cache;
+// delete from phpwebgallery_user_feed;
+// delete from phpwebgallery_user_group;
+// delete from phpwebgallery_user_infos;
+// delete from phpwebgallery_sessions;
+// delete from phpwebgallery_rate;
+// update phpwebgallery_images set average_rate = NULL;
+// delete from phpwebgallery_caddie;
+// delete from phpwebgallery_favorites;
+//
+// All informations contained in these tables and column are related to
+// phpwebgallery_users table.
+$conf['users_table'] = $prefixeTable.'users';
+
+// user_fields : mapping between generic field names and table specific
+// field names. For example, in PWG, the mail address is names
+// "mail_address" and in punbb, it's called "email".
+$conf['user_fields'] = array(
+ 'id' => 'id',
+ 'username' => 'username',
+ 'password' => 'password',
+ 'email' => 'mail_address'
+ );
+
+// pass_convert : function to crypt or hash the clear user password to store
+// it in the database
+$conf['pass_convert'] = create_function('$s', 'return md5($s);');
+
+// guest_id : id of the anonymous user
+$conf['guest_id'] = 2;
+
+// webmaster_id : webmaster'id.
+$conf['webmaster_id'] = 1;
+
+// allow to use adviser mode
+$conf['allow_adviser'] = false;
+
+// does the guest have access ?
+// (not a security feature, set your categories "private" too)
+// If false it'll be redirected from index.php to identification.php
+$conf['guest_access'] = true;
+
+// +-----------------------------------------------------------------------+
+// | upload |
+// +-----------------------------------------------------------------------+
+
+// upload_maxfilesize: maximum filesize for the uploaded pictures. In
+// kilobytes.
+$conf['upload_maxfilesize'] = 200;
+
+// upload_maxheight: maximum height authorized for the uploaded images. In
+// pixels.
+$conf['upload_maxheight'] = 800;
+
+// upload_maxwidth: maximum width authorized for the uploaded images. In
+// pixels.
+$conf['upload_maxwidth'] = 800;
+
+// upload_maxheight_thumbnail: maximum height authorized for the uploaded
+// thumbnails
+$conf['upload_maxheight_thumbnail'] = 100;
+
+// upload_maxwidth_thumbnail: maximum width authorized for the uploaded
+// thumbnails
+$conf['upload_maxwidth_thumbnail'] = 150;
+
+// +-----------------------------------------------------------------------+
+// | history |
+// +-----------------------------------------------------------------------+
+
+// nb_logs_page : how many logs to display on a page
+$conf['nb_logs_page'] = 300;
+
+// +-----------------------------------------------------------------------+
+// | urls |
+// +-----------------------------------------------------------------------+
+
+// question_mark_in_urls : the generated urls contain a ? sign. This can be
+// changed to false only if the server translates PATH_INFO variable
+// (depends on the server AcceptPathInfo directive configuration)
+$conf['question_mark_in_urls'] = true;
+
+// php_extension_in_urls : if true, the urls generated for picture and
+// category will not contain the .php extension. This will work only if
+// .htaccess defines Options +MultiViews parameter or url rewriting rules
+// are active.
+$conf['php_extension_in_urls'] = true;
+
+// category_url_style : one of 'id' (default) or 'id-name'. 'id-name'
+// means that an simplified ascii represntation of the category name will
+// appear in the url
+$conf['category_url_style'] = 'id';
+
+// picture_url_style : one of 'id' (default), 'id-file' or 'file'. 'id-file'
+// or 'file' mean that the file name (without extension will appear in the
+// url). Note that one aditionnal sql query will occur if 'file' is choosen.
+// Note that you might experience navigation issues if you choose 'file'
+// and your file names are not unique
+$conf['picture_url_style'] = 'id';
+
+// tag_url_style : one of 'id-tag' (default), 'id' or 'tag'.
+// Note that if you choose 'tag' and the url (ascii) representation of your
+// tags is not unique, all tags with the same url representation will be shown
+$conf['tag_url_style'] = 'id-tag';
+
+// +-----------------------------------------------------------------------+
+// | tags |
+// +-----------------------------------------------------------------------+
+
+// full_tag_cloud_items_number: number of tags to show in the full tag
+// cloud. Only the most represented tags will be shown
+$conf['full_tag_cloud_items_number'] = 200;
+
+// menubar_tag_cloud_items_number: number of tags to show in the tag
+// cloud in the menubar. Only the most represented tags will be shown
+$conf['menubar_tag_cloud_items_number'] = 100;
+
+// content_tag_cloud_items_number: number of tags to show in the tag
+// cloud on the content page. Only the most represented tags will be shown
+$conf['content_tag_cloud_items_number'] = 12;
+
+// tags_levels: number of levels to use for display. Each level is bind to a
+// CSS class tagLevelX.
+$conf['tags_levels'] = 5;
+
+// +-----------------------------------------------------------------------+
+// | Notification by mail |
+// +-----------------------------------------------------------------------+
+
+// Default Value for nbm user
+$conf['nbm_default_value_user_enabled'] = false;
+
+// Search list user to send quickly (List all without to check news)
+// More quickly but less fun to use
+$conf['nbm_list_all_enabled_users_to_send'] = false;
+
+// Max time used on one pass in order to send mails.
+// Timeout delay ratio.
+$conf['nbm_max_treatment_timeout_percent'] = 0.8;
+
+// If timeout cannot be compite with nbm_max_treatment_timeout_percent,
+// nbm_treatment_timeout_default is used by default
+$conf['nbm_treatment_timeout_default'] = 20;
+
+// +-----------------------------------------------------------------------+
+// | Set default admin layout |
+// +-----------------------------------------------------------------------+
+
+// Must be user setable in future
+// Default value of admin layout
+// Step 1, default_admin_layout is not defined
+// null value, user_layout is used for admin layout
+// defined value, this value are used for admin layout
+// Next on step 2, default_admin_layout will be used
+// if there are not checked like admin layout
+// stored on user informations
+//$conf['default_admin_layout']='yoga/dark';
+
+// should we load the active plugins ? true=Yes, false=No
+$conf['enable_plugins']=true;
+
+// +-----------------------------------------------------------------------+
+// | Set default for Web Service |
+// +-----------------------------------------------------------------------+
+
+// Web services are allowed (true) or completely forbidden (false)
+$conf['allow_web_services'] = true;
+
+// Maximum number of images to be returned foreach call to the web service
+$conf['ws_max_images_per_page'] = 500;
+
+// On Access control false
+// Controls are done on public basis or
+// if connected on member authorization basis
+$conf['ws_access_control'] = false;
+
+// On Access control true
+// Additionnal controls are made based on Web Service Access Table
+
+// Max returned rows number ( > 0 )
+ $conf['ws_allowed_limit'] = array(1,2,3,5,10,25);
+
+// By default can be delayed by 0, 1, 2, 3, 5, 7, 14 or 30 days
+// 0 it's Now(), don't remove that one
+ $conf['ws_postponed_start'] = array(0,1,2,3,5,7,14,30); /* In days */
+
+// By default 10, 5, 2, 1 year(s) or 6, 3, 1 month(s)
+// or 15, 10, 7, 5, 1, 0 day(s)
+// 0 it's temporary closed (Useful for one access)
+ $conf['ws_durations'] = array(3650,1825,730,365,182,91,30,15,10,7,5,1,0);
+
+// +-----------------------------------------------------------------------+
+// | Filter |
+// +-----------------------------------------------------------------------+
+// $conf['filter_pages'] contains configuration for each pages
+// o If values are not defined for a specific page, default value are used
+// o Array is composed by the basename of each page without extention
+// o List of value names:
+// - used: filter function are used
+// (if false nothing is done [start, cancel, stop, ...]
+// - cancel: cancel current started filter
+// - add_notes: add notes about current started filter on the header
+// o Empty configuration in order to disable completely filter functions
+// No filter, No icon,...
+// $conf['filter_pages'] = array();
+$conf['filter_pages'] = array
+ (
+ // Default page
+ 'default' => array(
+ 'used' => true, 'cancel' => false, 'add_notes' => false),
+ // Real pages
+ 'index' => array('add_notes' => true),
+ 'tags' => array('add_notes' => true),
+ 'search' => array('add_notes' => true),
+ 'comments' => array('add_notes' => true),
+ 'admin' => array('used' => false),
+ 'feed' => array('used' => false),
+ 'notification' => array('used' => false),
+ 'nbm' => array('used' => false),
+ 'popuphelp' => array('used' => false),
+ 'profile' => array('used' => false),
+ 'web_service' => array('used' => false),
+ 'ws' => array('used' => false),
+ 'identification' => array('cancel' => true),
+ 'install' => array('cancel' => true),
+ 'password' => array('cancel' => true),
+ 'register' => array('cancel' => true),
+ 'upgrade_feed' => array('cancel' => true),
+ );
+
+// +-----------------------------------------------------------------------+
+// | Light slideshow |
+// +-----------------------------------------------------------------------+
+// $conf['light_slideshow'] indicates to use slideshow.tpl in state of
+// picture.tpl for slideshow
+// Take care to have slideshow.tpl in all available templates
+// Or set it false.
+// Check if Picture's plugins are compliant with it
+// Every plugin from 1.7 would be design to manage light_slideshow case.
+$conf['light_slideshow'] = true;
+
+?>
Index: /tags/release-1_7_0RC1/include/constants.php
===================================================================
--- /tags/release-1_7_0RC1/include/constants.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/constants.php (revision 1826)
@@ -0,0 +1,78 @@
+
Index: /tags/release-1_7_0RC1/include/feedcreator.class.php
===================================================================
--- /tags/release-1_7_0RC1/include/feedcreator.class.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/feedcreator.class.php (revision 1826)
@@ -0,0 +1,1541 @@
+useCached(); // use cached version if age<1 hour
+$rss->title = "PHP news";
+$rss->description = "daily news from the PHP scripting world";
+
+//optional
+$rss->descriptionTruncSize = 500;
+$rss->descriptionHtmlSyndicated = true;
+
+$rss->link = "http://www.dailyphp.net/news";
+$rss->syndicationURL = "http://www.dailyphp.net/".$_SERVER["PHP_SELF"];
+
+$image = new FeedImage();
+$image->title = "dailyphp.net logo";
+$image->url = "http://www.dailyphp.net/images/logo.gif";
+$image->link = "http://www.dailyphp.net";
+$image->description = "Feed provided by dailyphp.net. Click to visit.";
+
+//optional
+$image->descriptionTruncSize = 500;
+$image->descriptionHtmlSyndicated = true;
+
+$rss->image = $image;
+
+// get your news items from somewhere, e.g. your database:
+mysql_select_db($dbHost, $dbUser, $dbPass);
+$res = mysql_query("SELECT * FROM news ORDER BY newsdate DESC");
+while ($data = mysql_fetch_object($res)) {
+ $item = new FeedItem();
+ $item->title = $data->title;
+ $item->link = $data->url;
+ $item->description = $data->short;
+
+ //optional
+ item->descriptionTruncSize = 500;
+ item->descriptionHtmlSyndicated = true;
+
+ $item->date = $data->newsdate;
+ $item->source = "http://www.dailyphp.net";
+ $item->author = "John Doe";
+
+ $rss->addItem($item);
+}
+
+// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated),
+// MBOX, OPML, ATOM, ATOM0.3, HTML, JS
+echo $rss->saveFeed("RSS1.0", "news/feed.xml");
+
+
+***************************************************************************
+* A little setup *
+**************************************************************************/
+
+// your local timezone, set to "" to disable or for GMT
+define("TIME_ZONE","+01:00");
+
+
+
+
+/**
+ * Version string.
+ **/
+define("FEEDCREATOR_VERSION", "FeedCreator 1.7.2");
+
+
+
+/**
+ * A FeedItem is a part of a FeedCreator feed.
+ *
+ * @author Kai Blankenhorn
Error creating feed file, please check write permissions.
";
+ }
+ }
+
+}
+
+
+/**
+ * FeedDate is an internal class that stores a date for a feed or feed item.
+ * Usually, you won't need to use this.
+ */
+class FeedDate {
+ var $unix;
+
+ /**
+ * Creates a new instance of FeedDate representing a given date.
+ * Accepts RFC 822, ISO 8601 date formats as well as unix time stamps.
+ * @param mixed $dateString optional the date this FeedDate will represent. If not specified, the current date and time is used.
+ */
+ function FeedDate($dateString="") {
+ if ($dateString=="") $dateString = date("r");
+
+ if (is_integer($dateString)) {
+ $this->unix = $dateString;
+ return;
+ }
+ if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~",$dateString,$matches)) {
+ $months = Array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12);
+ $this->unix = mktime($matches[4],$matches[5],$matches[6],$months[$matches[2]],$matches[1],$matches[3]);
+ if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') {
+ $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60;
+ } else {
+ if (strlen($matches[7])==1) {
+ $oneHour = 3600;
+ $ord = ord($matches[7]);
+ if ($ord < ord("M")) {
+ $tzOffset = (ord("A") - $ord - 1) * $oneHour;
+ } elseif ($ord >= ord("M") AND $matches[7]!="Z") {
+ $tzOffset = ($ord - ord("M")) * $oneHour;
+ } elseif ($matches[7]=="Z") {
+ $tzOffset = 0;
+ }
+ }
+ switch ($matches[7]) {
+ case "UT":
+ case "GMT": $tzOffset = 0;
+ }
+ }
+ $this->unix += $tzOffset;
+ return;
+ }
+ if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~",$dateString,$matches)) {
+ $this->unix = mktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]);
+ if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') {
+ $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60;
+ } else {
+ if ($matches[7]=="Z") {
+ $tzOffset = 0;
+ }
+ }
+ $this->unix += $tzOffset;
+ return;
+ }
+ $this->unix = 0;
+ }
+
+ /**
+ * Gets the date stored in this FeedDate as an RFC 822 date.
+ *
+ * @return a date in RFC 822 format
+ */
+ function rfc822() {
+ //return gmdate("r",$this->unix);
+ $date = gmdate("D, d M Y H:i:s", $this->unix);
+ if (TIME_ZONE!="") $date .= " ".str_replace(":","",TIME_ZONE);
+ return $date;
+ }
+
+ /**
+ * Gets the date stored in this FeedDate as an ISO 8601 date.
+ *
+ * @return a date in ISO 8601 format
+ */
+ function iso8601() {
+ $date = gmdate("Y-m-d\TH:i:sO",$this->unix);
+ $date = substr($date,0,22) . ':' . substr($date,-2);
+ if (TIME_ZONE!="") $date = str_replace("+00:00",TIME_ZONE,$date);
+ return $date;
+ }
+
+ /**
+ * Gets the date stored in this FeedDate as unix time stamp.
+ *
+ * @return a date as a unix time stamp
+ */
+ function unix() {
+ return $this->unix;
+ }
+}
+
+
+/**
+ * RSSCreator10 is a FeedCreator that implements RDF Site Summary (RSS) 1.0.
+ *
+ * @see http://www.purl.org/rss/1.0/
+ * @since 1.3
+ * @author Kai Blankenhorn
HTML";
+
+ //optional
+ //item->descriptionTruncSize = 500;
+ $item->descriptionHtmlSyndicated = true;
+
+ $item->date = time();
+ $item->source = "http://www.dailyphp.net";
+ $item->author = "John Doe";
+
+ $rss->addItem($item);
+//}
+
+// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1, MBOX, OPML, ATOM0.3, HTML, JS
+echo $rss->saveFeed("RSS0.91", "feed.xml");
+
+
+
+***************************************************************************/
+
+?>
Index: /tags/release-1_7_0RC1/include/filter.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/filter.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/filter.inc.php (revision 1826)
@@ -0,0 +1,147 @@
+ SUBDATE(
+ CURRENT_DATE,INTERVAL '.$filter['recent_period'].' DAY)';
+
+ $filter['visible_images'] = implode(',', array_from_query($query, 'image_id'));
+
+ if (empty($filter['visible_images']))
+ {
+ // Must be not empty
+ $filter['visible_images'] = -1;
+ }
+
+ // Save filter data on session
+ pwg_set_session_var('filter_enabled', $filter['enabled']);
+ pwg_set_session_var('filter_check_key', $filter['check_key']);
+ pwg_set_session_var('filter_recent_period', $filter['recent_period']);
+ pwg_set_session_var('filter_categories', serialize($filter['categories']));
+ pwg_set_session_var('filter_visible_categories', $filter['visible_categories']);
+ pwg_set_session_var('filter_visible_images', $filter['visible_images']);
+
+ }
+ else
+ {
+ // Read only data
+ $filter['check_key'] = pwg_get_session_var('filter_check_key', '');
+ $filter['categories'] = unserialize(pwg_get_session_var('filter_categories', serialize(array())));
+ $filter['visible_categories'] = pwg_get_session_var('filter_visible_categories', '');
+ $filter['visible_images'] = pwg_get_session_var('filter_visible_images', '');
+ }
+
+ if (get_filter_page_value('add_notes'))
+ {
+ $header_notes[] = l10n_dec('note_filter_day', 'note_filter_days', $filter['recent_period']);
+ }
+}
+else
+{
+ if (pwg_get_session_var('filter_enabled', false))
+ {
+ pwg_unset_session_var('filter_enabled');
+ pwg_unset_session_var('filter_check_key');
+ pwg_unset_session_var('filter_recent_period');
+ pwg_unset_session_var('filter_categories');
+ pwg_unset_session_var('filter_visible_categories');
+ pwg_unset_session_var('filter_visible_images');
+ }
+}
+
+
+?>
Index: /tags/release-1_7_0RC1/include/functions.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/functions.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/functions.inc.php (revision 1826)
@@ -0,0 +1,1224 @@
+ $option)
+ {
+ $options[$i] = str_replace("'", '',$option);
+ }
+ }
+ }
+ mysql_free_result($result);
+ return $options;
+}
+
+// get_boolean transforms a string to a boolean value. If the string is
+// "false" (case insensitive), then the boolean value false is returned. In
+// any other case, true is returned.
+function get_boolean( $string )
+{
+ $boolean = true;
+ if ( preg_match( '/^false$/i', $string ) )
+ {
+ $boolean = false;
+ }
+ return $boolean;
+}
+
+/**
+ * returns boolean string 'true' or 'false' if the given var is boolean
+ *
+ * @param mixed $var
+ * @return mixed
+ */
+function boolean_to_string($var)
+{
+ if (is_bool($var))
+ {
+ if ($var)
+ {
+ return 'true';
+ }
+ else
+ {
+ return 'false';
+ }
+ }
+ else
+ {
+ return $var;
+ }
+}
+
+// The function get_moment returns a float value coresponding to the number
+// of seconds since the unix epoch (1st January 1970) and the microseconds
+// are precised : e.g. 1052343429.89276600
+function get_moment()
+{
+ $t1 = explode( ' ', microtime() );
+ $t2 = explode( '.', $t1[0] );
+ $t2 = $t1[1].'.'.$t2[1];
+ return $t2;
+}
+
+// The function get_elapsed_time returns the number of seconds (with 3
+// decimals precision) between the start time and the end time given.
+function get_elapsed_time( $start, $end )
+{
+ return number_format( $end - $start, 3, '.', ' ').' s';
+}
+
+// - The replace_space function replaces space and '-' characters
+// by their HTML equivalent &nbsb; and −
+// - The function does not replace characters in HTML tags
+// - This function was created because IE5 does not respect the
+// CSS "white-space: nowrap;" property unless space and minus
+// characters are replaced like this function does.
+// - Example :
+// ['.$page['count_queries'].'] ';
+ $output.= "\n".$query;
+ $output.= "\n".'(this query time : ';
+ $output.= ''.number_format($time, 3, '.', ' ').' s)';
+ $output.= "\n".'(total SQL time : ';
+ $output.= number_format($page['queries_time'], 3, '.', ' ').' s)';
+ $output.= "\n".'(total time : ';
+ $output.= number_format( ($time+$start-$t2), 3, '.', ' ').' s)';
+ $output.= "
\n";
+
+ $debug .= $output;
+ }
+
+ return $result;
+}
+
+function pwg_debug( $string )
+{
+ global $debug,$t2,$page;
+
+ $now = explode( ' ', microtime() );
+ $now2 = explode( '.', $now[0] );
+ $now2 = $now[1].'.'.$now2[1];
+ $time = number_format( $now2 - $t2, 3, '.', ' ').' s';
+ $debug .= '';
+ $error.= $header;
+ $error.= '[mysql error '.mysql_errno().'] ';
+ $error.= mysql_error();
+ $error.= '
';
+
+ if ($conf['die_on_sql_error'])
+ {
+ die($error);
+ }
+ else
+ {
+ echo $error;
+ }
+}
+
+/**
+ * creates an array based on a query, this function is a very common pattern
+ * used here
+ *
+ * @param string $query
+ * @param string $fieldname
+ * @return array
+ */
+function array_from_query($query, $fieldname)
+{
+ $array = array();
+
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($array, $row[$fieldname]);
+ }
+
+ return $array;
+}
+
+/**
+ * instantiate number list for days in a template block
+ *
+ * @param string blockname
+ * @param string selection
+ */
+function get_day_list($blockname, $selection)
+{
+ global $template;
+
+ $template->assign_block_vars(
+ $blockname,
+ array(
+ 'SELECTED' => '',
+ 'VALUE' => 0,
+ 'OPTION' => '--'
+ )
+ );
+
+ for ($i = 1; $i <= 31; $i++)
+ {
+ $selected = '';
+ if ($i == (int)$selection)
+ {
+ $selected = 'selected="selected"';
+ }
+ $template->assign_block_vars(
+ $blockname,
+ array(
+ 'SELECTED' => $selected,
+ 'VALUE' => $i,
+ 'OPTION' => str_pad($i, 2, '0', STR_PAD_LEFT)
+ )
+ );
+ }
+}
+
+/**
+ * instantiate month list in a template block
+ *
+ * @param string blockname
+ * @param string selection
+ */
+function get_month_list($blockname, $selection)
+{
+ global $template, $lang;
+
+ $template->assign_block_vars(
+ $blockname,
+ array(
+ 'SELECTED' => '',
+ 'VALUE' => 0,
+ 'OPTION' => '------------')
+ );
+
+ for ($i = 1; $i <= 12; $i++)
+ {
+ $selected = '';
+ if ($i == (int)$selection)
+ {
+ $selected = 'selected="selected"';
+ }
+ $template->assign_block_vars(
+ $blockname,
+ array(
+ 'SELECTED' => $selected,
+ 'VALUE' => $i,
+ 'OPTION' => $lang['month'][$i])
+ );
+ }
+}
+
+/**
+ * fill the current user caddie with given elements, if not already in
+ * caddie
+ *
+ * @param array elements_id
+ */
+function fill_caddie($elements_id)
+{
+ global $user;
+
+ include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+
+ $query = '
+SELECT element_id
+ FROM '.CADDIE_TABLE.'
+ WHERE user_id = '.$user['id'].'
+;';
+ $in_caddie = array_from_query($query, 'element_id');
+
+ $caddiables = array_diff($elements_id, $in_caddie);
+
+ $datas = array();
+
+ foreach ($caddiables as $caddiable)
+ {
+ array_push($datas, array('element_id' => $caddiable,
+ 'user_id' => $user['id']));
+ }
+
+ if (count($caddiables) > 0)
+ {
+ mass_inserts(CADDIE_TABLE, array('element_id','user_id'), $datas);
+ }
+}
+
+/**
+ * returns the element name from its filename
+ *
+ * @param string filename
+ * @return string name
+ */
+function get_name_from_file($filename)
+{
+ return str_replace('_',' ',get_filename_wo_extension($filename));
+}
+
+/**
+ * returns the corresponding value from $lang if existing. Else, the key is
+ * returned
+ *
+ * @param string key
+ * @return string
+ */
+function l10n($key)
+{
+ global $lang, $conf;
+
+ if ($conf['debug_l10n'] and !isset($lang[$key]))
+ {
+ echo '[l10n] language key "'.$key.'" is not defined
';
+ }
+
+ return isset($lang[$key]) ? $lang[$key] : $key;
+}
+
+/**
+ * returns the prinft value for strings including %d
+ * return is concorded with decimal value (singular, plural)
+ *
+ * @param singular string key
+ * @param plural string key
+ * @param decimal value
+ * @return string
+ */
+function l10n_dec($singular_fmt_key, $plural_fmt_key, $decimal)
+{
+ return sprintf(l10n(($decimal > 1 ? $plural_fmt_key :
+ $singular_fmt_key)), $decimal);
+}
+
+/**
+ * Translate string in string ascii7bits
+ * It's possible to do that with iconv_substr
+ * but this fonction is not avaible on all the providers.
+ *
+ * @param string str
+ * @return string
+ */
+function str_translate_to_ascii7bits($str)
+{
+ global $lang_table_translate_ascii7bits;
+
+ $src_table = array_keys($lang_table_translate_ascii7bits);
+ $dst_table = array_values($lang_table_translate_ascii7bits);
+
+ return str_replace($src_table , $dst_table, $str);
+}
+
+/**
+ * returns the corresponding value from $themeconf if existing. Else, the
+ * key is returned
+ *
+ * @param string key
+ * @return string
+ */
+function get_themeconf($key)
+{
+ global $template;
+
+ return $template->get_themeconf($key);
+}
+
+/**
+ * Returns webmaster mail address depending on $conf['webmaster_id']
+ *
+ * @return string
+ */
+function get_webmaster_mail_address()
+{
+ global $conf;
+
+ $query = '
+SELECT '.$conf['user_fields']['email'].'
+ FROM '.USERS_TABLE.'
+ WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
+;';
+ list($email) = mysql_fetch_array(pwg_query($query));
+
+ return $email;
+}
+
+/**
+ * which upgrades are available ?
+ *
+ * @return array
+ */
+function get_available_upgrade_ids()
+{
+ $upgrades_path = PHPWG_ROOT_PATH.'install/db';
+
+ $available_upgrade_ids = array();
+
+ if ($contents = opendir($upgrades_path))
+ {
+ while (($node = readdir($contents)) !== false)
+ {
+ if (is_file($upgrades_path.'/'.$node)
+ and preg_match('/^(.*?)-database\.php$/', $node, $match))
+ {
+ array_push($available_upgrade_ids, $match[1]);
+ }
+ }
+ }
+ natcasesort($available_upgrade_ids);
+
+ return $available_upgrade_ids;
+}
+
+/**
+ * Add configuration parameters from database to global $conf array
+ *
+ * @return void
+ */
+function load_conf_from_db($condition = '')
+{
+ global $conf;
+
+ $query = '
+SELECT param, value
+ FROM '.CONFIG_TABLE.'
+ '.(!empty($condition) ? 'WHERE '.$condition : '').'
+;';
+ $result = pwg_query($query);
+
+ if ((mysql_num_rows($result) == 0) and !empty($condition))
+ {
+ die('No configuration data');
+ }
+
+ while ($row = mysql_fetch_array($result))
+ {
+ $conf[ $row['param'] ] = isset($row['value']) ? $row['value'] : '';
+
+ // If the field is true or false, the variable is transformed into a
+ // boolean value.
+ if ($conf[$row['param']] == 'true' or $conf[$row['param']] == 'false')
+ {
+ $conf[ $row['param'] ] = get_boolean($conf[ $row['param'] ]);
+ }
+ }
+}
+
+/**
+ * Prepends and appends a string at each value of the given array.
+ *
+ * @param array
+ * @param string prefix to each array values
+ * @param string suffix to each array values
+ */
+function prepend_append_array_items($array, $prepend_str, $append_str)
+{
+ array_walk(
+ $array,
+ create_function('&$s', '$s = "'.$prepend_str.'".$s."'.$append_str.'";')
+ );
+
+ return $array;
+}
+
+/**
+ * creates an hashed based on a query, this function is a very common
+ * pattern used here. Among the selected columns fetched, choose one to be
+ * the key, another one to be the value.
+ *
+ * @param string $query
+ * @param string $keyname
+ * @param string $valuename
+ * @return array
+ */
+function simple_hash_from_query($query, $keyname, $valuename)
+{
+ $array = array();
+
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ $array[ $row[$keyname] ] = $row[$valuename];
+ }
+
+ return $array;
+}
+
+/**
+ * Return basename of the current script
+ * Lower case convertion is applied on return value
+ * Return value is without file extention ".php"
+ *
+ * @param void
+ *
+ * @return script basename
+ */
+function script_basename()
+{
+ if (!empty($_SERVER['SCRIPT_NAME']))
+ {
+ $file_name = $_SERVER['SCRIPT_NAME'];
+ }
+ else if (!empty($_SERVER['SCRIPT_FILENAME']))
+ {
+ $file_name = $_SERVER['SCRIPT_FILENAME'];
+ }
+ else
+ {
+ $file_name = '';
+ }
+
+ // $_SERVER return lower string following var and systems
+ return basename(strtolower($file_name), '.php');
+}
+
+/**
+ * Return value for the current page define on $conf['filter_pages']
+ * Îf value is not defined, default value are returned
+ *
+ * @param value name
+ *
+ * @return filter page value
+ */
+function get_filter_page_value($value_name)
+{
+ global $conf;
+
+ $page_name = script_basename();
+
+ if (isset($conf['filter_pages'][$page_name][$value_name]))
+ {
+ return $conf['filter_pages'][$page_name][$value_name];
+ }
+ else if (isset($conf['filter_pages']['default'][$value_name]))
+ {
+ return $conf['filter_pages']['default'][$value_name];
+ }
+ else
+ {
+ return null;
+ }
+}
+
+?>
Index: /tags/release-1_7_0RC1/include/functions_calendar.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/functions_calendar.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/functions_calendar.inc.php (revision 1826)
@@ -0,0 +1,296 @@
+ 'id'
+ ),
+ 'AND', false
+ );
+ }
+ else
+ {
+ $inner_sql .= '
+ '.get_sql_condition_FandF
+ (
+ array
+ (
+ 'forbidden_categories' => 'category_id',
+ 'visible_categories' => 'category_id',
+ 'visible_images' => 'id'
+ ),
+ 'WHERE', true
+ );
+ }
+ }
+ else
+ {
+ if ( empty($page['items']) )
+ {
+ return; // nothing to do
+ }
+ $inner_sql .= '
+WHERE id IN (' . implode(',',$page['items']) .')';
+ }
+
+//-------------------------------------- initialize the calendar parameters ---
+ pwg_debug('start initialize_calendar');
+
+ $fields = array(
+ // Created
+ 'created' => array(
+ 'label' => l10n('Creation date'),
+ ),
+ // Posted
+ 'posted' => array(
+ 'label' => l10n('Post date'),
+ ),
+ );
+
+ $styles = array(
+ // Monthly style
+ 'monthly' => array(
+ 'include' => 'calendar_monthly.class.php',
+ 'view_calendar' => true,
+ ),
+ // Weekly style
+ 'weekly' => array(
+ 'include' => 'calendar_weekly.class.php',
+ 'view_calendar' => false,
+ ),
+ );
+
+ $views = array(CAL_VIEW_LIST,CAL_VIEW_CALENDAR);
+
+ // Retrieve calendar field
+ if ( !isset( $fields[ $page['chronology_field'] ] ) )
+ {
+ die('bad chronology field');
+ }
+
+ // Retrieve style
+ if ( !isset( $styles[ $page['chronology_style'] ] ) )
+ {
+ $page['chronology_style'] = 'monthly';
+ }
+ $cal_style = $page['chronology_style'];
+ include(PHPWG_ROOT_PATH.'include/'. $styles[$cal_style]['include']);
+ $calendar = new Calendar();
+
+ // Retrieve view
+
+ if ( !isset($page['chronology_view']) or
+ !in_array( $page['chronology_view'], $views ) )
+ {
+ $page['chronology_view'] = CAL_VIEW_LIST;
+ }
+
+ if ( CAL_VIEW_CALENDAR==$page['chronology_view'] and
+ !$styles[$cal_style]['view_calendar'] )
+ {
+
+ $page['chronology_view'] = CAL_VIEW_LIST;
+ }
+
+ // perform a sanity check on $requested
+ if (!isset($page['chronology_date']))
+ {
+ $page['chronology_date'] = array();
+ }
+ while ( count($page['chronology_date']) > 3)
+ {
+ array_pop($page['chronology_date']);
+ }
+
+ $any_count = 0;
+ for ($i = 0; $i < count($page['chronology_date']); $i++)
+ {
+ if ($page['chronology_date'][$i] == 'any')
+ {
+ if ($page['chronology_view'] == CAL_VIEW_CALENDAR)
+ {// we dont allow any in calendar view
+ while ($i < count($page['chronology_date']))
+ {
+ array_pop($page['chronology_date']);
+ }
+ break;
+ }
+ $any_count++;
+ }
+ elseif ($page['chronology_date'][$i] == '')
+ {
+ while ($i < count($page['chronology_date']))
+ {
+ array_pop($page['chronology_date']);
+ }
+ }
+ else
+ {
+ $page['chronology_date'][$i] = (int)$page['chronology_date'][$i];
+ }
+ }
+ if ($any_count == 3)
+ {
+ array_pop($page['chronology_date']);
+ }
+
+ $calendar->initialize($inner_sql);
+
+ //echo (''. var_export($calendar, true) . '
');
+
+ $must_show_list = true; // true until calendar generates its own display
+ if (script_basename() != 'picture') // basename without file extention
+ {
+ if ($calendar->generate_category_content())
+ {
+ $page['items'] = array();
+ $must_show_list = false;
+ }
+
+ foreach ($styles as $style => $style_data)
+ {
+ foreach ($views as $view)
+ {
+ if ( $style_data['view_calendar'] or $view != CAL_VIEW_CALENDAR)
+ {
+ $selected = '';
+
+ if ($style!=$cal_style)
+ {
+ $chronology_date = array();
+ if ( isset($page['chronology_date'][0]) )
+ {
+ array_push($chronology_date, $page['chronology_date'][0]);
+ }
+ }
+ else
+ {
+ $chronology_date = $page['chronology_date'];
+ }
+ $url = duplicate_index_url(
+ array(
+ 'chronology_style' => $style,
+ 'chronology_view' => $view,
+ 'chronology_date' => $chronology_date,
+ )
+ );
+
+ if ($style==$cal_style and $view==$page['chronology_view'] )
+ {
+ $selected = 'SELECTED';
+ }
+
+ $template->assign_block_vars(
+ 'calendar.views.view',
+ array(
+ 'VALUE' => $url,
+ 'CONTENT' => l10n('chronology_'.$style.'_'.$view),
+ 'SELECTED' => $selected,
+ )
+ );
+ }
+ }
+ }
+ $url = duplicate_index_url(
+ array(), array('start', 'chronology_date')
+ );
+ $calendar_title = ''
+ .$fields[$page['chronology_field']]['label'].'';
+ $calendar_title.= $calendar->get_display_name();
+ $template->merge_block_vars('calendar',
+ array(
+ 'TITLE' => $calendar_title
+ )
+ );
+ } // end category calling
+
+ if ($must_show_list)
+ {
+ $query = 'SELECT DISTINCT(id)';
+ $query .= $calendar->inner_sql.'
+ '.$calendar->get_date_where();
+ if ( isset($page['super_order_by']) )
+ {
+ $query .= '
+ '.$conf['order_by'];
+ }
+ else
+ {
+ if ( count($page['chronology_date'])==0
+ or in_array('any', $page['chronology_date']) )
+ {// selected period is very big so we show newest first
+ $order = ' DESC, ';
+ }
+ else
+ {// selected period is small (month,week) so we show oldest first
+ $order = ' ASC, ';
+ }
+ $order_by = str_replace(
+ 'ORDER BY ',
+ 'ORDER BY '.$calendar->date_field.$order, $conf['order_by']
+ );
+ $query .= '
+ '.$order_by;
+ }
+ $page['items'] = array_from_query($query, 'id');
+ }
+ pwg_debug('end initialize_calendar');
+}
+
+?>
Index: /tags/release-1_7_0RC1/include/functions_category.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/functions_category.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/functions_category.inc.php (revision 1826)
@@ -0,0 +1,417 @@
+ restriction)
+ if (in_array($category_id, explode(',', $user['forbidden_categories'])))
+ {
+ access_denied();
+ }
+}
+
+function get_categories_menu()
+{
+ global $page, $user, $filter;
+
+ $query = '
+SELECT ';
+ // From CATEGORIES_TABLE
+ $query.= '
+ name, id, nb_images, global_rank,';
+ // From USER_CACHE_CATEGORIES_TABLE
+ $query.= '
+ date_last, max_date_last, count_images, count_categories';
+
+ // $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
+ $query.= '
+FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
+ ON id = cat_id and user_id = '.$user['id'];
+
+ // Always expand when filter is activated
+ if (!$user['expand'] and !$filter['enabled'])
+ {
+ $query.= '
+WHERE
+(id_uppercat is NULL';
+ if (isset($page['category']))
+ {
+ $query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
+ }
+ $query.= ')';
+ }
+ else
+ {
+ $query.= '
+ '.get_sql_condition_FandF
+ (
+ array
+ (
+ 'visible_categories' => 'id',
+ ),
+ 'WHERE'
+ );
+ }
+
+ $query.= '
+;';
+
+ $result = pwg_query($query);
+ $cats = array();
+ while ($row = mysql_fetch_assoc($result))
+ {
+ array_push($cats, $row);
+ }
+ usort($cats, 'global_rank_compare');
+
+ // Update filtered data
+ if (function_exists('update_cats_with_filtered_data'))
+ {
+ update_cats_with_filtered_data($cats);
+ }
+
+ return get_html_menu_category($cats);
+}
+
+
+/**
+ * Retrieve informations about a category in the database
+ *
+ * Returns an array with following keys :
+ *
+ * - comment
+ * - dir : directory, might be empty for virtual categories
+ * - name : an array with indexes from 0 (lowest cat name) to n (most
+ * uppercat name findable)
+ * - nb_images
+ * - id_uppercat
+ * - site_id
+ * -
+ *
+ * @param int category id
+ * @return array
+ */
+function get_cat_info( $id )
+{
+ $infos = array('nb_images','id_uppercat','comment','site_id'
+ ,'dir','date_last','uploadable','status','visible'
+ ,'representative_picture_id','uppercats','commentable'
+ ,'image_order');
+
+ $query = '
+SELECT '.implode(',', $infos).'
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id = '.$id.'
+;';
+ $row = mysql_fetch_array(pwg_query($query));
+ if (empty($row))
+ return null;
+
+ $cat = array();
+ foreach ($infos as $info)
+ {
+ if (isset($row[$info]))
+ {
+ $cat[$info] = $row[$info];
+ }
+ else
+ {
+ $cat[$info] = '';
+ }
+ // If the field is true or false, the variable is transformed into a
+ // boolean value.
+ if ($cat[$info] == 'true' or $cat[$info] == 'false')
+ {
+ $cat[$info] = get_boolean( $cat[$info] );
+ }
+ }
+ global $conf;
+ if ( !( $conf['allow_html_descriptions'] and
+ preg_match('/<(div|br|img|script).*>/i', $cat['comment']) ) )
+ {
+ $cat['comment'] = nl2br($cat['comment']);
+ }
+
+ $names = array();
+ $query = '
+SELECT name,id
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id IN ('.$cat['uppercats'].')
+;';
+ $result = pwg_query($query);
+ while($row = mysql_fetch_array($result))
+ {
+ $names[$row['id']] = $row['name'];
+ }
+
+ // category names must be in the same order than uppercats list
+ $cat['name'] = array();
+ foreach (explode(',', $cat['uppercats']) as $cat_id)
+ {
+ $cat['name'][$cat_id] = $names[$cat_id];
+ }
+
+ return $cat;
+}
+
+// get_complete_dir returns the concatenation of get_site_url and
+// get_local_dir
+// Example : "pets > rex > 1_year_old" is on the the same site as the
+// PhpWebGallery files and this category has 22 for identifier
+// get_complete_dir(22) returns "./galleries/pets/rex/1_year_old/"
+function get_complete_dir( $category_id )
+{
+ return get_site_url($category_id).get_local_dir($category_id);
+}
+
+// get_local_dir returns an array with complete path without the site url
+// Example : "pets > rex > 1_year_old" is on the the same site as the
+// PhpWebGallery files and this category has 22 for identifier
+// get_local_dir(22) returns "pets/rex/1_year_old/"
+function get_local_dir( $category_id )
+{
+ global $page;
+
+ $uppercats = '';
+ $local_dir = '';
+
+ if ( isset( $page['plain_structure'][$category_id]['uppercats'] ) )
+ {
+ $uppercats = $page['plain_structure'][$category_id]['uppercats'];
+ }
+ else
+ {
+ $query = 'SELECT uppercats';
+ $query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$category_id;
+ $query.= ';';
+ $row = mysql_fetch_array( pwg_query( $query ) );
+ $uppercats = $row['uppercats'];
+ }
+
+ $upper_array = explode( ',', $uppercats );
+
+ $database_dirs = array();
+ $query = 'SELECT id,dir';
+ $query.= ' FROM '.CATEGORIES_TABLE.' WHERE id IN ('.$uppercats.')';
+ $query.= ';';
+ $result = pwg_query( $query );
+ while( $row = mysql_fetch_array( $result ) )
+ {
+ $database_dirs[$row['id']] = $row['dir'];
+ }
+ foreach ($upper_array as $id)
+ {
+ $local_dir.= $database_dirs[$id].'/';
+ }
+
+ return $local_dir;
+}
+
+// retrieving the site url : "http://domain.com/gallery/" or
+// simply "./galleries/"
+function get_site_url($category_id)
+{
+ global $page;
+
+ $query = '
+SELECT galleries_url
+ FROM '.SITES_TABLE.' AS s,'.CATEGORIES_TABLE.' AS c
+ WHERE s.id = c.site_id
+ AND c.id = '.$category_id.'
+;';
+ $row = mysql_fetch_array(pwg_query($query));
+ return $row['galleries_url'];
+}
+
+// returns an array of image orders available for users/visitors
+function get_category_preferred_image_orders()
+{
+ global $conf;
+ return array(
+ array(l10n('default_sort'), '', true),
+ array(l10n('Average rate'), 'average_rate DESC', $conf['rate']),
+ array(l10n('most_visited_cat'), 'hit DESC', true),
+ array(l10n('Creation date'), 'date_creation DESC', true),
+ array(l10n('Post date'), 'date_available DESC', true),
+ array(l10n('File name'), 'file ASC', true)
+ );
+}
+
+function display_select_categories($categories,
+ $selecteds,
+ $blockname,
+ $fullname = true)
+{
+ global $template;
+
+ foreach ($categories as $category)
+ {
+ $selected = '';
+ if (in_array($category['id'], $selecteds))
+ {
+ $selected = ' selected="selected"';
+ }
+
+ if ($fullname)
+ {
+ $option = get_cat_display_name_cache($category['uppercats'],
+ null,
+ false);
+ }
+ else
+ {
+ $option = str_repeat(' ',
+ (3 * substr_count($category['global_rank'], '.')));
+ $option.= '- '.$category['name'];
+ }
+
+ $template->assign_block_vars(
+ $blockname,
+ array('SELECTED'=>$selected,
+ 'VALUE'=>$category['id'],
+ 'OPTION'=>$option
+ ));
+ }
+}
+
+function display_select_cat_wrapper($query, $selecteds, $blockname,
+ $fullname = true)
+{
+ $result = pwg_query($query);
+ $categories = array();
+ if (!empty($result))
+ {
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($categories, $row);
+ }
+ }
+ usort($categories, 'global_rank_compare');
+ display_select_categories($categories, $selecteds, $blockname, $fullname);
+}
+
+/**
+ * returns all subcategory identifiers of given category ids
+ *
+ * @param array ids
+ * @return array
+ */
+function get_subcat_ids($ids)
+{
+ $query = '
+SELECT DISTINCT(id)
+ FROM '.CATEGORIES_TABLE.'
+ WHERE ';
+ foreach ($ids as $num => $category_id)
+ {
+ if ($num > 0)
+ {
+ $query.= '
+ OR ';
+ }
+ $query.= 'uppercats REGEXP \'(^|,)'.$category_id.'(,|$)\'';
+ }
+ $query.= '
+;';
+ $result = pwg_query($query);
+
+ $subcats = array();
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($subcats, $row['id']);
+ }
+ return $subcats;
+}
+
+function global_rank_compare($a, $b)
+{
+ return strnatcasecmp($a['global_rank'], $b['global_rank']);
+}
+
+function rank_compare($a, $b)
+{
+ if ($a['rank'] == $b['rank'])
+ {
+ return 0;
+ }
+
+ return ($a['rank'] < $b['rank']) ? -1 : 1;
+}
+
+/**
+ * returns display text for information images of category
+ *
+ * @param array categories
+ * @return string
+ */
+function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_categories, $short_message = true)
+{
+ $display_text = '';
+
+ // Count of category is main
+ // if not picture on categorie, test on sub-categories
+ $count = ($cat_nb_images > 0 ? $cat_nb_images : $cat_count_images);
+
+ if ($count > 0)
+ {
+ $display_text.= l10n_dec('image_available', 'images_available', $count);
+
+ if ($cat_nb_images > 0)
+ {
+ if (! $short_message)
+ {
+ $display_text.= ' '.l10n('images_available_cpl');
+ }
+ }
+ else
+ {
+ $display_text.= ' '.l10n_dec('images_available_cat', 'images_available_cats', $cat_count_categories);
+ }
+ }
+
+ return $display_text;
+}
+
+?>
Index: /tags/release-1_7_0RC1/include/functions_filter.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/functions_filter.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/functions_filter.inc.php (revision 1826)
@@ -0,0 +1,66 @@
+ $category)
+ {
+ foreach ($upd_fields as $upd_field)
+ {
+ $cats[$cat_id][$upd_field] = $filter['categories'][$category['id']][$upd_field];
+ }
+ }
+ }
+}
+
+?>
Index: /tags/release-1_7_0RC1/include/functions_group.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/functions_group.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/functions_group.inc.php (revision 1826)
@@ -0,0 +1,30 @@
+
Index: /tags/release-1_7_0RC1/include/functions_html.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/functions_html.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/functions_html.inc.php (revision 1826)
@@ -0,0 +1,730 @@
+ 'recent', true => 'recent_by_child' );
+ $title = $lang['recent_image'].' '.$user['recent_period']
+ .' '.$lang['days'];
+ foreach ($icons as $key => $icon)
+ {
+ $icon_url = get_themeconf('icon_dir').'/'.$icon.'.png';
+ $size = getimagesize( PHPWG_ROOT_PATH.$icon_url );
+ $icon_url = get_root_url().$icon_url;
+ $output = '';
+ $page['get_icon_cache']['_icons_'][$key] = $output;
+ }
+ }
+ $page['get_icon_cache'][$date] = true;
+ }
+ if (! $page['get_icon_cache'][$date] )
+ return '';
+ return $page['get_icon_cache']['_icons_'][$is_child_date];
+}
+
+
+function create_navigation_bar(
+ $url, $nb_element, $start, $nb_element_page, $clean_url = false
+ )
+{
+ global $lang, $conf;
+
+ $pages_around = $conf['paginate_pages_around'];
+ $start_str = $clean_url ? '/start-' :
+ ( ( strstr($url, '?')===false ? '?':'&') . 'start=' );
+
+ $navbar = '';
+
+ // current page detection
+ if (!isset($start)
+ or !is_numeric($start)
+ or (is_numeric($start) and $start < 0))
+ {
+ $start = 0;
+ }
+
+ // navigation bar useful only if more than one page to display !
+ if ($nb_element > $nb_element_page)
+ {
+ // current page and last page
+ $cur_page = ceil($start / $nb_element_page) + 1;
+ $maximum = ceil($nb_element / $nb_element_page);
+
+ // link to first page ?
+ if ($cur_page != 1)
+ {
+ $navbar.=
+ ''
+ .$lang['first_page']
+ .'';
+ }
+ else
+ {
+ $navbar.= $lang['first_page'];
+ }
+ $navbar.= ' | ';
+ // link on previous page ?
+ if ($start != 0)
+ {
+ $previous = $start - $nb_element_page;
+
+ $navbar.=
+ ''
+ .$lang['previous_page']
+ .'';
+ }
+ else
+ {
+ $navbar.= $lang['previous_page'];
+ }
+ $navbar.= ' |';
+
+ if ($cur_page > $pages_around + 1)
+ {
+ $navbar.= ' 1';
+
+ if ($cur_page > $pages_around + 2)
+ {
+ $navbar.= ' ...';
+ }
+ }
+
+ // inspired from punbb source code
+ for ($i = $cur_page - $pages_around, $stop = $cur_page + $pages_around + 1;
+ $i < $stop;
+ $i++)
+ {
+ if ($i < 1 or $i > $maximum)
+ {
+ continue;
+ }
+ else if ($i != $cur_page)
+ {
+ $temp_start = ($i - 1) * $nb_element_page;
+
+ $navbar.=
+ ' '
+ .''
+ .$i
+ .'';
+ }
+ else
+ {
+ $navbar.=
+ ' '
+ .''
+ .$i
+ .'';
+ }
+ }
+
+ if ($cur_page < ($maximum - $pages_around))
+ {
+ $temp_start = ($maximum - 1) * $nb_element_page;
+
+ if ($cur_page < ($maximum - $pages_around - 1))
+ {
+ $navbar.= ' ...';
+ }
+
+ $navbar.= ' '.$maximum.'';
+ }
+
+ $navbar.= ' | ';
+ // link on next page ?
+ if ($nb_element > $nb_element_page
+ and $start + $nb_element_page < $nb_element)
+ {
+ $next = $start + $nb_element_page;
+
+ $navbar.=
+ ''
+ .$lang['next_page']
+ .'';
+ }
+ else
+ {
+ $navbar.= $lang['next_page'];
+ }
+
+ $navbar.= ' | ';
+ // link to last page ?
+ if ($cur_page != $maximum)
+ {
+ $temp_start = ($maximum - 1) * $nb_element_page;
+
+ $navbar.=
+ ''
+ .$lang['last_page']
+ .'';
+ }
+ else
+ {
+ $navbar.= $lang['last_page'];
+ }
+ }
+ return $navbar;
+}
+
+//
+// Pick a language, any language ...
+//
+function language_select($default, $select_name = "language")
+{
+ $available_lang = get_languages();
+
+ $lang_select = '';
+
+ return $lang_select;
+}
+
+/**
+ * returns the list of categories as a HTML string
+ *
+ * categories string returned contains categories as given in the input
+ * array $cat_informations. $cat_informations array must be an association
+ * of {category_id => category_name}. If url input parameter is null,
+ * returns only the categories name without links.
+ *
+ * @param array cat_informations
+ * @param string url
+ * @param boolean replace_space
+ * @return string
+ */
+function get_cat_display_name($cat_informations,
+ $url = '',
+ $replace_space = true)
+{
+ global $conf;
+
+ $output = '';
+ $is_first = true;
+ foreach ($cat_informations as $id => $name)
+ {
+ if ($is_first)
+ {
+ $is_first = false;
+ }
+ else
+ {
+ $output.= $conf['level_separator'];
+ }
+
+ if ( !isset($url) )
+ {
+ $output.= $name;
+ }
+ elseif ($url == '')
+ {
+ $output.= '';
+ $output.= $name.'';
+ }
+ else
+ {
+ $output.= '';
+ $output.= $name.'';
+ }
+ }
+ if ($replace_space)
+ {
+ return replace_space($output);
+ }
+ else
+ {
+ return $output;
+ }
+}
+
+/**
+ * returns the list of categories as a HTML string, with cache of names
+ *
+ * categories string returned contains categories as given in the input
+ * array $cat_informations. $uppercats is the list of category ids to
+ * display in the right order. If url input parameter is empty, returns only
+ * the categories name without links.
+ *
+ * @param string uppercats
+ * @param string url
+ * @param boolean replace_space
+ * @return string
+ */
+function get_cat_display_name_cache($uppercats,
+ $url = '',
+ $replace_space = true)
+{
+ global $cat_names, $conf;
+
+ if (!isset($cat_names))
+ {
+ $query = '
+SELECT id,name
+ FROM '.CATEGORIES_TABLE.'
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ $cat_names[$row['id']] = $row['name'];
+ }
+ }
+
+ $output = '';
+ $is_first = true;
+ foreach (explode(',', $uppercats) as $category_id)
+ {
+ $name = $cat_names[$category_id];
+
+ if ($is_first)
+ {
+ $is_first = false;
+ }
+ else
+ {
+ $output.= $conf['level_separator'];
+ }
+
+ if ( !isset($url) )
+ {
+ $output.= $name;
+ }
+ elseif ($url == '')
+ {
+ $output.= '
+'.$name.'';
+ }
+ else
+ {
+ $output.= '
+'.$name.'';
+ }
+ }
+ if ($replace_space)
+ {
+ return replace_space($output);
+ }
+ else
+ {
+ return $output;
+ }
+}
+
+/**
+ * returns the HTML code for a category item in the menu (for the main page)
+ *
+ * HTML code generated uses logical list tags ul and each category is an
+ * item li. The paramter given is the category informations as an array,
+ * used keys are : id, name, nb_images, max_date_last, date_last
+ * count_images, count_categories
+ *
+ * @param array categories
+ * @return string
+ */
+function get_html_menu_category($categories)
+{
+ global $page, $lang;
+
+ $ref_level = 0;
+ $level = 0;
+ $menu = '';
+
+ // $page_cat value remains 0 for special sections
+ $page_cat = 0;
+ if (isset($page['category']))
+ {
+ $page_cat = $page['category'];
+ }
+
+ foreach ($categories as $category)
+ {
+ $level = substr_count($category['global_rank'], '.') + 1;
+ if ($level > $ref_level)
+ {
+ $menu.= "\n";
+ }
+ else if ($level == $ref_level)
+ {
+ $menu.= "\n";
+ }
+ else if ($level < $ref_level)
+ {
+ // we may have to close more than one level at the same time...
+ $menu.= "\n";
+ $menu.= str_repeat("\n
",($ref_level-$level));
+ }
+ $ref_level = $level;
+
+ $menu.= "\n\n".'';
+ foreach ($tags as $tag)
+ {
+ $output.=
+ '
';
+
+ return $output;
+}
+
+function name_compare($a, $b)
+{
+ return strcmp(strtolower($a['name']), strtolower($b['name']));
+}
+
+/**
+ * exits the current script (either exit or redirect)
+ */
+function access_denied()
+{
+ global $user, $lang;
+
+ $login_url =
+ get_root_url().'identification.php?redirect='
+ .urlencode(urlencode($_SERVER['REQUEST_URI']));
+
+ if ( isset($user['is_the_guest']) and !$user['is_the_guest'] )
+ {
+ echo '';
+ exit();
+ }
+ else
+ {
+ set_status_header(401);
+ redirect_html($login_url);
+ }
+}
+
+/**
+ * exits the current script with 403 code
+ * @param string msg a message to display
+ * @param string alternate_url redirect to this url
+ */
+function page_forbidden($msg, $alternate_url=null)
+{
+ set_status_header(403);
+ if ($alternate_url==null)
+ $alternate_url = make_index_url();
+ redirect_html( $alternate_url,
+ 'Forbidden
'
+.$msg.'Page not found
'
+.$msg.'
';
+
+ foreach($date_detail['elements'] as $element)
+ {
+ $tn_src = get_thumbnail_url($element);
+ $description .= '';
+ }
+ $description .= '...
';
+
+ $description .=
+ '';
+ foreach($date_detail['categories'] as $cat)
+ {
+ $description .=
+ '
';
+
+ return $description;
+}
+
+/**
+ * explodes a MySQL datetime format (2005-07-14 23:01:37) in fields "year",
+ * "month", "day", "hour", "minute", "second".
+ *
+ * @param string mysql datetime format
+ * @return array
+ */
+function explode_mysqldt($mysqldt)
+{
+ $date = array();
+ list($date['year'],
+ $date['month'],
+ $date['day'],
+ $date['hour'],
+ $date['minute'],
+ $date['second'])
+ = preg_split('/[-: ]/', $mysqldt);
+
+ return $date;
+}
+
+/**
+ * returns title about recently published elements grouped by post date
+ * @param $date_detail: selected date computed by get_recent_post_dates function
+ */
+function get_title_recent_post_date($date_detail)
+{
+ global $lang;
+
+ $date = $date_detail['date_available'];
+ $exploded_date = explode_mysqldt($date);
+
+ $title = l10n_dec('%d new element', '%d new elements', $date_detail['nb_elements']);
+ $title .= ' ('.$lang['month'][(int)$exploded_date['month']].' '.$exploded_date['day'].')';
+
+ return $title;
+}
+
+?>
Index: /tags/release-1_7_0RC1/include/functions_picture.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/functions_picture.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/functions_picture.inc.php (revision 1826)
@@ -0,0 +1,222 @@
+ $element_info['id'],
+ 'part' => $what_part,
+ )
+ );
+ return trigger_event( 'get_download_url', $url, $element_info);
+}
+
+?>
Index: /tags/release-1_7_0RC1/include/functions_plugins.inc.php
===================================================================
--- /tags/release-1_7_0RC1/include/functions_plugins.inc.php (revision 1826)
+++ /tags/release-1_7_0RC1/include/functions_plugins.inc.php (revision 1826)
@@ -0,0 +1,287 @@
+$func,
+ 'accepted_args'=>$accepted_args);
+ ksort( $pwg_event_handlers[$event] );
+ return true;
+}
+
+/* Register a event handler.
+ * @param string $event the name of the event to listen to
+ * @param mixed $func the function that needs removal
+ * @param int $priority optional priority (greater priority will
+ * be executed at last)
+*/
+function remove_event_handler($event, $func,
+ $priority=EVENT_HANDLER_PRIORITY_NEUTRAL)
+{
+ global $pwg_event_handlers;
+
+ if (!isset( $pwg_event_handlers[$event][$priority] ) )
+ {
+ return false;
+ }
+ for ($i=0; $i