function phpAds_Start()
{
    global $phpAds_config;
    global $Session;
    global $phpAds_productname;
    if (!defined('phpAds_installing')) {
        phpAds_SessionDataFetch();
    }
    if (!phpAds_isLoggedIn() || phpAds_SuppliedCredentials()) {
        // Load preliminary language settings
        @(include phpAds_path . '/language/english/default.lang.php');
        if ($phpAds_config['language'] != 'english' && file_exists(phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php')) {
            @(include phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php');
        }
        phpAds_SessionDataRegister(phpAds_Login());
    }
    // Overwrite certain preset preferences
    if (isset($Session['language']) && $Session['language'] != '' && $Session['language'] != $phpAds_config['language']) {
        $phpAds_config['language'] = $Session['language'];
    }
}
function phpAds_sqlDie()
{
    global $phpAds_dbmsname, $phpAds_version_readable, $phpAds_version, $phpAds_productname;
    global $phpAds_last_query;
    $error = phpAds_dbError();
    $corrupt = false;
    if ($phpAds_dbmsname == 'MySQL') {
        $errornumber = phpAds_dbErrorNo();
        if ($errornumber == 1027 || $errornumber == 1039) {
            $corrupt = true;
        }
        if ($errornumber == 1016 || $errornumber == 1030) {
            // Probably corrupted table, do additional check
            eregi("[0-9]+", $error, $matches);
            if ($matches[0] == 126 || $matches[0] == 127 || $matches[0] == 132 || $matches[0] == 134 || $matches[0] == 135 || $matches[0] == 136 || $matches[0] == 141 || $matches[0] == 144 || $matches[0] == 145) {
                $corrupt = true;
            }
        }
    }
    if ($corrupt) {
        $title = $GLOBALS['strErrorDBSerious'];
        $message = $GLOBALS['strErrorDBNoDataSerious'];
        if (phpAds_isLoggedIn() && phpAds_isUser(phpAds_Admin)) {
            $message .= " (" . $error . ").<br><br>" . $GLOBALS['strErrorDBCorrupt'];
        } else {
            $message .= ".<br>" . $GLOBALS['strErrorDBContact'];
        }
    } else {
        $title = $GLOBALS['strErrorDBPlain'];
        $message = $GLOBALS['strErrorDBNoDataPlain'];
        if (phpAds_isLoggedIn() && phpAds_isUser(phpAds_Admin)) {
            $message .= $GLOBALS['strErrorDBSubmitBug'];
            $last_query = $phpAds_last_query;
            $message .= "<br><br><table cellpadding='0' cellspacing='0' border='0'>";
            $message .= "<tr><td valign='top' nowrap><b>Version:</b>&nbsp;&nbsp;&nbsp;</td><td>" . $phpAds_productname . " " . $phpAds_version_readable . " (" . $phpAds_version . ")</td></tr>";
            $message .= "<tr><td>&nbsp;</td><td>PHP " . phpversion() . " / " . $phpAds_dbmsname . " " . phpAds_dbResult(phpAds_dbQuery('SELECT VERSION()'), 0, 0) . "</td></tr>";
            $message .= "<tr><td valign='top' nowrap><b>Page:</b></td><td>" . $_SERVER['PHP_SELF'] . "</td></tr>";
            $message .= "<tr><td valign='top' nowrap><b>Error:</b></td><td>" . $error . "</td></tr>";
            $message .= "<tr><td valign='top' nowrap><b>Query:</b></td><td>" . $last_query . "</td></tr>";
            $message .= "</table>";
        }
    }
    phpAds_Die($title, $message);
}