123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- /*
- |--------------------------------------------------------------------------
- | project.php 后台管理 项目管理
- |--------------------------------------------------------------------------
- */
- namespace MazeApp\Manage;
- use Maze;
- use Maze\Config\Project as Config;
- use Maze\Http\Input;
- //Maze::load('manage/auth.init');
- class Project
- {
- /**
- * get
- *
- * @return string
- */
- public function get()
- {
- $list = Config::read();
-
- //unset($list['manage']);
-
- /*
- 取消排序,放到数据表中排序
- $order = array();
- foreach($list as $v)
- {
- $order[] = $v['order'];
- }
- array_multisort($order, SORT_DESC, $list);
- */
- return $list;
- }
- /**
- * 生成key->value的形式
- *
- * @return string
- */
- public function key()
- {
- $list = Config::read();
-
- //unset($list['manage']);
- return $list;
- }
-
- /**
- * set
- *
- * @return string
- */
- public function set()
- {
- $config = $this->get();
- $key = Input::get('key');
- $index = Input::get('index', 'lang');
- $value = Input::get('value');
-
- Config::update($key, $index, $value);
- }
-
- /**
- * name
- *
- * @return string
- */
- public function name($key)
- {
- $project = Config::load($key);
-
- if($project)
- {
- return $project['lang'];
- }
- else
- {
- return $key;
- }
- }
- /**
- * config
- *
- * @return string
- */
- public function config($key)
- {
- $project = Config::load($key);
-
- if($project)
- {
- return $project;
- }
- else
- {
- return $key;
- }
- }
- /**
- * path
- *
- * @return string
- */
- public function path($key)
- {
- $project = Config::load($key);
-
- if($project)
- {
- return $project['path'];
- }
- else
- {
- return $key;
- }
- }
- public function loop()
- {
- while(true)
- {
- $this->cron();
- }
- }
-
- /**
- * cron
- *
- * @return string
- */
- public function cron()
- {
- $time = time();
- # 获取所有的计划任务
- $data = Maze::load('manage/cron-get', array('where_ldate' => $time));
- if($data)
- {
- # 比如属于weixin项目的group_list
- # weixin.mazephp.com/data.group_list
- foreach($data as $k => $v)
- {
- Maze::daemon($v['interface'], $v['project']);
-
- $param['where_id'] = $v['id'];
- $param['set_ldate'] = $time + $v['time'];
- if($v['time'] <= 0)
- {
- $param['set_state'] = 2;
- }
- Maze::load('manage/cron-update',$param);
- }
- }
- }
- }
|