" . PHP_EOL . "" . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . $title . "" . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL; $post = " " . PHP_EOL . "" . PHP_EOL; $html5 = $pre . $html_data . $post; return $html5; } /* * Writes HTML table with the following info: * Token + shortened pubkey | Name | Description | Users | View Links(?) | Join URL */ function get_table_html($info_arrays) { // $jl = "http://116.203.217.101/feels?public_key=2054fa3271f27ec9e55492c85d022f9582cb4aa2f457e4b885147fb913b9c131"; // $img_tag = get_qr_img_tag_from_join_url($jl); $table_lines = array(); foreach($info_arrays as $id => $content) { /* * $id is "room token+shortened_pubkey", e.g. "example+09af" * Each $content looks like this: * $info_array = array( * "name" => "Name of the room", * "language" => "🇩🇪", * "description" => "Some text that describes the community", * "active_users" => 1234, * "preview_link" => "https://example.com/r/example", * "join_link" => "https://example.com/example?public_key=[64_hex_chars]" * ); */ $exploded = explode("/", $content["join_link"]); // https: + "" + 1.2.3.4:56789 + token?public_key=0123456789abcdef $server_url = $exploded[0] . "//" . $exploded[2]; // extract server_url $token = explode("?", $exploded[3])[0]; // extract token $line = " " . PHP_EOL . " " . $id . "" . PHP_EOL . " " . $content["language"] . "" . PHP_EOL . " " . $content["name"] . "" . PHP_EOL . " " . $content["description"] . "" . PHP_EOL . " " . $content["active_users"] . "" . PHP_EOL . " " . $content["preview_link"] . "" . PHP_EOL . // " " . PHP_EOL; " " . $content["join_link"] . "" . PHP_EOL . " " . PHP_EOL; $table_lines[] = $line; } // prefix $prefix = "

Session Communities

" . PHP_EOL . "" . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . // " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL; // suffix $suffix = "
IdentifierLNameDescriptionUsersPreviewQRJoin URL
" . PHP_EOL . "" . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . "
" . count($table_lines) . " unique Session Communities on " . count_servers($info_arrays) . " servers have been found.
Last checked X minutes ago.
" . PHP_EOL; // concatenate html $html = $prefix; foreach($table_lines as $line) { $html = $html . $line; } $html = $html . $suffix; return $html; } function get_qr_img_tag_from_join_url($join_url) { $data = get_base64_qr_code_from_join_url($join_url); $mime = "image/png"; $src = "data: " . $mime . ";base64," . $data; $result = ""; // echo($result . PHP_EOL); return $result; } function get_base64_qr_code_from_join_url($join_url) { // https://developers.google.com/chart/infographics/docs/qr_codes $data = urlencode($join_url); $size = "512x512"; //$error_correction_level = ""; // "chld=" L = 7%, M = 15%, Q = 25%, H = 30% $api_url = "https://chart.googleapis.com/chart?cht=qr" . "&chs=" . $size . "&chl=" . $data; $img_base64 = base64_encode(file_get_contents($api_url)); // echo($img_base64 . PHP_EOL); return $img_base64; } ?>