case '0.5.6': // SQL queries for v0.5.6
// Get current month
- $curr = padLeftZero(getMonth());
+ $curr = padLeftZero(getMonth(), 2);
if ($curr == '00') $curr = '12';
// Generate timemark...
$mod = substr($mod, 0, 2);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'idx=' . $idx . ',part1=' . $part1 . '/part2=' . $part2 . '/mod=' . $mod . '(' . strlen($mod) . ')');
- $mod = padLeftZero($mod);
+ $mod = padLeftZero($mod, 2);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mod(' . ($idx * 2) . ')=' . $mod . '*');
$start += 2;
$newHash .= $mod;
$hex = '';
for ($i = 0; $i < strlen($hash); $i++) {
// Encode char to decimal, pad it with zero, add it
- $hex .= padLeftZero(dechex(ord(substr($hash, $i, 1))));
+ $hex .= padLeftZero(dechex(ord(substr($hash, $i, 1))), 2);
} // END - if
// Return it
$body = http_build_query($requestData, '', '&');
// Generate POST request header
- $request = 'POST ' . (isProxyUsed() === TRUE ? $baseUrl : '') . trim($baseUrl) . ' HTTP/1.0' . getConfig('HTTP_EOL');
+ $request = 'POST ' . (isProxyUsed() === TRUE ? $getUrl : '') . trim($getUrl) . ' HTTP/1.0' . getConfig('HTTP_EOL');
$request .= 'Host: ' . $host . getConfig('HTTP_EOL');
$request .= 'Referer: ' . getUrl() . '/admin.php' . getConfig('HTTP_EOL');
if (isConfigEntrySet('FULL_VERSION')) {
break;
default: // Unknown error (maybe new?)
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown error %s from WDS66 API received.", $data[1]));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf('Unknown error %s from WDS66 API received.', $data[1]));
$return = array(
'status' => 'request_failed',
'message' => '{%message,WERNIS_API_REQUEST_FAILED=' . $data[1] . '%}'
// Tests the function by calling balance.php on the API
function WERNIS_TEST_API () {
+ // Only as admin
+ assert(isAdmin());
+
// Result is always failed
$result = FALSE;
+ // Prepare the request data
+ $requestData = array(
+ 't_uid' => getWernisRefid(),
+ 't_md5' => getWernisPassMd5()
+ );
+
// Return the result from the lower functions
- $return = WERNIS_SEND_REQUEST('balance.php');
+ $return = WERNIS_SEND_REQUEST('balance.php', $requestData);
// Did it went smoothly?
if ($return['status'] == 'OK') {
addYouAreHereLink('admin', __FILE__);
if (isFormSent('save_config')) {
+ // Hash the password and remove clear-text
+ setPostRequestElement('wernis_pass_md5', hashSha256(postRequestElement('wernis_pass')));
+
// First merge temporarily the new API data into the current config
mergeConfig(postRequestArray());
setPostRequestElement('wernis_' . $revert, postRequestElement('wernis_' . $revert));
} // END - if
- // Hash the password and remove clear-text
- setPostRequestElement('wernis_pass_md5', hashSha256(postRequestElement('wernis_pass')));
+ // Remove clear password
unsetPostRequestElement('wernis_pass');
// Save settings
// Shall I withdraw now?
if (isPostRequestElementSet('withdraw')) {
// Okay, let's prepare...
- $curr = padLeftZero(getMonth() - 1);
+ $curr = padLeftZero(getMonth() - 1, 2);
updateConfiguration('last_monthly', $curr);
displayMessage('{--ADMIN_BEG_WITHDRAW_PREPARED--}');
} // END - if
// Shall I withdraw now?
if (isPostRequestElementSet('withdraw')) {
// Okay, let's prepare...
- $curr = padLeftZero(getMonth() - 1);
+ $curr = padLeftZero(getMonth() - 1, 2);
updateConfiguration('last_monthly', $curr);
displayMessage('{--ADMIN_BONUS_WITHDRAW_PREPARED--}');
} // END - if
addPointsThroughReferralSystem('wernis_withdraw', getMemberId(), bigintval(postRequestElement('amount')));
// Update the user data as well..
- sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1',
array(bigintval(postRequestElement('wernis_userid')), getMemberId()), __FILE__, __LINE__);
// All done!
subtractPoints('wernis_payout', getMemberId(), postRequestElement('amount'));
// Update WDS66 id
- sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1',
array(bigintval(postRequestElement('wernis_userid')), getMemberId()), __FILE__, __LINE__);
// All done!
break;
default: // Invalid mode!
- logDebugMessage(__FILE__, __LINE__, sprintf("Invalid mode %s detected.", getRequestElement('do')));
+ logDebugMessage(__FILE__, __LINE__, sprintf('Invalid mode %s detected.', getRequestElement('do')));
displayMessage('{%message,MEMBER_WERNIS_MODE_INVALID=' . getRequestElement('do') . '%}');
return;
} // END - switch
} // END - if
// Prepare mode for template name
-$mode = sprintf("member_wernis_mode_%s", getRequestElement('do'));
+$mode = sprintf('member_wernis_mode_%s', getRequestElement('do'));
// Load the template
loadTemplate($mode, FALSE, $content);
case 'ho': // Hours
for ($idx = 0; $idx <= 23; $idx++) {
- $padded = padLeftZero($idx);
+ $padded = padLeftZero($idx, 2);
$OUT .= '<option value="' . $padded . '"';
if ($default == $padded) $OUT .= ' selected="selected"';
$OUT .= '>' . $padded . '</option>';
case 'mi': // Minutes
case 'se': // Seconds
for ($idx = 0; $idx <= 59; $idx+=5) {
- $padded = padLeftZero($idx);
+ $padded = padLeftZero($idx, 2);
$OUT .= '<option value="' . $padded . '"';
if ($default == $padded) $OUT .= ' selected="selected"';
$OUT .= '>' . $padded . '</option>';