当前位置: 首页 > news >正文

PHP 5.5 Action Management with Parameters (English Version)

PHP 5.5 Action Management with Parameters (English Version)

Here’s a PHP 5.5 compatible script that uses URL parameters instead of paths for all operations:

<?php
// Start session for persistent storage
session_start();// Initialize the stored action if not set
if (!isset($_SESSION['stored_action'])) {$_SESSION['stored_action'] = null;
}// Process requests based on parameters
if (isset($_GET['action'])) {// Store the action value$_SESSION['stored_action'] = $_GET['action'];echo "Action stored: " . htmlspecialchars($_GET['action']);
} elseif (isset($_GET['cmd'])) {$command = strtolower($_GET['cmd']);if ($command === 'status') {// Return the stored action value$action = $_SESSION['stored_action'];echo "Current action: " . ($action ? htmlspecialchars($action) : "No action stored");} elseif ($command === 'delete') {// Delete the stored action$_SESSION['stored_action'] = null;echo "Action deleted successfully";} else {echo "Invalid command";}
} else {// Display usage instructionsecho "<h1>Action Management System</h1>";echo "<p>Usage:</p>";echo "<ul>";echo "<li>Add <code>?action=value</code> to store a value</li>";echo "<li>Add <code>?cmd=status</code> to view stored value</li>";echo "<li>Add <code>?cmd=delete</code> to delete stored value</li>";echo "</ul>";echo "<p>Examples:</p>";echo "<ul>";echo "<li><a href='?action=test_value'>?action=test_value</a></li>";echo "<li><a href='?cmd=status'>?cmd=status</a></li>";echo "<li><a href='?cmd=delete'>?cmd=delete</a></li>";echo "</ul>";
}
?>

How to Use

  1. Store an action value:

    • URL: yourscript.php?action=your_value
    • Example: yourscript.php?action=open_door
  2. Check stored value:

    • URL: yourscript.php?cmd=status
    • Will display the currently stored action
  3. Delete stored value:

    • URL: yourscript.php?cmd=delete
    • Clears the stored action

Key Features

  1. Uses URL parameters for all operations (action, cmd)
  2. Session-based storage persists between requests
  3. Full English interface and comments
  4. Input sanitization with htmlspecialchars()
  5. Case-insensitive command handling
  6. Clear usage instructions
  7. PHP 5.5 compatible

Security Notes

  • Always sanitize output with htmlspecialchars()
  • Session storage is more secure than using a global variable
  • Consider adding CSRF protection for production use
  • For sensitive data, consider database storage instead of sessions
http://www.lryc.cn/news/605753.html

相关文章:

  • 通义千问Qwen3-30B-A3B-Thinking-2507技术解析:推理模型的工程实践突破
  • 常见的中间件漏洞如tomcat,weblogic,jboss,apache靶场攻略
  • 基于瑞芯微SoC的产品开发流程详解
  • 18650圆柱电池自动面垫机:自动化生产的效率革命
  • 人工智能之数学基础:频率和概率之间的关系
  • Java项目:基于SSM框架实现的小区物业管理系统【ssm+B/S架构+源码+数据库+毕业论文+开题报告+任务书+远程部署】
  • JS常见问题
  • BatchNorm 一般放在哪里?
  • InfluxDB 与 Python 框架结合:Django 应用案例(二)
  • DoRA详解:从LoRA到权重分解的进化
  • 小杰数据结构(three day)——静以修身,俭以养德。
  • 【Linux系统】库的制作与原理
  • 【数据结构】算法代码
  • 渗透RCE
  • TS 常用类型与语法
  • Cesium 快速入门(六)实体类型介绍
  • Jmeter 性能测试常用图表、服务器资源监控
  • C语言指针(三):数组传参本质、冒泡排序与二级指针详解
  • FISCO BCOS Gin调用WeBASE-Front接口发请求
  • [硬件电路-111]:滤波的分类:模拟滤波与数字滤波; 无源滤波与有源滤波;低通、带通、带阻、高通滤波;时域滤波与频域滤波;低价滤波与高阶滤波。
  • 操作系统数据格式相关(AI回答)
  • 无人船 | 图解基于LQR控制的路径跟踪算法(以欠驱动无人艇Otter为例)
  • 学习笔记《区块链技术与应用》第4天 比特币脚本语言
  • Docker部署Seata
  • Linux核心转储(Core Dump)原理、配置与调试实践
  • 前端-移动Web-day2
  • 野生动物巡查系统(H题)--2025 年全国大学生电子设计竞赛试题
  • ENSP防火墙部署
  • 快速理解RTOS中的pendsv中断和systick中断
  • Java Stream进阶:map是“一对一”,flatMap是“一对多”