Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Продление/покупка лицензии #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions simpla/LicenseAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,41 @@ public function fetch()


$this->design->assign('license', $l);

if (! $l->valid) {
$end = date("Y-m-d", time()+60*60*24*31); // на 31 день
$c = '';
for($i=0; $i<rand(30, 40); $i++)
{
$c .= rand(0,9);
}
$license = $h.'#'.$end.'#'.$c;
$y = pow($g, $x) % $p; // same as x

$message = bin2hex($license);
$message = str_split($message, 4);

$key = '';
$shift = $x;

foreach($message as $block)
{
$block = base_convert($block, 16, 10);
$enc_block = '';
for($i = 0; $i < strlen($block); $i++)
{
$k = rand(2, $p - 1);
$a = pow($g, $k) % $p + ($i + $shift) % 26;
$b = ( (pow($y % $p, $k) % $p) * ($block[$i]) ) % $p + ($i + $shift) % 25;

$enc_block .= base_convert($a, 10, 36).base_convert($b, 10, 36);
}
$key .= $enc_block.' ';
$shift += $x;
}

$this->design->assign('testlicense', $key);
}

return $this->design->fetch('license.tpl');
}
Expand Down
12 changes: 10 additions & 2 deletions simpla/design/html/license.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{/capture}

<!-- Основная форма -->
<form method=post id=product enctype="multipart/form-data">
<form method=post id="product" name="license" enctype="multipart/form-data">
<input type=hidden name="session_id" value="{$smarty.session.id}">
<!-- Левая колонка свойств товара -->
<div id="column_left">
Expand All @@ -20,7 +20,15 @@
</div>
<div class=block>
<input class="button_green button_save" type="submit" name="" value="Сохранить"/>
<a href='http://simplacms.ru/check?domain={$smarty.server.HTTP_HOST|escape}'>Проверить лицензию</a>
{if $license->valid}
{if $license->expiration != '*'}
<a href='http://simplacms.ru/buy.html'>Купить лицензию</a>
{else}
<a href='http://simplacms.ru/check?domain={$smarty.server.HTTP_HOST|escape}'>Проверить лицензию</a>
{/if}
{else}
<input type='button' value='Продлить' onclick="document.license.license.value='{$testlicense|escape}';">
{/if}
</div>
</div>

Expand Down