*/ error_reporting(E_ALL); if (function_exists('date_default_timezone_set')) date_default_timezone_set('Greenwich'); if (!session_id()) session_start(); define("MAIN_DIR", dirname(__FILE__) . "/"); define("INCLUDES_DIR", MAIN_DIR . "includes/"); include MAIN_DIR . "config.php"; include INCLUDES_DIR . "types.php"; include INCLUDES_DIR . "class/GetTextReader.php"; if (version_compare(PHP_VERSION, "5.0.0", "<")) include INCLUDES_DIR . "class/Sql-php4.php"; else include INCLUDES_DIR . "class/Sql.php"; define("VERSION_NUMBER", "1.3.3"); define("PREVIEW_CHAR_SIZE", 75); $adapterList[] = "mysql"; if (function_exists("sqlite_open") || (class_exists("PDO") && in_array("sqlite", PDO::getAvailableDrivers()))) { $adapterList[] = "sqlite"; } $cookieLength = time() + (60*24*60*60); $langList['id_ID'] = "Bahasa Indonesia"; $langList['ms_ID'] = "Bahasa Melayu"; $langList['ca_AD'] = "Català"; $langList['cs_CZ'] = "Čeština"; $langList['sr_RS'] = "Српски ћирилица"; $langList['da_DK'] = "Dansk"; $langList['de_DE'] = "Deutsch"; $langList['et_EE'] = "Eesti keel"; $langList['en_US'] = "English"; $langList['es_ES'] = "Español"; $langList['es_AR'] = "Español (Argentina)"; $langList['eo_EO'] = "Esperanto"; $langList['fr_FR'] = "Français"; $langList['gl_ES'] = "Galego"; $langList['hr_HR'] = "Hrvatski"; $langList['it_IT'] = "Italiano"; $langList['ko_KR'] = "한국어"; $langList['lo_LA'] = "Lao"; $langList['lv_LV'] = "Latviešu"; $langList['hu_HU'] = "Magyar"; $langList['nl_NL'] = "Nederlands"; $langList['no_NO'] = "Norsk"; $langList['pl_PL'] = "Polski"; $langList['pt_BR'] = "Português (Brasil)"; $langList['pt_PT'] = "Português (Portugal)"; $langList['ru_RU'] = "Русский"; $langList['ro_RO'] = "Română"; $langList['sq_AL'] = "Shqip"; $langList['sk_SK'] = "Slovenčina"; $langList['sl_SL'] = "Slovenščina"; $langList['sp_RS'] = "Srpski"; $langList['fi_FI'] = "Suomi"; $langList['sv_SE'] = "Svenska"; $langList['tl_PH'] = "Tagalog"; $langList['vi_VN'] = "Tiếng Việt"; $langList['tr_TR'] = "Türkçe"; $langList['uk_UA'] = "Українська"; $langList['ar_DZ'] = "العربية"; $langList['fa_IR'] = "فارسی"; $langList['he_IL'] = "עִבְרִית"; $langList['bg_BG'] = "български език"; $langList['bn_BD'] = "বাংলা"; $langList['el_GR'] = "ελληνικά"; $langList['th_TH'] = "ภาษาไทย"; $langList['zh_CN'] = "中文 (简体)"; $langList['zh_TW'] = "中文 (繁體)"; $langList['ja_JP'] = "日本語"; if (isset($_COOKIE['sb_lang']) && array_key_exists($_COOKIE['sb_lang'], $langList)) { $lang = preg_replace("/[^a-z0-9_]/i", "", $_COOKIE['sb_lang']); } else { $lang = "en_US"; } if ($lang != "en_US") { // extend the cookie length setcookie("sb_lang", $lang, $cookieLength); } else if (isset($_COOKIE['sb_lang'])) { // cookie not needed for en_US setcookie("sb_lang", "", time() - 10000); } $themeList["classic"] = "Classic"; $themeList["bittersweet"] = "Bittersweet"; if (isset($_COOKIE['sb_theme'])) { $currentTheme = preg_replace("/[^a-z0-9_]/i", "", $_COOKIE['sb_theme']); if (array_key_exists($currentTheme, $themeList)) { $theme = $currentTheme; // extend the cookie length setcookie("sb_theme", $theme, $cookieLength); } else { $theme = "bittersweet"; setcookie("sb_theme", "", time() - 10000); } } else { $theme = "bittersweet"; } $gt = new GetTextReader($lang . ".pot"); if (isset($_SESSION['SB_LOGIN_STRING'])) { $user = (isset($_SESSION['SB_LOGIN_USER'])) ? $_SESSION['SB_LOGIN_USER'] : ""; $pass = (isset($_SESSION['SB_LOGIN_PASS'])) ? $_SESSION['SB_LOGIN_PASS'] : ""; $conn = new SQL($_SESSION['SB_LOGIN_STRING'], $user, $pass); } // unique identifer for this session, to validate ajax requests. // document root is included because it is likely a difficult value // for potential attackers to guess $requestKey = substr(md5(session_id() . $_SERVER["DOCUMENT_ROOT"]), 0, 16); if (isset($conn) && $conn->isConnected()) { if (isset($_GET['db'])) $db = $conn->escapeString($_GET['db']); if (isset($_GET['table'])) $table = $conn->escapeString($_GET['table']); if ($conn->hasCharsetSupport()) { $charsetSql = $conn->listCharset(); if ($conn->isResultSet($charsetSql)) { while ($charsetRow = $conn->fetchAssoc($charsetSql)) { $charsetList[] = $charsetRow['Charset']; } } $collationSql = $conn->listCollation(); if ($conn->isResultSet($collationSql)) { while ($collationRow = $conn->fetchAssoc($collationSql)) { $collationList[$collationRow['Collation']] = $collationRow['Charset']; } } } } // undo magic quotes, if necessary if (get_magic_quotes_gpc()) { $_GET = stripslashesFromArray($_GET); $_POST = stripslashesFromArray($_POST); $_COOKIE = stripslashesFromArray($_COOKIE); $_REQUEST = stripslashesFromArray($_REQUEST); } function stripslashesFromArray($value) { $value = is_array($value) ? array_map('stripslashesFromArray', $value) : stripslashes($value); return $value; } function loginCheck($validateReq = true) { if (!isset($_SESSION['SB_LOGIN'])){ if (isset($_GET['ajaxRequest'])) redirect("login.php?timeout=1"); else redirect("login.php"); exit; } if ($validateReq) { if (!validateRequest()) { exit; } } startOutput(); } function redirect($url) { if (isset($_GET['ajaxRequest']) || headers_sent()) { global $requestKey; ?> isConnected()) { $conn->disconnect(); unset($conn); } } function outputPage() { global $requestKey; global $sbconfig; global $conn; global $lang; ?> SQL Buddy " media="all" /> " media="all" /> " media="print" /> " media="all" />
    getAdapter() != "sqlite") { ?>

    PREVIEW_CHAR_SIZE) { $text = utf8_substr($text, 0, PREVIEW_CHAR_SIZE) . " [...]"; } return $text; } function formatDataForCSV($text) { $text = str_replace('"', '""', $text); return $text; } function splitQueryText($query) { // the regex needs a trailing semicolon $query = trim($query); if (substr($query, -1) != ";") $query .= ";"; // i spent 3 days figuring out this line preg_match_all("/(?>[^;']|(''|(?>'([^']|\\')*[^\\\]')))+;/ixU", $query, $matches, PREG_SET_ORDER); $querySplit = ""; foreach ($matches as $match) { // get rid of the trailing semicolon $querySplit[] = substr($match[0], 0, -1); } return $querySplit; } function memoryFormat($bytes) { if ($bytes < 1024) $dataString = $bytes . " B"; else if ($bytes < (1024 * 1024)) $dataString = round($bytes / 1024) . " KB"; else if ($bytes < (1024 * 1024 * 1024)) $dataString = round($bytes / (1024 * 1024)) . " MB"; else $dataString = round($bytes / (1024 * 1024 * 1024)) . " GB"; return $dataString; } function themeFile($filename) { global $theme; return smartCaching("themes/" . $theme . "/" . $filename); } function smartCaching($filename) { return $filename . "?ver=" . str_replace(".", "_", VERSION_NUMBER); } function __($t) { global $gt; return $gt->getTranslation($t); } function __p($singular, $plural, $count) { global $gt; if ($count == 1) { return $gt->getTranslation($singular); } else { return $gt->getTranslation($plural); } } function utf8_substr($str, $from, $len) { # utf8 substr # www.yeap.lv return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'. '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s', '$1',$str); } function utf8_strlen($str) { $i = 0; $count = 0; $len = strlen ($str); while ($i < $len) { $chr = ord ($str[$i]); $count++; $i++; if ($i >= $len) break; if ($chr & 0x80) { $chr <<= 1; while ($chr & 0x80) { $i++; $chr <<= 1; } } } return $count; } function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } ?>