Small hiccup in that the WebCogs "instantly accessible" system doesn't like the generated key it sent me which, given my tired state, is a tad annoying, but anyway... I'll release the little module (it won't be hard to write


Code: Select all
function isIPAddress($ipaddr)
{
if (preg_match("#^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$#", $ipaddr, $digit)) {
if (($digit[1] <= 255) && ($digit[2] <= 255) && ($digit[3] <= 255) && ($digit[4] <= 255)) {
return true;
}
}
return false;
}
Code: Select all
function canViewMobileSite()
{
$mobileDevice = getPortableDeviceType();
if($mobileDevice && getConfig('enableMobileTemplate') && in_array($mobileDevice['device'], getConfig('enableMobileTemplateDevices'))) {
return true;
}
return false;
}
Code: Select all
//MOD WebCogs Password Generator
/*
* This mod gets a pronouncable password from the webcogs service
* checks it and then uses it as the password for auto generated
* accounts.
*
* Defaults back to the original ISC one if webcogs one is not available
*
*/
function webCogsPassword($type='') {
$genpwd = '';
// YOU NEED TO PUT YOUR WEBCOGS SERVICE SERIAL NUMBER BELOW
$serial = "YOURSERIALHERE";
// END EDITING.
$url = "secure.webcogs.com";
$path = "/webservices/";
$file = "passwordgenerator.asmx/getRandomPassword?strAccessKey=";
$filename = "http://".$url.$path.$file.$serial;
$buffer = '';
$dataFile = fopen( $filename, "r" ) ;
if ( $dataFile ) {
while (!feof($dataFile)) {
$buffer .= fgets($dataFile, 4096);
}
fclose($dataFile);
}
else {
return false;
}
// DEBUG echo $buffer;
// Parse out the string suggested.
$pattern = "@<string xmlns=\"(http|https){1}://".$url.$path."\">([a-z0-9]+)</string>@is";
preg_match($pattern, $buffer, $matches);
$genpwd = $matches[2];
// Check the password is set and comprises alphanumerics of 5+ characters
if(!preg_match("@[a-z0-9]{5,}@i", $genpwd)) {
// empty the string if it does not
$genpwd = '';
}
$password = (!empty($genpwd)) ? $genpwd : ($type=='read' ? GenerateReadablePassword(): substr(md5(uniqid(true)), 0, 8));
return $password;
}
// MOD END WebCogs
Code: Select all
$password = GenerateReadablePassword();
$updateData = array(
'custpassword' => md5($password),
'customerpasswordresettoken' => '',
'customerpasswordresetemail' => '',
);
Code: Select all
//MOD WebCogs Password Generator
$password = webCogsPassword('read');
//$password = (!empty($genpwd)) ? $genpwd : GenerateReadablePassword();
// MOD END WebCogs
Code: Select all
// If we're automatically creating accounts for customers then we need to save those details too
if(!CustomerIsSignedIn() && GetConfig('GuestCheckoutCreateAccounts')) {
Code: Select all
//MOD WebCogs Password Generator
$password = webCogsPassword();
// MOD END WebCogs
// $password = substr(md5(uniqid(true)), 0, 8);
Code: Select all
$autoAccount = 1;
}
if(!isset($_SESSION['CHECKOUT']['CREATE_ACCOUNT']) && isset($_POST['billing_EmailAddress'])) {
Code: Select all
//MOD WebCogs Password Generator
$password = webCogsPassword();
//$password = substr(md5(uniqid(true)), 0, 8);
//DEBUG echo "\nPWD: $password"; exit;
// MOD END WebCogs