Skip to content

Commit

Permalink
0.4.7 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nightflyza committed Nov 4, 2013
1 parent 2305c14 commit 1b09cd3
Show file tree
Hide file tree
Showing 87 changed files with 6,499 additions and 168 deletions.
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.6 rev 2939
0.4.7 rev 3042
1 change: 1 addition & 0 deletions api/apiloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
include('api/libs/api.ubim.php');
include('api/libs/api.snmp.php');
include('api/libs/api.mikrotik.php');
include('api/libs/api.watchdog.php');

/*
* Initial class creation
Expand Down
6 changes: 3 additions & 3 deletions api/libs/api.address.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ function web_CitySelectorAc() {
$selector.='<option value="'.$eachcity['id'].'">'.$eachcity['cityname'].'</option>';
}
}
$selector.='</select> <a href="?module=city">'. web_city_icon().'</a>';
$selector.='</select> <a href="?module=city" target="_BLANK">'. web_city_icon().'</a>';
return ($selector);
}

Expand All @@ -414,7 +414,7 @@ function web_StreetSelectorAc($cityid) {
$selector.='<option value="'.$eachstreet['id'].'">'.$eachstreet['streetname'].'</option>';
}
}
$selector.='</select> <a href="?module=streets">'. web_street_icon().'</a>';
$selector.='</select> <a href="?module=streets" target="_BLANK">'. web_street_icon().'</a>';
return ($selector);
}

Expand All @@ -439,7 +439,7 @@ function web_BuildSelectorAc($streetid) {
$selector.='<option value="'.$eachbuild['id'].'">'.$eachbuild['buildnum'].'</option>';
}
}
$selector.='</select> <a href="?module=builds&action=edit&streetid='.$streetid.'">'. web_build_icon().'</a>';
$selector.='</select> <a href="?module=builds&action=edit&streetid='.$streetid.'" target="_BLANK">'. web_build_icon().'</a>';
return ($selector);
}

Expand Down
15 changes: 15 additions & 0 deletions api/libs/api.cess.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,4 +779,19 @@ function web_NdsPaymentsShowYear($year) {
show_window(__('Payments by').' '.$year, $result);
}

function zb_RegContrAhentSelect($name,$selected='') {
$allagents=zb_ContrAhentGetAllData();
$agentArr=array();

$select='<select name="regagent">';
if (!empty ($allagents)) {
foreach ($allagents as $io=>$eachagent) {
$agentArr[$eachagent['id']]=$eachagent['contrname'];
}

}
$select= wf_Selector($name, $agentArr, '', $selected, false);
return($select);
}

?>
6 changes: 6 additions & 0 deletions api/libs/api.compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ function curmonth() {
return($currentmonth);
}

//returns previous month in mysql DATETIME view
function prevmonth() {
$result=date("Y-m", strtotime("-1 months"));
return ($result);
}

//returns current year
function curyear() {
$currentyear=date("Y");
Expand Down
43 changes: 34 additions & 9 deletions api/libs/api.networking.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,30 @@ function handle_dhcp_rebuild_option82($netid,$confname) {
foreach ($allhosts as $io=>$eachhost) {
$dhcphostname='m'. str_replace('.', 'x', $eachhost['ip']);
$options=explode('|',$eachhost['option']);
$result.='
class "'.$dhcphostname.'" {
match if binary-to-ascii (10, 8, "", option agent.remote-id) = "'.$options[0].'" and binary-to-ascii (10, 8, "", option agent.circuit-id) = "'.$options[1].' ";
}
$customTemplate= file_get_contents(CONFIG_PATH."dhcp/option82.template");
if (empty($customTemplate)) {
$customTemplate='
class "{HOSTNAME}" {
match if binary-to-ascii (16, 8, "", option agent.remote-id) = "{REMOTEID}" and binary-to-ascii (10, 8, "", option agent.circuit-id) = "{CIRCUITID}";
}
pool {
range {IP};
allow members of "{HOSTNAME}";
}
'."\n";
}

if (isset($options[1])) {
$parseTemplate=$customTemplate;
$parseTemplate=str_ireplace('{HOSTNAME}', $dhcphostname, $parseTemplate);
$parseTemplate=str_ireplace('{REMOTEID}', $options[0], $parseTemplate);
$parseTemplate=str_ireplace('{CIRCUITID}', $options[1], $parseTemplate);
$parseTemplate=str_ireplace('{IP}', $eachhost['ip'], $parseTemplate);

pool {
range '.$eachhost['ip'].';
allow members of "'.$dhcphostname.'";
}
'."\n";
$result.=$parseTemplate;
}

}

file_put_contents($confpath, $result);
Expand Down Expand Up @@ -567,6 +581,16 @@ function multinet_rebuild_globalconf() {
$subnets_template=file_get_contents("config/dhcp/subnets.template");
$alldhcpsubnets_q="SELECT `id`,`netid` from `dhcp` ORDER BY `id` ASC";
$alldhcpsubnets=simple_queryall($alldhcpsubnets_q);
$allMembers_q="SELECT `ip` from `nethosts` WHERE `option` != 'NULL'";
$allMembers= simple_queryall($allMembers_q);
$membersMacroContent='';
if (!empty($allMembers)) {
foreach ($allMembers as $ix=>$eachMember) {
$memberClass='m'.str_replace('.', 'x', $eachMember['ip']);;
$membersMacroContent.='deny members of "'.$memberClass.'";'."\n";
}
}

$subnets='';
if (!empty ($alldhcpsubnets)) {
foreach ($alldhcpsubnets as $io=>$eachnet) {
Expand All @@ -593,6 +617,7 @@ function multinet_rebuild_globalconf() {
}

$globdata['{SUBNETS}']=$subnets;
$globdata['{DENYMEMBERS}']=$membersMacroContent;
$globconf=multinet_ParseTemplate($global_template,$globdata);
file_write_contents("multinet/dhcpd.conf", $globconf);
}
Expand Down
106 changes: 75 additions & 31 deletions api/libs/api.userreg.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function zb_rand_string($size=4) {
return ($string);
}


function zb_rand_digits($size=4) {
$characters = '0123456789';
$string = "";
Expand Down Expand Up @@ -74,6 +75,7 @@ function checkapt()
return ($result);
}



function web_UserRegFormLocation() {
$aptsel='';
Expand All @@ -97,11 +99,22 @@ function web_UserRegFormLocation() {
}

if (isset($_POST['buildsel'])) {
$submit_btn='';
$builddata=zb_AddressGetBuildData($_POST['buildsel']);
$buildsel=$builddata['buildnum'].'<input type="hidden" name="buildsel" value="'.$builddata['id'].'">';
$aptsel=web_AddressBuildShowAptsCheck($builddata['id']).web_AptCreateForm();
$servicesel=multinet_service_selector();
$submit_btn='
//contrahens user diff
$alter_conf= rcms_parse_ini_file(CONFIG_PATH."alter.ini");
if (isset($alter_conf['LOGIN_GENERATION'])) {
if ($alter_conf['LOGIN_GENERATION']=='DEREBAN') {
$agentCells=wf_TableCell(zb_RegContrAhentSelect('regagent', $alter_conf['DEFAULT_ASSIGN_AGENT']));
$agentCells.=wf_TableCell(__('Contrahent name'));
$submit_btn.=wf_TableRow($agentCells, 'row2');

}
}
$submit_btn.='
<tr class="row3">
<td><input type="submit" value="'.__('Save').'"></td> <td></td>
</tr>
Expand Down Expand Up @@ -130,6 +143,7 @@ function web_UserRegFormLocation() {
<tr class="row3">
<td>'.$servicesel.'</td> <td>'.__('Service').'</td>
</tr>
<br>
'.$submit_btn.'
</form>
</table>
Expand All @@ -150,7 +164,7 @@ function zb_AllBusyLogins() {
return ($result);
}

function zb_RegLoginProposal($cityalias,$streetalias,$buildnum,$apt,$ip_proposal) {
function zb_RegLoginProposal($cityalias,$streetalias,$buildnum,$apt,$ip_proposal,$agentid='') {
$alterconf=rcms_parse_ini_file(CONFIG_PATH."alter.ini");
$result='';
if (isset($alterconf['LOGIN_GENERATION'])) {
Expand Down Expand Up @@ -185,24 +199,29 @@ function zb_RegLoginProposal($cityalias,$streetalias,$buildnum,$apt,$ip_proposal
}
}
}
//use five five digits increment

//use five five digits increment with zero prefix
if ($type=='INCREMENTFIVE') {
$busylogins=zb_AllBusyLogins();
$prefix='';

$prefixSize=5;
for ($i=1;$i<100000;$i++) {

if ($i<10000) { $prefix='0'; }

if ($i<1000) { $prefix='00'; }

if ($i<100) { $prefix='000'; }

if ($i<10) { $prefix='0000'; }

if (!isset($busylogins[$prefix.$i])) {
$result=$prefix.$i;
$nextIncrementFiveProposal=sprintf('%0'.$prefixSize.'d', $i);
if (!isset($busylogins[$nextIncrementFiveProposal])) {
$result=$nextIncrementFiveProposal;
break;
}
}

}

//use five six digits increment with zero prefix
if ($type=='INCREMENTSIX') {
$busylogins=zb_AllBusyLogins();
$prefixSize=6;
for ($i=1;$i<1000000;$i++) {
$nextIncrementFiveProposal=sprintf('%0'.$prefixSize.'d', $i);
if (!isset($busylogins[$nextIncrementFiveProposal])) {
$result=$nextIncrementFiveProposal;
break;
}
}
Expand All @@ -212,21 +231,13 @@ function zb_RegLoginProposal($cityalias,$streetalias,$buildnum,$apt,$ip_proposal
//use five five digits increment
if ($type=='INCREMENTFIVEREV') {
$busylogins=zb_AllBusyLogins();
$prefix='';

$prefixSize=5;
for ($i=1;$i<100000;$i++) {

if ($i<10000) { $prefix='0'; }

if ($i<1000) { $prefix='00'; }

if ($i<100) { $prefix='000'; }

if ($i<10) { $prefix='0000'; }

if (!isset($busylogins[$i.$prefix])) {
$result=$prefix.$i;
$result= strrev($result);
$nextIncrementFiveRevProposal=sprintf('%0'.$prefixSize.'d', $i);
$nextIncrementFiveRevProposal= strrev($nextIncrementFiveRevProposal);
if (!isset($busylogins[$nextIncrementFiveRevProposal])) {
$result=$nextIncrementFiveRevProposal;
break;
}
}
Expand Down Expand Up @@ -255,6 +266,20 @@ function zb_RegLoginProposal($cityalias,$streetalias,$buildnum,$apt,$ip_proposal
$result=zb_rand_string(10);
}

//contrahent based model
if ($type=='DEREBAN') {
$busylogins=zb_AllBusyLogins();
$agentPrefix=$agentid;
$prefixSize=6;
for ($i=1;$i<1000000;$i++) {
$nextIncrementDerProposal=$agentPrefix.sprintf('%0'.$prefixSize.'d', $i);
if (!isset($busylogins[$nextIncrementDerProposal])) {
$result=$nextIncrementDerProposal;
break;
}
}
}


///// if wrong option - use DEFAULT
if (empty($result)) {
Expand Down Expand Up @@ -298,9 +323,19 @@ function web_UserRegFormNetData($newuser_data) {
$newuser_data['apt']=0;
}
$apt=zb_TranslitString($newuser_data['apt']);
//assign some agent from previously selected form
if (isset($alterconf['LOGIN_GENERATION'])) {
if ($alterconf['LOGIN_GENERATION']=='DEREBAN') {
$agentPrefixID=$newuser_data['contrahent'];
} else {
$agentPrefixID='';
}
} else {
$agentPrefixID='';
}

$ip_proposal=multinet_get_next_freeip('nethosts', 'ip', multinet_get_service_networkid($newuser_data['service']));
$login_proposal= zb_RegLoginProposal($cityalias, $streetalias, $buildnum, $apt, $ip_proposal);
$login_proposal= zb_RegLoginProposal($cityalias, $streetalias, $buildnum, $apt, $ip_proposal,$agentPrefixID);
$password_proposal= zb_RegPasswordProposal();


Expand Down Expand Up @@ -472,6 +507,7 @@ function zb_UserRegister($user_data,$goprofile=true) {
zb_UserRegisterLog($login);
// if random mac needed
$billingconf=rcms_parse_ini_file(CONFIG_PATH.'/billing.ini');
$alterconf= rcms_parse_ini_file(CONFIG_PATH."alter.ini");
if ($billingconf['REGRANDOM_MAC']) {
// funny random mac, yeah? :)
$mac='14:'.'88'.':'.rand(10,99).':'.rand(10,99).':'.rand(10,99).':'.rand(10,99);
Expand All @@ -491,6 +527,14 @@ function zb_UserRegister($user_data,$goprofile=true) {
$billing->setdstat($login,$dstat);
log_register('CHANGE dstat ('.$login.') ON '.$dstat);
}

//set contract same as login for this user
if (isset($alterconf['CONTRACT_SAME_AS_LOGIN'])) {
if ($alterconf['CONTRACT_SAME_AS_LOGIN']) {
$newUserContract=$login;
zb_UserChangeContract($login, $newUserContract);
}
}

///////////////////////////////////
if ($goprofile) {
Expand Down
Loading

0 comments on commit 1b09cd3

Please sign in to comment.