OpenSourceBikeShare
OpenSourceBikeShare copied to clipboard
Only change the lock code every few rides.
Although this turned out to be not practical in our case, it might be helpful for others.
$codereset=sprintf("%04d",rand(1,4));
if ($codereset == 3)
{
{ $newCode = sprintf("%04d",rand(100,9900));
}
}
if ($codereset != 3)
{
{ $newCode=$currentCode;
}
}
// do not create a code with more than one leading zero or more than two leading 9s (kind of unusual/unsafe).
if ($force==FALSE)
{
if ($currentUser==$userId)
{
response(_('You already rented bike')." ".$bikeNum.". "._('Code is')." ".$currentCode.".",ERROR);
return;
}
if ($currentUser!=0)
{
response(_('Bike')." ".$bikeNum." "._('is already rented').".",ERROR);
return;
}
}
if ($codereset == 3)
{
{ $message='<h3>'._('Bike').' '.$bikeNum.': <span class="label label-primary">'._('Open with code').' '.$currentCode.'.</span></h3>'._('Change code immediately to').' <span class="label label-default">'.$newCode.'</span><br />'._('(open, move pin on the bottom to position B, set new code, move pin back to position A)').'.';
}
}
if ($codereset != 3)
{
{ $message='<h3>'._('Bike').' '.$bikeNum.': <span class="label label-primary">'._('Open with code').' '.$currentCode.'.</span></h3>'._('You do not need to change the code').' .';
}
}
Thanks.
Please, @jozefbalun add this as a config option to the new Laravel version as well as implement it accordingly (or assign to @miroc).
Reasoning: some systems may want to change the code only from time to time, e.g. every 10th ride or such.