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,但是只是介绍了一个大概.接下来我准备用很多 ...
随机推荐
- thinkphp 匹配qq 表情
<?php// 匹配qq表情 function replace_phiz($content){ preg_match_all('/\[.*?\]/is',$content,$ ...
- javase
http://blog.csdn.net/itlwc/article/category/1572517 http://blog.csdn.net/itlwc
- POJ 1862 Stripies#贪心(水)
(- ̄▽ ̄)-* #include<iostream> #include<cstdio> #include<cmath> #include<algorithm ...
- Java中的Unsafe
在阅读AtomicInteger的源码时,看到了这个类:sum.msic.Unsafe,之前从没见过.所以花了点时间google了一下. Unsafe的源码:http://www.docjar.com ...
- 正则表达式协助实现排序&&邮箱验证
/** 将IP地址按照字符串的自然顺序排序,只要让他们的每段的位数都是3就可以. 1.按照每一段需要的最多的0进行补齐,那么每一段就会至少保证有3位. 2.将每一段都保留3位.这样所有的ip地址都是每 ...
- Sitemesh 3
Sitemesh 3 的使用及配置(收藏自:http://www.cnblogs.com/luotaoyeah/p/3776879.html) 1 . Sitemesh 3 简介 Sitemesh 是 ...
- matlab里的nargin
nargin是用来判断输入变量个数的函数,这样就可以针对不同的情况执行不同的功能.
- why do we need virtual methods in C++?
http://stackoverflow.com/questions/2391679/why-do-we-need-virtual-methods-in-c Basic idea: when mark ...
- 常见的jquery一些效果
1.CSS渐变:background: linear-gradient(to bottom right, #999 , #eee);
- C# 16位的GUDI
引用: http://www.cnblogs.com/lcwzj/archive/2009/04/16/1436992.html 当我们想要获得一个唯一的key的时候,通常会想到GUID.这个key ...