i have a program to update some file from my site and i do all work but i have a problem in update.php script
my application side update cod is(in C#):
public string[] NeededFiles = { "teknomw3.dll" };
public string HomePageUrl = "http://se7enclan.ir";
public string NewsUrl = "http://se7enclan.ir/news";
public string DownloadUrl = "http://se7enclan.ir/";
public string UpdateList = "http://se7enclan.ir/update.php?action=list";
public string UpdateBaseUrl = "http://se7enclan.ir/Update/";
and my update directory on my site as you see(all files is here.):
so what script must be in update.php that i can use this: "update.php?action=list"
this update.php script must work like this site: http://mw3luncher.netai.net/update.php?action=list
Thank you.
I understand your problem man. Here is a solution:
<?PHP
function getFileList($dir)
{
// array to hold return value
$retval = array();
// add trailing slash if missing
if(substr($dir, -1) != "/") $dir .= "/";
// open pointer to directory and read list of files
$d = @dir($dir) or die("getFileList: Failed opening directory $dir for reading");
while(false !== ($entry = $d->read())) {
// skip hidden files
if($entry[0] == ".") continue;
if(is_dir("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry/",
"type" => filetype("$dir$entry"),
"size" => 0,
"lastmod" => filemtime("$dir$entry")
);
} elseif(is_readable("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry",
"type" => mime_content_type("$dir$entry"),
"size" => filesize("$dir$entry"),
"lastmod" => filemtime("$dir$entry")
);
}
}
$d->close();
return $retval;
}
?>
You can use this function as follows:
<?PHP
// examples for scanning the current directory
$dirlist = getFileList(".");
$dirlist = getFileList("./");
?>
And to output the results to an HTML page we just loop through the returned array:
<?PHP
// output file list as HTML table
echo "<table border="1">
";
echo "<tr><th>Name</th><th>Type</th><th>Size</th><th>Last Mod.</th></tr>
";
foreach($dirlist as $file) {
echo "<tr>
";
echo "<td>{$file['name']}</td>
";
echo "<td>{$file['type']}</td>
";
echo "<td>{$file['size']}</td>
";
echo "<td>",date('r', $file['lastmod']),"</td>
";
echo "</tr>
";
}
echo "</table>
";
?>
Hope it helps!