<commit_before><?php
/*
 All Emoncms code is released under the GNU Affero General Public License.
 See COPYRIGHT.txt and LICENSE.txt.

 ---------------------------------------------------------------------
 Emoncms - open source energy visualisation
 Part of the OpenEnergyMonitor project:
 http://openenergymonitor.org
 */

// no direct access
defined('EMONCMS_EXEC') or die('Restricted access');



class Input
{
    private $mysqli;
    private $feed;
    private $redis;

    public function __construct($mysqli,$redis,$feed)
    {
        $this->mysqli = $mysqli;
        $this->feed = $feed;

        $this->redis = $redis;
    }
    // Check a nodeID against the current node-ID limits to see if it's valid
    // True = Valid
    // False = not valid
    public function check_node_id_valid($nodeid)
    {
        global $max_node_id_limit;
        //
        // Holy SHIT php is stupid. (int)"wat" returns 0. What the HELL?
        //
        // Issues: is_numeric allows all sorts of crazy crap. Octal? Yep.
        // e-notation (+0123.45e6)? Yep. Hex? Yep. PHP doesn't seem to have
        // a good way to check if a string will cast to a valid *integer*
        // also, !crazy shit! like (int) Array({stuff})resuling in numeric "1"
        // is apparently a thing (the php developers are on crack).
        //
        // Anyways, I'd still like to catch non-integer numbers at some point,
        // but just checking against isNumeric will probably catch *most*
        // of the potential issues
        if (!is_numeric ($nodeid))
        {
            return false;
        }

        $nodeid = (int) $nodeid;

        if (!isset($max_node_id_limit))
        {
            $max_node_id_limit = 32;    // Default to 32 if not overridden
        }

        if ($nodeid<$max_node_id_limit)
        {
            return true;
        }
        else
        {
            return false;
        }

    }
    // USES: redis input & user<commit_msg>remove invective<commit_after><?php
/*
 All Emoncms code is released under the GNU Affero General Public License.
 See COPYRIGHT.txt and LICENSE.txt.

 ---------------------------------------------------------------------
 Emoncms - open source energy visualisation
 Part of the OpenEnergyMonitor project:
 http://openenergymonitor.org
 */

// no direct access
defined('EMONCMS_EXEC') or die('Restricted access');



class Input
{
    private $mysqli;
    private $feed;
    private $redis;

    public function __construct($mysqli,$redis,$feed)
    {
        $this->mysqli = $mysqli;
        $this->feed = $feed;

        $this->redis = $redis;
    }
    // Check a nodeID against the current node-ID limits to see if it's valid
    // True = Valid
    // False = not valid
    public function check_node_id_valid($nodeid)
    {
        global $max_node_id_limit;
        //
        // Issues: is_numeric allows all sorts of crazy crap. Octal? Yep.
        // e-notation (+0123.45e6)? Yep. Hex? Yep. PHP doesn't seem to have
        // a good way to check if a string will cast to a valid *integer*
        // also, !crazy shit! like (int) Array({stuff})resuling in numeric "1"
        // is apparently a thing.
        //
        // Anyways, I'd still like to catch non-integer numbers at some point,
        // but just checking against isNumeric will probably catch *most*
        // of the potential issues
        //
        if (!is_numeric ($nodeid))
        {
            return false;
        }

        $nodeid = (int) $nodeid;

        if (!isset($max_node_id_limit))
        {
            $max_node_id_limit = 32;    // Default to 32 if not overridden
        }

        if ($nodeid<$max_node_id_limit)
        {
            return true;
        }
        else
        {
            return false;
        }

    }
    // USES: redis input & user
{'fraction_non_alphanumeric': 0.13331587218438973, 'fraction_numerical': 0.006547930853850184, 'mean_word_length': 1.7200854700854702, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '7530892', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1087, 'n_words': 367}