PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Silver_Eclipse
Forum Commoner
Posts: 61 Joined: Sun Aug 18, 2002 7:26 pm
Post
by Silver_Eclipse » Sun Oct 27, 2002 5:52 pm
Code: Select all
$templateFile = "$boarddir/template.php";
if (!file_exists($templateFile))
$templateFile = "$boarddir/template.html";
$file = fopen($templateFile,"r");
$fulltemplate = fread($file,filesize($templateFile));
$fulltemplate = preg_replace(".admin_color {
COLOR: (.*);}.gm_color {
COLOR: (.*);}.developer_color {
COLOR: (.*);}.modteam_color {
COLOR: (.*);}.users_color {
COLOR: (.*);}",".admin_color {
COLOR: {HTTP_POST_VARSї'admin_usercolor']};}.gm_color {
COLOR: {HTTP_POST_VARSї'globalmod_usercolor']};}.developer_color {
COLOR: {HTTP_POST_VARSї'developer_usercolor']};}.modteam_color {
COLOR: {HTTP_POST_VARSї'mod_usercolor']};}.users_color {
COLOR: {HTTP_POST_VARSї'users_usercolor']};}",$fulltemplate);
$fh = fopen($boarddir/template.php,'w');
fputs ($fh,$fulltemplate);
fclose($fh);
can someone please tell me what is wrong with this code, i have been editing it over and over and it still doesnt work right. Thanks.
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sun Oct 27, 2002 6:30 pm
try putting a $ infront of all the HTTP_POST_VARS
and escape the {'s (unless they are supposed to be there for literals)
Silver_Eclipse
Forum Commoner
Posts: 61 Joined: Sun Aug 18, 2002 7:26 pm
Post
by Silver_Eclipse » Sun Oct 27, 2002 6:32 pm
*smacks himself* how could i forget the $'s doh thanks i'll try that
Edit: Still doesnt work
Silver_Eclipse
Forum Commoner
Posts: 61 Joined: Sun Aug 18, 2002 7:26 pm
Post
by Silver_Eclipse » Sun Oct 27, 2002 6:35 pm
also those {'s that arent around the $HTTP_POST_VARS are part of the pattern that i'm trying to replace(the file has css in it)
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sun Oct 27, 2002 7:19 pm
try something like...
Code: Select all
$exps = array(
"1" => "(\.admin_color \{ COLOR: )(.*)(;\})",
"2" => "(\.gm_color \{ COLOR: )(.*)(;\})",
"3" => "(\.developer_color \{ COLOR: )(.*)(;\})",
"4" => "(\.modteam_color \{ COLOR: )(.*)(;\})",
"5" => "(\.users_color \{ COLOR: )(.*)(;\})"
);
$reps = array(
"1" => "\\1{$HTTP_POST_VARSї'admin_usercolor']}\\3",
"2" => "\\1{$HTTP_POST_VARSї'globalmod_usercolor']}\\3",
"3" => "\\1{$HTTP_POST_VARSї'developer_usercolor']}\\3",
"4" => "\\1{$HTTP_POST_VARSї'mod_usercolor']}\\3",
"5" => "\\1{$HTTP_POST_VARSї'users_usercolor']}\\3"
);
$fulltemplate = preg_replace($exps, $reps, $fulltemplate);
Silver_Eclipse
Forum Commoner
Posts: 61 Joined: Sun Aug 18, 2002 7:26 pm
Post
by Silver_Eclipse » Mon Oct 28, 2002 4:26 pm
in:
Code: Select all
"1" => "\\1{$HTTP_POST_VARSї'admin_usercolor']}\\3",
what is the \\1 and \\3 for? also the (.*) sould be the only thing replaced by the variables the rest needs to be put back in.(also i tried it and still doesnt work and i have no idea why, i always have trouble with changeing flat files.