![](/img/trans.png)
[英]Is there a way to run output php actions to variable in javascript?
[英]php run actions on a different website
我遇到了一個問題,我正在構建一個應用程序,該應用程序允許用戶更改通常只能在管理面板中更改的數據。 我的應用程序過濾掉了所有易受攻擊的數據。 但是,當我更改應用中的數據時,還必須在原始管理面板中對其進行更新。 為此,我必須將xml文件上傳到管理面板中。 目前這是手動的,但必須是自動化的。 但是,我必須通過管理面板上傳它,否則該面板中的數據將不會更新。 使用file_put_contents
直接更新它並不可行。
這段代碼位於mydomain.com/system_backup.php
。 這是在管理面板中,它要求您使用用戶名登錄並通過,然后才能使用它。
//The html on this page. system_backup.php
<form action="system_backup.php" method="post" enctype="multipart/form-data">
//Downloads the current xml-file from the server
<input name="Download" type="submit" class="formbtn" id="download" value="Download configuration">
//select the xml file from your local system.
<input name="conffile" type="file" class="formfld" id="conffile" size="40">
//restore/update the xml-file.
<input name="Restore" type="submit" class="formbtn" id="restore" value="Restore configuration">
</form>
看起來像這樣。
當您在瀏覽器中打開頁面時,將使用javascript / jquery給出以下登錄提示。
那么,有沒有一種方法可以使用php創建自動腳本,該腳本將使用此管理面板登錄並更新此文件? 如果使用php無法實現,那么是否可以使用其他語言? 我將不得不每天晚上都通過cron-job來運行它。
這是可能的,而且非常容易。 您只需要弄清楚您的Web服務器用於驗證用戶身份的方法,並在標頭(或cookie)中發送適當的數據即可。
例如,如果您的服務器正在使用基本訪問身份驗證 (並且可能確實在使用),則必須向請求添加標頭,如下所示:
Authorization: Basic xxxxxxxxxxxxx
其中xxxxxxxxxxxxx是字符串的Base64: username:password
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.