续上篇:http://lazycai.blog.51cto.com/690494/765860
其实发现做hacking这种活儿,只要思路顺了,写起来还是挺快的··
$cycle = z(v('cycle'));
`cycle` = '" . $cycle . "'
<div id="todo_cycle">
重复周期:<input type="radio" name="cycle" value="0">不重复 <input type="radio" name="cycle" value="1">每日 <input type="radio" name="cycle" value="2">每周 <input type="radio" name="cycle" value="3">每月
</div>
重复周期:<input type="radio" name="cycle" value="0" <?php if( $tinfo['cycle'] == 0 ){ echo 'checked'; } ?>>不重复 <input type="radio" name="cycle" value="1" <?php if( $tinfo['cycle'] == 1 ){ echo 'checked'; } ?>>每日 <input type="radio" name="cycle" value="2" <?php if( $tinfo['cycle'] == 2 ){ echo 'checked'; } ?>>每周 <input type="radio" name="cycle" value="3" <?php if( $tinfo['cycle'] == 3 ){ echo 'checked'; } ?>>每月
if( $todo['cycle'] != 0 ) { //如果todo设置了重复周期,则复制该todo $this->copy_todo($tid); }
public function copy_todo($tid) {
if( $tid < 1 ) return ajax_box('错误的TODO ID');
$todo = get_line("SELECT * FROM `todo` WHERE `id` = '" . intval( $tid ) . "' LIMIT 1");
$name = $todo['name'];
$link = $todo['link'];
$desp = $todo['desp'];
$uid = $todo['uid'];
$creator_uid = $todo['creator_uid'];
$pid = $todo['pid'];
$follow_uids = $todo['follow_uids'];
$due_date = $todo['due_date'];
$cycle = $todo['cycle'];
switch($cycle) {
case 0:
//0的话就不该进来这里吧
break;
case 1:
$due_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($due_date)) . " +1 day"));
break;
case 2:
$due_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($due_date)) . " +1 week"));
break;
case 3:
$due_date = date("Y-m-d", strtotime(date("Y-m-d", strtotime($due_date)) . " +1 month"));
break;
}
$sql = "INSERT INTO `todo` ( `name` , `link` , `desp` , `uid` , `creator_uid` , `pid` , `is_done` , `follow_uids` , `timeline` , `check_time`, `due_date`, `cycle` ) VALUES ( '" . $name . "' , '" . $link . "', '" . $desp . "' , '" . $uid . "' , '" . $creator_uid . "' , '" . $pid . "' , '" . 0 . "' , '" . $follow_uids . "' , NOW() , NOW() , '" . $due_date . "' , '" . $cycle . "' )";
run_sql( $sql );
}
目前的感觉是,自己对异常没做什么处理,可能有隐患,但暂时也想不到那么多,反正是内部人员使用的系统,能用就行啦。
还有个管理员更改成员密码的功能也做好了,见下篇说明。
本文转自shenleigang 51CTO博客,原文链接:http://blog.51cto.com/lazycai/770305,如需转载请自行联系原作者