function check_writable_r($dir, $chmod = 0666, $func = CHMOD_FILE, $first = false)
{
    $dh = opendir($dir);
    if (!$first) {
        check_writable($dir, $chmod, false, $func);
    }
    while ($file = readdir($dh)) {
        if ($file != '.' && $file != '..') {
            $fullpath = $dir . DIRECTORY_SEPARATOR . $file;
            if (is_file($fullpath)) {
                check_writable($fullpath, $chmod, false, $func);
            } elseif (is_dir($fullpath)) {
                check_writable_r($fullpath, $chmod, $func, true);
            }
        }
    }
    closedir($dh);
}
    check_writable_r('docs');
    check_writable_r('language');
    check_executable_r('admin/backup');
    check_executable_r('admin/data');
    check_executable_r('designs');
    check_executable_r('docs');
    check_executable_r('images');
    check_executable_r('templates');
    check_executable_r('components');
    check_executable_r('language');
    check_executable('classes/cron/jobs');
    check_executable('classes/feedcreator');
    check_executable('classes/fonts');
    check_executable('classes/geshi');
    check_executable('classes/graphic/noises');
    check_writable_r('templates');
}
@ini_set('default_charset', '');
header('Content-type: text/html; charset: iso-8859-1');
$htmlhead = '';
// Arrays for Dates
$months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
// Arrays for Permissions
$gls = array('admin' => 'Is Administrator', 'gmod' => 'Is Global Moderator', 'guest' => 'Is Guest', 'members' => 'Can view Memberlist', 'profile' => 'Can view Profiles', 'pdf' => 'Can view PDF-Files', 'pm' => 'Can use PM', 'wwo' => 'Can view Who is Online', 'search' => 'Can use Search', 'team' => 'Can view Teamlist', 'usepic' => 'Can use (own) Avatar', 'useabout' => 'Create (own) Personal Page', 'usesignature' => 'Can use (own) Signature', 'downloadfiles' => 'Can download Attachements', 'forum' => 'Can view Forums', 'posttopics' => 'Can start a new Thread', 'postreplies' => 'Can write a reply', 'addvotes' => 'Can start a Poll', 'attachments' => 'Can add Attachements', 'edit' => 'Can edit own Posts', 'voting' => 'Can vote', 'docs' => 'Can view Documents/Pages');
$gll = array('admin' => 'The user ist he highest ranked Administrator in the forum. He may use this admincenter and has full control of the forum!', 'gmod' => 'The user will automatically be moderator in all forums and can use all options and actions on topics.', 'guest' => 'The users in this usergroup are (not registered) guests.', 'members' => 'May view the memberlist and use eventually observably data.', 'profile' => 'The user may view the profiles of the members and use eventually observably data.', 'pdf' => 'The user may download particular topics as PDF-file.', 'pm' => 'The user may use the Private Messaging (PM) System. He can send, receive, administer and archive private messages.', 'wwo' => 'May view the where-is-who-online-list with the users residence.', 'search' => 'May use the Search and view the results.', 'team' => 'May view the teamlist with administrators, global moderators and moderators.', 'usepic' => 'May upload his own picture for his profile (frequently named avatar) or indicate an URL to a picture.', 'useabout' => 'May create a personal site in his user profile.', 'usesignature' => 'The user may create his own signature.', 'downloadfiles' => 'The user may view and download attached files.', 'forum' => 'The user may generally view the forums and read them.', 'posttopics' => 'New topics may be started.', 'postreplies' => 'Answers to topics may be written.', 'addvotes' => 'Polls may be created within topics.', 'attachments' => 'The user may attach files to his post.', 'edit' => 'The user may edit and delete his own posts.', 'voting' => 'The user may participate in polls in topics.', 'docs' => 'May view all documents & pages.');
$glk = array_keys($gls);
$glk_forums = array('f_downloadfiles' => 'downloadfiles', 'f_forum' => 'forum', 'f_posttopics' => 'posttopics', 'f_postreplies' => 'postreplies', 'f_addvotes' => 'addvotes', 'f_attachments' => 'attachments', 'f_edit' => 'edit', 'f_voting' => 'voting');
$guest_limitation = array('admin', 'gmod', 'pm', 'usepic', 'useabout', 'usesignature', 'voting', 'edit');
// Variables
require_once "classes/function.gpc.php";
<?php

if (isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) == "function.viscacha_backend.php") {
    die('Error: Hacking Attempt');
}
// Gets a file with php-functions
@(include_once "classes/function.phpcore.php");
require_once "classes/class.filesystem.php";
$filesystem = new filesystem($config['ftp_server'], $config['ftp_user'], $config['ftp_pw'], $config['ftp_port']);
$filesystem->set_wd($config['ftp_path']);
@(include_once "classes/function.chmod.php");
if ($config['check_filesystem'] == 1) {
    check_writable('admin/data/notes.php');
    check_writable_r('docs');
    check_writable_r('language');
    check_executable_r('admin/backup');
    check_executable_r('admin/data');
    check_executable_r('designs');
    check_executable_r('docs');
    check_executable_r('images');
    check_executable_r('smilies');
    check_executable_r('templates');
    check_executable_r('components');
    check_executable_r('language');
    check_executable('classes/cron/jobs');
    check_executable('classes/feedcreator');
    check_executable('classes/fonts');
    check_executable('classes/geshi');
    check_executable('classes/graphic/noises');
}
@ini_set('default_charset', '');