<?php

/*  Alternate WebKit
(C) 2011-2014 by Alternate Tools
-----------------------------------------------------

File:         index.php
Description:  Administrative entry point

*/

    include "../modules/mod_admin.php";
    include "../modules/mod_constants.php";
    include "../modules/class_user.php";
    include "../modules/class_theme.php";
    include "../modules/class_themelist.php";

    // Check privileges
    check_login();
    if (user_is_customer() == true)
    {
        log_out();
        return;
    }

    // Edit configuration?
    if (isset ($_POST['admin_Config']))
    {
        header ('location: ' . $ADMIN_EDITCONFIGURATION_SITE);
        return;
    }
    // Edit splash page?
    if (isset ($_POST['admin_Splashpage']))
    {
        header ('location: ' . $ADMIN_EDITSPLASHPAGE_SITE);
        return;
    }
    // Edit survey page?
    if (isset ($_POST['admin_Survey']))
    {
        header ('location: ' . $ADMIN_EDITSURVEY_SITE);
        return;
    }
    // Edit survey results?
    if (isset ($_POST['admin_SurveyResults']))
    {
        header ('location: ' . $ADMIN_LIST_SURVEYRESULTS_SITE);
        return;
    }
    // Edit construction?
    if (isset ($_POST['admin_Construction']))
    {
        header ('location: ' . $ADMIN_EDITCONSTRUCTION_SITE);
        return;
    }
    // Edit pages?
    if (isset ($_POST['admin_EditPages']))
    {
        header ('location: ' . $ADMIN_LIST_PAGES_SITE);
        return;
    }
    // Edit pagecontents?
    if (isset ($_POST['admin_EditPageContents']))
    {
        header ('location: ' . $ADMIN_LIST_PAGECONTENTS_SITE);
        return;
    }
    // Edit pageimages?
    if (isset ($_POST['admin_EditPageImages']))
    {
        header ('location: ' . $ADMIN_LIST_PAGEIMAGES_SITE);
        return;
    }
    // Edit pagefiles?
    if (isset ($_POST['admin_EditPageFiles']))
    {
        header ('location: ' . $ADMIN_LIST_PAGEFILES_SITE);
        return;
    }
    // Select theme?
    if (isset ($_POST['admin_Theme']))
    {
        header ('location: ' . $ADMIN_SELECT_THEME_SITE);
        return;
    }
    // Edit logos?
    if (isset ($_POST['admin_Logos']))
    {
        header ('location: ' . $ADMIN_EDIT_LOGOS_SITE);
        return;
    }
    // Send newsletter?
    if (isset ($_POST['admin_Newsletter']))
    {
        header ('location: ' . $ADMIN_SEND_NEWSLETTER_SITE);
        return;
    }
    // Edit users?
    if (isset ($_POST['admin_Users']))
    {
        header ('location: ' . $ADMIN_LIST_USERS_SITE);
        return;
    }
    // Edit mails?
    if (isset ($_POST['admin_Mails']))
    {
        header('location: ' . $ADMIN_LIST_MAILS_SITE);
        return;
    }
    // Display system info?
    if (isset ($_POST['admin_SysInfo']))
    {
        header ('location: ' . $ADMIN_SYSINFO_SITE);
        return;
    }
    // Display log?
    if (isset ($_POST['admin_Log']))
    {
        header ('location: ' . $ADMIN_LOG_SITE);
        return;
    }
    // Display php info?
    if (isset ($_POST['admin_PhpInfo']))
    {
        header ('location: ' . $ADMIN_PHPINFO_SITE);
        return;
    }
    // Edit folder?
    if (isset ($_POST['admin_EditFolder']))
    {
        header ('location: ' . $ADMIN_EDITFOLDER_SITE);
        return;
    }

    // Display
    // Display
    print_admin_header(get_translation('admin_main_head'), true, get_translation('admin_login_logout'), $ADMIN_HELP_FILE);
    echo_r('<form method="post" action="">');
    echo_r('<table border="0" width="100%">');
    echo_r('  <tr>');
    echo_r('    <td>' . get_translation('admin_main_welcome') . '</td>');
    echo_r('    <td align="left">');
    if ($ADMIN_USEEXTERNALLINKS == true)
    {
      if ($ADMIN_EXTERNALLINK1 != "")
          echo_r('     <a href="' . $ADMIN_EXTERNALLINK1 . '" target="_blank">' . $ADMIN_EXTERNALDESCRIPTION1 . '</a><br>');
      if ($ADMIN_EXTERNALLINK2 != "")
          echo_r('     <a href="' . $ADMIN_EXTERNALLINK2 . '" target="_blank">' . $ADMIN_EXTERNALDESCRIPTION2 . '</a><br>');
      if ($ADMIN_EXTERNALLINK3 != "")
          echo_r('     <a href="' . $ADMIN_EXTERNALLINK3 . '" target="_blank">' . $ADMIN_EXTERNALDESCRIPTION3 . '</a>');
    }
    echo_r('</td>');
    echo_r('  </tr>');
    echo_r('</table>');
    echo_r('<br>');
    // Edit pages contents
    echo_r('<hr>');
    echo_r('<table border="0" width="100%">');
    echo_r('  <tr>');
    echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_EditPageContents" value="' . get_translation('admin_main_editpagecontents') . '"></td>');
    echo_r('    <td>' . get_translation('admin_main_editpagecontentshint') . '</td>');
    echo_r('  </tr>');
    echo_r('</table>');
    if (user_is_reporter() == false)
    {
        // Edit pages
        echo_r('<hr>');
        echo_r('<table border="0" width="100%">');
        echo_r('  <tr>');
        echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_EditPages" value="' . get_translation('admin_main_editpages') . '"></td>');
        echo_r('    <td>' . get_translation('admin_main_editpageshint') . '</td>');
        echo_r('  </tr>');
        echo_r('</table>');
    }
    if (user_is_reporter() == false)
    {
        // Edit pageimages
        echo_r('<hr>');
        echo_r('<table border="0" width="100%">');
        echo_r('  <tr>');
        echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_EditPageImages" value="' . get_translation('admin_main_editpageimages') . '"></td>');
        echo_r('    <td>' . get_translation('admin_main_editpageimageshint') . '</td>');
        echo_r('  </tr>');
        echo_r('</table>');
    }
    if (user_is_reporter() == false)
    {
        // Edit pagefiles
        echo_r('<hr>');
        echo_r('<table border="0" width="100%">');
        echo_r('  <tr>');
        echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_EditPageFiles" value="' . get_translation('admin_main_editpagefiles') . '"></td>');
        echo_r('    <td>' . get_translation('admin_main_editpagefileshint') . '</td>');
        echo_r('  </tr>');
        echo_r('</table>');
    }
    // Splash page
    echo_r('<hr>');
    echo_r('<table border="0" width="100%">');
    echo_r('  <tr>');
    echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_Splashpage" value="' . get_translation('admin_main_editadhoc') . '"></td>');
    echo_r('    <td>' . get_translation('admin_main_editadhochint') . '</td>');
    echo_r('  </tr>');
    echo_r('</table>');
    // Survey page
    echo_r('<hr>');
    echo_r('<table border="0" width="100%">');
    echo_r('  <tr>');
    echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_Survey" value="' . get_translation('admin_main_editsurvey') . '"></td>');
    echo_r('    <td>' . get_translation('admin_main_editsurveyhint') . '</td>');
    echo_r('  </tr>');
    echo_r('</table>');
    // Survey results page
    echo_r('<hr>');
    echo_r('<table border="0" width="100%">');
    echo_r('  <tr>');
    echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_SurveyResults" value="' . get_translation('admin_main_editsurveyresults') . '"></td>');
    echo_r('    <td>' . get_translation('admin_main_editsurveyresultshint') . '</td>');
    echo_r('  </tr>');
    echo_r('</table>');
    // Construction page
    echo_r('<hr>');
    echo_r('<table border="0" width="100%">');
    echo_r('  <tr>');
    echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_Construction" value="' . get_translation('admin_main_editconstruction') . '"></td>');
    echo_r('    <td>' . get_translation('admin_main_editconstructionhint') . '</td>');
    echo_r('  </tr>');
    echo_r('</table>');
    // Send newsletter
    echo_r('<hr>');
    echo_r('<table border="0" width="100%">');
    echo_r('  <tr>');
    echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_Newsletter" value="' . get_translation('admin_main_sendnewsletter') . '"></td>');
    echo_r('    <td>' . get_translation('admin_main_sendnewsletterhint') . '</td>');
    echo_r('  </tr>');
    echo_r('</table>');
    // Edit configuration
    echo_r('    <hr>');
    echo_r('<table border="0" width="100%">');
    echo_r('  <tr>');
    echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_Config" value="' . get_translation('admin_main_editconfig') . '"></td>');
    echo_r('    <td>' . get_translation('admin_main_editconfighint') . '</td>');
    echo_r('  </tr>');
    echo_r('</table>');
    if (user_is_reporter() == false)
    {
        // Edit users
        echo_r('    <hr>');
        echo_r('<table border="0" width="100%">');
        echo_r('  <tr>');
        echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_Users" value="' . get_translation('admin_main_editusers') . '"></td>');
        echo_r('    <td>' . get_translation('admin_main_editusershint') . '</td>');
        echo_r('  </tr>');
        echo_r('</table>');
        // Mails
        echo_r('    <hr>');
        echo_r('<table border="0" width="100%">');
        echo_r('  <tr>');
        echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_Mails" value="' . get_translation('admin_main_editmails') . '"></td>');
        echo_r('    <td>' . get_translation('admin_main_editmailshint') . '</td>');
        echo_r('  </tr>');
        echo_r('</table>');
    }

    // Themes
    if (user_is_admin() == true)
    {
        echo_r('    <hr>');
        echo_r('<table border="0" width="100%">');
        echo_r('  <tr>');
        echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_Theme" value="' . get_translation('admin_main_selecttheme') . '"></td>');
        echo_r('    <td>' . get_translation('admin_main_selectthemehint') . '</td>');
        echo_r('  </tr>');
        echo_r('</table>');
    }
    // Logos
    if (user_is_admin() == true)
    {
        echo_r('    <hr>');
        echo_r('<table border="0" width="100%">');
        echo_r('  <tr>');
        echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_Logos" value="' . get_translation('admin_main_editlogos') . '"></td>');
        echo_r('    <td>' . get_translation('admin_main_editlogoshint') . '</td>');
        echo_r('  </tr>');
        echo_r('</table>');
    }

    // System info
    echo_r('    <hr>');
    echo_r('<table border="0" width="100%">');
    echo_r('  <tr>');
    echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_SysInfo" value="' . get_translation('admin_main_sysinfo') . '"></td>');
    echo_r('    <td>' . get_translation('admin_main_sysinfohint') . '</td>');
    echo_r('  </tr>');
    echo_r('</table>');
    // Log info
    if (user_is_admin() == true)
    {
        echo_r('    <hr>');
        echo_r('<table border="0" width="100%">');
        echo_r('  <tr>');
        echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_Log" value="' . get_translation('admin_main_syslog') . '"></td>');
        echo_r('    <td>' . get_translation('admin_main_sysloghint') . '</td>');
        echo_r('  </tr>');
        echo_r('</table>');
    }
    // Php info
    if (user_is_admin() == true)
    {
        echo_r('    <hr>');
        echo_r('<table border="0" width="100%">');
        echo_r('  <tr>');
        echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_PhpInfo" value="' . get_translation('admin_main_phpinfo') . '"></td>');
        echo_r('    <td>' . get_translation('admin_main_phpinfohint') . '</td>');
        echo_r('  </tr>');
        echo_r('</table>');
    }
    // Edit folder
    if (user_is_admin() == true)
    {
        echo_r('    <hr>');
        echo_r('<table border="0" width="100%">');
        echo_r('  <tr>');
        echo_r('    <td width="30%"><input type="submit" class="action_btn" name="admin_EditFolder" value="' . get_translation('admin_main_editfolder') . '"></td>');
        echo_r('    <td>' . get_translation('admin_main_editfolderhint') . '</td>');
        echo_r('  </tr>');
        echo_r('</table>');
    }
    echo_r('    <hr>');
    echo_r('</form>');

    print_admin_footer();
?>