1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 
<?php
/**
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines http://www.simplemachines.org
 * @copyright 2019 Simple Machines and individual contributors
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.1 RC1
 */

/**
 * This template wraps around the simple settings page to add javascript functionality.
 */
function template_avatar_settings_above()
{
}

/**
 * JavaScript to be output below the simple settings page
 */
function template_avatar_settings_below()
{
    echo '
    <script>
        var fUpdateStatus = function ()
        {
            document.getElementById("avatar_max_width_external").disabled = document.getElementById("avatar_download_external").checked;
            document.getElementById("avatar_max_height_external").disabled = document.getElementById("avatar_download_external").checked;
            document.getElementById("avatar_action_too_large").disabled = document.getElementById("avatar_download_external").checked;
        }
        addLoadEvent(fUpdateStatus);
    </script>';
}

/**
 * The attachment maintenance page
 */
function template_maintenance()
{
    global $context, $settings, $scripturl, $txt, $modSettings;

    echo '
    <div id="manage_attachments">
        <div class="cat_bar">
            <h3 class="catbg">', $txt['attachment_stats'], '</h3>
        </div>
        <div class="windowbg">
            <dl class="settings">
                <dt><strong>', $txt['attachment_total'], ':</strong></dt>
                <dd>', $context['num_attachments'], '</dd>
                <dt><strong>', $txt['attachment_manager_total_avatars'], ':</strong></dt>
                <dd>', $context['num_avatars'], '</dd>
                <dt><strong>', $txt['attachmentdir_size'], ':</strong></dt>
                <dd>', $context['attachment_total_size'], ' ', $txt['kilobyte'], '</dd>
                <dt><strong>', $txt['attach_current_dir'], ':</strong></dt>
                <dd>', $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']], '</dd>
                <dt><strong>', $txt['attachmentdir_size_current'], ':</strong></dt>
                <dd>', $context['attachment_current_size'], ' ', $txt['kilobyte'], '</dd>
                <dt><strong>', $txt['attachment_space'], ':</strong></dt>
                <dd>', isset($context['attachment_space']) ? $context['attachment_space'] . ' ' . $txt['kilobyte'] : $txt['attachmentdir_size_not_set'], '</dd>
                <dt><strong>', $txt['attachmentdir_files_current'], ':</strong></dt>
                <dd>', $context['attachment_current_files'], '</dd>
                <dt><strong>', $txt['attachment_files'], ':</strong></dt>
                <dd>', isset($context['attachment_files']) ? $context['attachment_files'] : $txt['attachmentdir_files_not_set'], '</dd>
            </dl>
        </div>
        <div class="cat_bar">
            <h3 class="catbg">', $txt['attachment_integrity_check'], '</h3>
        </div>
        <div class="windowbg">
            <form action="', $scripturl, '?action=admin;area=manageattachments;sa=repair;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
                <p>', $txt['attachment_integrity_check_desc'], '</p>
                <input type="submit" name="repair" value="', $txt['attachment_check_now'], '" class="button">
            </form>
        </div>
        <div class="cat_bar">
            <h3 class="catbg">', $txt['attachment_pruning'], '</h3>
        </div>
        <div class="windowbg">
            <form action="', $scripturl, '?action=admin;area=manageattachments" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirm(\'', $txt['attachment_pruning_warning'], '\');">
                <dl class="settings">
                    <dt>', $txt['attachment_remove_old'], '</dt>
                    <dd><input type="number" name="age" value="25" size="4"> ', $txt['days_word'], '</dd>
                    <dt>', $txt['attachment_pruning_message'], '</dt>
                    <dd><input type="text" name="notice" value="', $txt['attachment_delete_admin'], '" size="40"></dd>
                    <input type="submit" name="remove" value="', $txt['remove'], '" class="button">
                    <input type="hidden" name="type" value="attachments">
                    <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
                    <input type="hidden" name="sa" value="byAge">
                </dl>
            </form>
            <form action="', $scripturl, '?action=admin;area=manageattachments" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirm(\'', $txt['attachment_pruning_warning'], '\');">
                <dl class="settings">
                    <dt>', $txt['attachment_remove_size'], '</dt>
                    <dd><input type="number" name="size" id="size" value="100" size="4"> ', $txt['kilobyte'], '</dd>
                    <dt>', $txt['attachment_pruning_message'], '</dt>
                    <dd><input type="text" name="notice" value="', $txt['attachment_delete_admin'], '" size="40"></dd>
                    <input type="submit" name="remove" value="', $txt['remove'], '" class="button">
                    <input type="hidden" name="type" value="attachments">
                    <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
                    <input type="hidden" name="sa" value="bySize">
                </dl>
            </form>
            <form action="', $scripturl, '?action=admin;area=manageattachments" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirm(\'', $txt['attachment_pruning_warning'], '\');">
                <dl class="settings">
                    <dt>', $txt['attachment_manager_avatars_older'], '</dt>
                    <dd><input type="number" name="age" value="45" size="4"> ', $txt['days_word'], '</dd>
                    <input type="submit" name="remove" value="', $txt['remove'], '" class="button">
                    <input type="hidden" name="type" value="avatars">
                    <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
                    <input type="hidden" name="sa" value="byAge">
                </dl>
            </form>
        </div><!-- .windowbg -->
    </div><!-- #manage_attachments -->';

    if (!empty($context['results']))
        echo '
    <div class="noticebox">', $context['results'], '</div>';

    echo '
    <div id="transfer" class="cat_bar">
        <h3 class="catbg">', $txt['attachment_transfer'], '</h3>
    </div>
    <div class="windowbg">
        <form action="', $scripturl, '?action=admin;area=manageattachments;sa=transfer" method="post" accept-charset="', $context['character_set'], '">
            <p>', $txt['attachment_transfer_desc'], '</p>
            <dl class="settings">
                <dt>', $txt['attachment_transfer_from'], '</dt>
                <dd>
                    <select name="from">
                        <option value="0">', $txt['attachment_transfer_select'], '</option>';

    foreach ($context['attach_dirs'] as $id => $dir)
        echo '
                        <option value="', $id, '">', $dir, '</option>';

    echo '
                    </select>
                </dd>
                <dt>', $txt['attachment_transfer_auto'], '</dt>
                <dd>
                    <select name="auto">
                        <option value="0">', $txt['attachment_transfer_auto_select'], '</option>
                        <option value="-1">', $txt['attachment_transfer_forum_root'], '</option>';

    if (!empty($context['base_dirs']))
        foreach ($context['base_dirs'] as $id => $dir)
            echo '
                        <option value="', $id, '">', $dir, '</option>';
    else
        echo '
                        <option value="0" disabled>', $txt['attachment_transfer_no_base'], '</option>';

    echo '
                    </select>
                </dd>
                <dt>', $txt['attachment_transfer_to'], '</dt>
                <dd>
                    <select name="to">
                        <option value="0">', $txt['attachment_transfer_select'], '</option>';

    foreach ($context['attach_dirs'] as $id => $dir)
        echo '
                        <option value="', $id, '">', $dir, '</option>';

    echo '
                    </select>
                </dd>';

    if (!empty($modSettings['attachmentDirFileLimit']))
        echo '
                <dt>', $txt['attachment_transfer_empty'], '</dt>
                <dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked' : '', '></dd>';

    echo '
            </dl>
            <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
            <input type="submit" onclick="start_progress()" name="transfer" value="', $txt['attachment_transfer_now'], '" class="button">
            <div id="progress_msg"></div>
            <div id="show_progress" class="padding"></div>
        </form>
        <script>
            function start_progress() {
                setTimeout(\'show_msg()\', 1000);
            }

            function show_msg() {
                $(\'#progress_msg\').html(\'<div><img src="', $settings['actual_images_url'], '/loading_sm.gif" alt="', $txt['ajax_in_progress'], '" width="35" height="35"> ', $txt['attachment_transfer_progress'], '<\/div>\');
                show_progress();
            }

            function show_progress() {
                $(\'#show_progress\').on("load", "progress.php");
                setTimeout(\'show_progress()\', 1500);
            }

        </script>
    </div><!-- .windowbg -->';
}

/**
 * The file repair page
 */
function template_attachment_repair()
{
    global $context, $txt, $scripturl;

    // If we've completed just let them know!
    if ($context['completed'])
        echo '
    <div id="manage_attachments">
        <div class="cat_bar">
            <h3 class="catbg">', $txt['repair_attachments_complete'], '</h3>
        </div>
        <div class="windowbg">
            ', $txt['repair_attachments_complete_desc'], '
        </div>
    </div>';

    // What about if no errors were even found?
    elseif (!$context['errors_found'])
        echo '
    <div id="manage_attachments">
        <div class="cat_bar">
            <h3 class="catbg">', $txt['repair_attachments_complete'], '</h3>
        </div>
        <div class="windowbg">
            ', $txt['repair_attachments_no_errors'], '
        </div>
    </div>';

    // Otherwise, I'm sad to say, we have a problem!
    else
    {
        echo '
    <div id="manage_attachments">
        <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=manageattachments;sa=repair;fixErrors=1;step=0;substep=0;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
            <div class="cat_bar">
                <h3 class="catbg">', $txt['repair_attachments'], '</h3>
            </div>
            <div class="windowbg">
                <p>', $txt['repair_attachments_error_desc'], '</p>';

        // Loop through each error reporting the status
        foreach ($context['repair_errors'] as $error => $number)
            if (!empty($number))
                echo '
                <input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '">
                <label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br>';

        echo '
                <br>
                <input type="submit" value="', $txt['repair_attachments_continue'], '" class="button">
                <input type="submit" name="cancel" value="', $txt['repair_attachments_cancel'], '" class="button">
            </div>
        </form>
    </div><!-- #manage_attachments -->';
    }
}

/**
 * The page that handles managing attachment paths.
 */
function template_attachment_paths()
{
    global $modSettings;

    if (!empty($modSettings['attachment_basedirectories']))
        template_show_list('base_paths');

    template_show_list('attach_paths');
}

?>