예제 #1
0
 public function postCheckdb()
 {
     if (!Session::get('step2')) {
         return Redirect::to('install/step2');
     }
     $dbhost = Input::get('dbhost');
     $dbuser = Input::get('dbuser');
     $dbpass = Input::get('dbpass');
     $dbname = Input::get('dbname');
     Session::put(array('dbhost' => $dbhost, 'dbuser' => $dbuser, 'dbpass' => $dbpass, 'dbname' => $dbname));
     try {
         $dbh = new pdo("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
         $sql = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/install/res/dump.sql');
         $result = $dbh->exec($sql);
         $databaseFile = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/install/res/database.php');
         $databaseFile = str_replace(array('{DBHOST}', '{DBNAME}', '{DBUSER}', '{DBPASS}'), array($dbhost, $dbname, $dbuser, $dbpass), $databaseFile);
         file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/config/database.php', $databaseFile);
         file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/apps/backend/config/database.php', $databaseFile);
         Session::put('step3', true);
         return Illuminate\Support\Facades\Redirect::to('install/step4');
     } catch (PDOException $ex) {
         Session::put('step3', false);
         return Illuminate\Support\Facades\Redirect::to('install/step3')->with('conerror', 'Date invalide');
     }
 }
 function __construct($host, $username, $password, $db)
 {
     $conn_para = "mysql:{$host};{$db};charset=utf8";
     $opt = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC);
     $this->_pdo = new PDO($conn_para, $username, $password, $opt) or die('There is problem in connecting to database');
     $this->_pdo->exec("USE " . $db);
     self::$_instance = $this;
 }
예제 #3
0
function dbConnect($timeout, $options = array())
{
    $db = new pdo(PDO_dsn, PDO_username, PDO_password);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
    $db->setAttribute(PDO::ATTR_TIMEOUT, "0");
    foreach ($options as $option) {
        $db->exec($option);
    }
    return $db;
}
예제 #4
0
 public static function getAll()
 {
     $lijst = array();
     $dbh = new pdo(dbconfigpizzeria::$DB_CONNSTRING, dbconfigpizzeria::$DB_USERNAME, dbconfigpizzeria::$DB_PASSWORD);
     $sql = "select * from klanten";
     $resultSet = $dbh->query($sql);
     foreach ($resultSet as $rij) {
         $pizza = new Pizza($rij["voornaam"], $rij["familienaam"], $rij["email"], $rij["wachtwoord"]);
         $lijst[] = $pizza;
     }
     $dbh = null;
     return $lijst;
 }
예제 #5
0
 public static function getAll()
 {
     $lijst = array();
     $dbh = new pdo(dbconfigpizzeria::$DB_CONNSTRING, dbconfigpizzeria::$DB_USERNAME, dbconfigpizzeria::$DB_PASSWORD);
     $sql = "select * from pizzas";
     $resultSet = $dbh->query($sql);
     foreach ($resultSet as $rij) {
         $pizza = new Pizza($rij["pid"], $rij["pnaam"], $rij["pomsch"], $rij["prijs"]);
         $lijst[] = $pizza;
     }
     $dbh = null;
     return $lijst;
 }
예제 #6
0
 public static function getAll()
 {
     $lijst = array();
     $dbh = new pdo(dbconfigpizzeria::$DB_CONNSTRING, dbconfigpizzeria::$DB_USERNAME, dbconfigpizzeria::$DB_PASSWORD);
     $sql = "select * from extras";
     $resultSet = $dbh->query($sql);
     foreach ($resultSet as $rij) {
         $extra = new Extra($rij["extraid"], $rij["omschrijving"], $rij["prijs"]);
         $lijst[] = $extra;
     }
     $dbh = null;
     return $lijst;
 }
예제 #7
0
 /**
  * Get Database PDO connection
  * @param - no param
  * @return pdo
  */
 public function getDb()
 {
     if (self::$pdo == null) {
         $dsn = DBENGINE . ':dbname=' . DATABASE . ';host=' . HOST . ';portname=' . PORTNAME . ';';
         try {
             self::$pdo = new PDO($dsn, USERNAME, PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
             //Enabling exceptions
             self::$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         } catch (PDOException $e) {
             echo $e->getMessage();
         }
     }
     return self::$pdo;
 }
 public function displayMsgUser(pdo $conexao, $idUsuario)
 {
     try {
         $msg = "";
         $stmtSel = $conexao->prepare(mensagemDAO::$SELECT_MENSAGEM_USER);
         $stmtSel->execute(array(':idUsuario' => $idUsuario));
         $resultado = $stmtSel->fetchAll();
         foreach ($resultado as $linha) {
             $msg .= "<div class='listMsg'>\n                        <span class='usuario1'>{$linha['3']}</span>";
         }
         return $msg;
     } catch (PDOException $e) {
         print_r($e);
     }
 }
예제 #9
0
 /**
  * This method will execute sql query.
  *
  * @param queryId - The query id to execute. if no value is given the method will seach for it as request param.
  * @param params -  List of parameters to bind to teh stored procedure.
  *                  If no parameters are passed all the request params will be used as bind parameters.
  *
  * @return - Returns an array containing all of the result set rows
  */
 public function executeQuery($queryId = null, $params = null)
 {
     if (!isset($queryId)) {
         $queryId = Utils::getParam('queryId', null);
         if (!isset($queryId)) {
             throw new Exception('Missing queryId');
         }
     }
     // -----------------------------------------------------------------------------------
     // -- If no parameters are passed auto build the params from all the GET/POST pairs --
     // -----------------------------------------------------------------------------------
     if (!isset($params)) {
         $params = array();
         // We read the parameters form the request since it contains both get and post params
         foreach ($_REQUEST as $key => $value) {
             $params[':' . $key] = $value;
         }
     }
     // Get the query we wish to execute
     $query = $this->sql_queries[$queryId];
     $statment = $this->pdo->prepare($query);
     $statment->setFetchMode(PDO::FETCH_ASSOC);
     $statment->execute($params);
     // Check to see if we have error or not
     $error = $statment->errorInfo();
     // Set the error message
     if ($error[0] > 0) {
         $_REQUEST['DBLayer.executeQuery.error'] = $statment->errorInfo();
     }
     // return all the rows
     return $statment->fetchAll();
 }
예제 #10
0
 /**
  * @param array $config
  */
 public function __construct($config)
 {
     $_alldbtype = array('mysql', 'pgsql', 'mssql', 'sybase', 'dblib');
     $driver_options = array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_PERSISTENT => $config['persistent'], PDO::ATTR_CASE => PDO::CASE_LOWER, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC);
     if (in_array($config['dbtype'], $_alldbtype)) {
         $dsn = $config['dbtype'] . ':dbname=' . $config['dbname'] . ';host=' . $config['dbhost'] . ';charset=' . $config['charset'];
         if (!empty($config['dbport'])) {
             $dsn .= ';port=' . $config['dbport'];
         }
         $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
     } elseif ($config['dbtype'] == 'oci') {
         $dsn = 'oci:dbname=//' . $config['dbhost'] . ':' . $config['dbport'] . '/' . $config['dbname'] . ';charset=AL32UTF8';
         $driver_options[PDO::ATTR_STRINGIFY_FETCHES] = true;
     } elseif ($config['dbtype'] == 'sqlite') {
         $dsn = 'sqlite:' . $config['dbname'];
     } else {
         trigger_error($config['dbtype'] . ' is not supported', 256);
     }
     $this->server = $config['dbhost'];
     $this->dbtype = $config['dbtype'];
     $this->dbname = $config['dbname'];
     $this->user = $config['dbuname'];
     try {
         parent::__construct($dsn, $config['dbuname'], $config['dbpass'], $driver_options);
         parent::exec("SET SESSION time_zone='" . NV_SITE_TIMEZONE_GMT_NAME . "'");
         $this->connect = 1;
     } catch (PDOException $e) {
         trigger_error($e->getMessage());
     }
 }
예제 #11
0
 /**
 * The garbage collector deletes all sessions from the database
 * that where not deleted by the session_destroy function.
 * so your session table will stay clean.
 *
 * @access public
 * @access Integer $maxlifetime The maximum session lifetime
 * @return Boolean
 */
 public function gc($maxlifetime)
 {
     // Set a period after that a session pass off.
     $maxlifetime = strtotime("-20 minutes");
     // Setup a query to delete discontinued sessions, ...
     $delete = "DELETE FROM `sessions` WHERE `sessions`.`last_updated` < :maxlifetime;";
     $result = $this->pdo->query($delete, array("maxlifetime" => $maxlifetime));
     return $result;
 }
예제 #12
0
파일: data.php 프로젝트: h3len/Project
 function step3()
 {
     $support = pdo::getAvailableDrivers();
     if (!$support) {
         $this->errorOutput("PDO不支持任何数据库驱动");
     }
     $this->addItem($support);
     $this->output();
 }
예제 #13
0
 public function test_getMessageIDfromQueue_2()
 {
     $name = 'getMessageIDfromQueue 2';
     $mq_id = $this->m->addQueue($name);
     $method = new ReflectionMethod('phpMQ\\pdom', 'getMessageIDfromQueue');
     $method->setAccessible(TRUE);
     $mid_get = $method->invoke($this->setUp(), $mq_id);
     $this->assertEquals(FALSE, $mid_get);
 }
예제 #14
0
파일: config2.php 프로젝트: gummybites/mks
 public function __construct()
 {
     $this->dbtype = 'mysql';
     $this->host = 'localhost';
     $this->user = '******';
     $this->pass = '';
     $this->database = 'mks';
     $dns = $this->dbtype . ':dbname=' . $this->database . ";host=" . $this->host;
     parent::__construct($dns, $this->user, $this->pass);
 }
예제 #15
0
 public function updateInformation($table, $update, $where, $val)
 {
     foreach ($update as $key => $value) {
         $x++;
         $set .= "" . $key . " = " . $value . "";
         if (count($update) > $x) {
             $set .= ", ";
         }
     }
     try {
         $db = new pdo($this->db_config["host"], $this->db_config["user"], $this->db_config["pswd"]);
         $sql = $db->prepare("UPDATE " . $table . " SET " . $set . " WHERE " . $where . " = " . $val . "");
         $sql->execute();
         unset($db);
         return $row;
     } catch (PDOException $e) {
         die("Database Error: " . $e);
         return false;
     }
 }
예제 #16
0
파일: MSGBox.php 프로젝트: xop32/phpPM
    public function setAllMsgDeleteInThread($threadId)
    {
        $sql = $this->getQuery('UPDATE ' . self::$SCHEMA . '.MSG_BOX set "Status"=(
																CASE WHEN ( "To_User_ID" = ' . $this->userId . ' AND "Status" = ' . self::$DELETED_BY_FROM_USER . ') THEN ' . self::$DELETED_BY_BOTH . '
																	 WHEN ( "From_User_ID" = ' . $this->userId . ' AND "Status" = ' . self::$DELETED_BY_TO_USER . ') THEN ' . self::$DELETED_BY_BOTH . '
																	 WHEN "From_User_ID" = ' . $this->userId . ' AND "Status" = ' . self::$NOT_READED . ' THEN ' . self::$DELETED_FROM_USER_NOT_READED_BY_TO_USER . '
																	 WHEN "To_User_ID" = ' . $this->userId . ' THEN ' . self::$DELETED_BY_TO_USER . '
																	 WHEN "From_User_ID" = ' . $this->userId . ' THEN ' . self::$DELETED_BY_FROM_USER . '
																END )
				 WHERE "MSG_ID" in (Select "ID" from ' . self::$SCHEMA . '.MSG where "Thread_ID"=?) AND ("To_User_ID"=' . $this->userId . ' OR "From_User_ID"=' . $this->userId . ')');
        $stmt = $this->pdo->prepare($sql);
        $stmt->execute(array($threadId));
    }
예제 #17
0
 /**
  * Restauration d'un fichier
  * 
  * @param string $file
  */
 protected function restoreMysql($file)
 {
     try {
         // Ouverture du fichier à restaurer
         $this->gz_file = @gzopen(SITE_ROOT . DS . 'App' . DS . 'Migrations' . DS . $file, 'r');
         // Lecture et stockage des commandes
         $string = '';
         while (!gzeof($this->gz_file)) {
             $string .= gzread($this->gz_file, 4096);
         }
         $fetchData = explode(";\n", $string);
         // Connexion et envoi des commandes de restauration
         $this->cnxBdd();
         foreach ($fetchData as $cmd) {
             $this->mysql->query($cmd . ";");
         }
         $this->helper('Restoration complete !');
     } catch (\PDOException $e) {
         $this->helper($e->getMessage(), 'error');
     }
 }
예제 #18
0
파일: PDO.php 프로젝트: sebbie42/casebox
 /**
  * Removes a lock from a uri
  *
  * @param string $uri
  * @param LockInfo $lockInfo
  * @return bool
  */
 function unlock($uri, LockInfo $lockInfo)
 {
     $stmt = $this->pdo->prepare('DELETE FROM ' . $this->tableName . ' WHERE uri = ? AND token = ?');
     $stmt->execute([$uri, $lockInfo->token]);
     return $stmt->rowCount() === 1;
 }
예제 #19
0
파일: PDO.php 프로젝트: rolwi/koala
 /**
  * Removes a lock from a uri 
  * 
  * @param string $uri 
  * @param Sabre_DAV_Locks_LockInfo $lockInfo 
  * @return bool 
  */
 public function unlock($uri, Sabre_DAV_Locks_LockInfo $lockInfo)
 {
     $stmt = $this->pdo->prepare('DELETE FROM locks WHERE uri = ? AND token = ?');
     $stmt->execute(array($uri, $lockInfo->token));
     return $stmt->rowCount() === 1;
 }
         } catch (PDOException $e) {
             $_SESSION["message"] = "Error: " . $e;
             header('location: gegevens-wijzigen-form.php');
         }
     } else {
         $_SESSION['message'] = "ERROR. De file is geen jpeg/gif/png bestand. Het is een " . $typeBestand . " bestand.";
     }
 } else {
     $_SESSION['message'] = "Er werd geen nieuwe profielfoto geselecteerd";
 }
 if (isset($_POST['updateEmail'])) {
     $updatedEmail = $_POST['updateEmail'];
     $isEmail = filter_var($updatedEmail, FILTER_VALIDATE_EMAIL);
     if ($isEmail) {
         if ($currentEmail != $updatedEmail) {
             $db = new pdo('mysql:host=localhost;dbname=users-fileupload', 'root', '');
             $updateEmailQuery = "UPDATE users SET email='{$updatedEmail}' WHERE email='{$currentEmail}';";
             $updateEmail = $db->prepare($updateEmailQuery);
             $updateEmail->execute();
             setcookie("login", time() - 500);
             setcookie("login", $updatedEmail, time() + 86400 * 30);
             $_SESSION['message'] = "Emailadres werd gewijzigd naar " . $updatedEmail;
         } else {
             $_SESSION['message'] = "Het emailadres werd niet veranderd. Huidig emailadres: |" . $currentEmail . " | Nieuw emailadres: |" . $updatedEmail . " | En de cookievalue zegt: |" . $getCookie[0] . "|";
         }
     } else {
         $_SESSION['message'] = "Dit is geen emailadres.";
     }
 } else {
     $_SESSION['message'] = "Je moet een emailadres opgeven.";
 }
예제 #21
0
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
ob_start();
session_start();
// Create a connection.
$DB = null;
if (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false) {
    // Connect from App Engine.
    try {
        $DB = new pdo('mysql:unix_socket=/cloudsql/motivatestudy-967:db; dbname=motivate', 'root', '');
    } catch (PDOException $ex) {
        die(json_encode(array('outcome' => false, 'message' => 'Unable to connect.')));
    }
} else {
    // Connect from a development environment.
    try {
        $DB = new pdo('mysql:host=localhost; dbname=ODK_Local', 'root', 'root');
    } catch (PDOException $ex) {
        die(json_encode(array('outcome' => false, 'message' => 'Unable to connect')));
    }
}
//get error/success messages
if ($_SESSION["errorType"] != "" && $_SESSION["errorMsg"] != "") {
    $ERROR_TYPE = $_SESSION["errorType"];
    $ERROR_MSG = $_SESSION["errorMsg"];
    $_SESSION["errorType"] = "";
    $_SESSION["errorMsg"] = "";
}
/* 
 * Session verification. If no session value page redirect to login.php
 */
$mode = $_REQUEST["mode"];
<?php

session_start();
$link = str_replace(basename(__FILE__), '', $_SERVER['REQUEST_URI']);
$zoekterm = '';
$jaar = 2010;
$fetchRow = array();
$message = '';
if (isset($_SESSION['notification'])) {
    $message = $_SESSION['notification'];
    unset($_SESSION['notification']);
}
try {
    $db = new pdo('mysql:host=localhost;dbname=opdracht_mod_rewrite_blog', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
    if (isset($_GET['zoekInArtikel'])) {
        $zoekterm = 'artikels die het woord "' . $_GET['artikel'] . '" bevatten';
        $zoekArtikelQueryString = "Select * from artikels\n                                        WHERE artikel LIKE :artikel";
        $statement2 = $db->prepare($zoekArtikelQueryString);
        $statement2->bindValue(':artikel', '%' . $_GET['artikel'] . '%');
        $statement2->execute();
        $fetchRow = array();
        while ($row = $statement2->fetch(PDO::FETCH_ASSOC)) {
            $fetchRow[] = $row;
        }
    }
    if (isset($_GET['zoekOpDatum'])) {
        $jaar = $_GET['jaar'];
        $zoekterm = 'artikels geschreven in "' . $_GET['jaar'] . '"';
        $zoekOpDatumQueryString = "Select * from artikels\n                                        WHERE year(Datum) = :jaar";
        $statement3 = $db->prepare($zoekOpDatumQueryString);
        $statement3->bindValue(':jaar', $_GET['jaar']);
<?php

if (isset($_POST["submit"])) {
    try {
        $db = new pdo('mysql:host=localhost;dbname=bieren', 'root', '');
        // Root password not set up
        $message = "db init";
        $brNaam = $_POST["brouwernaam"];
        $adres = $_POST["adres"];
        $postcode = $_POST["postcode"];
        $gemeente = $_POST["gemeente"];
        $omzet = $_POST["omzet"];
        $insertQuery = "INSERT INTO brouwers (brnaam, adres, postcode, gemeente, omzet) VALUES('{$brNaam}','{$adres}','{$postcode}','{$gemeente}','{$omzet}');";
        // var_dump("INSERT INTO brouwers (brnaam, adres, postcode, gemeente, omzet) VALUES(" . $brNaam . ", " . $adres . ", ". $postcode . ", " . $gemeente . ", " . $omzet . ");");
        $statement = $db->prepare($insertQuery);
        $isAdded = $statement->execute();
        if ($isAdded) {
            $id = $db->lastInsertId();
            // Returns id of the last inserted row
            $message = 'Brouwerij succesvol toegevoegd. Het unieke nummer van deze brouwerij is ' . $id . '.';
        } else {
            $message = 'Er ging iets mis met het toevoegen, probeer opnieuw';
        }
    } catch (PDOException $e) {
        $message = 'De connectie is niet gelukt.';
    }
}
?>
    
<!doctype html>
<html>
예제 #24
0
 /**
  * Converts the given Person PDO to a bean object.
  * This includes the conversion from nested lists
  * of PDO objects to usable lists of oids/names to be used
  * by the page renderer.
  * 
  * @access private
  * @param pdo $pdo Person
  * @return bean Person
  */
 private function pdoToBean($pdo)
 {
     global $logger;
     $logger->debug(get_class($this) . "::pdoToBean({$pdo})");
     // if this is an artist, be sure to get the artist PDO not the person
     $scope = $pdo->getScope();
     $id = $pdo->getOid();
     if ($scope == 'Artist') {
         $epm = epManager::instance();
         $pdo = $epm->get('Artist', $id);
     }
     $bean = new $scope($pdo->epGetVars());
     // pubState to a string
     $ps = '';
     if ($pdo->getPubState() != null) {
         $ps = $pdo->getPubState()->getValue();
     }
     $bean->setPubState($ps);
     // if it is an artist, convert the exhibitions
     if (get_class($bean) == 'Artist') {
         $exhibitions = $pdo->exhibitions;
         if ($exhibitions) {
             $related = array();
             foreach ($exhibitions as $event) {
                 $related[] = new Exhibition($event->epGetVars());
             }
             $bean->setExhibitions($related);
         }
     }
     return $bean;
 }
예제 #25
0
파일: install.php 프로젝트: xuedi/pedetes
    public function install($ctn)
    {
        if (!$ctn['config']['installed']) {
            $msg = "";
            // no sec here, just install
            if ($_REQUEST['action'] == 'save') {
                $file = $ctn['pathApp'] . "config.json";
                $config = $ctn['config'];
                // update DB settings
                $config['database']['name'] = $_REQUEST['db_name'];
                $config['database']['user'] = $_REQUEST['db_user'];
                $config['database']['pass'] = $_REQUEST['db_pass'];
                $config['database']['host'] = $_REQUEST['db_host'];
                $config['database']['port'] = $_REQUEST['db_port'];
                unset($config['database']['nodatabase']);
                // set basic data
                $config['url'] = $_REQUEST['url'];
                $config['site'] = preg_replace("/[^0-9a-zA-Z_\\s]+/", "", $_REQUEST['url']);
                $config['salt'] = md5(time() . rand(10, 20));
                // connect to database (with new parameters)
                try {
                    $db = new pdo('mysql:host=' . $_REQUEST['db_host'] . ':' . $_REQUEST['db_port'] . ';dbname=' . $_REQUEST['db_name'], $_REQUEST['db_user'], $_REQUEST['db_pass']);
                    // install mysql structure
                    $structureFile = $ctn['pathApp'] . "database.sql";
                    if (!file_exists($structureFile)) {
                        $msg = "Could not fine database file";
                    } else {
                        $cmd = file_get_contents($structureFile);
                        $sth = $db->prepare($cmd);
                        $sth->execute();
                        // create user
                        $sth = $db->prepare("INSERT INTO user (role_id,username,password) VALUES (3,:user,:pass); ");
                        $sth->bindValue("user", $_REQUEST['user']);
                        $sth->bindValue("pass", password_hash($_REQUEST['pass'] . $config['salt'], PASSWORD_BCRYPT, array('cost' => 12)));
                        $sth->execute();
                        $config['installed'] = true;
                        $json = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
                        file_put_contents($file, $json);
                        apcu_clear_cache();
                        header("Location: /");
                    }
                } catch (\PDOException $e) {
                    $msg = $e->getMessage();
                }
            }
            ?>
				<form action="/">
				<input type="hidden" name="action" value="save" />
				<h1>Install</h1>
				<h2>Website Settings</h2>
				<table>
					<tr>
						<td>URL:</td>
						<td><input type="text" name="url" value="<?php 
            echo $_REQUEST['url'];
            ?>
" /></td>
					</tr>
					<tr>
						<td>Username:</td>
						<td><input type="text" name="user" value="<?php 
            echo $_REQUEST['user'];
            ?>
" /></td>
					</tr>
					<tr>
						<td>Password:</td>
						<td><input type="password" name="pass" value="<?php 
            echo $_REQUEST['pass'];
            ?>
" /></td>
					</tr>
				</table>
				<h2>Database Settings</h2>
				<p style='color: red;'><?php 
            echo $msg;
            ?>
</p>
				<table>
					<tr>
						<td>DB-Name:</td>
						<td><input type="text" name="db_name" value="<?php 
            echo $_REQUEST['db_name'];
            ?>
" /></td>
					</tr>
					<tr>
						<td>Username:</td>
						<td><input type="text" name="db_user" value="<?php 
            echo $_REQUEST['db_user'];
            ?>
" /></td>
					</tr>
					<tr>
						<td>Password:</td>
						<td><input type="password" name="db_pass" value="<?php 
            echo $_REQUEST['db_pass'];
            ?>
" /></td>
					</tr>
					<tr>
						<td>Host:</td>
						<td><input type="text" name="db_host" value="<?php 
            echo $_REQUEST['db_host'];
            ?>
" /></td>
					</tr>
					<tr>
						<td>Port:</td>
						<td><input type="text" name="db_port" value="<?php 
            echo $_REQUEST['db_port'];
            ?>
" /></td>
					</tr>
				</table>
				<p>
					<input type="submit" value="Install">
				</p>
				</form>
			<?php 
            die;
        }
    }
예제 #26
0
 $options = array('gs' => array('acl' => 'public-read', 'Content-Type' => $_FILES['uploaded_files']['type']));
 $ctx = stream_context_create($options);
 if (false == rename($_FILES['uploaded_files']['tmp_name'], $fileName, $ctx)) {
     die('Could not rename.');
 }
 // $var2 =(new \ DateTime())->format('i:s');
 $object_public_url = CloudStorageTools::getPublicUrl($fileName, true);
 $var1 = date("Y-m-d H:i:s");
 $var2 = microtime(true);
 $var3 = $var2 - $var1;
 //   echo $var3;
 // echo $object_public_url."<br>";
 //  print $thisfile;
 // print $thatfile;
 // var_dump($_FILES);
 $db = new pdo('mysql:unix_socket=/cloudsql/ordinal-gear-93506:testdb;dbname=g1', 'root', '');
 $stmt1 = $db->prepare("select * from another where filename='{$thatfile}'");
 $stmt1->execute();
 $row = $stmt1->fetch();
 if ($row > 0) {
     echo "duplicate entry";
     // $db->exec("insert into users values('8975','200')");
 } else {
     $db->exec("insert into another values('','{$thatfile}','{$var6}','{$object_public_url}','{$var1}')");
     //  $db->exec("insert into finaltest values('','$thatfile','filesize($thisfile)','$object_public_url','$var3')");
     $stmt = $db->prepare("select * from another ORDER BY filesize;");
     $stmt->execute();
     echo "<table border='2'>";
     echo '<tr>';
     echo '<th>ID:</th>';
     echo '<th>FileName:</th>';
예제 #27
0
<?php

session_start();
$ditBestand = $_SERVER['PHP_SELF'];
// classes ophalen
function __autoload($className)
{
    require_once 'classes/' . $className . '-class.php';
}
// connecteren:
try {
    $db = new pdo('mysql:host=localhost;dbname=bieren', 'root', '');
    $boodschap = 'connectie geslaagd!';
} catch (PDOException $e) {
    $boodschap = 'Er ging iets mis: ' . $e->getMessage();
}
// verwijderen
$teVerwijderen = '';
if (isset($_GET['delete'])) {
    $_SESSION['teVerwijderen'] = $_GET['delete'];
}
if (isset($_SESSION['teVerwijderen'])) {
    $teVerwijderen = $_SESSION['teVerwijderen'];
}
if (isset($_GET['bevestiging'])) {
    if ($_GET['bevestiging'] == 'ja') {
        $verwijderQuery = 'DELETE FROM brouwers 
									WHERE brouwernr = :teVerwijderen';
        //echo('Query: <code> ' . $verwijderQuery . '</code>') ;
        try {
            $statement = $db->prepare($verwijderQuery);
예제 #28
0
<?php

$db = new pdo('sqlite::memory:');
$db->query('CREATE TABLE IF NOT EXISTS foo (id INT AUTO INCREMENT, name TEXT)');
$db->query('INSERT INTO foo VALUES (NULL, "PHP")');
$db->query('INSERT INTO foo VALUES (NULL, "PHP6")');
var_dump($db->query('SELECT * FROM foo'));
var_dump($db->errorInfo());
var_dump($db->lastInsertId());
$db->query('DROP TABLE foo');
<?php

session_start();
if (isset($_POST['submit'])) {
    $_SESSION['titel'] = $_POST['titel'];
    $_SESSION['artikel'] = $_POST['artikel'];
    $_SESSION['kernwoorden'] = $_POST['kernwoorden'];
    $_SESSION['datum'] = $_POST['datum'];
    try {
        $db = new pdo('mysql:host=localhost;dbname=opdracht_mod_rewrite_blog', 'root', '', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
        $queryString = "insert into artikels\n    (Titel,Artikel,Kernwoorden,Datum)\n    values\n    (:Titel,:Artikel,:Kernwoorden,:Datum)";
        $statement = $db->prepare($queryString);
        $statement->bindValue(':Titel', $_POST['titel']);
        $statement->bindValue(':Artikel', $_POST['artikel']);
        $statement->bindValue(':Kernwoorden', $_POST['kernwoorden']);
        $statement->bindValue(':Datum', $_POST['datum']);
        $gelukt = $statement->execute();
        if ($gelukt) {
            $_SESSION['notification'] = 'Het artikel werd toegevoegd.';
            header('location:artikel-overzicht.php');
        } else {
            $_SESSION['notification'] = 'Er ging iets mis bij het toevoegen. Gelieve alle velden juist in te vullen.';
            header('location:artikel-toevoegen-form.php');
        }
    } catch (PDOException $e) {
        $_SESSION['notification'] = 'Er ging iets mis: ' . $e->getmessage();
    }
}
예제 #30
0
 public function exec($sql)
 {
     if ($this->path_log_file) {
         file_put_contents($this->path_log_file, $sql . "\n\n", FILE_APPEND);
     }
     ++$this->querycount;
     return parent::exec($sql);
 }