-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4c2e8c
commit a52862a
Showing
3 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* | ||
* @author Putra Sudaryanto <[email protected]> | ||
* @contact (+62)856-299-4114 | ||
* @copyright Copyright (c) 2018 Ommu Platform (opensource.ommu.co) | ||
* @copyright Copyright (c) 2018 Ommu Platform (www.ommu.co) | ||
* @created date 17 April 2018, 08:36 WIB | ||
* @link https://github.com/ommu/yii-traits | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* | ||
* @author Putra Sudaryanto <[email protected]> | ||
* @contact (+62)856-299-4114 | ||
* @copyright Copyright (c) 2018 Ommu Platform (opensource.ommu.co) | ||
* @copyright Copyright (c) 2018 Ommu Platform (www.ommu.co) | ||
* @created date 17 April 2018, 08:36 WIB | ||
* @link https://github.com/ommu/yii-traits | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* | ||
* @author Putra Sudaryanto <[email protected]> | ||
* @contact (+62)856-299-4114 | ||
* @copyright Copyright (c) 2018 Ommu Platform (opensource.ommu.co) | ||
* @copyright Copyright (c) 2018 Ommu Platform (www.ommu.co) | ||
* @created date 12 May 2018, 22:47 WIB | ||
* @link https://github.com/ommu/yii-traits | ||
* | ||
|
@@ -79,7 +79,7 @@ public function flashMessage($message, $class='success') | |
/** | ||
* User salt codes | ||
*/ | ||
public static function uniqueCode($length=32, $str=2) | ||
public function uniqueCode($length=32, $str=2) | ||
{ | ||
$chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
srand((double)microtime()*time()); | ||
|
@@ -95,4 +95,31 @@ public static function uniqueCode($length=32, $str=2) | |
|
||
return $salt; | ||
} | ||
|
||
/** | ||
* get License | ||
*/ | ||
public function getLicense($source='1234567890', $length=16, $char=4) | ||
{ | ||
$mod = $length%$char; | ||
if($mod == 0) | ||
$sep = ($length/$char); | ||
else | ||
$sep = (int)($length/$char)+1; | ||
|
||
$sourceLength = strlen($source); | ||
$random = ''; | ||
for ($i = 0; $i < $length; $i++) | ||
$random .= $source[rand(0, $sourceLength - 1)]; | ||
|
||
$license = ''; | ||
for ($i = 0; $i < $sep; $i++) { | ||
if($i != $sep-1) | ||
$license .= substr($random,($i*$char),$char).'-'; | ||
else | ||
$license .= substr($random,($i*$char),$char); | ||
} | ||
|
||
return $license; | ||
} | ||
} |