Location: PHPKode > projects > QuickTalk Forum > quicktalk/check.php
<?php



// QuickTalk 2.5 build:20100924



echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en" lang="en">



<head>

<title>QuickTalk installation checker</title>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>

<style type="text/css">

div.qtf_page {margin:5px auto;width:700px}

div.banner {color:inherit; background:#0C4C8C url(admin/bg_header.gif) repeat-x}

h1,h2,p,a,select,input,textarea,td,th,fieldset,div {font-family:Verdana, Arial, sans-serif}

h1 {margin-top:10px; margin-bottom:5px; font-size:14pt; font-weight:bold}

h2 {margin-top:10px; margin-bottom:5px; font-size:12pt; font-weight:bold}

p,select,input,textarea,td,th,a,fieldset {font-size:9pt; text-decoration:none}

a {color:#0000FF}

a.visited {color:#0000FF}

a:hover {color:#0000FF; text-decoration:underline}

p.check {margin:5px 0 0 0; padding:0}

p.endcheck {margin:5px 0 0 0; padding:5px; border:solid 1px #aaaaaa}

span.ok {color:#00aa00; background-color:inherit}

span.nok {color:#ff0000; background-color:inherit}

</style>

</head>



<body>



<!-- PAGE CONTROL -->

<div class="qtf_page">



<!-- HEADER BANNER -->

<div class="banner">

<div class="banner_in">

<img src="admin/qtf_logo.gif" width="175" height="50" style="border-width:0" alt="QuickTalk" title="QuickTalk"/>

</div>

</div>



<!-- BODY MAIN -->

<div class="main">

';



// --------

// 1 CONFIG

// --------



echo '<p style="margin:0;text-align:right">QuickTalk 2.5 build:20100924</p>';



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



$error = '';



// 1 file exist



  echo '<p class="check">Checking installed files... ';



  if ( !file_exists('bin/config.php') ) $error .= 'File <b>config.php</b> is not in the <b>bin</b> directory. Communication with database is impossible.<br/>';

  if ( !file_exists('bin/qtf_init.php') ) $error .= 'File <b>qtf_init.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';

  if ( !file_exists('bin/qtf_fn_base.php') ) $error .= 'File <b>qtf_fn_base.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';

  if ( !file_exists('bin/qt_lib_db.php') ) $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') ) $error .= 'File <b>qt_lib_txt.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';

  if ( !file_exists('bin/qtf_class_sec.php') ) $error .= 'File <b>qtf_class_sec.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';

  if ( !file_exists('bin/qtf_class_topic.php') ) $error .= 'File <b>qtf_class_topic.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';

  if ( !file_exists('bin/qtf_class_post.php') ) $error .= 'File <b>qtf_class_post.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';

  if ( !file_exists('bin/qtf_class_vip.php') ) $error .= 'File <b>qtf_class_vip.php</b> is not in the <b>bin</b> directory. Application cannot start.<br/>';



  if ( empty($error) )

  {

  echo '<span class="ok">Main files found.</span></p>';

  }

  else

  {

  die('<span class="nok">'.$error.'</span></p>');

  }



// 2 config is correct



  echo '<p class="check">Checking config.php... ';



  include('bin/config.php');

  include('bin/qtf_fn_base.php');



  if ( !isset($qtf_dbsystem) ) $error .= 'Variable <b>$qtf_dbsystem</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';

  if ( !isset($qtf_host) )     $error .= 'Variable <b>$qtf_host</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';

  if ( !isset($qtf_database) ) $error .= 'Variable <b>$qtf_database</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';

  if ( !isset($qtf_prefix) )   $error .= 'Variable <b>$qtf_prefix</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';

  if ( !isset($qtf_user) )     $error .= 'Variable <b>$qtf_user</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';

  if ( !isset($qtf_pwd) )      $error .= 'Variable <b>$qtf_pwd</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';

  if ( !isset($qtf_port) )     $error .= 'Variable <b>$qtf_port</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';

  if ( !isset($qtf_dsn) )      $error .= 'Variable <b>$qtf_dsn</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.<br/>';



  if ( !empty($error) )  die('<span class="nok">'.$error.'</span>');



  // check db type

  if ( !in_array($qtf_dbsystem,array('mysql4','mysql','mssql','pg','ibase','sqlite','db2','oci')) ) die('Unknown db type '.$qtf_dbsystem);

  // check other values

  if ( empty($qtf_host) )      $error .= '<br/>Variable <b>$qtf_host</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.';

  if ( empty($qtf_database) )  $error .= '<br/>Variable <b>$qtf_database</b> is not defined in the file <b>bin/config.php</b>. Communication with database is impossible.';



  if ( empty($error) )

  {

  echo '<span class="ok">Done.</span></p>';

  }

  else

  {

  die('<span class="nok">'.$error.'</span></p>');

  }



// 3 test db connection



  echo '<p class="check">Connecting to database... ';



  include('bin/qt_lib_db.php');



  $oDB = new cDB($qtf_dbsystem,$qtf_host,$qtf_database,$qtf_user,$qtf_pwd,$qtf_port,$qtf_dsn);



  if ( empty($oDB->error) )

  {

  echo '<span class="ok">Done.</span></p>';

  }

  else

  {

  die('<span class="nok">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.</span></p>');

  }



// end CONFIG tests



  echo '<p class="endcheck">Configuration tests completed successfully.</p>';



// --------

// 2 DATABASE

// --------



$error = '';



echo '

<h1>Checking your database design</h1>

';



// 1 setting table



  echo '<p class="check">Checking setting table... ';

   

  $oDB->Query('SELECT setting FROM '.$qtf_prefix.'qtasetting WHERE param="version"');

  if ( !empty($oDB->error) ) die('<span class="nok">Problem with table '.$qtf_prefix.'qtasetting</span>');

  $row = $oDB->Getrow();

  $strVersion = $row['setting'];



  echo '<span class="ok">Table [',$qtf_prefix,'qtasetting] exists. Version is ',$strVersion,'.</span>';

  if ( !in_array(substr($strVersion,0,3),array('2.2','2.3','2.4','2.5')) ) die('<span class="nok">But data in this table refers to an incompatible version (must be version 2.5).</span></p>');

  echo '</p>';



// 2 domain table



  echo '<p class="check">Checking domain table... ';

  

  $oDB->Query('SELECT count(*) as countid FROM '.$qtf_prefix.'qtadomain');

  if ( !empty($oDB->error) ) die('<span class="nok">Problem with table '.$qtf_prefix.'qtadomain</span>');

  $row = $oDB->Getrow();

  $intCount = $row['countid'];

  echo '<span class="ok">Table [',$qtf_prefix,'qtadomain] exists. ',$intCount,' domain(s) found.</span></p>';



// 3 team table



  echo '<p class="check">Checking forum table...';

  

  $oDB->Query('SELECT count(id) as countid FROM '.$qtf_prefix.'qtaforum');

  if ( !empty($oDB->error) ) die('<span class="nok">Problem with table '.$qtf_prefix.'qtasection</span>');

  $row = $oDB->Getrow();

  $intCount = $row['countid'];

  echo '<span class="ok">Table [',$qtf_prefix,'qtasection] exists. ',$intCount,' section(s) found.</span></p>';



// 4 topic table



  echo '<p class="check">Checking topic table...';

  

  $oDB->Query('SELECT count(id) as countid FROM '.$qtf_prefix.'qtatopic');

  if ( !empty($oDB->error) ) die('<span class="nok">Problem with table '.$qtf_prefix.'qtatopic</span>');

  $row = $oDB->Getrow();

  $intCount = $row['countid'];

  echo '<span class="ok">Table [',$qtf_prefix,'qtatopic] exists. ',$intCount,' topic(s) found.</span></p>';



// 5 post table



  echo '<p class="check">Checking post table...';

  

  $oDB->Query('SELECT count(id) as countid FROM '.$qtf_prefix.'qtapost');

  if ( !empty($oDB->error) ) die('<span class="nok">Problem with table '.$qtf_prefix.'qtapost</span>');

  $row = $oDB->Getrow();

  $intCount = $row['countid'];

  echo '<span class="ok">Table [',$qtf_prefix,'qtapost] exists. ',$intCount,' post(s) found.</span></p>';



// 6 user table



  echo '<p class="check">Checking user table... ';

  

  $oDB->Query('SELECT count(id) as countid FROM '.$qtf_prefix.'qtauser');

  if ( !empty($oDB->error) ) die('<span class="nok">Problem with table '.$qtf_prefix.'qtauser</span>');

  $row = $oDB->Getrow();

  $intCount = $row['countid'];

  echo '<span class="ok">Table [',$qtf_prefix,'qtauser] exists. ',$intCount,' user(s) found.</span></p>';



// end DATABASE tests



  echo '<p class="endcheck">Database tests completed successfully.</p>';



// --------

// 3 LANGUAGE AND SKIN

// --------



$error = '';



echo '

<h1>Checking language and skin options</h1>

';



  echo '<p class="check">Files... ';



  $oDB->Query('SELECT setting FROM '.$qtf_prefix.'qtasetting WHERE param="language"');

  $row = $oDB->Getrow();

  $str = $row['setting'];

  if ( empty($str) ) $error .= 'Setting <b>language</b> is not defined in the setting table. Application can only work with english.<br/>';  

  if ( !file_exists("language/$str/qtf_main.php") ) $error .= "File <b>qtf_main.php</b> is not in the <b>language/xxxx</b> directory.<br/>";

  if ( !file_exists("language/$str/qtf_adm.php") )  $error .= "File <b>qtf_adm.php</b> is not in the <b>language/xxxx</b> directory.<br/>";

  if ( !file_exists("language/$str/qtf_icon.php") ) $error .= "File <b>qtf_icon.php</b> is not in the <b>language/xxxx</b> directory.<br/>";

  if ( !file_exists("language/$str/qtf_reg.php") )  $error .= "File <b>qtf_reg.php</b> is not in the <b>language/xxxx</b> directory.<br/>";

  if ( !file_exists("language/$str/qtf_zone.php") ) $error .= "File <b>qtf_zone.php</b> is not in the <b>language/xxxx</b> directory.<br/>";

  if ( $str!='english' )

  {

  if ( !file_exists("language/english/qtf_main.php") ) $error .= "File <b>qtf_main.php</b> is not in the <b>language/english</b> directory. English language is mandatory.<br/>";

  if ( !file_exists("language/english/qtf_adm.php") )  $error .= "File <b>qtf_adm.php</b> is not in the <b>language/english</b> directory. English language is mandatory.<br/>";

  if ( !file_exists("language/english/qtf_icon.php") ) $error .= "File <b>qtf_icon.php</b> is not in the <b>language/english</b> directory. English language is mandatory.<br/>";

  if ( !file_exists("language/english/qtf_reg.php") )  $error .= "File <b>qtf_reg.php</b> is not in the <b>language/english</b> directory. English language is mandatory.<br/>";

  if ( !file_exists("language/english/qtf_zone.php") ) $error .= "File <b>qtf_zone.php</b> is not in the <b>language/english</b> directory. English language is mandatory.<br/>";

  }

  

  $oDB->Query('SELECT setting FROM '.$qtf_prefix.'qtasetting WHERE param="skin_dir"');

  $row = $oDB->Getrow();

  $str = $row['setting']; if ( substr($str,0,5)!='skin/' ) $str = 'skin/'.$str;



  if ( empty($str) ) $error .= 'Setting <b>skin</b> is not defined in the setting table. Application will not display correctly.<br/>';  

  if ( !file_exists("$str/qtf_main.css") ) $error .= "File <b>qtf_main.css</b> is not in the <b>$str</b> directory.<br/>";

  if ( !file_exists("skin/default/qtf_main.css") ) $error .= 'File <b>qtf_main.css</b> is not in the <b>skin/default</b> directory. Default skin is mandatory.<br/>';

  

  if ( empty($error) ) 

  {

  echo '<span class="ok">Ok.</span>';

  }

  else

  {

  echo '<span class="nok">',$error,'</span>';

  }



  echo '</p>';



// end LANGUAGE AND SKIN tests



  echo '<p class="endcheck">Language and skin files tested.</p>';



// --------

// 4 ADMINISTRATION TIPS

// --------



$error = '';



echo '

<h1>Administration tips</h1>

';



// 1 admin email



  echo '<p class="check">Email setting... ';



  $oDB->Query('SELECT setting FROM '.$qtf_prefix.'qtasetting WHERE param="admin_email"');

  $row = $oDB->Getrow();

  $strMail = $row['setting'];

  if ( empty($strMail) )

  {

  $error .= 'Administrator e-mail is not yet defined. It\'s mandatory to define it!';

  }

  else

  {

  if ( !preg_match("/^[A-Z0-9._%-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z]{2,6}$/i",$strMail) ) $error .= 'Administrator e-mail format seams incorrect. Please check it';

  }



  if ( !empty($error) ) echo '<span class="nok">'.$error.'</span></p>';

  echo '<span class="ok">Done.</span></p>';

  $error = '';



// 2 admin password



  echo '<p class="check">Security check... ';



  $oDB->Query('SELECT pwd FROM '.$qtf_prefix.'qtauser WHERE id=1');

  $row = $oDB->Getrow();

  $strPwd = $row['pwd'];

  If ( $strPwd==sha1('Admin') ) $error .= 'Administrator password is still the initial password. It\'s recommended to change it !<br/>';



  if ( empty($error) ) 

  {

  echo '<span class="ok">Done.</span></p>';

  }

  else

  {

  echo '<span class="nok">',$error,'</span></p>';

  }

  $error = '';



// 3 site url



  echo '<p class="check">Site url... ';



  $oDB->Query('SELECT setting FROM '.$qtf_prefix.'qtasetting WHERE param="site_url"');

  $row = $oDB->Getrow();

  $strText = trim($row['setting']);

  if ( substr($strText,0,7)!='http://' && substr($strText,0,8)!='https://' )

  {

    $error .= 'Site url is not yet defined (or not starting by http://). It\'s mandatory to define it !<br/>';

  }

  else

  {

    $strURL = ( empty($_SERVER['SERVER_HTTPS']) ? 'http://' : 'https://' ).$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];

    $strURL = substr($strURL,0,-10);

    if ( $strURL!=$strText ) $error .= 'Site url seams to be different that the current url. Please check it<br/>';

  }   



  if ( empty($error) ) 

  {

  echo '<span class="ok">Done.</span></p>';

  }

  else

  {

  echo '<span class="nok">',$error,'</span></p>';

  }

  $error = '';



// 4 avatar folder permission



  echo '<p class="check">Folder permissions... ';

  

  if ( !is_dir('avatar') )

  { 

    $error .= 'Directory <b>avatar</b> not found.<br/>Please create this directory and make it writeable (chmod 777) if you want to allow avatars.<br/>';

  }

  else

  {

    if ( !is_readable('avatar') ) $error .= 'Directory <b>avatar</b> is not readable.</font><br/>Change permissions (chmod 777) if you want to allow avatars.<br/>';

    if ( !is_writable('avatar') ) $error .= 'Directory <b>avatar</b> is not writable.</font><br/>Change permissions (chmod 777) if you want to allow avatars.<br/>';

  }



  if ( !empty($error) ) echo '<span class="nok">',$error,'</span></p>';

  echo '<span class="ok">Done.</span></p>';

  $error = '';



echo '<p class="endcheck">Administration tips completed.</p>';



// --------

// 5 END

// --------



echo '

<h1>Result</h1>

';

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



  $oDB->Query('SELECT setting FROM '.$qtf_prefix.'qtasetting WHERE param="board_offline"');

  $row = $oDB->Getrow();

  $strOff = $row['setting'];

  if ( $strOff=='1' ) echo 'Your board seams well installed, but is currently <font color="red">off-line</font>.<br/>Log as Administrator and go to the Administration panel to turn your board on-line.<br/>';



echo '<br/><br/><a href="qtf_index.php">Go to QuickTalk</a>';



// --------

// HTML END

// --------



echo '

</div>



<!-- END PAGE CONTROL -->

</div>

</body>

</html>';



?>

Return current item: QuickTalk Forum