Improvements for host selection, store ftn message in utf8

This commit is contained in:
Deon George 2021-07-05 23:17:00 +10:00
parent 5c5df12816
commit fe2784f98f
3 changed files with 11 additions and 9 deletions

View File

@ -203,6 +203,8 @@ class Message extends FTNBase
case 'msgid': return $this->kludge->get('msgid'); case 'msgid': return $this->kludge->get('msgid');
case 'message': case 'message':
return utf8_decode($this->{$key});
case 'subject': case 'subject':
case 'user_to': case 'user_to':
case 'user_from': case 'user_from':
@ -374,7 +376,7 @@ class Message extends FTNBase
* Anything after the origin line is also kludge data. * Anything after the origin line is also kludge data.
*/ */
if ($y = strpos($v,"\r * Origin: ")) { if ($y = strpos($v,"\r * Origin: ")) {
$this->message .= substr($v,$x+1,$y-$x-1); $this->message .= utf8_encode(substr($v,$x+1,$y-$x-1));
$this->parseOrigin(substr($v,$y)); $this->parseOrigin(substr($v,$y));
// If this is netmail, the FQFA will have been set by the INTL line, we can skip the rest of this // If this is netmail, the FQFA will have been set by the INTL line, we can skip the rest of this
@ -400,7 +402,7 @@ class Message extends FTNBase
// The message is the rest? // The message is the rest?
} elseif (strlen($v) > $x+1) { } elseif (strlen($v) > $x+1) {
$this->message .= substr($v,$x+1); $this->message .= utf8_encode(substr($v,$x+1));
} }
$v = substr($v,0,$x+1); $v = substr($v,0,$x+1);
@ -506,6 +508,7 @@ class Message extends FTNBase
* Translate the string into something printable via the web * Translate the string into something printable via the web
* *
* @param string $string * @param string $string
* @param array $skip
* @return string * @return string
*/ */
public static function tr(string $string,array $skip=[0x0a,0x0d]): string public static function tr(string $string,array $skip=[0x0a,0x0d]): string

View File

@ -67,6 +67,7 @@ class DomainController extends Controller
->when($region,function($query,$region) { return $query->where('region_id',$region)->where('node_id','<>',0); }) ->when($region,function($query,$region) { return $query->where('region_id',$region)->where('node_id','<>',0); })
->when((! $region),function($query) use ($region) { return $query->where('region_id',0); }) ->when((! $region),function($query) use ($region) { return $query->where('region_id',0); })
->where('point_id',0) ->where('point_id',0)
->FTNorder()
->with(['system']) ->with(['system'])
->get(); ->get();

View File

@ -79,22 +79,20 @@ class SystemController extends Controller
'host_id_new' => [ 'host_id_new' => [
'required', 'required',
new TwoByteInteger, new TwoByteInteger,
function ($attribute,$value,$fail) { function ($attribute,$value,$fail) use ($request) {
// Check that the region doesnt already exist // Check that the region doesnt already exist
$o = Address::where(function($query) use ($value) { $o = Address::where(function($query) use ($value) {
return $query->where('region_id',$value) return $query->where('region_id',$value)
->where('host_id',0)
->where('node_id',0)
->where('point_id',0)
->where('role',DomainController::NODE_RC); ->where('role',DomainController::NODE_RC);
}) })
// Check that a host doesnt already exist // Check that a host doesnt already exist
->orWhere(function($query) use ($value) { ->orWhere(function($query) use ($value) {
return $query->where('host_id',$value) return $query->where('host_id',$value)
->where('node_id',0)
->where('point_id',0)
->where('role',DomainController::NODE_NC); ->where('role',DomainController::NODE_NC);
}); })
->where('zone_id',$request->post('zone_id'))
->where('point_id',0)
->where('active',TRUE);
if ($o->count()) { if ($o->count()) {
$fail('Region or host already exists'); $fail('Region or host already exists');