[ Index ]
 

Code source de WebCalendar 1.0.5

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables | Statistiques

title

Body

[fermer]

/install/ -> index.php (source)

   1  <?php
   2  /*
   3   * $Id: index.php,v 1.17.2.3 2005/12/09 21:26:39 cknudsen Exp $
   4   *
   5   * Page Description:
   6   * Main page for install/config of db settings.
   7   * This page is used to create/update includes/settings.php.
   8   *
   9   * Input Parameters:
  10   * None
  11   *
  12   * Security:
  13   * The first time this page is accessed, there are no security
  14   * precautions.   The user is prompted to generate a config password.
  15   * From then on, users must know this password to make any changes
  16   * to the settings in settings.php./
  17   *
  18   * TODO:
  19   * Add translations to this page.
  20   */
  21  include_once  '../includes/php-dbi.php';
  22  
  23  $file = "../includes/settings.php";
  24  $fileDir = "../includes";
  25  
  26  // Get value from POST form
  27  function getPostValue ( $name ) {
  28    if ( ! empty ( $_POST[$name] ) ) {
  29      return $_POST[$name];
  30    }
  31    if ( ! isset ( $HTTP_POST_VARS ) ) {
  32      return null;
  33    }
  34    if ( ! isset ( $HTTP_POST_VARS[$name] ) ) {
  35      return null;
  36    }
  37    return ( $HTTP_POST_VARS[$name] );
  38  }
  39  
  40  
  41  // Get value from GET form
  42  function getGetValue ( $name ) {
  43    if ( ! empty ( $_GET[$name] ) ) {
  44      return $_GET[$name];
  45    }
  46    if ( ! isset ( $HTTP_GET_VARS ) ) {
  47      return null;
  48    }
  49    if ( ! isset ( $HTTP_GET_VARS[$name] ) ) {
  50      return null;
  51    }
  52    return ( $HTTP_GET_VARS[$name] );
  53  }
  54  
  55  function get_php_setting ( $val ) {
  56    $setting = ini_get ( $val );
  57    if ( $setting == '1' || $setting == 'ON' )
  58      return 'ON';
  59    else
  60      return 'OFF';
  61  }
  62  
  63  
  64  
  65  
  66  
  67  // First pass at settings.php.
  68  // We need to read it first in order to get the md5 password.
  69  $fd = @fopen ( $file, "rb", false );
  70  $settings = array ();
  71  $password = '';
  72  $forcePassword = false;
  73  if ( ! empty ( $fd ) ) {
  74    while ( ! feof ( $fd ) ) {
  75      $buffer = fgets ( $fd, 4096 );
  76      $buffer = trim ( $buffer, "\r\n " );
  77      if ( preg_match ( "/^(\S+):\s*(.*)/", $buffer,  $matches ) ) {
  78        if ( $matches[1] == "install_password" ) {
  79          $password = $matches[2];
  80          $settings['install_password'] = $password;
  81        }
  82      }
  83    }
  84    fclose ( $fd );
  85    // File exists, but no password.  Force them to create a password.
  86    if ( empty ( $password ) ) {
  87      $forcePassword = true;
  88    }
  89  }
  90  
  91  session_start ();
  92  $doLogin = false;
  93  
  94  // Handle "Logout" button
  95  if ( 'logout' == getGetValue ( 'action' ) ) {
  96    session_destroy ();
  97    Header ( "Location: index.php" );
  98    exit;
  99  }
 100  
 101  // If password already exists, check for session.
 102  if ( file_exists ( $file ) && ! empty ( $password ) &&
 103    ( empty ( $_SESSION['validuser'] ) ||
 104    $_SESSION['validuser'] != $password ) ) {
 105    // Make user login
 106    $doLogin = true;
 107  }
 108  
 109  
 110  $pwd = getPostValue ( "password" );
 111  if ( file_exists ( $file ) && ! empty ( $pwd ) ) {
 112    if ( md5($pwd) == $password ) {
 113      $_SESSION['validuser'] = $password;
 114      ?>
 115        <html><head><title>Password Accepted</title>
 116        <meta http-equiv="refresh" content="0; index.php" />
 117        </head>
 118        <body onload="alert('Successful Login');">
 119        </body></html>
 120      <?php
 121      exit;
 122    } else {
 123      // Invalid password
 124      $_SESSION['validuser'] = '';
 125      ?>
 126        <html><head><title>Password Incorrect</title>
 127        <meta http-equiv="refresh" content="0; index.php" />
 128        </head>
 129        <body onload="alert ('Invalid Login'); document.go(-1)">
 130        </body></html>
 131      <?php
 132      exit;
 133    }
 134  }
 135  
 136  $onload = "auth_handler (); ";
 137  
 138  $pwd1 = getPostValue ( "password1" );
 139  $pwd2 = getPostValue ( "password2" );
 140  if ( file_exists ( $file ) && $forcePassword && ! empty ( $pwd1 ) ) {
 141    if ( $pwd1 != $pwd2 ) {
 142      echo "Passwords do not match!<br/>\n";
 143      exit;
 144    }
 145    $fd = fopen ( $file, "a+b", false );
 146    if ( empty ( $fd ) ) {
 147      echo "<html><body>Unable to write password to settings.php file\n" .
 148        "</body></html>";
 149      exit;
 150    }
 151    fwrite ( $fd, "<?php\r\n" );
 152    fwrite ( $fd, "install_password: " . md5($pwd1) . "\r\n" );
 153    fwrite ( $fd, "?>\r\n" );
 154    fclose ( $fd );
 155    ?>
 156      <html><head><title>Password Updated</title>
 157      <meta http-equiv="refresh" content="0; index.php" />
 158      </head>
 159      <body onload="alert('Password has been set');">
 160      </body></html>
 161    <?php
 162    exit;
 163  }
 164  
 165  
 166  // Is this a db connection test?
 167  // If so, just test the connection, show the result and exit.
 168  $action = getGetValue ( "action" );
 169  if ( ! empty ( $action ) && $action == "dbtest" ) {
 170    if ( ! empty ( $_SESSION['validuser'] ) ) {
 171      $db_persistent = false;
 172      $db_type = getGetValue ( 'db_type' );
 173      $db_host = getGetValue ( 'db_host' );
 174      $db_database = getGetValue ( 'db_database' );
 175      $db_login = getGetValue ( 'db_login' );
 176      $db_password = getGetValue ( 'db_password' );
 177  
 178      echo "<html><head><title>WebCalendar: Db Connection Test</title>\n" .
 179        "</head><body style=\"background-color: #fff;\">\n";
 180      echo "<p><b>Connection Result:</b></p><blockquote>";
 181  
 182      $c = dbi_connect ( $db_host, $db_login,
 183        $db_password, $db_database );
 184  
 185      if ( $c ) {
 186        echo "<span style=\"color: #0f0;\">Success</span></blockquote>";
 187        $_SESSION['db_success'] = true;
 188        // TODO: update the text in the main window to indicate success
 189      } else {
 190        echo "<span style=\"color: #0f0;\">Failure</span</blockquote>";
 191        echo "<br/><br/><b>Reason:</b><blockquote>" . dbi_error () .
 192          "</blockquote>\n";
 193      }
 194      echo "<br/><br/><br/><div align=\"center\"><form><input align=\"middle\" type=\"button\" onclick=\"window.close()\" value=\"Close\" /></form></div>\n";
 195      echo "</p>";
 196      echo "<script language=\"JavaScript\" type=\"text/javascript\">\n";
 197      echo "<!-- <![CDATA[\n";
 198      echo "window.opener.show_db_status ( " .
 199        ( $c ? "true" : "false" ) . " );\n";
 200      echo "//]]> -->\n</script>\n";
 201      echo "</body></html>\n";
 202    } else { // Not valid user
 203      echo "You are not authorized.";
 204      // etranslate ( "You are not authorized" );  
 205    }
 206    exit;
 207  }
 208  
 209  // Is this a call to phpinfo()?
 210  $action = getGetValue ( "action" );
 211  if ( ! empty ( $action ) && $action == "phpinfo" ) {
 212    if ( ! empty ( $_SESSION['validuser'] ) ) {
 213      phpinfo();
 214    } else {
 215      echo "You are not authorized.";
 216      // etranslate ( "You are not authorized" );
 217    }
 218    exit;
 219  }
 220  
 221  
 222  $exists = file_exists ( $file );
 223  $canWrite = false;
 224  if ( $exists ) {
 225    $canWrite = is_writable ( $file );
 226  } else {
 227    // check to see if we can create a new file.
 228    $testFile = $fileDir . "/installTest.dat";
 229    $testFd = @fopen ( $testFile, "w+b", false );
 230    if ( file_exists ( $testFile ) ) {
 231      $canWrite = true;
 232    }
 233    @unlink ( $testFile );
 234  }
 235  
 236  
 237  
 238  // If we are handling a form POST, then take that data and put it in settings
 239  // array.
 240  $x = getPostValue ( "form_db_type" );
 241  if ( empty ( $x ) ) {
 242    // No form was posted.  Set defaults if none set yet.
 243    if ( ! file_exists ( $file ) ) {
 244      $settings['db_type'] = 'mysql';
 245      $settings['db_host'] = 'localhost';
 246      $settings['db_database'] = 'intranet';
 247      $settings['db_login'] = 'webcalendar';
 248      $settings['db_password'] = 'webcal01';
 249      $settings['db_persistent'] = 'true';
 250      $settings['readonly'] = 'false';
 251      $settings['user_inc'] = 'user.php';
 252      $settings['install_password'] = '';
 253      $settings['single_user_login'] = '';
 254      $settings['use_http_auth'] = 'false';
 255      $settings['single_user'] = 'false';
 256      $settings['user_inc'] = 'user.php';
 257    }
 258  } else {
 259    $settings['db_type'] = getPostValue ( 'form_db_type' );
 260    $settings['db_host'] = getPostValue ( 'form_db_host' );
 261    $settings['db_database'] = getPostValue ( 'form_db_database' );
 262    $settings['db_login'] = getPostValue ( 'form_db_login' );
 263    $settings['db_password'] = getPostValue ( 'form_db_password' );
 264    $settings['db_persistent'] = getPostValue ( 'form_db_persistent' );
 265    $settings['single_user_login'] = getPostValue ( 'form_single_user_login' );
 266    $settings['readonly'] = getPostValue ( 'form_readonly' );
 267    if ( getPostValue ( "form_user_inc" ) == "http" ) {
 268      $settings['use_http_auth'] = 'true';
 269      $settings['single_user'] = 'false';
 270      $settings['user_inc'] = 'user.php';
 271    } else if ( getPostValue ( "form_user_inc" ) == "none" ) {
 272      $settings['use_http_auth'] = 'false';
 273      $settings['single_user'] = 'true';
 274      $settings['user_inc'] = 'user.php';
 275    } else {
 276      $settings['use_http_auth'] = 'false';
 277      $settings['single_user'] = 'false';
 278      $settings['user_inc'] = getPostValue ( 'form_user_inc' );
 279    }
 280    // Save settings to file now.
 281    if ( empty ( $password ) ) {
 282      $onload = "alert('Your settings have been saved.\\n\\n" .
 283        "Please be sure to set a password.\\n');";
 284      $forcePassword = true;
 285    } else {
 286      $onload .= "alert('Your settings have been saved.\\n\\n');";
 287    }
 288    $fd = @fopen ( $file, "w+b", false );
 289    if ( empty ( $fd ) ) {
 290      if ( file_exists ( $file ) ) {
 291        $onload = "alert('Error: unable to write to file $file\\nPlease change the file permissions of this file.');";
 292      } else {
 293        $onload = "alert('Error: unable to write to file $file\\nPlease change the file permissions of your includes directory\\nto allow writing by other users.');";
 294      }
 295    } else {
 296      fwrite ( $fd, "<?php\r\n" );
 297      fwrite ( $fd, "# updated via install/index.php on " . date("r") . "\r\n" );
 298      foreach ( $settings as $k => $v ) {
 299        fwrite ( $fd, $k . ": " . $v . "\r\n" );
 300      }
 301      fwrite ( $fd, "# end settings.php\r\n?>\r\n" );
 302      fclose ( $fd );
 303      // Change to read/write by us only (only applies if we created file)
 304      // and read-only by all others.  Would be nice to make it 600, but
 305      // the send_reminders.php script is usually run under a different
 306      // user than the web server.
 307      @chmod ( $file, 0644 );
 308    }
 309  }
 310  
 311  
 312  $fd = @fopen ( $file, "rb", false );
 313  if ( ! empty ( $fd ) ) {
 314    while ( ! feof ( $fd ) ) {
 315      $buffer = fgets ( $fd, 4096 );
 316      $buffer = trim ( $buffer, "\r\n " );
 317      if ( preg_match ( "/^#/", $buffer ) )
 318        continue;
 319      if ( preg_match ( "/^<\?/", $buffer ) ) // start php code
 320        continue;
 321      if ( preg_match ( "/^\?>/", $buffer ) ) // end php code
 322        continue;
 323      if ( preg_match ( "/(\S+):\s*(.*)/", $buffer, $matches ) ) {
 324  // echo $matches[1] . " " .  $matches[2] . "<br>";
 325        $settings[$matches[1]] = $matches[2];
 326        //echo "settings $matches[1] => $matches[2] <br>";
 327      }
 328    }
 329    fclose ( $fd );
 330  }
 331  
 332  echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
 333  ?>
 334  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
 335  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 336  <head><title>WebCalendar Database Setup</title>
 337  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 338  <?php include  "../includes/js/visible.php"; ?>
 339  <script language="JavaScript" type="text/javascript">
 340  <!-- <![CDATA[
 341  <?php   if ( ! empty ( $_SESSION['validuser'] ) ) { ?>
 342  function testSettings () {
 343    var url;
 344    var form = document.dbform;
 345    url = "index.php?action=dbtest" +
 346      "&db_type=" + form.form_db_type.value +
 347      "&db_host=" + form.form_db_host.value +
 348      "&db_database=" + form.form_db_database.value +
 349      "&db_login=" + form.form_db_login.value +
 350      "&db_password=" + form.form_db_password.value;
 351    //alert ( "URL:\n" + url );
 352    window.open ( url, "wcDbTest", "width=400,height=350,resizable=yes,scrollbars=yes" );
 353  }
 354  function testPHPInfo () {
 355    var url;
 356    var form = document.phpinfo;
 357    url = "index.php?action=phpinfo";
 358    //alert ( "URL:\n" + url );
 359    window.open ( url, "wcTestPHPInfo", "width=800,height=600,resizable=yes,scrollbars=yes" );
 360  }
 361  <?php } ?>
 362  function validate(form)
 363  {
 364    var form = document.dbform;
 365    // only check is to make sure single-user login is specified if
 366    // in single-user mode
 367    if ( form.form_user_inc.options[4].selected ) {
 368      if ( form.form_single_user_login.value.length == 0 ) {
 369        // No single user login specified
 370        alert ( "Error: you must specify a\nSingle-User Login" );
 371        form.form_single_user_login.focus ();
 372        return false;
 373      }
 374    }
 375    // Submit form...
 376    form.submit ();
 377  }
 378  function auth_handler () {
 379    var form = document.dbform;
 380    if ( form.form_user_inc.options[4].selected ) {
 381      makeVisible ( "singleuser" );
 382    } else {
 383      makeInvisible ( "singleuser" );
 384    }
 385  }
 386  
 387  function show_db_status ( success ) {
 388    if ( success ) {
 389      makeVisible ( "db_success" );
 390      makeInvisible ( "no_db_success" );
 391    } else {
 392      makeInvisible ( "db_success" );
 393      makeVisible ( "no_db_success" );
 394    }
 395  }
 396   //]]> -->
 397  </script>
 398  <style type="text/css">
 399  body {
 400    background-color: #ffffff;
 401    font-family: Arial, Helvetica, sans-serif;
 402    margin: 0;
 403  }
 404  table {
 405    border: 1px solid #ccc;
 406  }
 407  th.header {
 408    font-size: 18px;
 409    background-color: #eee;
 410  }
 411  td {
 412    padding: 5px;
 413  }
 414  td.prompt {
 415    font-weight: bold;
 416    padding-right: 20px;
 417  }
 418  div.nav {
 419    margin: 0;
 420    border-bottom: 1px solid #000;
 421  }
 422  div.main {
 423    margin: 10px;
 424  }
 425  li {
 426    margin-top: 10px;
 427  }
 428  doc.li {
 429    margin-top: 5px;
 430  }
 431  .recommended {
 432    color: green;
 433  }
 434  .notrecommended {
 435    color: red;
 436  }
 437  </style>
 438  </head>
 439  <body onload="<?php echo $onload;?>">
 440  <?php
 441  /* other features coming soon.... 
 442  <div class="nav">
 443  <table border="0" width="100%">
 444  <tr>
 445  <td>&lt;&lt;<b>Database Setup</b>&gt;&gt;</td>
 446  <td>&lt;&lt;<a href="setup.php">Setup Wizard</a>&gt;&gt;</td>
 447  <td>&lt;&lt;<a href="diag.php">Diagnostics</a>&gt;&gt;</td>
 448  </tr></table>
 449  </div>
 450  */
 451  ?>
 452  <div class="main">
 453  <h2>WebCalendar Database Setup</h2>
 454  
 455  <p><b>Current Status:</b></p>
 456  <ul>
 457  
 458  <li>Supported databases for your PHP installation:
 459  <?php
 460    $dbs = array ();
 461    if ( function_exists ( "mysql_pconnect" ) )
 462      $dbs[] = "mysql";
 463    if ( function_exists ( "mysqli_connect" ) )
 464      $dbs[] = "mysqli";
 465    if ( function_exists ( "OCIPLogon" ) )
 466      $dbs[] = "oracle";
 467    if ( function_exists ( "pg_pconnect" ) )
 468      $dbs[] = "postgresql";
 469    if ( function_exists ( "odbc_pconnect" ) )
 470      $dbs[] = "odbc";
 471    if ( function_exists ( "db2_pconnect" ) )
 472      $dbs[] = "ibm_db2";
 473    if ( function_exists ( "ibase_pconnect" ) )
 474      $dbs[] = "ibase";
 475    if ( function_exists ( "mssql_pconnect" ) )
 476      $dbs[] = "mssql";
 477    for ( $i = 0; $i < count ( $dbs ); $i++ ) {
 478      if ( $i ) echo ", ";
 479      echo $dbs[$i];
 480      $supported[$dbs[$i]] = true;
 481    }
 482  ?>
 483  </li>
 484  <?php if ( ! empty ( $_SESSION['db_success'] ) && $_SESSION['db_success']  ) { ?>
 485  <li id="db_success"> Your current database settings are able to
 486    access the database.</li>
 487  <li id="no_db_success" style="visibility: hidden;"> Your current database settings are <b>not</b> able to
 488    access the database or have not yet been tested.</li>
 489  <?php } else { ?>
 490  <li id="no_db_success"> Your current database settings are <b>not</b> able to
 491    access the database or have not yet been tested.</li>
 492  <li id="db_success" style="visibility: hidden;"> Your current database settings are able to
 493    access the database.</li>
 494  <?php } ?>
 495  <?php if ( empty ( $password ) ) { ?>
 496    <li> You have not set a password for this page. </li>
 497  <?php } ?>
 498  <?php if ( $exists && ! $canWrite ) { ?>
 499  <li><b>Error:</b>
 500  The file permissions of <tt>settings.php</tt> are set so
 501  that this script does not have permission to write changes to it.
 502  You must change the file permissions of the following
 503  file to use this script:
 504  <blockquote><tt>
 505  <?php echo realpath ( $file ); ?>
 506  </tt></blockquote>
 507  </li>
 508  <?php } else if ( ! $exists && ! $canWrite ) { ?>
 509  <li><b>Error:</b>
 510  The file permissions of the <tt>includes</tt> directory are set so
 511  that this script does not have permission to create a new file
 512  in that directory.
 513  You must change the permissions of the follwing directory
 514  to use this script:
 515  <blockquote><tt>
 516  <?php echo realpath ( $fileDir ); ?>
 517  </tt></blockquote>
 518  </li>
 519  <?php } else { ?>
 520    <?php if ( ! file_exists ( $file ) ) { ?>
 521    <li>You have not created a <tt>settings.php</tt> file yet.</li>
 522    <?php } ?>
 523  <?php if ( empty ( $PHP_AUTH_USER ) ) { ?>
 524  <li>HTTP-based authentication was not detected.
 525  You will need to reconfigure your web server if you wish to
 526  select "Web Server" from the "User Authentication" choices below.
 527  </li>
 528  <?php } else { ?>
 529  <li>HTTP-based authentication was detected.
 530  User authentication is being handled by your web server.
 531  You should select "Web Server" from the list of
 532  "User Authentication " choices below.
 533  </li>
 534  <?php } ?>
 535  
 536  </ul>
 537  
 538  <table>  <tr><td valign="top">
 539  <?php if ( $doLogin ) { ?>
 540    <form action="index.php" method="post" name="dblogin">
 541  
 542    <p>Please enter the password.</p>
 543      <br /><br />
 544    </p>
 545    <table >
 546    <tr><th colspan="2" class="header">Enter Password</th></tr>
 547    <tr><th>Password:</th><td><input name="password" type="password" /></td></tr>
 548    <tr><td colspan="2" align="center"><input type="submit" value="Login" /></td></tr>
 549    </table><br />
 550    </form>
 551    </td></tr></table>
 552  <?php } else if ( $forcePassword ) { ?>
 553    <form action="index.php" method="post" name="dbpassword">
 554    <p>You have not set a password for access to this page yet.
 555       Please set the password.
 556      <br /><br />
 557    </p>
 558    <table border="0">
 559    <tr><th colspan="2" class="header">Create Password</th></tr>
 560    <tr><th>Password:</th><td><input name="password1" type="password" /></td></tr>
 561    <tr><th>Password (again):</th><td><input name="password2" type="password" /></td></tr>
 562    <tr><td colspan="2" align="center"><input type="submit" value="Set Password" /></td></tr>
 563    </table><br />
 564    </form>
 565    </td></tr></table>
 566  <?php } else { ?>
 567  <form action="index.php" method="post" name="dbform">
 568  
 569  <table>
 570  <tr><th class="header" colspan="2">Database Settings</th></tr>
 571  
 572  <tr><td class="prompt">Database Type:</td>
 573  <td>
 574  <select name="form_db_type">
 575  <?php
 576    if ( ! empty ( $supported['mysql'] ) )
 577      echo "<option value=\"mysql\" " .
 578        ( $settings['db_type'] == 'mysql' ? " selected=\"selected\"" : "" ) .
 579        "> MySQL </option>\n";
 580        
 581    if ( ! empty ( $supported['mysqli'] ) )
 582      echo "<option value=\"mysqli\" " .
 583        ( $settings['db_type'] == 'mysqli' ? " selected=\"selected\"" : "" ) .
 584        "> MySQL (Improved)</option>\n";
 585  
 586    if ( ! empty ( $supported['oracle'] ) )
 587      echo "<option value=\"oracle\" " .
 588        ( $settings['db_type'] == 'oracle' ? " selected=\"selected\"" : "" ) .
 589        "> Oracle (OCI) </option>\n";
 590  
 591    if ( ! empty ( $supported['postgresql'] ) )
 592      echo "<option value=\"postgresql\" " .
 593        ( $settings['db_type'] == 'postgresql' ? " selected=\"selected\"" : "" ) .
 594        "> PostgreSQL </option>\n";
 595  
 596    if ( ! empty ( $supported['ibm_db2'] ) )
 597      echo "  <option value=\"ibm_db2\" " .
 598        ( $settings['db_type'] == 'ibm_db2' ? " selected=\"selected\"" : "" ) .
 599        ">IBM DB2 Universal Database</option>\n";
 600  
 601    if ( ! empty ( $supported['odbc'] ) )
 602      echo "<option value=\"odbc\" " .
 603        ( $settings['db_type'] == 'odbc' ? " selected=\"selected\"" : "" ) .
 604        "> ODBC </option>\n";
 605  
 606    if ( ! empty ( $supported['ibase'] ) )
 607      echo "<option value=\"ibase\" " .
 608        ( $settings['db_type'] == 'ibase' ? " selected=\"selected\"" : "" ) .
 609        "> Interbase </option>\n";
 610  
 611    if ( ! empty ( $supported['mssql'] ) )
 612      echo "<option value=\"mssql\" " .
 613        ( $settings['db_type'] == 'mssql' ? " selected=\"selected\"" : "" ) .
 614        "> MS SQL Server </option>\n";
 615  ?>
 616  </select>
 617  </td></tr>
 618  
 619  <tr><td class="prompt">Server:</td>
 620  <td><input name="form_db_host" size="20" value="<?php echo $settings['db_host'];?>" /></td></tr>
 621  
 622  <tr><td class="prompt">Database Name:</td>
 623  <td><input name="form_db_database" size="20" value="<?php echo $settings['db_database'];?>" /></td></tr>
 624  
 625  <tr><td class="prompt">Login:</td>
 626  <td><input name="form_db_login" size="20" value="<?php echo $settings['db_login'];?>" /></td></tr>
 627  
 628  <tr><td class="prompt">Password:</td>
 629  <td><input name="form_db_password" size="20" value="<?php echo $settings['db_password'];?>" /></td></tr>
 630  
 631  <tr><td class="prompt">Connection Persistence:</td>
 632  <td><input name="form_db_persistent" value="true" type="radio"
 633    <?php echo ( $settings['db_persistent'] == 'true' )? " checked=\"checked\"" : "";
 634    ?> />Enabled
 635    &nbsp;&nbsp;&nbsp;&nbsp;
 636    <input name="form_db_persistent" value="false" type="radio"
 637    <?php echo ( $settings['db_persistent'] != 'true' )? " checked=\"checked\"" : "";
 638    ?> />Disabled
 639    </td></tr>
 640  <?php if ( ! empty ( $_SESSION['validuser'] ) ) { ?>
 641  <tr><td colspan="2" align="center">
 642  <input name="action" type="button" value="Test Settings"
 643    onclick="testSettings()" />
 644  </td></tr>
 645  <?php } else { ?>
 646  <tr><th class="header" colspan="2">
 647  <p>You must save before proceeding.</p>
 648  </th></tr>
 649  <?php } ?>
 650  </table>
 651  
 652  </td>
 653  <td valign="top">
 654    <table width="100%">
 655      <tr>
 656        <th class="header" colspan="2" >Application Settings</th>
 657      </tr>
 658      <tr>
 659        <td class="prompt">User Authentication:</td>
 660        <td>
 661          <select name="form_user_inc" onchange="auth_handler()">
 662  <?php
 663    echo "<option value=\"user.php\" " .
 664      ( $settings['user_inc'] == 'user.php' && $settings['use_http_auth'] != 'true' ? " selected=\"selected\"" : "" ) .
 665      "> Web-based via WebCalendar (default) </option>\n";
 666  
 667    echo "<option value=\"http\" " .
 668      ( $settings['user_inc'] == 'user.php' && $settings['use_http_auth'] == 'true' ? " selected=\"selected\"" : "" ) .
 669      "> Web Server " .
 670      ( empty ( $PHP_AUTH_USER ) ? "(not detected)" : "(detected)" ) .
 671      "</option>\n";
 672  
 673    echo "<option value=\"user-ldap.php\" " .
 674      ( $settings['user_inc'] == 'user-ldap.php' ? " selected=\"selected\"" : "" ) .
 675      "> LDAP </option>\n";
 676  
 677    echo "<option value=\"user-nis.php\" " .
 678      ( $settings['user_inc'] == 'user-nis.php' ? " selected=\"selected\"" : "" ) .
 679      "> NIS </option>\n";
 680  
 681    echo "<option value=\"none\" " .
 682      ( $settings['user_inc'] == 'user.php' && $settings['single_user'] == 'true' ? " selected=\"selected\"" : "" ) .
 683      "> None (Single-User) </option>\n</select>";
 684  ?>
 685          </td>
 686        </tr>
 687        <tr id="singleuser">
 688          <td class="prompt">&nbsp;&nbsp;&nbsp;Single-User Login:</td>
 689          <td>
 690            <input name="form_single_user_login" size="20" value="<?php echo $settings['single_user_login'];?>" /></td>
 691        </tr>
 692        <tr>
 693          <td class="prompt">Read-Only:</td>
 694          <td>
 695            <input name="form_readonly" value="true" type="radio"
 696    <?php echo ( $settings['readonly'] == 'true' )? " checked=\"checked\"" : "";?> />Yes
 697    &nbsp;&nbsp;&nbsp;&nbsp;
 698    <input name="form_readonly" value="false" type="radio"
 699    <?php echo ( $settings['readonly'] != 'true' )? " checked=\"checked\"" : "";?> />No
 700           </td>
 701         </tr>
 702      </table>
 703  <?php
 704  
 705  $php_settings = array (
 706    //array ('Safe Mode','safe_mode','OFF'),
 707    array ('Magic Quotes GPC','magic_quotes_gpc','ON'),
 708    array ('Register Globals','register_globals','ON'),
 709    array ('Display Errors','display_errors','ON'),
 710    //array ('Register Globals','register_globals','OFF'),
 711    array ('File Uploads','file_uploads','ON'),
 712  );
 713  
 714  ?>
 715  <table width="100%">
 716  <tr><th class="header"  colspan="2">PHP Settings</th></tr>
 717  <?php foreach ( $php_settings as $setting ) { ?>
 718    <tr><td class="prompt"><?php echo $setting[0];?></td>
 719    <?php
 720      $class = ( get_php_setting ( $setting[1] ) == $setting[2] ) ?
 721        'recommended' : 'notrecommended';
 722      echo "<td class=\"$class\">";
 723      echo get_php_setting ( $setting[1] );
 724     ?>
 725     </td></tr>
 726  <?php } ?>
 727  
 728  <?php if ( ! empty ( $_SESSION['validuser'] ) ) { ?>
 729  <tr><td  align="center" colspan="2"><input name="action" type="button" value="Detailed PHP Info"
 730    onclick="testPHPInfo()" /></td></tr>
 731  <?php } ?>
 732  
 733  
 734  </table></td></tr>
 735  
 736  <tr><td align="center" colspan="2">
 737  <input name="action" type="button" value="Save Settings"
 738    onclick="return validate();" />
 739    <?php if ( ! empty ( $_SESSION['db_success'] ) && $_SESSION['db_success']  && empty ( $dologin ) ) { ?>
 740      <input type="button" value="Launch WebCalendar"
 741        onclick="window.open('../index.php', 'webcalendar');" />
 742    <?php } ?>
 743    <?php if ( ! empty ( $_SESSION['validuser'] ) ) { ?>
 744      <input type="button" value="Logout"
 745        onclick="document.location.href='index.php?action=logout'" />
 746    <?php } ?>
 747  </form>
 748  </td></tr></table>
 749  <?php } ?>
 750  
 751  <?php } ?>
 752  </div>
 753  <div class="main">
 754  <p>
 755  <b>Documentation:</b>
 756  </p>
 757  <ul>
 758  <li class="doc"><a href="../docs/WebCalendar-SysAdmin.html" target="_docs">System Administrator's Guide</a> (Installation Instructions) </li>
 759  <li class="doc"><a href="../docs/WebCalendar-SysAdmin.html#faq" target="_docs">FAQ</a> </li>
 760  <li class="doc"><a href="../docs/WebCalendar-SysAdmin.html#trouble" target="_docs">Troubleshooting</a> </li>
 761  <li class="doc"><a href="../docs/WebCalendar-SysAdmin.html#help" target="_docs">Getting Help</a> </li>
 762  </ul>
 763  </div>
 764  </body>
 765  </html>


Généré le : Fri Nov 30 19:09:19 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics