static function on_index_begin() { global $page; $is_ajax = isset($_GET['rvts']); if (!$is_ajax) { if (empty($page['items'])) { add_event_handler('loc_end_index', array('RVTS', 'on_end_index')); } else { add_event_handler('loc_end_index_thumbnails', array('RVTS', 'on_index_thumbnails'), EVENT_HANDLER_PRIORITY_NEUTRAL, 1); } } else { $adj = (int) @$_GET['adj']; if ($adj) { $mult = pwg_get_session_var('rvts_mult', 1); if ($adj > 0 && $mult < 5) { pwg_set_session_var('rvts_mult', ++$mult); } if ($adj < 0 && $mult > 1) { pwg_set_session_var('rvts_mult', --$mult); } } $page['nb_image_page'] = (int) $_GET['rvts']; add_event_handler('loc_end_index_thumbnails', array('RVTS', 'on_index_thumbnails_ajax'), EVENT_HANDLER_PRIORITY_NEUTRAL + 5, 1); $page['root_path'] = get_absolute_root_url(false); $page['body_id'] = 'scroll'; global $user, $template, $conf; include PHPWG_ROOT_PATH . 'include/category_default.inc.php'; } }
/** * plugin initialization */ function oauth_init() { global $conf, $page, $hybridauth_conf, $template; load_language('plugin.lang', OAUTH_PATH); $conf['oauth'] = safe_unserialize($conf['oauth']); // check config if (defined('IN_ADMIN')) { if (empty($hybridauth_conf) and strpos(@$_GET['page'], 'plugin-oAuth') === false) { $page['warnings'][] = '<a href="' . OAUTH_ADMIN . '">' . l10n('Social Connect: You need to configure the credentials') . '</a>'; } if (!function_exists('curl_init')) { $page['warnings'][] = l10n('Social Connect: PHP Curl extension is needed'); } } // in case of registration aborded if (script_basename() == 'index' and ($oauth_id = pwg_get_session_var('oauth_new_user')) !== null) { pwg_unset_session_var('oauth_new_user'); if ($oauth_id[0] == 'Persona') { oauth_assign_template_vars(get_gallery_home_url()); $template->block_footer_script(null, 'navigator.id.logout();'); } else { require_once OAUTH_PATH . 'include/hybridauth/Hybrid/Auth.php'; try { $hybridauth = new Hybrid_Auth($hybridauth_conf); $adapter = $hybridauth->getAdapter($oauth_id[0]); $adapter->logout(); } catch (Exception $e) { } } } }
/** * Constructor, load $data from session */ function __construct() { global $conf; $this->data = array_merge(array('view_as' => 0, 'theme' => '', 'lang' => '', 'show_queries' => $conf['show_queries'], 'debug_l10n' => $conf['debug_l10n'], 'debug_template' => $conf['debug_template'], 'template_combine_files' => $conf['template_combine_files'], 'no_history' => false), pwg_get_session_var('multiview', array())); $this->data_url_params = array_keys($this->data); $this->data_url_params = array_map(create_function('$d', 'return "ato_".$d;'), $this->data_url_params); }
function TAT_tour_setup() { global $template, $TAT_restart, $conf; $tour_to_launch = pwg_get_session_var('tour_to_launch'); load_language('plugin.lang', PHPWG_PLUGINS_PATH . 'TakeATour/', array('force_fallback' => 'en_UK')); list(, $tour_name) = explode('/', $tour_to_launch); load_language('tour_' . $tour_name . '.lang', PHPWG_PLUGINS_PATH . 'TakeATour/', array('force_fallback' => 'en_UK')); $template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH . 'TakeATour/tpl/js_css.tpl'); $template->assign('ADMIN_THEME', $conf['admin_theme']); $template->parse('TAT_js_css'); if (isset($TAT_restart) and $TAT_restart) { $TAT_restart = false; $template->assign('TAT_restart', true); } $tat_path = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']); $template->assign('TAT_path', $tat_path); $template->assign('ABS_U_ADMIN', get_absolute_root_url()); // absolute one due to public pages and $conf['question_mark_in_urls'] = false+$conf['php_extension_in_urls'] = false; include $tour_to_launch . '/config.inc.php'; $template->set_filename('TAT_tour_tpl', $TOUR_PATH); $template->parse('TAT_tour_tpl'); }
function language_controler_switch() { global $user; $same = $user['language']; if (isset($_GET['lang'])) { include_once PHPWG_ROOT_PATH . 'admin/include/languages.class.php'; $languages = new languages(); if (!in_array($_GET['lang'], array_keys($languages->fs_languages))) { $_GET['lang'] = PHPWG_DEFAULT_LANGUAGE; } if (!empty($_GET['lang']) and file_exists(PHPWG_ROOT_PATH . 'language/' . $_GET['lang'] . '/common.lang.php')) { if (is_a_guest() or is_generic()) { pwg_set_session_var('lang_switch', $_GET['lang']); } else { $query = ' UPDATE ' . USER_INFOS_TABLE . ' SET language = \'' . $_GET['lang'] . '\' WHERE user_id = ' . $user['id'] . ' ;'; pwg_query($query); } $user['language'] = $_GET['lang']; } } elseif (is_a_guest() or is_generic()) { $user['language'] = pwg_get_session_var('lang_switch', $user['language']); } // Reload language only if it isn't the same one if ($same !== $user['language']) { load_language('common.lang', '', array('language' => $user['language'])); load_language('lang', PHPWG_ROOT_PATH . PWG_LOCAL_DIR, array('language' => $user['language'], 'no_fallback' => true, 'local' => true)); if (defined('IN_ADMIN') and IN_ADMIN) { // Never currently load_language('admin.lang', '', array('language' => $user['language'])); } } }
$page = array_merge($page, parse_well_known_params_url($tokens, $next_token)); //access a picture only by id, file or id-file without given section if (script_basename() == 'picture' and 'categories' == $page['section'] and !isset($page['category']) and !isset($page['chronology_field'])) { $page['flat'] = true; } // $page['nb_image_page'] is the number of picture to display on this page // By default, it is the same as the $user['nb_image_page'] $page['nb_image_page'] = $user['nb_image_page']; // if flat mode is active, we must consider the image set as a standard set // and not as a category set because we can't use the #image_category.rank : // displayed images are not directly linked to the displayed category if ('categories' == $page['section'] and !isset($page['flat'])) { $conf['order_by'] = $conf['order_by_inside_category']; } if (pwg_get_session_var('image_order', 0) > 0) { $image_order_id = pwg_get_session_var('image_order'); $orders = get_category_preferred_image_orders(); // the current session stored image_order might be not compatible with // current image set, for example if the current image_order is the rank // and that we are displaying images related to a tag. // // In case of incompatibility, the session stored image_order is removed. if ($orders[$image_order_id][2]) { $conf['order_by'] = str_replace('ORDER BY ', 'ORDER BY ' . $orders[$image_order_id][1] . ',', $conf['order_by']); $page['super_order_by'] = true; } else { pwg_unset_session_var('image_order'); $page['super_order_by'] = false; } } $forbidden = get_sql_condition_FandF(array('forbidden_categories' => 'category_id', 'visible_categories' => 'category_id', 'visible_images' => 'id'), 'AND');
// +-----------------------------------------------------------------------+ if (!defined("PHPWG_ROOT_PATH")) { die("Hacking attempt!"); } include_once PHPWG_ROOT_PATH . 'admin/include/plugins.class.php'; $template->set_filenames(array('plugins' => 'plugins_installed.tpl')); // should we display details on plugins? if (isset($_GET['show_details'])) { if (1 == $_GET['show_details']) { $show_details = true; } else { $show_details = false; } pwg_set_session_var('plugins_show_details', $show_details); } elseif (null != pwg_get_session_var('plugins_show_details')) { $show_details = pwg_get_session_var('plugins_show_details'); } else { $show_details = false; } $base_url = get_root_url() . 'admin.php?page=' . $page['page']; $pwg_token = get_pwg_token(); $action_url = $base_url . '&plugin=' . '%s' . '&pwg_token=' . $pwg_token; $plugins = new plugins(); //--------------------------------------------------perform requested actions if (isset($_GET['action']) and isset($_GET['plugin'])) { if (!is_webmaster()) { $page['errors'][] = l10n('Webmaster status is required.'); } else { check_pwg_token(); $page['errors'] = $plugins->perform_action($_GET['action'], $_GET['plugin']); if (empty($page['errors'])) {
$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_key); 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['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', ''); } unset($filter_key); if (get_filter_page_value('add_notes')) { $header_notes[] = l10n_dec('Photos posted within the last %d day.', 'Photos posted within the last %d days.', $filter['recent_period']); } include_once PHPWG_ROOT_PATH . 'include/functions_filter.inc.php'; } 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_categories'); pwg_unset_session_var('filter_visible_categories'); pwg_unset_session_var('filter_visible_images'); } }
FROM ' . IMAGES_TABLE . ' ORDER BY RAND() LIMIT 1 ;'; $row = pwg_db_fetch_assoc(pwg_query($query)); $template->assign('TAT_image_id', $row['id']); } //album id if (isset($_GET['page']) and preg_match('/^album-(\\d+)(?:-(.*))?$/', $_GET['page'], $matches)) { $_GET['cat_id'] = $matches[1]; } check_input_parameter('cat_id', $_GET, false, PATTERN_ID); if (isset($_GET['cat_id']) and pwg_get_session_var('TAT_cat_id') == null) { $template->assign('TAT_cat_id', $_GET['cat_id']); pwg_set_session_var('TAT_cat_id', $_GET['cat_id']); } elseif (is_numeric(pwg_get_session_var('TAT_cat_id'))) { $template->assign('TAT_cat_id', pwg_get_session_var('TAT_cat_id')); } else { $query = ' SELECT id FROM ' . CATEGORIES_TABLE . ' ORDER BY RAND() LIMIT 1 ;'; $row = pwg_db_fetch_assoc(pwg_query($query)); $template->assign('TAT_cat_id', $row['id']); } global $conf; if (isset($conf['enable_synchronization'])) { $template->assign('TAT_FTP', $conf['enable_synchronization']); }
$row['NB_COMMENTS'] = $row['nb_comments'] = (int) @$nb_comments_of[$row['id']]; } $name = render_element_name($row); $desc = render_element_description($row, 'main_page_element_description'); $tpl_var = array_merge($row, array('TN_ALT' => htmlspecialchars(strip_tags($name)), 'TN_TITLE' => get_thumbnail_title($row, $name, $desc), 'URL' => $url, 'DESCRIPTION' => $desc, 'src_image' => new SrcImage($row))); if ($conf['index_new_icon']) { $tpl_var['icon_ts'] = get_icon($row['date_available']); } if ($user['show_nb_hits']) { $tpl_var['NB_HITS'] = $row['hit']; } switch ($page['section']) { case 'best_rated': $name = '(' . $row['rating_score'] . ') ' . $name; break; case 'most_visited': if (!$user['show_nb_hits']) { $name = '(' . $row['hit'] . ') ' . $name; } break; } $tpl_var['NAME'] = $name; $tpl_thumbnails_var[] = $tpl_var; } $template->assign(array('derivative_params' => trigger_change('get_index_derivative_params', ImageStdParams::get_by_type(pwg_get_session_var('index_deriv', IMG_THUMB))), 'maxRequests' => $conf['max_requests'], 'SHOW_THUMBNAIL_CAPTION' => $conf['show_thumbnail_caption'])); $tpl_thumbnails_var = trigger_change('loc_end_index_thumbnails', $tpl_thumbnails_var, $pictures); $template->assign('thumbnails', $tpl_thumbnails_var); $template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails'); unset($pictures, $selection, $tpl_thumbnails_var); $template->clear_assign('thumbnails'); pwg_debug('end include/category_default.inc.php');
/** * return true if mobile theme should be loaded * * @return bool */ function mobile_theme() { global $conf; if (empty($conf['mobile_theme'])) { return false; } if (isset($_GET['mobile'])) { $is_mobile_theme = get_boolean($_GET['mobile']); pwg_set_session_var('mobile_theme', $is_mobile_theme); } else { $is_mobile_theme = pwg_get_session_var('mobile_theme'); } if (is_null($is_mobile_theme)) { $is_mobile_theme = get_device() == 'mobile'; pwg_set_session_var('mobile_theme', $is_mobile_theme); } return $is_mobile_theme; }
$page['errors'][] = l10n('Can\'t read or extract archive.'); break; default: $page['errors'][] = l10n('An error occured during extraction (%s).', htmlspecialchars($_GET['installstatus'])); $page['errors'][] = l10n('Please check "plugins" folder and sub-folders permissions (CHMOD).'); } } //---------------------------------------------------------------Order options $template->assign('order_options', array('date' => l10n('Post date'), 'revision' => l10n('Last revisions'), 'name' => l10n('Name'), 'author' => l10n('Author'), 'downloads' => l10n('Number of downloads'))); // +-----------------------------------------------------------------------+ // | start template output | // +-----------------------------------------------------------------------+ if ($plugins->get_server_plugins(true)) { /* order plugins */ if (pwg_get_session_var('plugins_new_order') != null) { $order_selected = pwg_get_session_var('plugins_new_order'); $plugins->sort_server_plugins($order_selected); $template->assign('order_selected', $order_selected); } else { $plugins->sort_server_plugins('date'); $template->assign('order_selected', 'date'); } foreach ($plugins->server_plugins as $plugin) { $ext_desc = trim($plugin['extension_description'], " \n\r"); list($small_desc) = explode("\n", wordwrap($ext_desc, 200)); $url_auto_install = htmlentities($base_url) . '&revision=' . $plugin['revision_id'] . '&extension=' . $plugin['extension_id'] . '&pwg_token=' . get_pwg_token(); $template->append('plugins', array('ID' => $plugin['extension_id'], 'EXT_NAME' => $plugin['extension_name'], 'EXT_URL' => PEM_URL . '/extension_view.php?eid=' . $plugin['extension_id'], 'SMALL_DESC' => trim($small_desc, " \r\n"), 'BIG_DESC' => $ext_desc, 'VERSION' => $plugin['revision_name'], 'REVISION_DATE' => preg_replace('/[^0-9]/', '', $plugin['revision_date']), 'AUTHOR' => $plugin['author_name'], 'DOWNLOADS' => $plugin['extension_nb_downloads'], 'URL_INSTALL' => $url_auto_install, 'URL_DOWNLOAD' => $plugin['download_url'] . '&origin=piwigo_download')); } } else { $page['errors'][] = l10n('Can\'t connect to server.'); }
FROM ' . COMMENTS_TABLE . ' WHERE image_id = ' . $page['image_id'] . $validated_clause . ' ;'; $row = pwg_db_fetch_assoc(pwg_query($query)); // navigation bar creation if (!isset($page['start'])) { $page['start'] = 0; } $navigation_bar = create_navigation_bar(duplicate_picture_url(array(), array('start')), $row['nb_comments'], $page['start'], $conf['nb_comment_page'], true); $template->assign(array('COMMENT_COUNT' => $row['nb_comments'], 'navbar' => $navigation_bar)); if ($row['nb_comments'] > 0) { // comments order (get, session, conf) if (!empty($_GET['comments_order']) && in_array(strtoupper($_GET['comments_order']), array('ASC', 'DESC'))) { pwg_set_session_var('comments_order', $_GET['comments_order']); } $comments_order = pwg_get_session_var('comments_order', $conf['comments_order']); $template->assign(array('COMMENTS_ORDER_URL' => add_url_params(duplicate_picture_url(), array('comments_order' => $comments_order == 'ASC' ? 'DESC' : 'ASC')), 'COMMENTS_ORDER_TITLE' => $comments_order == 'ASC' ? l10n('Show latest comments first') : l10n('Show oldest comments first'))); $query = ' SELECT com.id, author, author_id, u.' . $conf['user_fields']['email'] . ' AS user_email, date, image_id, website_url, com.email, content, validated FROM ' . COMMENTS_TABLE . ' AS com LEFT JOIN ' . USERS_TABLE . ' AS u
function modus_picture_content($content, $element_info) { global $conf, $picture, $template; if (!empty($content)) { // someone hooked us - so we skip; return $content; } $unique_derivatives = array(); $show_original = isset($element_info['element_url']); $added = array(); foreach ($element_info['derivatives'] as $type => $derivative) { if ($type == IMG_SQUARE || $type == IMG_THUMB) { continue; } if (!array_key_exists($type, ImageStdParams::get_defined_type_map())) { continue; } $url = $derivative->get_url(); if (isset($added[$url])) { continue; } $added[$url] = 1; $show_original &= !$derivative->same_as_source(); $unique_derivatives[$type] = $derivative; } if (isset($_COOKIE['picture_deriv'])) { // ignore persistence setcookie('picture_deriv', false, 0, cookie_path()); } $selected_derivative = null; if (isset($_COOKIE['phavsz'])) { $available_size = explode('x', $_COOKIE['phavsz']); } elseif (($caps = pwg_get_session_var('caps')) && $caps[0] > 1) { $available_size = array($caps[0] * $caps[1], $caps[0] * ($caps[2] - 100), $caps[0]); } if (isset($available_size)) { foreach ($unique_derivatives as $derivative) { $size = $derivative->get_size(); if (!$size) { break; } if ($size[0] <= $available_size[0] and $size[1] <= $available_size[1]) { $selected_derivative = $derivative; } else { if ($available_size[2] > 1 || !$selected_derivative) { $selected_derivative = $derivative; } break; } } if ($available_size[2] > 1 && $selected_derivative) { $ratio_w = $size[0] / $available_size[0]; $ratio_h = $size[1] / $available_size[1]; if ($ratio_w > 1 || $ratio_h > 1) { if ($ratio_w > $ratio_h) { $display_size = array($available_size[0] / $available_size[2], floor($size[1] / $ratio_w / $available_size[2])); } else { $display_size = array(floor($size[0] / $ratio_h / $available_size[2]), $available_size[1] / $available_size[2]); } } else { $display_size = array(round($size[0] / $available_size[2]), round($size[1] / $available_size[2])); } $template->assign(array('rvas_display_size' => $display_size, 'rvas_natural_size' => $size)); } if (isset($picture['next']) and $picture['next']['src_image']->is_original()) { $next_best = null; foreach ($picture['next']['derivatives'] as $derivative) { $size = $derivative->get_size(); if (!$size) { break; } if ($size[0] <= $available_size[0] and $size[1] <= $available_size[1]) { $next_best = $derivative; } else { if ($available_size[2] > 1 || !$next_best) { $next_best = $derivative; } break; } } if (isset($next_best)) { $template->assign('U_PREFETCH', $next_best->get_url()); } } } $as_pending = false; if (!$selected_derivative) { $as_pending = true; $selected_derivative = $element_info['derivatives'][pwg_get_session_var('picture_deriv', $conf['derivative_default_size'])]; } if ($show_original) { $template->assign('U_ORIGINAL', $element_info['element_url']); } $template->append('current', array('selected_derivative' => $selected_derivative, 'unique_derivatives' => $unique_derivatives), true); $template->set_filenames(array('default_content' => 'picture_content_asize.tpl')); $template->assign(array('ALT_IMG' => $element_info['file'], 'COOKIE_PATH' => cookie_path(), 'RVAS_PENDING' => $as_pending)); return $template->parse('default_content', true); }
/** * Function called from UAM_admin.php to send notification email when user registration have been manually validated by admin * * @param : user id * */ function validation_mail($id) { global $conf; $conf_UAM = unserialize($conf['UserAdvManager']); include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $custom_txt = ""; $subject = ""; // We have to get the user's language in database // ---------------------------------------------- $query = ' SELECT user_id, language FROM ' . USER_INFOS_TABLE . ' WHERE user_id = ' . $id . ' ;'; $data = pwg_db_fetch_assoc(pwg_query($query)); // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language // ------------------------------------------------------------------------------------------------------------------------------- if (empty($data)) { // And switch gallery to this language before using personalized and multilangual contents // --------------------------------------------------------------------------------------- $language = pwg_get_session_var('lang_switch', $user['language']); switch_lang_to($language); } else { // And switch gallery to this language before using personalized and multilangual contents // --------------------------------------------------------------------------------------- $language = $data['language']; // Usefull for debugging switch_lang_to($data['language']); load_language('plugin.lang', UAM_PATH); } // Retreive users email and user name from id // ------------------------------------------ $query = ' SELECT id, username, mail_address FROM ' . USERS_TABLE . ' WHERE id = ' . $id . ' ;'; $result = pwg_db_fetch_assoc(pwg_query($query)); if (isset($conf_UAM['ADMINVALIDATIONMAIL_SUBJECT']) and !empty($conf_UAM['ADMINVALIDATIONMAIL_SUBJECT'])) { // Management of Extension flags ([username], [mygallery]) // ------------------------------------------------------- $patterns[] = '#\\[username\\]#i'; $replacements[] = stripslashes($result['username']); $patterns[] = '#\\[mygallery\\]#i'; $replacements[] = $conf['gallery_title']; if (function_exists('get_user_language_desc')) { $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL_SUBJECT'])) . "\n\n"; } else { $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL_SUBJECT'])) . "\n\n"; } } if (isset($conf_UAM['ADMINVALIDATIONMAIL']) and !empty($conf_UAM['ADMINVALIDATIONMAIL'])) { // Management of Extension flags ([username], [mygallery], [myurl]) // ---------------------------------------------------------------- $patterns[] = '#\\[username\\]#i'; $replacements[] = stripslashes($result['username']); $patterns[] = '#\\[mygallery\\]#i'; $replacements[] = $conf['gallery_title']; $patterns[] = '#\\[myurl\\]#i'; $replacements[] = get_gallery_home_url(); if (function_exists('get_user_language_desc')) { $custom_txt = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL'])) . "\n\n"; } else { $custom_txt = l10n(preg_replace($patterns, $replacements, $conf_UAM['ADMINVALIDATIONMAIL'])) . "\n\n"; } } $infos = array(get_l10n_args('UAM_User: %s', stripslashes($result['username'])), get_l10n_args('Email: %s', $result['mail_address']), get_l10n_args('', '')); // Sending the email with subject and contents // ------------------------------------------- // Adding gallery URL at the end of the email if (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'true') { $content = l10n_args($infos) . "\n\n" . $custom_txt . get_absolute_root_url(); pwg_mail(array('name' => stripslashes($result['username']), 'email' => $result['mail_address']), array('content' => $content, 'content_format' => 'text/plain', 'subject' => $subject)); // Send a copy to admins if (isset($conf_UAM['EMAILS_COPY_TO_ADMINS']) and $conf_UAM['EMAILS_COPY_TO_ADMINS'] == 'true') { UAM_Copy2Admins($subject, $content); } } elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false') { $content = l10n_args($infos) . "\n\n" . $custom_txt; pwg_mail(array('name' => stripslashes($result['username']), 'email' => $result['mail_address']), array('content' => $content, 'content_format' => 'text/plain', 'subject' => $subject)); // Send a copy to admins if (isset($conf_UAM['EMAILS_COPY_TO_ADMINS']) and $conf_UAM['EMAILS_COPY_TO_ADMINS'] == 'true') { UAM_Copy2Admins($subject, $content); } } else { $content = l10n_args($infos) . "\n\n" . $custom_txt; pwg_mail(array('name' => stripslashes($result['username']), 'email' => $result['mail_address']), array('content' => $content, 'content_format' => 'text/plain', 'subject' => $subject)); // Send a copy to admins if (isset($conf_UAM['EMAILS_COPY_TO_ADMINS']) and $conf_UAM['EMAILS_COPY_TO_ADMINS'] == 'true') { UAM_Copy2Admins($subject, $content); } } // Switching back to default language // ---------------------------------- switch_lang_back(); }
function default_picture_content($content, $element_info) { global $conf; if (!empty($content)) { // someone hooked us - so we skip; return $content; } if (isset($_COOKIE['picture_deriv'])) { if (array_key_exists($_COOKIE['picture_deriv'], ImageStdParams::get_defined_type_map())) { pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']); } setcookie('picture_deriv', false, 0, cookie_path()); } $deriv_type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); $selected_derivative = $element_info['derivatives'][$deriv_type]; $unique_derivatives = array(); $show_original = isset($element_info['element_url']); $added = array(); foreach ($element_info['derivatives'] as $type => $derivative) { if ($type == IMG_SQUARE || $type == IMG_THUMB) { continue; } if (!array_key_exists($type, ImageStdParams::get_defined_type_map())) { continue; } $url = $derivative->get_url(); if (isset($added[$url])) { continue; } $added[$url] = 1; $show_original &= !$derivative->same_as_source(); $unique_derivatives[$type] = $derivative; } global $page, $template; if ($show_original) { $template->assign('U_ORIGINAL', $element_info['element_url']); } $template->append('current', array('selected_derivative' => $selected_derivative, 'unique_derivatives' => $unique_derivatives), true); $template->set_filenames(array('default_content' => 'picture_content.tpl')); $template->assign(array('ALT_IMG' => $element_info['file'], 'COOKIE_PATH' => cookie_path())); return $template->parse('default_content', true); }
/** * register page */ function oauth_begin_register() { global $conf, $template, $hybridauth_conf, $page, $user; if ($hybridauth_conf['enabled'] == 0) { return; } // coming from identification page if (pwg_get_session_var('oauth_new_user') != null) { list($provider, $user_identifier) = pwg_get_session_var('oauth_new_user'); try { if ($provider == 'Persona') { $template->assign('OAUTH_USER', array('provider' => 'Persona', 'username' => $user_identifier, 'u_profile' => null, 'avatar' => null)); oauth_assign_template_vars(); $template->append('OAUTH', array('persona_email' => $user_identifier), true); $conf['oauth']['include_common_template'] = true; } else { require_once OAUTH_PATH . 'include/hybridauth/Hybrid/Auth.php'; $hybridauth = new Hybrid_Auth($hybridauth_conf); $adapter = $hybridauth->authenticate($provider); $remote_user = $adapter->getUserProfile(); // security, check remote identifier if ($remote_user->identifier != $user_identifier) { pwg_unset_session_var('oauth_new_user'); throw new Exception('Hacking attempt!', 403); } $template->assign('OAUTH_USER', array('provider' => $hybridauth_conf['providers'][$provider]['name'], 'username' => $remote_user->displayName, 'u_profile' => $remote_user->profileURL, 'avatar' => $remote_user->photoURL)); } $oauth_id = pwg_db_real_escape_string($provider . '---' . $user_identifier); $page['infos'][] = l10n('Your registration is almost done, please complete the registration form.'); // register form submited if (isset($_POST['submit'])) { $user_id = register_user($_POST['login'], hash('sha1', $oauth_id . $conf['secret_key']), $_POST['mail_address'], true, $page['errors'], false); if ($user_id !== false) { pwg_unset_session_var('oauth_new_user'); // update oauth field single_update(USER_INFOS_TABLE, array('oauth_id' => $oauth_id), array('user_id' => $user_id)); // log_user and redirect log_user($user_id, false); redirect('profile.php'); } unset($_POST['submit']); } else { if (isset($_POST['login']) && $conf['oauth']['allow_merge_accounts']) { if ($conf['insensitive_case_logon'] == true) { $_POST['username'] = search_case_username($_POST['username']); } $user_id = get_userid($_POST['username']); if ($user_id === false) { $page['errors'][] = l10n('Invalid username or email'); } else { if ($user_id == $conf['webmaster_id']) { $page['errors'][] = l10n('For security reason, the main webmaster account can\'t be merged with a remote account, but you can use another webmaster account.'); } else { if (pwg_login(false, $_POST['username'], $_POST['password'], false)) { // update oauth field single_update(USER_INFOS_TABLE, array('oauth_id' => $oauth_id), array('user_id' => $user['id'])); pwg_unset_session_var('oauth_new_user'); redirect('profile.php'); } else { $page['errors'][] = l10n('Invalid password!'); } } } } } // overwrite fields with remote datas if ($provider == 'Persona') { $_POST['login'] = ''; $_POST['mail_address'] = $user_identifier; } else { $_POST['login'] = $remote_user->displayName; $_POST['mail_address'] = $remote_user->email; } // template $template->assign('OAUTH_PATH', OAUTH_PATH); if ($conf['oauth']['allow_merge_accounts']) { $template->assign('OAUTH_LOGIN_IN_REGISTER', true); $template->set_prefilter('register', 'oauth_add_login_in_register'); } else { $template->set_prefilter('register', 'oauth_add_profile_prefilter'); $template->set_prefilter('register', 'oauth_remove_password_fields_prefilter'); } } catch (Exception $e) { $page['errors'][] = l10n('An error occured, please contact the gallery owner. <i>Error code : %s</i>', $e->getCode()); } } else { if ($conf['oauth']['display_register']) { oauth_assign_template_vars(get_gallery_home_url()); $template->set_prefilter('register', 'oauth_add_buttons_prefilter'); } } }
function Fotorama_end_picture() { global $template, $conf, $user, $page; if (Fotorama_is_replace_picture()) { $url_up = duplicate_index_url(array('start' => floor($page['current_rank'] / $page['nb_image_page']) * $page['nb_image_page']), array('start')); //slideshow end $template->assign(array('U_SLIDESHOW_STOP' => $url_up)); $template->assign('replace_picture', true); } if (!$page['slideshow']) { return; } load_language('plugin.lang', FOTORAMA_PATH); $split_limit = 400; if ('mobile' == get_device()) { $split_limit /= 2; } $view_offset = null; if (count($page['items']) >= 1.2 * $split_limit) { $first = $split_limit * 0.2; $last = $split_limit - $first; $first = $page['current_rank'] - $first; if ($first < 0) { $first += count($page['items']); } $last = $page['current_rank'] + $last; if ($last >= count($page['items'])) { $last -= count($page['items']); } if ($first < $last) { $selection = array_slice($page['items'], $first, $last - $first); $view_borders = array(0, count($selection) - 1); $view_offset = array('from' => 0, 'offset' => $first); } else { $selection = array_slice($page['items'], 0, $last); $view_borders = array(count($selection), count($selection) - 1); $view_offset = array('from' => count($selection), 'offset' => $first - count($selection)); $selection = array_merge($selection, array_slice($page['items'], $first)); } } else { $selection = $page['items']; $view_borders = null; } $query = ' SELECT * FROM ' . IMAGES_TABLE . ' WHERE id IN (' . implode(',', $selection) . ') ORDER BY FIELD(id, ' . implode(',', $selection) . ') ;'; $result = pwg_query($query); $current = $template->get_template_vars('current'); if (isset($current['selected_derivative'])) { $type = $current['selected_derivative']->get_type(); } $defined = ImageStdParams::get_defined_type_map(); if (!isset($type) or !isset($defined[$type])) { $type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); } $skip = -1; $big_type = $type; $next_type = $type; foreach (ImageStdParams::get_defined_type_map() as $def_type => $params) { if ($def_type == $type) { $skip = 2; } if ($skip >= 0) { $big_type = $def_type; } if ($skip >= 1 and $conf['Fotorama']['resize']) { $next_type = $def_type; } if ($skip == 0) { break; } $skip = $skip - 1; } $type = $next_type; // +1 size for inpage slideshow if ($conf['Fotorama']['only_fullscreen']) { $type = $big_type; } $type_params = ImageStdParams::get_by_type($type); $big_type_params = ImageStdParams::get_by_type($big_type); if ($conf['Fotorama']['nav'] == 'thumbs' or $conf['Fotorama']['fullscreen_nav'] == 'thumbs') { $has_thumbs = true; } else { $has_thumbs = false; } if ($has_thumbs) { if ($conf['Fotorama']['square_thumb']) { $thumb_params = ImageStdParams::get_custom($conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight'], 1, $conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight']); } else { $thumb_params = ImageStdParams::get_custom(9999, $conf['Fotorama']['thumbheight']); } } $picture = array(); while ($row = pwg_db_fetch_assoc($result)) { $row['src_image'] = new SrcImage($row); $row['derivative'] = new DerivativeImage($type_params, $row['src_image']); $row['derivative_big'] = new DerivativeImage($big_type_params, $row['src_image']); if ($has_thumbs) { $row['derivative_thumb'] = new DerivativeImage($thumb_params, $row['src_image']); } $row['url'] = duplicate_picture_url(array('image_id' => $row['id'], 'image_file' => $row['file']), array('start')); $row['TITLE'] = render_element_name($row); $picture[] = $row; } $picture = trigger_change('fotorama_items', $picture, $selection); $template->assign(array('TOTAL_ITEMS' => count($page['items']), 'view_borders' => $view_borders, 'view_offset' => $view_offset, 'current_rank' => array_search($page['image_id'], $selection))); $template->assign('item_height', ImageStdParams::get_by_type($type)->max_height()); $template->assign('items', $picture); $template->assign(array('Fotorama' => $conf['Fotorama'])); $template->assign('Fotorama_has_thumbs', $has_thumbs); if (is_file('./themes/' . $user['theme'] . '/template/fotorama.tpl')) { $template->set_filenames(array('slideshow' => realpath('./themes/' . $user['theme'] . '/template/fotorama.tpl'))); } else { $template->set_filenames(array('slideshow' => realpath(FOTORAMA_PATH . 'template/fotorama.tpl'))); } $template->assign('FOTORAMA_CONTENT_PATH', realpath(FOTORAMA_PATH . 'template/fotorama-content.tpl')); }
<?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']); }
} $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) { $first_order = substr($first_order, 0, $pos); } $first_order = trim($first_order); $url = add_url_params(duplicate_index_url(), array('image_order' => '')); $tpl_orders = array(); $order_selected = false; foreach ($preferred_image_orders as $order_id => $order) { if ($order[2]) { // force select if the field is the first field of order_by if (!$order_selected && $order[1] == $first_order) { $order_idx = $order_id; $order_selected = true;