hey, this will help out EVERYBODY who wants to install a large amount of smilies into their phpbb forum. OK, the dev's at phpbb are very clever and have made it very easy to install smilies with the use of a .pak config file. HOWEVER, 99% of all smilie packs out there dont come with a .pak file.

I did some looking, and a .pak file has the syntax:

smilie_filename.gif=+:Smilie Description=+:smilie_code

Ideally all you have to do is replace smilie_filename.gif with the smilie's filename, Smilie Description with a description of the smilie and smilie_code with the actual code for the smilie. Upload smilies.pak to /phpbb/images/smiles/ where /phpbb is the directory of your phpBB2 installation. Now go to phpBB2 > Admin Panel > Smilies > Import Smiley Pak, select smilies.pak and import it

However, typing out hundreds of lines like this is just unneccessary.

SO! I consult my fellow genuises at phpfreaks. Can somebody help me make a simple script that will create a .pak file with the filename for the filename param, the filename for the description param, and the filename once again between two colons for the code for the code param.

EX.

icecream.gif=+:icecream=+:🍦

the only thing i don't understand is how php would be able to read the filenames of each smilie into the file!

Plz help, if it works I will give the proper credits and submit it to the phpbb official site, as many people would LOVE this script.

    is this what you were looking for.. im not familiar with .pak smilie files so im not sure if this is exactly right or if you wanted to do a whole directory at a time.. but im sure this is a big start in the right direction if it isn't the solution

    <?php
    #
    # takes a path to a directory, and output file name,
    # and a list of file types to look for
    #
    # creates/overwrites a .pak file in the specified directory
    #
    function dir2pak( $path, $pak_name='smilies', $allowed_extensions=array( 'gif', 'jpg', 'png', 'bmp' ) )
    {
        $line_break = "\n";
    
    if ( $path{-1} !== '/' &&  $path{-1} !== '\\\' ) {
        $path .= '/';
    }
    
    if ( !($dir=opendir($path)) ) {
        echo "dir2pak : Can't open dir ($path)";
        return false;
    }
    
    $file_contents = '';
    
    while (($item = readdir($dir)) !== false) {
        $item_path = $path.$item;
        $info = explode('.',basename($item));
        if ( !is_dir($item_path) && in_array($info[1],$allowed_extensions) ) {
            $file_contents .= "{$item}=+:{$info[0]}=+::{$info[0]}:{$line_break}";
        }
    }
    
    closedir($dir);
    
    if ( empty($file_contents) ) {
        echo "dir2pak : no allowed image files found";
        return false;
    }
    if ( !$pak_file = fopen("{$path}{$pak_name}.pak", 'w' ) ) {
        echo "dir2pak : can't open ({$path}{$pak_name}.pak)";
        return false;
    }
    if ( !fwrite($pak_file, $file_contents) ) {
        echo "dir2pak : can't write to ({$path}{$pak_name}.pak)";
        return false;
    }
    fclose($pak_file);
    return true;
    }
    
    echo dir2pak( './pics' ) ? 'you got a .pak file' : 'pak file creation failed';
    
    ?>
    
      Write a Reply...