Ejemplo n.º 1
0
 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 language_controler_flags()
{
    global $user, $template, $conf, $page;
    $available_lang = get_languages();
    if (isset($conf['no_flag_languages'])) {
        $available_lang = array_diff_key($available_lang, array_flip($conf['no_flag_languages']));
    }
    $url_starting = get_query_string_diff(array('lang'));
    if (isset($page['section']) and $page['section'] == 'additional_page' and isset($page['additional_page'])) {
        $base_url = make_index_url(array('section' => 'page')) . '/' . (isset($page['additional_page']['permalink']) ? $page['additional_page']['permalink'] : $page['additional_page']['id']);
    } else {
        $base_url = duplicate_index_url();
    }
    foreach ($available_lang as $code => $displayname) {
        $qlc = array('url' => add_url_params($base_url, array('lang' => $code)), 'alt' => ucwords($displayname), 'title' => substr($displayname, 0, -4), 'code' => $code);
        $lsw['flags'][$code] = $qlc;
        if ($code == $user['language']) {
            $lsw['Active'] = $qlc;
        }
    }
    $safe_themes = array('clear', 'dark', 'elegant', 'Sylvia', 'simple-grey', 'simple-black', 'simple-white', 'kardon', 'luciano', 'montblancxl');
    // stripped (2.6)
    $template->assign(array('lang_switch' => $lsw, 'LANGUAGE_SWITCH_PATH' => LANGUAGE_SWITCH_PATH, 'LANGUAGE_SWITCH_LOAD_STYLE' => !in_array($user['theme'], $safe_themes)));
    $template->set_filename('language_flags', dirname(__FILE__) . '/flags.tpl');
    $template->concat('PLUGIN_INDEX_ACTIONS', $template->parse('language_flags', true));
    $template->clear_assign('lang_switch');
}
Ejemplo n.º 3
0
function parse_sort_variables($sortable_by, $default_field, $get_param, $get_rejects, $template_var, $anchor = '')
{
    global $template;
    $url_components = parse_url($_SERVER['REQUEST_URI']);
    $base_url = $url_components['path'];
    parse_str($url_components['query'], $vars);
    $is_first = true;
    foreach ($vars as $key => $value) {
        if (!in_array($key, $get_rejects) and $key != $get_param) {
            $base_url .= $is_first ? '?' : '&';
            $is_first = false;
            $base_url .= $key . '=' . urlencode($value);
        }
    }
    $ret = array();
    foreach ($sortable_by as $field) {
        $url = $base_url;
        $disp = '↓';
        // TODO: an small image is better
        if ($field !== @$_GET[$get_param]) {
            if (!isset($default_field) or $default_field != $field) {
                // the first should be the default
                $url = add_url_params($url, array($get_param => $field));
            } elseif (isset($default_field) and !isset($_GET[$get_param])) {
                $ret[] = $field;
                $disp = '<em>' . $disp . '</em>';
            }
        } else {
            $ret[] = $field;
            $disp = '<em>' . $disp . '</em>';
        }
        if (isset($template_var)) {
            $template->assign($template_var . strtoupper($field), '<a href="' . $url . $anchor . '" title="' . l10n('Sort order') . '">' . $disp . '</a>');
        }
    }
    return $ret;
}
Ejemplo n.º 4
0
     , ROUND(AVG(rate),2) AS average
  FROM ' . RATE_TABLE . '
  WHERE element_id = ' . $picture['current']['id'] . '
;';
        list($rate_summary['count'], $rate_summary['average']) = pwg_db_fetch_row(pwg_query($query));
    }
    $template->assign('rate_summary', $rate_summary);
    $user_rate = null;
    if ($conf['rate_anonymous'] or is_autorize_status(ACCESS_CLASSIC)) {
        if ($rate_summary['count'] > 0) {
            $query = 'SELECT rate
      FROM ' . RATE_TABLE . '
      WHERE element_id = ' . $page['image_id'] . '
      AND user_id = ' . $user['id'];
            if (!is_autorize_status(ACCESS_CLASSIC)) {
                $ip_components = explode('.', $_SERVER['REMOTE_ADDR']);
                if (count($ip_components) > 3) {
                    array_pop($ip_components);
                }
                $anonymous_id = implode('.', $ip_components);
                $query .= ' AND anonymous_id = \'' . $anonymous_id . '\'';
            }
            $result = pwg_query($query);
            if (pwg_db_num_rows($result) > 0) {
                $row = pwg_db_fetch_assoc($result);
                $user_rate = $row['rate'];
            }
        }
        $template->assign('rating', array('F_ACTION' => add_url_params($url_self, array('action' => 'rate')), 'USER_RATE' => $user_rate, 'marks' => $conf['rate_items']));
    }
}
Ejemplo n.º 5
0
        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;
            }
        }
        if (is_admin()) {
            if ($row['validated'] != 'true') {
                $tpl_comment['U_VALIDATE'] = add_url_params($url_self, array('action' => 'validate_comment', 'comment_to_validate' => $row['id'], 'pwg_token' => get_pwg_token()));
            }
        }
        $template->append('comments', $tpl_comment);
    }
}
$show_add_comment_form = !is_a_guest() || $conf['guestbook']['guest_can_add'];
if (isset($edit_comment)) {
    $show_add_comment_form = false;
}
if ($show_add_comment_form) {
    foreach (array('content', 'author', 'website', 'email') as $el) {
        ${$el} = '';
        if ('reject' === @$comment_action and !empty($comm[$el])) {
            ${$el} = htmlspecialchars(stripslashes($comm[$el]));
        }
Ejemplo n.º 6
0
/**
 * Add main toolbar to current page
 * @trigger loc_after_page_header
 */
function admintools_add_public_controller()
{
    global $MultiView, $conf, $template, $page, $user, $picture;
    if (script_basename() == 'picture' and empty($picture['current'])) {
        return;
    }
    $url_root = get_root_url();
    $tpl_vars = array();
    if ($MultiView->is_admin()) {
        // full options for admin
        $tpl_vars['U_SITE_ADMIN'] = $url_root . 'admin.php?page=';
        $tpl_vars['MULTIVIEW'] = $MultiView->get_data();
        $tpl_vars['USER'] = $MultiView->get_user();
        $tpl_vars['CURRENT_USERNAME'] = $user['id'] == $conf['guest_id'] ? l10n('guest') : $user['username'];
        $tpl_vars['DELETE_CACHE'] = isset($conf['multiview_invalidate_cache']);
        if (($admin_lang = $MultiView->get_user_language()) !== false) {
            include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php';
            switch_lang_to($admin_lang);
        }
    } else {
        if ($conf['AdminTools']['public_quick_edit'] and script_basename() == 'picture' and $picture['current']['added_by'] == $user['id']) {
            // only "edit" button for photo owner
        } else {
            return;
        }
    }
    $tpl_vars['POSITION'] = $conf['AdminTools']['closed_position'];
    $tpl_vars['DEFAULT_OPEN'] = $conf['AdminTools']['default_open'];
    $tpl_vars['U_SELF'] = $MultiView->get_clean_url(true);
    // photo page
    if (script_basename() == 'picture') {
        $url_self = duplicate_picture_url();
        $tpl_vars['IS_PICTURE'] = true;
        // admin can add to caddie and set representattive
        if ($MultiView->is_admin()) {
            $template->clear_assign(array('U_SET_AS_REPRESENTATIVE', 'U_PHOTO_ADMIN', 'U_CADDIE'));
            $template->set_prefilter('picture', 'admintools_remove_privacy');
            $tpl_vars['U_CADDIE'] = add_url_params($url_self, array('action' => 'add_to_caddie'));
            $query = '
SELECT element_id FROM ' . CADDIE_TABLE . '
  WHERE element_id = ' . $page['image_id'] . '
;';
            $tpl_vars['IS_IN_CADDIE'] = pwg_db_num_rows(pwg_query($query)) > 0;
            if (isset($page['category'])) {
                $tpl_vars['CATEGORY_ID'] = $page['category']['id'];
                $tpl_vars['U_SET_REPRESENTATIVE'] = add_url_params($url_self, array('action' => 'set_as_representative'));
                $tpl_vars['IS_REPRESENTATIVE'] = $page['category']['representative_picture_id'] == $page['image_id'];
            }
            $tpl_vars['U_ADMIN_EDIT'] = $url_root . 'admin.php?page=photo-' . $page['image_id'] . (isset($page['category']) ? '&amp;cat_id=' . $page['category']['id'] : '');
        }
        $tpl_vars['U_DELETE'] = add_url_params($url_self, array('delete' => '', 'pwg_token' => get_pwg_token()));
        // gets tags (full available list is loaded in ajax)
        include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
        $query = '
SELECT id, name
  FROM ' . IMAGE_TAG_TABLE . ' AS it
    JOIN ' . TAGS_TABLE . ' AS t ON t.id = it.tag_id
  WHERE image_id = ' . $page['image_id'] . '
;';
        $tag_selection = get_taglist($query);
        $tpl_vars['QUICK_EDIT'] = array('img' => $picture['current']['derivatives']['square']->get_url(), 'name' => $picture['current']['name'], 'comment' => $picture['current']['comment'], 'author' => $picture['current']['author'], 'level' => $picture['current']['level'], 'date_creation' => substr($picture['current']['date_creation'], 0, 10), 'date_creation_time' => substr($picture['current']['date_creation'], 11, 5), 'tag_selection' => $tag_selection);
    } else {
        if ($MultiView->is_admin() and @$page['section'] == 'categories' and isset($page['category'])) {
            $url_self = duplicate_index_url();
            $tpl_vars['IS_CATEGORY'] = true;
            $tpl_vars['CATEGORY_ID'] = $page['category']['id'];
            $template->clear_assign(array('U_EDIT', 'U_CADDIE'));
            $tpl_vars['U_ADMIN_EDIT'] = $url_root . 'admin.php?page=album-' . $page['category']['id'];
            if (!empty($page['items'])) {
                $tpl_vars['U_CADDIE'] = add_url_params($url_self, array('caddie' => 1));
            }
            $tpl_vars['QUICK_EDIT'] = array('img' => null, 'name' => $page['category']['name'], 'comment' => $page['category']['comment']);
            if (!empty($page['category']['representative_picture_id'])) {
                $query = '
SELECT * FROM ' . IMAGES_TABLE . '
  WHERE id = ' . $page['category']['representative_picture_id'] . '
;';
                $image_infos = pwg_db_fetch_assoc(pwg_query($query));
                $tpl_vars['QUICK_EDIT']['img'] = DerivativeImage::get_one(IMG_SQUARE, $image_infos)->get_url();
            }
        }
    }
    $template->assign(array('ADMINTOOLS_PATH' => './plugins/' . ADMINTOOLS_ID . '/', 'ato' => $tpl_vars));
    $template->set_filename('ato_public_controller', realpath(ADMINTOOLS_PATH . 'template/public_controller.tpl'));
    $template->parse('ato_public_controller');
    if ($MultiView->is_admin() && @$admin_lang !== false) {
        switch_lang_back();
    }
}
function assign_vars_nbm_mail_content($nbm_user)
{
    global $env_nbm;
    set_make_full_url();
    $env_nbm['mail_template']->assign(array('USERNAME' => stripslashes($nbm_user['username']), 'SEND_AS_NAME' => $env_nbm['send_as_name'], 'UNSUBSCRIBE_LINK' => add_url_params(get_gallery_home_url() . '/nbm.php', array('unsubscribe' => $nbm_user['check_key'])), 'SUBSCRIBE_LINK' => add_url_params(get_gallery_home_url() . '/nbm.php', array('subscribe' => $nbm_user['check_key'])), 'CONTACT_EMAIL' => $env_nbm['send_as_mail_address']));
    unset_make_full_url();
}
Ejemplo n.º 8
0
// Database Transactions
$tmp_link = add_url_params($this->page_url, array("action" => "db_trans"), true);
$top_mod_links["links"][] = array("link" => $tmp_link, "desc" => "Transactions Tests", "image" => xml_escape($db_trans_image));
//=================================================================
// Pull a list records
//=================================================================
$strsql = "select * from contacts order by first_name, last_name";
$contacts = qdb_list($data_source, $strsql);
//=================================================================
// Alter dataset if Oracle or DB2
//=================================================================
lower_rec_keys($driver_type, $contacts);
foreach ($contacts as $key => $contact) {
    extract($contact);
    $edit_link = add_url_params($this->page_url, array("action" => "edit", "id" => $id));
    $delete_link = add_url_params($this->page_url, array("action" => "confirm_delete", "id" => $id));
    $contacts[$key]["edit"] = anchor($edit_link, $edit_image);
    $contacts[$key]["delete"] = anchor($delete_link, $delete_image);
    if (isset($change_id) && $id == $change_id) {
        $change_row = $key;
    }
}
//=================================================================
// Record Set List
//=================================================================
$data_order = array();
$data_order["id"] = "ID";
$data_order["first_name"] = "First Name";
$data_order["last_name"] = "Last Name";
$data_order["city"] = "City";
$data_order["state"] = "State";
Ejemplo n.º 9
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]
 *       o auth_key: authentication key to add on footer link [default value null]
 * @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 (!empty($args['auth_key'])) {
            $cache_key .= '-' . $args['auth_key'];
        }
        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');
            $add_url_params = array();
            if (!empty($args['auth_key'])) {
                $add_url_params['auth'] = $args['auth_key'];
            }
            $template->assign(array('GALLERY_URL' => add_url_params(get_gallery_home_url(), $add_url_params), '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;
}
/**
 * @param id image id
 * @param what_part string one of 'e' (element), 'r' (representative)
 */
function get_action_url($id, $what_part, $download)
{
    $params = array('id' => $id, 'part' => $what_part);
    if ($download) {
        $params['download'] = null;
    }
    return add_url_params(get_root_url() . 'action.php', $params);
}
Ejemplo n.º 11
0
 }
 // category comment
 if ($page['start'] == 0 and !isset($page['chronology_field']) and !empty($page['comment'])) {
     $template->assign('CONTENT_DESCRIPTION', $page['comment']);
 }
 if (isset($page['category']['count_categories']) and $page['category']['count_categories'] == 0) {
     // count_categories might be computed by menubar - if the case unassign flat link if no sub albums
     $template->clear_assign('U_MODE_FLAT');
 }
 //------------------------------------------------------ main part : thumbnails
 if (0 == $page['start'] and !isset($page['flat']) and !isset($page['chronology_field']) and ('recent_cats' == $page['section'] or 'categories' == $page['section']) and (!isset($page['category']['count_categories']) or $page['category']['count_categories'] > 0)) {
     include PHPWG_ROOT_PATH . 'include/category_cats.inc.php';
 }
 if (!empty($page['items'])) {
     include PHPWG_ROOT_PATH . 'include/category_default.inc.php';
     $url = add_url_params(duplicate_index_url(), array('display' => ''));
     $selected_type = $template->get_template_vars('derivative_params')->type;
     $template->clear_assign('derivative_params');
     $type_map = ImageStdParams::get_defined_type_map();
     unset($type_map[IMG_XXLARGE], $type_map[IMG_XLARGE]);
     foreach ($type_map as $params) {
         $template->append('image_derivatives', array('DISPLAY' => l10n($params->type), 'URL' => $url . $params->type, 'SELECTED' => $params->type == $selected_type ? true : false));
     }
 }
 // slideshow
 // execute after init thumbs in order to have all picture informations
 if (!empty($page['cat_slideshow_url'])) {
     if (isset($_GET['slideshow'])) {
         redirect($page['cat_slideshow_url']);
     } elseif ($conf['index_slideshow_icon']) {
         $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']);
Ejemplo n.º 12
0
function osm_make_kml_index_url($params)
{
    global $conf, $osm_dir;
    $url = get_root_url() . 'plugins/' . $osm_dir . '/kml.php';
    if ($conf['question_mark_in_urls']) {
        $url .= '?';
    }
    $url .= make_section_in_url($params);
    unset($params['start']);
    if ('categories' != $params['section']) {
        unset($params['flat']);
    }
    $url = add_well_known_params_in_url($url, $params);
    $get_params = array();
    if (isset($params['box']) and !empty($params['box'])) {
        include_once dirname(__FILE__) . '/functions_map.php';
        if (!bounds_is_world($params['box'])) {
            $get_params['box'] = bounds_to_url($params['box']);
        }
    }
    if (isset($params['ll']) and !empty($params['ll'])) {
        $get_params['ll'] = $params['ll']['lat'] . ',' . $params['ll']['lon'];
    }
    $url = add_url_params($url, $get_params);
    return $url;
}
Ejemplo n.º 13
0
        }
        if (can_manage_comment('edit', $comment['author_id'])) {
            $tpl_comment['U_EDIT'] = add_url_params($url_self, array('edit' => $comment['comment_id']));
            if (isset($edit_comment) and $comment['comment_id'] == $edit_comment) {
                $tpl_comment['IN_EDIT'] = true;
                $key = get_ephemeral_key(2, $comment['image_id']);
                $tpl_comment['KEY'] = $key;
                $tpl_comment['IMAGE_ID'] = $comment['image_id'];
                $tpl_comment['CONTENT'] = $comment['content'];
                $tpl_comment['PWG_TOKEN'] = get_pwg_token();
                $tpl_comment['U_CANCEL'] = $url_self;
            }
        }
        if (can_manage_comment('validate', $comment['author_id'])) {
            if ('true' != $comment['validated']) {
                $tpl_comment['U_VALIDATE'] = add_url_params($url_self, array('validate' => $comment['comment_id'], 'pwg_token' => get_pwg_token()));
            }
        }
        $template->append('comments', $tpl_comment);
    }
}
$derivative_params = trigger_change('get_comments_derivative_params', ImageStdParams::get_by_type(IMG_THUMB));
$template->assign('derivative_params', $derivative_params);
// include menubar
$themeconf = $template->get_template_vars('themeconf');
if (!isset($themeconf['hide_menu_on']) or !in_array('theCommentsPage', $themeconf['hide_menu_on'])) {
    include PHPWG_ROOT_PATH . 'include/menubar.inc.php';
}
// +-----------------------------------------------------------------------+
// |                           html code display                           |
// +-----------------------------------------------------------------------+
function pqv_end_section_init()
{
    global $template, $page;
    if (!pqv_is_active()) {
        return;
    }
    if (empty($page['items'])) {
        return;
    }
    $query = '
SELECT
    id
  FROM ' . IMAGES_TABLE . '
  WHERE id IN (' . implode(',', $page['items']) . ')
    AND pqv_validated = \'false\'
;';
    $pqv_rejected = query2array($query, null, 'id');
    if (isset($_GET['pqv_delete']) and count($pqv_rejected) > 0) {
        include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
        $deleted_count = delete_elements($pqv_rejected, true);
        if ($deleted_count > 0) {
            invalidate_user_cache();
            $_SESSION['page_infos'][] = l10n_dec('%d photo was deleted', '%d photos were deleted', $deleted_count);
            $redirect_url = duplicate_index_url(array(), array('pqv_delete'));
            redirect($redirect_url);
        }
    }
    if (count($pqv_rejected) > 0) {
        $delete_url = add_url_params(duplicate_index_url(), array('pqv_delete' => 1));
        $template->assign('CONTENT_DESCRIPTION', '<a href="' . $delete_url . '" onclick="return confirm(\'' . l10n('Are you sure?') . '\');">delete the ' . count($pqv_rejected) . ' rejected photo(s)</a>');
    }
}
Ejemplo n.º 15
0
function Audit_PWG_FluxBB()
{
    global $page, $conf, $errors;
    $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']);
    $msg_error_PWG_Dup = '';
    $msg_error_FluxBB_Dup = '';
    $msg_error_Link_Break = '';
    $msg_error_Link_Bad = '';
    $msg_error_Synchro = '';
    $msg_ok_Synchro = '';
    $msg_error_PWG2FluxBB = '';
    $msg_error_FluxBB2PWG = '';
    // Check duplicate accounts in Piwigo users table
    // ----------------------------------------------
    $query = '
SELECT COUNT(*) AS nbr_dup, id, username
FROM ' . USERS_TABLE . '
WHERE username NOT IN ("18","16")
GROUP BY BINARY username
HAVING COUNT(*) > 1
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_PWG_Dup .= '<br>' . l10n('Error_PWG_Dup') . $row['nbr_dup'] . ' x ' . stripslashes($row['username']);
    }
    // Display OK message or build errors
    if ($msg_error_PWG_Dup == '') {
        array_push($page['infos'], l10n('Audit_PWG_Dup') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_PWG_Dup = l10n('Audit_PWG_Dup') . $msg_error_PWG_Dup . '<br>' . l10n('Advise_PWG_Dup');
    }
    // Check duplicate accounts in FluxBB users table
    // ----------------------------------------------
    $query = '
SELECT COUNT(*) AS nbr_dup, username
FROM ' . FluxBB_USERS_TABLE . ' 
GROUP BY BINARY username
HAVING COUNT(*) > 1
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_FluxBB_Dup .= '<br>' . l10n('Error_FluxBB_Dup') . $row['nbr_dup'] . ' x ' . stripslashes($row['username']);
        $subquery = '
SELECT id, username, email
FROM ' . FluxBB_USERS_TABLE . ' 
WHERE BINARY username = BINARY "' . $row['username'] . '"
;';
        $subresult = pwg_query($subquery);
        while ($subrow = pwg_db_fetch_assoc($subresult)) {
            $msg_error_FluxBB_Dup .= '<br>id:' . $subrow['id'] . '=' . stripslashes($subrow['username']) . ' (' . $subrow['email'] . ')';
            // Action : Delete duplicate user from FluxBB
            $msg_error_FluxBB_Dup .= ' <a href="';
            $msg_error_FluxBB_Dup .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'del_user', 'id' => $subrow['id']));
            $msg_error_FluxBB_Dup .= '" title="' . l10n('Del_User') . stripslashes($subrow['username']) . '"';
            $msg_error_FluxBB_Dup .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
            $msg_error_FluxBB_Dup .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/user_delete.png" alt="' . l10n('Del_User') . $subrow['username'] . '" /></a>';
        }
    }
    // Display OK message or build errors
    if ($msg_error_FluxBB_Dup == '') {
        array_push($page['infos'], l10n('Audit_FluxBB_Dup') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_FluxBB_Dup = l10n('Audit_FluxBB_Dup') . $msg_error_FluxBB_Dup . '<br>' . l10n('Advise_FluxBB_Dup');
    }
    // Check links between Piwigo and FluxBB users
    // -------------------------------------------
    // Check fixable broken links between Piwigo and FluxBB users
    // ----------------------------------------------------------
    $query = '
SELECT pwg.id as pwg_id, bb.id as bb_id, pwg.username as pwg_user, pwg.mail_address as pwg_mail
FROM ' . FluxBB_USERS_TABLE . ' AS bb, ' . USERS_TABLE . ' as pwg
WHERE bb.id NOT in (
  SELECT id_user_FluxBB
  FROM ' . Register_FluxBB_ID_TABLE . '
  )
AND pwg.id NOT in (
  SELECT id_user_pwg
  FROM ' . Register_FluxBB_ID_TABLE . '
  )
AND pwg.username = bb.username
AND pwg.username NOT IN ("18","16")
AND pwg.mail_address = bb.email
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_Link_Break .= '<br>' . l10n('Error_Link_Break') . stripslashes($row['pwg_user']) . ' (' . $row['pwg_mail'] . ')';
        // Action : Create new link
        $msg_error_Link_Break .= ' <a href="';
        $msg_error_Link_Break .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'new_link', 'pwg_id' => $row['pwg_id'], 'bb_id' => $row['bb_id']));
        $msg_error_Link_Break .= '" title="' . l10n('New_Link') . stripslashes($row['pwg_user']) . '"';
        $msg_error_Link_Break .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_Link_Break .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/link_break.png" alt="' . l10n('New_Link') . stripslashes($row['pwg_user']) . '" /></a>';
    }
    // Display OK message or build errors
    if ($msg_error_Link_Break == '') {
        array_push($page['infos'], l10n('Audit_Link_Break') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_Link_Break = l10n('Audit_Link_Break') . $msg_error_Link_Break;
    }
    // Check not fixable broken links between Piwigo and FluxBB users
    // --------------------------------------------------------------
    $query = '
SELECT pwg.username as pwg_user, pwg.id as pwg_id, pwg.mail_address as pwg_mail, bb.id as bb_id, bb.username as bb_user, bb.email as bb_mail
FROM ' . FluxBB_USERS_TABLE . ' AS bb 
INNER JOIN ' . Register_FluxBB_ID_TABLE . ' AS link ON link.id_user_FluxBB = bb.id
INNER JOIN ' . USERS_TABLE . ' as pwg ON link.id_user_pwg = pwg.id
WHERE pwg.username <> bb.username
AND pwg.username NOT IN ("18","16")
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_Link_Bad .= '<br>' . l10n('Error_Link_Del') . stripslashes($row['pwg_user']) . ' (' . $row['pwg_mail'] . ')' . ' -- ' . stripslashes($row['bb_user']) . ' (' . $row['bb_mail'] . ')';
        // Action : Delete obsolete links
        $msg_error_Link_Bad .= ' <a href="';
        $msg_error_Link_Bad .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'link_del', 'pwg_id' => $row['pwg_id'], 'bb_id' => $row['bb_id']));
        $msg_error_Link_Bad .= '" title="' . l10n('Link_Del') . stripslashes($row['pwg_user']) . ' -- ' . stripslashes($row['bb_user']) . '"';
        $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_Link_Bad .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/link_delete.png" alt="' . l10n('Link_Del') . stripslashes($row['pwg_user']) . ' -- ' . stripslashes($row['bb_user']) . '" /></a>';
        // Action : Synch users data
        $msg_error_Link_Bad .= ' -- <a href="';
        $msg_error_Link_Bad .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'sync_user', 'username' => stripslashes($row['pwg_user'])));
        $msg_error_Link_Bad .= '" title="' . l10n('Sync_User') . stripslashes($row['pwg_user']) . ' --> ' . stripslashes($row['bb_user']) . '"';
        $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_Link_Bad .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/arrow_switch.png" alt="' . l10n('Sync_User') . stripslashes($row['pwg_user']) . ' --> ' . stripslashes($row['bb_user']) . '" /></a>';
    }
    // Check dead links between Piwigo and FluxBB users
    // ------------------------------------------------
    $query = '
SELECT COUNT(*) as nbr_dead
FROM ' . Register_FluxBB_ID_TABLE . ' AS Link
WHERE id_user_FluxBB NOT IN (
  SELECT id
  FROM ' . FluxBB_USERS_TABLE . '
  )
OR id_user_pwg NOT IN (
  SELECT id
  FROM ' . USERS_TABLE . '
  )
;';
    $Compteur = pwg_db_fetch_assoc(pwg_query($query));
    if (!empty($Compteur) and $Compteur['nbr_dead'] > 0) {
        $msg_error_Link_Bad .= '<br>' . l10n('Error_Link_Dead') . $Compteur['nbr_dead'];
        // Action : Repair dead links
        $msg_error_Link_Bad .= ' <a href="';
        $msg_error_Link_Bad .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'link_dead'));
        $msg_error_Link_Bad .= '" title="' . l10n('Link_Dead') . $Compteur['nbr_dead'] . '"';
        $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_Link_Bad .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/link_delete.png" alt="' . l10n('Link_Dead') . $Compteur['nbr_dead'] . '" /></a>';
    }
    // Check duplicated links between Piwigo and FluxBB users
    // ------------------------------------------------------
    $query = '
SELECT COUNT(*) AS nbr_dup, pwg.id AS pwg_id, pwg.username AS pwg_user, bb.username AS bb_user, bb.id AS bb_id
FROM ' . FluxBB_USERS_TABLE . ' AS bb 
INNER JOIN ' . Register_FluxBB_ID_TABLE . ' AS link ON link.id_user_FluxBB = bb.id
INNER JOIN ' . USERS_TABLE . ' as pwg ON link.id_user_pwg = pwg.id
WHERE pwg.username NOT IN ("18","16")
GROUP BY link.id_user_pwg, link.id_user_FluxBB
HAVING COUNT(*) > 1
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_Link_Bad .= '<br>' . l10n('Error_Link_Dup') . $row['nbr_dup'] . ' = ' . stripslashes($row['pwg_user']) . ' -- ' . stripslashes($row['bb_user']) . ')';
        // Action : Repair links
        $msg_error_Link_Bad .= ' <a href="';
        $msg_error_Link_Bad .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'new_link', 'pwg_id' => $row['pwg_id'], 'bb_id' => $row['bb_id']));
        $msg_error_Link_Bad .= '" title="' . l10n('Link_Dup') . stripslashes($row['pwg_user']) . ' -- ' . stripslashes($row['bb_user']) . '"';
        $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_Link_Bad .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/link_error.png" alt="' . l10n('Link_Dup') . stripslashes($row['pwg_user']) . ' -- ' . stripslashes($row['bb_user']) . '" /></a>';
    }
    // Display OK message or build errors
    if ($msg_error_Link_Bad == '') {
        array_push($page['infos'], l10n('Audit_Link_Bad') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_Link_Bad = l10n('Audit_Link_Bad') . $msg_error_Link_Bad;
    }
    // Check synch between Piwigo and FluxBB users
    // -------------------------------------------
    $query = '
SELECT pwg.id as pwg_id, pwg.username as username, pwg.mail_address as pwg_eml, FluxBB.email as bb_eml
FROM ' . FluxBB_USERS_TABLE . ' AS FluxBB 
INNER JOIN ' . Register_FluxBB_ID_TABLE . ' AS link ON link.id_user_FluxBB = FluxBB.id
INNER JOIN ' . USERS_TABLE . ' as pwg ON link.id_user_pwg = pwg.id
WHERE BINARY pwg.username = BINARY FluxBB.username
AND pwg.username NOT IN ("18","16")
ORDER BY LOWER(pwg.username)
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        if ($row['pwg_eml'] != $row['bb_eml'] or Reg_FluxBB_PwdSynch($row['pwg_id'])) {
            if ($row['pwg_eml'] != $row['bb_eml'] and Reg_FluxBB_PwdSynch($row['pwg_id'])) {
                $msg_error_Synchro .= '<br>' . l10n('Error_Synchro') . stripslashes($row['username']);
                // Action : Synch users data from Piwigo to FluxBB
                $msg_error_Synchro .= ' <a href="';
                $msg_error_Synchro .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'sync_user', 'username' => stripslashes($row['username'])));
                $msg_error_Synchro .= '" title="' . l10n('Sync_User') . stripslashes($row['username']) . '"';
                $msg_error_Synchro .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
                $msg_error_Synchro .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/user_refresh.png" alt="' . l10n('Sync_User') . stripslashes($row['username']) . '" /></a>';
                $msg_error_Synchro .= '<br>' . l10n('Error_Synchro_Mail') . '<br>-- PWG = ' . $row['pwg_eml'] . '<br>-- FluxBB = ' . $row['bb_eml'];
                $msg_error_Synchro .= '<br>' . l10n('Error_Synchro_Pswd');
            } elseif ($row['pwg_eml'] != $row['bb_eml'] and !Reg_FluxBB_PwdSynch($row['pwg_id'])) {
                $msg_error_Synchro .= '<br>' . l10n('Error_Synchro') . stripslashes($row['username']);
                // Action : Synch users data from Piwigo to FluxBB
                $msg_error_Synchro .= ' <a href="';
                $msg_error_Synchro .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'sync_user', 'username' => stripslashes($row['username'])));
                $msg_error_Synchro .= '" title="' . l10n('Sync_User') . stripslashes($row['username']) . '"';
                $msg_error_Synchro .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
                $msg_error_Synchro .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/user_refresh.png" alt="' . l10n('Sync_User') . stripslashes($row['username']) . '" /></a>';
                $msg_error_Synchro .= '<br>' . l10n('Error_Synchro_Mail') . '<br>-- PWG = ' . $row['pwg_eml'] . '<br>-- FluxBB = ' . $row['bb_eml'];
            } elseif ($row['pwg_eml'] = $row['bb_eml'] and Reg_FluxBB_PwdSynch($row['pwg_id'])) {
                $msg_error_Synchro .= '<br>' . l10n('Error_Synchro') . stripslashes($row['username']);
                $msg_error_Synchro .= '<br>' . l10n('Error_Synchro_Pswd');
            }
        } else {
            if ($conf_Register_FluxBB['FLUXBB_DETAIL'] == 'true') {
                $msg_ok_Synchro .= '<br> - ' . stripslashes($row['username']) . ' (' . $row['pwg_eml'] . ')' . l10n('Audit_Synchro_OK');
            }
        }
    }
    // Display OK message or build errors
    if ($msg_error_Synchro != '') {
        $msg_error_Synchro = l10n('Audit_Synchro') . $msg_error_Synchro;
    }
    if ($msg_ok_Synchro != '') {
        if ($msg_error_Synchro != '') {
            array_push($page['infos'], l10n('Audit_Synchro') . $msg_ok_Synchro . '<br><br>');
        } else {
            array_push($page['infos'], l10n('Audit_Synchro') . $msg_ok_Synchro . '<br><br>' . l10n('Audit_OK'));
        }
    }
    // Check Piwigo accounts not in FluxBB
    // -----------------------------------
    $query = '
SELECT username, mail_address FROM ' . USERS_TABLE . '
WHERE BINARY username <> BINARY "guest"
AND username NOT IN ("18","16")
AND id not in (
  SELECT id_user_pwg FROM ' . Register_FluxBB_ID_TABLE . '
  )
AND BINARY username not in (
  SELECT username FROM ' . FluxBB_USERS_TABLE . '
  )
ORDER BY LOWER(username)
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_PWG2FluxBB .= '<br>' . l10n('Error_PWG2FluxBB') . stripslashes($row['username']) . ' (' . $row['mail_address'] . ')';
        // Action : Add user to FluxBB
        $msg_error_PWG2FluxBB .= ' <a href="';
        $msg_error_PWG2FluxBB .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'add_user', 'username' => stripslashes($row['username'])));
        $msg_error_PWG2FluxBB .= '" title="' . l10n('Add_User') . stripslashes($row['username']) . '" ';
        $msg_error_PWG2FluxBB .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_PWG2FluxBB .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/user_add.png" alt="' . l10n('Add_User') . stripslashes($row['username']) . '" /></a>';
    }
    // Display OK message or build errors
    if ($msg_error_PWG2FluxBB == '') {
        array_push($page['infos'], l10n('Audit_PWG2FluxBB') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_PWG2FluxBB = l10n('Audit_PWG2FluxBB') . $msg_error_PWG2FluxBB;
    }
    // Check FluxBB accounts not in Piwigo
    // -----------------------------------
    $query = '
SELECT id, username, email FROM ' . FluxBB_USERS_TABLE . '
WHERE BINARY username <> BINARY "' . $conf_Register_FluxBB['FLUXBB_GUEST'] . '"
AND id not in (
  SELECT id_user_FluxBB FROM ' . Register_FluxBB_ID_TABLE . '
  )
AND BINARY username not in (
  SELECT username FROM ' . USERS_TABLE . '
  )
ORDER BY LOWER(username)
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_FluxBB2PWG .= '<br>' . l10n('Error_FluxBB2PWG') . stripslashes($row['username']) . ' (' . $row['email'] . ')';
        // Action : Delete user from FluxBB
        $msg_error_FluxBB2PWG .= ' <a href="';
        $msg_error_FluxBB2PWG .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'del_user', 'id' => $row['id']));
        $msg_error_FluxBB2PWG .= '" title="' . l10n('Del_User') . stripslashes($row['username']) . '"';
        $msg_error_FluxBB2PWG .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_FluxBB2PWG .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/user_delete.png" alt="' . l10n('Del_User') . stripslashes($row['username']) . '" /></a>';
        // Action : Add user from FluxBB to Piwigo
        $msg_error_FluxBB2PWG .= ' <a href="';
        $msg_error_FluxBB2PWG .= add_url_params(REGFLUXBB_ADMIN, array('action' => 'add2pwg', 'id' => $row['id'], 'username' => $row['username'], 'email' => $row['email']));
        $msg_error_FluxBB2PWG .= '" title="' . l10n('Add_User2pwg') . stripslashes($row['username']) . '"';
        $msg_error_FluxBB2PWG .= $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_FluxBB2PWG .= '><img src="' . REGFLUXBB_PATH . '/admin/template/icon/user_add.png" alt="' . l10n('Add_User2pwg') . stripslashes($row['username']) . '" /></a>';
    }
    // Display OK message or build errors
    if ($msg_error_FluxBB2PWG == '') {
        array_push($page['infos'], l10n('Audit_FluxBB2PWG') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_FluxBB2PWG = l10n('Audit_FluxBB2PWG') . $msg_error_FluxBB2PWG;
    }
    if ($msg_error_PWG_Dup != '') {
        $errors[] = $msg_error_PWG_Dup . (($msg_error_FluxBB_Dup == '' and $msg_error_Link_Break == '' and $msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>');
    }
    if ($msg_error_FluxBB_Dup != '') {
        $errors[] = $msg_error_FluxBB_Dup . (($msg_error_Link_Break == '' and $msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>');
    }
    if ($msg_error_Link_Break != '') {
        $errors[] = $msg_error_Link_Break . (($msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>');
    }
    if ($msg_error_Link_Bad != '') {
        $errors[] = $msg_error_Link_Bad . (($msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>');
    }
    if ($msg_error_Synchro != '') {
        $errors[] = $msg_error_Synchro . (($msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>');
    }
    if ($msg_error_PWG2FluxBB != '') {
        $errors[] = $msg_error_PWG2FluxBB . ($msg_error_FluxBB2PWG == '' ? '' : '<br><br>');
    }
    if ($msg_error_FluxBB2PWG != '') {
        $errors[] = $msg_error_FluxBB2PWG;
    }
    if (isset($errors) and count($errors) != 0) {
        foreach ($errors as $error) {
            array_push($page['errors'], $error);
        }
    }
}
Ejemplo n.º 16
0
  WHERE user_id = ' . $user['id'] . '
;';
                    pwg_query($query);
                    redirect(make_index_url(array('section' => 'favorites')));
                } else {
                    $query = '
SELECT image_id
  FROM ' . FAVORITES_TABLE . '
    INNER JOIN ' . IMAGES_TABLE . ' ON image_id = id
  WHERE user_id = ' . $user['id'] . '
' . get_sql_condition_FandF(array('visible_images' => 'id'), 'AND') . '
  ' . $conf['order_by'] . '
;';
                    $page = array_merge($page, array('items' => query2array($query, null, 'image_id')));
                    if (count($page['items']) > 0) {
                        $template->assign('favorite', array('U_FAVORITE' => add_url_params(make_index_url(array('section' => 'favorites')), array('action' => 'remove_all_from_favorites'))));
                    }
                }
            } else {
                if ($page['section'] == 'recent_pics') {
                    if (!isset($page['super_order_by'])) {
                        $conf['order_by'] = str_replace('ORDER BY ', 'ORDER BY date_available DESC,', $conf['order_by']);
                    }
                    $query = '
SELECT DISTINCT(id)
  FROM ' . IMAGES_TABLE . '
    INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON id = ic.image_id
  WHERE ' . get_recent_photos_sql('date_available') . '
  ' . $forbidden . $conf['order_by'] . '
;';
                    $page = array_merge($page, array('title' => '<a href="' . duplicate_index_url(array('start' => 0)) . '">' . l10n('Recent photos') . '</a>', 'items' => query2array($query, null, 'id')));
Ejemplo n.º 17
0
function mobile_link()
{
    global $template, $conf;
    $config = unserialize($conf['smartpocket']);
    $template->assign('smartpocket', $config);
    if (!empty($conf['mobile_theme']) && (get_device() != 'desktop' || mobile_theme())) {
        $template->assign(array('TOGGLE_MOBILE_THEME_URL' => add_url_params(htmlspecialchars($_SERVER['REQUEST_URI']), array('mobile' => mobile_theme() ? 'false' : 'true'))));
    }
}
Ejemplo n.º 18
0
SELECT *
  FROM ' . IMAGES_TABLE . '
  WHERE id IN (' . implode(',', $selection) . ')
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $row['rank'] = $rank_of[$row['id']];
        $pictures[] = $row;
    }
    usort($pictures, 'rank_compare');
    unset($rank_of);
}
if (count($pictures) > 0) {
    // define category slideshow url
    $row = reset($pictures);
    $page['cat_slideshow_url'] = add_url_params(duplicate_picture_url(array('image_id' => $row['id'], 'image_file' => $row['file']), array('start')), array('slideshow' => isset($_GET['slideshow']) ? $_GET['slideshow'] : ''));
    if ($conf['activate_comments'] and $user['show_nb_comments']) {
        $query = '
SELECT image_id, COUNT(*) AS nb_comments
  FROM ' . COMMENTS_TABLE . '
  WHERE validated = \'true\'
    AND image_id IN (' . implode(',', $selection) . ')
  GROUP BY image_id
;';
        $nb_comments_of = query2array($query, 'image_id', 'nb_comments');
    }
}
// template thumbnail initialization
$template->set_filenames(array('index_thumbnails' => 'thumbnails.tpl'));
trigger_notify('loc_begin_index_thumbnails', $pictures);
$tpl_thumbnails_var = array();
Ejemplo n.º 19
0
    $url_admin = get_root_url() . 'admin.php?page=photo-' . $page['image_id'] . (isset($page['category']) ? '&amp;cat_id=' . $page['category']['id'] : '');
    $template->assign(array('U_CADDIE' => add_url_params($url_self, array('action' => 'add_to_caddie')), 'U_PHOTO_ADMIN' => $url_admin));
    $template->assign('available_permission_levels', get_privacy_level_options());
}
// favorite manipulation
if (!is_a_guest() and $conf['picture_favorite_icon']) {
    // verify if the picture is already in the favorite of the user
    $query = '
SELECT COUNT(*) AS nb_fav
  FROM ' . FAVORITES_TABLE . '
  WHERE image_id = ' . $page['image_id'] . '
    AND user_id = ' . $user['id'] . '
;';
    $row = pwg_db_fetch_assoc(pwg_query($query));
    $is_favorite = $row['nb_fav'] != 0;
    $template->assign('favorite', array('IS_FAVORITE' => $is_favorite, 'U_FAVORITE' => add_url_params($url_self, array('action' => !$is_favorite ? 'add_to_favorites' : 'remove_from_favorites'))));
}
//--------------------------------------------------------- picture information
// legend
if (isset($picture['current']['comment']) and !empty($picture['current']['comment'])) {
    $template->assign('COMMENT_IMG', trigger_change('render_element_description', $picture['current']['comment'], 'picture_page_element_description'));
}
// author
if (!empty($picture['current']['author'])) {
    $infos['INFO_AUTHOR'] = $picture['current']['author'];
}
// creation date
if (!empty($picture['current']['date_creation'])) {
    $val = format_date($picture['current']['date_creation']);
    $url = make_index_url(array('chronology_field' => 'created', 'chronology_style' => 'monthly', 'chronology_view' => 'list', 'chronology_date' => explode('-', substr($picture['current']['date_creation'], 0, 10))));
    $infos['INFO_CREATION_DATE'] = '<a href="' . $url . '" rel="nofollow">' . $val . '</a>';
Ejemplo n.º 20
0
function do_action_send_mail_notification($action = 'list_to_send', $check_key_list = array(), $customize_mail_content = '')
{
    global $conf, $page, $user, $lang_info, $lang, $env_nbm;
    $return_list = array();
    if (in_array($action, array('list_to_send', 'send'))) {
        list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
        $is_action_send = $action == 'send';
        // disabled and null mail_address are not selected in the list
        $data_users = get_user_notifications('send', $check_key_list);
        // List all if it's define on options or on timeout
        $is_list_all_without_test = ($env_nbm['is_sendmail_timeout'] or $conf['nbm_list_all_enabled_users_to_send']);
        // Check if exist news to list user or send mails
        if (!$is_list_all_without_test or $is_action_send) {
            if (count($data_users) > 0) {
                $datas = array();
                if (!isset($customize_mail_content)) {
                    $customize_mail_content = $conf['nbm_complementary_mail_content'];
                }
                $customize_mail_content = trigger_change('nbm_render_global_customize_mail_content', $customize_mail_content);
                // Prepare message after change language
                if ($is_action_send) {
                    $msg_break_timeout = l10n('Time to send mail is limited. Others mails are skipped.');
                } else {
                    $msg_break_timeout = l10n('Prepared time for list of users to send mail is limited. Others users are not listed.');
                }
                // Begin nbm users environment
                begin_users_env_nbm($is_action_send);
                foreach ($data_users as $nbm_user) {
                    if (!$is_action_send and check_sendmail_timeout()) {
                        // Stop fill list on 'list_to_send', if the quota is override
                        $page['infos'][] = $msg_break_timeout;
                        break;
                    }
                    if ($is_action_send and check_sendmail_timeout()) {
                        // Stop fill list on 'send', if the quota is override
                        $page['errors'][] = $msg_break_timeout;
                        break;
                    }
                    // set env nbm user
                    set_user_on_env_nbm($nbm_user, $is_action_send);
                    if ($is_action_send) {
                        $auth = null;
                        $add_url_params = array();
                        $auth_key = create_user_auth_key($nbm_user['user_id'], $nbm_user['status']);
                        if ($auth_key !== false) {
                            $auth = $auth_key['auth_key'];
                            $add_url_params['auth'] = $auth;
                        }
                        set_make_full_url();
                        // Fill return list of "treated" check_key for 'send'
                        $return_list[] = $nbm_user['check_key'];
                        if ($conf['nbm_send_detailed_content']) {
                            $news = news($nbm_user['last_send'], $dbnow, false, $conf['nbm_send_html_mail'], $auth);
                            $exist_data = count($news) > 0;
                        } else {
                            $exist_data = news_exists($nbm_user['last_send'], $dbnow);
                        }
                        if ($exist_data) {
                            $subject = '[' . $conf['gallery_title'] . '] ' . l10n('New photos added');
                            // Assign current var for nbm mail
                            assign_vars_nbm_mail_content($nbm_user);
                            if (!is_null($nbm_user['last_send'])) {
                                $env_nbm['mail_template']->assign('content_new_elements_between', array('DATE_BETWEEN_1' => $nbm_user['last_send'], 'DATE_BETWEEN_2' => $dbnow));
                            } else {
                                $env_nbm['mail_template']->assign('content_new_elements_single', array('DATE_SINGLE' => $dbnow));
                            }
                            if ($conf['nbm_send_detailed_content']) {
                                $env_nbm['mail_template']->assign('global_new_lines', $news);
                            }
                            $nbm_user_customize_mail_content = trigger_change('nbm_render_user_customize_mail_content', $customize_mail_content, $nbm_user);
                            if (!empty($nbm_user_customize_mail_content)) {
                                $env_nbm['mail_template']->assign('custom_mail_content', $nbm_user_customize_mail_content);
                            }
                            if ($conf['nbm_send_html_mail'] and $conf['nbm_send_recent_post_dates']) {
                                $recent_post_dates = get_recent_post_dates_array($conf['recent_post_dates']['NBM']);
                                foreach ($recent_post_dates as $date_detail) {
                                    $env_nbm['mail_template']->append('recent_posts', array('TITLE' => get_title_recent_post_date($date_detail), 'HTML_DATA' => get_html_description_recent_post_date($date_detail, $auth)));
                                }
                            }
                            $env_nbm['mail_template']->assign(array('GOTO_GALLERY_TITLE' => $conf['gallery_title'], 'GOTO_GALLERY_URL' => add_url_params(get_gallery_home_url(), $add_url_params), 'SEND_AS_NAME' => $env_nbm['send_as_name']));
                            $ret = pwg_mail(array('name' => stripslashes($nbm_user['username']), 'email' => $nbm_user['mail_address']), array('from' => $env_nbm['send_as_mail_formated'], 'subject' => $subject, 'email_format' => $env_nbm['email_format'], 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true), 'content_format' => $env_nbm['email_format'], 'auth_key' => $auth));
                            if ($ret) {
                                inc_mail_sent_success($nbm_user);
                                $datas[] = array('user_id' => $nbm_user['user_id'], 'last_send' => $dbnow);
                            } else {
                                inc_mail_sent_failed($nbm_user);
                            }
                            unset_make_full_url();
                        }
                    } else {
                        if (news_exists($nbm_user['last_send'], $dbnow)) {
                            // Fill return list of "selected" users for 'list_to_send'
                            $return_list[] = $nbm_user;
                        }
                    }
                    // unset env nbm user
                    unset_user_on_env_nbm();
                }
                // Restore nbm environment
                end_users_env_nbm();
                if ($is_action_send) {
                    mass_updates(USER_MAIL_NOTIFICATION_TABLE, array('primary' => array('user_id'), 'update' => array('last_send')), $datas);
                    display_counter_info();
                }
            } else {
                if ($is_action_send) {
                    $page['errors'][] = l10n('No user to send notifications by mail.');
                }
            }
        } else {
            // Quick List, don't check news
            // Fill return list of "selected" users for 'list_to_send'
            $return_list = $data_users;
        }
    }
    // Return list of "selected" users for 'list_to_send'
    // Return list of "treated" check_key for 'send'
    return $return_list;
}
Ejemplo n.º 21
0
/**
 * Generates breadcrumb from categories list using a cache.
 * @see get_cat_display_name()
 *
 * @param string $uppercats
 * @param string|null $url
 * @param bool $single_link
 * @param string|null $link_class
 * @return string
 */
function get_cat_display_name_cache($uppercats, $url = '', $single_link = false, $link_class = null, $auth_key = null)
{
    global $cache, $conf;
    $add_url_params = array();
    if (isset($auth_key)) {
        $add_url_params['auth'] = $auth_key;
    }
    if (!isset($cache['cat_names'])) {
        $query = '
SELECT id, name, permalink
  FROM ' . CATEGORIES_TABLE . '
;';
        $cache['cat_names'] = query2array($query, 'id');
    }
    $output = '';
    if ($single_link) {
        $single_url = add_url_params(get_root_url() . $url . array_pop(explode(',', $uppercats)), $add_url_params);
        $output .= '<a href="' . $single_url . '"';
        if (isset($link_class)) {
            $output .= ' class="' . $link_class . '"';
        }
        $output .= '>';
    }
    $is_first = true;
    foreach (explode(',', $uppercats) as $category_id) {
        $cat = $cache['cat_names'][$category_id];
        $cat['name'] = trigger_change('render_category_name', $cat['name'], 'get_cat_display_name_cache');
        if ($is_first) {
            $is_first = false;
        } else {
            $output .= $conf['level_separator'];
        }
        if (!isset($url) or $single_link) {
            $output .= $cat['name'];
        } elseif ($url == '') {
            $output .= '
<a href="' . add_url_params(make_index_url(array('category' => $cat)), $add_url_params) . '">' . $cat['name'] . '</a>';
        } else {
            $output .= '
<a href="' . PHPWG_ROOT_PATH . $url . $category_id . '">' . $cat['name'] . '</a>';
        }
    }
    if ($single_link and isset($single_url)) {
        $output .= '</a>';
    }
    return $output;
}
Ejemplo n.º 22
0
/**
 * Returns html description about recently published elements grouped by post date.
 * @todo clean up HTML output, currently messy and invalid !
 *
 * @param array $date_detail returned value of get_recent_post_dates()
 * @return string
 */
function get_html_description_recent_post_date($date_detail, $auth_key = null)
{
    global $conf;
    $add_url_params = array();
    if (isset($auth_key)) {
        $add_url_params['auth'] = $auth_key;
    }
    $description = '<ul>';
    $description .= '<li>' . l10n_dec('%d new photo', '%d new photos', $date_detail['nb_elements']) . ' (' . '<a href="' . add_url_params(make_index_url(array('section' => 'recent_pics')), $add_url_params) . '">' . l10n('Recent photos') . '</a>' . ')' . '</li><br>';
    foreach ($date_detail['elements'] as $element) {
        $tn_src = DerivativeImage::thumb_url($element);
        $description .= '<a href="' . add_url_params(make_picture_url(array('image_id' => $element['id'], 'image_file' => $element['file'])), $add_url_params) . '"><img src="' . $tn_src . '"></a>';
    }
    $description .= '...<br>';
    $description .= '<li>' . l10n_dec('%d album updated', '%d albums updated', $date_detail['nb_cats']) . '</li>';
    $description .= '<ul>';
    foreach ($date_detail['categories'] as $cat) {
        $description .= '<li>' . get_cat_display_name_cache($cat['uppercats'], '', false, null, $auth_key) . ' (' . l10n_dec('%d new photo', '%d new photos', $cat['img_count']) . ')' . '</li>';
    }
    $description .= '</ul>';
    $description .= '</ul>';
    return $description;
}
Ejemplo n.º 23
0
$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();
Ejemplo n.º 24
0
function Audit_PWG_PhpBB()
{
    global $page, $conf, $errors;
    $conf_Register_PhpBB = isset($conf['Register_PhpBB']) ? explode(";", $conf['Register_PhpBB']) : array();
    $page_Register_PhpBB_admin = get_admin_plugin_menu_link(__FILE__);
    $msg_error_PWG_Dup = '';
    $msg_error_PhpBB_Dup = '';
    $msg_error_Link_Break = '';
    $msg_error_Link_Bad = '';
    $msg_error_Synchro = '';
    $msg_ok_Synchro = '';
    $msg_error_PWG2PhpBB = '';
    $msg_error_PhpBB2PWG = '';
    $query = "\nSELECT COUNT(*) AS nbr_dup, id, username\nFROM " . USERS_TABLE . "\nGROUP BY BINARY username\nHAVING COUNT(*) > 1\n;";
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_PWG_Dup .= '<br>' . l10n('Error_PWG_Dup') . $row['nbr_dup'] . ' x ' . stripslashes($row['username']);
    }
    if ($msg_error_PWG_Dup == '') {
        array_push($page['infos'], l10n('Audit_PWG_Dup') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_PWG_Dup = l10n('Audit_PWG_Dup') . $msg_error_PWG_Dup . '<br>' . l10n('Advise_PWG_Dup');
    }
    $query = "\nSELECT COUNT(*) AS nbr_dup, username\nFROM " . PhpBB_USERS_TABLE . "\nGROUP BY BINARY username\nHAVING COUNT(*) > 1\n;";
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_PhpBB_Dup .= '<br>' . l10n('Error_PhpBB_Dup') . $row['nbr_dup'] . ' x ' . stripslashes($row['username']);
        $subquery = "\nSELECT user_id, username, user_email\nFROM " . PhpBB_USERS_TABLE . "\nWHERE BINARY username = BINARY '" . $row['username'] . "'\n;";
        $subresult = pwg_query($subquery);
        while ($subrow = pwg_db_fetch_assoc($subresult)) {
            $msg_error_PhpBB_Dup .= '<br>id:' . $subrow['user_id'] . '=' . stripslashes($subrow['username']) . ' (' . $subrow['user_email'] . ')';
            $msg_error_PhpBB_Dup .= ' <a href="';
            $msg_error_PhpBB_Dup .= add_url_params($page_Register_PhpBB_admin, array('action' => 'del_user', 'user_id' => $subrow['user_id']));
            $msg_error_PhpBB_Dup .= '" title="' . l10n('Del_User') . stripslashes($subrow['username']) . '"';
            $msg_error_PhpBB_Dup .= $conf_Register_PhpBB[3] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
            $msg_error_PhpBB_Dup .= '><img src="' . REGPHPBB_PATH . '/admin/template/icon/user_delete.png" alt="' . l10n('Del_User') . $subrow['username'] . '" /></a>';
        }
    }
    if ($msg_error_PhpBB_Dup == '') {
        array_push($page['infos'], l10n('Audit_PhpBB_Dup') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_PhpBB_Dup = l10n('Audit_PhpBB_Dup') . $msg_error_PhpBB_Dup . '<br>' . l10n('Advise_PhpBB_Dup');
    }
    $query = "\nSELECT pwg.id as pwg_id, bb.user_id as bb_id, pwg.username as pwg_user, pwg.mail_address as pwg_mail\nFROM " . PhpBB_USERS_TABLE . " AS bb, " . USERS_TABLE . " as pwg\nWHERE bb.user_id NOT in (\n  SELECT id_user_PhpBB\n  FROM " . Register_PhpBB_ID_TABLE . "\n  )\nAND pwg.id NOT in (\n  SELECT id_user_pwg\n  FROM " . Register_PhpBB_ID_TABLE . "\n  )\nAND pwg.username = bb.username\nAND pwg.mail_address = bb.user_email\n;";
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_Link_Break .= '<br>' . l10n('Error_Link_Break') . stripslashes($row['pwg_user']) . ' (' . $row['pwg_mail'] . ')';
        $msg_error_Link_Break .= ' <a href="';
        $msg_error_Link_Break .= add_url_params($page_Register_PhpBB_admin, array('action' => 'new_link', 'pwg_id' => $row['pwg_id'], 'bb_id' => $row['bb_id']));
        $msg_error_Link_Break .= '" title="' . l10n('New_Link') . stripslashes($row['pwg_user']) . '"';
        $msg_error_Link_Break .= $conf_Register_PhpBB[3] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_Link_Break .= '><img src="' . REGPHPBB_PATH . '/admin/template/icon/link_break.png" alt="' . l10n('New_Link') . stripslashes($row['pwg_user']) . '" /></a>';
    }
    if ($msg_error_Link_Break == '') {
        array_push($page['infos'], l10n('Audit_Link_Break') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_Link_Break = l10n('Audit_Link_Break') . $msg_error_Link_Break;
    }
    $query = "\nSELECT pwg.username as pwg_user, pwg.id as pwg_id, pwg.mail_address as pwg_mail, bb.user_id as bb_id, bb.username as bb_user, bb.user_email as bb_mail\nFROM " . PhpBB_USERS_TABLE . " AS bb\nINNER JOIN " . Register_PhpBB_ID_TABLE . " AS link ON link.id_user_PhpBB = bb.user_id\nINNER JOIN " . USERS_TABLE . " as pwg ON link.id_user_pwg = pwg.id\nWHERE pwg.username <> bb.username\n;";
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_Link_Bad .= '<br>' . l10n('Error_Link_Del') . stripslashes($row['pwg_user']) . ' (' . $row['pwg_mail'] . ')' . ' -- ' . stripslashes($row['bb_user']) . ' (' . $row['bb_mail'] . ')';
        $msg_error_Link_Bad .= ' <a href="';
        $msg_error_Link_Bad .= add_url_params($page_Register_PhpBB_admin, array('action' => 'link_del', 'pwg_id' => $row['pwg_id'], 'bb_id' => $row['bb_id']));
        $msg_error_Link_Bad .= '" title="' . l10n('Link_Del') . stripslashes($row['pwg_user']) . ' -- ' . stripslashes($row['bb_user']) . '"';
        $msg_error_Link_Bad .= $conf_Register_PhpBB[3] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_Link_Bad .= '><img src="' . REGPHPBB_PATH . '/admin/template/icon/link_delete.png" alt="' . l10n('Link_Del') . stripslashes($row['pwg_user']) . ' -- ' . stripslashes($row['bb_user']) . '" /></a>';
        $msg_error_Link_Bad .= ' -- <a href="';
        $msg_error_Link_Bad .= add_url_params($page_Register_PhpBB_admin, array('action' => 'sync_user', 'username' => stripslashes($row['pwg_user'])));
        $msg_error_Link_Bad .= '" title="' . l10n('Sync_User') . stripslashes($row['pwg_user']) . ' --> ' . stripslashes($row['bb_user']) . '"';
        $msg_error_Link_Bad .= $conf_Register_PhpBB[3] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_Link_Bad .= '><img src="' . REGPHPBB_PATH . '/admin/template/icon/arrow_switch.png" alt="' . l10n('Sync_User') . stripslashes($row['pwg_user']) . ' --> ' . stripslashes($row['bb_user']) . '" /></a>';
    }
    $query = "\nSELECT COUNT(*) as nbr_dead\nFROM " . Register_PhpBB_ID_TABLE . " AS Link\nWHERE id_user_PhpBB NOT IN (\n  SELECT user_id\n  FROM " . PhpBB_USERS_TABLE . "\n  )\nOR id_user_pwg NOT IN (\n  SELECT id\n  FROM " . USERS_TABLE . "\n  )\n;";
    $Compteur = pwg_db_fetch_assoc(pwg_query($query));
    if (!empty($Compteur) and $Compteur['nbr_dead'] > 0) {
        $msg_error_Link_Bad .= '<br>' . l10n('Error_Link_Dead') . $Compteur['nbr_dead'];
        $msg_error_Link_Bad .= ' <a href="';
        $msg_error_Link_Bad .= add_url_params($page_Register_PhpBB_admin, array('action' => 'link_dead'));
        $msg_error_Link_Bad .= '" title="' . l10n('Link_Dead') . $Compteur['nbr_dead'] . '"';
        $msg_error_Link_Bad .= $conf_Register_PhpBB[3] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_Link_Bad .= '><img src="' . REGPHPBB_PATH . '/admin/template/icon/link_delete.png" alt="' . l10n('Link_Dead') . $Compteur['nbr_dead'] . '" /></a>';
    }
    $query = "\nSELECT COUNT(*) AS nbr_dup, pwg.id AS pwg_id, pwg.username AS pwg_user, bb.username AS bb_user, bb.user_id AS bb_id\nFROM " . PhpBB_USERS_TABLE . " AS bb\nINNER JOIN " . Register_PhpBB_ID_TABLE . " AS link ON link.id_user_PhpBB = bb.user_id\nINNER JOIN " . USERS_TABLE . " as pwg ON link.id_user_pwg = pwg.id\nGROUP BY link.id_user_pwg, link.id_user_PhpBB\nHAVING COUNT(*) > 1\n;";
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_Link_Bad .= '<br>' . l10n('Error_Link_Dup') . $row['nbr_dup'] . ' = ' . stripslashes($row['pwg_user']) . ' -- ' . stripslashes($row['bb_user']) . ')';
        $msg_error_Link_Bad .= ' <a href="';
        $msg_error_Link_Bad .= add_url_params($page_Register_PhpBB_admin, array('action' => 'new_link', 'pwg_id' => $row['pwg_id'], 'bb_id' => $row['bb_id']));
        $msg_error_Link_Bad .= '" title="' . l10n('Link_Dup') . stripslashes($row['pwg_user']) . ' -- ' . stripslashes($row['bb_user']) . '"';
        $msg_error_Link_Bad .= $conf_Register_PhpBB[3] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_Link_Bad .= '><img src="' . REGPHPBB_PATH . '/admin/template/icon/link_error.png" alt="' . l10n('Link_Dup') . stripslashes($row['pwg_user']) . ' -- ' . stripslashes($row['bb_user']) . '" /></a>';
    }
    if ($msg_error_Link_Bad == '') {
        array_push($page['infos'], l10n('Audit_Link_Bad') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_Link_Bad = l10n('Audit_Link_Bad') . $msg_error_Link_Bad;
    }
    $query = "\nSELECT pwg.username as username, pwg.password as pwg_pwd, pwg.mail_address as pwg_eml, PhpBB.user_password as bb_pwd, PhpBB.user_email as bb_eml\nFROM " . PhpBB_USERS_TABLE . " AS PhpBB\nINNER JOIN " . Register_PhpBB_ID_TABLE . " AS link ON link.id_user_PhpBB = PhpBB.user_id\nINNER JOIN " . USERS_TABLE . " as pwg ON link.id_user_pwg = pwg.id\nAND BINARY pwg.username = BINARY PhpBB.username\nORDER BY LOWER(pwg.username)\n;";
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        if ($row['pwg_pwd'] != $row['bb_pwd'] or $row['pwg_eml'] != $row['bb_eml']) {
            $msg_error_Synchro .= '<br>' . l10n('Error_Synchro') . stripslashes($row['username']);
            $msg_error_Synchro .= ' <a href="';
            $msg_error_Synchro .= add_url_params($page_Register_PhpBB_admin, array('action' => 'sync_user', 'username' => stripslashes($row['username'])));
            $msg_error_Synchro .= '" title="' . l10n('Sync_User') . stripslashes($row['username']) . '"';
            $msg_error_Synchro .= $conf_Register_PhpBB[3] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
            $msg_error_Synchro .= '><img src="' . REGPHPBB_PATH . '/admin/template/icon/user_refresh.png" alt="' . l10n('Sync_User') . stripslashes($row['username']) . '" /></a>';
            if ($row['pwg_pwd'] != $row['bb_pwd']) {
                $msg_error_Synchro .= '<br>' . l10n('Error_Synchro_Pswd');
            }
            if ($row['pwg_eml'] != $row['bb_eml']) {
                $msg_error_Synchro .= '<br>' . l10n('Error_Synchro_Mail') . '<br>-- PWG = ' . $row['pwg_eml'] . '<br>-- PhpBB = ' . $row['bb_eml'];
            }
        } else {
            if ($conf_Register_PhpBB[4] == 'true') {
                $msg_ok_Synchro .= '<br> - ' . stripslashes($row['username']) . ' (' . $row['pwg_eml'] . ')' . l10n('Audit_Synchro_OK');
            }
        }
    }
    if ($msg_error_Synchro != '') {
        $msg_error_Synchro = l10n('Audit_Synchro') . $msg_error_Synchro;
    }
    if ($msg_ok_Synchro != '') {
        if ($msg_error_Synchro != '') {
            array_push($page['infos'], l10n('Audit_Synchro') . $msg_ok_Synchro . '<br><br>');
        } else {
            array_push($page['infos'], l10n('Audit_Synchro') . $msg_ok_Synchro . '<br><br>' . l10n('Audit_OK'));
        }
    }
    $query = "\nSELECT username, mail_address FROM " . USERS_TABLE . "\nWHERE BINARY username <> BINARY 'guest'\nAND id not in (\n  SELECT id_user_pwg FROM " . Register_PhpBB_ID_TABLE . "\n  )\nAND BINARY username not in (\n  SELECT username FROM " . PhpBB_USERS_TABLE . "\n  )\nORDER BY LOWER(username)\n;";
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_PWG2PhpBB .= '<br>' . l10n('Error_PWG2PhpBB') . stripslashes($row['username']) . ' (' . $row['mail_address'] . ')';
        $msg_error_PWG2PhpBB .= ' <a href="';
        $msg_error_PWG2PhpBB .= add_url_params($page_Register_PhpBB_admin, array('action' => 'add_user', 'username' => stripslashes($row['username'])));
        $msg_error_PWG2PhpBB .= '" title="' . l10n('Add_User') . stripslashes($row['username']) . '" ';
        $msg_error_PWG2PhpBB .= $conf_Register_PhpBB[3] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_PWG2PhpBB .= '><img src="' . REGPHPBB_PATH . '/admin/template/icon/user_add.png" alt="' . l10n('Add_User') . stripslashes($row['username']) . '" /></a>';
    }
    if ($msg_error_PWG2PhpBB == '') {
        array_push($page['infos'], l10n('Audit_PWG2PhpBB') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_PWG2PhpBB = l10n('Audit_PWG2PhpBB') . $msg_error_PWG2PhpBB;
    }
    $query = "\nSELECT user_id, username, user_email FROM " . PhpBB_USERS_TABLE . "\nWHERE BINARY username <> BINARY '" . $conf_Register_PhpBB[2] . "'\nAND user_id not in (\n  SELECT id_user_PhpBB FROM " . Register_PhpBB_ID_TABLE . "\n  )\nAND BINARY username not in (\n  SELECT username FROM " . USERS_TABLE . "\n  )\nORDER BY LOWER(username)\n;";
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $msg_error_PhpBB2PWG .= '<br>' . l10n('Error_PhpBB2PWG') . stripslashes($row['username']) . ' (' . $row['user_email'] . ')';
        $msg_error_PhpBB2PWG .= ' <a href="';
        $msg_error_PhpBB2PWG .= add_url_params($page_Register_PhpBB_admin, array('action' => 'del_user', 'user_id' => $row['user_id']));
        $msg_error_PhpBB2PWG .= '" title="' . l10n('Del_User') . stripslashes($row['username']) . '"';
        $msg_error_PhpBB2PWG .= $conf_Register_PhpBB[3] == 'false' ? ' onclick="return confirm(\'' . l10n('Are you sure?') . '\');" ' : ' ';
        $msg_error_PhpBB2PWG .= '><img src="' . REGPHPBB_PATH . '/admin/template/icon/user_delete.png" alt="' . l10n('Del_User') . stripslashes($row['username']) . '" /></a>';
    }
    if ($msg_error_PhpBB2PWG == '') {
        array_push($page['infos'], l10n('Audit_PhpBB2PWG') . '<br>' . l10n('Audit_OK'));
    } else {
        $msg_error_PhpBB2PWG = l10n('Audit_PhpBB2PWG') . $msg_error_PhpBB2PWG;
    }
    if ($msg_error_PWG_Dup != '') {
        $errors[] = $msg_error_PWG_Dup . (($msg_error_PhpBB_Dup == '' and $msg_error_Link_Break == '' and $msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2PhpBB == '' and $msg_error_PhpBB2PWG == '') ? '' : '<br><br>');
    }
    if ($msg_error_PhpBB_Dup != '') {
        $errors[] = $msg_error_PhpBB_Dup . (($msg_error_Link_Break == '' and $msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2PhpBB == '' and $msg_error_PhpBB2PWG == '') ? '' : '<br><br>');
    }
    if ($msg_error_Link_Break != '') {
        $errors[] = $msg_error_Link_Break . (($msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2PhpBB == '' and $msg_error_PhpBB2PWG == '') ? '' : '<br><br>');
    }
    if ($msg_error_Link_Bad != '') {
        $errors[] = $msg_error_Link_Bad . (($msg_error_Synchro == '' and $msg_error_PWG2PhpBB == '' and $msg_error_PhpBB2PWG == '') ? '' : '<br><br>');
    }
    if ($msg_error_Synchro != '') {
        $errors[] = $msg_error_Synchro . (($msg_error_PWG2PhpBB == '' and $msg_error_PhpBB2PWG == '') ? '' : '<br><br>');
    }
    if ($msg_error_PWG2PhpBB != '') {
        $errors[] = $msg_error_PWG2PhpBB . ($msg_error_PhpBB2PWG == '' ? '' : '<br><br>');
    }
    if ($msg_error_PhpBB2PWG != '') {
        $errors[] = $msg_error_PhpBB2PWG;
    }
}
Ejemplo n.º 25
0
/**
 * Setups each block the main menubar.
 */
function initialize_menu()
{
    global $page, $conf, $user, $template, $filter;
    $menu = new BlockManager("menubar");
    $menu->load_registered_blocks();
    $menu->prepare_display();
    if (@$page['section'] == 'search' and isset($page['qsearch_details'])) {
        $template->assign('QUERY_SEARCH', htmlspecialchars($page['qsearch_details']['q']));
    }
    //--------------------------------------------------------------- external links
    if ($block = $menu->get_block('mbLinks') and !empty($conf['links'])) {
        $block->data = array();
        foreach ($conf['links'] as $url => $url_data) {
            if (!is_array($url_data)) {
                $url_data = array('label' => $url_data);
            }
            if (!isset($url_data['eval_visible']) or eval($url_data['eval_visible'])) {
                $tpl_var = array('URL' => $url, 'LABEL' => $url_data['label']);
                if (!isset($url_data['new_window']) or $url_data['new_window']) {
                    $tpl_var['new_window'] = array('NAME' => isset($url_data['nw_name']) ? $url_data['nw_name'] : '', 'FEATURES' => isset($url_data['nw_features']) ? $url_data['nw_features'] : '');
                }
                $block->data[] = $tpl_var;
            }
        }
        if (!empty($block->data)) {
            $block->template = 'menubar_links.tpl';
        }
    }
    //-------------------------------------------------------------- categories
    $block = $menu->get_block('mbCategories');
    //------------------------------------------------------------------------ filter
    if ($conf['menubar_filter_icon'] and !empty($conf['filter_pages']) and get_filter_page_value('used')) {
        if ($filter['enabled']) {
            $template->assign('U_STOP_FILTER', add_url_params(make_index_url(array()), array('filter' => 'stop')));
        } else {
            $template->assign('U_START_FILTER', add_url_params(make_index_url(array()), array('filter' => 'start-recent-' . $user['recent_period'])));
        }
    }
    if ($block != null) {
        $block->data = array('NB_PICTURE' => $user['nb_total_images'], 'MENU_CATEGORIES' => get_categories_menu(), 'U_CATEGORIES' => make_index_url(array('section' => 'categories')));
        $block->template = 'menubar_categories.tpl';
    }
    //------------------------------------------------------------------------ tags
    $block = $menu->get_block('mbTags');
    if ($block != null and !empty($page['items']) and 'picture' != script_basename()) {
        if ('tags' == @$page['section']) {
            $tags = get_common_tags($page['items'], $conf['menubar_tag_cloud_items_number'], $page['tag_ids']);
            $tags = add_level_to_tags($tags);
            foreach ($tags as $tag) {
                $block->data[] = array_merge($tag, array('U_ADD' => make_index_url(array('tags' => array_merge($page['tags'], array($tag)))), 'URL' => make_index_url(array('tags' => array($tag)))));
            }
        } else {
            $selection = array_slice($page['items'], $page['start'], $page['nb_image_page']);
            $tags = add_level_to_tags(get_common_tags($selection, $conf['content_tag_cloud_items_number']));
            foreach ($tags as $tag) {
                $block->data[] = array_merge($tag, array('URL' => make_index_url(array('tags' => array($tag)))));
            }
        }
        if (!empty($block->data)) {
            $block->template = 'menubar_tags.tpl';
        }
    }
    //----------------------------------------------------------- special categories
    if (($block = $menu->get_block('mbSpecials')) != null) {
        if (!is_a_guest()) {
            // favorites
            $block->data['favorites'] = array('URL' => make_index_url(array('section' => 'favorites')), 'TITLE' => l10n('display your favorites photos'), 'NAME' => l10n('Your favorites'));
        }
        $block->data['most_visited'] = array('URL' => make_index_url(array('section' => 'most_visited')), 'TITLE' => l10n('display most visited photos'), 'NAME' => l10n('Most visited'));
        if ($conf['rate']) {
            $block->data['best_rated'] = array('URL' => make_index_url(array('section' => 'best_rated')), 'TITLE' => l10n('display best rated photos'), 'NAME' => l10n('Best rated'));
        }
        $block->data['recent_pics'] = array('URL' => make_index_url(array('section' => 'recent_pics')), 'TITLE' => l10n('display most recent photos'), 'NAME' => l10n('Recent photos'));
        $block->data['recent_cats'] = array('URL' => make_index_url(array('section' => 'recent_cats')), 'TITLE' => l10n('display recently updated albums'), 'NAME' => l10n('Recent albums'));
        $block->data['random'] = array('URL' => get_root_url() . 'random.php', 'TITLE' => l10n('display a set of random photos'), 'NAME' => l10n('Random photos'), 'REL' => 'rel="nofollow"');
        $block->data['calendar'] = array('URL' => make_index_url(array('chronology_field' => $conf['calendar_datefield'] == 'date_available' ? 'posted' : 'created', 'chronology_style' => 'monthly', 'chronology_view' => 'calendar')), 'TITLE' => l10n('display each day with photos, month per month'), 'NAME' => l10n('Calendar'), 'REL' => 'rel="nofollow"');
        $block->template = 'menubar_specials.tpl';
    }
    //---------------------------------------------------------------------- summary
    if (($block = $menu->get_block('mbMenu')) != null) {
        // quick search block will be displayed only if data['qsearch'] is set
        // to "yes"
        $block->data['qsearch'] = true;
        // tags link
        $block->data['tags'] = array('TITLE' => l10n('display available tags'), 'NAME' => l10n('Tags'), 'URL' => get_root_url() . 'tags.php', 'COUNTER' => get_nb_available_tags());
        // search link
        $block->data['search'] = array('TITLE' => l10n('search'), 'NAME' => l10n('Search'), 'URL' => get_root_url() . 'search.php', 'REL' => 'rel="search"');
        if ($conf['activate_comments']) {
            // comments link
            $block->data['comments'] = array('TITLE' => l10n('display last user comments'), 'NAME' => l10n('Comments'), 'URL' => get_root_url() . 'comments.php', 'COUNTER' => get_nb_available_comments());
        }
        // about link
        $block->data['about'] = array('TITLE' => l10n('About Piwigo'), 'NAME' => l10n('About'), 'URL' => get_root_url() . 'about.php');
        // notification
        $block->data['rss'] = array('TITLE' => l10n('RSS feed'), 'NAME' => l10n('Notification'), 'URL' => get_root_url() . 'notification.php', 'REL' => 'rel="nofollow"');
        $block->template = 'menubar_menu.tpl';
    }
    //--------------------------------------------------------------- identification
    if (is_a_guest()) {
        $template->assign(array('U_LOGIN' => get_root_url() . 'identification.php', 'U_LOST_PASSWORD' => get_root_url() . 'password.php', 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering']));
        if ($conf['allow_user_registration']) {
            $template->assign('U_REGISTER', get_root_url() . 'register.php');
        }
    } else {
        $template->assign('USERNAME', stripslashes($user['username']));
        if (is_autorize_status(ACCESS_CLASSIC)) {
            $template->assign('U_PROFILE', get_root_url() . 'profile.php');
        }
        // the logout link has no meaning with Apache authentication : it is not
        // possible to logout with this kind of authentication.
        if (!$conf['apache_authentication']) {
            $template->assign('U_LOGOUT', get_root_url() . '?act=logout');
        }
        if (is_admin()) {
            $template->assign('U_ADMIN', get_root_url() . 'admin.php');
        }
    }
    if (($block = $menu->get_block('mbIdentification')) != null) {
        $block->template = 'menubar_identification.tpl';
    }
    $menu->apply('MENUBAR', 'menubar.tpl');
}
Ejemplo n.º 26
0
// Setup plugin Language
load_language('plugin.lang', VIDEOJS_PATH);
// Fetch the template.
global $template, $conf, $lang;
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
// Add the template to the global template
$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/admin.tpl');
if (!isset($_GET['tab'])) {
    $page['tab'] = 'config';
} else {
    $page['tab'] = $_GET['tab'];
}
$my_base_url = get_admin_plugin_menu_link(__FILE__);
$tabsheet = new tabsheet();
// Configuration Tab
$tabsheet->add('config', l10n('Configuration'), add_url_params($my_base_url, array('tab' => 'config')));
// Disable sync if global setting say so, http://piwigo.org/forum/viewtopic.php?id=22376
if ($conf['enable_synchronization']) {
    $tabsheet->add('sync', l10n('Synchronize'), add_url_params($my_base_url, array('tab' => 'sync')));
}
// Tab to handle external video like Vimeo or YouTube via videosjs-plugins
// https://github.com/videojs/video.js/wiki/Plugins
//$tabsheet->add( 'tech', l10n('Add video'), add_url_params( $my_base_url, array('tab'=>'tech') ) );
$tabsheet->select($page['tab']);
$tabsheet->assign();
$my_base_url = $tabsheet->sheets[$page['tab']]['url'];
$template->set_filename('tab_data', dirname(__FILE__) . '/admin_' . $page['tab'] . '.tpl');
include_once dirname(__FILE__) . '/admin_' . $page['tab'] . '.php';
$template->assign_var_from_handle('TAB_DATA', 'tab_data');
// Assign the template contents to ADMIN_CONTENT
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Ejemplo n.º 27
0
$languages = new languages();
$languages->get_db_languages();
//--------------------------------------------------perform requested actions
if (isset($_GET['action']) and isset($_GET['language'])) {
    $page['errors'] = $languages->perform_action($_GET['action'], $_GET['language']);
    if (empty($page['errors'])) {
        redirect($base_url);
    }
}
// +-----------------------------------------------------------------------+
// |                     start template output                             |
// +-----------------------------------------------------------------------+
$default_language = get_default_language();
$tpl_languages = array();
foreach ($languages->fs_languages as $language_id => $language) {
    $language['u_action'] = add_url_params($base_url, array('language' => $language_id));
    if (in_array($language_id, array_keys($languages->db_languages))) {
        $language['state'] = 'active';
        $language['deactivable'] = true;
        if (count($languages->db_languages) <= 1) {
            $language['deactivable'] = false;
            $language['deactivate_tooltip'] = l10n('Impossible to deactivate this language, you need at least one language.');
        }
        if ($language_id == $default_language) {
            $language['deactivable'] = false;
            $language['deactivate_tooltip'] = l10n('Impossible to deactivate this language, first set another language as default.');
        }
    } else {
        $language['state'] = 'inactive';
    }
    if ($language_id == $default_language) {
Ejemplo n.º 28
0
    u.' . $conf['user_fields']['email'] . ' AS email,
    u.' . $conf['user_fields']['username'] . ' AS username
  FROM ' . USER_INFOS_TABLE . ' AS ui
    JOIN ' . USERS_TABLE . ' AS u ON u.' . $conf['user_fields']['id'] . ' = ui.user_id
  WHERE ui.user_id IN (' . implode(',', $_POST['users']) . ')
;';
        $users = query2array($query);
        $usernames = array();
        foreach ($users as $u) {
            $usernames[] = $u['username'];
            $authkey = create_user_auth_key($u['user_id'], $u['status']);
            $user_tpl = $tpl;
            if ($authkey !== false) {
                $user_tpl['assign']['LINK'] = add_url_params($tpl['assign']['LINK'], array('auth' => $authkey['auth_key']));
                if (isset($user_tpl['assign']['IMG']['link'])) {
                    $user_tpl['assign']['IMG']['link'] = add_url_params($user_tpl['assign']['IMG']['link'], array('auth' => $authkey['auth_key']));
                }
            }
            $user_args = $args;
            if (isset($authkey)) {
                $user_args['auth_key'] = $authkey['auth_key'];
            }
            switch_lang_to($u['language']);
            pwg_mail($u['email'], $user_args, $user_tpl);
            switch_lang_back();
        }
        $message = l10n_dec('%d mail was sent.', '%d mails were sent.', count($users));
        $message .= ' (' . implode(', ', $usernames) . ')';
        $page['infos'][] = $message;
    } elseif ('group' == $_POST['who'] and !empty($_POST['group'])) {
        check_input_parameter('group', $_POST, false, PATTERN_ID);
function update_user_comment_guestbook($comment, $post_key)
{
    global $conf;
    $comment_action = 'validate';
    if (!verify_ephemeral_key($post_key)) {
        $comment_action = 'reject';
    } else {
        if (!$conf['guestbook']['comments_validation'] or is_admin()) {
            $comment_action = 'validate';
        } else {
            $comment_action = 'moderate';
        }
    }
    if ($comment_action != 'reject') {
        $user_where_clause = '';
        if (!is_admin()) {
            $user_where_clause = '   AND author_id = \'' . $GLOBALS['user']['id'] . '\'';
        }
        $query = '
UPDATE ' . GUESTBOOK_TABLE . '
  SET content = \'' . $comment['content'] . '\',
      validated = \'' . ($comment_action == 'validate' ? 'true' : 'false') . '\',
      validation_date = ' . ($comment_action == 'validate' ? 'NOW()' : 'NULL') . '
  WHERE id = ' . $comment['comment_id'] . $user_where_clause . '
;';
        $result = pwg_query($query);
        // mail admin and ask to validate the comment
        if ($result and $conf['guestbook']['email_admin_on_comment_validation'] and 'moderate' == $comment_action) {
            include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php';
            $comment_url = add_url_params(GUESTBOOK_URL, array('comment_id' => $comm['id']));
            $keyargs_content = array(get_l10n_args('Author: %s', stripslashes($GLOBALS['user']['username'])), get_l10n_args('Comment: %s', stripslashes($comment['content'])), get_l10n_args('', ''), get_l10n_args('Manage this user comment: %s', $comment_url), get_l10n_args('', ''), get_l10n_args('(!) This comment requires validation', ''));
            pwg_mail_notification_admins(get_l10n_args('Comment by %s', stripslashes($GLOBALS['user']['username'])), $keyargs_content);
        }
    }
    return $comment_action;
}
Ejemplo n.º 30
0
************************************************/
// Check whether we are indeed included by Piwigo.
if (!defined('PHPWG_ROOT_PATH')) {
    die('Hacking attempt!');
}
// Check access and exit when user status is not ok
check_status(ACCESS_ADMINISTRATOR);
// Setup plugin Language
load_language('plugin.lang', FORECAST_PATH);
// Fetch the template.
global $template, $conf, $lang;
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
// Add the template to the global template
$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/admin.tpl');
if (!isset($_GET['tab'])) {
    $page['tab'] = 'config';
} else {
    $page['tab'] = $_GET['tab'];
}
$my_base_url = get_admin_plugin_menu_link(__FILE__);
$tabsheet = new tabsheet();
$tabsheet->add('config', '<span class="icon-cog"></span>' . l10n('Configuration'), add_url_params($my_base_url, array('tab' => 'config')));
$tabsheet->add('tag', '<span class="icon-tags"></span>' . l10n('Tags'), add_url_params($my_base_url, array('tab' => 'tag')));
$tabsheet->select($page['tab']);
$tabsheet->assign();
$my_base_url = $tabsheet->sheets[$page['tab']]['url'];
$template->set_filename('tab_data', dirname(__FILE__) . '/admin_' . $page['tab'] . '.tpl');
include_once dirname(__FILE__) . '/admin_' . $page['tab'] . '.php';
$template->assign_var_from_handle('TAB_DATA', 'tab_data');
// Assign the template contents to ADMIN_CONTENT
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');