<commit_before><?php

/**
 * This file supplies a Memcached store backend for OpenID servers and
 * consumers.
 *
 * PHP versions 4 and 5
 *
 * LICENSE: See the COPYING file included in this distribution.
 *
 * @package OpenID
 * @author JanRain, Inc. <<EMAIL>>
 * @copyright 2005 Janrain, Inc.
 * @license http://www.gnu.org/copyleft/lesser.html LGPL
 *
 */

require('Interface.php');

function Net_OpenID_mkstemp($dir) {
    foreach (range(0, 4) as $i) {
        $name = tempnam($dir, "php_openid_filestore_");
        $fd = fopen($name, 'x+', 0600);

        if ($fd === false) {
            return false;
        } else {
            return array($fd, $name);
        }
    }
    return false;
}

function Net_OpenID_mkdtemp($dir) {
    foreach (range(0, 4) as $i) {
        $name = realpath($dir . DIRECTORY_SEPARATOR . strval(getmypid()) .
                         "-" . rand(1, time()));
        if (!mkdir($name, 0700)) {
            return false;
        } else {
            return $name;
        }
    }
    return false;
}

function Net_OpenID_listdir($dir) {
    $handle = opendir($dir);
    $files = array();
    while (false !== ($filename = readdir($handle))) {
        $files[] = $filename;
    }
    return $files;
}

$letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$digits = "0123456789";

$_Net_OpenID_filename_allowed = $letters . $digits . ".";

function _isFilenameSafe($char) {
    global $_Net_OpenID_filename_allowed;
    return (strpos($_Net_OpenID_filename_allowed, $hcar) !== false);
}

function _safe64($str) {
    $h64 = Net_OpenID_toBase64(Net_OpenID_CryptUtil::sha1($str));
    $h64 = str_replace('+', '_', $h64);
    $h64 = str_replace('/', '.', $h64);
    $h64 = str_replace('=', '', $h64);
    return $h64;
}

function _filenameEscape($str) {
    $filename_chunks = array();
    for ($i = 0; $i < strlen($str); $i++) {
        $c = $str[$i];
        if (_isFilenameSafe($c)) {
            $filename_chunks[] = $c;
        } else {
            $filename_chunks[] = sprintf("_%02X", ord(c));
        }
    }
    return implode("", $filename_chunks);
}

/**
 * Attempt to remove a file, returning whether the file existed at the<commit_msg>[project @ Fixed allowed characters for filename]<commit_after><?php

/**
 * This file supplies a Memcached store backend for OpenID servers and
 * consumers.
 *
 * PHP versions 4 and 5
 *
 * LICENSE: See the COPYING file included in this distribution.
 *
 * @package OpenID
 * @author JanRain, Inc. <<EMAIL>>
 * @copyright 2005 Janrain, Inc.
 * @license http://www.gnu.org/copyleft/lesser.html LGPL
 *
 */

require('Interface.php');

function Net_OpenID_mkstemp($dir) {
    foreach (range(0, 4) as $i) {
        $name = tempnam($dir, "php_openid_filestore_");
        $fd = fopen($name, 'x+', 0600);

        if ($fd === false) {
            return false;
        } else {
            return array($fd, $name);
        }
    }
    return false;
}

function Net_OpenID_mkdtemp($dir) {
    foreach (range(0, 4) as $i) {
        $name = realpath($dir . DIRECTORY_SEPARATOR . strval(getmypid()) .
                         "-" . rand(1, time()));
        if (!mkdir($name, 0700)) {
            return false;
        } else {
            return $name;
        }
    }
    return false;
}

function Net_OpenID_listdir($dir) {
    $handle = opendir($dir);
    $files = array();
    while (false !== ($filename = readdir($handle))) {
        $files[] = $filename;
    }
    return $files;
}

function _isFilenameSafe($char) {
    $letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $digits = "0123456789";
    $_Net_OpenID_filename_allowed = $letters . $digits . ".";
    return (strpos($_Net_OpenID_filename_allowed, $char) !== false);
}

function _safe64($str) {
    $h64 = Net_OpenID_toBase64(Net_OpenID_CryptUtil::sha1($str));
    $h64 = str_replace('+', '_', $h64);
    $h64 = str_replace('/', '.', $h64);
    $h64 = str_replace('=', '', $h64);
    return $h64;
}

function _filenameEscape($str) {
    $filename_chunks = array();
    for ($i = 0; $i < strlen($str); $i++) {
        $c = $str[$i];
        if (_isFilenameSafe($c)) {
            $filename_chunks[] = $c;
        } else {
            $filename_chunks[] = sprintf("_%02X", ord(c));
        }
    }
    return implode("", $filename_chunks);
}

/**
 * Attempt to remove a file, returning whether the file existed at the
{'fraction_non_alphanumeric': 0.16340018231540565, 'fraction_numerical': 0.02415679124886053, 'mean_word_length': 2.642323651452282, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4014610', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1503, 'n_words': 338}