Location: PHPKode > projects > QuickTicket > quickticket/quickticket/check_install.php
<?php

// QuickTicket 1.9.0.3 build:20081001

// --------
// HTML start
// --------
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en" lang="en">
<head>
<title>Quickticket installation checker</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<link rel="stylesheet" href="admin/qti_main.css">
</head>';

echo '<body>

<!-- PAGE CONTROL -->
<div class="div_page">
<table class="ta_page" width="550" cellspacing="0" style="margin:5px">
<tr class="tr_page">
<td class="td_page">
<!-- PAGE CONTROL -->

<!-- HEADER BANNER -->
<div class="div_banner">
<div class="div_banner_in">
<img src="admin/qti_logo.gif" width="175" height="50" style="border-width:0" alt="QuickTicket" title="QuickTicket"/>
</div>
</div>
<!-- END HEADER BANNER -->

<!-- BODY MAIN -->
<table width="100%" cellspacing="0" style="border:1px solid #AAAAAA;">
<tr>
<td style="padding:5px 10px 5px 10px;">
<!-- BODY MAIN -->
';

// --------
// 1 CONFIG
// --------

echo '<h1>Checking your configuration</h1>';

$qti_error = '';

// 1 file exist

  echo 'Checking installed files...<br/>';

  if ( !file_exists('bin/config.php') ) $qti_error .= 'File <b>config.php</b> is not in the <b>bin</b> directory. Communication with database is impossible.<br/>';
  if ( !file_exists('bin/qti_init.php') ) $qti_error .= 'File <b>qti_init.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';
  if ( !file_exists('bin/qti_fn_common.php') ) $qti_error .= 'File <b>qti_fn_common.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';
  if ( !file_exists('bin/qt_lib_db.php') ) $qti_error .= 'File <b>qt_lib_db.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';
  if ( !file_exists('bin/qt_lib_txt.php') ) $qti_error .= 'File <b>qt_lib_txt.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';
  if ( !file_exists('bin/qti_class_section.php') ) $qti_error .= 'File <b>qti_class_section.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';
  if ( !file_exists('bin/qti_class_topic.php') ) $qti_error .= 'File <b>qti_class_topic.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';
  if ( !file_exists('bin/qti_class_post.php') ) $qti_error .= 'File <b>qti_class_post.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';
  if ( !file_exists('bin/qti_class_vip.php') ) $qti_error .= 'File <b>qti_class_vip.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';
  if ( !file_exists('bin/qti_class_lang.php') ) $qti_error .= 'File <b>qti_class_lang.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';
  if ( !file_exists('bin/qti_class_status.php') ) $qti_error .= 'File <b>qti_class_status.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';

  if ( !empty($qti_error) ) die($qti_error);

  echo 'Main files found.<br/><br/>';

// 2 config is correct

  echo 'Checking config.php...<br/>';

  include('bin/config.php');

  if ( !isset($qti_dbsystem) ) $qti_error .= 'Variable <b>$qti_dbsystem</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';
  if ( !isset($qti_host) ) $qti_error .= 'Variable <b>$qti_host</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';
  if ( !isset($qti_database) ) $qti_error .= 'Variable <b>$qti_database</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';
  if ( !isset($qti_prefix) ) $qti_error .= 'Variable <b>$qti_prefix</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';
  if ( !isset($qti_user) ) $qti_error .= 'Variable <b>$qti_user</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';
  if ( !isset($qti_pwd) ) $qti_error .= 'Variable <b>$qti_pwd</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';
  if ( !isset($qti_port) ) $qti_error .= 'Variable <b>$qti_port</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';
  if ( !isset($qti_dsn) ) $qti_error .= 'Variable <b>$qti_dsn</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';
  if ( !empty($qti_error) ) die($qti_error);

  // check db type
  if ( !in_array($qti_dbsystem,array('mysql4','mysql','mssql','pg','ibase','sqlite','db2','access','ifx','oci')) ) die('Unknown db type '.$qti_dbsystem);

  // check other values
  if ( empty($qti_host) ) $qti_error .= 'Variable <b>$qti_host</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';
  if ( empty($qti_database) ) $qti_error .= 'Variable <b>$qti_database</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';
  if ( !empty($qti_error) ) die($qti_error);

  echo 'Done.<br/><br/>';

// 3 test db connection

  echo 'Connecting to database...<br/>';

  include('bin/qt_lib_db.php');

  $oDB = new cDB($qti_dbsystem,$qti_host,$qti_database,$qti_user,$qti_pwd,$qti_port,$qti_dsn);
  if ( !empty($oDB->error) ) die ('<p style="color:red">Connection with database failed.<br/>Check that server is up and running.<br/>Check that the settings in the file <b>bin/config.php</b> are correct for your database.</p>');

  echo 'Done.<br/><br/>';

echo '--> Configuration tests completed successfully.';

// --------
// 2 DATABASE
// --------

$qti_error = '';

echo '<h1>Checking your database design</h1>';

// 1 setting table (version 1.9 support database versions 1.9)

  echo 'Checking setting table...<br/>';

  $oDB->Query('SELECT setting FROM '.$qti_prefix.'qtisetting WHERE param="version"');
  if ( !empty($oDB->error) ) die("<br/><font color=red>Problem with table ".$qti_prefix."qtisetting</font>");
  $row = $oDB->Getrow();
  $strVersion = $row['setting'];
  echo "Table [".$qti_prefix."qtisetting] exists. Version is $strVersion.<br/><br/>";
  if ( !in_array(substr($strVersion,0,3),array('1.9')) ) die('But data in this table refers to an incompatible version (must be version 1.9).');

// 2 domain table

  echo 'Checking domain table...<br/>';

  $oDB->Query('SELECT count(id) as countid FROM '.$qti_prefix.'qtidomain');
  if ( !empty($oDB->error) ) die("<br/><font color=red>Problem with table ".$qti_prefix."qtidomain</font>");
  $row = $oDB->Getrow();
  $intCount = $row['countid'];
  echo "Table [".$qti_prefix."qtidomain] exists. $intCount domain(s) found.<br/><br/>";

// 3 forum table

  echo 'Checking forum table...<br/>';

  $oDB->Query('SELECT count(id) as countid FROM '.$qti_prefix.'qtiforum');
  if ( !empty($oDB->error) ) die("<br/><font color=red>Problem with table ".$qti_prefix."qtiforum</font>");
  $row = $oDB->Getrow();
  $intCount = $row['countid'];
  echo "Table [".$qti_prefix."qtiforum] exists. $intCount section(s) found.<br/><br/>";

// 4 topic table

  echo "Checking topic table...<br/>";

  $oDB->Query('SELECT count(id) as countid FROM '.$qti_prefix.'qtitopic');
  if ( !empty($oDB->error) ) die("<br/><font color=red>Problem with table ".$qti_prefix."qtitopic</font>");
  $row = $oDB->Getrow();
  $intCount = $row['countid'];
  echo "Table [".$qti_prefix."qtitopic] exists. $intCount ticket(s) found.<br/><br/>";

// 5 post table

  echo 'Checking post table...<br/>';

  $oDB->Query('SELECT count(id) as countid FROM '.$qti_prefix.'qtipost');
  if ( !empty($oDB->error) ) die("<br/><font color=red>Problem with table ".$qti_prefix."qtipost</font>");
  $row = $oDB->Getrow();
  $intCount = $row['countid'];
  echo "Table [".$qti_prefix."qtipost] exists. $intCount post(s) found.<br/><br/>";

// 6 user table

  echo 'Checking user table...<br/>';

  $oDB->Query('SELECT count(id) as countid FROM '.$qti_prefix.'qtiuser');
  if ( !empty($oDB->error) ) die("<br/><font color=red>Problem with table ".$qti_prefix."qtiuser</font>");
  $row = $oDB->Getrow();
  $intCount = $row['countid'];
  echo "Table [".$qti_prefix."qtiuser] exists. $intCount user(s) found.<br/><br/>";

echo '--> Database tests completed successfully.';

// --------
// 3 LANGUAGE AND SKIN
// --------

$qti_error = '';

echo "<h1>Checking language and skin options</h1>";

  $oDB->Query('SELECT setting FROM '.$qti_prefix.'qtisetting WHERE param="language"');
  $row = $oDB->Getrow();
  $str = $row['setting'];
  if ( empty($str) ) $qti_error .= 'Setting <b>language</b> is not defined in the setting table. Application can only work with english.<br/>';
  if ( !file_exists("language/$str/qti_lang_main.inc") ) $qti_error .= "File <b>qti_lang_main.inc</b> is not in the <b>language/xxxx</b> directory.<br/>";
  if ( !file_exists("language/$str/qti_lang_adm.inc") ) $qti_error .= "File <b>qti_lang_adm.inc</b> is not in the <b>language/xxxx</b> directory.<br/>";
  if ( !file_exists("language/$str/qti_lang_icon.inc") ) $qti_error .= "File <b>qti_lang_icon.inc</b> is not in the <b>language/xxxx</b> directory.<br/>";
  if ( !file_exists("language/$str/qti_lang_reg.inc") ) $qti_error .= "File <b>qti_lang_reg.inc</b> is not in the <b>language/xxxx</b> directory.<br/>";
  if ( !file_exists("language/$str/qti_lang_zone.inc") ) $qti_error .= "File <b>qti_lang_zone.inc</b> is not in the <b>language/xxxx</b> directory.<br/>";
  if ( !file_exists("language/english/qti_lang_main.inc") ) $qti_error .= "File <b>qti_lang_main.inc</b> is not in the <b>language/english</b> directory. English language is mandatory.<br/>";
  if ( !file_exists("language/english/qti_lang_adm.inc") ) $qti_error .= "File <b>qti_lang_adm.inc</b> is not in the <b>language/english</b> directory. English language is mandatory.<br/>";
  if ( !file_exists("language/english/qti_lang_icon.inc") ) $qti_error .= "File <b>qti_lang_icon.inc</b> is not in the <b>language/english</b> directory. English language is mandatory.<br/>";
  if ( !file_exists("language/english/qti_lang_reg.inc") ) $qti_error .= "File <b>qti_lang_reg.inc</b> is not in the <b>language/english</b> directory. English language is mandatory.<br/>";
  if ( !file_exists("language/english/qti_lang_zone.inc") ) $qti_error .= "File <b>qti_lang_zone.inc</b> is not in the <b>language/english</b> directory. English language is mandatory.<br/>";

  $oDB->Query('SELECT setting FROM '.$qti_prefix.'qtisetting WHERE param="skin_dir"');
  $row = $oDB->Getrow();
  $str = $row['setting'];

  if ( empty($str) ) $qti_error .= 'Setting <b>skin</b> is not defined in the setting table. Application will not display correctly.<br/>';
  if ( !file_exists("skin/$str/qti_main.css") ) $qti_error .= "File <b>qti_main.css</b> is not in the <b>skin/xxxx</b> directory.<br/>";
  if ( !file_exists("skin/default/qti_main.css") ) $qti_error .= "File <b>qti_main.css</b> is not in the <b>skin/default</b> directory. Default skin is mandatory.<br/>";

  if ( !empty($qti_error) ) echo $qti_error;
  $qti_error = '';

echo '--> Language and skin files tested.';

// --------
// 4 ADMINISTRATION TIPS
// --------

$qti_error = '';

echo '<h1>Administration tips</h1>';

// 1 admin email

  echo 'Email setting...<br/>';

  $oDB->Query('SELECT setting FROM '.$qti_prefix.'qtisetting WHERE param="admin_email"');
  $row = $oDB->Getrow();
  $strMail = $row['setting'];
  if ( empty($strMail) )
  {
  $qti_error .= "<font color=red>Administrator e-mail is not yet defined. It's mandatory to define it !</font><br/>";
  }
  else
  {
  if ( !ereg("^.+@.+\..+$",$strMail) ) $qti_error .= "<font color=red>Administrator e-mail format seams incorrect. Please check it</font><br/>";
  }

  if ( !empty($qti_error) ) echo $qti_error;
  echo "Done.<br/><br/>";
  $qti_error = '';

// 2 admin password

  echo 'Security check...<br/>';

  $oDB->Query('SELECT pwd FROM '.$qti_prefix.'qtiuser WHERE id=1');
  $row = $oDB->Getrow();
  $strPwd = $row['pwd'];
  If ( $strPwd==sha1('Admin') ) $qti_error .= "<font color=red>Administrator password is still the initial password. It's recommended to change it !</font><br/>";

  if ( !empty($qti_error) ) echo $qti_error;
  echo 'Done.<br/><br/>';
  $qti_error = '';

// 3 site url

  echo 'Site url...<br/>';

  $oDB->Query('SELECT setting FROM '.$qti_prefix.'qtisetting WHERE param="site_url"');
  $row = $oDB->Getrow();
  $strText = trim($row['setting']);
  if ( substr($strText,0,7)!="http://" && substr($strText,0,8)!="https://" )
  {
    $qti_error .= '<font color=red>Site url is not yet defined (or not starting by http://). It\'s mandatory to define it !</font><br/>';
  }
  else
  {
    $strURL = ( empty($_SERVER['SERVER_HTTPS']) ? "http://" : "https://" ).$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    $strURL = substr($strURL,0,-18);
    if ( $strURL!=$strText ) $qti_error .= '<font color=red>Site url seams to be different that the current url. Please check it</font><br/>';
  }

  if ( !empty($qti_error) ) echo $qti_error;
  echo 'Done.<br/><br/>';
  $qti_error = '';

// 4 avatar/upload folder permission

  echo 'Folder permissions...<br/>';

  if ( !is_dir('avatar') )
  {
    $qti_error .= '<font color=red>Directory <b>avatar</b> not found.</font><br/>Please create this directory and make it writeable (chmod 777) if you want to allow avatars<br/>';
  }
  else
  {
    if ( !is_readable('avatar') ) $qti_error .= '<font color=red>Directory <b>avatar</b> is not readable.</font><br/>Change permissions (chmod 777) if you want to allow avatars<br/>';
    if ( !is_writable('avatar') ) $qti_error .= '<font color=red>Directory <b>avatar</b> is not writable.</font><br/>Change permissions (chmod 777) if you want to allow avatars<br/>';
  }
  if ( !is_dir('upload') )
  {
    $qti_error .= '<font color=red>Directory <b>upload</b> not found.</font><br/>Please create this directory and make it writeable (chmod 777) if you want to allow uploads<br/>';
  }
  else
  {
    if ( !is_readable('upload') ) $qti_error .= '<font color=red>Directory <b>upload</b> is not readable.</font><br/>Change permissions (chmod 777) if you want to allow uploads<br/>';
    if ( !is_writable('upload') ) $qti_error .= '<font color=red>Directory <b>upload</b> is not writable.</font><br/>Change permissions (chmod 777) if you want to allow uploads<br/>';
  }

  if ( !empty($qti_error) ) echo $qti_error;
  echo 'Done.<br/><br/>';
  $qti_error = '';

echo '--> Administration tips completed.';

// --------
// 5 END
// --------

echo '<h1>Result</h1>';
echo 'The checker did not found blocking issues in your configuration.<br/>';

  $oDB->Query('SELECT setting FROM '.$qti_prefix.'qtisetting WHERE param="board_offline"');
  $row = $oDB->Getrow();
  $strOff = $row['setting'];
  if ( $strOff=='1' ) echo 'Your board seams well installed, but is currently off-line.<br/>Log as Administrator and go to the Administration panel to turn your board on-line.<br/>';

echo '<br/><br/><a href="qti_index.php">Go to QuickTicket</a>';

// --------
// HTML END
// --------

echo '<!-- END BODY MAIN -->
</td>
</tr>
</table>
<!-- END BODY MAIN -->

<div class="div_footer_copy">
<span class="p_footer_copy">powered by <a href="http://www.qt-cute.org" class="a_footer_copy">QT-cute</a></span>
</div>

<!-- END PAGE CONTROL -->
</td>
</tr>
</table>
</div>
<!-- END PAGE CONTROL -->

</body>

</html>';

?>
Return current item: QuickTicket