Okay guys. So I have it writing to the file... thanks for the help. Although I am getting the file written to, it's not doing as I want..... what a shock.
I pull all the information from the file, and then I want to search it for strings and replace it as it goes. Here's what I have for that function:
Well, that's what I had. After further looking on php.net I found that I should be able to do it through a loop using str_replace. Now I get some funky junk goin on with my file when it gets written. Variables come out of nowhere and are sporadically thrown throughout the entire thing. Weird.
Here's the funciton I have:
$site_name = $_REQUEST['site_name'];
$site_url = $_REQUEST['site_url'];
$allowreg = $_REQUEST['allowreg'];
$db_name = $_REQUEST['db_name'];
$db_user = $_REQUEST['db_user'];
$db_pass = $_REQUEST['db_pass'];
$db_host = $_REQUEST['db_host'];
$sendmethod = $_REQUEST['sendmethod'];
$socketfrom = $_REQUEST['socketfrom'];
$namefrom = $_REQUEST['namefrom'];
$sockethost = $_REQUEST['sockethost'];
$smtpauth = $_REQUEST['smtpauth'];
$smtpauthuser = $_REQUEST['smtpauthuser'];
$smtpauthpass = $_REQUEST['smtpauthpass'];
$emailclose = $_REQUEST['emailclose'];
$emailuser = $_REQUEST['emailuser'];
$dformat = $_REQUEST['dformat'];
$dformatemail = $_REQUEST['dformatemail'];
$allowattachments = $_REQUEST['allowattachments'];
$maxfilesize = $_REQUEST['maxfilesize'];
$uploadpath = $_REQUEST['uploadpath'];
$ticket_display = $_REQUEST['ticketdisplay'];
$replace = array(
"$sitename = 'PHP Support Tickets'"=>"$sitename = '".$site_name."'",
"$siteurl = 'http://www.phpsupporttickets.com'"=>"$siteurl = '".$site_url."'",
"$allowreg = 'ON'"=>"$allowreg = '".$allowreg."'",
"$host = 'localhost'"=>"$host = '".$db_host."'",
"$user = 'root'"=>"$user = '".$db_user."'",
"$pass = ''"=>"$pass = '".$db_pass."'",
"$data = 'support_tickets'"=>"$data = '".$db_name."'",
"$sendmethod = 'smtp'"=>"$sendmethod = '".$sendmethod."'",
"$socketfrom = 'email@yourdomain.com'"=>"$socketfrom = '".$socketfrom."'",
"$socketfromname = 'From Name'"=>"$socketfromname = '".$namefrom."'",
"$sockethost = 'smtp server'", "$sockethost = '".$sockethost."'",
"$smtpauth = 'FALSE'", "$smtpauth = '".$smtpauth."'",
"$smtpauthuser = 'USER'", "$smtpauthuser = '".$smtpauthuser."'",
"$smtpauthpass = 'PASSWORD'", "$smtpauthpass = '".$smtpauthpass."'",
"$emailclose = 'TRUE'", "$emailclose = '".$emailclose."'",
"$emailuser = 'TRUE'", "$emailuser = '".$emailuser."'",
"$dformat = 'd-m-Y'", "$dformat = '".$dformat."'",
"$allowattachments = 'TRUE'", "$allowattachments = '".$allowattachments."'",
"$maxfilesize = '10240000'", "$maxfilesize = '".$maxfilesize."'",
"'/FOLDER/upload/'", "'/".$uploadpath."'",
"$ticket_display = '50'", "$ticket_display = '".$ticket_display."'");
foreach($replace as $key=>$value){
$contents = str_replace($key, $value, $contents);
}
I'm gonna keep workin on it, and hopefully get it working.
I really think I'll have to go back to the eregi_replace() for each line that I want replaced. Or perhaps I should just edit my loop to only search teh document for the exact match as I think similar matches are being returned....
Help would be greatly appreciated.
~Brett
I'm just an idiot
Thanks for the help guys in getting the file writing to work. Really helped. If you look at the code I posted, you'll see my n00bish mistake.... oh well... it's 3 am here. So I fixed it and it's working like a charm now....
Thanks again for the help.
~Brett