<commit_before><?php
    /**
     * Gets the pads
     *
     * @return Array the pads list
     */
    function get_pads () {
        //TODO: move API key in config
        $url = "http://pad.wolfplex.be/api/1.2.1/listAllPads?apikey=<KEY>";
        $api_reply = json_decode(file_get_contents($url));
        if ($api_reply->code == 0) {
            return $api_reply->data->padIDs;
        }
        throw new Exception("API fatal error: $api_reply->message");
    }

    $format = array_key_exists('format', $_GET) ? $_GET['format'] : '';
    switch ($format) {
        case "":
        case "json":
            echo json_encode(get_pads());
            break;

        case "raw":
            echo implode("\n", get_pads());
            break;

        case "txt":
            header("Content-Type: text/plain");
            foreach (get_pads() as $pad) {
                echo "* $pad\n";
            }
            break;

        default:
            die("Unknown format: $format");
    }
?><commit_msg>Store the Etherpad API key as a secret.<commit_after><?php
    require '../_includes/SecurityData.php';

    /**
     * Gets the pads
     *
     * @return Array the pads list
     */
    function get_pads () {
        $key = SecurityData::getSecret('etherpad.api.key');
        $url = "http://pad.wolfplex.be/api/1.2.1/listAllPads?apikey=" . $key;
        $api_reply = json_decode(file_get_contents($url));
        if ($api_reply->code == 0) {
            return $api_reply->data->padIDs;
        }
        throw new Exception("API fatal error: $api_reply->message");
    }

    $format = array_key_exists('format', $_GET) ? $_GET['format'] : '';
    switch ($format) {
        case "":
        case "json":
            echo json_encode(get_pads());
            break;

        case "raw":
            echo implode("\n", get_pads());
            break;

        case "txt":
            header("Content-Type: text/plain");
            foreach (get_pads() as $pad) {
                echo "* $pad\n";
            }
            break;

        default:
            die("Unknown format: $format");
    }
?>
{'fraction_non_alphanumeric': 0.155049786628734, 'fraction_numerical': 0.003793266951161688, 'mean_word_length': 1.6947637292464879, 'pattern_counts': {'":': 8, '<': 6, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5124645', 'n_tokens_mistral': 655, 'n_tokens_neox': 636, 'n_words': 136}