mirror of
https://github.com/xevidos/codiad.git
synced 2024-11-10 21:26:35 +01:00
Added get all user options function, Continued work on SQL library, Fixed issue where project was not loaded from settings, Improved performance for getting all options, Refactored install process to fit with new library, Refactored active module to use SQL, Fixed issue where a non focused file could not be closed when first logged in, Fixed issue of text mode not being selected after renaming a file,
This commit is contained in:
parent
494675a9a0
commit
22a5ddc115
@ -1,15 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (c) Codiad, Kent Safranski (codiad.com), and Isaac Brown (telaaedifex.com), distributed
|
||||
* as-is and without warranty under the MIT License. See
|
||||
* [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
* Copyright (c) Codiad, Kent Safranski (codiad.com), and Isaac Brown (telaaedifex.com), distributed
|
||||
* as-is and without warranty under the MIT License. See
|
||||
* [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
require_once('../../common.php');
|
||||
|
||||
class Active extends Common
|
||||
{
|
||||
class Active extends Common {
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// PROPERTIES
|
||||
@ -18,7 +17,6 @@ class Active extends Common
|
||||
public $username = "";
|
||||
public $path = "";
|
||||
public $new_path = "";
|
||||
public $actives = "";
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// METHODS
|
||||
@ -30,59 +28,80 @@ class Active extends Common
|
||||
// Construct
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->actives = getJSON('active.php');
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// List User's Active Files
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
public function ListActive()
|
||||
{
|
||||
$active_list = array();
|
||||
public function ListActive() {
|
||||
|
||||
global $sql;
|
||||
$query = "SELECT path,focused FROM active WHERE username=?";
|
||||
$bind_variables = array( $this->username );
|
||||
$result = $sql->query( $query, $bind_variables, array() );
|
||||
$tainted = false;
|
||||
$root = WORKSPACE;
|
||||
if ($this->actives) {
|
||||
foreach ($this->actives as $active => $data) {
|
||||
if (is_array($data) && isset($data['username']) && $data['username']==$this->username) {
|
||||
if ($this->isAbsPath($data['path'])) {
|
||||
$active_list = $result;
|
||||
|
||||
if( ! empty( $return ) ) {
|
||||
|
||||
foreach ( $result as $id => $data ) {
|
||||
|
||||
if ( $this->isAbsPath( $data['path'] ) ) {
|
||||
|
||||
$root = "";
|
||||
} else {
|
||||
|
||||
$root = $root.'/';
|
||||
}
|
||||
if (file_exists($root.$data['path'])) {
|
||||
$focused = isset($data['focused']) ? $data['focused'] : false;
|
||||
$active_list[] = array('path'=>$data['path'], 'focused'=>$focused);
|
||||
} else {
|
||||
unset($this->actives[$active]);
|
||||
|
||||
if ( ! file_exists( $root . $data['path'] ) ) {
|
||||
|
||||
$tainted = true;
|
||||
unset( $active_list[$id] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $tainted ) {
|
||||
|
||||
$this->update_active( $active_list );
|
||||
}
|
||||
if ($tainted) {
|
||||
saveJSON('active.php', $this->actives);
|
||||
}
|
||||
echo formatJSEND("success", $active_list);
|
||||
|
||||
echo formatJSEND( "success", $active_list );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Check File
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
public function Check()
|
||||
{
|
||||
$cur_users = array();
|
||||
foreach ($this->actives as $active => $data) {
|
||||
if (is_array($data) && isset($data['username']) && $data['username']!=$this->username && $data['path']==$this->path) {
|
||||
$cur_users[] = $data['username'];
|
||||
public function Check() {
|
||||
|
||||
global $sql;
|
||||
$query = "SELECT username FROM active WHERE path=?";
|
||||
$bind_variables = array( $this->path );
|
||||
$result = $sql->query( $query, $bind_variables, array() );
|
||||
$tainted = false;
|
||||
$user = false;
|
||||
$users = array();
|
||||
$root = WORKSPACE;
|
||||
|
||||
foreach( $result as $id => $data ) {
|
||||
|
||||
array_push( $users, $data["username"] );
|
||||
if( $data["username"] == $this->username ) {
|
||||
|
||||
$user = true;
|
||||
}
|
||||
}
|
||||
if (count($cur_users)!=0) {
|
||||
//echo formatJSEND("error", "Warning: File ".substr($this->path, strrpos($this->path, "/")+1)." Currently Opened By: " . implode(", ", $cur_users));
|
||||
|
||||
if ( ( count( $result ) == 1 && ! $user ) || count( $result ) > 1 ) {
|
||||
|
||||
echo formatJSEND( "warning", "Warning: File " . substr( $this->path, strrpos( $this->path, "/" ) +1 ) . " Currently Opened By: " . implode( ", ", $users ) );
|
||||
} else {
|
||||
|
||||
echo formatJSEND("success");
|
||||
}
|
||||
}
|
||||
@ -91,18 +110,16 @@ class Active extends Common
|
||||
// Add File
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
public function Add()
|
||||
{
|
||||
$process_add = true;
|
||||
foreach ($this->actives as $active => $data) {
|
||||
if (is_array($data) && isset($data['username']) && $data['username']==$this->username && $data['path']==$this->path) {
|
||||
$process_add = false;
|
||||
}
|
||||
}
|
||||
if ($process_add) {
|
||||
$this->actives[] = array("username"=>$this->username,"path"=>$this->path);
|
||||
saveJSON('active.php', $this->actives);
|
||||
echo formatJSEND("success");
|
||||
public function Add() {
|
||||
|
||||
global $sql;
|
||||
$query = "INSERT INTO active( username, path, focused ) VALUES ( ?, ?, ? );";
|
||||
$bind_variables = array( $this->username, $this->path, false );
|
||||
$return = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
|
||||
if( $return > 0 ) {
|
||||
|
||||
echo formatJSEND( "success" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,64 +127,68 @@ class Active extends Common
|
||||
// Rename File
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
public function Rename()
|
||||
{
|
||||
$revised_actives = array();
|
||||
foreach ($this->actives as $active => $data) {
|
||||
if (is_array($data) && isset($data['username'])) {
|
||||
$revised_actives[] = array("username"=>$data['username'],"path"=>str_replace($this->path, $this->new_path, $data['path']));
|
||||
public function Rename() {
|
||||
|
||||
global $sql;
|
||||
$query = "UPDATE active SET path=? WHERE path=?;";
|
||||
$bind_variables = array( $this->new_path, $this->path );
|
||||
$return = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
|
||||
if( $return > 0 ) {
|
||||
|
||||
echo formatJSEND( "success" );
|
||||
}
|
||||
}
|
||||
saveJSON('active.php', $revised_actives);
|
||||
echo formatJSEND("success");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Remove File
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
public function Remove()
|
||||
{
|
||||
foreach ($this->actives as $active => $data) {
|
||||
if (is_array($data) && isset($data['username']) && $this->username==$data['username'] && $this->path==$data['path']) {
|
||||
unset($this->actives[$active]);
|
||||
public function Remove() {
|
||||
|
||||
global $sql;
|
||||
$query = "DELETE FROM active WHERE path=? AND username=?;";
|
||||
$bind_variables = array( $this->path, $this->username );
|
||||
$return = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
|
||||
if( $return > 0 ) {
|
||||
|
||||
echo formatJSEND( "success" );
|
||||
}
|
||||
}
|
||||
saveJSON('active.php', $this->actives);
|
||||
echo formatJSEND("success");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Remove All Files
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
public function RemoveAll()
|
||||
{
|
||||
foreach ($this->actives as $active => $data) {
|
||||
if (is_array($data) && isset($data['username']) && $this->username==$data['username']) {
|
||||
unset($this->actives[$active]);
|
||||
public function RemoveAll() {
|
||||
|
||||
global $sql;
|
||||
$query = "DELETE FROM active WHERE username=?;";
|
||||
$bind_variables = array( $this->username );
|
||||
$return = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
|
||||
if( $return > 0 ) {
|
||||
|
||||
echo formatJSEND( "success" );
|
||||
}
|
||||
}
|
||||
saveJSON('active.php', $this->actives);
|
||||
echo formatJSEND("success");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Mark File As Focused
|
||||
// All other files will be marked as non-focused.
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
public function MarkFileAsFocused()
|
||||
{
|
||||
foreach ($this->actives as $active => $data) {
|
||||
if (is_array($data) && isset($data['username']) && $this->username==$data['username']) {
|
||||
$this->actives[$active]['focused']=false;
|
||||
if ($this->path==$data['path']) {
|
||||
$this->actives[$active]['focused']=true;
|
||||
public function MarkFileAsFocused() {
|
||||
|
||||
global $sql;
|
||||
$query = "UPDATE active SET focused=? WHERE username=?;UPDATE active SET focused=? WHERE path=? AND username=?;";
|
||||
$bind_variables = array( false, $this->username, true, $this->path, $this->username );
|
||||
$return = $sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
|
||||
if( $return > 0 ) {
|
||||
|
||||
echo formatJSEND( "success" );
|
||||
}
|
||||
}
|
||||
}
|
||||
saveJSON('active.php', $this->actives);
|
||||
echo formatJSEND("success");
|
||||
}
|
||||
}
|
||||
|
@ -669,8 +669,7 @@
|
||||
var newSession = this.sessions[newPath];
|
||||
|
||||
// Change Editor Mode
|
||||
var ext = codiad.filemanager.getExtension(newPath);
|
||||
var mode = codiad.editor.selectMode(ext);
|
||||
var mode = codiad.editor.selectMode(newPath);
|
||||
|
||||
// handle async mode change
|
||||
var fn = function() {
|
||||
|
@ -99,7 +99,17 @@
|
||||
amplify.subscribe( 'active.onClose', function( path ) {
|
||||
|
||||
let _this = codiad.auto_save;
|
||||
try {
|
||||
|
||||
_this.editor.removeEventListener( "change", _this.change );
|
||||
} catch( e ) {
|
||||
|
||||
/**
|
||||
* If the listener is not currently on file and we
|
||||
* try to close it, the program will throw an exception and
|
||||
* stop you from closing the file
|
||||
*/
|
||||
}
|
||||
});
|
||||
|
||||
/* Subscribe to know when a file become active. */
|
||||
|
@ -321,18 +321,18 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
getSettings: function() {
|
||||
getSettings: async function() {
|
||||
|
||||
var boolVal = null;
|
||||
var _this = this;
|
||||
var options = [
|
||||
let boolVal = null;
|
||||
let _this = this;
|
||||
let options = [
|
||||
'editor.fontSize',
|
||||
'editor.overScroll',
|
||||
'editor.printMarginColumn',
|
||||
'editor.tabSize',
|
||||
'editor.theme',
|
||||
];
|
||||
var bool_options = [
|
||||
let bool_options = [
|
||||
'editor.autocomplete',
|
||||
'settings.autosave',
|
||||
'editor.printMargin',
|
||||
@ -345,9 +345,11 @@
|
||||
'editor.persistentModal',
|
||||
];
|
||||
|
||||
$.each( options, async function( idx, key ) {
|
||||
let user_settings = await codiad.settings.get_options();
|
||||
|
||||
let localValue = await codiad.settings.get_option( 'codiad.' + key );
|
||||
$.each( options, function( idx, key ) {
|
||||
|
||||
let localValue = user_settings['codiad.' + key];
|
||||
if ( localValue != null ) {
|
||||
|
||||
_this.settings[key.split('.').pop()] = localValue;
|
||||
@ -356,7 +358,7 @@
|
||||
|
||||
$.each( bool_options, async function(idx, key) {
|
||||
|
||||
let localValue = await codiad.settings.get_option( 'codiad.' + key );
|
||||
let localValue = user_settings['codiad.' + key];
|
||||
if ( localValue != null ) {
|
||||
|
||||
_this.settings[key.split('.').pop()] = (localValue == 'true');
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once( __DIR__ . "/../sql/class.sql.php" );
|
||||
require_once( __DIR__ . "/../settings/class.settings.php" );
|
||||
|
||||
class Install {
|
||||
|
||||
public $active = "";
|
||||
@ -15,6 +22,8 @@ class Install {
|
||||
|
||||
function __construct() {
|
||||
|
||||
if( isset( $_POST["path"] ) ) {
|
||||
|
||||
$path = $_POST['path'];
|
||||
$rel = str_replace( '/components/install/install.php', '', $_SERVER['REQUEST_URI'] );
|
||||
|
||||
@ -26,13 +35,17 @@ class Install {
|
||||
$this->users = $path . "/data/users.php";
|
||||
$this->rel = $rel;
|
||||
$this->workspace = $path . "/workspace";
|
||||
$this->db_types = sql::db_types;
|
||||
$this->db_types = sql::DB_TYPES;
|
||||
$this->project_name = $_POST["project_name"];
|
||||
$this->project_path = $this->clean_path( $_POST["project_path"] );
|
||||
$this->username = $this->clean_username( $_POST["username"] );
|
||||
$this->password = $this->encrypt_password( $_POST["password"] );
|
||||
|
||||
$this->check();
|
||||
|
||||
require_once( "../sql/class.sql.php" );
|
||||
$this->sql = new sql();
|
||||
$this->install();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function check() {
|
||||
@ -51,7 +64,12 @@ class Install {
|
||||
|
||||
if( ! in_array( DBTYPE, $this->db_types ) ) {
|
||||
|
||||
$this->JSEND( "Invalid database. Please select one of the following: " . implode( ", ", $db_types ), addslashes( json_encode( array( $dbtype, $db_types ) ) ) );
|
||||
$this->JSEND( "Invalid database. Please select one of the following: " . implode( ", ", $db_types ), json_encode( array( $dbtype, $db_types ) ) );
|
||||
}
|
||||
|
||||
if( ! is_dir( $this->sessions ) ) {
|
||||
|
||||
mkdir( $this->sessions, 00755 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,20 +152,20 @@ define("WSURL", BASE_URL . "/workspace");
|
||||
// Marketplace
|
||||
//define("MARKETURL", "http://market.codiad.com/json");
|
||||
';
|
||||
saveFile( $config, $config_data );
|
||||
$this->save_file( $this->config, $config_data );
|
||||
echo( "success" );
|
||||
}
|
||||
|
||||
function create_project() {
|
||||
|
||||
$project_path = $this->clean_path( $project_path );
|
||||
$project_path = $this->project_path;
|
||||
|
||||
if ( ! $this->is_abs_path( $project_path ) ) {
|
||||
|
||||
$project_path = str_replace( " ", "_", preg_replace( '/[^\w-\.]/', '', $project_path ) );
|
||||
if( ! is_dir( $workspace . "/" . $project_path ) ) {
|
||||
if( ! is_dir( $this->workspace . "/" . $project_path ) ) {
|
||||
|
||||
mkdir( $workspace . "/" . $project_path );
|
||||
mkdir( $this->workspace . "/" . $project_path );
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -171,11 +189,12 @@ define("WSURL", BASE_URL . "/workspace");
|
||||
}
|
||||
|
||||
$bind_variables = array(
|
||||
$project_name,
|
||||
$this->project_name,
|
||||
$project_path,
|
||||
$username
|
||||
$this->username
|
||||
);
|
||||
$query = "INSERT INTO projects(name, path, owner) VALUES (?,?,?);";
|
||||
$connection = $this->sql->connect();
|
||||
$statement = $connection->prepare( $query );
|
||||
$statement->execute( $bind_variables );
|
||||
$error = $statement->errorInfo();
|
||||
@ -190,6 +209,18 @@ define("WSURL", BASE_URL . "/workspace");
|
||||
|
||||
$this->sql->create_tables(
|
||||
array(
|
||||
"active" => array(
|
||||
"fields" => array(
|
||||
"username" => "string",
|
||||
"path" => "text",
|
||||
"focused" => "string"
|
||||
),
|
||||
"attributes" => array(
|
||||
"username" => array( "not null", "unique" ),
|
||||
"path" => array( "not null", "unique" ),
|
||||
"focused" => array( "not null" ),
|
||||
)
|
||||
),
|
||||
"options" => array(
|
||||
"fields" => array(
|
||||
"id" => "int",
|
||||
@ -216,7 +247,7 @@ define("WSURL", BASE_URL . "/workspace");
|
||||
"name" => array( "not null" ),
|
||||
"path" => array( "not null", "unique" ),
|
||||
"owner" => array( "not null", "unique" ),
|
||||
"access" => array( "not null" ),
|
||||
"access" => array(),
|
||||
)
|
||||
),
|
||||
"users" => array(
|
||||
@ -262,15 +293,16 @@ define("WSURL", BASE_URL . "/workspace");
|
||||
$bind_variables = array(
|
||||
"",
|
||||
"",
|
||||
$username,
|
||||
$password,
|
||||
$this->username,
|
||||
$this->password,
|
||||
"",
|
||||
$project_path,
|
||||
$this->project_path,
|
||||
"admin",
|
||||
"",
|
||||
""
|
||||
);
|
||||
$query = "INSERT INTO users(first_name, last_name, username, password, email, project, access, groups, token) VALUES (?,?,?,?,?,?,?,?,?)";
|
||||
$connection = $this->sql->connect();
|
||||
$statement = $connection->prepare( $query );
|
||||
$statement->execute( $bind_variables );
|
||||
$error = $statement->errorInfo();
|
||||
@ -279,6 +311,13 @@ define("WSURL", BASE_URL . "/workspace");
|
||||
|
||||
die( '{"message":"Could not create user in database.","error":"' . addslashes(json_encode( $error )) .'"}' );
|
||||
}
|
||||
|
||||
$this->set_default_options();
|
||||
}
|
||||
|
||||
function encrypt_password( $string ) {
|
||||
|
||||
return sha1( md5( $string ) );
|
||||
}
|
||||
|
||||
function is_abs_path( $path ) {
|
||||
@ -309,6 +348,7 @@ define("WSURL", BASE_URL . "/workspace");
|
||||
$this->create_tables();
|
||||
$this->create_project();
|
||||
$this->create_user();
|
||||
//exit( "stop" );
|
||||
$this->create_config();
|
||||
}
|
||||
|
||||
@ -325,6 +365,37 @@ define("WSURL", BASE_URL . "/workspace");
|
||||
exit( json_encode( $message ) );
|
||||
}
|
||||
|
||||
function save_file( $file, $data ) {
|
||||
|
||||
$write = fopen( $file, 'w' ) or die( '{"message": "can\'t open file"}' );
|
||||
fwrite( $write, $data );
|
||||
fclose( $write );
|
||||
}
|
||||
|
||||
public function set_default_options() {
|
||||
|
||||
foreach( Settings::DEFAULT_OPTIONS as $id => $option ) {
|
||||
|
||||
$query = "INSERT INTO user_options ( name, username, value ) VALUES ( ?, ?, ? );";
|
||||
$bind_variables = array(
|
||||
$option["name"],
|
||||
$this->username,
|
||||
$option["value"],
|
||||
);
|
||||
$result = $this->sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
|
||||
if( $result == 0 ) {
|
||||
|
||||
$query = "UPDATE user_options SET value=? WHERE name=? AND username=?;";
|
||||
$bind_variables = array(
|
||||
$option["value"],
|
||||
$option["name"],
|
||||
$this->username,
|
||||
);
|
||||
$result = $this->sql->query( $query, $bind_variables, 0, "rowCount" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Install = new Install();
|
||||
|
@ -1,295 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) Codiad & Kent Safranski (codiad.com), Isaac Brown (telaaedifex.com),
|
||||
* distributed as-is and without warranty under the MIT License. See
|
||||
* [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Paths
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
$path = $_POST['path'];
|
||||
|
||||
$rel = str_replace( '/components/install/process.php', '', $_SERVER['REQUEST_URI'] );
|
||||
|
||||
$workspace = $path . "/workspace";
|
||||
$users = $path . "/data/users.php";
|
||||
$projects = $path . "/data/projects.php";
|
||||
$active = $path . "/data/active.php";
|
||||
$sessions = $path . "/data/sessions";
|
||||
$config = $path . "/config.php";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Functions
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
function saveFile( $file, $data ) {
|
||||
|
||||
$write = fopen( $file, 'w' ) or die( '{"message": "can\'t open file"}' );
|
||||
fwrite( $write, $data );
|
||||
fclose( $write );
|
||||
}
|
||||
|
||||
function saveJSON( $file, $data ) {
|
||||
|
||||
$data = "<?php/*|\r\n" . json_encode( $data ) . "\r\n|*/?>";
|
||||
saveFile( $file, $data );
|
||||
}
|
||||
|
||||
function encryptPassword( $p ) {
|
||||
|
||||
return sha1( md5( $p ) );
|
||||
}
|
||||
|
||||
function cleanUsername( $username ) {
|
||||
|
||||
return preg_replace( '#[^A-Za-z0-9' . preg_quote( '-_@. ' ). ']#', '', $username );
|
||||
}
|
||||
|
||||
function isAbsPath( $path ) {
|
||||
|
||||
return $path[0] === '/';
|
||||
}
|
||||
|
||||
function cleanPath( $path ) {
|
||||
|
||||
// prevent Poison Null Byte injections
|
||||
$path = str_replace( chr( 0 ), '', $path );
|
||||
|
||||
// prevent go out of the workspace
|
||||
while ( strpos( $path, '../' ) !== false ) {
|
||||
|
||||
$path = str_replace( '../', '', $path );
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Verify no overwrites
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
if ( ! ( defined( 'DBHOST' ) && defined( 'DBNAME' ) && defined( 'DBUSER' ) && defined( 'DBPASS' ) && defined( 'DBTYPE' ) ) ) {
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Get POST responses
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
$username = cleanUsername( $_POST['username'] );
|
||||
$password = encryptPassword( $_POST['password'] );
|
||||
$project_name = $_POST['project_name'];
|
||||
if ( isset( $_POST['project_path'] ) ) {
|
||||
|
||||
$project_path = $_POST['project_path'];
|
||||
} else {
|
||||
|
||||
$project_path = $project_name;
|
||||
}
|
||||
$timezone = $_POST['timezone'];
|
||||
|
||||
$dbtype = $_POST['dbtype'];
|
||||
$dbhost = $_POST['dbhost'];
|
||||
$dbname = $_POST['dbname'];
|
||||
$dbuser = $_POST['dbuser'];
|
||||
$dbpass = $_POST['dbpass'];
|
||||
|
||||
//Valid databases Codiad is able to use
|
||||
$db_types = [
|
||||
'mysql',
|
||||
'pgsql',
|
||||
//'sqlite',
|
||||
];
|
||||
|
||||
//Is selected database type valid?
|
||||
if( ! in_array( $dbtype, $db_types ) ) {
|
||||
|
||||
die( '{"message": "Invalid database. Please select one of the following: ' . implode( ", ", $db_types ) . '.", "error": "' . addslashes(json_encode( array( $dbtype, $db_types ) ) ) . '"}' );
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$connection = new PDO( "{$dbtype}:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass );
|
||||
} catch( PDOException $e ) {
|
||||
|
||||
die( '{"message":"Could not connect to database.","error":"' . addslashes( json_encode( $e->getMessage() ) ) .'"}' );
|
||||
}
|
||||
$bind_vars = array();
|
||||
$bind = "";
|
||||
$database_sql_fullpath = $path . '/components/install/sql/' . $dbtype . '.sql';
|
||||
if( ! is_file( $database_sql_fullpath ) ) {
|
||||
|
||||
die( '{"message":"Could not find the sql script for the database type: ' . $dbtype . '","error":"' . addslashes( json_encode( array( "path" => $database_sql_fullpath, "dbtype" => $dbtype ) ) ) .'"}' );
|
||||
}
|
||||
$sql = file_get_contents( $database_sql_fullpath );
|
||||
|
||||
try {
|
||||
|
||||
//Create the database
|
||||
$result = $connection->exec( $sql );
|
||||
} catch( PDOException $e ) {
|
||||
|
||||
die( '{"message":"Could not create initial tables in database.","error":"' . addslashes( json_encode( $e->getMessage() ) ) .'"}' );
|
||||
}
|
||||
|
||||
$error = $connection->errorInfo();
|
||||
if( ! $error[0] == "00000" ) {
|
||||
|
||||
die( '{"message":"Could not create initial tables in database.","error":"' . addslashes( json_encode( $error ) ) .'"}' );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Create Projects files
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
$project_path = cleanPath( $project_path );
|
||||
|
||||
if ( ! isAbsPath( $project_path ) ) {
|
||||
|
||||
$project_path = str_replace( " ", "_", preg_replace( '/[^\w-\.]/', '', $project_path ) );
|
||||
if( ! is_dir( $workspace . "/" . $project_path ) ) {
|
||||
|
||||
mkdir( $workspace . "/" . $project_path );
|
||||
}
|
||||
} else {
|
||||
|
||||
$project_path = cleanPath( $project_path );
|
||||
if ( substr( $project_path, -1 ) == '/' ) {
|
||||
|
||||
$project_path = substr( $project_path, 0, strlen( $project_path ) - 1 );
|
||||
}
|
||||
if ( ! file_exists( $project_path ) ) {
|
||||
|
||||
if ( ! mkdir( $project_path . '/', 0755, true ) ) {
|
||||
|
||||
die( '{"message": "Unable to create Absolute Path"}' );
|
||||
}
|
||||
} else {
|
||||
|
||||
if ( ! is_writable( $project_path ) || ! is_readable( $project_path ) ) {
|
||||
|
||||
die( '{"message": "No Read/Write Permission"}' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$bind_variables = array(
|
||||
$project_name,
|
||||
$project_path,
|
||||
$username
|
||||
);
|
||||
$query = "INSERT INTO projects(name, path, owner) VALUES (?,?,?);";
|
||||
$statement = $connection->prepare( $query );
|
||||
$statement->execute( $bind_variables );
|
||||
$error = $statement->errorInfo();
|
||||
|
||||
if( ! $error[0] == "00000" ) {
|
||||
|
||||
die( '{"message":"Could not create project in database.","error":"' . addslashes(json_encode( $error )) .'"}' );
|
||||
}
|
||||
|
||||
$bind_variables = array(
|
||||
"",
|
||||
"",
|
||||
$username,
|
||||
$password,
|
||||
"",
|
||||
$project_path,
|
||||
"admin",
|
||||
"",
|
||||
""
|
||||
);
|
||||
$query = "INSERT INTO users(first_name, last_name, username, password, email, project, access, groups, token) VALUES (?,?,?,?,?,?,?,?,?)";
|
||||
$statement = $connection->prepare( $query );
|
||||
$statement->execute( $bind_variables );
|
||||
$error = $statement->errorInfo();
|
||||
|
||||
if( ! $error[0] == "00000" ) {
|
||||
|
||||
die( '{"message":"Could not create user in database.","error":"' . addslashes(json_encode( $error )) .'"}' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create sessions path.
|
||||
*/
|
||||
|
||||
if ( ! is_dir( $sessions ) ) {
|
||||
|
||||
mkdir( $sessions, 00755 );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Create Active file
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
saveJSON( $active, array( '' ) );
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Create Config
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
$config_data = '<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) Codiad & Kent Safranski (codiad.com), Isaac Brown (telaaedifex.com),
|
||||
* distributed as-is and without warranty under the MIT License. See
|
||||
* [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// CONFIG
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
// PATH TO CODIAD
|
||||
define("BASE_PATH", "' . $path . '");
|
||||
|
||||
// BASE URL TO CODIAD (without trailing slash)
|
||||
define("BASE_URL", "' . $_SERVER["HTTP_HOST"] . $rel . '");
|
||||
|
||||
// THEME : default, modern or clear (look at /themes)
|
||||
define("THEME", "default");
|
||||
|
||||
// ABSOLUTE PATH
|
||||
define("WHITEPATHS", BASE_PATH . ",/home");
|
||||
|
||||
// SESSIONS (e.g. 7200)
|
||||
$cookie_lifetime = "0";
|
||||
|
||||
// TIMEZONE
|
||||
date_default_timezone_set("' . $_POST['timezone'] . '");
|
||||
|
||||
// External Authentification
|
||||
//define("AUTH_PATH", "/path/to/customauth.php");
|
||||
|
||||
// Site Name
|
||||
define("SITE_NAME", "' . $_POST['site_name'] . '");
|
||||
|
||||
// Database Information
|
||||
define( "DBHOST", "' . $_POST['dbhost'] . '" );
|
||||
define( "DBNAME", "' . $_POST['dbname'] . '" );
|
||||
define( "DBUSER", "' . $_POST['dbuser'] . '" );
|
||||
define( "DBPASS", "' . $_POST['dbpass'] . '" );
|
||||
define( "DBTYPE", "' . $_POST['dbtype'] . '" );
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// ** DO NOT EDIT CONFIG BELOW **
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
// PATHS
|
||||
define("COMPONENTS", BASE_PATH . "/components");
|
||||
define("PLUGINS", BASE_PATH . "/plugins");
|
||||
define("THEMES", BASE_PATH . "/themes");
|
||||
define("DATA", BASE_PATH . "/data");
|
||||
define("WORKSPACE", BASE_PATH . "/workspace");
|
||||
|
||||
// URLS
|
||||
define("WSURL", BASE_URL . "/workspace");
|
||||
|
||||
// Marketplace
|
||||
//define("MARKETURL", "http://market.codiad.com/json");
|
||||
';
|
||||
|
||||
saveFile( $config, $config_data );
|
||||
echo( "success" );
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
--
|
||||
-- Table structure for table options
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS options (
|
||||
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
value text NOT NULL,
|
||||
CONSTRAINT option_name UNIQUE (name)
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table projects
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS projects (
|
||||
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
path varchar(255) NOT NULL,
|
||||
owner varchar(255) NOT NULL,
|
||||
access text,
|
||||
CONSTRAINT project UNIQUE (path, owner)
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table users
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
first_name varchar(255) DEFAULT NULL,
|
||||
last_name varchar(255) DEFAULT NULL,
|
||||
username varchar(255) NOT NULL,
|
||||
password text NOT NULL,
|
||||
email varchar(255) DEFAULT NULL,
|
||||
project varchar(255) DEFAULT NULL,
|
||||
access varchar(255) NOT NULL,
|
||||
groups text,
|
||||
token text,
|
||||
CONSTRAINT username UNIQUE (username)
|
||||
);
|
||||
|
||||
--
|
||||
-- Table structure for table user_options
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_options (
|
||||
id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
username varchar(255) NOT NULL,
|
||||
value text NOT NULL,
|
||||
CONSTRAINT option_name UNIQUE (name,username)
|
||||
);
|
@ -1,53 +0,0 @@
|
||||
--
|
||||
-- Table structure for table options
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS options (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL UNIQUE,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table projects
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS projects (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
path varchar(255) NOT NULL UNIQUE,
|
||||
owner varchar(255) NOT NULL UNIQUE,
|
||||
access text
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table users
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
first_name varchar(255) DEFAULT NULL,
|
||||
last_name varchar(255) DEFAULT NULL,
|
||||
username varchar(255) NOT NULL UNIQUE,
|
||||
password text NOT NULL,
|
||||
email varchar(255) DEFAULT NULL,
|
||||
project varchar(255) DEFAULT NULL,
|
||||
access varchar(255) NOT NULL,
|
||||
groups text,
|
||||
token text
|
||||
);
|
||||
|
||||
--
|
||||
-- Table structure for table user_options
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_options (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL UNIQUE,
|
||||
username varchar(255) NOT NULL UNIQUE,
|
||||
value text NOT NULL
|
||||
);
|
@ -1,53 +0,0 @@
|
||||
--
|
||||
-- Table structure for table options
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS options (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name CHAR(255) NOT NULL UNIQUE,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table projects
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS projects (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name CHAR(255) NOT NULL,
|
||||
path CHAR(255) NOT NULL UNIQUE,
|
||||
owner CHAR(255) NOT NULL UNIQUE,
|
||||
access text
|
||||
);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table users
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
first_name CHAR(255) DEFAULT NULL,
|
||||
last_name CHAR(255) DEFAULT NULL,
|
||||
username CHAR(255) NOT NULL UNIQUE,
|
||||
password text NOT NULL,
|
||||
email CHAR(255) DEFAULT NULL,
|
||||
project CHAR(255) DEFAULT NULL,
|
||||
access CHAR(255) NOT NULL,
|
||||
groups text,
|
||||
token text
|
||||
);
|
||||
|
||||
--
|
||||
-- Table structure for table user_options
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_options (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name CHAR(255) NOT NULL UNIQUE,
|
||||
username CHAR(255) NOT NULL UNIQUE,
|
||||
value text NOT NULL
|
||||
);
|
@ -7,9 +7,9 @@
|
||||
* [root]/license.txt for more. This information must remain intact.
|
||||
*/
|
||||
|
||||
require_once( "./install.php" );
|
||||
require_once( __DIR__ . "/install.php" );
|
||||
|
||||
$path = rtrim(str_replace("index.php", "", $_SERVER['SCRIPT_FILENAME']), "/");
|
||||
$path = rtrim( str_replace("index.php", "", $_SERVER['SCRIPT_FILENAME']), "/");
|
||||
|
||||
$workspace = is_writable($path . "/workspace");
|
||||
$data = is_writable($path . "/data");
|
||||
@ -179,7 +179,8 @@ if ($newrelic) {
|
||||
<label><?php i18n("Database Type"); ?></label>
|
||||
<select name="dbtype">
|
||||
<?php
|
||||
foreach ($aValidDBType as $db_name => $key) {
|
||||
$select_dbtypes = "";
|
||||
foreach (sql::DB_TYPES as $db_name => $key) {
|
||||
if ($autocomplete['dbtype'] == $key) {
|
||||
$select_dbtypes .= '<option selected="selected" value="' . $key . '">' . $db_name . '</option>';
|
||||
} else {
|
||||
@ -366,7 +367,7 @@ if ($newrelic) {
|
||||
if(!password_match){ alert('The passwords entered do not match'); }
|
||||
|
||||
if(!empty_fields && password_match && check_path){
|
||||
$.post('components/install/process.php',$('#install').serialize(),function( data ) {
|
||||
$.post('components/install/install.php',$('#install').serialize(),function( data ) {
|
||||
|
||||
if( data == 'success' ){
|
||||
window.location.reload();
|
||||
|
@ -257,6 +257,7 @@
|
||||
$.get( this.controller + '?action=get_current', function( data ) {
|
||||
|
||||
var projectInfo = codiad.jsend.parse( data );
|
||||
|
||||
if ( projectInfo != 'error' ) {
|
||||
|
||||
$( '#file-manager' )
|
||||
|
@ -168,6 +168,36 @@ class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
public function get_options( $action = "return" ) {
|
||||
|
||||
global $sql;
|
||||
|
||||
$query = "SELECT name, value FROM user_options WHERE username=?;";
|
||||
$bind_variables = array( $option, $this->username );
|
||||
$return = $sql->query( $query, $bind_variables, array() );
|
||||
$options = array();
|
||||
|
||||
foreach( $return as $id => $data ) {
|
||||
|
||||
$options[$data["name"]] = $data["value"];
|
||||
}
|
||||
|
||||
$options = json_encode( $options );
|
||||
|
||||
switch( $action ) {
|
||||
|
||||
case( "exit" ):
|
||||
|
||||
exit( $options );
|
||||
break;
|
||||
|
||||
case( "return" ):
|
||||
|
||||
return( $options );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Save User Settings
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
@ -54,6 +54,12 @@ if ( $_GET['action'] == 'get_option' ) {
|
||||
$Settings->get_option( $_POST['option'], $_SESSION["user"], "exit" );
|
||||
}
|
||||
|
||||
if ( $_GET['action'] == 'get_options' ) {
|
||||
|
||||
$Settings->username = $_SESSION['user'];
|
||||
$Settings->get_options( "exit" );
|
||||
}
|
||||
|
||||
if ( $_GET['action'] == 'update_option' ) {
|
||||
|
||||
$Settings->username = $_SESSION['user'];
|
||||
|
@ -56,6 +56,29 @@
|
||||
}
|
||||
},
|
||||
|
||||
get_options: async function() {
|
||||
|
||||
let result;
|
||||
|
||||
try {
|
||||
|
||||
result = await $.ajax({
|
||||
|
||||
url: this.controller + '?action=get_options',
|
||||
type: "POST",
|
||||
dataType: 'html',
|
||||
data: {
|
||||
},
|
||||
});
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
|
||||
console.log(error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Save Settings
|
||||
//////////////////////////////////////////////////////////////////
|
||||
@ -142,7 +165,7 @@
|
||||
},
|
||||
success: function( data ) {
|
||||
|
||||
console.log( "Data: " + data )
|
||||
console.log( `Update Option ( ${option} ): ` + data )
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
|
||||
|
@ -165,9 +165,9 @@ class sql_conversions {
|
||||
|
||||
"unique" => array(
|
||||
|
||||
"mysql" => "CONSTRAINT '%constraint_name%' UNIQUE ( %field_names% )",
|
||||
"pgsql" => "CONSTRAINT '%constraint_name%' UNIQUE ( %field_names% )",
|
||||
"sqlite" => "CONSTRAINT '%constraint_name%' UNIQUE ( %field_names% )",
|
||||
"mysql" => "CONSTRAINT %constraint_name% UNIQUE ( %field_names% )",
|
||||
"pgsql" => "CONSTRAINT %constraint_name% UNIQUE ( %field_names% )",
|
||||
"sqlite" => "CONSTRAINT %constraint_name% UNIQUE ( %field_names% )",
|
||||
),
|
||||
);
|
||||
|
||||
@ -338,6 +338,8 @@ class sql_conversions {
|
||||
|
||||
$query .= "{$id} {$this->data_types[$type][$dbtype]}";
|
||||
|
||||
if( isset( $attributes[$id] ) ) {
|
||||
|
||||
foreach( $attributes[$id] as $attribute ) {
|
||||
|
||||
$attribute_string = $this->specials["$attribute"][$dbtype];
|
||||
@ -347,6 +349,14 @@ class sql_conversions {
|
||||
continue;
|
||||
}
|
||||
|
||||
if( $dbtype == "pgsql" ) {
|
||||
|
||||
if( $id == "id" ) {
|
||||
|
||||
$query = substr( $query, 0, -( strlen( " {$this->data_types[$type][$dbtype]}" ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( ! strpos( $attribute_string, "%table_name%" ) === FALSE ) {
|
||||
|
||||
$attribute_string = str_replace( "%table_name%", $table_name, $attribute_string );
|
||||
@ -366,6 +376,7 @@ class sql_conversions {
|
||||
}
|
||||
$query .= " {$attribute_string}";
|
||||
}
|
||||
}
|
||||
$query .= ",";
|
||||
}
|
||||
|
||||
@ -380,14 +391,14 @@ class sql_conversions {
|
||||
|
||||
if( $unique_string == "" ) {
|
||||
|
||||
$unique_string = $this->specials["unique"] . ",";
|
||||
$unique_string = $this->specials["unique"][$dbtype] . ",";
|
||||
}
|
||||
$fields_string .= "{$id_open}{$id}{$id_close},";
|
||||
}
|
||||
}
|
||||
|
||||
$unique_string = str_replace( "%constraint_name%", $fields_string, $unique_string );
|
||||
$unique_string = str_replace( "%field_names%", $fields_string, $unique_string );
|
||||
$unique_string = str_replace( "%constraint_name%", strtolower( preg_replace( '#[^A-Za-z0-9' . preg_quote( '-_@. ').']#', '', $fields_string ) ), $unique_string );
|
||||
$unique_string = str_replace( "%field_names%", substr( $fields_string, 0, -1 ), $unique_string );
|
||||
$query .= $unique_string;
|
||||
|
||||
$query = substr( $query, 0, -1 );
|
||||
|
@ -4,6 +4,13 @@ require_once( __DIR__ . "/class.sql.conversions.php" );
|
||||
|
||||
class sql {
|
||||
|
||||
const DB_TYPES = array(
|
||||
|
||||
"MySQL" => "mysql",
|
||||
"PostgresSQL" => "pgsql",
|
||||
"SQLite" => "sqlite",
|
||||
);
|
||||
|
||||
public $connection = null;
|
||||
public $conversions = null;
|
||||
public $identifier_character = null;
|
||||
@ -77,8 +84,9 @@ class sql {
|
||||
*/
|
||||
|
||||
$query = $this->conversions->tables( $table );
|
||||
//echo var_dump( $query ) . "<br>";
|
||||
$result = $this->query( $query, array(), array() );
|
||||
$connection = $this->connect();
|
||||
$result = $connection->exec( $query );
|
||||
//echo var_dump( $query, $result, $connection->errorInfo() ) . "<br>";
|
||||
}
|
||||
|
||||
public static function escape_identifier( $i ) {
|
||||
@ -156,6 +164,7 @@ class sql {
|
||||
}
|
||||
|
||||
$error = $statement->errorInfo();
|
||||
|
||||
if( ! $error[0] == "00000" ) {
|
||||
|
||||
echo var_export( $error );
|
||||
|
@ -252,7 +252,7 @@ class User {
|
||||
$_SESSION['lang'] = $this->lang;
|
||||
$_SESSION['theme'] = $this->theme;
|
||||
$_SESSION["login_session"] = true;
|
||||
$user = $return;
|
||||
$user = $return[0];
|
||||
|
||||
$query = "UPDATE users SET token=? WHERE username=?;";
|
||||
$bind_variables = array( sha1( $token ), $this->username );
|
||||
|
Loading…
Reference in New Issue
Block a user