@param string $bin

@return array [$id, $offset, $size, $flags]
426133
private function unpackHeader(string $bin): array
    {
        $data = unpack('Sid/Soffset/Qsize/Iflags', $bin);

        return [
            $data['id'],
            $data['offset'],
            $data['size'],
            $data['flags'],
        ];
    }
1312463
protected function getAnchorsInPage($id)
    {
        $page = SiteTree::get()->byID($id);

        if (!$page || !$page->canView()) {
            return [];
        }

        return $page->getAnchorsOnPage();
    }
1135911
public function getSons($id)
    {
        $sons = [];
        foreach ($this->_tree as $key => $value) {
            if ($value[$this->_parentSign] == $id) {
                $sons[] = $value;
            }
        }
        return $sons;
    }
343659
public function get(array $ids = [], array $codes = [], $offset = 0, $limit = self::MAX_GET_USERS): array
    {
        $options = ['json' => compact('ids', 'codes')];
        $options['json']['size'] = $limit;
        $options['json']['offset'] = $offset;

        /** @var JsonStream $stream */
        $stream = $this->client
            ->get(UserApi::generateUrl('users.json'), $options)
            ->getBody();

        return $stream->jsonSerialize()['users'];
    }
757417
public function getSize($id = 0)
    {
        if ($id) {
            $pos = $this->_positions[$id - 1];
            return $pos['end'] - $pos['start'];
        }

        $result = array();
        foreach ($this->_positions as $num => $pos) {
            $result[$num + 1] = $pos['end'] - $pos['start'];
        }

        return $result;
    }
535007
public static function binToDec($bin, $length = 0)
    {
        $gmp = gmp_init($bin, 2);
        $dec = gmp_strval($gmp, 10);

        return self::pad($dec, $length);
    }
741189
public function get_id_by_bit(string $id): ?string
  {
    if ( \bbn\str::is_uid($id) && ($p = $this->get_by_bit($id)) ){
      return $p[$this->fields['id']];
    }
    return null;
  }
333781
private function parseBinariesSettings(\DOMNode $binaries) {

		$context = $this->isLocalhost ? 'local' : 'remote';

		$xpath = new \DOMXPath($binaries->ownerDocument);

		$e = $xpath->query("db_connection[@context='$context']", $binaries);

		if(!$e->length) {
			$e = $xpath->query('executables');
		}

		if($e->length) {

			$p = $e->item(0)->getElementsByTagName('path');

			if(empty($p)) {
				throw new ConfigException('Malformed "site.ini.xml"! Missing path for binaries.');
			}

			$this->binaries = new \stdClass;
			$this->binaries->path = rtrim($p->item(0)->nodeValue, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;

			foreach($e->item(0)->getElementsByTagName('executable') as $v) {

				if(!($id = $v->getAttribute('id'))) {
					throw new ConfigException('Binary without id found.');
				}

				foreach($v->attributes as $attr) {
					$this->binaries->executables[$id][$attr->nodeName] = $attr->nodeValue;
				}
			}
		}

	}
643505
public function exportById($id): array
    {
        $volume = Craft::$app->volumes->getVolumeById((int) $id);

        return $this->export($volume);
    }
431266
public function buildBinary($binary)
    {
        $class = $this->modulable->findQualifiedName($binary, 'binaries');

        // If there is a class by that name
        if ($class) {
            return new $class($this->container);
        }

        // Else wrap the command in an AnonymousBinary
        $anonymous = new AnonymousBinary($this->container);
        $anonymous->setBinary($this->bash->which($binary));

        return $anonymous;
    }
783486
public function getPins($type, $id = NULL) {
    if ($id) {
      $location_ids[] = $id;
    }
    else {
      $location_ids = $this->queryFactory->get('node')
        ->condition('type', $type)
        ->condition('status', 1)
        ->execute();
    }

    if (!$location_ids) {
      return [];
    }

    $storage = $this->entityTypeManager->getStorage('node');
    $builder = $this->entityTypeManager->getViewBuilder('node');
    $locations = $storage->loadMultiple($location_ids);

    // Get labels and icons for every bundle from OpenY Map config.
    $typeIcons = $this->configFactory->get('openy_map.settings')->get('type_icons');
    $typeLabels = $this->configFactory->get('openy_map.settings')->get('type_labels');
    $tag = $typeLabels[$type];
    $pins = [];
    foreach ($locations as $location) {
      $view = $builder->view($location, 'teaser');
      $coordinates = $location->get('field_location_coordinates')->getValue();
      if (!$coordinates) {
        continue;
      }
      $uri = !empty($typeIcons[$location->bundle()]) ? $typeIcons[$location->bundle()] :
        '/' . drupal_get_path('module', 'openy_map') . "/img/map_icon_green.png";
      $pins[] = [
        'icon' => $uri,
        'tags' => [$tag],
        'lat' => round($coordinates[0]['lat'], 5),
        'lng' => round($coordinates[0]['lng'], 5),
        'name' => $location->label(),
        'markup' => $this->renderer->renderRoot($view),
      ];
    }

    return $pins;
  }
11671
static function get_bin($url, $curl_options = array())
	{
		$original_url = $url;

		$ch = curl_init($url);
		curl_setopt_array($ch, array(
			CURLOPT_TIMEOUT => defval($curl_options, 'timeout', 15),
			CURLOPT_FOLLOWLOCATION => true,
			CURLOPT_MAXREDIRS => 22,
			CURLOPT_ENCODING => 'gzip, deflate',
			CURLOPT_REFERER => defval($curl_options, 'referer', $original_url),
			CURLOPT_AUTOREFERER => true,
//			CURLOPT_HTTPHEADER => $header,
			CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; FunWebProducts; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_COOKIESESSION => true,
			CURLOPT_COOKIEJAR => blib_files::tmp('cookie-jar-2'),
			CURLOPT_COOKIEFILE => blib_files::tmp('cookie-file-2'),
		));

//	if(preg_match("!lenta\.ru!", $url))
//		curl_setopt($ch, CURLOPT_PROXY, 'home.balancer.ru:3128');

		$content = curl_exec($ch);
		$info = curl_getinfo($ch);
		curl_close($ch);

		switch($info['content_type'])
		{
			case 'image/png':
				$ext = 'png';
				break;
			default:
				$ext = NULL;
				break;
		}
		$info['ext'] = $ext;

		$info['content'] = $content;

		return $info;
	}
677763
public function uninstall($id)
    {
        $plugin = $this->getById($id);
        if (!$plugin) {
            return ['code' => -3, 'message' => 'Plugin not found'];
        }

        if (!$this->isInstalled($id)) {
            return ['code' => -4, 'message' => 'Plugin not installed'];
        }

        if ($this->isBuildIn($id)) {
            return ['code' => -5, 'message' => 'Can not uninstall build-in plugin'];
        }

        $ret = $plugin->uninstall();
        if ($ret['code'] !== 1) {
            return $ret;
        }

        $pluginIds = $this->getInstalledIds();
        $key = array_search($id, $pluginIds);
        if (false === $key) {
            return ['code' => -6, 'message' => 'Plugin not installed'];
        }
        unset($pluginIds[$key]);
        $this->setInstalledIds($pluginIds);

        $this->getEvents(true);

        return $ret;
    }
1194684
protected function getBinaryFileFields(array $collectedFields)
    {
        $filtered = [];
        foreach ($collectedFields as $identifier => $value) {
            if ($value instanceof BinaryFile) {
                $filtered[] = $value;
            }
        }

        return empty($filtered) ? null : $filtered;
    }
527742
public function getBin()
    {
        if ($this->bin === null) {
            $this->bin = $this->detectBin();
        }

        return $this->bin;
    }
403019
public static String binToHex(byte[] bin)
  {
    StringBuffer hex = new StringBuffer();
    binToHex(bin,0,bin.length,hex);
    return hex.toString();
  }
1082359
public function initFromBinary($binary)
    {
        $resource = @imagecreatefromstring($binary);

        if ($resource === false) {
             throw new \Intervention\Image\Exception\NotReadableException(
                "Unable to init from given binary data."
            );
        }

        $image = $this->initFromGdResource($resource);
        $image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary);

        return $image;
    }