MyBB Community Forums

Full Version: Update to use new Templates::render function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
A quick script to do the conversion. There are a few bits left over that need manual prodding due to not following the pattern but those can be found with a grep for 'eval('

#!/bin/bash


for f in $1/*.php
do 
    sed -r --in-place 's#eval[(]"\\[$](.*?) = \\""\.[$]templates->get[(]([^,]*?)[)]\."\\";"[)];#$\1 = eval($templates->render(\2));#g' $f
    sed -r --in-place 's#eval[(]"\\[$](.*?) .= \\""\.[$]templates->get[(]([^,]*?)[)]\."\\";"[)];#$\1 .= eval($templates->render(\2));#g' $f
    sed -r --in-place 's#eval[(]"\\[$](.*?) = \\""\.[$]templates->get[(]([^,]*?), (.*?)[)]\."\\";"[)];#$\1 = eval($templates->render(\2, \3));#g' $f
    sed -r --in-place 's#eval[(]"\\[$](.*?) .= \\""\.[$]templates->get[(]([^,]*?), (.*?)[)]\."\\";"[)];#$\1 .= eval($templates->render(\2, \3));#g' $f
    
    sed -r --in-place "s#eval[(]'[$](.*?) = \"'\.[$]templates->get[(]'([^,]*?)'[)]\.'\";'[)];#$\1 = eval(\$templates->render(\"\2\"));#g" $f
    sed -r --in-place "s#eval[(]'[$](.*?) .= \"'\.[$]templates->get[(]'([^,]*?)'[)]\.'\";'[)];#$\1 .= eval(\$templates->render(\"\2\"));#g" $f
    sed -r --in-place "s#eval[(]'[$](.*?) = \"'\.[$]templates->get[(]'([^,]*?)', (.*?)[)]\.'\";'[)];#$\1 = eval(\$templates->render(\"\2\", \3));#g" $f
    sed -r --in-place "s#eval[(]'[$](.*?) .= \"'\.[$]templates->get[(]'([^,]*?)', (.*?)[)]\.'\";'[)];#$\1 .= eval(\$templates->render(\"\2\", \3));#g" $f
done

Use:
script.sh path/to/mybb
script.sh path/to/mybb/inc