bodyland Posted December 22, 2006 Share Posted December 22, 2006 Hi - I have the following script to run: As it is is creates the files it does in the same folder as the script runs. For security reason I need to have this script run from a different folder. So I need tochange the paths to the files it writes. How do I do that? Thank you[code]<?phpinclude ("mysql.php");include ("menu.html");$single = $_GET['id'] ;$writemenu = $writemenu."<table><tr>\n";$count = 0;if ($single == ''){$sql=@mysql_query("select id,name,term from girls order by name");}else{$sql=@mysql_query("select id,name,term from girls where id='$single'");}while ($tmp=@mysql_fetch_array($sql)){ extract($tmp);$linkid = $id;$htmlname = str_replace(' ','',$name);$htmlname = $htmlname.".shtml";echo "<center>Creating $htmlname... ";$name = ucwords($name);$writemenu = $writemenu."<td width=150><a href=/archives/$htmlname>$name</a></td>\n";$count++;if ($count == 6) { $writemenu = $writemenu."</tr>\n<tr>\n"; $count = 0;} $thumbcount = 0; $writepage = "<tr>\n"; $sql2=@mysql_query("select id,description from tblTgp where description like '%$term%' and accept like '%approved%' and category not like '%hidden%' order by vote"); while ($tmp2=@mysql_fetch_array($sql2)) { extract($tmp2); $writepage = $writepage."<td><a target=_blank href=/ct/cx.php?i=$id&s=65&t=1> <img src=/ct/thumbs/tn$id.jpg alt='$description' title= '$description' border=0 vspace=5 hspace=5></a></td>\n"; $thumbcount++; if ($thumbcount == 6) { $writepage = $writepage."</tr>\n<tr>\n"; $thumbcount = 0;} } $writepage = $writepage."</tr>"; $sql3=@mysql_query("select url,text from recips where girl='$linkid' order by vote"); while ($tmp3=@mysql_fetch_array($sql3)) { extract($tmp3); $writelinks = $writelinks."\n<tr>\n<td align=center><a target=_blank href=$url>$text</a></td>\n</tr>"; } $template = file_get_contents (newtemplate3.html'); $name = ucwords($name); $template = str_replace ('{{name}}',$name, $template); $template = str_replace ('{{insertthumbs}}',$writepage, $template); $template = str_replace ('{{insertlinks}}',$writelinks, $template); $writelinks = ''; $girlspage = $htmlname; $fp = fopen($girlspage, "w"); $write = fputs($fp, $template); fclose($fp);echo "done!</center>";}$writemenu = $writemenu."</tr></table>\n";if ($single == ''){$girlsmenu = 'menu.txt';$fp = fopen($girlsmenu, "w");$write = fputs($fp, $writemenu);fclose($fp);echo "<br><center><font size=+2>All pages have been generated</font></center>";}else{echo "<br><center><font size=+2>The page has been generated</font></center>";}?>[/code] Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted December 22, 2006 Share Posted December 22, 2006 If you look through the code you'll see references to fopen() throughout it, that's where it opens the file.The first parameter that function accepts is the path to the file. So search for fopen() in your script and change the path of the file to the correct directory.If you need further help then let me know and I can show you what needs changing, but have a go at it yourself first.RegardsHuggie Quote Link to comment Share on other sites More sharing options...
bodyland Posted December 22, 2006 Author Share Posted December 22, 2006 thanks - got it!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.