Web design software and server change problem!
2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 4, 2024 (RSS)
By richo - April 4, 2024
I have recently changed server. When using CMS builder before the server change I would use for example:
<?php
require_once "/home/sites/theatremusicshop.com/public_html/cmsAdmin/lib/viewer_functions.php";
list($mp3Records, $mp3MetaData) = getRecords(array(
'tableName' => 'mp3',
'orderBy' => 'title asc',
'allowSearch' => '0',
'where' => "duo duet_tracks='yes'",
'perPage' => '250',
));
?>
Now it has changed to:
<?php require_once "/home/sites/30b/5/5c4a52752c/public_html/cmsAdmin/lib/viewer_functions.php";
list($mp3Records, $mp3MetaData) = getRecords(array(
'tableName' => 'mp3',
'orderBy' => 'title asc',
'allowSearch' => '0',
'where' => "comedy_tracks='yes'",
'perPage' => '250',
));
My software will not allow search and replace for over 100 pages!
I will have to go through each page and make the change but how can I future proof it in case I change server again please?
Maybe have one file to include the new server <?php require_once "/home/sites/30b/5/5c4a52752c/public_html/cmsAdmin/lib/viewer_functions.php";
Change
<?php require_once "/home/sites/theatremusicshop.com/public_html/cmsAdmin/lib/viewer_functions.php";
to
<?php require_once "/home/sites/30b/5/5c4a52752c/public_html/cmsAdmin/lib/viewer_functions.php";
Any help would be appreciated.
Thank you.
John
By Dave - April 4, 2024
Hi John,
By default the code generator should create a block of code like this at the top that is portable between servers:
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = ['','../','../../','../../../','../../../../']; // add if needed: '/home/sites/theatremusicshop.com/public_html/cmsAdmin/lib/viewer_functions.php'
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
So that's one option. Another option would be to have the files all load a single init.php file and put your server-specific code in that file.
But if your software allows you to replace 100 files at a time you could do that in a few iterations, or download another editor or ide that lets you replace many files.
Either way, be sure to backup everything first.
Hope that helps!
interactivetools.com