index.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:35k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: index.php,v $
- // | $Date: 2004/02/12 21:16:57 $
- // | $Revision: 1.10 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Basic Configuration
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- if (function_exists('set_time_limit') and get_cfg_var('safe_mode') == 0) {
- @set_time_limit(1200);
- }
- define('DEVELOPERMODE', '1');
- define('DONOT_LOGQUERIES', '1');
- define('INSTALLER', 1);
- @include_once('./../includes/config.php');
- require_once('./../includes/global.php');
- require_once('./../includes/functions/admin-tech_functions.php');
- require_once('./../includes/functions/general_functions.php');
- require_once('./../includes/functions/database/mysql.php');
- require_once('./../includes/functions/conditional_functions.php');
- install_header('DeskPRO Installation & Upgrade');
- if (!in_string('index.php', $_SERVER['SCRIPT_NAME']) AND !in_string('index.php', $_SERVER['PHP_SELF'])) {
- echo "This file can only be run when the filename is <b>index.php</b>. Please rename it to run the file.";
- exit();
- }
- $latest_version = '2.0.1';
- ?>
- <script language="javascript">
- function visyes(id) {
- e=document.getElementById(id).style;
- e.display='';
- }
- </script>
- <?php
- ######################################################################################################################
- ############################################ EMPTY DATABASE #################################################
- ######################################################################################################################
- if ($_REQUEST['do'] == "delete_database") {
- echo "<center>Please <a href="index.php?do=delete_database2">confirm</a> that you wish to empty the database " . DATABASE_NAME . ". This will delete <b>ALL</b> tables and is completly irreversible.</center>";
- exit();
- }
- if ($_REQUEST['do'] == "delete_database2") {
- $db = new DB_Sql;
- $db->Halt_On_Error = 'no';
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->connect();
- $db->query("DROP database " . DATABASE_NAME);
- if (!$db->geterrno()) {
- $db->query("CREATE database " . DATABASE_NAME);
- if (!$errno = mysql_errno()) {
- alert('Your database has been emptied.');
- } else {
- alert('Your database was deleted but could not be recreated.');
- }
- } else {
- alert("Your database could not be deleted. Please check the database user has permission to perform this action. mySQL Error number: " . $db->geterrno() . " mySQL Error description: " . $db->geterrdesc());
- }
- unset($_REQUEST['do']);
- }
- if (!$_REQUEST['do']) {
- ######################################################################################################################
- ############################################ START INSTALL / UPGRADE #################################################
- ######################################################################################################################
-
- ?>
- <b>Welcome to the DeskPRO Installer & Upgrader.<br />
- Nullified by WTN-WDYL Team `2004'<br /></b>
- <br />
- <?php
- $fail += check_config();
- $fail += check_thelicense();
- $fail += check_php_ver();
- $fail += check_mysql();
- $fail += check_pcre();
- $fail += check_graphs_perms();
- $fail += check_encoding();
- $warning += check_gd();
- $warning += check_sessions();
- echo "<br /><br />";
- if ($fail) {
- echo "<P>Please correct the following problems, and reload this page. DeskPro v2.0 installation cannot continue until these are resolved:</P><UL>n";
- echo $askhostto;
- echo "</UL>";
- exit();
- }
- $db = new DB_Sql;
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->Halt_On_Error = 'no';
- $db->connect();
- $errno = mysql_errno();
- // we have connected to database, lets check for tables
- if (!$errno) {
- $send_to_deskpro .= "- We connected to the Databasen";
- $db->query("SHOW TABLES");
- if ($db->num_rows()) {
- $send_to_deskpro .= "- The database contained tablesn";
-
- // if we get here we have tables in this database. This is probably bad
- while ($result = $db->row_array()) {
- $send_to_deskpro .= "- Database table $result[0] foundn";
- // need to work out if this *is* deskpro
- $table_array[] = $result[0];
- // pick unusal v2 table
- if ($result[0] == 'tech_internal_help_entry') {
- $send_to_deskpro .= "- We found the tech_internal_help_entry table suggesting a DeskPRO v2 installn";
- $using_deskpro = 1;
- }
- // pick v1 table
- if ($result[0] == 'categories') {
- $send_to_deskpro .= "- We found the categories table suggesting a DeskPRO v1 installn";
- $using_deskpro = 1;
- $deskpro_v1 = 1;
- }
- }
- $result = $db->query_return("SELECT * FROM settings WHERE settings = 'deskpro_version'");
- if (is_array($result)) {
- $send_to_deskpro .= "- We found the DeskPRO version row in the settings tablen";
- $deskpro_version = $result['value'];
- $send_to_deskpro .= "- We found the DeskPRO version, it is $result[value]n";
- }
- // we now know if this is deskpro, what version of deskpro if it is and the table.
- if ($deskpro_version OR $using_deskpro) {
- $doupgrade = 1;
- echo "<span class="cp_temp_orig">DeskPRO database found with v$deskpro_version</span><br /><br />";
- echo "The database <i><b>" . DATABASE_NAME . "</b></i> already contains an installation of DeskPRO";
- if ($deskpro_version) {
- echo " v$deskpro_version.";
- }
- if ($deskpro_version == $latest_version) {
- echo "<br /><br />You already have the latest version of DeskPRO installed. <br /><br /> If you wish to reinstall DeskPRO you must first delete your database. This is irreversible and results in complete loss of your current data. " . jprompt('Are you sure you wish to delete your database?', 'index.php?do=delete_database', ' delete your database');
- exit();
- }
- echo " You can now start the DeskPRO upgrade process. If you wish to perform a fresh installation of DeskPRO you will first have to " . jprompt('Are you sure you wish to delete your database?', 'index.php?do=delete_database', 'empty your database') . ", (this is irreversible) and start with a new database from scratch.";
- ?>
- <br /><br />
- Please verify that you have backed up your database. You can back up your database using the <I>mysqldump</I> utility
- (included with MySQL). Alternately, you can use a utility such as
- phpMyAdmin. Please note that
- we can not be held responsible for any problems with the upgrade process. It is essential you have made a backup and that you have checked your backup is complete.<br /><br />
- We are now going to upgrade your DeskPRO installation from v<?php echo "$deskpro_version to v$latest_version";?>. If this is not the version of DeskPRO you currently have installed, please contact DeskPRO Support.<br /><br />
- The upgrade system will upgrade your software to the latest version of
- DeskPRO.<br /><br />
-
- <center>
- <form action="index.php" method="post" name="upgrade">
- <?php
- if ($deskpro_v1) {
- echo "<input type="hidden" name="do" value="upgrade_v1">";
- } else {
- echo "<input type="hidden" name="do" value="upgrade_v2">";
- }
- ?>
- <script language="JavaScript">
- function jprompt_2(message,url) {
- input_box=confirm(message);
- if (input_box==true) {
- document.upgrade.submit();
- }
- }
- document.write('<input type="button" name="upgrade" value="<?php echo "Upgrade v$deskpro_version to v$latest_version";?>" onclick="jprompt_2('This will immediately begin the upgrade process. Do NOT proceed until you have backed up your database! Without a backup, this process cannot be reversed!')">');
-
- </script>
- <noscript>
- <input type="submit" name="upgrade" value="Perform Upgrade" />
- </noscript>
- </form>
-
- <?php
-
- } else {
- echo "The database you specified in config.php already has tables in it. It is not recommended that you install DeskPRO in a database that already has tables are there are likely to be conflicts. You can either " . jprompt('Are you sure you wish to delete your database?', 'index.php?do=delete_database', ' delete your database') . " which is irreverisble or continue with the <a href="index.php?fromindex=1">install</a>";
- }
- } else {
- $send_to_deskpro .= "- The database contains no tablesn";
- }
- } else {
- $send_to_deskpro .= "- We could not connect to the databasen";
- }
- if (!$doupgrade) {
-
- // if we get here we either have no database found or an empty database.
- echo " <span class="cp_temp_orig">No current installations where found.</span><br /><center><form method="post" action="index.php"><input type="hidden" name="do" value="install"><input type="submit" name="go" value="Start Installation"></form>";
- }
- echo "</center><hr>If this the result above is not what you where expecting, click <a href="javascript:visyes('report');">here</a>.<br /><br />";
- echo "<div id="report" name="report" style="display:none">Error.<br /><br />
- <textarea style="width:100%" rows="15">$send_to_deskpro</textarea></div>
- ";
- }
- ######################################################################################################################
- ############################################ INSTALL #################################################################
- ######################################################################################################################
- if ($_REQUEST['do'] == 'install') {
- /*
- Lets install the latest version of DeskPRO
- */
- give_default($_REQUEST['step'], 1);
- include('./install.php');
- if (!defined('FINISHED')) {
- $step = $_REQUEST['step'] + 1;
- echo "<BR><BR>To continue the installation, <A HREF="index.php?do=install&step=$step">click here.</A>n";
- exit();
- }
- exit();
- }
- ######################################################################################################################
- ############################################ UPGRADE v1 -> v2 #################################################################
- ######################################################################################################################
- if ($_REQUEST['do'] == 'upgrade_v1') {
- /*
- Upgrades the system from v1.1.x to v2.0.0
- Once we complete this we continue upgrading to v2.x.y
- */
- $db = new DB_Sql;
- $db->Halt_On_Error = 'yes';
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->connect();
- $db2 = new DB_Sql;
- $db2->Halt_On_Error = 'yes';
- $db2->User=constant('DATABASE_USER');
- $db2->Password=constant('DATABASE_PASSWORD');
- $db2->Host=constant('DATABASE_HOST');
- $db2->Database=constant('DATABASE_NAME');
- $db2->connect();
- $this_version = $db->query_return("SELECT value FROM settings WHERE settings = 'deskpro_version'");
- $this_version = $this_version['value'];
- give_default($_REQUEST['step'], 1);
- include('./upgrade_v1_v2/upgrade-110-197.php');
- if (!defined('FINISHED')) {
- if (defined('CUSTOMDIRECT')) {
- echo "<BR><BR>To continue the upgrade, <A HREF="index.php?do=upgrade_v1&step=$step&$extra_variables">click here.</A>n";
- exit();
- } else {
- $step = $_REQUEST['step'] + 1;
- echo "<BR><BR>To continue the upgrade, <A HREF="index.php?do=upgrade_v1&step=$step">click here.</A>n";
- exit();
- }
- } else {
- echo "<BR><BR>Upgrade to v2.0.0 now finished. We now need to upgrade to $latest_version, <A HREF="index.php?do=upgrade_v2">click here.</A>n";
- }
- exit();
- }
- ######################################################################################################################
- ############################################ UPGRADE v2.x - v2.y #################################################################
- ######################################################################################################################
- if ($_REQUEST['do'] == 'upgrade_v2') {
- $db = new DB_Sql;
- $db->Halt_On_Error = 'no';
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db2 = new DB_Sql;
- $db2->Halt_On_Error = 'yes';
- $db2->User=constant('DATABASE_USER');
- $db2->Password=constant('DATABASE_PASSWORD');
- $db2->Host=constant('DATABASE_HOST');
- $db2->Database=constant('DATABASE_NAME');
- $db2->connect();
- give_default($_REQUEST['step'], 1);
- /*
- The upgrade system. We will always upgrade to the latest version.
- Key is to find the the version of DeskPRO we are currently working on.
- At the end we run any standard queries
- */
- $upgrades = array(
- '2.0.0' => 200,
- '2.0.1' => 201,
- '2.0.2' => 202,
- '2.1.0' => 210
- );
- $this_version = $db->query_return("SELECT value FROM settings WHERE settings = 'deskpro_version'");
- $this_version = $this_version['value'];
- $this_version = $upgrades["$this_version"];
-
- #################### DO THE UPGRADE TO v2.0.1 ####################
-
- if ($this_version == 200) {
-
- include('./upgrade_v2/201.php');
- if (!defined('FINISHED')) {
- $step = $_REQUEST['step'] + 1;
- echo "<BR><BR>To continue the upgrade, <A HREF="index.php?do=upgrade_v2&step=$step">click here.</A>n";
- exit();
- } else {
- echo "<BR><BR>To continue the upgrade, <a href="index.php?do=upgrade_v2standard">click here.</A>n";
- exit();
- }
- }
- #################### DO THE UPGRADE TO v2.0.2 ####################
- if ($this_version == 200) {
-
- include('./upgrade_v2/202.php');
- }
- #################### DO STANDARD CODE (INSTALL / UPGRADE) ####################
- }
- ######################################################################################################################
- ############################################ GLOBAL CHANGES #################################################################
- ######################################################################################################################
- if ($_REQUEST['do'] == 'upgrade_v2standard') {
- $db = new DB_Sql;
- $db->Halt_On_Error = 'yes';
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- if (!$_REQUEST['step']) {
- do_message("Upgrading your web templates");
- sort_web_templates();
- do_message_yes();
- echo "<BR><BR>To continue the upgrade, <a href="index.php?do=upgrade_v2standard&step=1">click here.</A>n";
- } elseif ($_REQUEST['step'] == 1) {
- do_message("Upgrading your email templates");
- sort_email_templates();
- do_message_yes();
- echo "<BR><BR>To continue the upgrade, <a href="index.php?do=upgrade_v2standard&step=2">click here.</A>n";
- } elseif ($_REQUEST['step'] == 2) {
- do_message("Upgrading the template words");
- sort_words();
- do_message_yes();
- echo "<BR><BR>To continue the upgrade, <a href="index.php?do=upgrade_v2standard&step=3">click here.</A>n";
-
- } elseif ($_REQUEST['step'] == 3) {
- do_message("Upgrading default data");
- load_data('data.sql');
- do_message_yes();
- echo "<BR><BR>To continue the upgrade, <a href="index.php?do=upgrade_v2standard&step=4">click here.</A>n";
- } elseif ($_REQUEST['step'] == 4) {
- do_message("Updating the settings");
- $settings_data = $db->query_return_array("SELECT * FROM settings");
- $queries = array(
- "DELETE FROM settings",
- "DELETE FROM settings_cat"
- );
- execute($queries);
- load_data('settings.sql');
- $queries = array(
- "DELETE FROM settings WHERE settings = ''"
- );
- if (is_array($settings_data)) {
- foreach ($settings_data AS $data) {
- $data['value'] = mysql_escape_string($data['value']);
- $queries[] = "UPDATE settings SET value = '$data[value]' WHERE settings = '$data[settings]'";
- }
- }
- execute($queries);
- do_message_yes();
- echo "<BR><BR>To continue the upgrade, <a href="index.php?do=upgrade_v2standard&step=5">click here.</A>n";
- } elseif ($_REQUEST['step'] == 5) {
- echo "Congratulations, your upgrade to DeskPRO v$latest_version is now complete<br /><br />You must now delete the /install/index.php file. You can then log into the <a href="./../admin/index.php">admin area</a>.";
- }
- }
- ######################################################################################################################
- ############################################ FUNCTIONS #################################################################
- ######################################################################################################################
-
- /*
- function sort_templates
- - This function sets the templates, email templates and words to the current version
- - It expects that the languages have already been created
- - The data will have an installid. This value refers to the installid for the language that element of data belongs to
- */
- function sort_web_templates() {
- global $db;
- include('./v2data/templates.php');
- $db->query("DELETE FROM template WHERE backup = '1'");
- foreach ($template_data AS $key => $var) {
- $var['template'] = parse_conditionals($var['template_unparsed']);
- // create the backup
- $db->query("
- INSERT INTO template SET
- name = '" . addslashes($var['name']) . "',
- description = '" . addslashes($var['description']) . "',
- template = '" . addslashes($var['template']) . "',
- backup = 1,
- template_unparsed = '" . addslashes($var['template_unparsed']) . "',
- category = '" . addslashes($var['category']) . "'
- ");
- // need details on current template (but not the backup we just created)
- $result = $db->query_return("
- SELECT changed, template_unparsed FROM template
- WHERE name = '" . addslashes($var['name']) . "'
- AND !backup
- ");
- // dosen't exist so create it
- if (!$db->num_rows()) {
- $db->query("
- INSERT INTO template SET
- name = '" . addslashes($var['name']) . "',
- description = '" . addslashes($var['description']) . "',
- template = '" . addslashes($var['template']) . "',
- template_unparsed = '" . addslashes($var['template_unparsed']) . "',
- category = '" . addslashes($var['category']) . "'
- ");
- } else {
- // first check it is actually different, if the template is the same
- // we only update the description
- if ($result['template_unparsed'] == $var['template_unparsed']) {
-
- $db->query("
- UPDATE template SET
- description = '" . addslashes($var['description']) . "',
- category = '" . addslashes($var['category']) . "',
- changed = '',
- upgraded = ''
- WHERE name = '" . addslashes($var['name']) . "'
- AND !backup
- ");
- } else {
- // template has changed, and user has edited it; leave template alone but
- // tell user it has changed
- if ($result['changed'] == 1) {
- $db->query("
- UPDATE template SET
- description = '" . addslashes($var['description']) . "',
- category = '" . addslashes($var['category']) . "',
- upgraded = 1,
- version_upgrade = '$latest_version'
- WHERE name = '" . addslashes($var['name']) . "'
- AND !backup
- ");
- // template has changed but user has not edited it; automatically update the
- // template
- } else {
- $db->query("
- UPDATE template SET
- description = '" . addslashes($var['description']) . "',
- template = '" . addslashes($var['template']) . "',
- template_unparsed = '" . addslashes($var['template_unparsed']) . "',
- category = '" . addslashes($var['category']) . "'
- WHERE name = '" . addslashes($var['name']) . "'
- AND !backup
- ");
- }
- }
- }
- }
- }
- function sort_email_templates() {
- global $db;
- // need to link the installid (deskpro language id) to the actual language id
- $db->query("SELECT id, name, installid FROM languages WHERE !custom");
- while ($result = $db->row_array()) {
- $language_convert[$result[installid]] = $result[id];
- $language_convert_name[$result[installid]] = $result[name];
- }
- include('./v2data/email_templates.php');
- $db->query("DELETE FROM template_email WHERE backup = '1'");
- foreach ($template_data AS $key => $var) {
- $var['template'] = parse_conditionals($var['template_unparsed']);
- // create the backup
- $db->query("
- INSERT INTO template_email SET
- name = '" . addslashes($var['name']) . "',
- description = '" . addslashes($var['description']) . "',
- category = '" . addslashes($var['category']) . "',
- template = '" . addslashes($var['template']) . "',
- subject = '" . addslashes($var['subject']) . "',
- language = '" . addslashes($language_convert[$var[language]]) . "',
- backup = 1,
- template_unparsed = '" . addslashes($var['template_unparsed']) . "'
- ");
- // need details on current template
- $result = $db->query_return("
- SELECT changed, template_unparsed FROM template_email
- WHERE name = '" . addslashes($var['name']) . "'
- AND !backup
- AND language = '" . $language_convert[$var[language]] . "'
- ");
- // dosen't exist so create it
- if (!$db->num_rows()) {
- $debug .= "$var[name] for language " . $language_convert_name[$var[language]] . " does not exist, creating it.n";
- // create the template
- $db->query("
- INSERT INTO template_email SET
- name = '" . addslashes($var['name']) . "',
- description = '" . addslashes($var['description']) . "',
- category = '" . addslashes($var['category']) . "',
- subject = '" . addslashes($var['subject']) . "',
- language = '" . $language_convert[$var[language]] . "',
- template_unparsed = '" . addslashes($var['template_unparsed']) . "',
- template = '" . addslashes($var['template']) . "'
- ");
- } else {
- // first check it is actually different, if the template is the same
- // we only update the description
- if ($result['template_unparsed'] == $var['template_unparsed']) {
- $debug .= "$var[name] for language " . $language_convert_name[$var[language]] . " is the same. Updating the description.n";
-
- $db->query("
- UPDATE template_email SET
- description = '" . addslashes($var['description']) . "',
- category = '" . addslashes($var['category']) . "',
- changed = '',
- upgraded = ''
- WHERE name = '" . addslashes($var['name']) . "'
- AND language = '" . addslashes($var['name']) . "'
- AND !backup
- ");
- } else {
- // exists and is changed
- if ($result['changed'] == 1) {
- $debug .= "$var[name] for language " . $language_convert_name[$var[language]] . " Template has changed and user has edited it. Set as upgraded.n";
- $db->query("
- UPDATE template_email SET
- description = '" . addslashes($var['description']) . "',
- upgraded = 1,
- version_upgrade = '$latest_version'
- WHERE name = '" . addslashes($var['name']) . "'
- AND !backup
- AND language = '" . $language_convert[$var[language]] . "'
- ");
- // exists but is unchanged so just overwrite it
- } else {
- $debug .= "$var[name] for language " . $language_convert_name[$var[language]] . " Template has changed but user has not touched it, overwrite the template.n";
- $db->query("
- UPDATE template_email SET
- subject = '" . addslashes($var['subject']) . "',
- description = '" . addslashes($var['description']) . "',
- template = '" . addslashes($var['template']) . "',
- template_unparsed = '" . addslashes($var['template_unparsed']) . "'
- WHERE name = '" . addslashes($var['name']) . "'
- AND !backup
- AND language = '" . $language_convert[$var[language]] . "'
- ");
- }
- }
- }
- }
- // echo "<textarea style="width:100%" rows="15">$debug</textarea>";
- }
- function sort_words() {
- global $db;
- // need to link the installid (deskpro language id) to the actual language id
- $db->query("SELECT id, installid FROM languages WHERE !custom");
- while ($result = $db->row_array()) {
- $language_convert[$result[installid]] = $result[id];
- }
- include('./v2data/words.php');
- $db->query("DELETE FROM template_words WHERE !cust");
- foreach ($template_data AS $key => $var) {
- $db->query("
- INSERT INTO template_words SET
- wordref = '" . addslashes($var[wordref]) . "',
- text = '" . addslashes($var[text]) . "',
- category = '" . addslashes($var[category]) . "',
- language = '" . $language_convert[$var[language]] . "'
- ");
- }
- }
- function check_php_ver() {
- global $askhostto;
- $fail = 0;
- $phpversion = phpversion();
- $minver = intval(str_replace('.', '', '4.1.0'));
- $maxver = intval(str_replace('.', '', '4.3.0'));
- $curver = intval(str_replace('.', '', $phpversion));
- echo "<li>PHP version ($phpversion): ";
- if ($curver >= $maxver ) {
- echo '<span class="cp_temp_orig">PASS</span></li>';
- } elseif ($curver >= $minver) {
- echo '<span class="cp_temp_warning">WARNING</span></li>';
- $askhostto .= "<li>Recompile PHP to at least 4.3.0<li>n";
- $warning ++;
- } else {
- echo '<span class="cp_temp_edit">FAIL</span></li>';
- $askhostto .= "<li>Upgrade PHP to at least 4.1.0.</li>n";
- $fail++;
- }
- return $fail;
- }
- function check_mysql() {
- global $askhostto;
- $fail = 0;
- echo "<li>MySQL support: ";
- if (function_exists('mysql_connect')) {
- echo '<span class="cp_temp_orig">PASS</span></li>';
- } else {
- echo '<span class="cp_temp_edit">FAIL</span></li>';
- $askhostto .= "<li>Recompile PHP with MySQL support.</li>n";
- $fail++;
- }
- return $fail;
- }
- function check_pcre() {
- global $askhostto;
- $fail = 0;
- echo "<li>PCRE support: ";
- if (function_exists('preg_replace')) {
- echo '<span class="cp_temp_orig">PASS</span></li>';
- } else {
- echo '<span class="cp_temp_edit">FAIL</span></li>';
- $askhostto .= "<li>Recompile PHP with PCRE support.</li>n";
- $fail++;
- }
- return $fail;
- }
- function check_gd() {
- global $askhostto;
- $warning = 0;
- echo "<li>GD support: ";
- if (function_exists('gd_info')) {
- echo '<span class="cp_temp_orig">PASS</span></li>';
- } else {
- echo '<span class="cp_temp_warning">WARNING</span></li>';
- $askhostto .= "<li>Recompile PHP with GD support.<li>n";
- $warning ++;
- }
- return $warning;
- }
- function check_encoding() {
- global $askhostto;
- $fail = 0;
- echo "<li>Check encoding: ";
- if (!defined('IS_ENCODED')) {
- echo "<span class="cp_temp_orig">PASS</span> (Encoding not required)";
- } else {
- if (extension_loaded('ionCube Loader')) {
- echo "<span class="cp_temp_orig">PASS</span> (Ioncube extension found)";
- } else {
- echo '<span class="cp_temp_edit">FAIL</span></li>';
- $askhostto .= "<li>You must install the ioncube decoder. Instructions can be found <a href="loader_help.php">here</a>.</li>";
- $fail++;
- }
- }
- return $fail;
- }
- function check_config() {
- global $askhostto;
- $fail = 0;
- echo "<li>Config.php file: ";
- if (!@include_once('./../includes/config.php')) {
- echo '<span class="cp_temp_edit">FAIL</span></li>';
- $askhostto .= "<li><b>Config.php has not been created</b> : Before you can install DeskPRO you must create a config.php file. This file contains your mySQL information (mysql location, database name, username and password). The file config_new.php is contained inside the /includes/ folder. You should edit that file and rename it to config.php.</li>";
- $fail++;
- } else {
- echo "<span class="cp_temp_orig">PASS</span>";
- }
- return $fail;
- }
- function check_thelicense() {
- }
- function check_sessions() {
- global $askhostto;
- $warning = 0;
- echo "<li>SESSIONS support: ";
- if (function_exists('session_id')) {
- echo '<span class="cp_temp_orig">PASS</span></li>';
- } else {
- echo '<span class="cp_temp_warning">WARNING</span></li>';
- $askhostto .= "<li>Recompile PHP with SESSIONS support.<li>n";
- $warning ++;
- }
- return $warning;
- }
- function check_graphs_perms() {
- global $askhostto;
- $fail = 0;
- echo "<li>GRAPH directory: ";
- if (function_exists('posix_getpwuid')) {
- if (!$userinfo = @posix_getpwuid(@posix_getuid())) {
- $userinfo = '(cannot determine current running username)';
- } else {
- $userinfo = "(which is running as user '$userinfo[name]')";
- }
- } else {
- $userinfo = '(cannot determine current running username)';
- }
- if (!file_exists('./../admin/graphs') OR !is_dir('./../admin/graphs') OR !is_writable('./../admin/graphs')) {
- echo "<span class="cp_temp_edit">FAIL</span>";
- $askhostto .= "<LI>Create the directory admin/graphs/, and make it writable by the server process $userinfo.</LI>";
- $fail++;
- } else {
- echo "<span class="cp_temp_orig">PASS</span>";
- }
- return $fail;
- }
- function check_schema_files() {
- global $warnhost, $schemafiles;
- echo "<LI>DeskPro v2.0 schema files: ";
- foreach ($schemafiles AS $file => $descr) {
- if (is_file($file)) {
- if (is_readable($file)) {
- $schemafiles[$file]['status'] = "Present and readable.";
- } else {
- $warn++;
- $schemafiles[$file]['status'] = "<B>Present, but not readable.</B>";
- }
- } else {
- $warn++;
- $schemafiles[$file]['status'] = "<B>Not present or not a regular file.</B>";
- }
- }
- if ($warn) {
- $warnhost .= "<LI>One or more schema files is missing. Without access to all the schema
- files, the installer cannot automatically load the database for you.
- <TABLE CELLPADDING="2"><TR><TD><B><U>File</U></B></TD><TD><B><U>Status</U></B></TD><TD><B><U>Description</U></B></TD></TR>";
- foreach($schemafiles AS $file => $descr) {
- $warnhost .= "<TR><TD><I>$file</I></TD><TD>{$schemafiles[$file]['status']}</TD><TD>{$schemafiles[$file]['descr']}</TD></TR>";
- }
-
- $warnhost .= "</LI>";
- } else {
- echo "Pass</LI>";
- }
- return $warn;
- }
- function do_message($text) {
- echo "$text ... ";
- }
- function do_message_yes() {
- echo "<span class="cp_temp_orig">Completed</span><br /><br />";
- }
- /*
- returns:
- true/false (if conection worked)
- value (the error)
- true (if the problem was lack of a database)
- */
- function check_mysql_connection() {
- $db = new DB_Sql;
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->Halt_On_Error = 'no';
- $db->connect();
- $dbname = constant('DATABASE_NAME');
- $errno = mysql_errno();
-
- if ($errno == 2005) {
-
- return array(false, 'Could not connect to MySQL server at '.constant('DATABASE_HOST'));
- } elseif ($errno == 1045) {
-
- return array(false, 'Could not log on to server using the username and password you specified.');
- } elseif ($errno == 1049) {
- return array(false, true, true);
- } elseif ($errno == 0) {
- return array(true);
-
- } else {
- return array(false, mysql_error());
- }
- }
- /*
- returns:
- true/false (if database creation worked)
- value (the error))
- */
- function create_database($dbname) {
- mysql_query("CREATE DATABASE $dbname");
- if (mysql_errno()) {
- return array(false, "The following error occured when attempting to create database '$dbname': " . mysql_errno() . ': ' . mysql_error() . "</LI>");
- } else {
- return true;
- }
- }
- function select_database() {
- global $db, $askhostto, $dbname;
- $fail = 0;
- echo "<LI>Can access database '$dbname': ";
- $db->select_db($dbname);
- if (mysql_errno()) {
- echo "<span class="cp_temp_edit">FAIL</span></li>";
- $askhostto .= "<LI>The following error occured when attempting to select database '$dbname': " . mysql_errno() . ': ' . mysql_error() . "</LI>";
- $fail++;
- } else {
- echo "<span class="cp_temp_orig">PASS</span></li>";
- }
- return $fail;
- }
- function load_data($name) {
- global $db, $schemafiles, $warnhost;
- if (!$data = file("./../install/v2data/" . $name)) {
- echo "Error";
- return 0;
- } else {
- foreach($data AS $query) {
- $db->query(trim($query));
- }
- return 1;
- }
- }
- function error($name) {
- global $schemafiles;
- echo "<P>An error has occured loading data from $name ({$schemafiles[$name]['descr']}).
- Until this problem has been resolved, DeskPRO cannot be used; the database is NOT
- ready for use. If this file exists but can't be read, check its permissions.
- If this file was not included with your distribution, please contact
- our support staff for assistance.</P>";
- exit;
- }
- function install_check() {
- if (!defined('INSTALLER')) {
- print "Security Alert : Script not called by installation system.";
- exit;
- }
- }
- function execute($queries) {
- global $db;
- if (is_array($queries)) {
- foreach ($queries AS $query) {
- $db->query($query);
- }
- }
- }
- function install_header($title) {
- if (defined('INSTALL_HEADER_YES')) {
- return;
- }
- define('INSTALL_HEADER_YES', 1);
- ?>
- <html><head>
- <link rel="stylesheet" href="./../includes/css/admin-tech.css" type="text/css">
- <link rel="stylesheet" href="./install.css" type="text/css">
- <script language="javascript" src="./../includes/javascript/general.js"></script>
- </head><body bgcolor="#7BA2D6" title="DeskPRO Installation - <?php echo $title;?>">
- <table width="720" style="border: #000000 1px solid;" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF">
- <tr><td>
- <table width="733" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td align="right" valign="bottom"><!--WTN-WDYL--><IMG height=66
- src="./images/intpic010.gif" width=165 border=0></td>
- <td valign="bottom">
- <table width="608" border="0" cellspacing="0" cellpadding="0">
- <tr bgcolor="#CC3333">
- <td height="45" colspan="2" valign="bottom">
- <p><IMG
- src="./images/intpic030.gif"></p>
- </td>
- </tr>
- <tr>
- <td width="471" height="24" background="./images/intpic040.gif"> </td>
- <td width="137"> </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <br /><br />
- <table width="98%" align="center"><tr><td>
- <?php
- }