static function on_index_thumbnails($thumbs)
 {
     global $page, $template;
     $total = count($page['items']);
     if (count($thumbs) >= $total) {
         add_event_handler('loc_end_index', array('RVTS', 'on_end_index'));
         return $thumbs;
     }
     $url_model = str_replace('123456789', '%start%', duplicate_index_url(array('start' => 123456789)));
     $ajax_url_model = add_url_params($url_model, array('rvts' => '%per%'));
     $url_model = str_replace('&', '&', $url_model);
     $ajax_url_model = str_replace('&', '&', $ajax_url_model);
     $my_base_name = basename(dirname(__FILE__));
     $ajax_loader_image = get_root_url() . "plugins/{$my_base_name}/ajax-loader.gif";
     $template->func_combine_script(array('id' => 'jquery', 'load' => 'footer', 'path' => 'themes/default/js/jquery.min.js'));
     $template->func_combine_script(array('id' => $my_base_name, 'load' => 'async', 'path' => 'plugins/' . $my_base_name . '/rv_tscroller.min.js', 'require' => 'jquery', 'version' => RVTS_VERSION));
     $start = (int) $page['start'];
     $per_page = $page['nb_image_page'];
     $moreMsg = 'See the remaining %d photos';
     if ('en' != $GLOBALS['lang_info']['code']) {
         load_language('lang', dirname(__FILE__) . '/');
         $moreMsg = l10n($moreMsg);
     }
     // the String.fromCharCode comes from google bot which somehow manage to get these urls
     $template->block_footer_script(null, "var RVTS = {\najaxUrlModel: String.fromCharCode(" . ord($ajax_url_model[0]) . ")+'" . substr($ajax_url_model, 1) . "',\nstart: {$start},\nperPage: {$per_page},\nnext: " . ($start + $per_page) . ",\ntotal: {$total},\nurlModel: String.fromCharCode(" . ord($url_model[0]) . ")+'" . substr($url_model, 1) . "',\nmoreMsg: '{$moreMsg}',\nprevMsg: '" . l10n("Previous") . "',\najaxLoaderImage: '{$ajax_loader_image}'\n};\njQuery('.navigationBar').hide();");
     return $thumbs;
 }
function osm_photo_add_tab($sheets, $id)
{
    if ($id == 'photo') {
        $sheets['openstreetmap'] = array('caption' => '<span class="osm-globe"></span>OpenStreetMap', 'url' => get_root_url() . 'admin.php?page=plugin&amp;section=piwigo-openstreetmap/admin/admin_photo.php&amp;image_id=' . $_GET['image_id']);
    }
    return $sheets;
}
 protected function setUp()
 {
     $this->install_type = get_install_type();
     $this->page_root = get_root_url();
     $this->setBrowser("*firefox");
     $this->setBrowserUrl($this->page_root . '/');
 }
/**
 * 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');
            }
        }
    }
}
/**
 * Plugin administration menu
 */
function PH_admin_menu($menu)
{
    // Retreive plugin name
    $plugin = PHInfos(PH_PATH);
    $name = $plugin['name'];
    array_push($menu, array('NAME' => $name, 'URL' => get_root_url() . 'admin.php?page=plugin-' . basename(PH_PATH)));
    return $menu;
}
function NBMS_admin_menu($menu)
{
    // +-----------------------------------------------------------------------+
    // |                      Getting plugin name                              |
    // +-----------------------------------------------------------------------+
    $plugin = NBMSInfos(NBMS_PATH);
    $name = $plugin['name'];
    array_push($menu, array('NAME' => $name, 'URL' => get_root_url() . 'admin.php?page=plugin-' . basename(NBMS_PATH)));
    return $menu;
}
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 vjs_add_tab($sheets, $id)
{
    if ($id == 'photo') {
        $query = "SELECT id FROM " . IMAGES_TABLE . " WHERE " . SQL_VIDEOS . " AND id = " . $_GET['image_id'] . ";";
        $result = pwg_query($query);
        if (!pwg_db_num_rows($result)) {
            return $sheets;
        }
        $sheets['videojs'] = array('caption' => 'VideoJS', 'url' => get_root_url() . 'admin.php?page=plugin&amp;section=piwigo-videojs/admin/admin_photo.php&amp;image_id=' . $_GET['image_id']);
        unset($sheets['coi'], $sheets['update']);
        unset($sheets['rotate'], $sheets['update']);
        /* Replace the RotateImage by a our own */
        $sheets['rotate'] = array('caption' => 'Rotate', 'url' => get_root_url() . 'admin.php?page=plugin&amp;section=piwigo-videojs/admin/admin_rotate.php&amp;image_id=' . $_GET['image_id']);
    }
    return $sheets;
}
/**
 * Retrieves an url for a plugin page.
 * @param string file - php script full name
 */
function get_admin_plugin_menu_link($file)
{
    global $page;
    $real_file = realpath($file);
    $url = get_root_url() . 'admin.php?page=plugin';
    if (false !== $real_file) {
        $real_plugin_path = rtrim(realpath(PHPWG_PLUGINS_PATH), '\\/');
        $file = substr($real_file, strlen($real_plugin_path) + 1);
        $file = str_replace('\\', '/', $file);
        //Windows
        $url .= '&amp;section=' . urlencode($file);
    } else {
        if (isset($page['errors'])) {
            $page['errors'][] = 'PLUGIN ERROR: "' . $file . '" is not a valid file';
        }
    }
    return $url;
}
function oauth_assign_template_vars($u_redirect = null)
{
    global $template, $conf, $hybridauth_conf, $user;
    $conf['oauth']['include_common_template'] = true;
    if ($template->get_template_vars('OAUTH') == null) {
        if (!empty($user['oauth_id'])) {
            list($provider, $identifier) = explode('---', $user['oauth_id'], 2);
            if ($provider == 'Persona') {
                $persona_email = $identifier;
            }
        }
        $template->assign('OAUTH', array('conf' => $conf['oauth'], 'u_login' => get_root_url() . OAUTH_PATH . 'auth.php?provider=', 'providers' => $hybridauth_conf['providers'], 'persona_email' => @$persona_email, 'key' => get_ephemeral_key(0)));
        $template->assign(array('OAUTH_PATH' => OAUTH_PATH, 'OAUTH_ABS_PATH' => realpath(OAUTH_PATH) . '/', 'ABS_ROOT_URL' => rtrim(get_gallery_home_url(), '/') . '/'));
    }
    if (isset($u_redirect)) {
        $template->append('OAUTH', compact('u_redirect'), true);
    }
}
/**
 * interrupt normal login if corresponding to an oauth user
 */
function oauth_try_log_user($success, $username)
{
    global $conf, $redirect_to;
    $query = '
SELECT oauth_id
  FROM ' . USER_INFOS_TABLE . ' AS i
    INNER JOIN ' . USERS_TABLE . ' AS u
    ON i.user_id = u.' . $conf['user_fields']['id'] . '
  WHERE ' . $conf['user_fields']['username'] . ' = "' . pwg_db_real_escape_string($username) . '"
  AND oauth_id != ""
;';
    $result = pwg_query($query);
    if (pwg_db_num_rows($result)) {
        list($oauth_id) = pwg_db_fetch_row($result);
        list($provider) = explode('---', $oauth_id, 2);
        $_SESSION['page_errors'][] = l10n('You registered with a %s account, please sign in with the same account.', $provider);
        $redirect_to = get_root_url() . 'identification.php';
        // variable used by identification.php
        return true;
    }
    return false;
}
function pfemail_admin_menu($menu)
{
    global $page;
    $query = '
SELECT
    COUNT(*)
  FROM ' . PFEMAIL_PENDINGS_TABLE . '
    JOIN ' . IMAGES_TABLE . ' ON image_id = id
  WHERE state = \'moderation_pending\'
;';
    $result = pwg_query($query);
    list($page['pfemail_nb_pendings']) = pwg_db_fetch_row($result);
    $name = 'Photo from Email';
    if ($page['pfemail_nb_pendings'] > 0) {
        $style = 'background-color:#666;';
        $style .= 'color:white;';
        $style .= 'padding:1px 5px;';
        $style .= 'border-radius:10px;';
        $style .= 'margin-left:5px;';
        $name .= '<span style="' . $style . '">' . $page['pfemail_nb_pendings'] . '</span>';
    }
    array_push($menu, array('NAME' => $name, 'URL' => get_root_url() . 'admin.php?page=plugin-photo_from_email'));
    return $menu;
}
Exemple #13
0
// | the Free Software Foundation                                          |
// |                                                                       |
// | This program is distributed in the hope that it will be useful, but   |
// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
// | General Public License for more details.                              |
// |                                                                       |
// | 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.                                                                  |
// +-----------------------------------------------------------------------+
if (!defined("PHPWG_ROOT_PATH")) {
    die("Hacking attempt!");
}
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
$my_base_url = get_root_url() . 'admin.php?page=languages';
if (isset($_GET['tab'])) {
    $page['tab'] = $_GET['tab'];
} else {
    $page['tab'] = 'installed';
}
$tabsheet = new tabsheet();
$tabsheet->set_id('languages');
$tabsheet->select($page['tab']);
$tabsheet->assign();
if ($page['tab'] == 'update') {
    include PHPWG_ROOT_PATH . 'admin/updates_ext.php';
} else {
    include PHPWG_ROOT_PATH . 'admin/languages_' . $page['tab'] . '.php';
}
Exemple #14
0
if ('sizes' == $page['section'] and isset($_GET['action']) and 'restore_settings' == $_GET['action']) {
    ImageStdParams::set_and_save(ImageStdParams::get_default_sizes());
    pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param = \'disabled_derivatives\'');
    clear_derivative_cache();
    $page['infos'][] = l10n('Your configuration settings are saved');
}
//----------------------------------------------------- template initialization
$template->set_filename('config', 'configuration_' . $page['section'] . '.tpl');
// TabSheet
$tabsheet = new tabsheet();
$tabsheet->set_id('configuration');
$tabsheet->select($page['section']);
$tabsheet->assign();
$action = get_root_url() . 'admin.php?page=configuration';
$action .= '&amp;section=' . $page['section'];
$template->assign(array('U_HELP' => get_root_url() . 'admin/popuphelp.php?page=configuration', 'F_ACTION' => $action));
switch ($page['section']) {
    case 'main':
        function order_by_is_local()
        {
            @(include PHPWG_ROOT_PATH . 'local/config/config.inc.php');
            if (isset($conf['local_dir_site'])) {
                @(include PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'config/config.inc.php');
            }
            return isset($conf['order_by']) or isset($conf['order_by_inside_category']);
        }
        if (order_by_is_local()) {
            $page['warnings'][] = l10n('You have specified <i>$conf[\'order_by\']</i> in your local configuration file, this parameter in deprecated, please remove it or rename it into <i>$conf[\'order_by_custom\']</i> !');
        }
        if (isset($conf['order_by_custom']) or isset($conf['order_by_inside_category_custom'])) {
            $order_by = array('');
Exemple #15
0
        }
        //
        // add permissions to users
        //
        $grant_users = $_POST['users'];
        if (count($grant_users) > 0) {
            add_permission_on_category($page['cat'], $grant_users);
        }
    }
    $page['infos'][] = l10n('Album updated successfully');
}
// +-----------------------------------------------------------------------+
// |                       template initialization                         |
// +-----------------------------------------------------------------------+
$template->set_filename('cat_perm', 'cat_perm.tpl');
$template->assign(array('CATEGORIES_NAV' => get_cat_display_name_from_id($page['cat'], 'admin.php?page=album-'), 'U_HELP' => get_root_url() . 'admin/popuphelp.php?page=cat_perm', 'F_ACTION' => $admin_album_base_url . '-permissions', 'private' => 'private' == $category['status']));
// +-----------------------------------------------------------------------+
// |                          form construction                            |
// +-----------------------------------------------------------------------+
// groups denied are the groups not granted. So we need to find all groups
// minus groups granted to find groups denied.
$groups = array();
$query = '
SELECT id, name
  FROM ' . GROUPS_TABLE . '
  ORDER BY name ASC
;';
$groups = simple_hash_from_query($query, 'id', 'name');
$template->assign('groups', $groups);
// groups granted to access the category
$query = '
Exemple #16
0
if (isset($_POST['submit'])) {
    check_pwg_token();
    $offsetX = trim($_POST['offsetX']);
    $offsetY = trim($_POST['offsetY']);
    if (strlen($offsetX) === 0 || strlen($offsetY) === 0 || !is_numeric($offsetX) || !is_numeric($offsetY)) {
        $page['errors'][] = 'Invalid offset value';
    }
    if (count($page['errors']) === 0) {
        $stereoTable = $prefixeTable . 'stereo';
        if (isset($picture['x'])) {
            $query = "UPDATE {$stereoTable}\n\t\t\t\tSET x={$offsetX}, y={$offsetY}\n\t\t\t\tWHERE media_id = {$id};";
        } else {
            $picture['x'] = $offsetX;
            $picture['y'] = $offsetY;
            $query = "INSERT INTO {$stereoTable} (media_id, x, y)\n\t\t\t\tVALUES ({$id}, {$offsetX}, {$offsetY})";
        }
        pwg_query($query);
        array_push($page['infos'], l10n('STEREO_EDIT_SUCCESS'));
    }
}
// needed for the photo tabsheet
$admin_photo_base_url = get_root_url() . 'admin.php?page=photo-' . $id;
$self_url = Stereo_get_admin_url($id);
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
$tabsheet = new tabsheet();
$tabsheet->set_id('photo');
$tabsheet->select('stereo');
$tabsheet->assign();
$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'F_ACTION' => $self_url, 'TITLE' => render_element_name($picture), 'PICTURE' => Stereo_render_element_content('', $picture), 'OFFSET_X' => empty($picture['x']) ? 0 : $picture['x'], 'OFFSET_Y' => empty($picture['y']) ? 0 : $picture['y']));
$template->set_filename('plugin_admin_content', STEREO_PATH . 'admin.tpl');
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Exemple #17
0
                break;
            case 'representative':
                // theoretically, all categories in $_POST['cat_false'] contain at
                // least one element, so Piwigo can find a representant.
                set_random_representant($_POST['cat_false']);
                break;
        }
    }
}
// +-----------------------------------------------------------------------+
// |                             template init                             |
// +-----------------------------------------------------------------------+
$template->set_filenames(array('cat_options' => 'cat_options.tpl', 'double_select' => 'double_select.tpl'));
$page['section'] = isset($_GET['section']) ? $_GET['section'] : 'status';
$base_url = PHPWG_ROOT_PATH . 'admin.php?page=cat_options&amp;section=';
$template->assign(array('U_HELP' => get_root_url() . 'admin/popuphelp.php?page=cat_options', 'F_ACTION' => $base_url . $page['section']));
// TabSheet
$tabsheet = new tabsheet();
$tabsheet->set_id('cat_options');
$tabsheet->select($page['section']);
$tabsheet->assign();
// +-----------------------------------------------------------------------+
// |                              form display                             |
// +-----------------------------------------------------------------------+
// for each section, categories in the multiselect field can be :
//
// - true : commentable for comment section
// - false : un-commentable for comment section
// - NA : (not applicable) for virtual categories
//
// for true and false status, we associates an array of category ids,
    state,
    from_name,
    from_address,
    subject
  FROM ' . IMAGES_TABLE . '
    JOIN ' . PFEMAIL_PENDINGS_TABLE . ' ON id = image_id

  WHERE image_id IN (' . implode(',', $pending_ids) . ')
  ORDER BY image_id DESC
  LIMIT ' . $page['start'] . ', ' . $page['nb_pendings_per_page'] . '
;';
$result = pwg_query($query);
$rows = array();
$image_ids = array();
while ($row = pwg_db_fetch_assoc($result)) {
    array_push($rows, $row);
    array_push($image_ids, $row['id']);
}
$template->assign(array('F_ACTION' => $admin_base_url));
foreach ($rows as $row) {
    $thumb = DerivativeImage::thumb_url(array('id' => $row['image_id'], 'path' => $row['path']));
    $template->append('photos', array('U_EDIT' => get_root_url() . 'admin.php?page=plugin-showcase_admin-photo&amp;image_id=' . $row['image_id'], 'ID' => $row['image_id'], 'TN_SRC' => $thumb, 'WEBSIZE_SRC' => $row['path'], 'ADDED_BY' => $row['author'], 'ADDED_ON' => format_date($row['date_available'], true), 'NAME' => $row['name'], 'FILE' => $row['file'], 'DATE_CREATION' => empty($row['date_creation']) ? l10n('N/A') : format_date($row['date_creation']), 'DESCRIPTION' => $row['comment'], 'FROM' => @$row['from_name'] . ' &lt;' . $row['from_address'] . '&gt;'));
}
// +-----------------------------------------------------------------------+
// |                            navigation bar                             |
// +-----------------------------------------------------------------------+
$template->assign('navbar', create_navigation_bar(get_root_url() . 'admin.php' . get_query_string_diff(array('start', 'action', 'showcase_id')), count($pending_ids), $page['start'], $page['nb_pendings_per_page']));
// +-----------------------------------------------------------------------+
// | sending html code                                                     |
// +-----------------------------------------------------------------------+
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Exemple #19
0
<?php

if (!defined('PHPWG_ROOT_PATH')) {
    die('Hacking attempt!');
}
/*
*
*	Here we have everything if valid ldap users are allowed or not to connect to piwigo
*	Valid ldap users with no piwigo login can create their login this way.
*
*/
global $template;
$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/newusers.tpl'));
$template->assign(array('PLUGIN_NEWUSERS' => get_root_url() . 'admin.php?page=plugin-Ldap_Login-newusers'));
$me = new Ldap();
$me->load_config();
// do we allow new users to have a piwigo login created if they have a valid ldap login ?
$template->assign('ALLOW_NEWUSERS', $me->config['allow_newusers']);
// do we send a mail to admins in case of new users ?
$template->assign('ADVERTISE_ADMINS', $me->config['advertise_admin_new_ldapuser']);
// do we send the piwigo (!) password to the mail address provided by ldap ?
$template->assign('SEND_CASUAL_MAIL', $me->config['send_password_by_mail_ldap']);
// Is there a restriction in the ldap users group ?
// Only members of this ldap group can log in !
$template->assign('USERS_GROUP', $me->config['users_group']);
if (isset($_POST['save'])) {
    $me->config['users_group'] = $_POST['USERS_GROUP'];
    if (isset($_POST['ALLOW_NEWUSERS'])) {
        $me->config['allow_newusers'] = True;
    } else {
        $me->config['allow_newusers'] = False;
Exemple #20
0
include PHPWG_ROOT_PATH . 'include/template.class.php';
include PHPWG_ROOT_PATH . 'include/cache.class.php';
include PHPWG_ROOT_PATH . 'include/Logger.class.php';
$persistent_cache = new PersistentFileCache();
// Database connection
try {
    pwg_db_connect($conf['db_host'], $conf['db_user'], $conf['db_password'], $conf['db_base']);
} catch (Exception $e) {
    my_error(l10n($e->getMessage()), true);
}
pwg_db_check_charset();
load_conf_from_db();
$logger = new Logger(array('directory' => PHPWG_ROOT_PATH . $conf['data_location'] . $conf['log_dir'], 'severity' => $conf['log_level'], 'filename' => 'log_' . date('Y-m-d') . '_' . sha1(date('Y-m-d') . $conf['db_password']) . '.txt', 'globPattern' => 'log_*.txt', 'archiveDays' => $conf['log_archive_days']));
if (!$conf['check_upgrade_feed']) {
    if (!isset($conf['piwigo_db_version']) or $conf['piwigo_db_version'] != get_branch_from_version(PHPWG_VERSION)) {
        redirect(get_root_url() . 'upgrade.php');
    }
}
ImageStdParams::load_from_db();
session_start();
load_plugins();
// users can have defined a custom order pattern, incompatible with GUI form
if (isset($conf['order_by_custom'])) {
    $conf['order_by'] = $conf['order_by_custom'];
}
if (isset($conf['order_by_inside_category_custom'])) {
    $conf['order_by_inside_category'] = $conf['order_by_inside_category_custom'];
}
include PHPWG_ROOT_PATH . 'include/user.inc.php';
if (in_array(substr($user['language'], 0, 2), array('fr', 'it', 'de', 'es', 'pl', 'hu', 'ru', 'nl', 'tr', 'da'))) {
    define('PHPWG_DOMAIN', substr($user['language'], 0, 2) . '.piwigo.org');
Exemple #21
0
Author: Mistic
Author URI: http://www.strangeplanet.fr
*/
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
if (basename(dirname(__FILE__)) != 'flickr2piwigo') {
    add_event_handler('init', 'flickr_error');
    function flickr_error()
    {
        global $page;
        $page['errors'][] = 'Flickr2Piwigo folder name is incorrect, uninstall the plugin and rename it to "flickr2piwigo"';
    }
    return;
}
global $conf;
define('FLICKR_PATH', PHPWG_PLUGINS_PATH . 'flickr2piwigo/');
define('FLICKR_ADMIN', get_root_url() . 'admin.php?page=plugin-flickr2piwigo');
define('FLICKR_FS_CACHE', PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/');
include_once FLICKR_PATH . 'include/ws_functions.inc.php';
$conf['flickr2piwigo'] = safe_unserialize($conf['flickr2piwigo']);
add_event_handler('ws_add_methods', 'flickr_add_ws_method');
if (defined('IN_ADMIN')) {
    add_event_handler('get_admin_plugin_menu_links', 'flickr_admin_menu');
    add_event_handler('get_batch_manager_prefilters', 'flickr_add_batch_manager_prefilters');
    add_event_handler('perform_batch_manager_prefilters', 'flickr_perform_batch_manager_prefilters', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    function flickr_admin_menu($menu)
    {
        $menu[] = array('NAME' => 'Flickr2Piwigo', 'URL' => FLICKR_ADMIN);
        return $menu;
    }
    function flickr_add_batch_manager_prefilters($prefilters)
    {
Exemple #22
0
// +-----------------------------------------------------------------------+
$template->set_filenames(array('element_set_ranks' => 'element_set_ranks.tpl'));
$base_url = get_root_url() . 'admin.php';
$query = '
SELECT *
  FROM ' . CATEGORIES_TABLE . '
  WHERE id = ' . $page['category_id'] . '
;';
$category = pwg_db_fetch_assoc(pwg_query($query));
if ($category['image_order'] == 'rank ASC') {
    $image_order_choice = 'rank';
} elseif ($category['image_order'] != '') {
    $image_order_choice = 'user_define';
}
// Navigation path
$navigation = get_cat_display_name_cache($category['uppercats'], get_root_url() . 'admin.php?page=album-');
$template->assign(array('CATEGORIES_NAV' => $navigation, 'F_ACTION' => $base_url . get_query_string_diff(array())));
// +-----------------------------------------------------------------------+
// |                              thumbnails                               |
// +-----------------------------------------------------------------------+
$query = '
SELECT
    id,
    file,
    path,
    representative_ext,
    width, height, rotation,
    name,
    rank
  FROM ' . IMAGES_TABLE . '
    JOIN ' . IMAGE_CATEGORY_TABLE . ' ON image_id = id
  ORDER BY date DESC
  LIMIT ' . $conf['guestbook']['nb_comment_page'] . ' OFFSET ' . $page['start'] . '
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        if (!empty($row['author'])) {
            $author = $row['author'];
            if ($author == 'guest') {
                $author = l10n('guest');
            }
        } else {
            $author = stripslashes($row['username']);
        }
        $tpl_comment = array('ID' => $row['id'], 'AUTHOR' => trigger_change('render_comment_author', $author), 'DATE' => format_date($row['date'], true), 'CONTENT' => trigger_change('render_comment_content', $row['content'], 'guestbook'), 'WEBSITE' => $row['website']);
        if ($conf['guestbook']['activate_rating']) {
            $tpl_comment['STARS'] = get_stars($row['rate'], get_root_url() . GUESTBOOK_PATH . 'template/jquery.raty/');
        }
        if (is_admin() and !empty($row['email'])) {
            $tpl_comment['EMAIL'] = $row['email'];
        }
        if (can_manage_comment('delete', $row['author_id'])) {
            $tpl_comment['U_DELETE'] = add_url_params($url_self, array('action' => 'delete_comment', 'comment_to_delete' => $row['id'], 'pwg_token' => get_pwg_token()));
        }
        if (can_manage_comment('edit', $row['author_id'])) {
            $tpl_comment['U_EDIT'] = add_url_params($url_self, array('action' => 'edit_comment', 'comment_to_edit' => $row['id']));
            if (isset($edit_comment) and $row['id'] == $edit_comment) {
                $tpl_comment['IN_EDIT'] = true;
                $tpl_comment['KEY'] = get_ephemeral_key(2);
                $tpl_comment['CONTENT'] = $row['content'];
                $tpl_comment['PWG_TOKEN'] = get_pwg_token();
                $tpl_comment['U_CANCEL'] = $url_self;
<?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']);
}
Exemple #25
0
// | the Free Software Foundation                                          |
// |                                                                       |
// | This program is distributed in the hope that it will be useful, but   |
// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
// | General Public License for more details.                              |
// |                                                                       |
// | 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.                                                                  |
// +-----------------------------------------------------------------------+
if (!defined("PHPWG_ROOT_PATH")) {
    die("Hacking attempt!");
}
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
$my_base_url = get_root_url() . 'admin.php?page=plugins';
if (isset($_GET['tab'])) {
    $page['tab'] = $_GET['tab'];
} else {
    $page['tab'] = 'installed';
}
$tabsheet = new tabsheet();
$tabsheet->set_id('plugins');
$tabsheet->select($page['tab']);
$tabsheet->assign();
if ($page['tab'] == 'update') {
    include PHPWG_ROOT_PATH . 'admin/updates_ext.php';
} else {
    include PHPWG_ROOT_PATH . 'admin/plugins_' . $page['tab'] . '.php';
}
Exemple #26
0
    $template->assign('U_COI', get_root_url() . 'admin.php?page=picture_coi&amp;image_id=' . $_GET['image_id']);
}
// image level options
$selected_level = isset($_POST['level']) ? $_POST['level'] : $row['level'];
$template->assign(array('level_options' => get_privacy_level_options(), 'level_options_selected' => array($selected_level)));
// categories
$query = '
SELECT category_id, uppercats
  FROM ' . IMAGE_CATEGORY_TABLE . ' AS ic
    INNER JOIN ' . CATEGORIES_TABLE . ' AS c
      ON c.id = ic.category_id
  WHERE image_id = ' . $_GET['image_id'] . '
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result)) {
    $name = get_cat_display_name_cache($row['uppercats'], get_root_url() . 'admin.php?page=album-');
    if ($row['category_id'] == $storage_category_id) {
        $template->assign('STORAGE_CATEGORY', $name);
    } else {
        $template->append('related_categories', $name);
    }
}
// jump to link
//
// 1. find all linked categories that are reachable for the current user.
// 2. if a category is available in the URL, use it if reachable
// 3. if URL category not available or reachable, use the first reachable
//    linked category
// 4. if no category reachable, no jumpto link
$query = '
SELECT category_id
        $page['infos'][] = l10n('Templates configuration has been recorded.');
    }
}
// +-----------------------------------------------------------------------+
// |                             template init                             |
// +-----------------------------------------------------------------------+
/* Clearing (remove old extents, add new ones) */
foreach ($tpl_extension as $file => $conditions) {
    if (!in_array($file, $new_extensions)) {
        unset($tpl_extension[$file]);
    } else {
        $new_extensions = array_diff($new_extensions, array($file));
    }
}
foreach ($new_extensions as $file) {
    $tpl_extension[$file] = array('N/A', 'N/A', 'N/A');
}
$template->set_filenames(array('extend_for_templates' => 'extend_for_templates.tpl'));
$base_url = PHPWG_ROOT_PATH . 'admin.php?page=extend_for_templates';
$template->assign(array('U_HELP' => get_root_url() . 'admin/popuphelp.php?page=extend_for_templates'));
ksort($tpl_extension);
foreach ($tpl_extension as $file => $conditions) {
    $handle = $conditions[0];
    $url_keyword = $conditions[1];
    $bound_tpl = $conditions[2];
    $template->append('extents', array('replacer' => $file, 'url_parameter' => $relevant_parameters, 'original_tpl' => array_keys($eligible_templates), 'bound_tpl' => $available_templates, 'selected_tpl' => $flip_templates[$handle], 'selected_url' => $url_keyword, 'selected_bound' => $bound_tpl));
}
// +-----------------------------------------------------------------------+
// |                           html code display                           |
// +-----------------------------------------------------------------------+
$template->assign_var_from_handle('ADMIN_CONTENT', 'extend_for_templates');
// |                                                                       |
// | This program is distributed in the hope that it will be useful, but   |
// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
// | General Public License for more details.                              |
// |                                                                       |
// | 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.                                                                  |
// +-----------------------------------------------------------------------+
if (!defined("PHPWG_ROOT_PATH")) {
    die("Hacking attempt!");
}
include_once PHPWG_ROOT_PATH . 'admin/include/themes.class.php';
$base_url = get_root_url() . 'admin.php?page=' . $page['page'];
$themes = new themes();
// +-----------------------------------------------------------------------+
// |                          perform actions                              |
// +-----------------------------------------------------------------------+
if (isset($_GET['action']) and isset($_GET['theme'])) {
    $page['errors'] = $themes->perform_action($_GET['action'], $_GET['theme']);
    if (empty($page['errors'])) {
        if ($_GET['action'] == 'activate' or $_GET['action'] == 'deactivate') {
            $template->delete_compiled_templates();
        }
        redirect($base_url);
    }
}
// +-----------------------------------------------------------------------+
// |                     start template output                             |
Exemple #29
0
            }
        }
    }
    $nb_sub_photos = array();
    foreach ($subcats_of as $cat_id => $subcat_ids) {
        $nb_photos = 0;
        foreach ($subcat_ids as $id) {
            if (isset($nb_photos_in[$id])) {
                $nb_photos += $nb_photos_in[$id];
            }
        }
        $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 .= '&amp;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 . '&amp;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 . '&amp;delete=' . $category['id'];
        $tpl_cat['U_DELETE'] .= '&amp;pwg_token=' . get_pwg_token();
    } else {
        if ($conf['enable_synchronization']) {
Exemple #30
0
 /**
  * @return string
  */
 function get_url()
 {
     if ($this->params == null) {
         return $this->src_image->get_url();
     }
     return embellish_url(trigger_change('get_derivative_url', get_root_url() . $this->rel_url, $this->params, $this->src_image, $this->rel_url));
 }