Static methods which 'generate'.

package dstruct_common

 Methods

Generate an anchor mailto: which is obscured from robots and requires JS to display properly.

mailTo(string $email, string $linktext, string $anchortitle, string $class) 
Static

If JS is not available,, you can encode the email address with toASCIIEntities(). The document.write() line from the out put MUST NOT be split over multiple lines when output to the browser.

Parameters

$email

string

Is encoded.

$linktext

string

The text which will show in the browser. Is encoded.

$anchortitle

string

Text for the HTML 'a' element title. Is encoded.

$class

string

Any class(es) you want on the HTML 'a' element

Generate a random string suitable for passwords.

password(integer $charcount, integer $characters, integer $case, string $exclude, string $include) : string
Static

Parameters

$charcount

integer

Number of characters required in output

$characters

integer

Hex characters or Alpha-Numeric output

$case

integer

Upper, Lower or Mixed case

$exclude

string

Characters not allowed in password

$include

string

Characters allowed in password which are not otherwise included

Returns

string

Make a Post to a URL without CURL.

postRequest(string $url, array $data, string $optional_headers) 
Static
link http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/

Parameters

$url

string

The target page

$data

array

e.g. 'id' => 3, 'name' => 'myname'

$optional_headers

string

Additional HTTP headers that you would like to send in your request.

POST data and grab response.

pullPage(string $host, string $usepath, string $postdata) : string
Static

Origin of this method?

Parameters

$host

string

Host

$usepath

string

Path of URL

$postdata

string

POST data

Returns

string

Generate array of ASCII from string.

toASCIIArray(string $str) : array
Static

Parameters

$str

string

Returns

array

Generate a string of ASCII HTML entities.

toASCIIEntities(string $str) : string
Static

Parameters

$str

string

Returns

string

Truncates text by looking for \n followed by space.

truncatedText(string $text, integer $maxchars, boolean $forcelinebreak, string $oversuffix) : string
Static

Useful for when inserting a summary of a longer bit of text somewhere. $forcelinebreak makes a break at the first \n (newline) regardless of whether line is short. $oversuffix is appended if the text is too long. Typically, it might be used to append '...' to the end of the output. If the text is shorter than $maxchars then the original text is returned. Should be UTF-8 safe.

Parameters

$text

string

Text to truncate

$maxchars

integer

Maximum characters allowed in output

$forcelinebreak

boolean

Break at first \n

$oversuffix

string

Suffixed to the output if it was truncated.

Returns

string

Class constructor.

__construct() 

 Constants

 

Lower case.

CASE_LOWER : integer
 

Mixed case.

CASE_MIXED : integer
 

Upper case.

CASE_UPPER : integer
 

Alpha-numeric characters

CHARACTERS_ALPHA_NUMERIC : integer
 

Hexadecimal characters

CHARACTERS_HEX : integer
 

Exclude from passwords generated.

PASSWORD_EXCLUDE : string