Poster un message
SQL Designer ; mod SQLite
20 octobre 2007, yannick lemut
remplace io.php par ceci et la sauvegarde de fera sur un fichier ; marche donc sans mysql mais il faut avoir acces à SQLite !
script posté aujourd’huis à Ondra Zara. si ca peut aider...
<?php
/* WWW SQL Designer, (C) 2005 Ondra Zara, o.z.fw@seznam.cz
This file is part of WWW SQL Designer.
WWW SQL Designer is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
WWW SQL Designer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with WWW SQL Designer; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* adapted to SQLite by Yannick Lemut (France) */
define('DB','sqlitedb');
define('TABLE','wwwsqldesigner');
/*yl: load SQLite extention if not allredy done*/
if (!extension_loaded('sqlite')) {
$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
dl($prefix . 'sqlite.' . PHP_SHLIB_SUFFIX);
}
/*yl: open SQLite database: */
if ( $db = sqlite_open( DB, 0666, $sqliteerror)){
//if table do not existe; create it (CREATE TABLE IF NOT EXISTS work only in v3)
echo "openned";
$r = sqlite_query($db,"SELECT name FROM sqlite_master WHERE type='table' AND name='".TABLE."'");
if (! sqlite_num_rows($r) > 0){
$r = sqlite_query($db,"CREATE TABLE ".TABLE." ( keyword VARCHAR(20) NOT NULL PRIMARY KEY, data MEDIUMTEXT NOT NULL, dt DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' );");
}
}
else { die ($sqliteerror);}
$action = 0; /*yl: default action: "save as"*/
if (isset($_GET['import'])) {$action = 1; /*yl: action load*/}
if (isset($_GET['show'])) {$action = 2; /*yl: action show liste*/}
switch ($action) {
case 0: /*yl: action: "save as"*/
$key = (isset($_POST['key']) ? $_POST['key'] : '');
$data = (isset($_POST['data']) ? $_POST['data'] : '');
if (!$key) {die();}
else {
$key = sqlite_escape_string($key);
/*yl: not so sure about this next line ????? dont know the magic stuff*/
if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) {$data = stripslashes($data);}
$data = sqlite_escape_string($data);
$r = sqlite_query($db,"SELECT id FROM ".TABLE." WHERE keyword = '".$key."'");
if (sqlite_num_rows($r) > 0) { sqlite_query($db,"UPDATE ".TABLE." SET data = '".$data."', dt=datetime('now') WHERE keyword = '".$key."'");
} else { sqlite_query($db,"INSERT INTO ".TABLE." (keyword, data, dt) VALUES ('".$key."', '".$data."', datetime('now'))");
}
}
break;
case 1: /*yl: action load*/
$key = (isset($_GET['key']) ? $_GET['key'] : '');
$key = sqlite_escape_string($key);
$r = sqlite_query($db,"SELECT data FROM ".TABLE." WHERE keyword = '".$key."'");
if (sqlite_num_rows($r) > 0) {echo sqlite_fetch_single($r);}
break;
case 2: /*yl: action show liste*/
$r = sqlite_query($db,"SELECT keyword, dt FROM ".TABLE." ORDER BY dt DESC");
while ($row = sqlite_fetch_array($r, SQLITE_BOTH)) {
printf ("%s: %s\n", $row["dt"], $row["keyword"]);
}
break;
}
sqlite_close($db);
?>
Merci de votre participation
Informations complémentaires
C'est-à-dire
Bien choisir son titre est très important en particulier lorsque vous lancez un nouveau message.
Les adresses emails apparaissent "cryptées". C'est un cryptage sommaire et un peu contraignant puisqu'il remplace l'arobase par trois caractères aléatoires, "open@office.org" devient "open h6Y office.org" mais c'est deja une bonne barrière contre le SPAM.
Merci de rester courtois, de garder un oeil sur l'orthographe et de ne pas abuser des majuscules et du langage SMS.
Informations générales
Juste une image
Petit Coeur- Creative Commons BY
Framakey
Nous suivre
Flux RSS
Page Wikipédia