{"id":20631071,"url":"https://github.com/zsnout/radio","last_synced_at":"2026-04-20T15:31:12.491Z","repository":{"id":104247490,"uuid":"278875334","full_name":"zSnout/Radio","owner":"zSnout","description":"Radio is a JavaScript library that gives you the ability to transfer data between devices in a simple manner.","archived":false,"fork":false,"pushed_at":"2021-05-30T19:39:54.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-08T23:32:18.390Z","etag":null,"topics":["javascript","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zSnout.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-11T14:15:02.000Z","updated_at":"2021-08-13T13:50:38.000Z","dependencies_parsed_at":"2023-03-14T02:31:01.771Z","dependency_job_id":null,"html_url":"https://github.com/zSnout/Radio","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zSnout/Radio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zSnout%2FRadio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zSnout%2FRadio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zSnout%2FRadio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zSnout%2FRadio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zSnout","download_url":"https://codeload.github.com/zSnout/Radio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zSnout%2FRadio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32053163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T11:35:06.609Z","status":"ssl_error","status_checked_at":"2026-04-20T11:34:48.899Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","php"],"created_at":"2024-11-16T14:10:44.984Z","updated_at":"2026-04-20T15:31:12.456Z","avatar_url":"https://github.com/zSnout.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Table of Contents\n\n - [Setting Up](#setting-up)\n   - [zSnout Hosting](#zsnout-hosting)\n   - [Personal Hosting](#personal-hosting)\n - [The `Radio` Class](#the-radio-class)\n   - [`.send(message)`](#sendmessage)\n   - [`.getAll()`](#getall)\n   - [`.getNew()`](#getnew)\n   - [`.wait()`](#wait)\n - [Example](#example)\n - [Security](#security)\n   - [Password Encryption](#password-encryption)\n   - [Data Encryption](#data-encryption)\n   - [Get your Data](#get-your-data)\n\n# Setting Up\n\nTo set up Radio, you can either use zSnout Hosting or host Radio yourself.\n\n## zSnout Hosting\nTo use zSnout hosting, all you need to do is include the `main.js` file into your webpage.\n``` html\n\u003cscript src=\"https://zsnout.com/radio/main.js\"\u003e\u003c/script\u003e\n```\n\n## Personal Hosting\nIf you are a large business, you may want to host your own copy of Radio. Here's how.\n\n 1. Download a copy of the [`assets`](/assets/) folder. You can rename it if you want.\n 2. Make sure that your server has PHP and MySQL, and has the PHP [Sodium](https://php.net/manual/en/book.sodium.php) extension enabled.\n   - If your server is missing any of the above, just use zSnout Hosting.\n 3. In the [`main.php`](/assets/main.php) file on line 3, change the `$database` variable to the MySQL database you're using for Radio.\n 4. Run the following command on your MySQL server in the database stored in `$database`.\n ``` mysql\n CREATE TABLE `chats`.`radio` ( `id` INT NOT NULL AUTO_INCREMENT , `domain` TEXT NOT NULL DEFAULT '' , `stream` TEXT NOT NULL DEFAULT '' , `password` TEXT NOT NULL DEFAULT '' , `data` TEXT NOT NULL DEFAULT '[]' , PRIMARY KEY (`id`)) ENGINE = InnoDB;\n ```\n 5. In the [`main.php`](/assets/main.php) file on line 4, change the `$MAIN` variable to the superglobal you're retrieving from. zSnout uses GET requests, so we use `$_GET`. However, if you prefer POST requests, use `$_POST`, or any other superglobal like them.\n 6. In the [`main.js`](/assets/main.js) file on line 3, change the `return` value to the number of seconds before `.wait()` refreshes. Lower values will mean that you'll get a response sooner, but too low might overload your server.\n 7. In the [`main.js`](/assets/main.js) file on line 7, change the `return` value to the path to the PHP and JavaScript files.\n 8. Make sure to load `main.js` from your location, not ours.\n\n# The `Radio` Class\nThe `Radio` class is where all of the magic happens. It can take anywhere from one to four parameters.\n\nThe first parameter, `stream`, is the name of the stream to connect to. If a stream doesn't exist, it is created.\nNote that `stream`s are unique to your domain. For example, the stream `chat` on `example.com` is not the same as `chat` on `mywebsite.com`. Also note that streams differ for subdomains. Ex: `chat` on `example.com` is not the same as `chat` on `chat.example.com`.\nAlso note that `stream`s are stored in lowercase, so `zSnout` \"redirects\" to `zsnout`.\n\nThe second parameter, `password`, is the password of the stream to connect to/create. You can use `\"\"` for no password.\n\nThe third parameter, `callback`, is a function accepting one argument. If provided, it is called whenever a new message is found, with the message as the parameter.\n\nThe fourth parameter, `current`, is a function accepting one argument. If provided, it is called on each message already sent, in order of time sent, with the message as the parameter.\n\nYou can leave any of these except `stream` as `undefined` to skip it.\n\nOnce the `Radio` object is created, you can start sending and recieving messages.\n\n## `.send(message)`\nThe `.send()` method allows you to send a message across the stream. It does not return anything.\n\nNote that `.send()` can only send text, so to send an array or object, convert it to a JSON string first with `JSON.stringify()`.\n\n## `.getAll()`\nThe `.getAll()` method allows you to get all the messages in the stream. It will returns a `Promise` that will:\n - Resolve with an array containing all the messages sent if the request was successful, or\n - Reject if a JavaScript error occurred.\n\n## `.getNew()`\nThe `.getNew()` method is like the `.getAll()` method, but it only resolves with messages that have not been fetched before.\n\n## `.wait()`\nThe `.wait()` method checks every 5 seconds for new data.\n\nIt returns a `Promise` that will:\n - Resolve with an array containing the new data once new data is successfully found, or\n - Reject with the error if a JavaScript error occurred.\n\n# Example\nWe at zSnout have created an example of Radio publicly available at [radio.zsnout.com](https://radio.zsnout.com/) in the form of a chat website. It is entirely built on Radio.\n\n# Security\nzSnout's Radio team wants you to know that we care about your security, so here's how we keep your data safe and secure.\n\nWe store the content of Radio in a database containing five columns: `id`, `domain`, `stream`, `password`, and `data`.\nThree of these columns are unencrypted: `id`, `domain`, and `stream`. However, the other two are fully encrypted.\n\n## Password Encryption\nWe use [PHP](https://php.net/)'s [`password_hash()`](https://www.php.net/manual/en/function.password-hash.php) function with BCrypt to hash your password. Hashing is a one-way algorithm, so there's no way for us to know your password.\n\n## Data Encryption\nWe use PHP's [Sodium](https://www.php.net/manual/en/book.sodium.php) extension to encrypt the data of your stream. The data is encrypted with your plain text password as the key, which can't be derived from the other columns in the database. The only way to know your data correctly is to have the right password.\n\n## Get your Data\nIf you would like to view the internal data we store, go to\n``` html\nhttps://zsnout.com/radio/content?host=\u003cdomain\u003e\u0026stream=\u003cstream\u003e\u0026password=\u003cpassword\u003e\n```\n\nIt will either print:\n - `NOEXIST` if the stream does not exist,\n - `PASSWORD` if the stream exists but you have the wrong password, or\n - A JSON string containing:\n   - `id`: The ID of the row in the database.\n   - `domain`: The domain of the row.\n   - `stream`: The stream name.\n   - `password`: The stream's password as it's stored in the database.\n   - `data`: An array containing the stream's data as it's stored in the database.\n\nWe recommend that you view the source instead of the output, as the JSON is pretty-printed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzsnout%2Fradio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzsnout%2Fradio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzsnout%2Fradio/lists"}