Jump to content

[SOLVED] changing folders


bodyland

Recommended Posts

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]
<?php

include ("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]
Link to comment
Share on other sites

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.

Regards
Huggie
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.