コード例 #1
0
 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';
     }
 }
コード例 #2
0
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']));
        }
    }
}
コード例 #3
0
<?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']);
}
コード例 #4
0
ファイル: functions.inc.php プロジェクト: squidjam/Piwigo
/**
 * 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;
}
コード例 #5
0
ファイル: picture.php プロジェクト: lcorbasson/Piwigo
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);
}
コード例 #6
0
ファイル: admin.php プロジェクト: lcorbasson/Piwigo
define('IN_ADMIN', true);
include_once PHPWG_ROOT_PATH . 'include/common.inc.php';
include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
include_once PHPWG_ROOT_PATH . 'admin/include/functions_plugins.inc.php';
include_once PHPWG_ROOT_PATH . 'admin/include/add_core_tabs.inc.php';
trigger_notify('loc_begin_admin');
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok                      |
// +-----------------------------------------------------------------------+
check_status(ACCESS_ADMINISTRATOR);
// +-----------------------------------------------------------------------+
// | Direct actions                                                        |
// +-----------------------------------------------------------------------+
// save plugins_new display order (AJAX action)
if (isset($_GET['plugins_new_order'])) {
    pwg_set_session_var('plugins_new_order', $_GET['plugins_new_order']);
    exit;
}
// theme changer
if (isset($_GET['change_theme'])) {
    $admin_themes = array('roma', 'clear');
    $new_admin_theme = array_pop(array_diff($admin_themes, array($conf['admin_theme'])));
    conf_update_param('admin_theme', $new_admin_theme);
    $url_params = array();
    foreach (array('page', 'tab', 'section') as $url_param) {
        if (isset($_GET[$url_param])) {
            $url_params[] = $url_param . '=' . $_GET[$url_param];
        }
    }
    $redirect_url = 'admin.php';
    if (count($url_params) > 0) {
コード例 #7
0
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA.                                                                  |
// +-----------------------------------------------------------------------+
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 . '&amp;plugin=' . '%s' . '&amp;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();
コード例 #8
0
ファイル: filter.inc.php プロジェクト: lcorbasson/Piwigo
            $query .= '
  category_id  IN (' . $filter['visible_categories'] . ') and';
        }
        $query .= '
    date_available >= ' . pwg_db_get_recent_period_expression($filter['recent_period']);
        $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');
コード例 #9
0
    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']);
}
//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']);
コード例 #10
0
ファイル: index.php プロジェクト: squidjam/Piwigo
    page_not_found('', duplicate_index_url(array('start' => 0)));
}
trigger_notify('loc_begin_index');
//---------------------------------------------- change of image display order
if (isset($_GET['image_order'])) {
    if ((int) $_GET['image_order'] > 0) {
        pwg_set_session_var('image_order', (int) $_GET['image_order']);
    } else {
        pwg_unset_session_var('image_order');
    }
    redirect(duplicate_index_url(array(), array('start')));
}
if (isset($_GET['display'])) {
    $page['meta_robots']['noindex'] = 1;
    if (array_key_exists($_GET['display'], ImageStdParams::get_defined_type_map())) {
        pwg_set_session_var('index_deriv', $_GET['display']);
    }
}
//-------------------------------------------------------------- initialization
// navigation bar
$page['navigation_bar'] = array();
if (count($page['items']) > $page['nb_image_page']) {
    $page['navigation_bar'] = create_navigation_bar(duplicate_index_url(array(), array('start')), count($page['items']), $page['start'], $page['nb_image_page'], true, 'start');
}
$template->assign('thumb_navbar', $page['navigation_bar']);
// caddie filling :-)
if (isset($_GET['caddie'])) {
    fill_caddie($page['items']);
    redirect(duplicate_index_url());
}
if (isset($page['is_homepage']) and $page['is_homepage']) {
コード例 #11
0
SELECT
    COUNT(*) AS nb_comments
  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
コード例 #12
0
 /**
  * Save $data in session
  */
 private function save()
 {
     pwg_set_session_var('multiview', $this->data);
 }
コード例 #13
0
ファイル: themeconf.inc.php プロジェクト: joubu/piwigo-modus
//HEAVY TEARDROP-SPOKED ASTERISK
define('MODUS_STR_RECENT_CHILD', "✻");
//TEARDROP-SPOKED ASTERISK
if (isset($conf['modus_theme']) && !is_array($conf['modus_theme'])) {
    $conf['modus_theme'] = unserialize($conf['modus_theme']);
}
if (!empty($_GET['skin']) && !preg_match('/[^a-zA-Z0-9_-]/', $_GET['skin'])) {
    $conf['modus_theme']['skin'] = $_GET['skin'];
}
$this->assign(array('MODUS_CSS_VERSION' => crc32(implode(',', array('a' . @$conf['modus_theme']['skin'], @$conf['modus_theme']['album_thumb_size'], ImageStdParams::get_by_type(IMG_SQUARE)->max_width(), $conf['index_created_date_icon'], $conf['index_posted_date_icon']))), 'MODUS_DISPLAY_PAGE_BANNER' => @$conf['modus_theme']['display_page_banner']));
if (!$conf['compiled_template_cache_language']) {
    load_language('theme.lang', dirname(__FILE__) . '/');
}
if (isset($_COOKIE['caps'])) {
    setcookie('caps', false, 0, cookie_path());
    pwg_set_session_var('caps', explode('x', $_COOKIE['caps']));
    /*file_put_contents(PHPWG_ROOT_PATH.$conf['data_location'].'tmp/modus.log', implode("\t", array(
    		date("Y-m-d H:i:s"), $_COOKIE['caps'], $_SERVER['HTTP_USER_AGENT']
    		))."\n", FILE_APPEND);*/
}
if ('mobile' == get_device()) {
    $conf['tag_letters_column_number'] = 1;
} elseif ('tablet' == get_device()) {
    $conf['tag_letters_column_number'] = min($conf['tag_letters_column_number'], 3);
}
$this->smarty->registerFilter('pre', 'modus_smarty_prefilter_wrap');
function modus_smarty_prefilter_wrap($source)
{
    include_once dirname(__FILE__) . '/functions.inc.php';
    return modus_smarty_prefilter($source);
}
コード例 #14
0
    // connected
    if (!empty($oauth_id)) {
        // check is already registered
        $query = '
SELECT user_id FROM ' . USER_INFOS_TABLE . '
  WHERE oauth_id = \'' . pwg_db_real_escape_string(implode('---', $oauth_id)) . '\'
;';
        $result = pwg_query($query);
        // registered : log_user and redirect
        if (pwg_db_num_rows($result)) {
            list($user_id) = pwg_db_fetch_row($result);
            log_user($user_id, false);
            $redirect_to = 'default';
        } else {
            if ($conf['allow_user_registration']) {
                pwg_set_session_var('oauth_new_user', $oauth_id);
                $redirect_to = 'register';
            } else {
                $_SESSION['page_errors'][] = l10n('Sorry, new registrations are blocked on this gallery.');
                if (isset($adapter)) {
                    $adapter->logout();
                }
                $redirect_to = 'identification';
            }
        }
        if ($provider == 'Persona') {
            echo json_encode(compact('redirect_to'));
            header('HTTP/1.1 200 OK');
            exit;
        } else {
            $template->assign('REDIRECT_TO', $redirect_to);
コード例 #15
0
/*
Plugin Name: Take A Tour of Your Piwigo
Version: 2.7.4
Description: Visit your Piwigo to discover its features. This plugin has multiple thematic tours for beginners and advanced users.
Plugin URI: http://piwigo.org/ext/extension_view.php?eid=776
Author:Piwigo Team
Author URI: http://piwigo.org
*/
if (!defined('PHPWG_ROOT_PATH')) {
    die('Hacking attempt!');
}
/** Tour sended via $_POST or $_GET**/
if (isset($_REQUEST['submited_tour_path']) and defined('IN_ADMIN') and IN_ADMIN) {
    check_pwg_token();
    pwg_set_session_var('tour_to_launch', $_REQUEST['submited_tour_path']);
    global $TAT_restart;
    $TAT_restart = true;
} elseif (isset($_GET['tour_ended']) and defined('IN_ADMIN') and IN_ADMIN) {
    pwg_unset_session_var('tour_to_launch');
}
/** Setup the tour **/
/*
 * CHANGE FOR RELEASE
$version_=str_replace('.','_',PHPWG_VERSION);*/
$version_ = "2_7_0";
/***/
if (pwg_get_session_var('tour_to_launch') != 'tours/' . $version_ and isset($_GET['page']) and $_GET['page'] == "plugin-TakeATour") {
    pwg_unset_session_var('tour_to_launch');
} elseif (pwg_get_session_var('tour_to_launch')) {
    add_event_handler('init', 'TAT_tour_setup');