php事件驱动
1. [文件] class.Dispatcher.php ~ 967B 下载(9)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<?phpsession_start();require_once('class.Handler_Event.php');header("Content-type:text/html; charset=utf-8");class Dispatcher{ private $handle; function __construct($event_handle){ $this->handle=$event_handle; } function handle_the_event(){ $name="handler_$this->handle"; if(class_exists("$name")){ $handler_obj=new $name($this->handle); $response=$handler_obj->secure_handler(); return $response; }else{ echo "I can't handle this!"; } }}?><html><head><title>Secure,Event Driven Record Viewer!</title></head><body><form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post"> <input type="submit" name="event" value="View"> <input type="submit" name="event" value="Edit"></form></body></html><?phpfunction handle(){ $event=$_POST['event']; $do=new Dispatcher($event); $do->handle_the_event();}$_SESSION['name']="Wangzy";if(isset($_POST['event'])) handle();?> |
2. [文件] class.Handler_Event.php ~ 1KB 下载(6)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<?php//Event parentabstract class Event_Handler{ function dbconn(){ $link_id=mysql_connect("localhost","root","root"); mysql_select_db("mytest",$link_id); mysql_query("set names utf8",$link_id); return $link_id; } abstract function handled_event(); abstract function secure_handler();}//View Eventclass Handler_View extends Event_Handler{ private $handle; function __construct($event_handle){ $this->handle=$event_handle; } function handled_event(){ echo "The event, $this->handle, is now handled.<br> It is ,I promise!<br><br> Your records are as follows:<br><br>"; $id=parent::dbconn(); $result=mysql_query("select * from table01",$id); while($row=mysql_fetch_array($result)){ echo "Numbers:".$row['number']."\tName:".$row['name']."<br>"; } } function secure_handler(){ if($_SESSION['name']=="Wangzy"){ $this->handled_event(); }else{ echo "Sorry {$_SESSION['name']} you are not authorized!"; } }}//Edit Eventclass Handler_Edit extends Event_Handler{ private $handle; function __construct($event_handle){ $this->handle=$event_handle; } function handled_event(){ echo "This is event $this->handle, which is now handled -no kidding!<br>"; } function secure_handler(){ $this->handled_event(); }} |
php事件驱动的更多相关文章
- C++ 事件驱动型银行排队模拟
最近重拾之前半途而废的C++,恰好看到了<C++ 实现银行排队服务模拟>,但是没有实验楼的会员,看不到具体的实现,正好用来作为练习. 模拟的是银行的排队叫号系统,所有顾客以先来后到的顺序在 ...
- Node学习笔记(二):事件驱动
接触Node,提得最多的可能就是回调,异步非阻塞处理,思前想后,JavaScript从前端语言过渡到服务器端,最大的劣势可能就是线程,当然这方面的不足现在也被慢慢弥补起来了(很多第三方的npm包可供下 ...
- IDDD 实现领域驱动设计-CQRS(命令查询职责分离)和 EDA(事件驱动架构)
上一篇:<IDDD 实现领域驱动设计-SOA.REST 和六边形架构> 阅读目录: CQRS-命令查询职责分离 EDA-事件驱动架构 Domin Event-领域事件 Long-Runni ...
- Reactor事件驱动的两种设计实现:面向对象 VS 函数式编程
Reactor事件驱动的两种设计实现:面向对象 VS 函数式编程 这里的函数式编程的设计以muduo为例进行对比说明: Reactor实现架构对比 面向对象的设计类图如下: 函数式编程以muduo为例 ...
- 输入事件驱动---evdev_handler的大致实现流程(修整版)
一.input输入子系统框架 下 图是input输入子系统框架,输入子系统由输入子系统核心层(input core),驱动层和事件处理层(Event Handler)三部分组成.一个输入事件,比如滑动 ...
- NodeJS中的异步I/O、事件驱动
nodejs的主要特点是单线程.异步I/O.事件驱动.让我们先大概了解一下这些名词的意思. 单线程 单线程是任务按照顺序执行的,并且每次只执行一个任务,只有前面的任务执行完成以后,后面的任务才执行.在 ...
- 事件驱动之Twsited异步网络框架
在这之前先了解下什么是事件驱动编程 传统的编程是如下线性模式的: 开始--->代码块A--->代码块B--->代码块C--->代码块D--->......--->结 ...
- Python交互式编程导论----事件驱动编程
传统的编程是如下线性模式的: 开始--->代码块A--->代码块B--->代码块C--->代码块D--->......--->结束 每一个代码块里是完成各种各样事情 ...
- [.NET领域驱动设计实战系列]专题七:DDD实践案例:引入事件驱动与中间件机制来实现后台管理功能
一.引言 在当前的电子商务平台中,用户下完订单之后,然后店家会在后台看到客户下的订单,然后店家可以对客户的订单进行发货操作.此时客户会在自己的订单状态看到店家已经发货.从上面的业务逻辑可以看出,当用户 ...
- ENode 1.0 - 事件驱动架构(EDA)思想的在框架中如何体现
开源地址:https://github.com/tangxuehua/enode 上一篇文章,我给大家分享了我的一个基于DDD以及EDA架构的框架enode,但是只是介绍了一个大概.接下来我准备用很多 ...
随机推荐
- jQuery进行简单验证的正则表达式
下面都是一些比较常用简单的验证,像那些特殊的复杂的情况这里不进行考虑 1.验证电话号码或者手机号码 ? 1 2 3 4 5 6 7 8 9 10 /** * 验证电话号码(手机号码+电话号码) * ...
- wamp配置sendmail发送邮件
下载 sendmail ( 地址: http://www.glob.com.au/sendmail/sendmail.zip ) [PHP.ini 配置] [mail function]; For W ...
- Testing a Redux & React web application
Part 1 - https://www.youtube.com/watch?v=iVKPbH3qyW0 Part 2 - https://www.youtube.com/watch?v=M5lwOs ...
- 把嵌入在eclipse中的tomcat日志分离出来
现象 不知道从哪个版本的tomcat开始,windows版本的tomcat不再包含{tomcat_home}\logs\catalina.out这个文件,eclipse中配置好tomcat服务器之后, ...
- 经典dp 最长公共子序列
首先,说明一下子序列的定义…… 一个序列A={a1,a2,a3,...,an},从中删除任意若干项,剩余的序列叫A的一个子序列. 很明显(并不明显……),子序列……并不需要元素是连续的……(一开始的时 ...
- 利用scrollTop 制作图片无缝滚动
<!doctype html><title>javascript无缝滚动 by 司徒正美</title><meta charset="utf-8&q ...
- digitalocean注册验证账户、激活账号教程
注册digitalocean账号很简单,使用优惠链接注册digitalocean还能赠送10美元余额,digitalocean vps是优秀的SSD VPS,最便宜的套餐只要5美元/月. 由于中国大陆 ...
- 星语硬件检测专家 V4.3 官方版
软件名称: 星语硬件检测专家 软件语言: 简体中文 授权方式: 免费软件 运行环境: Win 32位/64位 软件大小: 15.8MB 图片预览: 软件简介: 星语硬件检测专家是一款功能非常强大的硬件 ...
- UIAlertAction 弹出对话框9.0后有点变化
ios 9.0后再用以前的UIAlertAction 已经不行了 被弃用了 改用这种方法了 UIAlertController *alertController = [UIAlertControlle ...
- android 编译的原理介绍
http://blog.csdn.net/mr_raptor/article/details/7540066