function dbConnect($srcName) { global $DBProvider; if (isset($DBProvider)&&($DBProvider=='mysql')) { return mysqlConnect($srcName); } else { return sqliteConnect($srcName); } }
<!-- Custom styles for this template --> <link href="standard-template.css" rel="stylesheet"> <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> <!--[if lt IE 9]><script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]--> <script src="assets/js/ie-emulation-modes-warning.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <?php include 'header.php'; //editUser($_GET['id']); $file_db = sqliteConnect(); $result = $file_db->query("SELECT id,login,role,enable FROM utilisateurs\n\tWHERE id='{$_SESSION['iduser']}'"); foreach ($result as $row) { } $file_db = null; ?> <br/><br/><br/> <div class="container"> <form class="form-horizontal" method="post"> <fieldset> <!-- Form Name --> <legend>Edit user</legend> <!-- Text input--> <div class="form-group">
break; case "Delete": $db = sqliteConnect(''); fb('warning, deleting is unsafe, check allowed to do this'); if (isset($IN['Id'])) { $query = "DELETE FROM ".$datasource['Table']." WHERE ".$datasource['PK'].'='.$IN['Id']; //$query .= ' LIMIT 0,1';//for safety $result = sqlite_query($db,$query) or trigger_error("Sqlite Datasource($dsname) Query Error:".sqlite_last_error($db)); print '{"Status":"Deleted","Id":"'.$IN['Id'].'"}'; fb($query,FIREPHP::INFO); } else { trigger_error('PK not found.'); } break; case "CascadeDelete": $db = sqliteConnect(''); $query = $datasource['CascadeSQL']; $result = sqlite_query($db,$query) or trigger_error("Sqlite Datasource($dsname) Query Error:".sqlite_last_error($db)); print '{"Status":"Deleted"}'; fb($query,FIREPHP::INFO); break; } break; case 'mysql': switch($IN['Action']) { case "New": $db = mysqlConnect(''); $query = "INSERT INTO ".$datasource['Table']." (". $datasource['PK'].",". $datasource['NewFields']. ") VALUES (Null";
function newUser($login, $p1, $p2, $role, $enable) { $valide = false; $file_db = sqliteConnect(); if ($p1 == $p2) { $crypt = sha1($p1); $insert = $file_db->prepare("INSERT INTO utilisateurs(login,password,enable,role)\n\tVALUES (:login,:crypt,:enable,:role)"); $insert->execute(array('login' => $login, 'crypt' => $crypt, 'enable' => $enable, 'role' => $role)); $valide = true; } $insert = null; $file_db = null; return $valide; }