久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <small id='z9fu2'></small><noframes id='z9fu2'>

    1. <i id='z9fu2'><tr id='z9fu2'><dt id='z9fu2'><q id='z9fu2'><span id='z9fu2'><b id='z9fu2'><form id='z9fu2'><ins id='z9fu2'></ins><ul id='z9fu2'></ul><sub id='z9fu2'></sub></form><legend id='z9fu2'></legend><bdo id='z9fu2'><pre id='z9fu2'><center id='z9fu2'></center></pre></bdo></b><th id='z9fu2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='z9fu2'><tfoot id='z9fu2'></tfoot><dl id='z9fu2'><fieldset id='z9fu2'></fieldset></dl></div>

      <legend id='z9fu2'><style id='z9fu2'><dir id='z9fu2'><q id='z9fu2'></q></dir></style></legend>

        <bdo id='z9fu2'></bdo><ul id='z9fu2'></ul>
    2. <tfoot id='z9fu2'></tfoot>
      1. 使用 Zend 框架安全地運行 Cron 作業(yè)

        Securely Run Cron Jobs with Zend Framework(使用 Zend 框架安全地運行 Cron 作業(yè))
        <tfoot id='hEaUs'></tfoot>
          <tbody id='hEaUs'></tbody>
        • <bdo id='hEaUs'></bdo><ul id='hEaUs'></ul>

          <legend id='hEaUs'><style id='hEaUs'><dir id='hEaUs'><q id='hEaUs'></q></dir></style></legend>
          • <small id='hEaUs'></small><noframes id='hEaUs'>

                  <i id='hEaUs'><tr id='hEaUs'><dt id='hEaUs'><q id='hEaUs'><span id='hEaUs'><b id='hEaUs'><form id='hEaUs'><ins id='hEaUs'></ins><ul id='hEaUs'></ul><sub id='hEaUs'></sub></form><legend id='hEaUs'></legend><bdo id='hEaUs'><pre id='hEaUs'><center id='hEaUs'></center></pre></bdo></b><th id='hEaUs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hEaUs'><tfoot id='hEaUs'></tfoot><dl id='hEaUs'><fieldset id='hEaUs'></fieldset></dl></div>
                1. 本文介紹了使用 Zend 框架安全地運行 Cron 作業(yè)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我看過很多關于 cron 和 ZF 的帖子,但大多數解決方案都讓工作運行,以供公眾觸發(fā).

                  I've seen plenty of posts about cron and ZF but most of the solutions leave the job to be run available to triggering by the public.

                  如果你想設置一個只能由cron運行的動作怎么辦?不是某個匿名用戶,也不是必須登錄的人?

                  What if you want to set up an action that can ONLY be run by cron? Not by some anonymous user and not by someone that has to log in?

                  我使用的解決方案涉及將一個文件放在我的網絡根目錄之外,讓它引導足夠的 ZF 來使用我需要的東西(比如,我不需要視圖),然后從 cron 中點擊它.我的問題是,這是一種最佳實踐"方式嗎?如果您需要使代碼可通過網絡訪問,但仍需要防止隨機用戶找到并運行它,該怎么辦?

                  The solution I am using involved putting a file outside of my web root, having it bootstrap enough of the ZF to use what I need (like, I don't need the view) and then hit that from cron. My questions are, is this a "best practice" way to do this? What if you needed to make the code accessible over the web but still need to prevent random users from finding and running it?

                  為了說明,這是我正在為從 php 命令行和在同一臺服務器上運行的 cron 作業(yè)執(zhí)行的操作(有效),如下所示:

                  For illustration, here is what I am doing (that works) for a cron job run from the php command line, and on the same server, something like this:

                  * 10 * * * php /Apps/ZF/cronjobs/crontest.php
                  

                  Webroot 是:/Apps/ZF/someproject/

                  crontest.php:

                  crontest.php:

                  <?php
                  ini_set('include_path', ini_get('include_path') . ':/Apps/ZF/someproject/library');
                  
                  define('APPLICATION_PATH','/Apps/ZF/someproject/application');
                  define('APPLICATION_ENVIRONMENT','test');
                  
                  //Include the loader (for loading ZF resources)
                  require_once 'Zend/Loader.php';
                  
                  //Include the model (to access the Sites model in this case)
                  require_once(APPLICATION_PATH . '/models/Planets.php');
                  
                  Zend_Loader::registerAutoload();
                  
                  $configuration = new Zend_Config_Ini(
                      APPLICATION_PATH . '/config/config.ini',
                      APPLICATION_ENVIRONMENT
                  );
                  
                  // DB adapter
                  $dbAdapter = Zend_Db::factory($configuration->database);
                  
                  // DB table setup
                  Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
                  
                  // Whatever code we want to run... 
                  $test = new Model_Planets();
                  
                  $test->fetchEntries();
                  
                  Zend_Debug::dump($test);
                  ?>
                  

                  所以,正如我所說,這行得通,所以我不是在找人給我寫一個解決方案……只是對把這個做得更好"感到好奇.另外,如果我需要通過網絡訪問它但仍然希望它只能由 cron 運行怎么辦?讓它更靈活怎么樣(因為在這里我硬編碼了一些我懷疑可以變得更加動態(tài)的路徑)?

                  So, as I said, this works so I'm not looking for someone to write me a solution... just curious about doing this "better". Also, what if I needed this to be accessible via the web but still want to keep it only runnable by cron? What about making it more flexible (because here I am hard coding a few paths that I suspect could be made more dynamic)?

                  我假設我可以列出允許的服務器列表,然后使用 $_SERVER['REMOTE_ADDR'] 進行測試?

                  I assume I could make a list of permitted servers, then test that with $_SERVER['REMOTE_ADDR']?

                  大家怎么看?建議?我一個人工作,所以我沒有同事可以在這件事上尋求幫助......在某種程度上,我的同事就是這樣.

                  What do you all think? Suggestions? I work alone so I have no colleague to ask for help on this... SO is my colleague, in a way.

                  推薦答案

                  一種方法是設置環(huán)境變量.

                  One way is to set an environmental variable.

                  所以在你的 crontab 中

                  So in your crontab

                  SCRIPT_RUN_ENV=cron
                  * * * * * foo.php // Whatever your line is
                  

                  然后,在應用程序中,只需檢查:

                  Then, in the application, just check that:

                  if (get_env('SCRIPT_RUN_ENV') != 'cron') {
                      echo "Program cannot be run manually
                  ";
                      exit(1);
                  }
                  

                  現在,任何人都可以將他們的環(huán)境變量設置為該值并成功運行 cron,但它應該停止瑣碎的運行(或意外)...

                  Now, anyone can set their environmental variable to that value and successfully run the cron, but it should stop the trivial running (or accidental)...

                  但還要注意,任何可以在服務器上編輯環(huán)境變量的人都可以執(zhí)行它,所以沒有真正的方法從那個角度來保護它(至少沒有一個是自動化的)......還值得注意的是你無法通過 HTTP 注入環(huán)境變量.

                  But also note that anyone who can edit the environmental variable on the server can already execute it, so there's no real way to secure it from that angle (none that are automated at least)... It's also worth noting that you cannot inject an environmental variable through HTTP.

                  這篇關于使用 Zend 框架安全地運行 Cron 作業(yè)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯(lián)網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

                  <tfoot id='u7kyO'></tfoot>
                    <tbody id='u7kyO'></tbody>
                  <legend id='u7kyO'><style id='u7kyO'><dir id='u7kyO'><q id='u7kyO'></q></dir></style></legend>

                      • <small id='u7kyO'></small><noframes id='u7kyO'>

                          <i id='u7kyO'><tr id='u7kyO'><dt id='u7kyO'><q id='u7kyO'><span id='u7kyO'><b id='u7kyO'><form id='u7kyO'><ins id='u7kyO'></ins><ul id='u7kyO'></ul><sub id='u7kyO'></sub></form><legend id='u7kyO'></legend><bdo id='u7kyO'><pre id='u7kyO'><center id='u7kyO'></center></pre></bdo></b><th id='u7kyO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='u7kyO'><tfoot id='u7kyO'></tfoot><dl id='u7kyO'><fieldset id='u7kyO'></fieldset></dl></div>

                          • <bdo id='u7kyO'></bdo><ul id='u7kyO'></ul>
                          • 主站蜘蛛池模板: 国产精品视频二区三区 | 午夜男人天堂 | 自拍偷拍亚洲一区 | 精品一区二区三区免费视频 | 亚洲福利一区二区 | 黄色三级免费 | 日韩中文字幕 | 国产视频精品在线观看 | 黄色成人国产 | 亚洲视频二 | 亚洲精品欧美一区二区三区 | 男女国产网站 | 精品视频在线观看 | 久久久久久国 | 精品日韩一区 | 狠狠干天天干 | 99热这里有精品 | 欧美片网站免费 | 国产精品视频一区二区三区 | 成人久久久久久久久 | 国产剧情一区二区三区 | 亚洲午夜精品视频 | 在线视频一区二区三区 | 日日噜噜噜夜夜爽爽狠狠视频, | 国产高清一二三区 | 国户精品久久久久久久久久久不卡 | 精品欧美乱码久久久久久1区2区 | 黄色精品 | 亚洲国产一区二区视频 | 成人网av | 在线2区| 欧美视频 亚洲视频 | 国产激情一区二区三区 | 婷婷久久久久 | 手机av免费在线 | 密室大逃脱第六季大神版在线观看 | 超碰8| 黄色小视频大全 | 久久久久久久夜 | 亚洲成人999 | 蜜月va乱码一区二区三区 |