예제 #1
0
function do_timeout_treatment($post_keyname, $check_key_treated = array())
{
    global $env_nbm, $base_url, $page, $must_repost;
    if ($env_nbm['is_sendmail_timeout']) {
        if (isset($_POST[$post_keyname])) {
            $post_count = count($_POST[$post_keyname]);
            $treated_count = count($check_key_treated);
            if ($treated_count != 0) {
                $time_refresh = ceil((get_moment() - $env_nbm['start_time']) * $post_count / $treated_count);
            } else {
                $time_refresh = 0;
            }
            $_POST[$post_keyname] = array_diff($_POST[$post_keyname], $check_key_treated);
            $must_repost = true;
            $page['errors'][] = l10n_dec('Execution time is out, treatment must be continue [Estimated time: %d second].', 'Execution time is out, treatment must be continue [Estimated time: %d seconds].', $time_refresh);
        }
    }
}
예제 #2
0
            $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);
        pwg_mail_group($_POST['group'], $args, $tpl);
        $query = '
SELECT
    name
  FROM ' . GROUPS_TABLE . '
  WHERE id = ' . $_POST['group'] . '
;';
        list($group_name) = pwg_db_fetch_row(pwg_query($query));
        $page['infos'][] = l10n('An information email was sent to group "%s"', $group_name);
    }
    unset_make_full_url();
예제 #3
0
// +-----------------------------------------------------------------------+
// |                                actions                                |
// +-----------------------------------------------------------------------+
if (!empty($_POST)) {
    if (empty($_POST['comments'])) {
        $page['errors'][] = l10n('Select at least one comment');
    } else {
        include_once PHPWG_ROOT_PATH . 'include/functions_comment.inc.php';
        check_input_parameter('comments', $_POST, true, PATTERN_ID);
        if (isset($_POST['validate'])) {
            validate_user_comment($_POST['comments']);
            $page['infos'][] = l10n_dec('%d user comment validated', '%d user comments validated', count($_POST['comments']));
        }
        if (isset($_POST['reject'])) {
            delete_user_comment($_POST['comments']);
            $page['infos'][] = l10n_dec('%d user comment rejected', '%d user comments rejected', count($_POST['comments']));
        }
    }
}
// +-----------------------------------------------------------------------+
// |                             template init                             |
// +-----------------------------------------------------------------------+
$template->set_filenames(array('comments' => 'comments.tpl'));
$template->assign(array('F_ACTION' => get_root_url() . 'admin.php?page=comments'));
// +-----------------------------------------------------------------------+
// | Tabs                                                                  |
// +-----------------------------------------------------------------------+
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
$my_base_url = get_root_url() . 'admin.php?page=';
$tabsheet = new tabsheet();
$tabsheet->set_id('comments');
예제 #4
0
        $filter['visible_images'] = implode(',', array_from_query($query, 'image_id'));
        if (empty($filter['visible_images'])) {
            // Must be not empty
            $filter['visible_images'] = -1;
        }
        // Save filter data on session
        pwg_set_session_var('filter_enabled', $filter['enabled']);
        pwg_set_session_var('filter_check_key', $filter_key);
        pwg_set_session_var('filter_categories', serialize($filter['categories']));
        pwg_set_session_var('filter_visible_categories', $filter['visible_categories']);
        pwg_set_session_var('filter_visible_images', $filter['visible_images']);
    } else {
        // Read only data
        $filter['categories'] = unserialize(pwg_get_session_var('filter_categories', serialize(array())));
        $filter['visible_categories'] = pwg_get_session_var('filter_visible_categories', '');
        $filter['visible_images'] = pwg_get_session_var('filter_visible_images', '');
    }
    unset($filter_key);
    if (get_filter_page_value('add_notes')) {
        $header_notes[] = l10n_dec('Photos posted within the last %d day.', 'Photos posted within the last %d days.', $filter['recent_period']);
    }
    include_once PHPWG_ROOT_PATH . 'include/functions_filter.inc.php';
} else {
    if (pwg_get_session_var('filter_enabled', false)) {
        pwg_unset_session_var('filter_enabled');
        pwg_unset_session_var('filter_check_key');
        pwg_unset_session_var('filter_categories');
        pwg_unset_session_var('filter_visible_categories');
        pwg_unset_session_var('filter_visible_images');
    }
}
// |                               delete places                           |
// +-----------------------------------------------------------------------+
if (isset($_POST['delete']) and isset($_POST['places'])) {
    $query = '
SELECT name
  FROM ' . osm_place_table . '
  WHERE id IN (' . implode(',', $_POST['places']) . ')
;';
    $place_names = array_from_query($query, 'name');
    $query = '
DELETE
  FROM ' . osm_place_table . '
  WHERE id IN (' . implode(',', $_POST['places']) . ')
;';
    pwg_query($query);
    $page['infos'][] = l10n_dec('The following place was deleted', 'The %d following places were deleted', count($place_names)) . ' : ' . implode(', ', $place_names);
}
// +-----------------------------------------------------------------------+
// |                               add a place                             |
// +-----------------------------------------------------------------------+
if (isset($_POST['add']) and !empty($_POST['add_place'])) {
    $query = "INSERT INTO `" . osm_place_table . "` (`name`, `latitude`, `longitude`) VALUE ('" . $_POST['add_place'] . "', '" . $_POST['add_lat'] . "', '" . $_POST['add_lon'] . "');";
    $result = pwg_query($query);
}
// all places
$query = 'SELECT * FROM `' . osm_place_table . '`;';
$result = pwg_query($query);
$all_places = array();
while ($place = pwg_db_fetch_assoc($result)) {
    $all_places[] = $place;
}
예제 #6
0
 /**
  * Check integrities
  *
  * @param void
  * @return void
  */
 function check()
 {
     global $page, $header_notes, $conf;
     // Ignore list
     $conf_c13y_ignore = unserialize($conf['c13y_ignore']);
     if (is_array($conf_c13y_ignore) and isset($conf_c13y_ignore['version']) and $conf_c13y_ignore['version'] == PHPWG_VERSION and is_array($conf_c13y_ignore['list'])) {
         $ignore_list_changed = false;
         $this->ignore_list = $conf_c13y_ignore['list'];
     } else {
         $ignore_list_changed = true;
         $this->ignore_list = array();
     }
     // Retrieve list
     $this->retrieve_list = array();
     $this->build_ignore_list = array();
     trigger_notify('list_check_integrity', $this);
     // Information
     if (count($this->retrieve_list) > 0) {
         $header_notes[] = l10n_dec('%d anomaly has been detected.', '%d anomalies have been detected.', count($this->retrieve_list));
     }
     // Treatments
     if (isset($_POST['c13y_submit_correction']) and isset($_POST['c13y_selection'])) {
         $corrected_count = 0;
         $not_corrected_count = 0;
         foreach ($this->retrieve_list as $i => $c13y) {
             if (!empty($c13y['correction_fct']) and $c13y['is_callable'] and in_array($c13y['id'], $_POST['c13y_selection'])) {
                 if (is_array($c13y['correction_fct_args'])) {
                     $args = $c13y['correction_fct_args'];
                 } else {
                     if (!is_null($c13y['correction_fct_args'])) {
                         $args = array($c13y['correction_fct_args']);
                     } else {
                         $args = array();
                     }
                 }
                 $this->retrieve_list[$i]['corrected'] = call_user_func_array($c13y['correction_fct'], $args);
                 if ($this->retrieve_list[$i]['corrected']) {
                     $corrected_count += 1;
                 } else {
                     $not_corrected_count += 1;
                 }
             }
         }
         if ($corrected_count > 0) {
             $page['infos'][] = l10n_dec('%d anomaly has been corrected.', '%d anomalies have been detected corrected.', $corrected_count);
         }
         if ($not_corrected_count > 0) {
             $page['errors'][] = l10n_dec('%d anomaly has not been corrected.', '%d anomalies have not been corrected.', $not_corrected_count);
         }
     } else {
         if (isset($_POST['c13y_submit_ignore']) and isset($_POST['c13y_selection'])) {
             $ignored_count = 0;
             foreach ($this->retrieve_list as $i => $c13y) {
                 if (in_array($c13y['id'], $_POST['c13y_selection'])) {
                     $this->build_ignore_list[] = $c13y['id'];
                     $this->retrieve_list[$i]['ignored'] = true;
                     $ignored_count += 1;
                 }
             }
             if ($ignored_count > 0) {
                 $page['infos'][] = l10n_dec('%d anomaly has been ignored.', '%d anomalies have been ignored.', $ignored_count);
             }
         }
     }
     $ignore_list_changed = ($ignore_list_changed or count(array_diff($this->ignore_list, $this->build_ignore_list)) > 0 or count(array_diff($this->build_ignore_list, $this->ignore_list)) > 0);
     if ($ignore_list_changed) {
         $this->update_conf($this->build_ignore_list);
     }
 }
예제 #7
0
/**
 * Returns display text for images counter of category
 *
 * @param int $cat_nb_images nb images directly in category
 * @param int $cat_count_images nb images in category (including subcats)
 * @param int $cat_count_categories nb subcats
 * @param bool $short_message if true append " in this album"
 * @param string $separator
 * @return string
 */
function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_categories, $short_message = true, $separator = '\\n')
{
    $display_text = '';
    if ($cat_count_images > 0) {
        if ($cat_nb_images > 0 and $cat_nb_images < $cat_count_images) {
            $display_text .= get_display_images_count($cat_nb_images, $cat_nb_images, 0, $short_message, $separator) . $separator;
            $cat_count_images -= $cat_nb_images;
            $cat_nb_images = 0;
        }
        //at least one image direct or indirect
        $display_text .= l10n_dec('%d photo', '%d photos', $cat_count_images);
        if ($cat_count_categories == 0 or $cat_nb_images == $cat_count_images) {
            //no descendant categories or descendants do not contain images
            if (!$short_message) {
                $display_text .= ' ' . l10n('in this album');
            }
        } else {
            $display_text .= ' ' . l10n_dec('in %d sub-album', 'in %d sub-albums', $cat_count_categories);
        }
    }
    return $display_text;
}
function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_subscribe = false, $check_key_list = array())
{
    global $conf, $page, $env_nbm, $conf;
    set_make_full_url();
    $check_key_treated = array();
    $updated_data_count = 0;
    $error_on_updated_data_count = 0;
    if ($is_subscribe) {
        $msg_info = l10n('User %s [%s] was added to the subscription list.');
        $msg_error = l10n('User %s [%s] was not added to the subscription list.');
    } else {
        $msg_info = l10n('User %s [%s] was removed from the subscription list.');
        $msg_error = l10n('User %s [%s] was not removed from the subscription list.');
    }
    if (count($check_key_list) != 0) {
        $updates = array();
        $enabled_value = boolean_to_string($is_subscribe);
        $data_users = get_user_notifications('subscribe', $check_key_list, !$is_subscribe);
        // Prepare message after change language
        $msg_break_timeout = l10n('Time to send mail is limited. Others mails are skipped.');
        // Begin nbm users environment
        begin_users_env_nbm(true);
        foreach ($data_users as $nbm_user) {
            if (check_sendmail_timeout()) {
                // Stop fill list on 'send', if the quota is override
                $page['errors'][] = $msg_break_timeout;
                break;
            }
            // Fill return list
            $check_key_treated[] = $nbm_user['check_key'];
            $do_update = true;
            if ($nbm_user['mail_address'] != '') {
                // set env nbm user
                set_user_on_env_nbm($nbm_user, true);
                $subject = '[' . $conf['gallery_title'] . '] ' . ($is_subscribe ? l10n('Subscribe to notification by mail') : l10n('Unsubscribe from notification by mail'));
                // Assign current var for nbm mail
                assign_vars_nbm_mail_content($nbm_user);
                $section_action_by = $is_subscribe ? 'subscribe_by_' : 'unsubscribe_by_';
                $section_action_by .= $is_admin_request ? 'admin' : 'himself';
                $env_nbm['mail_template']->assign(array($section_action_by => true, 'GOTO_GALLERY_TITLE' => $conf['gallery_title'], 'GOTO_GALLERY_URL' => get_gallery_home_url()));
                $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']));
                if ($ret) {
                    inc_mail_sent_success($nbm_user);
                } else {
                    inc_mail_sent_failed($nbm_user);
                    $do_update = false;
                }
                // unset env nbm user
                unset_user_on_env_nbm();
            }
            if ($do_update) {
                $updates[] = array('check_key' => $nbm_user['check_key'], 'enabled' => $enabled_value);
                $updated_data_count += 1;
                $page['infos'][] = sprintf($msg_info, stripslashes($nbm_user['username']), $nbm_user['mail_address']);
            } else {
                $error_on_updated_data_count += 1;
                $page['errors'][] = sprintf($msg_error, stripslashes($nbm_user['username']), $nbm_user['mail_address']);
            }
        }
        // Restore nbm environment
        end_users_env_nbm();
        display_counter_info();
        mass_updates(USER_MAIL_NOTIFICATION_TABLE, array('primary' => array('check_key'), 'update' => array('enabled')), $updates);
    }
    $page['infos'][] = l10n_dec('%d user was updated.', '%d users were updated.', $updated_data_count);
    if ($error_on_updated_data_count != 0) {
        $page['errors'][] = l10n_dec('%d user was not updated.', '%d users were not updated.', $error_on_updated_data_count);
    }
    unset_make_full_url();
    return $check_key_treated;
}
예제 #9
0
                    array_push($page['errors'], l10n('UAM_No_reminder_for_Webmaster'));
                }
                if (in_array($user['id'], $collection)) {
                    array_push($page['errors'], l10n('UAM_No_reminder_for_your_account'));
                }
                if (count($page['errors']) == 0) {
                    foreach ($collection as $user_id) {
                        $query = '
SELECT id, username, mail_address
FROM ' . USERS_TABLE . '
WHERE id = ' . $user_id . '
;';
                        $data = pwg_db_fetch_assoc(pwg_query($query));
                        ghostreminder($user_id, stripslashes($data['username']), $data['mail_address']);
                    }
                    array_push($page['infos'], l10n_dec('UAM_%d_Reminder_Sent', 'UAM_%d_Reminders_Sent', count($collection)));
                    $page['filtered_users'] = get_ghost_user_list();
                }
            }
            if (isset($_POST['GhostTracker_Init']) and is_admin()) {
                $query1 = '
SELECT *
FROM ' . USER_LASTVISIT_TABLE . ';';
                $count = pwg_db_num_rows(pwg_query($query1));
                if ($count != 0) {
                    $query = '
SELECT DISTINCT u.id,
                ui.status AS status
FROM ' . USERS_TABLE . ' AS u
  INNER JOIN ' . USER_INFOS_TABLE . ' AS ui
    ON u.id = ui.user_id
예제 #10
0
/**
 * API method
 * Deletes users
 * @param mixed[] $params
 *    @option int[] user_id
 *    @option string pwg_token
 */
function ws_users_delete($params, &$service)
{
    if (get_pwg_token() != $params['pwg_token']) {
        return new PwgError(403, 'Invalid security token');
    }
    global $conf, $user;
    include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
    $protected_users = array($user['id'], $conf['guest_id'], $conf['default_user_id'], $conf['webmaster_id']);
    // an admin can't delete other admin/webmaster
    if ('admin' == $user['status']) {
        $query = '
SELECT
    user_id
  FROM ' . USER_INFOS_TABLE . '
  WHERE status IN (\'webmaster\', \'admin\')
;';
        $protected_users = array_merge($protected_users, query2array($query, null, 'user_id'));
    }
    // protect some users
    $params['user_id'] = array_diff($params['user_id'], $protected_users);
    $counter = 0;
    foreach ($params['user_id'] as $user_id) {
        delete_user($user_id);
        $counter++;
    }
    return l10n_dec('%d user deleted', '%d users deleted', $counter);
}
예제 #11
0
파일: intro.php 프로젝트: donseba/Piwigo
  FROM ' . GROUPS_TABLE . '
;';
list($nb_groups) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
  FROM ' . RATE_TABLE . '
;';
list($nb_rates) = pwg_db_fetch_row(pwg_query($query));
$template->assign(array('PHPWG_URL' => PHPWG_URL, 'PWG_VERSION' => PHPWG_VERSION, 'OS' => PHP_OS, 'PHP_VERSION' => phpversion(), 'DB_ENGINE' => 'MySQL', 'DB_VERSION' => $db_version, 'DB_ELEMENTS' => l10n_dec('%d photo', '%d photos', $nb_elements), 'DB_CATEGORIES' => l10n_dec('%d album including', '%d albums including', $nb_categories) . l10n_dec('%d physical', '%d physicals', $nb_physical) . l10n_dec(' and %d virtual', ' and %d virtuals', $nb_virtual), 'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category), 'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags), 'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag), 'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users), 'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups), 'DB_RATES' => $nb_rates == 0 ? l10n('no rate') : l10n('%d rates', $nb_rates), 'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH . 'admin.php?action=check_upgrade', 'U_PHPINFO' => PHPWG_ROOT_PATH . 'admin.php?action=phpinfo', 'PHP_DATATIME' => $php_current_timestamp, 'DB_DATATIME' => $db_current_date));
if ($conf['activate_comments']) {
    $query = '
SELECT COUNT(*)
  FROM ' . COMMENTS_TABLE . '
;';
    list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
    $template->assign('DB_COMMENTS', l10n_dec('%d comment', '%d comments', $nb_comments));
}
if ($nb_elements > 0) {
    $query = '
SELECT MIN(date_available)
  FROM ' . IMAGES_TABLE . '
;';
    list($first_date) = pwg_db_fetch_row(pwg_query($query));
    $template->assign('first_added', array('DB_DATE' => l10n('first photo added on %s', format_date($first_date))));
}
// graphics library
switch (pwg_image::get_library()) {
    case 'imagick':
        $library = 'ImageMagick';
        $img = new Imagick();
        $version = $img->getVersion();
예제 #12
0
파일: tags.php 프로젝트: donseba/Piwigo
            $page['infos'][] = l10n('Tags <em>%s</em> merged into tag <em>%s</em>', implode(', ', $tags_deleted), $name_of_tag[$destination_tag_id]);
        }
    }
}
// +-----------------------------------------------------------------------+
// |                               delete tags                             |
// +-----------------------------------------------------------------------+
if (isset($_POST['delete']) and isset($_POST['tags'])) {
    $query = '
SELECT name
  FROM ' . TAGS_TABLE . '
  WHERE id IN (' . implode(',', $_POST['tags']) . ')
;';
    $tag_names = array_from_query($query, 'name');
    delete_tags($_POST['tags']);
    $page['infos'][] = l10n_dec('The following tag was deleted', 'The %d following tags were deleted', count($tag_names)) . ' : ' . implode(', ', $tag_names);
}
// +-----------------------------------------------------------------------+
// |                           delete orphan tags                          |
// +-----------------------------------------------------------------------+
if (isset($_GET['action']) and 'delete_orphans' == $_GET['action']) {
    check_pwg_token();
    delete_orphan_tags();
    $_SESSION['page_infos'] = array(l10n('Orphan tags deleted'));
    redirect(get_root_url() . 'admin.php?page=tags');
}
// +-----------------------------------------------------------------------+
// |                               add a tag                               |
// +-----------------------------------------------------------------------+
if (isset($_POST['add']) and !empty($_POST['add_tag'])) {
    $ret = create_tag($_POST['add_tag']);
    function content_55bbb4656e3694_35803903($_smarty_tpl)
    {
        ?>
<dt>
<?php 
        if (isset($_smarty_tpl->tpl_vars['U_START_FILTER']->value)) {
            ?>
	<a href="<?php 
            echo $_smarty_tpl->tpl_vars['U_START_FILTER']->value;
            ?>
" class="pwg-state-default pwg-button menubarFilter" title="<?php 
            echo l10n('display only recently posted photos');
            ?>
" rel="nofollow"><span class="pwg-icon pwg-icon-filter"> </span></a>
<?php 
        }
        if (isset($_smarty_tpl->tpl_vars['U_STOP_FILTER']->value)) {
            ?>
	<a href="<?php 
            echo $_smarty_tpl->tpl_vars['U_STOP_FILTER']->value;
            ?>
" class="pwg-state-default pwg-button menubarFilter" title="<?php 
            echo l10n('return to the display of all photos');
            ?>
"><span class="pwg-icon pwg-icon-filter-del"> </span></a>
<?php 
        }
        ?>
	<a href="<?php 
        echo $_smarty_tpl->tpl_vars['block']->value->data['U_CATEGORIES'];
        ?>
"><?php 
        echo l10n('Albums');
        ?>
</a>
</dt>
<dd>
<?php 
        $_smarty_tpl->tpl_vars['ref_level'] = new Smarty_variable(0, null, 0);
        $_smarty_tpl->tpl_vars['cat'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['cat']->_loop = false;
        $_from = $_smarty_tpl->tpl_vars['block']->value->data['MENU_CATEGORIES'];
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['cat']->key => $_smarty_tpl->tpl_vars['cat']->value) {
            $_smarty_tpl->tpl_vars['cat']->_loop = true;
            if ($_smarty_tpl->tpl_vars['cat']->value['LEVEL'] > $_smarty_tpl->tpl_vars['ref_level']->value) {
                ?>
  <ul>
<?php 
            } else {
                ?>
    </li>
    <?php 
                echo str_repeat('</ul></li>', $_smarty_tpl->tpl_vars['ref_level']->value - $_smarty_tpl->tpl_vars['cat']->value['LEVEL']);
                ?>

<?php 
            }
            ?>
    <li <?php 
            if ($_smarty_tpl->tpl_vars['cat']->value['SELECTED']) {
                ?>
class="selected"<?php 
            }
            ?>
>
      <a href="<?php 
            echo $_smarty_tpl->tpl_vars['cat']->value['URL'];
            ?>
" <?php 
            if ($_smarty_tpl->tpl_vars['cat']->value['IS_UPPERCAT']) {
                ?>
rel="up"<?php 
            }
            ?>
 title="<?php 
            echo $_smarty_tpl->tpl_vars['cat']->value['TITLE'];
            ?>
"><?php 
            echo $_smarty_tpl->tpl_vars['cat']->value['NAME'];
            ?>
</a>
<?php 
            if ($_smarty_tpl->tpl_vars['cat']->value['count_images'] > 0) {
                ?>
      <span class="<?php 
                if ($_smarty_tpl->tpl_vars['cat']->value['nb_images'] > 0) {
                    ?>
menuInfoCat<?php 
                } else {
                    ?>
menuInfoCatByChild<?php 
                }
                ?>
" title="<?php 
                echo $_smarty_tpl->tpl_vars['cat']->value['TITLE'];
                ?>
">[<?php 
                echo $_smarty_tpl->tpl_vars['cat']->value['count_images'];
                ?>
]</span>
<?php 
            }
            if (!empty($_smarty_tpl->tpl_vars['cat']->value['icon_ts'])) {
                ?>
      <img title="<?php 
                echo $_smarty_tpl->tpl_vars['cat']->value['icon_ts']['TITLE'];
                ?>
" src="<?php 
                echo $_smarty_tpl->tpl_vars['ROOT_URL']->value;
                echo $_smarty_tpl->tpl_vars['themeconf']->value['icon_dir'];
                ?>
/recent<?php 
                if ($_smarty_tpl->tpl_vars['cat']->value['icon_ts']['IS_CHILD_DATE']) {
                    ?>
_by_child<?php 
                }
                ?>
.png" class="icon" alt="(!)">
<?php 
            }
            ?>
  <?php 
            $_smarty_tpl->tpl_vars['ref_level'] = new Smarty_variable($_smarty_tpl->tpl_vars['cat']->value['LEVEL'], null, 0);
        }
        echo str_repeat('</li></ul>', $_smarty_tpl->tpl_vars['ref_level']->value);
        ?>


	<p class="totalImages"><?php 
        echo l10n_dec('%d photo', '%d photos', $_smarty_tpl->tpl_vars['block']->value->data['NB_PICTURE']);
        ?>
</p>
</dd>
<?php 
    }
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>');
    }
}
예제 #15
0
 /**
  * @deprecated use "translate_dec" modifier
  */
 function l10n_dec($s, $p, $v)
 {
     return l10n_dec($s, $p, $v);
 }
예제 #16
0
        $existing_photos = simple_hash_from_query($query, 'id', 'file');
        $existing_photos = array_map(create_function('$p', 'return preg_replace("#^' . $flickr_prefix . '([0-9]+)\\.([a-z]{3,4})$#i", "$1", $p);'), $existing_photos);
        // remove existing photos
        $duplicates = 0;
        foreach ($all_photos as $id => &$photo) {
            if (in_array($id, $existing_photos)) {
                unset($all_photos[$id]);
                $duplicates++;
            } else {
                $photo = array('id' => $id, 'albums' => implode(',', $photo));
            }
        }
        unset($photo);
        $all_photos = array_values($all_photos);
        if ($duplicates > 0) {
            $page['infos'][] = '<a href="admin.php?page=batch_manager&amp;filter=prefilter-flickr">' . l10n_dec('One picture is not displayed because already existing in the database.', '%d pictures are not displayed because already existing in the database.', $duplicates) . '</a>';
        }
        $template->assign(array('nb_elements' => count($all_photos), 'all_elements' => json_encode($all_photos), 'F_ACTION' => FLICKR_ADMIN . '-import&amp;action=import_set'));
        // get piwigo categories
        $query = '
SELECT id, name, uppercats, global_rank
  FROM ' . CATEGORIES_TABLE . '
;';
        display_select_cat_wrapper($query, array(), 'category_parent_options');
        break;
        // success message after import
    // success message after import
    case 'import_set':
        if (isset($_POST['done'])) {
            $_SESSION['page_infos'][] = l10n('%d pictures imported', $_POST['done']);
        }
예제 #17
0
/**
 * Add info to the title of the thumbnail based on photo properties.
 *
 * @param array $info hit, rating_score, nb_comments
 * @param string $title
 * @param string $comment
 * @return string
 */
function get_thumbnail_title($info, $title, $comment = '')
{
    global $conf, $user;
    $details = array();
    if (!empty($info['hit'])) {
        $details[] = $info['hit'] . ' ' . strtolower(l10n('Visits'));
    }
    if ($conf['rate'] and !empty($info['rating_score'])) {
        $details[] = strtolower(l10n('Rating score')) . ' ' . $info['rating_score'];
    }
    if (isset($info['nb_comments']) and $info['nb_comments'] != 0) {
        $details[] = l10n_dec('%d comment', '%d comments', $info['nb_comments']);
    }
    if (count($details) > 0) {
        $title .= ' (' . implode(', ', $details) . ')';
    }
    if (!empty($comment)) {
        $comment = strip_tags($comment);
        $title .= ' ' . substr($comment, 0, 100) . (strlen($comment) > 100 ? '...' : '');
    }
    $title = htmlspecialchars(strip_tags($title));
    $title = trigger_change('get_thumbnail_title', $title, $info);
    return $title;
}
예제 #18
0
/**
 * Returns title about recently published elements grouped by post date.
 *
 * @param array $date_detail returned value of get_recent_post_dates()
 * @return string
 */
function get_title_recent_post_date($date_detail)
{
    global $lang;
    $date = $date_detail['date_available'];
    $exploded_date = strptime($date, '%Y-%m-%d %H:%M:%S');
    $title = l10n_dec('%d new photo', '%d new photos', $date_detail['nb_elements']);
    $title .= ' (' . $lang['month'][1 + $exploded_date['tm_mon']] . ' ' . $exploded_date['tm_mday'] . ')';
    return $title;
}
예제 #19
0
// | specific actions                                                      |
// +-----------------------------------------------------------------------+
if (isset($_GET['action'])) {
    if ('empty_caddie' == $_GET['action']) {
        $query = '
DELETE FROM ' . CADDIE_TABLE . '
  WHERE user_id = ' . $user['id'] . '
;';
        pwg_query($query);
        $_SESSION['page_infos'] = array(l10n('Information data registered in database'));
        redirect(get_root_url() . 'admin.php?page=' . $_GET['page']);
    }
    if ('delete_orphans' == $_GET['action']) {
        $deleted_count = delete_elements(get_orphans(), true);
        if ($deleted_count > 0) {
            $_SESSION['page_infos'][] = l10n_dec('%d photo was deleted', '%d photos were deleted', $deleted_count);
            redirect(get_root_url() . 'admin.php?page=' . $_GET['page']);
        }
    }
}
// +-----------------------------------------------------------------------+
// |                      initialize current set                           |
// +-----------------------------------------------------------------------+
// filters from form
if (isset($_POST['submitFilter'])) {
    // echo '<pre>'; print_r($_POST); echo '</pre>';
    unset($_REQUEST['start']);
    // new photo set must reset the page
    $_SESSION['bulk_manager_filter'] = array();
    if (isset($_POST['filter_prefilter_use'])) {
        $_SESSION['bulk_manager_filter']['prefilter'] = $_POST['filter_prefilter'];
예제 #20
0
파일: history.php 프로젝트: donseba/Piwigo
        $summary['nb_guests'] = count(array_keys($summary['guests_IP']));
        // we delete the "guest" from the $username_of hash so that it is
        // avoided in next steps
        unset($username_of[$conf['guest_id']]);
    }
    $summary['nb_members'] = count($username_of);
    $member_strings = array();
    foreach ($username_of as $user_id => $user_name) {
        $member_string = $user_name . '&nbsp;<a href="';
        $member_string .= get_root_url() . 'admin.php?page=history';
        $member_string .= '&amp;search_id=' . $page['search_id'];
        $member_string .= '&amp;user_id=' . $user_id;
        $member_string .= '">+</a>';
        $member_strings[] = $member_string;
    }
    $template->assign('search_summary', array('NB_LINES' => l10n_dec('%d line filtered', '%d lines filtered', $page['nb_lines']), 'FILESIZE' => $summary['total_filesize'] != 0 ? ceil($summary['total_filesize'] / 1024) . ' MB' : '', 'USERS' => l10n_dec('%d user', '%d users', $summary['nb_members'] + $summary['nb_guests']), 'MEMBERS' => sprintf(l10n_dec('%d member', '%d members', $summary['nb_members']) . ': %s', implode(', ', $member_strings)), 'GUESTS' => l10n_dec('%d guest', '%d guests', $summary['nb_guests'])));
    unset($name_of_tag);
}
// +-----------------------------------------------------------------------+
// |                            navigation bar                             |
// +-----------------------------------------------------------------------+
if (isset($page['search_id'])) {
    $navbar = create_navigation_bar(get_root_url() . 'admin.php' . get_query_string_diff(array('start')), $page['nb_lines'], $page['start'], $conf['nb_logs_page']);
    $template->assign('navbar', $navbar);
}
// +-----------------------------------------------------------------------+
// |                             filter form                               |
// +-----------------------------------------------------------------------+
$form = array();
if (isset($page['search'])) {
    if (isset($page['search']['fields']['date-after'])) {
예제 #21
0
/**
 * Works out the time since the given date
 *
 * @param int|string timestamp or datetime string
 * @param string $stop year,month,week,day,hour,minute,second
 * @param string $format input format respecting date() syntax
 * @param bool $with_text append "ago" or "in the future"
 * @param bool $with_weeks
 * @return string
 */
function time_since($original, $stop = 'minute', $format = null, $with_text = true, $with_week = true)
{
    $date = str2DateTime($original, $format);
    if (!$date) {
        return l10n('N/A');
    }
    $now = new DateTime();
    $diff = dateDiff($now, $date);
    $chunks = array('year' => $diff->y, 'month' => $diff->m, 'week' => 0, 'day' => $diff->d, 'hour' => $diff->h, 'minute' => $diff->i, 'second' => $diff->s);
    // DateInterval does not contain the number of weeks
    if ($with_week) {
        $chunks['week'] = (int) floor($chunks['day'] / 7);
        $chunks['day'] = $chunks['day'] - $chunks['week'] * 7;
    }
    $j = array_search($stop, array_keys($chunks));
    $print = '';
    $i = 0;
    foreach ($chunks as $name => $value) {
        if ($value != 0) {
            $print .= ' ' . l10n_dec('%d ' . $name, '%d ' . $name . 's', $value);
        }
        if (!empty($print) && $i >= $j) {
            break;
        }
        $i++;
    }
    $print = trim($print);
    if ($with_text) {
        if ($diff->invert) {
            $print = l10n('%s ago', $print);
        } else {
            $print = l10n('%s in the future', $print);
        }
    }
    return $print;
}
예제 #22
0
/**
 * Change the parent category of the given categories. The categories are
 * supposed virtual.
 *
 * @param int[] $category_ids
 * @param int $new_parent (-1 for root)
 */
function move_categories($category_ids, $new_parent = -1)
{
    global $page;
    if (count($category_ids) == 0) {
        return;
    }
    $new_parent = $new_parent < 1 ? 'NULL' : $new_parent;
    $categories = array();
    $query = '
SELECT id, id_uppercat, status, uppercats
  FROM ' . CATEGORIES_TABLE . '
  WHERE id IN (' . implode(',', $category_ids) . ')
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $categories[$row['id']] = array('parent' => empty($row['id_uppercat']) ? 'NULL' : $row['id_uppercat'], 'status' => $row['status'], 'uppercats' => $row['uppercats']);
    }
    // is the movement possible? The movement is impossible if you try to move
    // a category in a sub-category or itself
    if ('NULL' != $new_parent) {
        $query = '
SELECT uppercats
  FROM ' . CATEGORIES_TABLE . '
  WHERE id = ' . $new_parent . '
;';
        list($new_parent_uppercats) = pwg_db_fetch_row(pwg_query($query));
        foreach ($categories as $category) {
            // technically, you can't move a category with uppercats 12,125,13,14
            // into a new parent category with uppercats 12,125,13,14,24
            if (preg_match('/^' . $category['uppercats'] . '(,|$)/', $new_parent_uppercats)) {
                $page['errors'][] = l10n('You cannot move an album in its own sub album');
                return;
            }
        }
    }
    $tables = array(USER_ACCESS_TABLE => 'user_id', GROUP_ACCESS_TABLE => 'group_id');
    $query = '
UPDATE ' . CATEGORIES_TABLE . '
  SET id_uppercat = ' . $new_parent . '
  WHERE id IN (' . implode(',', $category_ids) . ')
;';
    pwg_query($query);
    update_uppercats();
    update_global_rank();
    // status and related permissions management
    if ('NULL' == $new_parent) {
        $parent_status = 'public';
    } else {
        $query = '
SELECT status
  FROM ' . CATEGORIES_TABLE . '
  WHERE id = ' . $new_parent . '
;';
        list($parent_status) = pwg_db_fetch_row(pwg_query($query));
    }
    if ('private' == $parent_status) {
        set_cat_status(array_keys($categories), 'private');
    }
    $page['infos'][] = l10n_dec('%d album moved', '%d albums moved', count($categories));
}
예제 #23
0
// |                              group list                               |
// +-----------------------------------------------------------------------+
$query = '
SELECT id, name, is_default
  FROM ' . GROUPS_TABLE . '
  ORDER BY name ASC
;';
$result = pwg_query($query);
$admin_url = get_root_url() . 'admin.php?page=';
$perm_url = $admin_url . 'group_perm&amp;group_id=';
$del_url = $admin_url . 'group_list&amp;delete=';
$toggle_is_default_url = $admin_url . 'group_list&amp;toggle_is_default=';
while ($row = pwg_db_fetch_assoc($result)) {
    $query = '
SELECT u.' . $conf['user_fields']['username'] . ' AS username
  FROM ' . USERS_TABLE . ' AS u
  INNER JOIN ' . USER_GROUP_TABLE . ' AS ug
    ON u.' . $conf['user_fields']['id'] . ' = ug.user_id
  WHERE ug.group_id = ' . $row['id'] . '
;';
    $members = array();
    $res = pwg_query($query);
    while ($us = pwg_db_fetch_assoc($res)) {
        $members[] = $us['username'];
    }
    $template->append('groups', array('NAME' => $row['name'], 'ID' => $row['id'], 'IS_DEFAULT' => get_boolean($row['is_default']) ? ' [' . l10n('default') . ']' : '', 'NB_MEMBERS' => count($members), 'L_MEMBERS' => implode(' <span class="userSeparator">&middot;</span> ', $members), 'MEMBERS' => l10n_dec('%d member', '%d members', count($members)), 'U_DELETE' => $del_url . $row['id'] . '&amp;pwg_token=' . get_pwg_token(), 'U_PERM' => $perm_url . $row['id'], 'U_ISDEFAULT' => $toggle_is_default_url . $row['id'] . '&amp;pwg_token=' . get_pwg_token()));
}
// +-----------------------------------------------------------------------+
// |                           sending html code                           |
// +-----------------------------------------------------------------------+
$template->assign_var_from_handle('ADMIN_CONTENT', 'group_list');
예제 #24
0
  ON u.id = ui.user_id
WHERE ui.status = "admin"
;';
                $result = pwg_query($query);
                while ($row = pwg_db_fetch_assoc($result)) {
                    if (in_array($row['id'], $collection)) {
                        array_push($page['errors'], l10n('PP_Admins is not unlockable'));
                    }
                }
                if (count($page['errors']) == 0) {
                    if (isset($_POST['confirm_unlock']) and 1 == $_POST['confirm_unlock']) {
                        foreach ($collection as $user_id) {
                            PP_unlock_user($user_id);
                        }
                        array_push($page['infos'], l10n_dec('PP %d user unlocked', 'PP %d users unlocked', count($collection)));
                        $template->append('infos', l10n_dec('PP %d user unlocked', 'PP %d users unlocked', count($collection)));
                    } else {
                        array_push($page['errors'], l10n('PP_You need to confirm unlock'));
                    }
                }
            }
            // +-----------------------------------------------------------------------+
            // |                               user list                               |
            // +-----------------------------------------------------------------------+
            $visible_user_list = array();
            foreach ($page['filtered_users'] as $num => $local_user) {
                $visible_user_list[] = $local_user;
            }
            foreach ($visible_user_list as $local_user) {
                if (!empty($local_user)) {
                    $query = '