PHP Classes

File: database/migrations/v1.11.0.48_qwk_bbs_id_setting.php

Recommend this page to a friend!
  Packages of Matthew Asham   Binkterm PHP   database/migrations/v1.11.0.48_qwk_bbs_id_setting.php   Download  
File: database/migrations/v1.11.0.48_qwk_bbs_id_setting.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Binkterm PHP
Bulletin board system based on the Web
Author: By
Last change:
Date: 5 days ago
Size: 1,132 bytes
 

Contents

Class file image Download
<?php
/**
 * Migration: v1.11.0.48 - Populate qwk.bbs_id in bbs.json from system name
 *
 * Derives the BBSID using the same logic as QwkBuilder::getBbsId() and writes
 * it into config/bbs.json so future changes to the system name don't affect
 * the packet filename or CONTROL.DAT identifier.
 */

return function ($db) {
   
$config = \BinktermPHP\BbsConfig::getConfig();

   
// Only set if not already configured
   
if (!empty($config['qwk']['bbs_id'])) {
        echo
"qwk.bbs_id already set to \"{$config['qwk']['bbs_id']}\" ? skipping\n";
        return
true;
    }

   
// Derive BBSID from system name using same logic as QwkBuilder::getBbsId()
   
$binkpConfig = \BinktermPHP\Binkp\Config\BinkpConfig::getInstance();
   
$name = $binkpConfig->getSystemName();
   
$bbsId = strtoupper(preg_replace('/[^A-Za-z0-9]/', '', $name));
   
$bbsId = substr($bbsId, 0, 8);
    if (
$bbsId === '') {
       
$bbsId = 'BINKTERM';
    }

   
$config['qwk']['bbs_id'] = $bbsId;
    \
BinktermPHP\BbsConfig::saveConfig($config);

    echo
"Set qwk.bbs_id to \"{$bbsId}\" (derived from system name \"{$name}\")\n";
    return
true;
};