Example #1
0
            $db->query('UPDATE ' . $db->prefix . 'config SET conf_value=' . $value . ' WHERE conf_name=\'file_' . $db->escape($key) . '\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());
        }
    }
    // Regenerate the config cache
    include_once PUN_ROOT . 'include/cache.php';
    generate_config_cache();
    redirect('admin_files.php', 'Options updated. Redirecting …');
} else {
    $page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / Admin / Files';
    $focus_element = array('files', 'form[upload_path]');
    require_once PUN_ROOT . 'header.php';
    // Display the admin navigation menu
    generate_admin_menu('files');
    if (isset($_POST['show_errors'])) {
        //confirm_referrer('admin_files.php');
        $log = show_problems();
        echo '<div id="imageupload" class="blockform">
<h2><span>Отчет об ошибках</span></h2>
<div class="box">
<div class="inform">
<div class="infldset">
<table class="aligntop" cellspacing="0">
<tr>
<td>';
        echo implode('<br/>', $log);
        echo '</td>
</tr>
</table>
</div>
</div>
</div>
Example #2
0
function show(array $files, $context)
{
    foreach ($files as $file) {
        $data = read($file);
        $ok = phutil_is_utf8($data);
        if ($ok) {
            echo "OKAY";
        } else {
            echo "FAIL";
        }
        echo "  " . name($file) . "\n";
        if (!$ok) {
            $lines = explode("\n", $data);
            $len = count($lines);
            $map = array();
            $bad = array();
            foreach ($lines as $n => $line) {
                if (phutil_is_utf8($line)) {
                    continue;
                }
                $bad[$n] = true;
                for ($jj = max(0, $n - $context); $jj < min($len, $n + 1 + $context); $jj++) {
                    $map[$jj] = true;
                }
            }
            $width = strlen(max(array_keys($map)));
            // Set $last such that we print a newline on the first iteration thorugh
            // the loop.
            $last = -2;
            foreach ($map as $idx => $ignored) {
                if ($idx != $last + 1) {
                    printf("\n");
                }
                $last = $idx;
                $line = $lines[$idx];
                if (!empty($bad[$idx])) {
                    $line = show_problems($line);
                }
                printf("  % {$width}d  %s\n", $idx + 1, $line);
            }
            echo "\n";
        }
    }
    return 0;
}