continued work on initial setup of installation systems

This commit is contained in:
xevidos 2020-07-13 00:21:06 -04:00
parent f26c386751
commit 5ff284bf02
12 changed files with 1945 additions and 82 deletions

4
assets/js/codiad.js Normal file
View File

@ -0,0 +1,4 @@
( function( global, $ ) {
var codiad = global.codiad = {};
})( this, jQuery );

0
assets/js/common.js Normal file
View File

1725
assets/js/forms.js Normal file

File diff suppressed because it is too large Load Diff

2
assets/js/jquery-3.5.1.js vendored Normal file

File diff suppressed because one or more lines are too long

15
assets/js/loading.js Normal file
View File

@ -0,0 +1,15 @@
( function( global, $ ) {
// Define core
let codiad = global.codiad,
scripts = document.getElementsByTagName( 'script' ),
path = scripts[scripts.length-1].src.split( '?' )[0],
curpath = path.split( '/' ).slice( 0, -1 ).join( '/' ) + '/';
codiad.loading = {
init: function() {},
};
})( this, jQuery );

View File

@ -58,6 +58,15 @@ class Common {
return ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] === 'on' ? "https" : "http" ) . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
}
public static function get_default_return() {
return array(
"status" => "none",
"message" => "",
"value" => null,
);
}
public static function i18n( $key, $args = array() ) {
global $lang;

View File

@ -21,6 +21,37 @@ class Data {
return self::$instance;
}
public function query( $query, $bind_vars, $default, $action='fetchAll', $errors="default" ) {
$return = common::get_default_return();
if( is_array( $query ) ) {
if( in_array( DBTYPE, array_keys( $query ) ) ) {
$query = $query[DBTYPE];
} else {
if( isset( $query["*"] ) ) {
$query = $query["*"];
} else {
$return = $default;
if( $errors == "message" ) {
$return = json_encode( array( "error" => "No query specified for database type." ) );
} elseif( $errors == "exception" ) {
throw new Error( "No query specified for database type." );
}
return $return;
}
}
}
}
}
?>

View File

@ -32,26 +32,31 @@ class Initialize {
function __construct() {
$config = realpath( __DIR__ . "/../../config.php" );
$config = realpath( dirname( __FILE__ ) . "/../../config.php" );
if( ! file_exists( $config ) || ! is_readable( $config ) ) {
if( ! self::is_installing() ) {
$message = "Error loading config file.";
if( ! file_exists( $config ) ) {
if( ( ! file_exists( $config ) || ! is_readable( $config ) ) ) {
$message = "Error, could not find config file. If you have not installed Codiad please go to /install/ to complete the installation.";
} elseif( ! is_readable( $config ) ) {
$message = "Error loading config file.";
$message = "Error config file is not readable, please check permissions.";
if( ! file_exists( $config ) ) {
$message = "Error, could not find config file. If you have not installed Codiad please go to <a href='./install'>/install/</a> to complete the installation.";
} elseif( ! is_readable( $config ) ) {
$message = "Error config file is not readable, please check permissions.";
}
echo $message;
exit();
} else {
require_once( $config );
}
echo $message;
exit();
}
require_once( $config );
$this->register_constants();
$this->register_globals();
$bases = self::BASES;
@ -67,7 +72,6 @@ class Initialize {
}
}
$this->register_globals();
$this->check_paths();
}
@ -101,6 +105,11 @@ class Initialize {
return self::$instance;
}
public static function is_installing() {
return ! ( strpos( $_SERVER["SCRIPT_NAME"], "install" ) === false );
}
function register_constants() {
if( ! defined( 'AUTH_TYPE' ) ) {
@ -140,6 +149,11 @@ class Initialize {
define( 'SITE_NAME', "Codiad" );
}
if( ! defined( 'THEME' ) ) {
define( "THEME", "default" );
}
if( ! defined( 'THEMES' ) ) {
define( "THEMES", BASE_PATH . "/themes" );

View File

@ -1,65 +0,0 @@
<?php
/*
* Copyright (c) Codiad & Kent Safranski (codiad.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", "absolute/path/to/codiad" );
// BASE URL TO CODIAD (without trailing slash)
//define( "BASE_URL", "domain.tld" );
// THEME : default, modern or clear (look at /themes)
define( "THEME", "default" );
// ABSOLUTE PATH, this is used as whitelist for absolute path projects
define( "WHITEPATHS", array(
"/home",
));
// SESSIONS ( e.g. 7200 )
$cookie_lifetime = "0";
// TIMEZONE
date_default_timezone_set( "America/New_York" );
// Allows to overwrite the default language
//define( "LANGUAGE", "en" );
// External Authentification
//define( "AUTH_PATH", "/path/to/customauth.php" );
// Site Name
define( "SITE_NAME", "Codiad" );
define( "DBHOST", "localhost" );
define( "DBNAME", "database" );
define( "DBUSER", "username" );
define( "DBPASS", "password" );
define( "DBTYPE", "mysql" );
//////////////////////////////////////////////////////////////////
// ** 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" );
?>

132
install/index.php Normal file
View File

@ -0,0 +1,132 @@
<?php
ini_set( 'display_errors', 1 );
ini_set( 'display_startup_errors', 1 );
error_reporting( E_ALL );
require_once( __DIR__ . "/../components/initialize/class.initialize.php" );
Initialize::get_instance();
$components = scandir( COMPONENTS );
unset( $components["."], $components[".."] );
// Theme
$theme = THEME;
if( isset( $_SESSION['theme'] ) ) {
$theme = $_SESSION['theme'];
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="
width=device-width,
initial-scale=1.0,
maximum-scale=1.0,
user-scalable=no">
<title><?php echo SITE_NAME;?></title>
<?php
// Load System CSS Files
$stylesheets = array(
"jquery.toastmessage.css",
"reset.css",
"fonts.css",
"screen.css"
);
foreach( $stylesheets as $sheet ) {
if( file_exists( THEMES . "/". $theme . "/" . $sheet ) ) {
echo( '<link rel="stylesheet" href="../themes/' . $theme . '/' . $sheet . '?v=' . Update::get_version() . '">' );
} else {
echo( '<link rel="stylesheet" href="../themes/default/' . $sheet . '?v=' . Update::get_version() . '">' );
}
}
// Load Component CSS Files
foreach( $components as $component ) {
if( file_exists( THEMES . "/". $theme . "/" . $component . "/screen.css" ) ) {
echo( '<link rel="stylesheet" href="../themes/' . $theme . '/' . $component . '/screen.css?v=' . Update::get_version() . '">' );
} else {
if( file_exists( "../themes/default/" . $component . "/screen.css" ) ) {
echo( '<link rel="stylesheet" href="../themes/default/' . $component . '/screen.css?v=' . Update::get_version() . '">' );
} else {
if( file_exists( COMPONENTS . "/" . $component . "/screen.css" ) ) {
echo( '<link rel="stylesheet" href="../components/' . $component . '/screen.css?v=' . Update::get_version() . '">' );
}
}
}
}
if( file_exists( THEMES . "/". $theme . "/favicon.ico" ) ) {
echo( '<link rel="icon" href="' . THEMES . '/' . $theme . '/favicon.ico" type="image/x-icon" />' );
} else {
echo( '<link rel="icon" href="../assets/images/favicon.ico" type="image/x-icon" />' );
}
?>
<style>
form {
left: 50%;
margin-left: -175px;
padding: 35px;
position: fixed;
top: 30%;
width: 350px;
}
</style>
<script src="../assets/js/jquery-3.5.1.js"></script>
<script src="../assets/js/codiad.js"></script>
<script src="../assets/js/events.js"></script>
<script src="../assets/js/loading.js"></script>
<script src="../assets/js/common.js"></script>
<script src="../assets/js/forms.js"></script>
</head>
<body>
<div id="installation"></div>
<script>
( function( global, $ ) {
$( document ).ready( function() {
let d = {
active: {
default: "true",
element: $( '<select></select>' ),
label: "Active On Website: ",
name: "active",
options: {
"Yes": "true",
"No": "false",
},
type: "select",
},
};
let form = new codiad.forms({
data: d,
container: $( "#installation" ),
});
});
})( this, jQuery );
</script>
</body>
</html>

View File

@ -1,9 +1,5 @@
<?php
ini_set( 'display_errors', 1 );
ini_set( 'display_startup_errors', 1 );
error_reporting( E_ALL );
require_once( __DIR__ . "/components/initialize/class.initialize.php" );
Initialize::get_instance();