Page 1 of 1

HELP: Problem saving a file.

Posted: Fri Oct 29, 2004 3:16 pm
by RyanGatewood
I am having trouble getting my config editor to work. It will save the first few lines of info, but not the rest.... Here is the code:

editform.php

Code: Select all

<?php
session_start(); 
header("Cache-control: private"); // IE 6 Fix.
if (empty($usernamein)) {
include("../header.php");
   print("Sorry You are not logged in, please <a href='/admin/'>login</a>.");
include("../footer.php");
die();
};
require("../users/$usernamein/config.php");
include("../header.php");
?>

       <form method="POST" action="editconfig.php">
        <table border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse" width="530" id="AutoNumber2">
          <tr>
            <td width="522" colspan="2">
            <p align="left"><u><b><font color="#F7DE0F" size="2">General Account 
            Settings</font></b></u></td>
          </tr>
          <tr>
            <td width="159" align="right">Display Name:</td>
            <td width="363">
            <input type="text" name="new_displayname" size="20" value="<?php echo"$displayname" ?>" maxlength="20"></td>
          </tr>
          <tr>
            <td width="159" align="right">Email Address:</td>
            <td width="363">
            <input type="text" name="new_emailaddress" size="20" value="<?php echo"$emailaddress" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Password:</td>
            <td width="363">
            <input type="password" name="new_password" size="20"value="<?php echo"$password" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Password Again:</td>
            <td width="363">
            <input type="password" name="passcheck" size="20" value="<?php echo"$password" ?>"></td>
          </tr>
          <tr>
            <td width="522" align="right" colspan="2">
            <p align="left"><u><font size="2" color="#F7DE0F"><b>Text Line 1 
            Settings</b></font></u></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Size:</td>
            <td width="363">
      <input type="text" name="new_text1size" size="1" maxlength="1" value="<?php echo"$text1size" ?>">
           
            </td>
          </tr>
          <tr>
            <td width="159" align="right">Text X Psition:</td>
            <td width="363">
            <input type="text" name="new_text1x" size="3" maxlength="3" value="<?php echo"$text1x" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Y Position:</td>
            <td width="363">
            <input type="text" name="new_text1y" size="3" maxlength="3" value="<?php echo"$text1y" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Color:<font size="1" color="#F7DE0F">(in 
            RGB format)</font></td>
            <td width="363">
            <input type="text" name="new_text1color1" size="3" maxlength="3" value="<?php echo"$text1color1" ?>">
            <input type="text" name="new_text1color2" size="3" maxlength="3" value="<?php echo"$text1color2" ?>">
            <input type="text" name="new_text1color3" size="3" maxlength="3" value="<?php echo"$text1color3" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text String:</td>
            <td width="363"><select size="1" name="new_text1string">
            <option value="Artist: $artist" selected>Artist</option>
            <option value="$onoff">File Name</option>
            <option value="Track: $title">Track</option>
            <option value="Album: $album">Album</option>
            </select></td>
          </tr>
          <tr>
            <td width="522" align="right" colspan="2">
            <p align="left"><u><font size="2" color="#F7DE0F"><b>Text Line 2 
            Settings</b></font></u></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Size:</td>
            <td width="363">
      <input type="text" name="new_text2size" size="1" maxlength="1" value="<?php echo"$text2size" ?>">
           
            </td>
          </tr>
          <tr>
            <td width="159" align="right">Text X Psition:</td>
            <td width="363">
            <input type="text" name="new_text2x" size="3" maxlength="3" value="<?php echo"$text2x" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Y Position:</td>
            <td width="363">
            <input type="text" name="new_text2y" size="3" maxlength="3" value="<?php echo"$text2y" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Color:<font size="1" color="#F7DE0F">(in 
            RGB format)</font></td>
            <td width="363">
            <input type="text" name="new_text2color1" size="3" maxlength="3" value="<?php echo"$text2color1" ?>">
            <input type="text" name="new_text2color2" size="3" maxlength="3" value="<?php echo"$text2color2" ?>">
            <input type="text" name="new_text2color3" size="3" maxlength="3" value="<?php echo"$text2color3" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text String:</td>
            <td width="363"><select size="1" name="new_text2string">
            <option value="Artist: $artist">Artist</option>
            <option value="$onoff">File Name</option>
            <option value="Track: $title" selected>Track</option>
            <option value="Album: $album">Album</option>
            </select></td>
          </tr>
          <tr>
            <td width="522" align="right" colspan="2">
            <p align="left"><u><font size="2" color="#F7DE0F"><b>Text Line 3 
            Settings</b></font></u></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Size:</td>
            <td width="363">
      <input type="text" name="new_text3size" size="1" maxlength="1" value="<?php echo"$text3size" ?>">
           
            </td>
          </tr>
          <tr>
            <td width="159" align="right">Text X Psition:</td>
            <td width="363">
            <input type="text" name="new_text3x" size="3" maxlength="3" value="<?php echo"$text3x" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Y Position:</td>
            <td width="363">
            <input type="text" name="new_text3y" size="3" maxlength="3" value="<?php echo"$text3y" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Color:<font size="1" color="#F7DE0F">(in 
            RGB format)</font></td>
            <td width="363">
            <input type="text" name="new_text3color1" size="3" maxlength="3" value="<?php echo"$text3color1" ?>">
            <input type="text" name="new_text3color2" size="3" maxlength="3" value="<?php echo"$text3color2" ?>">
            <input type="text" name="new_text3color3" size="3" maxlength="3" value="<?php echo"$text3color3" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text String:</td>
            <td width="363"><select size="1" name="new_text3string">
            <option value="Artist: $artist">Artist</option>
            <option value="$onoff">File Name</option>
            <option value="Track: $title">Track</option>
            <option value="Album: $album" selected>Album</option>
            </select></td>
          </tr>
          <tr>
            <td width="522" align="right" colspan="2">
            <p align="left"><u><font size="2" color="#F7DE0F"><b>Text Line 4 
            Settings</b></font></u></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Size:</td>
            <td width="363">
      <input type="text" name="new_text4size" size="1" maxlength="1" value="<?php echo"$text4size" ?>">
           
            </td>
          </tr>
          <tr>
            <td width="159" align="right">Text X Psition:</td>
            <td width="363">
            <input type="text" name="new_text4x" size="3" maxlength="3" value="<?php echo"$text4x" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Y Position:</td>
            <td width="363">
            <input type="text" name="new_text4y" size="3" maxlength="3" value="<?php echo"$text4y" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text Color:<font size="1" color="#F7DE0F">(in 
            RGB format)</font></td>
            <td width="363">
            <input type="text" name="new_text4color1" size="3" maxlength="3" value="<?php echo"$text4color1" ?>">
            <input type="text" name="new_text4color2" size="3" maxlength="3" value="<?php echo"$text4color2" ?>">
            <input type="text" name="new_text4color3" size="3" maxlength="3" value="<?php echo"$text4color3" ?>"></td>
          </tr>
          <tr>
            <td width="159" align="right">Text String:</td>
            <td width="363"><select size="1" name="new_text4string">
            <option value="Artist: $artist">Artist</option>
            <option selected value="$onoff">File Name</option>
            <option value="Track: $title">Track</option>
            <option value="Album: $album">Album</option>
            </select></td>
          </tr>
          <tr>
            <td width="159" align="right">&nbsp;</td>
            <td width="363">&nbsp;</td>
          </tr>
          <tr>
            <td width="522" align="right" colspan="2">
            <p align="center">
            <input type="submit" value="Save Settings" name="submit"></td>
          </tr>
          </table>
         </form>

<?php
include("../footer.php");
?>
editconfig.php

Code: Select all

<?php
session_start(); 
header("Cache-control: private"); // IE 6 Fix.
if (empty($usernamein)) {
include("../header.php");
   print("Sorry You are not logged in, please <a href='/admin/'>login</a>.");
include("../footer.php");
die();
};
include("../header.php");
if ( $new_password == $passcheck ){
$newcontent = '<?php' . "\n" . '$displayname =' . '"' . $_POST['new_displayname'] 
. '"'  . ';' . "\n".'$password =' . '"' . $_POST['new_password'] 
. '"'  . ';' . "\n".'$emailaddress =' . '"' . $_POST['new_emailaddress'] 
. '"'  . ';' . "\n".'$txt1size =' . '"' . $_POST['new_txt1size'] 
. '"'  . ';' . "\n".'$txt1x =' . '"' . $_POST['new_txt1x']
. '"'  . ';' . "\n".'$txt1y =' . '"' . $_POST['new_txt1y']
. '"'  . ';' . "\n".'$txt1color1 =' . '"' . $_POST['new_txt1color1'] 
. '"'  . ';' . "\n".'$txt1color2 =' . '"' . $_POST['new_txt1color2']
. '"'  . ';' . "\n".'$txt1color3 =' . '"' . $_POST['new_txt1color3']
. '"'  . ';' . "\n".'$txt1string =' . '"' . $_POST['new_txt1string']
. '"'  . ';' . "\n".'$txt2size =' . '"' . $_POST['new_txt2size'] 
. '"'  . ';' . "\n".'$txt2x =' . '"' . $_POST['new_txt2x']
. '"'  . ';' . "\n".'$txt2y =' . '"' . $_POST['new_txt2y']
. '"'  . ';' . "\n".'$txt2color1 =' . '"' . $_POST['new_txt2color1'] 
. '"'  . ';' . "\n".'$txt2color2 =' . '"' . $_POST['new_txt2color2']
. '"'  . ';' . "\n".'$txt2color3 =' . '"' . $_POST['new_txt2color3']
. '"'  . ';' . "\n".'$txt2string =' . '"' . $_POST['new_txt2string']
. '"'  . ';' . "\n".'$txt3size =' . '"' . $_POST['new_txt3size'] 
. '"'  . ';' . "\n".'$txt3x =' . '"' . $_POST['new_txt3x']
. '"'  . ';' . "\n".'$txt3y =' . '"' . $_POST['new_txt3y']
. '"'  . ';' . "\n".'$txt3color1 =' . '"' . $_POST['new_txt3color1'] 
. '"'  . ';' . "\n".'$txt3color2 =' . '"' . $_POST['new_txt3color2']
. '"'  . ';' . "\n".'$txt3color3 =' . '"' . $_POST['new_txt3color3']
. '"'  . ';' . "\n".'$txt3string =' . '"' . $_POST['new_txt3string']
. '"'  . ';' . "\n".'$txt4size =' . '"' . $_POST['new_txt4size'] 
. '"'  . ';' . "\n".'$txt4x =' . '"' . $_POST['new_txt4x']
. '"'  . ';' . "\n".'$txt4y =' . '"' . $_POST['new_txt4y']
. '"'  . ';' . "\n".'$txt4color1 =' . '"' . $_POST['new_txt4color1'] 
. '"'  . ';' . "\n".'$txt4color2 =' . '"' . $_POST['new_txt4color2']
. '"'  . ';' . "\n".'$txt4color3 =' . '"' . $_POST['new_txt4color3']
. '"'  . ';' . "\n".'$txt4string =' . '"' . $_POST['new_txt4string']
. '"'  . ';' . "\n".'$usernamefont =' . '"' . $_POST['font1.ttf']
. '"' .  ';' . "\n".'?>'; 


@ $FP = fopen("../users/$usernamein/config.php", 'w'); 
    fwrite($FP, $newcontent); 
    fclose($FP); 
    echo "Configuration Saved Successfully!"; 
    echo "<A HREF='index.php'>Click here to go to your admin page.</A>"; 
    }
    else {
	print("You Passwords did not match, please <a href='editcform.php'>go back</a> and try again."); 
	};
include("../footer.php");
?>
and its saving to

config.php

Code: Select all

<?php
$displayname ="";
$password ="test";
$emailaddress ="ewffew";
$txt1size ="";
$txt1x ="";
$txt1y ="";
$txt1color1 ="";
$txt1color2 ="";
$txt1color3 ="";
$txt1string ="";
$txt2size ="";
$txt2x ="";
$txt2y ="";
$txt2color1 ="";
$txt2color2 ="";
$txt2color3 ="";
$txt2string ="";
$txt3size ="";
$txt3x ="";
$txt3y ="";
$txt3color1 ="";
$txt3color2 ="";
$txt3color3 ="";
$txt3string ="";
$txt4size ="";
$txt4x ="";
$txt4y ="";
$txt4color1 ="";
$txt4color2 ="";
$txt4color3 ="";
$txt4string ="";
$usernamefont ="";
?>
any help would be greatly appreciated.

Thanks

-Ryan Gatewood

Posted: Fri Oct 29, 2004 4:10 pm
by RyanGatewood
LOL, nevermind, i found my problem ( text1 and txt1 arent the same... lol)