-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,195 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
class dbManager{ | ||
|
||
var $dbName; // nome del database | ||
var $dbHost; // nome dell'host su cui gira il database (localhost, oppure www.xyz.com) | ||
var $dbPass; // password per il database | ||
var $dbUser; // nome utente per la connesione al database | ||
|
||
|
||
function dbManager(){ | ||
/* costruttore */ | ||
$this->dbHost = "localhost"; | ||
$this->dbName = "wiigesture"; | ||
$this->dbPass = ""; | ||
$this->dbUser = "root"; | ||
} | ||
|
||
function dbConnect(){ | ||
/* funzione di connessione al database */ | ||
$db = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass) | ||
or die("Errore di connessione al dbms sull'host ".$this->dbHost); | ||
mysql_select_db($this->dbName, $db) | ||
or die("Impossibile selezionare il database ".$this->dbName); | ||
return $db; | ||
} | ||
|
||
function dbClose($db){ | ||
/* chiude la connessione col database */ | ||
mysql_close($db); | ||
} | ||
|
||
function execQuery($query, $db){ | ||
/* funzione di esecuzione query mySQL */ | ||
$result = mysql_query($query, $db) | ||
or die("Errore nell'esecuzione della query...<br/>".mysql_error()); | ||
return $result; | ||
} | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
include_once("dbmanager.php"); | ||
|
||
$file = $_POST['file']; | ||
$tabella = $_POST['tabella']; | ||
|
||
$originali = array("\n"); | ||
$sostituti = array(""); | ||
|
||
$dbMng = new dbManager(); | ||
$db = $dbMng->dbConnect(); | ||
|
||
$testo = @file($file); | ||
$numline = count($testo); | ||
$data = ""; | ||
|
||
for($i = 0; $i < $numline; $i++){ | ||
|
||
$line = str_replace($originali, $sostituti, $testo[$i]); | ||
|
||
if($line != "<gesture>" && $line != "</gesture>"){ | ||
|
||
echo($line . "<br/>\n"); | ||
$data = $data . $line ."\n"; | ||
|
||
|
||
|
||
} | ||
else if($line == "</gesture>"){ | ||
$query = "insert into ".$tabella." values('', '".$data."');"; | ||
$dbMng->execQuery($query, $db); | ||
$data = ""; | ||
} | ||
|
||
} | ||
|
||
$dbMng->dbClose($db); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<html> | ||
<head><title>Import di gesture nel database</title></head> | ||
|
||
<body> | ||
|
||
<form action="import.php" method="post"> | ||
<input type="text" name="file"/> File dati<br/> | ||
<input type="text" name="tabella"/> Nome tabella MySQL<br/> | ||
<input type="submit" value="Invia"/> | ||
<input type="reset" value="Cancella"/> | ||
</form> | ||
|
||
<p>File nella cartella:</p> | ||
|
||
</body> | ||
|
||
</html> |
Oops, something went wrong.