#!/usr/bin/env php objectModel->app->getBasePath() . 'www' . DS . 'data' . DS . 'ok.txt'; if(file_exists($okFile)) unlink($okFile); $extensionRoot = $editor->objectModel->app->getExtensionRoot(); $testPath = $extensionRoot . 'custom' . DS . 'test' . DS . 'ext' . DS . 'model' . DS . 'test.php'; $_POST['fileContent'] = "objectModel->save($testPath); r((int)(is_string($result) && str_contains($result, '为了安全起见'))) && p() && e('1'); touch($okFile); if(!is_dir(dirname($testPath))) mkdir(dirname($testPath), 0777, true); $_POST['fileContent'] = "objectModel->save($testPath); r($result === true ? 1 : 0) && p() && e('1'); $invalidPath = '/tmp/outside_zentao.php'; $_POST['fileContent'] = "objectModel->save($invalidPath); r((int)(is_string($result) && str_contains($result, '只能修改禅道文件'))) && p() && e('1'); $badPath = '/home/nonexistent/test.php'; $_POST['fileContent'] = "objectModel->save($badPath); r((int)(is_string($result) && !empty($result) && $result !== true)) && p() && e('1'); $filterPath = $extensionRoot . 'custom' . DS . 'test' . DS . 'ext' . DS . 'model' . DS . 'filter.php'; if(!is_dir(dirname($filterPath))) mkdir(dirname($filterPath), 0777, true); $_POST['fileContent'] = "objectModel->save($filterPath); $savedContent = file_exists($filterPath) ? file_get_contents($filterPath) : ''; r((int)str_contains($savedContent, 'eval')) && p() && e('1'); if(file_exists($okFile)) unlink($okFile);