Example #1
0
function get_tree($path = '.', $clean_path = '', $title = '', $first = true, $language = null)
{
    $options = get_options();
    $tree = array();
    $ignore = get_ignored();
    $dh = @opendir($path);
    $index = 0;
    // Build array of paths
    $paths = array();
    while (false !== ($file = readdir($dh))) {
        $paths[$file] = $file;
    }
    // Close the directory handle
    closedir($dh);
    // Sort paths
    sort($paths);
    if ($first && $language !== null) {
        $language_path = $language . "/";
    } else {
        $language_path = "";
    }
    // Loop through the paths
    // while(false !== ($file = readdir($dh))){
    foreach ($paths as $file) {
        // Check that this file or folder is not to be ignored
        if (!in_array($file, $ignore) && $file[0] !== '.') {
            $full_path = "{$path}/{$file}";
            $clean_sort = clean_sort($file);
            // If clean_urls is set to false and this is the first branch of the tree, append index.php to the clean_path.
            if ($options['clean_urls'] == false) {
                if ($first) {
                    $url = $clean_path . '/' . $language_path . 'index.php/' . $clean_sort;
                } else {
                    $url = $clean_path . '/' . $language_path . $clean_sort;
                }
            } else {
                $url = $clean_path . '/' . $language_path . $clean_sort;
            }
            $clean_name = clean_name($clean_sort);
            // Title
            if (empty($title)) {
                $full_title = $clean_name;
            } else {
                $full_title = $title . ': ' . $clean_name;
            }
            if (is_dir("{$path}/{$file}")) {
                // Directory
                $tree[$clean_sort] = array('type' => 'folder', 'name' => $clean_name, 'title' => $full_title, 'path' => $full_path, 'clean' => $clean_sort, 'url' => $url, 'tree' => get_tree($full_path, $url, $full_title, false, $language));
            } else {
                // File
                $tree[$clean_sort] = array('type' => 'file', 'name' => $clean_name, 'title' => $full_title, 'path' => $full_path, 'clean' => $clean_sort, 'url' => $url);
            }
        }
        $index++;
    }
    return $tree;
}
Example #2
0
function send_profile($arg = '')
{
    global $C, $F, $H, $I, $P, $U, $db;
    print_start('profile');
    echo "<div style=\"text-align:center;\"><{$H['form']}>{$H['commonform']}" . hidden('action', 'profile') . hidden('do', 'save') . "<h2>{$I['profile']}</h2><i>{$arg}</i><table style=\"margin-left:auto;margin-right:auto;\">";
    thr();
    array_multisort(array_map('strtolower', array_keys($P)), SORT_ASC, SORT_STRING, $P);
    $ignored = array();
    $ignore = get_ignored();
    foreach ($ignore as $ign) {
        if ($ign['by'] === $U['nickname']) {
            $ignored[] = $ign['ignored'];
        }
    }
    if (count($ignored) > 0) {
        echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><th>{$I['unignore']}</th><td style=\"text-align:right;\">";
        echo "<select name=\"unignore\" size=\"1\"><option value=\"\">{$I['choose']}</option>";
        foreach ($ignored as $ign) {
            $style = '';
            foreach ($P as $user) {
                if ($ign === $user[0]) {
                    $style = " style=\"{$user['1']}\"";
                    break;
                }
            }
            echo "<option value=\"{$ign}\"{$style}>{$ign}</option>";
        }
        echo '</select></td></tr></table></td></tr>';
        thr();
    }
    if (count($P) - count($ignored) > 1) {
        echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><th>{$I['ignore']}</th><td style=\"text-align:right;\">";
        echo "<select name=\"ignore\" size=\"1\"><option value=\"\">{$I['choose']}</option>";
        $stmt = $db->query("SELECT poster FROM {$C['prefix']}messages GROUP BY poster;");
        while ($nick = $stmt->fetch(PDO::FETCH_NUM)) {
            $nicks[] = $nick[0];
        }
        foreach ($P as $user) {
            if ($U['nickname'] !== $user[0] && !in_array($user[0], $ignored) && in_array($user[0], $nicks)) {
                echo "<option value=\"{$user['0']}\" style=\"{$user['1']}\">{$user['0']}</option>";
            }
        }
        echo '</select></td></tr></table></td></tr>';
        thr();
    }
    echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><th>{$I['refreshrate']}</th><td style=\"text-align:right;\">";
    echo "<input type=\"number\" name=\"refresh\" size=\"3\" maxlength=\"3\" min=\"5\" max=\"150\" value=\"{$U['refresh']}\"></td></tr></table></td></tr>";
    thr();
    if (!isset($_COOKIE[$C['cookiename']])) {
        $param = "&session={$U['session']}&lang={$C['lang']}";
    } else {
        $param = '';
    }
    preg_match('/#([0-9a-f]{6})/i', $U['style'], $matches);
    echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><td><b>{$I['fontcolour']}</b> (<a href=\"{$_SERVER['SCRIPT_NAME']}?action=colours{$param}\" target=\"view\">{$I['viewexample']}</a>)</td><td style=\"text-align:right;\">";
    echo "<input type=\"text\" size=\"6\" maxlength=\"6\" pattern=\"[a-fA-F0-9]{6}\" value=\"{$matches['1']}\" name=\"colour\"></td></tr></table></td></tr>";
    thr();
    echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><td><b>{$I['bgcolour']}</b> (<a href=\"{$_SERVER['SCRIPT_NAME']}?action=colours{$param}\" target=\"view\">{$I['viewexample']}</a>)</td><td style=\"text-align:right;\">";
    echo "<input type=\"text\" size=\"6\" maxlength=\"6\" pattern=\"[a-fA-F0-9]{6}\" value=\"{$U['bgcolour']}\" name=\"bgcolour\"></td></tr></table></td></tr>";
    thr();
    if ($U['status'] >= 3) {
        echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><th>{$I['fontface']}</th><td><table style=\"border-spacing:0px;margin-left:auto;\">";
        echo "<tr><td>&nbsp;</td><td><select name=\"font\" size=\"1\"><option value=\"\">* {$I['roomdefault']} *</option>";
        foreach ($F as $name => $font) {
            echo "<option style=\"{$font}\" ";
            if (strpos($U['style'], $font) !== false) {
                echo 'selected ';
            }
            echo "value=\"{$name}\">{$name}</option>";
        }
        echo '</select></td><td>&nbsp;</td><td><input type="checkbox" name="bold" id="bold" value="on"';
        if (strpos($U['style'], 'font-weight:bold;') !== false) {
            echo ' checked';
        }
        echo "><label for=\"bold\"><b>{$I['bold']}</b></label></td><td>&nbsp;</td><td><input type=\"checkbox\" name=\"italic\" id=\"italic\" value=\"on\"";
        if (strpos($U['style'], 'font-style:italic;') !== false) {
            echo ' checked';
        }
        echo "><label for=\"italic\"><i>{$I['italic']}</i></label></td></tr></table></td></tr></table></td></tr>";
        thr();
    }
    echo '<tr><td>' . style_this("{$U['nickname']} : {$I['fontexample']}", $U['style']) . '</td></tr>';
    thr();
    echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><th>{$I['timestamps']}</th><td style=\"text-align:right;\">";
    echo '<input type="checkbox" name="timestamps" id="timestamps" value="on"';
    if ($U['timestamps']) {
        echo ' checked';
    }
    echo "><label for=\"timestamps\"><b>{$I['enabled']}</b></label></td></tr></table></td></tr>";
    thr();
    if (get_setting('imgembed')) {
        echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><th>{$I['embed']}</th><td style=\"text-align:right;\">";
        echo '<input type="checkbox" name="embed" id="embed" value="on"';
        if ($U['embed'] && isset($_COOKIE[$C['cookiename']])) {
            echo ' checked';
        }
        echo "><label for=\"embed\"><b>{$I['enabled']}</b></label></td></tr></table></td></tr>";
        thr();
    }
    if ($U['status'] >= 5 && get_setting('incognito')) {
        echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><th>{$I['incognito']}</th><td style=\"text-align:right;\">";
        echo '<input type="checkbox" name="incognito" id="incognito" value="on"';
        if ($U['incognito']) {
            echo ' checked';
        }
        echo "><label for=\"incognito\"><b>{$I['enabled']}</b></label></td></tr></table></td></tr>";
        thr();
    }
    echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><th>{$I['pbsize']}</th><td><table style=\"border-spacing:0px;margin-left:auto;\">";
    echo "<tr><td>&nbsp;</td><td>{$I['width']}</td><td><input type=\"number\" name=\"boxwidth\" size=\"3\" maxlength=\"3\" value=\"{$U['boxwidth']}\"></td>";
    echo "<td>&nbsp;</td><td>{$I['height']}</td><td><input type=\"number\" name=\"boxheight\" size=\"3\" maxlength=\"3\" value=\"{$U['boxheight']}\"></td>";
    echo '</tr></table></td></tr></table></td></tr>';
    thr();
    if ($U['status'] >= 5) {
        echo "<tr><td><table style\"width:100%;text-align:left;\"><tr><th>{$I['nbsize']}</th><td><table style=\"border-spacing:0px;margin-left:auto;\">";
        echo "<tr><td>&nbsp;</td><td>{$I['width']}</td><td><input type=\"number\" name=\"notesboxwidth\" size=\"3\" maxlength=\"3\" value=\"{$U['notesboxwidth']}\"></td>";
        echo "<td>&nbsp;</td><td>{$I['height']}</td><td><input type=\"number\" name=\"notesboxheight\" size=\"3\" maxlength=\"3\" value=\"{$U['notesboxheight']}\"></td>";
        echo '</tr></table></td></tr></table></td></tr>';
        thr();
    }
    if ($U['status'] >= 2) {
        echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><th>{$I['changepass']}</th></tr>";
        echo '<tr><td><table style="border-spacing:0px;margin-left:auto;">';
        echo "<tr><td>&nbsp;</td><td>{$I['oldpass']}</td><td><input type=\"password\" name=\"oldpass\" size=\"20\"></td></tr>";
        echo "<tr><td>&nbsp;</td><td>{$I['newpass']}</td><td><input type=\"password\" name=\"newpass\" size=\"20\"></td></tr>";
        echo "<tr><td>&nbsp;</td><td>{$I['confirmpass']}</td><td><input type=\"password\" name=\"confirmpass\" size=\"20\"></td></tr>";
        echo '</table></td></tr></table></td></tr>';
        thr();
        echo "<tr><td><table style=\"width:100%;text-align:left;\"><tr><th>{$I['changenickname']}</th></tr>";
        echo '<tr><td><table style="border-spacing:0px;margin-left:auto;">';
        echo "<tr><td>&nbsp;</td><td>{$I['newnickname']}</td><td><input type=\"text\" name=\"newnickname\" size=\"20\"></td></tr>";
        echo "<tr><td>&nbsp;</td><td>{$I['newpass']}</td><td><input type=\"password\" name=\"new_pass\" size=\"20\"></td></tr>";
        echo '</table></td></tr></table></td></tr>';
        thr();
    }
    echo '<tr><td>' . submit($I['savechanges']) . "</td></tr></table></form><br>{$H['backtochat']}</div>";
    print_end();
}