コード例 #1
0
 function __construct($source_filepath, $library = null)
 {
     $this->source_filepath = $source_filepath;
     trigger_notify('load_image_library', array(&$this));
     if (is_object($this->image)) {
         return;
         // A plugin may have load its own library
     }
     $extension = strtolower(get_extension($source_filepath));
     if (!in_array($extension, array('jpg', 'jpeg', 'png', 'gif'))) {
         die('[Image] unsupported file extension');
     }
     if (!($this->library = self::get_library($library, $extension))) {
         die('No image library available on your server.');
     }
     $class = 'image_' . $this->library;
     $this->image = new $class($source_filepath);
 }
コード例 #2
0
ファイル: help.php プロジェクト: donseba/Piwigo
// | 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.                                                                  |
// +-----------------------------------------------------------------------+
include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok                      |
// +-----------------------------------------------------------------------+
check_status(ACCESS_ADMINISTRATOR);
$help_link = get_root_url() . 'admin.php?page=help&section=';
$selected = null;
if (!isset($_GET['section'])) {
    $selected = 'add_photos';
} else {
    $selected = $_GET['section'];
}
$tabsheet = new tabsheet();
$tabsheet->set_id('help');
$tabsheet->select($selected);
$tabsheet->assign();
trigger_notify('loc_end_help');
$template->set_filenames(array('help' => 'help.tpl'));
$template->assign(array('HELP_CONTENT' => load_language('help/help_' . $tabsheet->selected . '.html', '', array('return' => true)), 'HELP_SECTION_TITLE' => $tabsheet->sheets[$tabsheet->selected]['caption']));
// +-----------------------------------------------------------------------+
// |                           sending html code                           |
// +-----------------------------------------------------------------------+
$template->assign_var_from_handle('ADMIN_CONTENT', 'help');
コード例 #3
0
ファイル: user.inc.php プロジェクト: donseba/Piwigo
    }
}
// Now check the auto-login
if ($user['id'] == $conf['guest_id']) {
    auto_login();
}
// using Apache authentication override the above user search
if ($conf['apache_authentication']) {
    $remote_user = null;
    foreach (array('REMOTE_USER', 'REDIRECT_REMOTE_USER') as $server_key) {
        if (isset($_SERVER[$server_key])) {
            $remote_user = $_SERVER[$server_key];
            break;
        }
    }
    if (isset($remote_user)) {
        if (!($user['id'] = get_userid($remote_user))) {
            $user['id'] = register_user($remote_user, '', '', false);
        }
    }
}
// automatic login by authentication key
if (isset($_GET['auth'])) {
    auth_key_login($_GET['auth']);
}
$user = build_user($user['id'], (defined('IN_ADMIN') and IN_ADMIN) ? false : true);
if ($conf['browser_language'] and (is_a_guest() or is_generic()) and $language = get_browser_language()) {
    $user['language'] = $language;
}
trigger_notify('user_init', $user);
コード例 #4
0
ファイル: register.php プロジェクト: lcorbasson/Piwigo
            $_SESSION['page_infos'][] = l10n('Successfully registered, you will soon receive an email with your connection settings. Welcome!');
        }
        // log user and redirect
        $user_id = get_userid($_POST['login']);
        log_user($user_id, false);
        redirect(make_index_url());
    }
    $registration_post_key = get_ephemeral_key(2);
} else {
    $registration_post_key = get_ephemeral_key(6);
}
$login = !empty($_POST['login']) ? htmlspecialchars(stripslashes($_POST['login'])) : '';
$email = !empty($_POST['mail_address']) ? htmlspecialchars(stripslashes($_POST['mail_address'])) : '';
//----------------------------------------------------- template initialization
//
// Start output of page
//
$title = l10n('Registration');
$page['body_id'] = 'theRegisterPage';
$template->set_filenames(array('register' => 'register.tpl'));
$template->assign(array('U_HOME' => make_index_url(), 'F_KEY' => $registration_post_key, 'F_ACTION' => 'register.php', 'F_LOGIN' => $login, 'F_EMAIL' => $email, 'obligatory_user_mail_address' => $conf['obligatory_user_mail_address']));
// include menubar
$themeconf = $template->get_template_vars('themeconf');
if (!isset($themeconf['hide_menu_on']) or !in_array('theRegisterPage', $themeconf['hide_menu_on'])) {
    include PHPWG_ROOT_PATH . 'include/menubar.inc.php';
}
include PHPWG_ROOT_PATH . 'include/page_header.php';
trigger_notify('loc_end_register');
flush_page_messages();
$template->parse('register');
include PHPWG_ROOT_PATH . 'include/page_tail.php';
コード例 #5
0
 /**
  * Check integrities
  *
  * @param void
  * @return void
  */
 function check()
 {
     global $page, $header_notes, $conf;
     // Ignore list
     $conf_c13y_ignore = unserialize($conf['c13y_ignore']);
     if (is_array($conf_c13y_ignore) and isset($conf_c13y_ignore['version']) and $conf_c13y_ignore['version'] == PHPWG_VERSION and is_array($conf_c13y_ignore['list'])) {
         $ignore_list_changed = false;
         $this->ignore_list = $conf_c13y_ignore['list'];
     } else {
         $ignore_list_changed = true;
         $this->ignore_list = array();
     }
     // Retrieve list
     $this->retrieve_list = array();
     $this->build_ignore_list = array();
     trigger_notify('list_check_integrity', $this);
     // Information
     if (count($this->retrieve_list) > 0) {
         $header_notes[] = l10n_dec('%d anomaly has been detected.', '%d anomalies have been detected.', count($this->retrieve_list));
     }
     // Treatments
     if (isset($_POST['c13y_submit_correction']) and isset($_POST['c13y_selection'])) {
         $corrected_count = 0;
         $not_corrected_count = 0;
         foreach ($this->retrieve_list as $i => $c13y) {
             if (!empty($c13y['correction_fct']) and $c13y['is_callable'] and in_array($c13y['id'], $_POST['c13y_selection'])) {
                 if (is_array($c13y['correction_fct_args'])) {
                     $args = $c13y['correction_fct_args'];
                 } else {
                     if (!is_null($c13y['correction_fct_args'])) {
                         $args = array($c13y['correction_fct_args']);
                     } else {
                         $args = array();
                     }
                 }
                 $this->retrieve_list[$i]['corrected'] = call_user_func_array($c13y['correction_fct'], $args);
                 if ($this->retrieve_list[$i]['corrected']) {
                     $corrected_count += 1;
                 } else {
                     $not_corrected_count += 1;
                 }
             }
         }
         if ($corrected_count > 0) {
             $page['infos'][] = l10n_dec('%d anomaly has been corrected.', '%d anomalies have been detected corrected.', $corrected_count);
         }
         if ($not_corrected_count > 0) {
             $page['errors'][] = l10n_dec('%d anomaly has not been corrected.', '%d anomalies have not been corrected.', $not_corrected_count);
         }
     } else {
         if (isset($_POST['c13y_submit_ignore']) and isset($_POST['c13y_selection'])) {
             $ignored_count = 0;
             foreach ($this->retrieve_list as $i => $c13y) {
                 if (in_array($c13y['id'], $_POST['c13y_selection'])) {
                     $this->build_ignore_list[] = $c13y['id'];
                     $this->retrieve_list[$i]['ignored'] = true;
                     $ignored_count += 1;
                 }
             }
             if ($ignored_count > 0) {
                 $page['infos'][] = l10n_dec('%d anomaly has been ignored.', '%d anomalies have been ignored.', $ignored_count);
             }
         }
     }
     $ignore_list_changed = ($ignore_list_changed or count(array_diff($this->ignore_list, $this->build_ignore_list)) > 0 or count(array_diff($this->build_ignore_list, $this->ignore_list)) > 0);
     if ($ignore_list_changed) {
         $this->update_conf($this->build_ignore_list);
     }
 }
コード例 #6
0
/**
 * @see get_quick_search_results but without result caching
 */
function get_quick_search_results_no_cache($q, $options)
{
    global $conf;
    $q = trim(stripslashes($q));
    $search_results = array('items' => array(), 'qs' => array('q' => $q));
    $q = trigger_change('qsearch_pre', $q);
    $scopes = array();
    $scopes[] = new QSearchScope('tag', array('tags'));
    $scopes[] = new QSearchScope('photo', array('photos'));
    $scopes[] = new QSearchScope('file', array('filename'));
    $scopes[] = new QSearchScope('author', array(), true);
    $scopes[] = new QNumericRangeScope('width', array());
    $scopes[] = new QNumericRangeScope('height', array());
    $scopes[] = new QNumericRangeScope('ratio', array(), false, 0.001);
    $scopes[] = new QNumericRangeScope('size', array());
    $scopes[] = new QNumericRangeScope('filesize', array());
    $scopes[] = new QNumericRangeScope('hits', array('hit', 'visit', 'visits'));
    $scopes[] = new QNumericRangeScope('score', array('rating'), true);
    $scopes[] = new QNumericRangeScope('id', array());
    $createdDateAliases = array('taken', 'shot');
    $postedDateAliases = array('added');
    if ($conf['calendar_datefield'] == 'date_creation') {
        $createdDateAliases[] = 'date';
    } else {
        $postedDateAliases[] = 'date';
    }
    $scopes[] = new QDateRangeScope('created', $createdDateAliases, true);
    $scopes[] = new QDateRangeScope('posted', $postedDateAliases);
    // allow plugins to add their own scopes
    $scopes = trigger_change('qsearch_get_scopes', $scopes);
    $expression = new QExpression($q, $scopes);
    // get inflections for terms
    $inflector = null;
    $lang_code = substr(get_default_language(), 0, 2);
    @(include_once PHPWG_ROOT_PATH . 'include/inflectors/' . $lang_code . '.php');
    $class_name = 'Inflector_' . $lang_code;
    if (class_exists($class_name)) {
        $inflector = new $class_name();
        foreach ($expression->stokens as $token) {
            if (isset($token->scope) && !$token->scope->is_text) {
                continue;
            }
            if (strlen($token->term) > 2 && ($token->modifier & (QST_QUOTED | QST_WILDCARD)) == 0 && strcspn($token->term, '\'0123456789') == strlen($token->term)) {
                $token->variants = array_unique(array_diff($inflector->get_variants($token->term), array($token->term)));
            }
        }
    }
    trigger_notify('qsearch_expression_parsed', $expression);
    //var_export($expression);
    if (count($expression->stokens) == 0) {
        return $search_results;
    }
    $qsr = new QResults();
    qsearch_get_tags($expression, $qsr);
    qsearch_get_images($expression, $qsr);
    // allow plugins to evaluate their own scopes
    trigger_notify('qsearch_before_eval', $expression, $qsr);
    $ids = qsearch_eval($expression, $qsr, $tmp, $search_results['qs']['unmatched_terms']);
    $debug[] = "<!--\nparsed: " . $expression;
    $debug[] = count($expression->stokens) . ' tokens';
    for ($i = 0; $i < count($expression->stokens); $i++) {
        $debug[] = $expression->stokens[$i] . ': ' . count($qsr->tag_ids[$i]) . ' tags, ' . count($qsr->tag_iids[$i]) . ' tiids, ' . count($qsr->images_iids[$i]) . ' iiids, ' . count($qsr->iids[$i]) . ' iids' . ' modifier:' . dechex($expression->stoken_modifiers[$i]) . (!empty($expression->stokens[$i]->variants) ? ' variants: ' . implode(', ', $expression->stokens[$i]->variants) : '');
    }
    $debug[] = 'before perms ' . count($ids);
    $search_results['qs']['matching_tags'] = $qsr->all_tags;
    $search_results = trigger_change('qsearch_results', $search_results, $expression, $qsr);
    global $template;
    if (empty($ids)) {
        $debug[] = '-->';
        $template->append('footer_elements', implode("\n", $debug));
        return $search_results;
    }
    $permissions = !isset($options['permissions']) ? true : $options['permissions'];
    $where_clauses = array();
    $where_clauses[] = 'i.id IN (' . implode(',', $ids) . ')';
    if (!empty($options['images_where'])) {
        $where_clauses[] = '(' . $options['images_where'] . ')';
    }
    if ($permissions) {
        $where_clauses[] = get_sql_condition_FandF(array('forbidden_categories' => 'category_id', 'forbidden_images' => 'i.id'), null, true);
    }
    $query = '
SELECT DISTINCT(id) FROM ' . IMAGES_TABLE . ' i';
    if ($permissions) {
        $query .= '
    INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON id = ic.image_id';
    }
    $query .= '
  WHERE ' . implode("\n AND ", $where_clauses) . "\n" . $conf['order_by'];
    $ids = query2array($query, null, 'id');
    $debug[] = count($ids) . ' final photo count -->';
    $template->append('footer_elements', implode("\n", $debug));
    $search_results['items'] = $ids;
    return $search_results;
}
コード例 #7
0
        }
    }
    if (isset($search['fields']['ip'])) {
        $clauses[] = 'IP LIKE "' . $search['fields']['ip'] . '"';
    }
    $clauses = prepend_append_array_items($clauses, '(', ')');
    $where_separator = implode("\n    AND ", $clauses);
    $query = '
SELECT
    date,
    time,
    user_id,
    IP,
    section,
    category_id,
    tag_ids,
    image_id,
    image_type
  FROM ' . HISTORY_TABLE . '
  WHERE ' . $where_separator . '
;';
    // LIMIT '.$conf['nb_logs_page'].' OFFSET '.$page['start'].'
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $data[] = $row;
    }
    return $data;
}
add_event_handler('get_history', 'get_history');
trigger_notify('functions_history_included');
コード例 #8
0
ファイル: picture_modify.php プロジェクト: donseba/Piwigo
//    linked category
// 4. if no category reachable, no jumpto link
$query = '
SELECT category_id
  FROM ' . IMAGE_CATEGORY_TABLE . '
  WHERE image_id = ' . $_GET['image_id'] . '
;';
$authorizeds = array_diff(array_from_query($query, 'category_id'), explode(',', calculate_permissions($user['id'], $user['status'])));
if (isset($_GET['cat_id']) and in_array($_GET['cat_id'], $authorizeds)) {
    $url_img = make_picture_url(array('image_id' => $_GET['image_id'], 'image_file' => $image_file, 'category' => $cache['cat_names'][$_GET['cat_id']]));
} else {
    foreach ($authorizeds as $category) {
        $url_img = make_picture_url(array('image_id' => $_GET['image_id'], 'image_file' => $image_file, 'category' => $cache['cat_names'][$category]));
        break;
    }
}
if (isset($url_img)) {
    $template->assign('U_JUMPTO', $url_img);
}
// associate to albums
$query = '
SELECT id
  FROM ' . CATEGORIES_TABLE . '
    INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' ON id = category_id
  WHERE image_id = ' . $_GET['image_id'] . '
;';
$associated_albums = query2array($query, null, 'id');
$template->assign(array('associated_albums' => $associated_albums, 'represented_albums' => $represented_albums, 'STORAGE_ALBUM' => $storage_category_id, 'CACHE_KEYS' => get_admin_client_cache_keys(array('tags', 'categories'))));
trigger_notify('loc_end_picture_modify');
//----------------------------------------------------------- sending html code
$template->assign_var_from_handle('ADMIN_CONTENT', 'picture_modify');
コード例 #9
0
    unset($info);
}
if (count($user_representative_updates_for)) {
    $updates = array();
    foreach ($user_representative_updates_for as $cat_id => $image_id) {
        $updates[] = array('user_id' => $user['id'], 'cat_id' => $cat_id, 'user_representative_picture_id' => $image_id);
    }
    mass_updates(USER_CACHE_CATEGORIES_TABLE, array('primary' => array('user_id', 'cat_id'), 'update' => array('user_representative_picture_id')), $updates);
}
if (count($categories) > 0) {
    // Update filtered data
    if (function_exists('update_cats_with_filtered_data')) {
        update_cats_with_filtered_data($categories);
    }
    $template->set_filename('index_category_thumbnails', 'mainpage_categories.tpl');
    trigger_notify('loc_begin_index_category_thumbnails', $categories);
    $tpl_thumbnails_var = array();
    foreach ($categories as $category) {
        if (0 == $category['count_images']) {
            continue;
        }
        $category['name'] = trigger_change('render_category_name', $category['name'], 'subcatify_category_name');
        if ($page['section'] == 'recent_cats') {
            $name = get_cat_display_name_cache($category['uppercats'], null);
        } else {
            $name = $category['name'];
        }
        $representative_infos = $infos_of_image[$category['representative_picture_id']];
        $tpl_var = array_merge($category, array('ID' => $category['id'], 'representative' => $representative_infos, 'TN_ALT' => strip_tags($category['name']), 'URL' => make_index_url(array('category' => $category)), 'CAPTION_NB_IMAGES' => get_display_images_count($category['nb_images'], $category['count_images'], $category['count_categories'], true, '<br>'), 'DESCRIPTION' => trigger_change('render_category_literal_description', trigger_change('render_category_description', @$category['comment'], 'subcatify_category_description')), 'NAME' => $name));
        if ($conf['index_new_icon']) {
            $tpl_var['icon_ts'] = get_icon($category['max_date_last'], $category['is_child_date_last']);
コード例 #10
0
/**
 * Sets the http status header (200,401,...)
 * @param int $code
 * @param string $text for exotic http codes
 */
function set_status_header($code, $text = '')
{
    if (empty($text)) {
        switch ($code) {
            case 200:
                $text = 'OK';
                break;
            case 301:
                $text = 'Moved permanently';
                break;
            case 302:
                $text = 'Moved temporarily';
                break;
            case 304:
                $text = 'Not modified';
                break;
            case 400:
                $text = 'Bad request';
                break;
            case 401:
                $text = 'Authorization required';
                break;
            case 403:
                $text = 'Forbidden';
                break;
            case 404:
                $text = 'Not found';
                break;
            case 500:
                $text = 'Server error';
                break;
            case 501:
                $text = 'Not implemented';
                break;
            case 503:
                $text = 'Service unavailable';
                break;
        }
    }
    $protocol = $_SERVER["SERVER_PROTOCOL"];
    if ('HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol) {
        $protocol = 'HTTP/1.0';
    }
    header("{$protocol} {$code} {$text}", true, $code);
    trigger_notify('set_status_header', $code, $text);
}
コード例 #11
0
ファイル: password.php プロジェクト: squidjam/Piwigo
    redirect(get_gallery_home_url());
}
if ('lost' == $page['action'] and !is_a_guest()) {
    redirect(get_gallery_home_url());
}
// +-----------------------------------------------------------------------+
// | template initialization                                               |
// +-----------------------------------------------------------------------+
$title = l10n('Password Reset');
if ('lost' == $page['action']) {
    $title = l10n('Forgot your password?');
    if (isset($_POST['username_or_email'])) {
        $template->assign('username_or_email', htmlspecialchars(stripslashes($_POST['username_or_email'])));
    }
}
$page['body_id'] = 'thePasswordPage';
$template->set_filenames(array('password' => 'password.tpl'));
$template->assign(array('title' => $title, 'form_action' => get_root_url() . 'password.php', 'action' => $page['action'], 'username' => isset($page['username']) ? $page['username'] : $user['username'], 'PWG_TOKEN' => get_pwg_token()));
// include menubar
$themeconf = $template->get_template_vars('themeconf');
if (!isset($themeconf['hide_menu_on']) or !in_array('thePasswordPage', $themeconf['hide_menu_on'])) {
    include PHPWG_ROOT_PATH . 'include/menubar.inc.php';
}
// +-----------------------------------------------------------------------+
// |                           html code display                           |
// +-----------------------------------------------------------------------+
include PHPWG_ROOT_PATH . 'include/page_header.php';
trigger_notify('loc_end_password');
flush_page_messages();
$template->pparse('password');
include PHPWG_ROOT_PATH . 'include/page_tail.php';
コード例 #12
0
ファイル: picture.php プロジェクト: lcorbasson/Piwigo
$template->assign('U_CANONICAL', make_picture_url(array('image_id' => $picture['current']['id'], 'image_file' => $picture['current']['file'])));
// +-----------------------------------------------------------------------+
// |                               sub pages                               |
// +-----------------------------------------------------------------------+
include PHPWG_ROOT_PATH . 'include/picture_rate.inc.php';
if ($conf['activate_comments']) {
    include PHPWG_ROOT_PATH . 'include/picture_comment.inc.php';
}
if ($metadata_showable and pwg_get_session_var('show_metadata') != null) {
    include PHPWG_ROOT_PATH . 'include/picture_metadata.inc.php';
}
// include menubar
$themeconf = $template->get_template_vars('themeconf');
if ($conf['picture_menu'] and (!isset($themeconf['hide_menu_on']) or !in_array('thePicturePage', $themeconf['hide_menu_on']))) {
    if (!isset($page['start'])) {
        $page['start'] = 0;
    }
    include PHPWG_ROOT_PATH . 'include/menubar.inc.php';
}
include PHPWG_ROOT_PATH . 'include/page_header.php';
trigger_notify('loc_end_picture');
flush_page_messages();
if ($page['slideshow'] and $conf['light_slideshow']) {
    $template->pparse('slideshow');
} else {
    $template->parse_picture_buttons();
    $template->pparse('picture');
}
//------------------------------------------------------------ log informations
pwg_log($picture['current']['id'], 'picture');
include PHPWG_ROOT_PATH . 'include/page_tail.php';
コード例 #13
0
ファイル: template.class.php プロジェクト: squidjam/Piwigo
 /**
  * Process one combinable file.
  *
  * @param Combinable $combinable
  * @param bool $return_content
  * @param bool $force
  * @param string $header CSS directives that must appear first in
  *                       the minified file (only used when
  *                       $return_content===true)
  * @return null|string
  */
 private function process_combinable($combinable, $return_content, $force, &$header)
 {
     global $conf;
     if ($combinable->is_template) {
         if (!$return_content) {
             $key = array($combinable->path, $combinable->version);
             if ($conf['template_compile_check']) {
                 $key[] = filemtime(PHPWG_ROOT_PATH . $combinable->path);
             }
             $file = PWG_COMBINED_DIR . 't' . base_convert(crc32(implode(',', $key)), 10, 36) . '.' . $this->type;
             if (!$force && file_exists(PHPWG_ROOT_PATH . $file)) {
                 $combinable->path = $file;
                 $combinable->version = false;
                 return;
             }
         }
         global $template;
         $handle = $this->type . '.' . $combinable->id;
         $template->set_filename($handle, realpath(PHPWG_ROOT_PATH . $combinable->path));
         trigger_notify('combinable_preparse', $template, $combinable, $this);
         //allow themes and plugins to set their own vars to template ...
         $content = $template->parse($handle, true);
         if ($this->is_css) {
             $content = self::process_css($content, $combinable->path, $header);
         } else {
             $content = self::process_js($content, $combinable->path);
         }
         if ($return_content) {
             return $content;
         }
         file_put_contents(PHPWG_ROOT_PATH . $file, $content);
         $combinable->path = $file;
     } elseif ($return_content) {
         $content = file_get_contents(PHPWG_ROOT_PATH . $combinable->path);
         if ($this->is_css) {
             $content = self::process_css($content, $combinable->path, $header);
         } else {
             $content = self::process_js($content, $combinable->path);
         }
         return $content;
     }
 }
コード例 #14
0
ファイル: section_init.inc.php プロジェクト: squidjam/Piwigo
} elseif ('search' == $page['section']) {
    $page['meta_robots']['nofollow'] = 1;
}
if ($filter['enabled']) {
    $page['meta_robots']['noindex'] = 1;
}
// see if we need a redirect because of a permalink
if ('categories' == $page['section'] and isset($page['category'])) {
    $need_redirect = false;
    if (empty($page['category']['permalink'])) {
        if ($conf['category_url_style'] == 'id-name' and @$page['hit_by']['cat_url_name'] !== str2url($page['category']['name'])) {
            $need_redirect = true;
        }
    } else {
        if ($page['category']['permalink'] !== @$page['hit_by']['cat_permalink']) {
            $need_redirect = true;
        }
    }
    if ($need_redirect) {
        $redirect_url = script_basename() == 'picture' ? duplicate_picture_url() : duplicate_index_url();
        if (!headers_sent()) {
            // this is a permanent redirection
            set_status_header(301);
            redirect_http($redirect_url);
        }
        redirect($redirect_url);
    }
    unset($need_redirect, $page['hit_by']);
}
trigger_notify('loc_end_section_init');
コード例 #15
0
ファイル: tags.php プロジェクト: lcorbasson/Piwigo
        unset($letter['CHANGE_COLUMN']);
        $letter['TITLE'] = $current_letter;
        $template->append('letters', $letter);
    }
} else {
    // +-----------------------------------------------------------------------+
    // |                        tag cloud construction                         |
    // +-----------------------------------------------------------------------+
    // we want only the first most represented tags, so we sort them by counter
    // and take the first tags
    usort($tags, 'counter_compare');
    $tags = array_slice($tags, 0, $conf['full_tag_cloud_items_number']);
    // depending on its counter and the other tags counter, each tag has a level
    $tags = add_level_to_tags($tags);
    // we want tags diplayed in alphabetic order
    usort($tags, 'tag_alpha_compare');
    // display sorted tags
    foreach ($tags as $tag) {
        $template->append('tags', array_merge($tag, array('URL' => make_index_url(array('tags' => array($tag))))));
    }
}
// include menubar
$themeconf = $template->get_template_vars('themeconf');
if (!isset($themeconf['hide_menu_on']) or !in_array('theTagsPage', $themeconf['hide_menu_on'])) {
    include PHPWG_ROOT_PATH . 'include/menubar.inc.php';
}
include PHPWG_ROOT_PATH . 'include/page_header.php';
trigger_notify('loc_end_tags');
flush_page_messages();
$template->pparse('tags');
include PHPWG_ROOT_PATH . 'include/page_tail.php';
コード例 #16
0
ファイル: page_tail.php プロジェクト: donseba/Piwigo
$template->set_filenames(array('tail' => 'footer.tpl'));
trigger_notify('loc_begin_page_tail');
$template->assign(array('VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 'PHPWG_URL' => defined('PHPWG_URL') ? PHPWG_URL : ''));
//--------------------------------------------------------------------- contact
if (!is_a_guest()) {
    $template->assign('CONTACT_MAIL', get_webmaster_mail_address());
}
//------------------------------------------------------------- generation time
$debug_vars = array();
if ($conf['show_queries']) {
    $debug_vars = array_merge($debug_vars, array('QUERIES_LIST' => $debug));
}
if ($conf['show_gt']) {
    if (!isset($page['count_queries'])) {
        $page['count_queries'] = 0;
        $page['queries_time'] = 0;
    }
    $time = get_elapsed_time($t2, get_moment());
    $debug_vars = array_merge($debug_vars, array('TIME' => $time, 'NB_QUERIES' => $page['count_queries'], 'SQL_TIME' => number_format($page['queries_time'], 3, '.', ' ') . ' s'));
}
$template->assign('debug', $debug_vars);
//------------------------------------------------------------- mobile version
if (!empty($conf['mobile_theme']) && (get_device() != 'desktop' || mobile_theme())) {
    $template->assign('TOGGLE_MOBILE_THEME_URL', add_url_params(htmlspecialchars($_SERVER['REQUEST_URI']), array('mobile' => mobile_theme() ? 'false' : 'true')));
}
trigger_notify('loc_end_page_tail');
//
// Generate the page
//
$template->parse('tail');
$template->p();
コード例 #17
0
}
// representant management
if ($category['has_images'] or !empty($category['representative_picture_id'])) {
    $tpl_representant = array();
    // picture to display : the identified representant or the generic random
    // representant ?
    if (!empty($category['representative_picture_id'])) {
        $query = '
SELECT id,representative_ext,path
  FROM ' . IMAGES_TABLE . '
  WHERE id = ' . $category['representative_picture_id'] . '
;';
        $row = pwg_db_fetch_assoc(pwg_query($query));
        $src = DerivativeImage::thumb_url($row);
        $url = get_root_url() . 'admin.php?page=photo-' . $category['representative_picture_id'];
        $tpl_representant['picture'] = array('SRC' => $src, 'URL' => $url);
    }
    // can the admin choose to set a new random representant ?
    $tpl_representant['ALLOW_SET_RANDOM'] = $category['has_images'] ? true : false;
    // can the admin delete the current representant ?
    if ($category['has_images'] and $conf['allow_random_representative'] or !$category['has_images'] and !empty($category['representative_picture_id'])) {
        $tpl_representant['ALLOW_DELETE'] = true;
    }
    $template->assign('representant', $tpl_representant);
}
if ($category['is_virtual']) {
    $template->assign('parent_category', empty($category['id_uppercat']) ? array() : array($category['id_uppercat']));
}
trigger_notify('loc_end_cat_modify');
//----------------------------------------------------------- sending html code
$template->assign_var_from_handle('ADMIN_CONTENT', 'album_properties');
コード例 #18
0
ファイル: no_photo_yet.inc.php プロジェクト: squidjam/Piwigo
        $template = new Template(PHPWG_ROOT_PATH . 'themes', $user['theme']);
        if (isset($_GET['no_photo_yet'])) {
            if ('browse' == $_GET['no_photo_yet']) {
                $_SESSION['no_photo_yet'] = 'browse';
                redirect(make_index_url());
                exit;
            }
            if ('deactivate' == $_GET['no_photo_yet']) {
                conf_update_param('no_photo_yet', 'false');
                redirect(make_index_url());
                exit;
            }
        }
        header('Content-Type: text/html; charset=' . get_pwg_charset());
        $template->set_filenames(array('no_photo_yet' => 'no_photo_yet.tpl'));
        if (is_admin()) {
            $url = $conf['no_photo_yet_url'];
            if (substr($url, 0, 4) != 'http') {
                $url = get_root_url() . $url;
            }
            $template->assign(array('step' => 2, 'intro' => l10n('Hello %s, your Piwigo photo gallery is empty!', $user['username']), 'next_step_url' => $url, 'deactivate_url' => get_root_url() . '?no_photo_yet=deactivate'));
        } else {
            $template->assign(array('step' => 1, 'U_LOGIN' => 'identification.php', 'deactivate_url' => get_root_url() . '?no_photo_yet=browse'));
        }
        trigger_notify('loc_end_no_photo_yet');
        $template->pparse('no_photo_yet');
        exit;
    } else {
        conf_update_param('no_photo_yet', 'false');
    }
}
コード例 #19
0
ファイル: ws_core.inc.php プロジェクト: squidjam/Piwigo
 /**
  * Encodes a response and sends it back to the browser.
  */
 function sendResponse($response)
 {
     $encodedResponse = $this->_responseEncoder->encodeResponse($response);
     $contentType = $this->_responseEncoder->getContentType();
     @header('Content-Type: ' . $contentType . '; charset=' . get_pwg_charset());
     print_r($encodedResponse);
     trigger_notify('sendResponse', $encodedResponse);
 }
コード例 #20
0
ファイル: about.php プロジェクト: donseba/Piwigo
// | USA.                                                                  |
// +-----------------------------------------------------------------------+
//----------------------------------------------------------- include
define('PHPWG_ROOT_PATH', './');
include_once PHPWG_ROOT_PATH . 'include/common.inc.php';
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok                      |
// +-----------------------------------------------------------------------+
check_status(ACCESS_GUEST);
//----------------------------------------------------- template initialization
//
// Start output of page
//
$title = l10n('About Piwigo');
$page['body_id'] = 'theAboutPage';
trigger_notify('loc_begin_about');
$template->set_filename('about', 'about.tpl');
$template->assign('ABOUT_MESSAGE', load_language('about.html', '', array('return' => true)));
$theme_about = load_language('about.html', PHPWG_THEMES_PATH . $user['theme'] . '/', array('return' => true));
if ($theme_about !== false) {
    $template->assign('THEME_ABOUT', $theme_about);
}
// include menubar
$themeconf = $template->get_template_vars('themeconf');
if (!isset($themeconf['hide_menu_on']) or !in_array('theAboutPage', $themeconf['hide_menu_on'])) {
    include PHPWG_ROOT_PATH . 'include/menubar.inc.php';
}
include PHPWG_ROOT_PATH . 'include/page_header.php';
flush_page_messages();
$template->pparse('about');
include PHPWG_ROOT_PATH . 'include/page_tail.php';
コード例 #21
0
        // is the theme "deletable" ?
        $children = $themes->get_children_themes($theme_id);
        $tpl_theme['DELETABLE'] = true;
        if (count($children) > 0) {
            $tpl_theme['DELETABLE'] = false;
            $tpl_theme['DELETE_TOOLTIP'] = l10n('Impossible to delete this theme. Other themes depends on it: %s', implode(', ', $children));
        }
    }
    $tpl_themes[] = $tpl_theme;
}
// sort themes by state then by name
function cmp($a, $b)
{
    $s = array('active' => 0, 'inactive' => 1);
    if (@$a['IS_DEFAULT']) {
        return -1;
    }
    if (@$b['IS_DEFAULT']) {
        return 1;
    }
    if ($a['STATE'] == $b['STATE']) {
        return strcasecmp($a['NAME'], $b['NAME']);
    } else {
        return $s[$a['STATE']] >= $s[$b['STATE']];
    }
}
usort($tpl_themes, 'cmp');
$template->assign(array('activate_baseurl' => $base_url . '&amp;action=activate&amp;theme=', 'deactivate_baseurl' => $base_url . '&amp;action=deactivate&amp;theme=', 'set_default_baseurl' => $base_url . '&amp;action=set_default&amp;theme=', 'delete_baseurl' => $base_url . '&amp;action=delete&amp;theme=', 'tpl_themes' => $tpl_themes));
trigger_notify('loc_end_themes_installed');
$template->set_filenames(array('themes' => 'themes_installed.tpl'));
$template->assign_var_from_handle('ADMIN_CONTENT', 'themes');
コード例 #22
0
ファイル: search.php プロジェクト: squidjam/Piwigo
;';
$author_counts = array();
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result)) {
    if (!isset($author_counts[$row['author']])) {
        $author_counts[$row['author']] = 0;
    }
    $author_counts[$row['author']]++;
}
foreach ($author_counts as $author => $counter) {
    $authors[] = array('author' => $author, 'counter' => $counter);
}
$template->assign('AUTHORS', $authors);
//------------------------------------------------------------- categories form
$query = '
SELECT id,name,global_rank,uppercats
  FROM ' . CATEGORIES_TABLE . '
' . get_sql_condition_FandF(array('forbidden_categories' => 'id', 'visible_categories' => 'id'), 'WHERE') . '
;';
display_select_cat_wrapper($query, array(), 'category_options', true);
// include menubar
$themeconf = $template->get_template_vars('themeconf');
if (!isset($themeconf['hide_menu_on']) or !in_array('theSearchPage', $themeconf['hide_menu_on'])) {
    include PHPWG_ROOT_PATH . 'include/menubar.inc.php';
}
//------------------------------------------------------------ html code display
include PHPWG_ROOT_PATH . 'include/page_header.php';
trigger_notify('loc_end_search');
flush_page_messages();
$template->pparse('search');
include PHPWG_ROOT_PATH . 'include/page_tail.php';
コード例 #23
0
ファイル: functions.inc.php プロジェクト: squidjam/Piwigo
/**
 * Add configuration parameters from database to global $conf array
 *
 * @param string $condition SQL condition
 * @return void
 */
function load_conf_from_db($condition = '')
{
    global $conf;
    $query = '
SELECT param, value
 FROM ' . CONFIG_TABLE . '
 ' . (!empty($condition) ? 'WHERE ' . $condition : '') . '
;';
    $result = pwg_query($query);
    if (pwg_db_num_rows($result) == 0 and !empty($condition)) {
        fatal_error('No configuration data');
    }
    while ($row = pwg_db_fetch_assoc($result)) {
        $val = isset($row['value']) ? $row['value'] : '';
        // If the field is true or false, the variable is transformed into a boolean value.
        if ($val == 'true') {
            $val = true;
        } elseif ($val == 'false') {
            $val = false;
        }
        $conf[$row['param']] = $val;
    }
    trigger_notify('load_conf', $condition);
}
コード例 #24
0
/**
 * Loads all the registered plugins.
 */
function load_plugins()
{
    global $conf, $pwg_loaded_plugins;
    $pwg_loaded_plugins = array();
    if ($conf['enable_plugins']) {
        $plugins = get_db_plugins('active');
        foreach ($plugins as $plugin) {
            // include main from a function to avoid using same function context
            load_plugin($plugin);
        }
        trigger_notify('plugins_loaded');
    }
}
コード例 #25
0
ファイル: common.inc.php プロジェクト: squidjam/Piwigo
    if (check_upgrade_feed()) {
        $header_msgs[] = 'Some database upgrades are missing, ' . '<a href="' . get_absolute_root_url(false) . 'upgrade_feed.php">upgrade now</a>';
    }
}
if (count($header_msgs) > 0) {
    $template->assign('header_msgs', $header_msgs);
    $header_msgs = array();
}
if (!empty($conf['filter_pages']) and get_filter_page_value('used')) {
    include PHPWG_ROOT_PATH . 'include/filter.inc.php';
} else {
    $filter['enabled'] = false;
}
if (isset($conf['header_notes'])) {
    $header_notes = array_merge($header_notes, $conf['header_notes']);
}
// default event handlers
add_event_handler('render_category_literal_description', 'render_category_literal_description');
if (!$conf['allow_html_descriptions']) {
    add_event_handler('render_category_description', 'nl2br');
}
add_event_handler('render_comment_content', 'render_comment_content');
add_event_handler('render_comment_author', 'strip_tags');
add_event_handler('render_tag_url', 'str2url');
add_event_handler('blockmanager_register_blocks', 'register_default_menubar_blocks', EVENT_HANDLER_PRIORITY_NEUTRAL - 1);
if (!empty($conf['original_url_protection'])) {
    add_event_handler('get_element_url', 'get_element_url_protection_handler');
    add_event_handler('get_src_image_url', 'get_src_image_url_protection_handler');
}
trigger_notify('init');
コード例 #26
0
/**
 * Sends an email, using Piwigo specific informations.
 *
 * @param string|array $to
 * @param array $args
 *       o from: sender [default value webmaster email]
 *       o Cc: array of carbon copy receivers of the mail. [default value empty]
 *       o Bcc: array of blind carbon copy receivers of the mail. [default value empty]
 *       o subject [default value 'Piwigo']
 *       o content: content of mail [default value '']
 *       o content_format: format of mail content [default value 'text/plain']
 *       o email_format: global mail format [default value $conf_mail['default_email_format']]
 *       o theme: theme to use [default value $conf_mail['mail_theme']]
 *       o mail_title: main title of the mail [default value $conf['gallery_title']]
 *       o mail_subtitle: subtitle of the mail [default value subject]
 * @param array $tpl - use these options to define a custom content template file
 *       o filename
 *       o dirname (optional)
 *       o assign (optional)
 *
 * @return boolean
 */
function pwg_mail($to, $args = array(), $tpl = array())
{
    global $conf, $conf_mail, $lang_info, $page;
    if (empty($to) and empty($args['Cc']) and empty($args['Bcc'])) {
        return true;
    }
    if (!isset($conf_mail)) {
        $conf_mail = get_mail_configuration();
    }
    include_once PHPWG_ROOT_PATH . 'include/phpmailer/class.phpmailer.php';
    $mail = new PHPMailer();
    foreach (get_clean_recipients_list($to) as $recipient) {
        $mail->addAddress($recipient['email'], $recipient['name']);
    }
    $mail->WordWrap = 76;
    $mail->CharSet = 'UTF-8';
    // Compute root_path in order have complete path
    set_make_full_url();
    if (empty($args['from'])) {
        $from = array('email' => $conf_mail['email_webmaster'], 'name' => $conf_mail['name_webmaster']);
    } else {
        $from = unformat_email($args['from']);
    }
    $mail->setFrom($from['email'], $from['name']);
    $mail->addReplyTo($from['email'], $from['name']);
    // Subject
    if (empty($args['subject'])) {
        $args['subject'] = 'Piwigo';
    }
    $args['subject'] = trim(preg_replace('#[\\n\\r]+#s', '', $args['subject']));
    $mail->Subject = $args['subject'];
    // Cc
    if (!empty($args['Cc'])) {
        foreach (get_clean_recipients_list($args['Cc']) as $recipient) {
            $mail->addCC($recipient['email'], $recipient['name']);
        }
    }
    // Bcc
    $Bcc = get_clean_recipients_list(@$args['Bcc']);
    if ($conf_mail['send_bcc_mail_webmaster']) {
        $Bcc[] = array('email' => get_webmaster_mail_address(), 'name' => '');
    }
    if (!empty($Bcc)) {
        foreach ($Bcc as $recipient) {
            $mail->addBCC($recipient['email'], $recipient['name']);
        }
    }
    // theme
    if (empty($args['theme']) or !in_array($args['theme'], array('clear', 'dark'))) {
        $args['theme'] = $conf_mail['mail_theme'];
    }
    // content
    if (!isset($args['content'])) {
        $args['content'] = '';
    }
    // try to decompose subject like "[....] ...."
    if (!isset($args['mail_title']) and !isset($args['mail_subtitle'])) {
        if (preg_match('#^\\[(.*)\\](.*)$#', $args['subject'], $matches)) {
            $args['mail_title'] = $matches[1];
            $args['mail_subtitle'] = $matches[2];
        }
    }
    if (!isset($args['mail_title'])) {
        $args['mail_title'] = $conf['gallery_title'];
    }
    if (!isset($args['mail_subtitle'])) {
        $args['mail_subtitle'] = $args['subject'];
    }
    // content type
    if (empty($args['content_format'])) {
        $args['content_format'] = 'text/plain';
    }
    $content_type_list = array();
    if ($conf_mail['mail_allow_html'] and @$args['email_format'] != 'text/plain') {
        $content_type_list[] = 'text/html';
    }
    $content_type_list[] = 'text/plain';
    $contents = array();
    foreach ($content_type_list as $content_type) {
        // key compose of indexes witch allow to cache mail data
        $cache_key = $content_type . '-' . $lang_info['code'];
        if (!isset($conf_mail[$cache_key])) {
            // instanciate a new Template
            if (!isset($conf_mail[$cache_key]['theme'])) {
                $conf_mail[$cache_key]['theme'] = get_mail_template($content_type);
                trigger_notify('before_parse_mail_template', $cache_key, $content_type);
            }
            $template =& $conf_mail[$cache_key]['theme'];
            $template->set_filename('mail_header', 'header.tpl');
            $template->set_filename('mail_footer', 'footer.tpl');
            $template->assign(array('GALLERY_URL' => get_gallery_home_url(), 'GALLERY_TITLE' => isset($page['gallery_title']) ? $page['gallery_title'] : $conf['gallery_title'], 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 'PHPWG_URL' => defined('PHPWG_URL') ? PHPWG_URL : '', 'CONTENT_ENCODING' => get_pwg_charset(), 'CONTACT_MAIL' => $conf_mail['email_webmaster']));
            if ($content_type == 'text/html') {
                if ($template->smarty->templateExists('global-mail-css.tpl')) {
                    $template->set_filename('global-css', 'global-mail-css.tpl');
                    $template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'global-css');
                }
                if ($template->smarty->templateExists('mail-css-' . $args['theme'] . '.tpl')) {
                    $template->set_filename('css', 'mail-css-' . $args['theme'] . '.tpl');
                    $template->assign_var_from_handle('MAIL_CSS', 'css');
                }
            }
        }
        $template =& $conf_mail[$cache_key]['theme'];
        $template->assign(array('MAIL_TITLE' => $args['mail_title'], 'MAIL_SUBTITLE' => $args['mail_subtitle']));
        // Header
        $contents[$content_type] = $template->parse('mail_header', true);
        // Content
        // Stored in a temp variable, if a content template is used it will be assigned
        // to the $CONTENT template variable, otherwise it will be appened to the mail
        if ($args['content_format'] == 'text/plain' and $content_type == 'text/html') {
            // convert plain text to html
            $mail_content = '<p>' . nl2br(preg_replace('/(https?:\\/\\/([-\\w\\.]+[-\\w])+(:\\d+)?(\\/([\\w\\/_\\.\\#-]*(\\?\\S+)?[^\\.\\s])?)?)/i', '<a href="$1">$1</a>', htmlspecialchars($args['content']))) . '</p>';
        } else {
            if ($args['content_format'] == 'text/html' and $content_type == 'text/plain') {
                // convert html text to plain text
                $mail_content = strip_tags($args['content']);
            } else {
                $mail_content = $args['content'];
            }
        }
        // Runtime template
        if (isset($tpl['filename'])) {
            if (isset($tpl['dirname'])) {
                $template->set_template_dir($tpl['dirname'] . '/' . $content_type);
            }
            if ($template->smarty->templateExists($tpl['filename'] . '.tpl')) {
                $template->set_filename($tpl['filename'], $tpl['filename'] . '.tpl');
                if (!empty($tpl['assign'])) {
                    $template->assign($tpl['assign']);
                }
                $template->assign('CONTENT', $mail_content);
                $contents[$content_type] .= $template->parse($tpl['filename'], true);
            } else {
                $contents[$content_type] .= $mail_content;
            }
        } else {
            $contents[$content_type] .= $mail_content;
        }
        // Footer
        $contents[$content_type] .= $template->parse('mail_footer', true);
    }
    // Undo Compute root_path in order have complete path
    unset_make_full_url();
    // Send content to PHPMailer
    if (isset($contents['text/html'])) {
        $mail->isHTML(true);
        $mail->Body = move_css_to_body($contents['text/html']);
        if (isset($contents['text/plain'])) {
            $mail->AltBody = $contents['text/plain'];
        }
    } else {
        $mail->isHTML(false);
        $mail->Body = $contents['text/plain'];
    }
    if ($conf_mail['use_smtp']) {
        // now we need to split port number
        if (strpos($conf_mail['smtp_host'], ':') !== false) {
            list($smtp_host, $smtp_port) = explode(':', $conf_mail['smtp_host']);
        } else {
            $smtp_host = $conf_mail['smtp_host'];
            $smtp_port = 25;
        }
        $mail->IsSMTP();
        // enables SMTP debug information (for testing) 2 - debug, 0 - no message
        $mail->SMTPDebug = 0;
        $mail->Host = $smtp_host;
        $mail->Port = $smtp_port;
        if (!empty($conf_mail['smtp_secure']) and in_array($conf_mail['smtp_secure'], array('ssl', 'tls'))) {
            $mail->SMTPSecure = $conf_mail['smtp_secure'];
        }
        if (!empty($conf_mail['smtp_user'])) {
            $mail->SMTPAuth = true;
            $mail->Username = $conf_mail['smtp_user'];
            $mail->Password = $conf_mail['smtp_password'];
        }
    }
    $ret = true;
    $pre_result = trigger_change('before_send_mail', true, $to, $args, $mail);
    if ($pre_result) {
        $ret = $mail->send();
        if (!$ret and (!ini_get('display_errors') or is_admin())) {
            trigger_error('Mailer Error: ' . $mail->ErrorInfo, E_USER_WARNING);
        }
        if ($conf['debug_mail']) {
            pwg_send_mail_test($ret, $mail, $args);
        }
    }
    return $ret;
}
コード例 #27
0
/**
 * Performs all the cleanup on user logout.
 */
function logout_user()
{
    global $conf;
    trigger_notify('user_logout', @$_SESSION['pwg_uid']);
    $_SESSION = array();
    session_unset();
    session_destroy();
    setcookie(session_name(), '', 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'));
    setcookie($conf['remember_me_name'], '', 0, cookie_path(), ini_get('session.cookie_domain'));
}
コード例 #28
0
ファイル: profile.php プロジェクト: lcorbasson/Piwigo
/**
 * Assign template variables, from arguments
 * Used to build profile edition pages
 * 
 * @param string $url_action
 * @param string $url_redirect
 * @param array $userdata
 */
function load_profile_in_template($url_action, $url_redirect, $userdata, $template_prefixe = null)
{
    global $template, $conf;
    $template->assign('radio_options', array('true' => l10n('Yes'), 'false' => l10n('No')));
    $template->assign(array($template_prefixe . 'USERNAME' => stripslashes($userdata['username']), $template_prefixe . 'EMAIL' => @$userdata['email'], $template_prefixe . 'ALLOW_USER_CUSTOMIZATION' => $conf['allow_user_customization'], $template_prefixe . 'ACTIVATE_COMMENTS' => $conf['activate_comments'], $template_prefixe . 'NB_IMAGE_PAGE' => $userdata['nb_image_page'], $template_prefixe . 'RECENT_PERIOD' => $userdata['recent_period'], $template_prefixe . 'EXPAND' => $userdata['expand'] ? 'true' : 'false', $template_prefixe . 'NB_COMMENTS' => $userdata['show_nb_comments'] ? 'true' : 'false', $template_prefixe . 'NB_HITS' => $userdata['show_nb_hits'] ? 'true' : 'false', $template_prefixe . 'REDIRECT' => $url_redirect, $template_prefixe . 'F_ACTION' => $url_action));
    $template->assign('template_selection', $userdata['theme']);
    $template->assign('template_options', get_pwg_themes());
    foreach (get_languages() as $language_code => $language_name) {
        if (isset($_POST['submit']) or $userdata['language'] == $language_code) {
            $template->assign('language_selection', $language_code);
        }
        $language_options[$language_code] = $language_name;
    }
    $template->assign('language_options', $language_options);
    $special_user = in_array($userdata['id'], array($conf['guest_id'], $conf['default_user_id']));
    $template->assign('SPECIAL_USER', $special_user);
    $template->assign('IN_ADMIN', defined('IN_ADMIN'));
    // allow plugins to add their own form data to content
    trigger_notify('load_profile_in_template', $userdata);
    $template->assign('PWG_TOKEN', get_pwg_token());
}
コード例 #29
0
ファイル: cat_list.php プロジェクト: lcorbasson/Piwigo
        }
        $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']) {
            $tpl_cat['U_SYNC'] = $base_url . 'site_update&amp;site=1&amp;cat_id=' . $category['id'];
        }
    }
    $template->append('categories', $tpl_cat);
}
trigger_notify('loc_end_cat_list');
// +-----------------------------------------------------------------------+
// |                          sending html code                            |
// +-----------------------------------------------------------------------+
$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
コード例 #30
0
ファイル: nbm.php プロジェクト: donseba/Piwigo
// | along with this program; if not, write to the Free Software           |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA.                                                                  |
// +-----------------------------------------------------------------------+
//--------------------------------------------------------------------- include
define('PHPWG_ROOT_PATH', './');
include_once PHPWG_ROOT_PATH . 'include/common.inc.php';
check_status(ACCESS_FREE);
include_once PHPWG_ROOT_PATH . 'include/functions_notification.inc.php';
include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php';
include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
include_once PHPWG_ROOT_PATH . 'admin/include/functions_notification_by_mail.inc.php';
// Translations are in admin file too
load_language('admin.lang');
// Need to update a second time
trigger_notify('loading_lang');
load_language('lang', PHPWG_ROOT_PATH . PWG_LOCAL_DIR, array('no_fallback' => true, 'local' => true));
// +-----------------------------------------------------------------------+
// | Main                                                                  |
// +-----------------------------------------------------------------------+
if (isset($_GET['subscribe']) and preg_match('/^[A-Za-z0-9]{16}$/', $_GET['subscribe'])) {
    subscribe_notification_by_mail(false, array($_GET['subscribe']));
} else {
    if (isset($_GET['unsubscribe']) and preg_match('/^[A-Za-z0-9]{16}$/', $_GET['unsubscribe'])) {
        unsubscribe_notification_by_mail(false, array($_GET['unsubscribe']));
    } else {
        $page['errors'][] = l10n('Unknown identifier');
    }
}
// +-----------------------------------------------------------------------+
// | template initialization                                               |