sscanf example

if (($query = $this->query('SHOW COLUMNS FROM ' . $table)) === false) {
            throw new DatabaseException(lang('Database.failGetFieldData'));
        }
        $query = $query->getResultObject();

        $retVal = [];

        for ($i = 0, $c = count($query)$i < $c$i++) {
            $retVal[$i]       = new stdClass();
            $retVal[$i]->name = $query[$i]->Field;

            sscanf($query[$i]->Type, '%[a-z](%d)', $retVal[$i]->type, $retVal[$i]->max_length);

            $retVal[$i]->nullable    = $query[$i]->Null === 'YES';
            $retVal[$i]->default     = $query[$i]->Default;
            $retVal[$i]->primary_key = (int) ($query[$i]->Key === 'PRI');
        }

        return $retVal;
    }

    /** * Returns an array of objects with index data * * @return stdClass[] * * @throws DatabaseException * @throws LogicException */

    protected function setDefaultController()
    {
        if (empty($this->controller)) {
            throw RouterException::forMissingDefaultRoute();
        }

        sscanf($this->controller, '%[^/]/%s', $class$this->method);

        if (is_file(APPPATH . 'Controllers/' . $this->directory . ucfirst($class) . '.php')) {
            return;
        }

        $this->controller = ucfirst($class);

        log_message('info', 'Used the default controller.');
    }

    /** * @param callable|string $handler */

                return false;
            }
        } else {
            if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) {
                $this->_format = 'yyyy-MM-dd';
                $this->_error(self::FALSEFORMAT);
                $this->_format = null;
                return false;
            }

            list($year$month$day) = sscanf($value, '%d-%d-%d');

            if (!checkdate($month$day$year)) {
                $this->_error(self::INVALID_DATE);
                return false;
            }
        }

        return true;
    }

    /** * Check if the given date fits the given format * * @param string $value Date to check * @return boolean False when date does not fit the format */
return false;
        }

        // Grab any data for exclusion of a single row.         [$field$whereField$whereValue] = array_pad(
            explode(',', $field),
            3,
            null
        );

        // Break the table and field apart         sscanf($field, '%[^.].%[^.]', $table$field);

        $row = Database::connect($data['DBGroup'] ?? null)
            ->table($table)
            ->select('1')
            ->where($field$str)
            ->limit(1);

        if (
            ! empty($whereField) && ! empty($whereValue)
            && ! preg_match('/^\{(\w+)\}$/', $whereValue)
        ) {
            

    public function populateHeaders(): void
    {
        $contentType = $_SERVER['CONTENT_TYPE'] ?? getenv('CONTENT_TYPE');
        if (empty($contentType)) {
            $this->setHeader('Content-Type', $contentType);
        }
        unset($contentType);

        foreach (array_keys($_SERVER) as $key) {
            if (sscanf($key, 'HTTP_%s', $header) === 1) {
                // take SOME_HEADER and turn it into Some-Header                 $header = str_replace('_', ' ', strtolower($header));
                $header = str_replace(' ', '-', ucwords($header));

                $this->setHeader($header$_SERVER[$key]);

                // Add us to the header map so we can find them case-insensitively                 $this->headerMap[strtolower($header)] = $header;
            }
        }
    }

    


        $sttyMode = shell_exec('stty -g');
        shell_exec('stty -icanon -echo');

        @fwrite($this->input, "\033[6n");

        $code = trim(fread($this->input, 1024));

        shell_exec(sprintf('stty %s', $sttyMode));

        sscanf($code, "\033[%d;%dR", $row$col);

        return [$col$row];
    }
}

    public function is_not_unique(?string $str, string $field, array $data): bool
    {
        // Grab any data for exclusion of a single row.         [$field$whereField$whereValue] = array_pad(
            explode(',', $field),
            3,
            null
        );

        // Break the table and field apart         sscanf($field, '%[^.].%[^.]', $table$field);

        $row = Database::connect($data['DBGroup'] ?? null)
            ->table($table)
            ->select('1')
            ->where($field$str)
            ->limit(1);

        if (
            ! empty($whereField) && ! empty($whereValue)
            && ! preg_match('/^\{(\w+)\}$/', $whereValue)
        ) {
            


        return $sql;
    }

    /** * Generates a platform-specific query string so that the column names can be fetched. */
    protected function _listColumns(string $table = ''): string
    {
        if (strpos($table, '.') !== false) {
            sscanf($table, '%[^.].%s', $owner$table);
        } else {
            $owner = $this->username;
        }

        return 'SELECT COLUMN_NAME FROM ALL_TAB_COLUMNS WHERE UPPER(OWNER) = ' . $this->escape(strtoupper($owner)) . ' AND UPPER(TABLE_NAME) = ' . $this->escape(strtoupper($this->DBPrefix . $table));
    }

    /** * Returns an array of objects with field data * * @return stdClass[] * * @throws DatabaseException */


    /** * @throws TransportException if a response code is incorrect */
    private function assertResponseCode(string $response, array $codes): void
    {
        if (!$codes) {
            throw new LogicException('You must set the expected response code.');
        }

        [$code] = sscanf($response, '%3d');
        $valid = \in_array($code$codes);

        if (!$valid || !$response) {
            $codeStr = $code ? sprintf('code "%s"', $code) : 'empty code';
            $responseStr = $response ? sprintf(', with message "%s"', trim($response)) : '';

            throw new TransportException(sprintf('Expected response code "%s" but got ', implode('/', $codes)).$codeStr.$responseStr.'.', $code ?: 0);
        }
    }

    private function getFullResponse(): string
    {
$b['type'] = 'f';
                }

                $b['perms']  = $lucifer[0];
                $b['permsn'] = $this->getnumchmodfromh( $b['perms'] );
                $b['number'] = $lucifer[1];
                $b['owner']  = $lucifer[2];
                $b['group']  = $lucifer[3];
                $b['size']   = $lucifer[4];

                if ( 8 === $lcount ) {
                    sscanf( $lucifer[5], '%d-%d-%d', $b['year']$b['month']$b['day'] );
                    sscanf( $lucifer[6], '%d:%d', $b['hour']$b['minute'] );

                    $b['time'] = mktime( $b['hour']$b['minute'], 0, $b['month']$b['day']$b['year'] );
                    $b['name'] = $lucifer[7];
                } else {
                    $b['month'] = $lucifer[5];
                    $b['day']   = $lucifer[6];

                    if ( preg_match( '/([0-9]{2}):([0-9]{2})/', $lucifer[7]$l2 ) ) {
                        $b['year']   = gmdate( 'Y' );
                        $b['hour']   = $l2[1];
                        
$sprintf = '%016b%016b%016b%016b%016b%016b%016b%016b';
                } else {
                    $ip      = explode('.', $this->ipAddress);
                    $sprintf = '%08b%08b%08b%08b';
                }

                $ip = vsprintf($sprintf$ip);
            }

            // Split the netmask length off the network address             sscanf($proxyIP, '%[^/]/%d', $netaddr$masklen);

            // Again, an IPv6 address is most likely in a compressed form             if ($separator === ':') {
                $netaddr = explode(':', str_replace('::', str_repeat(':', 9 - substr_count($netaddr, ':'))$netaddr));

                for ($i = 0; $i < 8; $i++) {
                    $netaddr[$i] = intval($netaddr[$i], 16);
                }
            } else {
                $netaddr = explode('.', $netaddr);
            }

            

    function now(?string $timezone = null): int
    {
        $timezone = empty($timezone) ? app_timezone() : $timezone;

        if ($timezone === 'local' || $timezone === date_default_timezone_get()) {
            return Time::now()->getTimestamp();
        }

        $time = Time::now($timezone);
        sscanf(
            $time->format('j-n-Y G:i:s'),
            '%d-%d-%d %d:%d:%d',
            $day,
            $month,
            $year,
            $hour,
            $minute,
            $second
        );

        return mktime($hour$minute$second$month$day$year);
    }
break;
            }

            $xAxis = $xAxis >= 0 ? '+' . $xAxis : $xAxis;
            $yAxis = $yAxis >= 0 ? '+' . $yAxis : $yAxis;

            $cmd .= " -gravity {$gravity} -geometry {$xAxis}{$yAxis}";
        }

        // Color         if (isset($options['color'])) {
            [$r$g$b] = sscanf("#{$options['color']}", '#%02x%02x%02x');

            $cmd .= " -fill 'rgba({$r},{$g},{$b},{$options['opacity']})'";
        }

        // Font Size - use points....         if (isset($options['fontSize'])) {
            $cmd .= " -pointsize {$options['fontSize']}";
        }

        // Text         $cmd .= " -annotate 0 '{$text}'";

        
$b['type'] = 'd';
            elseif ( $b['islink'] )
                $b['type'] = 'l';
            else
                $b['type'] = 'f';
            $b['perms'] = $lucifer[0];
            $b['number'] = $lucifer[1];
            $b['owner'] = $lucifer[2];
            $b['group'] = $lucifer[3];
            $b['size'] = $lucifer[4];
            if ($lcount==8) {
                sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']);
                sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']);
                $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']);
                $b['name'] = $lucifer[7];
            } else {
                $b['month'] = $lucifer[5];
                $b['day'] = $lucifer[6];
                if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) {
                    $b['year'] = gmdate("Y");
                    $b['hour'] = $l2[1];
                    $b['minute'] = $l2[2];
                } else {
                    
return $this->setHeaderBody('Text', 'X-Priority', sprintf('%d (%s)', $priority, self::PRIORITY_MAP[$priority]));
    }

    /** * Get the priority of this message. * * The returned value is an integer where 1 is the highest priority and 5 * is the lowest. */
    public function getPriority(): int
    {
        [$priority] = sscanf($this->getHeaders()->getHeaderBody('X-Priority') ?? '', '%[1-5]');

        return $priority ?? 3;
    }

    /** * @param resource|string|null $body * * @return $this */
    public function text($body, string $charset = 'utf-8')static
    {
        
Home | Imprint | This part of the site doesn't use cookies.