function language_controler_flags() { global $user, $template, $conf, $page; $available_lang = get_languages(); if (isset($conf['no_flag_languages'])) { $available_lang = array_diff_key($available_lang, array_flip($conf['no_flag_languages'])); } $url_starting = get_query_string_diff(array('lang')); if (isset($page['section']) and $page['section'] == 'additional_page' and isset($page['additional_page'])) { $base_url = make_index_url(array('section' => 'page')) . '/' . (isset($page['additional_page']['permalink']) ? $page['additional_page']['permalink'] : $page['additional_page']['id']); } else { $base_url = duplicate_index_url(); } foreach ($available_lang as $code => $displayname) { $qlc = array('url' => add_url_params($base_url, array('lang' => $code)), 'alt' => ucwords($displayname), 'title' => substr($displayname, 0, -4), 'code' => $code); $lsw['flags'][$code] = $qlc; if ($code == $user['language']) { $lsw['Active'] = $qlc; } } $safe_themes = array('clear', 'dark', 'elegant', 'Sylvia', 'simple-grey', 'simple-black', 'simple-white', 'kardon', 'luciano', 'montblancxl'); // stripped (2.6) $template->assign(array('lang_switch' => $lsw, 'LANGUAGE_SWITCH_PATH' => LANGUAGE_SWITCH_PATH, 'LANGUAGE_SWITCH_LOAD_STYLE' => !in_array($user['theme'], $safe_themes))); $template->set_filename('language_flags', dirname(__FILE__) . '/flags.tpl'); $template->concat('PLUGIN_INDEX_ACTIONS', $template->parse('language_flags', true)); $template->clear_assign('lang_switch'); }
/** * Triggered on loc_begin_index * * Perform user logout after registration if account locked and redirection to profile page is password renewal is set */ function PP_Init() { global $conf, $user; include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; $conf_PP = unserialize($conf['PasswordPolicy']); // Perfoming redirection for locked accounts // ----------------------------------------- if (!is_a_guest() and $user['username'] != "16" and $user['username'] != "18") { // Perform user logout if user account is locked if (isset($conf_PP['LOGFAILBLOCK']) and $conf_PP['LOGFAILBLOCK'] == 'true' and PP_UsrBlock_Verif($user['username']) and !is_admin() and !is_webmaster()) { invalidate_user_cache(); logout_user(); if ($conf['guest_access']) { redirect(make_index_url() . '?PP_msg=locked', 0); } else { redirect(get_root_url() . 'identification.php?PP_msg=locked', 0); } } } // Performing redirection to profile page for password reset // --------------------------------------------------------- if (isset($conf_PP['PWDRESET']) and $conf_PP['PWDRESET'] == 'true') { $query = ' SELECT user_id, status FROM ' . USER_INFOS_TABLE . ' WHERE user_id = ' . $user['id'] . ' ;'; $data = pwg_db_fetch_assoc(pwg_query($query)); if ($data['status'] != "webmaster" and $data['status'] != "generic") { if (PP_check_pwdreset($user['id'])) { redirect(PHPWG_ROOT_PATH . 'profile.php'); } } } }
function tg_groups_display() { global $conf, $template, $user, $tags, $page; load_language('plugin.lang', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); load_language('lang', PHPWG_ROOT_PATH . PWG_LOCAL_DIR, array('no_fallback' => true, 'local' => true)); $template->set_prefilter('tags', 'tg_add_display_link_prefilter'); $template->assign('U_TAG_GROUPS', get_root_url() . 'tags.php?display_mode=groups'); if ($page['tg_display']) { // echo __FILE__.'::'.__LINE__.' display_mode=groups<br>'; $template->set_prefilter('tags', 'tg_groups_display_prefilter'); $template->assign('display_mode', 'groups'); // we want tags diplayed in alphabetic order usort($tags, 'tag_alpha_compare'); $current_tag_group = null; $nb_tags = count($tags); $current_column = 1; $current_tag_idx = 0; $tag_group = array('tags' => array()); foreach ($tags as $tag) { // if the tag belongs to no group, we don't show it on the "tag by // group" display mode if (strpos($tag['name'], ':') === false) { continue; } else { list($tag['group'], $tag['name']) = explode(':', $tag['name'], 2); $tag['group'] = preg_replace('/^[^=]*=/', '', $tag['group']); } if ($current_tag_idx == 0) { $current_tag_group = $tag['group']; $tag_group['TITLE'] = $tag['group']; } // new group? if ($tag['group'] !== $current_tag_group) { if ($current_column < $conf['tag_letters_column_number'] and $current_tag_idx > $current_column * $nb_tags / $conf['tag_letters_column_number']) { $tag_group['CHANGE_COLUMN'] = true; $current_column++; } $tag_group['TITLE'] = $current_tag_group; $template->append('tag_groups', $tag_group); $current_tag_group = $tag['group']; $tag_group = array('tags' => array()); } array_push($tag_group['tags'], array_merge($tag, array('URL' => make_index_url(array('tags' => array($tag)))))); $current_tag_idx++; } // flush last group if (count($tag_group['tags']) > 0) { unset($tag_group['CHANGE_COLUMN']); $tag_group['TITLE'] = $current_tag_group; $template->append('tag_groups', $tag_group); } } }
function osm_render_category() { global $template, $page, $conf, $filter; include_once dirname(__FILE__) . '/include/functions.php'; include_once dirname(__FILE__) . '/include/functions_map.php'; osm_load_language(); load_language('plugin.lang', OSM_PATH); // TF, 20160102: pass config as parameter $js_data = osm_get_items($conf, $page); if ($js_data != array()) { $local_conf = array(); $local_conf['contextmenu'] = 'false'; $local_conf['control'] = true; $local_conf['img_popup'] = false; $local_conf['popup'] = 1; $local_conf['center_lat'] = 0; $local_conf['center_lng'] = 0; $local_conf['zoom'] = 2; $local_conf['auto_center'] = 1; // TF, 20160102: pass config as parameter $local_conf['paths'] = osm_get_gps($conf, $page); $height = isset($conf['osm_conf']['category_description']['height']) ? $conf['osm_conf']['category_description']['height'] : '200'; $width = isset($conf['osm_conf']['category_description']['width']) ? $conf['osm_conf']['category_description']['width'] : 'auto'; $js = osm_get_js($conf, $local_conf, $js_data); $template->set_filename('map', dirname(__FILE__) . '/template/osm-category.tpl'); $template->assign(array('CONTENT_ENCODING' => get_pwg_charset(), 'OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'HOME' => make_index_url(), 'HOME_PREV' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : get_absolute_root_url(), 'HOME_NAME' => l10n("Home"), 'HOME_PREV_NAME' => l10n("Previous"), 'OSMJS' => $js, 'HEIGHT' => $height, 'WIDTH' => $width)); $osm_content = $template->parse('map', true); //$osm_content = '<div id="osmmap"><div class="map_title">'.l10n('EDIT_MAP').'</div>' . $osm_content . '</div>'; $index = isset($conf['osm_conf']['category_description']['index']) ? $conf['osm_conf']['category_description']['index'] : 0; // 0 - PLUGIN_INDEX_CONTENT_BEGIN // 1 - PLUGIN_INDEX_CONTENT_COMMENT // 2 - PLUGIN_INDEX_CONTENT_END if ($index <= 1) { // From index category comment at L300 if ($page['start'] == 0 and !isset($page['chronology_field'])) { if (empty($page['comment'])) { $page['comment'] = $osm_content; } else { if ($index == 0) { $page['comment'] = '<div>' . $osm_content . $page['comment'] . '</div>'; } else { $page['comment'] = '<div>' . $page['comment'] . $osm_content . '</div>'; } } } } else { $osm_content = '<div id="osmmap">' . $osm_content . '</div>'; $template->concat('PLUGIN_INDEX_CONTENT_END', "\n" . $osm_content); } } }
// +-----------------------------------------------------------------------+ check_status(ACCESS_GUEST); if (empty($_GET['q'])) { redirect(make_index_url()); } $search = array(); $search['q'] = $_GET['q']; $query = ' SElECT id FROM ' . SEARCH_TABLE . ' WHERE rules = \'' . addslashes(serialize($search)) . '\' ;'; $search_id = array_from_query($query, 'id'); if (!empty($search_id)) { $search_id = $search_id[0]; $query = ' UPDATE ' . SEARCH_TABLE . ' SET last_seen=NOW() WHERE id=' . $search_id; pwg_query($query); } else { $query = ' INSERT INTO ' . SEARCH_TABLE . ' (rules, last_seen) VALUES (\'' . addslashes(serialize($search)) . '\', NOW() ) ;'; pwg_query($query); $search_id = pwg_db_insert_id(SEARCH_TABLE); } redirect(make_index_url(array('section' => 'search', 'search' => $search_id)));
/** * API method * Returns a list of categories * @param mixed[] $params * @option int cat_id (optional) * @option bool recursive * @option bool public * @option bool tree_output * @option bool fullname */ function ws_categories_getList($params, &$service) { global $user, $conf; $where = array('1=1'); $join_type = 'INNER'; $join_user = $user['id']; if (!$params['recursive']) { if ($params['cat_id'] > 0) { $where[] = '( id_uppercat = ' . (int) $params['cat_id'] . ' OR id=' . (int) $params['cat_id'] . ' )'; } else { $where[] = 'id_uppercat IS NULL'; } } else { if ($params['cat_id'] > 0) { $where[] = 'uppercats ' . DB_REGEX_OPERATOR . ' \'(^|,)' . (int) $params['cat_id'] . '(,|$)\''; } } if ($params['public']) { $where[] = 'status = "public"'; $where[] = 'visible = "true"'; $join_user = $conf['guest_id']; } else { if (is_admin()) { // in this very specific case, we don't want to hide empty // categories. Function calculate_permissions will only return // categories that are either locked or private and not permitted // // calculate_permissions does not consider empty categories as forbidden $forbidden_categories = calculate_permissions($user['id'], $user['status']); $where[] = 'id NOT IN (' . $forbidden_categories . ')'; $join_type = 'LEFT'; } } $query = ' SELECT id, name, comment, permalink, uppercats, global_rank, id_uppercat, nb_images, count_images AS total_nb_images, representative_picture_id, user_representative_picture_id, count_images, count_categories, date_last, max_date_last, count_categories AS nb_categories FROM ' . CATEGORIES_TABLE . ' ' . $join_type . ' JOIN ' . USER_CACHE_CATEGORIES_TABLE . ' ON id=cat_id AND user_id=' . $join_user . ' WHERE ' . implode("\n AND ", $where) . ' ;'; $result = pwg_query($query); // management of the album thumbnail -- starts here $image_ids = array(); $categories = array(); $user_representative_updates_for = array(); // management of the album thumbnail -- stops here $cats = array(); while ($row = pwg_db_fetch_assoc($result)) { $row['url'] = make_index_url(array('category' => $row)); foreach (array('id', 'nb_images', 'total_nb_images', 'nb_categories') as $key) { $row[$key] = (int) $row[$key]; } if ($params['fullname']) { $row['name'] = strip_tags(get_cat_display_name_cache($row['uppercats'], null)); } else { $row['name'] = strip_tags(trigger_change('render_category_name', $row['name'], 'ws_categories_getList')); } $row['comment'] = strip_tags(trigger_change('render_category_description', $row['comment'], 'ws_categories_getList')); // management of the album thumbnail -- starts here // // on branch 2.3, the algorithm is duplicated from // include/category_cats, but we should use a common code for Piwigo 2.4 // // warning : if the API method is called with $params['public'], the // album thumbnail may be not accurate. The thumbnail can be viewed by // the connected user, but maybe not by the guest. Changing the // filtering method would be too complicated for now. We will simply // avoid to persist the user_representative_picture_id in the database // if $params['public'] if (!empty($row['user_representative_picture_id'])) { $image_id = $row['user_representative_picture_id']; } else { if (!empty($row['representative_picture_id'])) { // if a representative picture is set, it has priority $image_id = $row['representative_picture_id']; } else { if ($conf['allow_random_representative']) { // searching a random representant among elements in sub-categories $image_id = get_random_image_in_category($row); } else { // searching a random representant among representant of sub-categories if ($row['count_categories'] > 0 and $row['count_images'] > 0) { $query = ' SELECT representative_picture_id FROM ' . CATEGORIES_TABLE . ' INNER JOIN ' . USER_CACHE_CATEGORIES_TABLE . ' ON id=cat_id AND user_id=' . $user['id'] . ' WHERE uppercats LIKE \'' . $row['uppercats'] . ',%\' AND representative_picture_id IS NOT NULL ' . get_sql_condition_FandF(array('visible_categories' => 'id'), "\n AND") . ' ORDER BY ' . DB_RANDOM_FUNCTION . '() LIMIT 1 ;'; $subresult = pwg_query($query); if (pwg_db_num_rows($subresult) > 0) { list($image_id) = pwg_db_fetch_row($subresult); } } } } } if (isset($image_id)) { if ($conf['representative_cache_on_subcats'] and $row['user_representative_picture_id'] != $image_id) { $user_representative_updates_for[$row['id']] = $image_id; } $row['representative_picture_id'] = $image_id; $image_ids[] = $image_id; $categories[] = $row; } unset($image_id); // management of the album thumbnail -- stops here $cats[] = $row; } usort($cats, 'global_rank_compare'); // management of the album thumbnail -- starts here if (count($categories) > 0) { $thumbnail_src_of = array(); $new_image_ids = array(); $query = ' SELECT id, path, representative_ext, level FROM ' . IMAGES_TABLE . ' WHERE id IN (' . implode(',', $image_ids) . ') ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { if ($row['level'] <= $user['level']) { $thumbnail_src_of[$row['id']] = DerivativeImage::thumb_url($row); } else { // problem: we must not display the thumbnail of a photo which has a // higher privacy level than user privacy level // // * what is the represented category? // * find a random photo matching user permissions // * register it at user_representative_picture_id // * set it as the representative_picture_id for the category foreach ($categories as &$category) { if ($row['id'] == $category['representative_picture_id']) { // searching a random representant among elements in sub-categories $image_id = get_random_image_in_category($category); if (isset($image_id) and !in_array($image_id, $image_ids)) { $new_image_ids[] = $image_id; } if ($conf['representative_cache_on_level']) { $user_representative_updates_for[$category['id']] = $image_id; } $category['representative_picture_id'] = $image_id; } } unset($category); } } if (count($new_image_ids) > 0) { $query = ' SELECT id, path, representative_ext FROM ' . IMAGES_TABLE . ' WHERE id IN (' . implode(',', $new_image_ids) . ') ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $thumbnail_src_of[$row['id']] = DerivativeImage::thumb_url($row); } } } // compared to code in include/category_cats, we only persist the new // user_representative if we have used $user['id'] and not the guest id, // or else the real guest may see thumbnail that he should not if (!$params['public'] and count($user_representative_updates_for)) { $updates = array(); foreach ($user_representative_updates_for as $cat_id => $image_id) { $updates[] = array('user_id' => $user['id'], 'cat_id' => $cat_id, 'user_representative_picture_id' => $image_id); } mass_updates(USER_CACHE_CATEGORIES_TABLE, array('primary' => array('user_id', 'cat_id'), 'update' => array('user_representative_picture_id')), $updates); } foreach ($cats as &$cat) { foreach ($categories as $category) { if ($category['id'] == $cat['id'] and isset($category['representative_picture_id'])) { $cat['tn_url'] = $thumbnail_src_of[$category['representative_picture_id']]; } } // we don't want them in the output unset($cat['user_representative_picture_id'], $cat['count_images'], $cat['count_categories']); } unset($cat); // management of the album thumbnail -- stops here if ($params['tree_output']) { return categories_flatlist_to_tree($cats); } return array('categories' => new PwgNamedArray($cats, 'category', ws_std_get_category_xml_attributes())); }
/** * API method * Returns a list of images for tags * @param mixed[] $params * @option int[] tag_id (optional) * @option string[] tag_url_name (optional) * @option string[] tag_name (optional) * @option bool tag_mode_and * @option int per_page * @option int page * @option string order */ function ws_tags_getImages($params, &$service) { // first build all the tag_ids we are interested in $tags = find_tags($params['tag_id'], $params['tag_url_name'], $params['tag_name']); $tags_by_id = array(); foreach ($tags as $tag) { $tags['id'] = (int) $tag['id']; $tags_by_id[$tag['id']] = $tag; } unset($tags); $tag_ids = array_keys($tags_by_id); $where_clauses = ws_std_image_sql_filter($params); if (!empty($where_clauses)) { $where_clauses = implode(' AND ', $where_clauses); } $order_by = ws_std_image_sql_order($params, 'i.'); if (!empty($order_by)) { $order_by = 'ORDER BY ' . $order_by; } $image_ids = get_image_ids_for_tags($tag_ids, $params['tag_mode_and'] ? 'AND' : 'OR', $where_clauses, $order_by); $count_set = count($image_ids); $image_ids = array_slice($image_ids, $params['per_page'] * $params['page'], $params['per_page']); $image_tag_map = array(); // build list of image ids with associated tags per image if (!empty($image_ids) and !$params['tag_mode_and']) { $query = ' SELECT image_id, GROUP_CONCAT(tag_id) AS tag_ids FROM ' . IMAGE_TAG_TABLE . ' WHERE tag_id IN (' . implode(',', $tag_ids) . ') AND image_id IN (' . implode(',', $image_ids) . ') GROUP BY image_id ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $row['image_id'] = (int) $row['image_id']; $image_tag_map[$row['image_id']] = explode(',', $row['tag_ids']); } } $images = array(); if (!empty($image_ids)) { $rank_of = array_flip($image_ids); $query = ' SELECT * FROM ' . IMAGES_TABLE . ' WHERE id IN (' . implode(',', $image_ids) . ') ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $image = array(); $image['rank'] = $rank_of[$row['id']]; foreach (array('id', 'width', 'height', 'hit') as $k) { if (isset($row[$k])) { $image[$k] = (int) $row[$k]; } } foreach (array('file', 'name', 'comment', 'date_creation', 'date_available') as $k) { $image[$k] = $row[$k]; } $image = array_merge($image, ws_std_get_urls($row)); $image_tag_ids = $params['tag_mode_and'] ? $tag_ids : $image_tag_map[$image['id']]; $image_tags = array(); foreach ($image_tag_ids as $tag_id) { $url = make_index_url(array('section' => 'tags', 'tags' => array($tags_by_id[$tag_id]))); $page_url = make_picture_url(array('section' => 'tags', 'tags' => array($tags_by_id[$tag_id]), 'image_id' => $row['id'], 'image_file' => $row['file'])); $image_tags[] = array('id' => (int) $tag_id, 'url' => $url, 'page_url' => $page_url); } $image['tags'] = new PwgNamedArray($image_tags, 'tag', ws_std_get_tag_xml_attributes()); $images[] = $image; } usort($images, 'rank_compare'); unset($rank_of); } return array('paging' => new PwgNamedStruct(array('page' => $params['page'], 'per_page' => $params['per_page'], 'count' => count($images), 'total_count' => $count_set)), 'images' => new PwgNamedArray($images, 'image', ws_std_get_image_xml_attributes())); }
// 1. if a category is available in the URL, use it // 2. else use the first reachable linked category // 3. redirect to gallery root if (isset($_GET['cat_id']) and !empty($_GET['cat_id'])) { redirect(make_index_url(array('category' => get_cat_info($_GET['cat_id'])))); } $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']))); foreach ($authorizeds as $category_id) { redirect(make_index_url(array('category' => get_cat_info($category_id)))); } redirect(make_index_url()); } // +-----------------------------------------------------------------------+ // | synchronize metadata | // +-----------------------------------------------------------------------+ if (isset($_GET['sync_metadata'])) { sync_metadata(array(intval($_GET['image_id']))); $page['infos'][] = l10n('Metadata synchronized from file'); } //--------------------------------------------------------- update informations if (isset($_POST['submit'])) { $data = array(); $data['id'] = $_GET['image_id']; $data['name'] = $_POST['name']; $data['author'] = $_POST['author']; $data['level'] = $_POST['level'];
unset($letter['CHANGE_COLUMN']); $letter['TITLE'] = $current_letter; $template->append('letters', $letter); } } else { // +-----------------------------------------------------------------------+ // | tag cloud construction | // +-----------------------------------------------------------------------+ // we want only the first most represented tags, so we sort them by counter // and take the first tags usort($tags, 'counter_compare'); $tags = array_slice($tags, 0, $conf['full_tag_cloud_items_number']); // depending on its counter and the other tags counter, each tag has a level $tags = add_level_to_tags($tags); // we want tags diplayed in alphabetic order usort($tags, 'tag_alpha_compare'); // display sorted tags foreach ($tags as $tag) { $template->append('tags', array_merge($tag, array('URL' => make_index_url(array('tags' => array($tag)))))); } } // include menubar $themeconf = $template->get_template_vars('themeconf'); if (!isset($themeconf['hide_menu_on']) or !in_array('theTagsPage', $themeconf['hide_menu_on'])) { include PHPWG_ROOT_PATH . 'include/menubar.inc.php'; } include PHPWG_ROOT_PATH . 'include/page_header.php'; trigger_notify('loc_end_tags'); flush_page_messages(); $template->pparse('tags'); include PHPWG_ROOT_PATH . 'include/page_tail.php';
/** * Save picture form * @trigger loc_begin_picture */ function admintools_save_picture() { global $page, $conf, $MultiView, $user, $picture; if (!isset($_GET['delete']) and !isset($_POST['action']) and @$_POST['action'] != 'quick_edit') { return; } $query = 'SELECT added_by FROM ' . IMAGES_TABLE . ' WHERE id = ' . $page['image_id'] . ';'; list($added_by) = pwg_db_fetch_row(pwg_query($query)); if (!$MultiView->is_admin() and $user['id'] != $added_by) { return; } if (isset($_GET['delete']) and get_pwg_token() == @$_GET['pwg_token']) { include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; delete_elements(array($page['image_id']), true); invalidate_user_cache(); if (isset($page['rank_of'][$page['image_id']])) { redirect(duplicate_index_url(array('start' => floor($page['rank_of'][$page['image_id']] / $page['nb_image_page']) * $page['nb_image_page']))); } else { redirect(make_index_url()); } } if ($_POST['action'] == 'quick_edit') { include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; $data = array('name' => $_POST['name'], 'author' => $_POST['author']); if ($MultiView->is_admin()) { $data['level'] = $_POST['level']; } if ($conf['allow_html_descriptions']) { $data['comment'] = @$_POST['comment']; } else { $data['comment'] = strip_tags(@$_POST['comment']); } if (!empty($_POST['date_creation']) and strtotime($_POST['date_creation']) !== false) { $data['date_creation'] = $_POST['date_creation'] . ' ' . $_POST['date_creation_time']; } single_update(IMAGES_TABLE, $data, array('id' => $page['image_id'])); $tag_ids = array(); if (!empty($_POST['tags'])) { $tag_ids = get_tag_ids($_POST['tags']); } set_tags($tag_ids, $page['image_id']); } }
/** * Setups each block the main menubar. */ function initialize_menu() { global $page, $conf, $user, $template, $filter; $menu = new BlockManager("menubar"); $menu->load_registered_blocks(); $menu->prepare_display(); if (@$page['section'] == 'search' and isset($page['qsearch_details'])) { $template->assign('QUERY_SEARCH', htmlspecialchars($page['qsearch_details']['q'])); } //--------------------------------------------------------------- external links if ($block = $menu->get_block('mbLinks') and !empty($conf['links'])) { $block->data = array(); foreach ($conf['links'] as $url => $url_data) { if (!is_array($url_data)) { $url_data = array('label' => $url_data); } if (!isset($url_data['eval_visible']) or eval($url_data['eval_visible'])) { $tpl_var = array('URL' => $url, 'LABEL' => $url_data['label']); if (!isset($url_data['new_window']) or $url_data['new_window']) { $tpl_var['new_window'] = array('NAME' => isset($url_data['nw_name']) ? $url_data['nw_name'] : '', 'FEATURES' => isset($url_data['nw_features']) ? $url_data['nw_features'] : ''); } $block->data[] = $tpl_var; } } if (!empty($block->data)) { $block->template = 'menubar_links.tpl'; } } //-------------------------------------------------------------- categories $block = $menu->get_block('mbCategories'); //------------------------------------------------------------------------ filter if ($conf['menubar_filter_icon'] and !empty($conf['filter_pages']) and get_filter_page_value('used')) { if ($filter['enabled']) { $template->assign('U_STOP_FILTER', add_url_params(make_index_url(array()), array('filter' => 'stop'))); } else { $template->assign('U_START_FILTER', add_url_params(make_index_url(array()), array('filter' => 'start-recent-' . $user['recent_period']))); } } if ($block != null) { $block->data = array('NB_PICTURE' => $user['nb_total_images'], 'MENU_CATEGORIES' => get_categories_menu(), 'U_CATEGORIES' => make_index_url(array('section' => 'categories'))); $block->template = 'menubar_categories.tpl'; } //------------------------------------------------------------------------ tags $block = $menu->get_block('mbTags'); if ($block != null and !empty($page['items']) and 'picture' != script_basename()) { if ('tags' == @$page['section']) { $tags = get_common_tags($page['items'], $conf['menubar_tag_cloud_items_number'], $page['tag_ids']); $tags = add_level_to_tags($tags); foreach ($tags as $tag) { $block->data[] = array_merge($tag, array('U_ADD' => make_index_url(array('tags' => array_merge($page['tags'], array($tag)))), 'URL' => make_index_url(array('tags' => array($tag))))); } } else { $selection = array_slice($page['items'], $page['start'], $page['nb_image_page']); $tags = add_level_to_tags(get_common_tags($selection, $conf['content_tag_cloud_items_number'])); foreach ($tags as $tag) { $block->data[] = array_merge($tag, array('URL' => make_index_url(array('tags' => array($tag))))); } } if (!empty($block->data)) { $block->template = 'menubar_tags.tpl'; } } //----------------------------------------------------------- special categories if (($block = $menu->get_block('mbSpecials')) != null) { if (!is_a_guest()) { // favorites $block->data['favorites'] = array('URL' => make_index_url(array('section' => 'favorites')), 'TITLE' => l10n('display your favorites photos'), 'NAME' => l10n('Your favorites')); } $block->data['most_visited'] = array('URL' => make_index_url(array('section' => 'most_visited')), 'TITLE' => l10n('display most visited photos'), 'NAME' => l10n('Most visited')); if ($conf['rate']) { $block->data['best_rated'] = array('URL' => make_index_url(array('section' => 'best_rated')), 'TITLE' => l10n('display best rated photos'), 'NAME' => l10n('Best rated')); } $block->data['recent_pics'] = array('URL' => make_index_url(array('section' => 'recent_pics')), 'TITLE' => l10n('display most recent photos'), 'NAME' => l10n('Recent photos')); $block->data['recent_cats'] = array('URL' => make_index_url(array('section' => 'recent_cats')), 'TITLE' => l10n('display recently updated albums'), 'NAME' => l10n('Recent albums')); $block->data['random'] = array('URL' => get_root_url() . 'random.php', 'TITLE' => l10n('display a set of random photos'), 'NAME' => l10n('Random photos'), 'REL' => 'rel="nofollow"'); $block->data['calendar'] = array('URL' => make_index_url(array('chronology_field' => $conf['calendar_datefield'] == 'date_available' ? 'posted' : 'created', 'chronology_style' => 'monthly', 'chronology_view' => 'calendar')), 'TITLE' => l10n('display each day with photos, month per month'), 'NAME' => l10n('Calendar'), 'REL' => 'rel="nofollow"'); $block->template = 'menubar_specials.tpl'; } //---------------------------------------------------------------------- summary if (($block = $menu->get_block('mbMenu')) != null) { // quick search block will be displayed only if data['qsearch'] is set // to "yes" $block->data['qsearch'] = true; // tags link $block->data['tags'] = array('TITLE' => l10n('display available tags'), 'NAME' => l10n('Tags'), 'URL' => get_root_url() . 'tags.php', 'COUNTER' => get_nb_available_tags()); // search link $block->data['search'] = array('TITLE' => l10n('search'), 'NAME' => l10n('Search'), 'URL' => get_root_url() . 'search.php', 'REL' => 'rel="search"'); if ($conf['activate_comments']) { // comments link $block->data['comments'] = array('TITLE' => l10n('display last user comments'), 'NAME' => l10n('Comments'), 'URL' => get_root_url() . 'comments.php', 'COUNTER' => get_nb_available_comments()); } // about link $block->data['about'] = array('TITLE' => l10n('About Piwigo'), 'NAME' => l10n('About'), 'URL' => get_root_url() . 'about.php'); // notification $block->data['rss'] = array('TITLE' => l10n('RSS feed'), 'NAME' => l10n('Notification'), 'URL' => get_root_url() . 'notification.php', 'REL' => 'rel="nofollow"'); $block->template = 'menubar_menu.tpl'; } //--------------------------------------------------------------- identification if (is_a_guest()) { $template->assign(array('U_LOGIN' => get_root_url() . 'identification.php', 'U_LOST_PASSWORD' => get_root_url() . 'password.php', 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering'])); if ($conf['allow_user_registration']) { $template->assign('U_REGISTER', get_root_url() . 'register.php'); } } else { $template->assign('USERNAME', stripslashes($user['username'])); if (is_autorize_status(ACCESS_CLASSIC)) { $template->assign('U_PROFILE', get_root_url() . 'profile.php'); } // the logout link has no meaning with Apache authentication : it is not // possible to logout with this kind of authentication. if (!$conf['apache_authentication']) { $template->assign('U_LOGOUT', get_root_url() . '?act=logout'); } if (is_admin()) { $template->assign('U_ADMIN', get_root_url() . 'admin.php'); } } if (($block = $menu->get_block('mbIdentification')) != null) { $block->template = 'menubar_identification.tpl'; } $menu->apply('MENUBAR', 'menubar.tpl'); }
/** * Returns html description about recently published elements grouped by post date. * @todo clean up HTML output, currently messy and invalid ! * * @param array $date_detail returned value of get_recent_post_dates() * @return string */ function get_html_description_recent_post_date($date_detail, $auth_key = null) { global $conf; $add_url_params = array(); if (isset($auth_key)) { $add_url_params['auth'] = $auth_key; } $description = '<ul>'; $description .= '<li>' . l10n_dec('%d new photo', '%d new photos', $date_detail['nb_elements']) . ' (' . '<a href="' . add_url_params(make_index_url(array('section' => 'recent_pics')), $add_url_params) . '">' . l10n('Recent photos') . '</a>' . ')' . '</li><br>'; foreach ($date_detail['elements'] as $element) { $tn_src = DerivativeImage::thumb_url($element); $description .= '<a href="' . add_url_params(make_picture_url(array('image_id' => $element['id'], 'image_file' => $element['file'])), $add_url_params) . '"><img src="' . $tn_src . '"></a>'; } $description .= '...<br>'; $description .= '<li>' . l10n_dec('%d album updated', '%d albums updated', $date_detail['nb_cats']) . '</li>'; $description .= '<ul>'; foreach ($date_detail['categories'] as $cat) { $description .= '<li>' . get_cat_display_name_cache($cat['uppercats'], '', false, null, $auth_key) . ' (' . l10n_dec('%d new photo', '%d new photos', $cat['img_count']) . ')' . '</li>'; } $description .= '</ul>'; $description .= '</ul>'; return $description; }
/** * Returns the 'home page' of this gallery */ function get_gallery_home_url() { global $conf; if (!empty($conf['gallery_url'])) { if (url_is_remote($conf['gallery_url']) or $conf['gallery_url'][0] == '/') { return $conf['gallery_url']; } return get_root_url() . $conf['gallery_url']; } else { return make_index_url(); } }
if (is_admin() and !empty($page['items'])) { $template->assign('U_CADDIE', add_url_params(duplicate_index_url(), array('caddie' => 1))); } if ($page['section'] == 'search' and $page['start'] == 0 and !isset($page['chronology_field']) and isset($page['qsearch_details'])) { $cats = array_merge((array) @$page['qsearch_details']['matching_cats_no_images'], (array) @$page['qsearch_details']['matching_cats']); if (count($cats)) { usort($cats, 'name_compare'); $hints = array(); foreach ($cats as $cat) { $hints[] = get_cat_display_name(array($cat), ''); } $template->assign('category_search_results', $hints); } $tags = (array) @$page['qsearch_details']['matching_tags']; foreach ($tags as $tag) { $tag['URL'] = make_index_url(array('tags' => array($tag))); $template->append('tag_search_results', $tag); } if (empty($page['items'])) { $template->append('no_search_results', htmlspecialchars($page['qsearch_details']['q'])); } elseif (!empty($page['qsearch_details']['unmatched_terms'])) { $template->assign('no_search_results', array_map('htmlspecialchars', $page['qsearch_details']['unmatched_terms'])); } } // image order if ($conf['index_sort_order_input'] and count($page['items']) > 0 and $page['section'] != 'most_visited' and $page['section'] != 'best_rated') { $preferred_image_orders = get_category_preferred_image_orders(); $order_idx = pwg_get_session_var('image_order', 0); // get first order field and direction $first_order = substr($conf['order_by'], 9); if (($pos = strpos($first_order, ',')) !== false) {
SELECT tag_id, COUNT(image_id) AS counter FROM ' . IMAGE_TAG_TABLE . ' GROUP BY tag_id'; $tag_counters = simple_hash_from_query($query, 'tag_id', 'counter'); // all tags $query = ' SELECT * FROM ' . TAGS_TABLE . ' ;'; $result = pwg_query($query); $all_tags = array(); while ($tag = pwg_db_fetch_assoc($result)) { $raw_name = $tag['name']; $tag['name'] = trigger_change('render_tag_name', $raw_name, $tag); $tag['counter'] = intval(@$tag_counters[$tag['id']]); $tag['U_VIEW'] = make_index_url(array('tags' => array($tag))); $tag['U_EDIT'] = 'admin.php?page=batch_manager&filter=tag-' . $tag['id']; $alt_names = trigger_change('get_tag_alt_names', array(), $raw_name); $alt_names = array_diff(array_unique($alt_names), array($tag['name'])); if (count($alt_names)) { $tag['alt_names'] = implode(', ', $alt_names); } $all_tags[] = $tag; } usort($all_tags, 'tag_alpha_compare'); $template->assign(array('all_tags' => $all_tags)); if ((isset($_POST['edit']) or isset($_POST['duplicate']) or isset($_POST['merge'])) and isset($_POST['tags'])) { $list_name = 'EDIT_TAGS_LIST'; if (isset($_POST['duplicate'])) { $list_name = 'DUPLIC_TAGS_LIST'; } elseif (isset($_POST['merge'])) {
} $template->set_filename('index_category_thumbnails', 'mainpage_categories.tpl'); trigger_notify('loc_begin_index_category_thumbnails', $categories); $tpl_thumbnails_var = array(); foreach ($categories as $category) { if (0 == $category['count_images']) { continue; } $category['name'] = trigger_change('render_category_name', $category['name'], 'subcatify_category_name'); if ($page['section'] == 'recent_cats') { $name = get_cat_display_name_cache($category['uppercats'], null); } else { $name = $category['name']; } $representative_infos = $infos_of_image[$category['representative_picture_id']]; $tpl_var = array_merge($category, array('ID' => $category['id'], 'representative' => $representative_infos, 'TN_ALT' => strip_tags($category['name']), 'URL' => make_index_url(array('category' => $category)), 'CAPTION_NB_IMAGES' => get_display_images_count($category['nb_images'], $category['count_images'], $category['count_categories'], true, '<br>'), 'DESCRIPTION' => trigger_change('render_category_literal_description', trigger_change('render_category_description', @$category['comment'], 'subcatify_category_description')), 'NAME' => $name)); if ($conf['index_new_icon']) { $tpl_var['icon_ts'] = get_icon($category['max_date_last'], $category['is_child_date_last']); } if ($conf['display_fromto']) { if (isset($dates_of_category[$category['id']])) { $from = $dates_of_category[$category['id']]['from']; $to = $dates_of_category[$category['id']]['to']; if (!empty($from)) { $tpl_var['INFO_DATES'] = format_fromto($from, $to); } } } $tpl_thumbnails_var[] = $tpl_var; } // pagination
// | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | // | USA. | // +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+ // | define and include | // +-----------------------------------------------------------------------+ define('PHPWG_ROOT_PATH', './'); include_once PHPWG_ROOT_PATH . 'include/common.inc.php'; // +-----------------------------------------------------------------------+ // | Check Access and exit when user status is not ok | // +-----------------------------------------------------------------------+ check_status(ACCESS_GUEST); // +-----------------------------------------------------------------------+ // | generate random element list | // +-----------------------------------------------------------------------+ $query = ' SELECT id FROM ' . IMAGES_TABLE . ' INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON id = ic.image_id ' . get_sql_condition_FandF(array('forbidden_categories' => 'category_id', 'visible_categories' => 'category_id', 'visible_images' => 'id'), 'WHERE') . ' ORDER BY ' . DB_RANDOM_FUNCTION . '() LIMIT ' . min(50, $conf['top_number'], $user['nb_image_page']) . ' ;'; // +-----------------------------------------------------------------------+ // | redirect | // +-----------------------------------------------------------------------+ redirect(make_index_url(array('list' => array_from_query($query, 'id'))));
WHERE id IN (' . implode(',', array_keys($image_ids)) . ') ;'; $image_infos = query2array($query, 'id'); } if ($has_tags > 0) { $query = ' SELECT id, name, url_name FROM ' . TAGS_TABLE; global $name_of_tag; // used for preg_replace $name_of_tag = array(); $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $name_of_tag[$row['id']] = '<a href="' . make_index_url(array('tags' => array($row))) . '">' . trigger_change("render_tag_name", $row['name'], $row) . '</a>'; } } $i = 0; $first_line = $page['start'] + 1; $last_line = $page['start'] + $conf['nb_logs_page']; $summary['total_filesize'] = 0; $summary['guests_IP'] = array(); foreach ($history_lines as $line) { if (isset($line['image_type']) and $line['image_type'] == 'high') { $summary['total_filesize'] += @intval($image_infos[$line['image_id']]['filesize']); } if ($line['user_id'] == $conf['guest_id']) { if (!isset($summary['guests_IP'][$line['IP']])) { $summary['guests_IP'][$line['IP']] = 0; }
// Get the Guest custom settings $query = ' SELECT ' . implode(',', $fields) . ' FROM ' . USER_INFOS_TABLE . ' WHERE user_id = ' . $conf['default_user_id'] . ' ;'; $result = pwg_query($query); $default_user = pwg_db_fetch_assoc($result); $userdata = array_merge($userdata, $default_user); } save_profile_from_post($userdata, $page['errors']); $title = l10n('Your Gallery Customization'); $page['body_id'] = 'theProfilePage'; $template->set_filename('profile', 'profile.tpl'); $template->set_filename('profile_content', 'profile_content.tpl'); load_profile_in_template(get_root_url() . 'profile.php', make_index_url(), $userdata); $template->assign_var_from_handle('PROFILE_CONTENT', 'profile_content'); // include menubar $themeconf = $template->get_template_vars('themeconf'); if (!isset($themeconf['hide_menu_on']) or !in_array('theProfilePage', $themeconf['hide_menu_on'])) { include PHPWG_ROOT_PATH . 'include/menubar.inc.php'; } include PHPWG_ROOT_PATH . 'include/page_header.php'; trigger_notify('loc_end_profile'); flush_page_messages(); $template->pparse('profile'); include PHPWG_ROOT_PATH . 'include/page_tail.php'; } //------------------------------------------------------ update & customization function save_profile_from_post($userdata, &$errors) {
*/ defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); if (basename(dirname(__FILE__)) != 'GuestBook') { add_event_handler('init', 'guestbook_error'); function guestbook_error() { global $page; $page['errors'][] = 'GuestBook folder name is incorrect, uninstall the plugin and rename it to "GuestBook"'; } return; } global $conf, $prefixeTable; define('GUESTBOOK_PATH', PHPWG_PLUGINS_PATH . 'GuestBook/'); define('GUESTBOOK_TABLE', $prefixeTable . 'guestbook'); define('GUESTBOOK_ADMIN', get_root_url() . 'admin.php?page=plugin-GuestBook'); define('GUESTBOOK_URL', get_absolute_root_url() . make_index_url(array('section' => 'guestbook'))); $conf['guestbook'] = safe_unserialize($conf['guestbook']); include_once GUESTBOOK_PATH . 'include/events.inc.php'; add_event_handler('loading_lang', 'guestbook_loading_lang'); if (defined('IN_ADMIN')) { add_event_handler('get_admin_plugin_menu_links', 'gb_admin_menu'); } else { add_event_handler('loc_end_section_init', 'gb_section_init'); add_event_handler('loc_end_index', 'gb_index'); } if ($conf['guestbook']['menu_link']) { add_event_handler('blockmanager_apply', 'gb_menubar_apply', EVENT_HANDLER_PRIORITY_NEUTRAL + 10); } function guestbook_loading_lang() { load_language('plugin.lang', GUESTBOOK_PATH);
WHERE category_id = ' . $_GET['cat_id'] . ' LIMIT 1'; $result = pwg_query($query); $category['has_images'] = pwg_db_num_rows($result) > 0 ? true : false; // Navigation path $navigation = get_cat_display_name_cache($category['uppercats'], get_root_url() . 'admin.php?page=album-'); $form_action = $admin_album_base_url . '-properties'; //----------------------------------------------------- template initialization $template->set_filename('album_properties', 'cat_modify.tpl'); $base_url = get_root_url() . 'admin.php?page='; $cat_list_url = $base_url . 'cat_list'; $self_url = $cat_list_url; if (!empty($category['id_uppercat'])) { $self_url .= '&parent_id=' . $category['id_uppercat']; } $template->assign(array('CATEGORIES_NAV' => $navigation, 'CAT_ID' => $category['id'], 'CAT_NAME' => @htmlspecialchars($category['name']), 'CAT_COMMENT' => @htmlspecialchars($category['comment']), 'CAT_VISIBLE' => boolean_to_string($category['visible']), 'U_JUMPTO' => make_index_url(array('category' => $category)), 'U_ADD_PHOTOS_ALBUM' => $base_url . 'photos_add&album=' . $category['id'], 'U_CHILDREN' => $cat_list_url . '&parent_id=' . $category['id'], 'U_HELP' => get_root_url() . 'admin/popuphelp.php?page=cat_modify', 'F_ACTION' => $form_action)); if ($conf['activate_comments']) { $template->assign('CAT_COMMENTABLE', boolean_to_string($category['commentable'])); } // manage album elements link if ($category['has_images']) { $template->assign('U_MANAGE_ELEMENTS', $base_url . 'batch_manager&filter=album-' . $category['id']); $query = ' SELECT COUNT(image_id), MIN(DATE(date_available)), MAX(DATE(date_available)) FROM ' . IMAGES_TABLE . ' JOIN ' . IMAGE_CATEGORY_TABLE . ' ON image_id = id WHERE category_id = ' . $category['id'] . ' ;';
function cdnplus_update_url($content) { global $conf; // print "<br/>CDNPLUS IN[".$content."]"; if (!empty($conf['cdnplus_conf']['cdn_enabled'])) { $extension = get_extension(strtolower($content)); //print $extension; for ($i = 1; $i <= 5; $i++) { if (!empty($conf['cdnplus_conf']['cdn_' . $i]['extratypes'])) { $conf['cdnplus_conf']['cdn_' . $i]['filetypes'] = array_uniq(array_merge($conf['cdnplus_conf']['cdn_' . $i]['filetypes'], explode(',', $conf['cdnplus_conf']['cdn_' . $i]['extratypes']))); } if (!empty($conf['cdnplus_conf']['cdn_' . $i]['ignorefiles'])) { } if (!empty($conf['cdnplus_conf']['cdn_' . $i]['host']) && array_key_exists($extension, $conf['cdnplus_conf']['cdn_' . $i]['filetypes']) && !empty($conf['cdnplus_conf']['cdn_' . $i]['filetypes'][$extension])) { $cdnUrl = 'http://'; if (!empty($_SERVER['HTTPS']) && !empty($conf['cdnplus_conf']['cdn_' . $i]['keep_https'])) { $cdnUrl = 'https://'; } $cdnUrl = $cdnUrl . $conf['cdnplus_conf']['cdn_' . $i]['host'] . make_index_url(); $content = $cdnUrl . $content; } } } // print "<br/>CDNPLUS OUT[".embellish_url($content)."]"; return $content; }
/** * Returns template vars for main categories menu. * * @return array[] */ function get_categories_menu() { global $page, $user, $filter, $conf; $query = ' SELECT '; // From CATEGORIES_TABLE $query .= ' id, name, permalink, 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']) { $where = ' (id_uppercat is NULL'; if (isset($page['category'])) { $where .= ' OR id_uppercat IN (' . $page['category']['uppercats'] . ')'; } $where .= ')'; } else { $where = ' ' . get_sql_condition_FandF(array('visible_categories' => 'id'), null, true); } $where = trigger_change('get_categories_menu_sql_where', $where, $user['expand'], $filter['enabled']); $query .= ' WHERE ' . $where . ' ;'; $result = pwg_query($query); $cats = array(); $selected_category = isset($page['category']) ? $page['category'] : null; while ($row = pwg_db_fetch_assoc($result)) { $child_date_last = @$row['max_date_last'] > @$row['date_last']; $row = array_merge($row, array('NAME' => trigger_change('render_category_name', $row['name'], 'get_categories_menu'), 'TITLE' => get_display_images_count($row['nb_images'], $row['count_images'], $row['count_categories'], false, ' / '), 'URL' => make_index_url(array('category' => $row)), 'LEVEL' => substr_count($row['global_rank'], '.') + 1, 'SELECTED' => $selected_category['id'] == $row['id'] ? true : false, 'IS_UPPERCAT' => $selected_category['id_uppercat'] == $row['id'] ? true : false)); if ($conf['index_new_icon']) { $row['icon_ts'] = get_icon($row['max_date_last'], $child_date_last); } $cats[] = $row; if ($row['id'] == @$page['category']['id']) { //save the number of subcats for later optim $page['category']['count_categories'] = $row['count_categories']; } } usort($cats, 'global_rank_compare'); // Update filtered data if (function_exists('update_cats_with_filtered_data')) { update_cats_with_filtered_data($cats); } return $cats; }
is empty find child representative_picture_id */ if (!empty($category['representative_picture_id'])) { $img = array(); $query = ' SELECT id, file, path, representative_ext FROM ' . IMAGES_TABLE . ' WHERE id = ' . $category['representative_picture_id'] . ' ;'; $result = pwg_query($query); if (pwg_db_num_rows($result) > 0) { $element = pwg_db_fetch_assoc($result); $img = array('link' => make_picture_url(array('image_id' => $element['id'], 'image_file' => $element['file'], 'category' => $category)), 'src' => DerivativeImage::url(IMG_THUMB, $element)); } } $args = array('subject' => l10n('[%s] Visit album %s', $conf['gallery_title'], trigger_change('render_category_name', $category['name'], 'admin_cat_list'))); $tpl = array('filename' => 'cat_group_info', 'assign' => array('IMG' => $img, 'CAT_NAME' => trigger_change('render_category_name', $category['name'], 'admin_cat_list'), 'LINK' => make_index_url(array('category' => array('id' => $category['id'], 'name' => trigger_change('render_category_name', $category['name'], 'admin_cat_list'), 'permalink' => $category['permalink']))), 'CPL_CONTENT' => empty($_POST['mail_content']) ? '' : stripslashes($_POST['mail_content']))); if ('users' == $_POST['who'] and isset($_POST['users']) and count($_POST['users']) > 0) { check_input_parameter('users', $_POST, true, PATTERN_ID); // TODO code very similar to function pwg_mail_group. We'd better create // a function pwg_mail_users that could be called from here and from // pwg_mail_group // TODO to make checks even better, we should check that theses users // have access to this album. No real privacy issue here, even if we // send the email to a user without permission. $query = ' SELECT ui.user_id, ui.status, ui.language, u.' . $conf['user_fields']['email'] . ' AS email, u.' . $conf['user_fields']['username'] . ' AS username
$_SESSION['page_infos'][] = l10n('Successfully registered, you will soon receive an email with your connection settings. Welcome!'); } // log user and redirect $user_id = get_userid($_POST['login']); log_user($user_id, false); redirect(make_index_url()); } $registration_post_key = get_ephemeral_key(2); } else { $registration_post_key = get_ephemeral_key(6); } $login = !empty($_POST['login']) ? htmlspecialchars(stripslashes($_POST['login'])) : ''; $email = !empty($_POST['mail_address']) ? htmlspecialchars(stripslashes($_POST['mail_address'])) : ''; //----------------------------------------------------- template initialization // // Start output of page // $title = l10n('Registration'); $page['body_id'] = 'theRegisterPage'; $template->set_filenames(array('register' => 'register.tpl')); $template->assign(array('U_HOME' => make_index_url(), 'F_KEY' => $registration_post_key, 'F_ACTION' => 'register.php', 'F_LOGIN' => $login, 'F_EMAIL' => $email, 'obligatory_user_mail_address' => $conf['obligatory_user_mail_address'])); // include menubar $themeconf = $template->get_template_vars('themeconf'); if (!isset($themeconf['hide_menu_on']) or !in_array('theRegisterPage', $themeconf['hide_menu_on'])) { include PHPWG_ROOT_PATH . 'include/menubar.inc.php'; } include PHPWG_ROOT_PATH . 'include/page_header.php'; trigger_notify('loc_end_register'); flush_page_messages(); $template->parse('register'); include PHPWG_ROOT_PATH . 'include/page_tail.php';
WHERE user_id = ' . $user['id'] . ' ;'; pwg_query($query); redirect(make_index_url(array('section' => 'favorites'))); } else { $query = ' SELECT image_id FROM ' . FAVORITES_TABLE . ' INNER JOIN ' . IMAGES_TABLE . ' ON image_id = id WHERE user_id = ' . $user['id'] . ' ' . get_sql_condition_FandF(array('visible_images' => 'id'), 'AND') . ' ' . $conf['order_by'] . ' ;'; $page = array_merge($page, array('items' => query2array($query, null, 'image_id'))); if (count($page['items']) > 0) { $template->assign('favorite', array('U_FAVORITE' => add_url_params(make_index_url(array('section' => 'favorites')), array('action' => 'remove_all_from_favorites')))); } } } else { if ($page['section'] == 'recent_pics') { if (!isset($page['super_order_by'])) { $conf['order_by'] = str_replace('ORDER BY ', 'ORDER BY date_available DESC,', $conf['order_by']); } $query = ' SELECT DISTINCT(id) FROM ' . IMAGES_TABLE . ' INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON id = ic.image_id WHERE ' . get_recent_photos_sql('date_available') . ' ' . $forbidden . $conf['order_by'] . ' ;'; $page = array_merge($page, array('title' => '<a href="' . duplicate_index_url(array('start' => 0)) . '">' . l10n('Recent photos') . '</a>', 'items' => query2array($query, null, 'id')));
<?php /********************************** * REQUIRED PATH TO THE TPL FILE */ $TOUR_PATH = PHPWG_PLUGINS_PATH . 'TakeATour/tours/2_7_0/tour.tpl'; /*********************************/ /********************** * Preparse part * **********************/ $template->assign('TAT_index', make_index_url(array('section' => 'categories'))); $template->assign('TAT_search', get_root_url() . 'search.php'); //picture id if (isset($_GET['page']) and preg_match('/^photo-(\\d+)(?:-(.*))?$/', $_GET['page'], $matches)) { $_GET['image_id'] = $matches[1]; } check_input_parameter('image_id', $_GET, false, PATTERN_ID); if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id') == null) { $template->assign('TAT_image_id', $_GET['image_id']); pwg_set_session_var('TAT_image_id', $_GET['image_id']); } elseif (is_numeric(pwg_get_session_var('TAT_image_id'))) { $template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id')); } else { $query = ' SELECT id FROM ' . IMAGES_TABLE . ' ORDER BY RAND() LIMIT 1 ;'; $row = pwg_db_fetch_assoc(pwg_query($query)); $template->assign('TAT_image_id', $row['id']); }
} // filesize if (!empty($picture['current']['filesize'])) { $infos['INFO_FILESIZE'] = l10n('%d Kb', $picture['current']['filesize']); } // number of visits $infos['INFO_VISITS'] = $picture['current']['hit']; // file $infos['INFO_FILE'] = $picture['current']['file']; $template->assign($infos); $template->assign('display_info', unserialize($conf['picture_informations'])); // related tags $tags = get_common_tags(array($page['image_id']), -1); if (count($tags)) { foreach ($tags as $tag) { $template->append('related_tags', array_merge($tag, array('URL' => make_index_url(array('tags' => array($tag))), 'U_TAG_IMAGE' => duplicate_picture_url(array('section' => 'tags', 'tags' => array($tag)))))); } } // related categories if (count($related_categories) == 1 and isset($page['category']) and $related_categories[0]['id'] == $page['category']['id']) { // no need to go to db, we have all the info $template->append('related_categories', get_cat_display_name($page['category']['upper_names'])); } else { // use only 1 sql query to get names for all related categories $ids = array(); foreach ($related_categories as $category) { // add all uppercats to $ids $ids = array_merge($ids, explode(',', $category['uppercats'])); } $ids = array_unique($ids); $query = '
} $nb_sub_photos[$cat_id] = $nb_photos; } } $template->assign('categories', array()); $base_url = get_root_url() . 'admin.php?page='; if (isset($_GET['parent_id'])) { $template->assign('PARENT_EDIT', $base_url . 'album-' . $_GET['parent_id']); } foreach ($categories as $category) { $cat_list_url = $base_url . 'cat_list'; $self_url = $cat_list_url; if (isset($_GET['parent_id'])) { $self_url .= '&parent_id=' . $_GET['parent_id']; } $tpl_cat = array('NAME' => trigger_change('render_category_name', $category['name'], 'admin_cat_list'), 'NB_PHOTOS' => isset($nb_photos_in[$category['id']]) ? $nb_photos_in[$category['id']] : 0, 'NB_SUB_PHOTOS' => isset($nb_sub_photos[$category['id']]) ? $nb_sub_photos[$category['id']] : 0, 'NB_SUB_ALBUMS' => isset($subcats_of[$category['id']]) ? count($subcats_of[$category['id']]) : 0, 'ID' => $category['id'], 'RANK' => $category['rank'] * 10, 'U_JUMPTO' => make_index_url(array('category' => $category)), 'U_CHILDREN' => $cat_list_url . '&parent_id=' . $category['id'], 'U_EDIT' => $base_url . 'album-' . $category['id'], 'IS_VIRTUAL' => empty($category['dir'])); if (empty($category['dir'])) { $tpl_cat['U_DELETE'] = $self_url . '&delete=' . $category['id']; $tpl_cat['U_DELETE'] .= '&pwg_token=' . get_pwg_token(); } else { if ($conf['enable_synchronization']) { $tpl_cat['U_SYNC'] = $base_url . 'site_update&site=1&cat_id=' . $category['id']; } } $template->append('categories', $tpl_cat); } trigger_notify('loc_end_cat_list'); // +-----------------------------------------------------------------------+ // | sending html code | // +-----------------------------------------------------------------------+ $template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
/** * Returns the breadcrumb to be displayed above thumbnails on tag page. * * @return string */ function get_tags_content_title() { global $page; $title = '<a href="' . get_root_url() . 'tags.php" title="' . l10n('display available tags') . '">' . l10n(count($page['tags']) > 1 ? 'Tags' : 'Tag') . '</a> '; for ($i = 0; $i < count($page['tags']); $i++) { $title .= $i > 0 ? ' + ' : ''; $title .= '<a href="' . make_index_url(array('tags' => array($page['tags'][$i]))) . '" title="' . l10n('display photos linked to this tag') . '">' . trigger_change('render_tag_name', $page['tags'][$i]['name'], $page['tags'][$i]) . '</a>'; if (count($page['tags']) > 2) { $other_tags = $page['tags']; unset($other_tags[$i]); $remove_url = make_index_url(array('tags' => $other_tags)); $title .= '<a href="' . $remove_url . '" style="border:none;" title="' . l10n('remove this tag from the list') . '"><img src="' . get_root_url() . get_themeconf('icon_dir') . '/remove_s.png' . '" alt="x" style="vertical-align:bottom;">' . '</a>'; } } return $title; }