Author |
Message |
Anonymous
| Posted on Wednesday, August 25, 2004 - 10:40 am: | |
Hi. I am using with succes the component you have develop. I will like to have the regware4gen.pl developed in PHP. Is somebody allready done this? Thank you.
|
Winston Kotzan (Wak)
| Posted on Wednesday, August 25, 2004 - 11:04 am: | |
Sorry, there is no known instance of it being done in PHP. But if you do create a PHP version, please share it here or send it to our email. Thanks. |
WarrenAlexander
| Posted on Friday, March 04, 2005 - 5:43 am: | |
here is a PHP class based on regware4gen.pl <?php class RegGen { var $Seed1; var $Seed2; var $Seed3; var $Seed_storage1; var $Seed_storage2; var $Seed_storage3; var $Seed_d; var $RegCodeSize; function RegGen($seed1,$seed2,$seed3) { $this->Seed1=$seed1; $this->Seed2=$seed2; $this->Seed3=$seed3; $this->Seed_storage1 = 0x541D ; $this->Seed_storage2 = 0x9C41; $this->Seed_storage3 = 0xA460; $this->Seed_d = 0x45B7; $this->RegCodeSize=20; } function SetRegCodeSize($Size=20) { $this->RegCodeSize=$Size; } function SetSeeds($seed1,$seed2,$seed3) { $this->Seed1=$seed1; $this->Seed2=$seed2; $this->Seed3=$seed3; } function SetStorageValues($seed_storage1, $seed_storage2, $seed_storage3, $seed_d) { $this->Seed_storage1 = hexdec($seed_storage1) ; $this->Seed_storage2 = hexdec($seed_storage2); $this->Seed_storage3 = hexdec($seed_storage3); $this->Seed_d = hexdec($seed_d); } function p_chop(&$string) { $endchar = substr("$string", strlen("$string") - 1, 1); if ($endchar != "\n") { $string = substr("$string", 0, -1); } return $endchar; } function GenerateCode($UserID,$ExpireDays=0) { if($ExpireDays!=0) { if(strlen($UserID)<5 || strlen($UserID)>108) return false; $exp_date = mktime (0,0,0,date("m") ,date("d")+$ExpireDays,date("Y")); $Month = date('n',$exp_date); $Day = date('j',$exp_date); $Year = date('Y',$exp_date); echo"Month ".$Month."<br>"; echo"Day ".$Day."<br>"; echo"Year ".$Year."<br>"; $V1 = $Month ^ $this->Seed_d & 0x000F; $V2 = $Day ^ $this->Seed_d & 0x00FF; $V3 = $Year ^ $this->Seed_d & 0x0FFF; $V1 = sprintf("%X", $V1); $V2 = sprintf("%X", $V2); $V3 = sprintf("%X", $V3); $S2 = $V1; $S8 = $this->p_chop($V2); $S10 = $this->p_chop($V2); $S12 = $this->p_chop($V3); $S6 = $this->p_chop($V3); $S4 = $this->p_chop($V3); } //========= Segment #1 ================================================== ==== $seed1 = $this->Seed1 ^ $this->Seed_storage1; $V3 =strlen($UserID) - 1; $V1 = ord(substr($UserID, 0, 1)) + ord(substr($UserID, 1, 1)) + ord(substr($UserID, floor(($V3 - 1) / 2), 1)) + ord(substr($UserID, $V3, 1)) + ord(substr($UserID, $V3 - 1, 1)); $V2 = ($seed1 % $V1) & 0x00FF; $STMP = sprintf("%02X", $V2); $S3 = $this->p_chop($STMP); $S1 = $this->p_chop($STMP); $V1 = strlen($UserID); if ($V1 > 16) { $S5 = '0'; } else { $S5 = sprintf("%X", $V1); } //========= Segment #2 ================================================== ==== $V1=0; $V2=0; $seed2 = $this->Seed2 ^ $this->Seed_storage2; for ($I1 = 0; $I1 < (strlen($UserID)); $I1++) { $V2 += ord(substr($UserID, $I1, 1)); } $V1 = (($V2 << 4) ^ $seed2) & 0x0FFF; $STMP = sprintf("%03X", $V1); $S11 = $this->p_chop ($STMP); $S9 = $this->p_chop ($STMP); $S7 = $this->p_chop ($STMP); //========= Segment #3 ================================================== ==== $V1=0; $V2=0; $STMP=""; $seed3 = $this->Seed3 ^ $this->Seed_storage3; for ($I1 = 0; $I1 < strlen($UserID); $I1++) { $V2 = $V2 + ord(substr($UserID, $I1, 1)); } $V2 = $V2 *floor( 0x7FFFFFF / $V2); $I2 = 31; for ($I1 = 1; $I1 <= 32; $I1++) { $V3 = (($seed3 << $I1) | ($seed3 >> $I2)) & 0xFFFFFFFF; $V3 = abs($V3); if ($V3 > $V2) { $V1 = $V3 % $V2; } else { $V1 = $V2 % $V3; } $STMP .= sprintf("%03X", $V1 & 0xFFF); $I2--; } $S13 = substr($STMP, 0, $this->RegCodeSize - 12); return $S1.$S2.$S3.$S4.$S5.$S6.$S7.$S8.$S9.$S10.$S11.$S12 .$S13; } } ?> |
WarrenAlexander
| Posted on Friday, March 04, 2005 - 6:17 am: | |
Whoops - here it is again without the debug echos and with ability to deal with non-expiring registration codes (call GenerateCode method without ExpireDays argument) <?php class RegGen { var $Seed1; var $Seed2; var $Seed3; var $Seed_storage1; var $Seed_storage2; var $Seed_storage3; var $Seed_d; var $RegCodeSize; function RegGen($seed1,$seed2,$seed3) { $this->Seed1=$seed1; $this->Seed2=$seed2; $this->Seed3=$seed3; $this->Seed_storage1 = 0x541D ; $this->Seed_storage2 = 0x9C41; $this->Seed_storage3 = 0xA460; $this->Seed_d = 0x45B7; $this->RegCodeSize=20; } function SetRegCodeSize($Size=20) { $this->RegCodeSize=$Size; } function SetSeeds($seed1,$seed2,$seed3) { $this->Seed1=$seed1; $this->Seed2=$seed2; $this->Seed3=$seed3; } function SetStorageValues($seed_storage1, $seed_storage2, $seed_storage3, $seed_d) { $this->Seed_storage1 = hexdec($seed_storage1) ; $this->Seed_storage2 = hexdec($seed_storage2); $this->Seed_storage3 = hexdec($seed_storage3); $this->Seed_d = hexdec($seed_d); } function p_chop(&$string) { $endchar = substr("$string", strlen("$string") - 1, 1); if ($endchar != "\n") { $string = substr("$string", 0, -1); } return $endchar; } function GenerateCode($UserID,$ExpireDays=0) { if(strlen($UserID)<5 || strlen($UserID)>108) return false; if($ExpireDays==0) { $Month=12; $Day=30; $Year=1899; } else { $exp_date = mktime (0,0,0,date("m") ,date("d")+$ExpireDays,date("Y")); $Month = date('n',$exp_date); $Day = date('j',$exp_date); $Year = date('Y',$exp_date); } $V1 = $Month ^ $this->Seed_d & 0x000F; $V2 = $Day ^ $this->Seed_d & 0x00FF; $V3 = $Year ^ $this->Seed_d & 0x0FFF; $V1 = sprintf("%X", $V1); $V2 = sprintf("%X", $V2); $V3 = sprintf("%X", $V3); $S2 = $V1; $S8 = $this->p_chop($V2); $S10 = $this->p_chop($V2); $S12 = $this->p_chop($V3); $S6 = $this->p_chop($V3); $S4 = $this->p_chop($V3); //========= Segment #1 ================================================== ==== $seed1 = $this->Seed1 ^ $this->Seed_storage1; $V3 =strlen($UserID) - 1; $V1 = ord(substr($UserID, 0, 1)) + ord(substr($UserID, 1, 1)) + ord(substr($UserID, floor(($V3 - 1) / 2), 1)) + ord(substr($UserID, $V3, 1)) + ord(substr($UserID, $V3 - 1, 1)); $V2 = ($seed1 % $V1) & 0x00FF; $STMP = sprintf("%02X", $V2); $S3 = $this->p_chop($STMP); $S1 = $this->p_chop($STMP); $V1 = strlen($UserID); if ($V1 > 16) { $S5 = '0'; } else { $S5 = sprintf("%X", $V1); } //========= Segment #2 ================================================== ==== $V1=0; $V2=0; $seed2 = $this->Seed2 ^ $this->Seed_storage2; for ($I1 = 0; $I1 < (strlen($UserID)); $I1++) { $V2 += ord(substr($UserID, $I1, 1)); } $V1 = (($V2 << 4) ^ $seed2) & 0x0FFF; $STMP = sprintf("%03X", $V1); $S11 = $this->p_chop ($STMP); $S9 = $this->p_chop ($STMP); $S7 = $this->p_chop ($STMP); //========= Segment #3 ================================================== ==== $V1=0; $V2=0; $STMP=""; $seed3 = $this->Seed3 ^ $this->Seed_storage3; for ($I1 = 0; $I1 < strlen($UserID); $I1++) { $V2 = $V2 + ord(substr($UserID, $I1, 1)); } $V2 = $V2 *floor( 0x7FFFFFF / $V2); $I2 = 31; for ($I1 = 1; $I1 <= 32; $I1++) { $V3 = (($seed3 << $I1) | ($seed3 >> $I2)) & 0xFFFFFFFF; $V3 = abs($V3); if ($V3 > $V2) { $V1 = $V3 % $V2; } else { $V1 = $V2 % $V3; } $STMP .= sprintf("%03X", $V1 & 0xFFF); $I2--; } $S13 = substr($STMP, 0, $this->RegCodeSize - 12); return $S1.$S2.$S3.$S4.$S5.$S6.$S7.$S8.$S9.$S10.$S11.$S12 .$S13; } } ?> |
Anonymous
| Posted on Saturday, February 04, 2006 - 5:33 pm: | |
I'm not very good in web programming (perl and php), but I want to incude regcode generator to my web site. Please post sample php script with input boxes for name, etc. |
|