try { new PDO_Simple($dsn['value']); } catch (PDOException $e) { throw new PDOException("Connection validation error: " . $e->getMessage()); } if (!empty($dsn['id'])) { $DB->update("UPDATE dsn SET name=?, value=? WHERE id=?", $dsn['name'], $dsn['value'], $dsn['id']); } else { $DB->update("INSERT INTO dsn(id, name, value) VALUES(?, ?, ?)", $DB->getSeq(), $dsn['name'], $dsn['value']); } } else { if (!empty($dsn['id'])) { throw new PDOException("Field(s) cannot be empty here"); } } } } catch (PDOException $e) { addMessage("ID=" . ($id ? $id : "NEW") . ": " . $e->getMessage()); break 2; } } $DB->commit(); selfRedirect("Data is saved."); } else { $_POST['dsns'] = array(); foreach ($DB->select("SELECT id, name, value FROM dsn ORDER BY id") as $dsn) { $_POST['dsns'][$dsn['id']] = $dsn; } } } while (false); template("dsns", array("title" => "Databases"));
ob_start(array('HTML_FormPersister', 'ob_formpersisterhandler')); header("Content-Type: text/html; charset=utf-8"); } session_start(); $DB = createDbConnection(); // Check credentials. if (isCgi() && !defined("NO_AUTH")) { if (isset($_POST['auth'])) { $cred = $_POST['auth']['login'] . ":" . $_POST['auth']['pass']; if (getSetting("loginpass") === $cred) { $_SESSION['credentials'] = $cred; $tag = getSetting('tagafterlogin', ""); if (preg_match('{(/|index.php)$}s', $_SERVER['REQUEST_URI']) && $tag) { redirect("index.php?tag=" . urlencode($tag)); } else { selfRedirect(); } } else { addMessage("Authentication failed."); } } if (strval(@$_SESSION['credentials']) !== getSetting("loginpass", "")) { template("login", array("title" => "Authenticate yourself", "isGuest" => 1)); exit; } } // Undo damned magic_quotes_gpc(). if (get_magic_quotes_gpc()) { foreach (array("_GET", "_POST") as $k) { if (isset($GLOBALS[$k])) { array_walk_recursive($GLOBALS[$k], create_function('&$a', '$a = stripslashes($a);'));