function page_admincontrol()
{
    global $admin_lang;
    //
    // get the coutnt of all pages
    //
    $sitedata_result = db_result("SELECT page_id FROM " . DB_PREFIX . "pages_content");
    $page_count = mysql_num_rows($sitedata_result);
    //
    // get the count of all registered users
    //
    $users_result = db_result("SELECT user_id FROM " . DB_PREFIX . "users");
    $users_count = mysql_num_rows($users_result);
    //
    // get the size of all tables with the prefix DB_PREFIX
    //
    $table_infos_result = db_result("SHOW TABLE STATUS");
    $data_size = 0;
    while ($table_infos = mysql_fetch_object($table_infos_result)) {
        if (substr($table_infos->Name, 0, strlen(DB_PREFIX)) == DB_PREFIX) {
            $data_size += $table_infos->Data_length + $table_infos->Index_length;
        }
    }
    $out = "<h3>AdminControl</h3><hr />\r\n\t<table>\r\n\t\t<tr><td>" . $admin_lang['online since'] . "</td><td>#DATUM</td></tr>\r\n\t\t<tr><td>" . $admin_lang['registered users'] . "</td><td>" . $users_count . "</td></tr>\r\n\t\t<tr><td>" . $admin_lang['created pages'] . "</td><td>" . $page_count . "</td></tr>\r\n\t\t<tr><td>" . $admin_lang['database size'] . "</td><td>" . kbormb($data_size) . "</td></tr>\r\n\t</table>\r\n\t\r\n\t<h3>Aktuelle Besucher</h3><hr />\r\n\t<table>\r\n\t\t<tr>\r\n\t\t\t<td>" . $admin_lang['name'] . "</td>\r\n\t\t\t<td>" . $admin_lang['page'] . "</td>\r\n\t\t\t<td>" . $admin_lang['last action'] . "</td>\r\n\t\t\t<td>" . $admin_lang['language'] . "</td>\r\n\t\t\t<td>" . $admin_lang['ip'] . "</td>\r\n\t\t\t<td>" . $admin_lang['host'] . "</td>\r\n\t\t</tr>";
    //output all visitors surfing on the site
    $users_online_result = db_result("SELECT userid, page, lastaction, lang, ip, host FROM " . DB_PREFIX . "online");
    while ($users_online = mysql_fetch_object($users_online_result)) {
        if ($users_online->userid == 0) {
            $username = $admin_lang['not registered'];
        } else {
            $username = getUserById($users_online->userid);
        }
        //
        // FIXME: gethostbyaddr needes to much time if there are many users online
        //
        $out .= "\t\t\t<tr>\r\n\t\t\t<td>" . $username . "</td>\r\n\t\t\t<td><a href=\"index.php?page=" . $users_online->page . "\">" . $users_online->page . "</a></td>\r\n\t\t\t<td>" . date("d.m.Y H:i:s", $users_online->lastaction) . "</td>\r\n\t\t\t<td>" . $admin_lang[$users_online->lang] . "</td>\r\n\t\t\t<td>" . $users_online->ip . "</td>\r\n\t\t\t<td>" . $users_online->host . "</td>\r\n\t\t</tr>\r\n";
    }
    $out .= "</table>";
    return $out;
}
 function GenerateInlineMenu($PageID)
 {
     $sql = "SELECT *\r\n\t\t\t\tFROM " . DB_PREFIX . "inlinemenu_entries\r\n\t\t\t\tWHERE inlineentry_page_id={$PageID}\r\n\t\t\t\tORDER BY inlineentry_sortid ASC";
     $inlieMenuEntriesResult = $this->_SqlConnection->SqlQuery($sql);
     $inlieMenuHtml = "<ul>\r\n";
     while ($inlieMenuEntry = mysql_fetch_object($inlieMenuEntriesResult)) {
         if ($inlieMenuEntry->inlineentry_type == 'text') {
             $inlieMenuHtml .= "\t<li class=\"inline_text\">" . nl2br($inlieMenuEntry->inlineentry_text) . "</li>\r\n";
         } elseif ($inlieMenuEntry->inlineentry_type == 'link') {
             $inlieMenuHtml .= "\\<li class=\"inline_link\"><a href=\"{$inlieMenuEntry->inlineentry_link}\">{$inlieMenuEntry->inlineentry_text}</a></li>\r\n";
         } elseif ($inlieMenuEntry->inlineentry_type == 'intern') {
             $inlieMenuHtml .= "\t<li class=\"inline_intern\"><a href=\"{$inlieMenuEntry->inlineentry_link}\">{$inlieMenuEntry->inlineentry_text}</a></li>\r\n";
         } elseif ($inlieMenuEntry->inlineentry_type == 'download') {
             $sql = "SELECT *\r\n\t\t\t\t\t\tFROM " . DB_PREFIX . "files\r\n\t\t\t\t\t\tWHERE file_id={$inlieMenuEntry->inlineentry_link}\r\n\t\t\t\t\t\tLimit 0,1";
             $fileResult = $this->_SqlConnection->SqlQuery($sql);
             if ($file = mysql_fetch_object($fileResult)) {
                 if (file_exists($file->file_path)) {
                     $size = kbormb(filesize($file->file_path), false);
                     $inlieMenuHtml .= "\t<li class=\"inline_download\"><a href=\"download.php?file_id={$inlieMenuEntry->inlineentry_link}\" title=\"Download von &quot;{$file->file_name}&quot; bei einer Gr&ouml;&szlig;e von {$size}\">{$inlieMenuEntry->inlineentry_text}</a> (<span class=\"filesize\">{$size}</span>)</li>\r\n";
                 }
             }
         }
     }
     $inlieMenuHtml .= "</ul>\r\n";
     if ($inlieMenuHtml == "<ul>\r\n</ul>\r\n") {
         $inlieMenuHtml = '';
     }
     $sql = "UPDATE " . DB_PREFIX . "inlinemenu\r\n\t\t\t\tSET inlinemenu_html='{$inlieMenuHtml}'\r\n\t\t\t\tWHERE page_id='{$PageID}'";
     $this->_SqlConnection->SqlQuery($sql);
 }
 /**
  * Returns a formular to edit any errors if there are any or set the user back to showmenu page
  * @access private
  * @return string A template for a formular to edit the errors
  */
 function _CheckMenuEntry()
 {
     // Get external parameters
     $MenuID = GetPostOrGet('menu_id');
     $MenuEntryID = GetPostOrGet('menu_entry_id');
     $MenuEntryType = GetPostOrGet('menu_entry_type');
     $MenuEntryTitle = GetPostOrGet('menu_entry_title');
     $MenuEntryLink = GetPostOrGet('menu_entry_link');
     $MenuEntryCssID = GetPostOrGet('menu_entry_css_id');
     // Initialize the formmaker class
     $formMaker = new FormMaker($this->_Translation->GetTranslation('todo'), &$this->_SqlConnection);
     $formMaker->AddForm('check_menu_entry', 'admin.php', $this->_Translation->GetTranslation('save'), $this->_Translation->GetTranslation('add_menu_entry'), 'post');
     // Add hidden inputs to give some variables to next page
     $formMaker->AddHiddenInput('check_menu_entry', 'page', 'menueditor');
     $formMaker->AddHiddenInput('check_menu_entry', 'action', 'add_menu_entry');
     $formMaker->AddHiddenInput('check_menu_entry', 'menu_entry_type', $MenuEntryType);
     // Add the inputs to the formmakerclass
     $formMaker->AddInput('check_menu_entry', 'menu_id', 'select', $this->_Translation->GetTranslation('belongs_to_menu'), $this->_Translation->GetTranslation('this_is_the_menu_the_new_entry_should_be_added_to'));
     // Get the existing menus from the database
     $sql = "SELECT *\n\t\t\t\t\tFROM " . DB_PREFIX . "menu";
     $menuResult = $this->_SqlConnection->SqlQuery($sql);
     while ($menu = mysql_fetch_object($menuResult)) {
         // Add an entry for each existing menu
         $formMaker->AddSelectEntry('check_menu_entry', 'menu_id', $menu->menu_id == $MenuID ? true : false, $menu->menu_id, $menu->menu_id . ". " . $menu->menu_name);
     }
     $formMaker->AddInput('check_menu_entry', 'menu_entry_title', 'text', $this->_Translation->GetTranslation('menu_entry_title'), $this->_Translation->GetTranslation('this_is_the_title_of_the_menuentry_that_will_be_shown_in_the_menu'), $MenuEntryTitle);
     $formMaker->AddCheck('check_menu_entry', 'menu_entry_title', 'empty', $this->_Translation->GetTranslation('you_have_to_define_a_title_for_the_menu_entry'));
     if ($MenuEntryType == 'intern_link') {
         // Add select input for all pages in the system
         $formMaker->AddInput('check_menu_entry', 'menu_entry_link', 'select', $this->_Translation->GetTranslation('menu_entry_link'), $this->_Translation->GetTranslation('choose_here_the_page_to_which_the_link_should_refer'));
         // Add all existing pages to the select
         $pageStructure = new Pagestructure(&$this->_SqlConnection, &$this->_User, &$this->_ComaLib);
         $pageStructure->LoadParentIDs();
         $formMaker->AddSelectEntrysCode('check_menu_entry', 'menu_entry_link', $pageStructure->PageStructurePulldown(0, 0, '', -1, $MenuEntryLink));
     } elseif ($MenuEntryType == 'extern_link') {
         // Add input for the extern url
         $formMaker->AddInput('check_menu_entry', 'menu_entry_link', 'text', $this->_Translation->GetTranslation('menu_entry_link'), $this->_Translation->GetTranslation('type_here_the_url_of_the_page_to_link_to'), $MenuEntryLink);
         $formMaker->AddCheck('check_menu_entry', 'menu_entry_link', 'empty', $this->_Translation->GetTranslation('you_have_to_define_an_extern_url_for_this_link'));
     } elseif ($MenuEntryType == 'download') {
         // Add select input for the downloads
         $formMaker->AddInput('check_menu_entry', 'menu_entry_link', 'select', $this->_Translation->GetTranslation('download'), $this->_Translation->GetTranslation('choose_here_the_download_you_want_to_link_to'));
         // Add all existing files to the select input
         $sql = "SELECT *\n\t\t\t\t\t\tFROM " . DB_PREFIX . "files\n\t\t\t\t\t\tORDER BY file_name";
         $files_result = $this->_SqlConnection->SqlQuery($sql);
         while ($file = mysql_fetch_object($files_result)) {
             if (file_exists($file->file_path)) {
                 $formMaker->AddSelectEntry('check_menu_entry', 'menu_entry_link', $MenuEntryLink == $file->file_id ? true : false, $file->file_id, utf8_encode($file->file_name) . " (" . kbormb($file->file_size) . ")");
             }
         }
     }
     $formMaker->AddInput('check_menu_entry', 'menu_entry_css_id', 'text', $this->_Translation->GetTranslation('menu_entry_css'), $this->_Translation->GetTranslation('type_in_here_the_css_id_for_the_menuentry_if_you_need_one_for_it'));
     if ($formMaker->CheckInputs('check_menu_entry', true)) {
         if ($MenuEntryType == 'intern_link') {
             // Get the name of the page
             $sql = "SELECT *\n\t\t \t\t\t\tFROM " . DB_PREFIX . "pages\n\t \t\t\t\t\tWHERE page_id='{$MenuEntryLink}'";
             $pageResult = $this->_SqlConnection->SqlQuery($sql);
             if ($page = mysql_fetch_object($pageResult)) {
                 $PageID = $MenuEntryLink;
                 $MenuEntryLink = $page->page_name;
             }
         } else {
             $PageID = '';
         }
         // Add new user to the database
         $sql = "UPDATE " . DB_PREFIX . "menu_entries\n\t\t\t\t\t\tSET menu_entries_link='" . ($MenuEntryType == 'intern_link' ? 'l:' : ($MenuEntryType == 'download' ? 'd:' : ($MenuEntryType == 'extern_link' ? 'e:' : ''))) . "{$MenuEntryLink}', \n\t\t\t\t\t\t\tmenu_entries_title='{$MenuEntryTitle}', \n\t\t\t\t\t\t\tmenu_entries_type='{$MenuEntryType}', \n\t\t\t\t\t\t\tmenu_entries_css_id='{$MenuEntryCssID}', \n\t\t\t\t\t\t\tmenu_entries_menuid='{$MenuID}', \n\t\t\t\t\t\t\tmenu_entries_page_id='{$PageID}'\n\t\t\t\t\t\tWHERE menu_entries_id='{$MenuEntryID}'";
         $this->_SqlConnection->SqlQuery($sql);
         // Set user to the HomePage of the usermanager
         $template = "\r\n\t\t\t\t" . $this->_ShowMenu($MenuID);
         return $template;
     } else {
         // Generate to edit the errors
         $template = "\r\n\t\t\t\t" . $formMaker->GenerateMultiFormTemplate(&$this->_ComaLate, true);
         return $template;
     }
 }
    /**
     * mainpage with an overview over all files and a form to select 3 files for an upload
     * @access private
     */
    function _homePage()
    {
        $path = GetPostOrGet('path');
        if (substr($path, -1, 1) == '/') {
            $path = substr($path, 0, -1);
        }
        $pathPart = explode('/', $path);
        array_pop($pathPart);
        $uppath = implode('/', $pathPart);
        $pathLen = strlen($path);
        $out = "\t\t\t<fieldset>\n\t \t\t\t<legend>" . $this->_Translation->GetTranslation('upload') . "</legend>\n\t\t\t\t<form enctype=\"multipart/form-data\" action=\"admin.php?page=files\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1600000\" />\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"upload\" />\n\t\t\t\t\t<input type=\"hidden\" name=\"path\" value=\"" . $path . "\" />\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t<strong>" . $this->_Translation->GetTranslation('file') . " 1:</strong>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t<input name=\"uploadfile0\" type=\"file\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t<strong>" . $this->_Translation->GetTranslation('file') . " 2:</strong>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t<input name=\"uploadfile1\" type=\"file\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t<strong>" . $this->_Translation->GetTranslation('file') . " 3:</strong>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t<input name=\"uploadfile2\" type=\"file\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"" . $this->_Translation->GetTranslation('upload_files') . "\"/>\n\t\t\t\t\t</div>\n\t\t\t\t</form>\n\t\t\t\t<div class=\"row\">\n\t\t\t\t\t<a href=\"admin.php?page=files&amp;action=check_new_files\" class=\"button\">" . $this->_Translation->GetTranslation('check_for_changes') . "</a>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t<fieldset>\n\t \t\t\t<legend>" . $this->_Translation->GetTranslation('create_directory') . "</legend>\n\t\t\t\t<form action=\"admin.php?page=files\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"new_dir\" />\n\t\t\t\t\t<input type=\"hidden\" name=\"path\" value=\"" . $path . "\" />\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t<strong>" . $this->_Translation->GetTranslation('directory') . " </strong>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t<input name=\"dirname\" type=\"text\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t\n\t\t\t\t\t<div class=\"row\">\n\t\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"" . $this->_Translation->GetTranslation('create_directory') . "\"/>\n\t\t\t\t\t</div>\n\t\t\t\t</form>\n\t\t\t</fieldset>\t<h3>Pfad: /" . $path . "</h3>";
        if ($pathLen > 0) {
            $out .= "\n\t\t\t\t<div class=\"row\">\n\t\t\t\t\t<a href=\"admin.php?page=files&amp;path=" . $uppath . "\" class=\"button\">" . $this->_Translation->GetTranslation('directory_up') . "</a>\n\t\t\t\t</div>";
        }
        $out .= "\n\t\t\t<table id=\"files\" class=\"text_table full_width\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('preview') . "\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th>\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filename#files\" title=\"" . @sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filename')) . "\"><img alt=\"[" . @sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filename')) . "]\" src=\"img/up.png\"/></a>\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('filename') . "\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filename&amp;desc=1#files\" title=\"" . @sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filename')) . "\"><img alt=\"[" . @sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filename')) . "]\" src=\"img/down.png\"/></a>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th class=\"small_width\">\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filesize#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filesize')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filesize')) . "]\" src=\"img/up.png\"/></a>\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('filesize') . "\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filesize&amp;desc=1#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filesize')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filesize')) . "]\" src=\"img/down.png\"/></a>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th class=\"table_date_width_plus\">\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filedate#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('date')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('date')) . "]\" src=\"img/up.png\"/></a>\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('uploaded_on') . "\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filedate&amp;desc=1#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('date')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('date')) . "]\" src=\"img/down.png\"/></a>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th class=\"small_width\">\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filetype#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filetype')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('filetype')) . "]\" src=\"img/up.png\"/></a>\n\t\t\t\t\t\t\t" . $this->_Translation->GetTranslation('filetype') . "\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filetype&amp;desc=1#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filetype')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('filetype')) . "]\" src=\"img/down.png\"/></a>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th class=\"table_mini_width\">\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filedownloads#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('downloads')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_ascending_by_%name%'), $this->_Translation->GetTranslation('downloads')) . "]\" src=\"img/up.png\"/></a>\n\t\t\t\t\t\t\t<abbr title=\"" . $this->_Translation->GetTranslation('downloads') . "\">" . $this->_Translation->GetTranslation('downl') . "</abbr>\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;order=filedownloads&amp;desc=1#files\" title=\"" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('downloads')) . "\"><img alt=\"[" . sprintf($this->_Translation->GetTranslation('sort_descending_by_%name%'), $this->_Translation->GetTranslation('downloads')) . "]\" src=\"img/down.png\"/></a>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<th class=\"actions\">" . $this->_Translation->GetTranslation('actions') . "</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t\r\n";
        $dateDayFormat = $this->_Config->Get('date_day_format', 'd.m.Y');
        $dateTimeFormat = $this->_Config->Get('date_time_format', 'H:i:s');
        $dateFormat = $dateDayFormat . ' ' . $dateTimeFormat;
        $thumbnailfolder = $this->_Config->Get('thumbnailfolder', 'data/thumbnails/');
        $files = new Files($this->_SqlConnection, $this->_User);
        $order = FILES_NAME;
        $ascending = true;
        $orderByGet = GetPostOrGet('order');
        $desc = GetPostOrGet('desc');
        switch ($orderByGet) {
            case 'filesize':
                $order = FILES_SIZE;
                break;
            case 'filedate':
                $order = FILES_DATE;
                break;
            case 'filetype':
                $order = FILES_TYPE;
                break;
            case 'filedownloads':
                $order = FILES_DOWNLOADS;
                break;
            case 'filename':
            default:
                $order = FILES_NAME;
                break;
        }
        // descending or ascending?
        if ($desc == 1) {
            $ascending = false;
        }
        // get all files from the database/ which are registered in the database
        $filesArrayTmp = $files->FillArray($order, $ascending);
        //print str_replace('  ','&nbsp;&nbsp;',nl2br(print_r($fileArray, true)));
        //die();
        $filesCount = count($filesArrayTmp);
        $filesArray = array();
        for ($i = 0; $i < $filesCount; $i++) {
            $fileArray = $filesArrayTmp[$i];
            if (substr($fileArray['FILE_NAME'], 0, $pathLen) == $path && strlen($fileArray['FILE_NAME']) > $pathLen && !strpos($fileArray['FILE_NAME'], '/', $pathLen + 1)) {
                $fileArray['FILE_SIZE'] = kbormb($fileArray['FILE_SIZE']);
                $fileArray['FILE_DATE'] = date($dateFormat, $fileArray['FILE_DATE']);
                $fileArray['FILE_DOWNLOAD_FILE'] = sprintf($this->_Translation->GetTranslation('download_file_%file%'), $fileArray['FILE_NAME']);
                $fileArray['FILE_DELETE_FILE'] = sprintf($this->_Translation->GetTranslation('delete_file_%file%'), $fileArray['FILE_NAME']);
                $fileArray['FILE_MOVE_FILE'] = sprintf($this->_Translation->GetTranslation('move_file_%file%'), $fileArray['FILE_NAME']);
                $preview = '';
                if (strpos($fileArray['FILE_TYPE'], 'image/') === 0) {
                    $image = new ImageConverter($fileArray['FILE_PATH']);
                    // max: 100px;
                    $maximum = 100;
                    $size = $image->CalcSizeByMax($maximum);
                    $imageUrl = $image->SaveResizedTo($size[0], $size[1], $thumbnailfolder, $size[0] . 'x' . $size[1] . '_');
                    if (file_exists($imageUrl)) {
                        $preview = "<img alt=\"{$fileArray['FILE_NAME']}\" src=\"" . generateUrl($imageUrl) . "\" />";
                    }
                }
                $fileArray['FILE_PREVIEW'] = $preview;
                if ($pathLen > 0) {
                    $fileArray['FILE_NAME'] = substr($fileArray['FILE_NAME'], $pathLen + 1);
                }
                if ($fileArray['FILE_TYPE'] == 'dir') {
                    $det = $pathLen > 0 ? '/' : '';
                    $fileArray['FILE_NAME'] = '<a href="admin.php?page=files&amp;path=' . $path . $det . $fileArray['FILE_NAME'] . '">' . $fileArray['FILE_NAME'] . '</a>';
                }
                $fileArray['FILE_ACTION'] = '';
                if ($fileArray['FILE_TYPE'] != 'dir') {
                    $file_id = $fileArray['FILE_ID'];
                    $fileArray['FILE_ACTION'] .= '<a href="download.php?file_id=' . $file_id . '" ><img src="img/download.png" alt="[' . $fileArray['FILE_DOWNLOAD_FILE'] . ']" title="' . $fileArray['FILE_DOWNLOAD_FILE'] . '"/></a>';
                    $fileArray['FILE_ACTION'] .= '<a href="admin.php?page=files&amp;action=move&amp;file_id=' . $file_id . '" ><img src="img/restore.png" alt="[' . $fileArray['FILE_MOVE_FILE'] . ']" title="' . $fileArray['FILE_MOVE_FILE'] . '"/></a>';
                }
                $filesArray[] = $fileArray;
            }
        }
        $this->_ComaLate->SetReplacement('FILES', $filesArray);
        $this->_ComaLate->SetReplacement('SIZE_COUNT', kbormb($files->SizeCount));
        $this->_ComaLate->SetReplacement('LANG_ALTOGETHER', $this->_Translation->GetTranslation('altogether'));
        $out .= '<FILES:loop>
					<tr>
						<td>{FILE_PREVIEW}</td>
						<td>{FILE_NAME}</td>
						<td>{FILE_SIZE}</td>
						<td>{FILE_DATE}</td>
						<td>{FILE_TYPE}</td>
						<td>{FILE_DOWNLOADS}</td>
						<td>{FILE_ACTION}
						<a href="admin.php?page=files&amp;action=delete&amp;file_id={FILE_ID}" ><img src="img/del.png" alt="[{FILE_DELETE_FILE}]" title="{FILE_DELETE_FILE}" /></a></td>
					</tr>
					</FILES>
				</table>
				{LANG_ALTOGETHER} {SIZE_COUNT}';
        return $out;
    }
    /**
     * @access public
     * @param string $Action This parameter is without a function
     * @return string
     */
    function GetPage($Action = '')
    {
        // get some config-values
        $dateDayFormat = $this->_Config->Get('date_day_format', 'd.m.Y');
        $dateTimeFormat = $this->_Config->Get('date_time_format', 'H:i:s');
        $dateFormat = $dateDayFormat . ' ' . $dateTimeFormat;
        // get the number of pages which aren't deleted
        $sql = "SELECT page_id\n\t\t\t\t\tFROM " . DB_PREFIX . "pages\n\t\t\t\t\tWHERE page_access != 'deleted'";
        $pagesResult = $this->_SqlConnection->SqlQuery($sql);
        $pagesCount = mysql_num_rows($pagesResult);
        // get the number of all pages saved in the history
        $sql = "SELECT page_id\n\t\t\t\t\tFROM " . DB_PREFIX . "pages_history";
        $historyPagesResult = $this->_SqlConnection->SqlQuery($sql);
        $historyPagesCount = mysql_num_rows($historyPagesResult);
        // get the number of all registered users
        $sql = "SELECT user_id\n\t\t\t\t\tFROM " . DB_PREFIX . "users";
        $usersResult = $this->_SqlConnection->SqlQuery($sql);
        $usersCount = mysql_num_rows($usersResult);
        // get the size of all tables with the prefix DB_PREFIX
        $sql = "SHOW TABLE STATUS";
        $tableInfoResult = $this->_SqlConnection->SqlQuery($sql);
        $dataSize = 0;
        while ($tableInfo = mysql_fetch_object($tableInfoResult)) {
            if (substr($tableInfo->Name, 0, strlen(DB_PREFIX)) == DB_PREFIX) {
                $dataSize += $tableInfo->Data_length + $tableInfo->Index_length;
            }
        }
        // get the date of the installation or set one
        $installDate = $this->_Config->Get('install_date');
        if ($installDate == '') {
            $this->_Config->Save('install_date', mktime());
            $installDate = mktime();
        }
        // set replacements for translations
        $this->_ComaLate->SetReplacement('ADMIN_CONTROL_TITLE', $this->_Translation->GetTranslation('admincontrol'));
        $this->_ComaLate->SetReplacement('LOG_TITLE_DATE', $this->_Translation->GetTranslation('date'));
        $this->_ComaLate->SetReplacement('LOG_TITLE_PAGE', $this->_Translation->GetTranslation('page'));
        $this->_ComaLate->SetReplacement('LOG_TITLE_USER', $this->_Translation->GetTranslation('user'));
        $this->_ComaLate->SetReplacement('LOG_TITLE_COMMENT', $this->_Translation->GetTranslation('comment'));
        $this->_ComaLate->SetReplacement('ADMIN_CONTROL_LAST_CHANGES', $this->_Translation->GetTranslation('last_changes'));
        $this->_ComaLate->SetReplacement('USER_TITLE_NAME', $this->_Translation->GetTranslation('name'));
        $this->_ComaLate->SetReplacement('USER_TITLE_PAGE', $this->_Translation->GetTranslation('page'));
        $this->_ComaLate->SetReplacement('USER_TITLE_LAST_ACTION', $this->_Translation->GetTranslation('last_action'));
        $this->_ComaLate->SetReplacement('USER_TITLE_LANGUAGE', $this->_Translation->GetTranslation('language'));
        $this->_ComaLate->SetReplacement('USER_TITLE_IP', $this->_Translation->GetTranslation('ip'));
        $this->_ComaLate->SetReplacement('USER_TITLE_HOST', $this->_Translation->GetTranslation('host'));
        $this->_ComaLate->SetReplacement('ADMIN_CONTROL_USERS', $this->_Translation->GetTranslation('visitors'));
        // fill the table with some statistical data
        $adminControlStats = array();
        $adminControlStats[] = array('STATS_NAME' => $this->_Translation->GetTranslation('online_since'), 'STATS_VALUE' => date($dateDayFormat, $installDate));
        $adminControlStats[] = array('STATS_NAME' => $this->_Translation->GetTranslation('registered_users'), 'STATS_VALUE' => $usersCount);
        $adminControlStats[] = array('STATS_NAME' => $this->_Translation->GetTranslation('created_pages'), 'STATS_VALUE' => $pagesCount);
        $adminControlStats[] = array('STATS_NAME' => $this->_Translation->GetTranslation('saved_page_modifications'), 'STATS_VALUE' => $historyPagesCount);
        $adminControlStats[] = array('STATS_NAME' => $this->_Translation->GetTranslation('database_size'), 'STATS_VALUE' => kbormb($dataSize));
        $this->_ComaLate->SetReplacement('ADMIN_CONTROL_STATS', $adminControlStats);
        $pages = array();
        // get the last 6 pages
        $sql = "SELECT page_name, page_title, page_creator, page_edit_comment, page_date\n\t\t\t\t\tFROM " . DB_PREFIX . "pages\n\t\t\t\t\tORDER BY page_date DESC\n\t\t\t\t\tLIMIT 6";
        $pagesResult = $this->_SqlConnection->SqlQuery($sql);
        while ($page = mysql_fetch_object($pagesResult)) {
            $pages[$page->page_date] = array($page->page_name, $page->page_title, $page->page_creator, $page->page_edit_comment);
        }
        // get the last 6 pages of the history
        $sql = "SELECT page_name, page_title, page_creator, page_edit_comment, page_date\n\t\t\t\t\tFROM " . DB_PREFIX . "pages_history\n\t\t\t\t\tORDER BY page_date DESC\n\t\t\t\t\tLIMIT 6";
        $pagesResult = $this->_SqlConnection->SqlQuery($sql);
        while ($page = mysql_fetch_object($pagesResult)) {
            $pages[$page->page_date] = array($page->page_name, $page->page_title, $page->page_creator, $page->page_edit_comment);
        }
        krsort($pages);
        $logData = array();
        $count = 0;
        foreach ($pages as $date => $page) {
            $logData[] = array('LOG_DATE' => date($dateFormat, $date), 'LOG_PAGE_URL' => $page[0], 'LOG_PAGE_TITLE' => $page[1], 'LOG_PAGE_NAME' => rawurldecode($page[0]), 'LOG_USER' => $this->_ComaLib->GetUserByID($page[2]), 'LOG_COMMENT' => $page[3]);
            if ($count++ == 5) {
                break;
            }
        }
        $this->_ComaLate->SetReplacement('ADMIN_CONTROL_LOG', $logData);
        // get all visitors of the page which moved in the last 5 minutes
        $sql = "SELECT online_userid, online_page, online_lastaction, online_lang, online_ip, online_host\n\t\t\t\t\tFROM " . DB_PREFIX . "online\n\t\t\t\t\tWHERE online_lastaction >= " . (mktime() - 300) . "\n\t\t\t\t\tORDER BY online_userid";
        $usersOnlineResult = $this->_SqlConnection->SqlQuery($sql);
        $usersData = array();
        while ($userOnline = mysql_fetch_object($usersOnlineResult)) {
            if ($userOnline->online_userid == 0) {
                $username = $this->_Translation->GetTranslation('not_registered');
            } else {
                $username = $this->_ComaLib->GetUserByID($userOnline->online_userid);
            }
            $usersData[] = array('USER_NAME' => $username, 'USER_PAGE' => $userOnline->online_page, 'USER_LAST_ACTION' => date($dateFormat, $userOnline->online_lastaction), 'USER_LANGUAGE' => $this->_Translation->GetTranslation($userOnline->online_lang), 'USER_IP' => $userOnline->online_ip, 'USER_HOST' => $userOnline->online_host);
        }
        $this->_ComaLate->SetReplacement('ADMIN_CONTROL_USERS', $usersData);
        // throw out the temlate-data
        $template = '<h2>{ADMIN_CONTROL_TITLE}</h2>
					<table>
					<ADMIN_CONTROL_STATS:loop>
						<tr>
							<th>{STATS_NAME}:</th>
							<td>{STATS_VALUE}</td>
						</tr>
					</ADMIN_CONTROL_STATS>
					</table>
					<h2>{ADMIN_CONTROL_LAST_CHANGES}</h2>
					<table class="full_width">
						<tr>
							<th>{LOG_TITLE_DATE}</th>
							<th>{LOG_TITLE_PAGE}</th>
							<th>{LOG_TITLE_USER}</th>
							<th>{LOG_TITLE_COMMENT}</th>
						</tr>
					<ADMIN_CONTROL_LOG:loop>
						<tr>
							<td>{LOG_DATE}</td>
							<td><a href="index.php?page={LOG_PAGE_URL}">{LOG_PAGE_TITLE}</a>({LOG_PAGE_NAME})</td>
							<td>{LOG_USER}</td>
							<td>{LOG_COMMENT}</td>
						</tr>
					</ADMIN_CONTROL_LOG>
					</table>
					<h2>{ADMIN_CONTROL_USERS}</h2>
					<table class="full_width">
						<tr>
						<th>{USER_TITLE_NAME}</th>
						<th>{USER_TITLE_PAGE}</th>
						<th>{USER_TITLE_LAST_ACTION}</th>
						<th>{USER_TITLE_LANGUAGE}</th>
						<th>{USER_TITLE_IP}</th>
						<th>{USER_TITLE_HOST}</th>
						</tr>
						<ADMIN_CONTROL_USERS:loop>
						<tr>
						<td>{USER_NAME}</td>
						<td><a href="index.php?page={USER_PAGE}">{USER_PAGE}</a></td>
						<td>{USER_LAST_ACTION}</td>
						<td>{USER_LANGUAGE}</td>
						<td>{USER_IP}</td>
						<td>{USER_HOST}</td>
						</tr>
						</ADMIN_CONTROL_USERS>
					</table>';
        return $template;
    }
 /**
  * @param integer PageID
  * @return string
  * @access private
  */
 function _InlineMenuAddNewEntryDialogPage($PageID)
 {
     $adminLang =& $this->_AdminLang;
     // Get data from header
     $type = GetPostOrGet('type');
     $out = '';
     if ($type == 'link') {
         $out .= "<form action=\"admin.php\" method=\"post\">\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"page\" value=\"pagestructure\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"pageInlineMenu\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"pageID\" value=\"{$PageID}\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"action2\" value=\"addNewEntry\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"type\" value=\"link\" />\r\n\t\t\t\t\t\t<fieldset>\r\n\t\t\t\t\t\t<legend>Erstelle neuen InlineMen&uuml;-Interner-Link:</legend>\r\n\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t<label>Link-Titel:\r\n\t\t\t\t\t\t\t\t<span class=\"info\">Ein wenig Text der den Link deutlich macht.</span>\r\n\t\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t\t<input type=\"text\" name=\"text\" value=\"\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t<label>Link:\r\n\t\t\t\t\t\t\t\t<span class=\"info\">Hier kommt die URL hin die den Link sp&auml;ter ergibt.</span>\r\n\t\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t\t<input type=\"text\" name=\"link\" value=\"http://\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t<input type=\"reset\" class=\"button\" value=\"Zur&uuml;cksetzen\" />\r\n\t\t\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"Speichern\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</fieldset>\r\n\t\t\t\t\t\t</form>";
     } else {
         if ($type == 'text') {
             $out .= "<form action=\"admin.php\" method=\"post\">\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"page\" value=\"pagestructure\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"pageInlineMenu\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"pageID\" value=\"{$PageID}\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"action2\" value=\"addNewEntry\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"type\" value=\"text\" />\r\n\t\t\t\t\t\t<fieldset>\r\n\t\t\t\t\t\t<legend>Erstelle neuen InlineMen&uuml;-Text:</legend>\r\n\t\t\t\t\t\t<div class=\"row\"><label>Text: <span class=\"info\">Das ist der Text, der sp&auml;ter angezeigt werden soll</span></label>\r\n\t\t\t\t\t\t\t<textarea name=\"text\"></textarea></div>\r\n\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t<input type=\"reset\" class=\"button\" value=\"Zur&uuml;cksetzen\" />\r\n\t\t\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"Speichern\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</fieldset>\r\n\t\t\t\t\t\t</form>";
         } else {
             if ($type == 'intern') {
                 $out .= "<form action=\"admin.php\" method=\"post\">\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"page\" value=\"pagestructure\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"pageInlineMenu\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"pageID\" value=\"{$PageID}\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"action2\" value=\"addNewEntry\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"type\" value=\"intern\" />\r\n\t\t\t\t\t\t<fieldset>\r\n\t\t\t\t\t\t<legend>Erstelle neuen InlineMen&uuml;-Interner-Link:</legend>\r\n\t\t\t\t\t\t<div class=\"row\"><label>Link-Titel<span class=\"info\">Ein wenig Text der den Link deutlich macht.</span></label><input type=\"text\" name=\"text\" value=\"\" /></div>\r\n\t\t\t\t\t\t<div class=\"row\"><label>Interne Seite<span class=\"info\">Das ist die interne Seite, auf die der Link sp&auml;ter f&uuml;hren soll.</span></label><select name=\"link\">";
                 $out .= $this->_PageStructure->LoadParentIDs();
                 $out .= $this->_PageStructure->PageStructurePulldown(0);
                 $out .= "</select></div>\r\n\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t<input type=\"reset\" class=\"button\" value=\"" . $adminLang['reset'] . "\" />\r\n\t\t\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"" . $adminLang['save'] . "\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</fieldset>\r\n\t\t\t\t\t\t</form>";
             } else {
                 if ($type == 'download') {
                     $out .= "<form action=\"admin.php\" method=\"post\">\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"page\" value=\"pagestructure\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"pageInlineMenu\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"pageID\" value=\"{$PageID}\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"action2\" value=\"addNewEntry\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"type\" value=\"download\" />\r\n\t\t\t\t\t\t<fieldset>\r\n\t\t\t\t\t\t\t<legend>Download Hinzuf&uuml;gen</legend>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t<label class=\"row\" for=\"download_text\">\r\n\t\t\t\t\t\t\t\tDownload-Titel:\r\n\t\t\t\t\t\t\t\t<span class=\"info\">Der Text wird als Downloadlink angezeigt er kann zum Beispiel der Dateiname sein, aber auch ein kuzer eindeutiger Text ist sehr sinnvoll.</span>\r\n\t\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t\t<input type=\"text\" name=\"text\" id=\"download_text\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t<label class=\"row\" for=\"link\">\r\n\t\t\t\t\t\t\t\tDatei f&uuml;r den Download:\r\n\t\t\t\t\t\t\t\t<span class=\"info\">Die hier angegebene Datei kann dann sp&auml;ter heruntergeladen werden.</span>\r\n\t\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t\t<select name=\"link\" id=\"link\">";
                     $sql = "SELECT *\r\n\t\t\t\t\t\tFROM " . DB_PREFIX . "files\r\n\t\t\t\t\t\tORDER BY file_name";
                     $files_result = db_result($sql);
                     while ($file = mysql_fetch_object($files_result)) {
                         if (file_exists($file->file_path)) {
                             $out .= "<option value=\"{$file->file_id}\">" . utf8_encode($file->file_name) . " (" . kbormb($file->file_size) . ")</option>\r\n";
                         }
                     }
                     $out .= "</select>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div class=\"row\"><input type=\"reset\" class=\"button\" value=\"Zur&uuml;cksetzen\" /><input type=\"submit\" class=\"button\" value=\"Speichern\" /></div>\r\n\t\t\t\t\t\t</fieldset>\r\n\t\t\t\t\t\t</form>";
                 } else {
                     $out = "<form action=\"admin.php\" method=\"post\">\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"page\" value=\"pagestructure\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"pageInlineMenu\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"pageID\" value=\"{$PageID}\" />\r\n\t\t\t\t\t\t<input type=\"hidden\" name=\"action2\" value=\"addNewEntryDialog\" />\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t<fieldset>\r\n\t\t\t\t\t\t\t<legend>Eintrags-Typ:</legend>\r\n\t\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t\t<label for=\"type_link\">\r\n\t\t\t\t\t\t\t\t\tLink:\r\n\t\t\t\t\t\t\t\t\t<span class=\"info\">TODO</span>\r\n\t\t\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t\t\t<input id=\"type_link\" type=\"radio\" name=\"type\" value=\"link\" checked=\"checked\"/>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t\t<label for=\"type_text\">\r\n\t\t\t\t\t\t\t\t\tText:\r\n\t\t\t\t\t\t\t\t\t<span class=\"info\">TODO</span>\r\n\t\t\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t\t\t<input id=\"type_text\" type=\"radio\" name=\"type\" value=\"text\"/>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t\t<label for=\"type_intern\">\r\n\t\t\t\t\t\t\t\t\tInterner-Link:\r\n\t\t\t\t\t\t\t\t\t<span class=\"info\">TODO</span>\r\n\t\t\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t\t\t<input id=\"type_intern\" type=\"radio\" name=\"type\" value=\"intern\"/>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t\t<label for=\"type_download\">\r\n\t\t\t\t\t\t\t\t\tDownload:\r\n\t\t\t\t\t\t\t\t\t<span class=\"info\">TODO</span>\r\n\t\t\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t\t\t<input id=\"type_download\" type=\"radio\" name=\"type\" value=\"download\"/>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"Weiter\" />\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</fieldset>\r\n\t\t\t\t\t\t</form>";
                 }
             }
         }
     }
     return $out;
 }
function page_files()
{
    global $_SERVER, $_FILES, $extern_action, $admin_lang, $extern_file_id, $extern_sure;
    $out = "Files<br />";
    $upload_path = './data/upload/';
    if ($extern_action == 'upload') {
        foreach ($_FILES as $name => $file) {
            if (startsWith($name, 'uploadfile')) {
                $nr = substr($name, -1);
                if ($nr < 5) {
                    $save_path = $upload_path . $file['name'];
                    if (file_exists($save_path)) {
                        $save_path = $upload_path . uniqid() . $file['name'];
                    }
                    if ($file['error'] == 0) {
                        //
                        // TODO:dont allow an upload if a file with the same md5 exists
                        //
                        $file_md5 = md5_file($file['tmp_name']);
                        $sql = "SELECT file_name\r\n\t\t\t\t\t\t\t\tFROM " . DB_PREFIX . "files\r\n\t\t\t\t\t\t\t\tWHERE file_md5='{$file_md5}'";
                        $md5exists_result = db_result($sql);
                        if ($md5exists = mysql_fetch_object($md5exists_result)) {
                            $out .= "Die Datei <strong>&quot;" . $file['name'] . "&quot;</strong> ist bereits hochgeladen worden (&quot;{$md5exists->file_name}&quot;)";
                        } else {
                            move_uploaded_file($file['tmp_name'], $save_path);
                            $sql = "INSERT INTO " . DB_PREFIX . "files (file_name, file_type, file_path, file_size, file_md5, file_date)\r\n\t\t\t\t\t\t\t\t\tVALUES('" . $file['name'] . "', '" . $file['type'] . "', '{$save_path}', '" . filesize($save_path) . "', '" . md5_file($save_path) . "', " . mktime() . ")";
                            db_result($sql);
                        }
                    } else {
                        $out .= "Die Datei konnte nicht hochgeladen werden";
                    }
                }
            }
        }
    } elseif ($extern_action == 'delete') {
        if ($extern_file_id != '') {
            $sql = "SELECT *\r\n\t\t\t\t\tFROM " . DB_PREFIX . "files\r\n\t\t\t\t\tWHERE file_id = {$extern_file_id}";
            $file_result = db_result($sql);
            $file = mysql_fetch_object($file_result);
            if ($extern_sure) {
                $sql = "DELETE FROM " . DB_PREFIX . "files\r\n\t\t\t\t\tWHERE file_id = {$extern_file_id}";
                db_result($sql);
                unlink($file->file_path);
                //delete
                //unlink()
            } else {
                $out .= "Sind sie sicher, dass sie die Datei &quot;{$file->file_name}&quot; unwiederruflich löschen wollen?<br />\r\n\t\t\t\t\tDie Datei wurde am " . date('d.m.Y', $file->file_date) . " um " . date('H:i:s', $file->file_date) . " hochgeladen.<br />\r\n\t\t\t\t\t<a href=\"" . $_SERVER['PHP_SELF'] . "?page=files&amp;action=delete&amp;file_id=" . $extern_file_id . "&amp;sure=1\" title=\"Wirklich Löschen\">" . $admin_lang['yes'] . "</a> &nbsp;&nbsp;&nbsp;&nbsp;\r\n\t\t\t\t\t<a href=\"" . $_SERVER['PHP_SELF'] . "?page=files\" title=\"Nicht Löschen\">" . $admin_lang['no'] . "</a>";
                return $out;
            }
        }
    }
    $out .= "<form enctype=\"multipart/form-data\" action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\">\r\n\t\t\t<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1600000\" />\r\n\t\t\t<input type=\"hidden\" name=\"page\" value=\"files\" />\r\n\t\t\t<input type=\"hidden\" name=\"action\" value=\"upload\" />\r\n\t\t\t<input name=\"uploadfile0\" type=\"file\" />\r\n\t\t\t<input type=\"submit\" value=\"Hochladen\"/>\r\n\t\t</form>";
    $out .= "\r\n\t\t[Auf Veränderungen überprüfen]\r\n\t\t<table>\r\n\t\t<tr><td>id</td><td>Name</td><td>Größe</td><td>Hochgeladen am</td><td>Typ</td><td>Aktionen</td></tr>";
    $sql = "SELECT *\r\n\t\t\tFROM " . DB_PREFIX . "files\r\n\t\t\tORDER BY file_date DESC";
    $files_result = db_result($sql);
    $completesize = 0;
    while ($file = mysql_fetch_object($files_result)) {
        $out .= "<tr>\r\n\t\t\t\t<td>#{$file->file_id}</td>\r\n\t\t\t\t<td>{$file->file_name}</td>\r\n\t\t\t\t<td>" . kbormb($file->file_size) . "</td>\r\n\t\t\t\t<td>" . date('d.m.Y H:i:s', $file->file_date) . "</td>\r\n\t\t\t\t<td>{$file->file_type}</td>\r\n\t\t\t\t<td><a href=\"" . $_SERVER['PHP_SELF'] . "?page=files&amp;action=delete&amp;file_id={$file->file_id}\" ><img src=\"./img/del.jpg\" height=\"16\" width=\"16\" alt=\"" . $admin_lang['delete'] . "\" title=\"" . $admin_lang['delete'] . "\"/></a>\r\n\t\t\t</tr>\r\n";
        $completesize += $file->file_size;
    }
    $out .= "</table>";
    $out .= "Insgesammt " . kbormb($completesize) . ".";
    return $out;
}
 /**
  * mainpage with an overview over all files and a form to select 3 files for an upload
  * @access private
  */
 function _homePage()
 {
     $out = "\t\t\t<fieldset>\r\n\t \t\t\t<legend>{$this->_AdminLang['upload']}</legend>\r\n\t\t\t\t<form enctype=\"multipart/form-data\" action=\"admin.php?page=files\" method=\"post\">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1600000\" />\r\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"upload\" />\r\n\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t<label>\r\n\t\t\t\t\t\t\t<strong>{$this->_AdminLang['file']} 1:</strong>\r\n\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t<input name=\"uploadfile0\" type=\"file\" />\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t<label>\r\n\t\t\t\t\t\t\t<strong>{$this->_AdminLang['file']} 2:</strong>\r\n\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t<input name=\"uploadfile1\" type=\"file\" />\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t<label>\r\n\t\t\t\t\t\t\t<strong>{$this->_AdminLang['file']} 3:</strong>\r\n\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t<input name=\"uploadfile2\" type=\"file\" />\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t<input type=\"submit\" class=\"button\" value=\"{$this->_AdminLang['upload_files']}\"/>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</form>\r\n\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t<a href=\"admin.php?page=files&amp;action=check_new_files\" class=\"button\">{$this->_AdminLang['check_for_changes']}</a>\r\n\t\t\t\t</div>\r\n\t\t\t</fieldset>\r\n\t\t\t<table id=\"files\" class=\"text_table full_width\">\r\n\t\t\t\t<thead>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<th>\r\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;sort=filename#files\" title=\"" . sprintf($this->_AdminLang['sort_ascending_by_%name%'], $this->_AdminLang['filename']) . "\"><img alt=\"[" . sprintf($this->_AdminLang['sort_ascending_by_%name%'], $this->_AdminLang['filename']) . "]\" src=\"img/up.png\"/></a>\r\n\t\t\t\t\t\t\t{$this->_AdminLang['filename']}\r\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;sort=filename&amp;desc=1#files\" title=\"" . sprintf($this->_AdminLang['sort_descending_by_%name%'], $this->_AdminLang['filename']) . "\"><img alt=\"[" . sprintf($this->_AdminLang['sort_descending_by_%name%'], $this->_AdminLang['filename']) . "]\" src=\"img/down.png\"/></a>\r\n\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t<th class=\"small_width\">\r\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;sort=filesize#files\" title=\"" . sprintf($this->_AdminLang['sort_ascending_by_%name%'], $this->_AdminLang['filesize']) . "\"><img alt=\"[" . sprintf($this->_AdminLang['sort_ascending_by_%name%'], $this->_AdminLang['filesize']) . "]\" src=\"img/up.png\"/></a>\r\n\t\t\t\t\t\t\t{$this->_AdminLang['filesize']}\r\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;sort=filesize&amp;desc=1#files\" title=\"" . sprintf($this->_AdminLang['sort_descending_by_%name%'], $this->_AdminLang['filesize']) . "\"><img alt=\"[" . sprintf($this->_AdminLang['sort_descending_by_%name%'], $this->_AdminLang['filesize']) . "]\" src=\"img/down.png\"/></a>\r\n\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t<th class=\"table_date_width_plus\">\r\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;sort=filedate#files\" title=\"" . sprintf($this->_AdminLang['sort_ascending_by_%name%'], $this->_AdminLang['date']) . "\"><img alt=\"[" . sprintf($this->_AdminLang['sort_ascending_by_%name%'], $this->_AdminLang['date']) . "]\" src=\"img/up.png\"/></a>\r\n\t\t\t\t\t\t\t{$this->_AdminLang['uploaded_on']}\r\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;sort=filedate&amp;desc=1#files\" title=\"" . sprintf($this->_AdminLang['sort_descending_by_%name%'], $this->_AdminLang['date']) . "\"><img alt=\"[" . sprintf($this->_AdminLang['sort_descending_by_%name%'], $this->_AdminLang['date']) . "]\" src=\"img/down.png\"/></a>\r\n\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t<th class=\"small_width\">\r\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;sort=filetype#files\" title=\"" . sprintf($this->_AdminLang['sort_ascending_by_%name%'], $this->_AdminLang['filetype']) . "\"><img alt=\"[" . sprintf($this->_AdminLang['sort_ascending_by_%name%'], $this->_AdminLang['filetype']) . "]\" src=\"img/up.png\"/></a>\r\n\t\t\t\t\t\t\t{$this->_AdminLang['filetype']}\r\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;sort=filetype&amp;desc=1#files\" title=\"" . sprintf($this->_AdminLang['sort_descending_by_%name%'], $this->_AdminLang['filetype']) . "\"><img alt=\"[" . sprintf($this->_AdminLang['sort_descending_by_%name%'], $this->_AdminLang['filetype']) . "]\" src=\"img/down.png\"/></a>\r\n\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t<th class=\"table_mini_width\">\r\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;sort=filedownloads#files\" title=\"" . sprintf($this->_AdminLang['sort_ascending_by_%name%'], $this->_AdminLang['downloads']) . "\"><img alt=\"[" . sprintf($this->_AdminLang['sort_ascending_by_%name%'], $this->_AdminLang['downloads']) . "]\" src=\"img/up.png\"/></a>\r\n\t\t\t\t\t\t\t<abbr title=\"{$this->_AdminLang['downloads']}\">{$this->_AdminLang['downl']}</abbr>\r\n\t\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;sort=filedownloads&amp;desc=1#files\" title=\"" . sprintf($this->_AdminLang['sort_descending_by_%name%'], $this->_AdminLang['downloads']) . "\"><img alt=\"[" . sprintf($this->_AdminLang['sort_descending_by_%name%'], $this->_AdminLang['downloads']) . "]\" src=\"img/down.png\"/></a>\r\n\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t<th class=\"actions\">{$this->_AdminLang['actions']}</th>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</thead>\r\n";
     // get all files from the database/ which are registered in the database
     $sql = "SELECT file_type, file_path, file_name, file_id, file_downloads, file_date, file_size\r\n\t\t\t\tFROM " . DB_PREFIX . "files\r\n\t\t\t\tORDER BY ";
     $sort = GetPostOrGet('sort');
     $desc = GetPostOrGet('desc');
     // sorting by what?
     switch ($sort) {
         case 'filename':
             $sql .= 'file_name';
             break;
         case 'filesize':
             $sql .= 'file_size';
             break;
         case 'filedate':
             $sql .= 'file_date';
             break;
         case 'filetype':
             $sql .= 'file_type';
             break;
         case 'filedownloads':
             $sql .= 'file_downloads';
             break;
         default:
             $sql .= 'file_name';
             break;
     }
     // descending or ascending?
     if ($desc == 1) {
         $sql .= ' DESC';
     } else {
         $sql .= ' ASC';
     }
     $files_result = $this->_SqlConnection->SqlQuery($sql);
     $completeSize = 0;
     // show all files
     while ($file = mysql_fetch_object($files_result)) {
         $out .= "\t\t\t\t<tr>\r\n\t\t\t\t\t<td><span title=\"" . utf8_encode($file->file_path) . "\">" . utf8_encode($file->file_name) . "</span></td>\r\n\t\t\t\t\t<td>" . kbormb($file->file_size) . "</td>\r\n\t\t\t\t\t<td>" . date('d.m.Y H:i:s', $file->file_date) . "</td>\r\n\t\t\t\t\t<td>{$file->file_type}</td>\r\n\t\t\t\t\t<td>{$file->file_downloads}</td>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<a href=\"download.php?file_id={$file->file_id}\" ><img src=\"./img/download.png\" height=\"16\" width=\"16\" alt=\"[" . sprintf($this->_AdminLang['download_file_%file%'], utf8_encode($file->file_name)) . "]\" title=\"" . sprintf($this->_AdminLang['download_file_%file%'], utf8_encode($file->file_name)) . "\"/></a>\r\n\t\t\t\t\t\t<a href=\"admin.php?page=files&amp;action=delete&amp;file_id={$file->file_id}\" ><img src=\"./img/del.png\" height=\"16\" width=\"16\" alt=\" [" . sprintf($this->_AdminLang['delete_file_%file%'], utf8_encode($file->file_name)) . "]\" title=\"" . sprintf($this->_AdminLang['delete_file_%file%'], utf8_encode($file->file_name)) . "\"/></a>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n";
         // count the size of all files together
         $completeSize += $file->file_size;
     }
     $out .= "\t\t\t</table>\r\n";
     $out .= "\t\t\t" . $this->_AdminLang['altogether'] . ' ' . kbormb($completeSize);
     return $out;
 }
 /**
  * @access public
  * @param string action
  * @param array admin_lang
  * @param Config config
  * @return string
  */
 function GetPage($action)
 {
     // get the coutnt of all pages
     $sql = "SELECT page_id\r\n\t\t\t\tFROM " . DB_PREFIX . "pages";
     $sitedata_result = db_result($sql);
     $page_count = mysql_num_rows($sitedata_result);
     $sql = "SELECT page_id\r\n\t\t\t\tFROM " . DB_PREFIX . "pages_history";
     $history_sitedata_result = db_result($sql);
     $history_page_count = mysql_num_rows($history_sitedata_result);
     // get the count of all registered users
     $sql = "SELECT user_id\r\n\t\t\t\tFROM " . DB_PREFIX . "users";
     $users_result = db_result($sql);
     $users_count = mysql_num_rows($users_result);
     // get the size of all tables with the prefix DB_PREFIX
     $table_infos_result = db_result("SHOW TABLE STATUS");
     $data_size = 0;
     while ($table_infos = mysql_fetch_object($table_infos_result)) {
         if (substr($table_infos->Name, 0, strlen(DB_PREFIX)) == DB_PREFIX) {
             $data_size += $table_infos->Data_length + $table_infos->Index_length;
         }
     }
     $installdate = $this->config->Get('install_date');
     if ($installdate == '') {
         $config->Save('install_date', mktime());
         $installdate = mktime();
     }
     $out = "\t\t\t<h2>AdminControl</h2>\r\n\t\t\t<table class=\"text_table\">\r\n\t\t\t\t<tr><th>" . $this->admin_lang['online since'] . ":</th><td>" . date("d.m.Y", $installdate) . "</td></tr>\r\n\t\t\t\t<tr><th>" . $this->admin_lang['registered users'] . ":</th><td>{$users_count}</td></tr>\r\n\t\t\t\t<tr><th>" . $this->admin_lang['created pages'] . ":</th><td>{$page_count}</td></tr>\r\n\t\t\t\t<tr><th>" . $this->admin_lang['saved_page_modifications'] . ":</th><td>{$history_page_count}</td></tr>\r\n\t\t\t\t<tr><th>" . $this->admin_lang['database size'] . ":</th><td>" . kbormb($data_size) . "</td></tr>\r\n\t\t\t</table>\r\n\t\t\t<h2>Letzte Ver&auml;nderungen</h2>\r\n\t\t\t<table class=\"text_table full_width\">\r\n\t\t\t\t<thead>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<th>" . $this->admin_lang['date'] . "</th><th>" . $this->admin_lang['page'] . "</th><th>" . $this->admin_lang['user'] . "</th><th>" . $this->admin_lang['comment'] . "</th>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</thead>";
     $sql = "SELECT *\r\n\t\t\t\tFROM " . DB_PREFIX . "pages\r\n\t\t\t\tORDER BY page_date DESC\r\n\t\t\t\tLIMIT 0,6";
     $pages_result = db_result($sql);
     $pages = array();
     while ($page = mysql_fetch_object($pages_result)) {
         $pages[$page->page_date] = array($page->page_name, $page->page_title, $page->page_creator, $page->page_edit_comment);
     }
     $sql = "SELECT *\r\n\t\t\t\tFROM " . DB_PREFIX . "pages_history\r\n\t\t\t\tORDER BY page_date DESC\r\n\t\t\t\tLIMIT 0,6";
     $pages_result = db_result($sql);
     while ($page = mysql_fetch_object($pages_result)) {
         $pages[$page->page_date] = array($page->page_name, $page->page_title, $page->page_creator, $page->page_edit_comment);
     }
     krsort($pages);
     $count = 0;
     foreach ($pages as $date => $page) {
         $out .= "<tr>\r\n\t\t\t\t\t\t<td class=\"table_date_width\">" . date("d.m.Y H:i:s", $date) . "</td>\r\n\t\t\t\t\t\t<td><a href=\"index.php?page=" . $page[0] . "\">" . $page[1] . "</a> (" . rawurldecode($page[0]) . ")</td>\r\n\t\t\t\t\t\t<td>" . getUserById($page[2]) . "</td>\r\n\t\t\t\t\t\t<td>" . $page[3] . "</td>\r\n\t\t\t\t\t</tr>\r\n";
         $count++;
         if ($count > 5) {
             break;
         }
     }
     $out .= "</table>\r\n\t\t\t<h2>Aktuelle Besucher</h2>\r\n\t\t\t<table class=\"text_table full_width\">\r\n\t\t\t\t<thead>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<th>{$this->admin_lang['name']}</th>\r\n\t\t\t\t\t\t<th>{$this->admin_lang['page']}</th>\r\n\t\t\t\t\t\t<th>{$this->admin_lang['last action']}</th>\r\n\t\t\t\t\t\t<th>{$this->admin_lang['language']}</th>\r\n\t\t\t\t\t\t<th>{$this->admin_lang['ip']}</th>\r\n\t\t\t\t\t\t<th>{$this->admin_lang['host']}</th>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</thead>\r\n";
     // output all visitors surfing on the site
     $sql = "SELECT online_userid, online_page, online_lastaction, online_lang, online_ip, online_host\r\n\t\t\t\tFROM " . DB_PREFIX . "online\r\n\t\t\t\tWHERE online_lastaction >= " . (mktime() - 300);
     $users_online_result = db_result($sql);
     while ($users_online = mysql_fetch_object($users_online_result)) {
         if ($users_online->online_userid == 0) {
             $username = $this->admin_lang['not registered'];
         } else {
             $username = getUserById($users_online->online_userid);
         }
         $out .= "\t\t\t\t<tr>\r\n\t\t\t\t\t<td>" . $username . "</td>\r\n\t\t\t\t\t<td><a href=\"index.php?page=" . $users_online->online_page . "\">" . $users_online->online_page . "</a></td>\r\n\t\t\t\t\t<td>" . date("d.m.Y H:i:s", $users_online->online_lastaction) . "</td>\r\n\t\t\t\t\t<td>" . $this->admin_lang[$users_online->online_lang] . "</td>\r\n\t\t\t\t\t<td>" . $users_online->online_ip . "</td>\r\n\t\t\t\t\t<td>" . $users_online->online_host . "</td>\r\n\t\t\t\t</tr>\r\n";
     }
     $out .= "\t\t\t</table>";
     return $out;
 }