2012-06-02 72 views
-3

我有一個程序,從我的網站更新了一些文件,我做的所有工作,但我有 update.php腳本問題如何編寫一個php腳本來更新文件列表?

我的應用程序端更新鱈魚(在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/"; 

,當你看到我的網站上我的更新目錄(所有文件就在這裏。):

http://se7enclan.ir/Update/

等什麼腳本必須在update.php,我可以用這個?「update.php行動=清單」

這update.php腳本必須努力喜歡這個網站: http://mw3luncher.netai.net/update.php?action=list

謝謝。

+6

您的代碼示例不是用PHP編寫的。目前還不清楚你的問題是什麼。你是否要求完整的腳本在服務器上運行可執行文件? – Bojangles

+0

這個問題需要一個更好的標題。 – j08691

+2

PHP在哪裏? – PeeHaa

回答

1

我明白你的問題男人。這裏是一個解決方案:

<?PHP 
    // examples for scanning the current directory 
    $dirlist = getFileList("."); 
    $dirlist = getFileList("./"); 
?> 

,並輸出結果的HTML頁面,我們只是通過返回數組循環:

<?PHP 
    // output file list as HTML table 
    echo "<table border="1">\n"; 
    echo "<tr><th>Name</th><th>Type</th><th>Size</th><th>Last Mod.</th></tr>\n"; 
    foreach($dirlist as $file) { 
    echo "<tr>\n"; 
    echo "<td>{$file['name']}</td>\n"; 
    echo "<td>{$file['type']}</td>\n"; 
    echo "<td>{$file['size']}</td>\n"; 
    echo "<td>",date('r', $file['lastmod']),"</td>\n"; 
    echo "</tr>\n"; 
    } 
    echo "</table>\n\n"; 
?> 

<?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; 
    } 
?> 

如下您可以使用此功能

希望它有幫助!

+0

謝謝我用你的第一個腳本,但我得到空白頁????當我搜索「update.php?action = list」並輸出格式必須是這樣的:「iw5sp.exe」\t「96371a6f01b1e5465e0de0e5bc0c911b」\t「4753480」第一個文件名,第二我不知道它到底是什麼,我認爲它的文件流,和第三個大小關文件 –

+0

謝謝和請求看到我的問題在這裏:http://stackoverflow.com/questions/10869907/how-can-i-add-a-hash-segment-and-remove-this-part-from-output-data –

+0

當我使用這個鱈魚我得到此輸出數據: ./dir.php 1338721029 293 ./echo.php 1338719989 270 ./New Text Document.txt 1338719618 0 ./update.php 1338721316 924 問題:我不想添加此「。 /「先輸出數據中的文件名!所以我如何刪除它?問題2: 正如你在輸出數據中看到的,我有3部分:「文件名」,「13387 ....」「,」文件大小「,所以而不是13387 ....我想添加文件哈希,所以我怎麼可以在這裏添加哈希段?! 問題3:是否有可能的PHP鱈魚檢查和打印文件哈希自己? –

相關問題