</script> <div class="database-success-message">HTML 5 Local and Session Storage cleared unless error popped-up already.</div> <?php //Here because of very weird error session_start(); //initialize custom error handler require_once 'classes/CustomErrorHandler.php'; if (!isset($CustomErrorHandler)){ $CustomErrorHandler = new CustomErrorHandler("owasp-esapi-php/src/", 0); }// end if require_once 'classes/MySQLHandler.php'; $MySQLHandler = new MySQLHandler("owasp-esapi-php/src/", $_SESSION["security-level"]); $lErrorDetected = FALSE; function format($pMessage, $pLevel ) { switch ($pLevel){ case "I": $lStyle = "database-informative-message";break; case "S": $lStyle = "database-success-message";break; case "F": $lStyle = "database-failure-message";break; case "W": $lStyle = "database-warning-message";break; }// end switch return "<div class=\"".$lStyle."\">" . $pMessage . "</div>"; }// end function try{ echo format("Attempting to connect to MySQL server on host " . MySQLHandler::$mMySQLDatabaseHost . " with user name " . MySQLHandler::$mMySQLDatabaseUsername,"I");
<?php require 'MySQLHandler.class.php'; require 'SZUserMgnt.class.php'; require 'SZMail.class.php'; $MySQLHandler = new MySQLHandler(); $SZMail = new SZMail(); $MySQLHandler->init(); $SZUserMgnt = new SZUserMgnt($MySQLHandler, $SZMail);
<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/LIB/libMySQL.php"; include $_SERVER['DOCUMENT_ROOT'] . 'KhunluungramnerkP/loginMySQL.php'; $handler = new MySQLHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]); $handler->conn(); $checkLogin = array("tipo" => "SELECT", "campos" => array("login.user"), "tablas" => "login", "condicion" => array("login.user" => $_POST["user"], "login.passwd" => $_POST["passwd"])); $handler->query($checkLogin); if (count($handler->data->lista) == 1) { session_start(); $_SESSION["usr"] = $_POST["user"]; $newSesion = array("tipo" => "INSERT", "campos" => array("sesiones_serv.usr" => $_SESSION["usr"], "sesiones_serv.ip" => $_SERVER['REMOTE_ADDR']), "tabla" => "sesiones_serv"); $handler->query($newSesion); header('Location: index.php'); } else { die("ERROR: La combinación de usuario y contraseña proporcionada es incorrecta. Denegado el acceso a la edición"); } $handler->shutdown();
} print '</div> '; } } } ?> </div> <div class="menuBusqueda"> <form action="index.php" method="get"> Castellano-Khunlůn: <input name="traduccion"> <input type="submit"> </form> <?php if (!empty($_GET["traduccion"])) { $handler = new MySQLHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]); $handler->conn(); $handler->setStrict(false); $getPalabraSignificado = array("tipo" => "SELECT", "campos" => array('palabras.id', 'palabras.palabra'), "tablas" => array('palabras', 'significados'), "condicion" => array('significados.palabra_id=palabras.id' => null, 'significados.acepción' => '(, )*' . $_GET["traduccion"] . '(, )*')); $handler->query($getPalabraSignificado); $resultados = $handler->data->lista; if (!empty($resultados)) { foreach ($resultados as $resultado) { print ' <div class="busqueda"> <div class="infoPalabra"> ' . $resultado['palabras.palabra'] . ' </div> <div class="infoPalabra"> <a href="palabra.php?id=' . $resultado['palabras.id'] . '" class="btn boton">Ver</a> </div>
<?php include_once "libPalabras.php"; include $_SERVER['DOCUMENT_ROOT'] . 'KhunluungramnerkP/loginMySQL.php'; session_start(); include_once "header.html"; $handler = new MySQLHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]); $handler->conn(); $selectReformas = array("tipo" => "SELECT", "campos" => array("cte_reformas.id", "cte_reformas.acrónimo", "cte_reformas.nombre", "cte_reformas.descripción", "cte_reformas.fecha"), "tablas" => "cte_reformas"); $handler->query($selectReformas); $reformas = $handler->data->lista; print ' <div class="newReforma"> <a class="btn boton" href="reformar.php?new=true">Añadir nueva reforma</a> </div> '; foreach ($reformas as $reforma) { $date = date_create($reforma["fecha"]); $reforma["fecha"] = date_format($date, 'd/m/Y'); print ' <div class="reforma"> <div class="headReforma"> [' . $reforma["acrónimo"] . '] <a class="btn boton" href="reformar.php?id=' . $reforma["id"] . '">Ver</a> <br><br>' . $reforma["nombre"] . ' (' . $reforma["fecha"] . ') </div> <div class="descripcion">' . $reforma["descripción"] . '</div> </div> '; } $handler->shutdown();
<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/LIB/libMySQL.php"; include $_SERVER['DOCUMENT_ROOT'] . 'KhunluungramnerkP/loginMySQL.php'; session_start(); $handler = new MySQLHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]); $handler->conn(); $deleteSesion = array("tipo" => "DELETE", "tabla" => "sesiones_serv", "condicion" => array("sesiones_serv.usr" => $_SESSION["usr"], "sesiones_serv.ip" => $_SERVER['REMOTE_ADDR'])); $handler->query($deleteSesion); session_destroy(); header('Location: index.php');
public static function databaseAvailable() { self::$mDatabaseAvailableMessage = "AVAILABLE"; $lMySQLConnection = null; $UNKNOWN_DATABASE = "Unknown database"; $ACCESS_DENIED = "ccess denied for user"; $USERNAME = self::$mMySQLDatabaseUsername; $PASSWORD = self::$mMySQLDatabasePassword; $SAMURAI_WTF_PASSWORD = "******"; $HOSTNAME = self::$mMySQLDatabaseHost; $INCORRECT_DATABASE_CONFIGURATION_MESSAGE = "Error connecting to MySQL database on host '" . $HOSTNAME . "' with username '" . $USERNAME . "' and password '" . $PASSWORD . "'. First, try to reset the database (ResetDB button on menu). Next, check that the database service is running and that the database username, password, database name, and database location are configured correctly. Note: File /mutillidae/classes/MySQLHandler.php contains the database configuration."; $INCORRECT_DATABASE_CONFIGURATION_MESSAGE_SAMURAI = "Error connecting to MySQL database on host '" . $HOSTNAME . "' with username '" . $USERNAME . "' and password '" . $PASSWORD . "'. Note: In addition to the configured password '" . $PASSWORD . "', the password 'samurai' was tried as well. First, try to reset the database (ResetDB button on menu). Next, check that the database service is running and that the database username, password, database name, and database location are configured correctly. Note: File /mutillidae/classes/MySQLHandler.php contains the database configuration."; $UNKNOWN_DATABASE_MESSAGE = "Unable to select default database " . self::$mMySQLDatabaseName . ". It appears that the database to which Mutillidae is configured to connect has not been created. First, try to reset the database (ResetDB button on menu). Next, check that the database service is running and that the database username, password, database name, and database location are configured correctly. Note: File /mutillidae/classes/MySQLHandler.php contains the database configuration."; try { $lMySQLConnection = new mysqli($HOSTNAME, $USERNAME, $PASSWORD); if (strlen($lMySQLConnection->connect_error) > 0) { /* If error is "Access denied for user", it could just be an incorrect password. On samurai * the password is "samurai". Try that password. */ try { $lMySQLConnection = new mysqli($HOSTNAME, $USERNAME, $SAMURAI_WTF_PASSWORD); if (strlen($lMySQLConnection->connect_error) > 0) { self::$mDatabaseAvailableMessage = $INCORRECT_DATABASE_CONFIGURATION_MESSAGE_SAMURAI . " Connection error: " . $lMySQLConnection->connect_error; throw new Exception(self::$mDatabaseAvailableMessage); } // end if } catch (Exception $e) { self::$mDatabaseAvailableMessage = $INCORRECT_DATABASE_CONFIGURATION_MESSAGE . " Connection error: " . $lMySQLConnection->connect_error; throw new Exception(self::$mDatabaseAvailableMessage); } } // end if there was an error right away if (!$lMySQLConnection->select_db(self::$mMySQLDatabaseName)) { self::$mDatabaseAvailableMessage = $UNKNOWN_DATABASE_MESSAGE . " Connection error: " . $lMySQLConnection->connect_error; throw new Exception(self::$mDatabaseAvailableMessage); } //end if $lResult = $lMySQLConnection->query("SELECT 'test connection';"); if (!$lResult) { self::$mDatabaseAvailableMessage = "Failed to execute test query on MySQL database but we appear to be connected " . $lMySQLConnection->error . "<br /><br />First, try to reset the database (ResetDB button on menu)<br /><br />Check if the database configuration is correct. If the system made it this far, the username and password are probably correct. Perhaps the database name is wrong.<br /><br />"; throw new Exception(self::$mDatabaseAvailableMessage); } // end if $lResult = $lMySQLConnection->query("SELECT cid FROM blogs_table;"); if (!$lResult) { self::$mDatabaseAvailableMessage = "Failed to execute test query on blogs_table in the MySQL database but we appear to be connected " . $lMySQLConnection->error . "<br /><br />First, try to reset the database (ResetDB button on menu)<br /><br />The blogs table should exist in the " . self::$mMySQLDatabaseName . " database if the database configuration is correct. If the system made it this far, the username and password are probably correct. Perhaps the database name is wrong.<br /><br />"; throw new Exception(self::$mDatabaseAvailableMessage); } // end if $lMySQLConnection->close(); } catch (Exception $e) { self::$mDatabaseAvailableMessage = "Failed to connect to MySQL database. " . $e->getMessage(); throw new Exception(self::$mDatabaseAvailableMessage); } // end try return TRUE; }
}// end if $LogHandler = &$_SESSION["Objects"]["LogHandler"]; */ $LogHandler = new LogHandler(__ROOT__ . '/owasp-esapi-php/src/', $_SESSION["security-level"]); /* ------------------------------------------ * initialize MySQL handler * ------------------------------------------ */ /* if (!is_object($_SESSION["Objects"]["MySQLHandler"])){ $_SESSION["Objects"]["MySQLHandler"] = new MySQLHandler(__ROOT__.'/owasp-esapi-php/src/', $_SESSION["security-level"]); }// end if $MySQLHandler = &$_SESSION["Objects"]["MySQLHandler"]; */ $MySQLHandler = new MySQLHandler(__ROOT__ . '/owasp-esapi-php/src/', $_SESSION["security-level"]); $MySQLHandler->connectToDefaultDatabase(); /* ------------------------------------------ * initialize SQL Query handler * ------------------------------------------ */ /* if (!is_object($_SESSION["Objects"]["SQLQueryHandler"])){ $_SESSION["Objects"]["SQLQueryHandler"] = new SQLQueryHandler(__ROOT__.'/owasp-esapi-php/src/', $_SESSION["security-level"]); }// end if $SQLQueryHandler = &$_SESSION["Objects"]["SQLQueryHandler"]; */ $SQLQueryHandler = new SQLQueryHandler(__ROOT__ . '/owasp-esapi-php/src/', $_SESSION["security-level"]); /* ------------------------------------------ * initialize balloon-hint handler * ------------------------------------------ */
<?php /* ------------------------------------------------------ * INCLUDE CLASS DEFINITION PRIOR TO INITIALIZING * ------------------------------------------------------ */ require_once 'classes/MySQLHandler.php'; $lErrorMessage = ""; try { MySQLHandler::databaseAvailable(); } catch (Exception $e) { $lErrorMessage = $e->getMessage(); } //Here because of very weird error session_start(); $lSubmitButtonClicked = isset($_REQUEST["database-offline-php-submit-button"]); if ($lSubmitButtonClicked) { $_SESSION["UserOKWithDatabaseFailure"] = "TRUE"; header("Location: index.php", true, 302); } //end if ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="./styles/global-styles.css" /> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Database Offline</title> </head> <div class="page-title">The database server appears to be offline.</div>
include_once "header.html"; if (isset($_GET["new"])) { //formulario de creación de la reforma $_SESSION["urlVuelta"] = 'http://' . $_SERVER['HTTP_HOST'] . '/Khunluungramnerk/reformas.php'; print ' <form action="reforma.php" method="post"> <textarea name="acrónimo"></textarea> <textarea name="nombre"></textarea> <textarea name="descripción"></textarea> <input type="checkbox" name="crear" checked> crear <br> <input type="submit"> </form> '; } elseif (isset($_GET["id"])) { $_SESSION["urlVuelta"] = $_SESSION["urlVuelta"] = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $handler = new MySQLHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]); $handler->conn(); $selectReforma = array("tipo" => "SELECT", "campos" => array("cte_reformas.acrónimo", "cte_reformas.nombre", "cte_reformas.descripción", "cte_reformas.fecha"), "condicion" => array("cte_reformas.id" => $_GET["id"]), "tablas" => "cte_reformas"); $handler->query($selectReforma); $reforma = $handler->data->lista[0]; $date = date_create($reforma["cte_reformas.fecha"]); $reforma["cte_reformas.fecha"] = date_format($date, 'd/m/Y'); print ' <div class="reforma"> <div class="headReforma"> [' . $reforma["cte_reformas.acrónimo"] . ']<br><br>' . $reforma["cte_reformas.nombre"] . ' (' . $reforma["cte_reformas.fecha"] . ') </div> <div class="descripcion">' . $reforma["cte_reformas.descripción"] . '</div> </div> ';
<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/LIB/libMySQL.php"; include $_SERVER['DOCUMENT_ROOT'] . 'KhunluungramnerkP/loginMySQL.php'; $handler = new MySQLHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]); $handler->conn(); $getPalabra = array("tipo" => "SELECT", "campos" => array("id, palabra_et, posición, raíz"), "tablas" => "etim_raiz"); $handler->query($getPalabra); foreach ($handler->data->lista as $etimología) { if ($etimología["palabra_et"] === NULL) { $id = null; $getIDPalabra = array("tipo" => "SELECT", "campos" => array("id"), "tablas" => "palabras", "condicion" => array("palabra" => $etimología["raíz"])); $handler->query($getIDPalabra); if ($handler->data->esVacia()) { $getIDPalabra2 = array("tipo" => "SELECT", "campos" => array("etimologias.palabra_id"), "tablas" => "etimologias, etim_evol", "condicion" => array("etimologias.id=etim_evol.id" => null, "etim_evol.origen" => $etimología["raíz"])); $handler->query($getIDPalabra2); } else { $id = $handler->data->lista[0]['id']; } if (!$handler->data->esVacia()) { if (!isset($id)) { $id = $handler->data->lista[0]['etimologias.palabra_id']; } $updateIDPalabra = array("tipo" => "UPDATE", "tabla" => "etim_raiz", "campos" => array("palabra_et" => $id), "condicion" => array("raíz" => $etimología["raíz"])); $handler->query($updateIDPalabra); } } }
public function testTotalNumberTuplesInTable() { $mysqlHandler = new MySQLHandler($this->user, $this->password, $this->database, $this->host, $this->port); $rows = $mysqlHandler->GetTotalNumberTuplesInTable('colfusion_dnameinfo'); $this->assertGreaterThan(10, $rows); }
/** * Public function runBackups */ public function runBackups() { $mysqlDBHandler = new MySQLHandler(); //$dbList = DB::getDBList($this -> color); $dbList = explode("|", MySQLBackupDB::DATABASES); foreach ($dbList as $db) { SR_Agent::Log(APPID, SystemReporter::MSG_MESSAGE, "Starting Backup for {$db}"); OutputHandler::displayOutput("[%lightblue%{$db}%lightgray%]\tStarting backup\n%white%============================================%lightgray%", $this->color); $mysqlDBHandler->runBackup($db, $this->simulation, $this->color); OutputHandler::displayOutput("%white%============================================%lightgray%\n", $this->color); } $this->completeRun(); }
<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/LIB/libMySQL.php"; include $_SERVER['DOCUMENT_ROOT'] . 'KhunluungramnerkP/loginMySQL.php'; $handler = new MySQLHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]); $handler->conn(); $getMin0 = array("tipo" => "SELECT", "campos" => array("*"), "tablas" => "etim_raiz"); $handler->query($getMin0); foreach ($handler->data->lista as $resultado) { $getMaxId = array("tipo" => "SELECT", "campos" => array("max(id)+1"), "tablas" => "etim_raiz"); $handler->query($getMaxId); $idNueva = $handler->data->lista[0]["max(id)+1"]; $editID = array("tipo" => "UPDATE", "tabla" => "etim_raiz", "campos" => array("id" => $idNueva), "condicion" => array("etimologias_id" => $resultado["etimologias_id"], "posición" => $resultado["posición"])); $handler->query($editID); }
<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/LIB/libMySQL.php"; include $_SERVER['DOCUMENT_ROOT'] . 'KhunluungramnerkP/loginMySQL.php'; $handler = new MySQLHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]); $handler->conn(); $getPalabra = array("tipo" => "SELECT", "campos" => array("id, palabra_et, posición, raíz"), "tablas" => "etim_raiz"); $handler->query($getPalabra); foreach ($handler->data->lista as $etimología) { var_dump($etimología); $id = $etimología["id"]; $RaizCompuesta = new String($etimología["raíz"]); if ($RaizCompuesta->contains('-')) { $RaizCompuesta = explode('-', $RaizCompuesta->get()); $RaizCompuesta[1] = '-' . $RaizCompuesta[1]; $primer = new String($RaizCompuesta[0]); if ($primer->equals('')) { unset($RaizCompuesta[0]); } } elseif ($RaizCompuesta->contains('+')) { $RaizCompuesta = explode('+', $RaizCompuesta->get()); } var_dump($RaizCompuesta); $elimRaizPrevia = array("tipo" => "DELETE", "tabla" => "etim_raiz", "condicion" => array("id" => $id)); $handler->query($elimRaizPrevia); $i = 1; foreach ($RaizCompuesta as $raiz) { $insertRaiz = array("tipo" => "INSERT", "campos" => array("id" => $id, "posición" => $i, "raíz" => $raiz), "tabla" => "etim_raiz"); $handler->query($insertRaiz); $i++; } }
<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/HAL_WEB_ANGULAR/php/mySQLHandler.php"; $rwData = file_get_contents("php://input"); $data = json_decode($rwData); $prcInstr = $data->prcInstr; if ($prcInstr == "loginCheck") { $data->usrName = strtoupper($data->usrName); //Minden olyan cuccot amit szeretnénk megjeleníteni egy ideiglenes $debug változóba rakunk, //amit mindig frisssítünk a függvényhívások között :D $debug = "1 - pwd az AJAX_CON.phpban: " . $data->password . "\n"; $data->password = strtoupper(hash('sha512', $data->password)); $debug .= "2 - pwd az AJAX_CON.phpban: " . $data->password . "\n"; $debug .= " ---------------------------------- \n"; $db = new MySQLHandler(); $retArr = $db->chkUser($data->usrName, $data->password); //Csak frissítjük, nem felülsírjuk, hogy megmaradjon a hívott függvény által beletett PHP infó :D. $retArr['debug'] = $retArr['debug'] . $debug; echo json_encode($retArr); } elseif ($prcInstr == "test") { } else { echo "<p class=\"ERRMsg\">A php://input nemt tartalmazott prcInstr-t, enélkül nem tudja a PHP kód, \n\t\t\t\thogy mit szeretnél lekérdezni!</p>"; }