From 1d1f46a9dfe677287092777d070256b73031dd00 Mon Sep 17 00:00:00 2001 From: xevidos Date: Mon, 19 Nov 2018 13:30:49 -0500 Subject: [PATCH] Removed placeholder code for admin, Added sharing, Changed Git links away from local server, Made get and search user functions global. --- .gitignore | 0 admin.php | 173 +----------- common.php | 86 +++++- components/editor/dialog.php | 6 +- components/editor/init.js | 4 +- components/filemanager/dialog_upload.php | 77 +++--- components/project/class.project.php | 91 ++++++- components/project/controller.php | 71 +++++ components/project/dialog.php | 6 +- components/project/init.js | 27 +- components/right_bar.json | 2 +- components/settings/class.settings.php | 67 +++++ components/update/class.update.php | 31 +-- components/update/update.php | 321 +++++++---------------- components/user/class.user.php | 113 +++----- components/user/controller.php | 2 +- 16 files changed, 529 insertions(+), 548 deletions(-) mode change 100644 => 100755 .gitignore diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/admin.php b/admin.php index cd4b854..d74d3ee 100755 --- a/admin.php +++ b/admin.php @@ -1,172 +1,3 @@ - - - - - - <?php echo htmlentities( $site_name ); ?> - Admin - ' ); - } else { - - echo( '' ); - } - } - - // Load Component CSS Files - foreach( $components as $component ) { - - if( file_exists( THEMES . "/". $theme . "/" . $component . "/screen.css" ) ) { - - echo( '' ); - } else { - - if( file_exists( "themes/default/" . $component . "/screen.css" ) ){ - - echo( '' ); - } else { - - if( file_exists( COMPONENTS . "/" . $component . "/screen.css" ) ){ - - echo( '' ); - } - } - } - } - - // Load Plugin CSS Files - /*foreach( $plugins as $plugin ) { - - if( file_exists( THEMES . "/". $theme . "/" . $plugin . "/screen.css" ) ) { - - echo( '' ); - } else { - - if( file_exists( "themes/default/" . $plugin . "/screen.css" ) ){ - - echo( '' ); - } else { - - if( file_exists( PLUGINS . "/" . $plugin . "/screen.css" ) ) { - - echo( '' ); - } - } - } - }*/ - ?> - - - - - - - - - - - - - - - - -
- - - - '); - } - } - - foreach( $plugins as $plugin ) { - - if( file_exists( PLUGINS . "/" . $plugin . "/init.js" ) ) { - - echo( '' ); - } - } - - */ - ?> - - \ No newline at end of file +//Silence is golden. +?> \ No newline at end of file diff --git a/common.php b/common.php index 4205de7..2a6968d 100755 --- a/common.php +++ b/common.php @@ -117,7 +117,7 @@ class Common { ////////////////////////////////////////////////////////////////// // Check access to a project ////////////////////////////////////////////////////////////////// - public static function check_project_access( $project_name, $project_path, $action ) { + public static function check_project_access( $project_path, $action ) { $sql = "SELECT * FROM `projects` WHERE `name`=? AND `path`=? AND ( `owner`=? OR `owner`='nobody' );"; $bind = "sss"; @@ -151,13 +151,20 @@ class Common { self::return( $return, $action ); } - public static function get_users( $return = "return" ) { + public static function get_users( $return = "return", $exclude_current = false ) { - $sql = "SELECT `username` FROM `users`;"; + $sql = "SELECT `username` FROM `users`"; $bind = ""; $bind_variables = array(); - $result = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error checking users." ) ); + if( $exclude_current ) { + + $sql .= " WHERE `username`!=?"; + $bind .= "s"; + array_push( $bind_variables, $_SESSION["user"] ); + } + + $result = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error checking users." ) ); $user_list = array(); foreach( $result as $row ) { @@ -220,6 +227,74 @@ class Common { session_start(); } + ////////////////////////////////////////////////////////////////// + // Search Users + ////////////////////////////////////////////////////////////////// + + public function search_users( $username, $return = "return", $exclude_current = false ) { + + $sql = "SELECT `username` FROM `users` WHERE `username` LIKE ?"; + $bind = "s"; + $bind_variables = array( "%{$username}%" ); + + if( $exclude_current ) { + + $sql .= " AND `username`!=?"; + $bind .= "s"; + array_push( $bind_variables, $_SESSION["user"] ); + } + + $result = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error selecting user information." ) ); + $user_list = array(); + + foreach( $result as $row ) { + + array_push( $user_list, $row["username"] ); + } + + if( mysqli_num_rows( $result ) > 0 ) { + + switch( $return ) { + + case( "exit" ): + + exit( formatJSEND( "success", $user_list ) ); + break; + + case( "json" ): + + $return = json_encode( $user_list ); + break; + + case( "return" ): + + $return = $user_list; + break; + } + } else { + + switch( $return ) { + + case( "exit" ): + + exit( formatJSEND( "error", "Error selecting user information." ) ); + break; + + case( "json" ): + + $return = formatJSEND( "error", "Error selecting user information." ); + break; + + case( "return" ): + + $return = null; + break; + } + } + + return( $return ); + } + ////////////////////////////////////////////////////////////////// // Start Sessions ////////////////////////////////////////////////////////////////// @@ -580,5 +655,6 @@ function checkAccess() { return Common::checkAccess(); } function checkPath($path) { return Common::checkPath($path); } function isAvailable($func) { return Common::isAvailable($func); } function logout() { return Common::logout(); } -function get_users() { return Common::get_users(); } +function get_users( $return = "return", $exclude_current = false ) { return Common::get_users( $return, $exclude_current ); } +function search_users( $username, $return = "return", $exclude_current = false ) { return Common::search_users( $username, $return, $exclude_current ); } ?> diff --git a/components/editor/dialog.php b/components/editor/dialog.php index 7dbe71d..cede631 100755 --- a/components/editor/dialog.php +++ b/components/editor/dialog.php @@ -28,12 +28,12 @@ switch($_GET['action']){ $type = $_GET['type']; ?> - + - + @@ -52,7 +52,7 @@ switch($_GET['action']){ diff --git a/components/project/class.project.php b/components/project/class.project.php index e97cdfb..bdb5fed 100755 --- a/components/project/class.project.php +++ b/components/project/class.project.php @@ -23,6 +23,7 @@ class Project extends Common { public $assigned = false; public $command_exec = ''; public $public_project = false; + public $user = ''; ////////////////////////////////////////////////////////////////// // METHODS @@ -61,6 +62,45 @@ class Project extends Common { return( $return ); } + public function add_user() { + + $sql = "SELECT `access` FROM `projects` WHERE `path`=? AND `owner`=?"; + $bind = "ss"; + $bind_variables = array( $this->path, $_SESSION["user"] ); + $result = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error fetching projects." ) ); + + if( mysqli_num_rows( $result ) > 0 ) { + + $access = json_decode( mysqli_fetch_assoc( $result )["access"] ); + + if( is_array( $access ) ) { + + if( ! in_array( $this->user, $access ) ) { + + array_push( $access, $this->user ); + } + } else { + + $access = array( + $this->user + ); + } + + $access = json_encode( $access ); + $sql = "UPDATE `projects` SET `access`=? WHERE `path`=? AND `owner`=?;"; + $bind = "sss"; + $bind_variables = array( $access, $this->path, $_SESSION["user"] ); + $return = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error setting access for project." ) ); + if( sql::check_sql_error( $return ) ) { + + echo( formatJSEND( "success", "Successfully added {$this->user}." ) ); + } else { + + echo $return; + } + } + } + public function check_owner( $path = null, $exclude_public = false ) { if( $path === null ) { @@ -162,9 +202,9 @@ class Project extends Common { public function get_projects() { - $sql = "SELECT * FROM `projects` WHERE `owner`=? OR `owner`='nobody' ORDER BY `name`;"; - $bind = "s"; - $bind_variables = array( $_SESSION["user"] ); + $sql = "SELECT * FROM `projects` WHERE `owner`=? OR `owner`='nobody' OR `access` LIKE ? ORDER BY `name`;"; + $bind = "ss"; + $bind_variables = array( $_SESSION["user"], '%"' . $_SESSION["user"] . '"%' ); $return = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error fetching projects." ) ); if( mysqli_num_rows( $return ) > 0 ) { @@ -178,6 +218,45 @@ class Project extends Common { return( $return ); } + public function remove_user() { + + $sql = "SELECT `access` FROM `projects` WHERE `path`=? AND `owner`=?"; + $bind = "ss"; + $bind_variables = array( $this->path, $_SESSION["user"] ); + $result = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error fetching projects." ) ); + + if( mysqli_num_rows( $result ) > 0 ) { + + $access = json_decode( mysqli_fetch_assoc( $result )["access"] ); + + if( is_array( $access ) ) { + + $key = array_search( $this->user, $access ); + + if ( $key !== false ) { + + unset( $access[$key] ); + } else { + + echo( formatJSEND( "error", "{$this->user} is not in the access list." ) ); + } + } + + $access = json_encode( $access ); + $sql = "UPDATE `projects` SET `access`=? WHERE `path`=? AND `owner`=?;"; + $bind = "sss"; + $bind_variables = array( $access, $this->path, $_SESSION["user"] ); + $return = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error setting access for project." ) ); + if( sql::check_sql_error( $return ) ) { + + echo( formatJSEND( "success", "Successfully removed {$this->user}." ) ); + } else { + + echo $return; + } + } + } + public function rename_project( $old_name, $new_name, $path ) { $sql = "SELECT * FROM `projects` WHERE `name`=? AND `path`=? AND ( `owner`=? OR `owner`='nobody' );"; @@ -243,9 +322,9 @@ class Project extends Common { public function Open() { - $sql = "SELECT * FROM `projects` WHERE `path`=? AND ( `owner`=? OR `owner`='nobody' );"; - $bind = "ss"; - $bind_variables = array( $this->path, $_SESSION["user"] ); + $sql = "SELECT * FROM `projects` WHERE `path`=? AND ( `owner`=? OR `owner`='nobody' OR `access` LIKE ? );"; + $bind = "sss"; + $bind_variables = array( $this->path, $_SESSION["user"], '%"' . $_SESSION["user"] . '"%' ); $return = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error fetching projects." ) ); if( mysqli_num_rows( $return ) > 0 ) { diff --git a/components/project/controller.php b/components/project/controller.php index 491f043..349e9d8 100755 --- a/components/project/controller.php +++ b/components/project/controller.php @@ -18,6 +18,42 @@ checkSession(); $Project = new Project(); +if( $_GET['action'] == 'add_user' ) { + + $invalid_users = array( + "", + "null", + "undefined" + ); + + if( ! in_array( $_GET['username'], $invalid_users ) ) { + + $Project->user = $_GET['username']; + } else { + + echo formatJSEND( "error", "No username set." ); + return; + } + + if( $_GET['project_path'] != '' ) { + + $Project->path = $_GET['project_path']; + } else { + + echo formatJSEND( "error", "No project path set." ); + return; + } + + if( $Project->check_owner( $_GET["project_path"], true ) ) { + + $Project->add_user(); + } else { + + echo formatJSEND( "error", "You can not manage this project." ); + } +} + + ////////////////////////////////////////////////////////////////// // Create Project ////////////////////////////////////////////////////////////////// @@ -150,6 +186,41 @@ if( $_GET['action'] == 'open' ) { $Project->Open(); } +if( $_GET['action'] == 'remove_user' ) { + + $invalid = array( + "", + "null", + "undefined" + ); + + if( ! in_array( $_GET['username'], $invalid ) ) { + + $Project->user = $_GET['username']; + } else { + + echo formatJSEND( "error", "No username set." ); + return; + } + + if( ! in_array( $_GET['project_path'], $invalid ) ) { + + $Project->path = $_GET['project_path']; + } else { + + echo formatJSEND( "error", "No project path set." ); + return; + } + + if( $Project->check_owner( $_GET["project_path"], true ) ) { + + $Project->remove_user(); + } else { + + echo formatJSEND( "error", "You can not manage this project." ); + } +} + ////////////////////////////////////////////////////////////////// // Rename Project ////////////////////////////////////////////////////////////////// diff --git a/components/project/dialog.php b/components/project/dialog.php index 1b019c1..c7de734 100755 --- a/components/project/dialog.php +++ b/components/project/dialog.php @@ -204,13 +204,13 @@ switch( $_GET['action'] ) { $path = $_GET['path']; $project = $Project->get_project( $path ); $access = json_decode( $project["access"], true ); - $users = get_users(); + $users = get_users( "return", true ); ?>
- -   + "codiad.editor.fileManagerTrigger", + "value" => "false", + ), + array( + "name" => "codiad.editor.fontSize", + "value" => "14px", + ), + array( + "name" => "codiad.editor.highlightLine", + "value" => "true", + ), + array( + "name" => "codiad.editor.indentGuides", + "value" => "true", + ), + array( + "name" => "codiad.editor.overScroll", + "value" => "0.5", + ), + array( + "name" => "codiad.editor.persistentModal", + "value" => "true", + ), + array( + "name" => "codiad.editor.printMargin", + "value" => "true", + ), + array( + "name" => "codiad.editor.printMarginColumn", + "value" => "80", + ), + array( + "name" => "codiad.editor.rightSidebarTrigger", + "value" => "false", + ), + array( + "name" => "codiad.editor.softTabs", + "value" => "false", + ), + array( + "name" => "codiad.editor.tabSize", + "value" => "4", + ), + array( + "name" => "codiad.editor.theme", + "value" => "twilight", + ), + array( + "name" => "codiad.editor.wrapMode", + "value" => "false", + ), + array( + "name" => "codiad.settings.autosave", + "value" => "true", + ), + array( + "name" => "codiad.settings.plugin.sync", + "value" => "true", + ), + array( + "name" => "codiad.settings.plugin.sync", + "value" => "true", + ), + ); + ////////////////////////////////////////////////////////////////// // PROPERTIES ////////////////////////////////////////////////////////////////// diff --git a/components/update/class.update.php b/components/update/class.update.php index 6f517b6..b598eb8 100755 --- a/components/update/class.update.php +++ b/components/update/class.update.php @@ -39,10 +39,10 @@ class Update { public function __construct() { ini_set("user_agent", "Codiad"); - $this->archive = "https://gitlab.telaaedifex.com/xevidos/codiad/-/archive/master/codiad-master.zip"; - $this->commits = "https://gitlab.telaaedifex.com/api/v4/projects/3/repository/commits/"; - $this->tags = "https://gitlab.telaaedifex.com/api/v4/projects/3/repository/tags/"; - $this->update_file = "https://gitlab.telaaedifex.com/xevidos/codiad/raw/master/components/update/update.php"; + $this->archive = "https://gitlab.com/xevidos/codiad/-/archive/master/codiad-master.zip"; + $this->commits = "https://gitlab.com/api/v4/projects/8466613/repository/commits/"; + $this->tags = "https://gitlab.com/api/v4/projects/8466613/repository/tags/"; + $this->update_file = "https://gitlab.com/xevidos/codiad/raw/master/components/update/update.php"; $this->protocol = $this->CheckProtocol(); } @@ -183,16 +183,15 @@ class Update { public function getLocalVersion(){ - return getJSON('version.php');; + return getJSON( 'version.php' ); } ////////////////////////////////////////////////////////////////// // Get Remote Version ////////////////////////////////////////////////////////////////// - public function getRemoteVersion($action="check", $localversion = "") { + public function getRemoteVersion( $action="check", $localversion = "" ) { - //$remoteurl = Common::getConstant('UPDATEURL', $this->remote); if ( $this->protocol === "none" ) { return; @@ -203,15 +202,15 @@ class Update { case( "curl" ): $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $this->tags); + curl_setopt( $curl, CURLOPT_URL, $this->tags ); //curl_setopt($curl, CURLOPT_POSTFIELDS, ""); - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13'); - $content = curl_exec($curl); - curl_close($curl); + curl_setopt( $curl, CURLOPT_HEADER, 0 ); + curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 ); + curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false ); + curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, 0 ); + curl_setopt( $curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13' ); + $content = curl_exec( $curl ); + curl_close( $curl ); $response = json_decode( $content, true ); //Return latest release @@ -222,7 +221,5 @@ class Update { break; } - - //return( json_decode( file_get_contents( $remoteurl ), true ) ); } } \ No newline at end of file diff --git a/components/update/update.php b/components/update/update.php index 7902ea3..865def3 100755 --- a/components/update/update.php +++ b/components/update/update.php @@ -38,17 +38,17 @@ class updater { public $archive = ""; public $path = ""; public $protocol = ""; - + public $update = null; function __construct() { - $update = new Update(); - $this->archive = $update->archive; + $this->update = new Update(); + /*$this->archive = $update->archive; $this->path = Common::getConstant('BASE_PATH'); $this->protocol = $this->check_protocol(); //Trigger update - $this->update(); + $this->update();*/ } function check_protocol() { @@ -68,6 +68,21 @@ class updater { } } + function check_update() { + + $response = $this->update->getRemoteVersion(); + $local_version = $this->update::VERSION; + $remote_version = $response["name"]; + $return = "false"; + + if( $local_version < $remote_version ) { + + $return = "true"; + } + + return( $return ); + } + function copyr( $source, $dest ) { // Check for symlinks if (is_link($source)) { @@ -158,7 +173,7 @@ class updater { } function remove_directory( $path ) { - + $files = glob($path . '/*'); foreach ($files as $file) { @@ -246,6 +261,21 @@ class updater { } } +if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) { + + $updater = new updater(); + $action = $_GET["action"]; + + switch( $action ) { + + case( "check_update" ): + + echo $updater->check_update(); + break; + } + + exit(); +} ?> @@ -271,8 +301,6 @@ class updater { color: #666; display: block; - //float: left; - //font-size: 15px; font-weight: 500; margin: 10px; text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6); @@ -287,230 +315,77 @@ class updater { } +

- Telaaedifex Codiad Updater + Tela Codiad Updater

-
- Starting Update ... +
+

- - -archive = $update->archive; - $this->path = Common::getConstant('BASE_PATH'); - $this->protocol = $this->check_protocol(); - - //Trigger update - $this->update(); - - //Delete File - unlink( __FILE__ ); - } - - function check_protocol() { - - if( extension_loaded( 'curl' ) ) { - - //Curl is loaded - return "curl"; - } elseif( ini_get('allow_url_fopen') ) { - - //Remote get file is enabled - return "fopen"; - } else { - - //None are enabled exit. - return "none"; - } - } - - ////////////////////////////////////////////////////////////////// - // Download latest archive - ////////////////////////////////////////////////////////////////// - - function download() { - - switch( $this->protocol ) { - - case( "curl" ): - - $filepath = $this->path . "/update.zip"; - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $this->archive); - //curl_setopt($curl, CURLOPT_POSTFIELDS, ""); - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13'); - $raw_file_data = curl_exec($curl); - curl_close($curl); - - file_put_contents( $filepath, $raw_file_data ); - return ( filesize( $filepath ) > 0 ) ? true : false; - break; - - case( "fopen" ): - - break; - } - } - - function extract() { - - if ( ! extension_loaded( 'zip' ) ) { - - echo ""; - return false; - } - - $zip = new ZipArchive; - if ( $zip->open( $this->path . "/update.zip", ZipArchive::OVERWRITE ) === TRUE ) { - - $zip->extractTo( $this->path ); - $zip->close(); - - return true; - } else { - - return false; - } - } - - function update() { - - echo ""; - if ( ! $this->download() ) { - - echo ""; - } - - echo ""; - if ( ! $this->extract() ) { - - echo ""; - } - - echo ""; - try { - - exec( "cp -a " ); - } catch ( exception $e ) { - - echo ""; - return; - } - - echo ""; - exec( "rm -rf " . $this->path . "/update.zip;rm -rf " . $this->path . "/codiad-master" ); - } -} - -?> - - - - - Codiad Update - - - -

- Telaaedifex Codiad Updater -

-
- Starting Update ... -
- \ No newline at end of file diff --git a/components/user/class.user.php b/components/user/class.user.php index e347003..971cc96 100755 --- a/components/user/class.user.php +++ b/components/user/class.user.php @@ -6,6 +6,8 @@ * [root]/license.txt for more. This information must remain intact. */ +require_once( "../settings/class.settings.php" ); + class User { ////////////////////////////////////////////////////////////////// @@ -46,6 +48,7 @@ class User { if( sql::check_sql_error( $return ) ) { + $this->set_default_options(); echo formatJSEND( "success", array( "username" => $this->username ) ); } else { @@ -53,6 +56,33 @@ class User { } } + public function delete_user() { + + $sql = "DELETE FROM `user_options` WHERE `username`=?;"; + $bind = "s"; + $bind_variables = array( $this->username ); + $return = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error deleting user information." ) ); + + if( sql::check_sql_error( $return ) ) { + + $sql = "DELETE FROM `users` WHERE `username`=?;"; + $bind = "s"; + $bind_variables = array( $this->username ); + $return = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error deleting user information." ) ); + + if( sql::check_sql_error( $return ) ) { + + echo formatJSEND( "success", null ); + } else { + + echo $return; + } + } else { + + echo $return; + } + } + public function get_user( $username ) { $sql = "SELECT * FROM `users` WHERE `username`=?"; @@ -78,6 +108,16 @@ class User { return( $return ); } + + public function set_default_options() { + + $Settings = new Settings(); + $Settings->username = $this->username; + foreach( Settings::DEFAULT_OPTIONS as $id => $option ) { + + $Settings->update_option( $option["name"], $option["value"], true ); + } + } ////////////////////////////////////////////////////////////////// // Authenticate @@ -252,18 +292,7 @@ class User { public function Delete() { - $sql = "DELETE FROM `users` WHERE `username`=?;"; - $bind = "ss"; - $bind_variables = array( $this->username, $this->password ); - $return = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error deleting user information." ) ); - - if( sql::check_sql_error( $return ) ) { - - echo formatJSEND( "success", null ); - } else { - - echo $return; - } + $this->delete_user(); } ////////////////////////////////////////////////////////////////// @@ -315,66 +344,6 @@ class User { } } - ////////////////////////////////////////////////////////////////// - // Search Users - ////////////////////////////////////////////////////////////////// - - public function search_users( $username, $return = "return" ) { - - $sql = "SELECT `username` FROM `users` WHERE `username` LIKE ?;"; - $bind = "s"; - $bind_variables = array( "%{$username}%" ); - $result = sql::sql( $sql, $bind, $bind_variables, formatJSEND( "error", "Error selecting user information." ) ); - $user_list = array(); - - foreach( $result as $row ) { - - array_push( $user_list, $row["username"] ); - } - - if( mysqli_num_rows( $result ) > 0 ) { - - switch( $return ) { - - case( "exit" ): - - exit( formatJSEND( "success", $user_list ) ); - break; - - case( "json" ): - - $return = json_encode( $user_list ); - break; - - case( "return" ): - - $return = $user_list; - break; - } - } else { - - switch( $return ) { - - case( "exit" ): - - exit( formatJSEND( "error", "Error selecting user information." ) ); - break; - - case( "json" ): - - $return = formatJSEND( "error", "Error selecting user information." ); - break; - - case( "return" ): - - $return = null; - break; - } - } - - return( $return ); - } - ////////////////////////////////////////////////////////////////// // Verify Account Exists ////////////////////////////////////////////////////////////////// diff --git a/components/user/controller.php b/components/user/controller.php index 9c214c9..c03bfdc 100755 --- a/components/user/controller.php +++ b/components/user/controller.php @@ -129,7 +129,7 @@ if ( $_GET['action'] == 'search_users' ) { die( formatJSEND( "error", "Missing search term" ) ); } - $User->search_users( $_GET['search_term'], "exit" ); + search_users( $_GET['search_term'], "exit", true ); } //////////////////////////////////////////////////////////////////