static function verify() { $data = array('uname' => array(null, 'string', '', '用户名为空'), 'password' => array(null, 'length', array(4, 16), '密码错误'), 'checkcode' => array(null, 'string', '', '验证码为空')); Sys::S('core.Verify.Input'); $data = Input::dataFilter($data, 'post'); if (!isset($_SESSION['verify_code']) || strtoupper($data['checkcode']) != $_SESSION['verify_code']) { Error::halt(self::WRONG_CHECK_CODE, '验证码错误!'); } $oUcenterMember = Sys::D('UcenterMember'); $loginStatus = UcenterMemberModel::login($data['uname'], $data['password']); if ($loginStatus >= 10) { if ($loginStatus == 10) { Error::halt(UcenterMemberModel::LOGIN_SUCCESS, array('msg' => '登录成功', 'redirect' => DOMAIN . 'Index_index.jsp')); } else { if ($loginStatus == UcenterMemberModel::ACCOUNT_LOCKED) { Error::halt($loginStatus, '账号已被锁定!'); } else { if ($loginStatus == UcenterMemberModel::ACCOUNT_DISABLED) { Error::halt($loginStatus, '账号无效'); } else { Error::halt($loginStatus, '用户名或密码错误'); } } } } else { $msg = $loginStatus <= 0 ? '您的账号已被锁定' : '登录失败,您还有' . $loginStatus . '次机会登录!'; Error::halt($loginStatus, $msg); } }
public static function render(array $additional_js_files = array()) { echo '<hr> <footer> <div style="float: left;"> Copyright © ' . date("Y") . ' <a href="http://www.nodesocket.com">NodeSocket</a>, LLC. <br >All rights reserved. </div> <div style="float: right;"> <div style="margin-bottom: 2px;"><iframe src="http://ghbtns.com/github-btn.html?user=nodesocket&repo=commando&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe><iframe src="http://ghbtns.com/github-btn.html?user=nodesocket&repo=commando&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe></div> v' . Version::app . ' </div> </footer> </div>'; //// // JavaScript files that are always loaded //// echo '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script> <script type="text/javascript" src="/js/bootstrap.min.js"></script> <script type="text/javascript" src="/js/common.js"></script>'; //// // Remove possible duplicates from additional_js_files //// if (count($additional_js_files) > 1) { $additional_js_files = array_unique($additional_js_files); } //// // Additional JavaScript files to load //// foreach ($additional_js_files as $additional_js_file) { //// // Handle the special case of codemirror /// if ($additional_js_file === "codemirror") { echo '<script type="text/javascript" src="/js/codemirror/codemirror.js"></script> <script type="text/javascript" src="/js/codemirror/shell.js"></script> <script type="text/javascript" src="/js/codemirror/perl.js"></script> <script type="text/javascript" src="/js/codemirror/python.js"></script> <script type="text/javascript" src="/js/codemirror/javascript.js"></script> <script type="text/javascript" src="/js/codemirror/markdown.js"></script>'; } else { if ($additional_js_file === "code-pretty") { echo '<script type="text/javascript" src="/js/code-pretty/prettify.js"></script>'; } else { //// //Check to make sure the JavaScript file exists //// if (file_exists(dirname(__DIR__) . "/js/" . $additional_js_file . ".js")) { echo '<script type="text/javascript" src="/js/' . $additional_js_file . '.js"></script>'; } else { Error::halt(404, 'not found', 'The included JavaScript file \'/js/' . $additional_js_file . '.js\' does not exist.'); } } } } echo '</body> </html>'; }
public static function render(array $additional_js_files = array()) { echo '<hr> <footer> <p style="float: left;"> Copyright © ' . date("Y") . ' <a href="http://www.nodesocket.com">NodeSocket</a>, LLC. <br >All rights reserved. </p> <p style="float: right;"> v' . Version::current . ' <br />View on <a href="https://github.com/nodesocket/commando">GitHub</a>. </p> </footer> </div>'; //// // JavaScript files that are always loaded //// echo '<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"></script> <script type="text/javascript" src="/js/bootstrap.min.js"></script> <script type="text/javascript" src="/js/common.js"></script>'; //// // Remove possible duplicates from additional_js_files //// if (sizeof($additional_js_files) > 1) { $additional_js_files = array_unique($additional_js_files); } //// // Additional JavaScript files to load //// foreach ($additional_js_files as $additional_js_file) { //// // Handle the special case of codemirror /// if ($additional_js_file === "codemirror") { echo '<script type="text/javascript" src="/js/codemirror/codemirror.js"></script> <script type="text/javascript" src="/js/codemirror/shell.js"></script> <script type="text/javascript" src="/js/codemirror/perl.js"></script> <script type="text/javascript" src="/js/codemirror/python.js"></script> <script type="text/javascript" src="/js/codemirror/javascript.js"></script> <script type="text/javascript" src="/js/codemirror/markdown.js"></script>'; } else { if ($additional_js_file === "code-pretty") { echo '<script type="text/javascript" src="/js/code-pretty/prettify.js"></script>'; } else { //// //Check to make sure the JavaScript file exists //// if (file_exists(dirname(__DIR__) . "/js/" . $additional_js_file . ".js")) { echo '<script type="text/javascript" src="/js/' . $additional_js_file . '.js"></script>'; } else { Error::halt(404, 'not found', 'The included JavaScript file \'/js/' . $additional_js_file . '.js\' does not exist.'); } } } } echo '</body> </html>'; }
public static function connect() { MySQLConnection::$db_connection = mysqli_init(); $connected = @mysqli_real_connect(MySQLConnection::$db_connection, MySQLConfiguration::host, MySQLConfiguration::username, MySQLConfiguration::password, MySQLConfiguration::database, MySQLConfiguration::port, MySQLConfiguration::socket, MYSQLI_CLIENT_COMPRESS); if (!$connected) { //Output error details Error::halt(503, 'service unavailable', 'Temporarily unable to process request. Failed to establish a connection with MySQL. Please retry.'); } }
public static function insert(array $data, array $options = array("safe" => 1, "fsync" => false)) { try { return MongoConnection::$mongo_collection->insert($data, $options); } catch (Exception $MongoCursorException) { //Output error details Error::halt(503, 'service unavailable', 'Temporarily unable to process request. Failed to insert into the MongoDB collection. Please retry.'); } }
static function index() { if (self::isLogin()) { Error::halt('', '', '', ''); exit('<script>alert("你已经登录,请退出后再登录");window.location.href="./Index_index.jsp";</script>'); } View::assign('scripts', array('core.Bracket.bootstrapValidator#min')); View::assign('styles', array('core.Bracket.bootstrapValidator#min')); View::display(); }
public static function index() { Sys::D('AdminLoginLog'); AdminLoginLogModel::log($_SESSION['userinfo']['id'], AdminLoginLogModel::LOGIN_OUT); if (isset($_SESSION['userinfo'])) { unset($_SESSION['userinfo']); } if (isset($_SESSION['authority'])) { unset($_SESSION['authority']); } Error::halt(SUCCESS, '登出成功!', './Login_index.jsp'); }
public static function render(array $additional_css_files = array()) { $output = '<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>' . Header::$title . '</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="A web-based interface for streamlining the use of SSH for deployments and system administration tasks across groups of remote servers."> <meta name="author" content="Commando.io"> <link rel="shortcut icon" href="/img/favicon.ico"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/apple-touch-114.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/apple-touch-72.png"> <link rel="apple-touch-icon-precomposed" href="/img/apple-touch-57.png"> <link href="/css/bootstrap.min.css" rel="stylesheet"> <style type="text/css"> body { padding-top: 60px; padding-bottom: 40px; } </style> <link href="/css/bootstrap-responsive.min.css" rel="stylesheet"> <link href="/css/additional-styles.css" rel="stylesheet">'; //// // Remove possible duplicates from additional_css_files //// if (count($additional_css_files) > 1) { $additional_css_files = array_unique($additional_css_files); } //// // Additional CSS files to load //// foreach ($additional_css_files as $additional_css_file) { //// //Make sure the CSS file exists //// if (file_exists(dirname(__DIR__) . "/css/" . $additional_css_file . ".css")) { $output .= '<link href="/css/' . $additional_css_file . '.css" rel="stylesheet">'; } else { Error::halt(404, 'not found', 'The included CSS file \'/css/' . $additional_css_file . '.css\' does not exist.'); } } $output .= '<!--[if lt IE 9]> <script src="/js/html5.js"></script> <![endif]--> </head> <body>'; echo $output; }
public function modifyPassword() { Sys::S('core.Verify.Input'); $data = array('src_password' => array(null, 'string', '', '原密码不能为空'), 'new_password' => array(null, 'string', '', '新密码不能为空')); $data = Input::dataFilter($data, 'post'); if (md5($data['src_password']) != $_SESSION['userinfo']['password']) { Error::halt(FAIL, '原密码不正确'); } else { if ($data['src_password'] == $data['new_password']) { Error::halt(FAIL, '新密码不能与原密码一致'); } else { Sys::D('UcenterMember'); UcenterMemberModel::savePassword($_SESSION['userinfo']['id'], $data['new_password']); Error::halt(SUCCESS, '操作成功'); } } }
/** * 文件导入 */ public static function import($className, $type) { static $_file = array(); $method = ''; $flag = false; $type = strtolower($type); $type_refer = array('action' => 'importAction', 'model' => 'importModel', 'class' => 'importClass', 'static' => 'importStatic'); if (isset($_file[$className])) { return true; } //判断文件类型 1=>action 2=>model -1=>其他文件 $method = $type_refer[$type]; $flag = self::$method($className); if (!$flag) { Error::halt(FILE_NOTFOUND, '文件:' . $className . '未找到'); } }
public static function check_required_parameters($params) { if (is_array($params)) { foreach ($params as $param) { if (!isset($param) || empty($param)) { if ($param != 0) { //Output error details Error::halt(400, 'bad request', 'Missing required parameter.'); } } } } else { if (!isset($params) || empty($params)) { if ($param != 0) { //Output error details Error::halt(400, 'bad request', 'Missing required parameter.'); } } } }
public function query($str) { $rs = array(); $this->initConnect(); $this->queryID = $this->linkID->query($str); if (!$this->queryID) { Error::halt(501, '执行sql语句出错:' . $str); } else { if (is_bool($this->queryID)) { $this->numRows = mysqli_affected_rows($this->linkID); } else { $this->numRows = mysqli_affected_rows($this->linkID); $this->numFields = $this->queryID->field_count; for ($i = 0; $i < $this->numRows; $i++) { $rs[] = $this->queryID->fetch_assoc(); } $this->free(); return $rs; } } }
static function autoload() { require_once dirname(__DIR__) . "/classes/Prerequisites.php"; require_once dirname(__DIR__) . "/timezone.php"; require_once dirname(__DIR__) . "/defines.php"; require_once dirname(__DIR__) . "/classes/Error.php"; require_once dirname(__DIR__) . "/classes/Sessions.php"; if (!file_exists(dirname(__DIR__) . "/app.config.php")) { Error::halt(404, 'not found', 'File \'app.config.php\' does not exist. Did you run \'install.php\'?'); } require_once dirname(__DIR__) . "/app.config.php"; if (!file_exists(dirname(__DIR__) . "/classes/MySQLConfiguration.php")) { Error::halt(404, 'not found', 'File \'/classes/MySQLConfiguration.php\' does not exist.'); } if (!file_exists(dirname(__DIR__) . "/classes/MongoConfiguration.php")) { Error::halt(404, 'not found', 'File \'/classes/MongoConfiguration.php\' does not exist.'); } spl_autoload_register(function ($class_name) { require_once dirname(__DIR__) . "/classes/" . $class_name . ".php"; }); }
public static function init() { if (!self::ifUserLogined()) { Error::halt(10001, '???δ???'); return false; } if (self::isAdmin()) { return true; } else { self::getAuthInfo(); //???????????????? Sys::D('Menu'); $menu_id = MenuModel::getIdByActionAndModule(ACTION, MODULE); if ($menu_id) { return self::checkMenuAuth($menu_id); } Sys::D('GlobalRule'); $menu_id = GlobalRuleModel::getIdByActionAndModule(ACTION, MODULE); return self::checkGlobalAuth($menu_id); } }
public function auth($username, $public_key_path, $private_key_path, $throw_error = false) { //// // Confirm that the public key exists //// if (!file_exists($public_key_path)) { unset($this->ssh_connection); if ($throw_error) { //Throw error details (string) throw new Exception(Error::out(404, 'not found', 'The public SSH key file \'' . $public_key_path . '\' does not exist.')); } else { //Output error details Error::halt(404, 'not found', 'The public SSH key file \'' . $public_key_path . '\' does not exist.'); } } //// // Confirm that the private key exists //// if (!file_exists($private_key_path)) { unset($this->ssh_connection); if ($throw_error) { //Throw error details (string) throw new Exception(Error::out(404, 'not found', 'The private SSH key file \'' . $private_key_path . '\' does not exist.')); } else { //Output error details Error::halt(404, 'not found', 'The private SSH key file \'' . $private_key_path . '\' does not exist.'); } } if (!@ssh2_auth_pubkey_file($this->ssh_connection, $username, $public_key_path, $private_key_path)) { unset($this->ssh_connection); if ($throw_error) { //Throw error details (string) throw new Exception(Error::out(504, 'gateway timeout', 'Failed to authenticate a SSH connection with username \'' . $username . '\' on host \'' . $this->hostname . '\' on port \'' . $this->port . '\'.')); } else { //Output error details Error::halt(504, 'gateway timeout', 'Failed to authenticate a SSH connection with username \'' . $username . '\' on host \'' . $this->hostname . '\' on port \'' . $this->port . '\'.'); } } return true; }
static function call($m, $a, $fpath) { /** * 缓存有效性检查 * 如果缓存有效,则直接调用缓存文件 */ $fileName = RUNTIME_PATH . '' . md5($m . $a) . Conf::param('tpl_cache_suffix'); if (self::checkCache($fileName)) { exit(file_get_contents($fileName)); } if (is_file($fpath) && (require $fpath)) { if (class_exists($m, false)) { if (method_exists($m, $a)) { $m::$a(); } else { Error::halt(METHOD_NOTFOUND, $m . '::' . $a); } } else { Error::halt(CLASS_NOTFOUND, $m); } } else { Error::halt(FILE_NOTFOUND, $fpath); } }
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. */ //// // Minimum seed length is 64 characters (enforced) // // Do not change once set //// define("CRYPTO_SEED", "{{CRYPTO_SEED}}"); //// // Example output: 4/1/2012 4:23:35 PM //// define("DATE_FORMAT", "n/j/Y g:i:s A"); //// // The full path to the public key used for SSH //// define("SSH_PUBLIC_KEY_PATH", __DIR__ . "/keys/public-key.pub"); //// // The full path to the private key used for SSH //// define("SSH_PRIVATE_KEY_PATH", __DIR__ . "/keys/private-key"); //// // Make sure CRYPTO_SEED is set, and at least 64 characters in length //// if (!defined("CRYPTO_SEED") || strlen(CRYPTO_SEED) < 64) { Error::halt(409, 'conflict', 'The crypto seed defined in \'app.config.php\' must be configured, and at least 64 characters in length.'); }
$request = Functions::parse_uri_to_request(); //// // No request passed, require index page //// if (empty($request) || !isset($request[0])) { require_once __DIR__ . "/index.php"; } else { //// // Check to make sure not calling controller.php or /controller directly //// if ($request[0] === "controller.php" || $request[0] === "controller") { Functions::redirect("/"); die; } //// // Build page //// $page = $request[0] . ".php"; //// // Set the rest of the request elements as query string parameters //// for ($i = 1; $i < count($request); $i++) { $_GET['param' . $i] = $request[$i]; } //// // Include the page //// if (!@(include_once __DIR__ . "/" . $page)) { Error::halt(404, 'not found', 'File \'' . $page . '\' does not exist.'); } }
static function parsePath($data, $type) { $basePath = ''; $type = ucfirst($type); $data = strtr($data, '.#', '/.'); $suffix = $type == 'Css' ? '.css' : '.js'; $fpath = substr($data, 0, 4) == 'core' ? THINK_PATH . 'Common/' . $type . '/' . substr($data, 5) . $suffix : COMMON_PATH . $type . '/' . $data . $suffix; if (!is_file($fpath)) { Error::halt(FILE_NOTFOUND, '需要包含的文件不存在:' . $fpath); } return $fpath; }
<?php /* # Copyright 2012 NodeSocket, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. */ require_once dirname(__DIR__) . "/classes/Requires.php"; Functions::check_required_parameters(array($_POST['ids'])); //$ids 'should' be an array $ids = json_decode($_POST['ids']); if ($ids == null) { //Output error details Error::halt(400, 'bad request', 'Parameter \'ids\' is invalid JSON.'); } MongoConnection::connect(); MongoConnection::grid_fs(); MongoConnection::grid_fs_delete($ids); MongoConnection::close(); echo '{"deleted":' . count($ids) . '}';
public function execute($str) { $this->initConnect(); $result = mysql_query($str, $this->linkID) or Error::halt(QUERY_ERROR, 'Query Failed:' . $str . '<br />' . mysql_error($this->linkID)); $this->numRows = mysql_affected_rows($this->linkID); $this->lastInsID = mysql_insert_id($this->linkID); return $this->numRows; }
private function toColor($color) { /* 设置颜色 */ if (is_string($color) && 0 === strpos($color, '#')) { $color = str_split(substr($color, 1), 2); $color = array_map('hexdec', $color); if (empty($color[3]) || $color[3] > 127) { $color[3] = 0; } } elseif (!is_array($color)) { Error::halt(125, '错误的颜色值'); } return $color; }
//// // Invalid recipe id //// if (empty($head)) { Error::halt(404, 'not found', 'Recipe \'' . $_GET['param1'] . '\' does not exist.'); } else { $recipe_version = $head->recipe_version; } } $result = MySQLQueries::get_recipe_by_version($_GET['param1'], $recipe_version); $recipe = MySQLConnection::fetch_object($result); //// // Invalid recipe version //// if (empty($recipe)) { Error::halt(404, 'not found', 'Recipe version \'' . $_GET['param1'] . '\' does not exist.'); } $file_extension = null; switch ($recipe->interpreter) { case 'shell': $file_extension = ".sh"; break; case 'bash': $file_extension = ".sh"; break; case 'perl': $file_extension = ".pl"; break; case 'python': $file_extension = ".py"; break;
/** * Helper loader. * * @param mixed $helper * * @return bool */ public static function helper() { // In case we're loading multiple helpers $class = func_num_args() > 1 ? func_get_args() : func_get_arg(0); // Multiple helpers if (is_array($class)) { foreach ($class as $helper) { static::helper($helper); } return; } // Is it already loaded? if (in_array($class, static::$helpers)) { return true; } // Lowercase the file name $file_name = static::lowercase($class); // App helper if (file_exists(APPPATH . '/helpers/' . $file_name . '.php')) { require APPPATH . '/helpers/' . $file_name . '.php'; } // Avalon helper elseif (file_exists(SYSPATH . '/helpers/' . $file_name . '.php')) { require SYSPATH . '/helpers/' . $file_name . '.php'; } // Not found else { Error::halt("Loader Error", "Unable to load helper '{$class}'"); return false; } static::$helpers[] = $class; return true; }
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. */ require_once dirname(__DIR__) . "/classes/Requires.php"; Functions::check_required_parameters(array($_POST['groups'], $_POST['recipe'])); if (!CSRF::is_valid()) { Error::halt(400, 'bad request', 'Missing required security token.'); } $result = MySQLQueries::get_recipe($_POST['recipe']); $recipe = MySQLConnection::fetch_object($result); if (empty($recipe)) { //Output error details Error::halt(400, 'bad request', 'The recipe \'' . $_POST['recipe'] . '\' does not exist.'); } //Default group handling if (count($_POST['groups']) === 1 && empty($_POST['groups'][0])) { $_POST['groups'] = array(); } $servers = array(); $results = MySQLQueries::get_servers_by_groups($_POST['groups']); while ($row = MySQLConnection::fetch_object($results)) { $servers[] = $row; } $returned_results = array(); foreach ($servers as $server) { try { $ssh = new SSH($server->address, $server->ssh_port, THROW_ERROR); } catch (Exception $ex) {
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. */ $_SERVER['SCRIPT_NAME'] !== "/controller.php" ? require_once __DIR__ . "/classes/Requires.php" : (Links::$pretty = true); Functions::check_required_parameters(array($_GET['param1'])); $file = null; MongoConnection::connect(); MongoConnection::grid_fs(); $results = MongoConnection::grid_fs_find(array("_id" => new MongoId($_GET['param1']))); MongoConnection::close(); foreach ($results as $result) { $file = $result->file; $file['data'] = $result->getResource(); } if (empty($file)) { Error::halt(404, 'not found', 'File \'' . $_GET['param1'] . '\' does not exist.'); } $content = null; if (strpos($file['type'], 'text') !== false || $file['type'] === "application/json") { while (!feof($file['data'])) { $content .= fread($file['data'], 8192); } } header("Content-Type: text/plain; charset=utf-8"); echo $content; ?>
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. */ $_SERVER['SCRIPT_NAME'] !== "/controller.php" ? require_once __DIR__ . "/classes/Requires.php" : (Links::$pretty = true); Functions::check_required_parameters(array($_GET['param1'])); //Get execution history record $execution_history = null; MongoConnection::connect(); MongoConnection::select_collection("executions"); $results = MongoConnection::find(array("_id" => new MongoId($_GET['param1']))); MongoConnection::close(); foreach ($results as $result) { $result['executed'] = date(DATE_FORMAT, $result['executed']->sec + Functions::timezone_offset_in_seconds()); $execution_history = $result; } if (empty($execution_history)) { Error::halt(404, 'not found', 'Execution history ID \'' . $_GET['param1'] . '\' does not exist.'); } $execution_history_json = @json_encode($execution_history, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); header("Content-Type: application/json"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=\"" . $execution_history['_id'] . ".json\""); header("Content-Transfer-Encoding: quoted-printable"); header("Content-Length: " . strlen($execution_history_json)); echo $execution_history_json; ?>
<?php /* # Copyright 2012 NodeSocket, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. */ require_once dirname(__DIR__) . "/classes/Requires.php"; $public_key = Functions::get_public_ssh_key(); if ($public_key === null) { Error::halt(404, 'not found', 'The public SSH key file \'' . SSH_PUBLIC_KEY_PATH . '\' does not exist.'); } echo json_encode(array("public_ssh_key" => $public_key));
<?php /* # Copyright 2012 NodeSocket, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. */ require_once dirname(__DIR__) . "/classes/Requires.php"; Functions::check_required_parameters(array($_GET['id'], $_GET['version'])); if (!CSRF::is_valid(1, METHOD_GET)) { Error::halt(400, 'bad request', 'Missing required security token.'); } MySQLQueries::edit_recipe_head($_GET['id'], $_GET['version']); Functions::redirect(Links::render("view-recipe", array($_GET['id'])));
/** * 设置上传驱动 * @param string $driver 驱动名称 * @param array $config 驱动配置 */ private static function setDriver($driver = null, $config = null) { $class = THINK_PATH . 'Common/Class/Upload/Driver/' . ucfirst(strtolower($driver)) . '.class.php'; self::$uploader = new $class($config); if (!self::$uploader) { Error::halt(FILE_NOTFOUND, '不存在上传驱动文件:' . $class); } }