phpbb3 style clone

Clone phpBB 3 Style

Submitted by CyberAlien, Apr 2007.
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.

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:

  1.  
  2. $src = ‘prosilver’;
     
  3. $dst = ‘test1’;
     

  4.  
  5. $ln = isset($_SERVER[‘HTTP_HOST’]) ? ‘
    ‘ : “n”;
     

  6.  
  7. echo ‘Copying ‘, $src, ‘ to ‘, $dst, ‘…’, $ln;
     

  8.  
  9. $files = array();
     
  10. get_files($src, ‘/’);
     

  11.  
  12. function get_files($base, $dir)
     
  13. {
     
  14.    global $files;
     
  15.    $res = opendir($base . $dir);
     
  16.    while(($file = readdir($res)) !== false)
     
  17.    {
     
  18.        if($file !== ‘.’ && $file !== ‘..’)
     
  19.        {
     
  20.            if(is_dir($base . $dir . $file))
     
  21.            {
     
  22.                get_files($base, $dir . $file . ‘/’);
     
  23.            }
     
  24.            else
     
  25.            {
     
  26.                $files[] = $dir . $file;
     
  27.            }
     
  28.        }
     
  29.    }
     
  30.    closedir($res);
     
  31. }
     

  32.  
  33. for($i=0; $i
  34. {
     
  35.    clone_file($src, $dst, $files[$i]);
     
  36. }
     

  37.  
  38. function clone_file($src, $dst, $file)
     
  39. {
     
  40.    $new = $dst . str_replace($src, $dst, $file);
     
  41.    $data = @file_get_contents($src . $file);
     
  42.    $list = explode(‘.’, strtolower($file));
     
  43.    $ext = $list[count($list) – 1];
     
  44.    if($ext === ‘html’ || $ext === ‘cfg’ || $ext === ‘css’ || $ext === ‘php’ || $ext === ‘txt’ || $ext === ‘js’ || $ext === ‘htm’)
     
  45.    {
     
  46.        $data = str_replace($src, $dst, $data);
     
  47.    }
     
  48.    $dirname = dirname($new);
     
  49.    if(strlen($dirname) && !@file_exists($dirname))
     
  50.    {
     
  51.        $list = explode(‘/’, $dirname);
     
  52.        $str = ”;
     
  53.        for($i=0; $i
  54.        {
     
  55.            $str .= (strlen($str) ? ‘/’ : ”) . $list[$i];
     
  56.            if(!@file_exists($str))
     
  57.            {
     
  58.                if(!@mkdir($str, 0777))
     
  59.                {
     
  60.                    echo ‘Cannot write cache file “‘ . $new . ‘”.’, $ln;
     
  61.                    return;
     
  62.                }
     
  63.            }
     
  64.        }
     
  65.    }
     
  66.    $f = @fopen($new, ‘w’);
     
  67.    if(!$f)
     
  68.    {
     
  69.        echo ‘Cannot write cache file “‘ . $new . ‘”.’, $ln;
     
  70.        return;
     
  71.    }
     
  72.    fputs($f, $data);
     
  73.    fclose($f);
     
  74.    chmod($new, 0777);
     
  75.    touch($new, filemtime($src . $file));
     
  76. }
     

  77.  
  78. echo ‘done!’;
     

  79.  
  80. ?> 
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.

Share this tutorial

If you want to show this tutorial to someone else please use following code to link to this tutorial:

HTML Link:
Clone phpBB 3 Style” class=”text” onclick=”this.focus(); this.select();”/>
Forum BBCode:

Content of this tutorial may not be published anywhere else without author’s permission. Please link to this page instead.