Clone phpBB 3 Style
This tutorial explains how to clone phpBB 3 style. Cloning phpBB style is needed when you want to create a new style based on some other style.
There are two ways of doing it: manual and automated.
There are two ways of doing it: manual and automated.
Manual Cloning
1. Copy directory styles/prosilver/ to styles/newstyle/ (rename it as you want).
2. Rename style in styles/newstyle/style.cfg, styles/newstyle/imageset/imageset.cfg, styles/newstyle/template/template.cfg, styles/newstyle/theme/theme.cfg
That’s all. New style should be installable in admin control panel. If it isn’t, then you forgot to edit some cfg file.
Automated Cloning
Create file “clone.php” in directory “styles”, put this code in it:
Code:
Â- $src = ‘prosilver’;
 - $dst = ‘test1’;
Â
Â- $ln = isset($_SERVER[‘HTTP_HOST’]) ? ‘
‘ : “n”;
Â
Â- echo ‘Copying ‘, $src, ‘ to ‘, $dst, ‘…’, $ln;
Â
Â- $files = array();
 - get_files($src, ‘/’);
Â
Â- function get_files($base, $dir)
 - {
 -   global $files;
 -   $res = opendir($base . $dir);
 -   while(($file = readdir($res)) !== false)
 -   {
 -     if($file !== ‘.’ && $file !== ‘..’)
 -     {
 -       if(is_dir($base . $dir . $file))
 -       {
 -         get_files($base, $dir . $file . ‘/’);
 -       }
 -       else
 -       {
 -         $files[] = $dir . $file;
 -       }
 -     }
 -   }
 -   closedir($res);
 - }
Â
Â- for($i=0; $i
- {
 -   clone_file($src, $dst, $files[$i]);
 - }
Â
Â- function clone_file($src, $dst, $file)
 - {
 -   $new = $dst . str_replace($src, $dst, $file);
 -   $data = @file_get_contents($src . $file);
 -   $list = explode(‘.’, strtolower($file));
 -   $ext = $list[count($list) – 1];
 -   if($ext === ‘html’ || $ext === ‘cfg’ || $ext === ‘css’ || $ext === ‘php’ || $ext === ‘txt’ || $ext === ‘js’ || $ext === ‘htm’)
 -   {
 -     $data = str_replace($src, $dst, $data);
 -   }
 -   $dirname = dirname($new);
 -   if(strlen($dirname) && !@file_exists($dirname))
 -   {
 -     $list = explode(‘/’, $dirname);
 -     $str = ”;
 -     for($i=0; $i
- Â Â Â Â {
 -       $str .= (strlen($str) ? ‘/’ : ”) . $list[$i];
 -       if(!@file_exists($str))
 -       {
 -         if(!@mkdir($str, 0777))
 -         {
 -           echo ‘Cannot write cache file “‘ . $new . ‘”.’, $ln;
 -           return;
 -         }
 -       }
 -     }
 -   }
 -   $f = @fopen($new, ‘w’);
 -   if(!$f)
 -   {
 -     echo ‘Cannot write cache file “‘ . $new . ‘”.’, $ln;
 -     return;
 -   }
 -   fputs($f, $data);
 -   fclose($f);
 -   chmod($new, 0777);
 -   touch($new, filemtime($src . $file));
 - }
Â
Â- echo ‘done!’;
Â
Â- ?>Â
On line 3 replace “prosilver” with name of style you are copying from, on line 4 replace “test1” with name of style you are copying to.
Make sure script can write to directory “templates”. Best way to do it is to run this script on test forum on your own computer instead of remote server.
Then run that script once. It will copy all files and rename it.
Make sure script can write to directory “templates”. Best way to do it is to run this script on test forum on your own computer instead of remote server.
Then run that script once. It will copy all files and rename it.
Share this tutorial
Â