diff --git a/LICENSE.txt b/LICENSE.txt index 357fbc7..03592e4 100755 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -* Copyright (c) Codiad & Kent Safranski (codiad.com) +* Copyright (c) Codiad & Kent Safranski (codiad.com) & and Isaac Brown (telaaedifex.com) * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/admin/assets/classes/initialize.php b/admin/assets/classes/initialize.php old mode 100644 new mode 100755 diff --git a/admin/index.php b/admin/index.php old mode 100644 new mode 100755 index 96c9bf1..38b9a14 --- a/admin/index.php +++ b/admin/index.php @@ -11,8 +11,8 @@ * */ -require_once('../common.php'); -require_once('./assets/classes/initialize.php'); +require_once( '../common.php' ); +require_once( './assets/classes/initialize.php' ); new initialize(); ?> diff --git a/common.php b/common.php index e69de29..710c821 100755 --- a/common.php +++ b/common.php @@ -0,0 +1,388 @@ + $v ) { + + $return = str_replace( "%{" . $k . "}%", $v, $return ); + } + return $return; + } + + ////////////////////////////////////////////////////////////////// + // Check Session / Key + ////////////////////////////////////////////////////////////////// + + public static function checkSession() { + + // Set any API keys + $api_keys = array(); + // Check API Key or Session Authentication + $key = ""; + if( isset( $_GET['key'] ) ) { + + $key = $_GET['key']; + } + if( ! isset( $_SESSION['user'] ) && ! in_array( $key, $api_keys ) ) { + + //exit('{"status":"error","message":"Authentication Error"}'); + exit( '{"status":"error","message":"Authentication Error"}' ); + } + } + + + ////////////////////////////////////////////////////////////////// + // Get JSON + ////////////////////////////////////////////////////////////////// + + public static function getJSON( $file, $namespace="" ) { + + $path = DATA . "/"; + if( $namespace != "" ) { + + $path = $path . $namespace . "/"; + $path = preg_replace( '#/+#', '/', $path ); + } + + $json = file_get_contents( $path . $file ); + $json = str_replace( ["\n\r", "\r", "\n"], "", $json ); + $json = str_replace( "|*/?>", "", str_replace( ""; + $write = fopen( $path . $file, 'w' ) or die( "can't open file " . $path . $file ); + fwrite( $write, $data ); + fclose( $write ); + } + + ////////////////////////////////////////////////////////////////// + // Format JSEND Response + ////////////////////////////////////////////////////////////////// + + public static function formatJSEND( $status, $data = false ) { + + /// Debug ///////////////////////////////////////////////// + $debug = ""; + if( count( Common::$debugMessageStack ) > 0 ) { + + $debug .= ',"debug":'; + $debug .= json_encode( Common::$debugMessageStack ); + } + + if( $status == "success" ) { + + // Success /////////////////////////////////////////////// + if( $data ) { + + $jsend = '{"status":"success","data":' . json_encode( $data ) . $debug . '}'; + } else { + + $jsend = '{"status":"success","data":null' . $debug . '}'; + } + } else { + + // Error ///////////////////////////////////////////////// + $jsend = '{"status":"error","message":"' . $data . '"' . $debug . '}'; + } + // Return //////////////////////////////////////////////// + return $jsend; + } + + ////////////////////////////////////////////////////////////////// + // Check Function Availability + ////////////////////////////////////////////////////////////////// + + public static function checkAccess() { + + return !file_exists( DATA . "/" . $_SESSION['user'] . '_acl.php' ); + } + + ////////////////////////////////////////////////////////////////// + // Check Path + ////////////////////////////////////////////////////////////////// + + public static function checkPath( $path ) { + + if( file_exists( DATA . "/" . $_SESSION['user'] . '_acl.php' ) ) { + + foreach ( getJSON( $_SESSION['user'] . '_acl.php' ) as $projects => $data ) { + + if ( strpos( $path, $data ) === 0) { + + return true; + } + } + } else { + + foreach( getJSON( 'projects.php' ) as $project => $data ) { + + if ( strpos( $path, $data['path'] ) === 0 ) { + + return true; + } + } + } + return false; + } + + + ////////////////////////////////////////////////////////////////// + // Check Function Availability + ////////////////////////////////////////////////////////////////// + + public static function isAvailable( $func ) { + + if ( ini_get( 'safe_mode' ) ) { + + return false; + } + $disabled = ini_get( 'disable_functions' ); + if ( $disabled ) { + + $disabled = explode( ',', $disabled ); + $disabled = array_map( 'trim', $disabled ); + return ! in_array( $func, $disabled ); + } + return true; + } + + ////////////////////////////////////////////////////////////////// + // Check If Path is absolute + ////////////////////////////////////////////////////////////////// + + public static function isAbsPath( $path ) { + + return( $path[0] === '/' || $path[1] === ':' ) ? true : false; + } + + ////////////////////////////////////////////////////////////////// + // Check If WIN based system + ////////////////////////////////////////////////////////////////// + + public static function isWINOS( ) { + + return( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ); + } +} + +////////////////////////////////////////////////////////////////// +// Wrapper for old method names +////////////////////////////////////////////////////////////////// + +function debug($message) { Common::debug($message); } +function i18n($key, $args = array()) { echo Common::i18n($key, $args); } +function get_i18n($key, $args = array()) { return Common::get_i18n($key, $args); } +function checkSession(){ Common::checkSession(); } +function getJSON($file,$namespace=""){ return Common::getJSON($file,$namespace); } +function saveJSON($file,$data,$namespace=""){ Common::saveJSON($file,$data,$namespace); } +function formatJSEND($status,$data=false){ return Common::formatJSEND($status,$data); } +function checkAccess() { return Common::checkAccess(); } +function checkPath($path) { return Common::checkPath($path); } +function isAvailable($func) { return Common::isAvailable($func); } +?> diff --git a/components/default_plugins.json b/components/default_plugins.json old mode 100644 new mode 100755