//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',taskId[' . gettype($taskId) . ']=' . $taskId);
if ((!isValidId($taskId)) && (!isExtensionInstalled($ext_name))) {
// Set default message if ext-foo is missing
- $message = '{%message,ADMIN_EXTENSION_TEXT_FILE_MISSING=' . $ext_name . '%}';
+ $message = sprintf('{%%message,ADMIN_EXTENSION_TEXT_FILE_MISSING=%s%%}', $ext_name);
// Template file
$FQFN = sprintf('%s/ext/ext_%s.tpl',
// Load text for task if found
if (isFileReadable($FQFN)) {
// Load extension's description template (but do not compile the code)
- $message = '{OPEN_TEMPLATE}template,LoadTemplate=ext_' . $ext_name . '{CLOSE_TEMPLATE}';
+ $message = sprintf('{OPEN_TEMPLATE}template,LoadTemplate=ext_%s{CLOSE_TEMPLATE}', $ext_name);
} else {
// Write this in debug.log as well
logDebugMessage(__FUNCTION__, __LINE__, $message);
}
// "Translates" 'visible' and 'locked' to a CSS class
-function translateMenuVisibleLocked ($content, $prefix = '') {
- // 1st parameter should be an array
- assert(is_array($content));
-
+function translateMenuVisibleLocked (array $content, $prefix = '') {
// Default is 'menu_unknown'
$content['visible_css'] = $prefix . 'menu_unknown';
// Proxy agent found or something went wrong?
if (!isFilledArray($response)) {
// No response, maybe timeout
- $response = array('', '', '');
+ $response = ['', '', ''];
logDebugMessage(__FUNCTION__, __LINE__, 'Invalid empty response array, maybe timed out?');
} elseif ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && (isProxyUsed() === TRUE)) {
// Proxy header detected, so remove two lines
if ((!isHttpStatusOkay($response[0])) && ($allowOnlyHttpOkay === TRUE)) {
// Not found / access forbidden
logDebugMessage(__FUNCTION__, __LINE__, 'Unexpected status code ' . $response[0] . ' detected. "200 OK" was expected.');
- $response = array('', '', '');
+ $response = ['', '', ''];
} else {
// Check array for chuncked encoding
$response = unchunkHttpResponse($response);
// Is HTTP status okay?
function isHttpStatusOkay ($header) {
// Determine it
- return in_array(strtoupper(trim($header)), array('HTTP/1.1 200 OK', 'HTTP/1.0 200 OK'));
+ return in_array(strtoupper(trim($header)), ['HTTP/1.1 200 OK', 'HTTP/1.0 200 OK']);
}
// Sets up a proxy tunnel for given hostname and through resource
function setupProxyTunnel ($host, $proxyHost, $port, $resource) {
// Initialize array
- $response = array('', '', '');
+ $response = ['', '', ''];
// Generate CONNECT request header
$proxyTunnel = 'CONNECT ' . $host . ':' . $port . ' HTTP/1.0' . getConfig('HTTP_EOL');
}
// Check array for chuncked encoding
-function unchunkHttpResponse ($response) {
+function unchunkHttpResponse (array $response) {
// Default is not chunked
$isChunked = FALSE;
}
// Execute get.php reguest with given auth data (not all are used)
-function executeWernisApiGet ($authData, $subRequest, $fields) {
- // It must be an array
- assert(is_array($authData));
-
+function executeWernisApiGet (array $authData, $subRequest, $fields) {
// Check required array elements
assert(isset($authData['wernis_userid']));
assert(isset($authData['api_auth_key']));
assert(isset($authData['api_redirect_challenge']));
// Then create request array
- $requestData = array(
+ $requestData = [
'sub_request' => $subRequest,
'fields' => $fields,
't_uid' => bigintval($authData['wernis_userid']),
't_md5' => getWernisPassMd5(),
'auth_key' => $authData['api_auth_key'],
'challenge' => $authData['api_redirect_challenge']
- );
+ ];
// Call get.php
$return = sendWernisApiRequest('get.php', $requestData);
}
// Registers or updates Wernis registration data
-function registerUpdateWernisRegistrationCall ($args, $challenge, $status) {
+function registerUpdateWernisRegistrationCall (array $args, $challenge, $status) {
// Make sure the required array elements are there
- assert(is_array($args));
assert(isset($args['auth_key']));
assert(isset($args['wernis_userid']));
//-----------------------------------------------------------------------------
// Handler for auth_status=PENDING
-function doWernisAuthPending ($args) {
- // $args must always be an array
- assert(is_array($args));
-
+function doWernisAuthPending (array $args) {
// auth_key and wernis_userid must be set
assert(isset($args['auth_key']));
assert(isset($args['wernis_userid']));
}
// Handler for auth_status=ACCEPTED
-function doWernisAuthAccepted ($args) {
- // $args must always be an array
- assert(is_array($args));
-
+function doWernisAuthAccepted (array $args) {
// auth_key and wernis_userid must be set
assert(isset($args['auth_key']));
assert(isset($args['wernis_userid']));
}
// Parser function for Yoo!Media API responses
-function YOOMEDIA_PARSE_RESPONSE ($response, $type) {
+function YOOMEDIA_PARSE_RESPONSE (array $response, $type) {
// Init result
$result = [];
}
// Extract code from response
-function YOOMEDIA_GET_ERRORCODE_FROM_RESULT ($response) {
- // The response must be an array
- assert(is_array($response));
-
+function YOOMEDIA_GET_ERRORCODE_FROM_RESULT (array $response) {
// Bad code as default
$code = -999;
// Handle description...
if ((empty($content['descr'])) && (!empty($content['template']))) {
// Use description from template
- $content['descr'] = '{%template,LoadTemplate=rallye_' . $content['template'] . '%}';
+ $content['descr'] = sprintf('{%%template,LoadTemplate=rallye_%s%%}', $content['template']);
} // END - if
// Set start and end time
if ($expired === TRUE) {
$content['prices'] = addReferralRallyeWinners('guest', $content['id']);
- $content['top_users'] = '<div align="center" class="big">' . $content['extras'] . '</div>';
+ $content['top_users'] = sprintf('<div align="center" class="big">%s</div>', $content['extras']);
$content['can_win_this'] = '{--RALLYE_OUR_WINNERS_ARE--}';
} else {
$content['prices'] = addReferralRallyePrices($content['id'], 'html');
}
// Generates a 'selection box' from given array
-function generateSelectionBoxFromArray ($options, $name, $optionKey, $optionContent = '', $extraName = '', $templateName = '', $default = NULL, $nameElement = '', $allowNone = FALSE, $useDefaultAsArray = FALSE) {
- // options must be an array
- assert(is_array($options));
-
+function generateSelectionBoxFromArray (array $options, $name, $optionKey, $optionContent = '', $extraName = '', $templateName = '', $default = NULL, $nameElement = '', $allowNone = FALSE, $useDefaultAsArray = FALSE) {
// Default is empty
$addKey = '';
$OUT .= '</select>';
// Prepare output
- $content = array(
+ $content = [
'selection_box' => $OUT,
- );
+ ];
// Load template and return it
if (empty($templateName)) {
$OUT = '';
// Add them all together. This is maybe to simple
- foreach (array('__page_header', '__output', '__page_footer') as $pagePart) {
+ foreach (['__page_header', '__output', '__page_footer'] as $pagePart) {
// Add page part if set
if (isset($GLOBALS[$pagePart])) {
$OUT .= $GLOBALS[$pagePart];
$compactedContent = str_replace(chr(9), '', str_replace(PHP_EOL, '', str_replace(chr(13), '', $uncompactedContent)));
// Make a space after >
- $compactedContent = str_replace(array('>', ' '), array('> ', ' '), $compactedContent);
+ $compactedContent = str_replace(['>', ' '], ['> ', ' '], $compactedContent);
// Then regex all comments like <!-- //--> away
preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $compactedContent, $matches);
// Helper function to add extra content for guest area (module=index and others)
function doTemplateGuestFooterExtras ($templateName, $clear) {
// Init filter data
- $filterData = array(
+ $filterData = [
// Name of used template
'template' => $templateName,
// Target array for gathered data
'__data' => [],
// Where the HTML output will go
'__output' => '',
- );
+ ];
// Run the filter chain
$filterData = runFilterChain('guest_footer_extras', $filterData);
// Is the URL not NULL and not empty?
if ((!is_null($url)) && (!empty($url))) {
// Set HTML with EL code
- $url = '<a href="{%pipe,generateDereferrerUrl=' . $url . '%}" rel="external" target="_blank">{--ADMIN_TEST_URL--}</a>';
+ $url = sprintf('<a href="{%%pipe,generateDereferrerUrl=%s%%}" rel="external" target="_blank">{--ADMIN_TEST_URL--}</a>', $url);
} // END - if
// Return URL (or content) or dashes if empty
}
// Wrapper to check if the first element to be shifted is set to given value
-function shift_array (&$array, $value, $key = '0') {
+function shift_array (array &$array, $value, $key = '0') {
// Is the element set and value matches?
- assert(is_array($array));
assert(isset($array[$key]));
assert($array[$key] === $value);
}
// "Getter" for sql part back from given array
-function getSqlPartFromXmlArray ($columns) {
+function getSqlPartFromXmlArray (array $columns) {
// Init SQL
$sql = '';