function hesk_iCheckSetup()
{
    global $hesk_settings;
    $correct_these = array();
    // 1. PHP 5+ required
    if (function_exists('version_compare') && version_compare(PHP_VERSION, REQUIRE_PHP_VERSION, '<')) {
        $correct_these[] = '
		PHP version <b>' . REQUIRE_PHP_VERSION . '+</b> required, you are using: <b>' . PHP_VERSION . '</b><br /><br />
		You are using and old and insecure PHP version with known bugs, security issues and outdated functionality.<br /><br />
		Ask your hosting company to update your PHP version.
		';
    }
    // 2. File hesk_settings.inc.php must be writable
    if (!is__writable(HESK_PATH . 'hesk_settings.inc.php')) {
        // -> try to CHMOD it
        if (function_exists('chmod')) {
            @chmod(HESK_PATH . 'hesk_settings.inc.php', 0666);
        }
        // -> test again
        if (!is__writable(HESK_PATH . 'hesk_settings.inc.php')) {
            $correct_these[] = '
			File <b>hesk_settings.inc.php</b> is not writable by PHP.<br /><br />
			Make sure PHP has permission to write to file <b>hesk_settings.inc.php</b><br /><br />
			&raquo; on <b>Linux</b> servers <a href="http://www.phpjunkyard.com/tutorials/ftp-chmod-tutorial.php">CHMOD</a> this file to 666 (rw-rw-rw-)<br />
	        &raquo; on <b>Windows</b> servers allow Internet Guest Account to modify the file<br />
	        &raquo; contact your hosting company for help with setting up file permissions.
			';
        }
    }
    // 3. Folder attachments must exist
    $hesk_settings['attach_dir_name'] = isset($hesk_settings['attach_dir']) ? $hesk_settings['attach_dir'] : 'attachments';
    $hesk_settings['attach_dir'] = HESK_PATH . $hesk_settings['attach_dir_name'];
    // -> Try to create it
    if (!file_exists($hesk_settings['attach_dir'])) {
        @mkdir($hesk_settings['attach_dir'], 0755);
    }
    // -> Is the folder now there?
    if (is_dir($hesk_settings['attach_dir'])) {
        // -> Is it writable?
        if (!is__writable($hesk_settings['attach_dir'])) {
            // -> try to CHMOD it
            @chmod($hesk_settings['attach_dir'], 0777);
            // -> test again
            if (!is__writable($hesk_settings['attach_dir'])) {
                $correct_these[] = '
				Folder <b>' . $hesk_settings['attach_dir_name'] . '</b> is not writable by PHP.<br /><br />
				Make sure PHP has permission to write to folder <b>' . $hesk_settings['attach_dir_name'] . '</b><br /><br />
				&raquo; on <b>Linux</b> servers <a href="http://www.phpjunkyard.com/tutorials/ftp-chmod-tutorial.php">CHMOD</a> this folder to 777 (rwxrwxrwx)<br />
		        &raquo; on <b>Windows</b> servers allow Internet Guest Account to modify the folder<br />
		        &raquo; contact your hosting company for help with setting up folder permissions.
				';
            }
        }
    } else {
        $correct_these[] = '
		Folder <b>' . $hesk_settings['attach_dir_name'] . '</b> is missing.<br /><br />
		Create a folder called <b>' . $hesk_settings['attach_dir_name'] . '</b> inside your main HESK folder.<br /><br />
		';
    }
    // 4. MySQL must be available
    if (!function_exists('mysql_connect') && !function_exists('mysqli_connect')) {
        $correct_these[] = '
		MySQL is disabled.<br /><br />
		HESK requires MySQL to be installed and enabled.<br /><br />
        Ask your hosting company to enable MySQL for PHP.
		';
    }
    // 5. Can we use GD library?
    $GD_LIB = extension_loaded('gd') && function_exists('gd_info') ? true : false;
    // 6. Make sure old files are deleted
    $old_files = array('hesk_settings.inc', 'hesk.sql', 'inc/common.inc', 'inc/database.inc', 'inc/footer.inc', 'inc/header.inc', 'inc/print_tickets.inc', 'inc/show_admin_nav.inc', 'inc/show_search_form.inc', 'install.php', 'update.php', 'admin.php', 'admin_change_status.php', 'admin_main.php', 'admin_move_category', 'admin_reply_ticket.php', 'admin_settings.php', 'admin_settings_save.php', 'admin_ticket.php', 'archive.php', 'delete_tickets.php', 'find_tickets.php', 'manage_canned.php', 'manage_categories.php', 'manage_users.php', 'profile.php', 'show_tickets.php', 'emails/', 'language/english.php', 'secimg.inc.php', 'hesk_style_v23.css', 'help_files/', 'TreeMenu.js', 'inc/tiny_mce/utils/r00t10.php', 'language/en/help_files/r00t10.php', 'hesk_style_v24.css', 'hesk_javascript_v24.js', 'hesk_style_v25.css', 'hesk_javascript_v25.js');
    sort($old_files);
    $still_exist = array();
    foreach ($old_files as $f) {
        if (file_exists(HESK_PATH . $f)) {
            $still_exist[] = $f;
        }
    }
    if (count($still_exist)) {
        $correct_these[] = '
		Outdated files and folders<br /><br />
		For security reasons please delete these legacy files and folders:<br />
        <ul><li><b>' . implode('</b></li><li><b>', $still_exist) . '</b></li></ul>
		';
    }
    // Do we have any errors?
    if (count($correct_these)) {
        hesk_iHeader();
        ?>

        &nbsp;

        <div style="margin-left:40px;margin-right:40px">
            <?php 
        foreach ($correct_these as $correct_this) {
            hesk_show_error($correct_this);
            echo "&nbsp;";
        }
        ?>
        </div>

		<form method="post" action="<?php 
        echo INSTALL_PAGE;
        ?>
">
		<p align="center"><input type="submit" value="Click here to test again" class="btn btn-default" /></p>
		</form>
        <p>&nbsp;</p>
        <?php 
        hesk_iFooter();
    }
    // If all tests were successful, we can continue to the next step
    $_SESSION['set_attachments'] = 1;
    $_SESSION['set_captcha'] = $GD_LIB ? 1 : 0;
    $_SESSION['use_spamq'] = $GD_LIB ? 0 : 1;
    $_SESSION['step'] = 3;
    // When updating, first try saved MySQL info
    if (INSTALL_PAGE == 'update.php') {
        header('Location: ' . INSTALL_PAGE);
    } else {
        hesk_iDatabase();
    }
    exit;
}
Пример #2
0
// Test type?
$test_type = hesk_POST('test');
// Test MySQL connection
if ($test_type == 'mysql') {
    if (hesk_testMySQL()) {
        hesk_show_success($hesklang['conok']);
    } elseif (!empty($mysql_log)) {
        hesk_show_error($mysql_error . '<br /><br /><b>' . $hesklang['mysql_said'] . ':</b> ' . $mysql_log);
    } else {
        hesk_show_error($mysql_error);
    }
} elseif ($test_type == 'pop3') {
    if (hesk_testPOP3()) {
        hesk_show_success($hesklang['conok']);
    } else {
        hesk_show_error($pop3_error . '<br /><br /><textarea name="pop3_log" rows="10" cols="60">' . $pop3_log . '</textarea>');
    }
} elseif ($test_type == 'smtp') {
    if (hesk_testSMTP()) {
        // If no username/password add a notice
        if ($set['smtp_user'] == '' && $set['smtp_user'] == '') {
            $hesklang['conok'] .= '<br /><br />' . $hesklang['conokn'];
        }
        hesk_show_success($hesklang['conok']);
    } else {
        hesk_show_error($smtp_error . '<br /><br /><textarea name="smtp_log" rows="10" cols="60">' . $smtp_log . '</textarea>');
    }
} else {
    die($hesklang['attempt']);
}
exit;
Пример #3
0
function hesk_handle_messages()
{
    global $hesk_settings, $hesklang;
    $return_value = true;
    // Primary message - only one can be displayed and HESK_MESSAGE is required
    if (isset($_SESSION['HESK_MESSAGE'])) {
        if (isset($_SESSION['HESK_SUCCESS'])) {
            hesk_show_success($_SESSION['HESK_MESSAGE']);
        } elseif (isset($_SESSION['HESK_ERROR'])) {
            hesk_show_error($_SESSION['HESK_MESSAGE']);
            $return_value = false;
        } elseif (isset($_SESSION['HESK_NOTICE'])) {
            hesk_show_notice($_SESSION['HESK_MESSAGE']);
        } elseif (isset($_SESSION['HESK_INFO'])) {
            hesk_show_info($_SESSION['HESK_MESSAGE']);
        }
        hesk_cleanSessionVars('HESK_MESSAGE');
    }
    // Cleanup any primary message types set
    hesk_cleanSessionVars('HESK_ERROR');
    hesk_cleanSessionVars('HESK_SUCCESS');
    hesk_cleanSessionVars('HESK_NOTICE');
    hesk_cleanSessionVars('HESK_INFO');
    // Secondary message
    if (isset($_SESSION['HESK_2ND_NOTICE']) && isset($_SESSION['HESK_2ND_MESSAGE'])) {
        hesk_show_notice($_SESSION['HESK_2ND_MESSAGE']);
        hesk_cleanSessionVars('HESK_2ND_NOTICE');
        hesk_cleanSessionVars('HESK_2ND_MESSAGE');
    }
    return $return_value;
}
Пример #4
0
function hesk_iDatabase($problem = 0)
{
    global $hesk_settings, $hesk_db_link, $mysql_log;
    hesk_iHeader();
    ?>

	<h3>Database settings</h3>

	<br />

	<?php 
    if ($problem == 1) {
        hesk_show_error('<br /><br />Double-check all the information below. Contact your hosting company for the correct information to use!<br /><br /><b>MySQL said:</b> ' . $mysql_log . '</p>', 'Database connection failed');
    } elseif ($problem == 2) {
        hesk_show_error('<b>Database tables already exist!</b><br /><br />
        HESK database tables with <b>' . $hesk_settings['db_pfix'] . '</b> prefix already exist in this database!<br /><br />
	    To upgrade an existing HESK installation select <a href="index.php">Update existing install</a> instead.<br /><br />
	    To install a new copy of HESK in use a unique table prefix.');
    } elseif ($problem == 3) {
        hesk_show_error('<b>Old database tables not found!</b><br /><br />
        HESK database tables have not been found in this database!<br /><br />
	    To install HESK use the <a href="index.php">New install</a> option instead.');
    } elseif ($problem == 4) {
        hesk_show_error('<b>Version ' . HESK_NEW_VERSION . ' tables already exist!</b><br /><br />
        Your database seems to be compatible with HESK version ' . HESK_NEW_VERSION . '<br /><br />
	    To install a new copy of HESK use the <a href="index.php">New install</a> option instead.');
    } else {
        hesk_show_notice('To complete setup HESK needs to connect to your database.<br /><br />You must get these settings from your hosting company (where you setup MySQL databases)!');
    }
    ?>


	<div align="center">
	<table border="0" width="750" cellspacing="1" cellpadding="5" class="white">
	<tr>
	<td>

	<form action="<?php 
    echo INSTALL_PAGE;
    ?>
" method="post">
	<table>
	<tr>
	<td>Database Host:</td>
	<td><input type="text" name="host" value="<?php 
    echo $hesk_settings['db_host'];
    ?>
" size="40" autocomplete="off" /></td>
	</tr>
	<tr>
	<td>Database Name:</td>
	<td><input type="text" name="name" value="<?php 
    echo $hesk_settings['db_name'];
    ?>
" size="40" autocomplete="off" /></td>
	</tr>
	<tr>
	<td>Database User (login):</td>
	<td><input type="text" name="user" value="<?php 
    echo $hesk_settings['db_user'];
    ?>
" size="40" autocomplete="off" /></td>
	</tr>
	<tr>
	<td>User Password:</td>
	<td><input type="text" name="pass" value="<?php 
    echo $hesk_settings['db_pass'];
    ?>
" size="40" autocomplete="off" /></td>
	</tr>
    <?php 
    if (INSTALL_PAGE == 'install.php') {
        ?>
		<tr>
		<td>Table prefix:</td>
		<td><input type="text" name="pfix" value="<?php 
        echo $hesk_settings['db_pfix'];
        ?>
" size="40" autocomplete="off" /></td>
		</tr>
	    <?php 
    }
    ?>
	</table>

	<p align="center"><input type="hidden" name="dbtest" value="1" /><input type="submit" value="Continue to Step 4" class="orangebutton" onmouseover="hesk_btn(this,'orangebuttonover');" onmouseout="hesk_btn(this,'orangebutton');" /></p>
	</form>

	</td>
	</tr>
	</table>
	</div>

	<?php 
    hesk_iFooter();
}