diff --git a/ajaxchat.php b/ajaxchat.php index 3ddfd2d..5a8b688 100644 --- a/ajaxchat.php +++ b/ajaxchat.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + define('AJAX_CHAT_PATH', __DIR__); define('AJAX_CHAT_DEBUG', is_file(AJAX_CHAT_PATH . '/.debug')); @@ -20,17 +22,4 @@ if(AJAX_CHAT_DEBUG) { } // Include Class libraries: -require_once AJAX_CHAT_PATH . '/src/AJAXChat.php'; -require_once AJAX_CHAT_PATH . '/src/AJAXChatDataBase.php'; -require_once AJAX_CHAT_PATH . '/src/AJAXChatMySQLiDataBase.php'; -require_once AJAX_CHAT_PATH . '/src/AJAXChatMySQLiQuery.php'; -require_once AJAX_CHAT_PATH . '/src/AJAXChatEncoding.php'; -require_once AJAX_CHAT_PATH . '/src/AJAXChatString.php'; -require_once AJAX_CHAT_PATH . '/src/AJAXChatFileSystem.php'; -require_once AJAX_CHAT_PATH . '/src/AJAXChatHTTPHeader.php'; -require_once AJAX_CHAT_PATH . '/src/AJAXChatLanguage.php'; -require_once AJAX_CHAT_PATH . '/src/AJAXChatTemplate.php'; -require_once AJAX_CHAT_PATH . '/src/SockChatAuth.php'; -require_once AJAX_CHAT_PATH . '/src/CustomAJAXChat.php'; -require_once AJAX_CHAT_PATH . '/src/CustomAJAXChatShoutBox.php'; -require_once AJAX_CHAT_PATH . '/src/CustomAJAXChatInterface.php'; +require_once AJAX_CHAT_PATH . '/vendor/autoload.php'; diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..fb3d28d --- /dev/null +++ b/composer.json @@ -0,0 +1,10 @@ +{ + "autoload": { + "psr-4": { + "AJAXChat\\": "src" + } + }, + "require": { + "flashii/apii": "^0.2" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..2b9931b --- /dev/null +++ b/composer.lock @@ -0,0 +1,56 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "1eb898418ab7dcf8d2a4021ae3915e34", + "packages": [ + { + "name": "flashii/apii", + "version": "v0.2.1", + "source": { + "type": "git", + "url": "https://patchii.net/flashii/apii-php.git", + "reference": "6a93d31375dd7e75ff9264f3024f2208ce602f49" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpstan/phpstan": "^1.12", + "phpunit/phpunit": "^10.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Flashii\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "bsd-3-clause-clear" + ], + "authors": [ + { + "name": "flashwave", + "email": "packagist@flash.moe", + "homepage": "https://flash.moe", + "role": "mom" + } + ], + "description": "Client library for the Flashii.net API.", + "homepage": "https://api.flashii.net", + "time": "2024-11-16T16:03:42+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/public/index.php b/public/index.php index 6eab68a..dc0c2f0 100644 --- a/public/index.php +++ b/public/index.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + if(!empty($_GET['common'])) { $domain = (strpos($_SERVER['HTTP_HOST'], 'flashii.net') ? 'flashii' : 'edgii'); $commonUrl = 'https://futami.' . $domain . '.net/common.json'; @@ -155,4 +157,4 @@ if(!empty($_GET['common'])) { require_once __DIR__ . '/../ajaxchat.php'; // Initialize the chat: -$ajaxChat = new CustomAJAXChat(); +$ajaxChat = new CustomAJAXChat; diff --git a/src/AJAXChat.php b/src/AJAXChat.php index d51fb95..2306cb8 100644 --- a/src/AJAXChat.php +++ b/src/AJAXChat.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + // Ajax Chat backend logic: class AJAXChat { diff --git a/src/AJAXChatDataBase.php b/src/AJAXChatDataBase.php index 8946948..9be678a 100644 --- a/src/AJAXChatDataBase.php +++ b/src/AJAXChatDataBase.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + // Class to initialize the DataBase connection: class AJAXChatDataBase { diff --git a/src/AJAXChatMySQLiDataBase.php b/src/AJAXChatDataBaseMySQLi.php similarity index 98% rename from src/AJAXChatMySQLiDataBase.php rename to src/AJAXChatDataBaseMySQLi.php index 6c9a031..0491bc9 100644 --- a/src/AJAXChatMySQLiDataBase.php +++ b/src/AJAXChatDataBaseMySQLi.php @@ -7,6 +7,10 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + +use mysqli; + // Class to initialize the MySQL DataBase connection: class AJAXChatDataBaseMySQLi { diff --git a/src/AJAXChatEncoding.php b/src/AJAXChatEncoding.php index 6194139..ec59fc0 100644 --- a/src/AJAXChatEncoding.php +++ b/src/AJAXChatEncoding.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + // Class to provide static encoding methods class AJAXChatEncoding { diff --git a/src/AJAXChatFileSystem.php b/src/AJAXChatFileSystem.php index cd267cb..c5ad869 100644 --- a/src/AJAXChatFileSystem.php +++ b/src/AJAXChatFileSystem.php @@ -7,9 +7,10 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + // Class to provide methods for file system access: class AJAXChatFileSystem { - public static function getFileContents($file) { if(function_exists('file_get_contents')) { return file_get_contents($file); @@ -17,5 +18,4 @@ class AJAXChatFileSystem { return(implode('', file($file))); } } - } diff --git a/src/AJAXChatHTTPHeader.php b/src/AJAXChatHTTPHeader.php index 03c515c..3815280 100644 --- a/src/AJAXChatHTTPHeader.php +++ b/src/AJAXChatHTTPHeader.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + // Class to manage HTTP header class AJAXChatHTTPHeader { diff --git a/src/AJAXChatLanguage.php b/src/AJAXChatLanguage.php index deb65f6..1be9bab 100644 --- a/src/AJAXChatLanguage.php +++ b/src/AJAXChatLanguage.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + class AJAXChatLanguage { private $_regExpAcceptLangCode; diff --git a/src/AJAXChatMySQLiQuery.php b/src/AJAXChatMySQLiQuery.php index 7a7e0cd..a66d41d 100644 --- a/src/AJAXChatMySQLiQuery.php +++ b/src/AJAXChatMySQLiQuery.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + // Class to perform SQL (MySQLi) queries: class AJAXChatMySQLiQuery { diff --git a/src/AJAXChatString.php b/src/AJAXChatString.php index e3d0e8d..15aa25d 100644 --- a/src/AJAXChatString.php +++ b/src/AJAXChatString.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + // Class to provide multibyte enabled string methods class AJAXChatString { diff --git a/src/AJAXChatTemplate.php b/src/AJAXChatTemplate.php index 1aa05f0..047b46f 100644 --- a/src/AJAXChatTemplate.php +++ b/src/AJAXChatTemplate.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + // Class to handle HTML templates class AJAXChatTemplate { diff --git a/src/CustomAJAXChat.php b/src/CustomAJAXChat.php index 2493b09..d9e2e6f 100644 --- a/src/CustomAJAXChat.php +++ b/src/CustomAJAXChat.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + class CustomAJAXChat extends AJAXChat { // Returns an associative array containing userName, userID and userRole diff --git a/src/CustomAJAXChatInterface.php b/src/CustomAJAXChatInterface.php index c957f9d..3d5b894 100644 --- a/src/CustomAJAXChatInterface.php +++ b/src/CustomAJAXChatInterface.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + class CustomAJAXChatInterface extends CustomAJAXChat { function initialize() { diff --git a/src/CustomAJAXChatShoutBox.php b/src/CustomAJAXChatShoutBox.php index ede212a..dfefbb3 100644 --- a/src/CustomAJAXChatShoutBox.php +++ b/src/CustomAJAXChatShoutBox.php @@ -7,6 +7,8 @@ * @link https://blueimp.net/ajax/ */ +namespace AJAXChat; + class CustomAJAXChatShoutBox extends CustomAJAXChat { function initialize() { diff --git a/src/SockChatAuth.php b/src/SockChatAuth.php index 5aac211..233d1c7 100644 --- a/src/SockChatAuth.php +++ b/src/SockChatAuth.php @@ -1,4 +1,6 @@