\apex\app\ioio

I/O Library for File and Directory Handling.

Service: apex\services\utils\io

This class contains various methods to aid in managing files and directories, plus allows for the sending of HTTP requests, and creation / unpacking of zip archives.

This class is available within the services container, meaning its methods can be accessed statically via the service singleton as shown below.

PHP Example

</php

namespace apex;

use apex\app; use apex\services\utils\io;

// Create a directory io::create_dir($some_directory);

// Parse directory $files = io::parse_dir($some_dir);

Summary

Methods
Properties
Constants
parse_dir()
create_dir()
remove_dir()
send_http_request()
send_tor_request()
generate_random_string()
execute_sqlfile()
create_zip_archive()
unpack_zip_archive()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

parse_dir()

parse_dir(string  $rootdir, boolean  $return_dirs = false) : array

Parse a directory recursively, and return all files and/or directories.

Parameters

string $rootdir

The directory name / path to parse.

boolean $return_dirs

Whether or not to return directory names, or only filenames.

Returns

array —

An array of all resulting file / directory names.

create_dir()

create_dir(string  $dirname) 

Createa new directory recursively

Creates a directory recursively. Goes through the parent directories, and creates them as necessary if they do not exist.

Parameters

string $dirname

The directory to create.

remove_dir()

remove_dir(string  $dirname) 

Remove a directory

Removes a directory recursively. Goes through all files and sub-directories, and deletes them before deleting the parent directory.

Parameters

string $dirname

The directory name to delete.

send_http_request()

send_http_request(string  $url, string  $method = 'GET', array  $request = array(), string  $content_type = 'application/x-www-form-urlencoded', integer  $return_headers) : string

Send a remote HTTP request

Parameters

string $url

The full URL to send hte HTTP request to.

string $method

The method (GET/POST usually) of the request. Defaults to GET.

array $request

The request contents to send in array format.

string $content_type

THe content type of the request. Generally not needed, as the default works.

integer $return_headers

A 1 or 0 definine whether or not to return the HTTP readers of the response.

Returns

string —

Returns the response from the server.

send_tor_request()

send_tor_request(string  $url, string  $method = 'GET', array  $request = array(), string  $content_type = 'application/x-www-form-urlencoded', integer  $return_headers) : string

/ Send a remote HTTP request via the Tor network

Parameters

string $url

The full URL to send hte HTTP request to.

string $method

The method (GET/POST usually) of the request. Defaults to GET.

array $request

The request contents to send in array format.

string $content_type

THe content type of the request. Generally not needed, as the default works.

integer $return_headers

A 1 or 0 definine whether or not to return the HTTP readers of the response.

Returns

string —

Returns the response from the server.

generate_random_string()

generate_random_string(integer  $length = 6, boolean  $include_chars = false) : string

Generate a random string.

Parameters

integer $length

The length of the random string.

boolean $include_chars

Whether or not to include special characters.

Returns

string —

The generated random string.

execute_sqlfile()

execute_sqlfile(string  $sqlfile) 

Execute SQL file

Parameters

string $sqlfile

The path to the SQL file to execute against the database

create_zip_archive()

create_zip_archive(string  $tmp_dir, string  $archive_file) 

Creates a new zip archive from the given directory name.

Parameters

string $tmp_dir

The directory to archive

string $archive_file

The location of the resulting archive file.

unpack_zip_archive()

unpack_zip_archive(string  $zip_file, string  $dirname) : boolean

Unpack a zip archive

Parameters

string $zip_file

The path to the .zip archive

string $dirname

The directory to create and unpack the archive to

Returns

boolean —

Whether or not the operation was successful.