home *** CD-ROM | disk | FTP | other *** search
/ grafika-wolowiec.cba.pl / grafika-wolowiec.cba.pl.tar / grafika-wolowiec.cba.pl / admin / website_test.php < prev   
PHP Script  |  2014-01-24  |  6KB  |  142 lines

  1. <?php
  2.     require_once("header.php");
  3.     @include_once("../res/blog.inc.php");
  4. ?>
  5. <div id="imAdminPage">
  6.     <div id="imBody">
  7.         <div class="imContent">
  8. <?php
  9.             $testedFolders = array();
  10.             $test = new imTest();
  11.             $test->doTest(true, $test->php_version_test(), l10n('admin_test_version') . ": " . PHP_VERSION, l10n('admin_test_version_suggestion'));
  12.             $test->doTest(true, $test->session_test(), l10n('admin_test_session'), l10n('admin_test_session_suggestion'));
  13.  
  14.             @chdir("../.");
  15.             // Site root folder
  16.             if (isset($imSettings['general']['public_folder'])) {
  17.                 $testedFolders[] = $imSettings['general']['public_folder'];
  18.                 $test->doTest(true, $test->writable_folder_test($imSettings['general']['public_folder']), l10n('admin_test_folder') . ($imSettings['general']['public_folder'] != "" ? " (" . $imSettings['general']['public_folder'] . ")": " (site root folder)"), l10n("admin_test_folder_suggestion"));
  19.             }
  20.  
  21.             // Blog public folder
  22.             if (isset($imSettings['blog']) && $imSettings['blog']['sendmode'] == 'file' && !in_array($imSettings['blog']['folder'], $testedFolders)) {
  23.                 $testedFolders[] = $imSettings['blog']['folder'];
  24.                 $test->doTest(true, $test->writable_folder_test($imSettings['blog']['folder']), l10n('admin_test_folder') . ($imSettings['blog']['folder'] != "" ? " (" . $imSettings['blog']['folder'] . ")": " (site root folder)"), l10n("admin_test_folder_suggestion"));
  25.             }
  26.             
  27.             // Guestbooks public folder
  28.             if (isset($imSettings['guestbooks'])) {
  29.                 foreach($imSettings['guestbooks'] as $gb) {
  30.                     if ($gb['sendmode'] == 'file') {
  31.                         // Check this folder only if it's different from the blog's one
  32.                         if (!in_array($gb['folder'], $testedFolders)) {
  33.                             $testedFolders[] = $gb['folder'];
  34.                             $test->doTest(true, $test->writable_folder_test($gb['folder']), l10n('admin_test_folder') . ($gb['folder'] != "" ? " (" . $gb['folder'] . ")" :  " (site root folder)"), l10n("admin_test_folder_suggestion"));
  35.                         }
  36.                     }
  37.                 }            
  38.             }
  39.             if (isset($imSettings['dynamicobjects'])) {
  40.                 foreach($imSettings['dynamicobjects'] as $objId => $obj) {
  41.                     if (isset($obj['folder']) && !in_array($obj['folder'], $testedFolders)) {
  42.                         $testedFolders[] = $obj['folder'];
  43.                         $test->doTest(true, $test->writable_folder_test($obj['folder']), l10n('admin_test_folder') . ($obj['folder'] != "" ? " (" . $obj['folder'] . ")" :  " (site root folder)"), l10n("admin_test_folder_suggestion"));
  44.                     }
  45.                 }            
  46.             }
  47.             @chdir("admin");
  48.  
  49.             // Databases
  50.             if (isset($imSettings['databases'])) {
  51.                 foreach($imSettings['databases'] as $db) {
  52.                     $tst = $test->mysql_test($db['host'], $db['user'], $db['password'], $db['database']);
  53.                     $test->doTest(true, $tst, l10n('admin_test_database') . " (" . $db['description'] . ")", l10n("admin_test_database_suggestion"));
  54.                 }
  55.             }
  56.              
  57.             if (isset($_POST['send'])) {
  58.                 $attachment = array();
  59.                 if (is_uploaded_file($_FILES['attachment']['tmp_name']) && file_exists($_FILES['attachment']['tmp_name'])) {
  60.                     $attachment = array(array(
  61.                         "name" => $_FILES['attachment']['name'],
  62.                         "mime" => $_FILES['attachment']['type'],
  63.                         "content" => file_get_contents($_FILES['attachment']['tmp_name'])
  64.                     ));
  65.                 }
  66.                 $ImMailer->setEmailType($_POST['type']);
  67.                 $ImMailer->send($_POST['from'], $_POST['to'], $_POST['subject'], strip_tags($_POST['body']), nl2br($_POST['body']), $attachment);
  68.                 echo "<script>window.top.location.href = 'website_test.php';</script>";
  69.             }
  70. ?>
  71.         </div>
  72.         <div class="imContent" style="margin-top: 15px; padding: 5px;">
  73.             <h2 style="margin: 5px 0 15px 0; text-align: center;"><?php echo l10n('admin_test_email', 'Email form test'); ?></h2>
  74.             <form action="website_test.php" method="post" enctype="multipart/form-data">
  75.                 <table>
  76.                     <tr>
  77.                         <td style="vertical-align: middle;">
  78.                             <label for="type"><?php echo l10n('form_script_type'); ?></label>
  79.                         </td>
  80.                         <td>
  81.                             <!-- enable disable the attachment field basing on the email type -->
  82.                             <select name="type" id="type" onchange="var a = $('#attachment, [for=attachment]'); $(this).val() == 'text' ? a.val('').hide(0) : a.show(0)">
  83.                                 <option value="html"><?php echo l10n('form_script_type_html'); ?></option>
  84.                                 <option value="html-x"><?php echo l10n('form_script_type_html_x'); ?></option>
  85.                                 <option value="text"><?php echo l10n('form_script_type_text'); ?></option>
  86.                             </select>
  87.                             <a href="download.php?what=emaillibrary"><?php echo l10n("admin_download", "Download") ?></a>
  88.                         </td>
  89.                     </tr>
  90.                     <tr>
  91.                         <td>
  92.                             <label for="from"><?php echo l10n('form_from'); ?></label>
  93.                         </td>
  94.                         <td>
  95.                             <input type="text" name="from" id="from"/>
  96.                         </td>
  97.                     </tr>
  98.                     <tr>
  99.                         <td>
  100.                             <label for="to"><?php echo l10n('form_to'); ?></label>
  101.                         </td>
  102.                         <td>
  103.                             <input type="text" id="to" name="to"/>
  104.                         </td>
  105.                     </tr>
  106.                     <tr>
  107.                         <td>
  108.                             <label for="subject"><?php echo l10n('form_subject'); ?></label>
  109.                         </td>
  110.                         <td>
  111.                             <input type="text" id="subject" name="subject"/>
  112.                         </td>
  113.                     </tr>
  114.                     <tr>
  115.                         <td colspan="2">
  116.                             <textarea name="body" id="body" style="width: 99%;" rows="10"></textarea>    
  117.                         </td>
  118.                     </tr>
  119.                     <tr>
  120.                         <td>
  121.                             <label for="attachment"><?php echo l10n('form_attachment', 'Attachment: '); ?></label>
  122.                         </td>
  123.                         <td>
  124.                             <input type="file" name="attachment" id="attachment" />
  125.                         </td>
  126.                     </tr>
  127.                 </table>
  128.                 <div style="text-align: center; margin-top: 10px;">
  129.                     <input type="submit" value="<?php echo l10n('form_submit'); ?>" name="send">
  130.                     <input type="reset" value="<?php echo l10n('form_reset'); ?>">    
  131.                 </div>                
  132.             </form>
  133.             <script>$(document).ready(function () { $("#from").focus(); });</script>
  134. <?php 
  135. ?>
  136.         </div>
  137.     </div>
  138. </div>
  139. <?php
  140. require_once("footer.php");
  141. ?>
  142.